From 829bbd114f1c3dc00c1da47bca0a8207c049df3f Mon Sep 17 00:00:00 2001 From: Balaji Shankaran Date: Mon, 30 Sep 2019 22:54:56 +0530 Subject: [PATCH] Added code for MAC-PHY interface, DU_APP, F1AP, SCTP and CU stub Change-Id: Ife3bbb59c1d48bba163b83b3bedc55539f4fc638 Signed-off-by: Balaji Shankaran --- README | 43 +- build/common/asn.mak | 58 + build/common/cm.mak | 90 + build/common/{pj.mak => du_app.mak} | 61 +- build/common/env.mak | 2 + build/common/f1ap.mak | 68 + build/common/kw.mak | 2 +- build/common/mt.mak | 257 + build/common/phy_stub.mak | 68 + build/common/rg.mak | 3 +- build/common/rl.mak | 80 + build/common/rlog.pl | 244 + build/config/ssi_mem | 65 + build/odu/makefile | 173 + build/scripts/makefile | 2 - src/5gnrmac/rg_cl.h | 57 + src/5gnrmac/rg_cl_cfg.c | 132 + src/5gnrmac/rg_cl_li.c | 280 + src/5gnrmac/rg_cl_phy_inf.c | 103 + src/5gnrmac/rg_cl_util.c | 66 + src/5gnrmac/rg_env.h | 4 +- src/5gnrmac/rg_lmm.c | 22 + src/5gnrmac/rg_rom.c | 10 +- src/5gnrmac/rg_tom.c | 11 +- src/5gnrmac/rg_utl.c | 7 +- src/5gnrpdcp/pj.h | 1545 -- src/5gnrpdcp/pj.x | 604 - src/5gnrpdcp/pj_cfg_dl.c | 1512 -- src/5gnrpdcp/pj_cfg_ul.c | 1585 -- src/5gnrpdcp/pj_dbm.c | 163 - src/5gnrpdcp/pj_dbm_dl.c | 1332 -- src/5gnrpdcp/pj_dbm_ul.c | 1479 -- src/5gnrpdcp/pj_dl.h | 88 - src/5gnrpdcp/pj_dl.x | 792 - src/5gnrpdcp/pj_dl_ex_ms.c | 671 - src/5gnrpdcp/pj_dl_utl.c | 2710 ---- src/5gnrpdcp/pj_dlm.c | 2831 ---- src/5gnrpdcp/pj_env.h | 97 - src/5gnrpdcp/pj_err.h | 338 - src/5gnrpdcp/pj_id.c | 135 - src/5gnrpdcp/pj_lib.c | 1801 --- src/5gnrpdcp/pj_lib.h | 143 - src/5gnrpdcp/pj_lib.x | 695 - src/5gnrpdcp/pj_lim.c | 1094 -- src/5gnrpdcp/pj_lmm.c | 2975 ---- src/5gnrpdcp/pj_ptli.c | 627 - src/5gnrpdcp/pj_ptlib.c | 2343 --- src/5gnrpdcp/pj_ptmi.c | 607 - src/5gnrpdcp/pj_ptui.c | 1189 -- src/5gnrpdcp/pj_sec.h | 248 - src/5gnrpdcp/pj_tenb_stats.c | 340 - src/5gnrpdcp/pj_tmr.c | 870 -- src/5gnrpdcp/pj_udx.c | 6225 -------- src/5gnrpdcp/pj_udx.h | 292 - src/5gnrpdcp/pj_udx.x | 1503 -- src/5gnrpdcp/pj_udx_dl.c | 1740 --- src/5gnrpdcp/pj_udx_ptdl.c | 752 - src/5gnrpdcp/pj_udx_ptul.c | 1632 -- src/5gnrpdcp/pj_udx_ul.c | 1295 -- src/5gnrpdcp/pj_uim.c | 2101 --- src/5gnrpdcp/pj_ul.h | 106 - src/5gnrpdcp/pj_ul.x | 781 - src/5gnrpdcp/pj_ul_ex_ms.c | 658 - src/5gnrpdcp/pj_ul_utl.c | 2844 ---- src/5gnrpdcp/pj_ulm.c | 3085 ---- src/5gnrpdcp/pj_utl.c | 1977 --- src/5gnrrlc/kw_tmm_ul.c | 22 +- src/cm/ckw.c | 1776 +++ src/cm/cm_bdy5.c | 514 + src/cm/cm_gen.c | 3558 +++++ src/cm/cm_gen.h | 308 + src/cm/cm_hash.c | 1763 +++ src/cm/cm_inet.c | 10869 ++++++++++++++ src/cm/cm_inet.h | 635 + src/cm/cm_inet.x | 768 + src/cm/cm_lib.c | 541 + src/cm/cm_llist.c | 423 + src/cm/cm_lte.c | 507 + src/cm/cm_math.c | 208 + src/cm/cm_mblk.c | 739 + src/cm/cm_mem.c | 6895 +++++++++ src/cm/cm_mem.h | 150 + src/cm/cm_mem.x | 514 + src/cm/cm_mem_wl.c | 7613 ++++++++++ src/cm/cm_mem_wl.x | 536 + src/cm/cm_tenb_stats.c | 693 + src/cm/cm_tkns.c | 972 ++ src/cm/cpj.h | 307 - src/cm/cpj.x | 1655 --- src/cm/crg.c | 2307 +++ src/cm/ctf.c | 8335 +++++++++++ src/cm/ctf.x | 2687 ++++ src/cm/envdep.h | 2 +- src/cm/envopt.h | 8 - src/cm/gen.x | 2 +- src/cm/kwu.c | 2002 +++ src/cm/lcl.h | 169 + src/cm/lkw.c | 3276 ++++ src/cm/lpj.h | 237 - src/cm/lpj.x | 951 -- src/cm/lrg.c | 4637 ++++++ src/cm/lrg.h | 1 + src/cm/lrg.x | 3 + src/cm/pju.h | 185 - src/cm/pju.x | 787 - src/cm/rg_cl_phy.h | 896 ++ src/cm/rgm.c | 1487 ++ src/cm/rgr.c | 12378 ++++++++++++++++ src/cm/rgu.c | 4067 +++++ src/cm/ssi.h | 5 + src/cm/tfu.c | 15627 ++++++++++++++++++++ src/cu_app/cu_app_f1ap.c | 58 + src/cu_app/cu_common.h | 58 + src/cu_app/cu_mgr_main.c | 59 + src/cu_app/cu_mgr_main.h | 50 + src/cu_app/cu_sctp.c | 629 + src/cu_app/cu_sctp.h | 57 + src/cu_app/cu_util.c | 76 + src/du_app/F1AP/f1ap_msg_hdl.c | 68 + src/du_app/du_common.h | 814 + src/du_app/du_mgr.h | 84 + src/du_app/du_mgr_ex_ms.c | 181 + src/du_app/du_mgr_main.c | 327 + src/{5gnrpdcp/pj_ptsec.h => du_app/du_mgr_main.h} | 42 +- src/du_app/du_sctp.c | 622 + src/du_app/du_sctp.h | 55 + src/du_app/du_utils.c | 442 + src/mt/mt_err.h | 103 + src/mt/mt_ss.c | 9214 ++++++++++++ src/mt/mt_ss_wl.x | 219 + src/mt/ss_drvr.c | 308 + src/mt/ss_err.h | 962 ++ src/mt/ss_gen.c | 2279 +++ src/mt/ss_mem.c | 1033 ++ src/mt/ss_msg.c | 8733 +++++++++++ src/mt/ss_pack.c | 980 ++ src/mt/ss_queue.c | 1667 +++ src/mt/ss_rbuf.c | 615 + src/mt/ss_strm.c | 1529 ++ src/mt/ss_strm.h | 95 + src/mt/ss_strm.x | 106 + src/mt/ss_task.c | 4976 +++++++ src/mt/ss_timer.c | 1054 ++ src/phy_stub/.l1_bdy1.c.swo | Bin 0 -> 12288 bytes src/phy_stub/.l1_bdy1.c.swp | Bin 0 -> 12288 bytes src/phy_stub/l1_bdy1.c | 148 + src/rlog/rl_common.c | 70 + src/rlog/rl_common.h | 12 + src/rlog/rl_interface.h | 29 + src/rlog/rl_platform.c | 126 + src/{5gnrpdcp/pj_ptsec.x => rlog/rl_platform.h} | 47 +- src/rlog/rl_postproc.cpp | 747 + src/rlog/rl_rlog.c | 1938 +++ src/rlog/rl_rlog.h | 68 + src/rlog/rl_soc.c | 168 + src/rlog/rl_soc.h | 50 + 156 files changed, 140561 insertions(+), 58065 deletions(-) create mode 100755 build/common/asn.mak create mode 100755 build/common/cm.mak rename build/common/{pj.mak => du_app.mak} (61%) mode change 100644 => 100755 create mode 100755 build/common/f1ap.mak create mode 100755 build/common/mt.mak create mode 100755 build/common/phy_stub.mak create mode 100755 build/common/rl.mak create mode 100755 build/common/rlog.pl create mode 100755 build/config/ssi_mem create mode 100644 build/odu/makefile create mode 100644 src/5gnrmac/rg_cl.h create mode 100644 src/5gnrmac/rg_cl_cfg.c create mode 100644 src/5gnrmac/rg_cl_li.c create mode 100644 src/5gnrmac/rg_cl_phy_inf.c create mode 100644 src/5gnrmac/rg_cl_util.c delete mode 100755 src/5gnrpdcp/pj.h delete mode 100755 src/5gnrpdcp/pj.x delete mode 100755 src/5gnrpdcp/pj_cfg_dl.c delete mode 100755 src/5gnrpdcp/pj_cfg_ul.c delete mode 100755 src/5gnrpdcp/pj_dbm.c delete mode 100755 src/5gnrpdcp/pj_dbm_dl.c delete mode 100755 src/5gnrpdcp/pj_dbm_ul.c delete mode 100755 src/5gnrpdcp/pj_dl.h delete mode 100755 src/5gnrpdcp/pj_dl.x delete mode 100755 src/5gnrpdcp/pj_dl_ex_ms.c delete mode 100755 src/5gnrpdcp/pj_dl_utl.c delete mode 100755 src/5gnrpdcp/pj_dlm.c delete mode 100755 src/5gnrpdcp/pj_env.h delete mode 100755 src/5gnrpdcp/pj_err.h delete mode 100755 src/5gnrpdcp/pj_id.c delete mode 100755 src/5gnrpdcp/pj_lib.c delete mode 100755 src/5gnrpdcp/pj_lib.h delete mode 100755 src/5gnrpdcp/pj_lib.x delete mode 100755 src/5gnrpdcp/pj_lim.c delete mode 100755 src/5gnrpdcp/pj_lmm.c delete mode 100755 src/5gnrpdcp/pj_ptli.c delete mode 100755 src/5gnrpdcp/pj_ptlib.c delete mode 100755 src/5gnrpdcp/pj_ptmi.c delete mode 100755 src/5gnrpdcp/pj_ptui.c delete mode 100755 src/5gnrpdcp/pj_sec.h delete mode 100755 src/5gnrpdcp/pj_tenb_stats.c delete mode 100755 src/5gnrpdcp/pj_tmr.c delete mode 100755 src/5gnrpdcp/pj_udx.c delete mode 100755 src/5gnrpdcp/pj_udx.h delete mode 100755 src/5gnrpdcp/pj_udx.x delete mode 100755 src/5gnrpdcp/pj_udx_dl.c delete mode 100755 src/5gnrpdcp/pj_udx_ptdl.c delete mode 100755 src/5gnrpdcp/pj_udx_ptul.c delete mode 100755 src/5gnrpdcp/pj_udx_ul.c delete mode 100755 src/5gnrpdcp/pj_uim.c delete mode 100755 src/5gnrpdcp/pj_ul.h delete mode 100755 src/5gnrpdcp/pj_ul.x delete mode 100755 src/5gnrpdcp/pj_ul_ex_ms.c delete mode 100755 src/5gnrpdcp/pj_ul_utl.c delete mode 100755 src/5gnrpdcp/pj_ulm.c delete mode 100755 src/5gnrpdcp/pj_utl.c create mode 100755 src/cm/ckw.c create mode 100644 src/cm/cm_bdy5.c create mode 100644 src/cm/cm_gen.c create mode 100644 src/cm/cm_gen.h create mode 100644 src/cm/cm_hash.c create mode 100644 src/cm/cm_inet.c create mode 100644 src/cm/cm_inet.h create mode 100644 src/cm/cm_inet.x create mode 100644 src/cm/cm_lib.c create mode 100644 src/cm/cm_llist.c create mode 100755 src/cm/cm_lte.c create mode 100755 src/cm/cm_math.c create mode 100644 src/cm/cm_mblk.c create mode 100755 src/cm/cm_mem.c create mode 100644 src/cm/cm_mem.h create mode 100644 src/cm/cm_mem.x create mode 100755 src/cm/cm_mem_wl.c create mode 100755 src/cm/cm_mem_wl.x create mode 100755 src/cm/cm_tenb_stats.c create mode 100644 src/cm/cm_tkns.c delete mode 100755 src/cm/cpj.h delete mode 100755 src/cm/cpj.x create mode 100755 src/cm/crg.c create mode 100755 src/cm/ctf.c create mode 100755 src/cm/ctf.x create mode 100755 src/cm/kwu.c create mode 100644 src/cm/lcl.h create mode 100755 src/cm/lkw.c delete mode 100755 src/cm/lpj.h delete mode 100755 src/cm/lpj.x create mode 100755 src/cm/lrg.c delete mode 100755 src/cm/pju.h delete mode 100755 src/cm/pju.x create mode 100644 src/cm/rg_cl_phy.h create mode 100755 src/cm/rgm.c create mode 100755 src/cm/rgr.c create mode 100755 src/cm/rgu.c create mode 100755 src/cm/tfu.c create mode 100644 src/cu_app/cu_app_f1ap.c create mode 100644 src/cu_app/cu_common.h create mode 100644 src/cu_app/cu_mgr_main.c create mode 100644 src/cu_app/cu_mgr_main.h create mode 100644 src/cu_app/cu_sctp.c create mode 100644 src/cu_app/cu_sctp.h create mode 100644 src/cu_app/cu_util.c create mode 100644 src/du_app/F1AP/f1ap_msg_hdl.c create mode 100644 src/du_app/du_common.h create mode 100644 src/du_app/du_mgr.h create mode 100644 src/du_app/du_mgr_ex_ms.c create mode 100644 src/du_app/du_mgr_main.c rename src/{5gnrpdcp/pj_ptsec.h => du_app/du_mgr_main.h} (78%) mode change 100755 => 100644 create mode 100644 src/du_app/du_sctp.c create mode 100644 src/du_app/du_sctp.h create mode 100644 src/du_app/du_utils.c create mode 100755 src/mt/mt_err.h create mode 100644 src/mt/mt_ss.c create mode 100755 src/mt/mt_ss_wl.x create mode 100644 src/mt/ss_drvr.c create mode 100755 src/mt/ss_err.h create mode 100644 src/mt/ss_gen.c create mode 100644 src/mt/ss_mem.c create mode 100644 src/mt/ss_msg.c create mode 100644 src/mt/ss_pack.c create mode 100644 src/mt/ss_queue.c create mode 100755 src/mt/ss_rbuf.c create mode 100644 src/mt/ss_strm.c create mode 100755 src/mt/ss_strm.h create mode 100755 src/mt/ss_strm.x create mode 100644 src/mt/ss_task.c create mode 100644 src/mt/ss_timer.c create mode 100644 src/phy_stub/.l1_bdy1.c.swo create mode 100644 src/phy_stub/.l1_bdy1.c.swp create mode 100644 src/phy_stub/l1_bdy1.c create mode 100644 src/rlog/rl_common.c create mode 100644 src/rlog/rl_platform.c rename src/{5gnrpdcp/pj_ptsec.x => rlog/rl_platform.h} (70%) create mode 100644 src/rlog/rl_postproc.cpp create mode 100644 src/rlog/rl_rlog.c create mode 100644 src/rlog/rl_soc.c create mode 100755 src/rlog/rl_soc.h diff --git a/README b/README index a681258e2..71fbd36e8 100644 --- a/README +++ b/README @@ -1,39 +1,30 @@ Directory Structure : -1. 5gnr_opensource/lte_enb/build/ : contains files required to compile the code +1. 5gnr_opensource/build/ : contains files required to compile the code a. common : contains individual module's makefile - b. scripts : contains scripts and final makefile used to compile all layers using makefiles in common directory + b. config : contains SSI memory configuration + c. odu : contains main makefile to generate an executable binary + b. scripts : contains scripts required for compilation -2. 5gnr_opensource/lte_enb/src/ : contains layer specific source code - a. 5gnrpdcp : PDCP source code +2. 5gnr_opensource/src/ : contains layer specific source code + a. 5gnrmac : MAC source code b. 5gnrrlc : RLC source code - c. 5gnrmac : MAC source code - d. cm : common, environment and interface files - e. mt : wrapper functions over OS - f. rlog : logging module + c. cm : common, environment and interface files + d. cu_app : Stub code for CU + e. du_app : DU application and F1 code + f. mt : wrapper functions over OS + g. phy_stub : Stub code for Physical layer + h. rlog : logging module Pre-requisite for Compilation : 1. Linux 32-bit/64-bit machine 2. GCC version 4.6.3 and above - +3. Copy ASN code generated for F1 messages into 5gnr_opensource/src/du_app/F1AP/asn/ How to Compile : -1. cd 5gnr_opensource/lte_enb/build/scripts/ -2. Run script to clean and compile: ./build_5gnr.sh -3. To clean only, run command : make clean_all - -Compilation Error : -Any compilation error will be reported in file : 5gnr_opensource/lte_enb/build/scripts/err - -Generated Libraries : -Path : 5gnr_opensource/lte_enb/libs/ -1. librg.a : MAC library -2. libkw.a : RLC library -3. libpj.a : PDCP library +1. cd 5gnr_opensource/build/odu +2. To clean and compile: make clean_all odu MACHINE=BIT64 TEXT_LOG=YES +3. To clean only, run command : make clean_all MACHINE=BIT64 TEXT_LOG=YES -Generated Object Files : -Path : 5gnr_opensource/lte_enb/build/scripts/obj/ -1. rg* : Object files for MAC. The prefix 'rg' refers to MAC files and functions. -2. kw* : Object files for RLC. The prefix 'kw' refers to RLC files and functions. -3. pj* : Object files for PDCP. The prefix 'pj' refers to PDCP files and functions. +Executable binary generated : 5gnr_opensource/build/odu/obj/odu diff --git a/build/common/asn.mak b/build/common/asn.mak new file mode 100755 index 000000000..7334ab6d9 --- /dev/null +++ b/build/common/asn.mak @@ -0,0 +1,58 @@ +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ + +# This is makefile for ASN + +include ../common/rsys_fancy.mak +include ../common/env.mak +COLOR=$(COLOR_RED) + +SRC_DIR=$(ROOT_DIR)/src/du_app/F1AP/asn +C_SRCS=$(wildcard $(SRC_DIR)/*.c) +C_OBJS=$(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(C_SRCS)) +LOG_FILES=$(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.i,$(C_SRCS)) +BAK_FILES=$(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.i.bak,$(C_SRCS)) +DB_FILES =$(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.i.db,$(C_SRCS)) + + +lib: $(LIB_DIR)/libasn.a +include $(COM_BUILD_DIR)/compile.mak + + + +#-------------------------------------------------------------# +#Linker macros +#-------------------------------------------------------------# +ifeq ($(BIN_LOG),YES) +$(LIB_DIR)/libasn.a:$(C_OBJS) $(C_WO_PED_OBJS) + @echo -e "Creating log DB $(COLOR)$(LOG_DIR)/asnLog.db $(REVERT_COLOR)" + $(Q)cat $(DB_FILES) > $(LOG_DIR)/asnLog.db + @echo -e "Creating Archive $(COLOR) $@ $(REVERT_COLOR)" + $(Q)ar -cr $(LIB_DIR)/libasn.a $(C_OBJS) $(C_WO_PED_OBJS) +else +$(LIB_DIR)/libasn.a:$(C_OBJS) $(C_WO_PED_OBJS) + @echo -e "Creating Archive $(COLOR) $@ $(REVERT_COLOR)" + $(Q)ar -cr $(LIB_DIR)/libasn.a $(C_OBJS) $(C_WO_PED_OBJS) +endif + +#-------------------------------------------------------------# +#Clean macros +#-------------------------------------------------------------# +clean: + @echo -e "$(COLOR_RED)Cleaning ASN$(REVERT_COLOR)" + @echo $(SRC_DIR) $(CM_DIR) + $(Q)\rm -f $(LIB_DIR)/libasn.a $(C_OBJS) $(C_WO_PED_OBJS) $(LOG_FILES) $(BAK_FILES) + diff --git a/build/common/cm.mak b/build/common/cm.mak new file mode 100755 index 000000000..18e66068f --- /dev/null +++ b/build/common/cm.mak @@ -0,0 +1,90 @@ +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ + +#-------------------------------------------------------------# +#Makefile for product cm - script generated. +#Only the $(CCcmFLAGS) may be modified. +#-------------------------------------------------------------# +include ../common/rsys_fancy.mak +include ../common/env.mak +COLOR=$(COLOR_GREEN) +SRC_DIR=$(ROOT_DIR)/src/cm + +EG_DIR=$(ROOT_DIR)/src/egtpu +SZ_DIR=$(ROOT_DIR)/src/s1ap +CZ_DIR=$(ROOT_DIR)/src/x2ap + +# TODO - The dependency between layers and CM files should be removed # +I_OPTS+=-I$(EG_DIR) -I$(SZ_DIR) -I$(CZ_DIR) + +#-------------------------------------------------------------# +#User macros (to be modified) +#-------------------------------------------------------------# +#CCrmFLAGS=-DLRM_LWLC -DRMU_LWLC -URMU_NPLC -DRGM_LWLC -DLWLCSMRMMILRM -DLCSMRMMILRM -DSM -DRM_INTF +#CCnlFlags=-DLWLCSMSONILNL -DNLU_LWLC -DLCSMSONILNL -DNLU_TC -DTCSMSONILNL -DNL +#CCcmFLAGS=-DSS_MT_TMR -DSS_FLOAT -DRGR_V1 -DLSZV1 -DVE_SB_SCTP $(CCrmFLAGS) +#CCsmFLAGS=-DHI -DSB -DEG -DWR -DKW -DKW_PDCP -DPJ -DSZ -DYS -DRG -DNH -UVE_SM_LOG_TO_FILE -DRGR_SI_SCH -DTA_NEW -DSI_NEW -DCZ $(CCrmFLAGS) $(CCnlFlags) + +#-------------------------------------------------------------# +# Define all the layers that are part of this binary so that # +# their coupling requirements get defined from envopt.h. # +#-------------------------------------------------------------# +# TODO -DRM has conflict with some cm_atm files. It is temp- # +# orarily removed from this list. # +MOD_FLAGS=-DNH -DWR -DNX -DSZ -DCZ -DSB -DHI -DEG -DSM -DNL -DSM -DRG -DKW -DYS +#This module does not support binary logging so disable it +TEXT_LOG=YES + +#-------------------------------------------------------------# +# Source file list. This needs to be explicitly built as CM +# directory contains files for both CPUL and CPUH. +#-------------------------------------------------------------# +C_SRCS=$(wildcard $(SRC_DIR)/*.c) +C_SRCS:=$(filter-out %cm_ss.c, $(C_SRCS)) +C_SRCS:=$(filter-out %egt_util.c, $(C_SRCS)) +C_SRCS:=$(filter-out %lve.c, $(C_SRCS)) +C_SRCS:=$(filter-out %cm_atm.c, $(C_SRCS)) +C_SRCS:=$(filter-out %_ptsp.c, $(C_SRCS)) +C_SRCS:=$(filter-out %_se_tst.c, $(C_SRCS)) +ifeq ($(PLTFRM),XEON) +C_SRCS:=$(filter-out %mem_wl.c, $(C_SRCS)) +else +C_SRCS:=$(filter-out %mem.c, $(C_SRCS)) +endif + +C_OBJS_WO_LOG=$(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(C_SRCS)) +HDR_FILES+= $(wildcard $(SRC_DIR)/*.[hx]) + + +lib: $(LIB_DIR)/libcm.a + +include $(COM_BUILD_DIR)/compile.mak + +#-------------------------------------------------------------# +#Linker macros +#-------------------------------------------------------------# +$(LIB_DIR)/libcm.a:$(C_OBJS_WO_LOG) + @echo -e "Creating Archive $(COLOR) $@ $(REVERT_COLOR)" + $(Q)ar -cr $(LIB_DIR)/libcm.a $(C_OBJS) +#-------------------------------------------------------------# +#Clean macros +#-------------------------------------------------------------# +clean: + @echo -e "$(COLOR_RED)Cleaning CPUH CM$(REVERT_COLOR)" + @echo -e "$(COLOR_RED) $(REVERT_COLOR)" + $(Q)\rm -f $(LIB_DIR)/libcm.a $(C_OBJS_WO_LOG) + + diff --git a/build/common/pj.mak b/build/common/du_app.mak old mode 100644 new mode 100755 similarity index 61% rename from build/common/pj.mak rename to build/common/du_app.mak index 7b8767c9e..4ae71fc01 --- a/build/common/pj.mak +++ b/build/common/du_app.mak @@ -14,60 +14,55 @@ # limitations under the License. # ################################################################################ -#-------------------------------------------------------------# -#Makefile for product ib - script generated. -#Only the $(CCib) may be modified. -#-------------------------------------------------------------# +# This is makefile for DU APP include ../common/rsys_fancy.mak - include ../common/env.mak +COLOR=$(COLOR_RED) -SEC_ENG=SWLIB - -SRC_DIR=$(ROOT_DIR)/src/5gnrpdcp - -#Prepare source file list +SRC_DIR=$(ROOT_DIR)/src/du_app/ C_SRCS=$(wildcard $(SRC_DIR)/*.c) - -#prepare the list of object files and RLOG related files C_OBJS=$(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(C_SRCS)) +LOG_FILES=$(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.i,$(C_SRCS)) +BAK_FILES=$(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.i.bak,$(C_SRCS)) +DB_FILES =$(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.i.db,$(C_SRCS)) -#prepare the header file list for this layer # prepare the list of common header files HDR_FILES+=$(wildcard $(CM_DIR)/env*.[hx]) HDR_FILES+=$(wildcard $(CM_DIR)/gen*.[hx]) HDR_FILES+=$(wildcard $(CM_DIR)/ssi*.[hx]) HDR_FILES+=$(wildcard $(CM_DIR)/cm*.[hx]) -HDR_FILES+=$(wildcard $(CM_DIR)/lpj.[hx]) -HDR_FILES+=$(wildcard $(CM_DIR)/kwu.[hx]) -HDR_FILES+=$(wildcard $(CM_DIR)/pju.[hx]) -HDR_FILES+=$(wildcard $(CM_DIR)/cpj.[hx]) +HDR_FILES+=$(wildcard $(CM_DIR)/lkw*.[hx]) +HDR_FILES+=$(wildcard $(CM_DIR)/lrg*.[hx]) -# Add the product specific header files -HDR_FILES+= $(wildcard $(SRC_DIR)/*.[hx]) -#-------------------------------------------------------------# -#User macros (to be modified) -#-------------------------------------------------------------# -MOD_FLAGS= -UKW_PDCP -DKW -DPJ -DPTPJLIB +lib: $(LIB_DIR)/libduapp.a +include $(COM_BUILD_DIR)/compile.mak +I_OPTS+=-I$(ROOT_DIR)/src/mt +I_OPTS+=-I$(SRC_DIR)/F1AP -lib:$(LIB_DIR)/libpj.a -include $(COM_BUILD_DIR)/compile.mak #-------------------------------------------------------------# -#Linker macros +#Linker macros #-------------------------------------------------------------# -$(LIB_DIR)/libpj.a:$(C_OBJS) $(C_WO_WERR_OBJS) - @echo -e "Creating Archive $(COLOR) $@ $(REVERT_COLOR)" - $(Q)ar -cr $(LIB_DIR)/libpj.a $(C_OBJS) $(C_WO_WERR_OBJS) +ifeq ($(BIN_LOG),YES) +$(LIB_DIR)/libduapp.a:$(C_OBJS) $(C_WO_PED_OBJS) + @echo -e "Creating log DB $(COLOR)$(LOG_DIR)/duLog.db $(REVERT_COLOR)" + $(Q)cat $(DB_FILES) > $(LOG_DIR)/duLog.db + @echo -e "Creating Archive $(COLOR) $@ $(REVERT_COLOR)" + $(Q)ar -cr $(LIB_DIR)/libduapp.a $(C_OBJS) $(C_WO_PED_OBJS) +else +$(LIB_DIR)/libduapp.a:$(C_OBJS) $(C_WO_PED_OBJS) + @echo -e "Creating Archive $(COLOR) $@ $(REVERT_COLOR)" + $(Q)ar -cr $(LIB_DIR)/libduapp.a $(C_OBJS) $(C_WO_PED_OBJS) +endif #-------------------------------------------------------------# -#Clean macros +#Clean macros #-------------------------------------------------------------# clean: - @echo -e "$(COLOR_RED)Cleaning PDCP$(REVERT_COLOR)" - $(Q)\rm -f $(LIB_DIR)/libpj.a $(C_OBJS) $(C_WO_WERR_OBJS) - + @echo -e "$(COLOR_RED)Cleaning DU APP$(REVERT_COLOR)" + @echo $(SRC_DIR) $(CM_DIR) + $(Q)\rm -f $(LIB_DIR)/libduapp.a $(C_OBJS) $(C_WO_PED_OBJS) $(LOG_FILES) $(BAK_FILES) diff --git a/build/common/env.mak b/build/common/env.mak index 2af0a84db..8e6207acc 100644 --- a/build/common/env.mak +++ b/build/common/env.mak @@ -53,8 +53,10 @@ export S BUILD_DIR=$(PWD) ROOT_DIR_SCRIPTS =$(patsubst %/build/scripts,%,$(BUILD_DIR)) COM_BUILD_DIR=$(BUILD_DIR)/../common +ROOT_DIR=$(patsubst %/build/odu,%,$(BUILD_DIR)) export BUILD_DIR export COM_BUILD_DIR +export ROOT_DIR # Path where the .o files or the directories with .o files are located OBJ_ROOT =$(BUILD_DIR)/obj diff --git a/build/common/f1ap.mak b/build/common/f1ap.mak new file mode 100755 index 000000000..112f01d4a --- /dev/null +++ b/build/common/f1ap.mak @@ -0,0 +1,68 @@ +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ + +# This is makefile for DU APP + +include ../common/rsys_fancy.mak +include ../common/env.mak +COLOR=$(COLOR_RED) + +SRC_DIR=$(ROOT_DIR)/src/du_app/F1AP +C_SRCS=$(wildcard $(SRC_DIR)/*.c) +C_OBJS=$(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(C_SRCS)) +LOG_FILES=$(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.i,$(C_SRCS)) +BAK_FILES=$(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.i.bak,$(C_SRCS)) +DB_FILES =$(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.i.db,$(C_SRCS)) + +# prepare the list of common header files +HDR_FILES+=$(wildcard $(CM_DIR)/env*.[hx]) +HDR_FILES+=$(wildcard $(CM_DIR)/gen*.[hx]) +HDR_FILES+=$(wildcard $(CM_DIR)/ssi*.[hx]) +HDR_FILES+=$(wildcard $(CM_DIR)/cm*.[hx]) +HDR_FILES+=$(wildcard $(CM_DIR)/lkw*.[hx]) +HDR_FILES+=$(wildcard $(CM_DIR)/lrg*.[hx]) + + +lib: $(LIB_DIR)/libf1ap.a +include $(COM_BUILD_DIR)/compile.mak + +I_OPTS+=-I$(ROOT_DIR)/src/mt +I_OPTS+=-I$(ROOT_DIR)/src/du_app + + +#-------------------------------------------------------------# +#Linker macros +#-------------------------------------------------------------# +ifeq ($(BIN_LOG),YES) +$(LIB_DIR)/libf1ap.a:$(C_OBJS) $(C_WO_PED_OBJS) + @echo -e "Creating log DB $(COLOR)$(LOG_DIR)/f1apLog.db $(REVERT_COLOR)" + $(Q)cat $(DB_FILES) > $(LOG_DIR)/f1apLog.db + @echo -e "Creating Archive $(COLOR) $@ $(REVERT_COLOR)" + $(Q)ar -cr $(LIB_DIR)/libf1ap.a $(C_OBJS) $(C_WO_PED_OBJS) +else +$(LIB_DIR)/libf1ap.a:$(C_OBJS) $(C_WO_PED_OBJS) + @echo -e "Creating Archive $(COLOR) $@ $(REVERT_COLOR)" + $(Q)ar -cr $(LIB_DIR)/libf1ap.a $(C_OBJS) $(C_WO_PED_OBJS) +endif + +#-------------------------------------------------------------# +#Clean macros +#-------------------------------------------------------------# +clean: + @echo -e "$(COLOR_RED)Cleaning F1AP$(REVERT_COLOR)" + @echo $(SRC_DIR) $(CM_DIR) + $(Q)\rm -f $(LIB_DIR)/libf1ap.a $(C_OBJS) $(C_WO_PED_OBJS) $(LOG_FILES) $(BAK_FILES) + diff --git a/build/common/kw.mak b/build/common/kw.mak index 23207337a..cb44684ce 100644 --- a/build/common/kw.mak +++ b/build/common/kw.mak @@ -32,7 +32,7 @@ C_OBJS=$(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(C_SRCS)) #-------------------------------------------------------------# #User macros (to be modified) #-------------------------------------------------------------# -MOD_FLAGS=-DRG -DYS -DKW -DPX -DLCRGU -DLCKWULUDX -DLCUDX -DLWLCKWULUDX +MOD_FLAGS=-DRG -DYS -DKW -DLCRGU -DLCKWULUDX -DLCUDX -DLWLCKWULUDX -UPJ #-------------------------------------------------------------# #Linker macros diff --git a/build/common/mt.mak b/build/common/mt.mak new file mode 100755 index 000000000..f22a83e39 --- /dev/null +++ b/build/common/mt.mak @@ -0,0 +1,257 @@ +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +# +##-------------------------------------------------------------# +#Makefile for product mt - script generated. +#Only the $(CCmtFLAGS) may be modified. +#-------------------------------------------------------------# +include ../common/rsys_fancy.mak +include ../common/env.mak + +#-------------------------------------------------------------# +#User macros (to be modified) +#-------------------------------------------------------------# + +CCmtFLAGS=-DSS_MT_TMR -USS_LOGGER_SUPPORT -DEGTP_U#<---Insert mt specific defines here + +#-------------------------------------------------------------# +#File/Obj macros +#-------------------------------------------------------------# +SRC_DIR=$(ROOT_DIR)/src/mt + +C_SRCS=$(wildcard $(SRC_DIR)/*.c) +C_SRCS:=$(filter-out %ss_acc.c,$(C_SRCS)) +C_SRCS:=$(filter-out %mt_tst.c,$(C_SRCS)) +C_SRCS:=$(filter-out %sol.c, $(C_SRCS)) +C_SRCS:=$(filter-out %diag.c, $(C_SRCS)) +C_SRCS:=$(filter-out %mtsp.c, $(C_SRCS)) +C_SRCS:=$(filter-out %tskent.c, $(C_SRCS)) + +ifeq ($(PLTFRM),PAL) +C_SRCS:=$(filter-out %4gmx.c, $(C_SRCS)) +endif +ifneq ($(BOARD), T33H) +C_SRCS:=$(filter-out %t33.c, $(C_SRCS)) +endif + +C_OBJS_WO_LOG=$(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(C_SRCS)) +I_OPTS+=-isystem $(BSPPATH)/usr/include/brcm +I_OPTS+=-I$(SRC_DIR)/security + + +#mtSRCS= \ +# $(IN_DIR)/mt_id.c\ +# $(IN_DIR)/mt_ss.c\ +# $(IN_DIR)/ss_gen.c\ +# $(IN_DIR)/ss_id.c\ +# $(IN_DIR)/ss_mem.c\ +# $(IN_DIR)/ss_msg.c\ +# $(IN_DIR)/ss_pack.c\ +# $(IN_DIR)/ss_queue.c\ +# $(IN_DIR)/ss_strm.c\ +# $(IN_DIR)/ss_task.c\ +# $(IN_DIR)/ss_drvr.c\ +# $(IN_DIR)/ss_timer.c\ +# $(IN_DIR)/ss_diag.c +#ifeq (${BLDENV},lnx_e2e_ms) +# mtSRCS+=$(IN_DIR)/mt_4gmx.c +#else +#ifeq (${BLDENV},lnx_ms_withoutdiag) +# mtSRCS+=$(IN_DIR)/mt_4gmx.c +#endif +#endif +#ifeq ($(BLDENV),lnx_e2e_bc) +# mtSRCS+=$(IN_DIR)/bc_cpu_overload.c +# mtSRCS+=$(IN_DIR)/bc_icpu_snd.c +# mtSRCS+=$(IN_DIR)/bc_icpu_rcv.c +# mtSRCS+=$(IN_DIR)/bc_cpu_init.c +# mtSRCS+=$(IN_DIR)/rb_log.c +# mtSRCS+=$(IN_DIR)/ss_rbuf.c +# mtSRCS+=$(IN_DIR)/bc_free_mgr.c +# mtSRCS+=$(IN_DIR)/bc_batch_mgr.c +#else +# mtSRCS+=$(IN_DIR)/bc_cpu_overload.c +# mtSRCS+=$(IN_DIR)/bc_icpu_snd.c +# mtSRCS+=$(IN_DIR)/bc_icpu_rcv.c +# mtSRCS+=$(IN_DIR)/bc_cpu_init.c +# mtSRCS+=$(IN_DIR)/rb_log.c +# mtSRCS+=$(IN_DIR)/ss_rbuf.c +# mtSRCS+=$(IN_DIR)/bc_free_mgr.c +# mtSRCS+=$(IN_DIR)/bc_batch_mgr.c +#endif +# +#mtOBJS= \ +# $(OUT_DIR)/mt_id.$(OBJ)\ +# $(OUT_DIR)/mt_ss.$(OBJ)\ +# $(OUT_DIR)/ss_gen.$(OBJ)\ +# $(OUT_DIR)/ss_id.$(OBJ)\ +# $(OUT_DIR)/ss_mem.$(OBJ)\ +# $(OUT_DIR)/ss_msg.$(OBJ)\ +# $(OUT_DIR)/ss_pack.$(OBJ)\ +# $(OUT_DIR)/ss_queue.$(OBJ)\ +# $(OUT_DIR)/ss_strm.$(OBJ)\ +# $(OUT_DIR)/ss_task.$(OBJ)\ +# $(OUT_DIR)/ss_drvr.$(OBJ)\ +# $(OUT_DIR)/ss_timer.$(OBJ)\ +# $(OUT_DIR)/ss_diag.$(OBJ) +#ifeq (${BLDENV},lnx_e2e_ms) +# mtOBJS+=$(OUT_DIR)/mt_4gmx.$(OBJ) +#else +#ifeq (${BLDENV},lnx_ms_withoutdiag) +# mtOBJS+=$(OUT_DIR)/mt_4gmx.$(OBJ) +#endif +#endif +#ifeq ($(BLDENV),lnx_e2e_bc) +# mtOBJS+=$(OUT_DIR)/bc_cpu_overload.$(OBJ) +# mtOBJS+=$(OUT_DIR)/bc_icpu_snd.$(OBJ) +# mtOBJS+=$(OUT_DIR)/bc_icpu_rcv.$(OBJ) +# mtOBJS+=$(OUT_DIR)/bc_cpu_init.$(OBJ) +# mtOBJS+=$(OUT_DIR)/rb_log.$(OBJ) +# mtOBJS+=$(OUT_DIR)/ss_rbuf.$(OBJ) +# mtOBJS+=$(OUT_DIR)/bc_free_mgr.$(OBJ) +# mtOBJS+=$(OUT_DIR)/bc_batch_mgr.$(OBJ) +#else +# mtOBJS+=$(OUT_DIR)/bc_cpu_overload.$(OBJ) +# mtOBJS+=$(OUT_DIR)/bc_icpu_snd.$(OBJ) +# mtOBJS+=$(OUT_DIR)/bc_icpu_rcv.$(OBJ) +# mtOBJS+=$(OUT_DIR)/bc_cpu_init.$(OBJ) +# mtOBJS+=$(OUT_DIR)/rb_log.$(OBJ) +# mtOBJS+=$(OUT_DIR)/ss_rbuf.$(OBJ) +# mtOBJS+=$(OUT_DIR)/bc_free_mgr.$(OBJ) +# mtOBJS+=$(OUT_DIR)/bc_batch_mgr.$(OBJ) +#endif + +HDR_FILES+=$(wildcard $(CM_DIR)/env*.[hx]) +HDR_FILES+=$(wildcard $(CM_DIR)/gen*.[hx]) +HDR_FILES+=$(wildcard $(CM_DIR)/ssi*.[hx]) +HDR_FILES+=$(wildcard $(CM_DIR)/cm*.[hx]) +HDR_FILES+=$(wildcard $(SRC_DIR)/*.[hx]) +HDR_FILES+=$(wildcard $(SRC_DIR)/*.[hx]) + +#ifeq ($(BLDENV),lnx_e2e_bc) +# MT_INC+=$(IN_DIR)/bc_icpu.h +# MT_INC+=$(IN_DIR)/bc_cpu_init.h +# MT_INC+=$(IN_DIR)/rb_log.x +# MT_INC+=$(IN_DIR)/rb_log.h +# MT_INC+=$(IN_DIR)/bc_cpu_overload.h +#else +# MT_INC+=$(IN_DIR)/bc_icpu.h +# MT_INC+=$(IN_DIR)/bc_cpu_init.h +# MT_INC+=$(IN_DIR)/rb_log.x +# MT_INC+=$(IN_DIR)/rb_log.h +# MT_INC+=$(IN_DIR)/bc_cpu_overload.h +#endif + +#ALL_INC=$(MT_INC) $(CM_INC) + +#-------------------------------------------------------------# +#Compiler macros +#-------------------------------------------------------------# +#Compiler macros +#-------------------------------------------------------------# +#$(OUT_DIR)/mt_id.$(OBJ): $(IN_DIR)/mt_id.c $(ALL_INC) +# $(CC) -c -o $(OUT_DIR)/mt_id.o $(COPTS) $(IOPTS) $(POPTS) $(CCmtFLAGS) $(IN_DIR)/mt_id.c +#$(OUT_DIR)/mt_ss.$(OBJ): $(IN_DIR)/mt_ss.c $(ALL_INC) +# $(CC) -c -o $(OUT_DIR)/mt_ss.o $(COPTS) $(IOPTS) $(POPTS) $(CCmtFLAGS) $(IN_DIR)/mt_ss.c +#ifeq (${BLDENV},lnx_e2e_ms) +#$(OUT_DIR)/mt_4gmx.$(OBJ): $(IN_DIR)/mt_4gmx.c $(ALL_INC) +# $(CC) -c -o $(OUT_DIR)/mt_4gmx.o $(COPTS) $(IOPTS) $(POPTS) $(CCmtFLAGS) $(IN_DIR)/mt_4gmx.c +#else +#ifeq (${BLDENV},lnx_ms_withoutdiag) +#$(OUT_DIR)/mt_4gmx.$(OBJ): $(IN_DIR)/mt_4gmx.c $(ALL_INC) +# $(CC) -c -o $(OUT_DIR)/mt_4gmx.o $(COPTS) $(IOPTS) $(POPTS) $(CCmtFLAGS) $(IN_DIR)/mt_4gmx.c +#endif +#endif +# +#ifeq ($(BLDENV),lnx_e2e_bc) +#$(OUT_DIR)/bc_cpu_overload.$(OBJ): $(IN_DIR)/bc_cpu_overload.c $(ALL_INC) +# $(CC) -c -o $(OUT_DIR)/bc_cpu_overload.o $(COPTS) $(IOPTS) $(POPTS) $(CCmtFLAGS) $(IN_DIR)/bc_cpu_overload.c +#$(OUT_DIR)/bc_icpu_snd.$(OBJ): $(IN_DIR)/bc_icpu_snd.c $(ALL_INC) +# $(CC) -c -o $(OUT_DIR)/bc_icpu_snd.o $(COPTS) $(IOPTS) $(POPTS) $(CCmtFLAGS) $(IN_DIR)/bc_icpu_snd.c +#$(OUT_DIR)/bc_icpu_rcv.$(OBJ): $(IN_DIR)/bc_icpu_rcv.c $(ALL_INC) +# $(CC) -c -o $(OUT_DIR)/bc_icpu_rcv.o $(COPTS) $(IOPTS) $(POPTS) $(CCmtFLAGS) $(IN_DIR)/bc_icpu_rcv.c +#$(OUT_DIR)/bc_cpu_init.$(OBJ): $(IN_DIR)/bc_cpu_init.c $(ALL_INC) +# $(CC) -c -o $(OUT_DIR)/bc_cpu_init.o $(COPTS) $(IOPTS) $(POPTS) $(CCmtFLAGS) $(IN_DIR)/bc_cpu_init.c +#$(OUT_DIR)/rb_log.$(OBJ): $(IN_DIR)/rb_log.c $(ALL_INC) +# $(CC) -c -o $(OUT_DIR)/rb_log.o $(COPTS) $(IOPTS) $(POPTS) $(CCmtFLAGS) $(IN_DIR)/rb_log.c +#$(OUT_DIR)/ss_rbuf.$(OBJ): $(IN_DIR)/ss_rbuf.c $(ALL_INC) +# $(CC) -c -o $(OUT_DIR)/ss_rbuf.o $(COPTS) $(IOPTS) $(POPTS) $(CCmtFLAGS) $(IN_DIR)/ss_rbuf.c +#$(OUT_DIR)/bc_free_mgr.$(OBJ): $(IN_DIR)/bc_free_mgr.c $(ALL_INC) +# $(CC) -c -o $(OUT_DIR)/bc_free_mgr.o $(COPTS) $(IOPTS) $(POPTS) $(CCmtFLAGS) $(IN_DIR)/bc_free_mgr.c +#$(OUT_DIR)/bc_batch_mgr.$(OBJ): $(IN_DIR)/bc_batch_mgr.c $(ALL_INC) +# $(CC) -c -o $(OUT_DIR)/bc_batch_mgr.o $(COPTS) $(IOPTS) $(POPTS) $(CCmtFLAGS) $(IN_DIR)/bc_batch_mgr.c +#else +#$(OUT_DIR)/bc_cpu_overload.$(OBJ): $(IN_DIR)/bc_cpu_overload.c $(ALL_INC) +# $(CC) -c -o $(OUT_DIR)/bc_cpu_overload.o $(COPTS) $(IOPTS) $(POPTS) $(CCmtFLAGS) $(IN_DIR)/bc_cpu_overload.c +#$(OUT_DIR)/bc_icpu_snd.$(OBJ): $(IN_DIR)/bc_icpu_snd.c $(ALL_INC) +# $(CC) -c -o $(OUT_DIR)/bc_icpu_snd.o $(COPTS) $(IOPTS) $(POPTS) $(CCmtFLAGS) $(IN_DIR)/bc_icpu_snd.c +#$(OUT_DIR)/bc_icpu_rcv.$(OBJ): $(IN_DIR)/bc_icpu_rcv.c $(ALL_INC) +# $(CC) -c -o $(OUT_DIR)/bc_icpu_rcv.o $(COPTS) $(IOPTS) $(POPTS) $(CCmtFLAGS) $(IN_DIR)/bc_icpu_rcv.c +#$(OUT_DIR)/bc_cpu_init.$(OBJ): $(IN_DIR)/bc_cpu_init.c $(ALL_INC) +# $(CC) -c -o $(OUT_DIR)/bc_cpu_init.o $(COPTS) $(IOPTS) $(POPTS) $(CCmtFLAGS) $(IN_DIR)/bc_cpu_init.c +#$(OUT_DIR)/rb_log.$(OBJ): $(IN_DIR)/rb_log.c $(ALL_INC) +# $(CC) -c -o $(OUT_DIR)/rb_log.o $(COPTS) $(IOPTS) $(POPTS) $(CCmtFLAGS) $(IN_DIR)/rb_log.c +#$(OUT_DIR)/ss_rbuf.$(OBJ): $(IN_DIR)/ss_rbuf.c $(ALL_INC) +# $(CC) -c -o $(OUT_DIR)/ss_rbuf.o $(COPTS) $(IOPTS) $(POPTS) $(CCmtFLAGS) $(IN_DIR)/ss_rbuf.c +#$(OUT_DIR)/bc_free_mgr.$(OBJ): $(IN_DIR)/bc_free_mgr.c $(ALL_INC) +# $(CC) -c -o $(OUT_DIR)/bc_free_mgr.o $(COPTS) $(IOPTS) $(POPTS) $(CCmtFLAGS) $(IN_DIR)/bc_free_mgr.c +#$(OUT_DIR)/bc_batch_mgr.$(OBJ): $(IN_DIR)/bc_batch_mgr.c $(ALL_INC) +# $(CC) -c -o $(OUT_DIR)/bc_batch_mgr.o $(COPTS) $(IOPTS) $(POPTS) $(CCmtFLAGS) $(IN_DIR)/bc_batch_mgr.c +#endif +#$(OUT_DIR)/ss_drvr.$(OBJ): $(IN_DIR)/ss_drvr.c $(ALL_INC) +# $(CC) -c -o $(OUT_DIR)/ss_drvr.o $(COPTS) $(IOPTS) $(POPTS) $(CCmtFLAGS) $(IN_DIR)/ss_drvr.c +#$(OUT_DIR)/ss_gen.$(OBJ): $(IN_DIR)/ss_gen.c $(ALL_INC) +# $(CC) -c -o $(OUT_DIR)/ss_gen.o $(COPTS) $(IOPTS) $(POPTS) $(CCmtFLAGS) $(IN_DIR)/ss_gen.c +#$(OUT_DIR)/ss_id.$(OBJ): $(IN_DIR)/ss_id.c $(ALL_INC) +# $(CC) -c -o $(OUT_DIR)/ss_id.o $(COPTS) $(IOPTS) $(POPTS) $(CCmtFLAGS) $(IN_DIR)/ss_id.c +#$(OUT_DIR)/ss_mem.$(OBJ): $(IN_DIR)/ss_mem.c $(ALL_INC) +# $(CC) -c -o $(OUT_DIR)/ss_mem.o $(COPTS) $(IOPTS) $(POPTS) $(CCmtFLAGS) $(IN_DIR)/ss_mem.c +#$(OUT_DIR)/ss_msg.$(OBJ): $(IN_DIR)/ss_msg.c $(ALL_INC) +# $(CC) -c -o $(OUT_DIR)/ss_msg.o $(COPTS) $(IOPTS) $(POPTS) $(CCmtFLAGS) $(IN_DIR)/ss_msg.c +#$(OUT_DIR)/ss_pack.$(OBJ): $(IN_DIR)/ss_pack.c $(ALL_INC) +# $(CC) -c -o $(OUT_DIR)/ss_pack.o $(COPTS) $(IOPTS) $(POPTS) $(CCmtFLAGS) $(IN_DIR)/ss_pack.c +#$(OUT_DIR)/ss_queue.$(OBJ): $(IN_DIR)/ss_queue.c $(ALL_INC) +# $(CC) -c -o $(OUT_DIR)/ss_queue.o $(COPTS) $(IOPTS) $(POPTS) $(CCmtFLAGS) $(IN_DIR)/ss_queue.c +#$(OUT_DIR)/ss_rtr.$(OBJ): $(IN_DIR)/ss_rtr.c $(ALL_INC) +# $(CC) -c -o $(OUT_DIR)/ss_rtr.o $(COPTS) $(IOPTS) $(POPTS) $(CCmtFLAGS) $(IN_DIR)/ss_rtr.c +#$(OUT_DIR)/ss_strm.$(OBJ): $(IN_DIR)/ss_strm.c $(ALL_INC) +# $(CC) -c -o $(OUT_DIR)/ss_strm.o $(COPTS) $(IOPTS) $(POPTS) $(CCmtFLAGS) $(IN_DIR)/ss_strm.c +##$(OUT_DIR)/ss_task.$(OBJ): $(IN_DIR)/ss_task.c $(ALL_INC) +# $(CC) -c -o $(OUT_DIR)/ss_task.o $(COPTS) $(IOPTS) $(POPTS) $(CCmtFLAGS) $(IN_DIR)/ss_task.c +#$(OUT_DIR)/ss_timer.$(OBJ): $(IN_DIR)/ss_timer.c $(ALL_INC) +# $(CC) -c -o $(OUT_DIR)/ss_timer.o $(COPTS) $(IOPTS) $(POPTS) $(CCmtFLAGS) $(IN_DIR)/ss_timer.c +#$(OUT_DIR)/ss_diag.$(OBJ): $(IN_DIR)/ss_diag.c $(ALL_INC) +# $(CC) -c -o $(OUT_DIR)/ss_diag.o $(COPTS) $(IOPTS) $(POPTS) $(CCmtFLAGS) $(IN_DIR)/ss_diag.c +# + +lib:$(LIB_DIR)/libmt.a + +include $(COM_BUILD_DIR)/compile.mak + +#-------------------------------------------------------------# +#Linker macros +#-------------------------------------------------------------# +$(LIB_DIR)/libmt.a:$(C_OBJS_WO_LOG) + $(Q)ar -cr $(LIB_DIR)/libmt.a $(C_OBJS_WO_LOG) + +#-------------------------------------------------------------# +#Clean macros +#-------------------------------------------------------------# +clean: + @echo -e "$(COLOR_RED)Cleaning SSI from $(OBJ_DIR)$(REVERT_COLOR)" + $(Q)\rm -f $(LIB_DIR)/libmt.a $(C_OBJS_WO_LOG) + + diff --git a/build/common/phy_stub.mak b/build/common/phy_stub.mak new file mode 100755 index 000000000..494c3b125 --- /dev/null +++ b/build/common/phy_stub.mak @@ -0,0 +1,68 @@ +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ + +# This is makefile for PHY Stub + +include ../common/rsys_fancy.mak +include ../common/env.mak +COLOR=$(COLOR_RED) + +SRC_DIR=$(ROOT_DIR)/src/phy_stub/ +C_SRCS=$(wildcard $(SRC_DIR)/*.c) +C_OBJS=$(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(C_SRCS)) +LOG_FILES=$(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.i,$(C_SRCS)) +BAK_FILES=$(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.i.bak,$(C_SRCS)) +DB_FILES =$(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.i.db,$(C_SRCS)) + +# prepare the list of common header files +HDR_FILES+=$(wildcard $(CM_DIR)/env*.[hx]) +HDR_FILES+=$(wildcard $(CM_DIR)/gen*.[hx]) +HDR_FILES+=$(wildcard $(CM_DIR)/ssi*.[hx]) +HDR_FILES+=$(wildcard $(CM_DIR)/cm*.[hx]) +HDR_FILES+=$(wildcard $(CM_DIR)/rg*.[hx]) +HDR_FILES+=$(wildcard $(CM_DIR)/lrg*.[hx]) + + +lib: $(LIB_DIR)/libphystub.a +include $(COM_BUILD_DIR)/compile.mak + +I_OPTS+=-I$(ROOT_DIR)/src/mt + + +#-------------------------------------------------------------# +#Linker macros +#-------------------------------------------------------------# +ifeq ($(BIN_LOG),YES) +$(LIB_DIR)/libwr.a:$(C_OBJS) $(C_WO_PED_OBJS) + @echo -e "Creating log DB $(COLOR)$(LOG_DIR)/phyStub.db $(REVERT_COLOR)" + $(Q)cat $(DB_FILES) > $(LOG_DIR)/phyStub.db + @echo -e "Creating Archive $(COLOR) $@ $(REVERT_COLOR)" + $(Q)ar -cr $(LIB_DIR)/libphystub.a $(C_OBJS) $(C_WO_PED_OBJS) +else +$(LIB_DIR)/libphystub.a:$(C_OBJS) $(C_WO_PED_OBJS) + @echo -e "Creating Archive $(COLOR) $@ $(REVERT_COLOR)" + $(Q)ar -cr $(LIB_DIR)/libphystub.a $(C_OBJS) $(C_WO_PED_OBJS) +endif + +#-------------------------------------------------------------# +#Clean macros +#-------------------------------------------------------------# +clean: + @echo $(OAM_ENABLE) + @echo -e "$(COLOR_RED)Cleaning PHY stub$(REVERT_COLOR)" + @echo $(SRC_DIR) $(CM_DIR) + $(Q)\rm -f $(LIB_DIR)/libphystub.a $(C_OBJS) $(C_WO_PED_OBJS) $(LOG_FILES) $(BAK_FILES) + diff --git a/build/common/rg.mak b/build/common/rg.mak index 6b8fac2a3..4d0094cd7 100644 --- a/build/common/rg.mak +++ b/build/common/rg.mak @@ -38,6 +38,7 @@ HDR_FILES+= $(wildcard $(SRC_DIR)/*.[hx]) #prepare the list of source files C_SRCS=$(wildcard $(SRC_DIR)/*.c) +C_SRCS:=$(filter-out $(SRC_DIR)/rg_sch%, $(C_SRCS)) #prepare the list of object files and RLOG related files C_OBJS=$(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(C_SRCS)) @@ -48,7 +49,7 @@ C_OBJS=$(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(C_SRCS)) # Including RG_PHASE2_SCHED for supporting more than one schedulers # supported by mac # TODO: make it define for LTEMAC_MIMO and remove it from envopt.h -MOD_FLAGS=-DRGM_LC -DRGM_LWLC -USM -DTF -URG_DEBUG -DxRG_PHASE2_SCHED -DxRGR_V1 \ +MOD_FLAGS=-DRGM_LC -DRGM_LWLC -USM -URG_DEBUG -DxRG_PHASE2_SCHED -DxRGR_V1 \ -DRG_UL_DELTA=2 -ULTEMAC_DLUE_TMGOPTMZ -UTENB_SPLIT_ARCH -DRG -ULTEMAC_MIMO lib:$(LIB_DIR)/librg.a diff --git a/build/common/rl.mak b/build/common/rl.mak new file mode 100755 index 000000000..1212f6ce1 --- /dev/null +++ b/build/common/rl.mak @@ -0,0 +1,80 @@ +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +# +include ../common/rsys_fancy.mak +COLOR=$(COLOR_GREEN) + +#-------------------------------------------------------------# +#Makefile for RL +#-------------------------------------------------------------# +MOD_FLAGS=-UUSE_RLOG_DATA_TYPES + +SRC_DIR=$(ROOT_DIR)/src/rlog +CM_DIR =$(ROOT_DIR)/src/cm + +# Product sources------------------------------------------------------- +C_SRCS=$(SRC_DIR)/rl_rlog.c $(SRC_DIR)/rl_common.c $(SRC_DIR)/rl_platform.c $(SRC_DIR)/rl_soc.c +rlPOSTPROCSRCS=$(SRC_DIR)/rl_common.c $(SRC_DIR)/rl_postproc.cpp + +# Product includes ------------------------------------------------------- +HDR_FILES=$(SRC_DIR)/rl_common.h $(SRC_DIR)/rl_rlog.h $(SRC_DIR)/rl_interface.h \ + $(SRC_DIR)/rl_platform.h +HDR_FILES+=$(wildcard $(CM_DIR)/*.) + +# Object files ------------------------------------ +C_OBJS_WO_LOG=$(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(C_SRCS)) + +#-------------------------------------------------------------# +#Makefile for RL +#-------------------------------------------------------------# +rlPOSTPROCOPTS=-DSS_LINUX -DUSE_RLOG_DATA_TYPES + +#-------------------------------------------------------------# +#-------------------------------------------------------------# +#Compiler macros +#-------------------------------------------------------------# +#$(OBJ_DIR)/rl_rlog.$(OBJ):$(rlSRCS) +# @echo -e "Compiling $(COLOR) $< $(REVERT_COLOR)..." +# $(Q) $(CC) -c $(COPTS) $(IOPTS) $(POPTS) $(IN_DIR)/rl_rlog.$(SRC) -rdynamic -o $(OBJ_DIR)/rl_rlog.$(OBJ) +#$(OBJ_DIR)/rl_common.$(OBJ):$(rlSRCS) +# @echo -e "Compiling $(COLOR) $< $(REVERT_COLOR)..." +# $(Q) $(CC) -c $(COPTS) $(IOPTS) $(POPTS) $(IN_DIR)/rl_common.$(SRC) -o $(OBJ_DIR)/rl_common.$(OBJ) +#$(OBJ_DIR)/rl_platform.$(OBJ):$(rlSRCS) +# @echo -e "Compiling $(COLOR) $< $(REVERT_COLOR)..." +# $(Q) $(CC) -c $(COPTS) $(IOPTS) $(POPTS) $(IN_DIR)/rl_platform.$(SRC) -o $(OBJ_DIR)/rl_platform.$(OBJ) + +lib:$(LIB_DIR)/librl.a + +include $(COM_BUILD_DIR)/compile.mak + +#-------------------------------------------------------------# +#Linker macros +#-------------------------------------------------------------# +$(LIB_DIR)/librl.a:$(C_OBJS_WO_LOG) + @echo -e "Creating Archive $(COLOR) $@ $(REVERT_COLOR)" + $(Q)$(AR) -cr $(OBJ_DIR)/librl.a $(C_OBJS) + @echo -e "$(COLOR)Building the binary logging post processor$(REVERT_COLOR)" + $(Q)g++ $(rlPOSTPROCOPTS) $(rlPOSTPROCSRCS) -o $(OBJ_DIR)/rlogapp + +#-------------------------------------------------------------# +#Clean macros +#-------------------------------------------------------------# +clean: + @echo -e "$(COLOR_RED)Clearing binary logging$(REVERT_COLOR)" + $(Q)rm -f $(LIB_DIR)/librl.a $(C_OBJS_WO_LOG) + + + diff --git a/build/common/rlog.pl b/build/common/rlog.pl new file mode 100755 index 000000000..a3643c8fd --- /dev/null +++ b/build/common/rlog.pl @@ -0,0 +1,244 @@ +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ + +#!/usr/bin/perl -w +#use strict; +use POSIX; +use Time::HiRes qw(usleep); +local $| = 1; + +#if($ARGV[1] eq "INTEL") { +# if ($#ARGV == 3 ) { +# print "Make DB Script ERROR: More than two arument is passed to script\n"; +# exit; +# } +#} else { +# if ($#ARGV == 4 ) { +# print "Make DB Script ERROR: More than two arument is passed to script\n"; +# exit; +# } +#} +########################################################### +# Reading File name and creating DB file name. +# my $OrgFileName = $ARGV[0]; # Copied File name in to a varible. +# my @spltname = split('/', $OrgFileName); +my $numelem = $#spltname; +my $fileName = $spltname[$numelem]; + +#variable declaration. +my @arryOfLogId = 0; +my $moduleId = 0; +my $fileId = 0; +my $moduleName = 0; +my $lineNum = 0; +my $test = 0; +my $printString = 0; +my @varibles = 0; +my $logLvl = 0; +my $splArgName = 0; +my $splArgVal = 0; +my $tokenID = 0; +my $hexTokenID = 0; +my $CStart = 0; +my $CPattern = 0; +my $CVarible = 0; +my $CString = 0; +my $CEnd = 0; +my $NewVarible = 0; +my $delimit = '%8ld'; +#my $isModuleNameFound = 0; +my $greatestTokenID = 0; +my $DBFILE; +my $tmpfile; +my $tmpfile1; +my $dbentry; + +########################################################### +# Declare the subroutines +sub trim($); +sub ltrim($); +sub rtrim($); +sub findDup; + +# Perl trim function to remove whitespace from the start and end of the string +sub trim($) { + my $string = shift; + $string =~ s/^\s+//; + $string =~ s/\s+$//; + return $string; +} + +# Left trim function to remove leading whitespace +sub ltrim($) { + my $string = shift; + $string =~ s/^\s+//; + return $string; +} + +# Right trim function to remove trailing whitespace +sub rtrim($) { + my $string = shift; + $string =~ s/\s+$//; + return $string; +} + +my $prj = $ARGV[0]; +my $tmp = $ARGV[0]; +my @dbFilesDir = ($ARGV[2]); + +# Process the file and generate the log DB for the file +#print "Arguments passed are ", @ARGV, "\n"; +#print "Calling process of the file with argument ", $ARGV[1], "\n"; +parse_preproc_file($ARGV[1]); + +sub parse_preproc_file { + my $OrgFileName = shift; + #print "File passed is ", $OrgFileName, "\n"; + chomp($OrgFileName); + my $generatedb = 0; + my $dbFileName = sprintf("%s%s", $OrgFileName,".db"); + my $logNum = 0; + + my $isModuleIdFound = 0; + my $isFileIdFound = 0; + my $isModuleNameFound = 0; + $logNum = 0; + $fileId = 0; + + # Opening source.i file and DB file + # print "FILE:$OrgFileName\n"; + `cp -f $OrgFileName $OrgFileName.bak`; + if($tmp eq "INTEL") { + #print "Removing # for INTEL"; + system("sed -i '/^#/d' $OrgFileName"); + } elsif($tmp eq "XEON"){ + #print "Remove # for XEON"; + system("sed -i '/stdlib\-bsearch.h/s/^#//g' $OrgFileName"); + system("sed -i '/^#/d' $OrgFileName"); + system("sed -i '/stdlib\-bsearch.h/s/^/#/g' $OrgFileName"); + }else { + #print "Don't Remove # for BRCM"; + #system("sed -i '/^#/d' $OrgFileName"); + } + + open FILE, "<$OrgFileName" or die $!; + open my $OUTPFILE, '>', "$OrgFileName.tmp" or die "Can't write new file: $!"; + my $fromFound =0; + + while() { + if (( $_ =~ /logLev[0-4EHS]/ ) && ( $_ !~ /}[;]*/) && ( $_ !~ /R_LOG_LEVEL/)) { + $fromFound = 1; + $concatStr=$_; + chomp($concatStr); + next; + } + + if( ($_ =~ /}[;]*/) && ($fromFound == 1) ) { + $concatStr =~ s/(.*)(logLev[E0-4HS]) +(.*)/$1$2$3/g; + print $OUTPFILE $concatStr; + print $OUTPFILE $_; + $fromFound = 0; + next; + } + + if ($fromFound == 1) { + chomp($_); + $concatStr = $concatStr.$_; + } else { + #print $OUTPFILE "/* AARTI4*/"; + $_ =~ s/(.*)(logLev[E0-4HS]) +(.*)/$1$2$3/g; + print $OUTPFILE $_; + } + } + close(FILE); + close($OUTPFILE); + `mv -f $OrgFileName.tmp $OrgFileName`; + + open(INFILE, "< $OrgFileName") || die("Make DB Script ERROR: Cannot open file $OrgFileName for parse"); + open $tmpfile, "> $OrgFileName.tmp.i" || die("Data Base ERROR: Cannot Create temporary file"); + open ($dbfile, '>' , "$OrgFileName.tmp.db") || die("Data Base ERROR: Cannot create the file $dbFileName"); + ########################################################## + # Read each line and create the DB entries + while () { + if (($isModuleIdFound != 1) || ($isFileIdFound != 1) || ($isModuleNameFound !=1)) { + if (/(\s*.*)RLOG_MODULE_ID(\s*.*)=(\s*.*);/) { + $moduleId = $3; + $isModuleIdFound = 1; + } + + if (/(\s*.*)RLOG_FILE_ID(\s*.*)=(\s*.*);/) { + $fileId = $3; + $isFileIdFound = 1; + #print "FILE $OrgFileName FILE ID $fileId [$1] [$2] [$3]\n"; + } + if (/(\s*.*)*RLOG_MODULE_NAME(\s*.*)=(\s*.*);/) { + $moduleName = $3; + $moduleName = substr($moduleName,1); + $moduleName = substr($moduleName, 0, -1); + $isModuleNameFound = 1; + } + + print $tmpfile $_; + } elsif (/(\s*.*)(logLev[E0-4HS]\()(\s*.*\,)(\s*\".*\")(\s*.*)/) { + $CStart = $1; + $CPattern = $2; + $CVarible = $3; + $CString = $4; + $CEnd = $5; + + if( $3 =~ m/_LOGID/ ) { + my $fmtStr = $CString; + @variables = split(/,/, $CVarible); + my $arrSize = $#variables; + my $line = $variables[$arrSize]; + my $file = $variables[$arrSize-1]; + + if ($fileId < 0x3FF) { + $tokenID = ($fileId << 16)|(++$logNum); + $hexTokenID = sprintf("0x%x", $tokenID); + } else { print "SOME ERROR MODID:$moduleId FILEID:$fileId\n"; + return 1; + } + + $CVarible =~ s/_LOGID/$hexTokenID/; + + print $tmpfile "$CStart$CPattern$CVarible$CString$CEnd\n"; + print $dbfile "$tokenID;$line;$moduleName;$file;$fmtStr\n"; + $generatedb = 1; + } + } else { + print $tmpfile $_; + } + $lineNum = $lineNum + 1; + } + + ########################################################################## + #Close all files and create final output file + close(INFILE); + close ($tmpfile); + close ($dbfile); + + #close ($DBFILE); + #if( $generatedb eq 1) { + `cp -f $OrgFileName.tmp.i $OrgFileName`; + `mv -f $OrgFileName.tmp.db $dbFileName`; + `dos2unix -q $OrgFileName`; + `dos2unix -q $dbFileName`; + `rm -f $OrgFileName.tmp.i` + #} else { + # 'rm -f tmp.i'; + #} +} diff --git a/build/config/ssi_mem b/build/config/ssi_mem new file mode 100755 index 000000000..0a439efa4 --- /dev/null +++ b/build/config/ssi_mem @@ -0,0 +1,65 @@ +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ + +# Max number of Regions +4 +# Number of Buckets and Pools +4 4 +# Bucket Idx and Block Size +0 256 +1 1280 +2 2048 +3 8196 +# Region Idx +0 +# Bucket Idx and Number of blocks +0 10000 +1 500 +2 500 +3 500 +# Heap size +8194304U + +# Region Idx +1 +# Bucket Idx and Number of blocks +0 75000 +1 15000 +2 500 +3 1600 +# Heap size +1004800U + +# Region Idx +2 +# Bucket Idx and Number of blocks +0 65000 +1 8000 +2 600 +3 900 +# Heap size +6097512U + +# Region Idx +3 +# Bucket Idx and Number of blocks +0 50 +1 10 +2 10 +3 10 +# Heap size +128U + diff --git a/build/odu/makefile b/build/odu/makefile new file mode 100644 index 000000000..42c00874c --- /dev/null +++ b/build/odu/makefile @@ -0,0 +1,173 @@ +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ + +# Master makefile + +# Identify the location our software which is used by rest +# of the build scripts + +include ../common/rsys_fancy.mak +include ../common/env.mak + +RULE=$(COLOR_RED) +OPTS=$(COLOR_GREEN) +NORM=$(REVERT_COLOR) + +# For improved speed +CPUINFO=`cat /proc/cpuinfo | grep processor| wc -l` +ifeq ($(CPUINFO), 1) + NUM_PARALLEL=1 +else + NUM_PARALLEL=$(shell echo $(CPUINFO) - 1 |bc) +endif + +ifeq ($(FAST), 1) + NUM_PARALLEL=$(shell echo $(CPUINFO) + 2 |bc) +endif + +PARALLEL_COMP=-j $(NUM_PARALLEL) + +# Different options to CPUH and CPUL builds +# # Other apsects of tool chain set here +# # These should be made available appropriately to the builds +ifeq ($(MACHINE),BIT64) +CC =gcc -m64 +CC_STRIP =strip --strip-all +CC_LINKER =gcc -m64 +CCPP =g++ -m64 +CCPP_LINKER =g++ -m64 +else +CC =gcc -m32 +CC_STRIP =strip --strip-all +CC_LINKER =gcc -m32 +CCPP =g++ -m32 +CCPP_LINKER =g++ -m32 +endif + +CC1= $(CC) +CCPP1= $(CCPP) + +ifeq ($(MODE),TDD) +CNM_ENABLE = YES +else +CNM_ENABLE=NO +endif + +#----------------------------------------------------------------------- +# macro for output file name and makefile name +# + +prepare_dirs: + $(Q)echo -e "Preparing directories for build..." + $(Q)mkdir -p $(BUILD_DIR)/obj/odu + $(Q)mkdir -p $(LOG_ROOT)/odu + $(Q)mkdir -p $(LIB_ROOT)/odu + $(Q)echo -e "Directories are successfully prepared" + +PLTFRM_FLAGS= -UMSPD -DODU + +ifeq ($(MODE),TDD) + PLTFRM_FLAGS += -DMODE=TDD +endif +ifeq ($(CA_ENABLE),YES) + PLTFRM_FLAGS += -DCA_ENABLE=YES +endif + +# The include options get merged with the options needed by +# # the called makefiles and hence we export these to make them +# # available to them. +BUILD=i686-linux + +# The called makefiles depend on these macros and these need to be exported +export PLTFRM +export PLTFRM_FLAGS +export BUILD +export I_OPTS + +# Add to the linker options the platform specific components +L_OPTS+=-lnsl -lrt -lm -lpthread -lsctp + +# Export some of the flags expected from the command line. +# # These macros are made available for the makefiles called from this makefile +export BOARD +export MACHINE +export MODE +export OAM_ENABLE +export CNM_ENABLE +export TEXT_LOG +export CA_ENABLE + +help: + @echo -e "******************************************************************" + @echo -e "BUILD COMMAND DESCRIPTION " + @echo -e "------------------------------------------------------------------" + @echo -e "$(RULE)odu - Builds all components of ODU$(NORM)" + @echo -e "$(OPTS) options: $(NORM)" + @echo -e "$(OPTS) MACHINE=BIT64/BIT32 - Default is BIT32$(NORM)" + @echo -e "$(OPTS) TEXT_LOG=YES - With text logging instead of binary$(NORM)" + @echo -e "$(OPTS) MODE=TDD - If not specified, MODE=FDD$(NORM)" + @echo -e "$(RULE)clean_all tdd cleanup everything$(NORM)" + @echo -e "******************************************************************" + +du: + $(Q)$(MAKE) -f $(COM_BUILD_DIR)/du_app.mak OBJ_DIR=$(OBJ_ROOT)/odu LIB_DIR=$(LIB_ROOT)/odu LOG_DIR=$(LOG_ROOT)/odu CC='$(CC1)' + $(Q)$(MAKE) -f $(COM_BUILD_DIR)/f1ap.mak OBJ_DIR=$(OBJ_ROOT)/odu LIB_DIR=$(LIB_ROOT)/odu LOG_DIR=$(LOG_ROOT)/odu CC='$(CC1)' + $(Q)$(MAKE) -f $(COM_BUILD_DIR)/asn.mak OBJ_DIR=$(OBJ_ROOT)/odu LIB_DIR=$(LIB_ROOT)/odu LOG_DIR=$(LOG_ROOT)/odu CC='$(CC1)' + $(Q)$(MAKE) -f $(COM_BUILD_DIR)/kw.mak OBJ_DIR=$(OBJ_ROOT)/odu LIB_DIR=$(LIB_ROOT)/odu LOG_DIR=$(LOG_ROOT)/odu CC='$(CC1)' + $(Q)$(MAKE) -f $(COM_BUILD_DIR)/cm.mak OBJ_DIR=$(OBJ_ROOT)/odu LIB_DIR=$(LIB_ROOT)/odu LOG_DIR=$(LOG_ROOT)/odu CC='$(CC1)' + $(Q)$(MAKE) -f $(COM_BUILD_DIR)/rg.mak OBJ_DIR=$(OBJ_ROOT)/odu LIB_DIR=$(LIB_ROOT)/odu LOG_DIR=$(LOG_ROOT)/odu CC='$(CC1)' + $(Q)$(MAKE) -f $(COM_BUILD_DIR)/mt.mak OBJ_DIR=$(OBJ_ROOT)/odu LIB_DIR=$(LIB_ROOT)/odu LOG_DIR=$(LOG_ROOT)/odu CC='$(CC1)' + $(Q)$(MAKE) -f $(COM_BUILD_DIR)/rl.mak OBJ_DIR=$(OBJ_ROOT)/odu LIB_DIR=$(LIB_ROOT)/odu LOG_DIR=$(LOG_ROOT)/odu CC='$(CC1)' + $(Q)$(MAKE) -f $(COM_BUILD_DIR)/phy_stub.mak OBJ_DIR=$(OBJ_ROOT)/odu LIB_DIR=$(LIB_ROOT)/odu LOG_DIR=$(LOG_ROOT)/odu CC='$(CC1)' + +clean: + $(Q)$(MAKE) -f $(COM_BUILD_DIR)/du_app.mak clean OBJ_DIR=$(OBJ_ROOT)/odu LIB_DIR=$(LIB_ROOT)/odu LOG_DIR=$(LOG_ROOT)/odu CC='$(CC1)' + $(Q)$(MAKE) -f $(COM_BUILD_DIR)/f1ap.mak clean OBJ_DIR=$(OBJ_ROOT)/odu LIB_DIR=$(LIB_ROOT)/odu LOG_DIR=$(LOG_ROOT)/odu CC='$(CC1)' + $(Q)$(MAKE) -f $(COM_BUILD_DIR)/asn.mak clean OBJ_DIR=$(OBJ_ROOT)/odu LIB_DIR=$(LIB_ROOT)/odu LOG_DIR=$(LOG_ROOT)/odu CC='$(CC1)' + $(Q)$(MAKE) -f $(COM_BUILD_DIR)/kw.mak clean OBJ_DIR=$(OBJ_ROOT)/odu LIB_DIR=$(LIB_ROOT)/odu LOG_DIR=$(LOG_ROOT)/odu CC='$(CC1)' + $(Q)$(MAKE) -f $(COM_BUILD_DIR)/cm.mak clean OBJ_DIR=$(OBJ_ROOT)/odu LIB_DIR=$(LIB_ROOT)/odu LOG_DIR=$(LOG_ROOT)/odu CC='$(CC1)' + $(Q)$(MAKE) -f $(COM_BUILD_DIR)/rg.mak clean OBJ_DIR=$(OBJ_ROOT)/odu LIB_DIR=$(LIB_ROOT)/odu LOG_DIR=$(LOG_ROOT)/odu CC='$(CC1)' + $(Q)$(MAKE) -f $(COM_BUILD_DIR)/mt.mak clean OBJ_DIR=$(OBJ_ROOT)/odu LIB_DIR=$(LIB_ROOT)/odu LOG_DIR=$(LOG_ROOT)/odu CC='$(CC1)' + $(Q)$(MAKE) -f $(COM_BUILD_DIR)/rl.mak clean OBJ_DIR=$(OBJ_ROOT)/odu LIB_DIR=$(LIB_ROOT)/odu LOG_DIR=$(LOG_ROOT)/odu CC='$(CC1)' + $(Q)$(MAKE) -f $(COM_BUILD_DIR)/phy_stub.mak clean OBJ_DIR=$(OBJ_ROOT)/odu LIB_DIR=$(LIB_ROOT)/odu LOG_DIR=$(LOG_ROOT)/odu CC='$(CC1)' + +clean_all: clean + $(Q)rm -rf $(OBJ_ROOT) + $(Q)rm -rf $(LIB_ROOT) + $(Q)rm -rf $(LOG_ROOT) + $(Q)rm -rf bin +link_all: du + $(Q)$(CC1) -g -o $(OBJ_ROOT)/odu/odu -Wl,-R../lib/:. $(OBJ_ROOT)/odu/*.o\ + $(L_OPTS) -L$(LIB_ROOT)/odu -L$(ROOT_DIR)/libs/odu + +odu: prepare_dirs copy_build + +copy_build: link_all + $(Q)mkdir -p bin bin/config bin/odu bin/scripts +ifneq ($(TEXT_LOG), YES) + $(Q)cp -f ./obj/odu/rlogapp bin/odu + $(Q)cat $(LOG_ROOT)/odu/*.db > $(LOG_ROOT)/odu/rlog.logdb + $(Q)cp -f $(LOG_ROOT)/odu/rlog.logdb odu/bin/ + $(Q)echo -e "Completed generation of log database" +endif + $(Q)cp -f ./obj/odu/odu ./bin/odu +# $(Q)cp -f ../config/wr_cfg_fdd.txt ./odu/bin/wr_cfg.txt +# $(Q)cp -f ../config/ys_cfg.txt ./odu/bin/ys_cfg.txt + $(Q)cp -f ../config/ssi_mem ./bin/config + $(Q)cp -rf ./bin $(ROOT_DIR)/bin/ + $(Q)mkdir -p $(ROOT_DIR)/libs/ + $(Q)cp -f ./lib/odu/*.a $(ROOT_DIR)/libs/ + $(Q)echo -e "***** BUILD COMPLETE *****" diff --git a/build/scripts/makefile b/build/scripts/makefile index 4b276a801..ce6dabc62 100755 --- a/build/scripts/makefile +++ b/build/scripts/makefile @@ -161,13 +161,11 @@ help: enb: $(Q)$(MAKE) -f $(COM_BUILD_DIR)/kw.mak OBJ_DIR=$(OBJ_ROOT) LIB_DIR=$(LIB_ROOT) LOG_DIR=$(LOG_ROOT) CC='$(CC1)' - $(Q)$(MAKE) -f $(COM_BUILD_DIR)/pj.mak OBJ_DIR=$(OBJ_ROOT) LIB_DIR=$(LIB_ROOT) LOG_DIR=$(LOG_ROOT) CC='$(CC1)' $(Q)$(MAKE) -f $(COM_BUILD_DIR)/rg.mak OBJ_DIR=$(OBJ_ROOT) LIB_DIR=$(LIB_ROOT) LOG_DIR=$(LOG_ROOT) CC='$(CC1)' clean_all: $(Q)$(MAKE) -f $(COM_BUILD_DIR)/rg.mak clean OBJ_DIR=$(OBJ_ROOT) LIB_DIR=$(LIB_ROOT) LOG_DIR=$(LOG_ROOT) CC='$(CC2)' $(Q)$(MAKE) -f $(COM_BUILD_DIR)/kw.mak clean OBJ_DIR=$(OBJ_ROOT) LIB_DIR=$(LIB_ROOT) LOG_DIR=$(LOG_ROOT) CC='$(CC2)' - $(Q)$(MAKE) -f $(COM_BUILD_DIR)/pj.mak clean OBJ_DIR=$(OBJ_ROOT) LIB_DIR=$(LIB_ROOT) LOG_DIR=$(LOG_ROOT) CC='$(CC2)' ################################################################################################### diff --git a/src/5gnrmac/rg_cl.h b/src/5gnrmac/rg_cl.h new file mode 100644 index 000000000..9368b2acc --- /dev/null +++ b/src/5gnrmac/rg_cl.h @@ -0,0 +1,57 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/* Contains definitions for MAC CL modules */ +#ifndef __RG_CL_H__ +#define __RG_CL_H__ + +#define MAX_NUM_CELL_SUPP 1 + +typedef enum +{ + PHY_STATE_IDLE, + PHY_STATE_CONFIGURED, + PHY_STATE_RUNNING, + PHY_STATE_INVALID +}PhyState; + +typedef struct clCb +{ + Region region; + Pool pool; + Bool clCfgDone; /* CL configuration done */ + CmHashListCp cellCbLst; /* List of Cells configured */ + U8 numOfCells; /* Number of Cells configured */ + PhyState phyState; /* State of PHY */ +}ClCb; + +typedef struct cellCb +{ + U16 cellId; + ClCellCfg cellCfg; + PhyState phyState; +}ClCellCb; + +EXTERN ClCb clGlobalCp; +EXTERN ClCellCb * rgClUtlGetCellCb ARGS((U16 cellId)); + +#endif + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/5gnrmac/rg_cl_cfg.c b/src/5gnrmac/rg_cl_cfg.c new file mode 100644 index 000000000..3c699162a --- /dev/null +++ b/src/5gnrmac/rg_cl_cfg.c @@ -0,0 +1,132 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/* This file handles the cell configurtaion for MAC CL */ + +#include "envdep.h" +#include "gen.h" +#include "ssi.h" +#include "cm_hash.h" + +#include "gen.x" +#include "ssi.x" +#include "cm_hash.x" +#include "cm_lib.x" + +#include "lcl.h" +#include "rg_cl.h" + +EXTERN S16 rgClBldAndSndFAPICfgReq ARGS((ClCellCb *cellCb)); + +/******************************************************************* + * + * @brief Validates CL cell configuration + * + * @details + * + * Function : rgClVldtCellCfg + * + * Functionality: + * - Validates all PHY cell configuration patameters + * + * @params[in] cell config + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +PRIVATE S16 rgClVldtCellCfg +( +ClCellCfg *cellCfg +) +{ + RETVALUE(ROK); +} + + +/******************************************************************* + * + * @brief Cell configuration handler at MAC CL + * + * @details + * + * Function : RgClCellCfgReq + * + * Functionality: + * -Handler for new cell addition request from du_app + * + * @params[in] cell cfg + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +PUBLIC U16 RgClCellCfgReq +( +ClCellCfg *cellCfg +) +{ + ClCellCb *cellCb = NULLP; + + printf("\nReceived cell configuration request. Adding cellId[%d] phyCellId[%d]", cellCfg->cellId, cellCfg->phyCellId); + + if(clGlobalCp.numOfCells >= MAX_NUM_CELL_SUPP) + { + printf("\nMaximum number of cells [%d] already configured", MAX_NUM_CELL_SUPP); + RETVALUE(LCM_REASON_INVALID_PAR_VAL); + } + + if(rgClVldtCellCfg(cellCfg) != ROK) + { + printf("\nCell configuration failure. Cell Id [%d]", cellCfg->cellId); + RETVALUE(LCM_REASON_INVALID_PAR_VAL); + } + + if((cellCb = (ClCellCb *)rgClUtlGetCellCb(cellCfg->cellId)) == NULLP) + { + if((SGetSBuf(clGlobalCp.region, clGlobalCp.pool, (Data **)&cellCb, sizeof(ClCellCb)) != ROK) || (cellCb == NULLP)) + { + printf("\nFailed to allocate memory for new cell"); + RETVALUE(LCM_REASON_MEM_NOAVAIL); + } + cmMemset((U8 *)cellCb, 0, sizeof(ClCellCb)); + cellCb->cellId = cellCfg->cellId; + cellCb->phyState = PHY_STATE_IDLE; + + if((cmHashListInsert(&(clGlobalCp.cellCbLst), (PTR)cellCb, (U8 *)&cellCb->cellId, sizeof(U16))) != ROK) + { + printf("\nFailed to insert cell into list."); + RETVALUE(RFAILED); + } + + clGlobalCp.numOfCells++; + } + + cmMemcpy((U8 *)&cellCb->cellCfg, (U8 *)cellCfg, sizeof(ClCellCfg)); + + /* Build and send CONFIG request to PHY */ + if(rgClBldAndSndFAPICfgReq(cellCb) != ROK ) + { + printf("\nrgClBldAndSndPhyCfgReq failed"); + RETVALUE(LCM_REASON_NEG_CFM); + } + + RETVALUE(LCM_REASON_NOT_APPL); +} + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/5gnrmac/rg_cl_li.c b/src/5gnrmac/rg_cl_li.c new file mode 100644 index 000000000..d41c17bb1 --- /dev/null +++ b/src/5gnrmac/rg_cl_li.c @@ -0,0 +1,280 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/* This file contains handler for FAPI messages to be sent or received from PHY */ + +#include "envdep.h" +#include "gen.h" +#include "ssi.h" +#include "cm_hash.h" + +#include "gen.x" +#include "ssi.x" +#include "cm_hash.x" + +#include "lcl.h" +#include "rg_cl.h" +#include "rg_cl_phy.h" +/*#include "wls_lib.h"*/ + +EXTERN S16 sendToPhy ARGS((U16 msgType, U32 msgLen, void *msg)); + +/******************************************************************* + * + * @brief Fills FAPI message header + * + * @details + * + * Function : fillMsgHdr + * + * Functionality: + * -Fills FAPI message header + * + * @params[in] Pointer to header + * Number of messages + * Messae Type + * Length of message + * @return void + * + * ****************************************************************/ +PUBLIC void fillMsgHdr(MsgHdr *hdr, U8 nMsg, U16 msgType, U32 msgLen) +{ + hdr->nMsg = nMsg; + hdr->msgType = msgType; + hdr->msgLen = msgLen; +} + + /******************************************************************* + * + * @brief Fills TLV + * + * @details + * + * Function : fillTlv + * + * Functionality: + * -Fills TLV + * + * @params[in] Pointer to TLV + * Tag + * Length + * Value + * @return Void + * + * ****************************************************************/ +PUBLIC void fillTlv(L1L2Tlv *tlv, U16 tag, U16 len, U16 value) +{ + tlv->tag = tag; + tlv->length = len; + tlv->value = value; +} + + + /******************************************************************* + * + * @brief Fills next config TLV + * + * @details + * + * Function : fillConfigTLV + * + * Functionality: + * - Finds pointer to next TLV in config req + * - Fills the TLV + * - Calculates Message length + * + * @params[in] + * @return ROK - void + * + * ****************************************************************/ +PUBLIC void fillConfigTLV(L1L2Tlv *nextTlv, U8 *configTlvs, U16 tag, U16 length, U16 value, U16 *msgLen) +{ + nextTlv = (L1L2Tlv *)(configTlvs + *msgLen); + fillTlv(nextTlv, tag, length, value); + *msgLen = *msgLen + sizeof(tag) + sizeof(length) + length; +} + + + /******************************************************************* + * + * @brief Build and send FAPI config req to PHY + * + * @details + * + * Function : rgClBldAndSndFAPICfgReq + * + * Functionality: + * -Build and send FAPI config req to PHY + * + * @params[in] + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ + +PUBLIC S16 rgClBldAndSndFAPICfgReq +( +ClCellCb *cellCb +) +{ + U16 msgLen; + U32 FAPIConfigReqSize; + U8 *configTlvs; + L1L2ConfigReq *FAPIConfigReq; + L1L2Tlv *nextTlv; + ClCellCfg cellCfg; + + FAPIConfigReqSize = sizeof(L1L2ConfigReq) + + (cellCb->cellCfg.numTlv * sizeof(L1L2Tlv)); + + /* TO DO :Change SGetSBuf to SGetSBufWls() later */ + if(SGetSBuf(0,0,(Data **)&FAPIConfigReq, FAPIConfigReqSize) != ROK ) + { + printf("\nMemory allocation failed for PHY Config Req"); + RETVALUE(RFAILED); + } + + nextTlv = NULLP; + msgLen = 0; + cellCfg = cellCb->cellCfg; + configTlvs = (U8 *)((U8 *)FAPIConfigReq + MSG_HDR_SIZE + 2); + + FAPIConfigReq->nTlv = cellCfg.numTlv; + FAPIConfigReq->carrierId = cellCb->cellId; + + /* Filling cell configuration */ + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_PHY_CELL_ID, sizeof(U16), cellCfg.phyCellId, &msgLen); + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_FRAME_DUP_TYPE, sizeof(U16), cellCfg.dupType, &msgLen); + + /* Filling DL carrier configuration */ + if(cellCfg.dlCarrCfg.pres) + { + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_DL_BW, sizeof(U16), cellCfg.dlCarrCfg.bw, &msgLen); + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_DL_FREQ, sizeof(U16), cellCfg.dlCarrCfg.freq, &msgLen); + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_DLK0, sizeof(U16),cellCfg.dlCarrCfg.k0[0], &msgLen); + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_DL_GRID_SIZE, sizeof(U16),cellCfg.dlCarrCfg.gridSize[0], &msgLen); + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_NUM_TX_ANT, sizeof(U16), cellCfg.dlCarrCfg.numAnt, &msgLen); + } + + /* Filling UL carrier configuration */ + if(cellCfg.ulCarrCfg.pres) + { + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_UL_BW, sizeof(U16), cellCfg.ulCarrCfg.bw, &msgLen); + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_UL_FREQ, sizeof(U16), cellCfg.ulCarrCfg.freq, &msgLen); + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_ULK0, sizeof(U16), cellCfg.ulCarrCfg.k0[0], &msgLen); + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_UL_GRID_SIZE, sizeof(U16), cellCfg.ulCarrCfg.gridSize[0], &msgLen); + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_NUM_RX_ANT, sizeof(U16), cellCfg.ulCarrCfg.numAnt, &msgLen); + } + + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_FREQ_SHIFT_7P5KHZ, sizeof(U16), cellCfg.freqShft, &msgLen); + + /* Filling SSB configuration */ + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_SS_PBCH_PWR, sizeof(U16), cellCfg.ssbCfg.ssbPbchPwr, &msgLen); + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_BCH_PAYLOAD, sizeof(U16), cellCfg.ssbCfg.bchPayload, &msgLen); + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_SCS_COMM, sizeof(U16), cellCfg.ssbCfg.scsCmn, &msgLen); + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_SSB_OFFS_POINT_A, sizeof(U16), cellCfg.ssbCfg.ssbPrbOffset, &msgLen); + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_BETA_PSS, sizeof(U16), cellCfg.ssbCfg.betaPss, &msgLen); + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_SSB_PERIOD, sizeof(U16), cellCfg.ssbCfg.ssbPeriod, &msgLen); + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_SSB_SUBC_OFFS, sizeof(U16), cellCfg.ssbCfg.ssbSubcOffset, &msgLen); + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_MIB, sizeof(U16), cellCfg.ssbCfg.mibPdu, &msgLen); + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_SSB_MASK, sizeof(U16), cellCfg.ssbCfg.nSSBMask[0], &msgLen); + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_SS_PBCH_MULT_CARR_BAND, sizeof(U16), cellCfg.ssbCfg.multCarrBand, &msgLen); + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_MULT_CELL_SS_PBCH_CARR, sizeof(U16), cellCfg.ssbCfg.multCellCarr, &msgLen); + + /* Filling PRACH configuration */ + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_PRACH_SEQ_LEN, sizeof(U16), cellCfg.prachCfg.prachSeqLen, &msgLen); + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_PRACH_SUBC_SPAC, sizeof(U16), cellCfg.prachCfg.prachSubcSpacing, &msgLen); + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_RES_SET_CFG, sizeof(U16), cellCfg.prachCfg.prachRstSetCfg, &msgLen); + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_NUM_PRACH_FD_OCC, sizeof(U16), cellCfg.prachCfg.prachFdm, &msgLen); + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_PRACH_ROOT_SEQ_ID, sizeof(U16), cellCfg.prachCfg.fdm[0].rootSeqIdx, &msgLen); + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_NUM_ROOT_SEQ, sizeof(U16), cellCfg.prachCfg.fdm[0].numRootSeq, &msgLen); + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_K1, sizeof(U16), cellCfg.prachCfg.fdm[0].k1, &msgLen); + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_PRACH_ZERO_CORR_CFG, sizeof(U16), cellCfg.prachCfg.fdm[0].zeroCorrZoneCfg, &msgLen); + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_NUM_UNUSED_ROOT_SEQ, sizeof(U16), cellCfg.prachCfg.fdm[0].numUnusedRootSeq, &msgLen); + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_UNUSED_ROOT_SEQ, sizeof(U16), *(cellCfg.prachCfg.fdm[0].unsuedRootSeq), &msgLen); + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_SSB_PER_RACH, sizeof(U16), cellCfg.prachCfg.ssbPerRach, &msgLen); + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_PRACH_MULT_CARR_BAND, sizeof(U16), cellCfg.prachCfg.prachMultCarrBand, &msgLen); + + /* Filling TDD configuration */ + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_TDD_PERIOD, sizeof(U16), cellCfg.tddCfg.tddPeriod, &msgLen); + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_SLOT_CFG, sizeof(U16), cellCfg.tddCfg.slotCfg[0][0], &msgLen); + + /* Filling RSSI measurement configuration */ + fillConfigTLV(nextTlv, configTlvs, CFG_TAG_RSSI_MEAS, sizeof(U16), cellCfg.rssiUnit, &msgLen); + + msgLen = msgLen + sizeof(L1L2ConfigReq); + + /* Filling message header */ + fillMsgHdr(&FAPIConfigReq->hdr, 1, MSG_TYPE_CONFIG_REQ, msgLen); + + /* Sending msg to PHY */ + sendToPhy(MSG_TYPE_CONFIG_REQ, FAPIConfigReqSize, (void *)FAPIConfigReq); + + RETVALUE(ROK); +} + + +/******************************************************************* + * + * @brief Handles FAPI config response + * + * @details + * + * Function : rgClHndlCfgReq + * + * Functionality: + * -Handles FAPI config request + * + * @params[in] Message pointer + * + * @return void + * + *****************************************************************/ + +S16 rgClHndlCfgReq(void *msg) +{ + ClCellCb *cellCb = NULLP; + L1L2ConfigRsp *configRsp; + + configRsp = (L1L2ConfigRsp *)msg; + + if(configRsp->status != MSG_OK) + { + printf("\nPHY configuration failed"); + RETVALUE(RFAILED); + } + + if((cellCb = (ClCellCb *)rgClUtlGetCellCb(configRsp->carrierId)) != NULLP) + { + printf("\nCell Id[%d] not found", configRsp->carrierId); + RETVALUE(RFAILED); + } + + cellCb->phyState = PHY_STATE_CONFIGURED; + clGlobalCp.phyState = PHY_STATE_CONFIGURED; + + printf("\nReceived successful PHY configuration response"); + + SPutSBuf(0, 0, (Data *)msg, configRsp->hdr.msgLen ); + + RETVALUE(ROK); +} + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/5gnrmac/rg_cl_phy_inf.c b/src/5gnrmac/rg_cl_phy_inf.c new file mode 100644 index 000000000..250bec821 --- /dev/null +++ b/src/5gnrmac/rg_cl_phy_inf.c @@ -0,0 +1,103 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/* This file contains APIs to send/receive messages from PHY */ + +#include "stdio.h" +#include "envdep.h" +#include "ssi.h" + +#include "rg_cl_phy.h" + + +EXTERN S16 rgClHndlCfgReq ARGS((void *msg)); +EXTERN void macToPhy ARGS((U16 msgType, U32 msgLen, void *msg)); + +/****************************************************************** + * + * @brief Receives message to PHY + * + * @details + * + * Function : phyToMac + * + * Functionality: + * -Receives Msg from PHY + * + * @params[in] Message Pointer + * + * @return void + * + ******************************************************************/ + +void phyToMac(U16 msgType, U32 msgLen,void *msg) +{ + switch(msgType) + { + case MSG_TYPE_CONFIG_RSP: + rgClHndlCfgReq(msg); + break; + + default: + printf("\nInvalid message type[%x] from PHY", msgType); + } +} + +/******************************************************************* + * + * @brief Sends message to PHY + * + * @details + * + * Function : sendToPhy + * + * Functionality: + * -Sends message to PHY + * + * @params[in] Message Type + * Message Length + * Messaga Pointer + * + * @return void + * +******************************************************************/ + +PUBLIC S16 sendToPhy(U16 msgType, U32 msgLen, void *msg) +{ +#if 0 + S8 ret; + void *pMsg; + + pMsg = (void *)WLS_VA2PA(mtGetWlsHdl(), msg); + ret = WLS_put(mtGetWlsHdl(), (PTR)pMsg, msgLen, msgType, 0); + + if(ret != 0) + { + printf("\nFailure in sending message to PHY"); + RETVALUE(RFAILED); + } +#endif + + macToPhy(msgType, msgLen, msg); + + RETVALUE(ROK); +} + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/5gnrmac/rg_cl_util.c b/src/5gnrmac/rg_cl_util.c new file mode 100644 index 000000000..1820bdf4b --- /dev/null +++ b/src/5gnrmac/rg_cl_util.c @@ -0,0 +1,66 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/* This file contains all utility functions for MAC CL */ + +#include "stdio.h" +#include "envdep.h" +#include "gen.h" +#include "gen.x" +#include "cm_hash.h" +#include "cm_hash.x" +#include "lcl.h" +#include "rg_cl.h" + + /******************************************************************* + * + * @brief Fetch cellCb from Hash list + * + * @details + * + * Function : rgClUtlGetCellCb + * + * Functionality: + * - Searches for a cell entry at MAC CL + * + * @params[in] cell Id + * @return Pointer to cellCb - success + * NULLP - failure + * + * ****************************************************************/ +PUBLIC ClCellCb * rgClUtlGetCellCb +( + U16 cellId +) +{ + ClCellCb *cellCb; + + if(cellId >= MAX_NUM_CELL_SUPP) + { + printf("\n Invalid Cell Id [%d]. rgClUtlGetCellCb failed.", cellId); + RETVALUE(NULLP); + } + + cmHashListFind((CmHashListCp *)&clGlobalCp.cellCbLst, (U8 *)&cellId, sizeof(U16), 0, (PTR *)&cellCb); + + RETVALUE(cellCb); +} + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/5gnrmac/rg_env.h b/src/5gnrmac/rg_env.h index e015438fb..24ca5f4a3 100755 --- a/src/5gnrmac/rg_env.h +++ b/src/5gnrmac/rg_env.h @@ -152,10 +152,10 @@ /* per 1024 REs. */ #endif -EXTERN U32 wrSmDfltNumCells; +//EXTERN U32 wrSmDfltNumCells; #define RGSCH_MAX_UE_PER_DL_SF 32 #define RGSCH_MAX_RARNTI_PER_DL_SF 4 -#define RGSCH_INST_START wrSmDfltNumCells +#define RGSCH_INST_START 5 #define RGSCH_MAX_INST 2 /*MCELL changes*/ #define RG_MAX_INST 4 diff --git a/src/5gnrmac/rg_lmm.c b/src/5gnrmac/rg_lmm.c index e3dd82ed0..8e0c398f4 100755 --- a/src/5gnrmac/rg_lmm.c +++ b/src/5gnrmac/rg_lmm.c @@ -79,6 +79,9 @@ static int RLOG_MODULE_ID=4096; #endif #include "ss_rbuf.h" #include "ss_rbuf.x" + +#include "rg_cl.h" /* MAC CL defines */ + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ @@ -87,6 +90,8 @@ EXTERN Void rgGetSId ARGS((SystemId *s)); } #endif /* __cplusplus */ +/* Public variable declaration */ +ClCb clGlobalCp; /* forward references */ PRIVATE U16 rgLMMGenCfg ARGS(( @@ -202,6 +207,21 @@ Reason reason; /* reason */ SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULMAC,SS_RNG_TX); SAttachSRngBuf(SS_RNG_BUF_ULMAC_TO_ULRLC, SS_RBUF_ENT_ULRLC,SS_RNG_RX); #endif + + /* Initializing CL control block */ + clGlobalCp.region = region; + clGlobalCp.pool = 0; + clGlobalCp.clCfgDone = FALSE; + clGlobalCp.numOfCells = 0; + clGlobalCp.phyState = PHY_STATE_IDLE; + + if( cmHashListInit(&clGlobalCp.cellCbLst, MAX_NUM_CELL_SUPP, 0x0, FALSE, + CM_HASH_KEYTYPE_DEF, clGlobalCp.region, clGlobalCp.pool ) != ROK ) + { + printf("\n Cellcb hash list initialization failed for MAC CL"); + RETVALUE(RFAILED); + } + RETVALUE(ROK); } /* rgActvInit */ @@ -273,6 +293,8 @@ RgMngmt *cfg; /* config structure */ case STTFUSAP: reason = rgLMMSapCfg(inst,&cfg->t.cfg, cfg->hdr.elmId.elmnt); break; + case STCLCELL: + reason = RgClCellCfgReq(&cfg->t.cfg.s.cellCfg); default: ret = LCM_PRIM_NOK; reason = LCM_REASON_INVALID_ELMNT; diff --git a/src/5gnrmac/rg_rom.c b/src/5gnrmac/rg_rom.c index 30c0efa9f..06886fff9 100755 --- a/src/5gnrmac/rg_rom.c +++ b/src/5gnrmac/rg_rom.c @@ -304,7 +304,7 @@ RgRguDedDatReq *datReq; #ifdef CCPU_OPT boRpt.setMaxDlPrio= datReq->datReq[idx].datReqTb[idx1].lchData[idx2].boReport.staPduPrsnt; #endif - RgMacSchDedBoUpdt(&schPst, &boRpt); + //TODO: commented for compilation without SCH RgMacSchDedBoUpdt(&schPst, &boRpt); } } @@ -695,7 +695,7 @@ RgRguDedStaRsp *staRsp; boRpt.oldestSduArrTime = staRsp->boReport.oldestSduArrTime; rgGetPstToInst(&schPst,inst, cell->schInstMap.schInst); schPst.event = 0; - RgMacSchDedBoUpdt(&schPst, &boRpt); + //TODO: commented for compilation without SCH RgMacSchDedBoUpdt(&schPst, &boRpt); RETVALUE(ROK); } RLOG_ARG2(L_ERROR,DBG_CELLID,staRsp->cellId,"Invalid cell for CRNTI:%d LCID:%d ", @@ -726,7 +726,7 @@ S32 bo boRpt.bo = bo; rgGetPstToInst(&schPst,inst, cell->schInstMap.schInst); schPst.event = 0; - RgMacSchDedBoUpdtReq (&schPst,&boRpt); + //TODO: commented for compilation without SCH RgMacSchDedBoUpdtReq (&schPst,&boRpt); } RETVALUE(ROK); } @@ -904,7 +904,7 @@ RgErrInfo *err; boRpt.lcType = staRsp->lcType; boRpt.bo = staRsp->bo; rgGetPstToInst(&schPst,macInst, cell->schInstMap.schInst); - RgMacSchCmnBoUpdt(&schPst, &boRpt); + //TODO: commented for compilation without SCH RgMacSchCmnBoUpdt(&schPst, &boRpt); RETVALUE(ROK); } /* rgROMHndlCcchStaRsp */ @@ -986,7 +986,7 @@ RgErrInfo *err; } #endif rgGetPstToInst(&schPst,macInst, cell->schInstMap.schInst); - RgMacSchCmnBoUpdt(&schPst, &boRpt); + //TODO: commented for compilation without SCH RgMacSchCmnBoUpdt(&schPst, &boRpt); RETVALUE(ROK); } /* rgROMHndlBcchPcchStaRsp */ diff --git a/src/5gnrmac/rg_tom.c b/src/5gnrmac/rg_tom.c index 30fb50e70..af55609e3 100755 --- a/src/5gnrmac/rg_tom.c +++ b/src/5gnrmac/rg_tom.c @@ -1049,7 +1049,7 @@ PRIVATE S16 rgTOMUtlProcMsg(cellCb, ueCb, pdu, subframe, lcgBytes) MsgLen cpySz; #ifdef LTEMAC_SPS Pst schPst1; - RgInfSpsRelInfo relInfo; +// RgInfSpsRelInfo relInfo; #endif #ifdef LTE_L2_MEAS @@ -1308,11 +1308,14 @@ PRIVATE S16 rgTOMUtlProcMsg(cellCb, ueCb, pdu, subframe, lcgBytes) /* Indicate scheduler for explicit release */ cmMemset((U8*)&schPst1, (U8)0, sizeof(Pst)); rgGetPstToInst(&schPst1,inst, cellCb->schInstMap.schInst); + //TODO: commented for compilation without SCH +#if 0 relInfo.cellSapId = cellCb->schInstMap.cellSapId; relInfo.cRnti = ueCb->ueId; relInfo.isExplRel = TRUE; /* Release indicator is called now through the matrix in the function below */ - RgMacSchSpsRel( &schPst1, &relInfo ); + //TODO: commented for compilation without SCH RgMacSchSpsRel( &schPst1, &relInfo ); +#endif ueCb->ul.implRelCntr = 0; } } @@ -1667,7 +1670,7 @@ Inst inst; relInfo.cellSapId = cellCb->schInstMap.cellSapId; relInfo.cRnti = ueCb->ueId; relInfo.isExplRel = FALSE; - RgMacSchSpsRel(&schPst1, &relInfo); + //TODO: commented for compilation without SCH RgMacSchSpsRel(&schPst1, &relInfo); } } else @@ -1745,7 +1748,7 @@ Inst inst; rgGetPstToInst(&schPst, inst,cellCb->schInstMap.schInst); sfInfo->cellSapId = cellCb->schInstMap.cellSapId; - RgMacSchSfRecp(&schPst, sfInfo); + //TODO: commented for compilation without SCH RgMacSchSfRecp(&schPst, sfInfo); RETVALUE(ROK); } /* rgTOMDatInd */ diff --git a/src/5gnrmac/rg_utl.c b/src/5gnrmac/rg_utl.c index df681c668..709c0d2ba 100755 --- a/src/5gnrmac/rg_utl.c +++ b/src/5gnrmac/rg_utl.c @@ -1519,8 +1519,8 @@ Pst *pst; RgInfRlsRnti *rlsRnti; #endif { - Pst schPst; - RgInfUeDelInd ueDelInd; +// Pst schPst; +// RgInfUeDelInd ueDelInd; Inst macInst; RgCellCb *cell; #ifdef L2_OPTMZ @@ -1590,11 +1590,14 @@ TfuDelDatReqInfo delDatReq; if(FALSE == rlsRnti->isUeSCellDel) #endif { + //TODO: commented for compilation without SCH +#if 0 ueDelInd.cellSapId = cell->schInstMap.cellSapId; ueDelInd.cellId = rlsRnti->cellId; ueDelInd.rnti = rlsRnti->rnti; rgGetPstToInst(&schPst,macInst, cell->schInstMap.schInst); RgMacSchUeDel(&schPst, &ueDelInd); +#endif } RETVALUE(ROK); diff --git a/src/5gnrpdcp/pj.h b/src/5gnrpdcp/pj.h deleted file mode 100755 index fad0430c9..000000000 --- a/src/5gnrpdcp/pj.h +++ /dev/null @@ -1,1545 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: LTE PDCP file - - Type: C include file - - Desc: This file contain the hash definations for PDCP - - File: pj.h - - -*********************************************************************21*/ -/** @file pj.h -@brief PDCP Hash definitions -*/ - -#ifndef __PJH__ -#define __PJH__ - -#include "rl_interface.h" -#include "rl_common.h" -#include "rl_rlog.h" - - -#define PJLAYERNAME "LTE PDCP" /* Layer Name */ - -#define EPJxxx 1 -#define PJ_TMR_LEN 10 -#define PJ_MAX_KWUSAPS 2 /*!< Maximum number of KWU Saps. */ -#define PJ_MAX_UDXSAPS 1 -#define PJ_MAX_RB_PER_CELL 10 -#define PJ_MAX_SRB_PER_UE 3 -#define PJ_MAX_DRB_PER_UE 32 -#define PJ_MAX_LCH_PER_UE 12 -#define PJ_MAX_LCH_PER_CELL 6 -#define PJ_MAX_NUM_RB 24 -#define PJ_MAX_UE 0xffffffff -#define PJ_UE_LIST_BUCKET_SIZE 128 -#define PJ_CELL_LIST_BUCKET_SIZE 10 -#define PJ_MAX_RB 32 -#define PJ_DEF_SEQ_NUM 0 -#define PJ_ASYNC_WIN 16 - -#define PJ_MAX_CPJSAPS 1 /*!< Maximum number of CPJ Saps. */ -#define PJ_MAX_PJUSAPS 2 /*!< Maximum number of PJU Saps. */ - -#define PJ_LMM_GENCFG_DONE 2 /*!< PDCP LM general configuraiton done. */ - -#define PJ_PDCP_MODE_DL 1 -#define PJ_PDCP_MODE_UL 2 - -/* Direction defines */ -#define PJ_DIR_UL 1 /*!< Unlink direction */ -#define PJ_DIR_DL 2 /*!< Downlink direction */ -#define PJ_DIR_BOTH 3 /*!< Both Downlink and Unlink */ - -#define PJ_DBG_SUB_MASK DBGMASK_MI /* Use for sub-mask */ -#define PJ_DBGMASK_DETAIL (PJ_DBG_SUB_MASK << 0) /* Parameters, It will give - in depth info */ -#define PJ_DBGMASK_BRIEF (PJ_DBG_SUB_MASK << 1) /* Info, It will give info at - entry and exit places along - with certain state changes */ -#define PJ_DBGMASK_ERROR (PJ_DBG_SUB_MASK << 2) /* Error information */ -#define PJ_DBGMASK_FATAL (PJ_DBG_SUB_MASK << 3) /* FATAL errors like memory - resource failure etc., */ - - -#define PJ_DBG_MDL_MASK (PJ_DBG_SUB_MASK << 4) - -#define PJ_DBGMASK_DLM (PJ_DBG_MDL_MASK << 0) /* DL */ -#define PJ_DBGMASK_ULM (PJ_DBG_MDL_MASK << 1) /* UL */ -#define PJ_DBGMASK_UTL (PJ_DBG_MDL_MASK << 2) /* DBM, UTL, TMR */ -#define PJ_DBGMASK_CFG (PJ_DBG_MDL_MASK << 3) /* LMM and CFG */ -#define PJ_DBGMASK_LIB (PJ_DBG_MDL_MASK << 4) /* LIB - means software - or offboard hooks */ -#define PJ_DBGMASK_INF (PJ_DBG_MDL_MASK << 5) -#define PJ_DBGMASK_LMM (PJ_DBG_MDL_MASK << 6) -#define PJ_DBGMASK_DL (PJ_DBG_MDL_MASK << 7) -#define PJ_DBGMASK_UL (PJ_DBG_MDL_MASK << 8) - - -#ifdef TENB_T2K3K_SPECIFIC_CHANGES - -#define ICC_POOL_ZERO_SIZE 384 -#define ICC_POOL_ONE_SIZE 1920 -#define ICC_POOL_TWO_SIZE 3968 -#define ICC_POOL_THREE_SIZE 16256 -#endif /* TENB_T2K3K_SPECIFIC_CHANGES */ - -#ifdef DEBUGP -#define _pjPBuf pjCb.init.prntBuf - -#define PJ_PRNT(_cb,_prntbuf) \ -{ \ - sprintf _prntbuf; \ - SPrint(_cb->init.prntBuf); \ -} - -#else /* DEBUGP */ -#define PJ_PRNT_HLINE(_pMsg) -#define PJ_PRNT(_cb,_prntbuf) -#define PJ_PRNT_TSTAMP -#define PJ_PRNT_MBUF(_mBufPtr) -#define PJ_PRNT_MEMINFO -#endif /* DEBUGP */ - -#ifdef DEBUGP -#define PJ_PRNT_HLINE(_pMsg) \ -{ \ - sprintf(_pjPBuf, "[PDCP_LAYER: %s:%d]::", __FILE__, __LINE__); \ - SPrint(_pjPBuf); \ - sprintf(_pjPBuf, _pMsg); \ - SPrint(_pjPBuf); \ -} - -#define PJDBGP(_cb,_mask, _arg) \ -do \ -{ \ - if (!((_cb->init.dbgMask & _mask) ^ _mask)) \ - { \ - PJ_PRNT(_cb,_arg); \ - } \ -}while(0) -#else /* DEBUGP */ -#define PJ_PJ_PRNT_HLINE(_pMsg) -#define PJDBGP(_cb,_mask, _arg) -#endif /* DEBUGP */ - - - -/************************************************************************ - * SAP States - ************************************************************************/ - -/* ############################PDCP DEFINES ############################# */ - -#define PJ_SAP_NOT_CFG 0 /*!< SAP Not Configured */ -#define PJ_SAP_CFG 1 /*!< SAP Configured but not not bound */ -#define PJ_SAP_BND 2 /*!< SAP Bound */ -#define PJ_SAP_BINDING 3 /*!< SAP Bind initiated */ -#define PJ_SAP_UBND 4 /*!< SAP Unbind */ -#define PJ_MAX_SAP_BND_RETRY 3 /*!< Maximum SAP Bin Retries */ - -/* Times related */ -#define PJ_RB_MAX_TIMERS 1 /* No of timers */ -#define PJ_MAX_OBD_TMR 3 /* Number of OBD Timers */ -#define PJ_MAX_DISC_TMR 1 /* Number of Discard Timers */ -#define PJ_MAX_KWUSAP_TMR 1 /*!< Maximum number of KWU SAP Timers. */ -#define PJ_EVT_WAIT_BNDCFM 0x01 /* Bind confirm timer */ -#define PJ_MAX_UDXSAP_TMR 1 /*!< Maximum number of UDX SAP Timers. */ -#define PJ_EVT_DL_OBD_TMR 0x11 -#define PJ_EVT_UL_OBD_TMR 0x12 -#define PJ_EVT_OBD_TMR 0x13 -#define PJ_EVT_TMR_NONE 0x14 -#define PJ_EVT_OBD_WAIT_TMR 0x15 -#define PJ_EVT_UE_DEL_WAIT_TMR 0x16 -/* kw005.201 added support for L2 Measurement */ -#ifdef LTE_L2_MEAS -#define PJ_EVT_L2_TMR 0x20 -#define PJ_EVT_L2_MEAS_TMR 0x17 -#endif /* LTE_L2_MEAS */ -#define PJ_EVT_UL_REORD_TMR 0x21 -#define PJ_MAX_UL_REORD_TMRS 1 -#define PJ_EVT_WAIT_KWU_BNDCFM 0x18 -#define PJ_EVT_WAIT_UDX_BNDCFM 0x19 -#define PJ_DRB_12BIT_SN_HDR 0x8000 -#define PJ_DRB_18BIT_SN_HDR 0x800000 /*!<18 bit SN setting the hdr for DRB */ -#define PJ_ROHC_FEEDBACK_HDR 0x0010 -#define PJ_FIRST_BIT 0x80 - -#define PJ_DATA_PDU 0x01 -#define PJ_ROHC_FEEDBACK 0x02 -#define PJ_STA_PDU 0x03 - -#define PJ_INTG_KEY_LEN 16 -#define PJ_CIPHER_KEY_LEN 16 - -/*#define PJ_MAX_DAT_CFM 512 */ -/* changed from 512 to 1024 */ -#define PJ_MAX_DAT_CFM 1024 - -#define PJ_SDU_RECEIVED 0x01 -#define PJ_WAIT_FOR_INTPROT 0x02 -#define PJ_WAIT_FOR_CMP 0x03 -#define PJ_WAIT_FOR_CIPHER 0x04 -#define PJ_PDU_CONSTRUCTED 0x05 -#define PJ_PDU_SUBMITTED 0x06 -#define PJ_TX_ENT_TO_DEL 0x07 - -#define PJ_12_BIT_SN 12 -#define PJ_18_BIT_SN 18 - -#define PJ_TX_BUF_LEN 256 -#define PJ_MAX_SDU_SIZE 8188 - -#define PJ_SRB PJ_SRB_SAP -#define PJ_DRB PJ_DRB_SAP - -#define PJ_SRB_SAP 0 -#define PJ_DRB_SAP 1 - -#define PJ_DRB_UM 2 -#define PJ_DRB_AM 3 - -#define PJ_CFM_NOK 1 -#define PJ_CFM_OK 0 - -#define PJ_GET_PJCB(_inst) pjCb[_inst]; -#define PJ_BYTE_LEN 8 - - -#define PJ_SEC_DIR_UL 0 -#define PJ_SEC_DIR_DL 1 - -#define PJ_PDU_CONSTRUCT_FAILED 1 -#define PJ_HDR_COMP_FAILED 2 -#define PJ_INTG_PROT_FAILED 3 -#define PJ_CIPHER_FAILED 4 -#define PJ_CPY_MSG_FAILED 5 -#define PJ_REM_MSG_FAILED 6 -#define PJ_DISC_TMR_EXP 7 -#define PJ_OBD_TIMEOUT 8 - -#define PJ_CFG_RLC 1 -#define PJ_CFG_PDCP 2 -#define PJ_CFG_BOTH 3 -#define PJ_TRANS_ID_LST_BKT_SIZE 10 - -/* PJ_MS_KENB_LEN: Its the max lenght of the key for derivation of CK and IK */ -/* PJ_MS_STR_S_LEN: Length of "STR S" which is one of the inputs for CK and IK dervation */ -#define PJ_MS_KENB_LEN 32 -#define PJ_MS_STR_S_LEN 9 -#define PJ_NUM_BYTES_FRESH 4 /*= PJ_MAX_RB_PER_CELL) \ - { \ - _ret = RFAILED; \ - } \ - } \ - else \ - { \ - if ((_rbType != CM_LTE_SRB) && (_rbType != CM_LTE_DRB)) \ - { \ - _ret = RFAILED; \ - } \ - else if (_rbType == CM_LTE_SRB &&_rbId >= PJ_MAX_SRB_PER_UE) \ - { \ - _ret = RFAILED; \ - } \ - else if (_rbType == CM_LTE_DRB &&_rbId >= PJ_MAX_DRB_PER_UE) \ - { \ - _ret = RFAILED; \ - } \ - } \ -} - -#define PJ_DBM_FETCH_RBCB(_rbId, _rbType, _ueCb, _rbCb) \ -{ \ - PjRbCb **_rbCbLst; \ - _rbCbLst = (_rbType==CM_LTE_SRB)?_ueCb->srbCb:_ueCb->drbCb;\ - if (_rbCbLst[_rbId] != NULLP) \ - { \ - _rbCb = _rbCbLst[_rbId]; \ - } \ - else \ - { \ - _rbCb = NULLP; \ - } \ -} -#define PJ_DBM_FETCH_CELL_RBCB(_rbId, _rbCbLst, _rbCb) \ -{ \ - if (_rbCbLst[_rbId] != NULLP) \ - { \ - _rbCb = _rbCbLst[_rbId]; \ - } \ - else \ - { \ - _rbCb = NULLP; \ - } \ -} - -#define PJ_GET_UL_UDX_SAP(_cb) (&(_cb->u.ulCb->udxUlSap[0])) - -/* LMM Module Macros */ -#define PJ_LMM_RB_STS_INC(_cb) \ -{ \ - _cb->pjGenSts.numOfRb++; \ -} - -#define PJ_LMM_RB_STS_DEC(_cb) \ -{ \ - _cb->pjGenSts.numOfRb--; \ -} - - - - -/* kw005.201 moved the definition from kw_pj_dlm.c file */ -#define PJ_PJ_ASYNC_WIN 16 -#ifdef LTE_L2_MEAS -/* L2 Measurement index to be used in rbCb to store measData */ -#define PJ_L2MEAS_UL_LOSS 0 -#define PJ_L2CPU_PERCORE_STATS 1 -#define PJ_L2MEM_PERPOOL_STATS 2 -#define PJ_L2MEAS_ACT_UE 3 -#define PJ_L2MEAS_DL_DELAY 4 -#define PJ_L2MEAS_DL_DISC 5 -#define PJ_MAX_L2MEAS_INRB 6 -#define PJ_L2MEAS_UU_LOSS 7 -#define PJ_L2MEAS_DL_IP 8 -#define PJ_L2MEAS_UL_IP 9 - -#define PJ_L2_MAX_TIMERS 1 - -#define PJ_MAX_L2MEAS_EVT 10 -#define PJ_INIT_RB_L2CB(_measVal, _measCb, _pjRbCb) \ -{ \ - cmLListAdd2Tail(&_measCb->rbList, &_pjRbCb->rbL2Cb.listNode[_measVal]);\ - _pjRbCb->rbL2Cb.l2Sts[_measVal] = &_measCb->measData[_pjRbCb->qci]; \ -} - -#define PJ_RMV_RB_FRM_L2LIST(_measVal, _measCb, _pjRbCb) \ -cmLListDelFrm(&_measCb->rbList, \ - &_pjRbCb->rbL2Cb.listNode[_measVal]); - -#define PJ_UPD_L2_DLDELAY_STS(_pjRbCb, _val) \ -{ \ - _pjRbCb->rbL2Cb.l2Sts[PJ_L2MEAS_DL_DELAY]->dlDelay.numPkts++; \ - _pjRbCb->rbL2Cb.l2Sts[PJ_L2MEAS_DL_DELAY]->dlDelay.val += _val; \ -} -#define PJ_UPD_L2_DLDISC_PKT_STS(_pjCb, _pjRbCb) \ -{ \ - if((_pjRbCb->rbType == PJ_DRB) && \ - ((_pjCb)->u.dlCb->pjL2Cb.measOn[_pjRbCb->qci] & LPJ_L2MEAS_DL_DISC)) \ - { \ - _pjRbCb->rbL2Cb.l2Sts[PJ_L2MEAS_DL_DISC]->dlDisc.numPkts++; \ - } \ -} - -#define PJ_UPD_L2_DLDISC_STS(_pjCb, _pjRbCb) \ -{ \ - if((_pjRbCb->rbType == PJ_DRB) && \ - ((_pjCb)->u.dlCb->pjL2Cb.measOn[_pjRbCb->qci] & LPJ_L2MEAS_DL_DISC)) \ - { \ - _pjRbCb->rbL2Cb.l2Sts[PJ_L2MEAS_DL_DISC]->dlDisc.val++; \ - } \ -} - -#define PJ_SEND_SAPID_ALARM(_cb,_sapId, _evnt, _cause) \ -{ \ - pjLmmSendAlarm(_cb,LCM_CATEGORY_INTERFACE, _evnt, _cause, _sapId, 0, 0); \ -} -#define PJ_SEND_UEID_ALARM(_ueId, _qci, _evnt, _cause) \ -{ \ - pjLmmSendAlarm(LCM_CATEGORY_INTERFACE, _evnt, _cause, 0, _ueId, _qci); \ -} - -#define PJ_UPD_L2_DECR_PER_QCI_RB_COUNT(_pjCb, _pjRbCb) \ -{ \ - if(((_pjRbCb)->rbType == CM_LTE_DRB) && \ - ((_pjCb)->u.dlCb->pjL2Cb.measOn[_pjRbCb->qci] & LPJ_L2MEAS_DL_DISC)) \ - { \ - U32 idx1; \ - for (idx1 = 0; idx1 < LPJ_MAX_L2MEAS; idx1++) \ - { \ - if(_pjCb->u.dlCb->pjL2Cb.pjL2EvtCb[idx1].measCb.measType & LPJ_L2MEAS_DL_DISC) \ - { \ - if(_pjCb->u.dlCb->pjL2Cb.pjL2EvtCb[idx1].measCb.measData[(_pjRbCb)->qci].totDrbsPerQci > 0) \ - { \ - _pjCb->u.dlCb->pjL2Cb.pjL2EvtCb[idx1].measCb.measData[(_pjRbCb)->qci].totDrbsPerQci--; \ - if (_pjCb->u.dlCb->pjL2Cb.pjL2EvtCb[idx1].measCb.measData[(_pjRbCb)->qci].totDrbsPerQci == 0) \ - { \ - _pjCb->u.dlCb->pjL2Cb.pjL2EvtCb[idx1].measCb.qci[(_pjRbCb)->qci] = 0; \ - cmMemset((U8 *)&_pjCb->u.dlCb->pjL2Cb.pjL2EvtCb[idx1].measCb.measData[(_pjRbCb)->qci], 0, \ - sizeof(_pjCb->u.dlCb->pjL2Cb.pjL2EvtCb[idx1].measCb.measData[(_pjRbCb)->qci])); \ - } \ - } \ - } \ - } \ - } \ -} - -#define PJ_GET_SN_DIFF(_expSn, _rcvdSn, _snLen, _diff) \ -{ \ - if(_expSn > _rcvdSn) \ - { \ - _diff = _rcvdSn + (1 << _snLen) - _expSn; \ - } \ - else \ - { \ - _diff = _rcvdSn - _expSn; \ - } \ -} - -#define PJ_UPD_L2_ULLOSS_CNTRS(_cb,_count, _pjRbCb) \ -{ \ - PjSn _sn; \ - U32 _hfn; \ - PJ_GET_SN_HFN(_count, _pjRbCb->snLen, _sn, _hfn) \ - if(_cb->u.ulCb->pjL2Cb.measOn[_pjRbCb->qci] & LPJ_L2MEAS_UL_LOSS) \ - { \ - U32 _diff; \ - PJ_GET_SN_DIFF(_pjRbCb->ulCb.nxtSubSn, _sn, _pjRbCb->snLen, _diff) \ - _pjRbCb->rbL2Cb.l2Sts[PJ_L2MEAS_UL_LOSS]->ulLoss.numPkts += _diff + 1; \ - _pjRbCb->rbL2Cb.l2Sts[PJ_L2MEAS_UL_LOSS]->ulLoss.val += _diff; \ - } \ - _pjRbCb->ulCb.nxtSubSn = (_sn + 1) % (1 << _pjRbCb->snLen); \ -} - -#else /* LTE_L2_MEAS */ -#define PJ_UPD_L2_DLDELAY_STS(_pjRbCb, _val) -#define PJ_UPD_L2_ULLOSS_PKT_STS(_pjRbCb) -#define PJ_UPD_L2_ULLOSS_STS(_pjRbCb) -#define PJ_UPD_L2_DLDISC_PKT_STS(_pjCb,_pjRbCb) -#define PJ_UPD_L2_DLDISC_STS(_pjCb,_pjRbCb) -#define PJ_SEND_SAPID_ALARM(_cb,_sapId, _evnt, _cause) -#define PJ_SEND_UEID_ALARM(_ueId, _qci, _evnt, _cause) -#define PJ_UPD_L2_DECR_PER_QCI_RB_COUNT(_pjCb, _pjRbCb) -#define PJ_UPD_L2_ULLOSS_CNTRS(_cb, _count, _pjRbCb) -#endif /* LTE_L2_MEAS */ -/* kw005.201 added support for L2 Measurement */ -#ifdef LTE_L2_MEAS -#if (ERRCLASS & ERRCLS_INT_PAR) -#define PJ_VALDATE_SAP(_cb, _chkSpId, _sap, _ret) \ -{ \ - if (_chkSpId != _sap->spId) \ - { \ - RLOG0(L_ERROR,"Sap Id Validation Failed."); \ - _ret = RFAILED; \ - } \ - /* SAP state validation */ \ - if(_sap->state != PJ_SAP_BND) \ - { \ - RLOG0(L_ERROR,"Sap State Invalid."); \ - pjLmmSendAlarm(_cb, LCM_CATEGORY_INTERFACE, LCM_EVENT_UI_INV_EVT, \ - LCM_CAUSE_INV_STATE, 0, 0, 0); \ - _ret = RFAILED; \ - } \ -} -#else /* ERRCLASS & ERRCLS_INT_PAR */ -#define PJ_VALDATE_SAP(_cb, _chkSpId, _sap, _ret) \ -{ \ - /* SAP state validation */ \ - if(_sap->state != PJ_SAP_BND) \ - { \ - RLOG0(L_ERROR,"Sap State Invalid."); \ - pjLmmSendAlarm(_cb, LCM_CATEGORY_INTERFACE, LCM_EVENT_UI_INV_EVT, \ - LCM_CAUSE_INV_STATE, 0, 0, 0); \ - _ret = RFAILED; \ - } \ -} -#endif /* ERRCLASS & ERRCLS_INT_PAR */ -#else /* LTE_L2_MEAS */ -#if (ERRCLASS & ERRCLS_INT_PAR) -#define PJ_VALDATE_SAP(_cb, _chkSpId, _sap, _ret) \ -{ \ - if (_chkSpId != _sap->spId) \ - { \ - RLOG0(L_ERROR,"Sap Id Validation Failed."); \ - _ret = RFAILED; \ - } \ - /* SAP state validation */ \ - if(_sap->state != PJ_SAP_BND) \ - { \ - RLOG0(L_ERROR,"Sap State Invalid."); \ - pjLmmSendAlarm(_cb, LCM_CATEGORY_INTERFACE, LCM_EVENT_UI_INV_EVT, \ - LCM_CAUSE_INV_STATE, 0, 0); \ - _ret = RFAILED; \ - } \ -} -#else /* ERRCLASS & ERRCLS_INT_PAR */ -#define PJ_VALDATE_SAP(_cb, _chkSpId, _sap, _ret) \ -{ \ - /* SAP state validation */ \ - if(_sap->state != PJ_SAP_BND) \ - { \ - RLOG0(L_ERROR,"Sap State Invalid."); \ - pjLmmSendAlarm(_cb, LCM_CATEGORY_INTERFACE, LCM_EVENT_UI_INV_EVT, \ - LCM_CAUSE_INV_STATE, 0, 0); \ - _ret = RFAILED; \ - } \ -} -#endif /* ERRCLASS & ERRCLS_INT_PAR */ -#endif/* LTE_L2_MEAS */ - -#ifdef TENB_DPDK_BUF -#define PJ_FREE_FLAT_BUF(_cb, _buf) \ -{ \ - if(((_buf)->len != 0) && ((_buf)->startAddr != NULLP)) \ - { \ - (Void) SPutSBufDpdk((Data *) (_buf)->startAddr); \ - } \ -} -#else /* TENB_DPDK_BUF */ -#ifdef INTEL_WLS - -#define PJ_FREE_FLAT_BUF(_cb, _buf) \ -{ \ - if(((_buf)->len != 0) && ((_buf)->startAddr != NULLP)) \ - { \ - (Void) SPutSBufWls(_cb->init.region, _cb->init.pool, \ - (Data *) (_buf)->startAddr, (Size)(2048)); \ - }\ -} -#else -#ifdef FLAT_BUFFER_OPT -#define PJ_FREE_FLAT_BUF(_cb, _buf) \ -{ \ - if(((_buf)->len != 0) && ((_buf)->startAddr != NULLP))\ - {\ - (Void) SPutStaticBuffer(_cb->init.region, _cb->init.pool, \ - (Data *) (_buf)->startAddr, (Size)((_buf)->ptr - (_buf)->startAddr + (_buf)->len) , 0); \ - }\ -} -#endif /* FLAT_BUFFER_OPT */ -#endif /* INTEL_WLS */ -#endif /* TENB_DPDK_BUF */ - - -#define PJ_FREE_SHRABL_BUF(_cb,_buf, _size) \ -{ \ - if (_buf != NULLP) \ - { \ - (Void) SPutStaticBuffer(_cb->init.region, _cb->init.pool, \ - (Data *) _buf, (Size) _size, 0); \ - _buf = NULLP; \ - } \ -} - -#define PJ_ALLOC_SHRABL_BUF(_cb,_buf, _size) \ -{ \ - if (SGetStaticBuffer(_cb->init.region, _cb->init.pool, (Data **)&_buf, \ - (Size) _size, 0) == ROK) \ - { \ - cmMemset((U8 *)(_buf), 0, _size); \ - } \ - else \ - { \ - (_buf) = NULLP; \ - } \ -} - -#define PJ_ALLOC_SHRABL_BUF_WM(_cb,_buf, _size) \ -{ \ - SGetStaticBuffer(_cb->init.region, _cb->init.pool, (Data **)&_buf, \ - (Size) _size, 0); \ -} - -#ifndef XEON_SPECIFIC_CHANGES -#define PJ_FREE_SHRABL_BUF_PST(_region, _pool, _buf, _size) \ -{ \ - if (_buf != NULLP) \ - { \ - (Void) SPutStaticBuffer(_region, _pool, \ - (Data *) _buf, (Size) _size, 0); \ - _buf = NULLP; \ - } \ -} -#else -#define PJ_FREE_SHRABL_BUF_PST(_region, _pool, _buf, _size) \ -{ \ - if (_buf != NULLP) \ - { \ - (Void) SPutSBuf(_region, _pool, \ - (Data *) _buf, (Size) _size); \ - _buf = NULLP; \ - } \ -} -#endif - -#define PJ_ALLOC_SHRABL_BUF_PST(_region, _pool, _buf, _size) \ -{ \ - SGetStaticBuffer(_region, _pool, (Data **)&_buf, \ - (Size) _size, 0); \ -} - -#ifndef XEON_SPECIFIC_CHANGES -#define PJ_ALLOC_BUF_SHRABL(_pst, _buf, _size, _ret) \ -{ \ - if(SGetStaticBuffer(_pst.region, _pst.pool, (Data **)&_buf, \ - (Size) _size, 0) != ROK) \ - { \ - _ret = RFAILED; \ - } \ -} -#else -#define PJ_ALLOC_BUF_SHRABL(_pst, _buf, _size, _ret) \ -{ \ - if(SGetSBuf(_pst.region, _pst.pool, (Data **)&_buf, \ - (Size) _size) != ROK) \ - { \ - _ret = RFAILED; \ - } \ -} -#endif - -#define PJ_PJDBM_CREATE_RBCB(_rbCb,_rbCbLst, _rbId, _rbType) \ -{ \ - /* Allocate memory for rbCb */ \ - PJ_ALLOC(_rbCb, sizeof(RbCb)); \ - \ - if ( rbCb != NULLP) \ - { \ - _rbCbLst[_rbId] = (_rbCb); \ - _rbCb->kwRbCb.rlcId.rbId = _rbId; \ - } \ -} - -/* Macros for configuration module */ -#define PJ_CFG_FILL_CFG_CFM(_entCfm, _rbId, _rbType, _status, _reason) \ -{ \ - _entCfm->rbId = _rbId; \ - _entCfm->rbType = _rbType; \ - _entCfm->status = _status; \ - _entCfm->reason = _reason; \ -} - -#define PJ_CFG_FILL_SECCFG_CFM(_entCfm, _ueId, _cellId, _transId, _status, _reason) \ -{ \ - _entCfm->ueId = _ueId; \ - _entCfm->cellId = _cellId; \ - _entCfm->transId = _transId; \ - _entCfm->status = _status; \ - _entCfm->reason = _reason; \ -} - -#define PJ_CFG_FILL_SDUSTA_CFM(_entCfm, _ueId, _cellId, _transId, _status, _reason) \ -{ \ - _entCfm->ueId = _ueId; \ - _entCfm->cellId = _cellId; \ - _entCfm->transId = _transId; \ - _entCfm->status = _status; \ - _entCfm->reason = _reason; \ -} - -#define PJ_CFG_FILL_REESTREQ_CFM(_entCfm, _ueId, _cellId, _transId, _status) \ -{ \ - _entCfm->ueId = _ueId; \ - _entCfm->cellId = _cellId; \ - _entCfm->transId = _transId; \ - _entCfm->status = _status; \ -} -/* -#define PJ_UPD_COUNT(_pjRbCb, _sn, _txHfn, _count) \ -{ \ - _count = _txHfn << (_pjRbCb->snLen); \ - _count |= _sn; \ -} */ -#define PJ_ADD_PST_MSG(_pdu, _hdr, _size, _ret) \ -{ \ - Data _liByte; \ - S16 _bytes; \ - _bytes = _size - 1; \ - while (_bytes >= 0 ) \ - { \ - _liByte = (U8) (_hdr >> (8*_bytes)); \ - _ret = SAddPstMsg((Data )_liByte, _pdu); \ - if ( _ret != ROK ) \ - { \ - break; \ - } \ - _bytes--; \ - } \ -} - -#define PJ_RESET_ALL_VAR(_pjRbCb) \ -{ \ - _pjRbCb->dlCb.cfmExp = 0; \ - _pjRbCb->dlCb.count = 0; \ - _pjRbCb->dlCb.txNext = 0; \ -} - -#define PJ_ALLOC(_cb, _buf, _size) \ -{ \ - if (SGetSBuf(_cb->init.region, _cb->init.pool, (Data **)&_buf,\ - (Size) _size) == ROK) \ - { \ - cmMemset((U8 *)(_buf), 0, _size); \ - } \ - else \ - { \ - (_buf) = NULLP; \ - } \ -} - -#define PJ_ALLOC_WC(_cb, _buf, _size)\ -{ \ - if (SGetSBuf(_cb->init.region, _cb->init.pool, (Data **)&_buf,\ - (Size) _size) != ROK) \ - { \ - (_buf) = NULLP; \ - } \ -} - - -#define PJ_FREE_BUF(_buf) \ -{ \ - if (_buf != NULLP) \ - { \ - SPutMsg(_buf); \ - } \ - _buf = NULLP; \ -} - -#define PJ_FREE(_cb, _buf, _size) \ -{ \ - if (_buf != NULLP) \ - { \ - (Void) SPutSBuf(_cb->init.region, _cb->init.pool, \ - (Data *) _buf, (Size) _size); \ - _buf = NULLP; \ - } \ -} - -#define PJ_PST_FREE(_region, _pool, _buf, _size) \ -{ \ - if (_buf != NULLP) \ - { \ - (Void) SPutSBuf(_region, _pool, \ - (Data *) _buf, (Size) _size); \ - _buf = NULLP; \ - } \ -} - -#define PJ_MEM_CPY(_dst, _src, _size) \ -{ \ - cmMemcpy((U8*)_dst, (U8 *)_src, _size); \ -} - -#define PJ_DLM_UPD_VAR(_pjRbCb, _count) \ -{ \ - PjDlCb *_dlCb; \ - \ - _dlCb = &_pjRbCb->dlCb; \ - _count = _dlCb->txNext; \ - if ( (++_dlCb->txNext) == 0xFFFFFFFF) \ - { \ - _dlCb->txNext = 0; \ - } \ -} -#define PJ_DLM_GET_SN(_pjRbCb, _count,_sn) \ -{\ - _sn = (_count % ( _pjRbCb->maxTxSn)); \ -} - - -#define PJ_FILL_CFM_OK(_cb,_pjRbCb, _fms, _datCfm) \ -{ \ - U32 _startCount = _pjRbCb->dlCb.cfmExp; \ - U32 _stopCount = _pjRbCb->dlCb.cfmExp; \ - PjTxEnt *_ent; \ - _ent = (PjTxEnt *)pjDbmGetTxEntSn(_cb, &(_pjRbCb->dlCb.txBuf), _fms); \ - if ( _ent != NULLP ) \ - { \ - _stopCount = _ent->count; \ - _pjRbCb->dlCb.cfmExp = _ent->count; \ - _pjRbCb->dlCb.nxtToSub = _ent->count; \ - } \ - while ( _startCount < _stopCount ) \ - { \ - _ent = (PjTxEnt *)pjDbmGetTxEnt(_cb, &(_pjRbCb->dlCb.txBuf), _startCount);\ - if ( _ent != NULLP ) \ - { \ - if ( _pjRbCb->dlCb.cfmReqd) \ - { \ - _datCfm->cfmSta[_datCfm->numSdus].sduId = _ent->sduId;\ - _datCfm->cfmSta[_datCfm->numSdus].status = PJ_CFM_OK;\ - _datCfm->numSdus++; \ - } \ - pjDbmDelTxEnt(_cb, &(pjRbCb->dlCb.txBuf), _ent->count);\ - } \ - _startCount++; \ - } \ -} - -#define PJ_UPD_CFM_EXP(_cb,_dlCb) \ -{ \ - U32 _curCount = _dlCb->count; \ - U32 _count = _dlCb->cfmExp; \ - PjTxEnt *_txEnt = NULLP; \ - while ( _count <= _curCount ) \ - { \ - _txEnt = (PjTxEnt *)pjDbmGetTxEnt(_cb,&(_dlCb->txBuf), _count);\ - if ( _txEnt != NULLP ) \ - { \ - break; \ - } \ - _count++; \ - } \ - _dlCb->cfmExp = _count; \ -} - -#define PJ_UPD_DL_VAR(_cb, _pjRbCb, _curCnt) \ -{ \ - U32 _count = _curCnt + 1; \ - if ( _pjRbCb->dlCb.nxtToSub == _curCnt ) \ - { \ - _pjRbCb->dlCb.nxtToSub = _count; \ - } \ - if ( _pjRbCb->dlCb.cfmExp == _curCnt ) \ - { \ - _pjRbCb->dlCb.cfmExp = _count; \ - } \ -} - -#define PJ_CREATE_NEW_LIST(_cb,_pjRbCb, _tmpTxBuf, _ret) \ -{ \ - _tmpTxBuf.datQ = _pjRbCb->dlCb.txBuf.datQ; \ - _tmpTxBuf.numEntries = pjRbCb->dlCb.txBuf.numEntries; \ - _tmpTxBuf.numBins = pjRbCb->dlCb.txBuf.numBins; \ - _tmpTxBuf.sduSubmitQ = pjRbCb->dlCb.txBuf.sduSubmitQ; \ - pjDbmDlBufInit(_cb,&pjRbCb->dlCb.txBuf,_cb->pjGenCfg.nmbDlBins);\ - if ( _pjRbCb->dlCb.txBuf.datQ == NULLP ) \ - { \ - RLOG0(L_ERROR,"PJ_CREATE_NEW_LIST: PJ_ALLOC Failed."); \ - _ret = RFAILED; \ - } \ -} - -#define PJ_SND_ROHC_FDB(_cb,_pjRbCb, _rohcFdbPdu, _ret) \ -{ \ - Data _hdr = 0; \ - U32 _count = 0; \ - _hdr |= PJ_ROHC_FEEDBACK_HDR; \ - _ret = SAddPreMsg((Data) _hdr, _rohcFdbPdu); \ - if ( _ret != ROK ) \ - { \ - RLOG0(L_ERROR,"PJ_SND__ROHC_FDB: SAddPreMsg failed for pdu ");\ - PJ_FREE_BUF(_rohcFdbPdu); \ - _ret = RFAILED; \ - } \ - if ( _pjRbCb->mode == PJ_DRB_UM ) \ - { \ - _count = _pjRbCb->dlCb.nxtToSub - 1; \ - } \ - else \ - { \ - _count = _pjRbCb->dlCb.cfmExp - 1; \ - } \ - if ( _ret == ROK ) \ - { \ - pjDlmSendDatReq(_cb, _pjRbCb, _count, _rohcFdbPdu); \ - } \ -} - -#define PJ_MAX_HASH_BINS 255 - -/* Defines used in gp_pj_dbm.c */ -#define PJ_HASH_FN(_buf, _cnt) (_cnt % PJ_MAX_HASH_BINS) - -/* Defines used in gp_pj_ulm.c */ -#define MAX_BMAP_SIZE 2048 -#define PJ_WINSIZE(_snLen) (1 << (_snLen - 1)) -#define PJ_MAX_HFN(_snLen) ((1 << (32 - _snLen)) - 1) -#define PJ_U16_BIT_SIZE 16 -#define PJ_BYTE_SIZE 8 -//#define PJ_SRB_SN_LEN 12 -#define PJ_SRB_SN_LEN 12 -#define PJ_DRBAM_SN_LEN 12 -#define PJ_TYPE_DRB_DATA 0x80 -#define PJ_TYPE_STATUS_REPORT 0x00 -#define PJ_TYPE_ROHC_FEEDBACK 0x01 -#define PJ_PDU_BIT_MASK 0x70 -#define PJ_12_BIT_SN_MSB_MASK 0x0F -#define PJ_18_BIT_SN_MSB_MASK 0x03 -#define PJ_CPDU_RES_VAL_MASK 0x0F -#define PJ_MACI_LEN 4 - -#define PJ_RDY_TO_DCIPHER 1 -#define PJ_SENT_TO_DCIPHER 2 -#define PJ_RDY_TO_INTVER 3 -#define PJ_SENT_TO_INTVER 4 -#define PJ_RDY_TO_DCOMP 5 -#define PJ_SENT_TO_DCOMP 6 -#define PJ_RDY_TO_SUBMIT 7 -#define PJ_RX_ENT_TO_DEL 8 -#define PJ_RX_INTVER_FAIL 9 - -#define PJ_STATE_NORMAL 1 -#define PJ_STATE_REEST 2 -#define PJ_STATE_REEST_HO 3 -#define PJ_STATE_HO 4 -#define PJ_TMR_ULM_OBD 10 - -/* Defines used in gp_pj_utl.c */ -#define PJ_LIB_COMP_BIT_MASK 0x00000001 -#define PJ_LIB_INT_BIT_MASK 0x00000002 -#define PJ_LIB_CP_CIP_BIT_MASK 0x00000004 -#define PJ_LIB_UP_CIP_BIT_MASK 0x00000008 - -#define PJ_MAX_SDU_IN_DAT_FWD_IND 5 -/* Defines used for multi cfg confirms */ -#define PJ_MAX_ASYNC_CFM 2 - -#define PJ_SEC_ASYNC_CFM 0x01 -#define PJ_CFG_ASYNC_CFM 0x02 -#define PJ_CFG_REEST_ASYNC_CFM 0x04 -#define PJ_CFG_UEDEL_ASYNC_CFM 0x08 -#define PJ_REEST_ASYNC_CFM 0x10 - -#define PJ_SEC_INIT_CFM 1 -#define PJ_CMP_INIT_CFM 2 - -#define PJ_GET_MEM_REGION(_cb) (_cb->init.region) - -#define PJ_GET_MEM_POOL(_cb) (_cb->init.pool) - -#define PJ_GET_MEM_POOL_ADDRESS(_cb) (&_cb->init.pool) - -#define PJ_GET_DBG_MASK(_cb) (_cb->init.dbgMask) - -/* Memset to value */ -#define PJ_MEM_SET(_arg, _val, _size) \ -{ \ - cmMemset((U8 *)_arg, (U8)_val, _size); \ -} - -/* Set the unsolictated Status flag */ -#define PJ_SET_USTA_FLAG(_cb, _value) \ -{ \ - _cb->init.usta = _value; \ -} - -#define PJ_DATA_FWD_PKT 1 -#define PJ_DATA_NRM_PKT 2 - -#define PJ_CHK_RESTART_OBD_TIMER(_cb,_ueCb, _cfgTxId) \ -{ \ - U16 _idx; \ - if(_ueCb->libInfo.crntTmrTxId == _cfgTxId) \ - { \ - pjStopTmr(_cb,(PTR)_ueCb, PJ_EVT_OBD_WAIT_TMR); \ - } \ - \ - if(pjChkTmr(_cb,(PTR)_ueCb, PJ_EVT_OBD_WAIT_TMR) == FALSE) \ - { \ - for(_idx = 0; _idx < (PJ_MAX_ASYNC_CFM - 1) ; _idx++) \ - { \ - _ueCb->libInfo.crntTmrTxId = \ - (U16)((_ueCb->libInfo.crntTmrTxId + 1) % PJ_MAX_ASYNC_CFM); \ - if((_ueCb->libInfo.asyncCfm[_ueCb->libInfo.crntTmrTxId] != NULLP) && \ - (_ueCb->libInfo.asyncCfm[_ueCb->libInfo.crntTmrTxId]->startTmr \ - == TRUE)) \ - { \ - pjStartTmr(_cb,(PTR)_ueCb, PJ_EVT_OBD_WAIT_TMR); \ - break; \ - } \ - } \ - } \ -} \ - -#define PJ_CLEAN_AND_UPD_ASYNCINFO(_cb,_ueCb, _txIdx) \ -{ \ - PJ_FREE(_cb,_ueCb->libInfo.asyncCfm[_txIdx], sizeof(PjAsyncCfm)); \ - _ueCb->libInfo.asyncCfm[_txIdx]=NULLP; \ - if(_ueCb->libInfo.nxtAvlbTxId == PJ_MAX_ASYNC_CFM) \ - { \ - _ueCb->libInfo.nxtAvlbTxId = _txIdx; \ - } \ -} \ - -#define PJ_FILL_TIMEOUT_CFG_CFM_INFO(_cb,_cfgCfm, _asyncCfm) \ -{ \ - U16 _idx; \ - PJ_ALLOC(_cb,_cfgCfm, sizeof(CpjCfgCfmInfo)); \ - if (_cfgCfm != NULLP) \ - { \ - for ( _idx = 0; _idx < _asyncCfm->numEnt ; _idx++) \ - { \ - if ( _asyncCfm->cmpInitBitMask & \ - (1 << (_asyncCfm->cfmEnt[_idx].rbId - 1))) \ - { \ - _cfgCfm->cfmEnt[_idx].status = CPJ_CFG_CFM_NOK; \ - _cfgCfm->cfmEnt[_idx].reason = CPJ_CFG_REAS_OBD_TIMEOUT; \ - } \ - else \ - { \ - _cfgCfm->cfmEnt[_idx].status = _asyncCfm->cfmEnt[_idx].status;\ - _cfgCfm->cfmEnt[_idx].reason = _asyncCfm->cfmEnt[_idx].reason;\ - } \ - _cfgCfm->cfmEnt[_idx].rbId = _asyncCfm->cfmEnt[_idx].rbId; \ - _cfgCfm->cfmEnt[_idx].rbType = _asyncCfm->cfmEnt[_idx].rbType; \ - } \ - _cfgCfm->ueId = _asyncCfm->ueId; \ - _cfgCfm->cellId = _asyncCfm->cellId; \ - _cfgCfm->transId = _asyncCfm->transId; \ - _cfgCfm->numEnt = _asyncCfm->numEnt; \ - } \ -} \ - -#ifdef PJ_SEC_ASYNC -/* In the case when all the elements in the reception buffer have already - * been sent to the dcomp unit or sent up, our nxtSubDcomp will be pointing to - * NEXT_PDCP_RX_SN. So if there is a jump, this has to be updated accordingly */ -#define PJ_ULM_UPD_NXT2DCOMP(_ulCb, _snLen, _rcvdCount, _oldRxCnt) \ -{ \ - if(_oldRxCnt == _ulCb->nxtSubDeCmp) \ - { \ - _ulCb->nxtSubCnt = _rcvdCount; \ - } \ -} -#else /* !PJ_SEC_ASYNC */ -#define PJ_ULM_UPD_NXT2DCOMP(_ulCb, _snLen, _sn, _oldRxCnt) -#endif /* PJ_SEC_ASYNC */ - -#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) -/* There can be a case where the first PDU that you receive * - * does not match with the NEXT_PDCP_RX_SN. If nxtSubCnt is also - * pointing to NETX_PDCP_RX_SN, it has to be updated. */ -#define PJ_ULM_UPD_NXT2SUB(_ulCb, _cnt) \ -{ \ - if(_ulCb->recBuf.numEntries == 0) \ - { \ - _ulCb->nxtSubCnt = _cnt; \ - _ulCb->nxtSubDeCmp = _cnt; \ - } \ -} -#define PJ_INC_OBD_COUNT(_pjRbCb, _count) \ -{ \ - if(_pjRbCb->state == PJ_STATE_REEST || \ - _pjRbCb->state == PJ_STATE_REEST_HO) \ - { \ - _pjRbCb->ulCb.obdCnt ++; \ - } \ -} - -/* Notes: This will be called only for DRBs */ -#define PJ_DEC_OBD_COUNT(_cb, _pjRbCb, _count) \ -{ \ - if(_pjRbCb->state == PJ_STATE_REEST || \ - _pjRbCb->state == PJ_STATE_REEST_HO) \ - { \ - if((_count >= _pjRbCb->ulCb.firstReEstCnt)&& \ - (_pjRbCb->mode = PJ_DRB_AM)) \ - { \ - _pjRbCb->ulCb.obdCnt --; \ - } \ - } \ -} -#else /* (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) */ -/* Dummy defines */ -#define PJ_ULM_UPD_NXT2SUB(_ulCb, _cnt) -#define PJ_INC_OBD_COUNT(_pjRbCb, _count) -#define PJ_DEC_OBD_COUNT(_cb,_pjRbCb, _count) -#endif /* (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) */ - - -#define PJ_INC_SN(_sn, _snLen) ((++_sn) % (1 << _snLen)) \ - -#define PJ_GET_SN_HFN(_count, _snLen, _sn, _hfn) \ -{ \ - _sn = (_count % (1 << _snLen)); \ - _hfn = (_count >> _snLen); \ -} \ - -#define PJ_GET_HFN(_count,_snLen,_hfn)\ -{\ - _hfn = (_count >> _snLen);\ -} -#define PJ_GET_SN(_count, _snLen, _sn) (_sn = _count % (1 << _snLen)); - -#define PJ_ULM_REEST_DRB_AM(_pjRbCb) \ -{ \ - _pjRbCb->frstReEstCnt = _pjRbCb->rxDeliv; \ - _pjRbCb->obdCnt = 0; \ - \ -} - - -/* kw005.201,replaced macro with function */ -#define PJ_SND_PJU_STA_IND(_cb,_pjRbCb, _rxEnt) \ -{ \ - CmLtePdcpId _pdcpId; \ - Buffer *_mBuf = NULLP; \ - PjuStaIndInfo _staInd; \ - PjPjuSapCb *_pjuSap; \ - \ - if (_pjRbCb->rbType == PJ_SRB) \ - _pjuSap = &(_cb->u.ulCb->pjuSap[PJ_SRB_SAP]); \ - else \ - _pjuSap = &(_cb->u.ulCb->pjuSap[PJ_DRB_SAP]); \ - \ - \ - \ - _pdcpId.ueId = _pjRbCb->ueCb->key.ueId; \ - _pdcpId.cellId = _pjRbCb->ueCb->key.cellId; \ - _pdcpId.rbId = _pjRbCb->rbId; \ - _pdcpId.rbType = _pjRbCb->rbType; \ - \ - switch (_rxEnt->state) \ - { \ - case PJ_RDY_TO_DCIPHER: \ - case PJ_SENT_TO_DCIPHER: \ - { \ - _staInd.cause = PJU_DCIP_FAILED; \ - break; \ - } \ - case PJ_RDY_TO_INTVER: \ - case PJ_SENT_TO_INTVER: \ - { \ - _staInd.cause = PJU_INTVER_FAILED; \ - _mBuf = _rxEnt->mBuf; \ - _rxEnt->mBuf = NULLP; \ - break; \ - } \ - case PJ_RDY_TO_DCOMP: \ - case PJ_SENT_TO_DCOMP: \ - { \ - _staInd.cause = PJU_DCOMP_FAILED; \ - if(_pjRbCb->ulCb.discReqd == FALSE) \ - { \ - _mBuf = _rxEnt->mBuf; \ - _rxEnt->mBuf = NULLP; \ - } \ - break; \ - } \ - default: \ - break; \ - } \ - PjUiPjuStaInd(&(_pjuSap->pst), _pjuSap->suId, \ - &_pdcpId, &_staInd, _mBuf); \ -} - - - -#define PJ_SND_PJU_DAT_IND(_cb,_pjRbCb, _rxEnt) \ -{ \ - CmLtePdcpId _pdcpId; \ - Buffer *_mBuf; \ - PjPjuSapCb *_pjuSap; \ - \ - if (_pjRbCb->rbType == PJ_SRB) \ - { \ - _pjuSap = &(_cb->u.ulCb->pjuSap[PJ_SRB_SAP]); \ - } \ - else \ - { \ - PJ_UPD_L2_ULLOSS_CNTRS(_cb,_rxEnt->count, _pjRbCb) \ - _pjuSap = &(_cb->u.ulCb->pjuSap[PJ_DRB_SAP]); \ - } \ - \ - _pdcpId.ueId = _pjRbCb->ueCb->key.ueId; \ - _pdcpId.cellId = _pjRbCb->ueCb->key.cellId; \ - _pdcpId.rbType = _pjRbCb->rbType; \ - _pdcpId.rbId = _pjRbCb->rbId; \ - _mBuf = _rxEnt->mBuf; \ - _rxEnt->mBuf = NULLP; \ - \ - /* If trace flag is enabled send the trace indication */\ - if(_cb->init.trc == TRUE) \ - { \ - /* Populate the trace params */ \ - pjLmmSendTrc(_cb,EVTPJUDATIND, _mBuf); \ - } \ - \ - PjUiPjuDatInd(&(_pjuSap->pst), _pjuSap->suId, \ - &_pdcpId, _mBuf); \ - PJ_STS_INC_PJU_CNT(_cb,_pjRbCb->rbType, txSdus) \ -} - - -#define PJ_FILL_REEST_CFM_INFO(_reEstCfm, _asyncCfm, _status) \ -{ \ - _reEstCfm->ueId = _asyncCfm->ueId; \ - _reEstCfm->cellId = _asyncCfm->cellId; \ - _reEstCfm->transId = _asyncCfm->transId; \ - _reEstCfm->status = _status; \ -} - -#define PJ_FILL_SEC_CFM_INFO(_secCfgCfm, _asyncCfm) \ -{ \ - _secCfgCfm->ueId = _asyncCfm->ueId; \ - _secCfgCfm->cellId = _asyncCfm->cellId; \ - _secCfgCfm->transId = _asyncCfm->transId; \ - _secCfgCfm->status = UDX_CFG_CFM_OK; \ - _secCfgCfm->reason = UDX_CFG_REAS_NONE; \ -} - -#define PJ_FILL_REEST_CFG_CFM_INFO(_cfmInfo, _asyncCfm) \ -{ \ - U8 _idx; \ - for (_idx = 0; _idx < _asyncCfm->numEnt ; _idx++) \ - { \ - if (_asyncCfm->cfmEnt[_idx].cfgType == CPJ_CFG_REESTABLISH) \ - { \ - _cfmInfo->cfmEnt[_idx].status = CPJ_CFG_CFM_OK; \ - _cfmInfo->cfmEnt[_idx].reason = LCM_REASON_NOT_APPL; \ - } \ - else \ - { \ - _cfmInfo->cfmEnt[_idx].status = _asyncCfm->cfmEnt[_idx].status;\ - _cfmInfo->cfmEnt[_idx].reason = _asyncCfm->cfmEnt[_idx].reason;\ - } \ - _cfmInfo->cfmEnt[_idx].rbId = _asyncCfm->cfmEnt[_idx].rbId; \ - _cfmInfo->cfmEnt[_idx].rbType = _asyncCfm->cfmEnt[_idx].rbType; \ - } \ - _cfmInfo->ueId = _asyncCfm->ueId; \ - _cfmInfo->cellId = _asyncCfm->cellId; \ - _cfmInfo->transId = _asyncCfm->transId; \ - _cfmInfo->numEnt = _asyncCfm->numEnt; \ -} - - -#define PJ_PERFORM_ERR_UPDATES(_cb, _pjRbCb, _count) \ -{ \ - PjUlCb *_upCb; \ - \ - _upCb = &_pjRbCb->ulCb; \ - if(_upCb->recBuf.numEntries != 0) \ - { \ - PJ_CALC_NXT2SUB(_cb, _upCb); \ - } \ - PJ_CHK_RDY_TO_DELIVER(_cb, _pjRbCb); \ -} - - -#define PJ_CALC_NXT2SUB(_cb, __ulCb) \ -{ \ - PjRxEnt *_rxEnt; \ - U32 _nxtToSub; \ - _nxtToSub = __ulCb->nxtSubCnt; \ - if(__ulCb->recBuf.numEntries != 0) \ - { \ - _nxtToSub ++; \ - while( (_rxEnt = (PjRxEnt *)pjDbmGetRxEnt(_cb, &ulCb->recBuf, _nxtToSub)) != NULLP)\ - { \ - __ulCb->nxtSubCnt++; \ - } \ - } \ - __ulCb->nxtSubCnt = _nxtToSub; \ -} - - -#define PJ_CHK_RDY_TO_DELIVER(_cb, _pjRbCb) \ -{ \ - PjUlCb *_ulCb; \ - PjRxEnt *_rxEnt; \ - \ - _ulCb = &_pjRbCb->ulCb; \ - if(_ulCb->recBuf.numEntries == 0) \ - { \ - if((_pjRbCb->rbType == PJ_DRB)&& \ - (_pjRbCb->state != PJ_STATE_NORMAL)) \ - { \ - if((_ulCb->transCmp) \ - && (_ulCb->obdCnt == 0) \ - ) \ - { \ - pjUlmReEstDrbAm(_cb, _pjRbCb); \ - } \ - } \ - } \ - else \ - { \ - _rxEnt = (PjRxEnt *)pjDbmGetRxEnt(_cb, &_ulCb->recBuf, ulCb->nxtSubCnt);\ - if( _rxEnt && _rxEnt->state == PJ_RDY_TO_SUBMIT) \ - { \ - if(_pjRbCb->rbType == PJ_SRB) \ - { \ - pjUlmDeliverSrb(_cb, _pjRbCb, _rxEnt); \ - } \ - else \ - { \ - if(_pjRbCb->mode == PJ_DRB_UM) \ - { \ - pjUlmDeliverDrbUm(_cb, _pjRbCb, _rxEnt); \ - } \ - else \ - { \ - pjUlmDeliverDrbAm(_cb, _pjRbCb, _rxEnt); \ - } \ - } \ - } \ - } \ -} - -#define PJ_GET_COUNT(_count, _snLen, _sn, _hfn) \ -{ \ - _count = ((_hfn << _snLen) | _sn); \ -} - - -#define PJ_CALC_RCVD_HFN(_rcvdSn,_snLen,_rxDeliv,_rcvdHfn) \ -{ \ - U32 _hfn; \ - U32 _sn; \ - S32 _winSize; \ - PJ_GET_SN_HFN(_rxDeliv,_snLen,_sn,_hfn); \ - _winSize = _sn - PJ_WINSIZE(_snLen); \ - if((_winSize > 0) && (_rcvdSn < _winSize)) \ - { \ - _rcvdHfn = _hfn + 1; \ - } \ - else if(_rcvdSn >= (_sn + PJ_WINSIZE(_snLen))) \ - { \ - _rcvdHfn = _hfn - 1; \ - } \ - else \ - { \ - _rcvdHfn = _hfn; \ - } \ -} - - -#ifdef LTE_L2_MEAS -#define PJ_ULM_DRBUM_REEST(_cb,_pjRbCb) \ -{ \ - _pjRbCb->ulCb.rxNext = 0; \ - _pjRbCb->ulCb.rxDeliv = 0; \ - pjUtlUlHdlRbReEstComplete(_cb, _pjRbCb); \ -} -#else -#define PJ_ULM_DRBUM_REEST(_cb,_pjRbCb) \ -{ \ - _pjRbCb->ulCb.rxNext = 0; \ - _pjRbCb->ulCb.rxDeliv = 0; \ - pjUtlUlHdlRbReEstComplete(_cb, _pjRbCb); \ -} -#endif - - -/* Update state and call the respective delivery - * function */ -#define PJ_ULM_DELIVER_DRB(_cb,_pjRbCb, _rxEnt) \ -{ \ - if(_pjRbCb->mode == PJ_DRB_AM) \ - { \ - pjUlmDeliverDrbAm(_cb,_pjRbCb, _rxEnt); \ - } \ - else \ - { \ - pjUlmDeliverDrbUm(_cb,_pjRbCb, _rxEnt); \ - } \ -} - -/*update the state variable RX_NEXT */ -#define PJ_ULM_UPDATE_RX_NEXT(_pjRbCb,_rxEnt) \ -{ \ - U32 _diffRxNext;\ - U32 _diffRcvdCount;\ - _diffRxNext = ((_pjRbCb->ulCb.rxNext - _pjRbCb->ulCb.rxDeliv) % PJ_WINSIZE(_pjRbCb->snLen));\ - _diffRcvdCount = ((_rxEnt->count - _pjRbCb->ulCb.rxDeliv) % PJ_WINSIZE(_pjRbCb->snLen));\ - if(_diffRcvdCount >= _diffRxNext) \ - { \ - _pjRbCb->ulCb.rxNext = _rxEnt->count + 1; \ - } \ -} -/* Update state and call the respective delivery - * function */ -#define PJ_ULM_DELIVER_PDU(_cb,_pjRbCb, _rxEnt) \ -{ \ - \ - if(_pjRbCb->rbType == PJ_SRB) \ - { \ - pjUlmDeliverSrb(_cb,_pjRbCb, _rxEnt); \ - } \ - else \ - { \ - PJ_ULM_DELIVER_DRB(_cb,_pjRbCb, _rxEnt); \ - } \ -} - -/* There is case that all PDUs in the recv Buf can be back from off board - * but not sent up. In that case, though the the recvBuf has entries the - * obd timer should not be restarted. This works with the PJ_ULM_GET_DRBAM_SUBCNT - * macro to acheive this. */ -#define PJ_DRBAM_ALL_PDU_RECVD(_pjRbCb)\ -((pjRbCb->rbType == PJ_DRB) && \ - (pjRbCb->mode == PJ_DRB_AM) && \ - ((ulCb->rxDeliv - 1) == ulCb->obdPdu)) \ - - -#define PJ_ULM_GET_DRBAM_SUBCNT(_pjUlRbCb, _nxtSubCnt, _pjCb) \ -{ \ - U32 _count = _pjUlRbCb->ulCb.rxDeliv - 1; \ - U32 _nxtRxCnt = (_pjUlRbCb->ulCb.rxNext) ;\ - PjRxEnt *_rxEnt = NULLP; \ - _nxtSubCnt = _count; \ - if(((_pjUlRbCb->state != PJ_STATE_NORMAL) && \ - (_pjUlRbCb->ulCb.obdCnt != 0)) || \ - ((_pjUlRbCb->state == PJ_STATE_NORMAL) && \ - (_pjUlRbCb->ulCb.recBuf.numEntries != 0))) \ - { \ - _count ++; \ - for(;_count < _nxtRxCnt; _count ++) \ - { \ - _rxEnt = (PjRxEnt *)pjDbmGetRxEnt(_pjCb, &_pjUlRbCb->ulCb.recBuf, _count); \ - if((_rxEnt != NULLP) && (_rxEnt->state != PJ_RDY_TO_SUBMIT)) \ - { \ - _nxtSubCnt = _count; \ - break; \ - } \ - } \ - } \ -} - - -#define PJ_ULM_GET_SUBCNT(_pjUlRbCb, _subPdu, _pjCb) \ -{ \ - if((_pjUlRbCb->rbType == PJ_DRB) && (_pjUlRbCb->mode == PJ_DRB_AM))\ - { \ - PJ_ULM_GET_DRBAM_SUBCNT(_pjUlRbCb, _subPdu, _pjCb); \ - } \ - else \ - { \ - _subPdu = _pjUlRbCb->ulCb.nxtSubCnt; \ - } \ -} - - -#define PJ_STS_INC_GEN_CNT(_cb, _cntr) \ -{ \ - _cb->pjGenSts._cntr++; \ -} \ - -#define PJ_STS_INC_PJU_CNT(_cb, _rbType, _cntr) \ -{ \ - if (_rbType == PJ_SRB) \ - _cb->u.ulCb->pjuSap[PJ_SRB_SAP].sts._cntr++; \ - else \ - _cb->u.ulCb->pjuSap[PJ_DRB_SAP].sts._cntr++; \ -} \ - -#define PJ_PK_U8(_msg, _val, _ret) \ -{ \ - (_ret) = SAddPstMsg((Data) (_val), (_msg)); \ -} - -#define PJ_PK_U16(_msg, _val, _ret) \ -{ \ - PJ_PK_U8(_msg, (U8) GetHiByte(_val), _ret) \ - if ((_ret) == ROK) \ - PJ_PK_U8(_msg, (U8) GetLoByte(_val), _ret) \ -} - -#define PJ_PK_U32(_msg, _val, _ret) \ -{ \ - U16 _tmp16; \ - _tmp16 = (U16) GetHiWord(_val); \ - PJ_PK_U16(_msg, _tmp16, _ret) \ - if ((_ret) == ROK) \ - { \ - _tmp16 = (U16) GetLoWord(_val); \ - PJ_PK_U16(_msg, _tmp16, _ret) \ - } \ -} - -#define PJ_PACK_MACI(_mBuf, _macI) \ -{ \ - U16 _tmp; \ - Data _pkArray[4]; \ - _tmp = (U16) GetHiWord(_macI); \ - _pkArray[0] = (Data) GetHiByte(_tmp); \ - _pkArray[1] = (Data) GetLoByte(_tmp); \ - _tmp = (U16) GetLoWord(_macI); \ - _pkArray[2] = (Data) GetHiByte(_tmp); \ - _pkArray[3] = (Data) GetLoByte(_tmp); \ - SAddPstMsgMult(_pkArray, (MsgLen) 4, _mBuf); \ -} - -#define PJ_UNPK_MACI(_mBuf, _macI) \ -{ \ - U16 _tmp16 = 0; \ - Data _unPkArray[4] = {0}; \ - SRemPstMsgMult(_unPkArray, (MsgLen)4, _mBuf); \ - _tmp16 = (U16) PutHiByte(_tmp16, (U8) _unPkArray[3]); \ - _tmp16 = (U16) PutLoByte(_tmp16, (U8) _unPkArray[2]); \ - _macI = (U32) PutHiWord(_macI, (U16) _tmp16); \ - _tmp16 = (U16) PutHiByte(_tmp16, (U8) _unPkArray[1]); \ - _tmp16 = (U16) PutLoByte(_tmp16, (U8) _unPkArray[0]); \ - _macI = (U32) PutLoWord(_macI, (U16) _tmp16); \ -} - -/*@def PJ_SEC_FILL_COUNT -* -* This macro fills the COUNT value. COUNT value is composed -* of a HFN and the PDCP SN. Refer to 36.323 for details. -* -*@param[in]_secInp Count Value as Input -*@param[in]_pSecInfo Variable into which count value needs to be populated -* -*/ -#define PJ_SEC_FILL_COUNT(_secInp, _pSecInfo) \ -{ \ - U16 _tmp; \ - _tmp = (U16) GetHiWord(_secInp); \ - _pSecInfo[0] = (Data) GetHiByte(_tmp); \ - _pSecInfo[1] = (Data) GetLoByte(_tmp); \ - _tmp = (U16) GetLoWord(_secInp); \ - _pSecInfo[2] = (Data) GetHiByte(_tmp); \ - _pSecInfo[3] = (Data) GetLoByte(_tmp); \ -} - -/*@def PJ_SEC_FILL_FRESH -* -* This macro fills the FRESH value. FRESH [0], . FRESH [3] -* is set as BEARER[0] . BEARER[4] | 0 pow(27). Refer to 33.401 for details. -* -*@param[in]_fresh Variable into which o/p needs to be set. -*@param[in]_rbId RbId of the RB to be filled in FRESH -* -*/ -#define PJ_SEC_FILL_FRESH(_fresh, _rbId) \ -{ \ - _fresh[0] = 0; \ - _fresh[1] = 0; \ - _fresh[2] = 0; \ - _fresh[3] = _rbId; \ -} - -#define PJ_TIME_DIFF(cur,prev) \ - (currbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\ - CPJ_CFG_REAS_UE_CREAT_FAIL); - - RLOG_ARG1(L_ERROR,DBG_UEID,ueId, "CellId[%d] Creating DL UeCb Failed", - cellId); - RETVALUE(ret); - } - } - - (*ueCb)->inst = gCb->init.inst; - - /* Rb Id is allowed range or not */ - PJ_VALIDATE_RBID(ueId, entCfg->rbId, entCfg->rbType, ret); - if ( ROK != ret) - { - PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\ - CPJ_CFG_REAS_INVALID_RBID); - - RLOG_ARG2(L_ERROR,DBG_UEID,ueId, "CellId[%u]:RbId[%d] - " - "Invalid RB ID,RbCb Creation Failed ", cellId, entCfg->rbId); - RETVALUE(ret); - } - - /* Find Rb Cb already exist or not */ - PJ_DBM_FETCH_DL_RBCB(entCfg->rbId, entCfg->rbType, (*ueCb), rbCb); - if (NULLP != rbCb) - { - RLOG_ARG2(L_WARNING, DBG_UEID,ueId, "CellId [%u]:RbId[%d] already exists", - cellId,entCfg->rbId); - /* Rb Cb already exist for pdpcp */ - PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\ - CPJ_CFG_REAS_SAME_RBID); - - RLOG_ARG2(L_ERROR,DBG_UEID,ueId, "RB Id already present-- cellId(%d), rbId(%d)", - cellId, entCfg->rbId); - RETVALUE(RFAILED); - } - else if (NULLP == rbCb) - { - /* Create Rb Cb and place in Ue Cb */ - rbCb = pjDbmCreateDlRbCb(gCb, entCfg->rbId, entCfg->rbType, *ueCb, PJ_CFG_PDCP); - if(NULLP == rbCb) - { - /* Create Rb Cb Failed*/ - PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\ - CPJ_CFG_REAS_ENT_CREAT_FAIL); - - RLOG_ARG2(L_ERROR,DBG_UEID,ueId, "Failed to Create RB CB -- cellId(%d) rbId(%d)", - cellId, entCfg->rbId); - RETVALUE(RFAILED); - } - } - - /* Copy the Recived information into RbCb */ - ret = pjCfgFillPjDlRbCb(gCb, rbCb, *ueCb,isHo, entCfg , entCfm); - - /* Fill the Cfm status and Reason */ - PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_OK,\ - CPJ_CFG_REAS_NONE); - - RETVALUE(ret); -} /* pjCfgAddRb */ - -/** -* @brief -* -* Hanlder to update the PJRB with the received infromation during -* configuration or re configuration. -* -* @b Description: -* 1. update the data base with the new configuration informtion received. @n -* 2. update the data base with the new re-configuration informtion received. @n -* 3. If required Initiliaze the tx/rx Buffers and Timers. @n -* 4. Return Success or Failure to the caller with reason and status -* information. @n -* - * @param [out] rbCb - RB Control Block - * @param [out] entCfm - PDCP Entiry Confirmation - * @param [in] ueCb - UE Control Block - * @param [in] entCfg - PDCP Entity Configuration - * - * @return ROK - */ -#ifdef ANSI -PRIVATE S16 pjCfgFillPjDlRbCb -( -PjCb *gCb, -PjDlRbCb *pjRbCb, -PjDlUeCb *ueCb, -U8 isHo, -UdxCfgEnt *cfgEnt, -UdxCfmEnt *cfmEnt -) -#else -PRIVATE S16 pjCfgFillPjDlRbCb(gCb, pjRbCb, ueCb,isHo, cfgEnt, cfmEnt) -PjCb *gCb; -PjDlRbCb *pjRbCb; -PjDlUeCb *ueCb; -U8 isHo, -CpjCfgEnt *cfgEnt; -CpjCfmEnt *cfmEnt; -#endif -{ - S16 tmrVal; /* Timer Value */ - /* kw005.201 added support for L2 measurement */ - TRC3(pjCfgFillPjDlRbCb); - - /* Initialization */ - tmrVal = 0; - - RLOG_ARG3(L_DEBUG,DBG_UEID,ueCb->key.ueId, "Received Fill Req cellId(%d), rbId(%d),cfgType(%d)", - ueCb->key.cellId, - cfgEnt->rbId, cfgEnt->cfgType); - - switch (cfgEnt->cfgType) - { - /* Cfg Type received as ADD RB */ - case CPJ_CFG_ADD: - { - pjRbCb->state = PJ_STATE_NORMAL; - pjRbCb->rbId = cfgEnt->rbId; - pjRbCb->rbType = cfgEnt->rbType; - pjRbCb->mode = cfgEnt->m.addCfg.rlcInfo.mode; - pjRbCb->dir = cfgEnt->m.addCfg.rlcInfo.dir; - pjRbCb->ueCb = ueCb; - - if(PJ_SRB == pjRbCb->rbType) - { - /* SN length is fixed for SRB */ - pjRbCb->snLen = PJ_SRB_SN_LEN; - ueCb->numSrbs++; - } - else - { - if (CM_LTE_MODE_UM == pjRbCb->mode) - { - /* SN length can be 12 bit or 18 bit in UM mode */ - pjRbCb->snLen = cfgEnt->m.addCfg.rlcInfo.m.rlcUm.pdcpSNSize; -#ifdef NR_PDCP_DRB_SN_18_BIT - pjRbCb->snLen = PJ_18_BIT_SN; -#else - pjRbCb->snLen = PJ_12_BIT_SN; -#endif - } - else - { - /* SN length can be 12/18 bit for AM mode */ - pjRbCb->snLen = cfgEnt->m.addCfg.rlcInfo.m.rlcAm.pdcpSNSize; -#ifdef NR_PDCP_DRB_SN_18_BIT - pjRbCb->snLen = PJ_18_BIT_SN; -#else - pjRbCb->snLen = PJ_12_BIT_SN; -#endif - if (isHo) - { - pjRbCb->state = PJ_STATE_HO; - } - } - ueCb->numDrbs++; - } - pjRbCb->maxTxSn = (1 << pjRbCb->snLen); - /* Initialize all off board timers */ -#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) - cmInitTimers(&pjRbCb->dlCb.obdTmr,PJ_RB_MAX_TIMERS); -#endif - - RLOG_ARG2(L_DEBUG,DBG_UEID,ueCb->key.ueId, - "Received RB Req with -- Dir(%d), mode(%d)", - pjRbCb->dir, pjRbCb->mode); - - - if (PJ_DIR_DL & pjRbCb->dir) - { - pjRbCb->dlCb.discTmrInt = cfgEnt->m.addCfg.discardTmr; - pjRbCb->dlCb.cfmReqd = cfgEnt->m.addCfg.cfmReqd; - /* pjRbCb->dlCb.count = 0xffffffff; */ - - /* Discard Timer is Enabled */ - if(pjRbCb->dlCb.discTmrInt > 0 ) - { - cmInitTimers(&pjRbCb->dlCb.discTmr,PJ_RB_MAX_TIMERS); - /* 1. The discTmr value is absolute value in ms units - 2. Store the DiscardTmr value in terms of Layer resolution - ie discTmrVal = dicTrmVal/(SS_TICKS*Layer Resolution) - and round to next integer value. - */ - tmrVal = (S16)(pjRbCb->dlCb.discTmrInt % (SS_TICKS_SEC - * gCb->pjGenCfg.timeRes)); /*KW_FIX*/ - pjRbCb->dlCb.discTmrInt = (S16)(pjRbCb->dlCb.discTmrInt / - (SS_TICKS_SEC * gCb->pjGenCfg.timeRes)); - if(tmrVal) - pjRbCb->dlCb.discTmrInt +=1; /* Round to next integer value if - required */ - } - - /*Initialization for Tx Buf */ - gCb->pjGenCfg.nmbDlBins = PJ_MAX_HASH_BINS; - pjDbmDlBufInit(gCb, &pjRbCb->dlCb.txBuf,gCb->pjGenCfg.nmbDlBins); - cmLListInit(&pjRbCb->dlCb.dlPktQ); - } - - /* Update the Compressor Informatio in Rb Cb */ - if(cfgEnt->rbType == CM_LTE_DRB) - { - pjCfgUpdDlCompInfo(gCb, pjRbCb, ueCb,&(cfgEnt->m.addCfg.hdrCompCfg)); -/* kw005.201 added support for L2 measurement */ -#ifdef LTE_L2_MEAS - pjRbCb->qci = cfgEnt->m.addCfg.qci; - pjAddToDlL2Meas(gCb,pjRbCb, - ueCb->key.cellId,ueCb->key.ueId); -#endif - } - - break; - } - - /* Cfg Type received as Modify RB */ - case CPJ_CFG_MODIFY: - { - if(CPJ_RECFG_CFMREQ & cfgEnt->m.modCfg.bitFlag) - pjRbCb->dlCb.cfmReqd = cfgEnt->m.modCfg.cfmReqd; - - /* Header Compression profile has been modified */ - - if(TRUE == cfgEnt->m.modCfg.hdrCompCfg.hdrCompUsed) - { - /* Close All the channels */ - pjUtlDlCmpReset(gCb, pjRbCb); - pjCfgUpdDlCompInfo(gCb, pjRbCb, ueCb, &cfgEnt->m.modCfg.hdrCompCfg); - } - - /* In case of Hand off scenario: At Target eNode-B, - Handoff information will send in re-cfg req */ - - if(TRUE & cfgEnt->m.modCfg.hoInfo.isHoPres) - { - /* Store the HO information and call for Status Report - * Generation also */ - if(CPJ_HO_DL & cfgEnt->m.modCfg.hoInfo.isHoPres) - { - pjRbCb->dlCb.count = cfgEnt->m.modCfg.hoInfo.dlCount - 1; - if (pjRbCb->snLen != cfgEnt->m.modCfg.hoInfo.snLen) - { - pjRbCb->snLen = cfgEnt->m.modCfg.hoInfo.snLen; - } - } - pjDlmProcessDlPktQ(gCb, pjRbCb); - pjRbCb->state = PJ_STATE_NORMAL; - } - - break; - } - - /* Un Expected cfg type */ - default: - { - RLOG_ARG1(L_ERROR,DBG_CELLID, ueCb->key.cellId, - "pjCfgFillRbCb Failed -- for the invalid cfgType(%d)", - cfgEnt->cfgType); - } - } - RETVALUE(ROK); -} /* pjCfgFillPjRbCb */ - - - -/** -* @brief -* -* Hanlder to process the re-configuration for existing PJRB from the upper -* layer. -* -* @b Description: -* 1. This function fetch the PJRB from pdcp data base. @n -* 2. update the data base with the new configuration informtion received. @n -* 3. Return Success or Failure to the caller with reason and status -* information. @n -* -* @param [in] gCb - PDCP Instance Control block -* @param [in] ueId - UE Identifier -* @param [in] cellId - CELL Identifier -* @param [in] entCfg - Entity Configuration to be done. -* @param [out] entCfm - Entity Confirmation. -* -* @return ROK -* -*/ -#ifdef ANSI -PUBLIC S16 pjCfgReCfgDlRb -( -PjCb *gCb, -PjDlUeCb *ueCb, -UdxCfgEnt *entCfg, -UdxCfmEnt *entCfm -) -#else -PUBLIC S16 pjCfgReCfgDlRb (gCb,ueCb, entCfg, entCfm) -PjCb *gCb; -PjDlUeCb *ueCb; -UdxCfgEnt *entCfg; -UdxCfmEnt *entCfm; -#endif -{ - S16 ret; - PjDlRbCb *rbCb; /* Rb Cb */ - - TRC3(pjCfgReCfgDlRb); - - /* Initialization */ - ret = ROK; - - RLOG2(L_DEBUG, "pjCfgReCfgRb - Received for -- cellId(%d),ueId(%d)", - ueCb->key.cellId, ueCb->key.ueId); - - /* Fetch Rb Cb */ - PJ_DBM_FETCH_DL_RBCB(entCfg->rbId, entCfg->rbType, ueCb, rbCb); - /* Rb Cb is not present or Rb Cb is not configured for PDCP */ - if( NULLP == rbCb) - { - RLOG_ARG2(L_ERROR, DBG_UEID,ueCb->key.ueId, "CellId [%u]:RbId[%d] already exists", - ueCb->key.cellId,entCfg->rbId); - /* Fill entCfm structure */ - PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\ - CPJ_CFG_REAS_PDCPID_UNKWN); - - RLOG_ARG2(L_ERROR,DBG_UEID,ueCb->key.ueId, - "RB Cb is not present -- cellId(%d), rbId(%d)", - ueCb->key.cellId, entCfg->rbId); - RETVALUE(RFAILED); - } - - /* Copy the received infromation in to Rb Cb */ - ret = pjCfgFillPjDlRbCb(gCb, rbCb, ueCb,FALSE, entCfg , entCfm); - - /* Fill the Cfm status and Reason */ - PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_OK,\ - CPJ_CFG_REAS_NONE); - - - RETVALUE(ret); -} /* pjCfgReCfgRb */ - - -/** -* @brief -* This function deletes the existing RB(PDCP and RLC) from Ue Cb. -* -* @b Description: -* 1. Stop the timers and deallocate tx/rx Buffs for PJRB CB. @n -* 2. Delete the existing RB Cb(PDCP and RLC) from Ue Cb. @n -* -* @param [in] ueId - UE Identifier -* @param [in] cellId - CELL Identifier -* @param [in] entCfg - Entity Configuration to be done. -* @param [out] entCfm - Entity Confirmation. -* -* @return ROK -* -*/ -#ifdef ANSI -PUBLIC S16 pjCfgDelDlRb -( -PjCb *gCb, -PjDlUeCb *ueCb, -UdxCfgEnt *entCfg, -UdxCfmEnt *entCfm -) -#else -PUBLIC S16 pjCfgDelDlRb (gCb, ueCb, entCfg, entCfm) -PjCb *gCb; -PjDlUeCb *ueCb; -UdxCfgEnt *entCfg; -UdxCfmEnt *entCfm; -#endif -{ - S16 ret; - PjDlRbCb *rbCb; /* Rb Cb */ - - TRC3(pjCfgDelDlRb); - - /* Initialization */ - ret = ROK; - - RLOG2(L_DEBUG, "pjCfgDelRb- Received for -- cellId(%d),ueId(%d)", - ueCb->key.cellId,ueCb->key.ueId); - - /* Fetch RB Cb */ - PJ_DBM_FETCH_DL_RBCB(entCfg->rbId, entCfg->rbType, ueCb, rbCb); - - /* RB Cb is not present or not configured for PDCP */ - if (NULLP == rbCb) - { - RLOG_ARG2(L_ERROR, DBG_UEID,ueCb->key.ueId, "CellId [%u]:RbId[%d] already exists", - ueCb->key.cellId,entCfg->rbId); - /* Fill entCfm structure with invalid pdcp Id */ - PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\ - CPJ_CFG_REAS_INVALID_PDCPID); - - RLOG_ARG2(L_ERROR,DBG_UEID,ueCb->key.ueId, - "RB Cb is not found, Deletion Failed -- cellId(%d), rbId(%d)", - ueCb->key.cellId, entCfg->rbId); - RETVALUE(RFAILED); - } - /* Delete PDCP Related infromation from RB CB */ - ret= pjCfgDelPjDlRbCb(gCb, ueCb, rbCb); - - if(ROK != ret) - { - /* Fill entCfm structure with invalid pdcp Id */ - PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\ - CPJ_CFG_REAS_INVALID_PDCPID); - - RLOG_ARG2(L_ERROR,DBG_UEID,ueCb->key.ueId, - "RB Cb Deletion Failed -- cellId(%d), rbId(%d)", - ueCb->key.cellId, entCfg->rbId); - RETVALUE(ret); - } - rbCb->pktAdmitCnt= 0; - /* Fill the Cfm status and Reason */ - PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_OK,\ - CPJ_CFG_REAS_NONE); - - - RETVALUE(ret); -} /* pjCfgDelRb */ - - - - -/** -* @brief -* -* This primitive is used to re-establish downlink SRB2 and/or DRB'S during RRC connection -* re-configuration procedure. -* -* @b Description: -* 1. This function will trigger re-establishment for SRB2 and/or DRB's -* -* @param [in] gCb - PDCP Instance Control block -* @param [in] ueId - UE Identifier -* @param [in] cellId - CELL Identifier -* @param [in] entCfg - Entity Configuration to be done. -* @param [out] entCfm - Entity Configuration cfm. -* -* @return ROK -* -*/ -#ifdef ANSI -PUBLIC S16 pjCfgReEstDlRb -( -PjCb *gCb, -PjDlUeCb *ueCb, -UdxCfgEnt *entCfg, -UdxCfmEnt *entCfm -) -#else -PUBLIC S16 pjCfgReEstDlRb (gCb,ueCb, entCfg, entCfm) -PjCb *gCb; -PjDlUeCb *ueCb; -UdxCfgEnt *entCfg; -UdxCfmEnt *entCfm; -#endif -{ - S16 ret; - PjDlRbCb *rbCb; /* Rb Cb */ - - TRC3(pjCfgReEstDlRb); - - /* Initialization */ - ret = ROK; - - RLOG2(L_DEBUG, "pjCfgReEstRb- Received for -- cellId(%d),ueId(%d)", - ueCb->key.cellId, ueCb->key.ueId); - - /* Fetch Rb Cb */ - PJ_DBM_FETCH_DL_RBCB(entCfg->rbId, entCfg->rbType, ueCb, rbCb); - /* Rb Cb is not present or Rb Cb is not configured for PDCP */ - if( NULLP == rbCb ) - { - RLOG_ARG2(L_ERROR, DBG_UEID,ueCb->key.ueId, "CellId [%u]:RbId[%d] already exists", - ueCb->key.cellId,entCfg->rbId); - /* Fill entCfm structure with invalid PDCP Id*/ - PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\ - CPJ_CFG_REAS_PDCPID_UNKWN); - - RLOG_ARG1(L_ERROR,DBG_UEID,ueCb->key.ueId, - "Re-Est Failed : DL RB CB is not present -- cellId(%d)", - ueCb->key.cellId); - - RETVALUE(RFAILED); - } - - /* A Cfm with failure is sent if the re-establishment comes when RBs are not in - re-est state */ - if (ueCb->libInfo.state != PJ_STATE_REEST ) - { - /* Fill entCfm structure with invalid PDCP Id*/ - PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\ - CPJ_CFG_REAS_INVALID_STATE); - - RLOG_ARG1(L_ERROR,DBG_UEID,ueCb->key.ueId, - "Re-Est Failed : RB State is Not REEST -- cellId(%d)", - ueCb->key.cellId); - RETVALUE(RFAILED); - } - - /* 5. Call the respective reestablishment functions for SRB */ - if(rbCb->rbType == PJ_SRB) - { - pjDlmReEstSrb(gCb,rbCb); - } - else /* PJ_DRBs */ - { - /* During Re-Establishment DL RAB state is assumed to be in PJ_STATE_NORMAL - * and the Status Report is sent only if this is the state. - * But if the Reestablishment happens during HO(PJ_STATE_REEST_HO) - * due to the state change during HO no Status Report is sent after successful - * Re-establishment - */ - rbCb->state = PJ_STATE_NORMAL; - rbCb->pktAdmitCnt = 0; - if (rbCb->mode == PJ_DRB_UM) - { - pjDlmReEstDrbUm(gCb,rbCb); - } - else - { - pjDlmReEstDrbAm(gCb,rbCb); - } - }/* if(rbType == .... */ - - RETVALUE(ret); -} /* pjCfgReEstRb */ - - - -/** -* @brief -* This primitive Delete Ue Cb from PDCP/RLC data base. -* -* @b Description: -* 1. This primitive Delete the Ue Cb from PDCP/RLC Data base. -* -* @param [in] ueId - UE Identifier -* @param [in] cellId - CELL Identifier -* @param [in] entCfg - Entity Configuration to be done. -* @param [out] entCfm - Entity Confirmation. -* -* @return ROK -* -*/ -#ifdef ANSI -PUBLIC S16 pjCfgDelDlUe -( -PjCb *gCb, -PjDlUeCb *ueCb, -UdxCfgEnt *entCfg, -UdxCfmEnt *entCfm -) -#else -PUBLIC S16 pjCfgDelDlUe (gCb, ueCb, entCfg, entCfm) -PjCb *gCb; -PjDlUeCb *ueCb; -UdxCfgEnt *entCfg; -UdxCfmEnt *entCfm; -#endif -{ - TRC3(pjCfgDelDlUe); - - RLOG_ARG1(L_DEBUG,DBG_UEID,ueCb->key.ueId, - "pjCfgDelUe- Received for -- cellId(%d)", - ueCb->key.cellId); - - /* Delete Ue Cb */ - pjDbmDelDlUeCb(gCb, ueCb, FALSE); - - /* Fill the Cfm */ - PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_OK,\ - CPJ_CFG_REAS_NONE); - - RETVALUE(ROK); -} /* pjCfgDelUe */ - - -/** -* @brief -* This primitive configure the security information of an Ue Cb. -* -* @b Description: -* 1. This primitive configure the security information of an Ue Cb. -* 2. Initilize the Integrity/Ciphering Channels if required. -* -* @param [in] secCfg - Entity Configuration to be done. -* @param [out] secCfm - Entity Configuration Cfm done. -* -* @return ROK -* -*/ -#ifdef ANSI -PUBLIC S16 pjCfgPrcSecDlCfg -( -PjCb *gCb, -UdxSecCfgReqInfo *secCfg, -UdxSecCfgCfmInfo *cfgCfm -) -#else -PUBLIC S16 pjCfgPrcSecDlCfg (gCb, secCfg, cfgCfm) -PjCb *gCb; -UdxSecCfgReqInfo *secCfg; -UdxSecCfgCfmInfo *cfgCfm; -#endif -{ - S16 ret; - PjDlUeCb *ueCb; - - TRC3(pjCfgPrcSecDlCfg); - - /* Initialization */ - ret = ROK; - ueCb = NULLP; - - RLOG2(L_DEBUG, "pjCfgPrcSecCfg- Received for -- cellId(%d),ueId(%d)", - secCfg->cellId, secCfg->ueId); - - /* Fetch Ue Cb */ - ret = pjDbmFetchDlUeCb(gCb, secCfg->ueId, secCfg->cellId, &ueCb); - - /* Ue Cb is not present */ - if( ROK != ret || NULLP == ueCb) - { - RLOG_ARG1(L_ERROR, DBG_CELLID, secCfg->cellId,"UeId[%u] not found", - secCfg->ueId); - /* Fill entCfm structure */ - PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\ - CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_UE_UNKWN); - RETVALUE(ret); - } - - ueCb->secInfo.selSecAct= secCfg->secCfg.selSecAct; - - /* Store Integrity Information */ - ueCb->secInfo.intInfo.algoType=secCfg->secCfg.integInfo.algoType; - cmMemcpy(&ueCb->secInfo.intInfo.intKey[0], &secCfg->secCfg.integInfo.intKey[0], CPJ_INTG_KEY_LEN); - - /* Store Ciphering Informaiton */ - ueCb->secInfo.cipherInfo.algoType=secCfg->secCfg.cipherInfo.algoType; - - cmMemcpy(ueCb->secInfo.cipherInfo.cpKey, - &secCfg->secCfg.cipherInfo.ctrlplnKey[0],CPJ_CIPHER_KEY_LEN); - - cmMemcpy(ueCb->secInfo.cipherInfo.upKey, - &secCfg->secCfg.cipherInfo.usrplnKey[0],CPJ_CIPHER_KEY_LEN); - - /* Security Activation Done */ - ueCb->secInfo.secAct = TRUE; - - if(TRUE == secCfg->secCfg.isHo) - { - ueCb->secInfo.firstMsg = FALSE; - } - else - { - ueCb->secInfo.firstMsg = TRUE; - } - - ueCb->secInfo.secCxt.cellId = secCfg->cellId; - ueCb->secInfo.secCxt.ueId = secCfg->ueId; - ueCb->secInfo.secCxt.dir = PJ_SEC_DIR_DL; - -#ifndef ALIGN_64BIT - RLOG_ARG3(L_DEBUG,DBG_UEID,secCfg->ueId, - "Security Paramters stored in UE CB are -- cellId(%d)" - "Integrity Algo(%ld), cipherAlgoType(%ld) ", - secCfg->cellId, ueCb->secInfo.intInfo.algoType, - ueCb->secInfo.cipherInfo.algoType); -#else - RLOG_ARG3(L_DEBUG,DBG_UEID,secCfg->ueId, - "Security Paramters stored in UE CB are -- cellId(%d)" - "Integrity Algo(%d), cipherAlgoType(%d) ", - secCfg->cellId, ueCb->secInfo.intInfo.algoType, - ueCb->secInfo.cipherInfo.algoType); -#endif - /* Open the Security Channels */ - - if(ueCb->secInfo.secAct) - { - -#ifdef PJ_SEC_ASYNC - ueCb->secInfo.secCxt.cfgTxId = ueCb->libInfo.nxtAvlbTxId; -#endif - - ret = pjUtlDlIntInit(gCb, ueCb); - - /* Integrity Init failed */ - if(ROK != ret) - { - PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\ - CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_INTINIT_FAILED); - - RETVALUE(ret); - - } - ret = pjUtlDlCpInit(gCb, ueCb); - /* Ciphering Control Plane Init failed */ - if(ROK != ret) - { - PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\ - CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_CCIPHR_FAILED); - - RETVALUE(ret); - - } - ret = pjUtlDlUpInit(gCb, ueCb); - - /* Ciphering User Plane Init failed */ - if(ROK != ret) - { - PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\ - CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_UCIPHR_FAILED); - - RETVALUE(ret); - } - } - - /* Fill Cfg Cfm with Status OK */ - PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\ - CPJ_CFG_CFM_OK,CPJ_CFG_REAS_NONE); - - RETVALUE(ROK); -} /* pjCfgPrcSecCfg */ - - -/** -* @brief -* This primitive changes the ueId of existing Ue Cb. -* -* @b Description: -* -* 1. This function delete the UeCb from hashList. @n -* 2. Update the Ue Cb with the new Keys. @n -* 3. Insert the UeCb in hash list with new Key. @n -* -* @param [in] ueInfo - Old UE Information -* @param [in] newUeInfo - New UE Information -* @param [out] status - Status -* -* @return ROK -* -*/ -#ifdef ANSI -PUBLIC S16 pjCfgDlUeIdChng -( -PjCb *gCb, -UdxUeInfo *ueInfo, -UdxUeInfo *newUeInfo, -CmStatus *status -) -#else -PUBLIC S16 pjCfgDlUeIdChng (gCb, ueInfo, newUeInfo, status) -PjCb *gCb; -UdxUeInfo *ueInfo; -UdxUeInfo *newUeInfo; -CmStatus *status; -#endif -{ - PjDlUeCb *ueCb; - S16 ret; - - TRC3(pjCfgDlUeIdChng) - - ueCb = NULLP; - ret= ROK; - - RLOG2(L_DEBUG, "pjCfgUeIdChng- Recived for -- cellId(%d),ueId(%d)", - ueInfo->cellId, ueInfo->ueId); - - if ( (ueInfo->ueId == newUeInfo->ueId) && - (ueInfo->cellId == newUeInfo->cellId)) - { - status->reason = CPJ_CFG_REAS_SAME_UEID; - status->status = CPJ_CFG_CFM_NOK; - RLOG_ARG2(L_ERROR,DBG_CELLID,ueInfo->cellId,"Old UeId[%d] same as new UeId[%d]", - ueInfo->ueId,newUeInfo->ueId); - RETVALUE(RFAILED); - } - - ret = pjDbmFetchDlUeCb(gCb, newUeInfo->ueId, newUeInfo->cellId, &ueCb); - if (ret == ROK) - { - RLOG_ARG1(L_ERROR, DBG_CELLID, newUeInfo->cellId, "NewUeId[%d]:ueCb already exists", - newUeInfo->ueId); - status->reason = CPJ_CFG_REAS_SAME_UEID; - status->status = CPJ_CFG_CFM_NOK; - RETVALUE(RFAILED); - } - - ret = pjDbmFetchDlUeCb(gCb, ueInfo->ueId, ueInfo->cellId, &ueCb); - if (ret != ROK) - { - RLOG_ARG1(L_ERROR,DBG_CELLID,ueInfo->cellId,"UeId [%d]: UeCb not found", - ueInfo->ueId); - status->reason = CPJ_CFG_REAS_UE_UNKWN; - status->status = CPJ_CFG_CFM_NOK; - RETVALUE(RFAILED); - } - - ret = cmHashListDelete(&(gCb->u.dlCb->ueLstCp), (PTR) ueCb); - if (ret != ROK) - { - RLOG_ARG1(L_ERROR,DBG_CELLID,ueInfo->cellId,"UeId[%u] HashList Deletion Failed", - ueInfo->ueId); - status->reason = CPJ_CFG_REAS_UE_CREAT_FAIL; - status->status = CPJ_CFG_CFM_NOK; - RETVALUE(RFAILED); - } - - /* update the hash key with new values */ - ueCb->key.ueId = newUeInfo->ueId; - ueCb->key.cellId = newUeInfo->cellId; - - ret = cmHashListInsert(&(gCb->u.dlCb->ueLstCp), (PTR)ueCb, - (U8 *)&(ueCb->key), (U16) sizeof(PjUeKey)); - - if (ret != ROK) - { - RLOG_ARG1(L_ERROR,DBG_CELLID,newUeInfo->cellId,"UeId[%u] HashList Insertion Failed", - newUeInfo->ueId); - status->reason = CPJ_CFG_REAS_UE_CREAT_FAIL; - status->status = CPJ_CFG_CFM_NOK; - } - - RETVALUE(ret); -} /* pjCfgUeIdChng */ - - -/** -* @brief -* This primitive reports the Count informatin of all RBs of an Ue Cb. -* -* @b Description: -* 1. This function reports the count information of all the RBs of an UE. -* -* @param [in] ueId - UE Identifier -* @param [in] cellId - CELL Identifier -* @param [out] countCfm - Count Information -* -* @return ROK -* -*/ -#ifdef ANSI -PUBLIC S16 pjCfgPrcDlCount -( -PjCb *gCb, -UdxCountReqInfo *countReq, -UdxCountCfmInfo *countCfm -) -#else -PUBLIC S16 pjCfgPrcDlCount (gCb, countReq, countCfm) -PjCb *gCb; -UdxCountReqInfo *countReq; -UdxCountCfmInfo *countCfm; -#endif -{ - S16 ret; - PjDlUeCb *ueCb; - PjDlRbCb *rbCb; - U8 numRb; - U8 idx; - - TRC3(pjCfgPrcDlCount); - - /* Initialization */ - ueCb = NULLP; - rbCb = NULLP; - ret = ROK; - numRb = 0; - idx = 0; - - RLOG2(L_DEBUG, "pjCfgPrcCount - Count Request Received for - cellId(%d),ueId(%d)", - countReq->cellId, countReq->ueId); - - /* Fetch ue Cb */ - ret = pjDbmFetchDlUeCb(gCb, countReq->ueId, countReq->cellId, &ueCb); - countCfm->ueId = countReq->ueId; - countCfm->cellId = countReq->cellId; - countCfm->transId = countReq->transId; - - /* Ue Cb is not present */ - if( ROK != ret || NULLP == ueCb) - { - RLOG_ARG1(L_ERROR, DBG_CELLID, countCfm->cellId,"UeId[%u] not found",countCfm->ueId); - /* Fill entCfm structure */ - countCfm->numRb = numRb; - countCfm->status = CPJ_CFG_CFM_NOK; - countCfm->reason = CPJ_CFG_REAS_UE_UNKWN; - RETVALUE(ret); - } - - /* Loop through all DRBs */ - for(numRb=0, idx=0; idx < PJ_MAX_DRB_PER_UE && numRb < UDX_MAX_DRB; idx++) /* KW_FIX */ - { - rbCb = ueCb->drbCb[idx]; - /* RB is present and configured for PDCP Layer */ - if(NULLP != rbCb) - { - countCfm->countInfo[numRb].rbId= rbCb->rbId; - countCfm->countInfo[numRb].dir = rbCb->dir; - countCfm->countInfo[numRb].dlCount= rbCb->dlCb.count; - countCfm->countInfo[numRb].ulCount= 0; - numRb++; - } - } - - /* Fill CountCfm with status and reason */ - countCfm->numRb = numRb; - if(numRb) - { - countCfm->status =CPJ_CFG_CFM_OK; - countCfm->reason =CPJ_CFG_REAS_NONE; - } - else - { - countCfm->status =CPJ_CFG_CFM_NOK; - countCfm->reason =CPJ_CFG_REAS_NO_DRBS; - - } - - RETVALUE(ret); -} /* pjCfgPrcCount */ - -/** -* @brief -* This primitive reports SDU status information of all RBs of an Ue Cb. -* -* @b Description: -* 1. This primitive Trigger the Handoff Request procedure -* -* @param [in] ueId - UE Identifier -* @param [in] cellId - CELL Identifier -* @param [out] sduStaCfm - SDU Status Information -* -* @return ROK -* -*/ -#ifdef ANSI -PUBLIC S16 pjCfgPrcDlSduSta -( -PjCb *gCb, -UdxSduStaReqInfo *staReq -) -#else -PUBLIC S16 pjCfgPrcDlSduSta (gCb, staReq) -PjCb *gCb; -UdxSduStaReqInfo *staReq; -#endif -{ - S16 ret; - PjDlUeCb *ueCb; - U8 rbCnt; - U8 numRb = 0; - UdxSduStaInfo *staInfo; - PjDlHoCfmInfo *hoCfmInfo; - UdxSduStaCfmInfo *cfmInfo; - PjUdxDlSapCb *udxSap; - - TRC3(pjCfgPrcDlSduSta); - - /* Initialization */ - ret = ROK; - ueCb = NULLP; - - RLOG2(L_DEBUG, "pjCfgPrcSduSta - Received for -- cellId(%d),ueId(%d)", - staReq->cellId, staReq->ueId); - - /* Memory leak fix ccpu00135359 */ - udxSap = &(gCb->u.dlCb->udxDlSap[0]); - PJ_ALLOC_BUF_SHRABL(udxSap->pst, cfmInfo, - sizeof (UdxSduStaCfmInfo), ret); - if(ret != ROK) - { -#if (ERRCLASS & ERRCLS_DEBUG) /*KW_FIX*/ - RLOG0(L_FATAL, "Memory Allocation failed."); - /*ccpu00136858 */ - PJ_PST_FREE(gCb->u.dlCb->udxDlSap[0].pst.region, - gCb->u.dlCb->udxDlSap[0].pst.pool, - staReq, sizeof(UdxSduStaReqInfo)); -#endif - RETVALUE(RFAILED); - } - cfmInfo->ueId = staReq->ueId; - cfmInfo->cellId = staReq->cellId; - cfmInfo->transId = staReq->transId; - cfmInfo->status = CPJ_CFG_CFM_OK; - - /* Fetch Ue Cb */ - ret = pjDbmFetchDlUeCb(gCb, staReq->ueId, staReq->cellId, &ueCb); - - /* UeCb is not present */ - if( ROK != ret || NULLP == ueCb) - { - RLOG_ARG1(L_ERROR, DBG_CELLID, staReq->cellId,"UeId[%u] not found",staReq->ueId); - cfmInfo->status = CPJ_CFG_CFM_NOK; - cfmInfo->reason = CPJ_CFG_REAS_UE_UNKWN; - cfmInfo->numRb = numRb; - - /* Caller should return cfm with failure */ - RLOG_ARG1(L_ERROR,DBG_UEID,staReq->ueId, - "UE Cb is not found -- cellId(%d)", - staReq->cellId); - - /* Send Failure SduStaCfm */ - PjDlUdxSduStaCfm(&gCb->u.dlCb->udxDlSap[0].pst, - gCb->u.dlCb->udxDlSap[0].suId, cfmInfo); - - RETVALUE(RFAILED); - } - - /* Call Ho Start handler for this UE */ - pjUtlDlReEstHO(gCb, ueCb); - - for(rbCnt=0, numRb=0; rbCnt < PJ_MAX_DRB_PER_UE && numRb < CPJ_MAX_DRB; rbCnt++) - { - hoCfmInfo = &ueCb->hoInfo->hoCfmInfo[rbCnt]; - staInfo = &cfmInfo->sduStaInfo[numRb]; - if(hoCfmInfo->pres != TRUE) - { - continue; - } - - staInfo->rbId = hoCfmInfo->rbId; - staInfo->dir = hoCfmInfo->dir; - staInfo->dlSduStaInfo.count = hoCfmInfo->count; - staInfo->dlSduStaInfo.hoPres = TRUE; - numRb++; - } - cfmInfo->numRb = numRb; - cfmInfo->status = ROK; - cfmInfo->reason = CPJ_CFG_REAS_NONE; - PJ_FREE(gCb,ueCb->hoInfo->hoCfmInfo, - (PJ_MAX_DRB_PER_UE * sizeof(PjDlHoCfmInfo))); - PJ_FREE(gCb,ueCb->hoInfo, sizeof(PjDlHoInfo)); - - PjDlUdxSduStaCfm(&gCb->u.dlCb->udxDlSap[0].pst, - gCb->u.dlCb->udxDlSap[0].suId, cfmInfo); - RETVALUE(ROK); -} /* pjCfgPrcSduSta */ - - - -/** - * @brief - * This primitive to update the ROHC Comp details in PJRB Cb. - * - * @b Description: - * 1. This primitive to update the ROHC comp detils in PJRB Cb. - * - * @param [in] pjRbCb - RB Control Block - * @param [in] ueCb - Ue Control Block - * @param [in] hdrCompCfg- Comp Cfg Information - * - * @return ROK - * - */ -#ifdef ANSI -PRIVATE S16 pjCfgUpdDlCompInfo -( -PjCb *gCb, -PjDlRbCb *rbCb, -PjDlUeCb *ueCb, -UdxHdrCompCfg *rohcCfg -) -#else -PRIVATE S16 pjCfgUpdDlCompInfo(gCb, rbCb, ueCb, rohcCfg) -PjCb *gCb; -PjDlRbCb *rbCb; -PjDlUeCb *ueCb; -UdxHdrCompCfg *rohcCfg; -#endif -{ - U16 profId; - U8 idx; - S16 ret; - - TRC3(pjCfgUpdDlCompInfo); - - /* Initialization */ - ret = ROK; - profId = 0; - idx = 0; - - RLOG2(L_DEBUG, "pjCfgUpdCompInfo - Received for -- cellId(%d),RbId(%d)", - rbCb->rbId, ueCb->key.ueId); - - /* Header Compresion information present */ - if(rohcCfg->hdrCompUsed) - { - /* Header Compression is enabled */ - rbCb->rohc.hdrCmpUsed = TRUE; - - /* User Can Configure multipel profiles. Maximum profile ID should be used */ - for(; idxrohcInfo.profLst[idx] )&& - (profId < rohcProfId[idx])) - profId = rohcProfId[idx]; - } - } - else - { - /* Header Compression is disabled */ - rbCb->rohc.hdrCmpUsed = FALSE; - profId = 0x0000; - } - - /* Store the profile Id and MaxCid */ - - rbCb->rohc.profId = profId; - rbCb->rohc.maxCid = rohcCfg->rohcInfo.maxCid; - - /* Store the ue Details in Compressor Context */ - rbCb->cmpCxt.ueId = ueCb->key.ueId; - rbCb->cmpCxt.cellId = ueCb->key.cellId; - rbCb->cmpCxt.rbId = rbCb->rbId; - rbCb->cmpCxt.rbType = rbCb->rbType; - - RLOG2(L_DEBUG, "pjCfgUpdCompInfo - Selected -- profId(%d),maxCid(%d)", - rbCb->rohc.profId, rbCb->rohc.maxCid); - - - /* Compress Init */ - if(rbCb->rohc.hdrCmpUsed) - { - ret=pjUtlDlCmpInit(gCb, rbCb); - } - - RETVALUE(ret); -} /* pjCfgUpdCompInfo */ - - -/** - * @brief - * This primitive to delete RB from Ue Cb. - * - * @b Description: - * 1. To delete the PJRB Cb from UeCb. - * - * @param [in] ueCb - Ue Control Block - * @param [in] rbCb - Rb Control Block - * - * @return ROK - * - */ -#ifdef ANSI -PUBLIC S16 pjCfgDelPjDlRbCb -( -PjCb *gCb, -PjDlUeCb *ueCb, -PjDlRbCb *rbCb -) -#else -PUBLIC S16 pjCfgDelPjDlRbCb(gCb,ueCb,rbCb) -PjCb *gCb; -PjDlUeCb *ueCb; -PjDlRbCb *rbCb; -#endif -{ - S16 ret; -/* kw005.201 added support for L2 measurement */ -#ifdef LTE_L2_MEAS -#endif - TRC3(pjCfgDelPjDlRbCb); - - /* Initialization */ - ret = ROK; - - /* RbCb is present and Configured for PDCP */ - if(NULLP != rbCb) - { - RLOG_ARG1(L_DEBUG, DBG_UEID,ueCb->key.ueId, - "Delete RB Req Received for -- rbId (%d)",rbCb->rbId); - -#ifdef LTE_L2_MEAS - PJ_UPD_L2_DECR_PER_QCI_RB_COUNT(gCb, rbCb); -#endif - rbCb->ueCb = NULLP; -#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) - /* Stop off board timers */ - if(PJ_DIR_DL & rbCb->dir) - pjStopTmr(gCb, (PTR)rbCb, PJ_EVT_DL_OBD_TMR); -#endif - /* Deinit Tx Buffers */ - pjDbmTxDeInit(gCb, &rbCb->dlCb.txBuf); - pjUtlEmptyDlPktList(gCb, rbCb); - - if (rbCb->dlCb.staRep != NULL) - { - PJ_FREE_BUF(rbCb->dlCb.staRep); - } - - if (PJ_SRB == rbCb->rbType) - { - ueCb->numSrbs--; - } - else if(PJ_DRB == rbCb->rbType) - { - ueCb->numDrbs--; - if (rbCb->rohc.hdrCmpUsed) - { - pjUtlCmpClose(gCb,rbCb->cmpCxtId); - } - } - - /* Free the rbCb */ - pjDbmDelDlRbCb(gCb,rbCb->rbId, rbCb->rbType, &rbCb, PJ_CFG_PDCP,ueCb); - } - RETVALUE(ret); -} /* pjCfgDelPjRBCb */ - - -/** - * @brief - * Handler to process the downlink re-establishment Request for SRB1 during - * RRC Re-Establishment request. - * - * @b Description: - * 1. This primitive is used to re-establish SRB1 only during RRC Re-establishment - * 2. New Security Algo will applied - * - * @param [in] gCb - PDCP Instance Control block. - * @param [in] reEstReq - Entity Configuration to be done. - * @param [out] reEstCfm - Entity Configuration cfm. - * - * @return ROK - * - */ -#ifdef ANSI -PUBLIC S16 pjCfgDlReEstReq -( -PjCb *gCb, -UdxReEstReqInfo *reEstReq, -UdxReEstCfmInfo *reEstCfm -) -#else -PUBLIC S16 pjCfgDlReEstReq (gCb, reEstReq, reEstCfm) -PjCb *gCb; -UdxReEstReqInfo *reEstReq; -UdxReEstCfmInfo *reEstCfm; -#endif -{ - S16 ret; - PjDlRbCb *rbCb; - CmLteRlcId rlcId; - - TRC3(pjCfgDlReEstReq); - - /* Initialization */ - rlcId.cellId = reEstReq->pdcpId.cellId; - rlcId.ueId = reEstReq->pdcpId.ueId; - rlcId.rbId = reEstReq->pdcpId.rbId; - rlcId.rbType = reEstReq->pdcpId.rbType; - - RLOG2(L_DEBUG, "ReEst Req Received for -- cellId(%d),ueId(%d)", - reEstReq->pdcpId.cellId, reEstReq->pdcpId.ueId); - - ret = pjDbmFetchDlRbCb(gCb,rlcId,&rbCb); - - /* Ue Cb is not present */ - if( ROK != ret || NULLP == rbCb) - { - RLOG_ARG2(L_ERROR, DBG_UEID,rlcId.ueId, "CellId[%u]:RbId[%d] not found", - rlcId.cellId, rlcId.rbId); - /* Fill entCfm structure */ - PJ_CFG_FILL_REESTREQ_CFM(reEstCfm, reEstReq->pdcpId.ueId,reEstReq->pdcpId.cellId, - reEstReq->transId, CPJ_CFG_CFM_NOK); - RETVALUE(ret); - } - - /* Copy Security Information */ - cmMemcpy(&rbCb->ueCb->secInfo.intInfo.intKey[0], &reEstReq->intKey[0], PJ_INTG_KEY_LEN); - cmMemcpy(&rbCb->ueCb->secInfo.cipherInfo.cpKey[0], &reEstReq->ctrlplnKey[0], PJ_CIPHER_KEY_LEN); - cmMemcpy(&rbCb->ueCb->secInfo.cipherInfo.upKey[0], &reEstReq->usrplnKey[0], PJ_CIPHER_KEY_LEN); - - /* Mark Security Action Done */ - rbCb->ueCb->secInfo.secAct = TRUE; - - /* update the status as success. Chances of failure after this is minimal*/ - PJ_CFG_FILL_REESTREQ_CFM(reEstCfm, reEstReq->pdcpId.ueId,reEstReq->pdcpId.cellId, - reEstReq->transId, CPJ_CFG_CFM_OK); - -#ifdef PJ_SEC_ASYNC - /* In case of Async need to save the cfm information */ - pjUtlDlSaveCfmInfo(gCb, rbCb->ueCb, PJ_REEST_ASYNC_CFM, TRUE, ENTPJ, - (PTR)reEstCfm, NULLP); - PJ_FREE(gCb,reEstCfm, sizeof(CpjReEstCfmInfo)); -#endif - - /* Call ReEst for SRB1 */ - pjUtlDlReEstSrb1(gCb, rbCb); - - RETVALUE(ROK); -} /* pjCfgReEstReq */ - -#ifdef LTE_L2_MEAS - -PRIVATE S16 pjAddToDlL2Meas(PjCb *gCb, PjDlRbCb *pjRbCb,U8 cellId,U16 ueId) -{ - PjL2MeasEvtCb *measEvtCb = NULLP; - PjL2MeasCb *measCb = NULLP; - U16 cntr; - - - for(cntr = 0; cntr < LPJ_MAX_L2MEAS; cntr++) - { - measEvtCb = &gCb->u.dlCb->pjL2Cb.pjL2EvtCb[cntr]; - measCb = &(measEvtCb->measCb); - - if (measCb->measType & LPJ_L2MEAS_DL_DISC) - { - pjUtlPlcMeasDatInDlL2Sts(&measCb->measData[pjRbCb->qci], - &pjRbCb->rbL2Cb, measCb->measType); - measCb->qci[pjRbCb->qci] = pjRbCb->qci; - - measCb->measData[pjRbCb->qci].totDrbsPerQci++; - } - } - RETVALUE(ROK); -}/*pjAddToDlL2Meas*/ -#endif /*LTE_L2_MEAS*/ - -/*@}*/ - -/********************************************************************30** - - End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_cfg_ul.c b/src/5gnrpdcp/pj_cfg_ul.c deleted file mode 100755 index 1224cbf6f..000000000 --- a/src/5gnrpdcp/pj_cfg_ul.c +++ /dev/null @@ -1,1585 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: LTE PDCP - Configuration Manager file - - Type: C source file - - Desc: It contains the following configuraiton primtives - -- pjCfgAddRb - -- pjCfgReCfgRb - -- pjCfgDelRb - -- pjCfgReEstRb - -- pjCfgDelUe - -- pjCfgPrcSecCfg - -- pjCfgUeIdChng - -- pjCfgPrcCount - -- pjCfgPrcSduSta - - File: pj_cfg_ul.c - -*********************************************************************21*/ -static const char* RLOG_MODULE_NAME="PDCP"; -static int RLOG_MODULE_ID=1024; -static int RLOG_FILE_ID=213; - -/** @file gp_pj_cfg.c -@brief LTE PDCP Configuration Module -**/ - - -/* header (.h) include files */ -#include "envopt.h" /* environment options */ -#include "envdep.h" /* environment dependent */ -#include "envind.h" /* environment independent */ - -#include "gen.h" /* general */ -#include "ssi.h" /* system services interface */ -#include "cm5.h" /* Timer Functions */ -#include "cm_lte.h" /* common LTE header file */ -#include "cm_hash.h" /* common hash module file */ -#include "cm_llist.h" /* common list header file */ -#include "cpj.h" /* RRC layer */ -#include "pju.h" /* PDCP service user */ -#include "lpj.h" /* RRC layer */ -#include "pj_env.h" /* RLC environment options */ -#include "pj.h" /* RLC layer */ -#include "pj_ul.h" -#include "pj_err.h" - - - -/* header/extern include files (.x) */ - -#include "gen.x" /* general */ -#include "ssi.x" /* system services interface */ -#include "cm_lib.x" /* common library */ -#include "cm5.x" /* Timer Functions */ -#include "cm_hash.x" /* common hash module */ -#include "cm_lte.x" /* common LTE file */ -#include "cm_llist.x" /* common list header file */ -#include "cpj.x" /* RRC layer */ -#include "pju.x" /* PDCP service user */ -#include "lpj.x" /* LM Interface */ -#include "pj.x" /* RLC layer */ -#include "pj_udx.h" -#include "pj_udx.x" -#include "pj_ul.x" - -/* Proto types declarations for local functions */ - -PRIVATE S16 pjCfgFillPjUlRbCb ARGS (( -PjCb *gCb, -PjUlRbCb *rbCb, -PjUlUeCb *ueCb, -U8 isHo, -CpjCfgEnt *cfgEnt, -CpjCfmEnt *cfmEnt -)); - -PRIVATE S16 pjCfgUpdUlCompInfo ARGS (( -PjCb *gCb, -PjUlRbCb *rbCb, -PjUlUeCb *ueCb, -CpjHdrCompCfg *rohcCfg -)); - -#ifdef LTE_L2_MEAS -PRIVATE S16 pjAddToUlL2Meas ARGS (( -PjCb *gCb, -PjUlRbCb *kwRbCb, -U8 cellId, -U16 ueId -)); -#endif - -/* Store the Profile ID into array index */ -/* RRC is not sending the profile id directly. It will give - the for all the profiles with True/False. PDCP will derive the profile - based on this profile Id list */ - -PRIVATE U16 rohcProfId[CPJ_MAX_ROHC_PROF_LIST]= { 0x0001, 0x0002, 0x0003, 0x0004, - 0x0006, 0x0101, 0x0102, 0x0103, - 0x0104}; -/** @addtogroup cfgdata */ -/*@{*/ -/** -* @brief -* -* Hanlder to process the configuration recieved from the upper layer and update the pdcp -* data base. -* -* @b Description: -* 1. This function create a new PDCP RB Cb. @n -* 2. Newly created PDCP RB Cb will be placed in Data base with the configuration -* informtion received. @n -* 3. Return Success or Failure to the caller with reason and status -* information. @n - - * @param [in] ueId - UE Identifier - * @param [in] cellId - CELL Identifier - * @param [in] entCfg - Entity Configuration to be done. - * @param [out] entCfm - Entity Confirmation. - * - * @return ROK - */ -#ifdef ANSI -PUBLIC S16 pjCfgAddUlRb -( -PjCb *gCb, -CmLteRnti ueId, -CmLteCellId cellId, -U8 isHo, -CpjCfgEnt *entCfg, -PjUlUeCb **ueCb, -CpjCfmEnt *entCfm -) -#else -PUBLIC S16 pjCfgAddUlRb (gCb, ueId, cellId,isHo, entCfg, entCfm) -PjCb *gCb; -CmLteRnti ueId; -CmLteCellId cellId; -U8 isHo; -CpjCfgEnt *entCfg; -PjUlUeCb **ueCb; -CpjCfmEnt *entCfm; -#endif -{ - S16 ret; - PjUlRbCb *rbCb; /* Rb Cb Pointer */ - - TRC3(pjCfgAddUlRb); - - /* Initialization */ - ret = ROK; - rbCb = NULLP; - - RLOG2(L_DEBUG, "pjCfgAddRb- Received with -- cellId(%d),ueId(%d)", - cellId, ueId); - - if( NULLP == *ueCb) - { - /* Ue Cb is not present, Create Ue Cb */ - if ( pjDbmCreateUlUeCb(gCb, ueId, cellId, ueCb) != ROK) - { - /* Ue Cb allocation failed */ - PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\ - CPJ_CFG_REAS_UE_CREAT_FAIL); - - RLOG_ARG1(L_ERROR,DBG_UEID,ueId, "Creating UE Cb Failed -- cellId(%d)", - cellId); - RETVALUE(ret); - } - } - - (*ueCb)->inst = gCb->init.inst; - /* Rb Id is allowed range or not */ - PJ_VALIDATE_RBID(ueId, entCfg->rbId, entCfg->rbType, ret); - if ( ROK != ret) - { - PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\ - CPJ_CFG_REAS_INVALID_RBID); - - RLOG_ARG2(L_ERROR,DBG_UEID,ueId, "Invalid RB ID-- cellId(%d),RB Id(%d)", - cellId, entCfg->rbId); - RETVALUE(ret); - } - - - /* Find Rb Cb already exist or not */ - PJ_DBM_FETCH_UL_RBCB(entCfg->rbId, entCfg->rbType, (*ueCb), rbCb); - - if (NULLP != rbCb) - { - RLOG_ARG2(L_WARNING, DBG_UEID,ueId, "CellId [%u]:RbId[%d] already exists", - cellId,entCfg->rbId); - /* Rb Cb already exist for pdpcp */ - PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\ - CPJ_CFG_REAS_SAME_RBID); - RETVALUE(RFAILED); - } - else if (NULLP == rbCb) - { - /* Create Rb Cb and place in Ue Cb */ - rbCb = pjDbmCreateUlRbCb(gCb, entCfg->rbId, entCfg->rbType, *ueCb, PJ_CFG_PDCP); - if(NULLP == rbCb) - { - RLOG_ARG2(L_ERROR, DBG_UEID, ueId,"CellId [%u]:Creation of rbCb with id [%d] failed", - cellId, entCfg->rbId); - /* Create Rb Cb Failed*/ - PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\ - CPJ_CFG_REAS_ENT_CREAT_FAIL); - RETVALUE(RFAILED); - } - } - - /* Copy the Recived information into RbCb */ - ret = pjCfgFillPjUlRbCb(gCb, rbCb, *ueCb,isHo, entCfg , entCfm); - - /* Fill the Cfm status and Reason */ - PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_OK,\ - CPJ_CFG_REAS_NONE); - - RETVALUE(ret); -} /* pjCfgAddRb */ - -/** -* @brief -* -* Hanlder to update the PJRB with the received infromation during -* configuration or re configuration. -* -* @b Description: -* 1. update the data base with the new configuration informtion received. @n -* 2. update the data base with the new re-configuration informtion received. @n -* 3. If required Initiliaze the tx/rx Buffers and Timers. @n -* 4. Return Success or Failure to the caller with reason and status -* information. @n -* - * @param [out] rbCb - RB Control Block - * @param [out] entCfm - PDCP Entiry Confirmation - * @param [in] ueCb - UE Control Block - * @param [in] entCfg - PDCP Entity Configuration - * - * @return ROK - */ -#ifdef ANSI -PRIVATE S16 pjCfgFillPjUlRbCb -( -PjCb *gCb, -PjUlRbCb *pjRbCb, -PjUlUeCb *ueCb, -U8 isHo, -CpjCfgEnt *cfgEnt, -CpjCfmEnt *cfmEnt -) -#else -PRIVATE S16 pjCfgFillPjUlRbCb(gCb, pjRbCb, ueCb, isHo, cfgEnt, cfmEnt) -PjCb *gCb; -PjUlRbCb *pjRbCb; -PjUlUeCb *ueCb; -U8 isHo; -CpjCfgEnt *cfgEnt; -CpjCfmEnt *cfmEnt; -#endif -{ - S16 ret; - U8 *bitMap; /* Bitmap status report buffer */ - U16 bMapLen; /* Bit Map length */ - /* kw005.201 added support for L2 measurement */ - - TRC3(pjCfgFillPjUlRbCb); - - /* Initialization */ - ret = ROK; - bMapLen = 0; - - RLOG_ARG3(L_DEBUG,DBG_UEID,ueCb->key.ueId,"Received Fill RB Req For " - "cellId(%d), rbId(%d), cfgType(%d)", - ueCb->key.cellId, cfgEnt->rbId, cfgEnt->cfgType); - - switch (cfgEnt->cfgType) - { - /* Cfg Type received as ADD RB */ - case CPJ_CFG_ADD: - { - pjRbCb->state = PJ_STATE_NORMAL; - pjRbCb->rbId = cfgEnt->rbId; - pjRbCb->rbType = cfgEnt->rbType; - pjRbCb->mode = cfgEnt->m.addCfg.rlcInfo.mode; - pjRbCb->dir = cfgEnt->m.addCfg.rlcInfo.dir; - pjRbCb->ueCb = ueCb; - - if(PJ_SRB == pjRbCb->rbType) - { - /* SN length is fixed for SRB */ - pjRbCb->snLen = PJ_SRB_SN_LEN; - ueCb->numSrbs++; - } - else - { - if (CM_LTE_MODE_UM == pjRbCb->mode) - { /* SN length can be 7 bit or 12 bit in UM mode */ - pjRbCb->snLen = cfgEnt->m.addCfg.rlcInfo.m.rlcUm.pdcpSNSize; -#ifdef NR_PDCP_DRB_SN_18_BIT - pjRbCb->snLen = PJ_18_BIT_SN; -#else - pjRbCb->snLen = PJ_12_BIT_SN; -#endif - } - else - { - /* SN length can be 12/15 bit for AM mode */ - pjRbCb->snLen = cfgEnt->m.addCfg.rlcInfo.m.rlcAm.pdcpSNSize; -#ifdef NR_PDCP_DRB_SN_18_BIT - pjRbCb->snLen = PJ_18_BIT_SN; -#else - pjRbCb->snLen = PJ_12_BIT_SN; -#endif - if (isHo) - { - pjRbCb->state = PJ_STATE_HO; - } - } - ueCb->numDrbs++; - } - /* Initialize all off board timers */ -#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) - cmInitTimers(&pjRbCb->ulCb.obdTmr,PJ_RB_MAX_TIMERS); -#endif - - RLOG_ARG2(L_DEBUG,DBG_UEID,ueCb->key.ueId, - "RB Add Req Received with - Dir(%d),mode(%d)", - pjRbCb->dir, pjRbCb->mode); - - pjRbCb->ulCb.discReqd = cfgEnt->m.addCfg.discReqd; - pjRbCb->ulCb.staRepReqd = cfgEnt->m.addCfg.rlcInfo.m.rlcAm.statusRepReqd; - - /*Initialization for Rx Buf */ - gCb->pjGenCfg.nmbUlBins = PJ_MAX_HASH_BINS; - pjDbmBufInit(gCb, &pjRbCb->ulCb.recBuf,gCb->pjGenCfg.nmbUlBins); - cmLListInit(&pjRbCb->ulCb.ulPktLst); - //pjRbCb->ulCb.lastSubCnt = 0xffffffff; - - - /* Update the Compressor Informatio in Rb Cb */ - if(cfgEnt->rbType == CM_LTE_DRB) - { - ret=pjCfgUpdUlCompInfo(gCb, pjRbCb, ueCb,&cfgEnt->m.addCfg.hdrCompCfg); -/* kw005.201 added support for L2 measurement */ -#ifdef LTE_L2_MEAS - pjRbCb->qci = cfgEnt->m.addCfg.qci; - pjAddToUlL2Meas(gCb,pjRbCb, - ueCb->key.cellId,ueCb->key.ueId); -#endif - } - /* TODO: once APP and RRC changes are done, we can enable the below line */ - //pjRbCb->reOrdrTmrVal = cfgEnt->m.addCfg.reOrdrTmrVal; - pjRbCb->reOrdrTmrVal = 8000; - cmInitTimers(&(pjRbCb->ulCb.tReordTmr), 1); - break; - } - - /* Cfg Type received as Modify RB */ - case CPJ_CFG_MODIFY: - { - /* Store the received Information */ - if(CPJ_RECFG_DISRQD & cfgEnt->m.modCfg.bitFlag) - pjRbCb->ulCb.discReqd = cfgEnt->m.modCfg.discReqd; - - if(CPJ_RECFG_REORDTMR & cfgEnt->m.modCfg.bitFlag) - { - - /* TODO: once APP and RRC changes are done, we can enable the below line */ - //pjRbCb->reOrdrTmrVal = cfgEnt->m.modCfg.reOrdrTmrVal; - pjRbCb->reOrdrTmrVal = 8000; - Bool tmrRunning = pjChkTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_REORD_TMR); - if(tmrRunning) - { - /* update RX_REORD to RX_NEXT; */ - pjRbCb->ulCb.rxReord = pjRbCb->ulCb.rxNext; - - /* stop and restart t-Reordering. */ - pjStopTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_REORD_TMR); - pjStartTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_REORD_TMR); - } - } - - /* Header Compression profile has been modified */ - if(TRUE == cfgEnt->m.modCfg.hdrCompCfg.hdrCompUsed) - { - /* Close All the channels */ - pjUtlUlCmpReset(gCb, pjRbCb); - pjCfgUpdUlCompInfo(gCb, pjRbCb, ueCb, &cfgEnt->m.modCfg.hdrCompCfg); - } - - /* In case of Hand off scenario: At Target eNode-B, - Handoff information will send in re-cfg req */ - - if(TRUE & cfgEnt->m.modCfg.hoInfo.isHoPres) - { - /* Store the HO information and call for Status Report - * Generation also */ - - /* Down Up Lin Information present */ - if(CPJ_HO_UL & cfgEnt->m.modCfg.hoInfo.isHoPres) - { - RLOG_ARG2(L_DEBUG,DBG_UEID,ueCb->key.ueId, - "Received PDCP Update from Application for dir(%d), mode(%d)", - pjRbCb->dir, pjRbCb->mode); - - pjRbCb->ulCb.rxDeliv = cfgEnt->m.modCfg.hoInfo.ulCount; - pjRbCb->ulCb.rxNext = cfgEnt->m.modCfg.hoInfo.ulCount; - if (pjRbCb->snLen != cfgEnt->m.modCfg.hoInfo.snLen) - { - pjRbCb->snLen = cfgEnt->m.modCfg.hoInfo.snLen; - } - /* Store the Count in ulCb, this is needed while sending PDCP Status Report */ - bMapLen = cfgEnt->m.modCfg.hoInfo.numBits; - bitMap = cfgEnt->m.modCfg.hoInfo.ulBitMap; - - /* Build and send the Status Report to RLC */ - /* Send the FMS & bitmap retrieved now from App */ - RLOG_ARG0(L_DEBUG,DBG_UEID,ueCb->key.ueId, - "Sending PDCP Status Report to UE "); - - pjUlmBldStaRep(gCb, pjRbCb, pjRbCb->ulCb.rxDeliv, bitMap, bMapLen); - - pjUlmProcessUlPktQ(gCb, pjRbCb); - - pjRbCb->state = PJ_STATE_NORMAL; - - if(bMapLen != 0) - { - PJ_FREE(gCb, bitMap, (bMapLen / 8) * sizeof(U8)); - } - } - } - - break; - } - - /* Un Expected cfg type */ - default: - { - RLOG1(L_ERROR, "Invalid cfgType [%d]", cfgEnt->cfgType); - } - } - RETVALUE(ret); -} /* pjCfgFillPjRbCb */ - - - -/** -* @brief -* -* Hanlder to process the re-configuration for existing PJRB from the upper -* layer. -* -* @b Description: -* 1. This function fetch the PJRB from pdcp data base. @n -* 2. update the data base with the new configuration informtion received. @n -* 3. Return Success or Failure to the caller with reason and status -* information. @n -* -* @param [in] ueId - UE Identifier -* @param [in] cellId - CELL Identifier -* @param [in] entCfg - Entity Configuration to be done. -* @param [out] entCfm - Entity Confirmation. -* -* @return ROK -* -*/ -#ifdef ANSI -PUBLIC S16 pjCfgReCfgUlRb -( -PjCb *gCb, -PjUlUeCb *ueCb, -CpjCfgEnt *entCfg, -CpjCfmEnt *entCfm -) -#else -PUBLIC S16 pjCfgReCfgUlRb (gCb, ueCb, entCfg, entCfm) -PjCb *gCb; -PjUlUeCb *ueCb; -CpjCfgEnt *entCfg; -CpjCfmEnt *entCfm; -#endif -{ - S16 ret; - PjUlRbCb *rbCb; /* Rb Cb */ - - TRC3(pjCfgReCfgUlRb); - - /* Initialization */ - ret = ROK; - rbCb = NULLP; - - RLOG2(L_DEBUG, "Re-Cfg UL RB Req Received for -- cellId(%d),ueId(%d)", - ueCb->key.cellId,ueCb->key.ueId); - - /* Fetch Rb Cb */ - PJ_DBM_FETCH_UL_RBCB(entCfg->rbId, entCfg->rbType, ueCb, rbCb); - - /* Rb Cb is not present or Rb Cb is not configured for PDCP */ - if( NULLP == rbCb) - { - RLOG_ARG2(L_ERROR, DBG_UEID,ueCb->key.ueId, "CellId[%u]:RbId[%d] not found", - ueCb->key.cellId, entCfg->rbId); - /* Fill entCfm structure */ - PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\ - CPJ_CFG_REAS_PDCPID_UNKWN); - - RETVALUE(RFAILED); - } - - /* Copy the received infromation in to Rb Cb */ - ret = pjCfgFillPjUlRbCb(gCb, rbCb, ueCb,FALSE, entCfg , entCfm); - - /* Fill the Cfm status and Reason */ - PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_OK,\ - CPJ_CFG_REAS_NONE); - - - RETVALUE(ret); -} /* pjCfgReCfgRb */ - - -/** -* @brief -* This function deletes the existing RB(PDCP and RLC) from Ue Cb. -* -* @b Description: -* 1. Stop the timers and deallocate tx/rx Buffs for PJRB CB. @n -* 2. Delete the existing RB Cb(PDCP and RLC) from Ue Cb. @n -* -* @param [in] ueId - UE Identifier -* @param [in] cellId - CELL Identifier -* @param [in] entCfg - Entity Configuration to be done. -* @param [out] entCfm - Entity Confirmation. -* -* @return ROK -* -*/ -#ifdef ANSI -PUBLIC S16 pjCfgDelUlRb -( -PjCb *gCb, -PjUlUeCb *ueCb, -CpjCfgEnt *entCfg, -CpjCfmEnt *entCfm -) -#else -PUBLIC S16 pjCfgDelUlRb (gCb, ueId, cellId, entCfg, entCfm) -PjCb *gCb; -PjUlUeCb *ueCb; -CpjCfgEnt *entCfg; -CpjCfmEnt *entCfm; -#endif -{ - S16 ret; - PjUlRbCb *rbCb = NULLP; - - TRC3(pjCfgDelUlRb); - - /* Initialization */ - ret = ROK; - - RLOG2(L_DEBUG, "Del UL RB Req Received for -- cellId(%d),ueId(%d)", - ueCb->key.cellId, ueCb->key.ueId); - - /* Fetch RB Cb */ - PJ_DBM_FETCH_UL_RBCB(entCfg->rbId, entCfg->rbType, ueCb, rbCb); - - /* RB Cb is not present or not configured for PDCP */ - if (NULLP == rbCb) - { - RLOG_ARG2(L_ERROR, DBG_UEID,ueCb->key.ueId, "CellId[%u]:RbId[%d] not found", - ueCb->key.cellId, entCfg->rbId); - /* Fill entCfm structure with invalid pdcp Id */ - PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\ - CPJ_CFG_REAS_INVALID_PDCPID); - - RETVALUE(RFAILED); - } - /* Delete PDCP Related infromation from RB CB */ - ret= pjCfgDelPjUlRbCb(gCb, ueCb, rbCb); - - if(ROK != ret) - { - /* Fill entCfm structure with invalid pdcp Id */ - PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\ - CPJ_CFG_REAS_INVALID_PDCPID); - - RLOG_ARG2(L_ERROR, DBG_UEID, ueCb->key.ueId, "CellId[%u]:RbId[%d] not deleted", - ueCb->key.cellId, entCfg->rbId); - RETVALUE(ret); - } - /* Fill the Cfm status and Reason */ - PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_OK,\ - CPJ_CFG_REAS_NONE); - - - RETVALUE(ret); -} /* pjCfgDelRb */ - - - - -/** -* @brief -* -* This primitive is used to re-establish Uplink SRB2 and/or DRB'S during RRC connection -* re-configuration procedure. -* -* @b Description: -* 1. This function will trigger re-establishment for SRB2 and/or DRB's -* -* @param [in] gCB - Pdcp Instance Control block -* @param [in] ueId - UE Identifier -* @param [in] cellId - CELL Identifier -* @param [in] entCfg - Entity Configuration to be done. -* @param [out] entCfm - Entity Configuration cfm. -* -* @return ROK -* -*/ -#ifdef ANSI -PUBLIC S16 pjCfgReEstUlRb -( -PjCb *gCb, -PjUlUeCb *ueCb, -CpjCfgEnt *entCfg, -CpjCfmEnt *entCfm, -UdxCfmEnt *entDlCfgCfm -) -#else -PUBLIC S16 pjCfgReEstUlRb (gCb, *ueCb, entCfg, entCfm, entDlCfgCfm) -PjCb *gCb; -PjUlUeCb *ueCb; -CpjCfgEnt *entCfg; -CpjCfmEnt *entCfm; -UdxCfmEnt *entDlCfgCfm; -#endif -{ - PjUlRbCb *rbCb = NULLP; - - TRC3(pjCfgReEstUlRb); - - RLOG2(L_DEBUG, "Config ReEst Req Received for UL RB -- cellId(%d),ueId(%d)", - ueCb->key.cellId, ueCb->key.ueId); - - /* Fetch Rb Cb */ - PJ_DBM_FETCH_UL_RBCB(entCfg->rbId, entCfg->rbType, ueCb, rbCb); - - /* Rb Cb is not present or Rb Cb is not configured for PDCP */ - if( NULLP == rbCb ) - { - RLOG_ARG2(L_ERROR, DBG_UEID, ueCb->key.ueId, "CellId[%u]:RbId[%d] not found", - ueCb->key.cellId, entCfg->rbId); - /*This RB might be configured at PDCP-DL not at PDCP-UL (Rlc-UM RB with DL direction)*/ - PJ_MEM_CPY(entCfm, entDlCfgCfm, sizeof(CpjCfmEnt)); /* KW_FIX */ - - RETVALUE(RFAILED); - } - /* A Cfm with failure is sent if the re-establishment comes when RBs are not in - re-est state */ - if (ueCb->libInfo.state != PJ_STATE_REEST ) - { - /* Fill entCfm structure with invalid PDCP Id*/ - PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\ - CPJ_CFG_REAS_INVALID_STATE); - RLOG_ARG2(L_ERROR, DBG_UEID, ueCb->key.ueId, "CellId[%u]:W/o REEST ,RbId[%d] not reestblshd", - ueCb->key.cellId, entCfg->rbId); - RETVALUE(RFAILED); - } - - if(rbCb->rbType == PJ_SRB) - { - pjUlmReEstSrb(gCb,rbCb); - } - else - { - ueCb->libInfo.numReEstDrb++; - rbCb->state = PJ_STATE_REEST; - -#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) - rbCb->ulCb.obdCnt = 0; - rbCb->ulCb.transCmp = FALSE; - if(rbCb->mode == PJ_DRB_AM) - { - rbCb->ulCb.firstReEstCnt = rbCb->ulCb.rxDeliv; - } -#endif /* (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) */ - }/* if(rbType == .... */ - - if (entDlCfgCfm->status != CPJ_CFG_CFM_OK) - { - PJ_MEM_CPY(entCfm, entDlCfgCfm, - sizeof(CpjCfmEnt)); /* KW_FIX */ - } - - RETVALUE(ROK); -} /* pjCfgReEstRb */ - - - -/** -* @brief -* This primitive Delete Ue Cb from PDCP/RLC data base. -* -* @b Description: -* 1. This primitive Delete the Ue Cb from PDCP/RLC Data base. -* -* @param [in] ueId - UE Identifier -* @param [in] cellId - CELL Identifier -* @param [in] entCfg - Entity Configuration to be done. -* @param [out] entCfm - Entity Confirmation. -* -* @return ROK -* -*/ -#ifdef ANSI -PUBLIC S16 pjCfgDelUlUe -( -PjCb *gCb, -PjUlUeCb *ueCb, -CpjCfgEnt *entCfg, -CpjCfmEnt *entCfm -) -#else -PUBLIC S16 pjCfgDelUlUe (gCb, ueId, cellId, entCfg, entCfm) -PjCb *gCb; -PjUlUeCb *ueCb, -CpjCfgEnt *entCfg; -CpjCfmEnt *entCfm; -#endif -{ - S16 ret; - - TRC3(pjCfgDelUlUe); - - /* Initialization */ - ret = ROK; - - RLOG2(L_DEBUG, "pjCfgDelUe- Received for -- cellId(%d),ueId(%d)", - ueCb->key.cellId, ueCb->key.ueId); - - - /* Delete Ue Cb */ - ret=pjDbmDelUlUeCb(gCb, ueCb, FALSE); - - /* Fill the Cfm */ - PJ_CFG_FILL_CFG_CFM(entCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_OK,\ - CPJ_CFG_REAS_NONE); - - - RETVALUE(ret); -} /* pjCfgDelUe */ - - -/** -* @brief -* This primitive configure the security information of an Ue Cb. -* -* @b Description: -* 1. This primitive configure the security information of an Ue Cb. -* 2. Initilize the Integrity/Ciphering Channels if required. -* -* @param [in] secCfg - Entity Configuration to be done. -* @param [out] secCfm - Entity Configuration Cfm done. -* -* @return ROK -* -*/ -#ifdef ANSI -PUBLIC S16 pjCfgPrcSecUlCfg -( -PjCb *gCb, -CpjSecCfgReqInfo *secCfg, -CpjSecCfgCfmInfo *cfgCfm -) -#else -PUBLIC S16 pjCfgPrcSecUlCfg (gCb,secCfg, cfgCfm) -PjCb *gCb; -CpjSecCfgReqInfo *secCfg; -CpjSecCfgCfmInfo *cfgCfm; -#endif -{ - S16 ret; - PjUlUeCb *ueCb; - - TRC3(pjCfgPrcSecUlCfg); - - /* Initialization */ - ret = ROK; - ueCb = NULLP; - - RLOG2(L_DEBUG, "pjCfgPrcSecCfg- Received for -- cellId(%d),ueId(%d)", - secCfg->cellId, secCfg->ueId); - - /* Fetch Ue Cb */ - ret = pjDbmFetchUlUeCb(gCb, secCfg->ueId, secCfg->cellId, &ueCb); - - /* Ue Cb is not present */ - if( ROK != ret || NULLP == ueCb) - { - RLOG_ARG1(L_ERROR, DBG_CELLID, secCfg->cellId,"UeId[%u] not found", - secCfg->ueId); - /* Fill entCfm structure */ - PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\ - CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_UE_UNKWN); - RETVALUE(ret); - } - - ueCb->secInfo.selSecAct= secCfg->secCfg.selSecAct; - - /* Store Integrity Information */ - ueCb->secInfo.intInfo.algoType=secCfg->secCfg.integInfo.algoType; - cmMemcpy(&ueCb->secInfo.intInfo.intKey[0], &secCfg->secCfg.integInfo.intKey[0], CPJ_INTG_KEY_LEN); - - /* Store Ciphering Informaiton */ - ueCb->secInfo.cipherInfo.algoType=secCfg->secCfg.cipherInfo.algoType; - - cmMemcpy(ueCb->secInfo.cipherInfo.cpKey, - &secCfg->secCfg.cipherInfo.ctrlplnKey[0],CPJ_CIPHER_KEY_LEN); - - cmMemcpy(ueCb->secInfo.cipherInfo.upKey, - &secCfg->secCfg.cipherInfo.usrplnKey[0],CPJ_CIPHER_KEY_LEN); - - /* Security Activation Done */ - ueCb->secInfo.secAct = TRUE; - - if(TRUE == secCfg->secCfg.isHo) - { - ueCb->secInfo.firstMsg = FALSE; - } - else - { - ueCb->secInfo.firstMsg = TRUE; - } - - ueCb->secInfo.secCxt.cellId = secCfg->cellId; - ueCb->secInfo.secCxt.ueId = secCfg->ueId; - ueCb->secInfo.secCxt.dir = PJ_SEC_DIR_UL; - -#ifndef ALIGN_64BIT - RLOG_ARG3(L_DEBUG,DBG_UEID,secCfg->ueId, - "Security Paramters stored in UE CB are -- cellId(%d)," - " Integrity Algo(%ld), cipherAlgoType(%ld) ", - secCfg->cellId, ueCb->secInfo.intInfo.algoType, - ueCb->secInfo.cipherInfo.algoType); -#else - RLOG_ARG3(L_DEBUG,DBG_UEID,secCfg->ueId, - "Security Paramters stored in UE CB are -- cellId(%d)," - " Integrity Algo(%d), cipherAlgoType(%d) ", - secCfg->cellId, ueCb->secInfo.intInfo.algoType, - ueCb->secInfo.cipherInfo.algoType); -#endif - /* Open the Security Channels */ - - if(ueCb->secInfo.secAct) - { - -#ifdef PJ_SEC_ASYNC - ueCb->secInfo.secCxt.cfgTxId = ueCb->libInfo.nxtAvlbTxId; -#endif - - ret = pjUtlUlIntInit(gCb,ueCb); - - /* Integrity Init failed */ - if(ROK != ret) - { - PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\ - CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_INTINIT_FAILED); - - RETVALUE(ret); - - } - ret = pjUtlUlCpInit(gCb,ueCb); - /* Ciphering Control Plane Init failed */ - if(ROK != ret) - { - PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\ - CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_CCIPHR_FAILED); - - RETVALUE(ret); - - } - ret = pjUtlUlUpInit(gCb,ueCb); - - /* Ciphering User Plane Init failed */ - if(ROK != ret) - { - PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\ - CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_UCIPHR_FAILED); - - RETVALUE(ret); - } - } - - /* Fill Cfg Cfm with Status OK */ - PJ_CFG_FILL_SECCFG_CFM(cfgCfm, secCfg->ueId,secCfg->cellId,secCfg->transId,\ - CPJ_CFG_CFM_OK,CPJ_CFG_REAS_NONE); - - RETVALUE(ROK); -} /* pjCfgPrcSecCfg */ - - -/** -* @brief -* This primitive changes the ueId of existing Ue Cb. -* -* @b Description: -* -* 1. This function delete the UeCb from hashList. @n -* 2. Update the Ue Cb with the new Keys. @n -* 3. Insert the UeCb in hash list with new Key. @n -* -* @param [in] ueInfo - Old UE Information -* @param [in] newUeInfo - New UE Information -* @param [out] status - Status -* -* @return ROK -* -*/ -#ifdef ANSI -PUBLIC S16 pjCfgUlUeIdChng -( -PjCb *gCb, -CpjUeInfo *ueInfo, -CpjUeInfo *newUeInfo, -CmStatus *status -) -#else -PUBLIC S16 pjCfgUlUeIdChng (gCb, ueInfo, newUeInfo, status) -PjCb *gCb; -CpjUeInfo *ueInfo; -CpjUeInfo *newUeInfo; -CmStatus *status; -#endif -{ - PjUlUeCb *ueCb; - S16 ret; - - TRC3(pjCfgUlUeIdChng) - - ueCb = NULLP; - ret= ROK; - - RLOG2(L_DEBUG, "pjCfgUeIdChng- Recived for -- cellId(%d),ueId(%d)", - ueInfo->cellId, ueInfo->ueId); - - if ( (ueInfo->ueId == newUeInfo->ueId) && - (ueInfo->cellId == newUeInfo->cellId)) - { - status->reason = CPJ_CFG_REAS_SAME_UEID; - status->status = CPJ_CFG_CFM_NOK; - -#ifdef DEBUGP - RLOG_ARG3(L_ERROR,DBG_UEID,ueInfo->ueId, "Changing UE Id -- Failed :" - "old and New UeId are Same - cellId(%d),newCellId(%d), newUeId(%d)", - ueInfo->cellId, newUeInfo->cellId, newUeInfo->ueId); -#endif - RETVALUE(RFAILED); - } - - ret = pjDbmFetchUlUeCb(gCb, newUeInfo->ueId, newUeInfo->cellId, &ueCb); - if (ret == ROK) - { - -#ifdef DEBUGP - RLOG_ARG1(L_ERROR,DBG_UEID,ueInfo->ueId, - "Changing Ue ID Failed :New UeId already Exists -- cellId(%d)", - newUeInfo->cellId ); -#endif - status->reason = CPJ_CFG_REAS_SAME_UEID; - status->status = CPJ_CFG_CFM_NOK; - RETVALUE(RFAILED); - } - - ret = pjDbmFetchUlUeCb(gCb, ueInfo->ueId, ueInfo->cellId, &ueCb); - if (ret != ROK) - { - RLOG_ARG1(L_ERROR, DBG_CELLID, ueInfo->cellId,"UeId[%u] not found",ueInfo->ueId); - status->reason = CPJ_CFG_REAS_UE_UNKWN; - status->status = CPJ_CFG_CFM_NOK; - RETVALUE(RFAILED); - } - - ret = cmHashListDelete(&(gCb->u.ulCb->ueLstCp), (PTR) ueCb); - if (ret != ROK) - { - -#ifdef DEBUGP - RLOG_ARG1(L_ERROR,DBG_UEID,ueInfo->ueId, "cmHashListDelete Failed -- cellId(%d)", - ueInfo->cellId); -#endif - status->reason = CPJ_CFG_REAS_UE_CREAT_FAIL; - status->status = CPJ_CFG_CFM_NOK; - RETVALUE(RFAILED); - } - - /* update the hash key with new values */ - ueCb->key.ueId = newUeInfo->ueId; - ueCb->key.cellId = newUeInfo->cellId; - - ret = cmHashListInsert(&(gCb->u.ulCb->ueLstCp), (PTR)ueCb, - (U8 *)&(ueCb->key), (U16) sizeof(PjUeKey)); - - if (ret != ROK) - { -#ifdef DEBUGP - RLOG_ARG2(L_ERROR,DBG_UEID,ueInfo->ueId, - "cmHashListInsert Failed -- cellId(%d),New ueId(%d)", - newUeInfo->cellId, newUeInfo->ueId); -#endif - status->reason = CPJ_CFG_REAS_UE_CREAT_FAIL; - status->status = CPJ_CFG_CFM_NOK; - } - - RETVALUE(ret); -} /* pjCfgUeIdChng */ - - -/** -* @brief -* This primitive reports the Count informatin of all RBs of an Ue Cb. -* -* @b Description: -* 1. This function reports the count information of all the RBs of an UE. -* -* @param [in] ueId - UE Identifier -* @param [in] cellId - CELL Identifier -* @param [out] countCfm - Count Information -* -* @return ROK -* -*/ -#ifdef ANSI -PUBLIC S16 pjCfgPrcUlCount -( -PjCb *gCb, -CpjCountReqInfo *countReq, -CpjCountCfmInfo *countCfm, -UdxCountCfmInfo *cntCfm -) -#else -PUBLIC S16 pjCfgPrcUlCount (gCb, countReq, countCfm) -PjCb *gCb; -CpjCountReqInfo *countReq; -CpjCountCfmInfo *countCfm; -UdxCountCfmInfo *cntCfm; -#endif -{ - S16 ret; - PjUlUeCb *ueCb; - PjUlRbCb *rbCb; - U8 numdlRb; - U8 idx; - U8 idx1; - - TRC3(pjCfgPrcUlCount); - - /* Initialization */ - ueCb = NULLP; - rbCb = NULLP; - ret = ROK; - idx = 0; - idx1 = 0; - numdlRb = cntCfm->numRb; - - RLOG2(L_DEBUG, "pjCfgPrcCount - Count Request Received for - cellId(%d),ueId(%d)", - countReq->cellId, countReq->ueId); - - /* Fetch ue Cb */ - ret = pjDbmFetchUlUeCb(gCb, countReq->ueId, countReq->cellId, &ueCb); - countCfm->ueId = countReq->ueId; - countCfm->cellId = countReq->cellId; - countCfm->transId = countReq->transId; - - /* Ue Cb is not present */ - if( ROK != ret || NULLP == ueCb) - { - RLOG_ARG1(L_ERROR, DBG_CELLID, countReq->cellId,"UeId[%u] not found",countReq->ueId); - /* Fill entCfm structure */ - countCfm->numRb = cntCfm->numRb; - countCfm->status = CPJ_CFG_CFM_NOK; - countCfm->reason = CPJ_CFG_REAS_UE_UNKWN; - RETVALUE(ret); - } - - /* Loop through all DRBs */ - for(idx=0; idx < PJ_MAX_DRB_PER_UE; idx++) /* KW_FIX */ - { - rbCb = ueCb->drbCb[idx]; - /* RB is present and configured for PDCP Layer */ - if(NULLP != rbCb) - { - for(idx1=0; idx1 < numdlRb; idx1++) - { - if(rbCb->rbId == countCfm->countInfo[idx1].rbId) - { - countCfm->countInfo[idx1].ulCount= rbCb->ulCb.rxNext; - break; - } - else - { - countCfm->countInfo[countCfm->numRb].rbId= rbCb->rbId; - countCfm->countInfo[countCfm->numRb].dir = rbCb->dir; - countCfm->countInfo[countCfm->numRb].ulCount= rbCb->ulCb.rxNext; - countCfm->countInfo[countCfm->numRb].dlCount= 0; - countCfm->numRb++; - } - } - if(numdlRb == 0) - { - countCfm->countInfo[countCfm->numRb].rbId= rbCb->rbId; - countCfm->countInfo[countCfm->numRb].dir = rbCb->dir; - countCfm->countInfo[countCfm->numRb].ulCount= rbCb->ulCb.rxNext; - countCfm->countInfo[countCfm->numRb].dlCount= 0; - countCfm->numRb++; - - } - - } - - } - - /* Fill CountCfm with status and reason */ - if(countCfm->numRb) - { - countCfm->status =CPJ_CFG_CFM_OK; - countCfm->reason =CPJ_CFG_REAS_NONE; - } - else - { - countCfm->status =CPJ_CFG_CFM_NOK; - countCfm->reason =CPJ_CFG_REAS_NO_DRBS; - - } - - RETVALUE(ret); -} /* pjCfgPrcCount */ - -/** -* @brief -* This primitive reports SDU status information of all RBs of an Ue Cb. -* -* @b Description: -* 1. This primitive Trigger the Handoff Request procedure -* -* @param [in] ueId - UE Identifier -* @param [in] cellId - CELL Identifier -* @param [out] sduStaCfm - SDU Status Information -* -* @return ROK -* -*/ -#ifdef ANSI -PUBLIC S16 pjCfgPrcUlSduSta -( -PjCb *gCb, -CpjSduStaReqInfo *staReq, -UdxSduStaCfmInfo *staCfm -) -#else -PUBLIC S16 pjCfgPrcUlSduSta (gCb, staReq, staCfm) -PjCb *gCb; -CpjSduStaReqInfo *staReq; -UdxSduStaCfmInfo *staCfm; -#endif -{ - S16 ret; - PjUlUeCb *ueCb; - CpjSduStaCfmInfo *cfmInfo; - - TRC3(pjCfgPrcUlSduSta); - - /* Initialization */ - ret = ROK; - ueCb = NULLP; - - RLOG2(L_DEBUG, "pjCfgPrcSduSta - Received for -- cellId(%d),ueId(%d)", - staReq->cellId, staReq->ueId); - - - /* Fetch Ue Cb */ - ret = pjDbmFetchUlUeCb(gCb, staReq->ueId, staReq->cellId, &ueCb); - - /* UeCb is not present */ - if( ROK != ret || NULLP == ueCb) - { - RLOG_ARG1(L_ERROR, DBG_CELLID, staReq->cellId,"UeId[%u] not found",staReq->ueId); - /* Memory leak fix ccpu00135359 */ - PjCpjSapCb *cpjSap; - cpjSap = &gCb->u.ulCb->cpjSap; - if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,(Data **)&cfmInfo, - sizeof (CpjSduStaCfmInfo)) != ROK) - { - RLOG0(L_FATAL,"Memory allocation failed"); - RETVALUE(RFAILED); - } - - cfmInfo->ueId = staReq->ueId; - cfmInfo->cellId = staReq->cellId; - cfmInfo->transId = staReq->transId; - cfmInfo->status = CPJ_CFG_CFM_NOK; - cfmInfo->reason = CPJ_CFG_REAS_UE_UNKWN; - - /* Caller should return cfm with failure */ - RLOG_ARG1(L_DEBUG,DBG_UEID,staReq->ueId, "UE Cb is not found -- cellId(%d)", - staReq->cellId); - - /* Send Failure SduStaCfm */ - PjUiCpjSduStaCfm(&gCb->u.ulCb->cpjSap.pst, - gCb->u.ulCb->cpjSap.suId, cfmInfo); - - - RETVALUE(RFAILED); - } - - /* Call Ho Start handler for this UE */ - pjUtlUlReEstHO(gCb, ueCb); - - ueCb->hoInfo->transId = staReq->transId; - ueCb->hoInfo->staCfm = staCfm; - - if (ueCb->libInfo.numReEstCmp > 0) - { - if (ueCb->libInfo.numReEstCmp > ueCb->libInfo.numReEstDrb) - { - /* Error Case */ - ueCb->libInfo.numReEstDrb = 0; - ueCb->libInfo.numReEstCmp = 0; - } - else - { - ueCb->libInfo.numReEstDrb -= ueCb->libInfo.numReEstCmp; - ueCb->libInfo.numReEstCmp = 0; - } - } - - if (ueCb->libInfo.numReEstDrb == 0) - { - pjUtlUlSndSduStaCfm(gCb,ueCb); - } - - RETVALUE(ROK); -} /* pjCfgPrcSduSta */ - - - -/** - * @brief - * This primitive to update the ROHC Comp details in PJRB Cb. - * - * @b Description: - * 1. This primitive to update the ROHC comp detils in PJRB Cb. - * - * @param [in] pjRbCb - RB Control Block - * @param [in] ueCb - Ue Control Block - * @param [in] hdrCompCfg- Comp Cfg Information - * - * @return ROK - * - */ -#ifdef ANSI -PRIVATE S16 pjCfgUpdUlCompInfo -( -PjCb *gCb, -PjUlRbCb *rbCb, -PjUlUeCb *ueCb, -CpjHdrCompCfg *rohcCfg -) -#else -PRIVATE S16 pjCfgUpdUlCompInfo(gCb, rbCb, ueCb, rohcCfg) -PjCb *gCb; -PjUlRbCb *rbCb; -PjUlUeCb *ueCb; -CpjHdrCompCfg *rohcCfg; -#endif -{ - U16 profId; - U8 idx; - S16 ret; - - TRC3(pjCfgUpdUlCompInfo); - - /* Initialization */ - ret = ROK; - profId = 0; - idx = 0; - - RLOG2(L_DEBUG, "pjCfgUpdCompInfo - Received for -- cellId(%d),RbId(%d)", - rbCb->rbId, ueCb->key.ueId); - - /* Header Compresion information present */ - if(rohcCfg->hdrCompUsed) - { - /* Header Compression is enabled */ - rbCb->rohc.hdrCmpUsed = TRUE; - - /* User Can Configure multipel profiles. Maximum profile ID should be used */ - for(; idxrohcInfo.profLst[idx] )&& - (profId < rohcProfId[idx])) - profId = rohcProfId[idx]; - } - } - else - { - /* Header Compression is disabled */ - rbCb->rohc.hdrCmpUsed = FALSE; - profId = 0x0000; - } - - /* Store the profile Id and MaxCid */ - - rbCb->rohc.profId = profId; - rbCb->rohc.maxCid = rohcCfg->rohcInfo.maxCid; - - /* Store the ue Details in Compressor Context */ - rbCb->cmpCxt.ueId = ueCb->key.ueId; - rbCb->cmpCxt.cellId = ueCb->key.cellId; - rbCb->cmpCxt.rbId = rbCb->rbId; - rbCb->cmpCxt.rbType = rbCb->rbType; - - RLOG2(L_DEBUG, "pjCfgUpdCompInfo - Selected -- profId(%d),maxCid(%d)", - rbCb->rohc.profId, rbCb->rohc.maxCid); - - - /* Compress Init */ - if(rbCb->rohc.hdrCmpUsed) - { - ret=pjUtlUlCmpInit(gCb, rbCb); - } - - RETVALUE(ret); -} /* pjCfgUpdCompInfo */ - - -/** - * @brief - * This primitive to delete RB from Ue Cb. - * - * @b Description: - * 1. To delete the PJRB Cb from UeCb. - * - * @param [in] ueCb - Ue Control Block - * @param [in] rbCb - Rb Control Block - * - * @return ROK - * - */ -#ifdef ANSI -PUBLIC S16 pjCfgDelPjUlRbCb -( -PjCb *gCb, -PjUlUeCb *ueCb, -PjUlRbCb *rbCb -) -#else -PUBLIC S16 pjCfgDelPjUlRbCb(gCb,ueCb,rbCb) -PjCb *gCb; -PjUlUeCb *ueCb; -PjUlRbCb *rbCb; -#endif -{ - S16 ret; -/* kw005.201 added support for L2 measurement */ -#ifdef LTE_L2_MEAS_COMMENT - U8 evtIdx; - U8 qciIdx; -#endif - TRC3(pjCfgDelPjUlRbCb); - - /* Initialization */ - ret = ROK; - - RLOG0(L_DEBUG,"pjCfgDelPjRBCb- Recieved -- rbId() CfgState() "); - - /* RbCb is present and Configured for PDCP */ - if(NULLP != rbCb) - { - RLOG1(L_DEBUG, "pjCfgDelPjRBCb- Received for -- rbId (%d)", - rbCb->rbId); - -#ifdef LTE_L2_MEAS - /* This should be done for every counter added for UL */ - if((rbCb->rbL2Cb.l2Sts[PJ_L2MEAS_UL_LOSS] != NULLP) && - (rbCb->rbL2Cb.l2Sts[PJ_L2MEAS_UL_LOSS]->totDrbsPerQci > 0)) - { - rbCb->rbL2Cb.l2Sts[PJ_L2MEAS_UL_LOSS]->totDrbsPerQci--; - } -#endif - Bool tmrRunning = pjChkTmr(gCb,(PTR)rbCb,PJ_EVT_UL_REORD_TMR); - if(tmrRunning) - { - pjStopTmr(gCb,(PTR)rbCb, PJ_EVT_UL_REORD_TMR); - } - - - rbCb->ueCb = NULLP; - -#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) - /* Stop off board timers */ - - if(PJ_DIR_UL & rbCb->dir) - if(rbCb->ulCb.obdTmr.tmrEvnt == PJ_EVT_DL_OBD_TMR) - { - pjStopTmr(gCb, (PTR)&rbCb, PJ_EVT_UL_OBD_TMR); - } -#endif - - /* Deinit Rx Buffers */ - pjDbmRxDeInit(gCb,&rbCb->ulCb.recBuf); - pjUtlEmptyUlPktList(gCb, rbCb); - - /* Close the Comp channels */ - if (PJ_SRB == rbCb->rbType) - { - ueCb->numSrbs--; - } - else if (PJ_DRB == rbCb->rbType) - { - ueCb->numDrbs--; - if (rbCb->rohc.hdrCmpUsed) - { - pjUtlCmpClose(gCb,rbCb->cmpCxtId); - } - } - /* Free the rbCb */ - pjDbmDelUlRbCb(gCb,rbCb->rbId, rbCb->rbType, &rbCb, PJ_CFG_PDCP, ueCb); - - } - RETVALUE(ret); -} /* pjCfgDelPjRBCb */ - - -/** - * @brief - * Handler to process the re-establishment Request for SRB1 during - * RRC Re-Establishment request. - * - * @b Description: - * 1. This primitive is used to re-establish SRB1 only during RRC Re-establishment - * 2. New Security Algo will applied - * - * @param [in] reEstReq - Entity Configuration to be done. - * @param [out] reEstCfm - Entity Configuration cfm. - * - * @return ROK - * - */ -#ifdef ANSI -PUBLIC S16 pjCfgUlReEstReq -( -PjCb *gCb, -CpjReEstReqInfo *reEstReq, -CpjReEstCfmInfo *reEstCfm -) -#else -PUBLIC S16 pjCfgUlReEstReq (gCb, reEstReq, reEstCfm) -PjCb *gCb; -CpjReEstReqInfo *reEstReq; -CpjReEstCfmInfo *reEstCfm; -#endif -{ - S16 ret; - PjUlUeCb *ueCb; - PjUlRbCb *rbCb; - CmLteRlcId rlcId; - - TRC3(pjCfgUlReEstReq); - - /* Initialization */ - ret = ROK; - rlcId.ueId = reEstReq->pdcpId.ueId; - rlcId.cellId = reEstReq->pdcpId.cellId; - rlcId.rbId = reEstReq->pdcpId.rbId; - rlcId.rbType = reEstReq->pdcpId.rbType; - - RLOG2(L_DEBUG, "pjCfgReEstReq- Received for -- cellId(%d),ueId(%d)", - rlcId.cellId, rlcId.ueId); - - ret = pjDbmFetchUlRbCb(gCb, rlcId,&rbCb); - - - /* Ue Cb is not present */ - if( ROK != ret || NULLP == rbCb) - { - RLOG_ARG2(L_ERROR, DBG_UEID,rlcId.ueId, "CellId[%u]:RbId[%d] not found", - rlcId.cellId, rlcId.rbId); - /* Fill entCfm structure */ - PJ_CFG_FILL_REESTREQ_CFM(reEstCfm, rlcId.ueId,rlcId.cellId, - reEstReq->transId, LCM_PRIM_NOK); - RETVALUE(ret); - } - - ueCb = rbCb->ueCb; - - /* Copy Security Information */ - cmMemcpy(&ueCb->secInfo.intInfo.intKey[0], &reEstReq->intKey[0], PJ_INTG_KEY_LEN); - cmMemcpy(&ueCb->secInfo.cipherInfo.cpKey[0], &reEstReq->ctrlplnKey[0], PJ_CIPHER_KEY_LEN); - cmMemcpy(&ueCb->secInfo.cipherInfo.upKey[0], &reEstReq->usrplnKey[0], PJ_CIPHER_KEY_LEN); - - /* Mark Security Action Done */ - ueCb->secInfo.secAct = TRUE; - - reEstCfm->transId = reEstReq->transId; - reEstCfm->ueId = reEstReq->pdcpId.ueId; - reEstCfm->cellId = reEstReq->pdcpId.cellId; - - /* Save the information */ -#ifdef PJ_SEC_ASYNC - pjUtlUlSaveCfmInfo(gCb,rbCb->ueCb, PJ_REEST_ASYNC_CFM, FALSE, ENTPJ, - (PTR)reEstCfm, NULLP); - PJ_FREE(gCb,reEstCfm, sizeof(CpjReEstCfmInfo)); -#endif /* PJ_SEC_ASYNC */ - - /* Call ReEst for SRB1 */ - pjUtlUlReEstSrb1(gCb,rbCb); - - RETVALUE(ROK); -} /* pjCfgReEstReq */ - -#ifdef LTE_L2_MEAS -/** - * @brief - * Handler to add measCb to rbCb. - * - * @b Description: - * Handler to add measCb to rbCb. - * - * - * @return ROK - * - */ -PRIVATE S16 pjAddToUlL2Meas(PjCb *tPjCb, PjUlRbCb *pjRbCb,U8 cellId, U16 ueId) -{ - U32 cntr; - - RLOG1(L_DEBUG, "L2_MEAS_ADD Adding UE ueid %d ", ueId); - - for(cntr = 0; cntr < LPJ_MAX_L2MEAS; cntr++) - { - PjL2MeasCb *measCb = &tPjCb->u.ulCb->pjL2Cb.pjL2EvtCb[cntr].measCb; - - if (measCb->measType & LPJ_L2MEAS_UL_LOSS) - { - pjUtlPlcMeasDatInUlL2Sts(&measCb->measData[pjRbCb->qci], - &pjRbCb->rbL2Cb, measCb->measType); - measCb->qci[pjRbCb->qci] = pjRbCb->qci; - measCb->measData[pjRbCb->qci].totDrbsPerQci++; - measCb->numQci++; - } - } - RETVALUE(ROK); -}/*pjAddToDlL2Meas*/ -#endif - -/*@}*/ - -/********************************************************************30** - - End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_dbm.c b/src/5gnrpdcp/pj_dbm.c deleted file mode 100755 index 8f7a25fe2..000000000 --- a/src/5gnrpdcp/pj_dbm.c +++ /dev/null @@ -1,163 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: PDCP - Database module file - - Type: C source file - - Desc: Source code for Database Module functions such as, - - - pjDbmBufInit - - pjDbmInsTxEnt - - pjDbmGetTxEnt - - pjDbmGetTxEntSn - - pjDbmDelTxEnt - - pjDbmTxDeInit - - pjDbmInsRxEnt - - pjDbmGetRxEnt - - pjDbmDelRxEnt - - pjDbmRxDeInit - - File: pj_dbm.c - -*********************************************************************21*/ -static const char* RLOG_MODULE_NAME="PDCP"; -static int RLOG_MODULE_ID=1024; -static int RLOG_FILE_ID=214; - - -/* header (.h) include files */ -#include "envopt.h" /* environment options */ -#include "envdep.h" /* environment dependent */ -#include "envind.h" /* environment independent */ - -#include "gen.h" /* general */ -#include "ssi.h" /* system services interface */ -#include "cm5.h" /* Timer Functions */ -#include "cm_lte.h" /* common LTE header file */ -#include "cm_hash.h" /* common hash module file */ -#include "cm_llist.h" /* common list header file */ -#include "cpj.h" /* RRC layer */ -#include "pju.h" /* PDCP service user */ -#include "lpj.h" /* RRC layer */ -#include "pj_env.h" /* RLC environment options */ -#include "pj.h" /* RLC layer */ -#include "pj_err.h" - -/* extern (.x) include files */ -#include "gen.x" /* general */ -#include "ssi.x" /* system services interface */ -#include "cm_lib.x" /* common library */ -#include "cm5.x" /* Timer Functions */ -#include "cm_hash.x" /* common hash module */ -#include "cm_lte.x" /* common LTE file */ -#include "cm_llist.x" /* common list header file */ -#include "cpj.x" /* RRC layer */ -#include "pju.x" /* PDCP service user */ -#include "lpj.x" /* LM Interface */ -#include "pj.x" /* RLC layer */ - - - -/* local defines */ - -/* local externs */ - -/* forward references */ - -/* public variable declarations */ - -/* This structure holds all the global structs we need. */ - -/* private variable declarations */ - -/* private function declarations */ - -/** @file gp_pj_dbm.c -@brief PDCP DBM Module -**/ - -/***************************************************************************** - * HANDLER FOR THE TRANSMISSION BUFFER - ****************************************************************************/ - -/** - * - * @brief Handler to initialize Buffer - * - * @b Description - * This function is invoked by config to initialize the Buffer - * hash List - * - * @param[in] buf Rx/Tx Buffer Control Point - * @param[in] numBins number of Bins - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC S16 pjDbmBufInit -( -PjCb *gCb, -PjBuf *buf, /* !< Rx/Tx Buffer */ -U8 numBins /* !< number of Bins */ -) -#else -PUBLIC S16 pjDbmBufInit(gCb,buf, numBins) -PjCb *gCb; -PjBuf *buf; /* !< Rx/Tx Buffer */ -U8 numBins; /* !< number of Bins */ -#endif -{ - U8 hashIndex; /* HashIndex of array */ - - TRC3(pjDbmBufInit) - - RLOG1(L_DEBUG, "pjDbmBufInit(buf, numBins(%d)", numBins); - - /* Initialize CmLListCps*/ - PJ_ALLOC(gCb,buf->datQ, (sizeof(CmLListCp) * numBins)); -#if (ERRCLASS & ERRCLS_DEBUG) - if (buf->datQ == NULLP) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } -#endif /* (ERRCLASS & ERRCLS_DEBUG) */ - - for(hashIndex = 0; hashIndex < numBins; hashIndex++) - { - cmLListInit(&buf->datQ[hashIndex]); - } - - /* Initialistations of buf */ - buf->numEntries = 0; - buf->numBins = numBins; - - RETVALUE(ROK); -} /* pjDbmBufInit */ - - -/********************************************************************30** - - End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_dbm_dl.c b/src/5gnrpdcp/pj_dbm_dl.c deleted file mode 100755 index 29e3db844..000000000 --- a/src/5gnrpdcp/pj_dbm_dl.c +++ /dev/null @@ -1,1332 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: PDCP - Database module file - - Type: C source file - - Desc: Source code for Database Module functions such as, - - - pjDbmBufInit - - pjDbmInsTxEnt - - pjDbmGetTxEnt - - pjDbmGetTxEntSn - - pjDbmDelTxEnt - - pjDbmTxDeInit - - pjDbmInsRxEnt - - pjDbmGetRxEnt - - pjDbmDelRxEnt - - pjDbmRxDeInit - - File: pj_dbm_dl.c - -*********************************************************************21*/ - -static const char* RLOG_MODULE_NAME="PDCP"; -static int RLOG_MODULE_ID=1024; -static int RLOG_FILE_ID=215; - -/* header (.h) include files */ -#include "envopt.h" /* environment options */ -#include "envdep.h" /* environment dependent */ -#include "envind.h" /* environment independent */ - -#include "gen.h" /* general */ -#include "ssi.h" /* system services interface */ -#include "cm5.h" /* Timer Functions */ -#include "cm_lte.h" /* common LTE header file */ -#include "cm_hash.h" /* common hash module file */ -#include "cm_llist.h" /* common list header file */ -#include "cpj.h" /* RRC layer */ -#include "pju.h" /* PDCP service user */ -#include "lpj.h" /* RRC layer */ -#include "pj_env.h" /* RLC environment options */ -#include "pj.h" /* RLC layer */ -#include "pj_dl.h" -#include "pj_err.h" -#include "pj_ptsec.h" -/* extern (.x) include files */ -#include "gen.x" /* general */ -#include "ssi.x" /* system services interface */ -#include "cm_lib.x" /* common library */ -#include "cm5.x" /* Timer Functions */ -#include "cm_hash.x" /* common hash module */ -#include "cm_lte.x" /* common LTE file */ -#include "cm_llist.x" /* common list header file */ -#include "cpj.x" /* RRC layer */ -#include "pju.x" /* PDCP service user */ -#include "lpj.x" /* LM Interface */ -#include "pj.x" /* RLC layer */ -#include "pj_udx.h" -#include "pj_udx.x" -#include "pj_dl.x" -#include "pj_ul.x" -U32 pjTotDlPckCntPerCell; - -/* local defines */ - -/* local externs */ - -/* forward references */ - -/* public variable declarations */ -PUBLIC S16 pjCiphStateChek ARGS ((PjCb *gCb, PjTxEnt *txEnt)); -/* This structure holds all the global structs we need. */ - -/* private variable declarations */ - -/* private function declarations */ - -/** @file gp_pj_dbm.c -@brief PDCP DBM Module -**/ -/***************************************************************************** - * HANDLER FOR THE TRANSMISSION BUFFER - ****************************************************************************/ - -/** - * - * @brief Handler to initialize Buffer - * - * @b Description - * This function is invoked by config to initialize the Buffer - * hash List - * - * @param[in] buf Rx/Tx Buffer Control Point - * @param[in] numBins number of Bins - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC S16 pjDbmDlBufInit -( -PjCb *gCb, -PjBuf *buf, /* !< Rx/Tx Buffer */ -U8 numBins /* !< number of Bins */ -) -#else -PUBLIC S16 pjDbmDlBufInit(gCb, buf, numBins) -PjCb *gCb; -PjBuf *buf; /* !< Rx/Tx Buffer */ -U8 numBins; /* !< number of Bins */ -#endif -{ - U8 hashIndex; /* HashIndex of array */ - - TRC3(pjDbmDlBufInit) - - RLOG1(L_DEBUG, "pjDbmBufInit(buf, numBins(%d)", numBins); - - /* Initialize CmLListCps*/ - PJ_ALLOC(gCb, buf->datQ, (sizeof(CmLListCp) * numBins)); -#if (ERRCLASS & ERRCLS_DEBUG) - if (buf->datQ == NULLP) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } -#endif /* (ERRCLASS & ERRCLS_DEBUG) */ - - for(hashIndex = 0; hashIndex < numBins; hashIndex++) - { - cmLListInit(&buf->datQ[hashIndex]); - } - - /* Initialistations of buf */ - buf->numEntries = 0; - buf->numBins = numBins; - - cmLListInit(&buf->datCfmQ); - cmLListInit(&buf->sduSubmitQ); - cmLListInit(&buf->reEstPktQ); - - RETVALUE(ROK); -} /* pjDbmBufInit */ - - -/** - * - * @brief Handler to insert into a TX Buffer - * - * @b Description - * This function is invoked to insert into - * the transmission buffer hash List - * - * @param[in] buf Tx Buffer - * @param[in] txEnt Transmission Entry - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC S16 pjDbmInsTxEnt -( -PjCb *gCb, -PjBuf *buf, /* !< Tx Buffer */ -PjTxEnt *txEnt /* !< Tx Entry */ -) -#else -PUBLIC S16 pjDbmInsTxEnt(gCb, buf, txEnt) -PjCb *gCb; -PjBuf *buf; /* !< Tx Buffer */ -PjTxEnt *txEnt; /* !< Tx Entry */ -#endif -{ - U8 hashKey; /* Computed HashKey */ - - TRC3(pjDbmInsTxEnt) - -// pjTotDlPckCntPerCell++; -#ifndef ALIGN_64BIT - PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), (gCb->init.prntBuf,\ - "pjDbmInsTxEnt(buf, txEnt(%ld)\n", txEnt->count)); -#else - PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), (gCb->init.prntBuf,\ - "pjDbmInsTxEnt(buf, txEnt(%d)\n", txEnt->count)); -#endif - /* Get the hash index */ - hashKey = (U8)PJ_HASH_FN(buf, txEnt->count); /*KW_FIX*/ - - txEnt->lstEnt.node = (PTR)txEnt; - cmLListAdd2Tail(&buf->datQ[hashKey], &txEnt->lstEnt); - buf->numEntries ++; - - txEnt->sduSubmitEnt.node = (PTR)txEnt; - cmLListAdd2Tail(&buf->sduSubmitQ, &txEnt->sduSubmitEnt); - - RETVALUE(ROK); -} /* pjDbmTxBufIns */ - - -/** - * - * @brief Handler to fetch from a TX Buffer - * - * @b Description - * This function is invoked to fetch from - * the transmission buffer hash List - * - * @param[in] buf Tx Buffer - * @param[in] count Count of the PjTxEnt to retrieve - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC PjTxEnt* pjDbmGetTxEnt -( -PjCb *gCb, -PjBuf *buf, /* !< Tx Buffer */ -U32 count /* !< Count of the PjTxEnt to retrieve */ -) -#else -PUBLIC PjTxEnt* pjDbmGetTxEnt(gCb, buf, count) -PjCb *gCb; -PjBuf *buf; /* !init.prntBuf,\ - "pjDbmGetTxEnt(buf, txEnt(%ld)\n", count)); -#else - PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), (gCb->init.prntBuf,\ - "pjDbmGetTxEnt(buf, txEnt(%d)\n", count)); -#endif - /* Call the hash function */ - hashKey = (U8)PJ_HASH_FN(buf, count); /*KW_FIX*/ - - datQ = &buf->datQ[hashKey]; - - cmLListFirst(datQ); - while(cmLListCrnt(datQ)) - { - tmpEnt = (PjTxEnt *) cmLListNode(cmLListCrnt(datQ)); - if(tmpEnt->count == count) - { - RETVALUE(tmpEnt); - } - cmLListNext(datQ); - } - RETVALUE(NULLP); -} /* pjDbmGetTxEnt */ - - -/** - * - * @brief Handler to fetch from a TX Buffer - * - * @b Description - * This function is fetch the node based on the SN. - * This function will be called only for the case of a - * PDCP STATUS REPORT being received by the DRB AM. - * - * @param[in] buf Tx Buffer - * @param[in] sn SN to get the Ent - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC PjTxEnt* pjDbmGetTxEntSn -( -PjCb *gCb, -PjBuf *buf, /* !< Tx Buffer */ -U16 sn /* !< SN of the PjTxEnt to retrieve */ -) -#else -PUBLIC PjTxEnt* pjDbmGetTxEntSn(gCb, buf, sn) -PjCb *gCb; -PjBuf *buf; /* !< Tx Buffer */ -U16 sn; /* !< SN of the PjTxEnt to retrieve */ -#endif -{ - U8 hashKey; /* Computed hash index */ - CmLListCp *datQ; /* Pointer to the ListCP */ - PjTxEnt *tmpEnt; /* Loop Var - pointer to PjTxEnt */ - - TRC3(pjDbmGetTxEntSn) - - RLOG1(L_DEBUG, "pjDbmGetTxEnt(buf, sn(%d)", sn); - - /* Call the hash function */ - hashKey = (U8)PJ_HASH_FN(buf, sn); /*KW_FIX*/ - - datQ = &buf->datQ[hashKey]; - - /* Loop through to find the entry that matches */ - cmLListFirst(datQ); - while(cmLListCrnt(datQ)) - { - tmpEnt = (PjTxEnt *) cmLListNode(cmLListCrnt(datQ)); - if(tmpEnt->sn == sn) - { - RETVALUE(tmpEnt); - } - cmLListNext(datQ); - } - RETVALUE(NULLP); - -} /* pjDbmGetTxEntSn */ - -/* ccpu00136902 */ -#if (defined (LTE_PAL_ENB) || defined (TENB_ACC)) -/** - * @brief This fn is called to chek the state of the PDCP pkts in DL before Ciphering operation - * and appropriate action is taken accordingly - * - * @details - * Function : pjCiphStateChek - * - * Processing Steps: - * - * - * @return S16 - * -# Success : ROK - * -# Failure : RFAILED -*/ -#ifdef ANSI -PUBLIC S16 pjCiphStateChek -( -PjCb *gCb, -PjTxEnt *txEnt -) -#else -PUBLIC S16 pjCiphStateChek(gCb, txEnt) -PjCb *gCb; -PjTxEnt *txEnt; -#endif -{ - TRC3(pjCiphStateChek); - PJ_FREE_BUF(txEnt->sdu); - PJ_FREE_BUF(txEnt->pdu); -#ifdef FLAT_BUFFER_OPT - if(txEnt->fb.startAddr) - { - PJ_FREE_FLAT_BUF(gCb, (&(txEnt->fb))); - } -#endif - - PJ_FREE(gCb, txEnt, sizeof(PjTxEnt)); - RETVALUE(ROK); -} -#endif - - -/** - * - * @brief Handler to delete from a TX Buffer - * - * @b Description - * This function is invoked by to insert into - * the transaction buffer hash List - * - * @param[in] buf Tx Buffer - * @param[in] count count to get the Ent - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC S16 pjDbmDelTxEnt -( -PjCb *gCb, -PjBuf *buf, /* !< Tx Buffer */ -U32 count /* !< Count of the PjTxEnt to delete */ -) -#else -PUBLIC S16 pjDbmDelTxEnt(gCb, buf, count) -PjCb *gCb; -PjBuf *buf; /* !< Tx Buffer */ -U32 count; /* !< Count of the PjTxEnt to delete */ -#endif -{ - U8 hashKey; /* Computed Hash Key */ - CmLListCp *datQ; /* Pointer to the ListCP */ - PjTxEnt *delEnt; /* Loop Var - pointer to PjTxEnt */ - - TRC3(pjDbmDelTxEnt) -#ifndef ALIGN_64BIT - PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), (gCb->init.prntBuf,\ - "pjDbmDelTxEnt(buf, count(%ld)\n", count)); -#else - PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), (gCb->init.prntBuf,\ - "pjDbmDelTxEnt(buf, count(%d)\n", count)); -#endif - - /* search for the entry */ - delEnt = pjDbmGetTxEnt(gCb, buf, count); - if(delEnt == NULLP) - { - RETVALUE(RFAILED); - } - - /* Compute the hash index */ - hashKey = (U8)PJ_HASH_FN(buf, delEnt->count); /*KW_FIX*/ - datQ = &buf->datQ[hashKey]; - - /* delete the entry */ - cmLListDelFrm(datQ, &delEnt->lstEnt); - - if (delEnt->sduSubmitEnt.node != NULLP) - { - delEnt->sduSubmitEnt.node = NULLP; - cmLListDelFrm(&buf->sduSubmitQ,&delEnt->sduSubmitEnt); - } - if(delEnt->datCfmEnt.node != NULLP) - { - delEnt->datCfmEnt.node = NULLP; - cmLListDelFrm(&buf->datCfmQ, &delEnt->datCfmEnt); - pjTotDlPckCntPerCell--; - } - - if(delEnt->reEstPktEnt.node != NULLP) - { - delEnt->reEstPktEnt.node = NULLP; - cmLListDelFrm(&buf->reEstPktQ, &delEnt->reEstPktEnt); - } - /* NULLing off to prevent double dealloc */ - if(delEnt->pdu == delEnt->sdu) - { - delEnt->pdu = NULLP; - } -/* ccpu00136902 */ - pjCiphStateChek(gCb, delEnt); - buf->numEntries --; - - RETVALUE(ROK); -} /* pjDbmDelTxEnt */ - - -/** - * - * @brief Handler to Delete all the elements in the hashlist - * - * - * @b Description - * This function is invoked to Delete all the elements in the - * hash List - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC S16 pjDbmTxDelAll -( -PjCb *gCb, -PjBuf *buf /* !< Tx Buffer */ -) -#else -PUBLIC S16 pjDbmTxDelAll(gCb,buf) -PjCb *gCb; -PjBuf *buf; /* !< Tx Buffer */ -#endif -{ - U8 i; /* index counter */ - CmLListCp *datQ; /* CmLListcp Ptr */ - CmLList *lstEnt; /* CmLList Ptr - Loop var */ - PjTxEnt *txEnt; /* Tx Entry Ptr - Loop var */ - - TRC3(pjDbmTxDelAll); - - RLOG0(L_DEBUG, "pjDbmTxDelAll(buf)"); - - /* cleanup the entries */ - for(i = 0; i< buf->numBins; i++) - { - datQ = &buf->datQ[i]; - while(cmLListFirst(datQ)) - { - lstEnt = cmLListDelFrm(datQ, cmLListCrnt(datQ)); - if(lstEnt != NULLP) - { - txEnt = (PjTxEnt *)cmLListNode(lstEnt); - if(txEnt->datCfmEnt.node != NULLP) - { - txEnt->datCfmEnt.node = NULLP; - cmLListDelFrm(&buf->datCfmQ, &txEnt->datCfmEnt); - pjTotDlPckCntPerCell--; - } - - if (txEnt->sduSubmitEnt.node != NULLP) - { - txEnt->sduSubmitEnt.node = NULLP; - cmLListDelFrm(&buf->sduSubmitQ,&txEnt->sduSubmitEnt); - } - - if(txEnt->reEstPktEnt.node != NULLP) - { - txEnt->reEstPktEnt.node = NULLP; - cmLListDelFrm(&buf->reEstPktQ, &txEnt->reEstPktEnt); - } - - if ( txEnt->sdu == txEnt->pdu ) - { - txEnt->sdu = NULLP; - } - /* ccpu00136902 */ - pjCiphStateChek(gCb, txEnt); - } - } - cmLListInit(datQ); - } - - RETVALUE(ROK); -} /* pjDbmTxDelAll */ - -/** - * - * @brief Handler to De initialize hash list - * - * - * @b Description - * This function is invoked by LMM to De initialize the - * hash List - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC S16 pjDbmTxDeInit -( -PjCb *gCb, -PjBuf *buf /* !< Tx Buffer */ -) -#else -PUBLIC S16 pjDbmTxDeInit(gCb,buf) -PjCb *gCb; -PjBuf *buf; /* !< Tx Buffer */ -#endif -{ - - TRC3(pjDbmTxDeInit); - - RLOG0(L_DEBUG, "pjDbmTxDeInit(buf)"); - - /* cleanup the entries */ - pjDbmTxDelAll(gCb,buf); - - /* Cleanup the listCps */ - PJ_FREE(gCb, buf->datQ, (sizeof(CmLListCp) * buf->numBins)); - buf->numBins = NULLP; - - RETVALUE(ROK); -} /* pjDbmDeInit */ - - - -/** - * - * @brief Handler to initialize hash list - * - * - * @b Description - * This function is invoked by LMM to initialize the UeCb and CellCb - * hash List - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC S16 pjDbmDlInit -( -PjCb *gCb -) -#else -PUBLIC S16 pjDbmDlInit(gCb) -PjCb *gCb; -#endif -{ - S16 ret; /* Return Value */ - - TRC3(pjDbmDlInit) - -#ifdef DEBUGP - RLOG0(L_DEBUG, "pjDbmInit()"); -#endif - - /* Initialize ueCb Hash List */ - ret = cmHashListInit(&(gCb->u.dlCb->ueLstCp), (U16) PJ_UE_LIST_BUCKET_SIZE, - (U16) 0, (Bool) FALSE, (U16) CM_HASH_KEYTYPE_DEF, - gCb->init.region, gCb->init.pool); - if (ret != ROK) - { -#ifdef DEBUGP - RLOG0(L_DEBUG, "pjDbmInit: cmHashListInit Failed for gCb.ueLstCp."); -#endif - RETVALUE(ret); - } - - RETVALUE(ROK); -} /* pjDbmInit */ - - -/** - * - * @brief Handler to De initialize hash list - * - * - * @b Description - * This function is invoked by LMM to De initialize the UeCb and CellCb - * hash List - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC S16 pjDbmDlDeInit -( -PjCb *gCb -) -#else -PUBLIC S16 pjDbmDlDeInit(gCb) -PjCb *gCb; -#endif -{ - S16 ret; /* Return Value */ - - TRC3(pjDbmDlDeInit); - -#ifdef DEBUGP - RLOG0(L_DEBUG, "pjDbmDeInit()"); -#endif - - /* Initialize ueCb Hash List */ - ret = cmHashListDeinit(&(gCb->u.dlCb->ueLstCp)); - if (ret != ROK) - { -#ifdef DEBUGP - RLOG0(L_ERROR, "pjDbmDeInit: cmHashListDeinit Failed for gCb.ueLstCp."); -#endif - RETVALUE(ret); - } - RETVALUE(ROK); -} /* pjDbmDeInit */ - - -/** - * - * @brief Handler to fetch rbCb in the Upper Interface - * - * - * @b Description - * This function is invoked by CFG to fetch rbCb from the cellCb/ueCb in - * the upper interface (CPJ/PJU). - * - * @param[in] rlcId RLC Identifier - * @param[out] rbCb RB Control Block - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC S16 pjDbmFetchDlRbCb -( -PjCb *gCb, -CmLteRlcId rlcId, /* RLC Identifier */ -PjDlRbCb **rbCb /* RB Cb */ -) -#else -PUBLIC S16 pjDbmFetchDlRbCb(gCb, rlcId, rbCb) -PjCb *gCb; -CmLteRlcId rlcId; /* RLC Identifier */ -PjDlRbCb **rbCb; /* RB Cb */ -#endif -{ - PjDlUeCb *ueCb; /* UE Control Block */ - PjDlRbCb *tRbCb; /* Local RB CB */ - S16 ret; /* Return Value */ - - TRC3(pjDbmFetchDlRbCb) - -#ifdef DEBUGP - RLOG3(L_DEBUG, "pjDbmFetchRbCbForLi(rlcId(ueId(%d), cellId(%d), rbId(%d)), rbCb)", - rlcId.ueId, rlcId.cellId, rlcId.rbId); -#endif - - ueCb = NULLP; - ret = ROK; - - /* Validate the RBID in case of TM/UM/AM */ - PJ_VALIDATE_RBID(rlcId.ueId, rlcId.rbId, rlcId.rbType, ret); - if (ret != ROK) - { -#ifdef DEBUGP - /* DEBUG_PRINT EROR */ - RLOG_ARG2(L_ERROR,DBG_UEID,rlcId.ueId, - "PJ_VALIDATE_RBID Failed -- rbId(%d), cellId(%d)", - rlcId.rbId, rlcId.cellId); - -#endif - RETVALUE(ret); - } - if (pjDbmFetchDlUeCb(gCb, rlcId.ueId, rlcId.cellId, &ueCb) != ROK) - { - RLOG_ARG1(L_ERROR, DBG_CELLID, rlcId.cellId,"UeId[%u] not found", - rlcId.ueId); - RETVALUE(RFAILED); - - } - - PJ_DBM_FETCH_DL_RBCB(rlcId.rbId, rlcId.rbType, ueCb, tRbCb); - - if (tRbCb == NULLP) - { - RLOG_ARG2(L_ERROR, DBG_UEID,rlcId.ueId, "CellId[%u]:RbId[%d] not found", - rlcId.cellId, rlcId.rbId); - RETVALUE(RFAILED); - } - - *rbCb = tRbCb; - - RETVALUE(ROK); -} /* pjDbmFetchRbCb */ - - -/** - * - * @brief Handler to delete RbCb - * - * - * @b Description - * This function is invoked by CFG to remove RbCb from Ue/Cell hashlist - * - * - * @param[in] rbCbLst - Rb Cb List - * @param[in] numRbCb - Number of rbCbs - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC S16 pjDbmDelAllDlRb -( -PjCb *gCb, -PjDlRbCb **rbCbLst, /* RB Cb list */ -U8 numRbCb /* Number of rbCbs */ -) -#else -PUBLIC S16 pjDbmDelAllDlRb(gCb,rbCbLst, numRbCb) -PjCb *gCb; -PjDlRbCb **rbCbLst; /* RB Cb list */ -U8 numRbCb; /* Number of rbCbs */ -#endif -{ - U8 idx; /* Index */ - PjDlRbCb *rbCb; /* RB Control Block */ - - TRC3(pjDbmDelAllDlRb) - -#ifdef DEBUGP - RLOG1(L_DEBUG, "pjDbmDelAllRb(rbCbLst, numRbCb(%d))", numRbCb); -#endif - - for (idx = 0; idx < numRbCb; idx++) - { - rbCb = rbCbLst[idx]; - if (rbCb != NULLP) - { - PJ_DBM_DELETE_DL_RBCB(gCb, rbCb); - rbCbLst[idx] = NULLP; - } - } - - RETVALUE(ROK); -} /* pjDbmDelAllRb */ - - -/** - * - * @brief Handler to create an UeCb - * - * - * @b Description - * This function is invoked by CFG to create UeCb and insert into the Ue hashlist - * of KwCb. - * - * - * @param[in] ueId UE Identifier - * @param[in] cellId Cell Identifier - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC S16 pjDbmCreateDlUeCb -( -PjCb *gCb, -CmLteRnti ueId, /* UE Identifier */ -CmLteCellId cellId, /* Cell Identifier */ -PjDlUeCb **ueCb /* UE Control Block */ -) -#else -PUBLIC S16 pjDbmCreateDlUeCb(gCb, ueId, cellId, ueCb) -PjCb *gCb; -CmLteRnti ueId; /* UE Identifier */ -CmLteCellId cellId; /* Cell Identifier */ -PjDlUeCb **ueCb; /* UE Control Block */ -#endif -{ - S16 ret; /* Return Value */ - PjDlUeCb *tUeCb; /* UE Control Block */ - - TRC3(PjDbmCreateDlUeCb) - -#ifdef DEBUGP - RLOG2(L_DEBUG, "pjDbmCreateUeCb(ueId(%d), cellId(%d))", ueId, cellId); -#endif - - PJ_ALLOC(gCb, *ueCb, sizeof(PjDlUeCb)); - -#if (ERRCLASS & ERRCLS_ADD_RES) - if (*ueCb == NULLP) - { - ret = RFAILED; - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(ret); - } -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - - tUeCb = *ueCb; - tUeCb->key.ueId = ueId; - tUeCb->key.cellId = cellId; - - ret = cmHashListInsert(&(gCb->u.dlCb->ueLstCp), (PTR)tUeCb, (U8 *)&(tUeCb->key), - (U16) sizeof(PjUeKey)); - if (ret != ROK) - { -#ifdef DEBUGP - RLOG_ARG1(L_ERROR,DBG_UEID,ueId, - "DL UE CB Hash Insert Failed for cellId (%d)", cellId); -#endif - RETVALUE(ret); - } - - /* kw005.201 ccpu00117318, updating the statistics */ - gCb->u.dlCb->pjGenSts.numUe++; - (*ueCb)->libInfo.state = PJ_STATE_NORMAL; - cmInitTimers(&((*ueCb)->libInfo.obdTmr), 1); - RETVALUE(ret); -} /* kwDbmCreateUeCb */ - - -/** - * - * @brief Handler to Fetch an UeCb - * - * - * @b Description - * This function is invoked by CFG to fetch UeCb from the Ue hashlist - * of KwCb. - * - * - * @param[in] ueId UE Identifier - * @param[in] cellId Cell Identifier - * @param[out] ueCb UE Control Block - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC S16 pjDbmFetchDlUeCb -( -PjCb *gCb, -CmLteRnti ueId, /* UE Identifier */ -CmLteCellId cellId, /* Cell Identifier */ -PjDlUeCb **ueCb /* UE Control Block */ -) -#else -PUBLIC S16 pjDbmFetchDlUeCb(gCb, ueId, cellId, ueCb) -PjCb *gCb; -CmLteRnti ueId; /* UE Identifier */ -CmLteCellId cellId; /* Cell Identifier */ -PjDlUeCb **ueCb; /* UE Control Block */ -#endif -{ - S16 ret; /* Return Value */ - PjUeKey key; /* Key for UE Hash List */ - - TRC3(pjDbmFetchDlUeCb) - - - key.ueId = ueId; - key.cellId = cellId; - - ret = cmHashListFind(&(gCb->u.dlCb->ueLstCp), (U8 *)&(key), sizeof(PjUeKey), - PJ_DEF_SEQ_NUM, (PTR *) ueCb); - if (ret != ROK) - { -#ifdef DEBUGP - RLOG_ARG0(L_WARNING,DBG_UEID,ueId, - "pjDbmFetchUeCb: cmHashListFind Failed for ueCb."); -#endif - RETVALUE(ret); - } - - RETVALUE(ROK); -} /* pjDbmFetchUeCb */ - - -/** - * - * @brief Handler to delete an UeCb - * - * - * @b Description - * This function is invoked by CFG to delete UeCb from the Ue hashlist - * of KwCb. - * - * - * @param[in] ueCb UE Control Block - * @param[in] abrtFlag Abort Flag - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC S16 pjDbmDelDlUeCb -( -PjCb *gCb, -PjDlUeCb *ueCb, /* UE Identifier */ -Bool abortFlag /* Abort Flag */ -) -#else -PUBLIC S16 pjDbmDelDlUeCb(gCb, ueCb, abortFlag) -PjCb *gCb; -PjDlUeCb *ueCb; /* UE Identifier */ -Bool abortFlag; /* Abort Flag */ -#endif -{ - S16 ret; /* Return Value */ - U8 idx; /* Index */ - - TRC3(pjDbmDelDlUeCb) - -#ifdef DEBUGP - RLOG2(L_DEBUG, "pjDbmDelUeCb(ueId(%d), cellId(%d))", - ueCb->key.ueId, ueCb->key.cellId); -#endif - -/* kw005.201 Check to see if there is atleast one logical channel */ - - for ( idx = 0; idx< PJ_MAX_SRB_PER_UE; idx++) - pjCfgDelPjDlRbCb(gCb, ueCb, ueCb->srbCb[idx]); - - for ( idx = 0; idx< PJ_MAX_DRB_PER_UE; idx++) - pjCfgDelPjDlRbCb(gCb, ueCb, ueCb->drbCb[idx]); - - /* Close the Integrity/Ciphering channels */ - if(ueCb->secInfo.secAct) - { -#ifdef INTEL_QAT_DP - pjUtlDlIntClose(gCb,ueCb->secInfo.cpIntSessCxtId); - pjUtlDlCipherClose(gCb,ueCb->secInfo.cpCiphSessCxtId); - pjUtlDlCipherClose(gCb,ueCb->secInfo.upCiphSessCxtId); -#else - pjUtlDlIntClose(gCb,ueCb->secInfo.intCxtId); - pjUtlDlCipherClose(gCb,ueCb->secInfo.cpCxtId); - pjUtlDlCipherClose(gCb,ueCb->secInfo.upCxtId); -#endif - } - - /* Delete hoInfo if present */ - if (ueCb->hoInfo != NULLP) - { - for (idx = 0; idx < PJ_MAX_DRB_PER_UE; idx++) - { - if (ueCb->hoInfo->hoCfmInfo[idx].pres == TRUE) - { /* should these be dl? */ - - } - } - - PJ_FREE(gCb, ueCb->hoInfo->hoCfmInfo, (PJ_MAX_DRB_PER_UE * sizeof(PjDlHoCfmInfo))); - PJ_FREE(gCb, ueCb->hoInfo, sizeof(PjDlHoInfo)); - } - - /* Delete ueCb entry from ueLstCp */ - ret = cmHashListDelete(&(gCb->u.dlCb->ueLstCp), (PTR) ueCb); - if (ret != ROK) - { - -#ifdef DEBUGP - RLOG_ARG0(L_ERROR,DBG_UEID,ueCb->key.ueId,"Hash Delete Failed for ueCb"); -#endif - } - /* kw005.201 ccpu00117318, updating the statistics */ - gCb->pjGenSts.numUe--; - /* Deallocate ueCb */ - PJ_FREE(gCb, ueCb, sizeof(PjDlUeCb)); - - RETVALUE(ret); -} /* pjDbmDelUeCb */ - - -/** - * - * @brief Handler to delete all UeCbs - * - * - * @b Description - * This function is invoked by CFG to delete all UeCbs from the Ue - * hashlist of KwCb. - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC S16 PjDbmDelAllDlUe -( -PjCb *gCb -) -#else -PUBLIC S16 PjDbmDelAllDlUe(gCb) -PjCb *gCb; -#endif -{ - S16 ret; - PjDlUeCb *ueCb; /* UE Control Block */ - - TRC3(pjDbmDelAllDlUe) - -#ifdef DEBUGP - RLOG0(L_DEBUG, "pjDbmDelAllUe()"); -#endif - - ret = ROK; - ueCb = NULLP; - - /* Until no more ueCb is ueLstCp hash list get and delete ueCb */ - while (cmHashListGetNext(&(gCb->u.dlCb->ueLstCp), (PTR) ueCb, (PTR *)&ueCb) == ROK) - { - /* Delete ueCb */ - ret = pjDbmDelDlUeCb(gCb,ueCb, TRUE); - if (ret != ROK) - { -#ifdef DEBUGP - RLOG_ARG0(L_ERROR,DBG_UEID,ueCb->key.ueId,"DL Ue Cb Deletion Failed"); -#endif - RETVALUE(ret); - } - ueCb = NULLP; - } - - RETVALUE(ret); -} /* pjDbmDelAllUe */ - -#ifdef ANSI -PUBLIC S16 pjDbmDlShutdown -( -PjCb *gCb -) -#else -PUBLIC S16 pjDbmDlShutdown(gCb) -PjCb *gCb; -#endif -{ -#if (ERRCLASS & ERRCLS_DEBUG) - S16 ret; -#endif - TRC3(pjDbmDlShutdown) - -#if (ERRCLASS & ERRCLS_DEBUG) - ret = pjDbmDlDeInit(gCb); - if (ret != ROK) - { - RLOG0(L_FATAL, "DL DeInitialization Failed"); - } -#else - pjDbmDlDeInit(gCb); -#endif /* ERRCLASS & ERRCLS_DEBUG */ - - RETVALUE(ROK); -} /* pjDbmShutdown */ - -/** - * - * @brief Handler to create a RB control block. - * - * - * @b Description - * This function is called to create a RLC control block or PDCP - * control block based on rb flag and update the pointers in RbCb. - * If the RbCb is already allocated, the rbId is updated in KwRbCb - * or PjDlRbCb based on rb. If the RbCb has not been allocated earlier, - * a new RbCb is created and the pointers are updated along with the - * rbIds. - * - * @param[in] rbId RB ID of the entity - * @param[in] rbCbLst List of the RBs in the UeCb - * @param[in] rb The RB to be created. This can be - * PJ_CFG_PDCP when PDCP is created - * or PJ_CFG_RLC when RLC is being - * created. - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC PjDlRbCb* pjDbmCreateDlRbCb -( -PjCb *gCb, -U8 rbId, -U8 rbType, -PjDlUeCb *ueCb, -U8 rb -) -#else -PUBLIC PjDlRbCb* pjDbmCreateDlRbCb(gCb,rbId,rbType,ueCb,rb) -PjCb *gCb; -U8 rbId; -U8 rbType; -PjDlUeCb *ueCb; -U8 rb; -#endif -{ - PjDlRbCb *rbCb; - PjDlRbCb **rbCbLst; - - TRC2(pjDbmCreateDlRbCb) - - rbCb = NULLP; - rbCbLst = NULLP; - - PJ_DBM_FETCH_DL_RBCB(rbId, rbType, ueCb, rbCb); - - if(rbCb == NULLP) - { - PJ_ALLOC(gCb, rbCb, sizeof(PjDlRbCb)); - if ( rbCb == NULLP ) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(rbCb); - } - } - - rbCb->rbId = rbId; - rbCb->rbType = rbType; - - rbCbLst = ((rbType == CM_LTE_SRB)? ueCb->srbCb:ueCb->drbCb); - rbCbLst[rbId] = rbCb; - /* kw005.201 ccpu00117318, updating the statistics */ - PJ_LMM_RB_STS_INC(gCb); - - RETVALUE(rbCb); - -} /* pjDbmCreateRbCb */ - -/** - * - * @brief Handler to fetch a PDCP RB control block. - * - * - * @b Description - * This function is used to fetch the PDCP RB control block based on - * the RB id. The pointer to PjDlRbCb is returned. - * - * @param[in] ueCb UE control block of the PDCP RB - * @param[in] rbId RB ID of the required PDCP entity. - * @param[out] pjRbCb PDCP RB Control Block. - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 pjDbmFetchPjDlRbCb -( -PjDlUeCb *ueCb, -U8 rbId, -U8 rbType, -PjDlRbCb **pjRbCb -) -#else -PUBLIC S16 pjDbmFetchPjDlRbCb(ueCb,rbId,rbType,pjRbCb) -PjDlUeCb *ueCb; -U8 rbId; -U8 rbType; -PjDlRbCb **pjRbCb; -#endif -{ - PjDlRbCb *rbCb; - - TRC2(PjDbmFetchPjDlRbCb) - - *pjRbCb = NULLP; - - PJ_DBM_FETCH_DL_RBCB(rbId, rbType, ueCb, rbCb); - if ( rbCb != NULLP ) - { - *pjRbCb = rbCb; - } - - RETVALUE(ROK); - -} /* pjDbmFetchPjDlRbCb */ - -/** - * - * @brief Handler to delete a PDCP/RLC RB control block. - * - * - * @b Description - * This function is used to delete the PDCP/RLC RB control block based - * on RB id and the RB type (PDCP/RLC). If the corresponding RB is - * present, the cfgStat flag is unset. If the cfgStat flag is zero, - * the RBCB is freed. - * - * @param[in] rbId RB ID of the to be deleted RB - * @param[in] rbCbLst RbCb list in UE CB - * @param[in] rb The RB to be deleted. This can be - * PJ_CFG_PDCP when PDCP is created - * or PJ_CFG_RLC when RLC is being - * created. - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 pjDbmDelDlRbCb -( -PjCb *gCb, -U8 rbId, -U8 rbType, -PjDlRbCb **rbCb, -U8 rb, -PjDlUeCb *ueCb -) -#else -PUBLIC S16 pjDbmDelDlRbCb(gCb,rbId,rbType,rbCb,rb,ueCb) -PjCb *gCb; -U8 rbId; -U8 rbType; -PjDlRbCb **rbCb; -U8 rb; -PjDlUeCb *ueCb; -#endif -{ - S16 ret; - PjDlRbCb **rbCbLst; - rbCbLst = NULLP; - - TRC2(pjDbmDelDlRbCb) - - ret = RFAILED; - /*updating rbCbList */ - rbCbLst = ((rbType == CM_LTE_SRB)? ueCb->srbCb:ueCb->drbCb); - - if ( (*rbCb) != NULLP ) - { - PJ_DBM_DELETE_DL_RBCB(gCb,*rbCb); - ret = ROK; - /*updating rbCbList */ - rbCbLst[rbId] = NULLP; - } - RETVALUE(ret); - -} /* pjDbmDelRbCb */ - - - - -/********************************************************************30** - - End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_dbm_ul.c b/src/5gnrpdcp/pj_dbm_ul.c deleted file mode 100755 index 27e70abc5..000000000 --- a/src/5gnrpdcp/pj_dbm_ul.c +++ /dev/null @@ -1,1479 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: PDCP - Database module file - - Type: C source file - - Desc: Source code for Database Module functions such as, - - - pjDbmBufInit - - pjDbmInsTxEnt - - pjDbmGetTxEnt - - pjDbmGetTxEntSn - - pjDbmDelTxEnt - - pjDbmTxDeInit - - pjDbmInsRxEnt - - pjDbmGetRxEnt - - pjDbmDelRxEnt - - pjDbmRxDeInit - - File: pj_dbm_ul.c - -*********************************************************************21*/ -static const char* RLOG_MODULE_NAME="PDCP"; -static int RLOG_MODULE_ID=1024; -static int RLOG_FILE_ID=216; - - -/* header (.h) include files */ -#include "envopt.h" /* environment options */ -#include "envdep.h" /* environment dependent */ -#include "envind.h" /* environment independent */ - -#include "gen.h" /* general */ -#include "ssi.h" /* system services interface */ -#include "cm5.h" /* Timer Functions */ -#include "cm_lte.h" /* common LTE header file */ -#include "cm_hash.h" /* common hash module file */ -#include "cm_llist.h" /* common list header file */ -#include "cpj.h" /* RRC layer */ -#include "pju.h" /* PDCP service user */ -#include "lpj.h" /* RRC layer */ -#include "pj_env.h" /* RLC environment options */ -#include "pj.h" /* RLC layer */ -#include "pj_ul.h" /* RLC layer */ -#include "pj_err.h" -/* extern (.x) include files */ -#include "gen.x" /* general */ -#include "ssi.x" /* system services interface */ -#include "cm_lib.x" /* common library */ -#include "cm5.x" /* Timer Functions */ -#include "cm_hash.x" /* common hash module */ -#include "cm_lte.x" /* common LTE file */ -#include "cm_llist.x" /* common list header file */ -#include "cpj.x" /* RRC layer */ -#include "pju.x" /* PDCP service user */ -#include "lpj.x" /* LM Interface */ -#include "pj.x" /* RLC layer */ -#include "pj_udx.h" -#include "pj_udx.x" -#include "pj_dl.x" -#include "pj_ul.x" - - -/* local defines */ - -/* local externs */ - -/* forward references */ - -/* public variable declarations */ -PUBLIC S16 pjDeciphStateChek ARGS ((PjCb *gCb, PjRxEnt *delEnt)); -/* This structure holds all the global structs we need. */ - -/* private variable declarations */ - -/* private function declarations */ - -/** @file gp_pj_dbm.c -@brief PDCP DBM Module -**/ - -/***************************************************************************** - * HANDLER FOR THE TRANSMISSION BUFFER - ****************************************************************************/ - -/***************************************************************************** - * HANDLERS FOR THE RECEPTION BUFFER - ****************************************************************************/ - -/** - * @brief Handler to insert packets In-Sequence into RX Buffer - * - * - */ -#ifdef ANSI -PRIVATE S16 pjDbmInsInSeqRxEnt -( -PjBuf *buf, /* !< Rx Buffer */ -PjRxEnt *rxEnt /* !< Rx Entry */ -) -#else -PRIVATE S16 pjDbmInsInSeqRxEnt(buf, rxEnt) -PjBuf *buf; -PjRxEnt *rxEnt; -#endif -{ - - PjRxEnt *tmpEnt = NULLP; - - tmpEnt = (PjRxEnt *) cmLListNode(cmLListFirst(&buf->datPktQ)); - if((rxEnt->count) < (tmpEnt->count)) - { - rxEnt->datPktEnt.node = (PTR) rxEnt; - cmLListInsCrnt(&buf->datPktQ, &rxEnt->datPktEnt); - } - else - { - tmpEnt = (PjRxEnt *) cmLListNode(cmLListLast(&buf->datPktQ)); - while((rxEnt->count) < (tmpEnt->count)) - { - cmLListPrev(&buf->datPktQ); - tmpEnt = (PjRxEnt *) cmLListNode(cmLListCrnt(&buf->datPktQ)); - } - rxEnt->datPktEnt.node = (PTR) rxEnt; - cmLListInsAfterCrnt(&buf->datPktQ, &rxEnt->datPktEnt); - } - RETVALUE(ROK); -} - - - -/** - * - * @brief Handler to insert into a RX Buffer - * - * @b Description - * This function is invoked by to insert into - * the reception buffer hash List - * - * @param[in] buf Rx Buffer - * @param[in] rxEnt Reception Entry - * @param[in] dupFlag Search for duplicates(Should be TRUE for AM) - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC S16 pjDbmInsRxEnt -( -PjCb *gCb, -PjBuf *buf, /* !< Rx Buffer */ -PjRxEnt *rxEnt, /* !< Rx Entry */ -Bool dupFlag /* !< Boolean to check for duplicate entries */ -) -#else -PUBLIC S16 pjDbmInsRxEnt(gCb, buf, rxEnt, dupFlag) -PjCb *gCb; -PjBuf *buf; /* !< Rx Buffer */ -PjRxEnt *rxEnt; /* !< Rx Entry */ -Bool dupFlag; /* !< Boolean to check for duplicate entries */ -#endif -{ - U8 hashKey; /* Computed hash key */ - PjRxEnt *tmpEnt = NULLP; /* Rx Entry Ptr */ - - TRC3(pjDbmInsRxEnt) -#ifndef ALIGN_64BIT - PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), (gCb->init.prntBuf,\ - "pjDbmInsRxEnt buf, rxEnt(%ld), dupFlag(%d)\n",\ - rxEnt->count, dupFlag)); -#else - PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), (gCb->init.prntBuf,\ - "pjDbmInsRxEnt buf, rxEnt(%d), dupFlag(%d)\n",\ - rxEnt->count, dupFlag)); -#endif - - if(dupFlag) - { - /* Search for duplicates */ - tmpEnt = pjDbmGetRxEnt(gCb, buf, rxEnt->count); - if(tmpEnt != NULLP) - { - RETVALUE(ROKDUP); - } - } - - /* Compute the hash index */ - hashKey = (U8)PJ_HASH_FN(buf, rxEnt->count); /*KW_FIX*/ - - rxEnt->lstEnt.node = (PTR) rxEnt; - cmLListAdd2Tail(&buf->datQ[hashKey], &rxEnt->lstEnt); - buf->numEntries ++; - - if(buf->datPktQ.count == 0) - { - rxEnt->datPktEnt.node = (PTR) rxEnt; - cmLListAdd2Tail(&buf->datPktQ, &rxEnt->datPktEnt); - } - else - { - pjDbmInsInSeqRxEnt(buf, rxEnt); - } - - RETVALUE(ROK); -} /* pjDbmRxBufIns */ - - -/** - * - * @brief Handler to fetch from a RX Buffer - * - * @b Description - * This function is invoked to fetch an entry from - * the transaction buffer hash List - * - * @param[in] buf Rx Buffer - * @param[in] count Count value of the entry to retrieve - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC PjRxEnt* pjDbmGetRxEnt -( -PjCb *gCb, -PjBuf *buf, /* !< Rx Buffer */ -U32 count /* !< Count value of the entry to retrieve */ -) -#else -PUBLIC PjRxEnt* pjDbmGetRxEnt(gCb, buf, count) -PjCb *gCb; -PjBuf *buf; /* !< Rx Buffer */ -U32 count; /* !< Count value of the entry to retrieve */ -#endif -{ - U8 hashKey; /* Computed hashKey */ - CmLListCp *datQ; /* Ptr to the CmLListCp */ - PjRxEnt *tmpEnt = NULLP; /* Loop var - Rx Entr Ptr */ - - TRC3(pjDbmGetRxEnt) - /* Compute the hask key*/ - hashKey = (U8)PJ_HASH_FN(buf, count); /*KW_FIX*/ - - datQ = &buf->datQ[hashKey]; - - /* Loop through and search */ - cmLListFirst(datQ); - while(cmLListCrnt(datQ)) - { - tmpEnt = (PjRxEnt *)cmLListNode(cmLListCrnt(datQ)); - if((tmpEnt->count) == count) - { - RETVALUE(tmpEnt); - } - cmLListNext(datQ); - } - RETVALUE(NULLP); -} /* pjDbmGetRxEnt */ -/** - * @brief This fn is called to chek the state of the PDCP pkts in UL before Deciphering operation - * and appropriate action is taken accordingly - * - * @details - * Function : pjDeciphStateChek - * - * Processing Steps: - * - * - * @return S16 - * -# Success : ROK - * -# Failure : RFAILED -*/ - -/* ccpu00136902 */ -#if (defined (LTE_PAL_ENB) || defined (TENB_ACC)) -#ifdef ANSI -PUBLIC S16 pjDeciphStateChek -( -PjCb *gCb, -PjRxEnt *delEnt -) -#else -PUBLIC S16 pjDeciphStateChek(gCb, delEnt) -PjCb *gCb; -PjRxEnt *delEnt; -#endif -{ - TRC3(pjDeciphStateChek); - PJ_FREE_BUF(delEnt->mBuf); - PJ_FREE(gCb, delEnt, sizeof(PjRxEnt)); - RETVALUE(ROK); -} -#endif - - -/** - * - * @brief Handler to delete from a RX Buffer - * - * @b Description - * This function is invoked by to delete from - * the transaction buffer hash List - * - * @param[in] buf Rx Buffer Control Point - * @param[in] count Count value of the Rx Entry to delete - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC S16 pjDbmDelRxEnt -( -PjCb *gCb, -PjBuf *buf, /* !< Rx Buffer */ -U32 count /* !< Count value of the entry to retrieve */ -) -#else -PUBLIC S16 pjDbmDelRxEnt(gCb, buf, count) -PjCb *gCb; -PjBuf *buf; /* !< Rx Buffer */ -U32 count; /* !< Count value of the entry to retrieve */ -#endif -{ - U8 hashKey; /* Computed hash value */ - CmLListCp *datQ; /* Pointer to the the ListCp */ - PjRxEnt *delEnt; /* Loop var - entry to be deleted */ - - TRC3(pjDbmDelRxEnt) -#ifndef ALIGN_64BIT - PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), (gCb->init.prntBuf,\ - "pjDbmDelRxEnt(buf, count(%ld)\n", count)); -#else - PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), (gCb->init.prntBuf,\ - "pjDbmDelRxEnt(buf, count(%d)\n", count)); -#endif - - /* Get the node */ - delEnt = pjDbmGetRxEnt(gCb, buf, count); - - if(delEnt == NULLP) - { - RETVALUE(ROK); - } - - hashKey = (U8)PJ_HASH_FN(buf, count); /*KW_FIX*/ - datQ = &buf->datQ[hashKey]; - - /* delete the entity and free it*/ - cmLListDelFrm(datQ, &delEnt->lstEnt); - if(delEnt->datPktEnt.node != NULLP) - { - cmLListDelFrm(&buf->datPktQ, &delEnt->datPktEnt); - delEnt->datPktEnt.node = NULLP; - } - /* ccpu00136902 */ - pjDeciphStateChek(gCb, delEnt); - buf->numEntries --; - - RETVALUE(ROK); -} /* pjDbmDelRxEnt */ - - -/** - * - * @brief Handler to Delete all the elements in the hashlist - * - * - * @b Description - * This function is invoked by delete all the elements in th3 - * hash List - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC S16 pjDbmRxDelAll -( -PjCb *gCb, -PjBuf *buf /* !< Rx Buffer */ -) -#else -PUBLIC S16 pjDbmRxDelAll(gCb,buf) -PjCb *gCb; -PjBuf *buf; /* !< Rx Buffer */ -#endif -{ - U8 listInd; /* loop index */ - CmLListCp *datQ; /* CmLListCp Ptr */ - CmLList *lstEnt; /* loop ptr to CmLlistEnt */ - PjRxEnt *delEnt; /* loop ptr to entry to be deleted */ - - TRC3(pjDbmRxDelAll); - - RLOG0(L_DEBUG, "pjDbmRxDelAll(buf)"); - - for(listInd = 0; listInd< buf->numBins; listInd++) - { - datQ = &buf->datQ[listInd]; - while(cmLListFirst(datQ)) - { - lstEnt = cmLListDelFrm(datQ, cmLListCrnt(datQ)); - if(lstEnt != NULLP) - { - delEnt = (PjRxEnt *)cmLListNode(lstEnt); - if(delEnt->datPktEnt.node != NULLP) - { - cmLListDelFrm(&buf->datPktQ, &delEnt->datPktEnt); - delEnt->datPktEnt.node = NULLP; - } - /* ccpu00136902 */ - pjDeciphStateChek(gCb, delEnt); - } - } - cmLListInit(datQ); - } - - RETVALUE(ROK); -} /* pjDbmRxDelAll */ - -/** - * - * @brief Handler to De initialize hash list - * - * - * @b Description - * This function is invoked by LMM to De initialize the - * hash List - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC S16 pjDbmRxDeInit -( -PjCb *gCb, -PjBuf *buf /* !< Rx Buffer */ -) -#else -PUBLIC S16 pjDbmRxDeInit(gCb,buf) -PjCb *gCb; -PjBuf *buf; /* !< Rx Buffer */ -#endif -{ - - TRC3(pjDbmRxDeInit); - - RLOG0(L_DEBUG, "pjDbmRxDeInit(buf)"); - - /* Cleanup all entries */ - pjDbmRxDelAll(gCb,buf); - - /* Cleanup hashlist */ - PJ_FREE(gCb, buf->datQ, (sizeof(CmLListCp) * buf->numBins)); - buf->numBins = NULLP; - - RETVALUE(ROK); -} /* pjDbmDeInit */ - - -/** - * - * @brief Handler to initialize hash list - * - * - * @b Description - * This function is invoked by LMM to initialize the UeCb and CellCb - * hash List - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC S16 pjDbmUlInit -( -PjCb *gCb -) -#else -PUBLIC S16 pjDbmUlInit(gCb) -PjCb *gCb; -#endif -{ - S16 ret; /* Return Value */ - - TRC3(pjDbmUlInit) - -#ifdef DEBUGP - RLOG0(L_DEBUG, "pjDbmInit()"); -#endif - - /* Initialize ueCb Hash List */ - ret = cmHashListInit(&(gCb->u.ulCb->ueLstCp), (U16) PJ_UE_LIST_BUCKET_SIZE, - (U16) 0, (Bool) FALSE, (U16) CM_HASH_KEYTYPE_DEF, - gCb->init.region, gCb->init.pool); - if (ret != ROK) - { -#ifdef DEBUGP - RLOG0(L_ERROR, "cmHashListInit Failed for gCb.ueLstCp."); -#endif - RETVALUE(ret); - } - - ret = cmHashListInit(&(gCb->u.ulCb->transIdLstCp), - (U16) PJ_TRANS_ID_LST_BKT_SIZE, - (U16) 0, (Bool) FALSE, (U16) CM_HASH_KEYTYPE_DEF, - PJ_GET_MEM_REGION(gCb), PJ_GET_MEM_POOL(gCb)); - if (ret != ROK) - { - cmHashListDeinit(&gCb->u.ulCb->ueLstCp); -#ifdef DEBUGP - RLOG0(L_ERROR, "cmHashListInit Failed for pjCb.transIdLstCp."); -#endif - } - - - RETVALUE(ROK); -} /* pjDbmInit */ - - -/** - * - * @brief Handler to De initialize hash list - * - * - * @b Description - * This function is invoked by LMM to De initialize the UeCb and CellCb - * hash List - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC S16 pjDbmUlDeInit -( -PjCb *gCb -) -#else -PUBLIC S16 pjDbmUlDeInit(gCb) -PjCb *gCb; -#endif -{ - S16 ret; /* Return Value */ - - TRC3(pjDbmUlDeInit); - -#ifdef DEBUGP - RLOG0(L_DEBUG, "pjDbmDeInit()"); -#endif - - /* Initialize ueCb Hash List */ - ret = cmHashListDeinit(&(gCb->u.ulCb->ueLstCp)); - if (ret != ROK) - { -#ifdef DEBUGP - RLOG0(L_ERROR, "cmHashListDeinit Failed for gCb.ueLstCp."); -#endif - RETVALUE(ret); - } - /* Initialize transId Hash List */ - /*MEM_LEAK_FIX*/ - ret = cmHashListDeinit(&(gCb->u.ulCb->transIdLstCp)); - if (ret != ROK) - { -#ifdef DEBUGP - RLOG0(L_ERROR, "cmHashListDeinit Failed for gCb.transIdLstCp."); -#endif - RETVALUE(ret); - } - - ret = cmHashListDeinit(&(gCb->u.ulCb->transIdLstCp)); - if (ret != ROK) - { -#ifdef DEBUGP - RLOG0(L_ERROR, "cmHashListDeinit Failed for gCb->u.ulCb->transIdLstCp"); -#endif - RETVALUE(ret); - } - RETVALUE(ROK); -} /* pjDbmDeInit */ - - -/** - * - * @brief Handler to fetch rbCb in the Upper Interface - * - * - * @b Description - * This function is invoked by CFG to fetch rbCb from the cellCb/ueCb in - * the upper interface (CPJ/PJU). - * - * @param[in] rlcId RLC Identifier - * @param[out] rbCb RB Control Block - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC S16 pjDbmFetchUlRbCb -( -PjCb *gCb, -CmLteRlcId rlcId, /* RLC Identifier */ -PjUlRbCb **rbCb /* RB Cb */ -) -#else -PUBLIC S16 pjDbmFetchUlRbCb(gCb, rlcId, rbCb) -PjCb *gCb; -CmLteRlcId rlcId; /* RLC Identifier */ -PjUlRbCb **rbCb; /* RB Cb */ -#endif -{ - PjUlUeCb *ueCb; /* UE Control Block */ - PjUlRbCb *tRbCb; /* Local RB CB */ - S16 ret; /* Return Value */ - - TRC3(pjDbmFetchUlRbCb) - - ueCb = NULLP; - ret = ROK; - - /* Validate the RBID in case of TM/UM/AM */ - PJ_VALIDATE_RBID(rlcId.ueId, rlcId.rbId, rlcId.rbType, ret); - if (ret != ROK) - { -#ifdef DEBUGP - /* DEBUG_PRINT EROR */ - RLOG_ARG2(L_ERROR,DBG_UEID,rlcId.ueId, - "PJ_VALIDATE_RBID Failed rbId(%d), cellId(%d)", - rlcId.rbId, rlcId.cellId); -#endif - RETVALUE(ret); - } - if (pjDbmFetchUlUeCb(gCb, rlcId.ueId, rlcId.cellId, &ueCb) != ROK) - { -#ifdef DEBUGP - RLOG_ARG0(L_ERROR,DBG_UEID,rlcId.ueId, "Failed to Fetch UE Cb"); -#endif - RETVALUE(RFAILED); - } - else - { - PJ_DBM_FETCH_UL_RBCB(rlcId.rbId, rlcId.rbType, ueCb, tRbCb); - } - - if (tRbCb == NULLP) - { - RLOG_ARG2(L_ERROR, DBG_UEID,rlcId.ueId, "CellId[%u]:RbId[%d] not found", - rlcId.cellId, rlcId.rbId); - RETVALUE(RFAILED); - } - - *rbCb = tRbCb; - - RETVALUE(ROK); -} /* pjDbmFetchRbCb */ - - - -/** - * - * @brief Handler to delete RbCb - * - * - * @b Description - * This function is invoked by CFG to remove RbCb from Ue/Cell hashlist - * - * - * @param[in] rbCbLst - Rb Cb List - * @param[in] numRbCb - Number of rbCbs - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC S16 pjDbmDelAllUlRb -( -PjCb *gCb, -PjUlRbCb **rbCbLst, /* RB Cb list */ -U8 numRbCb /* Number of rbCbs */ -) -#else -PUBLIC S16 pjDbmDelAllUlRb(gCb,rbCbLst, numRbCb) -PjCb *gCb; -PjUlRbCb **rbCbLst; /* RB Cb list */ -U8 numRbCb; /* Number of rbCbs */ -#endif -{ - U8 idx; /* Index */ - PjUlRbCb *rbCb; /* RB Control Block */ - - TRC3(pjDbmDelAllUlRb) - -#ifdef DEBUGP - RLOG1(L_DEBUG, "pjDbmDelAllRb(rbCbLst, numRbCb(%d))", numRbCb); -#endif - - for (idx = 0; idx < numRbCb; idx++) - { - rbCb = rbCbLst[idx]; - if (rbCb != NULLP) - { - PJ_DBM_DELETE_UL_RBCB(gCb,rbCb); - rbCbLst[idx] = NULLP; - } - } - - RETVALUE(ROK); -} /* pjDbmDelAllRb */ - - -/** - * - * @brief Handler to create an UeCb - * - * - * @b Description - * This function is invoked by CFG to create UeCb and insert into the Ue hashlist - * of PjCb. - * - * - * @param[in] ueId UE Identifier - * @param[in] cellId Cell Identifier - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC S16 pjDbmCreateUlUeCb -( -PjCb *gCb, -CmLteRnti ueId, /* UE Identifier */ -CmLteCellId cellId, /* Cell Identifier */ -PjUlUeCb **ueCb /* UE Control Block */ -) -#else -PUBLIC S16 pjDbmCreateUlUeCb(gCb, ueId, cellId, ueCb) -PjCb *gCb; -CmLteRnti ueId; /* UE Identifier */ -CmLteCellId cellId; /* Cell Identifier */ -PjUlUeCb **ueCb; /* UE Control Block */ -#endif -{ - S16 ret; /* Return Value */ - PjUlUeCb *tUeCb; /* UE Control Block */ - - TRC3(pjDbmCreateUlUeCb) - -#ifdef DEBUGP - RLOG2(L_DEBUG, "pjDbmCreateUeCb(ueId(%d), cellId(%d))", ueId, cellId); -#endif - - PJ_ALLOC(gCb, *ueCb, sizeof(PjUlUeCb)); - -#if (ERRCLASS & ERRCLS_ADD_RES) - if (*ueCb == NULLP) - { - ret = RFAILED; - RLOG0(L_FATAL, "Memory Allocation failure"); - RETVALUE(ret); - } -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - - tUeCb = *ueCb; - tUeCb->key.ueId = ueId; - tUeCb->key.cellId = cellId; - - ret = cmHashListInsert(&(gCb->u.ulCb->ueLstCp), (PTR)tUeCb, (U8 *)&(tUeCb->key), - (U16) sizeof(PjUeKey)); - if (ret != ROK) - { -#ifdef DEBUGP - RLOG_ARG1(L_ERROR,DBG_UEID,ueId,"Ul UeCb Hash Insert Failed : cellId(%d)", - cellId); -#endif - RETVALUE(ret); - } - - /* kw005.201 ccpu00117318, updating the statistics */ - gCb->pjGenSts.numUe++; - - (*ueCb)->libInfo.state = PJ_STATE_NORMAL; - cmInitTimers(&((*ueCb)->libInfo.obdTmr), 1); - RETVALUE(ret); -} /* kwDbmCreateUeCb */ - - -/** - * - * @brief Handler to Fetch an UeCb - * - * - * @b Description - * This function is invoked by CFG to fetch UeCb from the Ue hashlist - * of PjCb. - * - * - * @param[in] ueId UE Identifier - * @param[in] cellId Cell Identifier - * @param[out] ueCb UE Control Block - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC S16 pjDbmFetchUlUeCb -( -PjCb *gCb, -CmLteRnti ueId, /* UE Identifier */ -CmLteCellId cellId, /* Cell Identifier */ -PjUlUeCb **ueCb /* UE Control Block */ -) -#else -PUBLIC S16 pjDbmFetchUlUeCb(gCb, ueId, cellId, ueCb) -PjCb *gCb; -CmLteRnti ueId; /* UE Identifier */ -CmLteCellId cellId; /* Cell Identifier */ -PjUlUeCb **ueCb; /* UE Control Block */ -#endif -{ - S16 ret; /* Return Value */ - PjUeKey key; /* Key for UE Hash List */ - - TRC3(pjDbmFetchUlUeCb) - - - key.ueId = ueId; - key.cellId = cellId; - - ret = cmHashListFind(&(gCb->u.ulCb->ueLstCp), (U8 *)&(key), sizeof(PjUeKey), - PJ_DEF_SEQ_NUM, (PTR *) ueCb); - if (ret != ROK) - { -#ifdef DEBUGP - RLOG_ARG0(L_INFO,DBG_UEID,ueId, "Hash Find Failed for fetching ueCb"); -#endif - RETVALUE(ret); - } - - RETVALUE(ROK); -} /* pjDbmFetchUeCb */ - - -/** - * - * @brief Handler to delete an UeCb - * - * - * @b Description - * This function is invoked by CFG to delete UeCb from the Ue hashlist - * of PjCb. - * - * - * @param[in] ueCb UE Control Block - * @param[in] abrtFlag Abort Flag - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC S16 pjDbmDelUlUeCb -( -PjCb *gCb, -PjUlUeCb *ueCb, /* UE Identifier */ -Bool abortFlag /* Abort Flag */ -) -#else -PUBLIC S16 pjDbmDelUlUeCb(gCb, ueCb, abortFlag) -PjCb *gCb; -PjUlUeCb *ueCb; /* UE Identifier */ -Bool abortFlag; /* Abort Flag */ -#endif -{ - S16 ret; /* Return Value */ - U8 idx; /* Index */ - - TRC3(pjDbmDelUlUeCb) - -#ifdef DEBUGP - RLOG2(L_DEBUG, "pjDbmDelUeCb(ueId(%d), cellId(%d))", - ueCb->key.ueId, ueCb->key.cellId); -#endif - -/* kw005.201 Check to see if there is atleast one logical channel */ - - for ( idx = 0; idx< PJ_MAX_SRB_PER_UE; idx++) - pjCfgDelPjUlRbCb(gCb, ueCb, ueCb->srbCb[idx]); - - for ( idx = 0; idx< PJ_MAX_DRB_PER_UE; idx++) - pjCfgDelPjUlRbCb(gCb, ueCb, ueCb->drbCb[idx]); - - /* Close the Integrity/Ciphering channels */ - if(ueCb->secInfo.secAct) - { -#ifdef INTEL_QAT_DP - pjUtlUlIntClose(gCb,ueCb->secInfo.cpIntSessCxtId); - pjUtlUlCipherClose(gCb,ueCb->secInfo.cpCiphSessCxtId); - pjUtlUlCipherClose(gCb,ueCb->secInfo.upCiphSessCxtId); -#else - pjUtlUlIntClose(gCb,ueCb->secInfo.intCxtId); - pjUtlUlCipherClose(gCb,ueCb->secInfo.cpCxtId); - pjUtlUlCipherClose(gCb,ueCb->secInfo.upCxtId); -#endif - } - - /* Delete hoInfo if present */ - if (ueCb->hoInfo != NULLP) - { - for (idx = 0; idx < PJ_MAX_DRB_PER_UE; idx++) - { - if (ueCb->hoInfo->hoCfmInfo[idx].pres == TRUE) - { - PJ_FREE(gCb, ueCb->hoInfo->hoCfmInfo[idx].ulBitMap, - (ueCb->hoInfo->hoCfmInfo[idx].numBits % 8)? - ((ueCb->hoInfo->hoCfmInfo[idx].numBits / 8) + 1): - (ueCb->hoInfo->hoCfmInfo[idx].numBits / 8 )); - } - } - - PJ_FREE(gCb, ueCb->hoInfo->hoCfmInfo, - (PJ_MAX_DRB_PER_UE * sizeof(PjUlHoCfmInfo))); - PJ_FREE(gCb, ueCb->hoInfo, sizeof(PjUlHoInfo)); - } - - /* Delete ueCb entry from ueLstCp */ - ret = cmHashListDelete(&(gCb->u.ulCb->ueLstCp), (PTR) ueCb); - if (ret != ROK) - { - -#ifdef DEBUGP - RLOG_ARG0(L_ERROR,DBG_UEID,ueCb->key.ueId, - "Hash Delete Failed for deleting ueCb."); -#endif - } - /* kw005.201 ccpu00117318, updating the statistics */ - gCb->pjGenSts.numUe--; - - /* Deallocate ueCb */ - PJ_FREE(gCb, ueCb, sizeof(PjUlUeCb)); - - RETVALUE(ret); -} /* pjDbmDelUeCb */ - - -/** - * - * @brief Handler to delete all UeCbs - * - * - * @b Description - * This function is invoked by CFG to delete all UeCbs from the Ue - * hashlist of PjCb. - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC S16 pjDbmDelAllUlUe -( -PjCb *gCb -) -#else -PUBLIC S16 pjDbmDelAllUlUe(gCb) -PjCb *gCb; -#endif -{ - S16 ret; - PjUlUeCb *ueCb; /* UE Control Block */ - - TRC3(pjDbmDelAllUlUe) - -#ifdef DEBUGP - RLOG0(L_DEBUG, "pjDbmDelAllUe()"); -#endif - - ret = ROK; - ueCb = NULLP; - - /* Until no more ueCb is ueLstCp hash list get and delete ueCb */ - while (cmHashListGetNext(&(gCb->u.ulCb->ueLstCp), (PTR) ueCb, (PTR *)&ueCb) == ROK) - { - /* Delete ueCb */ - ret = pjDbmDelUlUeCb(gCb,ueCb, TRUE); - if (ret != ROK) - { -#ifdef DEBUGP - RLOG_ARG0(L_ERROR,DBG_UEID,ueCb->key.ueId, "UE deletion Failed"); -#endif - RETVALUE(ret); - } - ueCb = NULLP; - } - - RETVALUE(ret); -} /* pjDbmDelAllUe */ - -/** - * - * @brief Handler to Shutdown all UeCbs - * - * - * @b Description - * This function is invoked by CFG to shutdown UeCbs from the PjCb. - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC S16 pjDbmUlShutdown -( -PjCb *gCb -) -#else -PUBLIC S16 pjDbmUlShutdown(gCb) -PjCb *gCb; -#endif -{ -#if (ERRCLASS & ERRCLS_DEBUG) -S16 ret -#endif - - TRC3(pjDbmUlShutdown) - -#if (ERRCLASS & ERRCLS_DEBUG) - ret = pjDbmUlDeInit(gCb); - if (ret != ROK) - { - RLOG0(L_FATAL, "UL DeInitialization Failed"); - } -#else - pjDbmUlDeInit(gCb); -#endif /* ERRCLASS & ERRCLS_DEBUG */ - - RETVALUE(ROK); -} /* pjDbmShutdown */ - -/** - * - * @brief Handler to create a RB control block. - * - * - * @b Description - * This function is called to create a RLC control block or PDCP - * control block based on rb flag and update the pointers in RbCb. - * If the RbCb is already allocated, the rbId is updated in PjRbCb - * or PjUlRbCb based on rb. If the RbCb has not been allocated earlier, - * a new RbCb is created and the pointers are updated along with the - * rbIds. - * - * @param[in] rbId RB ID of the entity - * @param[in] rbCbLst List of the RBs in the UeCb - * @param[in] rb The RB to be created. This can be - * PJ_CFG_PDCP when PDCP is created - * or PJ_CFG_RLC when RLC is being - * created. - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC PjUlRbCb* pjDbmCreateUlRbCb -( -PjCb *gCb, -U8 rbId, -U8 rbType, -PjUlUeCb *ueCb, -U8 rb -) -#else -PUBLIC PjUlRbCb* pjDbmCreateUlRbCb(gCb,rbId,rbType,ueCb,rb) -PjCb *gCb; -U8 rbId; -U8 rbType; -PjUlUeCb *ueCb; -U8 rb; -#endif -{ - PjUlRbCb *rbCb; - PjUlRbCb **rbCbLst; - - TRC2(pjDbmCreateUlRbCb) - - rbCb = NULLP; - rbCbLst = NULLP; - PJ_ALLOC(gCb, rbCb, sizeof(PjUlRbCb) ); - if ( rbCb == NULLP ) - { - RLOG0(L_FATAL, "Memory Allocation failed"); - RETVALUE(rbCb); - } - rbCb->rbId = rbId; - rbCb->rbType = rbType; - - rbCbLst = ((rbType == CM_LTE_SRB)? ueCb->srbCb:ueCb->drbCb); - rbCbLst[rbId] = rbCb; - /* kw005.201 ccpu00117318, updating the statistics */ - PJ_LMM_RB_STS_INC(gCb); - - RETVALUE(rbCb); - -} /* pjDbmCreateRbCb */ - -/** - * - * @brief Handler to fetch a PDCP RB control block. - * - * - * @b Description - * This function is used to fetch the PDCP RB control block based on - * the RB id. The pointer to PjUlRbCb is returned. - * - * @param[in] ueCb UE control block of the PDCP RB - * @param[in] rbId RB ID of the required PDCP entity. - * @param[out] pjRbCb PDCP RB Control Block. - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 pjDbmFetchPjUlRbCb -( -PjUlUeCb *ueCb, -U8 rbId, -U8 rbType, -PjUlRbCb **pjRbCb -) -#else -PUBLIC S16 pjDbmFetchPjUlRbCb(ueCb,rbId,rbType,pjRbCb) -PjUlUeCb *ueCb; -U8 rbId; -U8 rbType; -PjUlRbCb **pjRbCb; -#endif -{ - PjUlRbCb *rbCb; - - TRC2(pjDbmFetchPjUlRbCb) - - *pjRbCb = NULLP; - - PJ_DBM_FETCH_UL_RBCB(rbId, rbType, ueCb, rbCb); - if ( rbCb != NULLP ) - { - *pjRbCb = rbCb; - } - - RETVALUE(ROK); - -} /* pjDbmFetchPjUlRbCb */ - -/** - * - * @brief Handler to delete a PDCP/RLC RB control block. - * - * - * @b Description - * This function is used to delete the PDCP/RLC RB control block based - * on RB id and the RB type (PDCP/RLC). If the corresponding RB is - * present, the cfgStat flag is unset. If the cfgStat flag is zero, - * the RBCB is freed. - * - * @param[in] rbId RB ID of the to be deleted RB - * @param[in] rbCbLst RbCb list in UE CB - * @param[in] rb The RB to be deleted. This can be - * PJ_CFG_PDCP when PDCP is created - * or PJ_CFG_RLC when RLC is being - * created. - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 pjDbmDelUlRbCb -( -PjCb *gCb, -U8 rbId, -U8 rbType, -PjUlRbCb **rbCb, -U8 rb, -PjUlUeCb *ueCb -) -#else -PUBLIC S16 pjDbmDelUlRbCb(gCb,rbId,rbType,rbCb,rb) -PjCb *gCb; -U8 rbId; -U8 rbType; -PjUlRbCb **rbCb; -U8 rb; -PjUlUeCb *ueCb; -#endif -{ - S16 ret; - PjUlRbCb **rbCbLst; - rbCbLst = NULLP; - - TRC2(pjDbmDelUlRbCb) - - ret = RFAILED; - /*updating rbCbList */ - rbCbLst = ((rbType == CM_LTE_SRB)? ueCb->srbCb:ueCb->drbCb); - if ( (*rbCb) != NULLP ) - { - PJ_DBM_DELETE_UL_RBCB(gCb,(*rbCb)); - ret = ROK; - /*updating rbCbList */ - rbCbLst[rbId] = NULLP; - } - RETVALUE(ret); - -} /* pjDbmDelRbCb */ - -/** - * - * @brief Handler to add UL Transaction Id to List - * - * - * @b Description - * This function is invoked by CFG to add all itransaction IDs to - * hashlist of PjCb. - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC S16 pjDbmAddUlTransIdLst -( -PjCb *gCb, -PjCfgInfo *cfg /* UE Control Block */ -) -#else -PUBLIC S16 pjDbmAddUlTransIdLst(gCb,cfg) -PjCb *gCb; -PjCfgInfo *cfg; /* UE Control Block */ -#endif -{ - S16 ret; /* Return Value */ - - TRC3(pjDbmAddUlTransIdLst) - -#ifdef DEBUGP -#ifndef ALIGN_64BIT - RLOG1(L_UNUSED, "pjDbmAddUlTransIdLst(transId(%ld))", cfg->transId); -#else - RLOG1(L_UNUSED, "pjDbmAddUlTransIdLst(transId(%d))", cfg->transId); -#endif -#endif - - ret = cmHashListInsert(&(gCb->u.ulCb->transIdLstCp), (PTR)cfg, - (U8 *)&(cfg->transId), (U16) sizeof(cfg->transId)); - if (ret != ROK) - { -#ifdef DEBUGP - RLOG0(L_ERROR, "Hash Insert Failed for Inserting UL transId"); -#endif - RETVALUE(ret); - } - - RETVALUE(ret); -} /* pjDbmAddUlTransIdLst */ - -/** - * - * @brief Handler to Find UL Transaction Id in the List - * - * - * @b Description - * This function is invoked by CFG to Find transaction IDs in the - * hashlist of PjCb. - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC S16 pjDbmFindUlTransIdLst -( -PjCb *gCb, -U32 transId, -PjCfgInfo **cfg /* UE Control Block */ -) -#else -PUBLIC S16 pjDbmFindUlTransIdLst(gCb,cfg) -PjCb *gCb; -U32 transId; -PjCfgInfo *cfg; /* UE Control Block */ -#endif -{ - S16 ret; /* Return Value */ - - TRC3(pjDbmFindUlTransIdLst) - -#ifdef DEBUGP -#ifndef ALIGN_64BIT - RLOG1(L_DEBUG, "pjDbmFindUlTransIdLst(transId(%ld))", transId); -#else - RLOG1(L_DEBUG, "pjDbmFindUlTransIdLst(transId(%d))", transId); -#endif -#endif - - ret = cmHashListFind(&(gCb->u.ulCb->transIdLstCp),(U8 *) &transId, - sizeof (transId), PJ_DEF_SEQ_NUM,(PTR *) cfg); - if (ret != ROK) - { -#ifdef DEBUGP - RLOG1(L_ERROR,"Hash Find Failed Fetch for transId [%d]", transId); -#endif - } - ret = pjDbmDelUlTransIdLst(gCb, cfg); - if (ret != ROK) - { -#ifdef DEBUGP - RLOG0(L_ERROR,"Deleting Trans ID Failed"); -#endif - RETVALUE(ret); - } - - RETVALUE(ret); -} /* pjDbmAddUlTransIdLst */ - -/** - * - * @brief Handler to Delete UL Transaction Id to List - * - * - * @b Description - * This function is invoked by CFG to Delete transaction IDs From the - * hashlist of PjCb. - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC S16 pjDbmDelUlTransIdLst -( -PjCb *gCb, -PjCfgInfo **cfg /* UE Control Block */ -) -#else -PUBLIC S16 pjDbmDelUlTransIdLst(gCb,cfg) -PjCb *gCb; -PjCfgInfo **cfg; /* UE Control Block */ -#endif -{ - S16 ret; /* Return Value */ - - TRC3(pjDbmDelUlTransIdLst) - -#ifdef DEBUGP - RLOG0(L_DEBUG, "pjDbmFindUlTransIdLst(transId()" ); -#endif - - ret = cmHashListDelete(&(gCb->u.ulCb->transIdLstCp),(PTR) (*cfg)); - if (ret != ROK) - { -#ifdef DEBUGP - RLOG1(L_ERROR," Hash Delete Failed for transId(%d)",(*cfg)->transId); -#endif - } - - RETVALUE(ret); -} /* pjDbmAddUlTransIdLst */ - -/** - * - * @brief Handler to Delete All UL Transaction Ids from the List - * - * - * @b Description - * This function is invoked by CFG to Delete all itransaction IDs from the - * hashlist of PjCb. - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ -#ifdef ANSI -PUBLIC S16 pjDbmDelAllUlTransIdLst -( -PjCb *gCb -) -#else -PUBLIC S16 pjDbmDelAllUlTransIdLst(gCb) -PjCb *gCb; -#endif -{ - S16 ret; /* Return Value */ - PjCfgInfo *cfg; - - TRC3(pjDbmDelAllUlTransIdLst) - -#ifdef DEBUGP - RLOG0(L_DEBUG, "pjDbmFindUlTransIdLst"); -#endif - ret = ROK; - cfg = NULLP; /*KW_FIX*/ - /* Until no more ueCb is ueLstCp hash list get and delete ueCb */ - while (cmHashListGetNext(&(gCb->u.ulCb->transIdLstCp), - (PTR) cfg, (PTR *)&cfg) == ROK) - - { - /* Delete ueCb */ - ret = pjDbmDelUlTransIdLst(gCb,&cfg); - if (ret != ROK) - { -#ifdef DEBUGP - RLOG0(L_ERROR, " pjDbmDelTransIdLst Failed."); -#endif - RETVALUE(ret); - } - - cfg = NULLP; - } - - RETVALUE(ret); -} /* pjDbmAddUlTransIdLst */ - - - - - - -/********************************************************************30** - - End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_dl.h b/src/5gnrpdcp/pj_dl.h deleted file mode 100755 index 37d2d2a1c..000000000 --- a/src/5gnrpdcp/pj_dl.h +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: LTE PDCP file - - Type: C include file - - Desc: This file contain the hash definations for PDCP - - File: pj_dl.h - -*********************************************************************21*/ -/** @file pj_dl.h -@brief PDCP Hash definitions -*/ - -#ifndef __PJ_DLH__ -#define __PJ_DLH__ - - -#define PJ_DBM_FETCH_DL_RBCB(_rbId, _rbType, _ueCb, _rbCb) \ -{ \ - _rbCb = (_rbType==CM_LTE_SRB)?_ueCb->srbCb[_rbId]:_ueCb->drbCb[_rbId];\ -} - -/* HO_FIX: RRC expects the results as ROK or RFAILED - Hence, changing the vlaue to ROK from CPJ_CFG_CFM_OK */ -#define PJ_FILL_DL_SDU_CFM_INFO(_cb,_cfmInfo, _ueCb) \ -{ \ - U8 _rbCnt; \ - U8 _numRb = 0; \ - PjDlHoCfmInfo *_hoCfmInfo; \ - UdxSduStaInfo *_staInfo; \ - _cfmInfo->ueId = _ueCb->key.ueId; \ - _cfmInfo->cellId = _ueCb->key.cellId; \ - _cfmInfo->transId = _ueCb->hoInfo->transId; \ - for(_rbCnt = 0; _rbCnt < PJ_MAX_DRB_PER_UE && _numRb < CPJ_MAX_DRB; _rbCnt++) \ - { \ - _hoCfmInfo = &_ueCb->hoInfo->hoCfmInfo[_rbCnt]; \ - _staInfo = &_cfmInfo->sduStaInfo[_numRb]; \ - if(_hoCfmInfo->pres != TRUE) \ - { \ - continue; \ - } \ - \ - _staInfo->rbId = _hoCfmInfo->rbId; \ - _staInfo->dir = _hoCfmInfo->dir; \ - _staInfo->dlSduStaInfo.count = _hoCfmInfo->count; \ - _staInfo->dlSduStaInfo.hoPres = TRUE; \ - _numRb++; \ - } \ - _cfmInfo->numRb = _numRb; \ - _cfmInfo->status = ROK; \ - _cfmInfo->reason = CPJ_CFG_REAS_NONE; \ - PJ_FREE(_cb,_ueCb->hoInfo->hoCfmInfo, \ - (PJ_MAX_DRB_PER_UE * sizeof(PjDlHoCfmInfo))) \ - PJ_FREE(_cb,_ueCb->hoInfo, sizeof(PjDlHoInfo)); \ -} -#define PJ_DBM_DELETE_DL_RBCB(_cb, _rbCb) \ -{ \ - /* Free memory for rbCb */ \ - PJ_FREE(_cb, _rbCb, sizeof(PjDlRbCb)); \ - PJ_LMM_RB_STS_DEC(_cb); \ -} - -#endif /* __PJH__ */ - -/********************************************************************30** - - End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_dl.x b/src/5gnrpdcp/pj_dl.x deleted file mode 100755 index 6bb5a9ab6..000000000 --- a/src/5gnrpdcp/pj_dl.x +++ /dev/null @@ -1,792 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: LTE PDCP file - - Type: C include file - - Desc: This file contains all the data structures and - prototypes for LTE PDCP. - - File: pj_dl.x - -*********************************************************************21*/ -/** @file pj_dl.x -@brief PDCP Product Structures, prototypes -*/ - -#ifdef TENB_STATS -#include "pj_tenb_stats.x" -#endif - - -#ifndef __PJ_DL_X__ -#define __PJ_DL_X__ - - -/* - * The structures and variables declared in this file - * correspond to structures and variables used by - * the following TRILLIUM software: - * - * part no. description - * -------- ---------------------------------------------- - * 1000371 LTE-RLC - * -*/ - - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -typedef struct pjDlUeCb PjDlUeCb; -typedef struct pjDlRbCb PjDlRbCb; /* PDCP RB control block */ - - - -/** @addtogroup dldata */ -/*@{*/ - -/** - * @brief - * PDCP SDU Status Information for a DRB mapped to RLC AM. - */ - -typedef struct pjDlHoCfmInfo -{ - U8 rbId; /*!< RB ID */ - Bool pres; /*!< Is handover info present for this RB */ - U8 dir; /*!< Direction of the RB */ - U8 res1; - U32 count; /*!< Count of the next SN to be assigned */ -}PjDlHoCfmInfo; - -/** - * @brief - * Handover information maintainned during processing of SduStaReq - */ -typedef struct pjDlHoInfo -{ - U32 transId; /*!< Transaction ID */ - PjDlHoCfmInfo *hoCfmInfo; /*!< SDU Status Confirm */ -}PjDlHoInfo; - -/** @struct PjTxEnt -PDCP Tx Entry - SDU received from Relay */ -typedef struct pjTxEnt -{ - CmLList lstEnt; /*!< List entry for SDU */ - CmLList datCfmEnt; /*!< List entry for SDU */ - CmLList sduSubmitEnt; /*!< List entry for SDU */ - CmLList reEstPktEnt; /*!< List entry for SDU */ - U8 state; /*!< SDU state */ - U8 res; /*!< reserved */ - PjSn sn; /*!< PDCP SN associated with this SDU */ - U32 count; /*!< COUNT associated with this SDU */ - Data *ciphDBuf; /*Pointer to flat buffer created for ciphering */ - Buffer *pdu; /*!< Pdu Buffer */ - Buffer *sdu; /*!< Sdu Buffer */ -#ifdef FLAT_BUFFER_OPT - FlatBuffer fb; -#endif - U32 sduId; /*!< SDU ID */ - PjDlRbCb *rbCb; - MsgLen bufLen; -#ifdef LTE_L2_MEAS - EpcTime epcTime; /*!< Arrival Time of the SDU for dl delay */ -#endif -}PjTxEnt; - -/** @struct PjDlCb -PDCP downlink control block */ -typedef struct pjDlCb -{ - S16 discTmrInt; /*!< Discard timer Interval */ - U32 txNext; /*! Activates Initialization - * - * @b Description: - * This function is invoked by system services to initialize the LTE-PDCP - * layer. This is an entry point used by LTE_PDCP layer to initialize its - * global variables, before becoming operational. - * - * Allowable values for parameters are specified in ssi.h. - * - * @param[in] ent - Specify the entity id of the LTE-RLC task. - * @param[in] inst - Specify the entity id of the LTE-RLC task. - * @param[in] region - Specifies the memory region from which - * LTE-PDCP should allocate structures and buffers. - * @param[in] reason - Specifies the reason for calling this - * initialization function. - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 pjDlActvInit -( - Ent ent, /* entity */ - Inst inst, /* instance */ - Region region, /* region */ - Reason reason /* reason */ - ) -#else -PUBLIC S16 pjDlActvInit(ent, inst, region, reason) - Ent ent; /* entity */ - Inst inst; /* instance */ - Region region; /* region */ - Reason reason; /* reason */ -#endif -{ - PjCb *tPjCb; - TRC3(pjDlActvInit) - if (inst >= PJ_MAX_PDCP_INSTANCES) - { - /* intance greater than MAX instances */ - RETVALUE(RFAILED); - } - - if (pjCb[inst] != NULLP) - { - RETVALUE (RFAILED); - } - - if (SGetSBuf(region, 0, (Data **)&tPjCb, - (Size)sizeof (PjCb)) != ROK) - { - RETVALUE(RFAILED); - } - /* Initialize kwCb */ - PJ_MEM_SET(tPjCb, 0, sizeof(PjCb)); - - /* Initialize task configuration parameters */ - /* We will take only entity name */ - tPjCb->init.ent = ent; /* entity */ - tPjCb->init.inst = inst; /* instance */ - tPjCb->init.region = region; /* static region */ - tPjCb->init.pool = 0; /* static pool */ - tPjCb->init.reason = reason; /* reason */ - tPjCb->init.cfgDone = FALSE; /* configuration done */ - tPjCb->init.acnt = TRUE; /* enable accounting */ - tPjCb->init.usta = TRUE; /* enable unsolicited status */ - tPjCb->init.trc = FALSE; /* enable trace */ -#ifdef DEBUGP - tPjCb->init.dbgMask = 0x00000000; -#endif - tPjCb->init.procId = SFndProcId(); - - pjCb[inst] = tPjCb; - - RETVALUE(ROK); -} /* pjActvInit */ - - -/** - * - * @brief - * - * Activation Task - * - * @b Description: - * Processes events received for LTE-PDCP layer via System Services from - * other layers. - * - * @param[in] pst - Pst Structure - * @param[in] mBuf - Message Buffer - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 pjDlActvTsk -( -Pst *pst, /* pst structure */ -Buffer *mBuf /* message buffer */ -) -#else -PUBLIC S16 pjDlActvTsk(pst, mBuf) -Pst *pst; /* pst structure */ -Buffer *mBuf; /* message buffer */ -#endif -{ - S16 ret = ROK; - - TRC3(pjDlActvTsk); - - switch(pst->srcEnt) - { - case ENTSM: - { - switch(pst->event) - { -#ifdef LCLPJ - case LPJ_EVT_CFG_REQ: - { - ret = cmUnpkLpjCfgReq(PjMiLpjCfgReq, pst, mBuf); - break; - } - - case LPJ_EVT_CNTRL_REQ: - { - ret = cmUnpkLpjCntrlReq(PjMiLpjCntrlReq, pst, mBuf); - break; - } - - case LPJ_EVT_STS_REQ: - { - ret = cmUnpkLpjStsReq(PjMiLpjStsReq, pst, mBuf); - break; - } - - case LPJ_EVT_STA_REQ: - { - ret = cmUnpkLpjStaReq(PjMiLpjStaReq, pst, mBuf); - break; - } - /* kw005.201 added support for L2 Measurement */ - - default: - { - RLOG0(L_ERROR, "Received Invalid Event from SM"); - ret = RFAILED; - break; - } -#endif /* LCLPJ */ - } - break; - } - - case ENTPJ: - { - switch(pst->event) - { -#ifdef LCUDX - case EVTUDXBNDREQ: - { - cmUnpkPjUdxBndReq(PjDlUdxBndReq, pst, mBuf); - break; - } - - case EVTUDXUBNDREQ: - { - cmUnpkPjUdxUbndReq(PjDlUdxUbndReq, pst, mBuf); - break; - } - - case EVTUDXCFGREQ: - { - cmUnpkPjUdxCfgReq(PjDlUdxCfgReq, pst, mBuf); - break; - } - - case EVTUDXULSTAREP: - { - cmUnpkPjUdxUlStaRep(PjDlUdxUlStaRep, pst, mBuf); - break; - } - - case EVTUDXDLSTAREP: - { - cmUnpkPjUdxDlStaRep(PjDlUdxDlStaRep, pst, mBuf); - break; - } - - case EVTUDXULROHCFDB: - { - cmUnpkPjUdxUlFdbkPkt(PjDlUdxUlFdbkPktInfo, pst, mBuf); - break; - } - - case EVTUDXDLROHCFDB: - { - cmUnpkPjUdxDlFdbkPkt(PjDlUdxDlFdbkPktInfo, pst, mBuf); - break; - } - - case EVTUDXREESTREQ: - { - cmUnpkPjUdxReEstReq(PjDlUdxReEstReq, pst, mBuf); - break; - } - - case EVTUDXSECCFGREQ: - { - cmUnpkPjUdxSecCfgReq(PjDlUdxSecCfgReq, pst, mBuf); - break; - } - - case EVTUDXUEIDCHGREQ: - { - cmUnpkPjUdxUeIdChgReq(PjDlUdxUeIdChgReq, pst, mBuf); - break; - } - - case EVTUDXCOUNTREQ: - { - cmUnpkPjUdxCountReq(PjDlUdxCountReq, pst, mBuf); - break; - } - - case EVTUDXSDUSTAREQ: - { - cmUnpkPjUdxSduStaReq(PjDlUdxSduStaReq, pst, mBuf); - break; - } - case EVTUDXDATRESUME: - { -#ifdef FLAT_BUFFER_OPT - cmUnpkPjUdxDatResumeReq(PjDlUdxDatResumeReq, pst, mBuf); -#else - cmUnpkPjUdxDatResumeReq(PjDlUdxDatResumeReq, pst, mBuf); -#endif - break; - } - case EVTUDXDATFRWD: - { -#ifdef FLAT_BUFFER_OPT - printf("Received Event EVTUDXDATFRWD at PDCP DL \n"); - cmUnpkPjUdxDatForwardReq(PjDlUdxDatForwardReqFB, pst, mBuf); -#else - cmUnpkPjUdxDatForwardReq(PjDlUdxDatForwardReq, pst, mBuf); -#endif - break; - } -#ifdef LTE_L2_MEAS - case PJ_UDX_EVT_L2MEAS_REQ: - { - ret = cmUnpkPjUdxL2MeasReq(PjDlUdxL2MeasReq, pst, mBuf); - break; - } - case PJ_UDX_EVT_L2MEAS_SEND_REQ: - { - - ret = cmUnpkPjUdxL2MeasSendReq(PjDlUdxL2MeasSendReq, pst, mBuf); - - break; - } - case PJ_UDX_EVT_L2MEAS_STOP_REQ: - { - ret = cmUnpkPjUdxL2MeasStopReq(PjDlUdxL2MeasStopReq, pst, mBuf); - break; - } -#endif - default: - { - RLOG0(L_ERROR, "Received Invalid Event from PDCP UL"); - ret = RFAILED; - break; - } -#endif /* LCLPJ */ - } - break; - } - - - case ENTNH: - { - switch(pst->event) - { -#ifdef LCPJU - case EVTPJUBNDREQ: - { - cmUnpkPjuBndReq(PjUiPjuBndReq, pst, mBuf); - break; - } - - case EVTPJUUBNDREQ: - { - cmUnpkPjuUbndReq(PjUiPjuUbndReq, pst, mBuf); - break; - } - - case EVTPJUDATREQ: - { - cmUnpkPjuDatReq(PjUiPjuDatReq, pst, mBuf); - break; - } - - case EVTPJUDATFWDREQ: - { - cmUnpkPjuDatFwdReq(PjUiPjuDatFwdReq, pst, mBuf); - break; - } -#endif /* LCPJU */ - default: - SPutMsg(mBuf); - RLOG0(L_ERROR, " Received Invalid Event From RRC"); - ret = RFAILED; - break; - - } - break; - } - - case ENTPX: - { - switch(pst->event) - { -#ifdef LCPJU - case EVTPJUBNDREQ: - { - cmUnpkPjuBndReq(PjUiPjuBndReq, pst, mBuf); - break; - } - - case EVTPJUUBNDREQ: - { - cmUnpkPjuUbndReq(PjUiPjuUbndReq, pst, mBuf); - break; - } - - case EVTPJUDATREQ: - { -#ifdef SS_RBUF - cmUnpkFpPjuDatReq(PjUiPjuDatReq, pst, mBuf); -#else - cmUnpkPjuDatReq(PjUiPjuDatReq, pst, mBuf); -#endif - break; - } - - case EVTPJUDATFWDREQ: - { - cmUnpkPjuDatFwdReq(PjUiPjuDatFwdReq, pst, mBuf); - break; - } -#endif -#ifdef PCAP_IP_DATGEN_LOAD_5GTF - case EVTPCAPIPDATIND: - { - //printf("ENTPX!!!!EVTPCAPIPDATIND:\n\r "); - //RLOG0(L_ERROR, " Received Invalid Event from Relay"); - wrDamPcapDatInd(mBuf); - break; - } -#endif - default: - SPutMsg(mBuf); - RLOG0(L_ERROR, " Received Invalid Event from Relay"); - ret = RFAILED; - break; - } - break; - } - - case ENTOC: - { - switch(pst->event) - { -#ifdef PJ_CMP_ASYNC - /* Compression Confirmations */ - case OBD_EVT_CMP_INIT_CFM: - ret = cmUnpkLibObdCmpInitCfm(PjLibObdCmpInitCfm, pst,mBuf); - break; - - case OBD_EVT_CMP_CFM: - ret = cmUnpkLibObdCmpCfm(PjLibObdCmpCfm, pst, mBuf); - break; - -#endif /* PJ_CMP_ASYNC */ - default: - SPutMsg(mBuf); - RLOG0(L_ERROR, "Received Invalid Event from Offboard Ciphering"); - ret = RFAILED; - break; - } - break; - } - - case ENTOS: - { - switch(pst->event) - { -#ifdef PJ_SEC_ASYNC - /* Integrity Confirmations */ - case OBD_EVT_INT_INIT_CFM: - ret = cmUnpkLibObdIntInitCfm(PjLibObdIntInitCfm, pst, mBuf); - break; - - case OBD_EVT_INT_PROT_CFM: - ret = cmUnpkLibObdIntProtCfm(PjLibObdIntProtCfm, pst, mBuf); - break; - - /* Ciphering Confirmations */ - case OBD_EVT_CP_INIT_CFM: - ret = cmUnpkLibObdCpInitCfm(PjLibObdCpInitCfm, pst, mBuf); - break; - - case OBD_EVT_UP_INIT_CFM: - ret = cmUnpkLibObdUpInitCfm(PjLibObdUpInitCfm, pst, mBuf); - break; - - case OBD_EVT_CIPHER_CFM: - ret = cmUnpkLibObdCipherCfm(PjLibObdCipherCfm, pst, mBuf); - break; - -#endif /* PJ_SEC_ASYNC */ - default: - SPutMsg(mBuf); - RLOG0(L_ERROR, "Received Invalid Event from Offboard Security"); - ret = RFAILED; - break; - } - break; - } - case ENTKW: - { - switch(pst->event) - { -#ifdef LCKWU - case KWU_EVT_BND_CFM: /* Bind request */ - { - ret = cmUnpkKwuBndCfm(PjLiKwuBndCfm, pst, mBuf ); - break; - } - - case KWU_EVT_DAT_CFM: /* Dedicated Channel Data request */ - { - ret = cmUnpkKwuDatCfm(PjLiKwuDatCfm, pst, mBuf); - break; - } - - case KWU_EVT_DISC_SDU_REQ: /* Coomon Channel Status Response */ - { - ret = cmUnpkKwuDiscSduReq(PjLiKwuDiscSduReq, pst , mBuf); - break; - } - - case KWU_EVT_STA_IND: /* Dedicated Channel Status Response */ - { - ret = cmUnpkKwuStaInd(PjLiKwuStaInd, pst, mBuf); - break; - } - case KWU_EVT_DISC_SDU_CFM: /* Harq status indication */ - { - ret = cmUnpkKwuDiscSduCfm(PjLiKwuDiscSduCfm, pst, mBuf); - break; - } - case KWU_EVT_FLOW_CNTRL_IND: /* Flow control indication*/ - { - ret = cmUnpkKwuFlowCntrlInd(PjLiKwuFlowCntrlInd, pst, mBuf); - break; - } - default: - { - SPutMsg(mBuf); - RLOG0(L_ERROR, "Received Invalid Event from RLC"); - ret = RFAILED; - break; - } - -#endif /* LCRGU */ - } - break; - } -#ifdef TENB_AS_SECURITY - case ENTYS: - { - switch(pst->event) - { - case EVTPJUTTIIND: - { -#ifndef SS_RBUF - static U32 ttitick = 0; -#endif - - ysPjPrcTtiInd++; /* UDAY */ - SPutMsg(mBuf); - /*Trigger batching of the packets queued for ciphering - * and deciphering*/ - /*Note: UL trigger should be posted to UL thread if UL - * and DL are on different threads.*/ -#ifndef L2_L3_SPLIT -#ifdef MAC_RLC_UL_RBUF - kwUlBatchProc(); -#endif -#endif -#ifdef XEON_SPECIFIC_CHANGES -#ifdef INTEL_QAT_DP - PjCb *tPjCb = PJ_GET_PJCB(pst->dstInst); - pjPollQatDat(tPjCb,ttitick); -#endif /* INTEL_QAT_DP */ -#else -#ifndef SS_RBUF - pjProcessSpaccRdWr(ttitick); -#endif -#endif -#if (defined(L2_L3_SPLIT) && defined(ICC_RECV_TSK_RBUF)) -#ifndef UL_RLC_NET_CLUSTER - pjUlBatchProcSplit(); -#endif -#endif -#ifndef SS_RBUF - ttitick++; -#endif -#ifdef LC_EGTP_THREAD - egWrReadRingBuf(SS_RNG_BUF_EGTP_FREE_RING); -#endif - break; - } - } - break; - } -#endif -#ifdef SS_RBUF - case ENTTF: - { - switch(pst->event) - { - case EVTCTFBTCHPROCTICK: - { - pjBatchProcTick(); - break; - } - case EVTCTFNRTRBUFCLEAN: - { - pjRBufFreeMsg(); - } - } - SPutMsg(mBuf); - break; - } -#endif - default: - { - RLOG0(L_ERROR, "Recieved Invalid Source Entity "); - SPutMsg(mBuf); - ret = RFAILED; - break; - } - } - - SExitTsk(); - - RETVALUE(ret); -} /* pjActvTsk */ - - -/********************************************************************30** - End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_dl_utl.c b/src/5gnrpdcp/pj_dl_utl.c deleted file mode 100755 index b236af701..000000000 --- a/src/5gnrpdcp/pj_dl_utl.c +++ /dev/null @@ -1,2710 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************** - - Name: LTE-PDCP Layer - - Type: C file - - Desc: Source code for PDCP Utility Module - - This file contains following functions: - - --PjLibObdCmpCfm - --PjLibObdIntProtCfm - --PjLibObdCipherCfm - --PjLibObdDecipherCfm - --PjLibObdIntVerCfm - --PjLibObdDecmpCfm - -- pjUtlCmpReq - -- pjUtlCipherReq - -- pjUtlIntProtReq - - File: pj_dl_utl.c - -**********************************************************************/ - static const char* RLOG_MODULE_NAME="PDCP"; -static int RLOG_MODULE_ID=1024; -static int RLOG_FILE_ID=218; - -/** @file pj_dl_utl.c -@brief PDCP Utility Module -*/ - -/* header (.h) include files */ -#include "envopt.h" /* environment options */ -#include "envdep.h" /* environment dependent */ -#include "envind.h" /* environment independent */ - -#include "gen.h" /* general */ -#include "ssi.h" /* system services */ -#include "cm5.h" /* common timer defines */ -#include "cm_tkns.h" /* common tokens defines */ -#include "cm_mblk.h" /* common memory allocation library defines */ -#include "cm_llist.h" /* common link list defines */ -#include "cm_hash.h" /* common hash list defines */ -#include "cm_lte.h" /* common LTE defines */ -#include "cpj.h" /* CPJ defines */ -#include "pju.h" /* PJU defines */ -#include "lpj.h" /* LPJ defines */ - -#include "pj_env.h" /* RLC environment options */ -#include "pj.h" /* RLC defines */ -#include "pj_dl.h" -#include "pj_err.h" /* Error defines */ -#include "pj_udx.h" -#include "pj_ptsec.h" - -/* extern (.x) include files */ -#include "gen.x" /* general */ -#include "ssi.x" /* system services */ - -#include "cm5.x" /* common timer library */ -#include "cm_tkns.x" /* common tokens */ -#include "cm_mblk.x" /* common memory allocation */ -#include "cm_llist.x" /* common link list */ -#include "cm_hash.x" /* common hash list */ -#include "cm_lte.x" /* common LTE includes */ -#include "cm_lib.x" /* common memory allocation library */ -#include "cpj.x" /* CPJ */ -#include "pju.x" /* PJU */ -#include "lpj.x" /* LPJ */ -#include "pj.x" -#include "pj_udx.h" -#include "pj_udx.x" -#include "pj_dl.x" -#include "pj_lib.x" /* LIB */ - - -EXTERN CmLListCp pjMsCiphQ; -EXTERN CmLListCp pjMsDeCiphQ; -#ifndef XEON_SPECIFIC_CHANGES -EXTERN U32 dbgPdcpMemCount,pdcpdrop, dbgSpaccThreshHoldDropCnt; -EXTERN U32 dbgPdcpQSizeThreshHoldDropCnt; -U32 spaccDropCount = 0; -EXTERN U32 pjMsDlSpaccQCnt; -EXTERN U32 pjMsUlSpaccQCnt; -#endif -#ifdef __cplusplus -EXTERN "C" { -#endif /* __cplusplus */ - -#ifdef INTEL_SW_SEC -EXTERN S16 PjLibObdSwCipherReq(PjLibTrans *libTrans, Buffer *mBuf, PjCb *gCb, Buffer **opSdu); - -EXTERN S16 pjSendToSwCipherFB ARGS((PjLibTrans *libTrans, FlatBuffer *mBuf, - PjCb *gCb, Buffer **opSdu)); -#endif - -PUBLIC S16 pjUtlReEstDl -( -PjCb *gCb, -PjDlUeCb *ueCb /* UE Control Block */ -); - -PRIVATE S16 pjUtlDlHdlSecInitCfm ARGS((PjCb *gCb,PjDlUeCb *ueCb, - U16 txIdx,PjAsyncCfm *asyncCfm, UdxSecCfgCfmInfo *secCfgCfm,UdxReEstCfmInfo *reEstCfm)); -PRIVATE S16 pjUtlDlHdlCmpInitCfm ARGS((PjCb *gCb,PjDlUeCb *ueCb, - U16 txIdx,PjAsyncCfm *asyncCfm, UdxCfgCfmInfo *cfgCfm)); - -/** - * - * @brief - * - * Handler to apply the new security algorithms and - * reset the compression unit. - * - * @b Description: - * - * This function - * 1. Creates new contexts for Control Plane Ciphering and Integrity. - * 2. Closes the old contexts for Control Plane Ciphering and Integrity. - * - * @param[in] ueCb UE Control Block - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 pjUtlDlUpdUpSecKeys -( -PjCb *gCb, -PjDlUeCb *ueCb /* UE Control Block */ -) -#else -PUBLIC S16 pjUtlDlUpdUpSecKeys(gCb,ueCb) -PjCb *gCb; -PjDlUeCb *ueCb; /* UE Control Block */ -#endif -{ - Void *tmpUpCxt; - - TRC2(pjUtlDlUpdUpSecKeys); - - RLOG2(L_DEBUG, "pjUtlReEstReconfig(ueCb(%d,%d))", - ueCb->key.ueId, ueCb->key.cellId); - - if(ueCb->secInfo.secAct == TRUE) - { - /* Initialisation is done first followed by closure since we - * do not want the same ctxId to be returned for the new init. - * In ASYNC case, we drop packets if they are returned from a - * different ctxId. */ - -#ifdef INTEL_QAT_DP - tmpUpCxt = ueCb->secInfo.upCiphSessCxtId; -#else - tmpUpCxt = ueCb->secInfo.upCxtId; -#endif - - pjUtlDlUpInit(gCb,ueCb); - pjUtlDlCipherClose(gCb,tmpUpCxt); - } - - RETVALUE(ROK); -} /* pjUtlDlUpdUpSecKeys */ - -/** - * - * @brief - * - * Handler to apply the new security algorithms and - * reset the compression unit. - * - * @b Description: - * - * This function - * 1. Creates new contexts for Control Plane Ciphering and Integrity. - * 2. Closes the old contexts for Control Plane Ciphering and Integrity. - * - * @param[in] ueCb UE Control Block - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 pjUtlDlUpdCpSecKeys -( -PjCb *gCb, -PjDlUeCb *ueCb /* UE Control Block */ -) -#else -PUBLIC S16 pjUtlDlUpdCpSecKeys(gCb,ueCb) -PjCb *gCb; -PjDlUeCb *ueCb; /* UE Control Block */ -#endif -{ - Void *tmpIntCxt; - Void *tmpCpCxt; - - TRC2(pjUtlDlUpdCpSecKeys); - - RLOG2(L_DEBUG, "pjUtlReEstReconfig(ueCb(%d,%d))", - ueCb->key.ueId, ueCb->key.cellId); - - if(ueCb->secInfo.secAct == TRUE) - { - /* Initialisation is done first followed by closure since we - * do not want the same ctxId to be returned for the new init. - * In ASYNC case, we drop packets if they are returned from a - * different ctxId. */ - -#ifdef INTEL_QAT_DP - tmpIntCxt = ueCb->secInfo.cpIntSessCxtId; - tmpCpCxt = ueCb->secInfo.cpCiphSessCxtId; -#else - tmpIntCxt = ueCb->secInfo.intCxtId; - tmpCpCxt = ueCb->secInfo.cpCxtId; -#endif - - pjUtlDlCpInit(gCb,ueCb); - pjUtlDlIntInit(gCb,ueCb); - - pjUtlDlIntClose(gCb,tmpIntCxt); - pjUtlDlCipherClose(gCb,tmpCpCxt); - - } - - RETVALUE(ROK); - -} /* pjUtlDlUpdCpSecKeys */ - -/******************************************************************** - * Utility Handler for Sending to Offboarding unit * - *******************************************************************/ - -/** - * - * @brief - * - * Handler for opening the context with the compression unit (either - * synchronous or asynchronous) for RB within an UE. - * - * @b Description: - * - * This function opens the context with the compression unit per RB per - * UE, by sending ROHC configuration elements using synchronous / asynchronous - * function calls with relevant input parameters. - * - * - * @param[in] pjRbCb PDCP RbCb - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 pjUtlDlCmpInit -( -PjCb *gCb, -PjDlRbCb *pjRbCb /* PDCP RbCb */ -) -#else -PUBLIC S16 pjUtlDlCmpInit(pjRbCb) -PjCb *gCb; -PjDlRbCb *pjRbCb; /* PDCP RbCb */ -#endif -{ - TRC3(pjUtlDlCmpInit) - - RLOG2(L_DEBUG, "pjUtlDlCmpInit(pjRbCb(%d,%d))",pjRbCb->rbId, pjRbCb->rbType); -#ifdef PJ_CMP_ASYNC - - pjRbCb->ueCb->libInfo.tCmpInitBitMask |= (1 << (pjRbCb->rbId - 1)); - pjRbCb->ueCb->libInfo.tLibInitBitMask |= PJ_LIB_COMP_BIT_MASK; - pjRbCb->cmpCxt.cfgTxId = pjRbCb->ueCb->libInfo.nxtAvlbTxId; - - PjLibObdCmpInitReq(&gCb->pjGenCfg.obdPst.cmpPst, - pjRbCb->cmpCxt, pjRbCb->rohc); -#else - pjLibCmpInitReq(pjRbCb->cmpCxt, pjRbCb->rohc, &(pjRbCb->cmpCxtId)); -#endif /* PJ_CMP_ASYNC */ - - RETVALUE(ROK); - -} /* end of pjUtlCmpInit */ - - - -/** - * - * @brief - * - * Handler for opening the context with the Integration unit (either - * synchronous or asynchronous) for all SRBs of an UE. - * - * @b Description: - * - * This function opens the context with the security algo unit per UE - * for Integration protection/verification by sending the configured - * Integrity Info using synchronous / asynchronous function calls with - * relevant input parameters. - * - * @param[in] pjRbCb Pointer to RB control Block - * - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 pjUtlDlIntInit -( -PjCb *gCb, -PjDlUeCb *ueCb /* UE CB Ptr */ -) -#else -PUBLIC S16 pjUtlDlIntInit(*gCb, *ueCb) -PjCb *gCb; -PjDlUeCb *ueCb; /* UE CB Ptr */ -#endif -{ - - S16 ret=ROK; - Void *ctxId = NULLP; -#ifdef PJ_SEC_ASYNC - U8 txIdx; - U32 *libInitBitMask = NULLP; -#endif - - TRC3(pjUtlDlIntInit) - - RLOG2(L_DEBUG, "pjUtlDlIntInit(ueCb(%d,%d))",ueCb->key.ueId, ueCb->key.cellId); - -#ifdef PJ_SEC_ASYNC - - if(ueCb->libInfo.state == PJ_STATE_REEST) - { - for(txIdx = 0; txIdx < PJ_MAX_ASYNC_CFM; txIdx++) - { - if((ueCb->libInfo.asyncCfm[txIdx] != NULLP) && - (ueCb->libInfo.asyncCfm[txIdx]->cfmType == PJ_REEST_ASYNC_CFM)) - { - libInitBitMask = &ueCb->libInfo.asyncCfm[txIdx]->libInitBitMask; - break; - } - } - } - else if(ueCb->libInfo.state == PJ_STATE_NORMAL) - { - libInitBitMask = &ueCb->libInfo.tLibInitBitMask; - } - - if(libInitBitMask) - { - (*libInitBitMask) = (*libInitBitMask) | PJ_LIB_INT_BIT_MASK; - } - - ret = PjLibObdIntInitReq(&gCb->pjGenCfg.obdPst.secPst, - ueCb->secInfo.secCxt, ueCb->secInfo.intInfo); -#else -#ifdef INTEL_QAT_DP -#ifdef QAT_TWO_INSTANCE - pjLibIntInitReq(gCb->u.dlCb->instHndl, ueCb->secInfo.intInfo,&ctxId); -#else - pjLibIntInitReq(gCb, ueCb->secInfo.intInfo,&ctxId); -#endif - ueCb->secInfo.cpIntSessCxtId = ctxId; -#else - pjLibIntInitReq(ueCb->secInfo.secCxt, ueCb->secInfo.intInfo,&(ctxId)); - ueCb->secInfo.intCxtId = ctxId; -#endif /* INTEL_QAT_DP */ -#endif /* PJ_SEC_ASYNC */ - - RETVALUE(ret); - -} /* end of pjUtlIntInit */ - -/** - * - * @brief - * - * Handler for opening the context with the Ciphering unit (either - * synchronous or asynchronous) for SRBs of an UE. - * - * @b Description: - * - * This function opens the context with the security algo unit per UE - * for ciphering / deciphering by key by sending the configured - * Ciphering Info with control plane key using synchronous / asynchronous - * function calls with relevant input parameters. - * - * @param[in] pjRbCb Pointer to RB control Block - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 pjUtlDlCpInit -( -PjCb *gCb, -PjDlUeCb *ueCb /* UE CB Ptr */ -) -#else -PUBLIC S16 pjUtlDlCpInit(*gCb, *ueCb) -PjCb *gCb; -PjDlUeCb *ueCb; /* UE CB Ptr */ -#endif -{ - Void *ctxId = NULLP; -#ifdef PJ_SEC_ASYNC - U8 txIdx; - U32 *libInitBitMask = NULLP; -#endif - S16 ret = ROK; - - TRC3(pjUtlDlCpInit) - - RLOG2(L_DEBUG, "pjUtlCpInit(ueCb(%d,%d))",ueCb->key.ueId, ueCb->key.cellId); - -#ifdef PJ_SEC_ASYNC - - if(ueCb->libInfo.state == PJ_STATE_REEST) - { - for(txIdx = 0; txIdx < PJ_MAX_ASYNC_CFM; txIdx++) - { - if((ueCb->libInfo.asyncCfm[txIdx] != NULLP) && - (ueCb->libInfo.asyncCfm[txIdx]->cfmType == PJ_REEST_ASYNC_CFM)) - { - libInitBitMask = &ueCb->libInfo.asyncCfm[txIdx]->libInitBitMask; - break; - } - } - } - else if(ueCb->libInfo.state == PJ_STATE_NORMAL) - { - libInitBitMask = &ueCb->libInfo.tLibInitBitMask; - } - - if(libInitBitMask) - { - (*libInitBitMask) = (*libInitBitMask) | PJ_LIB_CP_CIP_BIT_MASK; - } - ret = PjLibObdCpInitReq(&gCb->pjGenCfg.obdPst.secPst, ueCb->secInfo.secCxt, - ueCb->secInfo.cipherInfo.algoType, ueCb->secInfo.cipherInfo.cpKey); -#else -#ifdef INTEL_QAT_DP -#ifdef QAT_TWO_INSTANCE - ret = pjLibCpInitReq(gCb->u.dlCb->instHndl, ueCb->secInfo.secCxt, ueCb->secInfo.cipherInfo.algoType, - ueCb->secInfo.cipherInfo.cpKey, &ctxId); -#else - ret = pjLibCpInitReq(gCb, ueCb->secInfo.secCxt, ueCb->secInfo.cipherInfo.algoType, - ueCb->secInfo.cipherInfo.cpKey, &ctxId); -#endif - ueCb->secInfo.cpCiphSessCxtId= ctxId; -#else - ret = pjLibCpInitReq(ueCb->secInfo.secCxt, (U8)ueCb->secInfo.cipherInfo.algoType, - ueCb->secInfo.cipherInfo.cpKey, &ctxId); /*KW_FIX*/ - ueCb->secInfo.cpCxtId = ctxId; -#endif /* INTEL_QAT_DP */ -#endif /* PJ_SEC_ASYNC */ - - RETVALUE(ret); - -} /* end of pjUtlCpInit */ - -/** - * - * @brief - * - * Handler for opening the context with the Ciphering unit (either - * synchronous or asynchronous) for DRBs of an UE. - * - * @b Description: - * - * This function opens the context with the security algo unit per UE - * for ciphering / deciphering by sending the configured - * Ciphering Info with user plane key using synchronous / asynchronous - * function calls with relevant input parameters. - * - * @param[in] pjRbCb Pointer to RB control Block - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 pjUtlDlUpInit -( -PjCb *gCb, -PjDlUeCb *ueCb /* UE CB Ptr */ -) -#else -PUBLIC S16 pjUtlDlUpInit(*gCb,*ueCb) -PjCb *gCb; -PjDlUeCb *ueCb; /* UE CB Ptr */ -#endif -{ - - Void *ctxId = NULLP; -#ifdef PJ_SEC_ASYNC - U8 txIdx; - U32 *libInitBitMask = NULLP; -#endif - S16 ret = ROK; - - TRC3(pjUtlDlUpInit) - - RLOG2(L_DEBUG, "pjUtlUpInit(ueCb(%d,%d))",ueCb->key.ueId, ueCb->key.cellId); - -#ifdef PJ_SEC_ASYNC - - if(ueCb->libInfo.state == PJ_STATE_REEST) - { - for(txIdx = 0; txIdx < PJ_MAX_ASYNC_CFM; txIdx++) - { - if((ueCb->libInfo.asyncCfm[txIdx] != NULLP) && - (ueCb->libInfo.asyncCfm[txIdx]->cfmType == PJ_REEST_ASYNC_CFM)) - { - libInitBitMask = &ueCb->libInfo.asyncCfm[txIdx]->libInitBitMask; - break; - } - } - } - else if(ueCb->libInfo.state == PJ_STATE_NORMAL) - { - libInitBitMask = &ueCb->libInfo.tLibInitBitMask; - } - - if(libInitBitMask) - (*libInitBitMask) = (*libInitBitMask) | PJ_LIB_UP_CIP_BIT_MASK; - - ret = PjLibObdUpInitReq(&gCb->pjGenCfg.obdPst.secPst, ueCb->secInfo.secCxt, - ueCb->secInfo.cipherInfo.algoType, ueCb->secInfo.cipherInfo.upKey); -#else -#ifdef INTEL_QAT_DP -#ifdef QAT_TWO_INSTANCE - pjLibUpInitReq(gCb->u.dlCb->instHndl, ueCb->secInfo.secCxt, ueCb->secInfo.cipherInfo.algoType, - ueCb->secInfo.cipherInfo.upKey, &ctxId); -#else - pjLibUpInitReq(gCb, ueCb->secInfo.secCxt, ueCb->secInfo.cipherInfo.algoType, - ueCb->secInfo.cipherInfo.upKey, &ctxId); -#endif - ueCb->secInfo.upCiphSessCxtId= ctxId; -#else - pjLibUpInitReq(ueCb->secInfo.secCxt, (U8)ueCb->secInfo.cipherInfo.algoType, - ueCb->secInfo.cipherInfo.upKey, &ctxId); /*KW_FIX*/ - ueCb->secInfo.upCxtId = ctxId; -#endif /* INTEL_QAT_DP */ -#endif /* PJ_SEC_ASYNC */ - RETVALUE(ret); -} /* end of pjUtlUpInit */ - - - -/** - * - * @brief - * - * Handler for redirecing ciphering request to either synchronous - * or asynchronous module. - * - * @b Description: - * - * This function sends ciphering protection request as either synchronous or - * asynchronous function calls with relevant input parameters. - * - * @param[in] pjRbCb PDCP RbCb - * @param[in] secInp Input parameters for deciphering - * @param[in] mBuf Data to be deciphered - * @param[in] opSdu Deciphered SDU - * - * @return S16 - * -# ROK - * - */ -//#ifdef TENB_AS_SECURITY -#ifdef ANSI -PUBLIC S16 pjUtlCipherReq -( -PjCb *gCb, -PjDlRbCb *pjRbCb, /* PDCP RbCb */ -U32 count, /* Input parameters for deciphering */ -Buffer *mBuf, /* Data to be deciphered */ -Buffer **opSdu /* Deciphered SDU */ -) -#else -PUBLIC S16 pjUtlCipherReq(gCb, pjRbCb, count, mBuf, opSdu) -PjCb *gCb, -PjDlRbCb *pjRbCb; /* PDCP RbCb */ -U32 count; /* Input parameters for deciphering */ -Buffer *mBuf; /* Data to be deciphered */ -Buffer **opSdu; /* Deciphered SDU */ -#endif -{ - S16 ret = ROK; - PjDlUeCb *dlUeCb; - PjLibTrans libTrans; /* Transaction Id for deciphering */ - -#if PJ_SEC_ASYNC - Void *cxtId; /* Context Identifier */ -#endif - - TRC3(pjUtlCipherReq) - - dlUeCb = pjRbCb->ueCb; - libTrans.pdcpInstance = gCb->init.inst; - libTrans.count = count; - - libTrans.rbId = pjRbCb->rbId - 1; - libTrans.dir = PJ_SEC_DIR_DL; - libTrans.rbType = pjRbCb->rbType; - libTrans.snLen = pjRbCb->snLen; - libTrans.ciphAlgoType = dlUeCb->secInfo.cipherInfo.algoType; - libTrans.ueCb = (PTR)dlUeCb; - libTrans.ueId = dlUeCb->key.ueId; - libTrans.cellId = dlUeCb->key.cellId; - if(PJ_SRB == pjRbCb->rbType) - { - libTrans.key = dlUeCb->secInfo.cipherInfo.cpKey; -#ifdef INTEL_QAT_DP - libTrans.sessCxtId = dlUeCb->secInfo.cpCiphSessCxtId; -#ifdef QAT_TWO_INSTANCE - libTrans.instHndl = gCb->u.dlCb->instHndl; -#else - libTrans.instHndl = gCb->instHndl; -#endif -#endif - } - else - { - libTrans.key = dlUeCb->secInfo.cipherInfo.upKey; -#ifdef INTEL_QAT_DP - libTrans.sessCxtId = dlUeCb->secInfo.upCiphSessCxtId; -#ifdef QAT_TWO_INSTANCE - libTrans.instHndl = gCb->u.dlCb->instHndl; -#else - libTrans.instHndl = gCb->instHndl; -#endif -#endif - } - -#ifdef PJ_SEC_ASYNC - /* Start the timer if it is not started already */ - if((pjChkTmr(gCb, (PTR)pjRbCb, PJ_EVT_DL_OBD_TMR)) == FALSE) - { - pjStartTmr(gCb, (PTR)pjRbCb, PJ_EVT_DL_OBD_TMR); - } - - if (pjRbCb->rbType == PJ_SRB) - { - cxtId = pjRbCb->ueCb->secInfo.cpCxtId; - } - else - { - cxtId = pjRbCb->ueCb->secInfo.upCxtId; - } - - ret = PjLibObdCipherReq(&(gCb->pjGenCfg.obdPst.secPst), cxtId, - secInp, libTrans, mBuf); - -#else -#ifdef INTEL_SW_SEC - ret = PjLibObdSwCipherReq(&libTrans, mBuf, gCb,opSdu); -#else - ret = PjLibObdCipherReq(&libTrans, mBuf, opSdu); -#endif /* INTEL_SW_SEC */ -#endif - - RETVALUE(ret); - -} - - -#ifdef FLAT_BUFFER_OPT -/** - * - * @brief - * - * Handler for redirecing ciphering request to either synchronous - * or asynchronous module. - * - * @b Description: - * - * This function sends ciphering protection request as either synchronous or - * asynchronous function calls with relevant input parameters. - * - * @param[in] pjRbCb PDCP RbCb - * @param[in] secInp Input parameters for deciphering - * @param[in] mBuf Flat Buffer to be deciphered - * @param[in] opSdu Deciphered SDU - * - * @return S16 - * -# ROK - * - */ - -#ifdef ANSI -PUBLIC S16 pjUtlCipherReqFB -( -PjCb *gCb, -PjDlRbCb *pjRbCb, /* PDCP RbCb */ -U32 count, /* Input parameters for deciphering */ -FlatBuffer *mBuf, /* Data to be deciphered */ -Buffer **opSdu /* Deciphered SDU */ -) -#else -PUBLIC S16 pjUtlCipherReqFB(gCb, pjRbCb, count, mBuf, opSdu) -PjCb *gCb, -PjDlRbCb *pjRbCb; /* PDCP RbCb */ -U32 count; /* Input parameters for deciphering */ -FlatBuffer *mBuf; /* Data to be deciphered */ -Buffer **opSdu; /* Deciphered SDU */ -#endif -{ - S16 ret = ROK; -#ifdef PJ_SEC_ASYNC - Void *cxtId; /* Context Identifier */ -#endif - PjDlUeCb *dlUeCb; - PjLibTrans libTrans; - - TRC3(pjUtlCipherReqFB) - -#ifdef PJ_SEC_ASYNC - cxtId = pjRbCb->ueCb->secInfo.upCxtId; -#endif - - dlUeCb = pjRbCb->ueCb; - libTrans.pdcpInstance = gCb->init.inst; - libTrans.count = count; - - libTrans.rbId = pjRbCb->rbId - 1; - libTrans.dir = PJ_SEC_DIR_DL; - libTrans.rbType = pjRbCb->rbType; - libTrans.snLen = pjRbCb->snLen; - libTrans.ciphAlgoType = dlUeCb->secInfo.cipherInfo.algoType; - libTrans.ueCb = (PTR)dlUeCb; - libTrans.ueId = dlUeCb->key.ueId; - libTrans.cellId = dlUeCb->key.cellId; - if(PJ_SRB == pjRbCb->rbType) - { - libTrans.key = dlUeCb->secInfo.cipherInfo.cpKey; -#ifdef INTEL_QAT_DP - libTrans.sessCxtId = dlUeCb->secInfo.cpCiphSessCxtId; -#ifdef QAT_TWO_INSTANCE - libTrans.instHndl = gCb->u.dlCb->instHndl; -#else - libTrans.instHndl = gCb->instHndl; -#endif -#endif - } - else - { - libTrans.key = dlUeCb->secInfo.cipherInfo.upKey; -#ifdef INTEL_QAT_DP - libTrans.sessCxtId = dlUeCb->secInfo.upCiphSessCxtId; -#ifdef QAT_TWO_INSTANCE - libTrans.instHndl = gCb->u.dlCb->instHndl; -#else - libTrans.instHndl = gCb->instHndl; -#endif -#endif - } - -#ifdef PJ_SEC_ASYNC - /* Start the timer if it is not started already */ - if((pjChkTmr(gCb, (PTR)pjRbCb, PJ_EVT_DL_OBD_TMR)) == FALSE) - { - pjStartTmr(gCb, (PTR)pjRbCb, PJ_EVT_DL_OBD_TMR); - } - - ret = PjLibObdCipherReq(&(gCb->pjGenCfg.obdPst.secPst), cxtId, - secInp, libTrans, mBuf); - -#else -#ifndef INTEL_SW_SEC - ret = PjLibObdCipherReqFB(&libTrans, mBuf, opSdu); -#else - ret = pjSendToSwCipherFB(&libTrans, mBuf,gCb,opSdu); -#endif -#endif - - RETVALUE(ret); - -} -#endif - - -/** - * - * @brief - * - * Handler for redirecing Integration request to either synchronous - * or asynchronous module. - * - * @b Description: - * - * This function sends Intergrity protection request as either synchronous or - * asynchronous function calls with relevant input parameters. - * - * @param[in] pjRbCb PDCP RbCb - * @param[in] secInp Input parameters for integrity - * @param[in] mBuf SDU to be compressed - * @param[out] macI Message authentication code for the SDU - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 pjUtlIntProtReq -( -PjCb *gCb, -PjDlRbCb *pjRbCb, /* PDCP RbCb */ -PjSecInp secInp, /* Input parameters for integrity */ -Buffer **mBuf /* SDU to be compressed */ -) -#else -PUBLIC S16 pjUtlIntProtReq(gCb, pjRbCb, secInp, mBuf) -PjCb *gCb; -PjDlRbCb *pjRbCb; /* PDCP RbCb */ -PjSecInp secInp; /* Input parameters for integrity */ -Buffer **mBuf; /* SDU to be compressed */ -#endif -{ - S16 ret = ROK; - PjDlUeCb *dlUeCb; - PjLibTrans libTrans; -#if PJ_SEC_ASYNC - Void *cxtId; /* Context Identifier */ -#endif - - TRC3(pjUtlIntProtReq) - -#if PJ_SEC_ASYNC - cxtId = pjRbCb->ueCb->secInfo.intCxtId; -#endif - - dlUeCb = pjRbCb->ueCb; - libTrans.pdcpInstance = gCb->init.inst; - libTrans.count = secInp.count; - libTrans.rbId = pjRbCb->rbId - 1; - libTrans.dir = secInp.dir; - libTrans.rbType = pjRbCb->rbType; - /*pSecInfo.snLen = pjRbCb->snLen;*/ - libTrans.intAlgoType = dlUeCb->secInfo.intInfo.algoType; - libTrans.ueCb = (PTR)dlUeCb; - libTrans.ueId = dlUeCb->key.ueId; - libTrans.cellId = dlUeCb->key.cellId; - libTrans.key = &(dlUeCb->secInfo.intInfo.intKey[0]); - PJ_SEC_FILL_FRESH(libTrans.fresh, libTrans.rbId); - -#ifdef INTEL_QAT_DP - libTrans.sessCxtId = dlUeCb->secInfo.cpIntSessCxtId; -#ifdef QAT_TWO_INSTNACES - libTrans.instHndl = gCb->u.dlCb->instHndl; -#else - libTrans.instHndl = gCb->instHndl; -#endif -#endif - -#ifdef PJ_SEC_ASYNC - /* Start the timer if it is not started already */ - if((pjChkTmr(gCb, (PTR)pjRbCb, PJ_EVT_DL_OBD_TMR)) == FALSE) - { - pjStartTmr(gCb, (PTR)pjRbCb, PJ_EVT_DL_OBD_TMR); - } - - ret = PjLibObdIntProtReq(&(gCb->pjGenCfg.obdPst.secPst), cxtId, - secInp, libTrans, mBuf); - -#else -#ifdef INTEL_SW_INTEG - ret = PjLibObdIntProtReq(gCb, &libTrans, mBuf); -#else - ret = PjLibObdIntProtReq(&libTrans, mBuf); -#endif /* INTEL_SW_INTEG */ -#endif - - RETVALUE(ret); - -} /* end of pjUtlIntProtReq */ - -//#endif - - -/** - * - * @brief - * - * Handler for closing the DL context with the Ciphering unit (either - * synchronous or asynchronous) for SRBs of an UE. - * - * @b Description: - * - * This function closes an existing DL context with the security algo unit per UE - * for ciphering / deciphering with control plane key using synchronous / asynchronous - * function calls with relevant input parameters. - * - * - * @param[in] cpCxtId Context Id for Ciphering to be closed - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 pjUtlDlCipherClose -( -PjCb *gCb, -Void *cpCxtId /* Context Id for Ciphering to be closed */ -) -#else -PUBLIC S16 pjUtlDlCipherClose(gCb, cpCxtId) -PjCb *gCb; -Void *cpCxtId; /* Context Id for Ciphering to be closed */ -#endif -{ -#ifdef INTEL_QAT_DP - S16 ret; -#endif - TRC3(pjUtlDlCipherClose) - - RLOG0(L_DEBUG, "pjUtlDlCipherClose"); - -#ifndef PJ_SEC_ASYNC -#ifdef INTEL_QAT_DP -#ifdef QAT_TWO_INSTANCE - ret = PjLibObdCipherCloseReq(gCb->u.dlCb->instHndl, cpCxtId); -#else - ret = PjLibObdCipherCloseReq(gCb->instHndl, cpCxtId); -#endif -#else - PjLibObdCipherCloseReq(cpCxtId); -#endif -#else -#ifdef INTEL_QAT_DP -#ifdef QAT_TWO_INSTANCE - ret = PjLibObdCipherCloseReq(gCb->u.dlCb->instHndl, cpCxtId); -#else - ret = PjLibObdCipherCloseReq(gCb->instHndl, cpCxtId); -#endif -#else - PjLibObdCipherCloseReq(&gCb->pjGenCfg.obdPst.secPst, cpCxtId); -#endif -#endif - -#ifdef INTEL_QAT_DP - RETVALUE(ret); -#else - RETVALUE(ROK); -#endif - -} /* end of pjUtlCipherClose */ - - -/** - * - * @brief - * - * Handler for closing the DL context with the Integration unit (either - * synchronous or asynchronous) for all RBs of an UE. - * - * @b Description: - * - * This function closes an existing DL context with the security algo unit per UE - * for Integration protection/verification using synchronous / asynchronous function - * calls with relevant input parameters. - * - * - * @param[in] intCxtId Integration CxtId to be closed - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 pjUtlDlIntClose -( -PjCb *gCb, -Void *intCxtId /* Integration CxtId to be closed */ -) -#else -PUBLIC S16 pjUtlDlIntClose(gCb, intCxtId) -PjCb *gCb; -Void *intCxtId; /* Integration CxtId to be closed */ -#endif -{ -#ifdef INTEL_QAT_DP - S16 ret = ROK; -#endif - TRC3(pjUtlDlIntClose) - - RLOG0(L_DEBUG, "pjUtlDlIntClose"); - -#ifdef PJ_SEC_ASYNC - PjLibObdIntCloseReq(&gCb->pjGenCfg.obdPst.secPst,intCxtId); -#else -#ifdef INTEL_QAT_DP -#ifdef QAT_TWO_INSTANCE - ret = PjLibObdIntCloseReq(gCb->u.dlCb->instHndl,intCxtId); -#else - ret = PjLibObdIntCloseReq(gCb->instHndl,intCxtId); -#endif -#else - PjLibObdIntCloseReq(intCxtId); -#endif /* INTEL_QAT_DP */ -#endif /* PJ_SEC_ASYNC */ - -#ifdef INTEL_QAT_DP - RETVALUE(ret); -#else - RETVALUE(ROK); -#endif - -} /* end of pjUtlIntClose */ - - -/** - * - * @brief - * - * Handler for resetting the context with the compression unit (either - * synchronous or asynchronous) for RB within an UE. - * - * @b Description: - * - * This function resets the context with the compression unit per RB per - * UE by using synchronous / asynchronous function calls. - * - * - * @param[in] cmpCxtId Context to be reset for compression - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 pjUtlDlCmpReset -( -PjCb *gCb, -PjDlRbCb *pjRbCb /* Context to be reset for compression */ -) -#else -PUBLIC S16 pjUtlDlCmpReset(pjRbCb) -PjCb *gCb; -PjDlRbCb *pjRbCb; /* Context to be reset for compression */ -#endif -{ - TRC3(pjUtlDlCmpReset) - - RLOG2(L_DEBUG, "pjUtlCmpReset(pjRbCb(%d,%d))",pjRbCb->rbId, pjRbCb->rbType); - -#ifdef PJ_CMP_ASYNC - PjLibObdCmpResetReq(&gCb->pjGenCfg.obdPst.cmpPst, pjRbCb->cmpCxtId); -#else - pjLibCmpResetReq(pjRbCb->cmpCxtId); -#endif - - RETVALUE(ROK); - -} /* end of pjUtlCmpReset */ - - -/** - * - * @brief - * Handle re-establishment on SRB1. - * - * @b Description: - * This function - * 1. Marks the state of the RBs as PJ_STATE_REEST. - * 2. Calculates the number of RBs undergoing reestablishment. - * - * @param[in] gCb PDCP Instance control block - * @param[in] pjRbCb Downlink Rb control block - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 pjUtlDlReEstSrb1 -( -PjCb *gCb, -PjDlRbCb *pjRbCb /* PDCP Control Block Pointer */ -) -#else -PUBLIC S16 pjUtlDlReEstSrb1(gCb, pjRbCb) -PjCb *gCb; -PjDlRbCb *pjRbCb; /* PDCP Control Block Pointer */ -#endif -{ - PjDlUeCb *ueCb; - - TRC2(pjUtlDlReEstSrb1) - - RLOG2(L_DEBUG, "pjUtlReEstSrb1(pjRbCb(%d,%d))",pjRbCb->rbId, pjRbCb->rbType); - - ueCb = pjRbCb->ueCb; - - ueCb->libInfo.state = PJ_STATE_REEST; - - /* SRB Reconfiguration we can update the control Plane keys and - the Integrity Keys in the OBD module */ - - pjUtlDlUpdCpSecKeys(gCb,ueCb); - - /* Perform downlink reestablishment of SRB1 */ - pjDlmReEstSrb(gCb,pjRbCb); - - /* If Only SRB1 configured then we can update userplane - keys also */ - if ((ueCb->numSrbs == 1) && (ueCb->numDrbs == 0)) - { - pjUtlDlUpdUpSecKeys(gCb,ueCb); - } - - RETVALUE(ROK); -} /* pjUtlReEstSrb1 */ - - -/** - * - * @brief - * - * Handler to start reestablishment processing - * - * @b Description: - * - * This function - * 1. Marks the state of the RBs as PJ_STATE_REEST_HO. - * 2. Calculates the number of RBs undergoing reestablishment. - * - * @param[in] ueCb Number of RBs undergoing reestablishment - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 pjUtlDlReEstHO -( -PjCb *gCb, -PjDlUeCb *ueCb /* Number of RBs undergoing reestablishment*/ -) -#else -PUBLIC S16 pjUtlDlReEstHO(gCb,ueCb) -PjCb *gCb; -PjDlUeCb *ueCb; /* Number of RBs undergoing reestablishment*/ -#endif -{ - U8 rbCnt; - PjDlRbCb **rbCbLst; - PjDlRbCb * pjRbCb; - - TRC2 (pjUtlDlReEstHO); - -#ifdef ALIGN_64BIT - RLOG2(L_DEBUG, "pjUtlReEstHO(ueCb(%d,%d))",ueCb->key.ueId, ueCb->key.cellId); -#else - RLOG2(L_DEBUG, "pjUtlReEstHO(ueCb(%d,%d))",ueCb->key.ueId, ueCb->key.cellId); -#endif - - /* Initialisations */ - ueCb->libInfo.numReEstDrb = 0; - ueCb->libInfo.state = PJ_STATE_REEST_HO; - - /* Perform initialisations on the HO Info structure */ - PJ_ALLOC(gCb,ueCb->hoInfo, sizeof(PjDlHoInfo)); -#if (ERRCLASS & ERRCLS_ADD_RES) - if (ueCb->hoInfo == NULLP) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - - PJ_ALLOC(gCb,ueCb->hoInfo->hoCfmInfo, sizeof(PjDlHoCfmInfo) * PJ_MAX_DRB_PER_UE ); -#if (ERRCLASS & ERRCLS_ADD_RES) - if (ueCb->hoInfo->hoCfmInfo == NULLP ) - { - /*ccpu00136858 */ - PJ_PST_FREE(gCb->u.dlCb->udxDlSap[0].pst.region, - gCb->u.dlCb->udxDlSap[0].pst.pool, - ueCb->hoInfo, sizeof(PjDlHoInfo)); - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - - /* Initialise the reestablishment states for the RBs */ - rbCbLst = ueCb->drbCb; - for(rbCnt = 0; rbCnt < PJ_MAX_DRB_PER_UE; rbCnt ++) - { - /* Check of rbCb available */ - if( (pjRbCb = rbCbLst[rbCnt]) == NULLP) - { - continue; - } - - /* Fetch the rbCb and intialise the states */ - pjRbCb->state = PJ_STATE_REEST_HO; - - if(pjRbCb->mode == PJ_DRB_AM) - { - pjDlmReEstHoDrbAm(gCb, pjRbCb); - } - - }/* for(rbCnt .. */ - - RETVALUE(ROK); -} /* pjUtlReEstHO */ - - -/** - * - * @brief - * - * Called after the new security algorithms have been applied - * and header compression/decompression reset. It starts - * reestablishment procedures for downlink DRBs. - * - * @b Description: - * - * This function - * 1. Creates new contexts for Ciphering and Integrity. - * 2. Closes the old contexts for Ciphering and Integrity. - * 3. Resets the ROHC unit. - * - * @param[in] ueCb UE Control Block - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 pjUtlReEstDl -( -PjCb *gCb, -PjDlUeCb *ueCb /* UE Control Block */ -) -#else -PUBLIC S16 pjUtlReEstDl(gCb, ueCb) -PjCb *gCb; -PjDlUeCb *ueCb; /* UE Control Block */ -#endif -{ - TRC2(pjUtlReEstDl); - - RLOG2(L_DEBUG, "pjUtlReEstDl(ueCb(%d,%d))",ueCb->key.ueId, ueCb->key.cellId); - - - /* Send Cfms and update the state only - when there is some cfgreq cfm is present for other RBs*/ - if(ueCb->libInfo.state == PJ_STATE_REEST) - { - pjUtlDlSndReEstCfgCfm(gCb, ueCb); - } - else if(ueCb->libInfo.state == PJ_STATE_REEST_HO) - { - pjUtlDlSndSduStaCfm(gCb, ueCb); - } - ueCb->libInfo.state = PJ_STATE_NORMAL; - - RETVALUE(ROK); - -} /* pjUtlReEstDl */ - - - - -/** - * - * @brief - * - * Function to sent the REESTABLISHMENT COMPPLETE - * to the RRC. - * - * @b Description: - * - * This function - * 1. Sends a ReEstablishment Confirm for normal reestablishment. - * 2. Sends a SDU status confirm for handover reestablishment. - * - * @param[in] ueCb UE Control Block - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 pjUtlDlSndReEstCfgCfm -( -PjCb *gCb, -PjDlUeCb *ueCb /* UE Control Block */ -) -#else -PUBLIC S16 pjUtlDlSndReEstCfgCfm(ueCb) -PjCb *gCb; -PjDlUeCb *ueCb; /* UE Control Block */ -#endif -{ - U8 rbCnt; - PjDlRbCb *tRbCb; - CpjCfgCfmInfo *cfgCfmInfo; - U8 txIdx; - PjAsyncCfm *asyncCfm = NULLP; - PjUdxDlSapCb *udxSap; - S16 ret = ROK; - - TRC2(pjUtlDlSndReEstCfgCfm); - - RLOG2(L_DEBUG, "pjUtlSndReEstCfgCfm(ueCb(%d,%d))",ueCb->key.ueId, ueCb->key.cellId); - - ueCb->libInfo.state = PJ_STATE_NORMAL; - - /* Pick up the confirm info */ - for(txIdx = 0; txIdx < PJ_MAX_ASYNC_CFM; txIdx++) - { - if((ueCb->libInfo.asyncCfm[txIdx] != NULLP) && - (ueCb->libInfo.asyncCfm[txIdx]->cfmType & PJ_CFG_REEST_ASYNC_CFM)) - { - asyncCfm = ueCb->libInfo.asyncCfm[txIdx]; - break; - } - } - - /* its a reestablishment with only srb1 configured */ - if(asyncCfm == NULLP) - { - RETVALUE(ROK); - } - - for(rbCnt = 0; rbCnt < PJ_MAX_SRB_PER_UE; rbCnt ++) - { - if( ((tRbCb = ueCb->srbCb[rbCnt]) == NULLP) || - (tRbCb->state == PJ_STATE_NORMAL)) - { - continue; - } - - /* Fetch the rbCb and intialise the states */ - tRbCb->state = PJ_STATE_NORMAL; - } - - /* Memory leak fix ccpu00135359 */ - udxSap = &(gCb->u.dlCb->udxDlSap[0]); - PJ_ALLOC_BUF_SHRABL(udxSap->pst, cfgCfmInfo, - sizeof (CpjCfgCfmInfo), ret); - if(ret != ROK) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } - - PJ_FILL_REEST_CFG_CFM_INFO(cfgCfmInfo, asyncCfm); - PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx); - - PjDlUdxCfgCfm(&gCb->u.dlCb->udxDlSap[0].pst, - gCb->u.dlCb->udxDlSap[0].suId, - (UdxCfgCfmInfo *)cfgCfmInfo); - - RETVALUE(ROK); -} /* pjUtlSndReEstCfgCfm */ - - -/** - * - * @brief Handler to store the confirms while we wait for the init - * confirms from the off-board. - * - * - * @b Description - * This function is invoked during security config request, - * reestablishment request and config request if the libraries - * are off-boarded. This stores the entries in a confirm list - * while waiting for the confirm from the offboard. - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ - -#ifdef ANSI -PUBLIC S16 pjUtlDlSaveCfmInfo -( -PjCb *gCb, -PjDlUeCb *ueCb, /* Pointer to UeCb */ -U8 cfmType, /* Confirm type */ -Bool startTmr, /* Start Timer */ -U8 entity, /* Confirm type */ -PTR cfmPtr, /* Pointer to the structure for confirm */ -PTR cfgPtr /* Pointer to the structure for request */ -) -#else -PUBLIC S16 pjUtlDlSaveCfmInfo(ueCb, cfmType, startTmr, entity, cfmPtr, cfgPtr) -PjCb *gCb; -PjDlUeCb *ueCb; /* Pointer to UeCb */ -U8 cfmType; /* Confirm type */ -Bool startTmr; /* Start Timer */ -U8 entity; /* Confirm type */ -PTR cfmPtr; /* Pointer to the structure for confirm */ -PTR cfgPtr; /* Pointer to the structure for request */ -#endif -{ - S16 ret; /* Return value */ - CpjSecCfgCfmInfo *secCfm; /* Security confirm */ - CpjReEstCfmInfo *reEstCfm; /* Reestablishment confirm */ - CpjCfgCfmInfo *cfgCfm; /* Config confirm */ - U16 txId; /* Transaction Id */ - PjAsyncCfm *tAsyncCfm; /* Pointer to the async Cfm*/ - CpjCfgReqInfo *cfgReq; /* Pointer to the config request */ - U8 cfmIdx; /* index for loopoing */ - - - TRC3(pjUtlDlSaveCfmInfo) - - RLOG_ARG4(L_DEBUG,DBG_UEID,ueCb->key.ueId, - "pjUtlSaveCfmInfo cellId(%d),cfmType(%d),startTmr(%d),entity(%d))", - ueCb->key.cellId, cfmType, startTmr, entity); - - /* Initialisations */ - ret = ROK; - secCfm = NULLP; - reEstCfm = NULLP; - cfgCfm = NULLP; - cfgReq = NULLP; - txId = ueCb->libInfo.nxtAvlbTxId; - - if(txId == PJ_MAX_ASYNC_CFM) - { - /* The entire list is full, have to return negative confirms */ - RETVALUE(RFAILED); - } - - /* is entry already present */ - if(ueCb->libInfo.asyncCfm[txId] != NULLP) - { - RETVALUE(RFAILED); - } - - /* Allocate the structure */ - PJ_ALLOC(gCb,ueCb->libInfo.asyncCfm[txId], sizeof(PjAsyncCfm)); - if(ueCb->libInfo.asyncCfm[txId]== NULLP) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } - - /* Initialise the structure */ - tAsyncCfm = ueCb->libInfo.asyncCfm[txId]; - tAsyncCfm->libInitBitMask = ueCb->libInfo.tLibInitBitMask; - tAsyncCfm->cmpInitBitMask = ueCb->libInfo.tCmpInitBitMask; - tAsyncCfm->entity = entity; - tAsyncCfm->startTmr = startTmr; - - ueCb->libInfo.tLibInitBitMask = 0; - ueCb->libInfo.tCmpInitBitMask = 0; - - /* Assign the values */ - if(cfmType == PJ_SEC_ASYNC_CFM) - { - secCfm = (CpjSecCfgCfmInfo *)cfmPtr; - tAsyncCfm->cfmType = cfmType; - tAsyncCfm->ueId = secCfm->ueId; - tAsyncCfm->cellId = secCfm->cellId; - tAsyncCfm->transId = secCfm->transId; - } - else if(cfmType == PJ_REEST_ASYNC_CFM) - { - reEstCfm = (CpjReEstCfmInfo *)cfmPtr; - tAsyncCfm->cfmType = cfmType; - tAsyncCfm->ueId = reEstCfm->ueId; - tAsyncCfm->cellId = reEstCfm->cellId; - tAsyncCfm->transId = reEstCfm->transId; - } - else if((cfmType & PJ_CFG_ASYNC_CFM) || - (cfmType & PJ_CFG_REEST_ASYNC_CFM)|| - (cfmType & PJ_CFG_UEDEL_ASYNC_CFM)) - { - if(entity == ENTPJ) - { - cfgCfm = (CpjCfgCfmInfo *)cfmPtr; - cfgReq = (CpjCfgReqInfo *)cfgPtr; - - tAsyncCfm->cfmType = cfmType; - tAsyncCfm->ueId = cfgCfm->ueId; - tAsyncCfm->cellId = cfgCfm->cellId; - tAsyncCfm->transId = cfgCfm->transId; - tAsyncCfm->numEnt = cfgReq->numEnt; - - for ( cfmIdx = 0; cfmIdx < cfgReq->numEnt; cfmIdx++ ) - { - tAsyncCfm->cfmEnt[cfmIdx].status = cfgCfm->cfmEnt[cfmIdx].status; - tAsyncCfm->cfmEnt[cfmIdx].reason = cfgCfm->cfmEnt[cfmIdx].reason; - tAsyncCfm->cfmEnt[cfmIdx].rbId = cfgCfm->cfmEnt[cfmIdx].rbId; - tAsyncCfm->cfmEnt[cfmIdx].rbType = cfgCfm->cfmEnt[cfmIdx].rbType; - tAsyncCfm->cfmEnt[cfmIdx].cfgType = cfgReq->cfgEnt[cfmIdx].cfgType; - } - } - else if(entity == ENTPJ) - { - CpjCfgCfmInfo *pjCfgCfm; /* Configuraiton Confirm */ - - pjCfgCfm = (CpjCfgCfmInfo *)cfmPtr; - - tAsyncCfm->cfmType = cfmType; - tAsyncCfm->transId = pjCfgCfm->transId; - tAsyncCfm->ueId = pjCfgCfm->ueId; - tAsyncCfm->cellId = pjCfgCfm->cellId; - tAsyncCfm->numEnt = pjCfgCfm->numEnt; - - for ( cfmIdx = 0; cfmIdx < pjCfgCfm->numEnt; cfmIdx++ ) - { - tAsyncCfm->cfmEnt[cfmIdx].status = - pjCfgCfm->cfmEnt[cfmIdx].status; - tAsyncCfm->cfmEnt[cfmIdx].reason = - pjCfgCfm->cfmEnt[cfmIdx].reason; - tAsyncCfm->cfmEnt[cfmIdx].rbId = - pjCfgCfm->cfmEnt[cfmIdx].rbId; - tAsyncCfm->cfmEnt[cfmIdx].rbType = - pjCfgCfm->cfmEnt[cfmIdx].rbType; - } - } - } - - /* Start timer */ - /* Timer should not be started when SEC is SYNC for ReEst Req - * and for the subsequent config req for REEST. The config req - * after reest req can still start the timer in the case comp being - * async and sec being sync if it also adds a RB and a compInit has - * to be sent . - * */ - - if(tAsyncCfm->startTmr == TRUE) - { - if((pjChkTmr(gCb,(PTR)ueCb, PJ_EVT_OBD_WAIT_TMR)) == FALSE) - { - pjStartTmr(gCb,(PTR)ueCb, PJ_EVT_OBD_WAIT_TMR); - ueCb->libInfo.crntTmrTxId = ueCb->libInfo.nxtAvlbTxId; - } - } - - /* update nxtAvlbTxId to the next empty slot */ - for(cfmIdx = 0; cfmIdx < PJ_MAX_ASYNC_CFM; cfmIdx++) - { - ueCb->libInfo.nxtAvlbTxId = - (U16)((ueCb->libInfo.nxtAvlbTxId + 1) % PJ_MAX_ASYNC_CFM); /*KW_FIX*/ - - if(ueCb->libInfo.asyncCfm[ueCb->libInfo.nxtAvlbTxId] == NULLP) - { - break; - } - } - - /* Cant find an empty slot ? */ - if(cfmIdx == PJ_MAX_ASYNC_CFM) - { - ueCb->libInfo.nxtAvlbTxId = PJ_MAX_ASYNC_CFM; - } - - RETVALUE(ret); -}/* pjUtlSaveCfmInfo */ - -/** - * - * @brief Handler to store update the bitmaks and send confirms if necessary. - * - * - * @b Description - * This function is invoked when receiving a InitCfm from Offboard. - * It updates the bit masks and checks if it is necesary to send a - * confirm. - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ - -#ifdef ANSI -PUBLIC S16 pjUtlDlHdlObdInitCfm -( -PjCb *gCb, -PjDlUeCb *ueCb, /* Pointer to UeCb */ -U16 txIdx, /* Transaction Index for UeCb */ -U8 cfmType, /* Confirm type */ -U8 maskVal /* mask value */ -) -#else -PUBLIC S16 pjUtlDlHdlObdInitCfm(ueCb, txIdx, cfmType, maskVal) -PjCb *gCb; -PjDlUeCb *ueCb; /* Pointer to UeCb */ -U16 txIdx; /* Transaction Index for UeCb */ -U8 cfmType; /* Confirm type */ -U8 maskVal; /* mask value */ -#endif -{ - UdxSecCfgCfmInfo *secCfgCfm; /* Security config confirm */ - UdxReEstCfmInfo *reEstCfm; /* Reest config confirm */ - PjAsyncCfm *asyncCfm; - UdxCfgCfmInfo *cfgCfm; - U8 idx; - S16 ret; - - TRC3(pjUtlDlHdlObdInitCfm) - - RLOG_ARG4(L_DEBUG,DBG_UEID,ueCb->key.ueId, - "pjUtlHdlDlObdInitCfm cellId(%d), txIdx(%d), cfmType(%d), maskVal(%d))", - ueCb->key.cellId, txIdx, cfmType, maskVal); - - /* Initialisations */ - secCfgCfm = NULLP; - reEstCfm = NULLP; - cfgCfm = NULLP; - asyncCfm = NULLP; - ret = ROK; - - if((txIdx == PJ_MAX_ASYNC_CFM) || - (ueCb->libInfo.asyncCfm[txIdx] == NULLP)) - { - RETVALUE(RFAILED); - } - - asyncCfm = ueCb->libInfo.asyncCfm[txIdx]; - - if(cfmType & PJ_SEC_INIT_CFM) - { - /* Update bit mask and check if all confirms have been received */ - asyncCfm->libInitBitMask ^= (maskVal); - ret = pjUtlDlHdlSecInitCfm(gCb,ueCb,txIdx,asyncCfm,secCfgCfm,reEstCfm); - } - else if(cfmType & PJ_CMP_INIT_CFM) - { - /* Check if all confirms have been received */ - asyncCfm->cmpInitBitMask &= ~(1 << (maskVal - 1)); - - /* Update the status and reason for the received CmpInitCfm */ - for ( idx = 0; idx < asyncCfm->numEnt; idx++ ) - { - if ( asyncCfm->cfmEnt[idx].rbId == maskVal) - { - asyncCfm->cfmEnt[idx].status = CPJ_CFG_CFM_OK; - asyncCfm->cfmEnt[idx].reason = CPJ_CFG_REAS_NONE; - break; - } - } - - /* Check if we can send confirm */ - if(asyncCfm->cmpInitBitMask == 0) - { - ret = pjUtlDlHdlCmpInitCfm(gCb,ueCb,txIdx,asyncCfm,cfgCfm); - } - } - RETVALUE(ret); -}/* pjUtlHdlDlObdInitCfm */ - -/** - * - * @brief Handler for init off-board timer expiry. - * - * - * @b Description - * This function is called when the off-board timer expires for - * a Init Req of a channel (either for ciphering/integrity/compression). - * This function sends a confirm with failure for SecCfgReq if the - * state of the RB is normal. It sends a confirm with failure - * for config request(only for RBs with Re-establishment Req, a failure - * is stored in the confirm) if the state of the RB is re-establishment. - * - * @param[in] ueCb UE control block. - * - * - * @return S16 - * -# ROK - */ - -#ifdef ANSI -PUBLIC S16 pjUtlDlHdlInitObdTmrExp -( -PjCb *gCb, -PjDlUeCb *ueCb -) -#else -PUBLIC S16 pjUtlDlHdlInitObdTmrExp(ueCb) -PjCb *gCb; -PjDlUeCb *ueCb; -#endif -{ - S16 ret; /* Return Value */ - UdxSecCfgCfmInfo *secCfgCfm; /* Security Cfg Confirm Info */ - UdxCfgCfmInfo *cfgCfm; /* Config Confirm Info */ - UdxReEstCfmInfo *reEstCfm; /* Reest config confirm */ - UdxCfgCfmInfo *pjCfgCfm; - PjLibInfo *libInfo; /* Off-board Info */ - PjAsyncCfm *asyncCfm; /* Async Cfm Info */ - PjUdxDlSapCb *udxSap; - U16 txIdx; /* Tx Idx */ - U16 idx; /* Index for looping */ - U16 cfgIdx; - - TRC3(pjUtlDlHdlInitObdTmrExp) - - RLOG2(L_DEBUG, "pjUtlDlHdlInitObdTmrExp(ueCb(%d,%d))", - ueCb->key.ueId, ueCb->key.cellId); - - ret = ROK; - udxSap = &(gCb->u.dlCb->udxDlSap[0]); - secCfgCfm = NULLP; - libInfo = &ueCb->libInfo; - txIdx = libInfo->crntTmrTxId; - - /* Restart the timer */ - PJ_CHK_RESTART_OBD_TIMER(gCb,ueCb, txIdx); - - /* Shouldnt happen, nevertheless, check */ - if( txIdx >= PJ_MAX_ASYNC_CFM || libInfo->asyncCfm[txIdx] == NULLP) - { - RETVALUE(ROK); - } - - asyncCfm = libInfo->asyncCfm[txIdx]; - - /* Security confirm */ - if(asyncCfm->cfmType & PJ_SEC_ASYNC_CFM) - { - PJ_ALLOC_BUF_SHRABL(udxSap->pst,secCfgCfm, - sizeof (UdxSecCfgCfmInfo), ret); - if(ret != ROK) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } - PJ_FILL_SEC_CFM_INFO(secCfgCfm, asyncCfm); - secCfgCfm->status = CPJ_CFG_CFM_NOK; - secCfgCfm->reason = CPJ_CFG_REAS_OBD_TIMEOUT; - - PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx); - - PjDlUdxSecCfgCfm((&udxSap->pst), udxSap->suId, secCfgCfm); - } - - /* Configuration confirms */ - else if ((asyncCfm->cfmType & PJ_CFG_ASYNC_CFM) || - (asyncCfm->cfmType & PJ_CFG_REEST_ASYNC_CFM)) - { - PJ_FILL_TIMEOUT_CFG_CFM_INFO(gCb,cfgCfm, asyncCfm); - - PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx); - - PjDlUdxCfgCfm(&(gCb->u.dlCb->udxDlSap[0].pst), - gCb->u.dlCb->udxDlSap[0].suId, - cfgCfm); - } - else if (asyncCfm->cfmType & PJ_REEST_ASYNC_CFM) - { - /* Send ReEstCfm */ - /* Memory leak fix ccpu00135359 */ - PJ_ALLOC_BUF_SHRABL(udxSap->pst,reEstCfm, - sizeof (UdxReEstCfmInfo), ret); - if(ret != ROK) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } - PJ_FILL_REEST_CFM_INFO(reEstCfm, asyncCfm, LCM_PRIM_NOK); - - PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx); - - PjDlUdxReEstCfm(&udxSap->pst, - udxSap->suId, reEstCfm); - - /* Send the config confirm also if any exists */ - cfgIdx = (U16)( txIdx + 1); /*KW_FIX*/ - - for(idx = 0; idx < PJ_MAX_ASYNC_CFM; idx++, cfgIdx++) - { - cfgIdx %= PJ_MAX_ASYNC_CFM; - if((libInfo->asyncCfm[cfgIdx] != NULLP) && - (libInfo->asyncCfm[cfgIdx]->cfmType & PJ_CFG_REEST_ASYNC_CFM)) - { - break; - } - } - - /* This scenario occurs when only SRB1 is configured */ - if(idx == PJ_MAX_ASYNC_CFM) - { - RETVALUE(ROK); - } - - PJ_CHK_RESTART_OBD_TIMER(gCb,ueCb, cfgIdx); - asyncCfm = libInfo->asyncCfm[cfgIdx]; - - PJ_FILL_TIMEOUT_CFG_CFM_INFO(gCb,cfgCfm, asyncCfm); - - PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx); - - PjDlUdxCfgCfm(&gCb->u.dlCb->udxDlSap[0].pst, - gCb->u.dlCb->udxDlSap[0].suId, cfgCfm); - } - else if(asyncCfm->cfmType & PJ_CFG_UEDEL_ASYNC_CFM) - { - /* Delete ueCb entry from ueLstCp */ - pjStopTmr(gCb,(PTR)ueCb, PJ_EVT_OBD_WAIT_TMR); - ret = cmHashListDelete(&(gCb->u.ulCb->ueLstCp), (PTR) ueCb); - if (ret != ROK) - { - -#ifdef DEBUGP - RLOG_ARG0(L_ERROR, DBG_UEID,ueCb->key.ueId, - "Hash List Delete Failed for DL ueCb"); -#endif - } - - if ( asyncCfm->entity == ENTPJ ) - { - PJ_ALLOC_BUF_SHRABL(udxSap->pst,cfgCfm, - sizeof (UdxCfgCfmInfo), ret); - if(ret != ROK) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } - - for ( idx = 0; idx < asyncCfm->numEnt; idx++) - { - cfgCfm->cfmEnt[idx].status = asyncCfm->cfmEnt[idx].status; - cfgCfm->cfmEnt[idx].reason = asyncCfm->cfmEnt[idx].reason; - cfgCfm->cfmEnt[idx].rbId = asyncCfm->cfmEnt[idx].rbId; - cfgCfm->cfmEnt[idx].rbType = asyncCfm->cfmEnt[idx].rbType; - } - cfgCfm->ueId = asyncCfm->ueId; - cfgCfm->cellId = asyncCfm->cellId; - cfgCfm->transId = asyncCfm->transId; - cfgCfm->numEnt = asyncCfm->numEnt; - - /* delete all confirms present there */ - for(idx = 0; idx < PJ_MAX_ASYNC_CFM; idx++) - { - if(libInfo->asyncCfm[idx] != NULLP) - { - PJ_FREE(gCb,ueCb->libInfo.asyncCfm[idx], sizeof(PjAsyncCfm)); - ueCb->libInfo.asyncCfm[idx] = NULLP; - } - } - - PJ_FREE(gCb,ueCb, sizeof(PjDlUeCb)); - PjDlUdxCfgCfm(&(udxSap->pst), udxSap->suId, cfgCfm); - } - else if ( asyncCfm->entity == ENTPJ ) - { - /* Memory leak fix ccpu00135359 */ - PJ_ALLOC_BUF_SHRABL(udxSap->pst,pjCfgCfm, - sizeof (UdxCfgCfmInfo), ret); - if(ret != ROK) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } - for ( idx = 0; idx < asyncCfm->numEnt; idx++) - { - pjCfgCfm->cfmEnt[idx].status = asyncCfm->cfmEnt[idx].status; - pjCfgCfm->cfmEnt[idx].reason = asyncCfm->cfmEnt[idx].reason; - pjCfgCfm->cfmEnt[idx].rbId = asyncCfm->cfmEnt[idx].rbId; - pjCfgCfm->cfmEnt[idx].rbType = asyncCfm->cfmEnt[idx].rbType; - } - pjCfgCfm->ueId = asyncCfm->ueId; - pjCfgCfm->cellId = asyncCfm->cellId; - pjCfgCfm->transId = asyncCfm->transId; - pjCfgCfm->numEnt = asyncCfm->numEnt; - - /* delete all confirms present there */ - for(idx = 0; idx < PJ_MAX_ASYNC_CFM; idx++) - { - if(libInfo->asyncCfm[idx] != NULLP) - { - PJ_FREE(gCb,ueCb->libInfo.asyncCfm[idx], sizeof(PjAsyncCfm)); - ueCb->libInfo.asyncCfm[idx] = NULLP; - } - } - - PJ_FREE(gCb,ueCb, sizeof(PjDlUeCb)); - PjDlUdxCfgCfm(&(udxSap->pst), udxSap->suId, pjCfgCfm); - } - } - - RETVALUE(ret); -} /* pjHdlUeDelWaitTmrExp */ - - -/** - * - * @brief - * - * Function to sent the REESTABLISHMENT COMPPLETE - * to the RRC. - * - * @b Description: - * - * This function - * 1. Sends a ReEstablishment Confirm for normal reestablishment. - * 2. Sends a SDU status confirm for handover reestablishment. - * - * @param[in] ueCb UE Control Block - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 pjUtlDlSndSduStaCfm -( -PjCb *gCb, -PjDlUeCb *ueCb /* UE Control Block */ -) -#else -PUBLIC S16 pjUtlDlSndSduStaCfm(gCb, ueCb) -PjCb *gCb; -PjDlUeCb *ueCb; /* UE Control Block */ -#endif -{ - UdxSduStaCfmInfo *cfmInfo; - PjUdxDlSapCb *udxSap; - S16 ret = ROK; - - TRC2(pjUtlDlSndSduStaCfm); - - RLOG2(L_DEBUG, "pjUtlSndSduStaCfm(ueCb(%d,%d))",ueCb->key.ueId, ueCb->key.cellId); - - /* Perform processing for filling up cfm structures */ - /* Memory leak fix ccpu00135359 */ - udxSap = &(gCb->u.dlCb->udxDlSap[0]); - PJ_ALLOC_BUF_SHRABL(udxSap->pst, cfmInfo, - sizeof (UdxSduStaCfmInfo), ret); - if( ret != ROK) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } - PJ_FILL_DL_SDU_CFM_INFO(gCb,cfmInfo, ueCb); - - PjDlUdxSduStaCfm(&gCb->u.dlCb->udxDlSap[0].pst, - gCb->u.dlCb->udxDlSap[0].suId, - cfmInfo); - - RETVALUE(ROK); - -} /* pjUtlSndSduStaCfm */ - -/** - * - * @brief Handler to clean up all the PDCP Control Blocks. - * - * - * @b Description - * This function is invoked by LMM to shutdown the - * layer. This cleans up recBuf and txBuf of all the - * PDCP RBs in all the UEs. - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ - -#ifdef ANSI -PUBLIC S16 pjUtlDlShutdown -( -PjCb *gCb -) -#else -PUBLIC S16 pjUtlDlShutdown() -PjCb *gCb; -#endif -{ - S16 ret; /* Return Value */ - PjDlUeCb *ueCb; /* UE Control Block */ - PjDlUeCb *prevUeCb; /* Previos UE Control Block */ - PjDlRbCb *rbCb; /* RB Control Block */ - PjDlRbCb **rbCbLst; /* RB Control Block List */ - PjSec secInfo; /* Security info of UE */ - U8 idx; /* Index for RBs */ -#ifdef LTE_L2_MEAS_COMMENT - PjL2MeasEvtCb *measEvtCb = NULLP; -#endif - TRC3(pjUtlDlShutdown) - - RLOG0(L_DEBUG, "pjUtlShutdown()"); - - ret = ROK; - ueCb = NULLP; - prevUeCb = NULLP; - rbCb = NULLP; - rbCbLst = NULLP; - idx = 0; - - /* Until no more ueCb is ueLstCp hash list get and delete ueCb */ - while (cmHashListGetNext(&(gCb->u.dlCb->ueLstCp), (PTR) prevUeCb, (PTR *)&ueCb) == ROK) - { - if ( ueCb != NULLP ) - { -#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) - if (ueCb->libInfo.obdTmr.tmrEvnt == PJ_EVT_OBD_TMR) - { - pjStopTmr(gCb,(PTR)ueCb, PJ_EVT_OBD_TMR); - } -#endif - rbCbLst = ueCb->srbCb; - for (idx = 0; idx < PJ_MAX_SRB_PER_UE; idx++) - { - rbCb = rbCbLst[idx]; - if (rbCb != NULLP) - { - /* Free the Buffers of RbCb */ - pjUtlDlFreeRb(gCb,rbCb); - } - } - rbCbLst = ueCb->drbCb; - for (idx = 0; idx < PJ_MAX_DRB_PER_UE; idx++) - { - rbCb = rbCbLst[idx]; - if (rbCb != NULLP) - { - pjUtlDlFreeRb(gCb,rbCb); - } - } - /* Close all the context info for offboarding */ - secInfo = ueCb->secInfo; -#ifdef INTEL_QAT_DP - pjUtlDlIntClose(gCb,ueCb->secInfo.cpIntSessCxtId); - pjUtlDlCipherClose(gCb,ueCb->secInfo.cpCiphSessCxtId); - pjUtlDlCipherClose(gCb,ueCb->secInfo.upCiphSessCxtId); -#else - pjUtlDlCipherClose(gCb,secInfo.cpCxtId); - pjUtlDlCipherClose(gCb,secInfo.upCxtId); - pjUtlDlIntClose(gCb,secInfo.intCxtId); -#endif - - /* Delete hoInfo if present */ - if (ueCb->hoInfo != NULLP) - { - PJ_FREE(gCb,ueCb->hoInfo->hoCfmInfo, - (PJ_MAX_DRB_PER_UE * sizeof(PjDlHoCfmInfo))); - PJ_FREE(gCb,ueCb->hoInfo, sizeof(PjDlHoInfo)); - } - } - prevUeCb = ueCb; - } -#ifdef LTE_L2_MEAS_COMMENT - for(idx = 0; idx < PJ_MAX_L2MEAS_EVT; idx++) - { - if(gCb->u.dlCb->pjL2Cb.pjMeasEvtCb[idx] != NULLP) - { - measEvtCb = gCb->u.dlCb->pjL2Cb.pjMeasEvtCb[idx]; - pjStopTmr((PTR)measEvtCb, PJ_EVT_L2_TMR); - gCb->u.dlCb->pjL2Cb.pjNumMeas--; - PJ_FREE(gCb,measEvtCb, sizeof(PjL2MeasEvtCb)); - gCb->u.dlCb->pjL2Cb.pjMeasEvtCb[idx] = NULLP; - } - } -#endif - ret = pjDbmDlDeInit(gCb); -#if (ERRCLASS & ERRCLS_DEBUG) - if (ret != ROK) - { - RLOG0(L_FATAL, "PDCP DL DeInitialization Failed."); - } -#endif /* ERRCLASS & ERRCLS_DEBUG */ - - - /* commented this to use in deregister timer and kwusap */ - /* gCb->init.cfgDone &= ~PJ_LMM_GENCFG_DONE; */ - RETVALUE(ret); -} - -/** - * - * @brief - * - * Handler to free a PDCP Control Block. - * - * @b Description: - * - * This function frees the txBuf and rxBuf in a PDCP control block. - * and closes the compression channel opened. It stops the timers - * of this control block if they are running. - * - * @param[in] pst Post structure - * @param[in] secCxt Context for Integrity protection/verification - * @param[in] ctxId Integrity Context Id - * - * - * @return S16 - * -# ROK - * - */ - -#ifdef ANSI -PUBLIC Void pjUtlDlFreeRb -( -PjCb *gCb, -PjDlRbCb *pjRbCb -) -#else -PUBLIC Void pjUtlDlFreeRb(pjRbCb) -PjCb *gCb; -PjDlRbCb *pjRbCb; -#endif -{ - TRC3(pjUtlDlFreeRb) - RLOG0(L_DEBUG, "pjUtlFreeRb()"); - - -#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) - if (pjRbCb->dlCb.obdTmr.tmrEvnt == PJ_EVT_DL_OBD_TMR) - { - pjStopTmr(gCb,(PTR)pjRbCb, PJ_EVT_DL_OBD_TMR); - } -#endif - - pjUtlCmpClose(gCb,pjRbCb->cmpCxtId); - /*pj004.201 Adding of Missing Trace in LTE RLC PDCP*/ - RETVOID; -} - -/* pj005.201 added function to send data forward indication message */ -/** - * - * @brief - * - * Handler to send Data Fwd Indication - * - * @b Description: - * This function sends Data Fwd Indication message to PDCP user - * - * @param[in] pjRbCb PDCP RbCb - * @param[in] datFwdInd Data forward indication - * - * - * @return S16 - * -# ROK - * - */ - -#ifdef ANSI -PUBLIC S16 pjUtlDlSndDatFwdInd -( -PjCb *gCb, -PjDlRbCb *pjRbCb, -PjuDatFwdIndInfo *datFwdInd -) -#else -PUBLIC S16 pjUtlDlSndDatFwdInd(pjRbCb, datFwdInd) -PjCb *gCb; -PjDlRbCb *pjRbCb; -PjuDatFwdIndInfo *datFwdInd; -#endif -{ - CmLtePdcpId *pdcpId; - PjPjuSapCb *pjuSap; - - TRC3(pjUtlDlSndDatFwdInd) - - RLOG0(L_DEBUG, "pjUtlSndDatFwdInd()"); - - pjuSap = &(gCb->u.dlCb->pjuSap[PJ_DRB_SAP]); - CmLtePdcpId pdcpIdTmp; - pdcpId = &pdcpIdTmp; - - if(pdcpId != NULLP) - { - pdcpId->ueId = pjRbCb->ueCb->key.ueId; - pdcpId->cellId = pjRbCb->ueCb->key.cellId; - pdcpId->rbId = pjRbCb->rbId; - pdcpId->rbType = pjRbCb->rbType; - - gCb->pjGenSts.numPktsFrwd += datFwdInd->numSdus; - /* If trace flag is enabled send the trace indication */ - if(gCb->init.trc == TRUE) - { - /* Populate the trace params */ - pjLmmSendTrc(gCb,EVTPJUDATFWDIND, NULLP); - } - PjUiPjuDatFwdInd(&(pjuSap->pst), pjuSap->suId, pdcpId, datFwdInd); - } - - RETVALUE(ROK); - -}/* end of pjUtlSndDatFwdInd */ - -/* pj005.201 added support for L2 Measurement */ -#ifdef LTE_L2_MEAS -/** - * - * @brief Function to initialise measurement - * - * @b Description - * - * @param[in] gCb PDCP Instance Control Block - * - * @return Void - * - */ -S16 pjUtlL2MeasDlInit(PjCb *gCb) -{ - U16 cntr; - - gCb->u.dlCb->pjL2Cb.pjNumMeas=0; - for(cntr = 0; cntr < LPJ_MAX_L2MEAS; cntr++) - { - cmMemset((U8 *)&(gCb->u.dlCb->pjL2Cb.pjL2EvtCb[cntr]), 0, sizeof(PjL2MeasEvtCb)); - } - gCb->u.dlCb->pjL2Cb.pjL2EvtCb[0].measCb.measType = LPJ_L2MEAS_DL_DISC; - - RETVALUE(ROK); -} - -/** - * - * @brief Handler for sending L2 Measurement report - * - * @b Description - * - * @param[in] gCb PDCP Instance Control Block. - * @param[in] measEvtCb Measurement Event Control Block. - * - * - * @return S16 - * -# ROK - */ - -#ifdef ANSI -PUBLIC S16 pjUtlSndDlL2MeasCfm -( -PjCb *gCb, -PjL2MeasEvtCb *measEvtCb -) -#else -PUBLIC S16 pjUtlSndDlL2MeasCfm(measEvtCb) -PjCb *gCb; -PjL2MeasEvtCb *measEvtCb; -#endif -{ - PjL2MeasCb *measCb; - PjL2MeasCfmEvt measCfmEvt; - U8 qciIdx; - - TRC3(pjUtlSndDlL2MeasCfm) - - measCb = &measEvtCb->measCb; - cmMemset((U8*)&measCfmEvt, 0, sizeof(PjL2MeasCfmEvt)); - - measCfmEvt.measType = measCb->measType; - measCfmEvt.status.status = LCM_PRIM_OK; - measCfmEvt.status.reason = LCM_REASON_NOT_APPL; - for(qciIdx = 0; qciIdx < (LPJ_MAX_QCI-1); qciIdx++) - { - measCfmEvt.measCfm[measCfmEvt.numQciCfm].qci = measCb->qci[qciIdx]; - if(measCfmEvt.measCfm[measCfmEvt.numQciCfm].qci > 0) - { - if((measCb->measType & LPJ_L2MEAS_DL_DISC) && - (measCb->measData[measCb->qci[qciIdx]].dlDisc.numPkts > 0)) - { - /* dlDisc = num of Pkts Discarded * 10^6 / total no of pkts. */ - measCfmEvt.measCfm[measCfmEvt.numQciCfm].dlDisc = - measCb->measData[measCb->qci[qciIdx]].dlDisc.val * (1000000) / - measCb->measData[measCb->qci[qciIdx]].dlDisc.numPkts; - /* Reset the counters */ - measCb->measData[measCb->qci[qciIdx]].dlDisc.val = 0; - measCb->measData[measCb->qci[qciIdx]].dlDisc.numPkts =0; - } - measCfmEvt.numQciCfm++; - } - } - - /* Send Measurement confirmation to layer manager */ - PjMiLpjL2MeasCfm(&gCb->pjGenCfg.lmPst,&measCfmEvt); - - RETVALUE(ROK); -} - - -/** - * @brief Validates the measurement request parameters. - * - * @details - * - * Function :pjUtlValidateL2Meas - * - * @param[in] PjL2MeasReqEvt measReqEvt - * @param[out] PjL2MeasCfmEvt measCfmEvt - **/ -/** - * - * @brief Handler for resetting the DL measurement counters - * - * Function :pjUtlResetDlL2MeasCntr - * - * @b Description - * - * @param[in] measCb Measurement Control Block. - * - * - * @return Void - */ -#ifdef ANSI - -PUBLIC Void pjUtlResetDlL2MeasCntr -( -PjCb *gCb, -PjL2MeasCb *measCb, -U8 measType -) -#else -PUBLIC Void pjUtlResetDlL2MeasCntr(gCb, measCb, measType) -PjCb *gCb; -PjL2MeasCb *measCb; -U8 measType; -#endif -{ - /* for now the only meas should be DL discard in this case */ - if (measCb->measType & LPJ_L2MEAS_DL_DISC) - { - U32 i; - for(i = 0; i < (LPJ_MAX_QCI - 1); i++) - { - U8 qciVal = measCb->qci[i]; - - measCb->measData[qciVal].dlDisc.val = 0; - measCb->measData[qciVal].dlDisc.numPkts = 0; - gCb->u.dlCb->pjL2Cb.measOn[qciVal] &= ~LPJ_L2MEAS_DL_DISC; - } - - measCb->numQci = 0; - } -} - -/** - * - * @brief Handler for storing address of MeasData in rbCb at right index - * - * - * @b Description - * This function is called when LM sends measReq message to RLC. - * - * @param[in] - * @param[out] - * @param[in] - * - * - * @return S16 - * -# ROK - */ -#ifdef ANSI -PUBLIC Void pjUtlPlcMeasDatInDlL2Sts -( -PjL2Cntr *measData, -PjL2MeasRbCb *rbL2Cb, -U8 measType -) -#else -PUBLIC Void pjUtlPlcMeasDatInDlL2Sts(measData, rbL2Cb, measType) -PjL2Cntr *measData; -PjL2MeasRbCb *rbL2Cb; -U8 measType; -#endif -{ - TRC3(pjUtlPlcMeasDatInDlL2Sts) - - /* We should check the number of measType in the request. This can be done - * by looking at each bit in the measType. Also store the measData in the - * correct index of l2Sts in RbCb. - * */ - - if(measType & LPJ_L2MEAS_DL_DISC) - { - rbL2Cb->l2Sts[PJ_L2MEAS_DL_DISC] = measData; - } - -}/* End of pjUtlPlcMeasDatInDlL2Sts */ -#endif /* LTE_L2_MEAS */ - -void dumpPDCPDlRbInformation(PjDlRbCb* dlRbCb, U16 ueId) -{ - PjDlCb* dlCb = &dlRbCb->dlCb; - RLOG_ARG1(L_INFO,DBG_UEID,ueId, "PDCP DL RB numEntries = %lu", - dlCb->txBuf.numEntries); -#ifndef ALIGN_64BIT - RTLIN_DUMP_DEBUG("UE [%u] PDCP DL RB numEntries = %lu", - ueId, dlCb->txBuf.numEntries); -#else - RTLIN_DUMP_DEBUG("UE [%u] PDCP DL RB numEntries = %u", - ueId, dlCb->txBuf.numEntries); -#endif -} - -void DumpPDCPDlDebugInformation(void) -{ -#ifndef RGL_SPECIFIC_CHANGES -#ifdef TENB_T2K3K_SPECIFIC_CHANGES - void *iccHdl = NULLP; - U32 poolZeroFreeCnt; - U32 poolOneFreeCnt; - U32 poolTwoFreeCnt; - U32 poolThreeFreeCnt; -#endif - - PjCb* dlInst = pjCb[1]; /* TODO: check whether DL is 0 or 1 */ - PjDlgCb* dlgCb = dlInst->u.dlCb; - - PjDlUeCb *ueCb = NULLP; - RLOG0(L_INFO,"PDCP DL Information"); - RLOG0(L_INFO,"==================="); - RTLIN_DUMP_DEBUG("PDCP DL Information\n"); - RTLIN_DUMP_DEBUG("===================\n"); - /* Until no more ueCb is ueLstCp hash list get and delete ueCb */ - while (ROK == cmHashListGetNext(&dlgCb->ueLstCp, - (PTR) ueCb, - (PTR *)&ueCb)) - { - U32 i; - for(i = 0; i < PJ_MAX_SRB_PER_UE; i++) - { - PjDlRbCb* rbCb = ueCb->srbCb[i]; - if(rbCb != NULLP) - { - dumpPDCPDlRbInformation(rbCb, ueCb->key.ueId); - } - } - for(i = 0; i < PJ_MAX_DRB_PER_UE; i++) - { - PjDlRbCb* rbCb = ueCb->drbCb[i]; - if(rbCb != NULLP) - { - dumpPDCPDlRbInformation(rbCb, ueCb->key.ueId); - } - } - }/* end while */ - /*printing ICC memory statistics*/ -#ifdef TENB_T2K3K_SPECIFIC_CHANGES - iccHdl = ssGetIccHdl(dlInst->init.region); - if(NULLP != iccHdl) - { - poolZeroFreeCnt = TL_GetFreeBlocks(iccHdl, ICC_POOL_ZERO_SIZE); - poolOneFreeCnt = TL_GetFreeBlocks(iccHdl, ICC_POOL_ONE_SIZE); - poolTwoFreeCnt = TL_GetFreeBlocks(iccHdl, ICC_POOL_TWO_SIZE); - poolThreeFreeCnt = TL_GetFreeBlocks(iccHdl, ICC_POOL_THREE_SIZE); - RLOG1(L_ALWAYS,"ICC pool zero free count = %lu", poolZeroFreeCnt); - RLOG1(L_ALWAYS,"ICC pool one free count = %lu", poolOneFreeCnt); - RLOG1(L_ALWAYS,"ICC pool two free count = %lu", poolTwoFreeCnt); - RLOG1(L_ALWAYS,"ICC pool three free count = %lu", poolThreeFreeCnt); - RTLIN_DUMP_DEBUG("ICC pool zero free count = %lu\n", poolZeroFreeCnt); - RTLIN_DUMP_DEBUG("ICC pool one free count = %lu\n", poolOneFreeCnt); - RTLIN_DUMP_DEBUG("ICC pool two free count = %lu\n", poolTwoFreeCnt); - RTLIN_DUMP_DEBUG("ICC pool three free count = %lu\n", poolThreeFreeCnt); - } - /*ccpu00136858 */ - RLOG1(L_ALWAYS,"SPACC cipher Q num of entry = %lu ", pjMsCiphQ.count); - RLOG1(L_ALWAYS,"SPACC decipher Q num of entry = %lu ", pjMsDeCiphQ.count); - RTLIN_DUMP_DEBUG("SPACC cipher Q num of entry = %lu \n", pjMsCiphQ.count); - RTLIN_DUMP_DEBUG("SPACC decipher Q num of entry = %lu \n", pjMsDeCiphQ.count); -#endif -#endif -} - -PUBLIC Void pjUtlEmptyDlPktList(PjCb *gCb, PjDlRbCb *pjRbCb) -{ - PjDlPkt *ulPkt; - CmLListCp *ulPktLst = &pjRbCb->dlCb.dlPktQ; - while(ulPktLst->first) - { - ulPkt = (PjDlPkt *)(ulPktLst->first->node); - cmLListDelFrm(ulPktLst, ulPktLst->first); - PJ_FREE_BUF(ulPkt->pdu); -#ifdef FLAT_BUFFER_OPT - PJ_FREE_FLAT_BUF(gCb, &(ulPkt->fb)) -#endif - PJ_FREE(gCb, ulPkt, sizeof(PjDlPkt)); - } - RETVOID; -} - -void ResetPDCPStats(void) -{ - cmMemset((U8*)&gPdcpStats, 0, sizeof(PDCPStats)); -} - -#ifndef ALIGN_64BIT -void PrintPDCPStats(void) -{ -#ifdef TENB_T2K3K_SPECIFIC_CHANGES - /* UDAY */ -#ifdef XEON_SPECIFIC_CHANGES - RLOG3(L_INFO,"PDCP Stats: SDUs Dropped = (%ld),SDUs Queued for SPAcc Cipher = (%ld)," - "Decipher = (%ld)", - gPdcpStats.numPdcpSdusDiscarded, pjMsCiphQ.count, pjMsDeCiphQ.count); -#else - RLOG3(L_INFO,"PDCP Stats: SDUs Dropped = (%ld),SDUs Queued for SPAcc Cipher = (%ld)," - "Decipher = (%ld)", - gPdcpStats.numPdcpSdusDiscarded, pjMsDlSpaccQCnt, pjMsUlSpaccQCnt); -#endif -#ifdef XEON_SPECIFIC_CHANGES - if((gPdcpStats.numPdcpSdusDiscarded > 0) || (pjMsCiphQ.count > 0) || (pjMsDeCiphQ.count > 0) ) - { - RTLIN_DUMP_DEBUG("PDCP Stats: SDUs Dropped = (%d)," - "SDUs Queued for SPAcc Cipher = (%d), Decipher = (%d) \n", - gPdcpStats.numPdcpSdusDiscarded, pjMsCiphQ.count, pjMsDeCiphQ.count); /* UDAY */ - } -#else - RTLIN_DUMP_DEBUG("PDCP Stats: SDUs Dropped = (%ld)," - "SDUs Queued for SPAcc Cipher = (%ld), Decipher = (%ld) Rb Overload DROP = (%ld) dbgPdcpQSizeThreshHoldDropCnt is (%ld) MmThredHldDrp (%ld) spaccQDropCnt (%ld) dlSpaccPktDrop %ld\n", - gPdcpStats.numPdcpSdusDiscarded, pjMsDlSpaccQCnt, pjMsUlSpaccQCnt,dbgPdcpMemCount,dbgPdcpQSizeThreshHoldDropCnt,pdcpdrop, dbgSpaccThreshHoldDropCnt,spaccDropCount); /* UDAY */ - dbgPdcpMemCount =0; - dbgPdcpQSizeThreshHoldDropCnt=0; - pdcpdrop = 0; - - spaccDropCount = 0; - //pdcpDropMemTh=0; -#endif -#endif -} -#else -void PrintPDCPStats(void) -{ - printf ("\n============================== PDCP STATS ===========================\n"); - RTLIN_DUMP_DEBUG("SDUs Dropped = (%u) No of Reodering Tmr Exp (%u)", - gPdcpStats.numPdcpSdusDiscarded, gPdcpStats.numPdcpCellReorderTmrExp); -} -#endif - -#ifdef ANSI -PRIVATE S16 pjUtlDlHdlSecInitCfm -( -PjCb *gCb, /* Pointer to PJ DL Control Block */ -PjDlUeCb *ueCb, /* Pointer to UeCb */ -U16 txIdx, /* Transaction Index for UeCb */ -PjAsyncCfm *asyncCfm, -UdxSecCfgCfmInfo *secCfgCfm, /* Security config confirm */ -UdxReEstCfmInfo *reEstCfm /* Reest config confirm */ -) -#else -PRIVATE S16 pjUtlDlHdlSecInitCfm(gCb,ueCb,txIdx,secCfgCfm,reEstCfm) -( -PjCb *gCb; /* Pointer to PJ DL Control Block */ -PjDlUeCb *ueCb; /* Pointer to UeCb */ -U16 txIdx; /* Transaction Index for UeCb */ -PjAsyncCfm *asyncCfm; -UdxSecCfgCfmInfo *secCfgCfm; /* Security config confirm */ -UdxReEstCfmInfo *reEstCfm; /* Reest config confirm */ -) -#endif -{ - PjUdxDlSapCb *udxSap; - S16 ret = ROK; - - TRC3(pjUtlDlHdlSecInitCfm) - - if(asyncCfm->libInitBitMask == 0) - { - PJ_CHK_RESTART_OBD_TIMER(gCb,ueCb, txIdx); - if(ueCb->libInfo.state == PJ_STATE_NORMAL) - { - /* Send security config confirm */ - /* Memory leak fix ccpu00135359 */ - udxSap = &(gCb->u.dlCb->udxDlSap[0]); - PJ_ALLOC_BUF_SHRABL(udxSap->pst,secCfgCfm, - sizeof (UdxSecCfgCfmInfo), ret); - if(ret != ROK) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } - PJ_FILL_SEC_CFM_INFO(secCfgCfm, asyncCfm); - - PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx); - - PjDlUdxSecCfgCfm(&gCb->u.dlCb->udxDlSap[0].pst, - gCb->u.dlCb->udxDlSap[0].suId, - (UdxSecCfgCfmInfo *) secCfgCfm); - } - else if(ueCb->libInfo.state == PJ_STATE_REEST) - { - /* Send ReEstCfm */ - /* Memory leak fix ccpu00135359 */ - udxSap = &(gCb->u.dlCb->udxDlSap[0]); - PJ_ALLOC_BUF_SHRABL(udxSap->pst,reEstCfm, - sizeof (UdxReEstCfmInfo), ret); - if(ret != ROK) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } - PJ_FILL_REEST_CFM_INFO(reEstCfm, asyncCfm, LCM_PRIM_OK); - - /* Some house keeping work */ - PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx); - - PjDlUdxReEstCfm(&gCb->u.dlCb->udxDlSap[0].pst, - gCb->u.dlCb->udxDlSap[0].suId, reEstCfm); - - pjUtlReEstDl(gCb, ueCb); - } - } - RETVALUE(ROK); -} - - -#ifdef ANSI -PRIVATE S16 pjUtlDlHdlCmpInitCfm -( -PjCb *gCb, /* Pointer to PJ DL Control Block */ -PjDlUeCb *ueCb, /* Pointer to UeCb */ -U16 txIdx, /* Transaction Index for UeCb */ -PjAsyncCfm *asyncCfm, /* Async Confirm */ -UdxCfgCfmInfo *cfgCfm /* UDX Config Confirm */ -) -#else -PRIVATE S16 pjUtlDlHdlCmpInitCfm(gCb,ueCb,txIdx,asyncCfm,cfgCfm) -( -PjCb *gCb; /* Pointer to PJ DL Control Block */ -PjDlUeCb *ueCb; /* Pointer to UeCb */ -U16 txIdx; /* Transaction Index for UeCb */ -PjAsyncCfm *asyncCfm; /* Async Confirm */ -UdxCfgCfmInfo *cfgCfm; /* UDX Config Confirm */ -) -#endif -{ - PjUdxDlSapCb *udxSap; - U32 idx; - S16 ret = ROK; - TRC3(pjUtlDlHdlCmpInitCfm) - - asyncCfm->libInitBitMask ^= (PJ_LIB_COMP_BIT_MASK); - - if((asyncCfm->libInitBitMask == 0) && - !(asyncCfm->cfmType & PJ_CFG_REEST_ASYNC_CFM)) - { - - /* Send config confirm */ - /* Memory leak fix ccpu00135359 */ - udxSap = &(gCb->u.dlCb->udxDlSap[0]); - PJ_ALLOC_BUF_SHRABL(udxSap->pst,cfgCfm, - sizeof (UdxCfgCfmInfo), ret); - if(ret != ROK) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } - cfgCfm->transId = asyncCfm->transId; - cfgCfm->ueId = asyncCfm->ueId; - cfgCfm->cellId = asyncCfm->cellId; - cfgCfm->numEnt = asyncCfm->numEnt; - for ( idx = 0; idx < asyncCfm->numEnt; idx++ ) - { - cfgCfm->cfmEnt[idx].status = asyncCfm->cfmEnt[idx].status; - cfgCfm->cfmEnt[idx].reason = asyncCfm->cfmEnt[idx].reason; - cfgCfm->cfmEnt[idx].rbId = asyncCfm->cfmEnt[idx].rbId; - cfgCfm->cfmEnt[idx].rbType = asyncCfm->cfmEnt[idx].rbType; - } - - /* Some house keeping work */ - PJ_CHK_RESTART_OBD_TIMER(gCb,ueCb, txIdx); - PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx); - - /* Send confirmtion to the User */ - PjDlUdxCfgCfm(&(gCb->u.dlCb->udxDlSap[0].pst), - gCb->u.dlCb->udxDlSap[0].suId, - (UdxCfgCfmInfo *)cfgCfm); - } - - RETVALUE(ROK); -} - - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ -/********************************************************************30** - End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_dlm.c b/src/5gnrpdcp/pj_dlm.c deleted file mode 100755 index d2ad4811f..000000000 --- a/src/5gnrpdcp/pj_dlm.c +++ /dev/null @@ -1,2831 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************** - - Name: LTE-PDCP Layer - - Type: C file - - Desc: Source code for PDCP Downlink module. - This file contains following functions - - --pjDlmProcessSdus - --pjDlmBldPdu - --pjDlmReEstSrb - --pjDlmReEstDrbUm - --pjDlmReEstDrbAm - --pjDlmProcessCfm - --pjDlmHndlStaRep - --pjDlmDiscSdu - --pjDlmDeliverPdu - --pjDlmReEstHoDrbAm - --pjDlmHndlDatFwdReq - --pjDlmProcSrb - --pjDlmProcDrb - - File: pj_dlm.c - -**********************************************************************/ - -static const char* RLOG_MODULE_NAME="PDCP"; -static int RLOG_FILE_ID=241; -static int RLOG_MODULE_ID=1024; -/** @file pj_dlm.c -@brief PDCP Downlink module -*/ - -/* header (.h) include files */ -#include "envopt.h" /* environment options */ -#include "envdep.h" /* environment dependent */ -#include "envind.h" /* environment independent */ - -#include "gen.h" /* general */ -#include "ssi.h" /* system services interface */ -#include "cm5.h" /* Timer Functions */ -#include "cm_lte.h" /* common LTE header file */ -#include "cm_hash.h" /* common hash module file */ -#include "cm_llist.h" /* common list header file */ -#include "cpj.h" /* RRC layer */ -#include "pju.h" /* PDCP service user */ -#include "lpj.h" /* LPJ defines */ -#include "pj_env.h" /* RLC environment options */ -#include "pj.h" /* RLC layer */ -#include "pj_dl.h" -#include "pj_err.h" -#include "pj_ptsec.h" -#ifndef TENB_T2K3K_SPECIFIC_CHANGES -void prc_trace_format_string(U32 group_mask, U16 level, const char *format, ...); -#endif - - -/* header/extern include files (.x) */ -#include "gen.x" /* general */ -#include "ssi.x" /* system services interface */ -#include "cm_lib.x" /* common library */ -#include "cm5.x" /* Timer Functions */ -#include "cm_hash.x" /* common hash module */ -#include "cm_lte.x" /* common LTE file */ -#include "cm_llist.x" /* common list header file */ -#include "cpj.x" /* RRC layer */ -#include "pju.x" /* PDCP service user */ -#include "lpj.x" /* LPJ defines */ -#include "pj.x" /* RLC layer */ -#include "pj_udx.h" -#include "pj_udx.x" -#include "pj_dl.x" -#include "pj_ul.x" - -EXTERN U32 pjTotDlPckCntPerCell; -#ifdef TENB_AS_SECURITY -EXTERN U8 isSecBatchMode; -#endif - - -#ifdef TENB_T2K3K_SPECIFIC_CHANGES -EXTERN Ticks SGetT2KTtiCount(Void); -#endif -/* kw005.201 Moved definition of PJ_ASYNC_WIN to kw.h file */ -/** @addtogroup dldata */ -/*@{*/ -EXTERN S16 pjUtlChekTxEnqReq ARGS(( PjCb *gCb, PjDlRbCb *pjRbCb, PjTxEnt *txEnt)); - -PRIVATE S16 pjDlmBldPdu(PjCb *gCb,PjDlRbCb *pjRbCb,PjTxEnt *txEnt); -PRIVATE Void pjDlmDelTxEntUptoFmc ARGS ((PjCb *gCb, PjDlRbCb *pjRbCb, U32 fmc, PjuDatCfmInfo *datCfm)); - -/** - * - * @brief - * - * Handler to free all sdus present in datCfmQ till the First Missing - * Segment. - * - * @param[in] pjRbCb PDCP control block. - * @param[in] fmc First Missing Segment count - * @param[in] datCfm datCfm - * - * @return S16 - * -# ROK - * -# RFAILED - */ -#ifdef ANSI -PRIVATE Void pjDlmDelTxEntUptoFmc -( -PjCb *gCb, -PjDlRbCb *pjRbCb, -U32 count, -PjuDatCfmInfo *datCfm -) -#else -PRIVATE Void pjDlmDelTxEntUptoFmc(gCb, pjRbCb, count, datCfm) -PjCb *gCb; -PjDlRbCb *pjRbCb; -U32 count; -PjuDatCfmInfo *datCfm; -#endif -{ - PjTxEnt *txEnt; - - - cmLListFirst(&pjRbCb->dlCb.txBuf.datCfmQ); - while (cmLListCrnt(&pjRbCb->dlCb.txBuf.datCfmQ)) - { - txEnt = (PjTxEnt *) cmLListNode(cmLListCrnt(&pjRbCb->dlCb.txBuf.datCfmQ)); - if (txEnt != NULLP) - { - if (txEnt->count < count) - { - if (pjRbCb->dlCb.cfmReqd && datCfm!= NULLP) - { - /* As of now, DATCFM is sent only for the 1st 25 PDUs. Once we */ - /* enable cfmReqd, we need to add code to send for all PDUs in loop */ - if(datCfm->numSdus < PJU_MAX_SDU_CFM) - { - datCfm->cfmSta[datCfm->numSdus].sduId = txEnt->sduId; - datCfm->cfmSta[datCfm->numSdus].status = PJ_CFM_OK; - datCfm->numSdus++; - } - } - pjDbmDelTxEnt(gCb, &(pjRbCb->dlCb.txBuf), txEnt->count); - } - else - { - /* fmc reached break out of the loop */ - break; - } - } - cmLListNext(&pjRbCb->dlCb.txBuf.datCfmQ); - } - - RETVOID; -} - -/** - * - * @brief - * - * Handler to process the SDU received from upper layer, form a PDU - * and send the PDU to the lower layer. - * - * @b Description: - * - * 1. This function places the SDU in the transmission buffer and performs - * Compression for DRB SDUs and Integrity Protection for SRB SDUs. @n - * 2. After compression/integrity protection, it performs ciphering and then - * constructs the PDU and sends it to the lower layer. @n - * 3. The first DL message of SRBs is not ciphered and is just integrity - * protected. @n - * 4. This function checks the UE CB control block to check the flag for the - * first DL message and performs only integrity protection and unsets - * the flag. @n - * - * @param[in] pjRbCb PDCP control block. - * @param[in] sdu SDU to be processed. - * @param[in] sduId SDU ID. - * - * @return S16 - * -# ROK - * -# RFAILED - */ - -U32 pjTxSdu; - -#ifdef ANSI -PUBLIC S16 pjDlmProcessSdus -( -PjCb *gCb, -PjDlRbCb *pjRbCb, /* !< PDCP Control Block */ -Buffer *sdu, /* !< SDU to be processed */ -U32 sduId, /* !< PDCP SDU ID */ -U32 count /* !< count to be assigned */ -) -#else -PUBLIC S16 pjDlmProcessSdus(gCb, pjRbCb, sdu, sduId, count) -PjCb *gCb; -PjDlRbCb *pjRbCb; /* !< PDCP Control Block */ -Buffer *sdu; /* !< SDU to be processed */ -U32 sduId; /* !< PDCP SDU ID */ -U32 count; /* !< count to be assigned */ -#endif -{ - S16 ret; /* Return Value */ - PjTxEnt *txEnt; /* Transmission Entity for sdu*/ -#ifdef L2_PDCP_OPTMZ - U8 hashKey; /* Computed HashKey */ - PjBuf *buf; -#endif - - TRC2(pjDlmProcessSdus) - -#ifndef ALIGN_64BIT - PJDBGP(gCb,(PJ_DBGMASK_DLM | PJ_DBGMASK_BRIEF | PJ_DBGMASK_DL), - (gCb->init.prntBuf, "pjDlmProcessSdus(pjRbCb(%d), sdu, sduId(%ld), \ - txHfn) \n)", pjRbCb->rbId, sduId)); -#else - PJDBGP(gCb,(PJ_DBGMASK_DLM | PJ_DBGMASK_BRIEF | PJ_DBGMASK_DL), - (gCb->init.prntBuf, "pjDlmProcessSdus(pjRbCb(%d), sdu, sduId(%d), \ - txHfn) \n)", pjRbCb->rbId, sduId)); -#endif - - - ret = ROK; - - /* Allocate the transmission entity */ - PJ_ALLOC(gCb,txEnt, sizeof(PjTxEnt)); - -#if (ERRCLASS & ERRCLS_ADD_RES) - if (txEnt == NULLP) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - PJ_FREE_BUF(sdu); - RETVALUE(RFAILED); - } -#endif /* ERRCLASS & ERRCLS_RES */ - - /* Update COUNT to the current count in dlCb*/ - pjRbCb->dlCb.count = count; - /* Fill TxEnt values */ - PJ_DLM_GET_SN(pjRbCb,count,txEnt->sn); - //txEnt->count = count; - //txEnt->txHfn = txHfn; - txEnt->count = count; - txEnt->state = PJ_SDU_RECEIVED; - txEnt->sduId = sduId; - /* The received buffer is stored in the SDU and the output from - * Compression/Ciphering is stored in the PDU. - */ - txEnt->sdu = sdu; - txEnt->pdu = NULLP; - - /* Process the SDU based on rbType */ - if (pjRbCb->rbType == PJ_SRB) - { - /* Insert TxEnt into the transmission buffer */ - pjDbmInsTxEnt(gCb, &(pjRbCb->dlCb.txBuf), txEnt); - ret = pjDlmProcSrb(gCb, pjRbCb, txEnt); - } - else - { -#ifndef RGL_SPECIFIC_CHANGES -#ifndef TENB_ACC -#ifndef LTE_PAL_ENB - EXTERN U32 dlrate_pju; - MsgLen len; - SFndLenMsg(sdu, (MsgLen *) &len); - dlrate_pju += len; -#endif -#endif -#endif -#ifndef L2_PDCP_OPTMZ - pjDbmInsTxEnt(gCb, &(pjRbCb->dlCb.txBuf), txEnt); -#else - /* Fix for NULL ciphering. For null ciphering add PDUs to sduSubmitQ*/ - if(pjRbCb->ueCb->secInfo.secAct && pjRbCb->ueCb->secInfo.cipherInfo.algoType != 0) - { - txEnt->datCfmEnt.node = NULLP; - txEnt->reEstPktEnt.node = NULLP; - txEnt->sduSubmitEnt.node = (PTR)NULLP; - - buf=&(pjRbCb->dlCb.txBuf); - hashKey = (U8)PJ_HASH_FN(buf, txEnt->count); /*KW_FIX*/ - - txEnt->lstEnt.node = (PTR)txEnt; - cmLListAdd2Tail(&buf->datQ[hashKey], &txEnt->lstEnt); - buf->numEntries ++; - /* Dont add PDUs to datCfmQ in case of UM mode*/ - if (pjRbCb->mode == PJ_DRB_AM ) - { - txEnt->datCfmEnt.node = (PTR)txEnt; - cmLListAdd2Tail(&pjRbCb->dlCb.txBuf.datCfmQ, &txEnt->datCfmEnt); - } - txEnt->state = PJ_PDU_SUBMITTED; - } - else - { - pjDbmInsTxEnt(gCb, &(pjRbCb->dlCb.txBuf), txEnt); - } -#endif - ret = pjDlmProcDrb(gCb, pjRbCb, txEnt); - } - - RETVALUE(ret); -} - -/** - * - * @brief - * - * Handler to Re-establish a SRB. - * - * @b Description: - * - * 1. This function is called when re-establishment request is - * received for a SRB. @n - * 2. The stored PDUs and SDUs are freed and the variables are reset. @n - * - * @param[in] pjRbCb PDCP control block. - * - */ - -#ifdef ANSI -PUBLIC Void pjDlmRbDataResume -( -PjCb *gCb, -PjDlRbCb *pjRbCb -) -#else -PUBLIC Void pjDlmRbDataResume(gCb, pjRbCb) -PjCb *gCb; -PjDlRbCb *pjRbCb; -#endif -{ - S16 ret; - PjTxEnt *txEnt; - TRC3(pjDlmRbDataResume) - - RLOG_ARG0(L_DEBUG,DBG_RBID,pjRbCb->rbId, "pjDlmRbDataResume(pjRbCb ()) "); - - cmLListFirst(&pjRbCb->dlCb.txBuf.reEstPktQ); - while (cmLListCrnt(&pjRbCb->dlCb.txBuf.reEstPktQ)) - { - txEnt = (PjTxEnt *) cmLListNode(cmLListCrnt(&pjRbCb->dlCb.txBuf.reEstPktQ)); -#if (ERRCLASS & ERRCLS_DEBUG) /* KW_FIX */ - if(txEnt == NULLP) - { - RLOG_ARG0(L_ERROR,DBG_RBID,pjRbCb->rbId, - "pjDlmRbDataResume:Transmission Entity is NULL "); - /*ccpu00136858 : Void function returning RFAILED */ - RETVOID; - } -#endif /* (ERRCLASS & ERRCLS_DEBUG) */ -/* Free the existing PDU and cpy the SDU to PDU */ - -#ifdef FLAT_BUFFER_OPT -#ifndef XEON_SPECIFIC_CHANGES - { - /* Check whether the spacc q has space to hold - this packet.. else dropping */ - if(FALSE == (pjMsCheckSpaccQueue(FALSE))) - { - { - extern U32 spaccDropCount; - spaccDropCount++; - } - PJ_FREE_FLAT_BUF(pjCb[1],&(txEnt->fb)); - gPdcpStats.numPdcpSdusDiscarded++; - PJ_UPD_L2_DLDISC_STS(pjCb[1], pjRbCb); - - if(txEnt->pdu != NULL) - printf("PDU is not null while deletion"); - - if(txEnt->sdu != NULL) - printf("SDU is not null while deletion"); - pjDbmDelTxEnt(pjCb[1], &(pjRbCb->dlCb.txBuf), txEnt->count); - //txEnt->reEstPktEnt.node = NULLP; - //cmLListDelFrm(&pjRbCb->dlCb.txBuf.reEstPktQ, &txEnt->reEstPktEnt); - - cmLListFirst(&pjRbCb->dlCb.txBuf.reEstPktQ); - continue; - } - } -#endif -#endif -#ifdef FLAT_BUFFER_OPT - if(txEnt->sdu == NULLP) - { - PJ_FREE_BUF(txEnt->pdu); - } - else -#endif - if ( txEnt->pdu != txEnt->sdu ) - { - PJ_FREE_BUF(txEnt->pdu); - } - else - { - txEnt->pdu = NULLP; - } -#ifdef L2_PDCP_OPTMZ - txEnt->state = PJ_PDU_SUBMITTED; -#else - txEnt->state = PJ_SDU_RECEIVED; -#endif - /* Fix for ccpu00135798 */ - txEnt->reEstPktEnt.node = NULLP; - cmLListDelFrm(&pjRbCb->dlCb.txBuf.reEstPktQ, &txEnt->reEstPktEnt); -#ifndef L2_PDCP_OPTMZ - txEnt->sduSubmitEnt.node = (PTR)txEnt; - cmLListAdd2Tail(&pjRbCb->dlCb.txBuf.sduSubmitQ, &txEnt->sduSubmitEnt); -#else - if( pjRbCb->mode == PJ_DRB_AM) - { - txEnt->datCfmEnt.node = (PTR)txEnt; - cmLListAdd2Tail(&pjRbCb->dlCb.txBuf.datCfmQ, &txEnt->datCfmEnt); - } -#endif - - ret = pjDlmProcDrb(gCb, pjRbCb, txEnt); - if ( ret != ROK ) - { - RLOG_ARG0(L_ERROR,DBG_RBID,pjRbCb->rbId, - "pjDlmRbDataResume: pjDlmProcDrb Failed "); - } - cmLListFirst(&pjRbCb->dlCb.txBuf.reEstPktQ); - } - - pjDlmProcessDlPktQ(gCb,pjRbCb); - - RETVOID; -} - -#ifdef FLAT_BUFFER_OPT - -/** - * - * @brief - * - * Handler to process the SDU received from upper layer, form a PDU - * and send the PDU to the lower layer. - * - * @b Description: - * - * 1. This function places the SDU in the transmission buffer and performs - * Compression for DRB SDUs and Integrity Protection for SRB SDUs. @n - * 2. After compression/integrity protection, it performs ciphering and then - * constructs the PDU and sends it to the lower layer. @n - * 3. The first DL message of SRBs is not ciphered and is just integrity - * protected. @n - * 4. This function checks the UE CB control block to check the flag for the - * first DL message and performs only integrity protection and unsets - * the flag. @n - * - * @param[in] pjRbCb PDCP control block. - * @param[in] sdu SDU to be processed. - * @param[in] sduId SDU ID. - * - * @return S16 - * -# ROK - * -# RFAILED - */ - -#ifdef ANSI -PUBLIC S16 pjDlmProcessSdusFB -( -PjCb *gCb, /* !< Global control Block*/ -PjDlRbCb *pjRbCb, /* !< PDCP Control Block */ -FlatBuffer *sdu, /* !< SDU to be processed */ -U32 sduId, /* !< PDCP SDU ID */ -U32 count /* !< TX_HFN to be assigned */ -) -#else -PUBLIC S16 pjDlmProcessSdusFB(gCb, pjRbCb, sdu, sduId, count) -PjCb *gCb; /* !< Global control Block*/ -PjDlRbCb *pjRbCb; /* !< PDCP Control Block */ -FlatBuffer *sdu; /* !< SDU to be processed */ -U32 sduId; /* !< PDCP SDU ID */ -U32 count; /* !< TX_HFN to be assigned */ -#endif -{ - S16 ret; /* Return Value */ - PjTxEnt *txEnt; /* Transmission Entity for sdu*/ -#ifdef L2_PDCP_OPTMZ - U8 hashKey; /* Computed HashKey */ - PjBuf *buf; -#endif - - - TRC2(pjDlmProcessSdusFB) - -#ifndef ALIGN_64BIT - RLOG_ARG2(L_DEBUG,DBG_RBID,pjRbCb->rbId, - "pjDlmProcessSdusFB(pjRbCb(), sdu, sduId(%ld), count(%ld) )", - sduId, count); -#else - RLOG_ARG2(L_DEBUG,DBG_RBID,pjRbCb->rbId, - "pjDlmProcessSdusFB(pjRbCb(), sdu, sduId(%d), count(%d) )", - sduId, count); -#endif - - - ret = ROK; - - /* Allocate the transmission entity */ - PJ_ALLOC(gCb,txEnt, sizeof(PjTxEnt)); - -#if (ERRCLASS & ERRCLS_ADD_RES) - if (txEnt == NULLP) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - PJ_FREE_FLAT_BUF(gCb,sdu); - RETVALUE(RFAILED); - } -#endif /* ERRCLASS & ERRCLS_RES */ - - /* Update COUNT to the current count in dlCb*/ - - PJ_DLM_UPD_VAR(pjRbCb,txEnt->count); - PJ_DLM_GET_SN(pjRbCb,txEnt->count,txEnt->sn); - pjRbCb->dlCb.count = txEnt->count; - /* Fill TxEnt values */ - txEnt->state = PJ_SDU_RECEIVED; - txEnt->sduId = sduId; - /* The received buffer is stored in the SDU and the output from - * Compression/Ciphering is stored in the PDU. - */ - txEnt->fb = *sdu; - txEnt->pdu = NULLP; - txEnt->sdu = NULLP; - /* Insert TxEnt into the transmission buffer */ - /* kw005.201 added support for L2 Measurement */ -#ifndef L2_PDCP_OPTMZ - pjDbmInsTxEnt(gCb, &(pjRbCb->dlCb.txBuf), txEnt); -#else - /* Fix for NULL ciphering. For null ciphering add PDUs to sduSubmitQ*/ - if(pjRbCb->ueCb->secInfo.secAct && pjRbCb->ueCb->secInfo.cipherInfo.algoType != 0) - { - txEnt->datCfmEnt.node = NULLP; - txEnt->reEstPktEnt.node = NULLP; - txEnt->sduSubmitEnt.node = (PTR)NULLP; - - buf=&(pjRbCb->dlCb.txBuf); - hashKey = (U8)PJ_HASH_FN(buf, txEnt->count); /*KW_FIX*/ - - txEnt->lstEnt.node = (PTR)txEnt; - cmLListAdd2Tail(&buf->datQ[hashKey], &txEnt->lstEnt); - buf->numEntries ++; - - /* Dont add PDUs to datCfmQ in case of UM mode*/ - if (pjRbCb->mode == PJ_DRB_AM ) - { - txEnt->datCfmEnt.node = (PTR)txEnt; - cmLListAdd2Tail(&pjRbCb->dlCb.txBuf.datCfmQ, &txEnt->datCfmEnt); - } - - txEnt->state = PJ_PDU_SUBMITTED; - } - else - { - pjDbmInsTxEnt(gCb, &(pjRbCb->dlCb.txBuf), txEnt); - } -#endif - - /* Process the SDU based on rbType */ - { -#ifndef RGL_SPECIFIC_CHANGES -#ifdef MSPD - { - extern U32 dlrate_pju; - dlrate_pju += sdu->len; - } -#endif -#endif - ret = pjDlmProcDrb(gCb, pjRbCb, txEnt); - } - - RETVALUE(ret); -} -#endif - -/** -* - * @brief - * - * Handler to construct a data PDU/Control PDU. - * - * @b Description: - * - * 1. This function constructs the PDU header based on the SN length - * configured. @n - * 2. The header is inserted at the start of the PDU and - * the constructed PDU is returned to the calling function. @n - * - * @param[in] pjRbCb PDCP control block. - * @param[in] txEnt Transmission Entity. - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PRIVATE S16 pjDlmBldPdu -( -PjCb *gCb, -PjDlRbCb *pjRbCb, -PjTxEnt *txEnt -) -#else -PRIVATE S16 pjDlmBldPdu(gCb,pjRbCb,txEnt) -PjCb *gCb; -PjDlRbCb *pjRbCb; -PjTxEnt *txEnt; -#endif -{ - U32 hdr; /* Header field */ - S16 ret; /* Return Value */ - U32 numBytes; /* Number of bytes to be added to the PDU */ - - TRC3(pjDlmBldPdu) -#ifndef ALIGN_64BIT - PJDBGP(gCb,(PJ_DBGMASK_DLM | PJ_DBGMASK_BRIEF | PJ_DBGMASK_DL), - (gCb->init.prntBuf, "pjDlmBldPdu(pjRbCb, txEnt (%ld)) \n", txEnt->sduId)); -#else - PJDBGP(gCb,(PJ_DBGMASK_DLM | PJ_DBGMASK_BRIEF | PJ_DBGMASK_DL), - (gCb->init.prntBuf, "pjDlmBldPdu(pjRbCb, txEnt (%d)) \n", txEnt->sduId)); -#endif - - hdr = txEnt->sn; - ret = ROK; - numBytes = 2; /* for SRB it is 1 byte and even for 7 bit SN on DRB it is 1 byte */ - - //hdr = 0x234; - - /* Build a Data PDU */ - if ( pjRbCb->rbType != PJ_SRB ) - { - - /* The two byte header has the SN and MSB as '1' */ - if (pjRbCb->snLen == PJ_12_BIT_SN) - { - hdr |= PJ_DRB_12BIT_SN_HDR; - numBytes = 2; - } - else if (pjRbCb->snLen == PJ_18_BIT_SN) - { - hdr |= PJ_DRB_18BIT_SN_HDR; - numBytes = 3; - } - } - - /* Add the hdr(based on numBytes) at the start of the PDU */ - PJ_ADD_PRE_MSG( txEnt->pdu, hdr, numBytes, ret); - -#if (ERRCLASS & ERRCLS_ADD_RES) - if (ret != ROK) - { - RLOG_ARG1(L_ERROR, DBG_RBID, pjRbCb->rbId, - "SAddPreMsg failed SN [%u]", - txEnt->sn ); - RETVALUE(RFAILED); - } -#endif /* ERRCLASS & ERRCLS_RES */ - RETVALUE(ret); -} - -/** - * - * @brief - * - * Handler to Re-establish a SRB. - * - * @b Description: - * - * 1. This function is called when re-establishment request is - * received for a SRB. @n - * 2. The stored PDUs and SDUs are freed and the variables are reset. @n - * - * @param[in] pjRbCb PDCP control block. - * - */ - -#ifdef ANSI -PUBLIC Void pjDlmReEstSrb -( -PjCb *gCb, -PjDlRbCb *pjRbCb -) -#else -PUBLIC Void pjDlmReEstSrb(gCb, pjRbCb) -PjCb *gCb; -PjDlRbCb *pjRbCb; -#endif -{ - - TRC3(pjDlmResetSrb) - - RLOG_ARG0(L_DEBUG,DBG_RBID,pjRbCb->rbId, "pjDlmResetSrb(pjRbCb ()) "); - - - /* Stop the off-board and discard timer if running */ -#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)) - if (pjRbCb->dlCb.obdTmr.tmrEvnt == PJ_EVT_DL_OBD_TMR) - { - pjStopTmr(gCb, (PTR)pjRbCb, PJ_EVT_DL_OBD_TMR); - } -#endif - /* Clean up all the SDUs present */ - pjDbmTxDelAll(gCb, &(pjRbCb->dlCb.txBuf)); - - /* Reset the variables in rbCb */ - PJ_RESET_ALL_VAR(pjRbCb); - /*kw004.201 Adding of Missing Trace in LTE RLC PDCP*/ - RETVOID; -} - -/** - * - * @brief - * - * Handler to Re-establish a UM DRB. - * - * @b Description: - * - * 1. This function is called when re-establishment request is - * received for a UM DRB. @n - * 2. The stored PDUs are freed and the variables are reset. @n - * 3. The PDUs which were associated with a SN and were not sent - * to the lower layer are now sent with the new ciphering - * algorithm and keys. @n - * - * @param[in] pjRbCb PDCP control block. - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ - -#ifdef ANSI -PUBLIC S16 pjDlmReEstDrbUm -( -PjCb *gCb, -PjDlRbCb *pjRbCb -) -#else -PUBLIC S16 pjDlmReEstDrbUm(gCb,pjRbCb) -PjCb *gCb; -PjDlRbCb *pjRbCb; -#endif -{ - S16 ret; /* Return Value */ - PjTxEnt *txEnt; /* Transmission Entity */ - PjBuf tmpTxBuf; /* Tx Buffer */ - - TRC3(pjDlmReEstDrbUm) - - RLOG_ARG0(L_DEBUG,DBG_RBID,pjRbCb->rbId, "pjDlmReEstDrbUm(pjRbCb ()) "); - ret = ROK; /* KW_FIX */ - txEnt = NULLP; - - /* Reset all the variable */ - PJ_RESET_ALL_VAR(pjRbCb); -#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)) - /* Stop the off board timer if running */ - if (pjRbCb->dlCb.obdTmr.tmrEvnt == PJ_EVT_DL_OBD_TMR) - { - pjStopTmr(gCb, (PTR)pjRbCb, PJ_EVT_DL_OBD_TMR); - } -#endif - - if(pjRbCb->dlCb.txBuf.numEntries == 0) - { - RETVALUE(ROK); - } - - /* Create the new buffer list and store the old pointer in datQ */ - PJ_CREATE_NEW_LIST(gCb,pjRbCb, tmpTxBuf, ret); -#if (ERRCLASS & ERRCLS_ADD_RES) - if (ret != ROK) - { - RLOG0(L_FATAL, "Memory Allocation failed"); - RETVALUE(RFAILED); - } -#endif /* ERRCLASS & ERRCLS_RES */ - - /* Process all the existing PDUs as received from above layer */ - cmLListFirst(&tmpTxBuf.sduSubmitQ); - while (cmLListCrnt(&tmpTxBuf.sduSubmitQ)) - { - U8 hashKey = 0; - txEnt = (PjTxEnt *) cmLListNode(cmLListCrnt(&tmpTxBuf.sduSubmitQ)); - /* Assign the new SN, TX_HFN and insert in the new transmission - * buffer. - */ - if ( txEnt != NULLP ) - { -#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)) - if ( txEnt->pdu != txEnt->sdu ) - { - PJ_FREE_BUF(txEnt->pdu); - } - else - { - txEnt->pdu = NULLP; - } -#endif - hashKey = (U8)PJ_HASH_FN((&tmpTxBuf), txEnt->count); - PJ_DLM_UPD_VAR(pjRbCb,txEnt->count); - PJ_DLM_GET_SN(pjRbCb,txEnt->count,txEnt->sn); - pjRbCb->dlCb.count = txEnt->count; - txEnt->state = PJ_SDU_RECEIVED; - txEnt->pdu = NULLP; - - cmLListDelFrm(&tmpTxBuf.datQ[hashKey], &txEnt->lstEnt); - cmLListDelFrm(&tmpTxBuf.sduSubmitQ, &txEnt->sduSubmitEnt); - - tmpTxBuf.numEntries --; - - pjDbmInsTxEnt(gCb, &(pjRbCb->dlCb.txBuf), txEnt); - - txEnt->reEstPktEnt.node = (PTR)txEnt; - cmLListAdd2Tail(&pjRbCb->dlCb.txBuf.reEstPktQ, &txEnt->reEstPktEnt); - - txEnt->sduSubmitEnt.node=NULLP; - cmLListDelFrm(&pjRbCb->dlCb.txBuf.sduSubmitQ, &txEnt->sduSubmitEnt); - } - cmLListFirst(&tmpTxBuf.sduSubmitQ); - } - /* Free up the old transmission buffer */ - pjDbmTxDeInit(gCb,&tmpTxBuf); - RETVALUE(ret); -} - -/** - * - * @brief - * - * Handler to Re-establish a AM DRB. - * - * @b Description: - * - * 1. This function is called when re-establishment request is - * received for a AM DRB. @n - * 2. The stored PDUs are freed. @n - * 3. The PDUs which were not submitted to the lower - * layer and for which a confirm has not been received - * are now sent with the new ciphering algorithm and keys. @n - * - * @param[in] pjRbCb PDCP control block. - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 pjDlmReEstDrbAm -( -PjCb *gCb, -PjDlRbCb *pjRbCb -) -#else -PUBLIC S16 pjDlmReEstDrbAm(gCb,pjRbCb) -PjCb *gCb; -PjDlRbCb *pjRbCb; -#endif -{ - PjTxEnt *txEnt; - - TRC3(pjDlmReEstDrbAm) - - RLOG_ARG0(L_DEBUG,DBG_RBID,pjRbCb->rbId, "pjDlmReEstDrbAm(pjRbCb ()) "); - - - if (pjRbCb->dlCb.txBuf.numEntries == 0) - { - RETVALUE(ROK); - } - - cmLListFirst(&pjRbCb->dlCb.txBuf.datCfmQ); - while (cmLListCrnt(&pjRbCb->dlCb.txBuf.datCfmQ)) - { - txEnt = (PjTxEnt *) cmLListNode(cmLListCrnt(&pjRbCb->dlCb.txBuf.datCfmQ)); -#if (ERRCLASS & ERRCLS_DEBUG) /* KW_FIX */ - if(txEnt == NULLP) - { - RLOG_ARG0(L_ERROR,DBG_RBID,pjRbCb->rbId, - "pjDlmReEstDrbAm:Transmission Entity is NULL "); - RETVALUE(RFAILED); - } -#endif /* (ERRCLASS & ERRCLS_DEBUG) */ - if (txEnt != NULLP) - { - txEnt->reEstPktEnt.node = (PTR)txEnt; - cmLListAdd2Tail(&pjRbCb->dlCb.txBuf.reEstPktQ, &txEnt->reEstPktEnt); - pjTotDlPckCntPerCell--; - } - txEnt->datCfmEnt.node = NULLP; - cmLListDelFrm(&pjRbCb->dlCb.txBuf.datCfmQ, &txEnt->datCfmEnt); - cmLListFirst(&pjRbCb->dlCb.txBuf.datCfmQ); - } - - cmLListFirst(&pjRbCb->dlCb.txBuf.sduSubmitQ); - while (cmLListCrnt(&pjRbCb->dlCb.txBuf.sduSubmitQ)) - { - txEnt = (PjTxEnt *) cmLListNode(cmLListCrnt(&pjRbCb->dlCb.txBuf.sduSubmitQ)); - if (txEnt != NULLP) /*KW_FIX : ccpu00136902*/ - { - txEnt->reEstPktEnt.node = (PTR)txEnt; - cmLListAdd2Tail(&pjRbCb->dlCb.txBuf.reEstPktQ, &txEnt->reEstPktEnt); - txEnt->sduSubmitEnt.node=NULLP; - cmLListDelFrm(&pjRbCb->dlCb.txBuf.sduSubmitQ, &txEnt->sduSubmitEnt); - cmLListFirst(&pjRbCb->dlCb.txBuf.sduSubmitQ); - } - else - { - RLOG_ARG0(L_ERROR,DBG_RBID,pjRbCb->rbId, "This should not be hit "); - break; - } - } - - RETVALUE(ROK); -} - -/** - * - * @brief - * - * Handler to send data confirmation to RRC. - * - * @b Description: - * - * 1. This function is called when a status indication or a confirm is - * received from the lower layer. @n - * 2. The confirm type can be a success or failure. @n - * 3. The corresponding SDUs and PDUs are cleaned up and - * if cfmReqd is configured, a confirm is sent to the upper layer. @n - * - * @param[in] pjRbCb PDCP control block. - * @param[in] staInd Status Indication Information. - * @param[in] cfmType Confirm Type can be SUCCESS or FAILURE. - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ - -U32 pjRxCfm; - -#ifdef ANSI -PUBLIC S16 pjDlmProcessCfm -( -PjCb *gCb, -PjDlRbCb *pjRbCb, -PjDatCfm *pjDatCfm, -U8 cfmType -) -#else -PUBLIC S16 pjDlmProcessCfm(gCb,pjRbCb,pjDatCfm,cfmType) -PjCb *gCb; -PjDlRbCb *pjRbCb; -PjDatCfm *pjDatCfm; -U8 cfmType; -#endif -{ - PjuDatCfmInfo *datCfm; /* Data Cfm to be sent to upper layer */ - U32 cnt; /* Counter for number of SDUs in datCfm*/ - U16 datCfmCnt; /* Counter for number of SDUs in datCfm*/ /*KW_FIX*/ - PjPjuSapCb *pjuSap; /* Upper Sap of PDCP User */ - CmLtePdcpId *pdcpId; /* PDCP ID */ - PjTxEnt *txEnt; /* Transmission entity */ - - TRC3(pjDlmProcessCfm) - - gCb->pjPerfSts.pjSduRcvCnt += pjDatCfm->numSdu; - - pdcpId = NULLP; - cnt = 0; - pjuSap = NULLP; - datCfm = NULLP; - txEnt = NULLP; - - /* If cfmReqd flag is sent a confirmation is sent to the above layer. - * For each SDU, get the sduId and status and fill in the datCfm - * structure and discard the txEnt. Also update cfmExp count. - */ - if ( (pjRbCb->dlCb.cfmReqd) || (PJ_CFM_NOK == cfmType)) - { - PjuDatCfmInfo datCfmTmp; - CmLtePdcpId pdcpIdTmp; - datCfm = &datCfmTmp; - pdcpId = &pdcpIdTmp; - pdcpId->rbId = pjRbCb->rbId; - pdcpId->rbType = pjRbCb->rbType; - pdcpId->ueId = pjRbCb->ueCb->key.ueId; - pdcpId->cellId = pjRbCb->ueCb->key.cellId; - - if (pjRbCb->rbType == PJ_SRB) - pjuSap = &(gCb->u.dlCb->pjuSap[PJ_SRB_SAP]); - else - pjuSap = &(gCb->u.dlCb->pjuSap[PJ_DRB_SAP]); - - datCfmCnt = 0; - for ( cnt = 0; cnt < pjDatCfm->numSdu; cnt++) - { - txEnt = (PjTxEnt *)pjDbmGetTxEnt(gCb,&(pjRbCb->dlCb.txBuf), - pjDatCfm->sduId[cnt]); - if ( txEnt != NULLP ) - { - datCfm->cfmSta[datCfmCnt].sduId = txEnt->sduId; - /* RLC_DL_MAX_RETX fix */ - if (PJ_CFM_OK != cfmType) - { - datCfm->cfmSta[datCfmCnt].status = PJU_RLC_TRANS_FAIL; - } - else - { - datCfm->cfmSta[datCfmCnt].status = cfmType; - } - - datCfm->cfmSta[datCfmCnt].status = cfmType; - datCfmCnt ++; - pjDbmDelTxEnt(gCb, &(pjRbCb->dlCb.txBuf), txEnt->count); - } - } - datCfm->numSdus = datCfmCnt; - if(datCfm->numSdus) - { - /* If trace flag is enabled send the trace indication */ - if(gCb->init.trc == TRUE) - { - /* Populate the trace params */ - pjLmmSendTrc(gCb, EVTPJUDATCFM, NULLP); - } - - PjUiPjuDatCfm(&pjuSap->pst, pjuSap->suId, pdcpId, datCfm); - } - } - /* If cfmReqd is not set, discard the txEnts and update the cfmExp count */ - else - { - for ( cnt = 0; cnt < pjDatCfm->numSdu; cnt++) - { - pjDbmDelTxEnt(gCb, &(pjRbCb->dlCb.txBuf), pjDatCfm->sduId[cnt]); - } - - } - - RETVALUE(ROK); -} - -/** - * - * @brief - * - * Handler to send process the status report. - * - * @b Description: - * - * 1. This function is called when a status report is received from the - * peer. @n - * 2. This function process the status report and sends a confirmation - * to the above layer and removes the PDUs and SDUs for which positive - * acknowledgement is received. @n - * - * @param[in] pjRbCb PDCP control block. - * @param[in] staPdu Status report. - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ - -#ifdef ANSI -PUBLIC S16 pjDlmHndlStaRep -( -PjCb *gCb, -PjDlRbCb *pjRbCb, -PjSn fmc, -Buffer *staPdu -) -#else -PUBLIC S16 pjDlmHndlStaRep(gCb,pjRbCb,fmc,staPdu) -PjCb *gCb; -PjDlRbCb *pjRbCb; -PjSn fmc; -Buffer *staPdu; -#endif -{ - PjuDatCfmInfo *datCfm; /* Dat Cfm to be sent to the upper layer */ - PjuDatCfmInfo datCfmTmp; /* Tmp variable allocated to assign local memory to the datCfm pointer */ - CmLtePdcpId pdcpIdTmp; /* Tmp variable allocated to assign local memory to the pdcpId pointer */ - S16 ret; /* Return Value */ - PjPjuSapCb *pjuSap; /* PJU SAP Control Block */ - CmLtePdcpId *pdcpId; /* PDCP ID */ - U32 bitPos; /* Bit position in the Status PDU */ - U8 cnt; /* Counter for the bits in a byte */ - U8 sduSta; /* SDU Status of reception at the Peer */ - PjTxEnt *txEnt; /* Transmission entity */ - U8 byte; /* One Byte of a Status Pdu */ - MsgLen bMapLen; /* StaPdu Length in bytes */ - PjSn count; /* count of the PDU */ - - TRC3(pjDlmHndlStaRep) - - RLOG_ARG1(L_DEBUG,DBG_RBID,pjRbCb->rbId, "pjDlmHndlStaRep(pjRbCb (), fmc (%lu), staPdu) ",fmc); - - datCfm = NULLP; - ret = ROK; - pjuSap = NULLP; - pdcpId = NULLP; - - - /* Allocate for datCfm structure is cfmReqd is set */ - if ( pjRbCb->dlCb.cfmReqd ) - { - datCfm = &datCfmTmp; - } - - /* Fills the confirm information for all the PDUs whose COUNT < COUNT(FMC) - * and sets cfmExp to fmc - */ - pjDlmDelTxEntUptoFmc(gCb, pjRbCb, fmc, datCfm); - - - cnt = 0; - bitPos = 1; - byte = 0; - bMapLen = 0; - SFndLenMsg(staPdu, &bMapLen); - - /* Read one byte at a time from Status PDU */ - while ( bMapLen != 0 ) - { - ret = SRemPreMsg(&byte,staPdu); -#if (ERRCLASS & ERRCLS_ADD_RES) - if (ret != ROK) - { - RLOG0(L_ERROR, "SRemPreMsg Failed for staPdu"); - PJ_FREE_BUF(staPdu); - RETVALUE(RFAILED); - } -#endif /* ERRCLASS & ERRCLS_RES */ - - /* Check if each bit in a byte is set or not. - * If cfmReqd is set fill in the cfm info. - * Discard the txEnt if the bit is set to 1. - */ - for ( cnt = 0; cnt < PJ_BYTE_LEN; cnt++, bitPos++ ) - { - sduSta = (byte << cnt) & PJ_FIRST_BIT; - if (sduSta) - { - count = (fmc + bitPos) % PJ_TX_BUF_LEN; - txEnt = (PjTxEnt *)pjDbmGetTxEnt(gCb, &(pjRbCb->dlCb.txBuf), count); - if ( txEnt != NULLP ) - { - if ((pjRbCb->dlCb.cfmReqd)&& (datCfm->numSdus < PJU_MAX_SDU_CFM)) - { - - datCfm->cfmSta[datCfm->numSdus].sduId = txEnt->sduId; - datCfm->cfmSta[datCfm->numSdus].status = sduSta; - datCfm->numSdus++;; - } - pjDbmDelTxEnt(gCb, &(pjRbCb->dlCb.txBuf), txEnt->count); - } - } - } - bMapLen--; - } - /* Send a confirmation to the upper layer */ - if ((pjRbCb->dlCb.cfmReqd) && (datCfm->numSdus > 0)) - { - pdcpId = &pdcpIdTmp; - - pdcpId->rbId = pjRbCb->rbId; - pdcpId->rbType = pjRbCb->rbType; - pdcpId->ueId = pjRbCb->ueCb->key.ueId; - pdcpId->cellId = pjRbCb->ueCb->key.cellId; - - pjuSap = &gCb->u.dlCb->pjuSap[PJ_DRB_SAP]; - /* If trace flag is enabled send the trace indication */ - if(gCb->init.trc == TRUE) - { - /* Populate the trace params */ - pjLmmSendTrc(gCb, EVTPJUDATCFM, NULLP); - } - PjUiPjuDatCfm(&pjuSap->pst, pjuSap->suId, pdcpId, datCfm); - } - - PJ_FREE_BUF(staPdu); - - RETVALUE(ret); -} - -/** - * - * @brief - * - * Handler to forward the downlink data to the upper layer. - * - * @b Description: - * - * 1. This function is used to send the downlink data to the upper layer - * during handover. @n - * 2. The unacknowledged data SDUs are sent to the upper - * layer. @n - * - * @param[in] pjRbCb PDCP control block. - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ - -#ifdef ANSI -PUBLIC S16 pjDlmReEstHoDrbAm -( -PjCb *gCb, -PjDlRbCb *pjRbCb -) -#else -PUBLIC S16 pjDlmReEstHoDrbAm(gCb,pjRbCb) -PjCb *gCb; -PjDlRbCb *pjRbCb; -#endif -{ - TRC3(pjDlmReEstHoDrbAm) - - RLOG_ARG0(L_DEBUG,DBG_RBID,pjRbCb->rbId, "pjDlmReEstHoDrbAm(pjRbCb ()) "); - - - pjRbCb->pktAdmitCnt = 0; - pjRbCb->ueCb->hoInfo->hoCfmInfo[pjRbCb->rbId].pres = TRUE; - pjRbCb->ueCb->hoInfo->hoCfmInfo[pjRbCb->rbId].rbId = pjRbCb->rbId; - pjRbCb->ueCb->hoInfo->hoCfmInfo[pjRbCb->rbId].dir = PJ_DIR_DL; - pjRbCb->ueCb->hoInfo->hoCfmInfo[pjRbCb->rbId].count = pjRbCb->dlCb.count + 1; - - RETVALUE(ROK); -} - - -/** - * - * @brief - * - * Handler to forward the downlink data to the upper layer. - * - * @b Description: - * - * 1. This function is used to send the downlink data to the upper layer - * during handover. @n - * 2. The unacknowledged data SDUs are sent to the upper - * layer. @n - * - * @param[in] pjRbCb PDCP control block. - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ - -#ifdef ANSI -PUBLIC S16 pjDlmStartDataFrwdPerRb -( -PjCb *gCb, -PjDlRbCb *pjRbCb -) -#else -PUBLIC S16 pjDlmStartDataFrwdPerRb(gCb,pjRbCb) -PjCb *gCb; -PjDlRbCb *pjRbCb; -#endif -{ - - U32 numSdu =0; - U16 count; /*KW_FIX*/ - U32 numSduCnt =0,numSduTx = 0; - PjTxEnt *txEnt = NULLP; - PjuDatFwdIndInfo *datFwdInd = NULLP; - PjPjuSapCb *pjuSap; - PjDlPkt *pkt = NULLP; - - TRC3(pjDlmStartDataFrwdPerRb) - - RLOG_ARG0(L_DEBUG,DBG_RBID,pjRbCb->rbId, "pjDlmStartDataFrwdPerRb(pjRbCb ()) "); - - pjuSap = &(gCb->u.dlCb->pjuSap[PJ_DRB_SAP]); - /* Update hoCfmInfo, used to fill SduStaCfm */ - if(pjRbCb->dlCb.txNext == 0) - { - // PJ_ALLOC(gCb,datFwdInd, sizeof(PjuDatFwdIndInfo)); - if(SGetSBuf(pjuSap->pst.region,pjuSap->pst.pool,(Data **)&datFwdInd, - sizeof (PjuDatFwdIndInfo)) != ROK) - { -#if (ERRCLASS & ERRCLS_ADD_RES) - if (datFwdInd == NULLP) - { - /*ccpu00136858 */ - RLOG0(L_FATAL, "Memory Allocation failed."); - } -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - RETVALUE(RFAILED); - } - datFwdInd->dir = PJ_DIR_DL; - datFwdInd->numSdus = 0; - datFwdInd->isLastDatFwdInd = TRUE; - - /* sending DatFwdInd even if numSdu is zero */ - pjUtlDlSndDatFwdInd(gCb,pjRbCb, datFwdInd); - RETVALUE(ROK); - } - - /* Find the total count of the txEnts present */ - numSdu = pjRbCb->dlCb.txBuf.numEntries + pjRbCb->dlCb.dlPktQ.count; - numSduCnt = numSdu; - - /* This was added from Hotfix branch when Data Fwding was not supported */ - - cmLListFirst(&pjRbCb->dlCb.txBuf.datCfmQ); - cmLListFirst(&pjRbCb->dlCb.txBuf.sduSubmitQ); - cmLListFirst(&pjRbCb->dlCb.dlPktQ); - - -while(numSduCnt >0) -{ - count = 0; - /* For BRDCM PJ_FWD_MAX_SDU_CNT = 16, for MSPD PJ_FWD_MAX_SDU_CNT=1 */ - - if(numSduCnt > PJ_FWD_MAX_SDU_CNT) - { - numSduTx = PJ_FWD_MAX_SDU_CNT; - numSduCnt = numSduCnt - PJ_FWD_MAX_SDU_CNT; - } - else - { - numSduTx = numSduCnt; - numSduCnt = 0; - } - - if(SGetSBuf(pjuSap->pst.region,pjuSap->pst.pool,(Data **)&datFwdInd, - sizeof (PjuDatFwdIndInfo)) != ROK) - { - /*ccpu00136858 */ - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } - - if(SGetSBuf(pjuSap->pst.region,pjuSap->pst.pool,(Data **)&datFwdInd->datFwdInfo, - (sizeof(PjuDatFwdInfo) * numSduTx)) != ROK) - { - /* Free memory for DatFwdInfo */ - PJ_PST_FREE(pjuSap->pst.region, pjuSap->pst.pool,datFwdInd->datFwdInfo, - numSdu * sizeof(PjuDatFwdIndInfo)); - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } - - while (numSduTx>0) - { - - if(NULLP != cmLListCrnt(&pjRbCb->dlCb.txBuf.datCfmQ)) - { - txEnt = (PjTxEnt *) cmLListNode(cmLListCrnt(&pjRbCb->dlCb.txBuf.datCfmQ)); - datFwdInd->datFwdInfo[count].sduId = txEnt->sduId; - datFwdInd->datFwdInfo[count].sn = txEnt->sn; -#ifdef SS_RBUF - datFwdInd->datFwdInfo[count].sdu = txEnt->sdu; -#else -#ifdef FLAT_BUFFER_OPT - if(txEnt->sdu == NULLP) - { - pjUtlCopyFbToBuf(gCb, &(txEnt->fb), &(datFwdInd->datFwdInfo[count].sdu)); - } - else -#endif - { - SCpyMsgMsg(txEnt->sdu, 0, 0, &datFwdInd->datFwdInfo[count].sdu); - } -#endif - cmLListNext(&pjRbCb->dlCb.txBuf.datCfmQ); - numSduTx--; - count++; - continue; - } - - - if(NULLP != cmLListCrnt(&pjRbCb->dlCb.txBuf.sduSubmitQ)) - { - txEnt = (PjTxEnt *) cmLListNode(cmLListCrnt(&pjRbCb->dlCb.txBuf.sduSubmitQ)); - datFwdInd->datFwdInfo[count].sduId = txEnt->sduId; - datFwdInd->datFwdInfo[count].sn = txEnt->sn; -#ifdef SS_RBUF - datFwdInd->datFwdInfo[count].sdu = txEnt->sdu; -#else -#ifdef FLAT_BUFFER_OPT - if(txEnt->sdu == NULLP) - { - pjUtlCopyFbToBuf(gCb, &(txEnt->fb), &(datFwdInd->datFwdInfo[count].sdu)); - } - else -#endif - { - SCpyMsgMsg(txEnt->sdu, 0, 0, &datFwdInd->datFwdInfo[count].sdu); - } -#endif - cmLListNext(&pjRbCb->dlCb.txBuf.sduSubmitQ); - numSduTx--; - count++; - continue; - } - - - if(NULLP != cmLListCrnt(&pjRbCb->dlCb.dlPktQ)) - { - pkt = (PjDlPkt *) cmLListNode(cmLListCrnt(&pjRbCb->dlCb.dlPktQ)); - datFwdInd->datFwdInfo[count].sduId = pkt->sduId; - datFwdInd->datFwdInfo[count].sn = pkt->sn; -#ifdef SS_RBUF - datFwdInd->datFwdInfo[count].sdu = pkt->pdu; -#else -#ifdef FLAT_BUFFER_OPT - if(pkt->pdu == NULLP) - { - pjUtlCopyFbToBuf(gCb, &(pkt->fb), &(datFwdInd->datFwdInfo[count].sdu)); - } - else -#endif - { - SCpyMsgMsg(pkt->pdu, 0, 0, &datFwdInd->datFwdInfo[count].sdu); - } -#endif - - cmLListNext(&pjRbCb->dlCb.dlPktQ); - numSduTx--; - count++; - } - - } - datFwdInd->dir = PJ_DIR_DL; - datFwdInd->numSdus = count; - datFwdInd->isLastDatFwdInd = FALSE; - pjUtlDlSndDatFwdInd(gCb,pjRbCb, datFwdInd); -} - - pjuSap = &(gCb->u.dlCb->pjuSap[PJ_DRB_SAP]); - if(SGetSBuf(pjuSap->pst.region,pjuSap->pst.pool,(Data **)&datFwdInd, - sizeof (PjuDatFwdIndInfo)) != ROK) - { - /*ccpu00136858 */ - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } - datFwdInd->dir = PJ_DIR_DL; - datFwdInd->numSdus = 0; - datFwdInd->isLastDatFwdInd = TRUE; - - /* sending DatFwdInd even if numSdu is zero */ - pjUtlDlSndDatFwdInd(gCb,pjRbCb, datFwdInd); - RETVALUE(ROK); - -} - - -/** - * - * @brief - * - * Handler to process the forwarded data received from upper layer. - * - * @b Description: - * - * 1. This function is used to process the SDUs received from the upper - * layer as part of handover. @n - * 2. This function calls pjDlmProcessSdus function with the correct - * SN and HFN values. @n - * - * @param[in] gCb PDCP Instance control block. - * @param[in] pjRbCb Rb control block. - * @param[in] datFwdReq Data Forward Info. - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 pjDlmHndlDatFwdReq -( -PjCb *gCb, -PjDlRbCb *pjRbCb, -PjuDatFwdReqInfo *datFwdReq -) -#else -PUBLIC S16 pjDlmHndlDatFwdReq(gCb,pjRbCb,datFwdReq) -PjCb *gCb; -PjDlRbCb *pjRbCb; -PjuDatFwdReqInfo *datFwdReq; -#endif -{ - - U32 sduCount; /* Number of received SDUs */ - U32 numSdus; /* Counter for SDUs */ - //U32 txHfn; /* TX_HFN of a SDU */ - PjTxEnt *txEnt; /* Transmission Entity */ -#ifdef L2_PDCP_OPTMZ - U8 hashKey; /* Computed HashKey */ - PjBuf *buf; -#endif - - TRC3(pjDlmHdlDatFwdReq) - - RLOG_ARG1(L_DEBUG,DBG_RBID,pjRbCb->rbId, "pjDlmHndlDatFwdReq(pjRbCb (),datFwdReq(%d)) ", - datFwdReq->numSdus); - - sduCount = datFwdReq->numSdus; - //txHfn = pjRbCb->dlCb.txHfn; - numSdus = 0; - - /* FIXME is this required , TC 11.10 */ - /* FIXME NOT a proper fix also */ - if(pjRbCb->dlCb.txNext == 0) - { - //pjRbCb->dlCb.nxtTxSn = datFwdReq->datFwdInfo[sduCount - 1].sn; - pjRbCb->dlCb.count = datFwdReq->datFwdInfo[sduCount - 1].sn; - } - gCb->pjGenSts.numPktsRcvd += sduCount; - /* Process each of the SDUs with received SN and sduId */ - for ( numSdus = 0; numSdus < sduCount; numSdus++ ) - { - /* - The variables nxtTxSn and COUNT are assumed to be - already updated in dlCb to continue with the - transmission ( in the target eNodeB ). - */ - PJ_ALLOC(gCb,txEnt, sizeof(PjTxEnt)); - -#if (ERRCLASS & ERRCLS_ADD_RES) - if (txEnt == NULLP) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - PJ_FREE_BUF(datFwdReq->datFwdInfo[numSdus].sdu); - RETVALUE(RFAILED); - } -#endif /* ERRCLASS & ERRCLS_RES */ - - - /* Fill TxEnt values */ - txEnt->sn = datFwdReq->datFwdInfo[numSdus].sn; - txEnt->sduId = datFwdReq->datFwdInfo[numSdus].sduId; - txEnt->state = PJ_SDU_RECEIVED; - txEnt->sdu = datFwdReq->datFwdInfo[numSdus].sdu; - txEnt->pdu = NULLP; - -#ifndef L2_PDCP_OPTMZ - pjDbmInsTxEnt(gCb, &(pjRbCb->dlCb.txBuf), txEnt); -#else - /* Fix for NULL ciphering. For null ciphering add PDUs to sduSubmitQ*/ - if(pjRbCb->ueCb->secInfo.secAct && pjRbCb->ueCb->secInfo.cipherInfo.algoType != 0) - { - txEnt->datCfmEnt.node = NULLP; - txEnt->reEstPktEnt.node = NULLP; - txEnt->sduSubmitEnt.node = (PTR)NULLP; - - buf=&(pjRbCb->dlCb.txBuf); - hashKey = (U8)PJ_HASH_FN(buf, txEnt->count); /*KW_FIX*/ - - txEnt->lstEnt.node = (PTR)txEnt; - cmLListAdd2Tail(&buf->datQ[hashKey], &txEnt->lstEnt); - buf->numEntries ++; - - /* Dont add PDUs to datCfmQ in case of UM mode*/ - if (pjRbCb->mode == PJ_DRB_AM ) - { - txEnt->datCfmEnt.node = (PTR)txEnt; - cmLListAdd2Tail(&pjRbCb->dlCb.txBuf.datCfmQ, &txEnt->datCfmEnt); - } - - txEnt->state = PJ_PDU_SUBMITTED; - } - else - { - pjDbmInsTxEnt(gCb, &(pjRbCb->dlCb.txBuf), txEnt); - } -#endif - pjDlmProcDrb(gCb,pjRbCb,txEnt); - - } - - - RETVALUE(ROK); -} - -/** - * - * @brief - * - * Handler to construct a PDU and send it to the lower layer. - * - * @b Description: - * - * 1. This function is used to deliver a PDU to the lower layer.@n - * 2. It calls pjDlmBldPdu function and sends the PDU to - * the lower layer using pjDlmSendDatReq function. @n - * 3. The txBuf is freed up if the cfmReqd is not configured or - * if the rbType is UM.@n - * - * @param[in] pjRbCb PDCP control block. - * @param[in] txEnt Transmission Entity. - * @param[in] mBuf The PDU to be transmitted. - * @param[in] pduType Type of the PDU. - * @return S16 - * -# ROK - * -# RFAILED - */ - -#ifdef ANSI -PUBLIC S16 pjDlmDeliverPdu -( -PjCb *gCb, -PjDlRbCb *pjRbCb, -PjTxEnt *txEnt -) -#else -PUBLIC S16 pjDlmDeliverPdu(gCb,pjRbCb,txEnt) -PjCb *gCb; -PjDlRbCb *pjRbCb; -PjTxEnt *txEnt; -#endif -{ - S16 ret; /* Return Value */ - S16 ret1; /* Return Value */ - PjTxEnt *txFirstEntity; - - - TRC3(pjDlmDeliverPdu) - - - ret = ROK; - - - /* Constructs a PDU */ - if ( txEnt->state != PJ_PDU_CONSTRUCTED ) - { - ret = pjDlmBldPdu(gCb, pjRbCb, txEnt); - } - - if ( ret != ROK ) - { - RLOG_ARG2(L_ERROR, DBG_RBID, pjRbCb->rbId, "PDCP DL Build PDU Failed SN [%u] , Count [%lu]", - txEnt->sn, txEnt->count); - PJ_UPD_DL_VAR(gCb, pjRbCb, txEnt->count); - if ( pjRbCb->dlCb.cfmReqd) - { - PJ_SND_CFM(gCb,pjRbCb, txEnt, PJ_PDU_CONSTRUCT_FAILED); - } - RETVALUE(RFAILED); - } - txEnt->state = PJ_PDU_CONSTRUCTED; - - /* Deliver the PDU to the lower layer only if it is nxtToSub. - * Also deliver the consecutive PDUs if they are constructed. - * If not just store the PDU. - */ - cmLListFirst(&pjRbCb->dlCb.txBuf.sduSubmitQ); - - while (cmLListCrnt(&pjRbCb->dlCb.txBuf.sduSubmitQ)) - { - txFirstEntity = (PjTxEnt *) cmLListNode(cmLListCrnt(&pjRbCb->dlCb.txBuf.sduSubmitQ)); - if (txFirstEntity->state == PJ_PDU_CONSTRUCTED ) - { - ret1 = - pjDlmSendDatReq(gCb, pjRbCb, txFirstEntity->count, - txFirstEntity->pdu); - gCb->pjGenSts.txPdus++; - txFirstEntity->pdu = NULLP; - txFirstEntity->state = PJ_PDU_SUBMITTED; - - txFirstEntity->sduSubmitEnt.node = (PTR)NULLP; - cmLListDelFrm(&pjRbCb->dlCb.txBuf.sduSubmitQ, &txFirstEntity->sduSubmitEnt); - - if ((pjRbCb->mode == PJ_DRB_UM ) - || (!(pjRbCb->dlCb.cfmReqd) && pjRbCb->rbType == PJ_SRB) - || (ret1 != ROK)) - { - pjDbmDelTxEnt(gCb, &(pjRbCb->dlCb.txBuf), txFirstEntity->count); - } - else - { - /* Add to the DatCfm Q */ - txFirstEntity->datCfmEnt.node = (PTR)txEnt; - cmLListAdd2Tail(&pjRbCb->dlCb.txBuf.datCfmQ, &txFirstEntity->datCfmEnt); - pjTotDlPckCntPerCell++; - } - cmLListFirst(&pjRbCb->dlCb.txBuf.sduSubmitQ); - } - else - { - break; - } - } - - RETVALUE(ret); -} -/** -* - * @brief - * - * Handler to construct a process a SRB SDU. - * - * @b Description: - * - * 1. This function performs integrity protection if it is - * configured. @n - * 2. The first DL message of SRBs is not ciphered and is just integrity - * protected. @n - * 3. This function checks the UE CB control block to check the flag for the - * first DL message and performs only integrity protection and unsets - * the flag. @n - * 4. Ciphering is performed if applicable. - * 5. The PDU is constructed and then delivered to the lower - * layer. @n - * - * @param[in] pjRbCb PDCP control block. - * @param[in] txEnt Transmission Entity. - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ - - -#ifdef ANSI -PUBLIC S16 pjDlmProcSrb -( -PjCb *gCb, -PjDlRbCb *pjRbCb, -PjTxEnt *txEnt -) -#else -PUBLIC S16 pjDlmProcSrb(gCb, pjRbCb, txEnt) -PjCb *gCb; -PjDlRbCb *pjRbCb; -PjTxEnt *txEnt; -#endif -{ - S16 ret; /* Return Value */ - U32 macI; /* MAC-I value to be padded to the PDU */ - Buffer *pdu; /* Pointer for the PDU in txEnt */ - - TRC3(pjDlmProcSrb) -#ifndef ALIGN_64BIT - RLOG_ARG1(L_DEBUG,DBG_RBID,pjRbCb->rbId, "pjDlmProcSrb(pjRbCb (), txEnt(%ld)) ", - txEnt->count); -#else - RLOG_ARG1(L_DEBUG,DBG_RBID,pjRbCb->rbId, "pjDlmProcSrb(pjRbCb (), txEnt(%d)) ", - txEnt->count); -#endif - - - pdu = txEnt->sdu; - macI = 0; - ret = ROK; - - /* Perform security operation only if configured */ - if ( pjRbCb->ueCb->secInfo.secAct && pjRbCb->ueCb->secInfo.intInfo.algoType != 0) - { - /* Perform integrity/ciphering */ - ret = pjDlmHdlIntProt(gCb, pjRbCb, txEnt); - if ( ret != ROK ) - { - RLOG_ARG2(L_ERROR, DBG_RBID, pjRbCb->rbId, "Integrity Prot failed SN [%u] TXNEXT [%lu]", txEnt->sn, txEnt->count); - } - } - else - { - /* If security is not configured, pad the PDU with 4 bytes - * and deliver to the lower layer - */ - PJ_PACK_MACI(pdu, macI); - ret = pjDlmHdlCiph(gCb, pjRbCb, txEnt); -/* ret = pjDlmDeliverPdu(gCb, pjRbCb, txEnt);*/ - } - - RETVALUE(ret); -} - -/** - * - * @brief - * - - * Handler to construct a process a DRB SDU. - * - * @b Description: - * - * 1. This function performs header compression if it is - * configured. @n - * 2. If security is configured, ciphering is performed. @n - * 3. The PDU is constructed and then delivered to the lower - * layer. @n - * - * @param[in] pjRbCb PDCP control block. - * @param[in] txEnt Transmission Entity. - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ - -#ifdef ANSI -PUBLIC S16 pjDlmProcDrb -( -PjCb *gCb, -PjDlRbCb *pjRbCb, -PjTxEnt *txEnt -) -#else -PUBLIC S16 pjDlmProcDrb(gCb,pjRbCb,txEnt) -PjCb *gCb; -PjDlRbCb *pjRbCb; -PjTxEnt *txEnt; -#endif -{ - TRC3(pjDlmProcDrb) -#ifndef ALIGN_64BIT - RLOG_ARG1(L_UNUSED,DBG_RBID,pjRbCb->rbId, - "pjDlmProcDrb(pjRbCb (), txEnt(%ld)) ", txEnt->count); -#else - RLOG_ARG1(L_UNUSED,DBG_RBID,pjRbCb->rbId, - "pjDlmProcDrb(pjRbCb (), txEnt(%d)) ", txEnt->count); -#endif - - RETVALUE(pjDlmHdlCmp(gCb, pjRbCb, txEnt)); -} - -/** - * - * @brief - * - * Handler to process the Integrity Protection Request - * - * @b Description: - * - * 1. This function performs integrity protection - * of a SDU by prepending the header. @n - * 2. If ciphering is applicable, it is performed after removing - * the header. @n - * 3. The PDU is constructed and then delivered to the lower - * layer. @n - * - * @param[in] pjRbCb PDCP control block. - * @param[in] txEnt Transmission Entity. - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ - -#ifdef ANSI -PUBLIC S16 pjDlmHdlIntProt -( -PjCb *gCb, -PjDlRbCb *pjRbCb, -PjTxEnt *txEnt -) -#else -PUBLIC S16 pjDlmHdlIntProt(gCb,pjRbCb,txEnt) -PjCb *gCb; -PjDlRbCb *pjRbCb; -PjTxEnt *txEnt; -#endif -{ - S16 ret; /* Return Value */ - U32 hdr; /* Header Value */ -#ifndef TENB_AS_SECURITY - U32 macI = 0; /* MAC-I value to be padded to the PDU */ -#endif - Buffer *pdu = NULLP; /* Pointer for the PDU in txEnt */ - PjSecInp secInp; /* Security Input for Ciphering and Int Prot */ - - TRC3(pjDlmHdlIntProt) -#ifndef ALIGN_64BIT - RLOG_ARG1(L_DEBUG,DBG_RBID,pjRbCb->rbId, - "pjDlmHdlIntProt(pjRbCb (), txEnt (%ld)) ", txEnt->count); -#else - RLOG_ARG1(L_DEBUG,DBG_RBID,pjRbCb->rbId, - "pjDlmHdlIntProt(pjRbCb (), txEnt (%d)) ", txEnt->count); -#endif - - pdu = txEnt->sdu; - - ret = ROK; - hdr = 0; - - /* If firstDL msg after secCfg, unset the ueCb flag ans set - * rbCb flag and set the SN - */ - if (pjRbCb->ueCb->secInfo.selSecAct == TRUE && - pjRbCb->ueCb->secInfo.firstMsg == TRUE ) - { - pjRbCb->firstDlMsg = TRUE; - pjRbCb->firstSn = txEnt->sn; - pjRbCb->ueCb->secInfo.firstMsg = FALSE; - } - secInp.dir = PJ_SEC_DIR_DL; - secInp.rbId = pjRbCb->rbId; - secInp.count= txEnt->count; - - /* Add the header and then send it for Integrity Protection */ - hdr = txEnt->sn; - PJ_ADD_PRE_MSG(pdu, hdr, 2, ret); -#ifndef TENB_T2K3K_SPECIFIC_CHANGES - txEnt->sdu = pdu; -#endif - -#if (ERRCLASS & ERRCLS_ADD_RES) - if ( ret != ROK ) - { - RLOG1(L_ERROR, "SAddPreMsg failed Tx Count[%lu]", txEnt->count); - PJ_UPD_DL_VAR(gCb, pjRbCb, txEnt->count); - if ( pjRbCb->dlCb.cfmReqd) - { - PJ_SND_CFM(gCb,pjRbCb, txEnt, PJ_REM_MSG_FAILED); - } - RETVALUE(RFAILED); - } -#endif - - txEnt->state = PJ_WAIT_FOR_INTPROT; - ret = pjUtlIntProtReq(gCb, pjRbCb, secInp, &pdu); - - - if ( ret != ROK ) - { - RLOG1(L_ERROR, "Integrity Protection Req failed Tx Count[%lu]", txEnt->count); - PJ_UPD_DL_VAR(gCb, pjRbCb, txEnt->count); - if ( pjRbCb->dlCb.cfmReqd) - { - PJ_SND_CFM(gCb,pjRbCb, txEnt, PJU_INTPROT_FAILED); - } - gCb->pjGenSts.numIntgPrtFails++; - RETVALUE(RFAILED); - } -#ifdef INTEL_QAT_DP - if (pjRbCb->ueCb->secInfo.intInfo.algoType == 0) -#endif - { -#ifndef PJ_SEC_ASYNC - /* Append the macI at the end */ -#ifdef TENB_AS_SECURITY - /*PJ_PACK_MACI(pdu, macI);*/ -#else - PJ_PACK_MACI(pdu, macI); -#endif - txEnt->pdu = pdu; -#ifndef TENB_ACC -#ifndef TENB_T2K3K_SPECIFIC_CHANGES -#ifdef SS_RBUF -// prc_trace_format_string(0x40,3,"[%ld] ",macI); -#endif -#endif -#endif - - /* Remove the header and then only send for ciphering */ - ret = SRemPreMsg((Data *)&hdr, txEnt->pdu); -#if (ERRCLASS & ERRCLS_ADD_RES) - if ( ret != ROK ) - { - RLOG1(L_ERROR, "SRemPreMsg failed Tx Count [%lu]", txEnt->count); - PJ_UPD_DL_VAR(gCb, pjRbCb, txEnt->count); - if ( pjRbCb->dlCb.cfmReqd) - { - PJ_SND_CFM(gCb,pjRbCb, txEnt, PJ_REM_MSG_FAILED); - } - RETVALUE(RFAILED); - } -#endif /* ERRCLASS & ERRCLS_RES */ - ret = SRemPreMsg((Data *)&hdr, txEnt->pdu); -#if (ERRCLASS & ERRCLS_ADD_RES) - if ( ret != ROK ) - { - RLOG1(L_ERROR, "SRemPreMsg failed Tx Count [%lu]", txEnt->count); - PJ_UPD_DL_VAR(gCb, pjRbCb, txEnt->count); - if ( pjRbCb->dlCb.cfmReqd) - { - PJ_SND_CFM(gCb,pjRbCb, txEnt, PJ_REM_MSG_FAILED); - } - RETVALUE(RFAILED); - } -#endif /* ERRCLASS & ERRCLS_RES */ - - /* If rbCb flag is set => firstDL msg. So skip ciphering */ - if ( pjRbCb->firstDlMsg == TRUE && pjRbCb->firstSn == txEnt->sn) - { - pjRbCb->firstDlMsg = FALSE; -#ifndef SS_RBUF - PJ_FREE_BUF(txEnt->sdu); -#endif - txEnt->sdu = NULLP; - ret = pjDlmDeliverPdu(gCb, pjRbCb, txEnt); - } - else - { - ret = pjDlmHdlCiph(gCb, pjRbCb, txEnt); - } -#endif - } - RETVALUE(ret); -} - - -/** - * - * @brief - * - * Handler to process NULL Ciphering. - * - * @b Description: - * This function handles the PDU for NULL ciphering. - * - * @param[in] gCb Global control block. - * @param[in] pjRbCb RB control block. - * @param[in] txEnt Transmission Entity. - * @return S16 - * -# ROK - * -# RFAILED - */ - -#ifdef ANSI -PUBLIC S16 pjDlmHdlNullCiph -( -PjCb *gCb, -PjDlRbCb *pjRbCb, -PjTxEnt *txEnt -) -#else -PUBLIC S16 pjDlmHdlNullCiph(gCb,pjRbCb,txEnt) -PjCb *gCb; -PjDlRbCb *pjRbCb; -PjTxEnt *txEnt; -#endif -{ - S16 ret; /* Return Value */ - - TRC3(pjDlmHdlNullCiph); - - ret=ROK; - - /* If Ciphering is enabled, txEnt->pdu will point to a mBuf */ -#ifdef FLAT_BUFFER_OPT - if(txEnt->sdu == NULLP) - { - ret = pjUtlCopyFbToBuf(gCb, &(txEnt->fb), &(txEnt->pdu)); - if (ret != ROK) - { - RLOG1(L_ERROR, "Cpoying to Flat Buf Failed Tx Count [%lu]", txEnt->count); - PJ_UPD_DL_VAR(gCb, pjRbCb, txEnt->count); - if ( pjRbCb->dlCb.cfmReqd) - { - PJ_SND_CFM(gCb,pjRbCb, txEnt, PJ_CPY_MSG_FAILED); - } - RETVALUE(RFAILED); - } - } -#endif - - if (txEnt->pdu == NULLP ) - { - if ( pjRbCb->mode == PJ_DRB_AM -#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)) - || pjRbCb->mode == PJ_DRB_UM -#endif - ) - { - PJ_CPY_MSG(gCb,txEnt->sdu, &(txEnt->pdu), ret); -#if (ERRCLASS & ERRCLS_ADD_RES) - if (ret != ROK) - { - RLOG1(L_ERROR, "SAddMsgRef Failed Tx Count [%lu]", txEnt->count); - - PJ_UPD_DL_VAR(gCb, pjRbCb, txEnt->count); - if ( pjRbCb->dlCb.cfmReqd) - { - PJ_SND_CFM(gCb,pjRbCb, txEnt, PJ_CPY_MSG_FAILED); - } - RETVALUE(RFAILED); - } -#endif - } - else - { - txEnt->pdu = txEnt->sdu; - txEnt->sdu = NULLP; - } - } - - RETVALUE(ret); -} - -/** - * - * @brief - * - * Handler to process the Compression Request. - * - * @b Description: - * - * 1. This function performs header compression if configured. @n - * 2. If ciphering is applicable, it is performed. @n - * 3. The PDU is constructed and then delivered to the lower - * layer. @n - * - * @param[in] pjRbCb PDCP control block. - * @param[in] txEnt Transmission Entity. - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ - - -#ifdef ANSI -PUBLIC S16 pjDlmHdlCmp -( -PjCb *gCb, -PjDlRbCb *pjRbCb, -PjTxEnt *txEnt -) -#else -PUBLIC S16 pjDlmHdlCmp(gCb,pjRbCb,txEnt) -PjCb *gCb; -PjDlRbCb *pjRbCb; -PjTxEnt *txEnt; -#endif -{ - S16 ret; /* Return Value */ - Buffer *opSdu; /* Pointer for Output of Compression */ - U32 macI; /* MAC-I value to be padded to the PDU */ - TRC3(pjDlmHdlCmp) -#ifndef ALIGN_64BIT - RLOG_ARG1(L_UNUSED,DBG_RBID,pjRbCb->rbId, "pjDlmHdlCmp(pjRbCb (), txEnt (%ld)) ", - txEnt->count); -#else - RLOG_ARG1(L_UNUSED,DBG_RBID,pjRbCb->rbId, "pjDlmHdlCmp(pjRbCb (), txEnt (%d)) ", - txEnt->count); -#endif - - ret = ROK; - opSdu = NULLP; - - /* Perform compression if ocnfigured */ - if ( pjRbCb->rohc.hdrCmpUsed ) - { - txEnt->pdu = txEnt->sdu; - txEnt->state = PJ_WAIT_FOR_CMP; - ret = pjUtlCmpReq(gCb, pjRbCb, txEnt->pdu, &opSdu, txEnt->count); - if ( ret != ROK ) - { - - RLOG1(L_ERROR, "Compression Req Failed Tx Count [%lu]", txEnt->count); - PJ_UPD_DL_VAR(gCb, pjRbCb, txEnt->count); - if ( pjRbCb->dlCb.cfmReqd) - { - PJ_SND_CFM(gCb,pjRbCb, txEnt, PJU_COMP_FAILED); - } - gCb->pjGenSts.numCmpFails++; - RETVALUE(RFAILED); - } -#ifdef PJ_CMP_ASYNC - RETVALUE(ret); -#else - txEnt->pdu = opSdu; -#endif - } - if(pjRbCb->ueCb->secInfo.intProtEnbForDrb) - { - macI = 0; - PJ_PACK_MACI(txEnt->sdu, macI); - } - /* Perform ciphering if security is configured */ - ret = pjDlmHdlCiph(gCb, pjRbCb, txEnt); - RETVALUE(ret); -} - -#ifdef LTE_PAL_ENB -/** - * @brief This fn cheks whether the RING buffer is used and therefore DL pkts - * need to be enqueued before forwarding it for ciphering. - * Note: It acts as a dummy fn so far in case of Mindspeed pltfm - * - * @details - * Function : pjUtlChekTxEnqReq - * - * Processing Steps: - * - * - * @return S16 - * -# Success : ROK - * -# Failure : RFAILED -*/ -#ifdef ANSI -PUBLIC S16 pjUtlChekTxEnqReq -( -PjCb *gCb, -PjDlRbCb *pjRbCb, -PjTxEnt *txEnt -) -#else -PUBLIC S16 pjUtlChekTxEnqReq(gCb,pjRbCb, txEnt) -PjCb *gCb; -PjDlRbCb *pjRbCb; -PjTxEnt *txEnt; -#endif -{ - RETVALUE(ROK); -} -#endif -/** - * - * @brief - * - * Handler to process the Ciphering Request. - * - * @b Description: - * - * 1. This function performs ciphering. @n - * 2. If asynchronous flag is defined, the function returns . @n - * 3. Else the function updates the PDU field in txEnt and returns. @n - * - * @param[in] pjRbCb PDCP control block. - * @param[in] txEnt Transmission Entity. - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 pjDlmHdlCiph -( -PjCb *gCb, -PjDlRbCb *pjRbCb, -PjTxEnt *txEnt -) -#else -PUBLIC S16 pjDlmHdlCiph(gCb,pjRbCb,txEnt) -PjCb *gCb; -PjDlRbCb *pjRbCb; -PjTxEnt *txEnt; -#endif -{ - S16 ret; /* Return Value */ - Buffer *ciphSdu; /* Pointer for Output of Ciphering */ - PjSec *secInfo; - - TRC3(pjDlmHdlCiph) -#ifndef SS_RBUF -#ifndef TENB_ACC - pjUtlChekTxEnqReq(gCb, pjRbCb, txEnt); -#endif -#if CIPH_BATCH_PROC - RETVALUE(ROK); -#endif -#endif -#ifndef ALIGN_64BIT - RLOG_ARG1(L_UNUSED,DBG_RBID,pjRbCb->rbId, "pjDlmHdlCiph(pjRbCb (), txEnt (%ld)) ", - txEnt->count); -#else - RLOG_ARG1(L_UNUSED,DBG_RBID,pjRbCb->rbId, "pjDlmHdlCiph(pjRbCb (), txEnt (%d)) ", - txEnt->count); -#endif - ret = ROK; - ciphSdu = NULLP; -#ifndef L2_PDCP_OPTMZ -txEnt->state = PJ_WAIT_FOR_CIPHER; -#endif - - - secInfo = &(pjRbCb->ueCb->secInfo); - - if ( secInfo->secAct && secInfo->cipherInfo.algoType != 0) /* If its not NULL Ciphering and Security is enabled */ - { - if ( txEnt->pdu == NULLP ) - { - txEnt->pdu = txEnt->sdu; - } - /* Note: FB is only for DRB data in DL direction. SRB data after */ - /* integrity protection will use the NON-FB version of code. */ - /* The below "if" check is to identify whether it is for SRB data */ - /* or DRB data. */ -#ifdef CIPH_BATCH_PROC -#ifndef TENB_ACC - pjUtlChekTxEnqReq(gCb, pjRbCb, txEnt); -#endif - RETVALUE(ROK); -#endif - -#ifdef FLAT_BUFFER_OPT - if (txEnt->sdu == NULLP) - { - ret = pjUtlCipherReqFB(gCb, pjRbCb, txEnt->count, &(txEnt->fb), &ciphSdu); - } - else -#endif - { - ret = pjUtlCipherReq(gCb, pjRbCb, txEnt->count, txEnt->pdu, &ciphSdu); - } - - /*There can be failures in creating the input for SPACC*/ - if ( ret != ROK ) - { - RLOG1(L_ERROR, "Ciphering Req failed Tx Count [%lu]", txEnt->count); - PJ_UPD_DL_VAR(gCb, pjRbCb, txEnt->count); - if ( pjRbCb->dlCb.cfmReqd) - { - PJ_SND_CFM(gCb,pjRbCb, txEnt, PJU_CIPHER_FAILED); - } - gCb->pjGenSts.numCiphFails++; - RETVALUE(RFAILED); - } -#ifdef INTEL_SW_SEC - if(ciphSdu) - { - //printf("Ciphered PDU\n"); - //SPrntMsg(ciphSdu,0,0); - if(txEnt->pdu) - { - PJ_FREE_BUF(txEnt->pdu); - } - txEnt->pdu = ciphSdu; - } - else - { - PJLOGERROR(gCb, ERRCLS_ADD_RES, EPJXXX, (ErrVal)sduId, - "pjSendToSwCipherFB:Ciphering failed for txEnt\n"); - pjDbmDelTxEnt(gCb, &(pjRbCb->dlCb.txBuf), txEnt->count); - RETVALUE(RFAILED); - } -#endif - -#ifdef TENB_AS_SECURITY - if(isSecBatchMode) - { - txEnt->state = PJ_PDU_SUBMITTED; -#ifdef L2_PDCP_OPTMZ - /* Delete Tx entity in case of UM mode*/ - if (pjRbCb->mode == PJ_DRB_UM ) - { - pjDbmDelTxEnt(gCb, &(pjRbCb->dlCb.txBuf), txEnt->count); - } -#endif - RETVALUE(ret); - } - else -#endif - { - txEnt->pdu = ciphSdu; - } - - } - else - { -#ifdef L2_PDCP_OPTMZ - txEnt->state = PJ_WAIT_FOR_CIPHER; -#endif - -#ifdef SS_RBUF - txEnt->pdu = NULLP; -#endif - ret = pjDlmHdlNullCiph(gCb, pjRbCb, txEnt); - } - - txEnt->state = PJ_PDU_SUBMITTED; - ret = pjDlmDeliverPdu(gCb, pjRbCb, txEnt); - - - RETVALUE(ROK); -} - -#ifdef FLAT_BUFFER_OPT -/** - * - * @brief - * - * Handler to process the Ciphering Request. - * - * @b Description: - * - * 1. This function performs ciphering. @n - * 2. If asynchronous flag is defined, the function returns . @n - * 3. Else the function updates the PDU field in txEnt and returns. @n - * - * @param[in] pjRbCb PDCP control block. - * @param[in] txEnt Transmission Entity. - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ - -#ifdef ANSI -PUBLIC S16 pjDlmHdlCiphFB -( -PjCb *gCb, -PjDlRbCb *pjRbCb, -PjTxEnt *txEnt -) -#else -PUBLIC S16 pjDlmHdlCiphFB(gCb,pjRbCb,txEnt) -PjCb *gCb; -PjDlRbCb *pjRbCb; -PjTxEnt *txEnt; -#endif -{ - S16 ret; /* Return Value */ - Buffer *ciphSdu; /* Pointer for Output of Ciphering */ - - TRC3(pjDlmHdlCiphFB) -#ifndef ALIGN_64BIT - PJDBGP(gCb,(PJ_DBGMASK_DLM | PJ_DBGMASK_BRIEF | PJ_DBGMASK_DL), - (gCb->init.prntBuf, "pjDlmHdlCiphFB(pjRbCb (%d), txEnt (%ld)) \n", - pjRbCb->rbId, txEnt->count)); -#else - PJDBGP(gCb,(PJ_DBGMASK_DLM | PJ_DBGMASK_BRIEF | PJ_DBGMASK_DL), - (gCb->init.prntBuf, "pjDlmHdlCiphFB(pjRbCb (%d), txEnt (%d)) \n", - pjRbCb->rbId, txEnt->count)); -#endif - ret = ROK; - ciphSdu = NULLP; - - txEnt->state = PJ_WAIT_FOR_CIPHER; - ret = pjUtlCipherReqFB(gCb, pjRbCb, txEnt->count, &(txEnt->fb), &ciphSdu); - - /*There can be failures in creating the input for SPACC*/ - if ( ret != ROK ) - { - RLOG1(L_ERROR, "Ciphering Req failed Tx Count [%lu]", txEnt->count); - PJ_UPD_DL_VAR(gCb, pjRbCb, txEnt->count); - if ( pjRbCb->dlCb.cfmReqd) - { - PJ_SND_CFM(gCb,pjRbCb, txEnt, PJU_CIPHER_FAILED); - } - gCb->pjGenSts.numCiphFails++; - RETVALUE(RFAILED); - } - - - txEnt->state = PJ_PDU_SUBMITTED; - - - RETVALUE(ROK); -} -#endif - - -/** - * - * @brief - * - * @param[in] pjRbCb PDCP control block. - @param[in] PjRxEnt *rxEnt - * - * @return Void - */ - -#ifdef ANSI -PUBLIC Void pjDlmEnqueueDlPkt -( -PjCb *gCb, -PjDlRbCb *pjRbCb, /* !< PDCP Control Block */ -U8 datType, -PjuDatFwdReqInfo *datFwd, /* !< SN value of PDU */ -PjuSduId sduId, -Buffer *pdu /* !< PDU message buffer */ -) -#else -PUBLIC Void pjDlmEnqueueDlPkt(gCb,pjRbCb,datType,datFwd,suId,pdu) -PjCb *gCb; -PjDlRbCb *pjRbCb; /* !< PDCP Control Block */ -U8 datType; -PjuDatFwdReqInfo *datFwd; /* !< SN value of PDU */ -PjuSduId sduId; -Buffer *pdu; /* !< PDU message buffer */ -#endif -{ - PjDlPkt *pkt; - U32 numSdu; - - TRC2(pjDlmEnqueueDlPkt) - - if (datType == PJ_DATA_FWD_PKT) - { - for (numSdu=0; numSdu < datFwd->numSdus; numSdu++) - { - PJ_ALLOC(gCb, pkt, sizeof(PjDlPkt)); - if (pkt != NULLP) - { - pkt->type = datType; - pkt->sn = datFwd->datFwdInfo[numSdu].sn; - pkt->sduId = datFwd->datFwdInfo[numSdu].sduId; - pkt->pdu = datFwd->datFwdInfo[numSdu].sdu; - pkt->lnk.node = (PTR)pkt; - cmLListAdd2Tail (&pjRbCb->dlCb.dlPktQ, &pkt->lnk); - } - } - } - else - { - PJ_ALLOC(gCb, pkt, sizeof(PjDlPkt)); - if (pkt != NULLP) - { - pkt->type = datType; - pkt->pdu = pdu; - pkt->sduId = sduId; - pkt->lnk.node = (PTR)pkt; - cmLListAdd2Tail (&pjRbCb->dlCb.dlPktQ, &pkt->lnk); - } - else - { - RLOG0(L_FATAL, "Memory Allocation failed."); - PJ_FREE_BUF(pdu); - } - } - - RETVOID; -}/* end of pjDlmEnqueueHoPkt */ - -#ifdef FLAT_BUFFER_OPT -/** - * - * @brief - * - * @param[in] pjRbCb PDCP control block. - @param[in] PjRxEnt *rxEnt - * - * @return Void - */ -#ifdef ANSI -PUBLIC Void pjDlmEnqueueDlPktFB -( -PjCb *gCb, -PjDlRbCb *pjRbCb, /* !< PDCP Control Block */ -U8 datType, -PjuDatFwdReqInfo *datFwd, /* !< SN value of PDU */ -PjuSduId sduId, -FlatBuffer *pdu /* !< Flat Buffer PDU */ -) -#else -PUBLIC Void pjDlmEnqueueDlPktFB(gCb,pjRbCb,datType,datFwd,suId,pdu) -PjCb *gCb; -PjDlRbCb *pjRbCb; /* !< PDCP Control Block */ -U8 datType; -PjuDatFwdReqInfo *datFwd; /* !< SN value of PDU */ -PjuSduId sduId; -FlatBuffer *pdu; /* !< Flat Buffer PDU */ -#endif -{ - PjDlPkt *pkt; - - TRC2(pjDlmEnqueueDlPktFB) - - if (datType == PJ_DATA_FWD_PKT) - { - /* printf("pjDlmEnqueueDlPktFB: datType = PJ_DATA_FWD_PKT. TODO !!!!! "); */ - } - else - { - PJ_ALLOC(gCb, pkt, sizeof(PjDlPkt)); - if (pkt != NULLP) - { - pkt->type = datType; - pkt->fb.startAddr = pdu->startAddr; - pkt->fb.ptr = pdu->ptr; - pkt->fb.len = pdu->len; - pkt->pdu = NULLP; - pkt->sduId = sduId; - pkt->lnk.node = (PTR)pkt; - cmLListAdd2Tail (&pjRbCb->dlCb.dlPktQ, &pkt->lnk); - /*printf("pjDlmEnqueueDlPktFB: Enqueue DL Flat Buffer Packets. Sdu Id is %d ", - pkt->sduId);*/ - } - else - { - RLOG0(L_FATAL, "Memory Allocation failed."); - PJ_FREE_FLAT_BUF(gCb, pdu); - } - } - - RETVOID; -}/* end of pjDlmEnqueueDlPktFB */ -#endif - -/** - * - * @brief It processes the packets queued up in DLPktQ - * - * @Description - * This DlPktQ queues the Normal and forwarded message during - * reestablishment/handover. - * - * @param[in] pjCb PDCP Instance control block. - * @param[in] pjRbCb Rb Control block - * - * @return Void - */ -#ifdef ANSI -PUBLIC Void pjDlmProcessDlPktQ -( -PjCb *gCb, -PjDlRbCb *pjRbCb /* !< PDCP Control Block */ -) -#else -PUBLIC Void pjDlmProcessDlPktQ(gCb, pjRbCb) -PjCb *gCb; -PjDlRbCb *pjRbCb; /* !< PDCP Control Block */ -#endif -{ - PjDlPkt *pkt; - CmLList *node; - S16 ret; /*KW_FIX*/ - - TRC2(pjDlmProcessDlPktQ) - - /* first send the status report if any enqueued */ - - if (pjRbCb->dlCb.staRep != NULL) - { - pjDlmSendDatReq(gCb, pjRbCb, 0xffffffff, pjRbCb->dlCb.staRep); - pjRbCb->dlCb.staRep = NULL; - } - - CM_LLIST_FIRST_NODE(&(pjRbCb->dlCb.dlPktQ), node); - while (node != NULLP) - { - pkt = (PjDlPkt *) node->node; - if (pkt->type == PJ_DATA_FWD_PKT) - { - PjuDatFwdReqInfo datFwdReq; - PjuDatFwdInfo datFwd; - datFwdReq.numSdus = 1; - datFwd.sn = pkt->sn; - datFwd.sdu = pkt->pdu; - datFwd.sduId = pkt->sduId; - datFwdReq.datFwdInfo = &datFwd; - pjDlmHndlDatFwdReq(gCb, pjRbCb, &datFwdReq); - } - else - { - - -#ifdef FLAT_BUFFER_OPT -#ifndef XEON_SPECIFIC_CHANGES - { - /* Check whether the spacc q has space to hold - this packet.. else dropping */ - if(FALSE == (pjMsCheckSpaccQueue(FALSE))) - { - PJ_FREE_FLAT_BUF(pjCb[1],&(pkt->fb)); - gPdcpStats.numPdcpSdusDiscarded++; - PJ_UPD_L2_DLDISC_STS(pjCb[1], pjRbCb); - - cmLListDelFrm(&(pjRbCb->dlCb.dlPktQ), node); - PJ_FREE(gCb, pkt, sizeof (PjDlPkt)); - node = NULLP; - CM_LLIST_FIRST_NODE(&(pjRbCb->dlCb.dlPktQ), node); - continue; - } - } -#endif - if((pkt->fb.len !=0) && (pkt->fb.ptr != NULLP)) - { - ret = pjDlmProcessSdusFB(gCb, pjRbCb, &(pkt->fb), pkt->sduId, pjRbCb->dlCb.txNext); - } - else -#endif - { - ret = pjDlmProcessSdus(gCb, pjRbCb, pkt->pdu, pkt->sduId, pjRbCb->dlCb.txNext); - } - if ( ret != ROK ) - { -#if (ERRCLASS & ERRCLS_INT_PAR) - RLOG_ARG1(L_ERROR, DBG_RBID, pjRbCb->rbId, "Processing of SDU [%lu] failed", pkt->sduId); -#endif /* ERRCLASS & ERRCLS_INT_PAR */ - } - } - - cmLListDelFrm(&(pjRbCb->dlCb.dlPktQ), node); - PJ_FREE(gCb, pkt, sizeof (PjDlPkt)); - node = NULLP; - CM_LLIST_FIRST_NODE(&(pjRbCb->dlCb.dlPktQ), node); - } - - RETVOID; -}/* end of pjDlmProcessDlPktQ */ - - - - -#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)) -/** - * - * @brief Handler for downlink off-board timer expiry. - * - * - * @b Description - * This function is called when the off-board timer expires. - * This function discards the txEnt of dlCb.obdCount if it is - * is not submitted and sends the constructed PDUs to the lower - * layer and start the timer for the next valid txEnt. - * - * @param[in] pjRbCb PDCP control block. - * - * - * @return S16 - * -# ROK - */ -#ifdef ANSI -PUBLIC S16 pjDlmObdTmrExp -( -PjCb *gCb, -PjDlRbCb *pjRbCb -) -#else -PUBLIC S16 pjDlmObdTmrExp(gCb, pjRbCb) -PjCb *gCb; -PjDlRbCb *pjRbCb; -#endif -{ - U32 count; - U32 curCount; - PjTxEnt *txEnt; - PjuDatCfmInfo *datCfm; - S16 ret; - - TRC3(pjDlmObdTmrExp) - - RLOG_ARG0(L_DEBUG,DBG_RBID,pjRbCb->rbId, "pjDlmObdTmrExp(pjRbCb()) "); - - count = pjRbCb->dlCb.obdCount; - curCount = pjRbCb->dlCb.count; - txEnt = pjDbmGetTxEnt(gCb, &(pjRbCb->dlCb.txBuf), count); - datCfm = NULLP; - ret = ROK; - - if ( txEnt && txEnt->state != PJ_PDU_SUBMITTED ) - { -#ifndef ALIGN_64BIT - RLOG_ARG1(L_DEBUG,DBG_RBID,pjRbCb->rbId, - "pjDlmObdTmrExp(pjRbCb()) : discarding txEnt withcount(%ld)", - txEnt->count); -#else - RLOG_ARG1(L_DEBUG,DBG_RBID,pjRbCb->rbId, - "pjDlmObdTmrExp(pjRbCb()) : discarding txEnt withcount(%d)", - txEnt->count); -#endif - PJ_UPD_DL_VAR(gCb, pjRbCb, txEnt->count); - PJ_SND_CFM(gCb,pjRbCb, txEnt, PJ_OBD_TIMEOUT); - gCb->pjGenSts.numSdusDiscObdTmrExp++; - count++; - while ( count <= curCount ) - { - txEnt = pjDbmGetTxEnt(gCb, &(pjRbCb->dlCb.txBuf), count); - if ( txEnt != NULLP ) - { - if ( txEnt->state == PJ_PDU_CONSTRUCTED ) - { - ret = pjDlmDeliverPdu(gCb, pjRbCb, txEnt); - count = pjRbCb->dlCb.nxtToSub; - } - break; - } - else - { - PJ_UPD_DL_VAR(gCb, pjRbCb, count); - } - count++; - } - } - else - { - count = pjRbCb->dlCb.nxtToSub; - } - if ( pjDbmGetTxEnt(gCb, &(pjRbCb->dlCb.txBuf), count) != NULLP ) - { - pjRbCb->dlCb.obdCount = count; - pjStartTmr(gCb, (PTR)pjRbCb, PJ_EVT_DL_OBD_TMR); - } - - RETVALUE(ret); -} - -#endif - -/*@}*/ -/********************************************************************30** - * End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_env.h b/src/5gnrpdcp/pj_env.h deleted file mode 100755 index 8f8f146b3..000000000 --- a/src/5gnrpdcp/pj_env.h +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: LTE PDCP file - - Type: H include file - - Desc: This file contain the hash definations for PDCP - - File: pj_env.h - -*********************************************************************21*/ -/** @file pj_env.h -@brief PDCP Hash definitions -*/ - -#ifndef __PJENVT2KH__ -#define __PJENVT2KH__ - -#define PJ_MAX_PDCP_INSTANCES 2 -#define PJ_FWD_MAX_SDU_CNT 1 - -#define PJ_ALLOC_BUF(gCb,_buf) \ -{ \ - if (SGetMsg(gCb->init.region, gCb->init.pool, (Buffer **)&_buf) != ROK) \ - { \ - (_buf) = NULLP; \ - } \ -} - -#define PJ_CPY_MSG(_cb,_x, _y, _ret) \ - _ret =(SAddMsgRef((_x), PJ_GET_MEM_REGION(_cb), PJ_GET_MEM_POOL(_cb), (_y))) - -#define PJ_SND_CFM(_cb,_pjRbCb, _txEnt, _cause) \ -{ \ - PjuDatCfmInfo *_datCfm; \ - CmLtePdcpId *_pdcpId; \ - PjPjuSapCb *_pjuSap; \ - if (_pjRbCb->rbType == PJ_SRB) \ - _pjuSap = &(_cb->u.dlCb->pjuSap[PJ_SRB_SAP]); \ - else \ - _pjuSap = &(_cb->u.dlCb->pjuSap[PJ_DRB_SAP]); \ - \ - PJ_ALLOC(_cb, _datCfm, sizeof(PjuDatCfmInfo)); \ - PJ_ALLOC(_cb,_pdcpId, sizeof(CmLtePdcpId)); \ - if ( _datCfm != NULLP && _pdcpId != NULLP ) \ - { \ - _datCfm->cfmSta[_datCfm->numSdus].sduId = _txEnt->sduId;\ - _datCfm->cfmSta[_datCfm->numSdus].status = _cause; \ - _datCfm->numSdus++; \ - _pdcpId->rbId = _pjRbCb->rbId; \ - _pdcpId->rbType = _pjRbCb->rbType; \ - _pdcpId->ueId = _pjRbCb->ueCb->key.ueId; \ - _pdcpId->cellId = _pjRbCb->ueCb->key.cellId; \ - PjUiPjuDatCfm(&(_pjuSap->pst), _pjuSap->suId, _pdcpId, _datCfm);\ - } \ - pjDbmDelTxEnt(_cb, &(pjRbCb->dlCb.txBuf), _txEnt->count); \ -} - -#define PJ_ADD_PRE_MSG(_pdu, _hdr, _numBytes, _ret) \ -{ \ - Data _liByte; \ - U16 _bytes; \ - _bytes = 0; \ - while (_numBytes > _bytes ) \ - { \ - _liByte = (U8) (_hdr >> (8*_bytes)); \ - _ret = SAddPreMsg((Data )_liByte, _pdu); \ - if ( _ret != ROK ) \ - { \ - break; \ - } \ - _bytes++; \ - } \ -} -#endif /* __PJENVT2KH__ */ -/********************************************************************30** - - End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_err.h b/src/5gnrpdcp/pj_err.h deleted file mode 100755 index 34f8ecd7f..000000000 --- a/src/5gnrpdcp/pj_err.h +++ /dev/null @@ -1,338 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: LTE PDCP file - - Type: C include file - - Desc: This file contain the hash definations for PDCP - - File: pj_err.h - -*********************************************************************21*/ -/** @file pj_err.h -@brief PDCP Hash definitions -*/ - -#ifndef __PJ_ERR_H__ -#define __PJ_ERR_H__ - - -#if (ERRCLASS & ERRCLS_INT_PAR) -#define PJLOGERROR(_cb, errCls, errCode, errVal, errDesc) \ - SLogError(_cb->init.ent, _cb->init.inst, _cb->init.procId, \ - __FILE__, __LINE__, errCls, errCode, errVal, errDesc) - -#define PJ_GET_AND_VALIDATE_CPJSAP(_cb, _cpjSap, _errCode, _fn, _ret) \ -{ \ - _ret = RFAILED; \ - if((_cpjSap != NULLP) && (_cpjSap->state == PJ_SAP_BND)) \ - { \ - _ret = ROK; \ - } \ - if(_ret != ROK) \ - { \ - PJLOGERROR(_cb, ERRCLS_INT_PAR, EPJXXX, (ErrVal) spId,\ - "PjUiCpjBndReq: CPJ SAP State is Invalid during Bind Req");\ - PJ_SEND_SAPID_ALARM(_cb, spId, LPJ_EVENT_CPJ_BND_REQ, LCM_CAUSE_INV_STATE);\ - ret = RFAILED; \ - } \ -} -#define PJ_GET_AND_VALIDATE_PJUSAP(_cb, _pjuSap, _errCode, _fn, _ret) \ -{ \ - _ret = RFAILED; \ - if((_pjuSap != NULLP) && (_pjuSap->state == PJ_SAP_BND)) \ - { \ - _ret = ROK; \ - } \ - if(_ret != ROK) \ - { \ - PJLOGERROR(_cb, ERRCLS_INT_PAR, EPJXXX, (ErrVal) spId,\ - "PjUiPjuBndReq: PJU SAP State is Invalid during Bind Req");\ - PJ_SEND_SAPID_ALARM(_cb, spId, LPJ_EVENT_PJU_BND_REQ, LCM_CAUSE_INV_STATE);\ - _ret = RFAILED; \ - } \ -} - -#else -#define PJLOGERROR(_cb, errCls, errCode, errVal, errDesc) - -#endif - -/* Error Codes */ -#define ERRPJ 0 -#define EPJXXX 0 - - -#define EPJ001 (ERRPJ + 1) /* gp_amm.c: 293 */ -#define EPJ002 (ERRPJ + 2) /* gp_amm.c: 405 */ -#define EPJ003 (ERRPJ + 3) /* gp_amm.c: 419 */ -#define EPJ004 (ERRPJ + 4) /* gp_amm.c: 880 */ -#define EPJ005 (ERRPJ + 5) /* gp_amm.c:1351 */ -#define EPJ006 (ERRPJ + 6) /* gp_amm.c:1367 */ -#define EPJ007 (ERRPJ + 7) /* gp_amm.c:1561 */ -#define EPJ008 (ERRPJ + 8) /* gp_amm.c:1649 */ -#define EPJ009 (ERRPJ + 9) /* gp_amm.c:2423 */ -#define EPJ010 (ERRPJ + 10) /* gp_amm.c:2445 */ -#define EPJ011 (ERRPJ + 11) /* gp_amm.c:2555 */ -#define EPJ012 (ERRPJ + 12) /* gp_amm.c:3047 */ -#define EPJ013 (ERRPJ + 13) /* gp_amm.c:3069 */ -#define EPJ014 (ERRPJ + 14) /* gp_amm.c:3077 */ -#define EPJ015 (ERRPJ + 15) /* gp_amm.c:3147 */ -#define EPJ016 (ERRPJ + 16) /* gp_amm.c:3179 */ -#define EPJ017 (ERRPJ + 17) /* gp_amm.c:3187 */ -#define EPJ018 (ERRPJ + 18) /* gp_amm.c:4489 */ - -#define EPJ019 (ERRPJ + 19) /* gp_cfg.c: 268 */ -#define EPJ020 (ERRPJ + 20) /* gp_cfg.c: 311 */ -#define EPJ021 (ERRPJ + 21) /* gp_cfg.c: 368 */ -#define EPJ022 (ERRPJ + 22) /* gp_cfg.c: 380 */ - -#define EPJ023 (ERRPJ + 23) /* gp_dbm.c: 633 */ -#define EPJ024 (ERRPJ + 24) /* gp_dbm.c: 958 */ -#define EPJ025 (ERRPJ + 25) /* gp_dbm.c:1182 */ -#define EPJ026 (ERRPJ + 26) /* gp_dbm.c:1190 */ -#define EPJ027 (ERRPJ + 27) /* gp_dbm.c:1198 */ -#define EPJ028 (ERRPJ + 28) /* gp_dbm.c:1263 */ - -#define EPJ029 (ERRPJ + 29) /* gp_ex_ms.c: 317 */ -#define EPJ030 (ERRPJ + 30) /* gp_ex_ms.c: 389 */ -#define EPJ031 (ERRPJ + 31) /* gp_ex_ms.c: 431 */ -#define EPJ032 (ERRPJ + 32) /* gp_ex_ms.c: 481 */ -#define EPJ033 (ERRPJ + 33) /* gp_ex_ms.c: 493 */ -#define EPJ034 (ERRPJ + 34) /* gp_ex_ms.c: 638 */ -#define EPJ035 (ERRPJ + 35) /* gp_ex_ms.c: 730 */ -#define EPJ036 (ERRPJ + 36) /* gp_ex_ms.c: 772 */ -#define EPJ037 (ERRPJ + 37) /* gp_ex_ms.c: 802 */ -#define EPJ038 (ERRPJ + 38) /* gp_ex_ms.c: 849 */ -#define EPJ039 (ERRPJ + 39) /* gp_ex_ms.c: 861 */ - -#define EPJ040 (ERRPJ + 40) /* gp_lim.c: 221 */ -#define EPJ041 (ERRPJ + 41) /* gp_lim.c: 231 */ - -#define EPJ042 (ERRPJ + 42) /* gp_lmm.c: 225 */ -#define EPJ043 (ERRPJ + 43) /* gp_lmm.c: 280 */ -#define EPJ044 (ERRPJ + 44) /* gp_lmm.c: 418 */ -#define EPJ045 (ERRPJ + 45) /* gp_lmm.c: 886 */ -#define EPJ046 (ERRPJ + 46) /* gp_lmm.c: 952 */ -#define EPJ047 (ERRPJ + 47) /* gp_lmm.c:1016 */ -#define EPJ048 (ERRPJ + 48) /* gp_lmm.c:1340 */ - -#define EPJ049 (ERRPJ + 49) /* gp_pj_cfg.c: 505 */ -#define EPJ050 (ERRPJ + 50) /* gp_pj_cfg.c:1276 */ - -#define EPJ051 (ERRPJ + 51) /* gp_pj_cfg.c.tmp: 505 */ -#define EPJ052 (ERRPJ + 52) /* gp_pj_cfg.c.tmp:1276 */ - -#define EPJ053 (ERRPJ + 53) /* gp_pj_dlm.c: 243 */ -#define EPJ054 (ERRPJ + 54) /* gp_pj_dlm.c: 381 */ -#define EPJ055 (ERRPJ + 55) /* gp_pj_dlm.c: 518 */ -#define EPJ056 (ERRPJ + 56) /* gp_pj_dlm.c: 564 */ -#define EPJ057 (ERRPJ + 57) /* gp_pj_dlm.c: 644 */ -#define EPJ058 (ERRPJ + 58) /* gp_pj_dlm.c: 724 */ -#define EPJ059 (ERRPJ + 59) /* gp_pj_dlm.c: 864 */ -#define EPJ060 (ERRPJ + 60) /* gp_pj_dlm.c: 883 */ -#define EPJ061 (ERRPJ + 61) /* gp_pj_dlm.c: 921 */ -#define EPJ062 (ERRPJ + 62) /* gp_pj_dlm.c:1036 */ -#define EPJ063 (ERRPJ + 63) /* gp_pj_dlm.c:1049 */ -#define EPJ064 (ERRPJ + 64) /* gp_pj_dlm.c:1176 */ -#define EPJ065 (ERRPJ + 65) /* gp_pj_dlm.c:1226 */ -#define EPJ066 (ERRPJ + 66) /* gp_pj_dlm.c:1299 */ -#define EPJ067 (ERRPJ + 67) /* gp_pj_dlm.c:1324 */ -#define EPJ068 (ERRPJ + 68) /* gp_pj_dlm.c:1466 */ -#define EPJ069 (ERRPJ + 69) /* gp_pj_dlm.c:1534 */ -#define EPJ070 (ERRPJ + 70) /* gp_pj_dlm.c:1621 */ -#define EPJ071 (ERRPJ + 71) /* gp_pj_dlm.c:1637 */ -#define EPJ072 (ERRPJ + 72) /* gp_pj_dlm.c:1657 */ -#define EPJ073 (ERRPJ + 73) /* gp_pj_dlm.c:1680 */ -#define EPJ074 (ERRPJ + 74) /* gp_pj_dlm.c:1750 */ -#define EPJ075 (ERRPJ + 75) /* gp_pj_dlm.c:1772 */ -#define EPJ076 (ERRPJ + 76) /* gp_pj_dlm.c:1847 */ -#define EPJ077 (ERRPJ + 77) /* gp_pj_dlm.c:1961 */ - -#define EPJ078 (ERRPJ + 78) /* gp_pj_lmm.c: 319 */ -#define EPJ079 (ERRPJ + 79) /* gp_pj_lmm.c: 806 */ -#define EPJ080 (ERRPJ + 80) /* gp_pj_lmm.c: 870 */ - -#define EPJ081 (ERRPJ + 81) /* gp_pj_uim.c: 268 */ -#define EPJ082 (ERRPJ + 82) /* gp_pj_uim.c: 347 */ -#define EPJ083 (ERRPJ + 83) /* gp_pj_uim.c: 444 */ -#define EPJ084 (ERRPJ + 84) /* gp_pj_uim.c: 758 */ -#define EPJ085 (ERRPJ + 85) /* gp_pj_uim.c: 844 */ -#define EPJ086 (ERRPJ + 86) /* gp_pj_uim.c: 937 */ -#define EPJ087 (ERRPJ + 87) /* gp_pj_uim.c:1008 */ -#define EPJ088 (ERRPJ + 88) /* gp_pj_uim.c:1158 */ -#define EPJ089 (ERRPJ + 89) /* gp_pj_uim.c:1221 */ -#define EPJ090 (ERRPJ + 90) /* gp_pj_uim.c:1305 */ -#define EPJ091 (ERRPJ + 91) /* gp_pj_uim.c:1412 */ -#define EPJ092 (ERRPJ + 92) /* gp_pj_uim.c:1454 */ -#define EPJ093 (ERRPJ + 93) /* gp_pj_uim.c:1566 */ - -#define EPJ094 (ERRPJ + 94) /* gp_pj_uim.c.tmp: 268 */ -#define EPJ095 (ERRPJ + 95) /* gp_pj_uim.c.tmp: 347 */ -#define EPJ096 (ERRPJ + 96) /* gp_pj_uim.c.tmp: 444 */ -#define EPJ097 (ERRPJ + 97) /* gp_pj_uim.c.tmp: 758 */ -#define EPJ098 (ERRPJ + 98) /* gp_pj_uim.c.tmp: 844 */ -#define EPJ099 (ERRPJ + 99) /* gp_pj_uim.c.tmp: 937 */ -#define EPJ100 (ERRPJ + 100) /* gp_pj_uim.c.tmp:1008 */ -#define EPJ101 (ERRPJ + 101) /* gp_pj_uim.c.tmp:1158 */ -#define EPJ102 (ERRPJ + 102) /* gp_pj_uim.c.tmp:1221 */ -#define EPJ103 (ERRPJ + 103) /* gp_pj_uim.c.tmp:1305 */ -#define EPJ104 (ERRPJ + 104) /* gp_pj_uim.c.tmp:1412 */ -#define EPJ105 (ERRPJ + 105) /* gp_pj_uim.c.tmp:1454 */ -#define EPJ106 (ERRPJ + 106) /* gp_pj_uim.c.tmp:1566 */ - -#define EPJ107 (ERRPJ + 107) /* gp_pj_ulm.c: 482 */ -#define EPJ108 (ERRPJ + 108) /* gp_pj_ulm.c: 812 */ -#define EPJ109 (ERRPJ + 109) /* gp_pj_ulm.c: 828 */ -#define EPJ110 (ERRPJ + 110) /* gp_pj_ulm.c: 943 */ -#define EPJ111 (ERRPJ + 111) /* gp_pj_ulm.c: 972 */ -#define EPJ112 (ERRPJ + 112) /* gp_pj_ulm.c:1047 */ -#define EPJ113 (ERRPJ + 113) /* gp_pj_ulm.c:1064 */ -#define EPJ114 (ERRPJ + 114) /* gp_pj_ulm.c:2070 */ -#define EPJ115 (ERRPJ + 115) /* gp_pj_ulm.c:2077 */ - -#define EPJ116 (ERRPJ + 116) /* gp_pj_utl.c: 213 */ -#define EPJ117 (ERRPJ + 117) /* gp_pj_utl.c: 221 */ -#define EPJ118 (ERRPJ + 118) /* gp_pj_utl.c: 291 */ -#define EPJ119 (ERRPJ + 119) /* gp_pj_utl.c: 356 */ -#define EPJ120 (ERRPJ + 120) /* gp_pj_utl.c: 421 */ -#define EPJ121 (ERRPJ + 121) /* gp_pj_utl.c: 510 */ -#define EPJ122 (ERRPJ + 122) /* gp_pj_utl.c: 525 */ -#define EPJ123 (ERRPJ + 123) /* gp_pj_utl.c: 532 */ -#define EPJ124 (ERRPJ + 124) /* gp_pj_utl.c: 554 */ -#define EPJ125 (ERRPJ + 125) /* gp_pj_utl.c: 640 */ -#define EPJ126 (ERRPJ + 126) /* gp_pj_utl.c: 652 */ -#define EPJ127 (ERRPJ + 127) /* gp_pj_utl.c: 676 */ -#define EPJ128 (ERRPJ + 128) /* gp_pj_utl.c: 782 */ -#define EPJ129 (ERRPJ + 129) /* gp_pj_utl.c: 794 */ -#define EPJ130 (ERRPJ + 130) /* gp_pj_utl.c: 805 */ -#define EPJ131 (ERRPJ + 131) /* gp_pj_utl.c: 826 */ -#define EPJ132 (ERRPJ + 132) /* gp_pj_utl.c: 905 */ -#define EPJ133 (ERRPJ + 133) /* gp_pj_utl.c: 919 */ -#define EPJ134 (ERRPJ + 134) /* gp_pj_utl.c: 926 */ -#define EPJ135 (ERRPJ + 135) /* gp_pj_utl.c:1027 */ -#define EPJ136 (ERRPJ + 136) /* gp_pj_utl.c:1042 */ -#define EPJ137 (ERRPJ + 137) /* gp_pj_utl.c:1070 */ -#define EPJ138 (ERRPJ + 138) /* gp_pj_utl.c:1205 */ -#define EPJ139 (ERRPJ + 139) /* gp_pj_utl.c:1222 */ -#define EPJ140 (ERRPJ + 140) /* gp_pj_utl.c:1232 */ -#define EPJ141 (ERRPJ + 141) /* gp_pj_utl.c:2460 */ -#define EPJ142 (ERRPJ + 142) /* gp_pj_utl.c:2470 */ -#define EPJ143 (ERRPJ + 143) /* gp_pj_utl.c:2642 */ -#define EPJ144 (ERRPJ + 144) /* gp_pj_utl.c:2874 */ -#define EPJ145 (ERRPJ + 145) /* gp_pj_utl.c:2963 */ -#define EPJ146 (ERRPJ + 146) /* gp_pj_utl.c:3153 */ -#define EPJ147 (ERRPJ + 147) /* gp_pj_utl.c:3171 */ -#define EPJ148 (ERRPJ + 148) /* gp_pj_utl.c:3219 */ -#define EPJ149 (ERRPJ + 149) /* gp_pj_utl.c:3322 */ -#define EPJ150 (ERRPJ + 150) /* gp_pj_utl.c:3353 */ -#define EPJ151 (ERRPJ + 151) /* gp_pj_utl.c:3412 */ -#define EPJ152 (ERRPJ + 152) /* gp_pj_utl.c:3449 */ -#define EPJ153 (ERRPJ + 153) /* gp_pj_utl.c:3540 */ - -#define EPJ154 (ERRPJ + 154) /* gp_pj_utl.c.tmp: 213 */ -#define EPJ155 (ERRPJ + 155) /* gp_pj_utl.c.tmp: 221 */ -#define EPJ156 (ERRPJ + 156) /* gp_pj_utl.c.tmp: 291 */ -#define EPJ157 (ERRPJ + 157) /* gp_pj_utl.c.tmp: 356 */ -#define EPJ158 (ERRPJ + 158) /* gp_pj_utl.c.tmp: 421 */ -#define EPJ159 (ERRPJ + 159) /* gp_pj_utl.c.tmp: 510 */ -#define EPJ160 (ERRPJ + 160) /* gp_pj_utl.c.tmp: 525 */ -#define EPJ161 (ERRPJ + 161) /* gp_pj_utl.c.tmp: 532 */ -#define EPJ162 (ERRPJ + 162) /* gp_pj_utl.c.tmp: 554 */ -#define EPJ163 (ERRPJ + 163) /* gp_pj_utl.c.tmp: 640 */ -#define EPJ164 (ERRPJ + 164) /* gp_pj_utl.c.tmp: 652 */ -#define EPJ165 (ERRPJ + 165) /* gp_pj_utl.c.tmp: 676 */ -#define EPJ166 (ERRPJ + 166) /* gp_pj_utl.c.tmp: 782 */ -#define EPJ167 (ERRPJ + 167) /* gp_pj_utl.c.tmp: 794 */ -#define EPJ168 (ERRPJ + 168) /* gp_pj_utl.c.tmp: 805 */ -#define EPJ169 (ERRPJ + 169) /* gp_pj_utl.c.tmp: 826 */ -#define EPJ170 (ERRPJ + 170) /* gp_pj_utl.c.tmp: 905 */ -#define EPJ171 (ERRPJ + 171) /* gp_pj_utl.c.tmp: 919 */ -#define EPJ172 (ERRPJ + 172) /* gp_pj_utl.c.tmp: 926 */ -#define EPJ173 (ERRPJ + 173) /* gp_pj_utl.c.tmp:1027 */ -#define EPJ174 (ERRPJ + 174) /* gp_pj_utl.c.tmp:1042 */ -#define EPJ175 (ERRPJ + 175) /* gp_pj_utl.c.tmp:1070 */ -#define EPJ176 (ERRPJ + 176) /* gp_pj_utl.c.tmp:1205 */ -#define EPJ177 (ERRPJ + 177) /* gp_pj_utl.c.tmp:1222 */ -#define EPJ178 (ERRPJ + 178) /* gp_pj_utl.c.tmp:1232 */ -#define EPJ179 (ERRPJ + 179) /* gp_pj_utl.c.tmp:2460 */ -#define EPJ180 (ERRPJ + 180) /* gp_pj_utl.c.tmp:2470 */ -#define EPJ181 (ERRPJ + 181) /* gp_pj_utl.c.tmp:2642 */ -#define EPJ182 (ERRPJ + 182) /* gp_pj_utl.c.tmp:2874 */ -#define EPJ183 (ERRPJ + 183) /* gp_pj_utl.c.tmp:2963 */ -#define EPJ184 (ERRPJ + 184) /* gp_pj_utl.c.tmp:3153 */ -#define EPJ185 (ERRPJ + 185) /* gp_pj_utl.c.tmp:3171 */ -#define EPJ186 (ERRPJ + 186) /* gp_pj_utl.c.tmp:3219 */ -#define EPJ187 (ERRPJ + 187) /* gp_pj_utl.c.tmp:3322 */ -#define EPJ188 (ERRPJ + 188) /* gp_pj_utl.c.tmp:3353 */ -#define EPJ189 (ERRPJ + 189) /* gp_pj_utl.c.tmp:3412 */ -#define EPJ190 (ERRPJ + 190) /* gp_pj_utl.c.tmp:3449 */ -#define EPJ191 (ERRPJ + 191) /* gp_pj_utl.c.tmp:3540 */ - -#define EPJ192 (ERRPJ + 192) /* gp_ptui.c: 666 */ -#define EPJ193 (ERRPJ + 193) /* gp_ptui.c: 709 */ -#define EPJ194 (ERRPJ + 194) /* gp_ptui.c: 752 */ -#define EPJ195 (ERRPJ + 195) /* gp_ptui.c: 795 */ -#define EPJ196 (ERRPJ + 196) /* gp_ptui.c: 842 */ -#define EPJ197 (ERRPJ + 197) /* gp_ptui.c:1081 */ -#define EPJ198 (ERRPJ + 198) /* gp_ptui.c:1123 */ -#define EPJ199 (ERRPJ + 199) /* gp_ptui.c:1158 */ - -#define EPJ200 (ERRPJ + 200) /* gp_tmm.c: 213 */ -#define EPJ201 (ERRPJ + 201) /* gp_tmm.c: 303 */ -#define EPJ202 (ERRPJ + 202) /* gp_tmm.c: 405 */ -#define EPJ203 (ERRPJ + 203) /* gp_tmm.c: 519 */ - -#define EPJ204 (ERRPJ + 204) /* gp_tmr.c: 253 */ -#define EPJ205 (ERRPJ + 205) /* gp_tmr.c: 358 */ -#define EPJ206 (ERRPJ + 206) /* gp_tmr.c: 554 */ - -#define EPJ207 (ERRPJ + 207) /* gp_uim.c: 276 */ -#define EPJ208 (ERRPJ + 208) /* gp_uim.c: 358 */ -#define EPJ209 (ERRPJ + 209) /* gp_uim.c: 437 */ -#define EPJ210 (ERRPJ + 210) /* gp_uim.c: 690 */ -#define EPJ211 (ERRPJ + 211) /* gp_uim.c: 769 */ -#define EPJ212 (ERRPJ + 212) /* gp_uim.c: 832 */ -#define EPJ213 (ERRPJ + 213) /* gp_uim.c: 912 */ - -#define EPJ214 (ERRPJ + 214) /* gp_umm.c: 213 */ -#define EPJ215 (ERRPJ + 215) /* gp_umm.c: 706 */ -#define EPJ216 (ERRPJ + 216) /* gp_umm.c:1248 */ - -#define EPJ217 (ERRPJ + 217) /* gp_utl.c: 227 */ -#define EPJ218 (ERRPJ + 218) /* gp_utl.c: 237 */ -#define EPJ219 (ERRPJ + 219) /* gp_utl.c: 263 */ -#define EPJ220 (ERRPJ + 220) /* gp_utl.c: 278 */ -#define EPJ221 (ERRPJ + 221) /* gp_utl.c: 383 */ -#define EPJ222 (ERRPJ + 222) /* gp_utl.c: 401 */ -#define EPJ223 (ERRPJ + 223) /* gp_utl.c: 413 */ -#define EPJ224 (ERRPJ + 224) /* gp_utl.c: 473 */ -#define EPJ225 (ERRPJ + 225) /* gp_utl.c: 598 */ -#define EPJ226 (ERRPJ + 226) /* gp_pj_tmr.c: 291 */ -#define EPJ227 (ERRPJ + 227) /* gp_pj_tmr.c: 576 */ -#define EPJ228 (ERRPJ + 228) -#define EPJ229 (ERRPJ + 229) -#endif /* __KW_ERR_H__ */ - -/********************************************************************30** - - End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_id.c b/src/5gnrpdcp/pj_id.c deleted file mode 100755 index f9d6e3197..000000000 --- a/src/5gnrpdcp/pj_id.c +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: LTE-PDCP Layer - - Type: C source file - - Desc: - - File: pj_id.c - -*********************************************************************21*/ - - -/* header include files (.h) */ - -#include "envopt.h" /* environment options */ -#include "envdep.h" /* environment dependent */ -#include "envind.h" /* environment independent */ - -#include "gen.h" /* general */ -#include "ssi.h" /* system services interface */ - -/* header/extern include files (.x) */ - -#include "gen.x" /* general */ -#include "ssi.x" /* system services interface */ - - -/* local defines */ - -#define KWSWMV 2 /* rlc - main version */ -#define KWSWMR 1 /* rlc - main revision */ -#define KWSWBV 0 /* rlc - branch version */ -#define KWSWBR 5 /* rlc - kw005.201 patch level */ -#define KWSWPN "1000371" /* rlc - part number */ - -/* local typedefs */ - -/* local externs */ - -/* forward references */ - -/* public variable declarations */ - -#ifdef __cplusplus -EXTERN "C" { -#endif /* CPLUSPLUS */ - -EXTERN S16 pjGetSId ARGS((SystemId *s)); -#ifdef __cplusplus -} -#endif /* CPLUSPLUS */ - -/* copyright banner */ - -PUBLIC CONSTANT Txt pjBan1[] = - {"(c) COPYRIGHT 1989-2002, Trillium Digital Systems, Inc."}; - -PUBLIC CONSTANT Txt pjBan2[] = - {" All rights reserved."}; - -/* system id */ - -PRIVATE CONSTANT SystemId sId ={ - KWSWMV, /* rlc - main version */ - KWSWMR, /* rlc - main revision */ - KWSWBV, /* rlc - branch version */ - KWSWBR, /* rlc - branch revision */ - KWSWPN /* rlc - part number */ -}; - -/* -* support functions -*/ - -/* -* -* Fun: get system id -* -* Desc: Get system id consisting of part number, main version and -* revision and branch version and branch. -* -* Ret: TRUE - ok -* -* Notes: None -* -* File: kw_id.c -* -*/ - -#ifdef ANSI -PUBLIC S16 pjGetSId -( -SystemId *s /* system id */ -) -#else -PUBLIC S16 pjGetSId(s) -SystemId *s; /* system id */ -#endif -{ - TRC2(pjGetSId); - - s->mVer = sId.mVer; - s->mRev = sId.mRev; - s->bVer = sId.bVer; - s->bRev = sId.bRev; - s->ptNmb = sId.ptNmb; - - RETVALUE(TRUE); - -} /* end of pjGetSId */ - - -/********************************************************************30** - - End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_lib.c b/src/5gnrpdcp/pj_lib.c deleted file mode 100755 index 322e2e635..000000000 --- a/src/5gnrpdcp/pj_lib.c +++ /dev/null @@ -1,1801 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: LTE-PDCP Layer - Upper Interface - - Type: C file - - Desc: C source code for the hook functions of LTE-PDCP - - This file contains the following functions: - - --pjLibCmpInit - --pjLibIntInit - --pjLibCpInit - --pjLibUpInit - --pjLibCmpReset - --pjLibCmpSdu - --pjLibIntProt - --pjLibIntVerify - --pjLibDecipherSdu - --pjLibSndFeedback - --pjLibCmpClose - --pjLibIntClose - --pjLibCpClose - --pjLibUpClose - - Portable functions for software hooks: - - --pjLibCmpInitReq - --pjLibIntInitReq - --pjLibCpInitReq - --pjLibUpInitReq - --pjLibCmpResetReq - --pjLibCmpReq - --pjLibIntProtReq - --pjLibCipherReq - --pjLibDecipherReq - --pjLibIntVerReq - --pjLibDeCmpReq - --pjLibCmpCloseReq - --pjLibIntCloseReq - --pjLibCiperCloseReq - --pjLibUpCloseReq - - - File: pj_lib.c - -*********************************************************************21*/ - -/** @file pj_lib.c -@brief PDPC Hook Interface -*/ - - -/* header (.h) include files */ -#include "envopt.h" /* environment options */ -#include "envdep.h" /* environment dependent */ -#include "envind.h" /* environment independent */ - -#include "gen.h" /* general */ -#include "ssi.h" /* system services */ -#include "cm5.h" /* common timer defines */ -#include "cm_tkns.h" /* common tokens defines */ -#include "cm_mblk.h" /* common memory allocation library defines */ -#include "cm_llist.h" /* common link list defines */ -#include "cm_hash.h" /* common hash list defines */ -#include "cm_lte.h" /* common LTE defines */ -#include "cpj.h" /* RRC layer */ -#include "pju.h" /* PDCP service user */ -#include "lpj.h" /* LPJ defines */ -#include "pj_err.h" -#include "pj_env.h" /* RLC environment options */ -#include "pj_lib.h" /* LIB options */ -#include "pj.h" /* RLC defines */ -#include "pj_dl.h" - -/* extern (.x) include files */ -#include "gen.x" /* general */ -#include "ssi.x" /* system services */ - -#include "cm5.x" /* common timer library */ -#include "cm_tkns.x" /* common tokens */ -#include "cm_mblk.x" /* common memory allocation */ -#include "cm_llist.x" /* common link list */ -#include "cm_hash.x" /* common hash list */ -#include "cm_lte.x" /* common LTE includes */ -#include "cm_lib.x" /* common memory allocation library */ -#include "cpj.x" /* CPJ */ -#include "pju.x" /* PJU */ -#include "lpj.x" /* LPJ */ - -#include "pj.x" -#include "pj_udx.h" -#include "pj_udx.x" -#include "pj_dl.x" -#include "pj_lib.x" /* LIB */ - -#ifdef __cplusplus -EXTERN "C" { -#endif /* __cplusplus */ - - -/**************************************************************************** - * Portable hooks for asynchronous - ***************************************************************************/ - -#ifdef PJ_CMP_ASYNC -#ifdef ANSI -PUBLIC S16 cmPkLibObdCmpInitCfm -( -Pst * pst, -PjCmpCxt cmpCxt, -PTR ctxId -) -#else -PUBLIC S16 cmPkLibObdCmpInitCfm(pst, cmpCxt, ctxId) -Pst * pst; -PjCmpCxt cmpCxt; -PTR ctxId; -#endif -{ - Buffer *mBuf = NULLP; - TRC3(cmPkLibObdCmpInitCfm) - - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB001, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - if (cmPkPtr(ctxId, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB002, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - if (cmPkPjCmpCxt(&cmpCxt, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB003, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - pst->event = (Event) OBD_EVT_CMP_INIT_CFM; - RETVALUE(SPstTsk(pst,mBuf)); -} - -#ifdef ANSI -PUBLIC S16 cmUnpkLibObdCmpInitCfm -( -ObdCmpInitCfm func, -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkLibObdCmpInitCfm(func, pst, mBuf) -ObdCmpInitCfm func; -Pst *pst; -Buffer *mBuf; -#endif -{ - PjCmpCxt cmpCxt; - PTR ctxId; - - TRC3(cmUnpkLibObdCmpInitCfm) - - if (cmUnpkPjCmpCxt(&cmpCxt, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB004, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - if (cmUnpkPtr(&ctxId, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB005, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - PJ_FREE_BUF(mBuf); - RETVALUE((*func)(pst, cmpCxt, ctxId)); -} - -#ifdef ANSI -PUBLIC S16 cmPkLibObdCmpCfm -( -Pst * pst, -PTR cmpCxtId, -PjLibTrans libTrans, -Buffer * opSdu -) -#else -PUBLIC S16 cmPkLibObdCmpCfm(pst, cmpCxtId, libTrans, opSdu) -Pst * pst; -PTR cmpCxtId; -PjLibTrans libTrans; -Buffer * opSdu; -#endif -{ - Buffer *mBuf = NULLP; - MsgLen msgLen = 0; - TRC3(cmPkLibObdCmpCfm) - - if (pst->selector == OBD_SEL_LC) { - if ( opSdu != NULLP ) - { - if (SFndLenMsg(opSdu, &msgLen) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB022, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(opSdu); - RETVALUE(RFAILED); - } - if (SCpyMsgMsg(opSdu, pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB023, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - } - else - { - msgLen = 0; - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB036, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - } - CMCHKPK(cmPkMsgLen, msgLen, mBuf); - - } - else - { - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB021, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - } - - if (cmPkPjLibTrans(&libTrans, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB025, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - if (cmPkPtr(cmpCxtId, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB026, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - pst->event = (Event) OBD_EVT_CMP_CFM; - RETVALUE(SPstTsk(pst,mBuf)); -} - -#ifdef ANSI -PUBLIC S16 cmUnpkLibObdCmpCfm -( -ObdCmpCfm func, -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkLibObdCmpCfm(func, pst, mBuf) -ObdCmpCfm func; -Pst *pst; -Buffer *mBuf; -#endif -{ - PTR cmpCxtId; - PjLibTrans libTrans; - Buffer *opSdu; - - TRC3(cmUnpkLibObdCmpCfm) - - opSdu = NULLP; - - if (cmUnpkPtr(&cmpCxtId, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB027, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - if (cmUnpkPjLibTrans(&libTrans, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB028, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - if (pst->selector == OBD_SEL_LC) { - MsgLen msgLen, totalMsgLen; - CMCHKUNPK(cmUnpkMsgLen, &msgLen, mBuf); - if (SFndLenMsg(mBuf, &totalMsgLen) != ROK) - RETVALUE(RFAILED); - if ( msgLen != 0 ) - { - if (SSegMsg(mBuf, totalMsgLen-msgLen, &opSdu) != ROK) - RETVALUE(RFAILED); - } - } - - PJ_FREE_BUF(mBuf); - RETVALUE((*func)(pst, cmpCxtId, libTrans, opSdu)); -} - -#ifdef ANSI -PUBLIC S16 cmPkLibObdDecmpCfm -( -Pst * pst, -PTR cmpCxtId, -PjLibTrans libTrans, -Buffer * opSdu, -Buffer * fbPkt -) -#else -PUBLIC S16 cmPkLibObdDecmpCfm(pst, cmpCxtId, libTrans, opSdu, fbPkt) -Pst * pst; -PTR cmpCxtId; -PjLibTrans libTrans; -Buffer * opSdu; -Buffer * fbPkt; -#endif -{ - Buffer *mBuf = NULLP; - Buffer *tBuf = NULLP; - MsgLen msgLen = 0; - TRC3(cmPkLibObdDecmpCfm) - - if (fbPkt != NULLP) { - if (SFndLenMsg(fbPkt, &msgLen) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB060, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - if (SCpyMsgMsg(fbPkt, pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB061, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - }else{ - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB059, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - - msgLen = 0; - } - CMCHKPK(cmPkMsgLen, msgLen, mBuf); - - if (opSdu != NULLP) { - if (SFndLenMsg(opSdu, &msgLen) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB060, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - if (SCpyMsgMsg(opSdu, pst->region, pst->pool, &tBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB061, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - if (SCatMsg(mBuf, tBuf, M1M2) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB061, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(mBuf); - PJ_FREE_BUF(tBuf); - RETVALUE(RFAILED); - } - - if (tBuf != NULLP) - PJ_FREE_BUF(tBuf); - } else { - msgLen = 0; - } - CMCHKPK(cmPkMsgLen, msgLen, mBuf); - - if (cmPkPjLibTrans(&libTrans, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB063, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - if (cmPkPtr(cmpCxtId, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB064, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - pst->event = (Event) OBD_EVT_DECMP_CFM; - RETVALUE(SPstTsk(pst,mBuf)); -} - -#ifdef ANSI -PUBLIC S16 cmUnpkLibObdDecmpCfm -( -ObdDecmpCfm func, -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkLibObdDecmpCfm(func, pst, mBuf) -ObdDecmpCfm func; -Pst *pst; -Buffer *mBuf; -#endif -{ - PTR cmpCxtId; - PjLibTrans libTrans; - Buffer *opSdu = NULLP; - Buffer *fbPkt = NULLP; - - TRC3(cmUnpkLibObdDecmpCfm) - - if (cmUnpkPtr(&cmpCxtId, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB065, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - if (cmUnpkPjLibTrans(&libTrans, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB066, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - if (pst->selector == OBD_SEL_LC) { - MsgLen msgLen, totalMsgLen; - CMCHKUNPK(cmUnpkMsgLen, &msgLen, mBuf); - if (SFndLenMsg(mBuf, &totalMsgLen) != ROK) - RETVALUE(RFAILED); - if(msgLen != 0) - if (SSegMsg(mBuf, totalMsgLen-msgLen, &opSdu) != ROK) - RETVALUE(RFAILED); - } - - if (pst->selector == OBD_SEL_LC) { - MsgLen msgLen, totalMsgLen; - CMCHKUNPK(cmUnpkMsgLen, &msgLen, mBuf); - if (SFndLenMsg(mBuf, &totalMsgLen) != ROK) - RETVALUE(RFAILED); - if(msgLen != 0) - if (SSegMsg(mBuf, totalMsgLen-msgLen, &fbPkt) != ROK) - RETVALUE(RFAILED); - } - - PJ_FREE_BUF(mBuf); - RETVALUE((*func)(pst, cmpCxtId, libTrans, opSdu, fbPkt)); -} - - -/*********************************************************** -* -* Func : cmPkPjRohc -* -* -* Desc : PjHdrCmp - Robust header compression Information -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmPkPjRohc -( -PjRohc *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjRohc(param, mBuf) -PjRohc *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmPkPjRohc) - - CMCHKPK(SPkU16, param->profId, mBuf); - CMCHKPK(SPkU16, param->maxCid, mBuf); - CMCHKPK(SPkU8, param->hdrCmpUsed, mBuf); - RETVALUE(ROK); -} - - -/*********************************************************** -* -* Func : cmUnpkPjRohc -* -* -* Desc : PjHdrCmp - Robust header compression Information -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjRohc -( -PjRohc *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjRohc(param, mBuf) -PjRohc *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmUnpkPjRohc) - - CMCHKUNPK(SUnpkU8, ¶m->hdrCmpUsed, mBuf); - CMCHKUNPK(SUnpkU16, ¶m->maxCid, mBuf); - CMCHKUNPK(SUnpkU16, ¶m->profId, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmPkPjCmpCxt -* -* -* Desc : PjCmpCxt -Context for ROHC -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmPkPjCmpCxt -( -PjCmpCxt *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjCmpCxt(param, mBuf) -PjCmpCxt *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmPkPjCmpCxt) - - CMCHKPK(cmPkLteRbId, param->rbId, mBuf); - CMCHKPK(cmPkLteRnti, param->ueId, mBuf); - CMCHKPK(cmPkLteCellId, param->cellId, mBuf); - CMCHKPK(SPkU8, param->rbType, mBuf); - CMCHKPK(SPkU16, param->cfgTxId, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmUnpkPjCmpCxt -* -* -* Desc : PjCmpCxt -Context for ROHC -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjCmpCxt -( -PjCmpCxt *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjCmpCxt(param, mBuf) -PjCmpCxt *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmUnpkPjCmpCxt) - - CMCHKUNPK(SUnpkU16, ¶m->cfgTxId, mBuf); - CMCHKUNPK(SUnpkU8, ¶m->rbType, mBuf); - CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); - CMCHKUNPK(cmUnpkLteRnti, ¶m->ueId, mBuf); - CMCHKUNPK(cmUnpkLteRbId, ¶m->rbId, mBuf); - RETVALUE(ROK); -} - -#endif /* PJ_CMP_ASYNC */ - -#ifdef PJ_SEC_ASYNC -#ifdef ANSI -PUBLIC S16 cmPkLibObdIntInitCfm -( -Pst * pst, -PjSecCxt secCtx, -PTR ctxId -) -#else -PUBLIC S16 cmPkLibObdIntInitCfm(pst, secCtx, ctxId) -Pst * pst; -PjSecCxt secCtx; -PTR ctxId; -#endif -{ - Buffer *mBuf = NULLP; - TRC3(cmPkLibObdIntInitCfm) - - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB006, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - if (cmPkPtr(ctxId, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB007, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - if (cmPkPjSecCxt(&secCtx, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB008, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - pst->event = (Event) OBD_EVT_INT_INIT_CFM; - RETVALUE(SPstTsk(pst,mBuf)); -} - -#ifdef ANSI -PUBLIC S16 cmUnpkLibObdIntInitCfm -( -ObdIntInitCfm func, -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkLibObdIntInitCfm(func, pst, mBuf) -ObdIntInitCfm func; -Pst *pst; -Buffer *mBuf; -#endif -{ - PjSecCxt secCtx; - PTR ctxId; - - TRC3(cmUnpkLibObdIntInitCfm) - - if (cmUnpkPjSecCxt(&secCtx, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB009, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - if (cmUnpkPtr(&ctxId, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB010, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - PJ_FREE_BUF(mBuf); - RETVALUE((*func)(pst, secCtx, ctxId)); -} - -#ifdef ANSI -PUBLIC S16 cmPkLibObdCpInitCfm -( -Pst * pst, -PjSecCxt secCxt, -PTR ctxId -) -#else -PUBLIC S16 cmPkLibObdCpInitCfm(pst, secCxt, ctxId) -Pst * pst; -PjSecCxt secCxt; -PTR ctxId; -#endif -{ - Buffer *mBuf = NULLP; - TRC3(cmPkLibObdCpInitCfm) - - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB011, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - if (cmPkPtr(ctxId, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB012, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - if (cmPkPjSecCxt(&secCxt, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB013, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - pst->event = (Event) OBD_EVT_CP_INIT_CFM; - RETVALUE(SPstTsk(pst,mBuf)); -} - -#ifdef ANSI -PUBLIC S16 cmUnpkLibObdCpInitCfm -( -ObdCpInitCfm func, -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkLibObdCpInitCfm(func, pst, mBuf) -ObdCpInitCfm func; -Pst *pst; -Buffer *mBuf; -#endif -{ - PjSecCxt secCxt; - PTR ctxId; - - TRC3(cmUnpkLibObdCpInitCfm) - - if (cmUnpkPjSecCxt(&secCxt, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB014, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - if (cmUnpkPtr(&ctxId, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB015, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - PJ_FREE_BUF(mBuf); - RETVALUE((*func)(pst, secCxt, ctxId)); -} - -#ifdef ANSI -PUBLIC S16 cmPkLibObdUpInitCfm -( -Pst * pst, -PjSecCxt secCxt, -PTR ctxId -) -#else -PUBLIC S16 cmPkLibObdUpInitCfm(pst, secCxt, ctxId) -Pst * pst; -PjSecCxt secCxt; -PTR ctxId; -#endif -{ - Buffer *mBuf = NULLP; - TRC3(cmPkLibObdUpInitCfm) - - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB016, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - if (cmPkPtr(ctxId, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB017, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - if (cmPkPjSecCxt(&secCxt, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB018, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - pst->event = (Event) OBD_EVT_UP_INIT_CFM; - RETVALUE(SPstTsk(pst,mBuf)); -} - -#ifdef ANSI -PUBLIC S16 cmUnpkLibObdUpInitCfm -( -ObdUpInitCfm func, -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkLibObdUpInitCfm(func, pst, mBuf) -ObdUpInitCfm func; -Pst *pst; -Buffer *mBuf; -#endif -{ - PjSecCxt secCxt; - PTR ctxId; - - TRC3(cmUnpkLibObdUpInitCfm) - - if (cmUnpkPjSecCxt(&secCxt, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB019, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - if (cmUnpkPtr(&ctxId, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB020, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - PJ_FREE_BUF(mBuf); - RETVALUE((*func)(pst, secCxt, ctxId)); -} - -#ifdef ANSI -PUBLIC S16 cmPkLibObdIntProtCfm -( -Pst * pst, -PTR cxtId, -PjLibTrans libTrans, -U32 macI -) -#else -PUBLIC S16 cmPkLibObdIntProtCfm(pst, cxtId, libTrans, macI) -Pst * pst; -PTR cxtId; -PjLibTrans libTrans; -U32 macI; -#endif -{ - Buffer *mBuf = NULLP; - TRC3(cmPkLibObdIntProtCfm) - - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB029, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - if (SPkU32(macI, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB030, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - if (cmPkPjLibTrans(&libTrans, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB031, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - if (cmPkPtr(cxtId, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB032, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - pst->event = (Event) OBD_EVT_INT_PROT_CFM; - RETVALUE(SPstTsk(pst,mBuf)); -} - -#ifdef ANSI -PUBLIC S16 cmUnpkLibObdIntProtCfm -( -ObdIntProtCfm func, -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkLibObdIntProtCfm(func, pst, mBuf) -ObdIntProtCfm func; -Pst *pst; -Buffer *mBuf; -#endif -{ - PTR cxtId; - PjLibTrans libTrans; - U32 macI; - - TRC3(cmUnpkLibObdIntProtCfm) - - if (cmUnpkPtr(&cxtId, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB033, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - if (cmUnpkPjLibTrans(&libTrans, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB034, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - if (SUnpkU32(&macI, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB035, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - PJ_FREE_BUF(mBuf); - RETVALUE((*func)(pst, cxtId, libTrans, macI)); -} - -#ifdef ANSI -PUBLIC S16 cmPkLibObdCipherCfm -( -Pst * pst, -PTR cxtId, -PjLibTrans libTrans, -Buffer * opSdu -) -#else -PUBLIC S16 cmPkLibObdCipherCfm(pst, cxtId, libTrans, opSdu) -Pst * pst; -PTR cxtId; -PjLibTrans libTrans; -Buffer * opSdu; -#endif -{ - Buffer *mBuf = NULLP; - MsgLen msgLen = 0; - TRC3(cmPkLibObdCipherCfm) - - if (pst->selector == OBD_SEL_LC) { - if ( opSdu != NULLP ) - { - if (SFndLenMsg(opSdu, &msgLen) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB037, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(opSdu); - RETVALUE(RFAILED); - } - if (SCpyMsgMsg(opSdu, pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB038, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(opSdu); - RETVALUE(RFAILED); - } - /* SPutMsg(opSdu); */ - } - else - { - msgLen = 0; - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB036, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - } - CMCHKPK(cmPkMsgLen, msgLen, mBuf); - - } - else - { - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB036, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(opSdu); - RETVALUE(RFAILED); - } - } - - - if (cmPkPjLibTrans(&libTrans, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB040, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(opSdu); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - if (cmPkPtr(cxtId, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB041, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(opSdu); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - pst->event = (Event) OBD_EVT_CIPHER_CFM; - RETVALUE(SPstTsk(pst,mBuf)); -} - -#ifdef ANSI -PUBLIC S16 cmUnpkLibObdCipherCfm -( -ObdCipherCfm func, -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkLibObdCipherCfm(func, pst, mBuf) -ObdCipherCfm func; -Pst *pst; -Buffer *mBuf; -#endif -{ - PTR cxtId; - PjLibTrans libTrans; - Buffer *opSdu; - - TRC3(cmUnpkLibObdCipherCfm) - - opSdu = NULLP; - - if (cmUnpkPtr(&cxtId, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB042, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - if (cmUnpkPjLibTrans(&libTrans, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB043, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - - if (pst->selector == OBD_SEL_LC) { - MsgLen msgLen, totalMsgLen; - CMCHKUNPK(cmUnpkMsgLen, &msgLen, mBuf); - if (SFndLenMsg(mBuf, &totalMsgLen) != ROK) - RETVALUE(RFAILED); - if ( msgLen != 0 ) - { - if (SSegMsg(mBuf, totalMsgLen-msgLen, &opSdu) != ROK) - { - RETVALUE(RFAILED); - } - } - } - - PJ_FREE_BUF(mBuf); - RETVALUE((*func)(pst, cxtId, libTrans, opSdu)); -} - -#ifdef ANSI -PUBLIC S16 cmPkLibObdDecipherCfm -( -Pst * pst, -PTR cxtId, -PjLibTrans libTrans, -Buffer * opSdu -) -#else -PUBLIC S16 cmPkLibObdDecipherCfm(pst, cxtId, libTrans, opSdu) -Pst * pst; -PTR cxtId; -PjLibTrans libTrans; -Buffer * opSdu; -#endif -{ - Buffer *mBuf = NULLP; - MsgLen msgLen = 0; - TRC3(cmPkLibObdDecipherCfm) - - if (pst->selector == OBD_SEL_LC) { - if ( opSdu != NULLP) - { - if (SFndLenMsg(opSdu, &msgLen) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB045, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - if (SCpyMsgMsg(opSdu, pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB046, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - } - else - { - msgLen = 0; - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB036, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - } - CMCHKPK(cmPkMsgLen, msgLen, mBuf); - - } - else - { - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB044, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - } - - if (cmPkPjLibTrans(&libTrans, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB048, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - if (cmPkPtr(cxtId, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB049, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - pst->event = (Event) OBD_EVT_DECIPHER_CFM; - RETVALUE(SPstTsk(pst,mBuf)); -} - -#ifdef ANSI -PUBLIC S16 cmUnpkLibObdDecipherCfm -( -ObdDecipherCfm func, -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkLibObdDecipherCfm(func, pst, mBuf) -ObdDecipherCfm func; -Pst *pst; -Buffer *mBuf; -#endif -{ - PTR cxtId; - PjLibTrans libTrans; - Buffer *opSdu= NULLP; - - TRC3(cmUnpkLibObdDecipherCfm) - - if (cmUnpkPtr(&cxtId, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB050, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - if (cmUnpkPjLibTrans(&libTrans, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB051, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - if (pst->selector == OBD_SEL_LC) { - MsgLen msgLen, totalMsgLen; - CMCHKUNPK(cmUnpkMsgLen, &msgLen, mBuf); - if (SFndLenMsg(mBuf, &totalMsgLen) != ROK) - RETVALUE(RFAILED); - if ( msgLen != 0 ) - { - if (SSegMsg(mBuf, totalMsgLen-msgLen, &opSdu) != ROK) - RETVALUE(RFAILED); - } - } - - PJ_FREE_BUF(mBuf); - RETVALUE((*func)(pst, cxtId, libTrans, opSdu)); -} - -#ifdef ANSI -PUBLIC S16 cmPkLibObdIntVerCfm -( -Pst * pst, -PTR cxtId, -PjLibTrans libTrans, -Status status -) -#else -PUBLIC S16 cmPkLibObdIntVerCfm(pst, cxtId, libTrans, status) -Pst * pst; -PTR cxtId; -PjLibTrans libTrans; -Status status; -#endif -{ - Buffer *mBuf = NULLP; - TRC3(cmPkLibObdIntVerCfm) - - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB052, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - if (SPkS16(status, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB053, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - if (cmPkPjLibTrans(&libTrans, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB054, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - if (cmPkPtr(cxtId, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB055, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - pst->event = (Event) OBD_EVT_INT_VER_CFM; - RETVALUE(SPstTsk(pst,mBuf)); -} - -#ifdef ANSI -PUBLIC S16 cmUnpkLibObdIntVerCfm -( -ObdIntVerCfm func, -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkLibObdIntVerCfm(func, pst, mBuf) -ObdIntVerCfm func; -Pst *pst; -Buffer *mBuf; -#endif -{ - PTR cxtId; - PjLibTrans libTrans; - Status status; - - TRC3(cmUnpkLibObdIntVerCfm) - - if (cmUnpkPtr(&cxtId, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB056, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - if (cmUnpkPjLibTrans(&libTrans, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB057, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - if (SUnpkS16(&status, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ELIB058, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - PJ_FREE_BUF(mBuf); - RETVALUE((*func)(pst, cxtId, libTrans, status)); -} - - -/*********************************************************** -* -* Func : cmPkPjSecCxt -* -* -* Desc : PjSecCxt -Context for Security Algorithm -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmPkPjSecCxt -( -PjSecCxt *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjSecCxt(param, mBuf) -PjSecCxt *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmPkPjSecCxt) - - CMCHKPK(cmPkLteRnti, param->ueId, mBuf); - CMCHKPK(cmPkLteCellId, param->cellId, mBuf); - CMCHKPK(SPkU16, param->cfgTxId, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmUnpkPjSecCxt -* -* -* Desc : PjSecCxt -Context for Security Algorithm -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjSecCxt -( -PjSecCxt *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjSecCxt(param, mBuf) -PjSecCxt *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmUnpkPjSecCxt) - - CMCHKUNPK(SUnpkU16, ¶m->cfgTxId, mBuf); - CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); - CMCHKUNPK(cmUnpkLteRnti, ¶m->ueId, mBuf); - RETVALUE(ROK); -} - - -/*********************************************************** -* -* Func : cmPkPjIntInfo -* -* -* Desc : PjIntInfo - PDCP Integrity Algo Information -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmPkPjIntInfo -( -PjIntInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjIntInfo(param, mBuf) -PjIntInfo *param; -Buffer *mBuf; -#endif -{ - - S32 i; - TRC3(cmPkPjIntInfo) - - for (i=PJ_INTG_KEY_LEN-1; i >= 0; i--) { - CMCHKPK(SPkU8, param->intKey[i], mBuf); - } - CMCHKPK(SPkU8, param->algoType, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmUnpkPjIntInfo -* -* -* Desc : PjIntInfo - PDCP Integrity Algo Information -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjIntInfo -( -PjIntInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjIntInfo(param, mBuf) -PjIntInfo *param; -Buffer *mBuf; -#endif -{ - - S32 i; - TRC3(cmUnpkPjIntInfo) - - CMCHKUNPK(SUnpkU8, ¶m->algoType, mBuf); - for (i=0; iintKey[i], mBuf); - } - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmPkPjSecInp -* -* -* Desc : PjSecInp -Input parameters for security algorithm -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmPkPjSecInp -( -PjSecInp *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjSecInp(param, mBuf) -PjSecInp *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmPkPjSecInp) - - CMCHKPK(SPkU8, param->dir, mBuf); - CMCHKPK(cmPkLteRbId, param->rbId, mBuf); - CMCHKPK(SPkU32, param->count, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmUnpkPjSecInp -* -* -* Desc : PjSecInp -Input parameters for security algorithm -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjSecInp -( -PjSecInp *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjSecInp(param, mBuf) -PjSecInp *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmUnpkPjSecInp) - - CMCHKUNPK(SUnpkU32, ¶m->count, mBuf); - CMCHKUNPK(cmUnpkLteRbId, ¶m->rbId, mBuf); - CMCHKUNPK(SUnpkU8, ¶m->dir, mBuf); - RETVALUE(ROK); -} - -#endif /* PJ_SEC_ASYNC */ - - -#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)) -/*********************************************************** -* -* Func : cmPkPjLibTrans -* -* -* Desc : PjLibTrans - Transaction Id for Security Algorithm -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmPkPjLibTrans -( -PjLibTrans *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjLibTrans(param, mBuf) -PjLibTrans *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmPkPjLibTrans) - - CMCHKPK(cmPkPtr, (PTR)param->ueCb, mBuf); - CMCHKPK(cmPkLteRbId, param->rbId, mBuf); - CMCHKPK(SPkU8, param->rbType, mBuf); - CMCHKPK(SPkU32, param->count, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmUnpkPjLibTrans -* -* -* Desc : PjLibTrans - Transaction Id for Security Algorithm -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjLibTrans -( -PjLibTrans *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjLibTrans(param, mBuf) -PjLibTrans *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmUnpkPjLibTrans) - - CMCHKUNPK(SUnpkU32, ¶m->count, mBuf); - CMCHKUNPK(SUnpkU8, ¶m->rbType, mBuf); - CMCHKUNPK(cmUnpkLteRbId, ¶m->rbId, mBuf); - CMCHKUNPK(cmUnpkPtr, (PTR*)¶m->ueCb, mBuf); - RETVALUE(ROK); -} - -#endif /* PJ_SEC_ASYNC || PJ_CMP_ASYNC */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ -/********************************************************************30** - End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_lib.h b/src/5gnrpdcp/pj_lib.h deleted file mode 100755 index 7159a9b15..000000000 --- a/src/5gnrpdcp/pj_lib.h +++ /dev/null @@ -1,143 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: LTE PDCP file - - Type: C include file - - Desc: This file contain the hash definations for PDCP - - File: pj_lib.h - -*********************************************************************21*/ -/** @file pj_lib.h -@brief PDCP Hash definitions -*/ - -#ifndef __KW_PJ_LIB_H__ -#define __KW_PJ_LIB_H__ - -#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) - -#define OBD_SEL_LC 0 - -/* Off-board Async Events */ -#define OBD_EVT_CMP_INIT_CFM 0x90 -#define OBD_EVT_CMP_CFM 0x91 -#define OBD_EVT_DECMP_CFM 0x92 -#define OBD_EVT_CMP_CLOSE_CFM 0x93 -#define OBD_EVT_CMP_RESET_CFM 0x94 - -#define OBD_EVT_INT_INIT_CFM 0xa0 -#define OBD_EVT_INT_PROT_CFM 0xa1 -#define OBD_EVT_INT_VER_CFM 0xa2 -#define OBD_EVT_INT_CLOSE_CFM 0xa3 - -#define OBD_EVT_CP_INIT_CFM 0xb0 -#define OBD_EVT_UP_INIT_CFM 0xb1 -#define OBD_EVT_CIPHER_CFM 0xb2 -#define OBD_EVT_DECIPHER_CFM 0xb3 -#define OBD_EVT_CIPHER_CLOSE_CFM 0xb4 - -#define ERRLIB 0 - -#define ELIB001 (ERRLIB + 1) -#define ELIB002 (ERRLIB + 2) -#define ELIB003 (ERRLIB + 3) -#define ELIB004 (ERRLIB + 4) -#define ELIB005 (ERRLIB + 5) -#define ELIB006 (ERRLIB + 6) -#define ELIB007 (ERRLIB + 7) -#define ELIB008 (ERRLIB + 8) -#define ELIB009 (ERRLIB + 9) -#define ELIB010 (ERRLIB + 10) -#define ELIB011 (ERRLIB + 11) -#define ELIB012 (ERRLIB + 12) -#define ELIB013 (ERRLIB + 13) -#define ELIB014 (ERRLIB + 14) -#define ELIB015 (ERRLIB + 15) -#define ELIB016 (ERRLIB + 16) -#define ELIB017 (ERRLIB + 17) -#define ELIB018 (ERRLIB + 18) -#define ELIB019 (ERRLIB + 19) -#define ELIB020 (ERRLIB + 20) -#define ELIB021 (ERRLIB + 21) -#define ELIB022 (ERRLIB + 22) -#define ELIB023 (ERRLIB + 23) -#define ELIB024 (ERRLIB + 24) -#define ELIB025 (ERRLIB + 25) -#define ELIB026 (ERRLIB + 26) -#define ELIB027 (ERRLIB + 27) -#define ELIB028 (ERRLIB + 28) -#define ELIB029 (ERRLIB + 29) -#define ELIB030 (ERRLIB + 30) -#define ELIB031 (ERRLIB + 31) -#define ELIB032 (ERRLIB + 32) -#define ELIB033 (ERRLIB + 33) -#define ELIB034 (ERRLIB + 34) -#define ELIB035 (ERRLIB + 35) -#define ELIB036 (ERRLIB + 36) -#define ELIB037 (ERRLIB + 37) -#define ELIB038 (ERRLIB + 38) -#define ELIB039 (ERRLIB + 39) -#define ELIB040 (ERRLIB + 40) -#define ELIB041 (ERRLIB + 41) -#define ELIB042 (ERRLIB + 42) -#define ELIB043 (ERRLIB + 43) -#define ELIB044 (ERRLIB + 44) -#define ELIB045 (ERRLIB + 45) -#define ELIB046 (ERRLIB + 46) -#define ELIB047 (ERRLIB + 47) -#define ELIB048 (ERRLIB + 48) -#define ELIB049 (ERRLIB + 49) -#define ELIB050 (ERRLIB + 50) -#define ELIB051 (ERRLIB + 51) -#define ELIB052 (ERRLIB + 52) -#define ELIB053 (ERRLIB + 53) -#define ELIB054 (ERRLIB + 54) -#define ELIB055 (ERRLIB + 55) -#define ELIB056 (ERRLIB + 56) -#define ELIB057 (ERRLIB + 57) -#define ELIB058 (ERRLIB + 58) -#define ELIB059 (ERRLIB + 59) -#define ELIB060 (ERRLIB + 60) -#define ELIB061 (ERRLIB + 61) -#define ELIB062 (ERRLIB + 62) -#define ELIB063 (ERRLIB + 63) -#define ELIB064 (ERRLIB + 64) -#define ELIB065 (ERRLIB + 65) -#define ELIB066 (ERRLIB + 66) -#define ELIB067 (ERRLIB + 67) -#define ELIB068 (ERRLIB + 68) -#define ELIB069 (ERRLIB + 69) -#define ELIB070 (ERRLIB + 70) -#define ELIB071 (ERRLIB + 71) -#define ELIB072 (ERRLIB + 72) -#define ELIB073 (ERRLIB + 73) -#define ELIB074 (ERRLIB + 74) -#define ELIB075 (ERRLIB + 75) - -#endif /* (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) */ -#endif /* __KW_PJ_LIB_H__ */ - -/********************************************************************30** - - End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_lib.x b/src/5gnrpdcp/pj_lib.x deleted file mode 100755 index 512974d4d..000000000 --- a/src/5gnrpdcp/pj_lib.x +++ /dev/null @@ -1,695 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: LTE PDCP file - - Type: C include file - - Desc: This file contain the hash definations for PDCP - - File: pj_lib.x - -*********************************************************************21*/ - -#ifndef __PJ_LIB_X__ -#define __PJ_LIB_X__ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#ifdef PJ_CMP_ASYNC - -typedef S16 (*ObdCmpInitCfm) ARGS(( - Pst * pst, - PjCmpCxt cmpCxt, - PTR ctxId)); - -typedef S16 (*ObdCmpCfm) ARGS(( - Pst * pst, - PTR cmpCxtId, - PjLibTrans libTrans, - Buffer * opSdu)); - -typedef S16 (*ObdDecmpCfm) ARGS(( - Pst * pst, - PTR cmpCxtId, - PjLibTrans libTrans, - Buffer * opSdu, - Buffer * fbPkt -)); - -/* Library function externs */ -EXTERN S16 PjLibObdCmpInitCfm ARGS(( -Pst *pst, /* post structure */ -PjCmpCxt cmpCxt, /* Context for ROHC */ -PTR ctxId /* Compression Context ID */ -)); -EXTERN S16 PjLibObdCmpCfm ARGS(( -Pst *pst, /* post structure */ -PTR cmpCxtId, /* Context Id for compression */ -PjLibTrans libTrans, /* Transaction Id */ -Buffer *opSdu /* compressed SDU */ -)); -EXTERN S16 PjLibObdDecmpCfm ARGS(( -Pst *pst, /* post structure */ -PTR cmpCxtId, /* Context Id for decompression */ -PjLibTrans libTrans, /* Transaction Id */ -Buffer *opSdu, /* decompressed SDU */ -Buffer *fbPkt /* Feedback pkt */ -)); -EXTERN S16 PjLibObdCmpInitReq ARGS(( -Pst * pst, -PjCmpCxt cmpCxt, -PjRohc rohc -)); -EXTERN S16 PjLibObdCmpReq ARGS(( -Pst * pst, -PTR cmpCxtId, -PjLibTrans libTrans, -Buffer * mBuf -)); -EXTERN S16 PjLibObdDecmpReq ARGS(( -Pst * pst, -PTR cmpCxtId, -PjLibTrans libTrans, -Buffer * mBuf -)); -EXTERN S16 PjLibObdCmpCloseReq ARGS(( -Pst * pst, -PTR cmpCxtId -)); -EXTERN S16 PjLibObdCmpResetReq ARGS(( -Pst * pst, -PTR cmpCxtId -)); -EXTERN S16 PjLibObdCmpFbReq ARGS(( -Pst *pst, /* post structure */ -PTR cmpCxtId, /* Context Id for compression */ -PjLibTrans libTrans, /* Transaction Id */ -Buffer *feedback /* SDU to be decompressed */ -)); - -EXTERN S16 cmPkLibObdCmpInitCfm ARGS(( -Pst * pst, -PjCmpCxt cmpCxt, -PTR ctxId -)); - -EXTERN S16 cmUnpkLibObdCmpInitCfm ARGS(( -ObdCmpInitCfm func, -Pst *pst, -Buffer *mBuf -)); - -EXTERN S16 cmPkLibObdCmpCfm ARGS(( - Pst * pst, - PTR cmpCxtId, - PjLibTrans libTrans, - Buffer * opSdu -)); - -EXTERN S16 cmUnpkLibObdCmpCfm ARGS(( - ObdCmpCfm func, - Pst * pst, - Buffer *mBuf -)); - -EXTERN S16 cmPkLibObdDecmpCfm ARGS(( - Pst * pst, - PTR cmpCxtId, - PjLibTrans libTrans, - Buffer * opSdu, - Buffer * fbPkt -)); - -EXTERN S16 cmUnpkLibObdDecmpCfm ARGS(( - ObdDecmpCfm func, - Pst * pst, - Buffer *mBuf -)); - -EXTERN S16 cmPkPjRohc ARGS(( - PjRohc *param, - Buffer *mBuf -)); -EXTERN S16 cmUnpkPjRohc ARGS(( - PjRohc *param, - Buffer *mBuf -)); -EXTERN S16 cmPkPjCmpCxt ARGS(( - PjCmpCxt *param, - Buffer *mBuf -)); -EXTERN S16 cmUnpkPjCmpCxt ARGS(( - PjCmpCxt *param, - Buffer *mBuf -)); - -#else - -EXTERN S16 pjLibCmpInitReq ARGS(( -PjCmpCxt cmpCxt, -PjRohc rohc, -PTR *cmpCxtId -)); -EXTERN S16 pjLibCmpReq ARGS(( -PTR cmpCxtId, -Buffer *mBuf, -Buffer **opSdu -)); -EXTERN S16 pjLibDecmpReq ARGS(( -PTR cmpCxtId, -Buffer *mBuf, -Buffer **opSdu, -Buffer **feedback -)); -EXTERN S16 pjLibCmpCloseReq ARGS(( -PTR cmpCxtId -)); -EXTERN S16 pjLibCmpResetReq ARGS(( -PTR cmpCxtId -)); -EXTERN S16 pjLibCmpFbReq ARGS(( -PTR cmpCxtId, -Buffer *feedback -)); - -#endif /* PJ_CMP_ASYNC */ - -#ifdef PJ_SEC_ASYNC - -typedef S16 (*ObdIntInitCfm) ARGS(( - Pst * pst, - PjSecCxt secCtx, - PTR ctxId)); - -typedef S16 (*ObdCpInitCfm) ARGS(( - Pst * pst, - PjSecCxt secCxt, - PTR ctxId)); - -typedef S16 (*ObdUpInitCfm) ARGS(( - Pst * pst, - PjSecCxt secCxt, - PTR ctxId)); - -typedef S16 (*ObdIntProtCfm) ARGS(( - Pst * pst, - PTR cxtId, - PjLibTrans libTrans, - U32 macI)); - -typedef S16 (*ObdCipherCfm) ARGS(( - Pst * pst, - PTR cxtId, - PjLibTrans libTrans, - Buffer * opSdu)); - -typedef S16 (*ObdDecipherCfm) ARGS(( - Pst * pst, - PTR cxtId, - PjLibTrans libTrans, - Buffer * opSdu)); - -typedef S16 (*ObdIntVerCfm) ARGS(( - Pst * pst, - PTR cxtId, - PjLibTrans libTrans, - Status status)); - -EXTERN S16 PjLibObdIntInitCfm ARGS(( -Pst *pst, /* post structure */ -PjSecCxt secCxt, /* Secutiry Context */ -PTR ctxId /* Integrity Context ID */ -)); -EXTERN S16 PjLibObdCpInitCfm ARGS(( -Pst *pst, /* post structure */ -PjSecCxt secCxt, /* Secutiry Context */ -PTR ctxId /* Ciphering Context ID */ -)); -EXTERN S16 PjLibObdUpInitCfm ARGS(( -Pst *pst, /* post structure */ -PjSecCxt secCxt, /* Secutiry Context */ -PTR ctxId /* Ciphering Context ID */ -)); -EXTERN S16 PjLibObdIntProtCfm ARGS(( -Pst *pst, /* post structure */ -PTR cxtId, /* Context Id for Integrity protection*/ -PjLibTrans libTrans, /* Transaction Id */ -U32 macI /* Message authentication code */ -)); -EXTERN S16 PjLibObdCipherCfm ARGS(( -Pst *pst, /* post structure */ -PTR cxtId, /* Context Id for Ciphering */ -PjLibTrans libTrans, /* Transaction Id */ -Buffer *opSdu /* ciphered SDU */ -)); -EXTERN S16 PjLibObdDecipherCfm ARGS(( -Pst *pst, /* post structure */ -PTR cxtId, /* Context Id for Integrity protection*/ -PjLibTrans libTrans, /* Transaction Id */ -Buffer *opPdu /* deciphered SDU */ -)); -EXTERN S16 PjLibObdIntVerCfm ARGS(( -Pst *pst, /* post structure */ -PTR cxtId, /* Context Id for Integrity protection*/ -PjLibTrans libTrans, /* Transaction Id */ -Status status /* Integrity verification status */ -)); -EXTERN S16 PjLibObdIntInitReq ARGS(( -Pst * pst, -PjSecCxt secCtx, -PjIntInfo intInfo -)); -EXTERN S16 PjLibObdCpInitReq ARGS(( -Pst * pst, -PjSecCxt secCxt, -U8 algoType, -U8 *cpKey -)); -EXTERN S16 PjLibObdUpInitReq ARGS(( -Pst * pst, -PjSecCxt secCxt, -U8 algoType, -U8 *upKey -)); -EXTERN S16 PjLibObdIntProtReq ARGS(( -Pst * pst, -PTR intCxtId, -PjSecInp secInp, -PjLibTrans libTrans, -Buffer ** mBuf -)); -EXTERN S16 PjLibObdCipherReq ARGS(( -Pst * pst, -PTR cxtId, -PjSecInp secInp, -PjLibTrans libTrans, -Buffer * mBuf -)); -EXTERN S16 PjLibObdIntVerReq ARGS(( -Pst * pst, -PTR intCxtId, -PjSecInp secInp, -PjLibTrans libTrans, -Buffer * mBuf, -U32 macI -)); -EXTERN S16 PjLibObdDecipherReq ARGS(( -Pst * pst, -PTR cxtId, -PjSecInp secInp, -PjLibTrans libTrans, -Buffer * mBuf -)); -EXTERN S16 PjLibObdIntCloseReq ARGS(( -Pst * pst, -PTR intCxtId -)); -EXTERN S16 PjLibObdCipherCloseReq ARGS(( -Pst * pst, -PTR cpCxtId -)); - -EXTERN S16 cmPkLibObdIntInitCfm ARGS(( - Pst * pst, - PjSecCxt secCtx, - PTR ctxId -)); - -EXTERN S16 cmUnpkLibObdIntInitCfm ARGS(( - ObdIntInitCfm func, - Pst * pst, - Buffer *mBuf -)); - -EXTERN S16 cmPkLibObdCpInitCfm ARGS(( - Pst * pst, - PjSecCxt secCxt, - PTR ctxId -)); - -EXTERN S16 cmUnpkLibObdCpInitCfm ARGS(( - ObdCpInitCfm func, - Pst * pst, - Buffer *mBuf -)); - -EXTERN S16 cmPkLibObdUpInitCfm ARGS(( - Pst * pst, - PjSecCxt secCxt, - PTR ctxId -)); - -EXTERN S16 cmUnpkLibObdUpInitCfm ARGS(( - ObdUpInitCfm func, - Pst * pst, - Buffer *mBuf -)); - -EXTERN S16 cmPkLibObdIntProtCfm ARGS(( - Pst * pst, - PTR cxtId, - PjLibTrans libTrans, - U32 macI -)); - -EXTERN S16 cmUnpkLibObdIntProtCfm ARGS(( - ObdIntProtCfm func, - Pst * pst, - Buffer *mBuf -)); - -EXTERN S16 cmPkLibObdCipherCfm ARGS(( - Pst * pst, - PTR cxtId, - PjLibTrans libTrans, - Buffer * opSdu -)); - -EXTERN S16 cmUnpkLibObdCipherCfm ARGS(( - ObdCipherCfm func, - Pst * pst, - Buffer *mBuf -)); - -EXTERN S16 cmPkLibObdDecipherCfm ARGS(( - Pst * pst, - PTR cxtId, - PjLibTrans libTrans, - Buffer * opSdu -)); - -EXTERN S16 cmUnpkLibObdDecipherCfm ARGS(( - ObdDecipherCfm func, - Pst * pst, - Buffer *mBuf -)); - -EXTERN S16 cmPkLibObdIntVerCfm ARGS(( - Pst * pst, - PTR cxtId, - PjLibTrans libTrans, - Status status -)); - -EXTERN S16 cmUnpkLibObdIntVerCfm ARGS(( - ObdIntVerCfm func, - Pst * pst, - Buffer *mBuf -)); - -EXTERN S16 cmPkPjSecCxt ARGS(( - PjSecCxt *param, - Buffer *mBuf -)); -EXTERN S16 cmUnpkPjSecCxt ARGS(( - PjSecCxt *param, - Buffer *mBuf -)); -EXTERN S16 cmPkPjIntInfo ARGS(( - PjIntInfo *param, - Buffer *mBuf -)); -EXTERN S16 cmUnpkPjIntInfo ARGS(( - PjIntInfo *param, - Buffer *mBuf -)); -EXTERN S16 cmPkPjSecInp ARGS(( - PjSecInp *param, - Buffer *mBuf -)); -EXTERN S16 cmUnpkPjSecInp ARGS(( - PjSecInp *param, - Buffer *mBuf -)); - -#else - -EXTERN S16 PjLibObdUlInitReq ARGS (( -PjCb *gCb -)); - -EXTERN S16 PjLibObdDlInitReq ARGS (( -PjCb *gCb -)); - -EXTERN S16 pjLibObdPrcKenbCfg ARGS (( -PjCb *gCb, -CpjAsKeyInfo* kenbInf, -CpjAskeyCfmInfo *kdfCfm -)); - -EXTERN S16 pjLibObdPrcKenbStarCfg ARGS (( -PjCb *gCb, -CpjKenbStarInfo* kenbInf, -CpjKenbStarCfmInfo *kdfCfm -)); - -#ifdef INTEL_QAT_DP -EXTERN S16 PjLibObdDlCloseReq ARGS ((Void *)); -#else -EXTERN S16 PjLibObdDlCloseReq ARGS ((Void)); -#endif - -#ifdef INTEL_QAT_DP -EXTERN S16 PjLibObdUlCloseReq ARGS ((Void *)); -#else -EXTERN S16 PjLibObdUlCloseReq ARGS ((Void)); -#endif - -EXTERN S16 PjLibObdIntInitReq ARGS (( -PjSec *secInp -)); - -EXTERN Void PjUlSpaccTrigger ARGS ((Void)); - -EXTERN Void PjDlSpaccTrigger ARGS ((Void)); - -#ifdef INTEL_SW_INTEG -EXTERN S16 PjLibObdIntProtReq ARGS (( -PjCb *gCb, -PjLibTrans *libTrans, -Buffer **mBuf -)); -#else -EXTERN S16 PjLibObdIntProtReq ARGS (( -PjLibTrans *libTrans, -Buffer **mBuf -)); -#endif - - - -#ifdef TENB_AS_SECURITY -EXTERN S16 PjLibObdDlInitReq ARGS (( -PjCb *gCb -)); - -EXTERN S16 PjLibObdUlInitReq ARGS (( -PjCb *gCb -)); -#ifdef INTEL_QAT_DP -EXTERN S16 PjLibObdDlCloseReq ARGS ((Void *)); -#else -EXTERN S16 PjLibObdDlCloseReq ARGS ((Void)); -#endif - -#ifdef INTEL_QAT_DP -EXTERN S16 PjLibObdUlCloseReq ARGS ((Void *)); -#else -EXTERN S16 PjLibObdUlCloseReq ARGS ((Void)); -#endif -#endif - -#ifdef TENB_AS_SECURITY -#ifdef INTEL_SW_INTEG -EXTERN S16 PjLibObdIntVerReq ARGS (( -PjCb *gCb, -PjLibTrans *libTrans, -Buffer * mBuf, -U32 macI -)); -#else -EXTERN S16 PjLibObdIntVerReq ARGS (( -PjLibTrans *libTrans, -Buffer * mBuf, -U32 macI -)); -#endif -#else -EXTERN S16 PjLibObdIntVerReq ARGS(( -Pst * pst, -PTR intCxtId, -PjSecInp secInp, -PjLibTrans libTrans, -Buffer * mBuf, -U32 macI -)); - -#endif - -#ifdef INTEL_QAT_DP -EXTERN S16 PjLibObdIntCloseReq ARGS (( -Void *instHndl, /* Instance Handler */ -Void *intCxtId -)); -#else -EXTERN S16 PjLibObdIntCloseReq ARGS (( -Void *intCxtId -)); -#endif - -EXTERN S16 PjLibObdCpInitReq ARGS (( -PjSec *secInp -)); - -EXTERN S16 PjLibObdUpInitReq ARGS (( -PjSec *secInp -)); - - -EXTERN S16 PjLibObdCipherReq ARGS (( -PjLibTrans *libTrans, -Buffer *mBuf, -Buffer **opSdu -)); - -#ifdef FLAT_BUFFER_OPT -EXTERN S16 PjLibObdCipherReqFB ARGS (( -PjLibTrans *libTrans, -FlatBuffer *mBuf, -Buffer **opSdu -)); -#endif - -EXTERN S16 PjLibObdDecipherReq ARGS (( -PjLibTrans *libTrans, -Buffer *mBuf, -Buffer **opSdu -)); - -#ifdef INTEL_QAT_DP -EXTERN S16 PjLibObdCipherCloseReq ARGS (( -Void *instHndl, /* Instance Handler */ -Void *cpCxtId -)); -#else -EXTERN S16 PjLibObdCipherCloseReq ARGS (( -Void *cpCxtId -)); -#endif - -#ifdef INTEL_QAT_DP -EXTERN S16 pjLibIntInitReq ARGS (( -PjCb *gCb, -PjIntInfo intInfo, /* Integrity Cfg Info */ -Void **cxtId /* FD */ -)); -#else -EXTERN S16 pjLibIntInitReq ARGS (( -PjSecCxt secCxt, /* Context for Intg protection/verification */ -PjIntInfo intInfo, /* Integrity Cfg Info */ -Void **cxtId /* FD */ -)); -#endif - -#ifdef INTEL_QAT_DP -EXTERN S16 pjLibCpInitReq ARGS (( -PjCb *gCb, -PjSecCxt secCxt, /* Context for Intg protection/verificatino */ -U8 algoType, /* Type of the algorithm */ -U8 *cpKey, /* Control plane ciphering key */ -Void **cxtId /* FD */ -)); -#else -EXTERN S16 pjLibCpInitReq ARGS (( -PjSecCxt secCxt, /* Context for Intg protection/verificatino */ -U8 algoType, /* Type of the algorithm */ -U8 *cpKey, /* Control plane ciphering key */ -Void **cxtId /* FD */ -)); -#endif - -#ifdef INTEL_QAT_DP -EXTERN S16 pjLibUpInitReq ARGS (( -PjCb *gCb, -PjSecCxt secCxt, /* Context for Intg protection/verificatino */ -U8 algoType, /* Type of the algorithm */ -U8 *upKey, /* User plane ciphering key */ -Void **cxtId /* FD */ -)); -#else -EXTERN S16 pjLibUpInitReq ARGS (( -PjSecCxt secCxt, /* Context for Intg protection/verificatino */ -U8 algoType, /* Type of the algorithm */ -U8 *upKey, /* User plane ciphering key */ -Void **cxtId /* FD */ -)); -#endif -EXTERN S16 pjLibDecipherReq ARGS(( -PTR intCxtId, /* Context Id for compression */ -PjSecInp secInp, /* Input for Deciphering */ -Buffer *mBuf, /* SDU to be deciphered */ -Buffer **opSdu /* deciphered SDU */ -)); -EXTERN S16 pjLibIntVerReq ARGS(( -PTR intCxtId, /* Context Id for compression */ -PjSecInp secInp, /* Input for Integrity protection */ -Buffer *mBuf, /* SDU to be compressed */ -U32 macI, /* Message authentication code for the SDU */ -Status *status /* Status of the Integrity verification */ -)); -#endif - -#if defined(PJ_CMP_ASYNC) || defined(PJ_SEC_ASYNC) -EXTERN S16 cmPkPjLibTrans ARGS(( - PjLibTrans *param, - Buffer *mBuf -)); -EXTERN S16 cmUnpkPjLibTrans ARGS(( - PjLibTrans *param, - Buffer *mBuf -)); - -#endif /* PJ_CMP_ASYNC || PJ_SEC_ASYNC */ -/* kw003.201 */ - -/* kw004.201 Guarded under PTPJLIB */ -#ifdef PTPJLIB -EXTERN S16 pjLibPktAdmCtrl ARGS(( - PjDlRbCb *pjRbCb, - Buffer *pkt -)); -#endif -#if defined(L2_L3_SPLIT) && defined(ICC_RECV_TSK_RBUF) -EXTERN S16 pjUlBatchProcSplit ARGS ((Void)); -#endif -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __PJ_LIB_X__ */ - -/********************************************************************30** - - End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_lim.c b/src/5gnrpdcp/pj_lim.c deleted file mode 100755 index 8b66cc7b0..000000000 --- a/src/5gnrpdcp/pj_lim.c +++ /dev/null @@ -1,1094 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: LTE-PDCP Layer - Lower Interface Functions - - Type: C file - - Desc: Source code for PDCP Lower Interface Module. - This file contains following functions - - --pjLimDatInd - --pjLimDatCfm - --pjLimStaInd - - File: pj_lim.c - -**********************************************************************/ - -static const char* RLOG_MODULE_NAME="PDCP"; -static int RLOG_MODULE_ID=1024; -static int RLOG_FILE_ID=219; -/** @file pj_lim.c -@brief PDCP Lower Interface Module -*/ - - -/* header (.h) include files */ -#include "envopt.h" /* environment options */ -#include "envdep.h" /* environment dependent */ -#include "envind.h" /* environment independent */ - -#include "gen.h" /* general */ -#include "ssi.h" /* system services interface */ -#include "cm5.h" /* Timer Functions */ -#include "cm_lte.h" /* common LTE header file */ -#include "cm_hash.h" /* common hash module file */ -#include "cm_llist.h" /* common list header file */ -#include "cpj.h" /* RRC layer */ -#include "kwu.h" -#include "pju.h" /* PDCP service user */ -#include "lpj.h" /* RRC layer */ -#include "pj_env.h" /* RLC environment options */ -#include "pj.h" /* RLC layer */ -#include "pj_err.h" - -/* header/extern include files (.x) */ - -#include "gen.x" /* general */ -#include "ssi.x" /* system services interface */ -#include "cm_lib.x" /* common library */ -#include "cm5.x" /* Timer Functions */ -#include "cm_hash.x" /* common hash module */ -#include "cm_lte.x" /* common LTE file */ -#include "cm_llist.x" /* common list header file */ -#include "kwu.x" -#include "cpj.x" /* RRC layer */ -#include "pju.x" /* PDCP service user */ -#include "lpj.x" /* LM Interface */ -#include "pj.x" /* RLC layer */ -#include "pj_udx.h" -#include "pj_udx.x" -#include "pj_ul.x" -#include "pj_dl.x" - -#ifdef __cplusplus -EXTERN "C" { -#endif /* __cplusplus */ -PRIVATE S16 pjLimDiscSduCfm ARGS((PjCb *gCb, - PjDlRbCb *pjRbCb, - KwuDiscSduInfo *discSduCfm)); - -/** - * - * @brief Handler for Sending sdu to Rlc. - * - * - * @b Description - * - * - * @param[in] pjRbCb PDCP control block. - * @param[in] sduId PDCP SDU id. - * @param[in] mBuf Pointer to PDCP Sdu - * - * - * @return S16 - * -# ROK - * -# RFAILED - */ - -#ifdef ANSI -PUBLIC S16 pjDlmSendDatReq -( -PjCb *gCb, -PjDlRbCb *pjRbCb, -U32 sduId, -Buffer *mBuf -) -#else -PUBLIC S16 pjDlmSendDatReq(gCb,pjRbCb,sduId, mBuf) -PjCb *gCb; -PjDlRbCb *pjRbCb; -U32 sduId; -Buffer *mBuf; -#endif -{ - PjKwuSapCb *pjSapCb; - KwuDatReqInfo datReq; - TRC2(pjDlmSendDatReq); - - pjSapCb = gCb->u.dlCb->kwuSap; - datReq.rlcId.rbId = pjRbCb->rbId; - datReq.rlcId.rbType = pjRbCb->rbType; - datReq.rlcId.ueId = pjRbCb->ueCb->key.ueId; - datReq.rlcId.cellId = pjRbCb->ueCb->key.cellId; -#ifdef CCPU_OPT - datReq.lcType = (U8)((pjRbCb->rbType == CM_LTE_SRB) ? - CM_LTE_LCH_DCCH : CM_LTE_LCH_DTCH); /*KW_FIX*/ -#endif - - datReq.sduId = sduId; - - RETVALUE(PjLiKwuDatReq(&(pjSapCb->pst),pjSapCb->spId, &datReq, mBuf)); -} - -/** - * - * @brief Handler for Discarding SDU to Rlc. - * - * - * @b Description - * - * - * @param[in] pjRbCb PDCP control block. - * @param[in] sduId PDCP SDU id. - * - * - * @return S16 - * -# ROK - * -# RFAILED - */ - -#ifdef ANSI -PUBLIC S16 pjDlmSendDiscSdu -( -PjCb *gCb, -PjDlRbCb *pjRbCb, -U32 sduId -) -#else -PUBLIC S16 pjDlmSendDiscSdu(gCb,pjRbCb,sduId) -PjCb *gCb; -PjDlRbCb *pjRbCb; -U32 sduId; -#endif -{ - KwuDiscSduInfo *discSdu; - PjKwuSapCb *pjSapCb; - TRC2(pjDlmSendDiscSdu); - - pjSapCb = gCb->u.dlCb->kwuSap; - KwuDiscSduInfo discSduTmp; - discSdu = &discSduTmp; - - discSdu->rlcId.rbId = pjRbCb->rbId; - discSdu->rlcId.rbType = pjRbCb->rbType; - discSdu->rlcId.ueId = pjRbCb->ueCb->key.ueId; - discSdu->rlcId.cellId = pjRbCb->ueCb->key.cellId; - - discSdu->sduIds[0] = sduId; - discSdu->numSduIds = 1; - - PjLiKwuDiscSduReq(&(pjSapCb->pst),pjSapCb->spId, discSdu); - - RETVALUE(ROK); -} - - - -/***************************************************************************** - * PDCP LOWER INTERFACE - ****************************************************************************/ -/** - * - * @brief - * - * Handler for getting the BndCfm from RLC. - * - * @b Description: - * - * This function receives the PDU from RLC - * and invokes the handler for processing the PDU. - * - * @param[in] pjRbCb - PDCP RB Control Block - * @param[in] mBuf - PDU - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 PjLiKwuBndCfm -( -Pst *pst, /* Post */ -SuId suId, /* Service User Id */ -U8 status /* Status */ -) -#else -PUBLIC Void PjLiKwuBndCfm (pst, suId, datCfm) -Pst *pst; /* Post */ -SuId suId; /* Service User Id */ -U8 status; /* Status */ -#endif -{ - U16 event; /* Event */ - U16 cause; /* Cause */ - PjKwuSapCb *kwuSap; /* RGU SAP Control Block */ - PjCb *tPjCb; - - TRC1(PjLiKwuBndCfm); - - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) /* KW_FIX */ - { - RETVALUE(RFAILED); - } - tPjCb = PJ_GET_PJCB(pst->dstInst); - - RLOG2(L_DEBUG, "PjLiKwuBndCfm(SuId (%d), status (%d) ",suId, status); - UNUSED(pst); - -#if (ERRCLASS & ERRCLS_INT_PAR) - if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE)) - { - /* INNC: ERROR CLASS */ - RLOG0(L_FATAL, "General configuration not done"); - /*PJ_SEND_SAPID_ALARM(tPjCb,suId, LPJ_EVENT_LI_BND_CFM, LPJ_CAUSE_INV_STATE);*/ - - RETVALUE(RFAILED); - } - - if (suId < 0) - { - /* INNC: ERROR CLASS */ - RLOG0(L_ERROR, "Invalid suId"); - /*PJ_SEND_SAPID_ALARM(tPjCb,suId, LPJ_EVENT_LI_BND_CFM, LPJ_CAUSE_INV_SUID);*/ - - RETVALUE(RFAILED); - } -#endif /* ERRCLASS & ERRCLS_INT_PAR */ - - if (tPjCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL) - { - kwuSap = tPjCb->u.ulCb->kwuSap; - } - else - { - kwuSap = tPjCb->u.dlCb->kwuSap; - } - -#ifdef DEBUGP - RLOG1(L_DEBUG, "PjLiKwuBndCfm: For KWU SAP state=%d", - kwuSap->state); -#endif - - /* Check rguSap state */ - switch (kwuSap->state) - { - case PJ_SAP_BINDING: - { - pjStopTmr (tPjCb, (PTR)kwuSap, PJ_EVT_WAIT_KWU_BNDCFM); - - kwuSap->retryCnt = 0; - - if (status == CM_BND_OK) - { - kwuSap->state = PJ_SAP_BND; - event = LCM_EVENT_BND_OK; - cause = LPJ_CAUSE_SAP_BNDENB; - } - else - { - kwuSap->state = PJ_SAP_CFG; - event = LCM_EVENT_BND_FAIL; - cause = LPJ_CAUSE_UNKNOWN; - } - } - break; - default: - event = LPJ_EVENT_RGU_BND_CFM; - cause = LCM_CAUSE_INV_STATE; - break; - } - - /* Send an alarm with proper event and cause */ - /* PJ_SEND_SAPID_ALARM(tPjCb, suId, event, cause);*/ -#ifdef LTE_L2_MEAS - pjLmmSendAlarm(tPjCb,LCM_CATEGORY_INTERFACE, event, cause, suId, 0,0); -#else - pjLmmSendAlarm(tPjCb,LCM_CATEGORY_INTERFACE, event, cause, suId, 0); -#endif - - RETVALUE(ROK); -} /* pjLimDatInd */ - -/** - * - * @brief - * - * Handler for getting the PDU from RLC. - * - * @b Description: - * - * This function receives the PDU from RLC - * and invokes the handler for processing the PDU. - * - * @param[in] pjRbCb - PDCP RB Control Block - * @param[in] mBuf - PDU - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 PjLiKwuDatInd -( -Pst *pst, /* Post */ -SuId suId, /* Service User Id */ -KwuDatIndInfo *datInd, /* Data Indication Info */ -Buffer *mBuf /* Buffer */ -) -#else -PUBLIC Void PjLiKwuDatInd(pst, suId, datInd, mBuf) -Pst *pst; /* Post */ -SuId suId; /* Service User Id */ -KwuDatIndInfo *datInd; /* Data Indication Info */ -Buffer *mBuf; /* Buffer */ -#endif -{ - S16 ret; /* Return Value */ - PjUlRbCb *pjRbCb; - PjCb *tPjCb; - - TRC1(PjLiKwuDatInd); - - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) /* KW_FIX*/ - { - RETVALUE(RFAILED); - } - tPjCb = PJ_GET_PJCB(pst->dstInst); - - ret = pjDbmFetchUlRbCb (tPjCb,datInd->rlcId,&pjRbCb); - if (ret != ROK) - { - RLOG_ARG2(L_ERROR, DBG_UEID,datInd->rlcId.ueId, "CellId[%u]:UL RbId[%d] not found", - datInd->rlcId.cellId, datInd->rlcId.rbId); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - - pjLimDatInd(tPjCb, pjRbCb, mBuf, datInd->isOutOfSeq); - - - RETVALUE(ROK); -} /* pjLimDatInd */ - - PUBLIC int pdcpDatCfmsReceived = 0; -/** - * - * @brief - * - * Handler for getting the datCfm from RLC. - * - * @b Description: - * - * This function receives the PDU from RLC - * and invokes the handler for processing the PDU. - * - * @param[in] pjRbCb - PDCP RB Control Block - * @param[in] mBuf - PDU - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 PjLiKwuDatCfm -( -Pst *pst, /* Post */ -SuId suId, /* Service User Id */ -KwuDatCfmInfo *datCfm /* Data Confirm Info */ -) -#else -PUBLIC Void PjLiKwuDatCfm(pst, suId, datCfm) -Pst *pst; /* Post */ -SuId suId; /* Service User Id */ -KwuDatCfmInfo *datCfm; /* Data Confirm Info */ -#endif -{ - S16 ret; /* Return Value */ - PjDlRbCb *pjRbCb; - PjDatCfm pjCfm; - PjCb *tPjCb; - - TRC1(PjLiKwuDatCfm); - - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) /* KW_FIX */ - { - RETVALUE(RFAILED); - } - - tPjCb = PJ_GET_PJCB(pst->dstInst); - - RLOG2(L_DEBUG, "PjLiKwuDatCfm(rbId(%d),rbType (%d), mBuf)", - datCfm->rlcId.rbId,datCfm->rlcId.rbType); - - ret = pjDbmFetchDlRbCb (tPjCb,datCfm->rlcId,&pjRbCb); - if (ret != ROK) - { - RLOG_ARG2(L_ERROR, DBG_UEID,datCfm->rlcId.ueId, "CellId[%u]:DL RbId[%d] not found", - datCfm->rlcId.cellId, datCfm->rlcId.rbId); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datCfm, sizeof(KwuDatCfmInfo)); - RETVALUE(RFAILED); - } - - pdcpDatCfmsReceived++; - - pjCfm.rlcId = datCfm->rlcId; - pjCfm.numSdu = (U16)(datCfm->numSduIds); /*KW_FIX*/ - cmMemcpy((U8*)pjCfm.sduId, (U8*)datCfm->sduIds, sizeof(U32)*datCfm->numSduIds); - pjLimDatCfm (tPjCb, pjRbCb, &pjCfm); - - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datCfm, sizeof(KwuDatCfmInfo)); - RETVALUE(ROK); -} /* pjLimDatInd */ - -/** - * - * @brief - * - * Handler for flow control indication from RLC. - * - * @b Description: - * - * TODO - * - * @param[in] pst - Pointer to post structure - * @param[in] suId - Service user Id - * @param[in] flowCntrlInfo - Flow control information - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 PjLiKwuFlowCntrlInd -( -Pst *pst, -SuId suId, -KwuFlowCntrlIndInfo *flowCntrlInfo -) -#else -PUBLIC Void PjLiKwuFlowCntrlInd(pst, suId, flowCntrlInfo) -Pst *pst; -SuId suId; -KwuFlowCntrlIndInfo *flowCntrlInfo; -#endif -{ - S16 ret; - PjDlRbCb *pjRbCb; - PjCb *tPjCb; - - TRC1(PjLiKwuFlowCntrlInd); - - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) - { - RETVALUE(RFAILED); - } - - tPjCb = PJ_GET_PJCB(pst->dstInst); - - RLOG2(L_DEBUG, "PjLiKwuFlowCntrlInd(rbId(%d),rbType (%d), mBuf)", - flowCntrlInfo->rlcId.rbId,flowCntrlInfo->rlcId.rbType); - - ret = pjDbmFetchDlRbCb (tPjCb,flowCntrlInfo->rlcId,&pjRbCb); - if (ret != ROK) - { - RLOG_ARG2(L_ERROR, DBG_UEID,flowCntrlInfo->rlcId.ueId, "CellId[%u]:DL RbId[%d] not found", - flowCntrlInfo->rlcId.cellId, flowCntrlInfo->rlcId.rbId); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, flowCntrlInfo, sizeof(KwuFlowCntrlIndInfo)); - RETVALUE(RFAILED); - } - - /* if RLC is requesting to stop the flow means RB is overloaded */ - if (flowCntrlInfo->pktAdmitCnt) - { - if (pjRbCb->mode == PJ_DRB_AM) - { - pjRbCb->dropOnlyOne = 1; - pjRbCb->pktAdmitCnt= 0; - } - else - { - pjRbCb->dropOnlyOne = 0; - pjRbCb->pktAdmitCnt = flowCntrlInfo->pktAdmitCnt; - } - } - else - { - /* flowCntrlInfo->pktAdmitCnt = 0 indicates PDB Recovered and no FC required - * reset FC state */ - pjRbCb->dropOnlyOne = 0; - pjRbCb->pktAdmitCnt = 0; - } - pjRbCb->pktCnt = 0; - - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, flowCntrlInfo, sizeof(KwuFlowCntrlIndInfo)); - RETVALUE(ROK); -} /* PjLiKwuFlowCntrlInd */ -/** - * - * @brief - * - * Handler for getting the Status Ind from RLC. - * - * @b Description: - * - * This function receives the PDU from RLC - * and invokes the handler for processing the PDU. - * - * @param[in] pjRbCb - PDCP RB Control Block - * @param[in] mBuf - PDU - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 PjLiKwuStaInd -( -Pst *pst, /* Post */ -SuId suId, /* Service User Id */ -KwuStaIndInfo *staInd /* StatusIndication Info */ -) -#else -PUBLIC Void PjLiKwuStaInd(pst, suId, datCfm) -Pst *pst; /* Post */ -SuId suId; /* Service User Id */ -KwuStaIndInfo *staInd; /* Status Indication Info */ -#endif -{ - S16 ret; /* Return Value */ - PjDlRbCb *pjRbCb; - PjCb *tPjCb; - U32 minSduCnt; - - TRC1(PjLiKwuStaInd); - - tPjCb = PJ_GET_PJCB(pst->dstInst); - if ((pst->dstInst >= PJ_MAX_PDCP_INSTANCES) || (tPjCb->init.cfgDone == FALSE)) - { - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staInd, sizeof(KwuStaIndInfo)); - RETVALUE(RFAILED); - } - - - RLOG2(L_DEBUG, "PjLiKwuStaInd(rbId(%d),rbType (%d), mBuf)", - staInd->rlcId.rbId,staInd->rlcId.rbType); - - ret = pjDbmFetchDlRbCb (tPjCb,staInd->rlcId,&pjRbCb); - if (ret != ROK) - { - RLOG_ARG2(L_ERROR, DBG_UEID,staInd->rlcId.ueId, "CellId[%u]:DL RbId[%d] not found", - staInd->rlcId.cellId, staInd->rlcId.rbId); -/* To confirm :: BRDCM team */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staInd, sizeof(KwuStaIndInfo)); - RETVALUE(RFAILED); - } - minSduCnt = (KWU_MAX_STA_IND_SDU < PJ_MAX_DAT_CFM)?KWU_MAX_STA_IND_SDU:PJ_MAX_DAT_CFM; - if(staInd->numSdu > minSduCnt) - { - staInd->numSdu = (U16)minSduCnt; /*KW_FIX*/ - RLOG_ARG2(L_ERROR, DBG_RBID , pjRbCb->rbId , "numSdu [%u] in StaInd is more than acceptable limit [%lu]", - staInd->numSdu , minSduCnt); - } - pjLimStaInd(tPjCb, pjRbCb, (PjDatCfm *) staInd); -/* To confirm :: BRDCM team */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staInd, sizeof(KwuStaIndInfo)); - RETVALUE(ROK); -} /* pjLimKwuStaInd */ - - - -/** - * - * @brief - * - * Handler for getting the ReEstablish Ind from RLC. - * - * @b Description: - * - * This function receives the PDU from RLC - * and invokes the handler for processing the PDU. - * - * @param[in] pjRbCb - PDCP RB Control Block - * @param[in] mBuf - PDU - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 PjLiKwuReEstCmpInd -( -Pst *pst, /* Post */ -SuId suId, /* Service User Id */ -CmLteRlcId rlcId /* RlcId */ -) -#else -PUBLIC Void PjLiKwuReEstCmpInd(pst, suId, rlcId) -Pst *pst; /* Post */ -SuId suId; /* Service User Id */ -CmLteRlcId rlcId; /* RlcId */ -#endif -{ - S16 ret; /* Return Value */ - PjUlRbCb *ulRbCb; - PjCb *tPjCb; - - TRC1(PjLiKwuReEstCmpInd); - - tPjCb = PJ_GET_PJCB(pst->dstInst); - if ((pst->dstInst >= PJ_MAX_PDCP_INSTANCES) || (tPjCb->init.cfgDone == FALSE)) - { - RETVALUE(RFAILED); - } - - - RLOG2(L_DEBUG, "PjLiKwuReEstCmpInd(rbId(%d),rbType (%d), mBuf)", - rlcId.rbId,rlcId.rbType); - - ret = pjDbmFetchUlRbCb (tPjCb,rlcId,&ulRbCb); - if (ret != ROK) - { - RLOG_ARG2(L_ERROR, DBG_UEID,rlcId.ueId, "CellId[%u]:UL RbId[%d] not found", - rlcId.cellId, rlcId.rbId); - RETVALUE(RFAILED); - } - pjUlmReEstCmpInd(tPjCb,ulRbCb); - - RETVALUE(ROK); -} /* pjLimDatInd */ - -#ifdef LTE_L2_MEAS -/** - * - * @brief - * - * Handler for getting the Ack Ind from RLC. - * - * @b Description: - * - * This function receives the PDU from RLC - * and invokes the handler for processing the PDU. - * - * @param[in] pjRbCb - PDCP RB Control Block - * @param[in] mBuf - PDU - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 PjLiKwuDatAckInd -( -Pst *pst, /* Post */ -SuId suId, /* Service User Id */ -KwuDatAckInfo *ackInfo /* Data Ack Info */ -) -#else -PUBLIC Void PjLiKwuDatAckInd(pst, suId, datCfm) -Pst *pst; /* Post */ -SuId suId; /* Service User Id */ -KwuDatAckInfo *ackInfo; /* Data Ack Info */ -#endif -{ - RETVALUE(ROK); -} /* pjLimDatInd */ -#endif - -/** - * - * @brief - * - * Handler for getting the DiscSdu Cfm from RLC. - * - * @b Description: - * - * This function receives the PDU from RLC - * and invokes the handler for processing the PDU. - * - * @param[in] pjRbCb - PDCP RB Control Block - * @param[in] mBuf - PDU - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 PjLiKwuDiscSduCfm -( -Pst *pst, /* Post */ -SuId suId, /* Service User Id */ -KwuDiscSduInfo *discInfo /* Data Ack Info */ -) -#else -PUBLIC Void PjLiKwuDiscSduCfm(pst, suId, discInfo) -Pst *pst; /* Post */ -SuId suId; /* Service User Id */ -KwuDiscSduInfo *discInfo; /* Data Ack Info */ -#endif -{ - S16 ret; /* Return Value */ - PjDlRbCb *pjRbCb; - PjCb *tPjCb; - - TRC1(PjLiKwuDiscSduCfm); - tPjCb = PJ_GET_PJCB(pst->dstInst); - - - RLOG2(L_DEBUG, "PjLiKwuDiscSduCfm (rbId(%d),rbType (%d), mBuf)", - discInfo->rlcId.rbId,discInfo->rlcId.rbType); - - ret = pjDbmFetchDlRbCb (tPjCb,discInfo->rlcId,&pjRbCb); - if (ret != ROK) - { - RLOG_ARG2(L_ERROR, DBG_UEID,discInfo->rlcId.ueId, "CellId[%u]:DL RbId[%d] not found", - discInfo->rlcId.cellId, discInfo->rlcId.rbId); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, discInfo, sizeof(KwuDiscSduInfo)); - RETVALUE(RFAILED); - } - - pjLimDiscSduCfm(tPjCb, pjRbCb, discInfo); - - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, discInfo, sizeof(KwuDiscSduInfo)); - - RETVALUE(ROK); -} /* pjLimDatInd */ - -/** - * - * @brief - * - * Handler for getting the PDU from RLC. - * - * @b Description: - * - * This function receives the PDU from RLC - * and invokes the handler for processing the PDU. - * - * @param[in] pjRbCb - PDCP RB Control Block - * @param[in] mBuf - PDU - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC Void pjLimDatInd -( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* RB Control Block */ -Buffer *mBuf, /* RLC PDU */ -Bool isOutOfSeq -) -#else -PUBLIC Void pjLimDatInd(gCb, pjRbCb, mBuf, isOutOfSeq) -PjCb *gCb; -PjUlRbCb *pjRbCb; /* RB Control Block */ -Buffer *mBuf; /* RLC PDU */ -Bool isOutOfSeq; -#endif -{ -#if (ERRCLASS & ERRCLS_DEBUG) - S16 ret; /* Return Value */ -#endif - - TRC3(pjLimDatInd); - - PJ_STS_INC_GEN_CNT(gCb, rxPdus); - - /* Extract the header */ - if(pjRbCb->rbType == PJ_SRB) - { - if((pjRbCb->rbId == 1) || (pjRbCb->ueCb->libInfo.state == PJ_STATE_NORMAL)) - { -#if (ERRCLASS & ERRCLS_DEBUG) - ret = pjUlmHdlSrbPkt(gCb, pjRbCb, mBuf); -#else - pjUlmHdlSrbPkt(gCb, pjRbCb, mBuf); -#endif - } - else - { - /* in reestablishment state */ - PJ_FREE_BUF(mBuf); - } - } - else if(pjRbCb->rbType == PJ_DRB) - { -#if (ERRCLASS & ERRCLS_DEBUG) - ret = pjUlmHdlDrbPkt(gCb, pjRbCb, mBuf, isOutOfSeq); -#else - pjUlmHdlDrbPkt(gCb, pjRbCb, mBuf, isOutOfSeq); -#endif - } - -#if (ERRCLASS & ERRCLS_DEBUG) - if (ret != ROK) - { - RLOG_ARG0(L_ERROR, DBG_RBID,pjRbCb->rbId, "pjLimDatInd: pjHdlProcessPdu Failed"); - } -#endif - - RETVOID; -} /* pjLimDatInd */ - - -/** - * - * @brief - * - * Handler for getting the Data Cfm from RLC. - * - * @b Description: - * - * This function receives the Data Cfm from RLC - * and invokes the handler for processing it. - * - * @param[in] pjRbCb - PDCP RB Control Block - * @param[in] datCfm - Data Confirmation Information - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC Void pjLimDatCfm -( -PjCb *gCb, -PjDlRbCb *pjRbCb, /* RB Control Block */ -PjDatCfm *datCfm /* Data Confirmation Information */ -) -#else -PUBLIC Void pjLimDatCfm(gCb, pjRbCb, datCfm) -PjCb *gCb; -PjDlRbCb *pjRbCb; /* RB Control Block */ -PjDatCfm *datCfm; /* Data Confirmation Information */ -#endif -{ -#if (ERRCLASS & ERRCLS_DEBUG) - S16 ret = ROK; /* Return Value */ -#endif - - TRC3(pjLimDatCfm); - - - /* Process the PDU */ -#if (ERRCLASS & ERRCLS_DEBUG) - ret = pjDlmProcessCfm(gCb, pjRbCb, datCfm, PJ_CFM_OK); - if (ret != ROK) - { - RLOG_ARG0(L_ERROR, DBG_RBID,pjRbCb->rbId, "pjLimDatCfm: pjDlmProcessCfm Failed"); - } -#else - pjDlmProcessCfm(gCb, pjRbCb, datCfm, PJ_CFM_OK); -#endif - /* pj002.201 : Removed freeing and allocation of datCfm */ - RETVOID; -} /* pjLimDatCfm */ - - -/** - * - * @brief - * - * Handler for trigerring the error indication when RLC times out - * for sending AM data. - * - * @b Description: - * - * This function receives the pduIds of the PDU that were not - * successfully sent to the layer. - * - * @param[in] pjRbCb - PDCP RB Control Block - * @param[in] staInd - Status Indication Information. - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC Void pjLimStaInd -( -PjCb *gCb, -PjDlRbCb *pjRbCb, /* PDCP RB Control Block */ -PjDatCfm *staInd /* Status Indication Information */ -) -#else -PUBLIC Void pjLimStaInd(gCb, pjRbCb, staInd) -PjCb *gCb; -PjDlRbCb *pjRbCb; /* PDCP RB control Block */ -PjDatCfm *staInd; /* Status Indication Information */ -#endif -{ -#if (ERRCLASS & ERRCLS_DEBUG) - S16 ret = ROK; /* Return Value */ -#endif - - TRC3(pjLimStaInd) - - if (gCb->init.cfgDone == FALSE) - { - RETVOID; - } - RLOG1(L_DEBUG, "pjLimStaInd(pjRbCb(%d), staInd)", pjRbCb->rbId); - - /* Call the confirm code */ -#if (ERRCLASS & ERRCLS_DEBUG) - ret = pjDlmProcessCfm(gCb, pjRbCb, staInd, PJ_CFM_NOK); - if (ret != ROK) - { - RLOG_ARG0(L_ERROR, DBG_RBID,pjRbCb->rbId, "pjLimStaInd: pjDlmProcessCfm Failed"); - } -#else - pjDlmProcessCfm(gCb, pjRbCb, staInd, PJ_CFM_NOK); -#endif - /* pj002.201 : Removed freeing and allocation of staInd */ - RETVOID; -} /* pjLimStaInd */ - - -/** - * - * @brief - * - * Handler for informing the PDCP that RLC has successfully discarded - * certain PDUs. - * - * @b Description: - * - * This function receives the pointer to the PDCP control block of the - * RB that has finished transmitting its data to PDCP. - * - * @param[in] pjRbCb - PDCP RB Control Block - * @param[in] discSduCfm - Info about the discarded SDUs - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PRIVATE S16 pjLimDiscSduCfm -( -PjCb *gCb, -PjDlRbCb *pjRbCb, /* PDCP RB Control Block */ -KwuDiscSduInfo *discSduCfm /* Info about the discarded SDUs*/ -) -#else -PRIVATE S16 pjLimDiscSduCfm(gCb, pjRbCb, count) -PjCb *gCb; -PjDlRbCb *pjRbCb; /* PDCP RB control Block */ -KwuDiscSduInfo *discSduCfm; /* Info about the discarded SDUs*/ -#endif -{ - PjuDatCfmInfo datCfm; /* DatCfm structure */ - CmLtePdcpId pdcpId; /* PDCP ID */ - PjTxEnt *txEnt; /* Transmission Entity */ - U32 count = 0; - U16 cfmsToUpperLayer = 0; /*KW_FIX*/ - - TRC3(pjLimDiscSduCfm); - - RLOG1(L_DEBUG, "pjLimDiscSduCfm(pjRbCb(%d))", pjRbCb->rbId); - - if((gCb->init.cfgDone == FALSE) || (discSduCfm->numSduIds == 0)) - { - RETVALUE(ROK); - } - - while(count < discSduCfm->numSduIds) - { - txEnt = pjDbmGetTxEnt(gCb, &(pjRbCb->dlCb.txBuf), discSduCfm->sduIds[count]); - - if(txEnt != NULLP) - { - if( pjRbCb->dlCb.cfmReqd) - { - datCfm.cfmSta[cfmsToUpperLayer].sduId = txEnt->sduId; - datCfm.cfmSta[cfmsToUpperLayer++].status = PJU_DISCARD_TMR_EXP; - } - - if( txEnt->pdu == txEnt->sdu ) - { - txEnt->sdu = NULLP; - } - - /* if the PDU being discarded was a one for which confirm was expected - then we need to set the confirm expectation correctly */ - - if(pjRbCb->dlCb.cfmExp < txEnt->count) - { - /* need to check if count should be just incremented by one or should the txHfn - also need to be considered */ - pjRbCb->dlCb.cfmExp = txEnt->count + 1; - } - - pjDbmDelTxEnt(gCb, &(pjRbCb->dlCb.txBuf), txEnt->count); - -#ifdef LTE_L2_MEAS - PJ_UPD_L2_DLDISC_STS(gCb,pjRbCb); -#endif - } - - count++; - } - - if(pjRbCb->dlCb.cfmReqd) - { - PjPjuSapCb *pjuSap; /* PJU SAP */ - - datCfm.numSdus = cfmsToUpperLayer; - - pdcpId.rbId = pjRbCb->rbId; - pdcpId.rbType = pjRbCb->rbType; - pdcpId.ueId = pjRbCb->ueCb->key.ueId; - pdcpId.cellId = pjRbCb->ueCb->key.cellId; - - if (pjRbCb->rbType == PJ_SRB) - { - pjuSap = &(gCb->u.dlCb->pjuSap[PJ_SRB_SAP]); - } - else - { - pjuSap = &(gCb->u.dlCb->pjuSap[PJ_DRB_SAP]); - } - - /* If trace flag is enabled send the trace indication */ - if(gCb->init.trc == TRUE) - { - /* Populate the trace params */ - pjLmmSendTrc(gCb, EVTPJUDATCFM, NULLP); - } - - PjUiPjuDatCfm(&pjuSap->pst, pjuSap->suId, &pdcpId, &datCfm); - } - - - RETVALUE(ROK); -} /* pjLimDiscSduCfm */ -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -/********************************************************************30** - End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_lmm.c b/src/5gnrpdcp/pj_lmm.c deleted file mode 100755 index 4ddbb0791..000000000 --- a/src/5gnrpdcp/pj_lmm.c +++ /dev/null @@ -1,2975 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: LTE - PDCP - Layer Manager file - - Type: C source file - - Desc: It contains the following common functions for processing - the all the external interfaces. - -- PjMiLpjCfgReq - -- PjMiLpjCfgCfm - -- PjMiLpjCntrlReq - -- PjMiLpjCntrlCfm - -- PjMiLpjStaReq - -- PjMiLpjStaCfm - -- PjMiLpjStaInd - -- PjMiLpjStsReq - -- PjMiLpjStsCfm - -- PjMiLpjTrcInd - - File: pj_lmm.c - -*********************************************************************21*/ -static const char* RLOG_MODULE_NAME="PDCP"; -static int RLOG_FILE_ID=135; -static int RLOG_MODULE_ID=1024; - -/** @file pj_lmm.c -@brief PDCP Layer Manager Module -**/ - - -/* header (.h) include files */ -#include "envopt.h" /* environment options */ -#include "envdep.h" /* environment dependent */ -#include "envind.h" /* environment independent */ - -#include "gen.h" /* general */ -#include "ssi.h" /* system services */ -#include "cm5.h" /* common timer defines */ -#include "cm_tkns.h" /* common tokens defines */ -#include "cm_mblk.h" /* common memory allocation library defines */ -#include "cm_llist.h" /* common link list defines */ -#include "cm_hash.h" /* common hash list defines */ -#include "cm_lte.h" /* common LTE defines */ -#include "kwu.h" -#include "lpj.h" /* LPJ defines */ -#include "cpj.h" /* CPJ defines */ -#include "pju.h" /* PJU defines */ -#include "lpj.h" -#include "pj_err.h" /* Err defines */ -#include "pj_env.h" /* PDCP environment options */ -#include "pj.h" /* PDCP defines */ -#include "pj_udx.h" - -/* extern (.x) include files */ -#include "gen.x" /* general */ -#include "ssi.x" /* system services */ - -#include "cm5.x" /* common timer library */ -#include "cm_tkns.x" /* common tokens */ -#include "cm_mblk.x" /* common memory allocation */ -#include "cm_llist.x" /* common link list */ -#include "cm_hash.x" /* common hash list */ -#include "cm_lte.x" /* common LTE includes */ -#include "cm_lib.x" /* common memory allocation library */ -#include "kwu.x" -#include "lpj.x" /* LPJ */ -#include "cpj.x" /* CPJ */ -#include "pju.x" /* PJU */ - -#include "pj.x" -#include "pj_udx.h" -#include "pj_udx.x" -#include "pj_ul.x" -#include "pj_dl.x" -#include "pj_lib.x" - -#ifdef __cplusplus -EXTERN "C" { -#endif /* CPLUSPLUS */ - -EXTERN S16 pjGetSId ARGS((SystemId *s)); -#ifdef __cplusplus -} -#endif /* CPLUSPLUS */ - -U8 *gPoolId; -PDCPStats gPdcpStats; - -#ifdef TENB_AS_SECURITY -U8 isSecBatchMode; -#endif - - -/********************************************************************* - * Forward Declaration of LPJ Porting Functions - ********************************************************************/ -PUBLIC PjCb *pjCb[PJ_MAX_PDCP_INSTANCES]; -EXTERN S16 pjActvTmr ARGS ((Ent ent, Inst inst)); - -PRIVATE S16 pjLmmSendCfm ARGS ((Pst *pst,PjMngmt *cfm,U8 type,Header *hdr)); -PRIVATE S16 pjLmmGenCfg ARGS ((PjCb *gCb,PjGenCfg *cfg)); -PRIVATE S16 pjLmmPjuSapCfg ARGS ((PjCb *gCb,PjSapCfg *cfg)); -PRIVATE S16 pjLmmKwuSapCfg ARGS ((PjCb *gCb,PjSapCfg *cfg)); -PRIVATE S16 pjLmmUdxSapCfg ARGS ((PjCb *gCb,PjSapCfg *cfg)); -PRIVATE S16 pjLmmCpjSapCfg ARGS ((PjCb *gCb,PjSapCfg *cfg)); -PRIVATE S16 pjLmmGenCntrl ARGS ((PjCb *gCb,PjMngmt *cntrl)); -PRIVATE S16 pjLmmUdxSapCntrl ARGS ((PjCb *gCb,PjMngmt *cntrl)); -PRIVATE S16 pjLmmLSapCntrl ARGS ((PjCb *gCb,PjMngmt *cntrl)); -PRIVATE S16 pjLmmFormLmCfm ARGS ((Pst *pst, Header *hdr, Reason reason)); -PRIVATE S16 pjLmmGetPjuSapSta ARGS ((PjCb *gCb,PjPjuSapSta *sta)); -PRIVATE S16 pjLmmGetKwuSapSta ARGS ((PjCb *gCb,PjKwuSapSta *sta)); -PRIVATE S16 pjLmmGetUdxSapSta ARGS ((PjCb *gCb,PjUdxSapSta *sta)); -PRIVATE S16 pjLmmGetCpjSapSta ARGS ((PjCb *gCb,PjCpjSapSta *sta)); -PRIVATE S16 pjLmmGetGenSts ARGS ((PjCb *gCb,PjGenSts *sts,Action action)); -PRIVATE S16 pjLmmGetSapSts ARGS ((PjCb *gCb,PjMngmt *sts,Elmnt elmnt,Action action)); -PRIVATE Void pjLmmCleanGblRsrcs ARGS ((PjCb *gCb)); - -/********************************************************************* - * Primitives for LPJ interface - ********************************************************************/ -/** - * @brief - Stores the general PDCP configuration. It calculates the - memory requirement and reserves it. It also initializes the - control blocks, the hash lists and registers the timers. In - case of error it rolls back and reports error in the confirm. - If the general configuration is already done it is treated as - reconfiguration, but right now reconfiguration is not supported. - - * @param[in] cfm PDCP LM general config structure - * @return S16 - * -# Success : LCM_REASON_NOT_APPL - * -# Failure : LCM_REASON_MEM_NOAVAIL - * LCM_REASON_REGTMR_FAIL - * LCM_REASON_INVALID_PAR_VAL - * LCM_REASON_HASHING_FAILED - */ -#ifdef ANSI -PRIVATE S16 pjLmmGenCfg -( -PjCb *gCb, -PjGenCfg *cfg -) -#else -PRIVATE S16 pjLmmGenCfg(gCb, cfg) -PjCb *gCb; -PjGenCfg *cfg; -#endif -{ - Size pjMemSize; - CmTqCp *pjTqCp; - U16 cnt; - S16 ret; - - TRC2(pjLmmGenCfg) - - ret = ROK; - pjMemSize = 0; - - if(cfg->maxUe > PJ_MAX_UE) - { -#if (ERRCLASS & ERRCLS_INT_PAR) - RLOG2(L_ERROR, "Invalid maxUe : Max [%lu] Received [%lu]", - PJ_MAX_UE, cfg->maxUe); -#endif /* ERRCLASS & ERRCLS_INT_PAR */ - RETVALUE(LCM_REASON_INVALID_PAR_VAL); - } - - if(cfg->maxPjuSaps > PJ_MAX_PJUSAPS) - { -#if (ERRCLASS & ERRCLS_INT_PAR) - RLOG2(L_ERROR, "Invalid maxPjuSaps : Max [%lu] Received [%lu]", - PJ_MAX_PJUSAPS, cfg->maxPjuSaps); -#endif /* ERRCLASS & ERRCLS_INT_PAR */ - RETVALUE(LCM_REASON_INVALID_PAR_VAL); - } - - if(cfg->maxKwuSaps > PJ_MAX_KWUSAPS) - { -#if (ERRCLASS & ERRCLS_INT_PAR) - RLOG2(L_ERROR, "Invalid maxKwuSaps : Max [%lu] Received [%lu]", - PJ_MAX_KWUSAPS, cfg->maxKwuSaps); -#endif /* ERRCLASS & ERRCLS_INT_PAR */ - RETVALUE(LCM_REASON_INVALID_PAR_VAL); - } - - if(cfg->maxUdxSaps > PJ_MAX_UDXSAPS) - { -#if (ERRCLASS & ERRCLS_INT_PAR) - RLOG2(L_ERROR, "Invalid maxUduSaps : Max [%lu] Received [%lu]", - PJ_MAX_UDXSAPS, cfg->maxUdxSaps); -#endif /* ERRCLASS & ERRCLS_INT_PAR */ - RETVALUE(LCM_REASON_INVALID_PAR_VAL); - } - - if(gCb->init.cfgDone & PJ_LMM_GENCFG_DONE) - { - /* reconfiguration is supported only for obdDiscTmrInt */ -#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)) - gCb->pjGenCfg.obdTmrInt = cfg->obdTmrInt; - gCb->pjGenCfg.obdWtTmrInt = cfg->obdWtTmrInt; -#endif /* PJ_SEC_ASYNC || PJ_CMP_ASYNC */ - RETVALUE(LCM_REASON_NOT_APPL); - } - - PJ_MEM_CPY(&(gCb->pjGenCfg), cfg, sizeof(PjGenCfg)); -#ifdef TENB_AS_SECURITY - isSecBatchMode = TRUE; - /* Rangeley Fix */ -#ifdef INTEL_SW_SEC - isSecBatchMode = FALSE; -#endif - -#endif - - /* Timer Queue Control point initialization */ - pjTqCp = &(gCb->pjTqCp); - pjTqCp->tmrLen = PJ_TMR_LEN; - pjTqCp->nxtEnt = 0; - - /* calculate the memory requirements */ - pjMemSize += (Size)SBUFSIZE(PJ_UE_LIST_BUCKET_SIZE * sizeof(CmListEnt)); - - /* Cell Hash List Size */ - pjMemSize += (Size)SBUFSIZE(PJ_CELL_LIST_BUCKET_SIZE * sizeof(CmListEnt)); - - /* Reserve the memory */ - if(SGetSMem(PJ_GET_MEM_REGION(gCb), pjMemSize, - PJ_GET_MEM_POOL_ADDRESS(gCb)) != ROK) - { - RETVALUE(LCM_REASON_MEM_NOAVAIL); - } - cmMemset((U8 *)&gCb->pjTq, 0, sizeof(CmTqType)*PJ_TMR_LEN); - cmMemset((U8 *)&gCb->pjTqCp, 0, sizeof(CmTqCp)); - gCb->pjTqCp.tmrLen = PJ_TMR_LEN; - /* Register the timer */ - if(SRegTmrMt(gCb->init.ent, gCb->init.inst, (U16)cfg->timeRes, - pjActvTmr) != ROK) - { - (Void) SPutSMem(PJ_GET_MEM_REGION(gCb), PJ_GET_MEM_POOL(gCb)); - - RETVALUE(LCM_REASON_REGTMR_FAIL); - } - - /* Timer Initialization */ - gCb->pjTqCp.tmrLen = PJ_TMR_LEN; - for(cnt = 0; cnt < PJ_TMR_LEN; cnt++) - { - gCb->pjTq[cnt].first = NULLP; - gCb->pjTq[cnt].tail = NULLP; - } - - - if (cfg->mode == LPJ_MODE_PDCP_UL) - { - PJ_ALLOC(gCb, gCb->u.ulCb, sizeof(PjUlgCb)); - if (gCb->u.ulCb == NULLP) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - /* Do clean up */ - RETVALUE(RFAILED); - } - - /* Initialize the Ue and Cell hash list */ - ret = pjDbmUlInit(gCb); /*How would DbmDlInit be called? */ - if (ret != ROK) - { - /* Do Clean up */ - RETVALUE(LCM_REASON_HASHING_FAILED); - } - - /* Initialize the PJU SAP control blocks */ - PJ_MEM_SET(&(gCb->u.ulCb->pjuSap[PJ_SRB_SAP]), 0, sizeof(PjPjuSapCb)); - PJ_MEM_SET(&(gCb->u.ulCb->pjuSap[PJ_DRB_SAP]), 0, sizeof(PjPjuSapCb)); - - /* Initialize the KWU SAP Control blocks */ - PJ_MEM_SET(&(gCb->u.ulCb->kwuSap), 0, (PJ_MAX_KWUSAPS * sizeof(PjPjuSapCb))); - PJ_MEM_SET(&(gCb->u.ulCb->udxUlSap), 0, (PJ_MAX_UDXSAPS * sizeof(PjUdxUlSapCb))); - - /* Initialize CPJ SAP control block */ - PJ_MEM_SET(&(gCb->u.ulCb->cpjSap), 0, sizeof(PjCpjSapCb)); -#ifdef LTE_L2_MEAS - pjUtlL2MeasUlInit(gCb); -#endif - } - else - { - PJ_ALLOC(gCb, gCb->u.dlCb, sizeof(PjDlgCb)); - if (gCb->u.dlCb == NULLP) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - /* Do clean up */ - RETVALUE(RFAILED); - } - - /* Initialize the Ue and Cell hash list */ - ret = pjDbmDlInit(gCb); - if (ret != ROK) - { - RETVALUE(LCM_REASON_HASHING_FAILED); - } - - - /* Initialize the PJU SAP control blocks */ - PJ_MEM_SET(&(gCb->u.dlCb->pjuSap[PJ_SRB_SAP]), 0, sizeof(PjPjuSapCb)); - PJ_MEM_SET(&(gCb->u.dlCb->pjuSap[PJ_DRB_SAP]), 0, sizeof(PjPjuSapCb)); - - /* Initialize the KWU SAP Control blocks */ - PJ_MEM_SET(&(gCb->u.dlCb->kwuSap), 0, (PJ_MAX_KWUSAPS * sizeof(PjPjuSapCb))); - PJ_MEM_SET(&(gCb->u.dlCb->udxDlSap), 0, (PJ_MAX_UDXSAPS * sizeof(PjUdxDlSapCb))); -#ifdef LTE_L2_MEAS - pjUtlL2MeasDlInit(gCb); -#endif - } - - PJ_MEM_CPY(&(gCb->init.lmPst), &cfg->lmPst, - sizeof(Pst)); - - gCb->init.lmPst.srcProcId = gCb->init.procId; - gCb->init.lmPst.srcEnt = gCb->init.ent; - gCb->init.lmPst.srcInst = gCb->init.inst; - gCb->init.lmPst.event = EVTNONE; - - /* pj002.201 For multi core and multi region, no need to reinitiailize the region again . - This would be done with pjActvInit from SSI */ -#if !defined(SS_MULTICORE_SUPPORT) && !defined(SS_M_PROTO_REGION) - gCb->init.region = cfg->lmPst.region; -#endif - gCb->init.pool = cfg->lmPst.pool; - - gCb->init.cfgDone |= PJ_LMM_GENCFG_DONE; - - gPoolId = &(gCb->u.dlCb->kwuSap->pst.pool); - -#ifdef TENB_AS_SECURITY - /* Initialize UL fd for interfacing with SPAcc */ - if (cfg->mode == LPJ_MODE_PDCP_UL) - { - if(PjLibObdUlInitReq(gCb) != ROK) - { - RETVALUE(LCM_REASON_MISC_FAILURE); - } - } - else - { - /* Initialize DL fd for interfacing with SPAcc */ - if(PjLibObdDlInitReq(gCb) != ROK) - { - RETVALUE(LCM_REASON_MISC_FAILURE); - } - } -#endif - - - RETVALUE(LCM_REASON_NOT_APPL); -} /* pjLmmGenCfg */ - -/** - * - * @brief - * Sends confirmation message to LM Called by Request function - * @param[in] pst Post structure - * @param[in] cfm PDCP LM structure - * @param[in] type type of message - * @param[in] hdr message header - * @return S16 - * -# ROK - */ -#ifdef ANSI -PRIVATE S16 pjLmmSendCfm -( -Pst *pst, /* Post structure */ -PjMngmt *cfm, /* PDCP LM structure */ -U8 type, /* type of message */ -Header *hdr /* message header */ -) -#else -PRIVATE S16 pjLmmSendCfm(pst, cfm, type, hdr) -Pst *pst; /* Post structure */ -PjMngmt *cfm; /* PDCP LM structure */ -U8 type; /* type of message */ -Header *hdr; /* message header */ -#endif -{ - Pst rPst; /* Reply post structure */ - PjCb *tPjCb; - TRC2(pjLmmSendCfm); - - tPjCb = PJ_GET_PJCB(pst->dstInst); - PJ_MEM_SET(&rPst, 0, sizeof(Pst)); - - /* reply post structure for confirmation */ - rPst.srcEnt = tPjCb->init.ent; - rPst.srcInst = tPjCb->init.inst; - rPst.srcProcId = SFndProcId(); - rPst.dstEnt = pst->srcEnt; - rPst.dstInst = pst->srcInst; - rPst.dstProcId = pst->srcProcId; - rPst.selector = hdr->response.selector; - rPst.prior = hdr->response.prior; - rPst.route = hdr->response.route; - rPst.region = hdr->response.mem.region; - rPst.pool= hdr->response.mem.pool; - - /* Fill the reply header */ - PJ_MEM_SET (&cfm->hdr, '\0', sizeof(cfm->hdr)); - cfm->hdr.elmId.elmnt = hdr->elmId.elmnt; - cfm->hdr.entId.ent = tPjCb->init.ent; - cfm->hdr.entId.inst = tPjCb->init.inst; - cfm->hdr.transId = hdr->transId; - - switch(type) - { - case TCFG: - PjMiLpjCfgCfm(&rPst,cfm); - break; - case TCNTRL: - SGetDateTime(&(cfm->t.cntrl.dt)); - PjMiLpjCntrlCfm(&rPst,cfm); - break; - case TSTS: - SGetDateTime(&(cfm->t.sts.dt)); - PjMiLpjStsCfm(&rPst,0,cfm); - break; - case TSSTA: - SGetDateTime(&(cfm->t.ssta.dt)); - PjMiLpjStaCfm(&rPst,cfm); - break; - default: -#if (ERRCLASS & ERRCLS_INT_PAR) - RLOG0(L_ERROR, "Invalid message type"); - -#endif /* ERRCLASS & ERRCLS_INT_PAR */ - break; - } - - RETVALUE(ROK); -} /* pjLmmSendCfm */ - - -/** -@brief -This function processes configuration requests received from the layer manager. -The configuration requests can be for general configuration, or configuration -of PJU, and CPJ SAPs. The type of the configuration request can be determined -from the elmId field in the header of the layer manager message.This function -is called by the layer manager to configure PDCP. - -This function implements the following logic: \n - -- switch (cfg->hdr.elmId.elmnt) - - case STGEN - - update the genCfg field in RlCb; - - allocate the maximum static memory required by the PDCP product; - - register the timer service by calling SReqTmr; - - set CfgDone for not configuring again; - - case STPJUSAP - - if genCfg is not done, send negative Cfm to the layer manager; - - if all the parameters are valid, then allocate the RlSap control block; - - update the SAP control block with the information provided in the - - configuration request; - - send configuration confirm with the status, success; - - case STCPJSAP - - if genCfg is not done, send negative Cfm to the layer manager; - - if all the parametes are valid, then allocate the CrSap control block; - - update the SAP control block with the information provided in the - configuration request; - - send configuration confirm with the status, success; -- end switch; - - * @param[in] pst post structure - * @param[in] cfg LM management structure - * @return S16 - * -# Success : ROK - * -# Failure : RFAILED -*/ - -#ifdef ANSI -PUBLIC S16 PjMiLpjCfgReq -( -Pst *pst, -PjMngmt *cfg -) -#else -PUBLIC S16 PjMiLpjCfgReq (pst, cfg) -Pst *pst; -PjMngmt *cfg; -#endif -{ - S16 ret; - Elmnt elmnt; /* header element */ - PjMngmt rCfm; /* Reply cfm */ - Reason reason; /* failure reason */ - PjCb *tPjCb; - - TRC3(PjMiLpjCfgReq); - - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) /* KW_FIX */ - { - RETVALUE(RFAILED); - } - - tPjCb = PJ_GET_PJCB(pst->dstInst); - - RLOG1(L_DEBUG, "PjMiLpjCfgReq(post, elmId(%d))", cfg->hdr.elmId.elmnt); - - ret = ROK; - - /* check configuration is done or not */ - if ((!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE)) && - (cfg->hdr.elmId.elmnt != STGEN)) - { - /* - * if general config is not over then use pst structure - * in primitive to communicate to stack manager - */ - - rCfm.cfm.status = LCM_PRIM_NOK; - rCfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE; - pjLmmSendCfm(pst, &rCfm, TCFG, &cfg->hdr); - RETVALUE(RFAILED); - } - - elmnt = cfg->hdr.elmId.elmnt; - - switch(elmnt) - { - case STGEN: - { - reason = pjLmmGenCfg(tPjCb,&cfg->t.cfg.s.gen); - break; - } - case STPJUSAP: - { - reason = pjLmmPjuSapCfg(tPjCb,&cfg->t.cfg.s.sap); - break; - } - case STKWUSAP: - { - reason = pjLmmKwuSapCfg(tPjCb,&cfg->t.cfg.s.sap); - break; - } - case STCPJSAP: - { - reason = pjLmmCpjSapCfg(tPjCb,&cfg->t.cfg.s.sap); - break; - } - case STUDXSAP: - { - reason = pjLmmUdxSapCfg(tPjCb,&cfg->t.cfg.s.sap); - break; - } - default: - { - reason = LCM_REASON_INVALID_ELMNT; - break; - } - } - - if (reason == LCM_REASON_NOT_APPL) - { - rCfm.cfm.status = LCM_PRIM_OK; - rCfm.cfm.reason = LCM_REASON_NOT_APPL; - - ret = ROK; - } - else - { - rCfm.cfm.status = LCM_PRIM_NOK; - rCfm.cfm.reason = reason; - - ret = RFAILED; - } - - RLOG2(L_DEBUG, "Cfg Req processed : status(%d) reason(%d)", - rCfm.cfm.status, rCfm.cfm.reason); - - ret = pjLmmSendCfm(pst, &rCfm, TCFG, &cfg->hdr); - - RETVALUE(ret); -} /* PjMiLpjCfgReq */ - -/** -@brief -The layer manager initiates and uses the management-control procedure to -control PDCP elements.The PDCP control request primitive (PjMiLpjCntrlReq) -can be called more than once and at any time after the management-configuration -procedure.The control request primitive is confirmed by a PjMiLpjCntrlCfm -primitive. - -This function implements the following logic: \n - -- if(cfgDone = FALSE) - - send negative confirmation to the layer manager; - - return; -- else -- switch(cntrl->hdr.elmId.elmnt) - - case STGEN - - switch (action) - - case AENA - - switch(subAction) - - case SAUSTA - - enable the unsolicited status flag; - - send the control Cfm with success; - - case SADBG - - set the debug mask; - - send the control Cfm with success; - - case SATRC - - enable the trace flag; - - send the control Cfm with success; - - case ADISIMM - - switch(subAction) - - case SAUSTA - - disable the unsolicited status flag; - - send the control Cfm with success; - - case SATRC - - disable the trace flag; - - send the control Cfm with success; - - case ASHUTDOWN - - case STMKSAP - - switch (action) - - case ABND - - case AUBND - - default -- end else - * @param[in] pst post structure - * @param[in] cntrl LM management structure - * @return S16 - * -# Success : ROK - * -# Failure : RFAILED -*/ -#ifdef ANSI -PUBLIC S16 PjMiLpjCntrlReq -( -Pst *pst, -PjMngmt *cntrl -) -#else -PUBLIC S16 PjMiLpjCntrlReq(pst, cntrl) -Pst *pst; -PjMngmt *cntrl; -#endif -{ - Elmnt elmnt; /* header element */ - PjMngmt rCfm; /* Reply cfm */ - Reason reason; /* failure reason */ - - S16 ret; - PjCb *tPjCb; - - TRC3(PjMiLpjCntrlReq) - - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) /* KW_FIX */ - { - RETVALUE(RFAILED); - } - - tPjCb = PJ_GET_PJCB(pst->dstInst); - - RLOG1(L_DEBUG, "Cntrl Req Received (post, elmId(%d))", - cntrl->hdr.elmId.elmnt); - - ret = ROK; - - if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE)) - { - rCfm.cfm.status = LCM_PRIM_NOK; - rCfm.cfm.reason = LCM_REASON_GENCFG_NOT_DONE; - - pjLmmSendCfm(pst, &rCfm, TCNTRL, &cntrl->hdr); - RETVALUE(RFAILED); - } - - /* In normal cases, LCM_REASON_NOT_APPL is returned in cfm. - * In all error cases appropriate reason is returned - * by the functions below - */ - - elmnt = cntrl->hdr.elmId.elmnt; - - reason = LCM_REASON_NOT_APPL; - - - switch (elmnt) - { - case STGEN: - { - /* general control */ - reason = pjLmmGenCntrl(tPjCb,cntrl); - break; - } - - case STKWUSAP: - { - /* general control */ - reason = pjLmmLSapCntrl(tPjCb,cntrl); - break; - } - case STUDXSAP: - { - /* general control */ - reason = pjLmmUdxSapCntrl(tPjCb,cntrl); - break; - } - - default: - { - reason = LCM_REASON_INVALID_ELMNT; - break; - } - } /* end switch */ - - RLOG1(L_DEBUG, "Cntrl Req Processed sending cfm: reason(%d)", reason); - - ret = pjLmmFormLmCfm(pst, &cntrl->hdr, reason); - RETVALUE(ret); -} /* PjMiLpjCntrlReq */ - -/** -@brief -This function processes solicited status requests received from the layer -manager. The layer manager can request status information regarding the -system ID, PJUSAP, or CPJSAP. - - * @param[in] pst post structure - * @param[in] cfm LM management structure - * @return S16 - * -# Success : ROK - * -# Failure : RFAILED -*/ -#ifdef ANSI -PUBLIC S16 PjMiLpjStaReq -( -Pst *pst, -PjMngmt *sta -) -#else -PUBLIC S16 PjMiLpjStaReq(pst, sta) -Pst *pst; -PjMngmt *sta; -#endif -{ - S16 ret; - Elmnt elmnt; /* Header element */ - PjMngmt rSta; /* Status */ - Reason reason; /* Failure reason */ - PjCb *tPjCb; - - TRC3(PjMiLpjStaReq); - - tPjCb = PJ_GET_PJCB(pst->dstInst); - RLOG1(L_DEBUG, "Status Req Received (post, elmId(%d))", - sta->hdr.elmId.elmnt); - - PJ_MEM_SET(&rSta, 0, sizeof(PjMngmt)); - - reason = LCM_REASON_NOT_APPL; - - elmnt = sta->hdr.elmId.elmnt; - - switch (elmnt) - { - case STSID: - { - reason = LCM_REASON_NOT_APPL; - pjGetSId(&rSta.t.ssta.s.sysId); - break; - } - case STGEN: - { - break; - } - case STKWUSAP: - { - PJ_MEM_CPY (&rSta.t.ssta.s.kwuSap, &sta->t.ssta.s.kwuSap, - sizeof (PjKwuSapSta)); - reason = pjLmmGetKwuSapSta (tPjCb,&rSta.t.ssta.s.kwuSap); - break; - } - case STUDXSAP: - { - PJ_MEM_CPY (&rSta.t.ssta.s.udxSap, &sta->t.ssta.s.udxSap, - sizeof (PjUdxSapSta)); - reason = pjLmmGetUdxSapSta (tPjCb,&rSta.t.ssta.s.udxSap); - break; - } - case STPJUSAP: - { - PJ_MEM_CPY (&rSta.t.ssta.s.pjuSap, &sta->t.ssta.s.pjuSap, - sizeof (PjPjuSapSta)); - reason = pjLmmGetPjuSapSta (tPjCb,&rSta.t.ssta.s.pjuSap); - break; - } - case STCPJSAP: - { - PJ_MEM_CPY (&rSta.t.ssta.s.cpjSap, &sta->t.ssta.s.cpjSap, - sizeof (PjCpjSapSta)); - reason = pjLmmGetCpjSapSta (tPjCb,&rSta.t.ssta.s.cpjSap); - break; - } - default: - { - reason = LCM_REASON_INVALID_ELMNT; - break; - } - } /* end of switch */ - - if (reason == LCM_REASON_NOT_APPL) - { - rSta.cfm.status = LCM_PRIM_OK; - rSta.cfm.reason = LCM_REASON_NOT_APPL; - - ret = ROK; - } - else - { - rSta.cfm.status = LCM_PRIM_NOK; - rSta.cfm.reason = reason; - - ret = RFAILED; - } - - RLOG2(L_DEBUG, "Sta Req processed - sending cfm: status(%d) reason(%d)", - rSta.cfm.status, rSta.cfm.reason); - - ret = pjLmmSendCfm(pst, &rSta, TSSTA, &sta->hdr); - - RETVALUE(ret); -} /* PjMiLpjStaReq */ - -/** -@brief -This function processes statistics requests received from the layer manager. -After collecting the statistics, this function calls the statistics confirm -function to send the statistics to the layer manager. - -- switch(sts->hdr.elmId.elmnt) - - case STGEN - - get the general statistics from the PJ control block; - - if (action = RESET) - - reset the general statistic field in the RlCb; - - call PjMiLpjStsCfm to send statistics back to layer manager; - - case STCPJSAP - - case STPJUSAP - - get the SAP specific statistics from PJ control block; - - if (action = RESET) - - reset the general statistic field in the RlCb; - - call PjMiLpjStsCfm to send statistics to the layer manager; --end switch; - - * @param[in] pst post structure - * @param[in] action action - * @param[in] cfg LM management structure - * @return S16 - * -# Success : ROK - * -# Failure : RFAILED -*/ -#ifdef ANSI -PUBLIC S16 PjMiLpjStsReq -( -Pst *pst, -Action action, -PjMngmt *sts -) -#else -PUBLIC S16 PjMiLpjStsReq (pst, action, sts) -Pst *pst; -Action action; -PjMngmt *sts; -#endif -{ - S16 ret; - PjMngmt rSts; /* Statistics */ - Reason reason; /* Reason for failure */ - Elmnt elmnt; /* Element Id */ - PjCb *tPjCb; - - TRC3(PjMiLpjStsReq); - - tPjCb = PJ_GET_PJCB(pst->dstInst); - RLOG2(L_DEBUG, "Sts Req (post, elmId(%d),action(%d))", - action, sts->hdr.elmId.elmnt); - - PJ_MEM_SET(&rSts, 0, sizeof(PjMngmt)); - elmnt = sts->hdr.elmId.elmnt; - - switch (elmnt) - { - case STGEN: - { - reason = pjLmmGetGenSts(tPjCb,&rSts.t.sts.s.gen, action); - break; - } - case STPJUSAP: - { - reason = pjLmmGetSapSts(tPjCb,sts, elmnt, action); - PJ_MEM_CPY(&rSts.t.sts.s.pjuSap, &sts->t.sts.s.pjuSap, - sizeof(PjPjuSts)); - break; - } - case STCPJSAP: /* No CPJ SAP statistics available */ - default: - { - reason = LCM_REASON_INVALID_ELMNT; - break; - } - } /* end switch */ - - if (reason == LCM_REASON_NOT_APPL) - { - rSts.cfm.status = LCM_PRIM_OK; - rSts.cfm.reason = LCM_REASON_NOT_APPL; - - ret = ROK; - } - else - { - rSts.cfm.status = LCM_PRIM_NOK; - rSts.cfm.reason = reason; - - ret = RFAILED; - } - - RLOG2(L_DEBUG, "Sts Req Processed - sending cfm: status(%d) reason(%d)", - rSts.cfm.status, rSts.cfm.reason); - - ret = pjLmmSendCfm(pst, &rSts, TSTS, &sts->hdr); - - RETVALUE(ret); -} /* PjMiLpjStsReq */ -/* pj005.201 added support for L2 Measurement */ -#ifdef LTE_L2_MEAS -/** - * @brief Validates the measurement request parameters. - * - * @details - * - * Function :pjUtlValidateL2Meas - * - * @param[in] PjL2MeasReqEvt measReqEvt - * @param[out] PjL2MeasCfmEvt measCfmEvt - **/ -#ifdef ANSI -PRIVATE S16 pjUtlValidateL2Meas -( -PjCb *tPjCb, -PjL2MeasReqEvt *measReqEvt, -PjL2MeasCfmEvt *measCfmEvt -) -#else -PRIVATE S16 pjUtlValidateL2Meas(tPjCb, measReqEvt, measCfmEvt) -PjCb *tPjCb; -PjL2MeasReqEvt *measReqEvt; -PjL2MeasCfmEvt *measCfmEvt; -#endif -{ - U16 measType; - S16 ret; - U8 qciIdx, qciVal; - - TRC3(pjUtlValidateL2Meas) - - ret = ROK; - measType = measReqEvt->measReq.measType; - - if(measType == 0) - { - measCfmEvt->numQciCfm = 1; - measCfmEvt->measCfm[0].qci = measReqEvt->measReq.qci[0]; - measCfmEvt->transId = measReqEvt->transId; - measCfmEvt->measType = measType; - measCfmEvt->status.status = LCM_PRIM_NOK; - measCfmEvt->status.reason = LPJ_CAUSE_INVALID_MEASTYPE; - RETVALUE(RFAILED); - } - if(((measReqEvt->measReq.measType & LPJ_L2CPU_PERCORE_STATS) || - (measReqEvt->measReq.measType & LPJ_L2MEM_PERPOOL_STATS)) && - (~(measReqEvt->measReq.measType & LPJ_L2MEAS_UL_LOSS))) - - { - RETVALUE(ROK); - } - if(measReqEvt->measReq.numQci > LPJ_MAX_QCI || measReqEvt->measReq.numQci == 0) - { - measCfmEvt->numQciCfm = 1; - measCfmEvt->transId = measReqEvt->transId; - measCfmEvt->measType = measType; - measCfmEvt->status.status = LCM_PRIM_NOK; - measCfmEvt->status.reason = LPJ_CAUSE_EXCEED_NUMQCI; - RETVALUE(RFAILED); - } - if(measReqEvt->measPeriod != 0) - { - measCfmEvt->numQciCfm = 1; - measCfmEvt->transId = measReqEvt->transId; - measCfmEvt->measType = measType; - measCfmEvt->status.status = LCM_PRIM_NOK; - measCfmEvt->status.reason = LPJ_CAUSE_INVALID_MEASTYPE; - RETVALUE(RFAILED); - } - for(qciIdx = 0; qciIdx < measReqEvt->measReq.numQci; qciIdx++) - { - if(tPjCb->u.ulCb->pjL2Cb.measOn[measReqEvt->measReq.qci[qciIdx]] & - measReqEvt->measReq.measType) - { - /* Measurement is already ongoing */ - measCfmEvt->measCfm[measCfmEvt->numQciCfm].qci = qciIdx; - measCfmEvt->measType = measType; - measCfmEvt->numQciCfm++; - } - } - if(measCfmEvt->numQciCfm > 0) - { - measCfmEvt->status.status = LCM_PRIM_NOK; - measCfmEvt->status.reason = LPJ_CAUSE_MEAS_ALREADY_ENA; - measCfmEvt->transId = measReqEvt->transId; - RETVALUE(RFAILED); - } - for(qciIdx = 0; qciIdx < measReqEvt->measReq.numQci; qciIdx++) - { - qciVal = measReqEvt->measReq.qci[qciIdx]; - if(qciVal == 0 || qciVal > 9) - { - measCfmEvt->numQciCfm = 1; - measCfmEvt->measCfm[0].qci = measReqEvt->measReq.qci[qciIdx]; - measCfmEvt->transId = measReqEvt->transId; - measCfmEvt->measType = measReqEvt->measReq.measType; - measCfmEvt->status.status = LCM_PRIM_NOK; - measCfmEvt->status.reason = LPJ_CAUSE_INVALID_QCI; - RETVALUE(RFAILED); - } - } - - - RETVALUE(ROK); -}/* pjUtlValidateL2Meas */ - -/** -@brief -This function processes L2 Measurement requests received from the layer manager. -The L2 Measurement is start for a time period and after the timer expiry, the -measurement confirm is sent. - -- Accept only one set of measurements. -- Allocate and initialise KwL2MeasEvtCb. -- Validate if the measurement is already in progress. - - Loop through the existing measEvtCb with matching measType - - Check if measurement is running for any qci present in the measReq - - If present, move the qCi to list of invalid qCIs. -- Set KwL2MeasEvtCb.measOn to TRUE for QCIs to be measured. -- For the number of measurements requested. - - For all Ues with RBs matching qCI. - - Add RbCb to the RB linked list. - - Set kwRbCb.measOn to measurement type. - - If Meas type is DL_DELAY - - Update COUNT to startCount. -- Start l2Timer - - * @param[in] pst post structure - * @param[in] action action - * @param[in] cfg LM management structure - * @return S16 - * -# Success : ROK - * -# Failure : RFAILED -*/ -#ifdef ANSI -PUBLIC S16 PjMiLpjL2MeasReq -( -Pst *pst, -PjL2MeasReqEvt *measReqEvt -) -#else -PUBLIC S16 PjMiLpjL2MeasReq (pst, measReqEvt) -Pst *pst; -PjL2MeasReqEvt *measReqEvt; -#endif -{ - S16 ret = ROK; - U16 measType; - PjL2MeasCfmEvt measCfmEvt; - PjL2Cb *pjL2Cb = NULLP; - PjCb *tPjCb = PJ_GET_PJCB(pst->dstInst); - - TRC3(PjMiLpjL2MeasReq); - - tPjCb = PJ_GET_PJCB(pst->dstInst); - - measType = measReqEvt->measReq.measType; - - RLOG1(L_DEBUG, "L2_MEAS START Measurement type is %u\n", measType); - /* Initialize measCfmEvt */ - memset(&measCfmEvt,0, sizeof(PjL2MeasCfmEvt)); - - ret = pjUtlValidateL2Meas(tPjCb, measReqEvt, &measCfmEvt); - if(ret != ROK) - { - pjUtlSndUlL2MeasNCfm(tPjCb, &measCfmEvt); - RETVALUE(RFAILED); - } - - RLOG1(L_DEBUG,"Measurement Start Req type is [%lu]", measType); - if (measType & LPJ_L2MEAS_UL_LOSS) - { - U32 cntr = 0; - - pjL2Cb = &tPjCb->u.ulCb->pjL2Cb; - - for(cntr = 1; cntr < LPJ_MAX_QCI; cntr++) - { - pjL2Cb->measOn[cntr] |= measType; - } - } - if ((measType & LPJ_L2MEM_PERPOOL_STATS) || (measType & LPJ_L2CPU_PERCORE_STATS) ) - { - /* starting measurement timer */ - ret = pjStartTmr(tPjCb, (PTR)tPjCb, PJ_EVT_L2_MEAS_TMR); - if(ret == RFAILED) - { - RETVALUE(ret); - } - } - if(measType & LPJ_L2MEM_PERPOOL_STATS) - { - pjL2Cb->memUtilizationMask |= LPJ_L2MEM_PERPOOL_STATS; - } - if(measType & LPJ_L2CPU_PERCORE_STATS) - { - pjL2Cb->cpuUtilizationMask |= LPJ_L2CPU_PERCORE_STATS; - } - /* Use else for DL in future */ - RETVALUE(ret); -} /* PjMiLpjL2MeasReq */ - -/** -@brief -This function processes L2 Measurement stop request received from the layer manager. -After receving this request, PDCP stops L2 Measurement - * @param[in] pst post structure - * @param[in] measType meas Type - * @return S16 - * -# Success : ROK - * -# Failure : RFAILED -*/ - -#ifdef ANSI -PUBLIC S16 PjMiLpjL2MeasStopReq -( -Pst *pst, -U16 measType -) -#else -PUBLIC S16 PjMiLpjL2MeasStopReq (pst, measType) -Pst *pst; -U16 measType; -#endif -{ - U16 cntr; - PjCb *tPjCb = PJ_GET_PJCB(pst->dstInst); - PjL2MeasEvtCb *measEvtCb = NULLP; - PjL2MeasCfmEvt measCfmEvt; - TRC3(PjMiLpjL2MeasStopReq); - - - RLOG1(L_DEBUG,"Meas Stop Req type is [%lu]", measType); - /* For UL counters only */ - cmMemset((U8*)&measCfmEvt, 0, sizeof(PjL2MeasCfmEvt)); - - if(measType & LPJ_L2MEM_PERPOOL_STATS || - measType & LPJ_L2CPU_PERCORE_STATS) - { - /* stopping timer */ - pjStopTmr(tPjCb, (PTR)tPjCb, PJ_EVT_L2_MEAS_TMR); - } - if(measType & LPJ_L2MEM_PERPOOL_STATS) - { - tPjCb->u.ulCb->pjL2Cb.memUtilizationMask = 0; - } - if(measType & LPJ_L2CPU_PERCORE_STATS) - { - tPjCb->u.ulCb->pjL2Cb.cpuUtilizationMask = 0; - } - - for(cntr = 0; cntr < LPJ_MAX_L2MEAS; cntr++) - { - measEvtCb = &(tPjCb->u.ulCb->pjL2Cb.pjL2EvtCb[cntr]); - if(measEvtCb->measCb.measType & measType) - { - pjUtlResetUlL2MeasCntr(tPjCb, &measEvtCb->measCb, measType); - } - } - PjMiLpjL2MeasStopCfm(&tPjCb->pjGenCfg.lmPst, measType,LCM_PRIM_OK); - RETVALUE(ROK); -} - - -/** - * - * @brief For reporting measurement. - * - * - * @b Description - * This function is called when the l2 measurement report send request is received. - * This function sends a consolidates the mesaurements taken during - * this time and sends the confirm . - * - * @param[in] measEvtCb Measurement Event Control Block. - * - * - * @return S16 - * -# ROK - */ - -#ifdef ANSI -PRIVATE S16 PjUtlPrepNSndL2MeasSendCfm -( -PjCb *tPjCb, -PjL2MeasEvtCb *measEvtCb -) -#else -PRIVATE S16 PjUtlPrepNSndL2MeasSendCfm(tPjCb, measEvtCb) -PjCb *tPjCb; -PjL2MeasEvtCb *measEvtCb; -#endif -{ - PjL2MeasCb *measCb; - PjL2MeasCfmEvt measCfmEvt; - U8 qciIdx; - U8 coreIdx; - S16 ret; - TRC3(PjUtlPrepNSndL2MeasSendCfm); - - measCb = &measEvtCb->measCb; - /* Initialize measCfmEvt */ - cmMemset((U8 *) &measCfmEvt, 0, sizeof(PjL2MeasCfmEvt)); - measCfmEvt.measType = measCb->measType; - measCfmEvt.status.status = LCM_PRIM_OK; - measCfmEvt.status.reason = LCM_REASON_NOT_APPL; - - /* Filling Memory Utilzation structure */ - if(measCb->measType & LPJ_L2MEM_PERPOOL_STATS) - { - if(tPjCb->u.ulCb->pjL2Cb.memUtilizationMask & LPJ_L2MEM_PERPOOL_STATS) - { - cmFillMemUtilizationMeas(&(measCfmEvt.memoryInfo),&(measCb->memInfo)); - cmClearMemUtilizationCounter(&(measCb->memInfo)); - if(FALSE == (pjChkTmr(tPjCb, (PTR)tPjCb, PJ_EVT_L2_MEAS_TMR))) - { - /* starting measurement timer */ - ret = pjStartTmr(tPjCb, (PTR)tPjCb, PJ_EVT_L2_MEAS_TMR); - if(ret == RFAILED) - { - RETVALUE(ret); - } - } - } - else - { - RLOG0(L_DEBUG,"Meas Send Req without configuring Memory meas"); - } - } - if(measCb->measType & LPJ_L2MEAS_UL_LOSS) - { - /* Fill the measCfmEvt structure */ - for(qciIdx = 1; qciIdx < LPJ_MAX_QCI; qciIdx++) - { - U8 qci = measCb->qci[qciIdx]; - if(qci > 0) - { - if(measCb->measType & LPJ_L2MEAS_UL_LOSS) - { - U64 totPkts, lostPkts; - - lostPkts = (U64)(measCb->measData[qci].ulLoss.val); - totPkts = (U64)(measCb->measData[qci].ulLoss.numPkts); - - measCfmEvt.measCfm[measCfmEvt.numQciCfm].qci = qci; - measCfmEvt.measCfm[measCfmEvt.numQciCfm].ulLoss = 0; - if (totPkts > 0) - { - /* ul Loss = num of Pkts lost * 10^6 / total no of pkts. */ - measCfmEvt.measCfm[measCfmEvt.numQciCfm].ulLoss = (((U64)(lostPkts * ((U64)1000000))) / totPkts); - - measCb->measData[qci].ulLoss.val = 0; - measCb->measData[qci].ulLoss.numPkts = 0; - } - } - if (measCb->measData[qci].totDrbsPerQci == 0) - { - measCb->qci[qciIdx] = 0; - } - measCfmEvt.numQciCfm++; - } - } - } - if((measCb->measType & LPJ_L2CPU_PERCORE_STATS) &&(tPjCb->u.ulCb->pjL2Cb.cpuUtilizationMask & LPJ_L2CPU_PERCORE_STATS)) - { - CmCpuStatsInfo *cpuInfo = &measCb->cpuInfo; - for(coreIdx = 0; (coreIdx < cpuInfo->numCores) && (coreIdx < CM_MAX_CPU_CORES); coreIdx++) - { - measCfmEvt.cmLteCpuInfo[coreIdx].avgCpuUtil = cpuInfo->cpuUtil[coreIdx].totCpuUtil / cpuInfo->cpuUtil[coreIdx].numSamples ; - measCfmEvt.cmLteCpuInfo[coreIdx].maxCpuUtil = cpuInfo->cpuUtil[coreIdx].maxCpuUtil ; - cpuInfo->cpuUtil[coreIdx].totCpuUtil = 0; - cpuInfo->cpuUtil[coreIdx].maxCpuUtil = 0; - cpuInfo->cpuUtil[coreIdx].numSamples = 0; - } - measCfmEvt.numCores = cpuInfo->numCores; - cpuInfo->numCores = 0; - if(FALSE == (pjChkTmr(tPjCb, (PTR)tPjCb, PJ_EVT_L2_MEAS_TMR))) - { - /* starting measurement timer */ - ret = pjStartTmr(tPjCb, (PTR)tPjCb, PJ_EVT_L2_MEAS_TMR); - if(ret == RFAILED) - { - RETVALUE(ret); - } - } - } - /* Send Measurement confirmation to layer manager */ - pjUtlSndUlL2MeasNCfm(tPjCb, &measCfmEvt); - - RETVALUE(ROK); -} /* PjUtlPrepNSndL2MeasSendCfm */ - -/** -@brief -This function processes L2 Measurement Send request received from the layer manager. -After receving this request, RLC sends L2 Measurement - * @param[in] pst post structure - * @param[in] measType meas Type - * @return S16 - * -# Success : ROK - * -# Failure : RFAILED -*/ - -#ifdef ANSI -PUBLIC S16 PjMiLpjL2MeasSendReq -( -Pst *pst, -U16 measType -) -#else -PUBLIC S16 PjMiLpjL2MeasSendReq (pst, measType) -Pst *pst; -U16 measType; -#endif -{ - TRC3(PjMiLpjL2MeasSendReq); - - if((measType & LPJ_L2MEAS_UL_LOSS) || - (measType & LPJ_L2MEM_PERPOOL_STATS) || - (measType & LPJ_L2CPU_PERCORE_STATS)) - { - U8 cntr; - PjCb *tPjCb = PJ_GET_PJCB(pst->dstInst); - PjL2MeasEvtCb *measEvtCb = NULLP; - - if((measType & LPJ_L2MEM_PERPOOL_STATS) && - (tPjCb->u.ulCb->pjL2Cb.memUtilizationMask & LPJ_L2MEM_PERPOOL_STATS)) - { - if(TRUE == (pjChkTmr(tPjCb, (PTR)tPjCb, PJ_EVT_L2_MEAS_TMR))) - { - /* stopping timer */ - pjStopTmr(tPjCb, (PTR)tPjCb, PJ_EVT_L2_MEAS_TMR); - } - } - if((measType & LPJ_L2CPU_PERCORE_STATS) && - (tPjCb->u.ulCb->pjL2Cb.cpuUtilizationMask & LPJ_L2CPU_PERCORE_STATS)) - { - if(TRUE == (pjChkTmr(tPjCb, (PTR)tPjCb, PJ_EVT_L2_MEAS_TMR))) - { - /* stopping timer */ - pjStopTmr(tPjCb, (PTR)tPjCb, PJ_EVT_L2_MEAS_TMR); - } - - } - for(cntr = 0; cntr < PJ_MAX_L2MEAS_EVT; cntr++) - { - measEvtCb = &tPjCb->u.ulCb->pjL2Cb.pjL2EvtCb[cntr]; - if(measEvtCb->measCb.measType & measType) - { - PjUtlPrepNSndL2MeasSendCfm(tPjCb, measEvtCb); - } - } - } - RETVALUE(ROK); -} -#ifdef ANSI -PUBLIC Void UpdateMemInfo -( -PjL2Cb *tPjL2Cb -) -#else -PUBLIC Void UpdateMemInfo(tPjL2Cb) -PjL2Cb *tPjL2Cb; -#endif -{ - U8 cntr; - PjL2MeasEvtCb *measEvtCb = NULLP; - for(cntr = 0; cntr < PJ_MAX_L2MEAS_EVT; cntr++) - { - measEvtCb = &tPjL2Cb->pjL2EvtCb[cntr]; - if(measEvtCb->measCb.measType & LPJ_L2MEM_PERPOOL_STATS) - { - /* Update Memory Info for SSI Memory */ - cmUpdateSsiMemInfo(&(measEvtCb->measCb.memInfo)); - -#ifdef SS_LOCKLESS_MEMORY -#ifndef LTE_PAL_ENB - UpdateSocMemInfo(CM_L2_MEM_UTIL_AREAIDX, &(measEvtCb->measCb.memInfo)); -#endif -#endif - break; - } - } -} - -#ifdef ANSI -PUBLIC S16 UpdateCpuInfo -( -PjL2Cb *tPjL2Cb -) -#else -PUBLIC S16 UpdateCpuInfo(tPjL2Cb) -PjL2Cb *tPjL2Cb; -#endif -{ - U8 cntr; - PjL2MeasEvtCb *measEvtCb = NULLP; -#ifndef LTE_PAL_ENB - for(cntr = 0; cntr < PJ_MAX_L2MEAS_EVT; cntr++) - { - measEvtCb = &tPjL2Cb->pjL2EvtCb[cntr]; - if(measEvtCb->measCb.measType & LPJ_L2CPU_PERCORE_STATS) - { - /* Update CpuUtilization Info */ - UpdateSocCpuInfo(&(measEvtCb->measCb.cpuInfo), CM_L2_CPU_UTIL); - break; - } - } -#endif - RETVALUE(ROK); -} - -#ifdef ANSI -PUBLIC S16 pjUtlMemCpuHdlTmrExp -( -PjCb *tPjCb, -PjL2Cb *tPjL2Cb -) -#else -PUBLIC S16 pjUtlMemCpuHdlTmrExp(tPjCb,tPjL2Cb) -PjCb *tPjCb; -PjL2Cb *tPjL2Cb; -#endif -{ - S16 ret = ROK; - if(tPjCb->u.ulCb->pjL2Cb.memUtilizationMask & LPJ_L2MEM_PERPOOL_STATS) - { - /* calling memory Info */ - UpdateMemInfo(tPjL2Cb); - } - if(tPjCb->u.ulCb->pjL2Cb.cpuUtilizationMask & LPJ_L2CPU_PERCORE_STATS) - { - UpdateCpuInfo(tPjL2Cb); - } - /*TODO: call cpu util */ - /* starting measurement timer */ - ret = pjStartTmr(tPjCb, (PTR)tPjCb, PJ_EVT_L2_MEAS_TMR); - if(ret == RFAILED) - { - RETVALUE(ret); - } - RETVALUE(ROK); -} - - -#endif /* LTE_L2_MEAS */ -/** - * @brief - This function configures the PDCP data sap - * - * @param[in] cfg PDCP LM Sap structure - * @return S16 - * -# Success : LCM_REASON_NOT_APPL - * -# Failure : LCM_REASON_INVALID_SAP - * LCM_REASON_INVALID_SAP - * LCM_REASON_RECONFIG_FAIL - */ -#ifdef ANSI -PRIVATE S16 pjLmmPjuSapCfg -( -PjCb *gCb, -PjSapCfg *cfg /* SAP control block */ -) -#else -PRIVATE S16 pjLmmPjuSapCfg(gCb, cfg) -PjCb *gCb; -PjSapCfg *cfg; /* SAP control block */ -#endif -{ - PjPjuSapCb *pjuSap; - - TRC2(pjLmmPjuSapCfg) - - /* Validate config parameters */ - if (cfg->sapId >= PJ_MAX_PJUSAPS ) - { - RETVALUE(LCM_REASON_INVALID_PAR_VAL); - } - - if (gCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL) - { - pjuSap = &(gCb->u.ulCb->pjuSap[cfg->sapId]); - } - else - { - pjuSap = &(gCb->u.dlCb->pjuSap[cfg->sapId]); - } - -#if (ERRCLASS & ERRCLS_INT_PAR) - /* Check for reconfiguration */ - if(pjuSap->state != PJ_SAP_NOT_CFG) - { - RLOG0(L_ERROR, "Invalid pjuSap State"); - RETVALUE(LCM_REASON_RECONFIG_FAIL); - } -#endif /* ERRCLASS & ERRCLS_INT_PAR */ - - /* Fill the parameters */ - pjuSap->pst.selector = cfg->selector; - pjuSap->pst.route = cfg->route; - pjuSap->pst.prior = cfg->priority; - /* pj002.201 With multicore support layer shall use the assigned region - and pool from SSI */ -#if defined(SS_MULTICORE_SUPPORT) && defined(SS_M_PROTO_REGION) - pjuSap->pst.region = gCb->init.region; - pjuSap->pst.pool = gCb->init.pool; -#else - pjuSap->pst.region = cfg->mem.region; - pjuSap->pst.pool = cfg->mem.pool; -#endif - pjuSap->pst.dstProcId = cfg->procId; - pjuSap->pst.dstEnt = cfg->ent; - pjuSap->pst.dstInst = cfg->inst; - pjuSap->pst.srcProcId = gCb->init.procId; - pjuSap->pst.srcEnt = gCb->init.ent; - pjuSap->pst.srcInst = gCb->init.inst; - pjuSap->pst.event = EVTNONE; - pjuSap->spId = cfg->sapId; - - /* make sap unbound initially */ - pjuSap->state = PJ_SAP_CFG; - - RETVALUE(LCM_REASON_NOT_APPL); -} /* pjLmmPjuSapCfg */ - -/** - * @brief - This function configures the PDCP / RLC data sap - * - * @param[in] cfg PDCP LM Sap structure - * @return S16 - * -# Success : LCM_REASON_NOT_APPL - * -# Failure : LCM_REASON_INVALID_SAP - * LCM_REASON_INVALID_SAP - * LCM_REASON_RECONFIG_FAIL - */ -#ifdef ANSI -PRIVATE S16 pjLmmKwuSapCfg -( -PjCb *gCb, -PjSapCfg *cfg /* SAP control block */ -) -#else -PRIVATE S16 pjLmmKwuSapCfg(gCb, cfg) -PjCb *gCb; -PjSapCfg *cfg; /* SAP control block */ -#endif -{ - PjKwuSapCb *kwuSap; - - TRC2(pjLmmKwuSapCfg) - - - /* Validate config parameters */ - if (cfg->sapId >= PJ_MAX_KWUSAPS ) - { - RETVALUE(LCM_REASON_INVALID_PAR_VAL); - } - - if (gCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL) - { - kwuSap = &(gCb->u.ulCb->kwuSap[cfg->sapId]); - } - else - { - kwuSap = &(gCb->u.dlCb->kwuSap[cfg->sapId]); - } - -#if (ERRCLASS & ERRCLS_INT_PAR) - /* Check for reconfiguration */ - if(kwuSap->state != PJ_SAP_NOT_CFG) - { - RLOG0(L_ERROR, "Invalid kwuSap State"); - RETVALUE(LCM_REASON_RECONFIG_FAIL); - } -#endif /* ERRCLASS & ERRCLS_INT_PAR */ - - /* Fill the parameters */ - kwuSap->pst.selector = cfg->selector; - kwuSap->pst.route = cfg->route; - kwuSap->pst.prior = cfg->priority; - /* pj002.201 With multicore support layer shall use the assigned region - and pool from SSI */ -#if defined(SS_MULTICORE_SUPPORT) && defined(SS_M_PROTO_REGION) - kwuSap->pst.region = gCb->init.region; - kwuSap->pst.pool = gCb->init.pool; -#else - kwuSap->pst.region = cfg->mem.region; - kwuSap->pst.pool = cfg->mem.pool; -#endif - kwuSap->pst.dstProcId = cfg->procId; - kwuSap->pst.dstEnt = cfg->ent; - kwuSap->pst.dstInst = cfg->inst; - kwuSap->pst.srcProcId = gCb->init.procId; - kwuSap->pst.srcEnt = gCb->init.ent; - kwuSap->pst.srcInst = gCb->init.inst; - kwuSap->pst.event = EVTNONE; - kwuSap->suId = cfg->sapId; - - /* make sap unbound initially */ - kwuSap->bndTmrInt = cfg->bndTmrIntvl; - cmInitTimers(&kwuSap->bndTmr,PJ_MAX_KWUSAP_TMR); - kwuSap->state = PJ_SAP_CFG; - - RETVALUE(LCM_REASON_NOT_APPL); -} /* pjLmmKwuSapCfg */ - -/** - * @brief - This function configures the PDCP / RLC data sap - * - * @param[in] cfg PDCP LM Sap structure - * @return S16 - * -# Success : LCM_REASON_NOT_APPL - * -# Failure : LCM_REASON_INVALID_SAP - * LCM_REASON_INVALID_SAP - * LCM_REASON_RECONFIG_FAIL - */ -#ifdef ANSI -PRIVATE S16 pjLmmUdxSapCfg -( -PjCb *gCb, -PjSapCfg *cfg /* SAP control block */ -) -#else -PRIVATE S16 pjLmmUdxSapCfg(gCb, cfg) -PjCb *gCb; -PjSapCfg *cfg; /* SAP control block */ -#endif -{ - - TRC2(pjLmmUdxSapCfg) - - - /* Validate config parameters */ - if (cfg->sapId >= PJ_MAX_UDXSAPS ) - { - RETVALUE(LCM_REASON_INVALID_PAR_VAL); - } - - if (gCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL) - { - PjUdxUlSapCb *udxSap; - udxSap = (gCb->u.ulCb->udxUlSap + cfg->sapId); -#if (ERRCLASS & ERRCLS_INT_PAR) - /* Check for reconfiguration */ - if(udxSap->state != PJ_SAP_NOT_CFG) - { - RLOG0(L_ERROR, "Invalid udxSap State"); - RETVALUE(LCM_REASON_RECONFIG_FAIL); - } -#endif /* ERRCLASS & ERRCLS_INT_PAR */ - - /* Fill the parameters */ - udxSap->pst.selector = cfg->selector; - udxSap->pst.route = cfg->route; - udxSap->pst.prior = cfg->priority; - /* pj002.201 With multicore support layer shall use the assigned region - and pool from SSI */ -#if defined(SS_MULTICORE_SUPPORT) && defined(SS_M_PROTO_REGION) - udxSap->pst.region = gCb->init.region; - udxSap->pst.pool = gCb->init.pool; -#else - udxSap->pst.region = cfg->mem.region; - udxSap->pst.pool = cfg->mem.pool; -#endif - udxSap->pst.dstProcId = cfg->procId; - udxSap->pst.dstEnt = cfg->ent; - udxSap->pst.dstInst = cfg->inst; - udxSap->pst.srcProcId = gCb->init.procId; - udxSap->pst.srcEnt = gCb->init.ent; - udxSap->pst.srcInst = gCb->init.inst; - udxSap->pst.event = EVTNONE; - udxSap->suId = cfg->sapId; - - /* make sap unbound initially */ - udxSap->bndTmrInt = cfg->bndTmrIntvl; - cmInitTimers(&udxSap->bndTmr,PJ_MAX_UDXSAP_TMR); - udxSap->state = PJ_SAP_CFG; - - } - else - { - PjUdxDlSapCb *udxSap; - udxSap = (gCb->u.dlCb->udxDlSap + cfg->sapId); -#if (ERRCLASS & ERRCLS_INT_PAR) - /* Check for reconfiguration */ - if(udxSap->state != PJ_SAP_NOT_CFG) - { - RLOG0(L_ERROR, "Invalid udxSap State"); - RETVALUE(LCM_REASON_RECONFIG_FAIL); - } -#endif /* ERRCLASS & ERRCLS_INT_PAR */ - - /* Fill the parameters */ - udxSap->pst.selector = cfg->selector; - udxSap->pst.route = cfg->route; - udxSap->pst.prior = cfg->priority; - /* pj002.201 With multicore support layer shall use the assigned region - and pool from SSI */ -#if defined(SS_MULTICORE_SUPPORT) && defined(SS_M_PROTO_REGION) - udxSap->pst.region = gCb->init.region; - udxSap->pst.pool = gCb->init.pool; -#else - udxSap->pst.region = cfg->mem.region; - udxSap->pst.pool = cfg->mem.pool; -#endif - udxSap->pst.dstProcId = cfg->procId; - udxSap->pst.dstEnt = cfg->ent; - udxSap->pst.dstInst = cfg->inst; - udxSap->pst.srcProcId = gCb->init.procId; - udxSap->pst.srcEnt = gCb->init.ent; - udxSap->pst.srcInst = gCb->init.inst; - udxSap->pst.event = EVTNONE; - udxSap->suId = cfg->sapId; - udxSap->state = PJ_SAP_CFG; - } - - RETVALUE(LCM_REASON_NOT_APPL); -} /* pjLmmUdxSapCfg */ - - - -/** - * @brief - This function configures the PDCP control sap - * - * @param[in] cfg PDCP LM Sap structure - * @return S16 - * -# Success : LCM_REASON_NOT_APPL - * -# Failure : LCM_REASON_INVALID_SAP - * LCM_REASON_INVALID_SAP - * LCM_REASON_RECONFIG_FAIL - */ -#ifdef ANSI -PRIVATE S16 pjLmmCpjSapCfg -( -PjCb *gCb, -PjSapCfg *cfg /* SAP control block */ -) -#else -PRIVATE S16 pjLmmCpjSapCfg(gCb,cfg) -PjCb *gCb; -PjSapCfg *cfg; /* SAP control block */ -#endif -{ - PjCpjSapCb *cpjSap; - - TRC2(pjLmmCpjSapCfg) - - /* Validate config parameters */ - if (cfg->sapId >= PJ_MAX_CPJSAPS ) - { - RETVALUE(LCM_REASON_INVALID_PAR_VAL); - } - - if (gCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL) - { - cpjSap = &(gCb->u.ulCb->cpjSap); - } - else - { - RETVALUE(LCM_REASON_INVALID_PAR_VAL); - } - -#if (ERRCLASS & ERRCLS_INT_PAR) - /* Check for reconfiguration */ - if(cpjSap->state != PJ_SAP_NOT_CFG) - { - RLOG0(L_ERROR, "Invalid cpjSap State"); - RETVALUE(LCM_REASON_RECONFIG_FAIL); - } -#endif /* ERRCLASS & ERRCLS_INT_PAR */ - - /* Fill the parameters */ - cpjSap->pst.selector = cfg->selector; - cpjSap->pst.route = cfg->route; - cpjSap->pst.prior = cfg->priority; - /* pj002.201 With multicore support layer shall use the assigned region - and pool from SSI */ -#if defined(SS_MULTICORE_SUPPORT) && defined(SS_M_PROTO_REGION) - cpjSap->pst.region = gCb->init.region; - cpjSap->pst.pool = gCb->init.pool; -#else - cpjSap->pst.region = cfg->mem.region; - cpjSap->pst.pool = cfg->mem.pool; -#endif - cpjSap->pst.dstProcId = cfg->procId; - cpjSap->pst.dstEnt = cfg->ent; - cpjSap->pst.dstInst = cfg->inst; - cpjSap->pst.srcProcId = gCb->init.procId; - cpjSap->pst.srcEnt = gCb->init.ent; - cpjSap->pst.srcInst = gCb->init.inst; - cpjSap->pst.event = EVTNONE; - cpjSap->spId = cfg->sapId; - - /* make sap unbound initially */ - cpjSap->state = PJ_SAP_CFG; - - RETVALUE(LCM_REASON_NOT_APPL); -} /* pjLmmCpjSapCfg */ - -/** - * @brief - Validates the PDCP general control parameters - * - * @param[in] cntrl PDCP LM structure - * @return S16 - * -# Success : LCM_REASON_NOT_APPL - * -# Failure : LCM_REASON_INVALID_SUBACTION - * LCM_REASON_INVALID_ACTION - */ -#ifdef ANSI -PRIVATE S16 pjLmmValidateGenCntrl -( -PjMngmt *cntrl /* PDCP LM structure */ -) -#else -PRIVATE S16 pjLmmValidateGenCntrl(cntrl) -PjMngmt *cntrl; /* PDCP LM structure */ -#endif -{ - S16 reason; /* reason for failure */ - U8 action; /* action parameter */ - U8 sAction; /* subaction field */ - - - reason = LCM_REASON_NOT_APPL; - - TRC2(pjLmmValidateGenCntrl); - - action = cntrl->t.cntrl.action; - sAction = cntrl->t.cntrl.subAction; - - switch (action) - { - case AENA: - case ADISIMM: - if ((sAction != SAUSTA) - && (sAction != SADBG) - && (sAction != SATRC)) - { - reason = LCM_REASON_INVALID_SUBACTION; - } - break; - case ASHUTDOWN: - break; - default: - reason = LCM_REASON_INVALID_ACTION; - break; - } - - RETVALUE(reason); -} /* pjLmmValidateGenCntrl */ - -/** - * @brief - Delete all SAPs and Control Blocks - * - * @b Description - * Shutdown of PDCP happens at modules level, tm, um and am modules will - * be shutdown using utility functin and dbm shutdown will clean up the - * SAPs, control blocks and lists. - * - * @return S16 - * -# Success : LCM_REASON_NOT_APPL - * -# Failure : LCM_REASON_HASHING_FAILED - */ -#ifdef ANSI -PRIVATE S16 pjLmmShutdown -( -PjCb *gCb -) -#else -PRIVATE S16 pjLmmShutdown(gCb) -PjCb *gCb; -#endif -{ - TRC2(pjLmmShutdown) - S16 ret; - /* Call PDCP DBM Cleanup function. - * RLC LM shutdown takes care of cleanup of Gloabal and RLC resources */ - if (gCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL) - { - ret = pjUtlUlShutdown(gCb); - -#ifdef TENB_AS_SECURITY -#ifdef INTEL_QAT_DP -#ifdef QAT_TWO_INSTANCE - PjLibObdUlCloseReq(gCb->u.ulCb->instHndl); -#else - /* There is only one instance so its already freed as part of UL shutdown */ -#endif -#else - PjLibObdUlCloseReq(); -#endif -#endif - } - else - { - ret = pjUtlDlShutdown(gCb); - -#ifdef TENB_AS_SECURITY -#ifdef INTEL_QAT_DP -#ifdef QAT_TWO_INSTANCE - PjLibObdDlCloseReq(gCb->u.dlCb->instHndl); -#else - /* There is only one instance so its already freed as part of UL shutdown */ -#endif -#else - PjLibObdDlCloseReq(); -#endif -#endif - } - pjLmmCleanGblRsrcs(gCb); - - if(ret != ROK) - { - RETVALUE(ret); - } - else - { - RETVALUE(LCM_REASON_NOT_APPL); - } -} /* end of pjLmmShutdown */ - -/** - * @brief - Function processes the general control request - * - * @param[in] cntrl PDCP LM structure - * @return S16 - * -# Success : LCM_REASON_NOT_APPL - * -# Failure : LCM_REASON_INVALID_SUBACTION - * LCM_REASON_INVALID_ACTION - */ -#ifdef ANSI -PRIVATE S16 pjLmmGenCntrl -( -PjCb *gCb, -PjMngmt *cntrl /* PDCP LM structure */ -) -#else -PRIVATE S16 pjLmmGenCntrl(gCb,cntrl) -PjCb *gCb; -PjMngmt *cntrl; /* PDCP LM structure */ -#endif -{ - U8 action; /* action parameter */ - U8 sAction; /* subaction field */ - PjTrcCntrl *trcCntrl; /* trace */ - -#ifdef DEBUGP - PjDbgCntrl *dbgCntrl; /* debug */ -#endif /* DEBUGP */ - - S16 reason; /* reason for failure */ - - TRC2(pjLmmGenCntrl); - - reason = LCM_REASON_NOT_APPL; - - /* Validate control parameters */ - reason = pjLmmValidateGenCntrl (cntrl); - - action = cntrl->t.cntrl.action; - sAction = cntrl->t.cntrl.subAction; - - if (reason != LCM_REASON_NOT_APPL) - { - RETVALUE(reason); - } - - switch(action) - { - case AENA: - { - switch(sAction) - { - case SAUSTA: - { - PJ_SET_USTA_FLAG(gCb, TRUE); - break; - } - case SADBG: - { -#ifdef DEBUGP - dbgCntrl = &cntrl->t.cntrl.s.dbgCntrl; - PJ_GET_DBG_MASK(gCb) |= dbgCntrl->dbgMask; -#endif /* DEBUGP */ - break; - } - case SATRC: - { - trcCntrl = &cntrl->t.cntrl.s.trcCntrl; - gCb->init.trc = TRUE; - gCb->trcLen = trcCntrl->trcLen; - (gCb->trcMask) |= trcCntrl->trcMask; - break; - } - } - break; - } - case ADISIMM: - { - switch(sAction) - { - case SAUSTA: - { - gCb->init.usta = FALSE; - } - break; - case SADBG: - { -#ifdef DEBUGP - dbgCntrl = &cntrl->t.cntrl.s.dbgCntrl; - PJ_GET_DBG_MASK(gCb) &= ~(dbgCntrl->dbgMask); -#endif /* DEBUGP */ - } - break; - case SATRC: - { - trcCntrl = &cntrl->t.cntrl.s.trcCntrl; - gCb->init.trc = FALSE; - gCb->trcMask &= ~(trcCntrl->trcMask); - } - break; - } - break; - } - case ASHUTDOWN: - { - reason = pjLmmShutdown(gCb); - break; - } - } - RETVALUE(reason); -} /* pjLmmGenCntrl */ - -/** - * @brief - Bind/Unbind RLC upper sap - * - * @param[in] cntrl RLC LM structure - * @return S16 - * -# Success : LCM_REASON_NOT_APPL - * -# Failure : LCM_REASON_INVALID_SAP - * LCM_REASON_INVALID_STATE - * LCM_REASON_INVALID_ACTION - */ -#ifdef ANSI -PRIVATE S16 pjLmmUdxSapCntrl -( -PjCb *gCb, -PjMngmt *cntrl /* RLC LM structure */ -) -#else -PRIVATE S16 pjLmmUdxSapCntrl(gCb,cntrl) -PjCb *gCb; -PjMngmt *cntrl; /* RLC LM structure */ -#endif -{ - U8 action; /* action parameter */ - S16 reason; /* reason for failure */ - PjUdxUlSapCb *udxSap; /* udx sap pointer */ - - TRC2(kwLmmUdxSapCntrl) - - - reason = LCM_REASON_NOT_APPL; - action = cntrl->t.cntrl.action; - - /* validate SuId */ - if((cntrl->t.cntrl.s.sapCntrl.suId < 0) - || (cntrl->t.cntrl.s.sapCntrl.suId >= PJ_MAX_KWUSAPS)) - { - reason = LCM_REASON_INVALID_SAP; - RETVALUE(reason); - } - - - if (gCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL) - { - /*udxSap = &(gCb->u.ulCb->udxUlSap[cntrl->t.cntrl.s.sapCntrl.suId]);*/ - udxSap = (gCb->u.ulCb->udxUlSap + cntrl->t.cntrl.s.sapCntrl.suId); - } - else - { - reason = LCM_REASON_INVALID_SAP; - RETVALUE(reason); - } - - -#if (ERRCLASS & ERRCLS_INT_PAR) - /* validate SAP */ - if(udxSap->state == PJ_SAP_NOT_CFG) - { - RLOG0(L_ERROR, "Invalid udxSap State"); - reason = LCM_REASON_INVALID_STATE; - RETVALUE(reason); - } -#endif /* ERRCLASS & ERRCLS_INT_PAR */ - - switch(action) - { - case ABND: - { - if(udxSap->state != PJ_SAP_BND) - { - S16 ret; - /* start timer to wait for bind confirm */ - ret = pjStartTmr(gCb, (PTR)udxSap, PJ_EVT_WAIT_UDX_BNDCFM); - if(ret == RFAILED) - { - reason = LCM_REASON_REGTMR_FAIL; - } - else - { - udxSap->state = PJ_SAP_BINDING; - /* udxSap->spId = cntrl->t.cntrl.s.sapCntrl.spId; */ - PjUlUdxBndReq(&(udxSap->pst), udxSap->suId, udxSap->spId); - } - } - else - { - /* control request received for an already bound SAP */ - reason = LCM_REASON_INVALID_STATE; - } - } - break; - case AUBND: - { - /* make the state of RGUSAP is configure but not bound */ - udxSap->state = PJ_SAP_CFG; - PjUlUdxUbndReq(&(udxSap->pst), udxSap->spId, 0); - } - break; - default: - reason = LCM_REASON_INVALID_ACTION; - break; - } /* end of switch */ - - RETVALUE(reason); -} /* pjLmmUdxSapCntrl */ - - -/** - * @brief - Bind/Unbind RLC upper sap - * - * @param[in] cntrl RLC LM structure - * @return S16 - * -# Success : LCM_REASON_NOT_APPL - * -# Failure : LCM_REASON_INVALID_SAP - * LCM_REASON_INVALID_STATE - * LCM_REASON_INVALID_ACTION - */ -#ifdef ANSI -PRIVATE S16 pjLmmLSapCntrl -( -PjCb *gCb, -PjMngmt *cntrl /* RLC LM structure */ -) -#else -PRIVATE S16 pjLmmLSapCntrl(gCb,cntrl) -PjCb *gCb; -PjMngmt *cntrl; /* RLC LM structure */ -#endif -{ - U8 action; /* action parameter */ - S16 reason; /* reason for failure */ - PjKwuSapCb *kwuSap; /* rgu sap pointer */ - - TRC2(kwLmmLSapCntrl) - - reason = LCM_REASON_NOT_APPL; - action = cntrl->t.cntrl.action; - - /* validate SuId */ - if((cntrl->t.cntrl.s.sapCntrl.suId < 0) - || (cntrl->t.cntrl.s.sapCntrl.suId >= PJ_MAX_KWUSAPS)) - { - reason = LCM_REASON_INVALID_SAP; - RETVALUE(reason); - } - - if (gCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL) - { - kwuSap = &(gCb->u.ulCb->kwuSap[cntrl->t.cntrl.s.sapCntrl.suId]); - } - else - { - kwuSap = &(gCb->u.dlCb->kwuSap[cntrl->t.cntrl.s.sapCntrl.suId]); - } - - -#if (ERRCLASS & ERRCLS_INT_PAR) - /* validate SAP */ - if(kwuSap->state == PJ_SAP_NOT_CFG) - { - RLOG0(L_ERROR, "Invalid kwuSap State"); - reason = LCM_REASON_INVALID_STATE; - RETVALUE(reason); - } -#endif /* ERRCLASS & ERRCLS_INT_PAR */ - - switch(action) - { - case ABND: - { - if(kwuSap->state != PJ_SAP_BND) - { - S16 ret; - /* start timer to wait for bind confirm */ - ret = pjStartTmr(gCb, (PTR)kwuSap, PJ_EVT_WAIT_KWU_BNDCFM); - if(ret == RFAILED) - { - reason = LCM_REASON_REGTMR_FAIL; - } - else - { - kwuSap->state = PJ_SAP_BINDING; - kwuSap->spId = cntrl->t.cntrl.s.sapCntrl.spId; - PjLiKwuBndReq(&(kwuSap->pst), kwuSap->suId, kwuSap->spId); - } - } - else - { - /* control request received for an already bound SAP */ - reason = LCM_REASON_INVALID_STATE; - } - } - break; - case AUBND: - { - /* make the state of RGUSAP is configure but not bound */ - kwuSap->state = PJ_SAP_CFG; - PjLiKwuUbndReq(&(kwuSap->pst), kwuSap->spId, 0); - } - break; - default: - reason = LCM_REASON_INVALID_ACTION; - break; - } /* end of switch */ - - RETVALUE(reason); -} /* pjLmmLSapCntrl */ - - -/** - * @brief - forms Lm Cfm based on the return values - * - * @param[in] cntrl PDCP LM structure - * @return S16 - * -# Success : ROK - * -# Failure : RFAILED - */ -#ifdef ANSI -PRIVATE S16 pjLmmFormLmCfm -( -Pst *pst, -Header *hdr, -Reason reason -) -#else -PRIVATE S16 pjLmmFormLmCfm(pst, hdr, reason) -Pst *pst; -Header *hdr; -Reason reason; -#endif -{ - PjMngmt rCfm; - S16 ret; - TRC3(pjLmmFormLmCfm) - - ret = ROK; - - if (reason == LCM_REASON_NOT_APPL) - { - rCfm.cfm.status = LCM_PRIM_OK; - rCfm.cfm.reason = LCM_REASON_NOT_APPL; - - ret = ROK; - } - else - { - rCfm.cfm.status = LCM_PRIM_NOK; - rCfm.cfm.reason = reason; - - ret = RFAILED; - } - - pjLmmSendCfm(pst, &rCfm, TCNTRL, hdr); - - RETVALUE(ret); -} /* pjLmmFormLmCfm */ - -/** - * @brief - Function gather the general PJU SAP status - * - * @param[in] sta LM PJU Sap Status structure - * @return S16 - * -# Success : LCM_REASON_NOT_APPL - * -# Failure : LCM_REASON_INVALID_PAR_VAL - */ -#ifdef ANSI -PRIVATE S16 pjLmmGetPjuSapSta -( -PjCb *gCb, -PjPjuSapSta *sta /* PJU SAP status */ -) -#else -PRIVATE S16 pjLmmGetPjuSapSta(gCb,sta) -PjCb *gCb; -PjPjuSapSta *sta; /* PJU SAP status */ -#endif -{ - PjPjuSapCb *pjuSap; - TRC2(pjLmmGetPjuSapSta); - - /* Validate config parameters */ - if (sta->spId >= PJ_MAX_PJUSAPS ) - { - RETVALUE(LCM_REASON_INVALID_PAR_VAL); - } - - if (gCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL) - { - pjuSap = &(gCb->u.ulCb->pjuSap[sta->spId]); - } - else - { - pjuSap = &(gCb->u.dlCb->pjuSap[sta->spId]); - } - - - /* Get Sap control block */ - sta->state = pjuSap->state; - - RETVALUE(LCM_REASON_NOT_APPL); -} /* pjLmmGetPjuSapSta */ - -/** - * @brief - Function gather the general PJU SAP status - * - * @param[in] sta LM PJU Sap Status structure - * @return S16 - * -# Success : LCM_REASON_NOT_APPL - * -# Failure : LCM_REASON_INVALID_PAR_VAL - */ -#ifdef ANSI -PRIVATE S16 pjLmmGetKwuSapSta -( -PjCb *gCb, -PjKwuSapSta *sta /* PJU SAP status */ -) -#else -PRIVATE S16 pjLmmGetKwuSapSta(gCb,sta) -PjCb *gCb; -PjKwuSapSta *sta; /* PJU SAP status */ -#endif -{ - PjKwuSapCb *kwuSap; - TRC2(pjLmmGetKwuSapSta); - - /* Validate config parameters */ - if (sta->spId >= PJ_MAX_PJUSAPS ) - { - RETVALUE(LCM_REASON_INVALID_PAR_VAL); - } - - if (gCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL) - { - kwuSap = &(gCb->u.ulCb->kwuSap[sta->spId]); - } - else - { - kwuSap = &(gCb->u.dlCb->kwuSap[sta->spId]); - } - - /* Get Sap control block */ - sta->state = kwuSap->state; - - RETVALUE(LCM_REASON_NOT_APPL); -} /* pjLmmGetKwuSapSta */ - -/** - * @brief - Function gather the general PJU SAP status - * - * @param[in] sta LM PJU Sap Status structure - * @return S16 - * -# Success : LCM_REASON_NOT_APPL - * -# Failure : LCM_REASON_INVALID_PAR_VAL - */ -#ifdef ANSI -PRIVATE S16 pjLmmGetUdxSapSta -( -PjCb *gCb, -PjUdxSapSta *sta /* PJU SAP status */ -) -#else -PRIVATE S16 pjLmmGetUdxSapSta(gCb,sta) -PjCb *gCb; -PjUdxSapSta *sta; /* PJU SAP status */ -#endif -{ - PjUdxUlSapCb *udxUlSap; - PjUdxDlSapCb *udxDlSap; - TRC2(pjLmmGetUdxSapSta); - - /* Validate config parameters */ - if (sta->spId >= PJ_MAX_UDXSAPS ) /* KW_FIX */ - { - RETVALUE(LCM_REASON_INVALID_PAR_VAL); - } - - if (gCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL) - { - udxUlSap = &(gCb->u.ulCb->udxUlSap[sta->spId]); - /* Get Sap control block */ - sta->state = udxUlSap->state; - } - else - { - udxDlSap = &(gCb->u.dlCb->udxDlSap[sta->spId]); - /* Get Sap control block */ - sta->state = udxDlSap->state; - } - - - RETVALUE(LCM_REASON_NOT_APPL); -} /* pjLmmGetKwuSapSta */ - - -/** - * @brief - Function gather the general CPJ SAP status - * - * @param[in] sta LM CPJ Sap Status structure - * @return S16 - * -# Success : LCM_REASON_NOT_APPL - * -# Failure : LCM_REASON_INVALID_PAR_VAL - */ -#ifdef ANSI -PRIVATE S16 pjLmmGetCpjSapSta -( -PjCb *gCb, -PjCpjSapSta *sta /* RLU SAP status */ -) -#else -PRIVATE S16 pjLmmGetCpjSapSta(sta) -PjCb *gCb; -PjCpjSapSta *sta; /* RLU SAP status */ -#endif -{ - PjCpjSapCb *cpjSap; - TRC2(pjLmmGetCpjSapSta); - - if (gCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL) - { - cpjSap = &(gCb->u.ulCb->cpjSap); - } - else - { - RETVALUE(LCM_REASON_INVALID_SAP); - } - - - sta->state = cpjSap->state; - - RETVALUE(LCM_REASON_NOT_APPL); - -} /* pjLmmGetCpjSapSta */ - -/** - * @brief - Gather the general statistics - * - * @param[in] sts LM general statistics structure - * @param[in] action action - * @return S16 - * -# Success : LCM_REASON_NOT_APPL - * -# Failure : LCM_REASON_INVALID_PAR_VAL - */ -#ifdef ANSI -PRIVATE S16 pjLmmGetGenSts -( -PjCb *gCb, -PjGenSts *sts, /* general statistics structure */ -Action action /* Action */ -) -#else -PRIVATE S16 pjLmmGetGenSts(gCb, sts, action) -PjCb *gCb; -PjGenSts *sts; /* general statistics structure */ -Action action; /* Action */ -#endif -{ - PjGenSts *genSts; /* General statistics */ - - TRC2(pjLmmGetGenSts); - - /* Validate protocol parameters */ - if ((action != LPJ_ZEROSTS) && (action != LPJ_NOZEROSTS)) - { - RETVALUE(LCM_REASON_INVALID_PAR_VAL); - } - - PJ_MEM_CPY (sts, &(gCb->pjGenSts), sizeof (PjGenSts)); - - if(action == LPJ_ZEROSTS) - { - genSts = &(gCb->pjGenSts); - PJ_MEM_SET (genSts, 0, sizeof (PjGenSts)); - } - - RETVALUE(LCM_REASON_NOT_APPL); -} /* pjLmmGetGenSts */ - -/** - * @brief - Gather the SAP statistics - * - * @param[in] sts LM general statistics structure - * @param[in] elmnt element - * @param[in] action action - * @return S16 - * -# Success : LCM_REASON_NOT_APPL - * -# Failure : LCM_REASON_INVALID_PAR_VAL - */ -#ifdef ANSI -PRIVATE S16 pjLmmGetSapSts -( -PjCb *gCb, -PjMngmt *sts, /* PDCP layer management */ -Elmnt elmnt, /* element */ -Action action /* Action */ -) -#else -PRIVATE S16 pjLmmGetSapSts(gCb, sts, elmnt, action) -PjCb *gCb; -PjMngmt *sts; /* PDCP layer management */ -Elmnt elmnt; /* element */ -Action action; /* Action */ -#endif -{ - PjPjuSapCb *pjuSapCb; /* PDCP User SAP control block */ - PjPjuSts *pjuSap; /* place holder for SAP statistics */ - - TRC2(pjLmmGetSapSts); - - /* Validate protocol parameters */ - if (action != LPJ_ZEROSTS && action != LPJ_NOZEROSTS) - { - RETVALUE(LCM_REASON_INVALID_PAR_VAL); - } - - pjuSap = &sts->t.sts.s.pjuSap; - - /* Get Sap control block */ - /* pj005.201, modified suId to spId */ - - pjuSapCb = (gCb->pjGenCfg.mode == LPJ_MODE_PDCP_DL)? - (PjPjuSapCb*)(gCb->u.dlCb->pjuSap + pjuSap->spId): - (PjPjuSapCb*)(gCb->u.ulCb->pjuSap + pjuSap->spId); - - - pjuSap->rxSdus = pjuSapCb->sts.rxSdus; - pjuSap->txSdus = pjuSapCb->sts.txSdus; - - if (action == LPJ_ZEROSTS) - { - PJ_MEM_SET (&pjuSapCb->sts, 0, sizeof (PjPjuSts)); - } - - SGetDateTime(&sts->t.sts.dt); - - RETVALUE(LCM_REASON_NOT_APPL); -} /* pjLmmGetSapSts */ - - -/** - * @brief - This function sends Unsolicited Status Indication to the Layer Management - Entity. - * - * @param[in] category Category - * @param[in] event event - * @param[in] cause cause - * @param[in] cause ueId - * @return Void - */ -/* pj005.201 added support for L2 Measurement */ -#ifdef LTE_L2_MEAS -#ifdef ANSI -PUBLIC Void pjLmmSendAlarm -( -PjCb *gCb, -U16 category, /* Category */ -U16 event, /* Alarm event */ -U16 cause, /* Alarm cause */ -SuId suId, /* suId */ -U32 ueId, /* ueId */ -U8 qci /* qci */ -) -#else -PUBLIC Void pjLmmSendAlarm(gCb, category, event, cause, suId, ueId, qci) -PjCb *gCb; -U16 category; /* Category */ -U16 event; /* Alarm event */ -U16 cause; /* Alarm cause */ -SuId suId; /* suId */ -U32 ueId; /* ueId */ -U8 qci; /* qci */ -#endif -#else -#ifdef ANSI -PUBLIC Void pjLmmSendAlarm -( -PjCb *gCb, -U16 category, /* Category */ -U16 event, /* Alarm event */ -U16 cause, /* Alarm cause */ -SuId suId, /* suId */ -U32 ueId /* ueId */ -) -#else -PUBLIC Void pjLmmSendAlarm(gCb, category, event, cause, suId, ueId) -PjCb *gCb; -U16 category; /* Category */ -U16 event; /* Alarm event */ -U16 cause; /* Alarm cause */ -SuId suId; /* suId */ -U32 ueId; /* ueId */ -#endif -#endif -{ - - PjMngmt usta; /* Rlc Management Structure */ - - TRC2(pjLmmSendAlarm); - - if(gCb->init.usta == FALSE) - { - RETVOID; - } - - /* initialize the management structure */ - PJ_MEM_SET(&usta, 0, sizeof(PjMngmt)); - - usta.hdr.elmId.elmnt = STGEN; - usta.hdr.entId.ent = gCb->init.ent; - usta.hdr.entId.inst = gCb->init.inst; - - /* fill in the event and category */ - usta.t.usta.alarm.category = category; - usta.t.usta.alarm.event = event; - usta.t.usta.alarm.cause = cause; - - /* set the suId and ueId */ - usta.t.usta.ueId = ueId; - usta.t.usta.suId = suId; - /* pj005.201 added support for L2 Measurement */ -#ifdef LTE_L2_MEAS - if(event == LPJ_EVT_MEAS_HALT) - { - usta.t.usta.qci = qci; - } -#endif - - /* update the date and time */ - (Void) SGetDateTime(&usta.t.usta.alarm.dt); - - PjMiLpjStaInd(&(gCb->init.lmPst), &usta); - - RETVOID; - -} /* pjLmmSendAlarm */ - -/** - * @brief - This function sends trace indication to LM - * - * @param[in] event event - * @param[in] mBuf meessage buffer - * @return S16 - * -# Success : ROK - * -# Failure : RFAILED - */ -#ifdef ANSI -PUBLIC S16 pjLmmSendTrc -( -PjCb *gCb, -Event event, /* event */ -Buffer *mBuf /* message buffer */ -) -#else -PUBLIC S16 pjLmmSendTrc(gCb, event, mBuf) -PjCb *gCb; -Event event; /* event */ -Buffer *mBuf; /* message buffer */ -#endif -{ - /* patch pj004.201 Corrected pjLmmSendTrc function definition */ - PjMngmt trc; /* PDCP management control block */ - Buffer *dstMbuf; - MsgLen bufLen; - Data *tempBuf; - MsgLen tempCnt; - Pst pst; - - TRC2(pjLmmSendTrc); - - PJ_MEM_SET(&trc, 0, sizeof(PjMngmt)); - - cmMemset((U8 *)&trc, 0, sizeof(PjMngmt)); - - pst = gCb->init.lmPst; - - trc.t.trc.event = event; - SGetDateTime(&trc.t.trc.dt); - trc.cfm.status = LCM_PRIM_OK; - trc.cfm.reason = LCM_REASON_NOT_APPL; - - if(mBuf != NULLP) - { - /* Check if the whole buffer is to be sent in Trace indication */ - if(gCb->trcLen == LPJ_FULL_TRACE) - { - if (SCpyMsgMsg(mBuf, pst.region, pst.pool, &dstMbuf) - != ROK) - { - /* rg005.201 removed SPutSBuf on error */ - RLOG0(L_DEBUG,"SCpyMsgMsg Failed."); - RETVALUE(RFAILED); - } - /* Send Trace Indication to Layer manager */ - PjMiLpjTrcInd(&pst, &trc, dstMbuf); - } - /* check if only a specified number of bytes are to be sent */ - else if(gCb->trcLen > 0) - { - /* Get the length of the recvd message buffer */ - if (SFndLenMsg(mBuf, &bufLen) != ROK) - { - RLOG0(L_DEBUG, "SFndLenMsg Failed."); - RETVALUE(RFAILED); - } - /* Check if the recvd buffer size is less than request trace len */ - if(bufLen < gCb->trcLen) - { - /* Copy the whole of the recvd buffer in trace indication */ - - if (SCpyMsgMsg(mBuf, pst.region, pst.pool, &dstMbuf) - != ROK) - { - RLOG0(L_DEBUG, "pjLmmSendTrc(): SCpyMsgMsg Failed."); - RETVALUE(RFAILED); - } - - /* Send Trace Indication to Layer manager */ - PjMiLpjTrcInd(&pst, &trc, dstMbuf); - } - /* if the recvd buffer size is greater than request trace len */ - if(bufLen >= gCb->trcLen) - { - /* Get a temporary buffer to store the msg */ - PJ_ALLOC(gCb, tempBuf, gCb->trcLen); - -#if (ERRCLASS & ERRCLS_INT_PAR) - if(tempBuf == NULLP) - { - (Void) SPutSMem(PJ_GET_MEM_REGION(gCb), PJ_GET_MEM_POOL(gCb)); - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(LCM_REASON_MEM_NOAVAIL); - } -#endif /* ERRCLASS & ERRCLS_INT_PAR */ - - /* Copy trcLen nos of bytes from the recvd message */ - if (SCpyMsgFix(mBuf,0,gCb->trcLen,tempBuf,&tempCnt) != ROK) - { - RLOG0(L_DEBUG, "SCpyMsgFix Failed."); - RETVALUE(RFAILED); - } - - if (SGetMsg(pst.region, pst.pool, &dstMbuf) != ROK) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } - /* Copy the tempBuf data to dst mBuf */ - if (SCpyFixMsg(tempBuf,dstMbuf,0,gCb->trcLen,&tempCnt) != ROK) - { - RLOG0(L_DEBUG, "SCpyFixMsg Failed."); - RETVALUE(RFAILED); - } - - /* Free the memory allocated for tempBuf */ - PJ_FREE(gCb, tempBuf, gCb->trcLen); - /* Send Trace Indication to Layer manager */ - PjMiLpjTrcInd(&pst, &trc, dstMbuf); - } - } - } - else - { - PjMiLpjTrcInd(&pst, &trc, mBuf); - } - - RETVALUE(ROK); - -} /* end of pjLmmSendTrc */ - - -/* -* -* Fun: Activate Task - timer -* -* Desc: Invoked by system services to activate a task with -* a timer tick. -* -* Ret: ROK - ok -* -* Notes: None -* -* File: gp_lmm.c -* -*/ -#ifdef ANSI -PUBLIC S16 pjActvTmr -( -Ent ent, -Inst inst -) -#else -PUBLIC S16 pjActvTmr(ent,inst) -Ent ent; -Inst inst; -#endif -{ - PjCb *gCb; - TRC2(pjActvTmr) - - if (inst >= PJ_MAX_PDCP_INSTANCES) - { - RETVALUE (RFAILED); - } - gCb = PJ_GET_PJCB(inst); - cmPrcTmr(&(gCb->pjTqCp), gCb->pjTq, (PFV) pjTmrExpiry); - - RETVALUE(ROK); - -} /* end of pjActvTmr */ - -/** - * @brief - it deregisters the timers and deregisters the kwuSap Control blocks - * - * @return Void - */ -#ifdef ANSI -PRIVATE Void pjLmmCleanGblRsrcs -( -PjCb *gCb -) -#else -PRIVATE Void pjLmmCleanGblRsrcs(gCb) -PjCb *gCb; -#endif -{ - - TRC2(pjLmmCleanGblRsrcs) - - if (gCb->init.cfgDone) - { - /* Deregister the timers */ - (Void) SDeregTmrMt(gCb->init.ent, gCb->init.inst, - (S16)gCb->pjGenCfg.timeRes, pjActvTmr); - /*(Void) SDeregTmr(gCb->init.ent, gCb->init.inst, - (S16)gCb->genCfg.timeRes, kwActvTmr);*/ - - if (gCb->pjGenCfg.mode == LPJ_MODE_PDCP_DL) - { - if (gCb->u.dlCb) - { - if (gCb->u.dlCb->kwuSap != (PjKwuSapCb *)NULLP) - { - /*PJ_FREE(gCb,gCb->u.dlCb->kwuSap, kwSapSize); */ - } - - PJ_FREE(gCb,gCb->u.dlCb, sizeof (PjDlgCb)); - } - - } - else - { - if (gCb->u.ulCb) - { - if (gCb->u.ulCb->kwuSap != (PjKwuSapCb *)NULLP) - { - /*PJ_FREE(gCb,gCb->u.ulCb->kwuSap, kwSapSize);*/ - } - - PJ_FREE(gCb,gCb->u.ulCb, sizeof (PjUlgCb)); - } - } - - (Void) SPutSMem(gCb->init.region, gCb->init.pool); - gCb->init.cfgDone = FALSE; - gCb->init.acnt = FALSE; - gCb->init.trc = FALSE; - gCb->init.usta = FALSE; - } - - RETVOID; -} /* pjLmmCleanGblRsrcs */ - -/********************************************************************30** - - End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_ptli.c b/src/5gnrpdcp/pj_ptli.c deleted file mode 100755 index 9fb1ab56d..000000000 --- a/src/5gnrpdcp/pj_ptli.c +++ /dev/null @@ -1,627 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: RLC service user (PDCP) lower interface - - Type: C file - - Desc: This file Contains the RLC service user lower interface - primitive implementain - - File: pj_ptli.c - -*********************************************************************21*/ - -/* header (.h) include files */ -#include "envopt.h" /* environment options */ -#include "envdep.h" /* environment dependent */ -#include "envind.h" /* environment independent */ - -#include "gen.h" /* general */ -#include "ssi.h" /* system services */ -#include "cm5.h" /* common timer defines */ -#include "cm_tkns.h" /* common tokens defines */ -#include "cm_mblk.h" /* common memory allocation library defines */ -#include "cm_llist.h" /* common link list defines */ -#include "cm_hash.h" /* common hash list defines */ -#include "cm_lte.h" /* common LTE defines */ -#include "kwu.h" /* KWU defines */ -#include "pj_err.h" - -/* extern (.x) include files */ -#include "gen.x" /* general */ -#include "ssi.x" /* system services */ -//#if defined(PDCP_RLC_DL_RBUF) -#include "ss_rbuf.h" -#include "ss_rbuf.x" -#include "kwu.h" /* PJU */ -#include "ss_queue.h" -#include "ss_queue.x" -#include "ss_task.h" -#include "ss_task.x" -#include "ss_timer.x" /* System services */ -#include "ss_msg.h" /* System services */ -#include "ss_msg.x" /* System services */ -#include "ss_mem.h" /* System services */ -#include "ss_mem.x" /* System services */ -#include "ss_drvr.x" -#include "ss_gen.h" -#include "ss_gen.x" -//#endif - -#include "cm5.x" /* common timer library */ -#include "cm_tkns.x" /* common tokens */ -#include "cm_mblk.x" /* common memory allocation */ -#include "cm_llist.x" /* common link list */ -#include "cm_hash.x" /* common hash list */ -#include "cm_lte.x" /* common LTE includes */ -#include "cm_lib.x" /* common memory allocation library */ -#include "kwu.x" /* KWU */ - - -PUBLIC U8 SUpdMbufMemInfo (Pst *pst,Buffer *mBuf); -#if defined(PDCP_RLC_DL_RBUF) && !defined(SS_RBUF) -PUBLIC S16 pjKwuRbufDatReq(Pst * pst,SpId spId,KwuDatReqInfo* datReq,Buffer * mBuf); -#endif - -EXTERN S16 PtLiKwuBndReq ARGS (( -Pst *post, -SuId suId, -SpId spId -)); - -EXTERN S16 PtLiKwuUbndReq ARGS (( -Pst *post, -SpId spId, -Reason reason -)); - -EXTERN S16 PtLiKwuDiscSduReq ARGS (( -Pst *post, -SpId spId, -KwuDiscSduInfo *discSdu -)); - -EXTERN S16 PtLiKwuDatReq ARGS (( -Pst *post, -SpId spId, -KwuDatReqInfo *datReq, -Buffer *mBuf -)); - -/************************************************************************ - KWU Interface Matrices -************************************************************************/ - -PUBLIC KwuBndReq pjLiKwuBndReqMt [] = -{ -#ifdef LCKWUIKWU - cmPkKwuBndReq, /* 0 - loosely coupled */ -#else - PtLiKwuBndReq, /* 0 - loosely coupled, portable */ -#endif -#ifdef KW - KwUiKwuBndReq, /* 1 - tightly coupled, stub layer */ -#else - PtLiKwuBndReq, /* 1 - tightly coupled, portable */ -#endif -#ifdef LWLCKWUIKWU - cmPkKwuBndReq, /* 3 - light weight loosely coupled */ -#else - PtLiKwuBndReq, /* 3 - light weight loosely coupled, portable */ -#endif -}; - -PUBLIC KwuUbndReq pjLiKwuUbndReqMt [] = -{ -#ifdef LCKWUIKWU - cmPkKwuUbndReq, /* 0 - loosely coupled */ -#else - PtLiKwuUbndReq, /* 0 - loosely coupled, portable */ -#endif -#ifdef KW - KwUiKwuUbndReq, /* 1 - tightly coupled, stub layer */ -#else - PtLiKwuUbndReq, /* 1 - tightly coupled, portable */ -#endif -#ifdef LWLCKWUIKWU - cmPkKwuUbndReq, /* 3 - light weight loosely coupled */ -#else - PtLiKwuUbndReq, /* 3 - light weight loosely coupled, portable */ -#endif -}; - -PUBLIC KwuDatReq pjLiKwuDatReqMt [] = -{ -#ifdef LCKWUIKWU - cmPkKwuDatReq, /* 0 - loosely coupled */ -#else - PtLiKwuDatReq, /* 0 - loosely coupled, portable */ -#endif -#ifdef KW - KwUiKwuDatReq, /* 1 - tightly coupled, stub layer */ -#else - PtLiKwuDatReq, /* 1 - tightly coupled, portable */ -#endif -#ifdef LWLCKWUIKWU - cmPkKwuDatReq, /* 3 - light weight loosely coupled */ -#else - PtLiKwuDatReq, /* 3 - light weight loosely coupled, portable */ -#endif -}; - -PUBLIC KwuDiscSduReq pjLiKwuDiscSduReqMt [] = -{ -#ifdef LCKWUIKWU - cmPkKwuDiscSduReq, /* 0 - loosely coupled */ -#else - PtLiKwuDiscSduReq, /* 0 - loosely coupled, portable */ -#endif -#ifdef KW - KwUiKwuDiscSduReq, /* 1 - tightly coupled, stub layer */ -#else - PtLiKwuDiscSduReq, /* 1 - tightly coupled, portable */ -#endif -#ifdef LWLCKWUIKWU - cmPkKwuDiscSduReq, /* 3 - light weight loosely coupled */ -#else - PtLiKwuDiscSduReq, /* 3 - light weight loosely coupled, portable */ -#endif -}; - - -/**************************************************************************** - * KWU Interface Mt functions - ***************************************************************************/ -/** - * - * @brief - * - * PjLiKwuBndReq - KWU SAP bind Request - * - * @param[in] pst - Post structure - * @param[in] suId - Service user SAP ID - * @param[in] spId - Service provider ID - * - * @return S16 - * -# ROK - */ -#ifdef ANSI -PUBLIC S16 PjLiKwuBndReq -( -Pst *pst, /* post structure */ -SuId suId, /* Service User Id */ -SpId spId /* Service Provider Id */ -) -#else -PUBLIC S16 PjLiKwuBndReq(pst, suId, spId) -Pst *pst; /* post structure */ -SuId suId; /* Service User Id */ -SpId spId; /* Service Provider Id */ -#endif -{ - TRC3(PjLiKwuBndReq) - - /* jump to specific primitive depending on configured selector */ - (*pjLiKwuBndReqMt[pst->selector])(pst, suId, spId); - - RETVALUE(ROK); - -} /* end of PjLiKwuBndReq */ - - -/** - * - * @brief - * - * PjLiKwuUbndReq - KWU SAP unbind Request - * - * @param[in] pst - Post structure - * @param[in] spId - Service provider SAP ID - * @param[in] reason - Reason - * - * @return S16 - * -# ROK - */ -#ifdef ANSI -PUBLIC S16 PjLiKwuUbndReq -( -Pst *pst, -SpId spId, -Reason reason -) -#else -PUBLIC S16 PjLiKwuUbndReq(pst, spId, reason) -Pst *pst; -SpId spId; -Reason reason; -#endif -{ - TRC3(PjLiKwuUbndReq) - - /* jump to specific primitive depending on configured selector */ - (*pjLiKwuUbndReqMt[pst->selector])(pst, spId, reason); - - RETVALUE(ROK); - -} /* end of PjLiKwuUbndReq */ - - -/** - * - * @brief - * - * PjLiKwuDatReq - KWU Data Request - * - * @param[in] pst - Post structure - * @param[in] spId - Service provider SAP ID - * @param[in] datReq - Data Request - * - * @return S16 - * -# ROK - */ -#ifdef ANSI -PUBLIC S16 PjLiKwuDatReq -( -Pst *pst, -SpId spId, -KwuDatReqInfo *datReq, -Buffer *mBuf -) -#else -PUBLIC S16 PjLiKwuDatReq(pst, spId, datReq, mBuf) -Pst *pst; -SpId spId; -KwuDatReqInfo *datReq; -Buffer *mBuf; -#endif -{ - S16 ret = ROK; - - TRC3(PjLiKwuDatReq) -#if defined(PDCP_RLC_DL_RBUF) && !defined(SS_RBUF) - if(datReq->lcType == CM_LTE_LCH_DTCH) - { - if((pjKwuRbufDatReq(pst,spId, datReq, mBuf)) != ROK) - { - /* Posting the message as ring buffer write failure */ - ret = RFAILED; - } - } - else -#endif - { - /* jump to specific primitive depending on configured selector */ - ret = (*pjLiKwuDatReqMt[pst->selector])(pst, spId, datReq, mBuf); - } - RETVALUE(ret); - -} /* end of PjLiKwuDatReq */ - - -/** - * - * @brief - * - * PjLiKwuDiscSduReq - KWU Discard SDU Request - * - * @param[in] pst - Post structure - * @param[in] spId - Service provider SAP ID - * @param[in] datReq - Data Request - * - * @return S16 - * -# ROK - */ -#ifdef ANSI -PUBLIC S16 PjLiKwuDiscSduReq -( -Pst *pst, -SpId spId, -KwuDiscSduInfo *discSdu -) -#else -PUBLIC S16 PjLiKwuDiscSduReq(pst, spId, discSdu) -Pst *pst; -SpId spId; -KwuDiscSduInfo *discSdu; -#endif -{ - TRC3(PjLiKwuDiscSduReq) - - /* jump to specific primitive depending on configured selector */ - (*pjLiKwuDiscSduReqMt[pst->selector])(pst, spId, discSdu); - - RETVALUE(ROK); - -} /* end of PjLiKwuDiscSduReq */ - -/**************************************************************************** - * Porting Functions - ***************************************************************************/ -/** - * - * @brief - * - * PtLiKwuBndReq - portable bind request - * - * @param[in] pst - Post structure - * @param[in] suId - Service user SAP ID - * @param[in] spId - Service provider ID - * - * @return S16 - * -# ROK - */ - -#ifdef ANSI -PUBLIC S16 PtLiKwuBndReq -( -Pst *post, -SuId suId, -SpId spId -) -#else -PUBLIC S16 PtLiKwuBndReq(post, suId, spId) -Pst *post; -SuId suId; -SpId spId; -#endif /* ANSI */ -{ - TRC3(PtLiKwuBndReq) -#if (ERRCLASS & ERRCLS_DEBUG) - /* S16 ret1; */ - SLogError(post->srcEnt, post->srcInst, post->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG, - (ErrVal)EPJXXX, (ErrVal)ERRZERO, "Improper selector for NhLiKwuBndReq\n"); - RETVALUE( RFAILED ); -#endif /* (ERRCLASS & ERRCLS_DEBUG) */ - UNUSED(post); - UNUSED(suId); - UNUSED(spId); - - RETVALUE(ROK); -} /* end of PtLiKwuBndReq() */ - - -/** - * - * @brief - * - * PtLiKwuUbndReq - portable unbind request - * - * @param[in] pst - Post structure - * @param[in] suId - Service provider SAP ID - * @param[in] reason - Reason - * - * @return S16 - * -# ROK - */ -#ifdef ANSI -PUBLIC S16 PtLiKwuUbndReq -( -Pst *post, -SpId spId, -Reason reason -) -#else -PUBLIC S16 PtLiKwuUbndReq(post, spId, reason) -Pst *post; -SpId spId; -Reason reason; -#endif /* ANSI */ -{ - TRC3(PtLiKwuUbndReq) -#if (ERRCLASS & ERRCLS_DEBUG) - /* S16 ret1; */ - SLogError(post->srcEnt, post->srcInst, post->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG, - (ErrVal)EPJXXX, (ErrVal)ERRZERO, "Improper selector for NhLiKwuUbndReq\n"); - RETVALUE( RFAILED ); -#endif /* (ERRCLASS & ERRCLS_DEBUG) */ - UNUSED(post); - UNUSED(spId); - UNUSED(reason); - - RETVALUE(ROK); -} /* end of PtLiKwuUbndReq() */ - -/** - * - * @brief - * - * PtLiKwuDiscSduReq - portable discard SDU request - * - * @param[in] pst - Post structure - * @param[in] spId - Service provider SAP ID - * @param[in] datReq - Data Request - * - * @return S16 - * -# ROK - */ -#ifdef ANSI -PUBLIC S16 PtLiKwuDiscSduReq -( -Pst *post, -SpId spId, -KwuDiscSduInfo *discSdu -) -#else -PUBLIC S16 PtLiKwuDiscSduReq(post, spId, discSdu) -Pst *post; -SpId spId; -KwuDiscSduInfo *discSdu; -#endif /* ANSI */ -{ - TRC3(PtLiKwuDiscSduReq) -#if (ERRCLASS & ERRCLS_DEBUG) - /* S16 ret1; */ - SLogError(post->srcEnt, post->srcInst, post->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG, - (ErrVal)EKWU010, (ErrVal)ERRZERO, "Improper selector for NhLiKwuDiscSduReq\n"); - RETVALUE( RFAILED ); - -#endif /* (ERRCLASS & ERRCLS_DEBUG) */ - UNUSED(post); - UNUSED(spId); - UNUSED(discSdu); - - RETVALUE(ROK); -} /* end of PtLiKwuDiscSduReq() */ - -/** - * - * @brief - * - * PtLiKwuDatReq - portable data request - * - * @param[in] pst - Post structure - * @param[in] spId - Service provider SAP ID - * @param[in] datReq - Data Request - * - * @return S16 - * -# ROK - */ -#ifdef ANSI -PUBLIC S16 PtLiKwuDatReq -( -Pst *pst, -SpId spId, -KwuDatReqInfo *datReq, -Buffer *mBuf -) -#else -PUBLIC S16 PtLiKwuDatReq(pst, spId, datReq, mBuf) -Pst *pst; -SpId spId; -KwuDatReqInfo *datReq; -Buffer *mBuf; -#endif /* ANSI */ -{ - TRC3(PtLiKwuDatReq) -#if (ERRCLASS & ERRCLS_DEBUG) - /* S16 ret1; */ - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG, - (ErrVal)EPJXXX, (ErrVal)ERRZERO, "Improper selector for NhLiKwuDatReq\n"); - RETVALUE( RFAILED ); -#endif /* (ERRCLASS & ERRCLS_DEBUG) */ - UNUSED(pst); - UNUSED(spId); - UNUSED(datReq); - UNUSED(mBuf); - - RETVALUE(ROK); -} /* end of PtLiKwuDatReq() */ -/* -* -* Fun: SUpdMbufMemInfo -* -* Desc: This function is used to get the mem region info of a task. -* -* Ret: ROK - ok -* RFAILED - failed, general (optional) -* -* -* File: ss_task.c -* -*/ -#ifdef TENB_T2K3K_SPECIFIC_CHANGES -#ifdef ANSI -PUBLIC U8 SUpdMbufMemInfo -( -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC U8 SUpdMbufMemInfo(pst,mBuf) -Pst *pst; -Buffer *mBuf; -#endif -{ - SsMsgInfo *minfo; - SsTTskEntry *tTsk; - SsIdx dstIdx; - - - minfo = (SsMsgInfo*) mBuf->b_rptr; - - dstIdx = osCp.tTskIds[pst->dstEnt][pst->dstInst]; - tTsk = &osCp.tTskTbl[dstIdx]; -#ifdef SS_MULTICORE_SUPPORT - minfo->region = tTsk->sTsk->region; -#endif /* SS_MULTICORE_SUPPORT */ - RETVALUE(ROK); -} -#endif - -#if defined(PDCP_RLC_DL_RBUF) && !defined(SS_RBUF) -#ifdef ANSI -PUBLIC S16 pjKwuRbufDatReq -( -Pst * pst, -SpId spId, -KwuDatReqInfo* datReq, -Buffer * mBuf -) -#else -PUBLIC S16 pjKwuRbufDatReq(pst, spId, datReq, mBuf) -Pst * pst; -SpId spId; -KwuDatReqInfo* datReq; -Buffer * mBuf; -#endif -{ - S16 ret1 = ROK; - - Void *elem = NULLP; - KwuDatReqDetl *kwuDatReqDetl = NULLP; - - elem = SRngGetWIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC); - if (NULLP != elem) - { - kwuDatReqDetl = (KwuDatReqDetl *) elem; - kwuDatReqDetl->spId = spId; - kwuDatReqDetl->lcType = datReq->lcType; - kwuDatReqDetl->sduId = datReq->sduId; - kwuDatReqDetl->rlcId = datReq->rlcId; - kwuDatReqDetl->mBuf = mBuf; - /* Commenting below function because memory region mapped with threadId*/ - /* SUpdMbufMemInfo(pst, mBuf);*/ - SRngIncrWIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC); - SsRngInfoTbl[SS_RNG_BUF_DLPDCP_TO_DLRLC].pktRate++; - } - else - { -#if (ERRCLASS & ERRCLS_DEBUG) - SLogError(ENTPJ, 0, SFndProcId(), - __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG, - (ErrVal)EPJXXX, (ErrVal)ERRZERO, "PDCP-DL RBUF is FULL!!!\n"); -#endif /* (ERRCLASS & ERRCLS_DEBUG) */ - SsRngInfoTbl[SS_RNG_BUF_DLPDCP_TO_DLRLC].pktDrop++; - ret1 = RFAILED; - } - RETVALUE(ret1); -} /* cmPkKwuDatReq */ - -#endif /* PDCP_RLC_DL_RBUF */ - - -/********************************************************************30** - End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_ptlib.c b/src/5gnrpdcp/pj_ptlib.c deleted file mode 100755 index f75e23a0b..000000000 --- a/src/5gnrpdcp/pj_ptlib.c +++ /dev/null @@ -1,2343 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: RLC service user (PDCP) lower interface - - Type: C file - - Desc: This file Contains the RLC service user lower interface - primitive implementain - - File: pj_ptlib.c - -*********************************************************************21*/ - -/* header (.h) include files */ -#include "envopt.h" /* environment options */ -#include "envdep.h" /* environment dependent */ -#include "envind.h" /* environment independent */ - -#include "gen.h" /* general */ -#include "ssi.h" /* system services */ -#include "cm5.h" /* common timer defines */ -#include "cm_tkns.h" /* common tokens defines */ -#include "cm_mblk.h" /* common memory allocation library defines */ -#include "cm_llist.h" /* common link list defines */ -#include "cm_hash.h" /* common hash list defines */ -#include "cm_lte.h" /* common LTE defines */ -#include "kwu.h" /* KWU defines */ -#include "pju.h" /* PJU defines */ -/*#include "rgu.h"*/ /* RGU defines */ -#include "cpj.h" /* CPJ defines */ -#include "lpj.h" /* LPJ defines */ -#include "pju.h" /* PJU defines */ -#include "pj_env.h" /* RLC environment options */ -#include "pj.h" /* RLC defines */ -#include "pj_dl.h" -#include "pj_ptsec.h" -#ifdef INTEL_NATIVE_SPACC -#include "elpspaccusr.h" -#endif - -/* extern (.x) include files */ -#include "gen.x" /* general */ -#include "ssi.x" /* system services */ - -#if (defined(L2_L3_SPLIT) && defined(ICC_RECV_TSK_RBUF)) -#include "ss_rbuf.h" -#include "ss_rbuf.x" -#include "kwu.h" /* PJU */ -#include "ss_queue.h" -#include "ss_queue.x" -#include "ss_task.h" -#include "ss_task.x" -#include "ss_timer.x" /* System services */ -#include "ss_msg.h" /* System services */ -#include "ss_msg.x" /* System services */ -#include "ss_mem.h" /* System services */ -#include "ss_mem.x" /* System services */ -#include "ss_drvr.x" -#include "ss_gen.h" -#include "ss_gen.x" -#endif - -#include "cm5.x" /* common timer library */ -#include "cm_tkns.x" /* common tokens */ -#include "cm_mblk.x" /* common memory allocation */ -#include "cm_llist.x" /* common link list */ -#include "cm_hash.x" /* common hash list */ -#include "cm_lte.x" /* common LTE includes */ -#include "cm_lib.x" /* common memory allocation library */ -#ifdef TENB_AS_SECURITY -#include "mt_plat_t33.h" -#include "mt_plat_t33.x" -#endif -#include "kwu.x" /* KWU */ -#include "pju.x" /* PJU */ -/*#include "rgu.x" */ /* RGU */ -#include "cpj.x" /* CPJ */ -#include "lpj.x" /* LPJ */ -#include "pju.x" /* PJU */ -#include "pj.x" -#include "pj_udx.h" /* LIB */ -#include "pj_udx.x" /* LIB */ -#include "pj_dl.x" -#include "pj_ul.x" -#include "pj_ptsec.x" -#include "pj_lib.x" /* LIB */ - -#ifdef TENB_AS_SECURITY -static const char* RLOG_MODULE_NAME="PDCP"; -static int RLOG_FILE_ID=293; -static int RLOG_MODULE_ID=1024; -#endif - -#ifdef TENB_T2K3K_SPECIFIC_CHANGES -extern U32 isMemThreshReached(Region region); -#endif -#ifdef TENB_AS_SECURITY -PUBLIC U32 pjMsSpaccHdlOpenReq(PTR *fd); -PUBLIC U32 pjMsSpaccHdlCloseReq(PTR *fd); -PUBLIC U32 pjMsSpaccCipherPkt(PjMsSecInfo *pSec, Buffer *mBuf); -PUBLIC U32 pjMsSpaccIntegProtPkt(PjLibTrans *libTrans, Buffer **mBuf); - -PRIVATE S16 pjExtractTxEntRbCbUsingSpaccMappingInfo ARGS (( -PjMsSPACCOutputMapInfo *spaccInfo, -PjCb **gCb, -PjDlRbCb **pjRbCb, -PjTxEnt **txEnt -)); - - - -PRIVATE Void pjMsSpaccProcessDlBatchOutput ARGS ((Void)); -PRIVATE Void pjMsSpaccProcessUlBatchOutput ARGS((Void)); -PUBLIC U32 pjMsCheckSpaccQueue(Bool isUl); -PUBLIC Void pjSpaccDeInitCiphQ(Void); -PUBLIC Void pjSpaccDeInitDeCipherQ(Void); -#endif - -#ifdef PTPJLIB -#ifdef PJ_CMP_ASYNC -/************************************************************************ - PJU Interface Matrices -************************************************************************/ - -/**************************************************************************** - * PJU Interface Mt functions - ***************************************************************************/ - -#ifdef ANSI -PUBLIC S16 PjLibObdCmpInitReq -( -Pst * pst, -PjCmpCxt cmpCxt, -PjRohc rohc -) -#else -PUBLIC S16 PjLibObdCmpInitReq(pst, cmpCxt, rohc) -Pst * pst; -PjCmpCxt cmpCxt; -PjRohc rohc; -#endif -{ - - TRC3(PjLibObdCmpInitReq) - - RETVALUE(ROK); -} - -#ifdef ANSI -PUBLIC S16 PjLibObdCmpReq -( -Pst * pst, -PTR cmpCxtId, -PjLibTrans libTrans, -Buffer * mBuf -) -#else -PUBLIC S16 PjLibObdCmpReq(pst, cmpCxtId, libTrans, mBuf) -Pst * pst; -PTR cmpCxtId; -PjLibTrans libTrans; -Buffer * mBuf; -#endif -{ - - TRC3(PjLibObdCmpReq) - - RETVALUE(ROK); - -} - -#ifdef ANSI -PUBLIC S16 PjLibObdDecmpReq -( -Pst * pst, -PTR cmpCxtId, -PjLibTrans libTrans, -Buffer * mBuf -) -#else -PUBLIC S16 PjLibObdDecmpReq(pst, cmpCxtId, libTrans, mBuf) -Pst * pst; -PTR cmpCxtId; -PjLibTrans libTrans; -Buffer * mBuf; -#endif -{ - - TRC3(PjLibObdDecmpReq) - - RETVALUE(ROK); - -} - -#ifdef ANSI -PUBLIC S16 PjLibObdCmpCloseReq -( -Pst * pst, -PTR cmpCxtId -) -#else -PUBLIC S16 PjLibObdCmpCloseReq(pst, cmpCxtId) -Pst * pst; -PTR cmpCxtId; -#endif -{ - - TRC3(PjLibObdCmpCloseReq) - - RETVALUE(ROK); - -} - -#ifdef ANSI -PUBLIC S16 PjLibObdCmpResetReq -( -Pst * pst, -PTR cmpCxtId -) -#else -PUBLIC S16 PjLibObdCmpResetReq(pst, cmpCxtId) -Pst * pst; -PTR cmpCxtId; -#endif -{ - - TRC3(PjLibObdCmpResetReq) - - RETVALUE(ROK); - -} - -#ifdef ANSI -PUBLIC S16 PjLibObdCmpFbReq -( -Pst * pst, -PTR cmpCxtId, -PjLibTrans libTrans, -Buffer *feedback -) -#else -PUBLIC S16 PjLibObdCmpFbReq(pst, cmpCxtId, libTrans, feedback) -Pst * pst; -PTR cmpCxtId; -PjLibTrans libTrans; -Buffer *feedback; -#endif -{ - - TRC3(PjLibObdCmpFbReq) - - RETVALUE(ROK); - -} - -#else -#ifdef ANSI -PUBLIC S16 PjLibObdCipherCloseReq -( -Void *cpCxtId -) -#else -PUBLIC S16 PjLibObdCipherCloseReq(cpCxtId) -Void *cpCxtId -#endif -{ - TRC3(PjLibObdCipherCloseReq) - -#ifdef INTEL_SPACC_IV_OPTIMIZATION - pjNSpaccReturnStreamIdToPool(cpCxtId); -#endif - RETVALUE(ROK); - -} - -#ifdef ANSI -PUBLIC S16 pjLibCmpInitReq -( -PjCmpCxt cmpCxt, /* Context for ROHC */ -PjRohc rohc, /* ROHC Config Info */ -PTR *cmpCxtId /* Compression Context ID */ -) -#else -PUBLIC S16 pjLibCmpInitReq(cmpCxt, rohc, cmpCxtId) -PjCmpCxt cmpCxt; /* Context for ROHC */ -PjRohc rohc; /* ROHC Config Info */ -PTR *cmpCxtId; /* Compression Context ID */ -#endif -{ - TRC3(pjLibCmpInitReq) - - RETVALUE(ROK); - -} /* end of pjLibCmpInitReq */ - -#ifdef ANSI -PUBLIC S16 pjLibCmpReq -( -PTR cmpCxtId, /* Context Id for compression */ -Buffer *mBuf, /* SDU to be compressed */ -Buffer **opSdu /* Compressed SDU */ -) -#else -PUBLIC S16 pjLibCmpReq(cmpCxtId, mBuf, opSdu) -PTR cmpCxtId; /* Context Id for compression */ -Buffer *mBuf; /* SDU to be compressed */ -Buffer **opSdu; /* Compressed SDU */ -#endif -{ - TRC3(pjLibCmpReq) - - RETVALUE(ROK); - -} /* end of pjLibCmpReq */ - -#ifdef ANSI -PUBLIC S16 pjLibDecmpReq -( -PTR cmpCxtId, /* Context Id for compression */ -Buffer *mBuf, /* SDU to be decompressed */ -Buffer **feedback, /* Decompressed SDU */ -Buffer **opSdu /* ROHC feedback buffer */ -) -#else -PUBLIC S16 pjLibDecmpReq(cmpCxtId, mBuf, feedback, opSdu) -PTR cmpCxtId; /* Context Id for compression */ -Buffer *mBuf; /* SDU to be decompressed */ -Buffer **feedback; /* Decompressed SDU */ -Buffer **opSdu; /* ROHC feedback buffer */ -#endif -{ - TRC3(pjLibDecmpReq) - - RETVALUE(ROK); - -} /* end of pjLibDecmpReq */ - -#ifdef ANSI -PUBLIC S16 pjLibCmpCloseReq -( -PTR cmpCxtId /* ROHC Context to be closed */ -) -#else -PUBLIC S16 pjLibCmpCloseReq(cmpCxtId) -PTR cmpCxtId; /* ROHC Context to be closed */ -#endif -{ - TRC3(pjLibCmpCloseReq) - - RETVALUE(ROK); - -} /* end of pjLibCmpCloseReq */ - -#ifdef ANSI -PUBLIC S16 pjLibCmpResetReq -( -PTR cmpCxtId /* ROHC Context to be closed */ -) -#else -PUBLIC S16 pjLibCmpResetReq(cmpCxtId) -PTR cmpCxtId; /* ROHC Context to be closed */ -#endif -{ - TRC3(pjLibCmpResetReq) - - RETVALUE(ROK); - -} /* end of pjLibCmpResetReq */ - -#ifdef ANSI -PUBLIC S16 pjLibCmpFbReq -( -PTR cmpCxtId, /* ROHC Context to be closed */ -Buffer *feedback /* Feed back */ -) -#else -PUBLIC S16 pjLibCmpFbReq(cmpCxtId, feedback) -PTR cmpCxtId; /* ROHC Context to be closed */ -Buffer *feedback; /* Feed back */ -#endif -{ - TRC3(pjLibCmpFbReq) - - RETVALUE(ROK); - -} /* end of pjLibCmpFbReq */ - -#endif /* PJ_CMP_ASYNC */ - -#ifdef ANSI -PUBLIC S16 pjLibIntInitReq -( -PjSecCxt secCxt, /* Context for Intg protection/verification */ -PjIntInfo intInfo, /* Integrity Cfg Info */ -Void **cxtId /* FD */ -) -#else -PUBLIC S16 pjLibIntInitReq(secCxt, intInfo, cxtId) -PjSecCxt secCxt; /* Context for Intg protection/verification */ -PjIntInfo intInfo; /* Integrity Cfg Info */ -Void **cxtId; /* FD */ -#endif -{ - S16 ret = ROK; - - TRC3(pjLibIntInitReq) - - RETVALUE(ret); - -} /* end of pjLibIntInitReq */ - -#ifdef ANSI -PUBLIC S16 pjLibCpInitReq -( -PjSecCxt secCxt, /* Context for Intg protection/verificatino */ -U8 algoType, /* Type of the algorithm */ -U8 *cpKey, /* Control plane ciphering key */ -Void **cxtId /* FD */ -) -#else -PUBLIC S16 pjLibCpInitReq(secCxt, algoType, cpKey, cxtId) -PjSecCxt secCxt; /* Context for Intg protection/verificatino */ -U8 algoType; /* Type of the algorithm */ -U8 *cpKey; /* Control plane ciphering key */ -Void **cxtId; /* FD */ -#endif -{ - S16 ret = ROK; - - TRC3(pjLibCpInitReq) - - RETVALUE(ret); - -} /* end of pjLibCpInitReq */ - -#ifdef ANSI -PUBLIC S16 pjLibUpInitReq -( -PjSecCxt secCxt, /* Context for Intg protection/verificatino */ -U8 algoType, /* Type of the algorithm */ -U8 *upKey, /* User plane ciphering key */ -Void **cxtId /* FD */ -) -#else -PUBLIC S16 pjLibUpInitReq(secCxt, algoType, upKey, cxtId) -PjSecCxt secCxt; /* Context for Intg protection/verificatino */ -U8 algoType; /* Type of the algorithm */ -U8 *upKey; /* User plane ciphering key */ -Void **cxtId; /* FD */ -#endif -{ - TRC3(pjLibUpInitReq) - -#ifdef INTEL_SPACC_IV_OPTIMIZATION - if(PJ_SEC_DIR_DL == secCxt.dir) - { - pjMsNSpaccIVPrepStreamIdForDl(cxtId); - } - else - { - pjMsNSpaccIVPrepStreamIdForUl(cxtId); - } -#endif - RETVALUE(ROK); - -} /* end of pjLibUpInitReq */ - - - -#ifdef ANSI -PUBLIC S16 PjLibObdCpInitReq -( -PjSec *secInp -) -#else -PUBLIC S16 PjLibObdCpInitReq(*secInp) -PjSec *secInp; -#endif -{ - TRC3(PjLibObdCpInitReq) - RETVALUE(ROK); -} - -#ifdef ANSI -PUBLIC S16 PjLibObdUpInitReq -( -PjSec *secInp -) -#else -PUBLIC S16 PjLibObdUpInitReq(*secInp) -PjSec *secInp -#endif -{ - TRC3(PjLibObdUpInitReq) - RETVALUE(ROK); -} - -#ifdef TENB_AS_SECURITY - -/** - * - * @brief Extracting gCb, rbCb, txEnt from SPAcc Mapping Information. - * - * - * @b Description: This function extracts gCb, rbCb, txEnt from SPAcc mapping - * info which is passed as one of the input params. - * - * - * @param[in] spaccInfo : Information required to map o/p PDU from SPACc to - * PDCP TxEnt. - * @param[in] gCb : PDCP Control Block - * @param[in] pjRbCb : PDCP rbCb - * @param[in] txEnt : PDCP TxEnt - * - * - * @return Void - */ - -#ifdef ANSI -PRIVATE S16 pjExtractTxEntRbCbUsingSpaccMappingInfo -( -PjMsSPACCOutputMapInfo *spaccInfo, -PjCb **gCb, -PjDlRbCb **pjRbCb, -PjTxEnt **txEnt -) -#else -PRIVATE S16 pjExtractTxEntRbCbUsingSpaccMappingInfo(spaccInfo, gCb, pjRbCb, txEnt) -PjMsSPACCOutputMapInfo *spaccInfo; -PjCb **gCb; -PjDlRbCb **pjRbCb; -PjTxEnt **txEnt; -#endif -{ - PjDlUeCb *ueCb = NULLP; - - *gCb = PJ_GET_PJCB(spaccInfo->pdcpInstance); - - pjDbmFetchDlUeCb(*gCb, spaccInfo->pdcpId.ueId,spaccInfo->pdcpId.cellId, &ueCb); - - if(ueCb == NULLP) - { - RLOG_ARG0(L_ERROR,DBG_UEID,spaccInfo->pdcpId.ueId,"UECB not found !!!! "); - RETVALUE(RFAILED); - } - - - pjDbmFetchPjDlRbCb(ueCb, spaccInfo->pdcpId.rbId, spaccInfo->pdcpId.rbType, pjRbCb); - if(*pjRbCb == NULLP) - { - RLOG_ARG2(L_ERROR, DBG_UEID,spaccInfo->pdcpId.ueId, - "CellId[%u]:RbId[%d] not found", - spaccInfo->pdcpId.cellId, spaccInfo->pdcpId.rbId); - RETVALUE(RFAILED); - } - - *txEnt = (PjTxEnt *)pjDbmGetTxEnt(*gCb, &((*pjRbCb)->dlCb.txBuf), - spaccInfo->count); - - if(*txEnt == NULLP) - { - RLOG_ARG0(L_ERROR,DBG_UEID,spaccInfo->pdcpId.ueId,"!!!!rxEnt is NULL!!!!"); - RETVALUE(RFAILED); - } - - RETVALUE(ROK); -} - - -/** - * - * @brief Handler for Processing Ciphered PDU's from SPAcc. - * - * - * @b Description: This function processes and extracts the required control - * blocks for the ciphered PDU and calls the function for to be processed - * further. - * - * @param[in] spaccOpInfo : Information required to process PDU - * @param[in] opSdu : Ciphered buffer - * - * @return S16 - * -# ROK - * -# RFAILED - */ - -#ifdef ANSI -PUBLIC S16 pjProcCiphPdu -( -Buffer *opSdu, -PjMsSPACCOutputMapInfo *spaccOpInfo -) -#else -PUBLIC S16 pjProcCiphPdu(opSdu, spaccOpInfo) -Buffer *opSdu; -PjMsSPACCOutputMapInfo *spaccOpInfo; -#endif -{ - U32 ret; - PjCb *gCb = NULLP; - PjDlRbCb *pjRbCb = NULLP; - PjTxEnt *txEnt = NULLP; - - /* Extract gCb, rbCb and txEnt for further processing */ - ret = pjExtractTxEntRbCbUsingSpaccMappingInfo(spaccOpInfo, &gCb, &pjRbCb, &txEnt); - - if(ret != ROK) - { - RLOG_ARG0(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId, - "pjExtractTxEntRbCbUsingSpaccMappingInfo: returned failure "); - PJ_FREE_BUF(opSdu); - RETVALUE(RFAILED); - } - else - { - if(pjRbCb->rbType == PJ_SRB) - { - if(txEnt->pdu != NULLP) - { - PJ_FREE_BUF(txEnt->pdu); - } - } - /* In case of Reestablish/HO , dropping the ciphered packets. These packets - * are processed again when events EVTCPJDATRESUMEREQ/EVTPJUDATFWDREQ are - * received from upper layer */ - if((pjRbCb->ueCb->libInfo.state != PJ_STATE_NORMAL) && (pjRbCb->rbType != PJ_SRB)) - { - RLOG_ARG0(L_INFO,DBG_UEID,spaccOpInfo->pdcpId.ueId, - "Dropping the packet in reestablish state "); - PJ_FREE_BUF(opSdu); - RETVALUE(RFAILED); - } - txEnt->pdu = opSdu; - - /* Call to deliver PDU to RLC */ - ret = pjDlmDeliverPdu(gCb, pjRbCb, txEnt); - if(ret != ROK) - { - RETVALUE(RFAILED); - RLOG_ARG0(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId, - "pjProcCiphPdu: pjDlmDeliverPdu failed !!!!"); - } - } - - RETVALUE(ROK); -} - - -/** - * - * @brief Handler for Ciphering failure - * - * - * @b Description: This function handles the steps to be taken on failure of - * ciphering - * - * - * @param[in] procInfo : Information required to process PDU - * - * - * @return Void - */ - -#ifdef ANSI -PUBLIC S16 pjHndlCiphFail -( -PjMsSPACCOutputMapInfo *spaccInfo -) -#else -PUBLIC S16 pjHndlCiphFail(spaccInfo) -PjMsSPACCOutputMapInfo *spaccInfo; -#endif -{ - PjCb *gCb = NULLP; - PjDlRbCb *pjRbCb = NULLP; - PjTxEnt *txEnt = NULLP; - - /* Extract gCb, rbCb and txEnt for further processing */ - if((pjExtractTxEntRbCbUsingSpaccMappingInfo(spaccInfo, &gCb, &pjRbCb, &txEnt)) != ROK) - { - RETVALUE(RFAILED); - } - else - { - PJ_UPD_DL_VAR(gCb, pjRbCb, txEnt->count); - if ( pjRbCb->dlCb.cfmReqd) - { - PJ_SND_CFM(gCb,pjRbCb, txEnt, - PJU_CIPHER_FAILED); - } - else - { - pjDbmDelTxEnt(gCb, &(pjRbCb->dlCb.txBuf), txEnt->count); - } - gCb->pjGenSts.numCiphFails++; - } - - RETVALUE(ROK); -} -#ifdef SPACC_THREADED -PRIVATE U32 globPollCount = 50; - -/** - * - * @brief Handler for SPACC Reset - * - * - * @b Description: This is triggeres when the processing of batch at SPACC - * is delayed - * - * - * - * @return Void - */ - - -#ifdef ANSI -PRIVATE Void pjMsSpaccReset(Void) -#else -PRIVATE Void pjMsSpaccReset() -#endif -{ - U32 ret=ROK; - U32 jobNum=1; - Buffer *opSdu=NULLP; - PjMsSPACCOutputMapInfo spaccInfo; - - RLOG0(L_DEBUG,"Restarting SPACC"); -// PjLibObdDlCloseReq(); - pjMsSPAccRestart(); - RLOG0(L_DEBUG,"SPACC Restarted"); - - for(;;) - { - ret = pjMsSpaccFetchDlPduInfo(&spaccInfo, &opSdu, jobNum, RFAILED); - if(ret == ROKDNA) - { - RLOG1(L_ERROR, "NUM DL jobs at failure:%ld",jobNum); - break; - } - pjHndlCiphFail(&spaccInfo); - jobNum++; - } - - pjMsSetQFreeDl(); - - jobNum = 1; - - for(;;) - { - ret = pjMsSpaccFetchUlPduInfo(&spaccInfo, &opSdu, jobNum, RFAILED); - if(ret == ROKDNA) - { - RLOG1(L_ERROR,"NUM UL jobs at failure:%ld",jobNum); - break; - } - pjHdlDecipherFailure(&spaccInfo); - jobNum++; - } - - pjMsSetQFreeUl(); - - //RLOG0(L_DEBUG, "pjMsSetQFreeUl done"); - //RLOG0(L_DEBUG, "Reopening SPACC DL"); - //pjMsSpaccHdlDlfdOpenReq(); - // RLOG0(L_DEBUG, "Reopened SPACC DL"); - - RETVOID; -} -#endif -/** - * - * @brief Handler for NRT TTI Indication to PDCP for DL batch processing - * - * - * @b Description: Triggers batch processing to SPAcc. Fetches the ciphered PDUs - * from SPAcc and triggers sending the PDU's RLC. - * - * - * - * @return Void - */ - - -#ifdef ANSI -PUBLIC Void PjDlSpaccTrigger(Void) -#else -PUBLIC Void PjDlSpaccTrigger() -#endif -{ - - U32 ret=ROK; - U32 jobNum=1; - Buffer *opSdu=NULLP; - PjMsSPACCOutputMapInfo spaccInfo; - -#ifdef SPACC_NONBLOCKING - static U32 dlPollCount = 0; - - S32 pollop; - pollop = pjMsSpaccPollDlQueue(); - if(PJ_MS_POLL_NOT_REQUIRED == pollop) - { - ret = pjMsSpaccBatchAndCipherPackets(); -// pjMsSpaccSetResetDlQueueFree(0); /* Set to FALSE */ - } - else - { - if(PJ_MS_POLL_COMPLETE == pollop) - { - dlPollCount = 0; - /* Process the o/p from SPAcc */ - pjMsSpaccProcessDlBatchOutput(); -// pjMsSpaccSetResetDlQueueFree(1); /* Set to TRUE */ - - /* Send next set of data to SPAcc after processing */ - ret = pjMsSpaccBatchAndCipherPackets(); -// pjMsSpaccSetResetDlQueueFree(0); /* Set to FALSE */ - } - else - { -#ifdef SPACC_THREADED - /*Workaround for the SPACC issue of "unexpected job"*/ - dlPollCount++; - if(dlPollCount >= globPollCount) - { - U32 numUnexpJobs = 0; - dlPollCount = 0; - numUnexpJobs = pjMsCheckUnExpJobs(); - if(numUnexpJobs != 0) - { - pjMsSpaccReset(); - } - } -#endif - /* Do nothing as SPAcc is not done with processing */ - } - } - - /* This condition is executed when SPAcc returns failure for whatever - * reason.So once failure is returned, we fetch all the PDU's we had sent - * for ciphering and process them as failure */ - if(ret != ROK) - { - RLOG0(L_ERROR,"Error leg in DL Spacc trigger hit "); - for(;;) - { - ret = pjMsSpaccFetchDlPduInfo(&spaccInfo, &opSdu, jobNum, ret); - if(ret == ROKDNA) - { - break; - } - pjHndlCiphFail(&spaccInfo); - jobNum++; - } - } - -#else - - ret = pjMsSpaccBatchAndCipherPackets(); - - /* This condition is executed when SPAcc returns failure for whatever - * reason.So once failure is returned, we fetch all the PDU's we had sent - * for ciphering and process them as failure */ - if(ret != ROK) - { - for(;;) - { - ret = pjMsSpaccFetchDlPduInfo(&spaccInfo, &opSdu, jobNum, ret); - if(ret == ROKDNA) - { - break; - } - pjHndlCiphFail(&spaccInfo); - RETVOID; - } - } - - pjMsSpaccProcessDlBatchOutput(); - -#endif - - RETVOID; -} - -/** - * - * @brief Handler for processing of Decipher Failure - * - * - * @b Description: This function handles decipher failures by deleting the - * RxEnt, send STA_IND to upper layer and updation of general statistics. - * - * - * @param[in] spaccOpInfo : Information required to process PDU - * - * - * @return Void - */ - -#ifdef ANSI -PUBLIC S16 pjHdlDecipherFailure -( -PjMsSPACCOutputMapInfo *spaccOpInfo -) -#else -PUBLIC S16 pjHdlDecipherFailure() -PjMsSPACCOutputMapInfo *spaccOpInfo; -#endif -{ - PjCb *gCb; - PjUlUeCb *ueCb = NULLP; - PjUlRbCb *pjRbCb = NULLP; - PjRxEnt *rxEnt = NULLP; - - gCb = PJ_GET_PJCB(spaccOpInfo->pdcpInstance); - - pjDbmFetchUlUeCb(gCb, - spaccOpInfo->pdcpId.ueId, - spaccOpInfo->pdcpId.cellId, - &ueCb); - - if(ueCb == NULLP) - { - RLOG_ARG0(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId,"UECB not found !!!! "); - RETVALUE(RFAILED); - } - - /* RLOG_ARG4(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId, - * "At PDCP: : RBTYPE:%d, CELLID:%d, RBID:%d, - COUNT:%d", spaccOpInfo->pdcpId.rbType, spaccOpInfo->pdcpId.cellId, - spaccOpInfo->pdcpId.rbId, spaccOpInfo->count);*/ - /* RLOG_ARG2(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId, - "SNLEN:%d, numjobs %d "spaccOpInfo->pdcpId.ueId, \ - spaccOpInfo->snLen, numJobs); */ - - pjDbmFetchPjUlRbCb(ueCb, spaccOpInfo->pdcpId.rbId, spaccOpInfo->pdcpId.rbType, &pjRbCb); - if(pjRbCb == NULLP) - { - RLOG_ARG0(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId,"RBCB not found !!!!"); - RETVALUE(RFAILED); - } - - rxEnt = (PjRxEnt *)pjDbmGetRxEnt(gCb, - &(pjRbCb->ulCb.recBuf), - spaccOpInfo->count); - - if(rxEnt == NULLP) - { - RLOG_ARG0(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId,"!!!!rxEnt is NULL!!!!"); - RETVALUE(RFAILED); - } - - PJ_SND_PJU_STA_IND(gCb,pjRbCb, rxEnt); - pjDbmDelRxEnt(gCb, &(pjRbCb->ulCb.recBuf), rxEnt->count); - PJ_STS_INC_GEN_CNT(gCb,numDeciphFails); - - RETVALUE(ROK); -} - -/** - * - * @brief Handler for processing deciphered PDU - * - * - * @b Description: This function processes and sends the ciphered PDU to RLC - * - * - * @param[in] spaccOpInfo : Information required to process PDU - * @param[in] opSdu : Deciphered buffer - * - * - * @return S16 - * -# ROK - * -# RFAILED - */ - -#ifdef ANSI -PUBLIC S16 pjProcDeCipherPdu -( -PjMsSPACCOutputMapInfo *spaccOpInfo, -Buffer *opSdu -) -#else -PUBLIC S16 pjProcDeCipherPdu() -PjMsSPACCOutputMapInfo *spaccOpInfo; -Buffer *opSdu; -#endif -{ - U32 ret; - PjCb *gCb; - PjUlUeCb *ueCb = NULLP; - PjUlRbCb *pjRbCb = NULLP; - PjRxEnt *rxEnt = NULLP; - - gCb = PJ_GET_PJCB(spaccOpInfo->pdcpInstance); - - pjDbmFetchUlUeCb(gCb, - spaccOpInfo->pdcpId.ueId, - spaccOpInfo->pdcpId.cellId, - &ueCb); - - if(ueCb == NULLP) - { - RLOG_ARG0(L_WARNING,DBG_UEID,spaccOpInfo->pdcpId.ueId,"UECB not found !!!! "); - RETVALUE(RFAILED); - } - -/* RLOG_ARG4(L_ERROR, DBG_UEID,spaccOpInfo->pdcpId.ueId, - "UDAY: At PDCP: : RBTYPE:%d, CELLID:%d, RBID:%d, COUNT:%d", - spaccOpInfo->pdcpId.rbType, spaccOpInfo->pdcpId.cellId, - spaccOpInfo->pdcpId.rbId, spaccOpInfo->count,);*/ -/* RLOG_ARG2(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId, - " SNLEN:%d, numjobs %d ",spaccOpInfo->snLen, numJobs); */ - - pjDbmFetchPjUlRbCb(ueCb, spaccOpInfo->pdcpId.rbId, spaccOpInfo->pdcpId.rbType, &pjRbCb); - if(pjRbCb == NULLP) - { - RLOG_ARG0(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId,"RBCB not found !!!! "); - RETVALUE(RFAILED); - } - - rxEnt = (PjRxEnt *)pjDbmGetRxEnt(gCb, &(pjRbCb->ulCb.recBuf), - spaccOpInfo->count); - -/* To be used for debugging. Will be removed once verified */ - - if(rxEnt == NULLP) - { - RLOG_ARG0(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId,"!!!!rxEnt is NULL!!!!"); - RETVALUE(RFAILED); - } - - /*Free the source buffer here*/ - if(rxEnt->mBuf) - { - PJ_FREE_BUF(rxEnt->mBuf); - } - - rxEnt->mBuf = opSdu; - - - if(pjRbCb->rbType == PJ_DRB) - { - rxEnt->state = PJ_RDY_TO_DCOMP; - ret = pjUlmHdlDeCmp(gCb, pjRbCb, rxEnt); - } - else - { - rxEnt->state = PJ_RDY_TO_INTVER; - ret = pjUlmHdlIntVer(gCb, pjRbCb, rxEnt); - } - - if(rxEnt->dupEntry == TRUE) - { - RLOG_ARG0(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId," 3. Deleting RxEnt"); - /* duplicate entry */ - PJ_FREE_BUF(rxEnt->mBuf); - PJ_FREE(gCb,rxEnt, sizeof(PjRxEnt)); - } - else if(rxEnt->discFlag == TRUE) - { - RLOG_ARG0(L_ERROR,DBG_UEID,spaccOpInfo->pdcpId.ueId,"4. Deleting RxEnt"); - /* duplicate entry */ - pjDbmDelRxEnt(gCb, &pjRbCb->ulCb.recBuf, rxEnt->count); - } - RETVALUE(ROK); - -} - -/** - * - * @brief Handler for NRT TTI Indication to PDCP for UL batch processing - * - * - * @b Description: Triggers batch processing of packets lined up for - * deciphering. Fetches the ciphered PDUs - * and triggers further processing at PDCP. - * - * - * - * @return Void - */ - - -#ifdef ANSI -PUBLIC Void PjUlSpaccTrigger(Void) -#else -PUBLIC Void PjUlSpaccTrigger(Void) -#endif -{ - - U32 ret=ROK; - U32 jobNum=1; - Buffer *opSdu=NULLP; - PjMsSPACCOutputMapInfo spaccInfo; - -#ifdef SPACC_NONBLOCKING - static U32 ulPollCount = 0; - - S32 pollop; - pollop = pjMsSpaccPollUlQueue(); - if(PJ_MS_POLL_NOT_REQUIRED == pollop) - { - ret = pjMsSpaccBatchAndDeCipherPackets(); - } - else - { - if(PJ_MS_POLL_COMPLETE == pollop) - { - ulPollCount = 0; - /* Process the o/p from SPAcc */ - pjMsSpaccProcessUlBatchOutput(); - pjMsSpaccSetResetUlQueueFree(1); /* Set to TRUE */ - - /* Send next set of data to SPAcc after processing */ - ret = pjMsSpaccBatchAndDeCipherPackets(); - } - else - { -#ifdef SPACC_THREADED - /*SPACC Workaround when SPACC is not able to complete BATCH*/ - ulPollCount++; - if(ulPollCount >= globPollCount) - { - U32 numUnexpJobs = 0; - ulPollCount = 0; - numUnexpJobs = pjMsCheckUnExpJobs(); - if(numUnexpJobs != 0) - { - pjMsSpaccReset(); - } - } -#endif - } - } - - /* This condition is executed when SPAcc returns failure for whatever - * reason.So once failure is returned, we fetch all the PDU's we had sent - * for Deciphering and process them as failure */ - if(ret != ROK) - { - RLOG0(L_ERROR, "Error leg in uL Spacc trigger hit "); - for(;;) - { - ret = pjMsSpaccFetchUlPduInfo(&spaccInfo, &opSdu, jobNum, ret); - if(ret == ROKDNA) - { - break; - } - pjHdlDecipherFailure(&spaccInfo); - jobNum++; - } - } - -#else - - ret = pjMsSpaccBatchAndDeCipherPackets(); - - /* This condition is executed when SPAcc returns failure for whatever - * reason.So once failure is returned, we fetch all the PDU's we had sent - * for Deciphering and process them as failure */ - if(ret != ROK) - { - for(;;) - { - ret = pjMsSpaccFetchUlPduInfo(&spaccInfo, &opSdu, jobNum, ret); - if(ret == ROKDNA) - { - break; - } - pjHdlDecipherFailure(&spaccInfo); - } - - RETVOID; - } - - pjMsSpaccProcessUlBatchOutput(); - - -#endif - - RETVOID; -} - - - -/** -*@brief -* This function calls the function which interfaces with SPAcc -* for opening of the fd. Also, it initializes the SPAcc DL Queues. -* -*@inparam[in] gCb PDCP Instance Control Block -*@return S16 -*/ - -#ifdef ANSI -PUBLIC S16 PjLibObdDlInitReq -( -PjCb *gCb -) -#else -PUBLIC S16 PjLibObdDlInitReq(gCb) -PjCb *gCb; -#endif -{ - TRC3(PjLibObdDlInitReq) - -#ifdef INTEL_NATIVE_SPACC - S32 ret = RFAILED; - ret = pjMsSpaccRegIccDlHndl(); - if(ret != ROK) - { - printf("Registration of ICC DL handle has failed\n"); - RETVALUE(ret); - } - printf("Registration of ICC DL handle has succeeded\n"); - ret = pjMsSpaccThreadActivation(appContext.hUAII_Dl); - if(ret != 0) - { - printf("Spacc thread activation has failed\n"); - RETVALUE(ret); - } - printf("Spacc thread activation is done again\n"); - /* Init Mem region and Pool */ - pjMsSPAccInitDlMemRegionPool(gCb->init.region, gCb->init.pool); -#ifdef INTEL_SPACC_IV_OPTIMIZATION - pjMsNSpaccDlInitForSpaccIV(gCb); -#endif -#else - /*Call to open file descriptors for interfacing with SPACC*/ - if(pjMsSpaccHdlDlfdOpenReq() != ROK) - { - RETVALUE(RFAILED); - } - - /*Call to initialise the DL/UL SPAcc queues*/ - pjMsSPAccInitDlQue(); - - /* Init Mem region and Pool */ - pjMsSPAccInitDlMemRegionPool(gCb->init.region, gCb->init.pool); -#endif - RETVALUE(ROK); -} - -/** -*@brief -* This function calls the function which interfaces with SPAcc -* for opening of the fd. Also, it initializes the SPAcc UL Queues. -* -*@inparam[in] gCb PDCP Instance Control Block -*@return S16 -* -*/ - -#ifdef ANSI -PUBLIC S16 PjLibObdUlInitReq -( -PjCb *gCb -) -#else -PUBLIC S16 PjLibObdUlInitReq(gCb) -PjCb *gCb; -#endif -{ - TRC3(PjLibObdUlInitReq) - -#ifdef INTEL_NATIVE_SPACC - S32 ret = RFAILED; - ret = pjMsSpaccRegIccUlHndl(); - if(ret != ROK) - { - printf("Registration of ICC UL handle has failed\n"); - RETVALUE(ret); - } - printf("Registration of ICC UL handle has succeeded\n"); - ret = pjMsSpaccThreadActivation(appContext.hUAII_Ul); - if(ret != 0) - { - printf("Spacc thread activation has failed\n"); - RETVALUE(ret); - } - printf("Spacc thread activation is done\n"); - /* Init Mem region and Pool */ - pjMsSPAccInitUlMemRegionPool(gCb->init.region, gCb->init.pool); -#ifdef INTEL_SPACC_IV_OPTIMIZATION - pjMsNSpaccUlInitForSpaccIV(gCb); -#endif -#else - /*Call to open file descriptors for interfacing with SPACC*/ - if(pjMsSpaccHdlUlfdOpenReq() != ROK) - { - RETVALUE(RFAILED); - } - - /*Call to initialise the UL SPAcc queues*/ - pjMsSPAccInitUlQue(); - - /* Init Mem region and Pool */ - pjMsSPAccInitUlMemRegionPool(gCb->init.region, gCb->init.pool); -#endif - RETVALUE(ROK); -} - - -/** - * - * @brief Handler for invoking key derivation function for KeNB*. This is used - * for Handover cases. - * - * - * @Description: When the eNB decides to perform an intra-eNB handover it - * shall derive KeNB* using target PCI, its frequency EARFCN-DL, and - * either NH or the current KeNB. - * - * @input: gCb - Control Block - * kenbInf - Input structure for KeNB* derivation. - * kdfCfm - Output filled into this structure after derivation. - * - * @return S16 - */ -#ifdef ANSI -PUBLIC S16 pjLibObdPrcKenbStarCfg -( -PjCb *gCb, -CpjKenbStarInfo* kenbInf, -CpjKenbStarCfmInfo *kdfCfm -) -#else -PUBLIC S16 pjLibObdPrcKenbStarCfg(gCb, kenbInf, kdfCfm) -PjCb *gCb; -CpjKenbStarInfo* kenbInf; -CpjKenbStarCfmInfo *kdfCfm; -#endif -{ - PjMsSecInfo *pSecInfo; - U32 ret=ROK; - - TRC2(pjLibObdPrcKenbStarCfg) - - PJ_ALLOC(gCb, pSecInfo , sizeof(PjMsSecInfo)); - if(pSecInfo == NULLP) - { - RLOG1(L_ERROR, "YsMsUlmPrcKenbStarCfg failed line %d ", __LINE__); - RETVALUE(RFAILED); - } - - - cmMemcpy(pSecInfo->hash_key, kenbInf->secKey, CPJ_SEC_KEY_LEN); - - /* Building the String S = FC || P0 || L0 || P1 || L1 */ - - /*Values are initialized as per section A7 33.401*/ - pSecInfo->strS[0] = 0x13; - pSecInfo->strS[3] = 0x00; - pSecInfo->strS[4] = 0x02; - pSecInfo->strS[7] = 0x00; - pSecInfo->strS[8] = 0x02; - - - RLOG2(L_DEBUG,"Value of Cellid, dl Freq is %d %d ", - kenbInf->physCellId, kenbInf->dlCarrFreq); - /******************************************* - *************kENB* from kENB************* - *******************************************/ - - /*PCI*/ - pSecInfo->strS[1] = kenbInf->physCellId >> 8; - pSecInfo->strS[2] = (U8)kenbInf->physCellId; - - /*DL frequency*/ - pSecInfo->strS[5] = kenbInf->dlCarrFreq >> 8; - pSecInfo->strS[6] = (U8)kenbInf->dlCarrFreq; - - pSecInfo->strSlen = 9; - - if((pjSendToKeyDeriveFunc(pSecInfo, kdfCfm->secKey)) != ROK) - { - RLOG0(L_ERROR, "In pjLibObdPrcKenbStarCfg: pjMsKDF failed"); - ret = RFAILED; - }/*End of if(ret!=ROK)*/ - - PJ_FREE(gCb, pSecInfo, sizeof(PjMsSecInfo)); - - RETVALUE(ret); -}/*End of function*/ - -/** - * - * @brief Handler for invoking key derivation function for KeNB. KeNB is Key - * derivation funtion. This is normal Ciphering/Integrity Key derivation at - * eNB. - * - * - * @Description: For Security to be enabled, Integrity and Ciphering keys need - * to be derived. These are applied on SRB/DRB data and the Ciphered/Integrity - * protected PDU are sent to UE. - * - * @input: gCb - Control Block - * kenbInf - Input structure for KeNB* derivation. - * kdfCfm - Output filled into this structure after derivation. - * - * @return S16 - */ -#ifdef ANSI -PUBLIC S16 pjLibObdPrcKenbCfg -( -PjCb *gCb, -CpjAsKeyInfo* kenbInf, -CpjAskeyCfmInfo *kdfCfm -) -#else -PUBLIC S16 pjLibObdPrcKenbCfg(kenbInf) -PjCb *gCb; -CpjAsKeyInfo* kenbInf; -CpjAskeyCfmInfo *kdfCfm; -#endif -{ - - S16 ret; - PjMsSecInfo *pSecInfo; - - - TRC2(pjLibObdPrcKenbCfg) - ret = ROK; - - PJ_ALLOC(gCb, pSecInfo, sizeof(PjMsSecInfo)); - if(pSecInfo == NULLP) - { - RLOG1(L_ERROR, "YsMsUlmPrcKenbCfg failed line %d ", __LINE__); - RETVALUE(RFAILED); - } - - - cmMemcpy(pSecInfo->hash_key, kenbInf->secKey, CPJ_SEC_KEY_LEN); - - /* Building the String S = FC || P0 || L0 || P1 || L1 */ - - /*Values are initialized as per section A7 33.401*/ - pSecInfo->strS[0] = 0x15; - pSecInfo->strS[2] = 0x00; - pSecInfo->strS[3] = 0x01; - pSecInfo->strS[5] = 0x00; - pSecInfo->strS[6] = 0x01; - - pSecInfo->strSlen = 7; - - /******************************************* - *************CP Ciphering key************* - *******************************************/ - pSecInfo->strS[1] = 0x3; - pSecInfo->strS[4] = kenbInf->ciphAlgoType; - - ret = pjSendToKeyDeriveFunc(pSecInfo, kdfCfm->cpCiphKey); - if(ret!=ROK) - { - RLOG0(L_ERROR, "Control Plane Cipher Key derivation failed"); - PJ_FREE(gCb, pSecInfo, sizeof(PjMsSecInfo)); - RETVALUE(RFAILED); - }/*End of if(ret!=ROK)*/ - - - /******************************************* - *************UP Ciphering key************* - *******************************************/ - pSecInfo->strS[1] = 0x5; - pSecInfo->strS[4] = kenbInf->ciphAlgoType; - - ret = pjSendToKeyDeriveFunc(pSecInfo, kdfCfm->upCiphKey); - if(ret!=ROK) - { - RLOG0(L_ERROR, "User Plane Cipher Key derivation failed"); - PJ_FREE(gCb, pSecInfo, sizeof(PjMsSecInfo)); - RETVALUE(RFAILED); - }/*End of if(ret!=ROK)*/ - - RLOG0(L_DEBUG, "Ciphering Key (UP) Derived"); - - /******************************************* - ************RRC Integrity key************* - *******************************************/ - pSecInfo->strS[1] = 0x4; - pSecInfo->strS[4] = kenbInf->intgAlgoType; - - ret = pjSendToKeyDeriveFunc(pSecInfo, kdfCfm->intKey); - if(ret!=ROK) - { - RLOG0(L_ERROR, "Integrity Key derivation failed"); - PJ_FREE(gCb, pSecInfo, sizeof(PjMsSecInfo)); - RETVALUE(RFAILED); - }/*End of if(ret!=ROK)*/ - - RLOG0(L_DEBUG, "Integrity Key Derived"); - - PJ_FREE(gCb, pSecInfo, sizeof(PjMsSecInfo)); - - - RETVALUE(ROK); -}/*End of function*/ - - -/** - * - * @brief - * - * Provides input params like Keys, RbId, direction which would be used - * as input for creation of SPAcc i/p structure.. - * - * @b Description: - * - * This function sends Intergrity protection request with elevant input parameters. - * - * @param[in] pjRbCb PDCP RbCb - * @param[in] intCxtId Input parameters for integrity - * @param[in] mBuf SDU to be compressed - * @param[out] libTrans Input to integrity algo (RbId, Count, Direction) - * - * @return S16 - * -# ROK - * - */ - -#ifdef ANSI -PUBLIC S16 PjLibObdIntProtReq -( -PjLibTrans *libTrans, -Buffer **mBuf -) -#else -PUBLIC S16 PjLibObdIntProtReq(libTrans, mBuf) -PjLibTrans *libTrans; -Buffer **mBuf; -#endif -{ - - U32 ret = ROK; - U32 dummyMacI =0 ; - TRC3(PjLibObdIntProtReq) - - if(libTrans->intAlgoType == PJ_SPACC_EIA1) - { - ret = pjMsSpaccIntegProtPkt(libTrans, mBuf); - } - else if (libTrans->intAlgoType == PJ_SPACC_EIA2) - { - ret = pjMsSpaccAesIntegProtPkt(libTrans, mBuf); - } - else if (libTrans->intAlgoType == PJ_SPACC_EIA3) - { - ret = pjMsSpaccIntegProtPkt(libTrans, mBuf); - } - else - { - /* NULL Algorithm */ - PJ_PACK_MACI(*mBuf, dummyMacI); - } - - RETVALUE(ret); -} - -/** - * - * @brief - * - * Handler for redirecing Integration request to SPAcc module. - * - * @b Description: - * - * This function sends Intergrity verification request along with relevant input parameters. - * - * @param[in] PjCb PDCP Cb - * @param[in] PTR Handle for Integrity verification (handle opened during spacc_dev_open) - * @param[in] PjLibTrans Input parameters for integrity - * @param[in] mBuf SDU to be compressed - * @param[out] macI MAC-I - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 PjLibObdIntVerReq -( -PjLibTrans *libTrans, -Buffer *mBuf, -U32 macI -) -#else -PUBLIC S16 PjLibObdIntVerReq(libTrans, mBuf, macI) -PjLibTrans *libTrans; -Buffer *mBuf; -U32 macI; -#endif -{ - U32 ret = ROK; - TRC3(PjLibObdIntVerReq) - - if(libTrans->intAlgoType != 0) - { - ret = pjMsSpaccIntegVerifyPkt(libTrans, &mBuf, macI); - } - else - { - RLOG_ARG0(L_ERROR,DBG_UEID,libTrans->ueId,"Integrity protection Algo type is == 0 "); - } - - RETVALUE(ret); -} - - -/** -*@brief -* This function calls the function which interfaces with SPAcc -* for closing the DL fd. -* -*@return S16 -* -ROK -* -*/ -#ifdef ANSI -PUBLIC S16 PjLibObdDlCloseReq(Void) -#else -PUBLIC S16 PjLibObdDlCloseReq(Void) -#endif -{ - - TRC3(PjLibObdDlCloseReq) - pjSpaccDeInitCiphQ(); - pjMsSPAccDlfdCloseReq(); - RETVALUE(ROK); - -} - -/** -*@brief -* This function calls the function which interfaces with SPAcc -* for closing the UL fd. -* -*@return S16 -* -ROK -* -*/ -#ifdef ANSI -PUBLIC S16 PjLibObdUlCloseReq(Void) -#else -PUBLIC S16 PjLibObdUlCloseReq(Void) -#endif -{ - - TRC3(PjLibObdUlCloseReq) - pjSpaccDeInitDeCipherQ(); - pjMsSPAccUlfdCloseReq(); - RETVALUE(ROK); - -} - - -/** - * - * @brief - * - * Handler for redirecing ciphering request to SPAcc Module. - * - * @b Description: - * - * This function sends ciphering protection request along with relevant input parameters. - * - * @param[in] PjCb PDCP Cb - * @param[in] PjLibTrans libTrans( Input parameters for deciphering ) - * @param[in] mBuf Data to be deciphered - * @param[in] opSdu Deciphered SDU - * @param[in] cxtId Handle for ciphering either for User/Control plane. - * - * @return S16 - * -# ROK - * - */ - -#ifdef ANSI -PUBLIC S16 PjLibObdCipherReq -( -PjLibTrans *libTrans, -Buffer *mBuf, -Buffer **opSdu -) -#else -PUBLIC S16 PjLibObdCipherReq(libTrans, mBuf, opSdu) -PjLibTrans *libTrans; -Buffer *mBuf; -Buffer **opSdu; -#endif -{ - U32 ret = ROK; - - TRC3(PjLibObdCipherReq) - - ret = pjSendToCipher(libTrans, mBuf); - - RETVALUE(ret); -} - - -#ifdef FLAT_BUFFER_OPT -/** - * - * @brief - * - * Handler for redirecing ciphering request to SPAcc Module. - * - * @b Description: - * - * This function sends ciphering protection request along with relevant input parameters. - * - * @param[in] PjCb PDCP Cb - * @param[in] PjLibTrans libTrans( Input parameters for deciphering ) - * @param[in] mBuf Flat Buffer to be deciphered - * @param[in] opSdu Deciphered SDU - * @param[in] cxtId Handle for ciphering either for User/Control plane. - * - * @return S16 - * -# ROK - * - */ - -#ifdef ANSI -PUBLIC S16 PjLibObdCipherReqFB -( -PjLibTrans *libTrans, -FlatBuffer *mBuf, -Buffer **opSdu -) -#else -PUBLIC S16 PjLibObdCipherReqFB(libTrans, mBuf, opSdu) -PjLibTrans *libTrans; -FlatBuffer *mBuf; -Buffer **opSdu; -#endif -{ - - U32 ret = ROK; - - TRC3(PjLibObdCipherReqFB) - - ret = pjSendToCipherFB(libTrans, mBuf); - - RETVALUE(ret); -} -#endif - - -/** - * - * @brief - * - * Handler for redirecing deciphering request to SPAcc module. - * - * @b Description: - * - * This function sends deciphering request along with relevant input parameters. - * - * @param[in] PjCb PDCP Cb - * @param[in] PTR Handle for Deciphering (stored during spacc_dev_open) - * @param[in] PjLibTrans Input parameters for deciphering - * @param[in] mBuf Data to be deciphered - * @param[in] opSdu Deciphered SDU - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 PjLibObdDecipherReq -( -PjLibTrans *libTrans, -Buffer *mBuf, -Buffer **opSdu -) -#else -PUBLIC S16 PjLibObdDecipherReq(libTrans, mBuf, opSdu) -PjLibTrans *libTrans; -Buffer *mBuf; -Buffer **opSdu; -#endif -{ - U32 ret = ROK; - - TRC3(PjLibObdDecipherReq) - - ret = pjSendToDeCipher(libTrans, mBuf); - - RETVALUE(ret); - -} -#else - -#ifdef ANSI -PUBLIC S16 pjLibObdPrcKenbCfg -( -PjCb *gCb, -CpjAsKeyInfo* kenbInf, -CpjAskeyCfmInfo *kdfCfm -) -#else -PUBLIC S16 pjLibObdPrcKenbCfg(gCb, kenbInf, kdfCfm) -PjCb *gCb; -CpjAsKeyInfo* kenbInf; -CpjAskeyCfmInfo *kdfCfm; -#endif -{ - TRC2(pjLibObdPrcKenbCfg); - RETVALUE(ROK); -} - -#ifdef ANSI -PUBLIC S16 pjLibObdPrcKenbStarCfg -( -PjCb *gCb, -CpjKenbStarInfo* kenbInf, -CpjKenbStarCfmInfo *kdfCfm -) -#else -PUBLIC S16 pjLibObdPrcKenbStarCfg(gCb, kenbInf, kdfCfm) -PjCb *gCb; -CpjKenbStarInfo* kenbInf; -CpjKenbStarCfmInfo *kdfCfm; -#endif -{ - - TRC2(pjLibObdPrcKenbStarCfg); - RETVALUE(ROK); - -} - - -#ifdef ANSI -PUBLIC S16 pjLibDecipherReq -( -PTR intCxtId, /* Context Id for compression */ -PjSecInp secInp, /* Input for Deciphering */ -Buffer *mBuf, /* SDU to be deciphered */ -Buffer **opSdu /* deciphered SDU */ -) -#else -PUBLIC S16 pjLibDecipherReq(intCxtId, secInp, mBuf, opSdu) -PTR intCxtId; /* Context Id for Deciphering */ -PjSecInp secInp; /* Input for Deciphering */ -Buffer *mBuf; /* SDU to be Deciphering */ -Buffer **opSdu; /* Deciphering SDU */ -#endif -{ - TRC3(pjLibDecipherReq) -#ifdef LTE_PAL_ENB - *opSdu = mBuf; -#endif - RETVALUE(ROK); - -} /* end of pjLibDecipherReq */ - - -#ifdef ANSI -PUBLIC S16 pjLibIntVerReq -( -PTR intCxtId, /* Context Id for compression */ -PjSecInp secInp, /* Input for Integrity protection */ -Buffer *mBuf, /* SDU to be compressed */ -U32 macI, /* Message authentication code for the SDU */ -Status *status /* Status of the Integrity verification */ -) -#else -PUBLIC S16 pjLibIntVerReq(intCxtId, secInp, mBuf, macI, status) -PTR intCxtId; /* Context Id for compression */ -PjSecInp secInp; /* Input for Integrity protection */ -Buffer *mBuf; /* SDU to be compressed */ -U32 macI; /* Message authentication code for the SDU */ -Status *status; /* Status of the Integrity verification */ -#endif -{ - TRC3(pjLibIntVerReq) - RETVALUE(ROK); - -} /* end of pjLibIntVerReq */ - -#ifdef ANSI -PUBLIC S16 PjLibObdIntProtReq -( -PjLibTrans *libTrans, -Buffer **mBuf -) -#else -PUBLIC S16 PjLibObdIntProtReq(libTrans, mBuf) -PjLibTrans *libTrans; -Buffer **mBuf; -#endif -{ -#ifdef LTE_PAL_ENB - Buffer *mBuf1; -#endif - TRC3(PjLibObdIntProtReq); -#ifdef LTE_PAL_ENB - SAddMsgRef(*mBuf, 0,0, &mBuf1); - - *mBuf = mBuf1; -#endif - RETVALUE(ROK); -} - - -#ifdef ANSI -PUBLIC S16 PjLibObdCipherReq -( -PjLibTrans *libTrans, -Buffer *mBuf, -Buffer **opSdu -) -#else -PUBLIC S16 PjLibObdCipherReq(libTrans, mBuf, opSdu) -PjLibTrans *libTrans; -Buffer *mBuf; -Buffer **opSdu; -#endif -{ - - TRC3(PjLibObdCipherReq); -#ifdef LTE_PAL_ENB - SAddMsgRef(mBuf, 0,0, opSdu); - -#endif - RETVALUE(ROK); - -} -#endif - -#ifdef TENB_T2K3K_SPECIFIC_CHANGES -#define PJ_MAX_SDUS_TO_WAIT_FOR_ACK 1200 -PRIVATE U32 gMemoryAlarm; -/* 384MB => 768M total -cat /sys/devices/virtual/icc/iccserv/mm -============ -Partition_7f1c7890 - type: LOCAL PART -Split logic is currently disabled -Part start address_9a200000, end address_ca1fffff -Size ...................... 786432 KiB -nBlocks ................... 304085 -Number of pools ........... 4 -GAP (between sectors) ..... 128 Bytes -Pools info: -Pool_0: BlkSize_(useful_384, total_512), BlkCnt_104856, FreeBlkCnt_97177 -Pool_1: BlkSize_(useful_1920, total_2048), BlkCnt_157285, FreeBlkCnt_130668 -Pool_2: BlkSize_(useful_3968, total_4096), BlkCnt_20970, FreeBlkCnt_11245 -Pool_3: BlkSize_(useful_16256, total_16384), BlkCnt_20970, FreeBlkCnt_12122 -============*/ -#endif - -PUBLIC U32 dbgSpaccThreshHoldDropCnt = 0; -PUBLIC U32 dbgPdcpQSizeThreshHoldDropCnt = 0; -PUBLIC U32 dbgPdcpMemCount = 0; -PUBLIC U32 pdcpDropMemTh = 0; -PUBLIC U32 dbgICCMemThreshHoldDropCnt = 0; -PUBLIC U32 dbgSSIMemThreshHoldDropCnt = 0; -PUBLIC U32 dbgICCMemAlarm; -PUBLIC U32 dbgPdcpQMsSpaccQFull = 0; -PUBLIC U32 dbgPdcpRbOverload = 0; -/* kw003.201 This function is for admission control at packet level */ -#ifdef ANSI -PUBLIC S16 pjLibPktAdmCtrl -( -PjDlRbCb *pjRbCb, -Buffer *pkt -) -#else -PUBLIC S16 pjLibPktAdmCtrl(pjRbCb, pkt) -PjDlRbCb *pjRbCb; -Buffer *pkt; -#endif -{ - TRC3(pjLibPktAdmCtrl) - /* Patch kw004.201 */ -#ifdef SS_CAVIUM - if(pjRbCb->dlCb.txBuf.numEntries > 450) - { - RETVALUE(RFAILED); - } -#endif -#ifdef LTE_PAL_ENB - if(pjRbCb->dlCb.txBuf.numEntries > 1200) - { - RETVALUE(RFAILED); - } -#endif -#ifdef TENB_T2K3K_SPECIFIC_CHANGES - if(pjRbCb->dlCb.txBuf.numEntries > PJ_MAX_SDUS_TO_WAIT_FOR_ACK) - { - dbgPdcpQSizeThreshHoldDropCnt++; - /*This is for AM bearers only. FC for UDP on AM will also - be taken care here. */ -#ifdef TENB_STATS - if (pjRbCb->ueCb->tenbStats) - { - pjRbCb->ueCb->tenbStats->stats.nonPersistent.pdcp.dlPdcpAckWaitDropCnt++; - } -#endif - RETVALUE(RFAILED); - } - - /* Check the SPAcc queue too as we need to start dropping the PDUs in case - * if SPAcc queue is waiting more number of PDUs - */ - if(FALSE == (pjMsCheckSpaccQueue(FALSE))) - { - dbgSpaccThreshHoldDropCnt++; - dbgPdcpQMsSpaccQFull++; - RETVALUE(RFAILED); - } - /* Memory threshold is reached then drop the packet */ - if(isMemThreshReached(pjCb[1]->init.region) != ROK) - { - { - extern U32 pdcpdrop; - pdcpdrop++; - //MSPD_LOG("at PDCPdrop %d new %d\n",pdcpdrop); - } - RETVALUE(RFAILED); - } - - dbgICCMemAlarm=gMemoryAlarm; -#endif - if (pjRbCb->dropOnlyOne) - { -#ifdef TENB_STATS - /*FC for AM bearers*/ - if (pjRbCb->ueCb->tenbStats) - { - pjRbCb->ueCb->tenbStats->stats.nonPersistent.pdcp.dlPdcpDropCnt++; - } - -#endif - - dbgPdcpMemCount++; - pjRbCb->dropOnlyOne = 0; - RETVALUE(RFAILED); - } - if ((pjRbCb->pktAdmitCnt) && (pjRbCb->pktCnt > pjRbCb->pktAdmitCnt)) - { - /* FC for UM bearers */ -#ifdef TENB_STATS - /*FC for AM bearers*/ - if (pjRbCb->ueCb->tenbStats) - { - pjRbCb->ueCb->tenbStats->stats.nonPersistent.pdcp.dlPdcpDropCnt++; - } -#endif - RETVALUE(RFAILED); - } - /* Pkt admitted. Counting it in.*/ - pjRbCb->pktCnt++; - RETVALUE(ROK); - -} /* end of pjLibPktAdmCtrl */ - -#ifdef TENB_AS_SECURITY -/** - * @brief This function is used to Process the o/p from SPAcc. - * - * @details This function is used to Process ciphered PDU's from SPAcc. We - * check if SPAcc has ciphered all PDU's successfully or not. If success we - * pass it to lower layers. If Failure, we initimate failure. - * - * @param[in] - Void - - * - * @return - Void - */ -#ifdef ANSI -PUBLIC Void pjMsSpaccProcessDlBatchOutput(Void) -#else -PUBLIC Void pjMsSpaccProcessDlBatchOutput(Void) -#endif -{ - U32 ret=ROK; - U32 jobNum=1; - Buffer *opSdu=NULLP; - PjMsSPACCOutputMapInfo spaccInfo; - - - for(;;) - { - /* Fetch Ciphered PDU's one by one from SPAcc */ - ret = pjMsSpaccFetchDlPduInfo(&spaccInfo, &opSdu, jobNum, ROK); - - /*No further packets for processing so break from here*/ - if(ret == ROKDNA) - { - break; - } - - if(ret == RFAILED) - { - /* Handling of failure of any of the Deciphered PDU's */ - if((pjHndlCiphFail(&spaccInfo)) != ROK) - { - /* We get to this scenario when ueCb/RbCb/TxEnt is deleted already - due to either re-establishment or any other scenario. So we just - drop the packets for these */ - PJ_FREE_BUF(opSdu); - } - } - else - { - /*Send the packet to RLC*/ - pjProcCiphPdu(opSdu, &spaccInfo); - } - - jobNum++; - - /* Num PDU's sent to SPAcc cant be greater than the below condition. - * Hence break */ - if(jobNum > (PJ_MS_MAX_JOBS_IN_QUEUE + 2)) - { - RLOG1(L_ERROR, "Num Jobs in pjMsSpaccProcessDlBatchOutput " - "exceeds %ld, hence exiting!!!!", jobNum); - break; - } - } -} - -/** - * @brief This function is used to Process the o/p from SPAcc. - * - * @details This function is used to Process Deciphered PDU's from SPAcc. We - * check if SPAcc has deciphered all PDU's successfully or not. If success we - * pass it to lower layers. If Failure, we initimate failure. - * - * @param[in] - Void - - * - * @return - Void - */ -#ifdef ANSI -PUBLIC Void pjMsSpaccProcessUlBatchOutput(Void) -#else -PUBLIC Void pjMsSpaccProcessUlBatchOutput(Void) -#endif -{ - U32 ret=ROK; - U32 retval = ROK; - U32 jobNum=1; - Buffer *opSdu=NULLP; - PjMsSPACCOutputMapInfo spaccInfo; - - for(;;) - { - ret = pjMsSpaccFetchUlPduInfo(&spaccInfo, &opSdu, jobNum, ROK); - if(ret == ROKDNA) - { - break; - } - - if(ret == RFAILED) - { - /* If one of the packets sent to SPAcc returns a failure, trigger - * handling of this failure scenario */ - retval = pjHdlDecipherFailure(&spaccInfo); - } - else - { - /* Success case */ - retval = pjProcDeCipherPdu(&spaccInfo, opSdu); - } - - if(retval != ROK) - { - /* Drop o/p pdu's as either ueCb/RbCb/RxEnt is already deleted - due to reestablishment or other scenario */ - PJ_FREE_BUF(opSdu); - } - - jobNum++; - - if(jobNum > (PJ_MS_MAX_JOBS_IN_QUEUE + 2)) - { - RLOG1(L_ERROR, "Num Jobs in PjUlSpaccTrigger exceeds %ld," - " hence aborting!!!!", jobNum); - break; - } - } -} - - -/** - * @brief This function is used to deInit the CipherQ - * - * @details - * - * @param[in] - Void - - * - * @return - Void - */ -#ifdef ANSI -PUBLIC Void pjSpaccDeInitCiphQ(Void) -#else -PUBLIC Void pjSpaccDeInitCiphQ(Void) -#endif -{ -#ifdef INTEL_NATIVE_SPACC - pjMsNativeSpaccDeInitCiphQ(); -#else - pjMsSpaccDeInitCiphQ(); -#endif - RETVOID; -} - -/** - * @brief This function is used to deInit the DeCipherQ - * - * @details - * - * @param[in] - Void - - * - * @return - Void - */ -#ifdef ANSI -PUBLIC Void pjSpaccDeInitDeCipherQ(Void) -#else -PUBLIC Void pjSpaccDeInitDeCipherQ(Void) -#endif -{ -#ifdef INTEL_NATIVE_SPACC - pjMsNativeSpaccDeInitDeCiphQ(); -#else - /*pjMsSpaccDeInitCiphQ();*/ - pjMsSpaccDeInitDeCipherQ(); -#endif - RETVOID; -} - -#endif - -/** - * - * @brief - * - * pjUlBatchProcSplit- Process rbuf messages - * - * @return S16 - * -# ROK - */ -#if defined(L2_L3_SPLIT) && defined(ICC_RECV_TSK_RBUF) -#ifdef ANSI -PUBLIC S16 pjUlBatchProcSplit -( -Void -) -#else -PUBLIC S16 pjUlBatchProcSplit() -Void; -#endif -{ - S16 ret1; -/* Read from Ring Buffer and process PDCP packets */ - Void *elmIndx = NULLP; - RxmBufReq *datInd = NULLP; - elmIndx = SRngGetRIndx(SS_RNG_BUF_RX_TO_ULPDCP); - while(NULLP != elmIndx) - { - datInd = (RxmBufReq *)elmIndx; - if(datInd->mBuf != NULLP) - { - ret1 = cmUnpkKwuDatInd(PjLiKwuDatInd, &datInd->pst, datInd->mBuf); - if(ret1 != ROK) - { -#if (ERRCLASS & ERRCLS_DEBUG) - SLogError(ENTPJ, 0, SFndProcId(), - __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG, - (ErrVal)EPJXXX, (ErrVal)ERRZERO, "UNPACK ERROR\n"); -#endif /* (ERRCLASS & ERRCLS_DEBUG) */ - } - } - else - { -#if (ERRCLASS & ERRCLS_DEBUG) - SLogError(ENTPJ, 0, SFndProcId(), - __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG, - (ErrVal)EPJXXX, (ErrVal)ERRZERO, "pjUlBatchProcSplit: mBuf NULL\n"); -#endif /* (ERRCLASS & ERRCLS_DEBUG) */ - if(datInd->mBuf) - cmUnpkKwuDatInd(PjLiKwuDatInd, &datInd->pst, datInd->mBuf); - } - - SsRngInfoTbl[SS_RNG_BUF_RX_TO_ULPDCP].nPktProc++;;//Number of pkt processed in tti - datInd->mBuf = NULLP; - SRngIncrRIndx(SS_RNG_BUF_RX_TO_ULPDCP); - - if((elmIndx = SRngGetRIndx(SS_RNG_BUF_RX_TO_ULPDCP)) == NULLP) - break; - } - - RETVALUE(ROK); -} -#endif - -#endif /* PTPJLIB */ - - -#ifdef ANSI -PUBLIC S16 PjLibObdIntCloseReq -( -Void *intCxtId -) -#else -PUBLIC S16 PjLibObdIntCloseReq(*intCxtId) -Void *intCxtId; -#endif -{ - TRC3(PjLibObdIntCloseReq) - RETVALUE(ROK); -} - - - - -/********************************************************************30** - End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_ptmi.c b/src/5gnrpdcp/pj_ptmi.c deleted file mode 100755 index 9ec0be970..000000000 --- a/src/5gnrpdcp/pj_ptmi.c +++ /dev/null @@ -1,607 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: PDCP Layer Management interface - - Type: C source file - - Desc: This file contains source code for RLC layer management - interface primitives. It includes the definition of the - following functions and their portable function - definitions. - -- PjMiLpjCfgCfm - -- PjMiLpjCntrlCfm - -- PjMiLpjStaInd - - - File: pj_ptmi.c - -*********************************************************************21*/ - - -/* header (.h) include files */ -#include "envopt.h" /* environment options */ -#include "envdep.h" /* environment dependent */ -#include "envind.h" /* environment independent */ - -#include "gen.h" /* general */ -#include "ssi.h" /* system services */ -#include "cm5.h" /* common timer defines */ -#include "cm_tkns.h" /* common tokens defines */ -#include "cm_mblk.h" /* common memory allocation library defines */ -#include "cm_llist.h" /* common link list defines */ -#include "cm_hash.h" /* common hash list defines */ -#include "cm_lte.h" /* common LTE defines */ -#include "lpj.h" /* LPJ defines */ - - -/* extern (.x) include files */ -#include "gen.x" /* general */ -#include "ssi.x" /* system services */ - -#include "cm5.x" /* common timer library */ -#include "cm_tkns.x" /* common tokens */ -#include "cm_mblk.x" /* common memory allocation */ -#include "cm_llist.x" /* common link list */ -#include "cm_hash.x" /* common hash list */ -#include "cm_lte.x" /* common LTE includes */ -#include "cm_lib.x" /* common memory allocation library */ -#include "lpj.x" /* LPJ */ - - -/* local defines */ -#ifndef LCPJMILPJ -#define PTPJLPJ -#endif - -#ifndef SM -#define PTPJLPJ -#endif - - -#ifdef PTPJLPJ - -EXTERN S16 PtMiLpjCfgCfm ARGS((Pst * pst, PjMngmt * cfgCfm)); - -EXTERN S16 PtMiLpjCntrlCfm ARGS((Pst * pst, PjMngmt * cntlCfm)); - -EXTERN S16 PtMiLpjStaInd ARGS((Pst * pst, PjMngmt * staInd)); - -EXTERN S16 PtMiLpjStaCfm ARGS((Pst * pst, PjMngmt * staCfm)); - -EXTERN S16 PtMiLpjStsCfm ARGS((Pst * pst, Action actn, PjMngmt * stsCfm)); - -EXTERN S16 PtMiLpjTrcInd ARGS((Pst * pst, PjMngmt * trc, Buffer * mBuf)); - -/* kw005.201 added support for L2 Measurement */ -#ifdef LTE_L2_MEAS -EXTERN S16 PtMiLpjL2MeasCfm ARGS((Pst *pst, PjL2MeasCfmEvt *measEvt)); -PRIVATE S16 PtMiLpjL2MeasStopCfm ARGS((Pst *pst, U16 measType,U8 status)); -#endif /* LTE_L2_MEAS */ - -#endif /*--#ifdef PTPJLPJ--*/ - -/********************************************************************* - * Primitives for LPJ interface - ********************************************************************/ -PRIVATE CONSTANT LpjCfgCfm PjMiLpjCfgCfmMt[] = -{ -#ifdef LCPJMILPJ - cmPkLpjCfgCfm, -#else - PtMiLpjCfgCfm, -#endif -#ifdef SM - SmMiLpjCfgCfm, -#else - PtMiLpjCfgCfm, -#endif -}; - - -PRIVATE CONSTANT LpjCntrlCfm PjMiLpjCntrlCfmMt[] = -{ -#ifdef LCPJMILPJ - cmPkLpjCntrlCfm, -#else - PtMiLpjCntrlCfm, -#endif -#ifdef SM - SmMiLpjCntrlCfm, -#else - PtMiLpjCntrlCfm, -#endif -}; - - -PRIVATE CONSTANT LpjStaInd PjMiLpjStaIndMt[] = -{ -#ifdef LCPJMILPJ - cmPkLpjStaInd, -#else - PtMiLpjStaInd, -#endif -#ifdef SM - SmMiLpjStaInd, -#else - PtMiLpjStaInd, -#endif -}; - - -PRIVATE CONSTANT LpjStaCfm PjMiLpjStaCfmMt[] = -{ -#ifdef LCPJMILPJ - cmPkLpjStaCfm, -#else - PtMiLpjStaCfm, -#endif -#ifdef SM - SmMiLpjStaCfm, -#else - PtMiLpjStaCfm, -#endif -}; - - -PRIVATE CONSTANT LpjStsCfm PjMiLpjStsCfmMt[] = -{ -#ifdef LCPJMILPJ - cmPkLpjStsCfm, -#else - PtMiLpjStsCfm, -#endif -#ifdef SM - SmMiLpjStsCfm, -#else - PtMiLpjStsCfm, -#endif -}; - - -PRIVATE CONSTANT LpjTrcInd PjMiLpjTrcIndMt[] = -{ -#ifdef LCPJMILPJ - cmPkLpjTrcInd, -#else - PtMiLpjTrcInd, -#endif -#ifdef SM - SmMiLpjTrcInd, -#else - PtMiLpjTrcInd, -#endif -}; - -/* kw005.201 added support for L2 Measurement */ -#ifdef LTE_L2_MEAS -PRIVATE CONSTANT LpjL2MeasCfm PjMiLpjL2MeasCfmMt[] = -{ -#ifdef LCPJMILPJ - cmPkLpjL2MeasCfm, -#else - PtMiLpjL2MeasCfm, -#endif -#ifdef SM - SmMiLpjL2MeasCfm, -#else - PtMiLpjL2MeasCfm, -#endif -}; -PRIVATE CONSTANT LpjL2MeasStopCfm PjMiLpjL2MeasStopCfmMt[] = -{ -#ifdef LCPJMILPJ - cmPkLpjL2MeasStopCfm, -#else - PtMiLpjL2MeasStopCfm, -#endif -#ifdef SM - SmMiLpjL2MeasStopCfm, -#else - PtMiLpjL2MeasStopCfm, -#endif -}; -#endif /* LTE_L2_MEAS */ - -/**************************************************************************** - * LPJ Interface Mt functions - ***************************************************************************/ -#ifdef ANSI -PUBLIC S16 PjMiLpjCfgCfm -( -Pst * pst, -PjMngmt * cfgCfm -) -#else -PUBLIC S16 PjMiLpjCfgCfm(pst, cfgCfm) -Pst * pst; -PjMngmt * cfgCfm; -#endif -{ - - TRC3(PjMiLpjCfgCfm) - - (*PjMiLpjCfgCfmMt[pst->selector])(pst, cfgCfm); - - RETVALUE(ROK); - -} - - -#ifdef ANSI -PUBLIC S16 PjMiLpjCntrlCfm -( -Pst * pst, -PjMngmt * cntlCfm -) -#else -PUBLIC S16 PjMiLpjCntrlCfm(pst, cntlCfm) -Pst * pst; -PjMngmt * cntlCfm; -#endif -{ - - TRC3(PjMiLpjCntrlCfm) - - (*PjMiLpjCntrlCfmMt[pst->selector])(pst, cntlCfm); - - RETVALUE(ROK); - -} - - -#ifdef ANSI -PUBLIC S16 PjMiLpjStaInd -( -Pst * pst, -PjMngmt * staInd -) -#else -PUBLIC S16 PjMiLpjStaInd(pst, staInd) -Pst * pst; -PjMngmt * staInd; -#endif -{ - - TRC3(PjMiLpjStaInd) - - (*PjMiLpjStaIndMt[pst->selector])(pst, staInd); - - RETVALUE(ROK); - -} - - -#ifdef ANSI -PUBLIC S16 PjMiLpjStaCfm -( -Pst * pst, -PjMngmt * staCfm -) -#else -PUBLIC S16 PjMiLpjStaCfm(pst, staCfm) -Pst * pst; -PjMngmt * staCfm; -#endif -{ - - TRC3(PjMiLpjStaCfm) - - (*PjMiLpjStaCfmMt[pst->selector])(pst, staCfm); - - RETVALUE(ROK); - -} - - -#ifdef ANSI -PUBLIC S16 PjMiLpjStsCfm -( -Pst * pst, -Action actn, -PjMngmt * stsCfm -) -#else -PUBLIC S16 PjMiLpjStsCfm(pst, actn, stsCfm) -Pst * pst; -Action actn; -PjMngmt * stsCfm; -#endif -{ - - TRC3(PjMiLpjStsCfm) - - (*PjMiLpjStsCfmMt[pst->selector])(pst, actn, stsCfm); - - RETVALUE(ROK); - -} - - -#ifdef ANSI -PUBLIC S16 PjMiLpjTrcInd -( -Pst * pst, -PjMngmt * trc, -Buffer * mBuf -) -#else -PUBLIC S16 PjMiLpjTrcInd(pst, trc, mBuf) -Pst * pst; -PjMngmt * trc; -Buffer * mBuf; -#endif -{ - - TRC3(PjMiLpjTrcInd) - - (*PjMiLpjTrcIndMt[pst->selector])(pst, trc, mBuf); - - RETVALUE(ROK); - -} - -/* kw005.201 added support for L2 Measurement */ -#ifdef LTE_L2_MEAS -#ifdef ANSI -PUBLIC S16 PjMiLpjL2MeasCfm -( -Pst * pst, -PjL2MeasCfmEvt *measEvt -) -#else -PUBLIC S16 PjMiLpjL2MeasCfm(pst, trc, mBuf) -Pst * pst; -PjL2MeasCfmEvt *measEvt; -#endif -{ - - TRC3(PjMiLpjL2MeasCfm) - - (*PjMiLpjL2MeasCfmMt[pst->selector])(pst, measEvt); - - RETVALUE(ROK); - -} -#ifdef ANSI -PUBLIC S16 PjMiLpjL2MeasStopCfm -( -Pst *pst, -U16 measType, -U8 status -) -#else -PUBLIC S16 PjMiLpjL2MeasStopCfm(pst, measType,status) -Pst *pst; -U16 measType; -U8 status; -#endif -{ - - TRC3(PjMiLpjL2MeasStopCfm) - - (*PjMiLpjL2MeasStopCfmMt[pst->selector])(pst, measType,status); - - RETVALUE(ROK); - -} -#endif /* LTE_L2_MEAS */ - - -#ifdef PTPJLPJ - - -#ifdef ANSI -PUBLIC S16 PtMiLpjCfgCfm -( -Pst * pst, -PjMngmt * cfgCfm -) -#else -PUBLIC S16 PtMiLpjCfgCfm(pst, cfgCfm) -Pst * pst; -PjMngmt * cfgCfm; -#endif -{ - - TRC3(PtMiLpjCfgCfm) - - UNUSED(pst); - UNUSED(cfgCfm); - - RETVALUE(ROK); - -} - - -#ifdef ANSI -PUBLIC S16 PtMiLpjCntrlCfm -( -Pst * pst, -PjMngmt * cntlCfm -) -#else -PUBLIC S16 PtMiLpjCntrlCfm(pst, cntlCfm) -Pst * pst; -PjMngmt * cntlCfm; -#endif -{ - - TRC3(PtMiLpjCntrlCfm) - - UNUSED(pst); - UNUSED(cntlCfm); - - RETVALUE(ROK); - -} - - -#ifdef ANSI -PUBLIC S16 PtMiLpjStaInd -( -Pst * pst, -PjMngmt * staInd -) -#else -PUBLIC S16 PtMiLpjStaInd(pst, staInd) -Pst * pst; -PjMngmt * staInd; -#endif -{ - - TRC3(PtMiLpjStaInd) - - UNUSED(pst); - UNUSED(staInd); - - RETVALUE(ROK); - -} - - -#ifdef ANSI -PUBLIC S16 PtMiLpjStaCfm -( -Pst * pst, -PjMngmt * staCfm -) -#else -PUBLIC S16 PtMiLpjStaCfm(pst, staCfm) -Pst * pst; -PjMngmt * staCfm; -#endif -{ - - TRC3(PtMiLpjStaCfm) - - UNUSED(pst); - UNUSED(staCfm); - - RETVALUE(ROK); - -} - - -#ifdef ANSI -PUBLIC S16 PtMiLpjStsCfm -( -Pst * pst, -Action actn, -PjMngmt * stsCfm -) -#else -PUBLIC S16 PtMiLpjStsCfm(pst, actn, stsCfm) -Pst * pst; -Action actn; -PjMngmt * stsCfm; -#endif -{ - - TRC3(PtMiLpjStsCfm) - - UNUSED(pst); - UNUSED(actn); - UNUSED(stsCfm); - - RETVALUE(ROK); - -} - - -#ifdef ANSI -PUBLIC S16 PtMiLpjTrcInd -( -Pst * pst, -PjMngmt * trc, -Buffer * mBuf -) -#else -PUBLIC S16 PtMiLpjTrcInd(pst, trc, mBuf) -Pst * pst; -PjMngmt * trc; -Buffer * mBuf; -#endif -{ - - TRC3(PtMiLpjTrcInd) - - UNUSED(pst); - UNUSED(trc); - UNUSED(mBuf); - - RETVALUE(ROK); - -} - -/* kw005.201 added support for L2 Measurement */ -#ifdef LTE_L2_MEAS -#ifdef ANSI -PUBLIC S16 PtMiLpjL2MeasCfm -( -Pst * pst, -PjL2MeasCfmEvt * measEvt -) -#else -PUBLIC S16 PtMiLpjL2MeasCfm(pst, measEvt) -Pst * pst; -PjL2MeasCfmEvt * measEvt; -#endif -{ - - TRC3(PtMiLpjL2MeasCfm) - - UNUSED(pst); - UNUSED(measEvt); - - RETVALUE(ROK); - -} -#ifdef ANSI -PRIVATE S16 PtMiLpjL2MeasStopCfm -( -Pst * pst, -U16 measType, -U8 status -) -#else -PRIVATE S16 PtMiLpjL2MeasStopCfm(pst, measType,status) -Pst * pst; -U16 measType; -U8 status; -#endif -{ - - TRC3(PtMiLpjL2MeasStopCfm) - - UNUSED(pst); - UNUSED(measType); - UNUSED(status); - - RETVALUE(ROK); - -} -#endif /* LTE_L2_MEAS */ -#endif /*--ifdef PTPJLPJ--*/ - -/********************************************************************30** - - End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_ptui.c b/src/5gnrpdcp/pj_ptui.c deleted file mode 100755 index 8be4a74c2..000000000 --- a/src/5gnrpdcp/pj_ptui.c +++ /dev/null @@ -1,1189 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: LTE-PDCP Layer - Upper Interface - - Type: C file - - Desc: C source code for the upper interface of LTE-PDCP - - File: pj_ptui.c - -*********************************************************************21*/ - -/** @file pj_ptui.c -@brief PDCP Upper Interface -*/ - - -/* header (.h) include files */ -#include "envopt.h" /* environment options */ -#include "envdep.h" /* environment dependent */ -#include "envind.h" /* environment independent */ - -#include "gen.h" /* general */ -#include "ssi.h" /* system services */ -#include "cm5.h" /* common timer defines */ -#include "cm_tkns.h" /* common tokens defines */ -#include "cm_mblk.h" /* common memory allocation library defines */ -#include "cm_llist.h" /* common link list defines */ -#include "cm_hash.h" /* common hash list defines */ -#include "cm_lte.h" /* common LTE defines */ -#include "cpj.h" /* CPJ defines */ -#include "pju.h" /* PJU defines */ -#include "lpj.h" - -#include "pj_err.h" -#include "pj_env.h" /* RLC environment options */ - -/* extern (.x) include files */ -#include "gen.x" /* general */ -#include "ssi.x" /* system services */ - -#include "cm5.x" /* common timer library */ -#include "cm_tkns.x" /* common tokens */ -#include "cm_mblk.x" /* common memory allocation */ -#include "cm_llist.x" /* common link list */ -#include "cm_hash.x" /* common hash list */ -#include "cm_lte.x" /* common LTE includes */ -#include "cm_lib.x" /* common memory allocation library */ -#include "cpj.x" /* CPJ defines */ -#include "pju.x" /* PJU defines */ -#include "lpj.x" /* LPJ defines */ - - -#if !(defined(LCPJUICPJ) && defined(NH)) -#define PTPJCPJ -#endif - -#if !(defined(LCPJUIPJU) && (defined(PX))) || !(defined(NH)) -#define PTPJPJU -#endif - -#ifdef __cplusplus -EXTERN "C" { -#endif /* __cplusplus */ - - -/********************************************************************* - * Forward Declartion for CPJ Porting Functions - ********************************************************************/ -#ifdef PTPJCPJ - -EXTERN S16 PtUiCpjBndCfm ARGS((Pst * pst, SuId suId, U8 status)); - -EXTERN S16 PtUiCpjCfgCfm ARGS((Pst * pst, SuId suId, CpjCfgCfmInfo * cfgCfm)); - -EXTERN S16 PtUiCpjReEstCfm ARGS((Pst * pst, SuId suId, CpjReEstCfmInfo * reEstCfm)); - -EXTERN S16 PtUiCpjSecCfgCfm ARGS((Pst * pst, SuId suId, CpjSecCfgCfmInfo * secCfgCfm)); - -EXTERN S16 PtUiCpjUeIdChgCfm ARGS((Pst * pst, SuId suId, U32 transId, CpjUeInfo * ueInfo, CmStatus status)); - -EXTERN S16 PtUiCpjCountCfm ARGS((Pst * pst, SuId suId, CpjCountCfmInfo * countCfm)); - -EXTERN S16 PtUiCpjSduStaCfm ARGS((Pst * pst, SuId suId, CpjSduStaCfmInfo * staCfm)); -EXTERN S16 PtUiCpjKdfCfm ARGS((Pst* pst, SuId suId, CpjCfgTransId transId, CpjKdfCfmInfo *kdfCfmInf, -U8 status -)); -EXTERN S16 PtUiCpjDatResumeCfm ARGS(( Pst *pst, SuId suId, CpjDatResumeCfmInfo *datResumeCfm)); -#endif /* PTPJCPJ */ - - -/********************************************************************* - * Forward Declartion for PJU Porting Functions - ********************************************************************/ -#ifdef PTPJPJU - -EXTERN S16 PtUiPjuBndReq ARGS((Pst* pst, SpId spId, SuId suId)); - -EXTERN S16 PtUiPjuBndCfm ARGS((Pst* pst, SuId suId, U8 status)); - -EXTERN S16 PtUiPjuDatCfm ARGS((Pst* pst, SuId suId, CmLtePdcpId * pdcpId, PjuDatCfmInfo * datCfm)); - -EXTERN S16 PtUiPjuDatInd ARGS((Pst* pst, SuId suId, CmLtePdcpId * pdcpId, Buffer * mBuf)); - -EXTERN S16 PtUiPjuStaInd ARGS((Pst* pst, SuId suId, CmLtePdcpId * pdcpId, PjuStaIndInfo * staInd, Buffer *mBuf)); - -EXTERN S16 PtUiPjuDatFwdInd ARGS((Pst* pst, SuId suId, CmLtePdcpId * pdcpId, PjuDatFwdIndInfo * datFwdInd)); -#endif /*--#ifdef PTPJPJU--*/ - - -/********************************************************************* - * Primitives for CPJ interface - ********************************************************************/ -PRIVATE CONSTANT CpjBndCfm PjUiCpjBndCfmMt[] = -{ -#ifdef LCPJUICPJ - cmPkCpjBndCfm, -#else - PtUiCpjBndCfm, -#endif -#ifdef NH - NhLiCpjBndCfm, -#else - PtUiCpjBndCfm, -#endif -}; - - -PRIVATE CONSTANT CpjCfgCfm PjUiCpjCfgCfmMt[] = -{ -#ifdef LCPJUICPJ - cmPkCpjCfgCfm, -#else - PtUiCpjCfgCfm, -#endif -#ifdef NH - NhLiCpjCfgCfm, -#else - PtUiCpjCfgCfm, -#endif -}; - - -PRIVATE CONSTANT CpjReEstCfm PjUiCpjReEstCfmMt[] = -{ -#ifdef LCPJUICPJ - cmPkCpjReEstCfm, -#else - PtUiCpjReEstCfm, -#endif -#ifdef NH - NhLiCpjReEstCfm, -#else - PtUiCpjReEstCfm, -#endif -}; - - -PRIVATE CONSTANT CpjSecCfgCfm PjUiCpjSecCfgCfmMt[] = -{ -#ifdef LCPJUICPJ - cmPkCpjSecCfgCfm, -#else - PtUiCpjSecCfgCfm, -#endif -#ifdef NH - NhLiCpjSecCfgCfm, -#else - PtUiCpjSecCfgCfm, -#endif -}; - - -PRIVATE CONSTANT CpjUeIdChgCfm PjUiCpjUeIdChgCfmMt[] = -{ -#ifdef LCPJUICPJ - cmPkCpjUeIdChgCfm, -#else - PtUiCpjUeIdChgCfm, -#endif -#ifdef NH - NhLiCpjUeIdChgCfm, -#else - PtUiCpjUeIdChgCfm, -#endif -}; - - -PRIVATE CONSTANT CpjCountCfm PjUiCpjCountCfmMt[] = -{ -#ifdef LCPJUICPJ - cmPkCpjCountCfm, -#else - PtUiCpjCountCfm, -#endif -#ifdef NH - NhLiCpjCountCfm, -#else - PtUiCpjCountCfm, -#endif -}; - - -PRIVATE CONSTANT CpjSduStaCfm PjUiCpjSduStaCfmMt[] = -{ -#ifdef LCPJUICPJ - cmPkCpjSduStaCfm, -#else - PtUiCpjSduStaCfm, -#endif -#ifdef NH - NhLiCpjSduStaCfm, -#else - PtUiCpjSduStaCfm, -#endif -}; - -PRIVATE CONSTANT CpjDatResumeCfm PjUiCpjDatResumeCfmMt[] = -{ -#ifdef LCPJUICPJ - cmPkCpjDatResumeCfm, -#else - PtUiCpjDatResumeCfm, -#endif -#ifdef NH - NhLiCpjDatResumeCfm, -#else - PtUiCpjDatResumeCfm, -#endif -}; - -/** @brief This API is used to receive a Config confirm from PDCP to - * Application. - */ -PRIVATE CONSTANT CpjKdfCfm PjUiCpjKdfCfmMt[] = -{ -#ifdef LCPJUICPJ - cmPkCpjKdfCfm, -#else - PtUiCpjKdfCfm, -#endif -#ifdef NH - PtUiCpjKdfCfm -#else - PtUiCpjKdfCfm -#endif - -}; - - -/**************************************************************************** - * CPJ Interface Mt functions - ***************************************************************************/ -#ifdef PJ -#ifdef ANSI -PUBLIC S16 PjUiCpjBndCfm -( -Pst * pst, -SuId suId, -U8 status -) -#else -PUBLIC S16 PjUiCpjBndCfm(pst, suId, status) -Pst * pst; -SuId suId; -U8 status; -#endif -{ - - TRC3(PjUiCpjBndCfm) - - (*PjUiCpjBndCfmMt[pst->selector])(pst, suId, status); - - RETVALUE(ROK); -} - -#ifdef ANSI -PUBLIC S16 PjUiCpjCfgCfm -( -Pst * pst, -SuId suId, -CpjCfgCfmInfo * cfgCfm -) -#else -PUBLIC S16 PjUiCpjCfgCfm(pst, suId, cfgCfm) -Pst * pst; -SuId suId; -CpjCfgCfmInfo * cfgCfm; -#endif -{ - - TRC3(PjUiCpjCfgCfm) - - (*PjUiCpjCfgCfmMt[pst->selector])(pst, suId, cfgCfm); - - RETVALUE(ROK); -} - -#ifdef ANSI -PUBLIC S16 PjUiCpjReEstCfm -( -Pst * pst, -SuId suId, -CpjReEstCfmInfo * reEstCfm -) -#else -PUBLIC S16 PjUiCpjReEstCfm(pst, suId, reEstCfm) -Pst * pst; -SuId suId; -CpjReEstCfmInfo * reEstCfm; -#endif -{ - - TRC3(PjUiCpjReEstCfm) - - (*PjUiCpjReEstCfmMt[pst->selector])(pst, suId, reEstCfm); - - RETVALUE(ROK); -} - -#ifdef ANSI -PUBLIC S16 PjUiCpjSecCfgCfm -( -Pst * pst, -SuId suId, -CpjSecCfgCfmInfo * secCfgCfm -) -#else -PUBLIC S16 PjUiCpjSecCfgCfm(pst, suId, secCfgCfm) -Pst * pst; -SuId suId; -CpjSecCfgCfmInfo * secCfgCfm; -#endif -{ - - TRC3(PjUiCpjSecCfgCfm) - - (*PjUiCpjSecCfgCfmMt[pst->selector])(pst, suId, secCfgCfm); - - RETVALUE(ROK); -} - -#ifdef ANSI -PUBLIC S16 PjUiCpjUeIdChgCfm -( -Pst * pst, -SuId suId, -U32 transId, -CpjUeInfo * ueInfo, -CmStatus status -) -#else -PUBLIC S16 PjUiCpjUeIdChgCfm(pst, suId, transId, ueInfo, status) -Pst * pst; -SuId suId; -U32 transId; -CpjUeInfo * ueInfo; -CmStatus status; -#endif -{ - - TRC3(PjUiCpjUeIdChgCfm) - - (*PjUiCpjUeIdChgCfmMt[pst->selector])(pst, suId, transId, ueInfo, status); - - RETVALUE(ROK); -} - -#ifdef ANSI -PUBLIC S16 PjUiCpjCountCfm -( -Pst * pst, -SuId suId, -CpjCountCfmInfo * countCfm -) -#else -PUBLIC S16 PjUiCpjCountCfm(pst, suId, countCfm) -Pst * pst; -SuId suId; -CpjCountCfmInfo * countCfm; -#endif -{ - - TRC3(PjUiCpjCountCfm) - - (*PjUiCpjCountCfmMt[pst->selector])(pst, suId, countCfm); - - RETVALUE(ROK); -} - -#ifdef ANSI -PUBLIC S16 PjUiCpjSduStaCfm -( -Pst * pst, -SuId suId, -CpjSduStaCfmInfo * staCfm -) -#else -PUBLIC S16 PjUiCpjSduStaCfm(pst, suId, staCfm) -Pst * pst; -SuId suId; -CpjSduStaCfmInfo * staCfm; -#endif -{ - - TRC3(PjUiCpjSduStaCfm) - - (*PjUiCpjSduStaCfmMt[pst->selector])(pst, suId, staCfm); - - RETVALUE(ROK); -} - -#ifdef ANSI -PUBLIC S16 PjUiCpjDatResumeCfm -( -Pst *pst, -SuId suId, -CpjDatResumeCfmInfo *datResCfm -) -#else -PUBLIC S16 PjUiCpjDatResumeCfm(pst, suId, datResCfm) -Pst *pst; -SuId suId; -CpjDatResumeCfmInfo *datResCfm; -#endif -{ - - TRC3(PjUiCpjDataResumeCfm) - - (*PjUiCpjDatResumeCfmMt[pst->selector])(pst, suId, datResCfm); - - RETVALUE(ROK); -} -/** -* @brief This API is used to receive a Bind confirm from PDCP to Application. -* -* @details -* -* Function : PjUiCpjKdfCfm -* -* @param[in] pst - Post structure -* @param[in] suId - Service User Id -* @param[in] transId - Transaction Id -* @param[in] kdfCfmInf - Generated keys -* @param[in] status - status of KDF request -* @return S16 -* -# ROK -**/ -#ifdef ANSI -PUBLIC S16 PjUiCpjKdfCfm -( -Pst* pst, -SuId suId, -CpjCfgTransId transId, -CpjKdfCfmInfo *kdfCfmInf, -U8 status -) -#else -PUBLIC S16 PjUiCpjKdfCfm(pst, suId, transId, status) -Pst* pst; -SuId suId; -CpjCfgTransId transId; -CpjKdfCfmInfo *kdfCfmInf; -U8 status; -#endif -{ - - TRC3(PtUiCpjCfgCfm); - - (*PjUiCpjKdfCfmMt[pst->selector])(pst, suId, transId,kdfCfmInf, status); - - RETVALUE(ROK); -} -#endif /*--ifdef PJ--*/ - - -/************************************************************************* - * CPJ Porting Functions - ************************************************************************/ -#ifdef PTPJCPJ - -#ifdef ANSI -PUBLIC S16 PtUiCpjBndCfm -( -Pst * pst, -SuId suId, -U8 status -) -#else -PUBLIC S16 PtUiCpjBndCfm(pst, suId, status) -Pst * pst; -SuId suId; -U8 status; -#endif -{ - - TRC3(PtUiCpjBndCfm) - - UNUSED(pst); - UNUSED(suId); - UNUSED(status); - - RETVALUE(ROK); - -} - - -#ifdef ANSI -PUBLIC S16 PtUiCpjCfgCfm -( -Pst * pst, -SuId suId, -CpjCfgCfmInfo * cfgCfm -) -#else -PUBLIC S16 PtUiCpjCfgCfm(pst, suId, cfgCfm) -Pst * pst; -SuId suId; -CpjCfgCfmInfo * cfgCfm; -#endif -{ - - TRC3(PtUiCpjCfgCfm) - - UNUSED(pst); - UNUSED(suId); - UNUSED(cfgCfm); - - RETVALUE(ROK); - -} - - -#ifdef ANSI -PUBLIC S16 PtUiCpjReEstCfm -( -Pst * pst, -SuId suId, -CpjReEstCfmInfo * reEstCfm -) -#else -PUBLIC S16 PtUiCpjReEstCfm(pst, suId, reEstCfm) -Pst * pst; -SuId suId; -CpjReEstCfmInfo *reEstCfm; -#endif -{ - - TRC3(PtUiCpjReEstCfm) - - UNUSED(pst); - UNUSED(suId); - UNUSED(reEstCfm); - - RETVALUE(ROK); - -} - - -#ifdef ANSI -PUBLIC S16 PtUiCpjSecCfgCfm -( -Pst * pst, -SuId suId, -CpjSecCfgCfmInfo * secCfgCfm -) -#else -PUBLIC S16 PtUiCpjSecCfgCfm(pst, suId, secCfgCfm) -Pst * pst; -SuId suId; -CpjSecCfgCfmInfo * secCfgCfm; -#endif -{ - - TRC3(PtUiCpjSecCfgCfm) - - UNUSED(pst); - UNUSED(suId); - UNUSED(secCfgCfm); - - RETVALUE(ROK); - -} - - -#ifdef ANSI -PUBLIC S16 PtUiCpjUeIdChgCfm -( -Pst * pst, -SuId suId, -U32 transId, -CpjUeInfo * ueInfo, -CmStatus status -) -#else -PUBLIC S16 PtUiCpjUeIdChgCfm(pst, suId, transId, ueInfo, status) -Pst * pst; -SuId suId; -U32 transId; -CpjUeInfo * ueInfo; -CmStatus status; -#endif -{ - - TRC3(PtUiCpjUeIdChgCfm) - - UNUSED(pst); - UNUSED(suId); - UNUSED(transId); - UNUSED(ueInfo); - UNUSED(status); - - RETVALUE(ROK); - -} - - -#ifdef ANSI -PUBLIC S16 PtUiCpjCountCfm -( -Pst * pst, -SuId suId, -CpjCountCfmInfo * countCfm -) -#else -PUBLIC S16 PtUiCpjCountCfm(pst, suId, countCfm) -Pst * pst; -SuId suId; -CpjCountCfmInfo * countCfm; -#endif -{ - - TRC3(PtUiCpjCountCfm) - - UNUSED(pst); - UNUSED(suId); - UNUSED(countCfm); - - RETVALUE(ROK); - -} - - -#ifdef ANSI -PUBLIC S16 PtUiCpjSduStaCfm -( -Pst * pst, -SuId suId, -CpjSduStaCfmInfo * staCfm -) -#else -PUBLIC S16 PtUiCpjSduStaCfm(pst, suId, staCfm) -Pst * pst; -SuId suId; -CpjSduStaCfmInfo * staCfm; -#endif -{ - - TRC3(PtUiCpjSduStaCfm) - - UNUSED(pst); - UNUSED(suId); - UNUSED(staCfm); - - RETVALUE(ROK); - -} - -#ifdef ANSI -PUBLIC S16 PtUiCpjDatResumeCfm -( -Pst *pst, -SuId suId, -CpjDatResumeCfmInfo *datResumeCfm -) -#else -PUBLIC S16 PtUiCpjDatResumeCfm(pst, suId, dataResCfm) -Pst *pst; -SuId suId; -CpjDataResumeCfmInfo *datResumeCfm; -#endif -{ - - TRC3(PtUiCpjDataResCfm) - - UNUSED(pst); - UNUSED(suId); - UNUSED(datResumeCfm); - - RETVALUE(ROK); - -} - -/** -* @brief This is a portable API for KDF function -* -* @details -* -* Function : PtUiCpjKdfCfm -* -* @param[in] pst - Post structure -* @param[in] suId - Service User Id -* @param[in] transId - Transaction Id -* @param[in] kdfCfmInf - Generated keys -* @param[in] status - status of KDF request -* @return S16 -* -# ROK -**/ -#ifdef ANSI -PUBLIC S16 PtUiCpjKdfCfm -( -Pst* pst, -SuId suId, -CpjCfgTransId transId, -CpjKdfCfmInfo *kdfCfmInf, -U8 status -) -#else -PUBLIC S16 PtUiCpjKdfCfm(pst, suId, transId, status) -Pst* pst; -SuId suId; -CpjCfgTransId transId; -CpjKdfCfmInfo *kdfCfmInf; -U8 status; -#endif -{ - - TRC3(PtUiCpjKdfCfm); - - UNUSED(pst); - UNUSED(suId); - UNUSED(transId); - UNUSED(kdfCfmInf); - UNUSED(status); - - RETVALUE(ROK); -} -#endif /*--ifdef PTPJCPJ--*/ - - -/********************************************************************* - * Primitives for PJU interface - ********************************************************************/ - -PRIVATE CONSTANT PjuBndCfm PjUiPjuBndCfmMt[] = -{ -#ifdef LCPJUIPJU - cmPkPjuBndCfm, -#else - PtUiPjuBndCfm, -#endif -#ifdef NH - NhLiPjuBndCfm, -#else - PtUiPjuBndCfm, -#endif -#ifdef PX - PxLiPjuBndCfm, -#else - PtUiPjuBndCfm, -#endif -}; - - -PRIVATE CONSTANT PjuDatCfm PjUiPjuDatCfmMt[] = -{ -#ifdef LCPJUIPJU - cmPkPjuDatCfm, -#else - PtUiPjuDatCfm, -#endif -#ifdef NH - NhLiPjuDatCfm, -#else - PtUiPjuDatCfm, -#endif -#ifdef PX - PxLiPjuDatCfm, -#else - PtUiPjuDatCfm, -#endif -}; - - -PRIVATE CONSTANT PjuDatInd PjUiPjuDatIndMt[] = -{ -#ifdef SS_RBUF -#ifndef TENB_ACC -#ifdef LCPJUIPJU - cmPkFpPjuDatInd, -#else - PtUiPjuDatInd, -#endif -#endif -#else -#ifdef LCPJUIPJU - cmPkPjuDatInd, -#else - PtUiPjuDatInd, -#endif -#endif -#ifdef NH - NhLiPjuDatInd, -#else - PtUiPjuDatInd, -#endif -#ifdef PX - PxLiPjuDatInd, -#else - PtUiPjuDatInd, -#endif -}; - - -PRIVATE CONSTANT PjuStaInd PjUiPjuStaIndMt[] = -{ -#ifdef LCPJUIPJU - cmPkPjuStaInd, -#else - PtUiPjuStaInd, -#endif -#ifdef NH - NhLiPjuStaInd, -#else - PtUiPjuStaInd, -#endif -#ifdef PX - PxLiPjuStaInd, -#else - PtUiPjuStaInd, -#endif -}; - - -PRIVATE CONSTANT PjuDatFwdInd PjUiPjuDatFwdIndMt[] = -{ -#ifdef LCPJUIPJU - cmPkPjuDatFwdInd, -#else - PtUiPjuDatFwdInd, -#endif -#ifdef NH - NhLiPjuDatFwdInd, -#else - PtUiPjuDatFwdInd, -#endif -#ifdef PX - PxLiPjuDatFwdInd, -#else - PtUiPjuDatFwdInd, -#endif -}; - - -/**************************************************************************** - * PJU Interface Mt functions - ***************************************************************************/ -#ifdef PJ - -#ifdef ANSI -PUBLIC S16 PjUiPjuBndCfm -( -Pst* pst, -SuId suId, -U8 status -) -#else -PUBLIC S16 PjUiPjuBndCfm(pst, suId, status) -Pst* pst; -SuId suId; -U8 status; -#endif -{ - - TRC3(PjUiPjuBndCfm) - - (*PjUiPjuBndCfmMt[pst->selector])(pst, suId, status); - - RETVALUE(ROK); - -} - - -#ifdef ANSI -PUBLIC S16 PjUiPjuDatCfm -( -Pst* pst, -SuId suId, -CmLtePdcpId * pdcpId, -PjuDatCfmInfo * datCfm -) -#else -PUBLIC S16 PjUiPjuDatCfm(pst, suId, pdcpId, datCfm) -Pst* pst; -SuId suId; -CmLtePdcpId * pdcpId; -PjuDatCfmInfo * datCfm; -#endif -{ - - TRC3(PjUiPjuDatCfm) - - (*PjUiPjuDatCfmMt[pst->selector])(pst, suId, pdcpId, datCfm); - - RETVALUE(ROK); - -} - - -#ifdef ANSI -PUBLIC S16 PjUiPjuDatInd -( -Pst* pst, -SuId suId, -CmLtePdcpId * pdcpId, -Buffer * mBuf -) -#else -PUBLIC S16 PjUiPjuDatInd(pst, suId, pdcpId, mBuf) -Pst* pst; -SuId suId; -CmLtePdcpId * pdcpId; -Buffer * mBuf; -#endif -{ - - TRC3(PjUiPjuDatInd) - - (*PjUiPjuDatIndMt[pst->selector])(pst, suId, pdcpId, mBuf); - - RETVALUE(ROK); - -} - - -#ifdef ANSI -PUBLIC S16 PjUiPjuStaInd -( -Pst * pst, -SuId suId, -CmLtePdcpId * pdcpId, -PjuStaIndInfo * staInd, -Buffer *mBuf -) -#else -PUBLIC S16 PjUiPjuStaInd(pst, suId, pdcpId, staInd, mBuf) -Pst * pst; -SuId suId; -CmLtePdcpId * pdcpId; -PjuStaIndInfo * staInd; -Buffer *mBuf; -#endif -{ - - TRC3(PjUiPjuStaInd) - - (*PjUiPjuStaIndMt[pst->selector])(pst, suId, pdcpId, staInd, mBuf); - - RETVALUE(ROK); - -} - - -#ifdef ANSI -PUBLIC S16 PjUiPjuDatFwdInd -( -Pst* pst, -SuId suId, -CmLtePdcpId * pdcpId, -PjuDatFwdIndInfo * datFwdInd -) -#else -PUBLIC S16 PjUiPjuDatFwdInd(pst, suId, pdcpId, datFwdInd) -Pst* pst; -SuId suId; -CmLtePdcpId * pdcpId; -PjuDatFwdIndInfo * datFwdInd; -#endif -{ - - TRC3(PjUiPjuDatFwdInd) - - (*PjUiPjuDatFwdIndMt[pst->selector])(pst, suId, pdcpId, datFwdInd); - - RETVALUE(ROK); - -} -#endif /*--ifdef PJ--*/ - - -/************************************************************************* - * PJU Porting Functions - ************************************************************************/ -#ifdef PTPJPJU - -#ifdef ANSI -PUBLIC S16 PtUiPjuBndReq -( -Pst* pst, -SpId spId, -SuId suId -) -#else -PUBLIC S16 PtUiPjuBndReq(pst, spId, suId) -Pst* pst; -SpId spId; -SuId suId; -#endif -{ - - TRC3(PtUiPjuBndReq) - - UNUSED(pst); - UNUSED(spId); - UNUSED(suId); - - RETVALUE(ROK); - -} - - -#ifdef ANSI -PUBLIC S16 PtUiPjuBndCfm -( -Pst* pst, -SuId suId, -U8 status -) -#else -PUBLIC S16 PtUiPjuBndCfm(pst, suId, status) -Pst* pst; -SuId suId; -U8 status; -#endif -{ - - TRC3(PtUiPjuBndCfm) - - UNUSED(pst); - UNUSED(suId); - UNUSED(status); - - RETVALUE(ROK); - -} - - -#ifdef ANSI -PUBLIC S16 PtUiPjuDatCfm -( -Pst* pst, -SuId suId, -CmLtePdcpId * pdcpId, -PjuDatCfmInfo * datCfm -) -#else -PUBLIC S16 PtUiPjuDatCfm(pst, suId, pdcpId, datCfm) -Pst* pst; -SuId suId; -CmLtePdcpId * pdcpId; -PjuDatCfmInfo * datCfm; -#endif -{ - - TRC3(PtUiPjuDatCfm) - - UNUSED(pst); - UNUSED(suId); - UNUSED(pdcpId); - UNUSED(datCfm); - - RETVALUE(ROK); - -} - - -#ifdef ANSI -PUBLIC S16 PtUiPjuDatInd -( -Pst* pst, -SuId suId, -CmLtePdcpId * pdcpId, -Buffer * mBuf -) -#else -PUBLIC S16 PtUiPjuDatInd(pst, suId, pdcpId, mBuf) -Pst* pst; -SuId suId; -CmLtePdcpId * pdcpId; -Buffer * mBuf; -#endif -{ - - TRC3(PtUiPjuDatInd) - - UNUSED(pst); - UNUSED(suId); - UNUSED(pdcpId); - UNUSED(mBuf); - - RETVALUE(ROK); - -} - - -#ifdef ANSI -PUBLIC S16 PtUiPjuStaInd -( -Pst* pst, -SuId suId, -CmLtePdcpId * pdcpId, -PjuStaIndInfo * staInd, -Buffer *mBuf -) -#else -PUBLIC S16 PtUiPjuStaInd(pst, suId, pdcpId, staInd, mBuf) -Pst* pst; -SuId suId; -CmLtePdcpId * pdcpId; -PjuStaIndInfo * staInd; -Buffer *mBuf; -#endif -{ - - TRC3(PtUiPjuStaInd) - - UNUSED(pst); - UNUSED(suId); - UNUSED(pdcpId); - UNUSED(staInd); - - RETVALUE(ROK); - -} - - -#ifdef ANSI -PUBLIC S16 PtUiPjuDatFwdInd -( -Pst* pst, -SuId suId, -CmLtePdcpId * pdcpId, -PjuDatFwdIndInfo * datFwdInd -) -#else -PUBLIC S16 PtUiPjuDatFwdInd(pst, suId, pdcpId, datFwdInd) -Pst* pst; -SuId suId; -CmLtePdcpId * pdcpId; -PjuDatFwdIndInfo * datFwdInd; -#endif -{ - - TRC3(PtUiPjuDatFwdInd) - - UNUSED(pst); - UNUSED(suId); - UNUSED(pdcpId); - UNUSED(datFwdInd); - - RETVALUE(ROK); - -} -#endif /*--ifdef PTPJPJU--*/ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ -/********************************************************************30** - End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_sec.h b/src/5gnrpdcp/pj_sec.h deleted file mode 100755 index 159476a9c..000000000 --- a/src/5gnrpdcp/pj_sec.h +++ /dev/null @@ -1,248 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - - #include "prc_types.h" -/* lenghth of the pointer variable */ -#define BC_ICPU_MSG_LEN sizeof(BcIcpuMsg) -#define BC_LOCAL_REG 0 -#define BC_SHARED_REG 1 -#define BC_ICPU_MSG_NOR 0 -#define BC_ICPU_MSG_FREE 1 - -#define BC_MAX_PDU_CIPHER_REQ 1 -#define BC_MAX_PDU_INTPROT_REQ 1 -#define BC_MAX_CPU 2 - - -#define PJ_SEC_ALLOC(_cb, _buf, _size) \ -{ \ - if (SGetSBuf(1,0, (Data **)&_buf,\ - (Size) _size) == ROK) \ - { \ - cmMemset((U8 *)(_buf), 0, _size); \ - } \ - else \ - { \ - (_buf) = NULLP; \ - } \ -} -typedef struct intProtCallBkParams -{ - PRC_SNOW_INTEGRITY_PARAMS *intgrtyParams; - U32 numPdu; - PRC_SNOW_INTEGRITY_DATA *pdu_list; - PjLibTrans libTrans; - Pst *pst; - Buffer *pduInfoBuffer; - Buffer *pduListBuffer; -}IntProtCallBkParams; -typedef struct intVerCallBkParams -{ - PRC_SNOW_INTEGRITY_PARAMS *intgrtyParams; - U32 numPdu; - PRC_SNOW_INTEGRITY_DATA *pdu_list; - PjLibTrans libTrans; - Pst *pst; - Buffer *pduInfoBuffer; - Buffer *pduListBuffer; - U32 recvMacI; -}IntVerCallBkParams; - -#ifdef CIPH_BATCH_PROC -typedef struct pjTxEntDtl { - void *txEnt; - void *rbCb; -}PjTxEntDtl; - -typedef struct pjRxEntDtl { - void *rxEnt; - void *rbCb; -}PjRxEntDtl; -#endif -typedef struct cipherCallBkParams -{ -#ifdef CIPH_BATCH_PROC - Data *cipheredBuf[32]; - PjTxEnt *txEntLst[32]; - PjRxEnt *rxEntLst[32]; - PRC_SNOW_CIPHER_DATA *pduList; -#else - PRC_SNOW_CIPHER_DATA *pdu_list; - PjLibTrans libTrans; - Buffer *mBuf[10]; - Buffer *pduInfoBuffer; - Buffer *pduListBuffer; - Pst *pst; -#endif - U32 numTxPdu; - U32 numRxPdu; - PRC_SNOW_CIPHER_PARAMS *cipherParams; -}CipherCallBkParams; - -/* ZUC_ALGO start */ -typedef struct zucIntProtCallBkParams -{ - PRC_ZUC_INTEGRITY_PARAMS *intgrtyParams; - U32 numPdu; - PRC_ZUC_INTEGRITY_DATA *pdu_list; - PjLibTrans libTrans; - Pst *pst; - Buffer *pduInfoBuffer; - Buffer *pduListBuffer; -}ZucIntProtCallBkParams; - -typedef struct zucIntVerCallBkParams -{ - PRC_ZUC_INTEGRITY_PARAMS *intgrtyParams; - U32 numPdu; - PRC_ZUC_INTEGRITY_DATA *pdu_list; - PjLibTrans libTrans; - Pst *pst; - Buffer *pduInfoBuffer; - Buffer *pduListBuffer; - U32 recvMacI; -}ZucIntVerCallBkParams; - -typedef struct zucEncryptCallBkParams -{ -#ifdef CIPH_BATCH_PROC - Data *encryptBuf[32]; - PjTxEnt *txEntLst[32]; - PjRxEnt *rxEntLst[32]; - PRC_ZUC_ENCRYPTION_DATA *pduList; -#else - PRC_ZUC_ENCRYPTION_DATA *pdu_list; - PjLibTrans libTrans; - Buffer *mBuf[10]; - Buffer *pduInfoBuffer; - Buffer *pduListBuffer; - Pst *pst; -#endif - U32 numTxPdu; - U32 numRxPdu; - PRC_ZUC_ENCRYPTION_PARAMS *encryptParams; -}ZucEncryptCallBkParams; -/* ZUC_ALGO - end */ - -#ifdef AES -typedef struct aesIntProtCallBkParams -{ - PRC_AES_INTEGRITY_PARAMS *intgrtyParams; - U32 numPdu; - PRC_AES_INTEGRITY_DATA *pdu_list; - PjLibTrans libTrans; - Pst *pst; - Buffer *pduInfoBuffer; - Buffer *pduListBuffer; -}AesIntProtCallBkParams; - -typedef struct aesIntVerCallBkParams -{ - PRC_AES_INTEGRITY_PARAMS *intgrtyParams; - U32 numPdu; - PRC_AES_INTEGRITY_DATA *pdu_list; - PjLibTrans libTrans; - Pst *pst; - Buffer *pduInfoBuffer; - Buffer *pduListBuffer; - U32 recvMacI; -}AesIntVerCallBkParams; - -typedef struct aesEncryptCallBkParams -{ -#ifdef CIPH_BATCH_PROC - Data *encryptBuf[32]; - PjTxEnt *txEntLst[32]; - PjRxEnt *rxEntLst[32]; - PRC_AES_ENCRYPTION_DATA *pduList; -#else - PRC_AES_ENCRYPTION_DATA *pdu_list; - PjLibTrans libTrans; - Buffer *mBuf[10]; - Buffer *pduInfoBuffer; - Buffer *pduListBuffer; - Pst *pst; -#endif - U32 numTxPdu; - U32 numRxPdu; - PRC_AES_ENCRYPTION_PARAMS *encryptParams; -}AesEncryptCallBkParams; -#endif /* AES */ - -#ifdef CIPH_BATCH_PROC -typedef struct deCipherCallBkParams -{ - U32 numPdu; - PjRxEnt *rxEntLst[32]; - //Buffer *deCipheredBuf[16]; - PRC_SNOW_CIPHER_DATA *pduList; - PRC_SNOW_CIPHER_PARAMS *deCipherParams; -}DecipherCallBkParams; - -typedef struct decryptCallBkParams -{ - U32 numPdu; - PjRxEnt *rxEntLst[32]; - //Buffer *deCipheredBuf[16]; - PRC_ZUC_ENCRYPTION_DATA *pduList; - PRC_ZUC_ENCRYPTION_PARAMS *decryptParams; -}DecryptCallBkParams; - -#ifdef AES -typedef struct decryptAesCallBkParams -{ - U32 numPdu; - PjRxEnt *rxEntLst[32]; - //Buffer *deCipheredBuf[16]; - PRC_AES_ENCRYPTION_DATA *pduList; - PRC_AES_ENCRYPTION_PARAMS *decryptParams; -}DecryptAesCallBkParams; -#endif -#endif - -#ifdef PJ_INT_ASYNC -extern S16 pjUtlIntProtCallBk ARGS(( -U32 rc, -Void* callback_params -)); -extern S16 pjUtlIntVerCallBk ARGS(( -U32 rc, -Void* callback_params -)); - - -extern S16 bcIntProtReq ARGS(( -Pst *pst, -PjSecInp secInp, /* Input for Integrity protection */ -PjLibTrans libTrans, -Buffer *mBuf /* SDU to be compressed */ -)); -#else -extern S16 bcIntProtReq ARGS(( -PjSecInp secInp, /* Input for Integrity protection */ -PjDlUeCb *ueCb, -Buffer *mBuf, /* SDU to be compressed */ -U32 *macI /* Message authentication code for the SDU */ -)); -#endif - -extern S16 pjUtlCipherCallBk ARGS((U32 rc, Void* callback_params)); -#ifdef CIPH_BATCH_PROC -extern S16 pjUtlBatchCipherCallBk ARGS((U32 rc, Void* callback_params)); -#endif - diff --git a/src/5gnrpdcp/pj_tenb_stats.c b/src/5gnrpdcp/pj_tenb_stats.c deleted file mode 100755 index 336237c2a..000000000 --- a/src/5gnrpdcp/pj_tenb_stats.c +++ /dev/null @@ -1,340 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************** - - Name: - - Type: C include file - - Desc: - - File: pj_tenb_stats.c - -**********************************************************************/ -/* header include files (.h) */ - -#include "envopt.h" /* Environment options */ -#include "envdep.h" /* Environment dependent */ -#include "envind.h" /* Environment independent */ -#include "gen.h" /* General */ -#include "ssi.h" /* System services interface */ -#include "cm_llist.h" /* Linked list header file */ -#include "cm_tkns.h" /* Common tokens header file */ - - -/* header/extern include files (.x) */ - -#include "gen.x" /* General */ -#include "ssi.x" /* System services interface */ -#include "cm_lib.x" /* Common lib header file */ -#include "cm_llist.x" /* Linked list header file */ -#include "cm_tkns.x" /* Common tokens header file */ -#include "ss_queue.h" -#include "ss_queue.x" -#include "ss_task.x" -#include "ss_msg.x" -#include "l2_tenb_stats.x" /* Total EnodeB Stats declarations */ - -#ifdef TENB_STATS -PUBLIC TSL2CellStatsCb* l2CellStats[L2_STATS_MAX_CELLS]; -PUBLIC TSL2UeStatsCb* l2UeStats[L2_STATS_MAX_UES]; -PUBLIC CmLListCp freeL2UeStatsLst; /*!< Free Pool of UE stats Blocks */ -PUBLIC CmLListCp inUseL2UeStatsLst;/*!< In Use Pool of UE stats Blocks */ - -/* -* -* Fun: TSL2AllocStatsMem -* -* Desc: Pre-Allocate Memory for L2 stats BLOCKs -* -* Ret: -* -* Notes: None -* -* -*/ -#ifdef ANSI -PUBLIC Void TSL2AllocStatsMem -( - Region region, - Pool pool -) -#else -PUBLIC Void TSL2AllocStatsMem(region, pool) - Region region; - Pool pool; -#endif -{ - U32 cnt=0; - - TRC2(TSL2AllocStatsMem) - - cmLListInit(&inUseL2UeStatsLst); - cmLListInit(&freeL2UeStatsLst); - for (cnt=0; cnt < L2_STATS_MAX_CELLS; cnt++) - { - if(NULL == l2CellStats[cnt]) - { - if (SGetSBuf(region, pool, (Data **)&l2CellStats[cnt], - (Size)sizeof (TSL2CellStatsCb)) != ROK) - { - printf("\n STATS Unexpected MEM Alloc Failure\n"); - } - } - cmMemset((U8 *)l2CellStats[cnt], 0x00, (Size)sizeof(TSL2CellStatsCb)); - } - - for (cnt=0; cnt < L2_STATS_MAX_UES; cnt++) - { - TSL2UeStatsCb *statsCb = l2UeStats[cnt]; - if(NULL == statsCb) - { - if (SGetSBuf(region, pool, (Data **)&statsCb, - (Size)sizeof (TSL2UeStatsCb)) != ROK) - { - printf("\n STATS Unexpected MEM Alloc Failure at %d\n", (int)cnt); - } - } - cmMemset((U8 *)statsCb, 0x00, (Size)sizeof(TSL2UeStatsCb)); - statsCb->lnk.node = (PTR)statsCb; - cmLListAdd2Tail(&freeL2UeStatsLst, &statsCb->lnk); - l2UeStats[cnt] = statsCb; - } - - RETVOID; -} - -/* -* -* Fun: TSL2AllocUeStatsBlk -* -* Desc: Assign Stats Block for this UE[RNTI] -* -* Ret: -* -* Notes: None -* -* -*/ -#ifdef ANSI -PUBLIC TSL2UeStatsCb* TSL2AllocUeStatsBlk -( - U16 rnti -) -#else -PUBLIC TSL2UeStatsCb* TSL2AllocUeStatsBlk(rnti) - U16 rnti; -#endif -{ - CmLList *tmp = NULLP; - TSL2UeStatsCb *statsCb = NULLP; - - TRC2(TSL2AllocUeStatsBlk) - - tmp = freeL2UeStatsLst.first; - if (tmp == NULLP) - { - printf("\n STATS Unexpected Mem BLK unavailable for UE %d\n", rnti); - } - cmLListDelFrm(&freeL2UeStatsLst, tmp); - statsCb = (TSL2UeStatsCb *)(tmp->node); - cmLListAdd2Tail(&inUseL2UeStatsLst, tmp); - - statsCb->stats.rnti = (U32)rnti; - statsCb->inUse = TRUE; - - RETVALUE(statsCb); -} - -/* -* -* Fun: TSL2DeallocUeStatsBlk -* -* Desc: Deassign Stats Block for this UE[RNTI] -* -* Ret: -* -* Notes: None -* -* -*/ -#ifdef ANSI -PUBLIC Void TSL2DeallocUeStatsBlk -( - U16 rnti, - TSL2UeStatsCb *statsCb -) -#else -PUBLIC Void TSL2DeallocUeStatsBlk(rnti, statsCb) - U16 rnti; - TSL2UeStatsCb *statsCb; -#endif -{ - TRC2(TSL2DeallocUeStatsBlk) - - statsCb->inUse = FALSE; - cmLListDelFrm(&inUseL2UeStatsLst, &statsCb->lnk); - freeL2UeStatsLst.crnt = freeL2UeStatsLst.first; - cmLListInsAfterCrnt(&freeL2UeStatsLst, &statsCb->lnk); - - RETVOID; -} - -/* -* -* Fun: TSL2AllocCellStatsBlk -* -* Desc: Assign Stats Block for this CELL[CELLID] -* -* Ret: -* -* Notes: None -* -* -*/ -#ifdef ANSI -PUBLIC TSL2CellStatsCb* TSL2AllocCellStatsBlk -( - U32 cellId -) -#else -PUBLIC TSL2CellStatsCb* TSL2AllocCellStatsBlk(cellId) - U32 cellId; -#endif -{ - TRC2(TSL2AllocCellStatsBlk) - - if (cellId != 1) - { - printf("\n STATS Unexpected CellID = %d\n", (int)cellId); - } - - RETVALUE(l2CellStats[cellId-1]); -} - -/* -* -* Fun: TSL2DeallocCellStatsBlk -* -* Desc: Deassign Stats Block for this CELL[CELLID] -* -* Ret: -* -* Notes: None -* -* -*/ -#ifdef ANSI -PUBLIC Void TSL2DeallocCellStatsBlk -( - U32 cellId -) -#else -PUBLIC Void TSL2DeallocCellStatsBlk(cellId) - U32 cellId; -#endif -{ - TRC2(TSL2DeallocCellStatsBlk) - - RETVOID; -} - -/* -* -* Fun: TSL2SendStatsToApp -* -* Desc: Collates and Sends STATS to Application -* Send UE STATS first. 10 UEs are grouped in one message. -* Followed by CELL Stats. All CELLS are grouped in one msg. -* At Reception of CELL stats APP assumes STATS reception cycle is complete. -* -* Ret: -* -* Notes: None -* -* -*/ -#ifdef ANSI -PUBLIC Void TSL2SendStatsToApp -( - Pst *pst, - SuId suId - ) -#else -PUBLIC Void TSL2SendStatsToApp(pst, suId) - Pst *pst; - SuId suId; -#endif -{ - U32 idx; - - TRC2(TSL2SendStatsToApp) - - for (idx = 0; idx < L2_STATS_MAX_UES; idx++) - { - TSL2UeStatsCb *statsCb = l2UeStats[idx]; - U32 rnti; - if (statsCb->inUse != TRUE) - { - continue; - } - if (pst->selector == 0) - { - /* Loose Coupling */ - TSInfPkSndL2UeStats(pst, suId, &statsCb->stats); - } - else - { -#ifdef PX - /* Tight Coupling */ - TSInfHdlL2UeStatsInd(pst, suId, &statsCb->stats); -#endif - } - rnti = statsCb->stats.rnti; - cmMemset((U8 *)&statsCb->stats, 0x00, (Size)sizeof(TSInfL2UeStats)); - statsCb->stats.rnti = rnti; - } - - /* Allocate mBuf for CELLSTATS */ - for (idx = 0; idx < L2_STATS_MAX_CELLS; idx++) - { - U16 cellId; - if (pst->selector == 0) - { - /* Loose Coupling */ - TSInfPkSndL2CellStats(pst, suId, l2CellStats[idx]); - } - else - { -#ifdef PX - /* Tight Coupling */ - TSInfHdlL2CellStatsInd(pst, suId, l2CellStats[idx]); -#endif - } - cellId = l2CellStats[idx]->cellId; - cmMemset((U8 *)l2CellStats[idx], 0x00, (Size)sizeof(TSInfL2CellStats)); - l2CellStats[idx]->cellId = cellId; - } - - RETVOID; -} -#endif /* TENB_STATS */ -/********************************************************************** - End of file: pj_tenb_stats.c@@/main/tenb_5.0_RIB/3 - Tue Oct 27 14:21:16 2015 -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_tmr.c b/src/5gnrpdcp/pj_tmr.c deleted file mode 100755 index 0377b3311..000000000 --- a/src/5gnrpdcp/pj_tmr.c +++ /dev/null @@ -1,870 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: PDCP - TMR module file - - Type: C source file - - Desc: Source code for timer functions such as, - - - pjStartTmr - - pjStopTmr - - pjTmrExpiry - - pjHdlDiscTmrExp - - pjHdlInitObdTmrExp - - pjHdlUeDelWaitTmrExp - - File: pj_tmr.c - -*********************************************************************21*/ -static const char* RLOG_MODULE_NAME="PDCP"; -static int RLOG_MODULE_ID=1024; -static int RLOG_FILE_ID=223; - - -/* header (.h) include files */ -#include "envopt.h" /* environment options */ -#include "envdep.h" /* environment dependent */ -#include "envind.h" /* environment independent */ - -#include "gen.h" /* general */ -#include "ssi.h" /* system services */ -#include "cm5.h" /* common timer defines */ -#include "cm_tkns.h" /* common tokens defines */ -#include "cm_mblk.h" /* common memory allocation library defines */ -#include "cm_llist.h" /* common link list defines */ -#include "cm_hash.h" /* common hash list defines */ -#include "cm_lte.h" /* common LTE defines */ -#include "cpj.h" /* RRC layer */ -#include "pju.h" /* PDCP service user */ -#include "kwu.h" -#include "lpj.h" /* LPJ defines */ -#include "pj_env.h" /* RLC environment options */ -#include "pj.h" /* RLC defines */ -#include "pj_err.h" /* Error defines */ -#include "pj_udx.h" - -/* extern (.x) include files */ -#include "gen.x" /* general */ -#include "ssi.x" /* system services */ -#include "cm5.x" /* common timer library */ -#include "cm_tkns.x" /* common tokens */ -#include "cm_mblk.x" /* common memory allocation */ -#include "cm_llist.x" /* common link list */ -#include "cm_hash.x" /* common hash list */ -#include "cm_lte.x" /* common LTE includes */ -#include "cm_lib.x" /* common memory allocation library */ -#include "cpj.x" /* RRC layer */ -#include "kwu.x" -#include "pju.x" /* PDCP service user */ -#include "lpj.x" /* LPJ */ -#include "pj.x" -#include "pj_udx.h" -#include "pj_udx.x" -#include "pj_ul.x" -#include "pj_dl.x" - -/* local defines */ - -/* local externs */ - -/* forward references */ -PRIVATE Void pjBndTmrExpiry ARGS ((S16 tmrEvnt, PTR cb)); -/* public variable declarations */ - -/* This structure holds all the global structs we need. */ - -/* private variable declarations */ - -/* private function declarations */ -/** @file gp_pj_tmr.c -@brief PDCP Timer Module -**/ - -/** - * @def PJ_TMR_CALCUATE_WAIT - * - * This macro calculates and assigns wait time based on the value of the - * timer and the timer resolution. Timer value of 0 signifies that the - * timer is not configured - * - * @param[out] _wait Time for which to arm the timer changed to proper - * value according to the resolution - * @param[in] _tmrVal Value of the timer - * @param[in] _timerRes Resolution of the timer - * - */ -#define PJ_TMR_CALCUATE_WAIT(_wait, _tmrVal, _timerRes) \ -{ \ - (_wait) = ((_tmrVal) * SS_TICKS_SEC)/((_timerRes) * 1000); \ - if((0 != (_tmrVal)) && (0 == (_wait))) \ - { \ - (_wait) = 1; \ - } \ -} - -/** - * - * @brief Handler to start timer - * - * - * @b Description - * This function is invoked by DLM modules to start the discard timer for SDUs. - * - * - * @param[in] cb Transmission Buffer control block - * @param[in] tmrEvnt Timer event to be started - * - * - * @return S16 - * -# ROK - * -# RFAILED -*/ -#ifdef ANSI -PUBLIC S16 pjStartTmr -( -PjCb *gCb, -PTR cb, /* Parent control block */ -S16 tmrEvnt /* Timer event */ -) -#else -PUBLIC S16 pjStartTmr (gCb, cb, tmrEvnt) -PjCb *gCb; -PTR cb; /* Parent control block */ -S16 tmrEvnt; /* Timer event */ -#endif -{ -#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)) - PjDlRbCb *dlRbCb; - PjTxEnt *txEnt; -#endif - U16 wait; - CmTimer *tmr; - U8 maxTmrs; - CmTmrArg arg; - /* kw005.201 added support for L2 Measurement */ -#ifdef LTE_L2_MEAS_COMMENT - PjL2MeasEvtCb *measEvtCb; -#endif - -#ifdef LTE_L2_MEAS - PjL2Cb *pjL2Cb = NULLP; - PjCb *tPjMeasCb = NULLP; -#endif - PjUlRbCb *ulRbCb; - - TRC2(pjStartTmr) - - RLOG1(L_DEBUG, "pjStartTmr(cb, tmrEvnt (%d)) ", tmrEvnt); - -#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)) - ulRbCb = NULLP; - dlRbCb = NULLP; - txEnt = NULLP; - - -#endif - wait = 0; - tmr = NULLP; - maxTmrs = 0; - - switch (tmrEvnt) - { - case PJ_EVT_WAIT_KWU_BNDCFM: - { - PjKwuSapCb *kwuSap = (PjKwuSapCb *)cb; - wait = (U16)((kwuSap->bndTmrInt * SS_TICKS_SEC)/(gCb->pjGenCfg.timeRes * 1000)); /*KW_FIX*/ - if( (0 != kwuSap->bndTmrInt) && (0 == wait) ) - { - wait = 1; - } - tmr = &kwuSap->bndTmr; - maxTmrs = PJ_MAX_KWUSAP_TMR; - break; - } - case PJ_EVT_WAIT_UDX_BNDCFM: - { - PjUdxUlSapCb *udxSap = (PjUdxUlSapCb *)cb; - wait = (U16)((udxSap->bndTmrInt * SS_TICKS_SEC)/(gCb->pjGenCfg.timeRes * 1000)); /*KW_FIX*/ - if( (0 != udxSap->bndTmrInt) && (0 == wait) ) - { - wait = 1; - } - tmr = &udxSap->bndTmr; - maxTmrs = PJ_MAX_UDXSAP_TMR; - break; - } -#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)) - case PJ_EVT_DL_OBD_TMR: - { - dlRbCb = (PjDlRbCb *)cb; - tmr=&(dlRbCb->dlCb.obdTmr); - maxTmrs = PJ_MAX_OBD_TMR; - txEnt = pjDbmGetTxEnt(gCb,&(dlRbCb->dlCb.txBuf), dlRbCb->dlCb.nxtToSub); - if ( txEnt != NULLP ) - { - wait = gCb->pjGenCfg.obdTmrInt; - dlRbCb->dlCb.obdCount = txEnt->count; - } - - break; - } - case PJ_EVT_UL_OBD_TMR: - { - ulRbCb = (PjUlRbCb *)cb; - tmr=&(ulRbCb->ulCb.obdTmr); - maxTmrs = PJ_MAX_OBD_TMR; - PJ_ULM_GET_SUBCNT(ulRbCb,(ulRbCb->ulCb.obdPdu),gCb); - if(pjDbmGetRxEnt(gCb,&(ulRbCb->ulCb.recBuf), ulRbCb->ulCb.obdPdu) != NULLP ) - { - wait = gCb->pjGenCfg.obdTmrInt; - } - - break; - } - case PJ_EVT_OBD_WAIT_TMR: - { - if (gCb->pjGenCfg.mode == LPJ_MODE_PDCP_DL) - { - PjDlUeCb *dlUeCb = (PjDlUeCb *)cb; - tmr=&(dlUeCb->libInfo.obdTmr); - } - else - { - PjUlUeCb *ulUeCb = (PjUlUeCb *)cb; - tmr=&(ulUeCb->libInfo.obdTmr); - } - maxTmrs = PJ_MAX_OBD_TMR; - wait = gCb->pjGenCfg.obdWtTmrInt; - break; - } - -#endif - /* kw005.201 added support for L2 Measurement */ -#ifdef LTE_L2_MEAS_COMMENT - case PJ_EVT_L2_TMR: - { - measEvtCb = (PjL2MeasEvtCb *)cb; - tmr=&(measEvtCb->l2Tmr); - maxTmrs = PJ_L2_MAX_TIMERS; - wait = (measEvtCb->l2TmrCfg.val * SS_TICKS_SEC)/(pjCb.genCfg.timeRes * 1000); - if((measEvtCb->l2TmrCfg.val > 0) && wait == 0) - { - wait = 1; - } - break; - } -#endif -#ifdef LTE_L2_MEAS - case PJ_EVT_L2_MEAS_TMR: - { - tPjMeasCb = (PjCb *)cb; - pjL2Cb = &tPjMeasCb->u.ulCb->pjL2Cb; - tmr=&(pjL2Cb->measTmr); - maxTmrs = PJ_L2_MAX_TIMERS; - wait = (pjL2Cb->measTmrCfg.val * SS_TICKS_SEC)/(gCb->pjGenCfg.timeRes * 1000); - wait = 500; - if((pjL2Cb->measTmrCfg.val > 0) && wait == 0) - { - wait = 1; - } - break; - } -#endif - case PJ_EVT_UL_REORD_TMR: - { - ulRbCb = (PjUlRbCb *)cb; - tmr=&(ulRbCb->ulCb.tReordTmr); - maxTmrs = PJ_MAX_UL_REORD_TMRS; - PJ_TMR_CALCUATE_WAIT(wait, ulRbCb->reOrdrTmrVal, gCb->pjGenCfg.timeRes); - break; - } - default: - { - RLOG0(L_ERROR, "Invalid Start tmr Evnt"); - RETVALUE(RFAILED); - } - } - - if(wait != 0) - { - arg.tqCp = &gCb->pjTqCp; - arg.tq = gCb->pjTq; - arg.cb = cb; - arg.timers = tmr; - arg.evnt = tmrEvnt; - arg.wait = wait; - arg.tNum = 0; - arg.max = maxTmrs; - - cmPlcCbTq(&arg); - } - - RETVALUE(ROK); -} - -/** - * - * @brief Handler to stop timer - * - * - * @b Description - * This function is used to stop protocol timer, based on the timer event. - * - * - * @param[in] cb Transmission Buffer control block - * @param[in] tmrEvnt Timer event to be started - * - * - * @return S16 - * -# ROK - * -# RFAILED -*/ -#ifdef ANSI -PUBLIC S16 pjStopTmr -( -PjCb *gCb, -PTR cb, /* Parent control block */ -U8 tmrEvnt /* Timer */ -) -#else -PUBLIC S16 pjStopTmr (gCb, cb, tmrEvnt) -PjCb *gCb; -PTR cb; /* Parent control block */ -U8 tmrEvnt; /* Timer */ -#endif -{ - CmTmrArg arg; - CmTimer *tmr; -#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)) - PjDlRbCb *pjDlRbCb; -#endif - PjKwuSapCb *kwuSap; - PjUdxUlSapCb *udxSap; -#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)) - PjDlUeCb *dlUeCb; - PjUlUeCb *ulUeCb; -#endif - /* kw005.201 added support for L2 Measurement */ -#ifdef LTE_L2_MEAS - PjL2Cb *pjL2Cb = NULLP; - PjCb *tPjMeasCb = NULLP; -#endif - U8 maxTimers; - PjUlRbCb *pjUlRbCb; - - TRC2(pjStopTmr) - - RLOG1(L_DEBUG, "pjStopTmr(cb, tmrEvnt(%d)) ", tmrEvnt); - - tmr = NULLP; - maxTimers = 0; -#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)) - pjUlRbCb = NULLP; - pjDlRbCb = NULLP; - /* ueCb = NULLP; */ -#endif - - switch (tmrEvnt) - { - case PJ_EVT_WAIT_KWU_BNDCFM: - { - kwuSap = (PjKwuSapCb *)cb; - tmr = &kwuSap->bndTmr; - arg.max = PJ_MAX_KWUSAP_TMR; - break; - } - case PJ_EVT_WAIT_UDX_BNDCFM: - { - udxSap = (PjUdxUlSapCb *)cb; - tmr = &udxSap->bndTmr; - arg.max = PJ_MAX_UDXSAP_TMR; - break; - } -#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)) - case PJ_EVT_DL_OBD_TMR: - { - pjDlRbCb = (PjDlRbCb *)cb; - tmr = &(pjDlRbCb->dlCb.obdTmr); - maxTimers = PJ_MAX_OBD_TMR; - break; - } - case PJ_EVT_UL_OBD_TMR: - { - pjUlRbCb = (PjUlRbCb *)cb; - tmr = &(pjUlRbCb->ulCb.obdTmr); - maxTimers = PJ_MAX_OBD_TMR; - break; - } - case PJ_EVT_OBD_WAIT_TMR: - { - /*if (gCb->pjGenCfg.mode == LPJ_PDCP_MODE_DL)*/ - if (gCb->pjGenCfg.mode == LPJ_MODE_PDCP_DL) - { - dlUeCb = (PjDlUeCb *)cb; - tmr = &(dlUeCb->libInfo.obdTmr); - } - else - { - ulUeCb = (PjUlUeCb *)cb; - tmr = &(ulUeCb->libInfo.obdTmr); - } - maxTimers = PJ_MAX_OBD_TMR; - break; - } - -#endif - /* kw005.201 added support for L2 Measurement */ -#ifdef LTE_L2_MEAS_COMMENT - case PJ_EVT_L2_TMR: - { - measEvtCb = (PjL2MeasEvtCb *)cb; - tmr = &(measEvtCb->l2Tmr); - maxTimers = PJ_L2_MAX_TIMERS; - break; - } -#endif -#ifdef LTE_L2_MEAS - case PJ_EVT_L2_MEAS_TMR: - { - tPjMeasCb = (PjCb *)cb; - pjL2Cb = &tPjMeasCb->u.ulCb->pjL2Cb; - tmr = &(pjL2Cb->measTmr); - maxTimers = PJ_L2_MAX_TIMERS; - break; - } -#endif - case PJ_EVT_UL_REORD_TMR: - { - pjUlRbCb = (PjUlRbCb *)cb; - tmr=&(pjUlRbCb->ulCb.tReordTmr); - maxTimers = PJ_MAX_UL_REORD_TMRS; - break; - } - default: - { - RLOG0(L_ERROR, "Invalid Stop tmr Evnt"); - RETVALUE(RFAILED); - } - } - - - if (tmrEvnt != TMR0) - { - arg.tqCp = &gCb->pjTqCp; - arg.tq = gCb->pjTq; - arg.cb = (PTR)cb; - arg.timers = tmr; - arg.evnt = tmrEvnt; - arg.wait = 0; - arg.max = maxTimers; - arg.tNum = 0; - cmRmvCbTq(&arg); - - } - - RETVALUE(ROK); -} - -/** - * - * @brief Handler to invoke events on expiry of timer. - * - * - * @b Description - * This function is used to handle expiry of timer,it invokes relevant functions. - * - * - * @param[in] cb Transmission Buffer control block - * @param[in] tmrType Type of the timer to be stopped - * - * - * @return S16 - * -# ROK - * -# RFAILED -*/ -#ifdef ANSI -PUBLIC S16 pjTmrExpiry -( -PTR cb, /* Parent control block */ -S16 tmrEvnt /* Timer event */ -) -#else -PUBLIC S16 pjTmrExpiry (cb, tmrEvnt) -PTR cb; /* Parent control block */ -S16 tmrEvnt; /* Timer event */ -#endif -{ -#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)) - PjDlRbCb *dlRbCb = NULLP; - PjDlUeCb *dlUeCb = NULLP; - PjUlUeCb *ulUeCb = NULLP; -#endif - PjUlRbCb *ulRbCb = NULLP; -#ifdef LTE_L2_MEAS - PjL2Cb *pjL2Cb = NULLP; - PjCb *tPjMeasCb = NULLP; -#endif - /* pj005.201 added support for L2 Measurement */ - TRC2(pjTmrExpiry) - - switch (tmrEvnt) - { - case PJ_EVT_WAIT_KWU_BNDCFM: - { - pjBndTmrExpiry(tmrEvnt,cb); - /* kw005.201 added missing break statement */ - break; - } - case PJ_EVT_WAIT_UDX_BNDCFM: - { - pjBndTmrExpiry(tmrEvnt,cb); - /* kw005.201 added missing break statement */ - break; - } -#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)) - case PJ_EVT_DL_OBD_TMR: - { - PjCb *tPjCb; - dlRbCb = (PjDlRbCb *)cb; - - if (dlRbCb->ueCb->inst >= PJ_MAX_PDCP_INSTANCES) - { - RETVALUE(RFAILED); - } - tPjCb = PJ_GET_PJCB(dlRbCb->ueCb->inst); - - pjDlmObdTmrExp(tPjCb,dlRbCb); - break; - } - case PJ_EVT_UL_OBD_TMR: - { - PjCb *tPjCb; - ulRbCb = (PjUlRbCb *)cb; - - if (ulRbCb->ueCb->inst >= PJ_MAX_PDCP_INSTANCES) - { - RETVALUE(RFAILED); - } - tPjCb = PJ_GET_PJCB(ulRbCb->ueCb->inst); - pjUlmHdlObdTmrExpiry(tPjCb,ulRbCb); - break; - } - case PJ_EVT_OBD_WAIT_TMR: - { - PjCb *tPjCb; - tPjCb = (PjCb*)cb; - if (tPjCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL) - { - ulUeCb = (PjUlUeCb *)cb; - if (ulUeCb->inst >= PJ_MAX_PDCP_INSTANCES) - { - RETVALUE(RFAILED); - } - tPjCb = PJ_GET_PJCB(ulUeCb->inst); - pjUtlUlHdlInitObdTmrExp(tPjCb,ulUeCb); - - } - else - { - dlUeCb = (PjDlUeCb *)cb; - if (dlUeCb->inst >= PJ_MAX_PDCP_INSTANCES) - { - RETVALUE(RFAILED); - } - tPjCb = PJ_GET_PJCB(dlUeCb->inst); - pjUtlDlHdlInitObdTmrExp(tPjCb,dlUeCb); - } - break; - } - -#endif -#ifdef LTE_L2_MEAS - case PJ_EVT_L2_MEAS_TMR: - { - tPjMeasCb = (PjCb *)cb; - pjL2Cb = &tPjMeasCb->u.ulCb->pjL2Cb; - pjUtlMemCpuHdlTmrExp((PjCb *)cb,pjL2Cb); - } - break; -#endif - case PJ_EVT_UL_REORD_TMR: - { - PjCb *tPjCb; - ulRbCb = (PjUlRbCb *)cb; - if (ulRbCb->ueCb->inst >= PJ_MAX_PDCP_INSTANCES) - { - RETVALUE(RFAILED); - } - tPjCb = PJ_GET_PJCB(ulRbCb->ueCb->inst); - pjUlmHdlReordTmrExpiry(tPjCb, ulRbCb); - break; - } - /* pj005.201 added support for L2 Measurement */ - default: - { - RETVALUE(RFAILED); - } - } - - RETVALUE(ROK); -} - -/** - * - * @brief Handler to check if the timer is running - * - * - * @b Description - * This function is used to check if the timer is running at the given - * moment. - * - * - * @param[in] cb Transmission Buffer control block - * @param[in] tmrType Type of the timer to be stopped - * - * - * @return S16 - * -# ROK - * -# RFAILED - */ -#ifdef ANSI -PUBLIC Bool pjChkTmr -( -PjCb *gCb, -PTR cb, /* Parent control block */ -S16 tmrEvnt /* Timer event */ -) -#else -PUBLIC Bool pjChkTmr(gCb, cb, tmrEvnt) -PjCb *gCb; -PTR cb; /* Parent control block */ -S16 tmrEvnt; /* Timer event */ -#endif -{ -#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)) - PjDlUeCb *dlUeCb = NULLP; - PjUlUeCb *ulUeCb = NULLP; -#endif -#ifdef LTE_L2_MEAS - PjL2Cb *pjL2Cb = NULLP; - PjCb *tPjMeasCb = NULLP; -#endif - Bool tmrRunning = FALSE; - PjUlRbCb *ulRbCb = NULLP; - - TRC2(pjChkTmr) - - RLOG1(L_UNUSED, "pjChkTmr(cb, tmrEvnt(%d)) ", tmrEvnt); - - switch (tmrEvnt) - { -#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)) - case PJ_EVT_DL_OBD_TMR: - { - dlRbCb = (PjDlRbCb *)cb; - if (dlRbCb->dlCb.obdTmr.tmrEvnt == PJ_EVT_DL_OBD_TMR) - { - tmrRunning = TRUE; - } - break; - } - case PJ_EVT_UL_OBD_TMR: - { - ulRbCb = (PjUlRbCb *)cb; - if (ulRbCb->ulCb.obdTmr.tmrEvnt == PJ_EVT_UL_OBD_TMR) - { - tmrRunning = TRUE; - } - break; - } - case PJ_EVT_OBD_WAIT_TMR: - { - if(gCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL) - { - ulUeCb = (PjUlUeCb *)cb; - if (ulUeCb->inst >= PJ_MAX_PDCP_INSTANCES) - { - RETVALUE(RFAILED); - } - if (ulUeCb->libInfo.obdTmr.tmrEvnt == PJ_EVT_OBD_WAIT_TMR) - { - tmrRunning = TRUE; - } - } - else - { - dlUeCb = (PjDlUeCb *)cb; - if (dlUeCb->inst >= PJ_MAX_PDCP_INSTANCES) - { - RETVALUE(RFAILED); - } - if (dlUeCb->libInfo.obdTmr.tmrEvnt == PJ_EVT_OBD_WAIT_TMR) - { - tmrRunning = TRUE; - } - } - break; - } -#endif -#ifdef LTE_L2_MEAS - case PJ_EVT_L2_MEAS_TMR: - { - tPjMeasCb = (PjCb *)cb; - pjL2Cb = &tPjMeasCb->u.ulCb->pjL2Cb; - if (pjL2Cb->measTmr.tmrEvnt == PJ_EVT_L2_MEAS_TMR) - { - tmrRunning = TRUE; - } - break; - } -#endif - case PJ_EVT_UL_REORD_TMR: - { - ulRbCb = (PjUlRbCb *)cb; - if(PJ_EVT_UL_REORD_TMR == ulRbCb->ulCb.tReordTmr.tmrEvnt) - { - tmrRunning = TRUE; - } - break; - } - default: - { - - RLOG0(L_ERROR, "Invalid Chk tmr Evnt"); - RETVALUE(RFAILED); - } - } - - RETVALUE(tmrRunning); -} -/** - * - * @brief Private handler to invoke an event for bind timer expiry - * - * - * @b Description - * This function processes the RLC bind timer expiry. If the number of retry is - * less than the maximum retry counter, bind request is sent again, else an - * alarm is raised to the layer manager. - * - * - * @param[in] cb RB control block - * - * - * @return Void - * -# RETVOID -*/ -#ifdef ANSI -PRIVATE Void pjBndTmrExpiry -( -S16 tmrEvnt, -PTR cb /* Parent control block */ -) -#else -PRIVATE Void pjBndTmrExpiry(tmrEvnt, cb) -S16 tmrEvnt; -PTR cb; /* Parent control block */ -#endif -{ - PjCb *tPjCb; - PjUdxUlSapCb *udxSap; - PjKwuSapCb *kwuSapCb; - - TRC2(pjBndTmrExpiry) - - if (tmrEvnt == PJ_EVT_WAIT_KWU_BNDCFM) - { - kwuSapCb = (PjKwuSapCb *) cb; - - tPjCb = PJ_GET_PJCB(kwuSapCb->pst.srcInst); - if (kwuSapCb->state == PJ_SAP_BINDING) - { - if (kwuSapCb->retryCnt < PJ_MAX_SAP_BND_RETRY) - { - /* Send bind request */ - kwuSapCb->retryCnt++; - - /* start timer to wait for bind confirm */ - pjStartTmr(tPjCb, (PTR)kwuSapCb, PJ_EVT_WAIT_KWU_BNDCFM); - - PjLiKwuBndReq (&kwuSapCb->pst, kwuSapCb->suId, kwuSapCb->spId); - } - else - { - kwuSapCb->retryCnt = 0; - kwuSapCb->state = PJ_SAP_CFG; - - /* Send alarm to the layer manager */ -#ifdef LTE_L2_MEAS - pjLmmSendAlarm(tPjCb,LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_FAIL, - LCM_CAUSE_TMR_EXPIRED, 0, 0, 0); -#else - pjLmmSendAlarm(tPjCb,LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_FAIL, - LCM_CAUSE_TMR_EXPIRED, 0, 0); -#endif - } - } - } - else - { - udxSap = (PjUdxUlSapCb *)cb; - - tPjCb = PJ_GET_PJCB (udxSap->pst.srcInst); - - if (udxSap->state == PJ_SAP_BINDING) - { - if (udxSap->retryCnt < PJ_MAX_SAP_BND_RETRY) - { - /* Send bind request */ - udxSap->retryCnt++; - - /* start timer to wait for bind confirm */ - pjStartTmr(tPjCb, (PTR)udxSap, PJ_EVT_WAIT_UDX_BNDCFM); - - PjUlUdxBndReq (&udxSap->pst, udxSap->suId, udxSap->spId); - } - else - { - udxSap->retryCnt = 0; - udxSap->state = PJ_SAP_CFG; - - /* Send alarm to the layer manager */ -#ifdef LTE_L2_MEAS - pjLmmSendAlarm(tPjCb,LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_FAIL, - LCM_CAUSE_TMR_EXPIRED, 0, 0, 0); -#else - pjLmmSendAlarm(tPjCb,LCM_CATEGORY_INTERFACE, LCM_EVENT_BND_FAIL, - LCM_CAUSE_TMR_EXPIRED, 0, 0); -#endif - } - } - - } - - RETVOID; -} - - - -/********************************************************************30** - - End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_udx.c b/src/5gnrpdcp/pj_udx.c deleted file mode 100755 index 6bffe08e2..000000000 --- a/src/5gnrpdcp/pj_udx.c +++ /dev/null @@ -1,6225 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: LTE PDCP Interface - - Type: C file - - Desc: This file contains the pack/unpack functions for the - data structures at UDX Interface. - - File: pj_udx.c - -*********************************************************************21*/ -#if(defined(LCUDX) || defined(LWLCUDX)) -static const char* RLOG_MODULE_NAME="PDCP"; -static int RLOG_MODULE_ID=1024; -static int RLOG_FILE_ID=224; -#endif - -/* header include files (.h) */ - -#include "envopt.h" /* Environment options */ -#include "envdep.h" /* Environment dependent */ -#include "envind.h" /* Environment independent */ -#include "gen.h" /* General */ -#include "ssi.h" /* System services interface */ -#include "cm_lte.h" /* Common LTE header file */ -#include "cm_llist.h" /* Linked List header file */ -#include "cm_tkns.h" /* Common tokens header file */ -#include "cm_hash.h" /* Hash List header file */ -#include "cpj.h" /* CPJ Interface header file */ -#include "lpj.h" -#include "pj_udx.h" - - - -/* header/extern include files (.x) */ - -#include "gen.x" /* General */ -#include "ssi.x" /* System services interface */ -#include "cm_lib.x" /* Common lib header file */ -#include "cm_hash.x" /* Hash List header file */ -#include "cm_llist.x" /* Linked List header file */ -#include "cm_tkns.x" /* Common tokens header file */ -#include "cm_lte.x" /* Common LTE header file */ -#include "cpj.x" /* CPJ Interface header file */ -#include "pj.h" -#include "lpj.x" -#include "pj_udx.x" - -#if(defined(LCUDX) || defined(LWLCUDX)) -/* Packing/Unpacking Macros */ - -#ifdef ANSI -PUBLIC S16 cmPkPjUdxBndReq -( -Pst * pst, -SuId suId, -SpId spId -) -#else -PUBLIC S16 cmPkPjUdxBndReq(pst, suId, spId) -Pst * pst; -SuId suId; -SpId spId; -#endif -{ - Buffer *mBuf = NULLP; - TRC3(cmPkPjUdxBndReq) - - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX001, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - if (SPkS16(spId, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX002, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - if (SPkS16(suId, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX003, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - pst->event = (Event) EVTUDXBNDREQ; - RETVALUE(SPstTsk(pst,mBuf)); -} - -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxBndReq -( -UdxBndReq func, -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxBndReq(func, pst, mBuf) -UdxBndReq func; -Pst *pst; -Buffer *mBuf; -#endif -{ - SuId suId; - SpId spId; - - TRC3(cmUnpkPjUdxBndReq) - - if (SUnpkS16(&suId, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX004, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - if (SUnpkS16(&spId, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX005, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - PJ_FREE_BUF(mBuf); - RETVALUE((*func)(pst, suId, spId)); -} - -#ifdef ANSI -PUBLIC S16 cmPkPjUdxBndCfm -( -Pst * pst, -SuId suId, -U8 status -) -#else -PUBLIC S16 cmPkPjUdxBndCfm(pst, suId, status) -Pst * pst; -SuId suId; -U8 status; -#endif -{ - Buffer *mBuf = NULLP; - TRC3(cmPkPjUdxBndCfm) - - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ006, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - if (SPkU8(status, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ007, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - if (SPkS16(suId, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ008, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - pst->event = (Event) EVTCPJBNDCFM; - RETVALUE(SPstTsk(pst,mBuf)); -} - -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxBndCfm -( -UdxBndCfm func, -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxBndCfm(func, pst, mBuf) -UdxBndCfm func; -Pst *pst; -Buffer *mBuf; -#endif -{ - SuId suId; - U8 status; - - TRC3(cmUnpkPjUdxBndCfm) - - if (SUnpkS16(&suId, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ009, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - if (SUnpkU8(&status, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ010, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - PJ_FREE_BUF(mBuf); - RETVALUE((*func)(pst, suId, status)); -} - -#ifdef ANSI -PUBLIC S16 cmPkPjUdxUbndReq -( -Pst * pst, -SpId spId, -Reason reason -) -#else -PUBLIC S16 cmPkPjUdxUbndReq(pst, spId, reason) -Pst * pst; -SpId spId; -Reason reason; -#endif -{ - Buffer *mBuf = NULLP; - TRC3(cmPkPjUdxUbndReq) - - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX011, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - - if (SPkS16(reason, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX012, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - if (SPkS16(spId, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX013, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - pst->event = (Event) EVTUDXUBNDREQ; - RETVALUE(SPstTsk(pst,mBuf)); -} - -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxUbndReq -( -UdxUbndReq func, -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxUbndReq(func, pst, mBuf) -UdxUbndReq func; -Pst *pst; -Buffer *mBuf; -#endif -{ - SpId spId; - Reason reason; - - TRC3(cmUnpkPjUdxUbndReq) - - if (SUnpkS16(&spId, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX014, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - if (SUnpkS16(&reason, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX015, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - PJ_FREE_BUF(mBuf); - RETVALUE((*func)(pst, spId, reason)); -} - -#ifdef ANSI -PUBLIC S16 cmPkPjUdxCfgReq -( -Pst * pst, -SpId spId, -UdxCfgReqInfo * cfgReq -) -#else -PUBLIC S16 cmPkPjUdxCfgReq(pst, spId, cfgReq) -Pst * pst; -SpId spId; -UdxCfgReqInfo * cfgReq; -#endif -{ - Buffer *mBuf = NULLP; - TRC3(cmPkPjUdxCfgReq) - - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX016, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, cfgReq, sizeof(UdxCfgReqInfo)); - RETVALUE(RFAILED); - } - - switch(pst->selector) - { -#ifdef LCUDX - case UDX_SEL_LC: - { - - if (cmPkPjUdxCfgReqInfo(pst, cfgReq, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX017, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, cfgReq, sizeof(UdxCfgReqInfo)); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - - /* Free Request Structure after packing */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, cfgReq, sizeof(UdxCfgReqInfo)); - - - break; - } - case UDX_SEL_LWLC: - { - CMCHKPKLOG(cmPkPtr,(PTR)cfgReq,mBuf,EUDXXXX,pst); - break; - } -#endif /* LCUDX */ - } - - if (SPkS16(spId, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX019, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, cfgReq, sizeof(UdxCfgReqInfo)); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - pst->event = (Event) EVTUDXCFGREQ; - - RETVALUE(SPstTsk(pst,mBuf)); -} - -#ifdef ANSI -PUBLIC S16 cmPkPjUdxUlStaRep -( -Pst * pst, -SpId spId, -UdxUlStaRepInfo *staRep -) -#else -PUBLIC S16 cmPkPjUdxUlStaRep(pst, spId, staRep) -Pst * pst; -SpId spId; -UdxUlStaRepInfo *staRep; -#endif -{ - S16 ret; - Buffer *mBuf; - mBuf = NULLP; - - TRC3(cmPkPjUdxUlStaRep) - - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX016, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(mBuf); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staRep, sizeof(UdxUlStaRepInfo)); - - RETVALUE(RFAILED); - } - - switch(pst->selector) - { -#ifdef LCUDX - case UDX_SEL_LC: - { - ret = cmPkPjUdxUlStaRepInfo( (staRep), pst, mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - if(ret != ROK) - { - PJ_FREE_BUF(mBuf); - PJ_FREE_BUF(staRep->sta); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, (Data *)staRep, sizeof(UdxUlStaRepInfo), 0); - - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDXXXX, (ErrVal)ret, "Packing failure"); - RETVALUE( ret ); - } -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - PJ_FREE_BUF(staRep->sta); -#ifndef XEON_SPECIFIC_CHANGES - if (SPutStaticBuffer(pst->region, pst->pool, (Data *)staRep, - sizeof(UdxUlStaRepInfo), 0) != ROK) -#else - if (SPutSBuf(pst->region, pst->pool, (Data *)staRep, - sizeof(UdxUlStaRepInfo)) != ROK) -#endif - { - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - - break; - } - case UDX_SEL_LWLC: - { - CMCHKPKLOG(cmPkPtr,(PTR)staRep,mBuf,EUDXXXX,pst); - break; - } -#endif /* LCUDX */ - } - - CMCHKPKLOG(SPkS16, spId, mBuf, EUDXXXX, pst); - pst->event = (Event) EVTUDXULSTAREP; - - RETVALUE(SPstTsk(pst,mBuf)); -} - -#ifdef ANSI -PUBLIC S16 cmPkPjUdxDlStaRep -( -Pst * pst, -SpId spId, -UdxDlStaRepInfo *staRep -) -#else -PUBLIC S16 cmPkPjUdxDlStaRep(pst, spId, staRep) -Pst * pst; -SpId spId; -UdxDlStaRepInfo *staRep; -#endif -{ - S16 ret; - Buffer *mBuf; - mBuf = NULLP; - - TRC3(cmPkPjUdxDlStaRep) - - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) - { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX016, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(staRep->staPdu); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staRep, sizeof(UdxDlStaRepInfo)); - - RETVALUE(RFAILED); - } - - switch(pst->selector) - { -#ifdef LCUDX - case UDX_SEL_LC: - { - ret = cmPkPjUdxDlStaRepInfo( (staRep), pst, mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - if(ret != ROK) - { - PJ_FREE_BUF(mBuf); - PJ_FREE_BUF(staRep->staPdu); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staRep, sizeof(UdxDlStaRepInfo)); - - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDXXXX, (ErrVal)ret, "Packing failure"); - RETVALUE( ret ); - } -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - PJ_FREE_BUF(staRep->staPdu); -#ifndef XEON_SPECIFIC_CHANGES - if (SPutStaticBuffer(pst->region, pst->pool, (Data *)staRep, - sizeof(UdxDlStaRepInfo), 0) != ROK) -#else - if (SPutSBuf(pst->region, pst->pool, (Data *)staRep, - sizeof(UdxDlStaRepInfo)) != ROK) -#endif - { - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - - break; - } - case UDX_SEL_LWLC: - { - CMCHKPKLOG(cmPkPtr,(PTR)staRep,mBuf,EUDXXXX,pst); - break; - } -#endif /* LCUDX */ - } - - CMCHKPKLOG(SPkS16, spId, mBuf, EUDXXXX, pst); - pst->event = (Event) EVTUDXDLSTAREP; - - RETVALUE(SPstTsk(pst,mBuf)); -} - - -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxCfgReq -( -UdxCfgReq func, -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxCfgReq(func, pst, mBuf) -UdxCfgReq func; -Pst *pst; -Buffer *mBuf; -#endif -{ - S16 ret1; - SpId spId; - UdxCfgReqInfo *cfgReq; - - TRC3(cmUnpkPjUdxCfgReq) - if (SUnpkS16(&spId, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX021, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - - switch(pst->selector) - { -#ifdef LCUDX - case UDX_SEL_LC: - { - - if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&cfgReq,\ - sizeof(UdxCfgReqInfo))) != ROK) - { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX040, (ErrVal)0, "SGetMsg() failed"); -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - RETVALUE(ret1); - } - - if (cmUnpkPjUdxCfgReqInfo(pst, cfgReq, mBuf) != ROK) { - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, cfgReq, sizeof(UdxCfgReqInfo); - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX023, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - break; - } - case UDX_SEL_LWLC: - { - CMCHKUNPK(cmUnpkPtr,(PTR *) &cfgReq, mBuf); - break; - } -#endif /* LCUDX */ - } - PJ_FREE_BUF(mBuf); - RETVALUE((*func)(pst, spId, cfgReq)); -} - -#ifdef ANSI -PUBLIC S16 cmPkPjUdxCfgCfm -( - Pst * pst, - SuId suId, - UdxCfgCfmInfo * cfgCfm - ) -#else -PUBLIC S16 cmPkPjUdxCfgCfm(pst, suId, cfgCfm) - Pst * pst; - SuId suId; - UdxCfgCfmInfo * cfgCfm; -#endif -{ - Buffer *mBuf = NULLP; - TRC3(cmPkPjUdxCfgCfm) - - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ024, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, cfgCfm, sizeof(UdxCfgCfmInfo)); - RETVALUE(RFAILED); - } - switch(pst->selector) - { -#ifdef LCUDX - case UDX_SEL_LC: - { - - if (cmPkPjUdxCfgCfmInfo(cfgCfm, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ025, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, cfgCfm, sizeof(UdxCfgCfmInfo)); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - /* cpj_c_001.main_3 */ - /* Free Confirm Structure after packing */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, cfgCfm, sizeof(UdxCfgCfmInfo)); - - - break; - } - case UDX_SEL_LWLC: - { - CMCHKPKLOG(cmPkPtr,(PTR)cfgCfm,mBuf,EUDXXXX,pst); - break; - } -#endif /* LCUDX */ - - } - - if (SPkS16(suId, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ027, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, cfgCfm, sizeof(UdxCfgCfmInfo)); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - pst->event = (Event) EVTCPJCFGCFM; - RETVALUE(SPstTsk(pst,mBuf)); -} - -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxCfgCfm -( - UdxCfgCfm func, - Pst *pst, - Buffer *mBuf - ) -#else -PUBLIC S16 cmUnpkPjUdxCfgCfm(func, pst, mBuf) - UdxCfgCfm func; - Pst *pst; - Buffer *mBuf; -#endif -{ - S16 ret1; - SuId suId; - UdxCfgCfmInfo *cfgCfm; - - TRC3(cmUnpkPjUdxCfgCfm) - if (SUnpkS16(&suId, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ029, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - switch(pst->selector) - { -#ifdef LCUDX - case UDX_SEL_LC: - { - - - if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&cfgCfm,\ - sizeof(UdxCfgCfmInfo))) != ROK) - { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ040, (ErrVal)0, "SGetMsg() failed"); -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - RETVALUE(ret1); - } - - if (cmUnpkPjUdxCfgCfmInfo(cfgCfm, mBuf) != ROK) { - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, cfgCfm, sizeof(UdxCfgCfmInfo)); - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ031, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - break; - } - case UDX_SEL_LWLC: - { - CMCHKUNPK(cmUnpkPtr,(PTR *) &cfgCfm, mBuf); - break; - } -#endif /* LCUDX */ - } - PJ_FREE_BUF(mBuf); - RETVALUE((*func)(pst, suId, cfgCfm)); -} - - -#ifdef ANSI -PUBLIC S16 cmPkPjUdxReEstReq -( -Pst * pst, -SpId spId, -UdxReEstReqInfo * reEstReq -) -#else -PUBLIC S16 cmPkPjUdxReEstReq(pst, spId, reEstReq) -Pst * pst; -SpId spId; -UdxReEstReqInfo * reEstReq; -#endif -{ - Buffer *mBuf = NULLP; - TRC3(cmPkPjUdxReEstReq) - - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) - { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX032, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, reEstReq, sizeof(UdxReEstReqInfo)); - RETVALUE(RFAILED); - } - switch(pst->selector) - { -#ifdef LCUDX - case UDX_SEL_LC: - { - if (cmPkPjUdxReEstReqInfo(reEstReq, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX033, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, reEstReq, sizeof(UdxReEstReqInfo)); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - /* Free Request Structure after packing */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, reEstReq, sizeof(UdxReEstReqInfo)); - - break; - } - case UDX_SEL_LWLC: - { - CMCHKPKLOG(cmPkPtr,(PTR)reEstReq,mBuf,EUDXXXX,pst); - break; - } -#endif /* LCUDX */ - } - - if (SPkS16(spId, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX035, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, reEstReq, sizeof(UdxReEstReqInfo)); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - - pst->event = (Event) EVTUDXREESTREQ; - RETVALUE(SPstTsk(pst,mBuf)); -} - -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxReEstReq -( -UdxReEstReq func, -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxReEstReq(func, pst, mBuf) -UdxReEstReq func; -Pst *pst; -Buffer *mBuf; -#endif -{ - S16 ret1; - SpId spId; - UdxReEstReqInfo *reEstReq; - - TRC3(cmUnpkPjUdxReEstReq) - - if (SUnpkS16(&spId, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX037, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - switch(pst->selector) - { -#ifdef LCUDX - case UDX_SEL_LC: - { - - if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&reEstReq,\ - sizeof(UdxReEstReqInfo))) != ROK) - { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX040, (ErrVal)0, "SGetMsg() failed"); -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - RETVALUE(ret1); - } - - if (cmUnpkPjUdxReEstReqInfo(reEstReq, mBuf) != ROK) { - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, reEstReq, sizeof(UdxReEstReqInfo)); - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX039, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - break; - } - case UDX_SEL_LWLC: - { - CMCHKUNPK(cmUnpkPtr,(PTR *) &reEstReq, mBuf); - break; - } -#endif /* LCUDX */ -} - - PJ_FREE_BUF(mBuf); - RETVALUE((*func)(pst, spId, reEstReq)); -} - - -#ifdef ANSI -PUBLIC S16 cmPkPjUdxReEstCfm -( - Pst * pst, - SuId suId, - UdxReEstCfmInfo * reEstCfm - ) -#else -PUBLIC S16 cmPkPjUdxReEstCfm(pst, suId, reEstCfm) - Pst * pst; - SuId suId; - UdxReEstCfmInfo * reEstCfm; -#endif -{ - Buffer *mBuf = NULLP; - TRC3(cmPkPjUdxReEstCfm) - - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ040, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, reEstCfm, sizeof(UdxReEstCfmInfo)); - RETVALUE(RFAILED); - } - switch(pst->selector) - { -#ifdef LCUDX - case UDX_SEL_LC: - { - - if (cmPkPjUdxReEstCfmInfo(reEstCfm, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ041, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, reEstCfm, sizeof(UdxReEstCfmInfo)); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - - /* Free Confirm Structure after packing */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, reEstCfm, sizeof(UdxReEstCfmInfo)); - break; - } - case UDX_SEL_LWLC: - { - CMCHKPKLOG(cmPkPtr,(PTR)reEstCfm,mBuf,EUDXXXX,pst); - break; - } -#endif /* LCUDX */ - } - if (SPkS16(suId, mBuf) != ROK) - { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ043, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, reEstCfm, sizeof(UdxReEstCfmInfo)); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - - - pst->event = (Event) EVTCPJREESTCFM; - RETVALUE(SPstTsk(pst,mBuf)); -} - -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxReEstCfm -( - UdxReEstCfm func, - Pst *pst, - Buffer *mBuf - ) -#else -PUBLIC S16 cmUnpkPjUdxReEstCfm(func, pst, mBuf) - UdxReEstCfm func; - Pst *pst; - Buffer *mBuf; -#endif -{ - S16 ret1; - SuId suId; - UdxReEstCfmInfo *reEstCfm; - - TRC3(cmUnpkPjUdxReEstCfm) - - if (SUnpkS16(&suId, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ045, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - switch(pst->selector) - { -#ifdef LCUDX - case UDX_SEL_LC: - { - - - if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&reEstCfm,\ - sizeof(UdxReEstCfmInfo))) != ROK) - { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ040, (ErrVal)0, "SGetMsg() failed"); -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - RETVALUE(ret1); - } - - if (cmUnpkPjUdxReEstCfmInfo(reEstCfm, mBuf) != ROK) { - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, reEstCfm, sizeof(UdxReEstCfmInfo)); - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ047, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - break; - } - case UDX_SEL_LWLC: - { - CMCHKUNPK(cmUnpkPtr,(PTR *) &reEstCfm, mBuf); - break; - } -#endif /* LCUDX */ - } - - PJ_FREE_BUF(mBuf); - RETVALUE((*func)(pst, suId, reEstCfm)); -} - - -#ifdef ANSI -PUBLIC S16 cmPkPjUdxSecCfgReq -( -Pst * pst, -SpId spId, -UdxSecCfgReqInfo * secCfgReq -) -#else -PUBLIC S16 cmPkPjUdxSecCfgReq(pst, spId, secCfgReq) -Pst * pst; -SpId spId; -UdxSecCfgReqInfo * secCfgReq; -#endif -{ - Buffer *mBuf = NULLP; - TRC3(cmPkPjUdxSecCfgReq) - - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX048, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, secCfgReq, sizeof(UdxSecCfgReqInfo)); - RETVALUE(RFAILED); - } - - switch(pst->selector) - { -#ifdef LCUDX - case UDX_SEL_LC: - { - - if (cmPkPjUdxSecCfgReqInfo(secCfgReq, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX049, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, secCfgReq, sizeof(UdxSecCfgReqInfo)); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - /* Free Request Structure after packing */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, secCfgReq, sizeof(UdxSecCfgReqInfo)); - break; - - } - case UDX_SEL_LWLC: - { - CMCHKPKLOG(cmPkPtr,(PTR)secCfgReq,mBuf,EUDXXXX,pst); - break; - } -#endif /* LCUDX */ - } - - if (SPkS16(spId, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX051, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, secCfgReq, sizeof(UdxSecCfgReqInfo)); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - - pst->event = (Event) EVTUDXSECCFGREQ; - RETVALUE(SPstTsk(pst,mBuf)); -} - -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxSecCfgReq -( -UdxSecCfgReq func, -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxSecCfgReq(func, pst, mBuf) -UdxSecCfgReq func; -Pst *pst; -Buffer *mBuf; -#endif -{ - S16 ret1; - SpId spId; - UdxSecCfgReqInfo *secCfgReq; - - TRC3(cmUnpkPjUdxSecCfgReq) - - if (SUnpkS16(&spId, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX053, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - switch(pst->selector) - { -#ifdef LCUDX - case UDX_SEL_LC: - { - - if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&secCfgReq,\ - sizeof(UdxSecCfgReqInfo))) != ROK) - { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX040, (ErrVal)0, "SGetMsg() failed"); -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - RETVALUE(ret1); - } - - if (cmUnpkPjUdxSecCfgReqInfo(secCfgReq, mBuf) != ROK) { - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, secCfgReq, sizeof(UdxSecCfgReqInfo)); - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX055, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - break; - - } - case UDX_SEL_LWLC: - { - CMCHKUNPK(cmUnpkPtr,(PTR *) &secCfgReq,mBuf); - break; - } -#endif /* LCUDX */ - } - PJ_FREE_BUF(mBuf); - RETVALUE((*func)(pst, spId, secCfgReq)); -} - - -#ifdef ANSI -PUBLIC S16 cmPkPjUdxSecCfgCfm -( - Pst * pst, - SuId suId, - UdxSecCfgCfmInfo * secCfgCfm - ) -#else -PUBLIC S16 cmPkPjUdxSecCfgCfm(pst, suId, secCfgCfm) - Pst * pst; - SuId suId; - UdxSecCfgCfmInfo * secCfgCfm; -#endif -{ - Buffer *mBuf = NULLP; - TRC3(cmPkPjUdxSecCfgCfm) - - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ056, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, secCfgCfm, sizeof(UdxSecCfgCfmInfo)); - RETVALUE(RFAILED); - } - switch(pst->selector) - { -#ifdef LCUDX - case UDX_SEL_LC: - { - - - if (cmPkPjUdxSecCfgCfmInfo(secCfgCfm, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ057, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, secCfgCfm, sizeof(UdxSecCfgCfmInfo)); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - /* Free Confirm Structure after packing */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, secCfgCfm, sizeof(UdxSecCfgCfmInfo)); - - - break; - - } - case UDX_SEL_LWLC: - { - CMCHKPKLOG(cmPkPtr,(PTR)secCfgCfm,mBuf,EUDXXXX,pst); - break; - } -#endif /* LCUDX */ - } - - - - if (SPkS16(suId, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ059, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, secCfgCfm, sizeof(UdxSecCfgCfmInfo)); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - - pst->event = (Event) EVTCPJSECCFGCFM; - RETVALUE(SPstTsk(pst,mBuf)); -} - -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxSecCfgCfm -( - UdxSecCfgCfm func, - Pst *pst, - Buffer *mBuf - ) -#else -PUBLIC S16 cmUnpkPjUdxSecCfgCfm(func, pst, mBuf) - UdxSecCfgCfm func; - Pst *pst; - Buffer *mBuf; -#endif -{ - S16 ret1; - SuId suId; - UdxSecCfgCfmInfo *secCfgCfm; - - TRC3(cmUnpkPjUdxSecCfgCfm) - - if (SUnpkS16(&suId, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ061, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - switch(pst->selector) - { -#ifdef LCUDX - case UDX_SEL_LC: - { - - - if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&secCfgCfm,\ - sizeof(UdxSecCfgCfmInfo))) != ROK) - { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ040, (ErrVal)0, "SGetMsg() failed"); -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - RETVALUE(ret1); - } - - if (cmUnpkPjUdxSecCfgCfmInfo(secCfgCfm, mBuf) != ROK) { - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, secCfgCfm, sizeof(UdxSecCfgCfmInfo)); - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ063, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - break; - - } - case UDX_SEL_LWLC: - { - CMCHKUNPK(cmUnpkPtr,(PTR *)&secCfgCfm,mBuf); - break; - } -#endif /* LCUDX */ - } - PJ_FREE_BUF(mBuf); - RETVALUE((*func)(pst, suId, secCfgCfm)); -} - - -#ifdef ANSI -PUBLIC S16 cmPkPjUdxUeIdChgReq -( -Pst * pst, -SpId spId, -U32 transId, -UdxUeInfo * oldUeInfo, -UdxUeInfo * newUeInfo -) -#else -PUBLIC S16 cmPkPjUdxUeIdChgReq(pst, spId, transId, oldUeInfo, newUeInfo) -Pst * pst; -SpId spId; -U32 transId; -UdxUeInfo * oldUeInfo; -UdxUeInfo * newUeInfo; -#endif -{ - Buffer *mBuf = NULLP; - TRC3(cmPkPjUdxUeIdChgReq) - - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX064, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, oldUeInfo, sizeof(UdxUeInfo)); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, newUeInfo, sizeof(UdxUeInfo)); - RETVALUE(RFAILED); - } - if (cmPkPjUdxUeInfo(newUeInfo, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX065, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, oldUeInfo, sizeof(UdxUeInfo)); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, newUeInfo, sizeof(UdxUeInfo)); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - - if (cmPkPjUdxUeInfo(oldUeInfo, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX067, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, oldUeInfo, sizeof(UdxUeInfo)); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, newUeInfo, sizeof(UdxUeInfo)); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - - if (SPkU32(transId, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX069, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, oldUeInfo, sizeof(UdxUeInfo)); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, newUeInfo, sizeof(UdxUeInfo)); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - if (SPkS16(spId, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX070, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, oldUeInfo, sizeof(UdxUeInfo)); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, newUeInfo, sizeof(UdxUeInfo)); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - - /* Free Request Structure after packing */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, oldUeInfo, sizeof(UdxUeInfo)); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, newUeInfo, sizeof(UdxUeInfo)); - - pst->event = (Event) EVTUDXUEIDCHGREQ; - RETVALUE(SPstTsk(pst,mBuf)); -} - -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxUeIdChgReq -( -UdxUeIdChgReq func, -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxUeIdChgReq(func, pst, mBuf) -UdxUeIdChgReq func; -Pst *pst; -Buffer *mBuf; -#endif -{ - S16 ret1; - SpId spId; - U32 transId; - UdxUeInfo *oldUeInfo; - UdxUeInfo *newUeInfo; - - TRC3(cmUnpkPjUdxUeIdChgReq) - - if (SUnpkS16(&spId, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX073, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - if (SUnpkU32(&transId, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX074, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - - if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&oldUeInfo,\ - sizeof(UdxUeInfo))) != ROK) - { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX040, (ErrVal)0, "SGetMsg() failed"); -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - RETVALUE(ret1); - } - - if (cmUnpkPjUdxUeInfo(oldUeInfo, mBuf) != ROK) { - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, oldUeInfo, sizeof(UdxUeInfo)); - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX076, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - - if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&newUeInfo,\ - sizeof(UdxUeInfo))) != ROK) - { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX040, (ErrVal)0, "SGetMsg() failed"); -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - RETVALUE(ret1); - } - - if (cmUnpkPjUdxUeInfo(newUeInfo, mBuf) != ROK) - { - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, oldUeInfo, sizeof(UdxUeInfo)); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, newUeInfo, sizeof(UdxUeInfo)); - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX078, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - PJ_FREE_BUF(mBuf); - RETVALUE((*func)(pst, spId, transId, oldUeInfo, newUeInfo)); -} - - -#ifdef ANSI -PUBLIC S16 cmPkPjUdxUeIdChgCfm -( -Pst * pst, -SuId suId, -U32 transId, -UdxUeInfo * ueInfo, -CmStatus status -) -#else -PUBLIC S16 cmPkPjUdxUeIdChgCfm(pst, suId, transId, ueInfo, status) -Pst * pst; -SuId suId; -U32 transId; -UdxUeInfo * ueInfo; -CmStatus status; -#endif -{ - Buffer *mBuf = NULLP; - TRC3(cmPkPjUdxUeIdChgCfm) - - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ079, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, ueInfo, sizeof(UdxUeInfo)); - RETVALUE(RFAILED); - } - if (cmPkCmStatus(&status, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ080, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, ueInfo, sizeof(UdxUeInfo)); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - if (cmPkPjUdxUeInfo(ueInfo, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ081, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, ueInfo, sizeof(UdxUeInfo)); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - - if (SPkU32(transId, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ083, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, ueInfo, sizeof(UdxUeInfo)); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - if (SPkS16(suId, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ084, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, ueInfo, sizeof(UdxUeInfo)); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - - /* Free Confirm Structure after packing */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, ueInfo, sizeof(UdxUeInfo)); - - pst->event = (Event) EVTCPJUEIDCHGCFM; - RETVALUE(SPstTsk(pst,mBuf)); -} - -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxUeIdChgCfm -( -UdxUeIdChgCfm func, -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxUeIdChgCfm(func, pst, mBuf) -UdxUeIdChgCfm func; -Pst *pst; -Buffer *mBuf; -#endif -{ - S16 ret1; - SuId suId; - U32 transId; - UdxUeInfo *ueInfo; - CmStatus status; - - TRC3(cmUnpkPjUdxUeIdChgCfm) - - if (SUnpkS16(&suId, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ086, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - if (SUnpkU32(&transId, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ087, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - - if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&ueInfo,\ - sizeof(UdxUeInfo))) != ROK) - { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ040, (ErrVal)0, "SGetMsg() failed"); -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - RETVALUE(ret1); - } - - if (cmUnpkPjUdxUeInfo(ueInfo, mBuf) != ROK) { - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, ueInfo, sizeof(UdxUeInfo)); - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ089, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - if (cmUnpkCmStatus(&status, mBuf) != ROK) { - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, ueInfo, sizeof(UdxUeInfo)); - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ090, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - PJ_FREE_BUF(mBuf); - RETVALUE((*func)(pst, suId, transId, ueInfo, status)); -} - -#ifdef ANSI -PUBLIC S16 cmPkPjUdxCountReq -( -Pst * pst, -SpId spId, -UdxCountReqInfo * countReq -) -#else -PUBLIC S16 cmPkPjUdxCountReq(pst, spId, countReq) -Pst * pst; -SpId spId; -UdxCountReqInfo * countReq; -#endif -{ - Buffer *mBuf = NULLP; - TRC3(cmPkPjUdxCountReq) - - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX091, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, countReq, sizeof(UdxCountReqInfo)); - RETVALUE(RFAILED); - } - - switch(pst->selector) - { -#ifdef LCUDX - case UDX_SEL_LC: - { - - if (cmPkPjUdxCountReqInfo(countReq, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX092, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, countReq, sizeof(UdxCountReqInfo)); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - /* Free Request Structure after packing */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, countReq, sizeof(UdxCountReqInfo)); - break; - } - case UDX_SEL_LWLC: - { - CMCHKPKLOG(cmPkPtr,(PTR)countReq,mBuf,EUDXXXX,pst); - break; - } -#endif /* LCUDX */ - } - - if (SPkS16(spId, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX094, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, countReq, sizeof(UdxCountReqInfo)); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - - pst->event = (Event) EVTUDXCOUNTREQ; - RETVALUE(SPstTsk(pst,mBuf)); -} - -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxCountReq -( -UdxCountReq func, -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxCountReq(func, pst, mBuf) -UdxCountReq func; -Pst *pst; -Buffer *mBuf; -#endif -{ - S16 ret1; - SpId spId; - UdxCountReqInfo *countReq; - - TRC3(cmUnpkPjUdxCountReq) - - if (SUnpkS16(&spId, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX096, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - switch(pst->selector) - { -#ifdef LCUDX - case UDX_SEL_LC: - { - - if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&countReq,\ - sizeof(UdxCountReqInfo))) != ROK) - { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX040, (ErrVal)0, "SGetMsg() failed"); -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - RETVALUE(ret1); - } - - if (cmUnpkPjUdxCountReqInfo(countReq, mBuf) != ROK) { - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, countReq, sizeof(UdxCountReqInfo)); - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX098, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - break; - } - case UDX_SEL_LWLC: - { - CMCHKUNPK(cmUnpkPtr,(PTR *) &countReq,mBuf); - break; - } -#endif /* LCUDX */ -} - -PJ_FREE_BUF(mBuf); - RETVALUE((*func)(pst, spId, countReq)); -} - - -#ifdef ANSI -PUBLIC S16 cmPkPjUdxCountCfm -( -Pst * pst, -SuId suId, -UdxCountCfmInfo * countCfm -) -#else -PUBLIC S16 cmPkPjUdxCountCfm(pst, suId, countCfm) -Pst * pst; -SuId suId; -UdxCountCfmInfo * countCfm; -#endif -{ - Buffer *mBuf = NULLP; - TRC3(cmPkPjUdxCountCfm) - - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ099, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, countCfm, sizeof(UdxCountCfmInfo)); - RETVALUE(RFAILED); - } - switch(pst->selector) - { -#ifdef LCUDX - case UDX_SEL_LC: - { - - if (cmPkPjUdxCountCfmInfo(countCfm, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ100, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, countCfm, sizeof(UdxCountCfmInfo)); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - /* Free Confirm Structure after packing */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, countCfm, sizeof(UdxCountCfmInfo)); - - break; - } - case UDX_SEL_LWLC: - { - CMCHKPKLOG(cmPkPtr,(PTR)countCfm,mBuf,EUDXXXX,pst); - break; - } -#endif /* LCUDX */ - } - - if (SPkS16(suId, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ102, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, countCfm, sizeof(UdxCountCfmInfo)); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - - pst->event = (Event) EVTCPJCOUNTCFM; - RETVALUE(SPstTsk(pst,mBuf)); -} - -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxCountCfm -( -UdxCountCfm func, -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxCountCfm(func, pst, mBuf) -UdxCountCfm func; -Pst *pst; -Buffer *mBuf; -#endif -{ - S16 ret1; - SuId suId; - UdxCountCfmInfo *countCfm = NULLP; - - TRC3(cmUnpkPjUdxCountCfm) - - if (SUnpkS16(&suId, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ104, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - - switch(pst->selector) - { -#ifdef LCUDX - case UDX_SEL_LC: - { - - - if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&countCfm,\ - sizeof(UdxCountCfmInfo))) != ROK) - { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ040, (ErrVal)0, "SGetMsg() failed"); -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - RETVALUE(ret1); - } - - if (cmUnpkPjUdxCountCfmInfo(countCfm, mBuf) != ROK) { - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, countCfm, sizeof(UdxCountCfmInfo)); - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ106, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - break; - } - case UDX_SEL_LWLC: - { - CMCHKUNPK(cmUnpkPtr,(PTR *) &countCfm,mBuf); - break; - } -#endif /* LCUDX */ -} - -PJ_FREE_BUF(mBuf); - RETVALUE((*func)(pst, suId, countCfm)); -} - - -#ifdef ANSI -PUBLIC S16 cmPkPjUdxSduStaReq -( -Pst * pst, -SpId spId, -UdxSduStaReqInfo * staReq -) -#else -PUBLIC S16 cmPkPjUdxSduStaReq(pst, spId, staReq) -Pst * pst; -SpId spId; -UdxSduStaReqInfo * staReq; -#endif -{ - Buffer *mBuf = NULLP; - TRC3(cmPkPjUdxSduStaReq) - - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX107, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staReq, sizeof(UdxSduStaReqInfo)); - RETVALUE(RFAILED); - } - - switch(pst->selector) - { -#ifdef LCUDX - case UDX_SEL_LC: - { - - if (cmPkPjUdxSduStaReqInfo(staReq, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX108, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staReq, sizeof(UdxSduStaReqInfo)); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - /* Free Request Structure after packing */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staReq, sizeof(UdxSduStaReqInfo)); - - - break; - } - case UDX_SEL_LWLC: - { - CMCHKPKLOG(cmPkPtr,(PTR)staReq,mBuf,EUDXXXX,pst); - break; - } -#endif /* LCUDX */ -} - if (SPkS16(spId, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX110, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staReq, sizeof(UdxSduStaReqInfo)); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - - pst->event = (Event) EVTUDXSDUSTAREQ; - RETVALUE(SPstTsk(pst,mBuf)); -} - -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxSduStaReq -( -UdxSduStaReq func, -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxSduStaReq(func, pst, mBuf) -UdxSduStaReq func; -Pst *pst; -Buffer *mBuf; -#endif -{ - S16 ret1; - SpId spId; - UdxSduStaReqInfo *staReq; - - TRC3(cmUnpkPjUdxSduStaReq) - - if (SUnpkS16(&spId, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX112, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - switch(pst->selector) - { -#ifdef LCUDX - case UDX_SEL_LC: - { - - if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&staReq,\ - sizeof(UdxSduStaReqInfo))) != ROK) - { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX040, (ErrVal)0, "SGetMsg() failed"); -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - RETVALUE(ret1); - } - - if (cmUnpkPjUdxSduStaReqInfo(staReq, mBuf) != ROK) { - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staReq, sizeof(UdxSduStaReqInfo)); - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX114, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - break; - } - case UDX_SEL_LWLC: - { - CMCHKUNPK(cmUnpkPtr,(PTR *) &staReq,mBuf); - break; - } -#endif /* LCUDX */ -} -PJ_FREE_BUF(mBuf); - RETVALUE((*func)(pst, spId, staReq)); -} - - -#ifdef ANSI -PUBLIC S16 cmPkPjUdxSduStaCfm -( - Pst * pst, - SuId suId, - UdxSduStaCfmInfo * staCfm - ) -#else -PUBLIC S16 cmPkPjUdxSduStaCfm(pst, suId, staCfm) - Pst * pst; - SuId suId; - UdxSduStaCfmInfo * staCfm; -#endif -{ - Buffer *mBuf = NULLP; - TRC3(cmPkPjUdxSduStaCfm) - - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ115, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staCfm, sizeof(UdxSduStaCfmInfo)); - RETVALUE(RFAILED); - } - switch(pst->selector) - { -#ifdef LCUDX - case UDX_SEL_LC: - { - - - if (cmPkPjUdxSduStaCfmInfo(pst, staCfm, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ116, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staCfm, sizeof(UdxSduStaCfmInfo)); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - break; - } - case UDX_SEL_LWLC: - { - CMCHKPKLOG(cmPkPtr,(PTR)staCfm,mBuf,EUDXXXX,pst); - break; - } -#endif /* LCUDX */ - } - - if (SPkS16(suId, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ118, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staCfm, sizeof(UdxSduStaCfmInfo)); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - - /* Free Confirm Structure after packing */ - /*SPutSBuf(pst->region, pst->pool, (Data *)staCfm, sizeof(UdxSduStaCfmInfo));*/ - - pst->event = (Event) EVTUDXSDUSTACFM; - RETVALUE(SPstTsk(pst,mBuf)); -} - -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxSduStaCfm -( - UdxSduStaCfm func, - Pst *pst, - Buffer *mBuf - ) -#else -PUBLIC S16 cmUnpkPjUdxSduStaCfm(func, pst, mBuf) - UdxSduStaCfm func; - Pst *pst; - Buffer *mBuf; -#endif -{ - S16 ret1; - SuId suId; - UdxSduStaCfmInfo *staCfm; - - TRC3(cmUnpkPjUdxSduStaCfm) - - if (SUnpkS16(&suId, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ120, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - switch(pst->selector) - { -#ifdef LCUDX - case UDX_SEL_LC: - { - if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&staCfm,\ - sizeof(UdxSduStaCfmInfo))) != ROK) - { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ040, (ErrVal)0, "SGetMsg() failed"); -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - RETVALUE(ret1); - } - - if (cmUnpkPjUdxSduStaCfmInfo(pst, staCfm, mBuf) != ROK) { - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staCfm, sizeof(UdxSduStaCfmInfo)); - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ122, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - } - break; - - case UDX_SEL_LWLC: - { - CMCHKUNPK(cmUnpkPtr,(PTR *) &staCfm,mBuf); - } - break; - } -#endif /* LCUDX */ - - - PJ_FREE_BUF(mBuf); - RETVALUE((*func)(pst, suId, staCfm)); -} - -#ifdef ANSI -PUBLIC S16 cmPkPjUdxDatResumeCfm -( - Pst * pst, - SuId suId, - UdxDatResumeCfmInfo * datResumeCfm - ) -#else -PUBLIC S16 cmPkPjUdxDatResumeCfm(pst, suId, datResumeCfm) - Pst * pst; - SuId suId; - UdxDatResumeCfmInfo * datResumeCfm; -#endif -{ - Buffer *mBuf = NULLP; - TRC3(cmPkPjUdxDatResumeCfm) - - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ115, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datResumeCfm, sizeof(UdxDatResumeCfmInfo)); - RETVALUE(RFAILED); - } - switch(pst->selector) - { -#ifdef LCUDX - case UDX_SEL_LC: - { - if (cmPkPjUdxDatResumeCfmInfo(pst, datResumeCfm, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ116, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datResumeCfm, sizeof(UdxDatResumeCfmInfo)); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - break; - } - case UDX_SEL_LWLC: - { - CMCHKPKLOG(cmPkPtr,(PTR)datResumeCfm,mBuf,EUDXXXX,pst); - break; - } -#endif /* LCUDX */ - } - - if (SPkS16(suId, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ118, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datResumeCfm, sizeof(UdxDatResumeCfmInfo)); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - - /* Free Confirm Structure after packing */ - /*SPutSBuf(pst->region, pst->pool, (Data *)datResumeCfm, sizeof(UdxSduStaCfmInfo));*/ - - pst->event = (Event) EVTUDXDATRESUMECFM; - RETVALUE(SPstTsk(pst,mBuf)); -} - -/* -* -* Fun: cmPkPjUdxDatForwardCfm -* -* Ret: ROK -ok -* -* Notes: None -* -* -*/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxDatForwardCfm -( - Pst * pst, - SuId suId, - UdxDatFwdCfmInfo * datFwdCfm - ) -#else -PUBLIC S16 cmPkPjUdxDatForwardCfm(pst, suId, datFwdCfm) - Pst * pst; - SuId suId; - UdxDatFwdCfmInfo * datFwdCfm; -#endif -{ - - Buffer *mBuf = NULLP; - TRC3(cmPkPjUdxDatForwardCfm) - - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ115, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datFwdCfm, sizeof(UdxDatFwdCfmInfo)); - RETVALUE(RFAILED); - } - - switch(pst->selector) - { -#ifdef LCUDX - case UDX_SEL_LC: - { - if (cmPkPjUdxDatForwardCfmInfo(pst, datFwdCfm, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ116, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datFwdCfm, sizeof(UdxDatFwdCfmInfo)); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - break; - } - case UDX_SEL_LWLC: - { - CMCHKPKLOG(cmPkPtr,(PTR)datFwdCfm,mBuf,EUDXXXX,pst); - break; - } -#endif /* LCUDX */ - } - - if (SPkS16(suId, mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ118, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datFwdCfm, sizeof(UdxDatFwdCfmInfo)); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - - /* Free Confirm Structure after packing */ - /*SPutSBuf(pst->region, pst->pool, (Data *)datFwdCfm, sizeof(UdxDatFwdCfmInfo));*/ - - pst->event = (Event) EVTUDXDATFRWDCFM; - RETVALUE(SPstTsk(pst,mBuf)); -} - -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxDatResumeCfm -( - UdxDatResumeCfm func, - Pst *pst, - Buffer *mBuf - ) -#else -PUBLIC S16 cmUnpkPjUdxDatResumeCfm(func, pst, mBuf) - UdxDatResumeCfm func; - Pst *pst; - Buffer *mBuf; -#endif -{ - S16 ret1; - SuId suId; - UdxDatResumeCfmInfo *datResumeCfm = NULLP; - - TRC3(cmUnpkPjUdxDatResumeCfm) - - RLOG0(L_DEBUG," Unpacking UdxDatResumeCfm"); - if (SUnpkS16(&suId, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ120, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - switch(pst->selector) - { -#ifdef LCUDX - case UDX_SEL_LC: - { - if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&datResumeCfm,\ - sizeof(UdxDatResumeCfmInfo))) != ROK) - { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ040, (ErrVal)0, "SGetMsg() failed"); -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - RETVALUE(ret1); - } - - if (cmUnpkPjUdxDatResumeCfmInfo(pst, datResumeCfm, mBuf) != ROK) { - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datResumeCfm, sizeof(UdxDatResumeCfmInfo)); - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ122, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - } - break; - - case UDX_SEL_LWLC: - { - CMCHKUNPK(cmUnpkPtr,(PTR *) &datResumeCfm,mBuf); - } - break; - } -#endif /* LCUDX */ - - - PJ_FREE_BUF(mBuf); - RETVALUE((*func)(pst, suId, datResumeCfm)); -} - -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxDatForwardCfm -( - UdxDatForwardCfm func, - Pst *pst, - Buffer *mBuf - ) -#else -PUBLIC S16 cmUnpkPjUdxDatForwardCfm(func, pst, mBuf) - UdxDatForwardCfm func; - Pst *pst; - Buffer *mBuf; -#endif -{ - S16 ret1; - SuId suId; - UdxDatFwdCfmInfo *datFwdCfm; - - TRC3(cmUnpkPjUdxDatForwardCfm) - - if (SUnpkS16(&suId, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ120, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - switch(pst->selector) - { -#ifdef LCUDX - case UDX_SEL_LC: - { - if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&datFwdCfm,\ - sizeof(UdxDatFwdCfmInfo))) != ROK) - { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ040, (ErrVal)0, "SGetMsg() failed"); -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - RETVALUE(ret1); - } - - if (cmUnpkPjUdxDatForwardCfmInfo(pst, datFwdCfm, mBuf) != ROK) { - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datFwdCfm, sizeof(UdxDatFwdCfmInfo)); - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)ECPJ122, (ErrVal)0, "Packing failed"); -#endif - RETVALUE(RFAILED); - } - } - break; - - case UDX_SEL_LWLC: - { - CMCHKUNPK(cmUnpkPtr,(PTR *) &datFwdCfm,mBuf); - } - break; - } -#endif /* LCUDX */ - - PJ_FREE_BUF(mBuf); - RETVALUE((*func)(pst, suId, datFwdCfm)); -} - - - -/*********************************************************** -* -* Func : cmPkPjUdxRlcAm -* -* -* Desc : * RLC parameter information in AM mode. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxRlcAm -( -UdxRlcAm *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjUdxRlcAm(param, mBuf) -UdxRlcAm *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmPkPjUdxRlcAm) - - CMCHKPK(SPkU8, param->statusRepReqd, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmUnpkPjUdxRlcAm -* -* -* Desc : * RLC parameter information in AM mode. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxRlcAm -( -UdxRlcAm *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxRlcAm(param, mBuf) -UdxRlcAm *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmUnpkPjUdxRlcAm) - - CMCHKUNPK(SUnpkU8, ¶m->statusRepReqd, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmPkPjUdxRlcUm -* -* -* Desc : * RLC parameter information in UM mode. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxRlcUm -( -UdxRlcUm *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjUdxRlcUm(param, mBuf) -UdxRlcUm *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmPkPjUdxRlcUm) - - CMCHKPK(SPkU8, param->pdcpSNSize, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmUnpkPjUdxRlcUm -* -* -* Desc : * RLC parameter information in UM mode. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxRlcUm -( -UdxRlcUm *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxRlcUm(param, mBuf) -UdxRlcUm *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmUnpkPjUdxRlcUm) - - CMCHKUNPK(SUnpkU8, ¶m->pdcpSNSize, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmPkPjUdxRlcInfo -* -* -* Desc : * Mapped RLC entity information in RLC for the PDCP entity -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxRlcInfo -( -UdxRlcInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjUdxRlcInfo(param, mBuf) -UdxRlcInfo *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmPkPjUdxRlcInfo) - - switch(param->mode) { - case CM_LTE_MODE_UM: - CMCHKPK(cmPkPjUdxRlcUm, ¶m->m.rlcUm, mBuf); - break; - case CM_LTE_MODE_AM: - CMCHKPK(cmPkPjUdxRlcAm, ¶m->m.rlcAm, mBuf); - break; - default : - RETVALUE(RFAILED); - } - CMCHKPK(SPkU8, param->mode, mBuf); - CMCHKPK(SPkU8, param->dir, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmUnpkPjUdxRlcInfo -* -* -* Desc : * Mapped RLC entity information in RLC for the PDCP entity -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxRlcInfo -( -UdxRlcInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxRlcInfo(param, mBuf) -UdxRlcInfo *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmUnpkPjUdxRlcInfo) - - CMCHKUNPK(SUnpkU8, ¶m->dir, mBuf); - CMCHKUNPK(SUnpkU8, ¶m->mode, mBuf); - switch(param->mode) { - case CM_LTE_MODE_AM: - CMCHKUNPK(cmUnpkPjUdxRlcAm, ¶m->m.rlcAm, mBuf); - break; - case CM_LTE_MODE_UM: - CMCHKUNPK(cmUnpkPjUdxRlcUm, ¶m->m.rlcUm, mBuf); - break; - default : - RETVALUE(RFAILED); - } - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmPkPjUdxCipherInfo -* -* -* Desc : * Ciphering information to be configured per UE in PDCP. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxCipherInfo -( -UdxCipherInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjUdxCipherInfo(param, mBuf) -UdxCipherInfo *param; -Buffer *mBuf; -#endif -{ - - S32 i; - TRC3(cmPkPjUdxCipherInfo) - - CMCHKPK(SPkU8, param->algoType, mBuf); - for (i=UDX_CIPHER_KEY_LEN-1; i >= 0; i--) { - CMCHKPK(SPkU8, param->usrplnKey[i], mBuf); - } - for (i=UDX_CIPHER_KEY_LEN-1; i >= 0; i--) { - CMCHKPK(SPkU8, param->ctrlplnKey[i], mBuf); - } - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmUnpkPjUdxCipherInfo -* -* -* Desc : * Ciphering information to be configured per UE in PDCP. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxCipherInfo -( -UdxCipherInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxCipherInfo(param, mBuf) -UdxCipherInfo *param; -Buffer *mBuf; -#endif -{ - - S32 i; - TRC3(cmUnpkPjUdxCipherInfo) - - for (i=0; ictrlplnKey[i], mBuf); - } - for (i=0; iusrplnKey[i], mBuf); - } - CMCHKUNPK(SUnpkU8, ¶m->algoType, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmPkPjUdxIntegInfo -* -* -* Desc : * Integrity protection paramater information. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxIntegInfo -( -UdxIntegInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjUdxIntegInfo(param, mBuf) -UdxIntegInfo *param; -Buffer *mBuf; -#endif -{ - - S32 i; - TRC3(cmPkPjUdxIntegInfo) - - for (i=UDX_INTG_KEY_LEN-1; i >= 0; i--) { - CMCHKPK(SPkU8, param->intKey[i], mBuf); - } - CMCHKPK(SPkU8, param->algoType, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmUnpkPjUdxIntegInfo -* -* -* Desc : * Integrity protection paramater information. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxIntegInfo -( -UdxIntegInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxIntegInfo(param, mBuf) -UdxIntegInfo *param; -Buffer *mBuf; -#endif -{ - - S32 i; - TRC3(cmUnpkPjUdxIntegInfo) - - CMCHKUNPK(SUnpkU8, ¶m->algoType, mBuf); - for (i=0; iintKey[i], mBuf); - } - RETVALUE(ROK); -} - - -/*********************************************************** -* -* Func : cmPkPjUdxSecCfg -* -* -* Desc : * PDCP Security configuration parameter. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxSecCfg -( -UdxSecCfg *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjUdxSecCfg(param, mBuf) -UdxSecCfg *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmPkPjUdxSecCfg) - - CMCHKPK(cmPkPjUdxCipherInfo, ¶m->cipherInfo, mBuf); - CMCHKPK(cmPkPjUdxIntegInfo, ¶m->integInfo, mBuf); - CMCHKPK(SPkU8, param->selSecAct, mBuf); - CMCHKPK(SPkU8, param->isHo, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmUnpkPjUdxSecCfg -* -* -* Desc : * PDCP Security configuration parameter. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxSecCfg -( -UdxSecCfg *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxSecCfg(param, mBuf) -UdxSecCfg *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmUnpkPjUdxSecCfg) - - CMCHKUNPK(SUnpkU8, ¶m->isHo, mBuf); - CMCHKUNPK(SUnpkU8, ¶m->selSecAct, mBuf); - CMCHKUNPK(cmUnpkPjUdxIntegInfo, ¶m->integInfo, mBuf); - CMCHKUNPK(cmUnpkPjUdxCipherInfo, ¶m->cipherInfo, mBuf); - RETVALUE(ROK); -} - - -/*********************************************************** -* -* Func : cmPkPjUdxRohcInfo -* -* -* Desc : * ROHC compression protocol information structure. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxRohcInfo -( -UdxRohcInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjUdxRohcInfo(param, mBuf) -UdxRohcInfo *param; -Buffer *mBuf; -#endif -{ - - S32 i; - TRC3(cmPkPjUdxRohcInfo) - - for (i=UDX_MAX_ROHC_PROF_LIST-1; i >= 0; i--) { - CMCHKPK(SPkU8, param->profLst[i], mBuf); - } - CMCHKPK(SPkU16, param->maxCid, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmUnpkPjUdxRohcInfo -* -* -* Desc : * ROHC compression protocol information structure. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxRohcInfo -( -UdxRohcInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxRohcInfo(param, mBuf) -UdxRohcInfo *param; -Buffer *mBuf; -#endif -{ - - S32 i; - TRC3(cmUnpkPjUdxRohcInfo) - - CMCHKUNPK(SUnpkU16, ¶m->maxCid, mBuf); - for (i=0; iprofLst[i], mBuf); - } - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmPkPjUdxHdrCompCfg -* -* -* Desc : * ROHC configuration information for PDCP entity. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxHdrCompCfg -( -UdxHdrCompCfg *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjUdxHdrCompCfg(param, mBuf) -UdxHdrCompCfg *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmPkPjUdxHdrCompCfg) - - CMCHKPK(cmPkPjUdxRohcInfo, ¶m->rohcInfo, mBuf); - CMCHKPK(SPkU8, param->hdrCompUsed, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmUnpkPjUdxHdrCompCfg -* -* -* Desc : * ROHC configuration information for PDCP entity. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxHdrCompCfg -( -UdxHdrCompCfg *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxHdrCompCfg(param, mBuf) -UdxHdrCompCfg *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmUnpkPjUdxHdrCompCfg) - - CMCHKUNPK(SUnpkU8, ¶m->hdrCompUsed, mBuf); - CMCHKUNPK(cmUnpkPjUdxRohcInfo, ¶m->rohcInfo, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmPkPjUdxHoInfo -* -* -* Desc : * Handover Information for RB. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxHoInfo -( -Pst *pst, -UdxHoInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjUdxHoInfo(pst, param, mBuf) -Pst *pst; -UdxHoInfo *param; -Buffer *mBuf; -#endif -{ - S16 cnt, idx; - - TRC3(cmPkPjUdxHoInfo) - - if (param->numBits % 8 == 0) - cnt = param->numBits/8; - else - cnt = param->numBits/8 + 1; - - for (idx = cnt-1; idx >= 0; idx--) - { - CMCHKPK(SPkU8, param->ulBitMap[idx], mBuf); - } - - /* Free ulBitMap after packing */ - if (cnt) - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, param->ulBitMap, cnt * sizeof(U8)); - - CMCHKPK(SPkU16, param->numBits, mBuf); - CMCHKPK(SPkU32, param->ulCount, mBuf); - CMCHKPK(SPkU32, param->dlCount, mBuf); - CMCHKPK(SPkU8, param->isHoPres, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmUnpkPjUdxHoInfo -* -* -* Desc : * Handover Information for RB. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxHoInfo -( -Pst *pst, -UdxHoInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxHoInfo(pst, param, mBuf) -Pst *pst; -UdxHoInfo *param; -Buffer *mBuf; -#endif -{ - S16 cnt, idx; - S16 ret1 = ROK; - - TRC3(cmUnpkPjUdxHoInfo) - - CMCHKUNPK(SUnpkU8, ¶m->isHoPres, mBuf); - CMCHKUNPK(SUnpkU32, ¶m->dlCount, mBuf); - CMCHKUNPK(SUnpkU32, ¶m->ulCount, mBuf); - CMCHKUNPK(SUnpkU16, ¶m->numBits, mBuf); - - if (param->numBits % 8 == 0) - cnt = param->numBits/8; - else - cnt = param->numBits/8 + 1; - - if(cnt && (ret1 = SGetStaticBuffer(pst->region, pst->pool, (Data **)¶m->ulBitMap,\ - cnt * sizeof(U8), 0)) != ROK) - { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX040, (ErrVal)0, "SGetMsg() failed"); -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - RETVALUE(ret1); - } - - if (cnt == 0) - param->ulBitMap = NULLP; - - for (idx = 0; idx < cnt; idx++) - { - CMCHKUNPK(SUnpkU8, ¶m->ulBitMap[idx], mBuf); - } - - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmPkPjUdxCfgEnt -* -* -* Desc : * Configuration structure for PDCP entity. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxCfgEnt -( -Pst *pst, -UdxCfgEnt *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjUdxCfgEnt(pst, param, mBuf) -Pst *pst; -UdxCfgEnt *param; -Buffer *mBuf; -#endif -{ - TRC3(cmPkPjUdxCfgEnt) - - switch(param->cfgType) { - case UDX_CFG_MODIFY: - if (cmPkPjUdxModCfgEnt(pst, ¶m->m.modCfg, mBuf) != ROK) - RETVALUE(RFAILED); - break; - case UDX_CFG_ADD: - CMCHKPK(cmPkPjUdxAddCfgEnt, ¶m->m.addCfg, mBuf); - break; - } - CMCHKPK(SPkU8, param->cfgType, mBuf); - CMCHKPK(SPkU8, param->rbType, mBuf); - CMCHKPK(SPkU8, param->rbId, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmUnpkPjUdxCfgEnt -* -* -* Desc : * Configuration structure for PDCP entity. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxCfgEnt -( -Pst *pst, -UdxCfgEnt *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxCfgEnt(pst, param, mBuf) -Pst *pst; -UdxCfgEnt *param; -Buffer *mBuf; -#endif -{ - TRC3(cmUnpkPjUdxCfgEnt) - - CMCHKUNPK(SUnpkU8, ¶m->rbId, mBuf); - CMCHKUNPK(SUnpkU8, ¶m->rbType, mBuf); - CMCHKUNPK(SUnpkU8, ¶m->cfgType, mBuf); - switch(param->cfgType) { - case UDX_CFG_ADD: - CMCHKUNPK(cmUnpkPjUdxAddCfgEnt, ¶m->m.addCfg, mBuf); - break; - case UDX_CFG_MODIFY: - if (cmUnpkPjUdxModCfgEnt(pst, ¶m->m.modCfg, mBuf) != ROK) - RETVALUE(RFAILED); - break; - } - RETVALUE(ROK); -} - - -#ifdef ANSI -PUBLIC S16 cmPkPjUdxAddCfgEnt -( -UdxAddCfgEnt *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjUdxAddCfgEnt(param, mBuf) -UdxAddCfgEnt *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmPkPjUdxAddCfgEnt) - - CMCHKPK(cmPkPjUdxHdrCompCfg, ¶m->hdrCompCfg, mBuf); - CMCHKPK(SPkS16, param->discardTmr, mBuf); - CMCHKPK(cmPkPjUdxRlcInfo, ¶m->rlcInfo, mBuf); - /* cpj_c_001.main_4 added support for L2 Measurement */ -#ifdef LTE_L2_MEAS - CMCHKPK(SPkU8, param->qci, mBuf); -#endif /* LTE_L2_MEAS */ - CMCHKPK(SPkU8, param->cfmReqd, mBuf); - CMCHKPK(SPkU8, param->discReqd, mBuf); - RETVALUE(ROK); -} - - -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxAddCfgEnt -( -UdxAddCfgEnt *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxAddCfgEnt(param, mBuf) -UdxAddCfgEnt *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmUnpkPjUdxAddCfgEnt) - - CMCHKUNPK(SUnpkU8, ¶m->discReqd, mBuf); - CMCHKUNPK(SUnpkU8, ¶m->cfmReqd, mBuf); - /* cpj_c_001.main_4 added support for L2 Measurement */ -#ifdef LTE_L2_MEAS - CMCHKUNPK(SUnpkU8, ¶m->qci, mBuf); -#endif /* LTE_L2_MEAS */ - CMCHKUNPK(cmUnpkPjUdxRlcInfo, ¶m->rlcInfo, mBuf); - CMCHKUNPK(SUnpkS16, ¶m->discardTmr, mBuf); - CMCHKUNPK(cmUnpkPjUdxHdrCompCfg, ¶m->hdrCompCfg, mBuf); - RETVALUE(ROK); -} - - -#ifdef ANSI -PUBLIC S16 cmPkPjUdxModCfgEnt -( -Pst *pst, -UdxModCfgEnt *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjUdxModCfgEnt(pst, param, mBuf) -Pst *pst; -UdxModCfgEnt *param; -Buffer *mBuf; -#endif -{ - TRC3(cmPkPjUdxModCfgEnt) - - if (cmPkPjUdxHoInfo(pst, ¶m->hoInfo, mBuf) != ROK) - RETVALUE(RFAILED); - CMCHKPK(cmPkPjUdxHdrCompCfg, ¶m->hdrCompCfg, mBuf); - CMCHKPK(SPkU8, param->cfmReqd, mBuf); - CMCHKPK(SPkU8, param->discReqd, mBuf); - CMCHKPK(SPkU8, param->bitFlag, mBuf); - RETVALUE(ROK); -} - - -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxModCfgEnt -( -Pst *pst, -UdxModCfgEnt *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxModCfgEnt(pst, param, mBuf) -Pst *pst; -UdxModCfgEnt *param; -Buffer *mBuf; -#endif -{ - TRC3(cmUnpkPjUdxModCfgEnt) - - CMCHKUNPK(SUnpkU8, ¶m->bitFlag, mBuf); - CMCHKUNPK(SUnpkU8, ¶m->discReqd, mBuf); - CMCHKUNPK(SUnpkU8, ¶m->cfmReqd, mBuf); - CMCHKUNPK(cmUnpkPjUdxHdrCompCfg, ¶m->hdrCompCfg, mBuf); - if (cmUnpkPjUdxHoInfo(pst, ¶m->hoInfo, mBuf) != ROK) - RETVALUE(RFAILED); - RETVALUE(ROK); -} - - -/*********************************************************** -* -* Func : cmPkPjUdxCfgReqInfo -* -* -* Desc : * PDCP Configuration structure. Parameters are filled by RRC - layer while configuring the PDCP layer. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxCfgReqInfo -( -Pst *pst, -UdxCfgReqInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjUdxCfgReqInfo(pst, param, mBuf) -Pst *pst; -UdxCfgReqInfo *param; -Buffer *mBuf; -#endif -{ - S32 i; - - TRC3(cmPkPjUdxCfgReqInfo) - - for (i=param->numEnt-1; i >= 0; i--) { - if (cmPkPjUdxCfgEnt(pst, ¶m->cfgEnt[i], mBuf) != ROK) - RETVALUE(RFAILED); - } -#ifdef TENB_MULT_CELL_SUPPRT - CMCHKPK(SPkS16, param->rlcDlSapId, mBuf); - CMCHKPK(SPkS16, param->rlcUlSapId, mBuf); -#endif - - CMCHKPK(SPkU8, param->numEnt, mBuf); - CMCHKPK(SPkU32, param->transId, mBuf); - CMCHKPK(cmPkLteCellId, param->cellId, mBuf); - CMCHKPK(cmPkLteRnti, param->ueId, mBuf); - RETVALUE(ROK); -} - -/* -* -* Fun: cmPkPjUdxUlStaRepInfo -* -* Desc: pack the structure UdxUlStaRepInfo -* -* Ret: ROK -ok -* -* Notes: None -* -* File: pj_udx.c -* -*/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxUlStaRepInfo -( -UdxUlStaRepInfo *param, -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjUdxUlStaRepInfo(param, pst, mBuf) -UdxUlStaRepInfo *param; -Pst *pst; -Buffer *mBuf; -#endif -{ - S16 msgLen; - TRC3(cmPkPjUdxUlStaRepInfo) - - CMCHKPK(SPkU8, param->pdcpId.rbType, mBuf); - CMCHKPK(cmPkLteRbId, param->pdcpId.rbId, mBuf); - CMCHKPK(cmPkLteRnti, param->pdcpId.ueId, mBuf); - CMCHKPK(cmPkLteCellId, param->pdcpId.cellId, mBuf); - - if (SFndLenMsg(param->sta, &msgLen) != ROK) - RETVALUE(RFAILED); - if (SCatMsg(mBuf, param->sta, M1M2) != ROK) - RETVALUE(RFAILED); - PJ_FREE_BUF(mBuf); - CMCHKPK(SPkS16, msgLen, mBuf); - - RETVALUE(ROK); -} /* cmPkPjUdxUlStaRepInfo */ - -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxUlStaRepInfo -( -Pst *pst, -UdxUlStaRepInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxUlStaRepInfo(pst, param, mBuf) -Pst *pst; -UdxUlStaRepInfo *param; -Buffer *mBuf; -#endif -{ - MsgLen msgLen=0; - MsgLen totalMsgLen; - - TRC3(cmUnpkPjUdxUlStaRepInfo); - - CMCHKUNPK(SUnpkU8, ¶m->pdcpId.rbType, mBuf); - CMCHKUNPK(cmUnpkLteRbId, ¶m->pdcpId.rbId, mBuf); - CMCHKUNPK(cmUnpkLteRnti, ¶m->pdcpId.ueId, mBuf); - CMCHKUNPK(cmUnpkLteCellId, ¶m->pdcpId.cellId, mBuf); - - if (SFndLenMsg(mBuf, &totalMsgLen) != ROK) - RETVALUE(RFAILED); - - if (SSegMsg(mBuf, totalMsgLen-msgLen, ¶m->sta) != ROK) - RETVALUE(RFAILED); - - RETVALUE(ROK); -} - -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxUlFdbkPktInfo -( -Pst *pst, -UdxUlFdbkPktInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxUlFdbkPktInfo(pst, param, mBuf) -Pst *pst; -UdxUlFdbkPktInfo *param; -Buffer *mBuf; -#endif -{ - MsgLen msgLen=0; - MsgLen totalMsgLen; - - TRC3(cmUnpkPjUdxUlFdbkPktInfo); - - CMCHKUNPK(SUnpkU8, ¶m->pdcpId.rbType, mBuf); - CMCHKUNPK(cmUnpkLteRbId, ¶m->pdcpId.rbId, mBuf); - CMCHKUNPK(cmUnpkLteRnti, ¶m->pdcpId.ueId, mBuf); - CMCHKUNPK(cmUnpkLteCellId, ¶m->pdcpId.cellId, mBuf); - - if (SFndLenMsg(mBuf, &totalMsgLen) != ROK) - RETVALUE(RFAILED); - - if (SSegMsg(mBuf, totalMsgLen-msgLen, ¶m->fbPkt) != ROK) - RETVALUE(RFAILED); - - RETVALUE(ROK); -} - -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxDlFdbkPktInfo -( -Pst *pst, -UdxDlFdbkPktInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxDlFdbkPktInfo(pst, param, mBuf) -Pst *pst; -UdxDlFdbkPktInfo *param; -Buffer *mBuf; -#endif -{ - MsgLen msgLen=0; - MsgLen totalMsgLen; - - TRC3(cmUnpkPjUdxDlFdbkPktInfo); - - CMCHKUNPK(SUnpkU8, ¶m->pdcpId.rbType, mBuf); - CMCHKUNPK(cmUnpkLteRbId, ¶m->pdcpId.rbId, mBuf); - CMCHKUNPK(cmUnpkLteRnti, ¶m->pdcpId.ueId, mBuf); - CMCHKUNPK(cmUnpkLteCellId, ¶m->pdcpId.cellId, mBuf); - - if (SFndLenMsg(mBuf, &totalMsgLen) != ROK) - RETVALUE(RFAILED); - - if (SSegMsg(mBuf, totalMsgLen-msgLen, ¶m->fbPkt) != ROK) - RETVALUE(RFAILED); - - RETVALUE(ROK); -} - -/* -* -* Fun: cmPkPjUdxDlStaRepInfo -* -* Desc: pack the structure UdxDlStaRepInfo -* -* Ret: ROK -ok -* -* Notes: None -* -* File: pj_udx.c -* -*/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxDlStaRepInfo -( -UdxDlStaRepInfo *param, -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjUdxDlStaRepInfo(param, pst, mBuf) -UdxDlStaRepInfo *param; -Pst *pst; -Buffer *mBuf; -#endif -{ - S16 msgLen; - TRC3(cmPkPjUdxDlStaRepInfo) - - CMCHKPK(SPkU8, param->pdcpId.rbType, mBuf); - CMCHKPK(cmPkLteRbId, param->pdcpId.rbId, mBuf); - CMCHKPK(cmPkLteRnti, param->pdcpId.ueId, mBuf); - CMCHKPK(cmPkLteCellId, param->pdcpId.cellId, mBuf); - CMCHKPK(SPkU32, param->fmc, mBuf); - - if (SFndLenMsg(param->staPdu, &msgLen) != ROK) - RETVALUE(RFAILED); - if (SCatMsg(mBuf, param->staPdu, M1M2) != ROK) - RETVALUE(RFAILED); - PJ_FREE_BUF(mBuf); - CMCHKPK(SPkS16, msgLen, mBuf); - - RETVALUE(ROK); -} /* cmPkPjUdxUlStaRepInfo */ - -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxDlStaRepInfo -( -Pst *pst, -UdxDlStaRepInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxDlStaRepInfo(pst, param, mBuf) -Pst *pst; -UdxDlStaRepInfo *param; -Buffer *mBuf; -#endif -{ - MsgLen msgLen=0; - MsgLen totalMsgLen; - - TRC3(cmUnpkPjUdxDlStaRepInfo); - - CMCHKUNPK(SUnpkU8, ¶m->pdcpId.rbType, mBuf); - CMCHKUNPK(cmUnpkLteRbId, ¶m->pdcpId.rbId, mBuf); - CMCHKUNPK(cmUnpkLteRnti, ¶m->pdcpId.ueId, mBuf); - CMCHKUNPK(cmUnpkLteCellId, ¶m->pdcpId.cellId, mBuf); - CMCHKUNPK(SUnpkU32, ¶m->fmc, mBuf); - - if (SFndLenMsg(mBuf, &totalMsgLen) != ROK) - RETVALUE(RFAILED); - - if (SSegMsg(mBuf, totalMsgLen-msgLen, ¶m->staPdu) != ROK) - RETVALUE(RFAILED); - - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmUnpkPjUdxCfgReqInfo -* -* -* Desc : * PDCP Configuration structure. Parameters are filled by RRC - layer while configuring the PDCP layer. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxCfgReqInfo -( -Pst *pst, -UdxCfgReqInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxCfgReqInfo(pst, param, mBuf) -Pst *pst; -UdxCfgReqInfo *param; -Buffer *mBuf; -#endif -{ - S32 i; - - TRC3(cmUnpkPjUdxCfgReqInfo) - - CMCHKUNPK(cmUnpkLteRnti, ¶m->ueId, mBuf); - CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); - CMCHKUNPK(SUnpkU32, ¶m->transId, mBuf); - CMCHKUNPK(SUnpkU8, ¶m->numEnt, mBuf); -#ifdef TENB_MULT_CELL_SUPPRT - CMCHKUNPK(SUnpkS16, ¶m->rlcUlSapId, mBuf); - CMCHKUNPK(SUnpkS16, ¶m->rlcDlSapId, mBuf); -#endif - for (i=0; inumEnt; i++) { - if (cmUnpkPjUdxCfgEnt(pst, ¶m->cfgEnt[i], mBuf) != ROK) - RETVALUE(RFAILED); - } - RETVALUE(ROK); -} - - -/*********************************************************** -* -* Func : cmPkPjUdxCfmEnt -* -* -* Desc : * PDCP confirm parameter structure for PDCP entity. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxCfmEnt -( -UdxCfmEnt *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjUdxCfmEnt(param, mBuf) -UdxCfmEnt *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmPkPjUdxCfmEnt) - - CMCHKPK(SPkS16, param->reason, mBuf); - CMCHKPK(SPkS16, param->status, mBuf); - CMCHKPK(SPkU8, param->rbType, mBuf); - CMCHKPK(SPkU8, param->rbId, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmUnpkPjUdxCfmEnt -* -* -* Desc : * PDCP confirm parameter structure for PDCP entity. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxCfmEnt -( -UdxCfmEnt *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxCfmEnt(param, mBuf) -UdxCfmEnt *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmUnpkPjUdxCfmEnt) - - CMCHKUNPK(SUnpkU8, ¶m->rbId, mBuf); - CMCHKUNPK(SUnpkU8, ¶m->rbType, mBuf); - CMCHKUNPK(SUnpkS16, ¶m->status, mBuf); - CMCHKUNPK(SUnpkS16, ¶m->reason, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmPkPjUdxCfgCfmInfo -* -* -* Desc : * PDCP configuration confirm structure. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxCfgCfmInfo -( -UdxCfgCfmInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjUdxCfgCfmInfo(param, mBuf) -UdxCfgCfmInfo *param; -Buffer *mBuf; -#endif -{ - - S32 i; - TRC3(cmPkPjUdxCfgCfmInfo) - - for (i=param->numEnt-1; i >= 0; i--) { - CMCHKPK(cmPkPjUdxCfmEnt, ¶m->cfmEnt[i], mBuf); - } - CMCHKPK(SPkU8, param->numEnt, mBuf); - CMCHKPK(SPkU32, param->transId, mBuf); - CMCHKPK(cmPkLteCellId, param->cellId, mBuf); - CMCHKPK(cmPkLteRnti, param->ueId, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmUnpkPjUdxCfgCfmInfo -* -* -* Desc : * PDCP configuration confirm structure. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxCfgCfmInfo -( -UdxCfgCfmInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxCfgCfmInfo(param, mBuf) -UdxCfgCfmInfo *param; -Buffer *mBuf; -#endif -{ - - S32 i; - TRC3(cmUnpkPjUdxCfgCfmInfo) - - CMCHKUNPK(cmUnpkLteRnti, ¶m->ueId, mBuf); - CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); - CMCHKUNPK(SUnpkU32, ¶m->transId, mBuf); - CMCHKUNPK(SUnpkU8, ¶m->numEnt, mBuf); - for (i=0; inumEnt; i++) { - CMCHKUNPK(cmUnpkPjUdxCfmEnt, ¶m->cfmEnt[i], mBuf); - } - RETVALUE(ROK); -} - - -/*********************************************************** -* -* Func : cmPkPjUdxReEstReqInfo -* -* -* Desc : * Reestabishment request structure for SRB1 of an UE. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxReEstReqInfo -( -UdxReEstReqInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjUdxReEstReqInfo(param, mBuf) -UdxReEstReqInfo *param; -Buffer *mBuf; -#endif -{ - - S32 i; - TRC3(cmPkPjUdxReEstReqInfo) - - for (i=UDX_CIPHER_KEY_LEN-1; i >= 0; i--) { - CMCHKPK(SPkU8, param->usrplnKey[i], mBuf); - } - for (i=UDX_CIPHER_KEY_LEN-1; i >= 0; i--) { - CMCHKPK(SPkU8, param->ctrlplnKey[i], mBuf); - } - for (i=UDX_INTG_KEY_LEN-1; i >= 0; i--) { - CMCHKPK(SPkU8, param->intKey[i], mBuf); - } - CMCHKPK(SPkU32, param->transId, mBuf); - - CMCHKPK(cmPkLtePdcpId, ¶m->pdcpId, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmUnpkPjUdxReEstReqInfo -* -* -* Desc : * Reestabishment request structure for SRB1 of an UE. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxReEstReqInfo -( -UdxReEstReqInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxReEstReqInfo(param, mBuf) -UdxReEstReqInfo *param; -Buffer *mBuf; -#endif -{ - - S32 i; - TRC3(cmUnpkPjUdxReEstReqInfo) - - CMCHKUNPK(cmUnpkLtePdcpId, ¶m->pdcpId, mBuf); - CMCHKUNPK(SUnpkU32, ¶m->transId, mBuf); - for (i=0; iintKey[i], mBuf); - } - for (i=0; ictrlplnKey[i], mBuf); - } - for (i=0; iusrplnKey[i], mBuf); - } - RETVALUE(ROK); -} - - -/*********************************************************** -* -* Func : cmPkPjUdxReEstCfmInfo -* -* -* Desc : * Reestablishment confirmation structure for an UE. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxReEstCfmInfo -( -UdxReEstCfmInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjUdxReEstCfmInfo(param, mBuf) -UdxReEstCfmInfo *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmPkPjUdxReEstCfmInfo) - - CMCHKPK(SPkS16, param->status, mBuf); - CMCHKPK(SPkU32, param->transId, mBuf); - CMCHKPK(cmPkLteCellId, param->cellId, mBuf); - CMCHKPK(cmPkLteRnti, param->ueId, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmUnpkPjUdxReEstCfmInfo -* -* -* Desc : * Reestablishment confirmation structure for an UE. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxReEstCfmInfo -( -UdxReEstCfmInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxReEstCfmInfo(param, mBuf) -UdxReEstCfmInfo *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmUnpkPjUdxReEstCfmInfo) - - CMCHKUNPK(cmUnpkLteRnti, ¶m->ueId, mBuf); - CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); - CMCHKUNPK(SUnpkU32, ¶m->transId, mBuf); - CMCHKUNPK(SUnpkS16, ¶m->status, mBuf); - RETVALUE(ROK); -} - - -/*********************************************************** -* -* Func : cmPkPjUdxSecCfgReqInfo -* -* -* Desc : * PDCP Security Configuration structure. Parameters are filled by RRC - * while configuring the security parameters. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxSecCfgReqInfo -( -UdxSecCfgReqInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjUdxSecCfgReqInfo(param, mBuf) -UdxSecCfgReqInfo *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmPkPjUdxSecCfgReqInfo) - - CMCHKPK(cmPkPjUdxSecCfg, ¶m->secCfg, mBuf); - CMCHKPK(SPkU32, param->transId, mBuf); - CMCHKPK(cmPkLteCellId, param->cellId, mBuf); - CMCHKPK(cmPkLteRnti, param->ueId, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmUnpkPjUdxSecCfgReqInfo -* -* -* Desc : * PDCP Security Configuration structure. Parameters are filled by RRC - * while configuring the security parameters. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxSecCfgReqInfo -( -UdxSecCfgReqInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxSecCfgReqInfo(param, mBuf) -UdxSecCfgReqInfo *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmUnpkPjUdxSecCfgReqInfo) - - CMCHKUNPK(cmUnpkLteRnti, ¶m->ueId, mBuf); - CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); - CMCHKUNPK(SUnpkU32, ¶m->transId, mBuf); - CMCHKUNPK(cmUnpkPjUdxSecCfg, ¶m->secCfg, mBuf); - RETVALUE(ROK); -} - - -/*********************************************************** -* -* Func : cmPkPjUdxSecCfgCfmInfo -* -* -* Desc : * PDCP Security configuration confirm structure. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxSecCfgCfmInfo -( -UdxSecCfgCfmInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjUdxSecCfgCfmInfo(param, mBuf) -UdxSecCfgCfmInfo *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmPkPjUdxSecCfgCfmInfo) - - CMCHKPK(SPkS16, param->reason, mBuf); - CMCHKPK(SPkS16, param->status, mBuf); - CMCHKPK(SPkU32, param->transId, mBuf); - CMCHKPK(cmPkLteCellId, param->cellId, mBuf); - CMCHKPK(cmPkLteRnti, param->ueId, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmUnpkPjUdxSecCfgCfmInfo -* -* -* Desc : * PDCP Security configuration confirm structure. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxSecCfgCfmInfo -( -UdxSecCfgCfmInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxSecCfgCfmInfo(param, mBuf) -UdxSecCfgCfmInfo *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmUnpkPjUdxSecCfgCfmInfo) - - CMCHKUNPK(cmUnpkLteRnti, ¶m->ueId, mBuf); - CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); - CMCHKUNPK(SUnpkU32, ¶m->transId, mBuf); - CMCHKUNPK(SUnpkS16, ¶m->status, mBuf); - CMCHKUNPK(SUnpkS16, ¶m->reason, mBuf); - RETVALUE(ROK); -} - - -/*********************************************************** -* -* Func : cmPkPjUdxUeInfo -* -* -* Desc : * UE ID information -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxUeInfo -( -UdxUeInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjUdxUeInfo(param, mBuf) -UdxUeInfo *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmPkPjUdxUeInfo) - - CMCHKPK(cmPkLteRnti, param->ueId, mBuf); - CMCHKPK(cmPkLteCellId, param->cellId, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmUnpkPjUdxUeInfo -* -* -* Desc : * UE ID information -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxUeInfo -( -UdxUeInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxUeInfo(param, mBuf) -UdxUeInfo *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmUnpkPjUdxUeInfo) - - CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); - CMCHKUNPK(cmUnpkLteRnti, ¶m->ueId, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmPkPjUdxCountReqInfo -* -* -* Desc : * PDCP Count Request Information from RRC. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxCountReqInfo -( -UdxCountReqInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjUdxCountReqInfo(param, mBuf) -UdxCountReqInfo *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmPkPjUdxCountReqInfo) - - CMCHKPK(SPkU32, param->transId, mBuf); - CMCHKPK(cmPkLteCellId, param->cellId, mBuf); - CMCHKPK(cmPkLteRnti, param->ueId, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmUnpkPjUdxCountReqInfo -* -* -* Desc : * PDCP Count Request Information from RRC. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxCountReqInfo -( -UdxCountReqInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxCountReqInfo(param, mBuf) -UdxCountReqInfo *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmUnpkPjUdxCountReqInfo) - - CMCHKUNPK(cmUnpkLteRnti, ¶m->ueId, mBuf); - CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); - CMCHKUNPK(SUnpkU32, ¶m->transId, mBuf); - RETVALUE(ROK); -} - - -/*********************************************************** -* -* Func : cmPkPjUdxCountInfo -* -* -* Desc : * PDCP Count Information for a DRB. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxCountInfo -( -UdxCountInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjUdxCountInfo(param, mBuf) -UdxCountInfo *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmPkPjUdxCountInfo) - - CMCHKPK(SPkU32, param->dlCount, mBuf); - CMCHKPK(SPkU32, param->ulCount, mBuf); - CMCHKPK(SPkU8, param->dir, mBuf); - CMCHKPK(SPkU8, param->rbId, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmUnpkPjUdxCountInfo -* -* -* Desc : * PDCP Count Information for a DRB. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxCountInfo -( -UdxCountInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxCountInfo(param, mBuf) -UdxCountInfo *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmUnpkPjUdxCountInfo) - - CMCHKUNPK(SUnpkU8, ¶m->rbId, mBuf); - CMCHKUNPK(SUnpkU8, ¶m->dir, mBuf); - CMCHKUNPK(SUnpkU32, ¶m->ulCount, mBuf); - CMCHKUNPK(SUnpkU32, ¶m->dlCount, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmPkPjUdxCountCfmInfo -* -* -* Desc : * PDCP Count Request Confirmation to RRC. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxCountCfmInfo -( -UdxCountCfmInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjUdxCountCfmInfo(param, mBuf) -UdxCountCfmInfo *param; -Buffer *mBuf; -#endif -{ - - S32 i; - TRC3(cmPkPjUdxCountCfmInfo) - - CMCHKPK(SPkS16, param->reason, mBuf); - CMCHKPK(SPkS16, param->status, mBuf); - for (i=param->numRb-1; i >= 0; i--) { - CMCHKPK(cmPkPjUdxCountInfo, ¶m->countInfo[i], mBuf); - } - CMCHKPK(SPkU8, param->numRb, mBuf); - CMCHKPK(SPkU32, param->transId, mBuf); - CMCHKPK(cmPkLteCellId, param->cellId, mBuf); - CMCHKPK(cmPkLteRnti, param->ueId, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmUnpkPjUdxCountCfmInfo -* -* -* Desc : * PDCP Count Request Confirmation to RRC. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxCountCfmInfo -( -UdxCountCfmInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxCountCfmInfo(param, mBuf) -UdxCountCfmInfo *param; -Buffer *mBuf; -#endif -{ - - S32 i; - TRC3(cmUnpkPjUdxCountCfmInfo) - - CMCHKUNPK(cmUnpkLteRnti, ¶m->ueId, mBuf); - CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); - CMCHKUNPK(SUnpkU32, ¶m->transId, mBuf); - CMCHKUNPK(SUnpkU8, ¶m->numRb, mBuf); - for (i=0; inumRb; i++) { - CMCHKUNPK(cmUnpkPjUdxCountInfo, ¶m->countInfo[i], mBuf); - } - CMCHKUNPK(SUnpkS16, ¶m->status, mBuf); - CMCHKUNPK(SUnpkS16, ¶m->reason, mBuf); - RETVALUE(ROK); -} - - -/*********************************************************** -* -* Func : cmPkPjUdxSduStaReqInfo -* -* -* Desc : * PDCP SDU Status Request Information from RRC - Used for reestablishment - * during handover. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxSduStaReqInfo -( -UdxSduStaReqInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjUdxSduStaReqInfo(param, mBuf) -UdxSduStaReqInfo *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmPkPjUdxSduStaReqInfo) - - CMCHKPK(SPkU32, param->transId, mBuf); - CMCHKPK(cmPkLteCellId, param->cellId, mBuf); - CMCHKPK(cmPkLteRnti, param->ueId, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmUnpkPjUdxSduStaReqInfo -* -* -* Desc : * PDCP SDU Status Request Information from RRC - Used for reestablishment - * during handover. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxSduStaReqInfo -( -UdxSduStaReqInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxSduStaReqInfo(param, mBuf) -UdxSduStaReqInfo *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmUnpkPjUdxSduStaReqInfo) - - CMCHKUNPK(cmUnpkLteRnti, ¶m->ueId, mBuf); - CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); - CMCHKUNPK(SUnpkU32, ¶m->transId, mBuf); - RETVALUE(ROK); -} - - -/*********************************************************** -* -* Func : cmPkPjUdxDlSduStaInfo -* -* -* Desc : * PDCP DL SDU Status Information for a DRB mapped to RLC AM. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxDlSduStaInfo -( -UdxDlSduStaInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjUdxDlSduStaInfo(param, mBuf) -UdxDlSduStaInfo *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmPkPjUdxDlSduStaInfo) - - CMCHKPK(cmPkBool, param->hoPres, mBuf); - CMCHKPK(SPkU32, param->count, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmUnpkPjUdxDlSduStaInfo -* -* -* Desc : * PDCP DL SDU Status Information for a DRB mapped to RLC AM. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxDlSduStaInfo -( -UdxDlSduStaInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxDlSduStaInfo(param, mBuf) -UdxDlSduStaInfo *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmUnpkPjUdxDlSduStaInfo) - - CMCHKUNPK(cmUnpkBool, ¶m->hoPres, mBuf); - CMCHKUNPK(SUnpkU32, ¶m->count, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmPkPjUdxSduStaInfo -* -* -* Desc : * PDCP SDU Status Information for a DRB mapped to RLC AM. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxSduStaInfo -( -Pst *pst, -UdxSduStaInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjUdxSduStaInfo(pst, param, mBuf) -Pst *pst; -UdxSduStaInfo *param; -Buffer *mBuf; -#endif -{ - TRC3(cmPkPjUdxSduStaInfo) - - CMCHKPK(cmPkPjUdxDlSduStaInfo, ¶m->dlSduStaInfo, mBuf); - CMCHKPK(SPkU8, param->dir, mBuf); - CMCHKPK(SPkU8, param->rbId, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmUnpkPjUdxSduStaInfo -* -* -* Desc : * PDCP SDU Status Information for a DRB mapped to RLC AM. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxSduStaInfo -( -Pst *pst, -UdxSduStaInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxSduStaInfo(pst, param, mBuf) -Pst *pst; -UdxSduStaInfo *param; -Buffer *mBuf; -#endif -{ - TRC3(cmUnpkPjUdxSduStaInfo) - - CMCHKUNPK(SUnpkU8, ¶m->rbId, mBuf); - CMCHKUNPK(SUnpkU8, ¶m->dir, mBuf); - - CMCHKUNPK(cmUnpkPjUdxDlSduStaInfo, ¶m->dlSduStaInfo, mBuf); - RETVALUE(ROK); -} - - - -/*********************************************************** -* -* Func : cmPkPjUdxSduStaCfmInfo -* -* -* Desc : * PDCP SDU Status Request Confirmation for an UE. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxSduStaCfmInfo -( -Pst *pst, -UdxSduStaCfmInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjUdxSduStaCfmInfo(pst, param, mBuf) -Pst *pst; -UdxSduStaCfmInfo *param; -Buffer *mBuf; -#endif -{ - S32 i; - - TRC3(cmPkPjUdxSduStaCfmInfo) - - CMCHKPK(SPkS16, param->reason, mBuf); - CMCHKPK(SPkS16, param->status, mBuf); - for (i=param->numRb-1; i >= 0; i--) { - if (cmPkPjUdxSduStaInfo(pst, ¶m->sduStaInfo[i], mBuf) != ROK) - RETVALUE(RFAILED); - } - CMCHKPK(SPkU8, param->numRb, mBuf); - CMCHKPK(SPkU32, param->transId, mBuf); - CMCHKPK(cmPkLteCellId, param->cellId, mBuf); - CMCHKPK(cmPkLteRnti, param->ueId, mBuf); - RETVALUE(ROK); -} - - -/*********************************************************** -* -* Func : cmPkPjUdxDatResumeCfmInfo -* -* -* Desc : * PDCP SDU Status Request Confirmation for an UE. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxDatResumeCfmInfo -( -Pst *pst, -UdxDatResumeCfmInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjUdxDatResumeCfmInfo(pst, param, mBuf) -Pst *pst; -UdxDatResumeCfmInfo *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmPkPjUdxDatResumeCfmInfo) - - CMCHKPK(SPkS16, param->reason, mBuf); - CMCHKPK(SPkS16, param->status, mBuf); - CMCHKPK(SPkU32, param->transId, mBuf); - CMCHKPK(cmPkLteCellId, param->cellId, mBuf); - CMCHKPK(cmPkLteRnti, param->ueId, mBuf); - RETVALUE(ROK); -} - -#ifdef ANSI -PUBLIC S16 cmPkPjUdxDatForwardCfmInfo -( -Pst *pst, -UdxDatFwdCfmInfo *param, -Buffer *mBuf - ) -#else -PUBLIC S16 cmPkPjUdxDatForwardCfmInfo(pst, param, mBuf) -Pst *pst; -UdxDatFwdCfmInfo *param; -Buffer *mBuf; -#endif -{ - TRC3(cmPkPjUdxDatForwardCfmInfo) - - CMCHKPK(SPkS16, param->reason, mBuf); - CMCHKPK(SPkS16, param->status, mBuf); - CMCHKPK(cmPkLteCellId, param->cellId, mBuf); - CMCHKPK(cmPkLteRnti, param->ueId, mBuf); - RETVALUE(ROK); -} -/* -* -* Fun: cmPkPjUdxDlFdbkPktInfo -* -* Desc: pack the structure UdxDlFdbPktInfo -* -* Ret: ROK -ok -* -* Notes: None -* -* File: pj_udx.c -* -*/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxDlFdbkPktInfo -( -UdxDlFdbkPktInfo *param, -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjUdxDlFdbkPktInfo(param, pst, mBuf) -UdxDlFdbkPktInfo *param; -Pst *pst; -Buffer *mBuf; -#endif -{ - S16 msgLen; - TRC3(cmPkPjUdxDlFdbkPktInfo) - - CMCHKPK(SPkU8, param->pdcpId.rbType, mBuf); - CMCHKPK(cmPkLteRbId, param->pdcpId.rbId, mBuf); - CMCHKPK(cmPkLteRnti, param->pdcpId.ueId, mBuf); - CMCHKPK(cmPkLteCellId, param->pdcpId.cellId, mBuf); - - if (SFndLenMsg(param->fbPkt, &msgLen) != ROK) - RETVALUE(RFAILED); - if (SCatMsg(mBuf, param->fbPkt, M1M2) != ROK) - RETVALUE(RFAILED); - PJ_FREE_BUF(mBuf); - CMCHKPK(SPkS16, msgLen, mBuf); - - RETVALUE(ROK); -} /* cmPkPjUdxDlFdbkPktInfo */ - - -/*********************************************************** -* -* Func : cmUnpkPjUdxSduStaCfmInfo -* -* -* Desc : * PDCP SDU Status Request Confirmation for an UE. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxSduStaCfmInfo -( -Pst *pst, -UdxSduStaCfmInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxSduStaCfmInfo(pst, param, mBuf) -Pst *pst; -UdxSduStaCfmInfo *param; -Buffer *mBuf; -#endif -{ - - S32 i; - TRC3(cmUnpkPjUdxSduStaCfmInfo) - - CMCHKUNPK(cmUnpkLteRnti, ¶m->ueId, mBuf); - CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); - CMCHKUNPK(SUnpkU32, ¶m->transId, mBuf); - CMCHKUNPK(SUnpkU8, ¶m->numRb, mBuf); - for (i=0; inumRb; i++) { - if (cmUnpkPjUdxSduStaInfo(pst, ¶m->sduStaInfo[i], mBuf) != ROK) - RETVALUE(RFAILED); - } - CMCHKUNPK(SUnpkS16, ¶m->status, mBuf); - CMCHKUNPK(SUnpkS16, ¶m->reason, mBuf); - RETVALUE(ROK); -} - - -/*********************************************************** -* -* Func : cmUnpkPjUdxDatResumeCfmInfo -* -* -* Desc : * PDCP SDU Status Request Confirmation for an UE. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxDatResumeCfmInfo -( -Pst *pst, -UdxDatResumeCfmInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxDatResumeCfmInfo(pst, param, mBuf) -Pst *pst; -UdxDatResumeCfmInfo *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmUnpkPjUdxDatResumeCfmInfo) - - CMCHKUNPK(cmUnpkLteRnti, ¶m->ueId, mBuf); - CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); - CMCHKUNPK(SUnpkU32, ¶m->transId, mBuf); - CMCHKUNPK(SUnpkS16, ¶m->status, mBuf); - CMCHKUNPK(SUnpkS16, ¶m->reason, mBuf); - RETVALUE(ROK); -} -/*********************************************************** -* -* Func : cmUnpkPjUdxDatForwardCfm -* -* -* Desc : * PDCP Data Forward Confirmation for an UE. -* -* -* Ret : S16 -* -* Notes: -* -* File : -* -**********************************************************/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxDatForwardCfmInfo -( -Pst *pst, -UdxDatFwdCfmInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxDatForwardCfmInfo(pst, param, mBuf) -Pst *pst; -UdxDatFwdCfmInfo *param; -Buffer *mBuf; -#endif -{ - - TRC3(cmUnpkPjUdxDatForwardCfmInfo) - - CMCHKUNPK(cmUnpkLteRnti, ¶m->ueId, mBuf); - CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); - CMCHKUNPK(SUnpkS16, ¶m->status, mBuf); - CMCHKUNPK(SUnpkS16, ¶m->reason, mBuf); - RETVALUE(ROK); -} - - -#ifdef ANSI -PUBLIC S16 cmPkPjUdxUlFdbkPkt -( -Pst * pst, -SpId spId, -UdxUlFdbkPktInfo *fdbkPktInfo -) -#else -PUBLIC S16 cmPkPjUdxUlFdbkPkt(pst, spId, fdbkPktInfo) -Pst * pst; -SpId spId; -UdxUlFdbkPktInfo *fdbkPktInfo; -#endif -{ - S16 ret; - Buffer *mBuf; - mBuf = NULLP; - - TRC3(cmPkPjUdxUlFdbkPkt) - - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX016, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(mBuf); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, fdbkPktInfo, sizeof(UdxUlFdbkPktInfo)); - - RETVALUE(RFAILED); - } - - switch(pst->selector) - { -#ifdef LCUDX - case UDX_SEL_LC: - { - ret = cmPkPjUdxUlFdbkPktInfo( (fdbkPktInfo), pst, mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - if(ret != ROK) - { - PJ_FREE_BUF(mBuf); - PJ_FREE_BUF(fdbkPktInfo->fbPkt); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, fdbkPktInfo, sizeof(UdxUlFdbkPktInfo)); - - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDXXXX, (ErrVal)ret, "Packing failure"); - RETVALUE( ret ); - } -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - PJ_FREE_BUF(fdbkPktInfo->fbPkt); -#ifndef XEON_SPECIFIC_CHANGES - if (SPutStaticBuffer(pst->region, pst->pool, (Data *)fdbkPktInfo, - sizeof(UdxUlFdbkPktInfo), 0) != ROK) -#else - if (SPutSBuf(pst->region, pst->pool, (Data *)fdbkPktInfo, - sizeof(UdxUlFdbkPktInfo)) != ROK) -#endif - { - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - - break; - } - case UDX_SEL_LWLC: - { - CMCHKPKLOG(cmPkPtr,(PTR)fdbkPktInfo,mBuf,EUDXXXX,pst); - break; - } -#endif /* LCUDX */ - } - - CMCHKPKLOG(SPkS16, spId, mBuf, EUDXXXX, pst); - pst->event = (Event) EVTUDXULROHCFDB; - - RETVALUE(SPstTsk(pst,mBuf)); -} - -#ifdef ANSI -PUBLIC S16 cmPkPjUdxDlFdbkPkt -( -Pst * pst, -SpId spId, -UdxDlFdbkPktInfo *fdbkPktInfo -) -#else -PUBLIC S16 cmPkPjUdxDlFdbkPkt(pst, spId, fdbkPktInfo) -Pst * pst; -SpId spId; -UdxDlFdbkPktInfo *fdbkPktInfo; -#endif -{ - S16 ret; - Buffer *mBuf; - mBuf = NULLP; - - TRC3(cmPkPjUdxDlFdbkPkt) - - if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX016, (ErrVal)0, "Packing failed"); -#endif - PJ_FREE_BUF(mBuf); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, fdbkPktInfo, sizeof(UdxUlFdbkPktInfo)); - - RETVALUE(RFAILED); - } - - switch(pst->selector) - { -#ifdef LCUDX - case UDX_SEL_LC: - { - ret = cmPkPjUdxDlFdbkPktInfo( (fdbkPktInfo), pst, mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - if(ret != ROK) - { - PJ_FREE_BUF(mBuf); - PJ_FREE_BUF(fdbkPktInfo->fbPkt); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, fdbkPktInfo, sizeof(UdxUlFdbkPktInfo)); - - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDXXXX, (ErrVal)ret, "Packing failure"); - RETVALUE( ret ); - } -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - PJ_FREE_BUF(fdbkPktInfo->fbPkt); -#ifndef XEON_SPECIFIC_CHANGES - if (SPutStaticBuffer(pst->region, pst->pool, (Data *)fdbkPktInfo, - sizeof(UdxDlFdbkPktInfo), 0) != ROK) -#else - if (SPutSBuf(pst->region, pst->pool, (Data *)fdbkPktInfo, - sizeof(UdxDlFdbkPktInfo)) != ROK) -#endif - { - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - - break; - } - case UDX_SEL_LWLC: - { - CMCHKPKLOG(cmPkPtr,(PTR)fdbkPktInfo,mBuf,EUDXXXX,pst); - break; - } -#endif /* LCUDX */ - } - - CMCHKPKLOG(SPkS16, spId, mBuf, EUDXXXX, pst); - pst->event = (Event) EVTUDXDLROHCFDB; - - RETVALUE(SPstTsk(pst,mBuf)); -} - -/* -* -* Fun: cmPkPjUdxUlFdbkPktInfo -* -* Desc: pack the structure UdxUlFdbPktInfo -* -* Ret: ROK -ok -* -* Notes: None -* -* File: pj_udx.c -* -*/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxUlFdbkPktInfo -( -UdxUlFdbkPktInfo *param, -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC S16 cmPkPjUdxUlFdbkPktInfo(param, pst, mBuf) -UdxUlFdbkPktInfo *param; -Pst *pst; -Buffer *mBuf; -#endif -{ - S16 msgLen; - TRC3(cmPkPjUdxUlFdbkPktInfo) - - CMCHKPK(SPkU8, param->pdcpId.rbType, mBuf); - CMCHKPK(cmPkLteRbId, param->pdcpId.rbId, mBuf); - CMCHKPK(cmPkLteRnti, param->pdcpId.ueId, mBuf); - CMCHKPK(cmPkLteCellId, param->pdcpId.cellId, mBuf); - - if (SFndLenMsg(param->fbPkt, &msgLen) != ROK) - RETVALUE(RFAILED); - if (SCatMsg(mBuf, param->fbPkt, M1M2) != ROK) - RETVALUE(RFAILED); - PJ_FREE_BUF(param->fbPkt); - CMCHKPK(SPkS16, msgLen, mBuf); - - RETVALUE(ROK); -} /* cmPkPjUdxUlFdbkPktInfo */ - - -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxDlFdbkPkt -( -UdxDlFdbkPkt func, -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxDlFdbkPkt(func, pst, mBuf) -UdxDlFdbkPkt func; -Pst *pst; -Buffer *mBuf; -#endif -{ - S16 ret1; - SpId spId; - UdxDlFdbkPktInfo *fdbkPkt; - - TRC3(cmUnpkPjUdxDlFdbkPkt) - - if (SUnpkS16(&spId, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX021, (ErrVal)0, "Unpacking failed"); -#endif - RETVALUE(RFAILED); - } - - switch(pst->selector) - { -#ifdef LCUDX - case UDX_SEL_LC: - { - if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&fdbkPkt,\ - sizeof(UdxDlFdbkPktInfo))) != ROK) - { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX040, (ErrVal)0, "SGetMsg() failed"); -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - - PJ_FREE_BUF(mBuf); - RETVALUE(ret1); - } - - if (cmUnpkPjUdxDlFdbkPktInfo(pst, fdbkPkt, mBuf) != ROK) - { - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, fdbkPkt, sizeof(UdxDlFdbkPktInfo)); - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX023, (ErrVal)0, "Unpacking failed"); -#endif - RETVALUE(RFAILED); - } - - break; - } - - case UDX_SEL_LWLC: - { - CMCHKUNPK(cmUnpkPtr,(PTR *) &fdbkPkt, mBuf); - break; - } -#endif /* LCUDX */ - } - - PJ_FREE_BUF(mBuf); - - RETVALUE((*func)(pst, spId, fdbkPkt)); -} - - -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxDlFdbPktInfo -( -Pst *pst, -UdxDlFdbkPktInfo *param, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxDlFdbPktInfo(pst, param, mBuf) -Pst *pst; -UdxDlFdbkPktInfo *param; -Buffer *mBuf; -#endif -{ - MsgLen msgLen=0; - MsgLen totalMsgLen; - - TRC3(cmUnpkPjUdxDlFdbPktInfo); - - CMCHKUNPK(SUnpkU8, ¶m->pdcpId.rbType, mBuf); - CMCHKUNPK(cmUnpkLteRbId, ¶m->pdcpId.rbId, mBuf); - CMCHKUNPK(cmUnpkLteRnti, ¶m->pdcpId.ueId, mBuf); - CMCHKUNPK(cmUnpkLteCellId, ¶m->pdcpId.cellId, mBuf); - - if (SFndLenMsg(mBuf, &totalMsgLen) != ROK) - RETVALUE(RFAILED); - - if (SSegMsg(mBuf, totalMsgLen-msgLen, ¶m->fbPkt) != ROK) - RETVALUE(RFAILED); - - RETVALUE(ROK); -} - - -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxUlStaRep -( -UdxUlStaRep func, -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxUlStaRep(func, pst, mBuf) -UdxUlStaRep func; -Pst *pst; -Buffer *mBuf; -#endif -{ - S16 ret1; - SpId spId; - UdxUlStaRepInfo *staRep; - - TRC3(cmUnpkPjUdxUlStaRep) - - if (SUnpkS16(&spId, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX021, (ErrVal)0, "Unpacking failed"); -#endif - RETVALUE(RFAILED); - } - - switch(pst->selector) - { -#ifdef LCUDX - case UDX_SEL_LC: - { - if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&staRep,\ - sizeof(UdxUlStaRepInfo))) != ROK) - { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX040, (ErrVal)0, "SGetMsg() failed"); -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - - PJ_FREE_BUF(mBuf); - RETVALUE(ret1); - } - - if (cmUnpkPjUdxUlStaRepInfo(pst, staRep, mBuf) != ROK) - { - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staRep, sizeof(UdxUlStaRepInfo)); - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX023, (ErrVal)0, "Unpacking failed"); -#endif - RETVALUE(RFAILED); - } - - break; - } - - case UDX_SEL_LWLC: - { - CMCHKUNPK(cmUnpkPtr,(PTR *) &staRep, mBuf); - break; - } -#endif /* LCUDX */ - } - - PJ_FREE_BUF(mBuf); - - RETVALUE((*func)(pst, spId, staRep)); -} - -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxDlStaRep -( -UdxDlStaRep func, -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxDlStaRep(func, pst, mBuf) -UdxDlStaRep func; -Pst *pst; -Buffer *mBuf; -#endif -{ - S16 ret1; - SpId spId; - UdxDlStaRepInfo *staRep; - - TRC3(cmUnpkPjUdxDlStaRep) - - if (SUnpkS16(&spId, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX021, (ErrVal)0, "Unpacking failed"); -#endif - RETVALUE(RFAILED); - } - - switch(pst->selector) - { -#ifdef LCUDX - case UDX_SEL_LC: - { - if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&staRep,\ - sizeof(UdxDlStaRepInfo))) != ROK) - { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX040, (ErrVal)0, "SGetMsg() failed"); -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - - PJ_FREE_BUF(mBuf); - RETVALUE(ret1); - } - - if (cmUnpkPjUdxDlStaRepInfo(pst, staRep, mBuf) != ROK) - { - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staRep, sizeof(UdxDlStaRepInfo)); - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX023, (ErrVal)0, "Unpacking failed"); -#endif - RETVALUE(RFAILED); - } - - break; - } - - case UDX_SEL_LWLC: - { - CMCHKUNPK(cmUnpkPtr,(PTR *) &staRep, mBuf); - break; - } -#endif /* LCUDX */ - } - - PJ_FREE_BUF(mBuf); - - RETVALUE((*func)(pst, spId, staRep)); -} - -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxUlFdbkPkt -( -UdxUlFdbkPkt func, -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxUlFdbkPkt(func, pst, mBuf) -UdxUlFdbkPkt func; -Pst *pst; -Buffer *mBuf; -#endif -{ - S16 ret1; - SpId spId; - UdxUlFdbkPktInfo *fdbkPkt; - - TRC3(cmUnpkPjUdxUlFdbkPkt) - - if (SUnpkS16(&spId, mBuf) != ROK) { - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX021, (ErrVal)0, "Unpacking failed"); -#endif - RETVALUE(RFAILED); - } - - switch(pst->selector) - { -#ifdef LCUDX - case UDX_SEL_LC: - { - if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&fdbkPkt,\ - sizeof(UdxUlFdbkPktInfo))) != ROK) - { -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX040, (ErrVal)0, "SGetMsg() failed"); -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - - PJ_FREE_BUF(mBuf); - RETVALUE(ret1); - } - - if (cmUnpkPjUdxUlFdbkPktInfo(pst, fdbkPkt, mBuf) != ROK) - { - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, fdbkPkt, sizeof(UdxUlFdbkPktInfo)); - PJ_FREE_BUF(mBuf); -#if (ERRCLASS & ERRCLS_ADD_RES) - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDX023, (ErrVal)0, "Unpacking failed"); -#endif - RETVALUE(RFAILED); - } - - break; - } - - case UDX_SEL_LWLC: - { - CMCHKUNPK(cmUnpkPtr,(PTR *) &fdbkPkt, mBuf); - break; - } -#endif /* LCUDX */ - } - - PJ_FREE_BUF(mBuf); - - RETVALUE((*func)(pst, spId, fdbkPkt)); -} - -#ifdef LTE_L2_MEAS -/* -* -* Fun: cmPkPjUdxL2MeasReq -* -* Ret: ROK -ok -* -* Notes: None -* -* -*/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxL2MeasReq -( -Pst *pst, -PjL2MeasReqEvt *measReqEvt -) -#else -PUBLIC S16 cmPkPjUdxL2MeasReq(pst, measReqEvt) -Pst *pst; -PjL2MeasReqEvt *measReqEvt; -#endif -{ - S16 ret1; - Buffer *mBuf = NULLP; - - TRC3(cmPkPjUdxL2MeasReq) - - if((ret1 = SGetMsg(pst->region, pst->pool, &mBuf)) != ROK) - { -#if (ERRCLASS & ERRCLS_ADD_RES) - if(ret1 != ROK) - { - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDXXXX, (ErrVal)0, "SGetMsg() failed"); - } -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - - RETVALUE(ret1); - } - - switch (pst->selector) - { - case UDX_SEL_LC: - { - } - case UDX_SEL_LWLC: - { - CMCHKPK(cmPkPtr,(PTR) measReqEvt, mBuf); - break; - } - } - pst->event = (Event) PJ_UDX_EVT_L2MEAS_REQ; - - RETVALUE(SPstTsk(pst, mBuf)); - -} /* cmPkPjUdxStaUpdReq */ - -/* -* -* Fun: cmPkPjUdxL2MeasSendReq -* -* Ret: ROK -ok -* -* Notes: None -* -* -*/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxL2MeasSendReq -( -Pst *pst, -U8 measType -) -#else -PUBLIC S16 cmPkPjUdxL2MeasSendReq(pst, measReqEvt) -Pst *pst; -U8 measType -#endif -{ - S16 ret1; - Buffer *mBuf = NULLP; - - TRC3(cmPkPjUdxL2MeasSendReq) - - if((ret1 = SGetMsg(pst->region, pst->pool, &mBuf)) != ROK) - { -#if (ERRCLASS & ERRCLS_ADD_RES) - if(ret1 != ROK) - { - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDXXXX, (ErrVal)0, "SGetMsg() failed"); - } -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - - RETVALUE(ret1); - } - - switch (pst->selector) - { - case UDX_SEL_LC: - { - } - case UDX_SEL_LWLC: - { - CMCHKPKLOG(SPkU8, measType, mBuf, EUDXXXX, pst); - break; - } - } - pst->event = (Event) PJ_UDX_EVT_L2MEAS_SEND_REQ; - - RETVALUE(SPstTsk(pst, mBuf)); - -} - -/* -* -* Fun: cmPkPjUdxL2MeasStopReq -* -* Ret: ROK -ok -* -* Notes: None -* -* -*/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxL2MeasStopReq -( -Pst *pst, -U8 measType -) -#else -PUBLIC S16 cmPkPjUdxL2MeasStopReq(pst, measType) -Pst *pst; -U8 measType -#endif -{ - S16 ret1; - Buffer *mBuf = NULLP; - - TRC3(cmPkPjUdxL2MeasStopReq) - - if((ret1 = SGetMsg(pst->region, pst->pool, &mBuf)) != ROK) - { -#if (ERRCLASS & ERRCLS_ADD_RES) - if(ret1 != ROK) - { - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDXXXX, (ErrVal)0, "SGetMsg() failed"); - } -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - - RETVALUE(ret1); - } - - switch (pst->selector) - { - case UDX_SEL_LC: - { - } - case UDX_SEL_LWLC: - { - CMCHKPKLOG(SPkU8, measType, mBuf, EUDXXXX, pst); - break; - } - } - pst->event = (Event) PJ_UDX_EVT_L2MEAS_STOP_REQ; - - RETVALUE(SPstTsk(pst, mBuf)); - -} - -/* - - -* Fun: cmUnpkPjUdxL2MeasReq -* -* Ret: ROK -ok -* -* Notes: None -* -* -*/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxL2MeasReq -( -UdxL2MeasReq func, -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxL2MeasReq(func, pst, mBuf) -UdxL2MeasReq func; -Pst *pst; -Buffer *mBuf; -#endif -{ - // S16 ret1; - PjL2MeasReqEvt *measReqEvt; - - TRC3(cmUnpkPjUdxL2MeasReq) - - switch (pst->selector) - { - case UDX_SEL_LC: - { - } - case UDX_SEL_LWLC: - { - CMCHKUNPK(cmUnpkPtr, (PTR *)&measReqEvt,mBuf); - break; - } - } - - SPutMsg(mBuf); - - RETVALUE((*func)(pst, measReqEvt)); -} /* cmUnpkPjUdxL2MeasReq */ - -/* -* -* Fun: cmUnpkPjUdxL2MeasSendReq -* -* Ret: ROK -ok -* -* Notes: None -* -* -*/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxL2MeasSendReq -( -UdxL2MeasSendReq func, -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxL2MeasSendReq(func, pst, mBuf) -UdxL2MeasSendReq func; -Pst *pst; -Buffer *mBuf; -#endif -{ - //S16 ret1; - U8 measType; - - TRC3(cmUnpkPjUdxL2MeasSendReq) - - switch (pst->selector) - { - case UDX_SEL_LC: - { - } - case UDX_SEL_LWLC: - { - CMCHKUNPK(SUnpkU8, &measType, mBuf); - break; - } - } - - SPutMsg(mBuf); - - RETVALUE((*func)(pst, measType)); -} /* cmUnpkPjUdxL2MeasReq */ - -/* -* -* Fun: cmUnpkPjUdxL2MeasStopReq -* -* Ret: ROK -ok -* -* Notes: None -* -* -*/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxL2MeasStopReq -( -UdxL2MeasStopReq func, -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxL2MeasStopReq(func, pst, mBuf) -UdxL2MeasStopReq func; -Pst *pst; -Buffer *mBuf; -#endif -{ - U8 measType; - - TRC3(cmUnpkPjUdxL2MeasStopReq) - - switch (pst->selector) - { - case UDX_SEL_LC: - { - } - case UDX_SEL_LWLC: - { - CMCHKUNPK(SUnpkU8, &measType, mBuf); - break; - } - } - - SPutMsg(mBuf); - - RETVALUE((*func)(pst, measType)); -} /* cmUnpkPjUdxL2MeasStopReq */ -#endif - -/* -* -* Fun: cmPkPjUdxDatResumeReq -* -* Ret: ROK -ok -* -* Notes: None -* -* -*/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxDatResumeReq -( -Pst *pst, -UdxDatResumeInfo *udxDatResumeInfo -) -#else -PUBLIC S16 cmPkPjUdxDatResumeReq(pst, cellId, ueId) -Pst *pst; -UdxDatResumeInfo *udxDatResumeInfo; -#endif -{ - S16 ret1; - Buffer *mBuf = NULLP; - - TRC3(cmPkPjUdxDatResume) - - if((ret1 = SGetMsg(pst->region, pst->pool, &mBuf)) != ROK) - { -#if (ERRCLASS & ERRCLS_ADD_RES) - if(ret1 != ROK) - { - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDXXXX, (ErrVal)0, "SGetMsg() failed"); - } -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, (Data *)udxDatResumeInfo,sizeof(UdxDatResumeInfo)); - RETVALUE(ret1); - } - - switch (pst->selector) - { - case UDX_SEL_LC: - { - } - case UDX_SEL_LWLC: - { - CMCHKPKLOG(cmPkPtr,(PTR)udxDatResumeInfo,mBuf,EUDXXXX,pst); - break; - } - } - pst->event = (Event) EVTUDXDATRESUME; - - RETVALUE(SPstTsk(pst, mBuf)); - -} /* cmPkPjUdxDatResumeReq */ - -/* -* -* Fun: cmUnpkPjUdxDatResumeReq -* -* Ret: ROK -ok -* -* Notes: None -* -* -*/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxDatResumeReq -( -UdxDatResumeReq func, -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxDatResumeReq(func, pst, mBuf) -UdxDatResumeReq func; -Pst *pst; -Buffer *mBuf; -#endif -{ - UdxDatResumeInfo *datResumeInfo; - - TRC3(cmUnpkPjUdxDatResumeReq) - - switch (pst->selector) - { - case UDX_SEL_LC: - { - } - case UDX_SEL_LWLC: - { - CMCHKUNPK(cmUnpkPtr,(PTR *) &datResumeInfo, mBuf); - break; - } - } - - SPutMsg(mBuf); - - RETVALUE((*func)(pst, datResumeInfo)); -} /* cmUnpkPjUdxDatResumeReq */ - -/* -* -* Fun: cmPkPjUdxDatForwardReq -* -* Ret: ROK -ok -* -* Notes: None -* -* -*/ -#ifdef ANSI -PUBLIC S16 cmPkPjUdxDatForwardReq -( -Pst *pst, -UdxDatForwardInfo *datFwdInfo -) -#else -PUBLIC S16 cmPkPjUdxDatForwardReq(pst, datFwdInfo) -Pst *pst; -UdxDatForwardInfo *datFwdInfo; -#endif -{ - S16 ret1; - Buffer *mBuf = NULLP; - - TRC3(cmPkPjUdxDatForwardReq) - - RLOG0(L_DEBUG,"Packing UdxDatForwadReq"); - if((ret1 = SGetMsg(pst->region, pst->pool, &mBuf)) != ROK) - { -#if (ERRCLASS & ERRCLS_ADD_RES) - if(ret1 != ROK) - { - SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, - __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, - (ErrVal)EUDXXXX, (ErrVal)0, "SGetMsg() failed"); - } -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - - RETVALUE(ret1); - } - - switch (pst->selector) - { - case UDX_SEL_LC: - { - } - case UDX_SEL_LWLC: - { - CMCHKPKLOG(cmPkPtr,(PTR)datFwdInfo,mBuf,EUDXXXX,pst); - break; - } - } - pst->event = (Event) EVTUDXDATFRWD; - - RETVALUE(SPstTsk(pst, mBuf)); - -} /* cmPkPjUdxDatForwardReq */ - -/* -* -* Fun: cmUnpkPjUdxDatForwardReq -* -* Ret: ROK -ok -* -* Notes: None -* -* -*/ -#ifdef ANSI -PUBLIC S16 cmUnpkPjUdxDatForwardReq -( -UdxDatForwardReq func, -Pst *pst, -Buffer *mBuf -) -#else -PUBLIC S16 cmUnpkPjUdxDatForwardReq(func, pst, mBuf) -UdxDatForwardReq func; -Pst *pst; -Buffer *mBuf; -#endif -{ - UdxDatForwardInfo *datFwdInfo; - - TRC3(cmUnpkPjUdxDatForwardReq) - - RLOG0(L_DEBUG,"Unpacking UdxDatForwadReq"); - switch (pst->selector) - { - case UDX_SEL_LC: - { - } - case UDX_SEL_LWLC: - { - CMCHKUNPK(cmUnpkPtr,(PTR *) &datFwdInfo, mBuf); - break; - } - } - - SPutMsg(mBuf); - - RETVALUE((*func)(pst, datFwdInfo)); -} /* cmUnpkPjUdxDatForwardReq */ -#endif /* end of #if(defined(LCUDX) || defined(LWLCUDX)) */ - -/********************************************************************30** - - End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_udx.h b/src/5gnrpdcp/pj_udx.h deleted file mode 100755 index fe54ddc3f..000000000 --- a/src/5gnrpdcp/pj_udx.h +++ /dev/null @@ -1,292 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: LTE PDCP Interface - - Type: C include file - - Desc: This file contains the defines required by PDCP user - - File: pj_udx.h - -*********************************************************************21*/ -#ifndef __UDX_H__ -#define __UDX_H__ - -#ifdef __cplusplus -EXTERN "C" { -#endif /*for extern "C"*/ - -/** - * @file - * @brief Macro for UDX Interface - */ - -#define UDX_SEL_LC 0 /* UDX loose couple selector */ -#define UDX_SEL_LWLC 1 -#define PJ_MAX_UDX 3 - -#define UDX_7BIT_SN_SIZE 7 /*!< Sequence length is 7-bit */ -#define UDX_12BIT_SN_SIZE 12 /*!< Sequence length is 12-bit */ -#define UDX_MAX_CFG 10 /*!< Maximum PDCP entity to be configured */ -#define UDX_MAX_DRB 12 /*!< Maximum DRBs per UE */ - -/* UDX Configuration Failure Reasons */ -#define UDX_CFG_REAS_NONE 0 /*!< No Failure */ -#define UDX_CFG_REAS_ENT_CREAT_FAIL 1 /*!< PDCP Entity Creation Failure*/ -#define UDX_CFG_REAS_UE_CREAT_FAIL 2 /*!< UE CB Creation Failure */ -#define UDX_CFG_REAS_INVALID_PDCPID 3 /*!< Invalid PDCP ID */ -#define UDX_CFG_REAS_PDCPID_PRSNT 4 /*!< PDCP ID already present */ -#define UDX_CFG_REAS_INVALID_RLCMODE 5 /*!< Invalid RLC Mode */ -#define UDX_CFG_REAS_PDCPID_UNKWN 6 /*!< PDCP ID Unknown */ -#define UDX_CFG_REAS_UE_UNKWN 7 /*!< UE Cb Unknown */ -#define UDX_CFG_REAS_CIPHER_ALGO_INVALID 8 /*!< Invalid Cipher Algo */ -#define UDX_CFG_REAS_ENT_DEL_FAIL 9 /*!< PDCP Entity Deletion Failure */ -#define UDX_CFG_REAS_UE_DEL_FAIL 10 /*!< UE Cb Deletion Failure */ -#define UDX_CFG_REAS_REEST_FAIL 11 /*!< PDCP Reestablish Failure */ -#define UDX_CFG_REAS_COMP_ALGO_INVALID 12 /*!< Compression Algo not - supported */ -#define UDX_CFG_REAS_RECFG_FAIL 13 /*!< PDCP Reconfiguration Failed */ -#define UDX_CFG_REAS_INVALID_CFG 14 /*!< Invalid Configuration Type */ -#define UDX_CFG_REAS_SAME_UEID 15 /*!< UE IDs match in ChngUeId - Request*/ -#define UDX_CFG_REAS_SAME_RBID 16 /*!< UE IDs match in ChngUeId - Request */ -#define UDX_CFG_REAS_INVALID_RBID 17 /*!< Invalid RB ID */ - -#define UDX_CFG_REAS_INTINIT_FAILED 18 /*!< Integrity Init Failed */ -#define UDX_CFG_REAS_CCIPHR_FAILED 19 /*!< Control Plane Cihper Init Failed */ -#define UDX_CFG_REAS_UCIPHR_FAILED 20 /*!< User Plane Cipher Init Failed */ - -#define UDX_CFG_REAS_NO_DRBS 21 /*!< No DRBs Present */ -#define UDX_CFG_REAS_OBD_TIMEOUT 22 /*!< No DRBs Present */ -#define UDX_CFG_REAS_INVALID_STATE 23 /*!< Invalid state to perform re-establishment */ - -/* UDX Configuration confirmations */ -#define UDX_CFG_CFM_OK 1 /*!< Confirm status OK */ -#define UDX_CFG_CFM_NOK 2 /*!< Confirm status NOK */ - -/*Event Code*/ -#define UDX_EVC_RESET_FAILED 1 /*!< Reset Failed */ - -#define EVTUDXBNDREQ 0x20 /*!< Bind Request */ -#define EVTUDXBNDCFM 0x21 /*!< Bind Confirmation */ -#define EVTUDXUBNDREQ 0x22 /*!< Unbind Request */ -#define EVTUDXCFGREQ 0x23 /*!< Config Request */ -#define EVTUDXCFGCFM 0x24 /*!< Config Confirmation */ -#define EVTUDXUEIDCHGREQ 0x25 /*!< UE ID Change Request */ -#define EVTUDXUEIDCHGCFM 0x26 /*!< UE ID Change Confirmation */ -#define EVTUDXSECCFGREQ 0x27 /*!< Security Config Request */ -#define EVTUDXSECCFGCFM 0x28 /*!< Security Config Confirm */ -#define EVTUDXREESTREQ 0x29 /*!< Count C Request */ -#define EVTUDXREESTCFM 0x2A /*!< Count C Confirm */ -#define EVTUDXCOUNTREQ 0x2B /*!< Count C Request */ -#define EVTUDXCOUNTCFM 0x2C /*!< Count C Confirm */ -#define EVTUDXSDUSTAREQ 0x2D /*!< SDU Status Request */ -#define EVTUDXSDUSTACFM 0x2E /*!< SDU Status Confirm */ -#define EVTUDXREESTTRIG 0x2F /*!< Reestablishment trigger */ -#define EVTUDXULSTAREP 0x30 /*!< UL PDCP Status Report */ -#define EVTUDXDLSTAREP 0x31 /*!< DL PDCP Status Report */ -#define EVTUDXULROHCFDB 0x32 /*!< ROHC FEEDBACK PKT INFO */ -#define EVTUDXDLROHCFDB 0x33 /*!< ROHC FEEDBACK PKT INFO */ -#define EVTUDXDATRESUME 0x34 /*!< Data Resume */ -#define EVTUDXDATFRWD 0x35 /*!< Data Forwarding */ -#define EVTUDXDATRESUMECFM 0x36 /*!< Dats Resume Confirm */ -#define EVTUDXDATFRWDCFM 0x37 /*!< Dats Forwarding Confirm */ -#define PJ_UDX_EVT_L2MEAS_REQ 0x38 /*!< L2 measurement request */ -#define PJ_UDX_EVT_L2MEAS_SEND_REQ 0x39 /*!< L2 measurement send request */ -#define PJ_UDX_EVT_L2MEAS_STOP_REQ 0x40 /*!< L2 measurement stop request */ - -#define UDX_CIPHER_KEY_LEN 16 /*!< Ciphering key length */ -#define UDX_INTG_KEY_LEN 16 /*!< Integrity key length */ -#define UDX_MAX_ROHC_PROF_LIST 9 /*!< ROHC profile list */ -#define UDX_MAX_CFM 10 /*!< Maximum number of confirm */ - -#define UDX_CFG_ADD 0x01 /*!< Configure new PDCP entity - in the requested UE */ -#define UDX_CFG_MODIFY 0x02 /*!< Reconfigure PDCP entity - in the requested UE */ -#define UDX_CFG_DELETE 0x03 /*!< Delete PDCP entity - in the requested UE */ -#define UDX_CFG_REESTABLISH 0x04 /*!< Reestablish PDCP entity - in the requested UE */ -#define UDX_CFG_DELETE_UE 0x05 /*!< Delete UE in PDCP */ - - -#define UDX_SEC_INTG_INFO 0x01 /*!< Integrity information */ -#define UDX_SEC_CIPHER_INFO 0x02 /*!< Ciphering information */ - -#define UDX_SEC_ALG_NULL 0x01 /*!< NULL algorithm */ -#define UDX_SEC_ALG_SNOW3G 0x02 /*!< Snow 3G algorithm */ -#define UDX_SEC_ALG_AES 0x03 /*!< AES algorithm */ - - - -/* Defines which is used in ModCfg to set the bitflag */ -#define UDX_RECFG_DISRQD 0x01 /*!< Discard Required is present*/ -#define UDX_RECFG_CFMREQ 0x02 /*!< Confirm Required is present */ - -/* Flags will be used to fill the Hand off information */ -#define UDX_HO_NOT_PRSNT 0 /*!< Hand of Info is not present */ -#define UDX_HO_UL 1 /*!< Uplink count present */ -#define UDX_HO_DL 2 /*!< Downlink count present */ - -/* cpj_h_001.main_2 added support for L2 Measurement */ -#ifdef LTE_L2_MEAS -#define UDX_MAX_QCI 10 -#endif - -/* Error Codes */ -#define EUDXXXX 0 -#define ERRUDX 0 - -#define EUDX001 (ERRUDX + 1) -#define EUDX002 (ERRUDX + 2) -#define EUDX003 (ERRUDX + 3) -#define EUDX004 (ERRUDX + 4) -#define EUDX005 (ERRUDX + 5) -#define EUDX006 (ERRUDX + 6) -#define EUDX007 (ERRUDX + 7) -#define EUDX008 (ERRUDX + 8) -#define EUDX009 (ERRUDX + 9) -#define EUDX010 (ERRUDX + 10) -#define EUDX011 (ERRUDX + 11) -#define EUDX012 (ERRUDX + 12) -#define EUDX013 (ERRUDX + 13) -#define EUDX014 (ERRUDX + 14) -#define EUDX015 (ERRUDX + 15) -#define EUDX016 (ERRUDX + 16) -#define EUDX017 (ERRUDX + 17) -#define EUDX018 (ERRUDX + 18) -#define EUDX019 (ERRUDX + 19) -#define EUDX020 (ERRUDX + 20) -#define EUDX021 (ERRUDX + 21) -#define EUDX022 (ERRUDX + 22) -#define EUDX023 (ERRUDX + 23) -#define EUDX024 (ERRUDX + 24) -#define EUDX025 (ERRUDX + 25) -#define EUDX026 (ERRUDX + 26) -#define EUDX027 (ERRUDX + 27) -#define EUDX028 (ERRUDX + 28) -#define EUDX029 (ERRUDX + 29) -#define EUDX030 (ERRUDX + 30) -#define EUDX031 (ERRUDX + 31) -#define EUDX032 (ERRUDX + 32) -#define EUDX033 (ERRUDX + 33) -#define EUDX034 (ERRUDX + 34) -#define EUDX035 (ERRUDX + 35) -#define EUDX036 (ERRUDX + 36) -#define EUDX037 (ERRUDX + 37) -#define EUDX038 (ERRUDX + 38) -#define EUDX039 (ERRUDX + 39) -#define EUDX040 (ERRUDX + 40) -#define EUDX041 (ERRUDX + 41) -#define EUDX042 (ERRUDX + 42) -#define EUDX043 (ERRUDX + 43) -#define EUDX044 (ERRUDX + 44) -#define EUDX045 (ERRUDX + 45) -#define EUDX046 (ERRUDX + 46) -#define EUDX047 (ERRUDX + 47) -#define EUDX048 (ERRUDX + 48) -#define EUDX049 (ERRUDX + 49) -#define EUDX050 (ERRUDX + 50) -#define EUDX051 (ERRUDX + 51) -#define EUDX052 (ERRUDX + 52) -#define EUDX053 (ERRUDX + 53) -#define EUDX054 (ERRUDX + 54) -#define EUDX055 (ERRUDX + 55) -#define EUDX056 (ERRUDX + 56) -#define EUDX057 (ERRUDX + 57) -#define EUDX058 (ERRUDX + 58) -#define EUDX059 (ERRUDX + 59) -#define EUDX060 (ERRUDX + 60) -#define EUDX061 (ERRUDX + 61) -#define EUDX062 (ERRUDX + 62) -#define EUDX063 (ERRUDX + 63) -#define EUDX064 (ERRUDX + 64) -#define EUDX065 (ERRUDX + 65) -#define EUDX066 (ERRUDX + 66) -#define EUDX067 (ERRUDX + 67) -#define EUDX068 (ERRUDX + 68) -#define EUDX069 (ERRUDX + 69) -#define EUDX070 (ERRUDX + 70) -#define EUDX071 (ERRUDX + 71) -#define EUDX072 (ERRUDX + 72) -#define EUDX073 (ERRUDX + 73) -#define EUDX074 (ERRUDX + 74) -#define EUDX075 (ERRUDX + 75) -#define EUDX076 (ERRUDX + 76) -#define EUDX077 (ERRUDX + 77) -#define EUDX078 (ERRUDX + 78) -#define EUDX079 (ERRUDX + 79) -#define EUDX080 (ERRUDX + 80) -#define EUDX081 (ERRUDX + 81) -#define EUDX082 (ERRUDX + 82) -#define EUDX083 (ERRUDX + 83) -#define EUDX084 (ERRUDX + 84) -#define EUDX085 (ERRUDX + 85) -#define EUDX086 (ERRUDX + 86) -#define EUDX087 (ERRUDX + 87) -#define EUDX088 (ERRUDX + 88) -#define EUDX089 (ERRUDX + 89) -#define EUDX090 (ERRUDX + 90) -#define EUDX091 (ERRUDX + 91) -#define EUDX092 (ERRUDX + 92) -#define EUDX093 (ERRUDX + 93) -#define EUDX094 (ERRUDX + 94) -#define EUDX095 (ERRUDX + 95) -#define EUDX096 (ERRUDX + 96) -#define EUDX097 (ERRUDX + 97) -#define EUDX098 (ERRUDX + 98) -#define EUDX099 (ERRUDX + 99) -#define EUDX100 (ERRUDX + 100) -#define EUDX101 (ERRUDX + 101) -#define EUDX102 (ERRUDX + 102) -#define EUDX103 (ERRUDX + 103) -#define EUDX104 (ERRUDX + 104) -#define EUDX105 (ERRUDX + 105) -#define EUDX106 (ERRUDX + 106) -#define EUDX107 (ERRUDX + 107) -#define EUDX108 (ERRUDX + 108) -#define EUDX109 (ERRUDX + 109) -#define EUDX110 (ERRUDX + 110) -#define EUDX111 (ERRUDX + 111) -#define EUDX112 (ERRUDX + 112) -#define EUDX113 (ERRUDX + 113) -#define EUDX114 (ERRUDX + 114) -#define EUDX115 (ERRUDX + 115) -#define EUDX116 (ERRUDX + 116) -#define EUDX117 (ERRUDX + 117) -#define EUDX118 (ERRUDX + 118) -#define EUDX119 (ERRUDX + 119) -#define EUDX120 (ERRUDX + 120) -#define EUDX121 (ERRUDX + 121) -#define EUDX122 (ERRUDX + 122) - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ -#endif /* __UDX_H__ */ - -/********************************************************************30** - - End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_udx.x b/src/5gnrpdcp/pj_udx.x deleted file mode 100755 index b9145692c..000000000 --- a/src/5gnrpdcp/pj_udx.x +++ /dev/null @@ -1,1503 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: LTE PDCP Interface - - Type: C include file - - Desc: This file contains the Data structures for LTE PDCP Interface - - File: pj_udx.x - -*********************************************************************21*/ -#ifndef __PJ_UDX_X__ -#define __PJ_UDX_X__ - -#ifdef __cplusplus -EXTERN "C" { -#endif /*for extern "C"*/ - -/** - * @file - * @brief UDX Interface file - */ - -/************************************************************************* - * START OF STRUCTURES - ************************************************************************/ -/** - * @brief - * Cipher Key type information. - */ -typedef U8 UdxCipherKey; - -/** - * @brief - * Integrity Key type information. - */ -typedef U8 UdxIntegrityKey; - -/** - * @brief - * RLC Parameter Information in AM mode. - */ -typedef struct udxRlcAm -{ - Bool statusRepReqd; /*!< Status report required */ - U8 pdcpSNSize; /*!< Length of PDCP sequence number */ -}UdxRlcAm; - -/** - * @brief - * RLC Parameter Information in UM mode. - */ -typedef struct udxRlcUm -{ - U8 pdcpSNSize; /*!< Length of PDCP sequence number */ -}UdxRlcUm; - -/** - * @brief - * Mapped RLC Entity Information in RLC for the PDCP Entity - */ -typedef struct udxRlcInfo -{ - U8 dir; /*!< UPLINK/DOWNLINK/BOTH */ - U8 mode; /*!< RLC Mode */ - union - { - UdxRlcAm rlcAm; /*!< RLC in AM mode */ - UdxRlcUm rlcUm; /*!< RLC in UM mode */ - }m; -}UdxRlcInfo; - - -/** - * @brief - * Ciphering Information to be configured per UE in PDCP. - */ -typedef struct udxCipherInfo -{ - UdxCipherKey ctrlplnKey[UDX_CIPHER_KEY_LEN]; /*!< Control plane - ciphering key */ - UdxCipherKey usrplnKey[UDX_CIPHER_KEY_LEN]; /*!< User plane - ciphering key */ - U8 algoType; /*!< Algorithm type. - Allowed values are: - -# UDX_SEC_ALG_NULL - -# UDX_SEC_ALG_SNOW3G - -# UDX_SEC_ALG_AES - */ -}UdxCipherInfo; - -/** - * @brief - * Integrity protection paramater information. -*/ -typedef struct udxIntegInfo -{ - U8 algoType; /*!< Algorithm type. - Allowed values are: - -# UDX_SEC_ALG_AES - -# UDX_SEC_ALG_SNOW3G - */ - UdxIntegrityKey intKey[UDX_INTG_KEY_LEN]; /*!< Integrity key */ -} UdxIntegInfo; - -/** - * @brief - * PDCP Security configuration parameter. - */ -typedef struct udxSecCfg -{ - Bool selSecAct; /*!< Selective security activation flag. - - PDCP applies only Integrity algorithm for the first UL and first DL - messages (security activation procedure), applies both Integrity and - ciphering for all the other messages (including handover which involves - reconfiguration messages). selSecAct enables to identify whether - PDCP needs to selectively apply only Integrity for first UL/DL message. - */ - Bool isHo; /*!< Will be set true in case of HO > */ - UdxIntegInfo integInfo; /*!< Integrity configuration */ - UdxCipherInfo cipherInfo; /*!< Ciphering configuration */ -} UdxSecCfg; - -/** - * @brief - * ROHC Compression protocol information structure. - */ -typedef struct udxRohcInfo -{ - U16 maxCid; /*!< Maximum CID */ - Bool profLst[UDX_MAX_ROHC_PROF_LIST]; /*!< ROHC profile - information */ -}UdxRohcInfo; - -/** - * @brief - * ROHC Configuration information for PDCP entity. - */ -typedef struct udxHdrCompCfg -{ - Bool hdrCompUsed; /*!< Header Compression Used/Not */ - UdxRohcInfo rohcInfo; /*!< ROHC configuration information */ -}UdxHdrCompCfg; - -/** - * @brief - * Handover Information for RB. - */ -typedef struct udxHoInfo -{ - U8 isHoPres; /*!< Last 2bits (from LSB)is used to convey handover information is present or - not. @n Allowed values are: - -# UDX_HO_NOT_PRSNT 00 - -# UDX_HO_UL 01 - -# UDX_HO_DL 10 - */ - U8 snLen; /*!< PDCP-SN length 12/15 bits */ - U32 dlCount; /*!< DL COUNT to assign for new SDUs */ - U32 ulCount; /*!< UL First Missing SN */ - U16 numBits; /*!< Number of bits in UL bitmap */ - U8 *ulBitMap; /*!< UL SN bitmap excluding FMS to be used - as status report */ -} UdxHoInfo; - -/** - * @brief - * Configuraiton Structure to add an RB. - */ -typedef struct udxAddCfgEnt -{ - Bool discReqd; /*!< Discard required/not for PDUs - with Integrity Verification failure */ - Bool cfmReqd; /*!< Confirm required/not for SDUs - received by the peer PDCP entity. */ - /* cpj_x_001.main_3 added support for L2 Measurement */ -#ifdef LTE_L2_MEAS - U8 qci; /*!< qCI value Associated with that RB */ -#endif /* LTE_L2_MEAS */ - - UdxRlcInfo rlcInfo; /*!< Corresponding RLC entity information. */ - S16 discardTmr; /*!< Discard timer. @n The value for this parameter - is expected in milli seconds. @n Value of infinity - is also allowed and -1 must be passed for - the same. */ - U16 reOrdTmrVal; /*!< t-Reorder Timer Value in ms */ - UdxHdrCompCfg hdrCompCfg; /*!< PDCP compression information */ -}UdxAddCfgEnt; - -/** - * @brief - * Configuraiton Structure to modify an RB. - */ -typedef struct udxModCfgEnt -{ - - U8 bitFlag; /*!< List of Modified Elements - Each bit respresents one element */ - - Bool discReqd; /*!< Discard required/not for PDUs - with Integrity Verification failure. - bitFlag=0x01 */ - Bool cfmReqd; /*!< Confirm required/not for SDUs - received by the peer PDCP entity. - bitFlag=0x02 */ - UdxHdrCompCfg hdrCompCfg; /*!< PDCP compression information */ - UdxHoInfo hoInfo; /*!< Handover Information */ - U16 reOrdTmrVal; /*!< t-Reorder Timer Value in ms */ -}UdxModCfgEnt; - - -/** - * @brief - * Configuration structure for PDCP entity. - */ -typedef struct udxCfgEnt -{ - U8 rbId; /*!< PDCP ID. */ - U8 cfgType; /*!< Configuration request type - - -# UDX_CFG_ADD, - -# UDX_CFG_MODIFY, - -# UDX_CFG_DELETE, - -# UDX_REESTABLISH, - -# UDX_CFG_DELETE_UE */ - U8 rbType; /*!< RB type. - -# CM_LTE_SRB - -# CM_LTE_DRB */ - - union{ - UdxAddCfgEnt addCfg; /*!< Configuration parameters for - cfgType UDX_CFG_ADD */ - UdxModCfgEnt modCfg; /*!< Configuration parameters for - cfgType UDX_CFG_MODIFY */ - }m; -}UdxCfgEnt; - - - -/** - * @brief - * PDCP Configuration structure. Parameters are filled by RRC - layer while configuring the PDCP layer. - */ -typedef struct udxCfgReqInfo -{ - CmLteRnti ueId; /*!< UE ID */ - CmLteCellId cellId; /*!< Cell ID */ - U32 transId; /*!< Transaction ID */ - U8 numEnt; /*!< Number of entities to be - configured in the Config request.*/ - U8 isHo; -#ifdef TENB_MULT_CELL_SUPPRT - SpId rlcUlSapId; - SpId rlcDlSapId; -#endif - UdxCfgEnt cfgEnt[UDX_MAX_CFG]; /*!< Config paramater for - PDCP entity. */ -}UdxCfgReqInfo; - - -/** - * @brief - * Status report from PDCP-UL to PDCP-DL during Reestablishment. - */ -typedef struct udxUlStaRepInfo -{ - CmLtePdcpId pdcpId; - Buffer *sta; -}UdxUlStaRepInfo; - -/** - * @brief - * Status report received from peer RLC entity. - */ -typedef struct udxDlStaRepInfo -{ - CmLtePdcpId pdcpId; - U32 fmc; - Buffer *staPdu; -}UdxDlStaRepInfo; - - -/** - * @brief - * ROHC Feedback packet Info from PDCP-UL to PDCP-DL. - */ -typedef struct udxUlFdbkPktInfo -{ - CmLtePdcpId pdcpId; - Buffer *fbPkt; -}UdxUlFdbkPktInfo; - -/** - * @brief - * ROHC Feedback packet Info received from UE. Send to PDCP-DL. - */ -typedef struct udxDlFdbkPktInfo -{ - CmLtePdcpId pdcpId; - Buffer *fbPkt; -}UdxDlFdbkPktInfo; - - -/** - * @brief - * PDCP Confirm parameter structure for PDCP entity. - */ -typedef struct udxCfmEnt -{ - U8 rbId; /*!< RB ID */ - U8 rbType; /*!< RB Type */ - Status status; /*!< ROK or RFAILED */ - Reason reason; /*!< Reason for failure */ -}UdxCfmEnt; - -/** - * @brief - * PDCP Configuration Confirm structure. - */ -typedef struct udxCfgCfmInfo -{ - CmLteRnti ueId; /*!< UE ID */ - CmLteCellId cellId; /*!< Cell ID */ - U32 transId; /*!< Transcation ID */ - U8 numEnt; /*!< Number of entities */ - UdxCfmEnt cfmEnt[UDX_MAX_CFM]; /*!< Confirm parameter for - PDCP entity */ -}UdxCfgCfmInfo; - -/** - * @brief - * Re-estabishment Request structure for SRB1 of an UE. - */ -typedef struct udxReEstReqInfo -{ - CmLtePdcpId pdcpId; /*!< PDCP ID */ - U32 transId; /*!< Transcation ID */ - U8 intKey[UDX_INTG_KEY_LEN]; /*!< Integrity key */ - UdxCipherKey ctrlplnKey[UDX_CIPHER_KEY_LEN]; /*!< Control plane - ciphering key */ - UdxCipherKey usrplnKey[UDX_CIPHER_KEY_LEN]; /*!< User plane - ciphering key */ -}UdxReEstReqInfo; - -/** - * @brief - * Re-establishment Confirmation structure for an UE. - */ -typedef struct udxReEstCfmInfo -{ - CmLteRnti ueId; /*!< UE ID */ - CmLteCellId cellId; /*!< Cell ID */ - U32 transId; /*!< Transcation ID */ - Status status; /*!< Status of reestablishment. - Allowed values are: - -# LCM_PRIM_OK - -# LCM_PRIM_NOK - */ -}UdxReEstCfmInfo; - -/** - * @brief - * PDCP Security Configuration structure. Parameters are filled by RRC - * while configuring the security parameters. - */ -typedef struct udxSecCfgReqInfo -{ - CmLteRnti ueId; /*!< UE ID */ - CmLteCellId cellId; /*!< Cell ID */ - U32 transId; /*!< Transcation ID */ - UdxSecCfg secCfg; /*!< Configuration paramater for PDCP entity */ -}UdxSecCfgReqInfo; - -/** - * @brief - * PDCP Security Configuration confirm structure. - */ -typedef struct udxSecCfgCfmInfo -{ - CmLteRnti ueId; /*!< UE ID */ - CmLteCellId cellId; /*!< Cell ID */ - U32 transId; /*!< Transcation ID */ - Status status; /*!< ROK or RFAILED */ - Reason reason; /*!< Reason for failure */ -}UdxSecCfgCfmInfo; - -/** - * @brief - * UE ID Information - */ -typedef struct udxUeInfo -{ - CmLteCellId cellId; /*!< Cell ID */ - CmLteRnti ueId; /*!< UE ID */ -}UdxUeInfo; - -/** - * @brief - * PDCP Count Request Information from RRC. - */ -typedef struct udxCountReqInfo -{ - CmLteRnti ueId; /*!< UE ID */ - CmLteCellId cellId; /*!< Cell ID */ - U32 transId; /*!< Transaction ID */ -} UdxCountReqInfo; - -/** - * @brief - * PDCP Count Information for a DRB. - */ -typedef struct udxCountInfo -{ - U8 rbId; /*!< RB ID */ - U8 dir; /*!< Direction of the RB */ - U32 ulCount; /*!< UL Count value */ - U32 dlCount; /*!< DL Count value */ -} UdxCountInfo; -/** - * @brief - * PDCP Count Request Confirmation to RRC. - */ -typedef struct udxCountCfmInfo -{ - CmLteRnti ueId; /*!< UE ID */ - CmLteCellId cellId; /*!< Cell ID */ - U32 transId; /*!< Transaction ID */ - U8 numRb; /*!< Number of DRBs */ - UdxCountInfo countInfo[UDX_MAX_DRB]; /*!< CountInfo of DRBs */ - Status status; /*!< ROK or RFAILED */ - Reason reason; /*!< Reason for failure */ -} UdxCountCfmInfo; - -/** - * @brief - * PDCP SDU Status Request Information from RRC - Used for reestablishment - * during handover. - */ -typedef struct udxSduStaReqInfo -{ - CmLteRnti ueId; /*!< UE ID */ - CmLteCellId cellId; /*!< Cell ID */ - U32 transId; /*!< Transaction ID */ -} UdxSduStaReqInfo; - -/** - * @brief - * PDCP DL SDU Status Information for a DRB mapped to RLC AM. - */ -typedef struct udxDlSduStaInfo -{ - Bool hoPres; - U32 count; /*!< Count with the next SN to be assigned - for a SDU */ -} UdxDlSduStaInfo; - -/** - * @brief - * PDCP SDU Status Information for a DRB mapped to RLC AM. - */ -typedef struct udxSduStaInfo -{ - U8 rbId; /*!< RB ID */ - U8 dir; /*!< Direction of the RB */ - UdxDlSduStaInfo dlSduStaInfo; /*!< SDU Status Info for DL */ -} UdxSduStaInfo; - -/** - * @brief - * PDCP SDU Status Request Confirmation for an UE. - */ -typedef struct udxSduStaCfmInfo -{ - CmLteRnti ueId; /*!< UE ID */ - CmLteCellId cellId; /*!< Cell ID */ - U32 transId; /*!< Transaction ID */ - U8 numRb; /*!< Number of RBs */ - UdxSduStaInfo sduStaInfo[UDX_MAX_DRB]; /*!< SDU Status Info of DRBs mapped - to RLC AM */ - Status status; /*!< ROK or RFAILED */ - Reason reason; /*!< Reason for Failure */ -} UdxSduStaCfmInfo; - -/** - * @brief - * Data Resume - */ -typedef struct udxDatResumeInfo -{ - CmLteRnti ueId; /*!< UE ID */ - CmLteCellId cellId; /*!< Cell ID */ - U32 transId; /*!< Transcation ID */ -} UdxDatResumeInfo; - -/** - * @brief - * Data Fwd Cfm - */ -typedef struct udxDatFwdCfmInfo -{ - CmLteRnti ueId; /*!< UE ID */ - CmLteCellId cellId; /*!< Cell ID */ - Status status; /*!< ROK or RFAILED */ - Reason reason; /*!< Reason for Failure */ -}UdxDatFwdCfmInfo; - - -typedef struct udxDatResumeCfmInfo -{ - CmLteRnti ueId; /*!< UE ID */ - CmLteCellId cellId; /*!< Cell ID */ - U32 transId; /*!< Transcation ID */ - Status status; /*!< ROK or RFAILED */ - Reason reason; /*!< Reason for Failure */ -} UdxDatResumeCfmInfo; -/** - * @brief - * Data Forward - */ -typedef struct udxDatForwardInfo -{ - CmLteRnti ueId; /*!< UE ID */ - CmLteCellId cellId; /*!< Cell ID */ - U32 transId; /*!< Transcation ID */ - Bool ulFwding; /*!< UL fwding to be done or not */ -} UdxDatForwardInfo; - -/************************************************************************* - * END OF STRUCTURES - ************************************************************************/ - -/************************************************************************* - * Start of Pointer Interface primitives - ************************************************************************/ -typedef S16 (*UdxBndReq) ARGS((Pst *pst, SuId suId, SpId spId)); -typedef S16 (*UdxBndCfm) ARGS((Pst *pst, SuId suId, U8 status)); -typedef S16 (*UdxUbndReq) ARGS((Pst *pst, SpId spId, Reason reason)); -typedef S16 (*UdxCfgReq) ARGS((Pst *pst, SpId spId, UdxCfgReqInfo *cfgReq)); -typedef S16 (*UdxCfgCfm) ARGS((Pst *pst, SuId suId, UdxCfgCfmInfo *cfgCfm)); -typedef S16 (*UdxReEstReq) ARGS((Pst *pst, SpId spId, UdxReEstReqInfo *reEstReq)); -typedef S16 (*UdxReEstCfm) ARGS((Pst *pst, SuId suId, UdxReEstCfmInfo *reEstCfm)); -typedef S16 (*UdxSecCfgReq) ARGS((Pst *pst, SpId spId, UdxSecCfgReqInfo *secCfgReq)); -typedef S16 (*UdxSecCfgCfm) ARGS((Pst *pst, SuId suId, UdxSecCfgCfmInfo *secCfgCfm)); -typedef S16 (*UdxUeIdChgReq) ARGS((Pst *pst, SpId spId, U32 transId, - UdxUeInfo *oldUeInfo, - UdxUeInfo *newUeInfo)); -typedef S16 (*UdxUeIdChgCfm) ARGS((Pst *pst, SuId suId, U32 transId, - UdxUeInfo *ueInfo, CmStatus status)); -typedef S16 (*UdxCountReq) ARGS((Pst *pst, SpId spId, UdxCountReqInfo *countReq)); -typedef S16 (*UdxCountCfm) ARGS((Pst *pst, SuId suId, UdxCountCfmInfo *countCfm)); -typedef S16 (*UdxSduStaReq) ARGS((Pst *pst, SpId spId, UdxSduStaReqInfo *staReq)); -typedef S16 (*UdxSduStaCfm) ARGS((Pst *pst, SuId suId, UdxSduStaCfmInfo *staCfm)); -typedef S16 (*UdxDatResumeCfm) ARGS((Pst *pst, SuId suId, UdxDatResumeCfmInfo *datResumeCfm)); -typedef S16 (*UdxDatForwardCfm) ARGS((Pst *pst, SuId suId, UdxDatFwdCfmInfo *datFwdCfm)); -typedef S16 (*UdxUlStaRep) ARGS((Pst *pst, SpId spId, UdxUlStaRepInfo *staRep)); -typedef S16 (*UdxDlStaRep) ARGS((Pst *pst, SpId spId, UdxDlStaRepInfo *staRep)); -typedef S16 (*UdxUlFdbkPkt) ARGS((Pst *pst, SpId spId, UdxUlFdbkPktInfo *fdbkPktInfo)); -typedef S16 (*UdxDlFdbkPkt) ARGS((Pst *pst, SpId spId, UdxDlFdbkPktInfo *fdbkPktInfo)); -typedef S16 (*UdxDatResumeReq) ARGS((Pst *pst, UdxDatResumeInfo *udxDatResumeInfo)); -typedef S16 (*UdxDatForwardReq) ARGS((Pst *pst, UdxDatForwardInfo *udxDatForwardInfo)); - -#ifdef LTE_L2_MEAS -typedef S16 (*UdxL2MeasReq) ARGS((Pst* pst, - PjL2MeasReqEvt *measReqEvt)); - -typedef S16 (*UdxL2MeasSendReq) ARGS((Pst* pst, - U8 measType)); - -typedef S16 (*UdxL2MeasStopReq) ARGS((Pst* pst, - U8 measType)); -#endif - - -/************************************************************************* - * End of Pointer Interface primitives - ************************************************************************/ -/* cpj_x_001.main_2 */ -/************************************************************************* - * Start of Extern Interface Declarations - ************************************************************************/ -/** - * @brief Bind request primitive - * @details - * The function binds the PDCP service user entity (RRC) to the PDCP product. - * PDCP acknowledges the receipt of the bind request by sending a PjDlUdxBndCfm - * primitive. - * - * @param[in] pst - Pointer to the post structure. - * @param[in] suId - Service user ID. This is the reference number used by - * PDCP service user to identify its SAP. This reference number is - * provided by PDCP in any further primitives sent by PDCP to the service user. - * @param[in] spId - Service provider ID. This is the reference number used - * by PDCP service user to identify its SAP. This reference number is - * provided by PDCP in any further primitives sent by PDCP to the service user. - * - * @return ROK - */ -EXTERN S16 PjUlUdxBndReq ARGS((Pst *pst, SuId suId, SpId spId)); -EXTERN S16 PjDlUdxBndReq ARGS((Pst *pst, SuId suId, SpId spId)); - -/** - * @brief Bind confirmation primitive - * @details - * PDCP invokes the bind confirm primitive to acknowledge the receipt of - * the PjDlUdxBndReq primitive from the RRC layer. The status field indicates - * whether the bind request succeeded or failed. The bind request may fail due - * to invalid parameters in the bind request from the service user - * (for example, an invalid spId). - * - * @param[in] pst - Pointer to the pst structure. - * @param[in] suId - Service user ID. This is the reference number used - * by PDCP service user (RRC layer) to identify its SAP. - * @param[in] status - Status field indicates whether the bind request - * succeeded or failed. - * -# TRUE, for successful bind. - * -# FALSE, otherwise. - * - * @return ROK. - */ -EXTERN S16 PjDlUdxBndCfm ARGS((Pst *pst, SuId suId, U8 status)); -EXTERN S16 PjUlUdxBndCfm ARGS((Pst *pst, SuId suId, U8 status)); - -/** - * @brief Unbind request primitive - * @details - * The PDCP service user (RRC) initiates this primitive for performing - * an unbind operation. This function brings the link between RRC and PDCP - * down if it is already up, and releases all the resources associated for - * this SAP at PDCP. - * - * @param[in] pst - Pointer to the post structure. - * @param[in] spId - Service provider ID. This is the reference number used - * by PDCP to identify its SAP. - * @param[in] reason - Unbind reason. Not used in the current implementation. - * - * @return ROK - */ -EXTERN S16 PjUlUdxUbndReq ARGS((Pst *pst, SpId spId, Reason reason)); -EXTERN S16 PjDlUdxUbndReq ARGS((Pst *pst, SpId spId, Reason reason)); - -/** - * @brief Configuration request primitive - * @details - * RRC uses this primitive to configure PDCP system parameters. The - * various parameters are configured by RRC. In one configuration request, - * multiple PDCP entities can be configured based on the rbId. - * For PDCP on target eNB, RRC can configure the handover information. - * - * @param[in] pst - Pointer to post structure. - * @param[in] spId - Service provider ID. This is the reference number used - * by PDCP to identify its SAP. - * @param[in] pdcpCfg - PDCP configuration structure. - * - * @return ROK - */ -EXTERN S16 PjUlUdxCfgReq ARGS((Pst *pst, SpId spId, UdxCfgReqInfo *cfgReq)); -EXTERN S16 PjDlUdxCfgReq ARGS((Pst *pst, SpId spId, UdxCfgReqInfo *cfgReq)); -EXTERN S16 PjDlUdxUlStaRep ARGS ((Pst *pst, SpId spId, UdxUlStaRepInfo *staRep)); -EXTERN S16 PjDlUdxDlStaRep ARGS ((Pst *pst, SpId spId, UdxDlStaRepInfo *staRep)); -EXTERN S16 PjUlUdxUlFdbkPktInfo ARGS((Pst *pst, SpId spId, UdxUlFdbkPktInfo *fdbkPktInfo)); -EXTERN S16 PjUlUdxDlFdbkPktInfo ARGS((Pst *pst, SpId spId, UdxDlFdbkPktInfo *fdbkPktInfo)); - - -/** - * @brief Configuration confirmation primitive - * @details - * This primitive is invoked by PDCP to inform to PDCP User (RRC) about - * the PDCP configuration request primitive execution status. - * - * @param[in] pst - Pointer to the post structure. - * @param[in] suId - Service user ID. This is the reference number used - * by PDCP to identify its SAP. - * @param[in] pdcpCfgCfm - PDCP configuration confirm structure. - * - * @return ROK - */ -EXTERN S16 PjUlUdxCfgCfm ARGS((Pst *pst, SuId suId, UdxCfgCfmInfo *cfgCfm)); -EXTERN S16 PjDlUdxCfgCfm ARGS((Pst *pst, SuId suId, UdxCfgCfmInfo *cfgCfm)); - -/** - * @brief Reestablishment request primtive - * @details - * RRC uses this primitive to reestablish the PDCP entity. - * This primitive is initiation of reestablishment procedure. - * This prmitive and corresponding confirmation are followed by - * PjDlUdxCfgReq procedure for entire reestablishment procedure to complete. - * - * @param[in] pst - Pointer to post structure. - * @param[in] spId - Service provider ID. This is the reference number used by - * PDCP to identify its SAP. - * @param[in] reEstReq - PDCP reestablishment request structure. - * - */ -EXTERN S16 PjUlUdxReEstReq ARGS((Pst *pst, SpId spId, UdxReEstReqInfo *reEstReq)); -EXTERN S16 PjDlUdxReEstReq ARGS((Pst *pst, SpId spId, UdxReEstReqInfo *reEstReq)); - -/** - * @brief Reestablishment confirmation primitive - * @details - * This primitive is invoked by PDCP to inform PDCP User (RRC) about the PDCP - * (SRB1) reestablishment request primitive execution status. - * - * @param[in] pst - Pointer to the post structure. - * @param[in] suId - Service user ID. This is the reference number used - * by PDCP to identify its SAP. - * @param[in] reEstCfm - PDCP reestablishment confirm structure. - * - */ -EXTERN S16 PjUlUdxReEstCfm ARGS((Pst *pst, SuId suId, UdxReEstCfmInfo *reEstCfm)); -EXTERN S16 PjDlUdxReEstCfm ARGS((Pst *pst, SuId suId, UdxReEstCfmInfo *reEstCfm)); - -/** - * @brief Security Configuration request primitive - * @details - * RRC uses this primitive to configure PDCP security parameters. - * Integrity protection and/or Ciphering are configured by RRC based on the - * selSecAct flag. Integrity Protection/Ciphering are configured per UE and applicable - * to all PDCP entities in that UE. Both Integrity protection and ciphering are - * configured during reestablishment. - * - * @param[in] pst - Pointer to post structure. - * @param[in] spId - Service provider ID. This is the reference number used by - * PDCP to identify its SAP. - * @param[in] pdcpSecCfg - PDCP security configuration structure. - * - * @return ROK - */ -EXTERN S16 PjUlUdxSecCfgReq ARGS((Pst *pst, SpId spId, - UdxSecCfgReqInfo *secCfgReq)); -EXTERN S16 PjDlUdxSecCfgReq ARGS((Pst *pst, SpId spId, - UdxSecCfgReqInfo *secCfgReq)); - -/** - * @brief Security Configuration confirmation primitive. - * @details - * This primitive is invoked by PDCP to inform to PDCP User (RRC) about - * the PDCP secutiry configuration request primitive execution status. - * - * @param[in] pst - Pointer to the post structure. - * @param[in] suId - Service user ID. This is the reference number used - * by PDCP to identify its SAP. - * @param[in] pdcpSecCfgCfm - PDCP configuration confirm structure. - * - * @return ROK - */ -EXTERN S16 PjUlUdxSecCfgCfm ARGS( (Pst *pst, SuId suId, - UdxSecCfgCfmInfo *secCfgCfm)); -EXTERN S16 PjDlUdxSecCfgCfm ARGS( (Pst *pst, SuId suId, - UdxSecCfgCfmInfo *secCfgCfm)); - -/** - * @brief UE ID change request primitive - * @details - * This primitive is used by RRC to change the UeId for the existing UE context. - * - * @param[in] pst - Point to the post structure - * @param[in] spId - The ID of the service provider SAP in the PDCP layer. - * @param[in] transId - Transaction ID. This field uniquely identifies - * transaction between RRC and PDCP. - * @param[in] oldUeInfo - Old UE ID info for which the change request has come. - * @param[in] newUeInfo - New UE ID info for existing UE context. - * - * @return ROK - */ -EXTERN S16 PjUlUdxUeIdChgReq ARGS((Pst *pst, SpId spId, U32 transId, - UdxUeInfo *oldUeInfo, UdxUeInfo *newUeInfo)); -EXTERN S16 PjDlUdxUeIdChgReq ARGS((Pst *pst, SpId spId, U32 transId, - UdxUeInfo *oldUeInfo, UdxUeInfo *newUeInfo)); - -/** - * @brief UE ID change confirmation primitive - * @details - * This primitive is used by PDCP to confirm the UeId change requested by RRC. - * The different values for status are:\n - * ROK - Success\n - * RFAILED - Failure\n - * - * The different reasons for the failure are: - * UDX_CFG_REAS_UE_CREAT_FAIL - UE Cb update failure \n - * UDX_CFG_REAS_UE_UNKWN - Request received for an unknown UE ID. - * - * @param [in] pst - Point to the post structure. - * @param [in] suId - The ID of the service user SAP associated with PDCP - * @param [in] transId - Transaction ID. This field uniquely identifies - * transaction between RRC and PDCP. - * @param [in] ueInfo - UE Identity which is changed with the new ID - * for the same context. - * @param [in] CmStatus - Confirmation status with appropriate reason - * information. - * @return ROK - */ -EXTERN S16 PjUlUdxUeIdChgCfm ARGS((Pst *pst, SuId suId, U32 transId, - UdxUeInfo *ueInfo, CmStatus status)); -EXTERN S16 PjDlUdxUeIdChgCfm ARGS((Pst *pst, SuId suId, U32 transId, - UdxUeInfo *ueInfo, CmStatus status)); - -/** - * @brief Count request primitive - * @details - * RRC uses this primitive to request count value for all DRBs in a UE. - * PDCP sends the UL and DL count values in the confirmation of this request. - * - * @param[in] pst - Pointer to post structure. - * @param[in] spId - Service provider ID. This is the reference number used - * by PDCP to identify its SAP. - * @param[in] countReq - PDCP Count Request Information. - * - * @return ROK - */ -EXTERN S16 PjUlUdxCountReq ARGS((Pst *pst, SpId spId, UdxCountReqInfo *countReq)); -EXTERN S16 PjDlUdxCountReq ARGS((Pst *pst, SpId spId, UdxCountReqInfo *countReq)); - -/** - * @brief Count confirmation primitive - * @details - * PDCP uses this primitive to send the count values for all - * DRBs in a UE to RRC. PDCP sends the RB ID, direction - * and count value(s) ( UL, DL or both based on direction of the RB) - * for each DRB. - * - * @param[in] pst - Pointer to post structure. - * @param[in] suId - The ID of the service user SAP associated with PDCP. - * @param[in] countCfm - PDCP Count Confirmation Info. - * - * @return ROK -*/ -EXTERN S16 PjUlUdxCountCfm ARGS((Pst *pst, SuId suId, UdxCountCfmInfo *countCfm)); -EXTERN S16 PjDlUdxCountCfm ARGS((Pst *pst, SuId suId, UdxCountCfmInfo *countCfm)); - -/** - * @brief SDU Status Request primitive - * @details - * RRC uses this primitive to request the status of the SDUs for DRBs in an UE. - * Its used as a reestablishment request during handover. - * This primitive is used to forward the handover control Information to the target - * eNodeB. - * - * @param[in] pst - Pointer to post structure. - * @param[in] spId - Service provider ID. This is the reference number used - * by PDCP to identify its SAP. - * @param[in] sduStaReq - PDCP SDU Status Request Information. - * - * @return ROK - */ -EXTERN S16 PjUlUdxSduStaReq ARGS((Pst *pst, SpId spId, UdxSduStaReqInfo *staReq)); -EXTERN S16 PjDlUdxSduStaReq ARGS((Pst *pst, SpId spId, UdxSduStaReqInfo *staReq)); - -/** - * @brief SDU Status confirmation primitive - * @details - * PDCP uses this primitive to send the SDU status for the DRBs in - * the requested UE. PDCP sends the RB ID, direction of the RB,status report - * and count(to indicate the first missing SN) in UL and count(to indicate - * the next SN to be assigned) in DL for each requested DRB mapped on to RLC AM. - * - * @param[in] pst - Pointer to post structure. - * @param[in] suId - The ID of the service user SAP associated with PDCP. - * @param[in] sduStaCfm - PDCP SDU Status Confirmation Info. - * - * @return ROK -*/ -EXTERN S16 PjDlUdxSduStaCfm ARGS((Pst *pst, SuId suId, UdxSduStaCfmInfo *staCfm)); -EXTERN S16 PjUlUdxSduStaCfm ARGS((Pst *pst, SuId suId, UdxSduStaCfmInfo *staCfm)); - - -EXTERN S16 PjDlUdxDatResumeCfm ARGS((Pst *pst, SuId suId, UdxDatResumeCfmInfo - *datResumeCfm)); -EXTERN S16 PjUlUdxDatResumeCfm ARGS((Pst *pst, SuId suId, UdxDatResumeCfmInfo - *datResumeCfm)); -EXTERN S16 PjDlUdxDatFwdCfm ARGS ((Pst *pst, SuId suId, UdxDatFwdCfmInfo - *datFwdCfm)); -EXTERN S16 PjUlUdxDatForwardCfm ARGS ((Pst *pst, SuId suId, UdxDatFwdCfmInfo - *datFwdCfm)); - -EXTERN S16 PjDlUdxUlFdbkPktInfo ARGS((Pst *pst, SpId spId, UdxUlFdbkPktInfo *fdbkPktInfo)); -EXTERN S16 PjDlUdxDlFdbkPktInfo ARGS((Pst * pst, SpId spId, UdxDlFdbkPktInfo * fdbkPktInfo)); - -#ifdef LTE_L2_MEAS -EXTERN S16 PjDlUdxL2MeasReq ARGS((Pst *pst, - PjL2MeasReqEvt *measReqEvt)); - -EXTERN S16 PjDlUdxL2MeasSendReq ARGS((Pst *pst, - U8 status)); - -EXTERN S16 PjDlUdxL2MeasStopReq ARGS((Pst *pst, - U8 status)); - -EXTERN S16 PjUlUdxL2MeasReq ARGS((Pst* pst, - PjL2MeasReqEvt *measReqEvt)); - -EXTERN S16 PjUlUdxL2MeasSendReq ARGS((Pst *pst, U8 status)); - -EXTERN S16 PjUlUdxL2MeasStopReq ARGS((Pst* pst, U8 measType)); -#endif -EXTERN S16 PjDlUdxDatResumeReq ARGS((Pst *pst, UdxDatResumeInfo *udxDatResumeInfo)); -EXTERN S16 PjUlUdxDatResumeReq ARGS((Pst *pst, UdxDatResumeInfo *udxDatResumeInfo)); -EXTERN S16 PjDlUdxDatForwardReq ARGS((Pst *pst, UdxDatForwardInfo *udxDatForwardInfo)); -EXTERN S16 PjUlUdxDatForwardReq ARGS((Pst *pst, UdxDatForwardInfo *udxDatForwardInfo)); -EXTERN S16 PjUlUdxDatResumeReqFB ARGS((Pst *pst, UdxDatResumeInfo *udxDatResumeInfo)); -EXTERN S16 PjUlUdxDatForwardReqFB ARGS((Pst *pst, UdxDatForwardInfo *udxDatForwardInfo)); -#ifdef FLAT_BUFFER_OPT -EXTERN S16 PjDlUdxDatResumeReqFB ARGS((Pst *pst,UdxDatResumeInfo *datResumeInfo)); -EXTERN S16 PjDlUdxDatForwardReqFB ARGS((Pst *pst,UdxDatForwardInfo *datFwdInfo)); -#endif -/************************************************************************* - * End of Extern Interface Declarations * - ************************************************************************/ - -/*********************************************************************** - * Start of pack/unpack functions * - * *********************************************************************/ -#if (defined(LCUDX) || defined(LCPJULUDX)) - -EXTERN S16 cmPkPjUdxBndReq ARGS(( -Pst * pst, -SuId suId, -SpId spId -)); -EXTERN S16 cmUnpkPjUdxBndReq ARGS(( -UdxBndReq func, -Pst *pst, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxBndCfm ARGS(( -Pst * pst, -SuId suId, -U8 status -)); -EXTERN S16 cmUnpkPjUdxBndCfm ARGS(( -UdxBndCfm func, -Pst *pst, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxUbndReq ARGS(( -Pst * pst, -SpId spId, -Reason reason -)); -EXTERN S16 cmUnpkPjUdxUbndReq ARGS(( -UdxUbndReq func, -Pst *pst, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxCfgReq ARGS(( -Pst * pst, -SpId spId, -UdxCfgReqInfo * cfgReq -)); -EXTERN S16 cmUnpkPjUdxCfgReq ARGS(( -UdxCfgReq func, -Pst *pst, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxCfgCfm ARGS(( -Pst * pst, -SuId suId, -UdxCfgCfmInfo * cfgCfm -)); -EXTERN S16 cmUnpkPjUdxCfgCfm ARGS(( -UdxCfgCfm func, -Pst *pst, -Buffer *mBuf -)); - -EXTERN S16 cmPkPjUdxUlStaRep ARGS (( -Pst * pst, -SpId spId, -UdxUlStaRepInfo *staRep -)); - -EXTERN S16 cmPkPjUdxDlStaRep ARGS (( -Pst * pst, -SpId spId, -UdxDlStaRepInfo *staRep -)); - -EXTERN S16 cmUnpkPjUdxUlStaRepInfo ARGS (( -Pst *pst, -UdxUlStaRepInfo *param, -Buffer *mBuf -)); - -EXTERN S16 cmPkPjUdxDlFdbkPktInfo ARGS (( -UdxDlFdbkPktInfo *param, -Pst *pst, -Buffer *mBuf -)); - -EXTERN S16 cmUnpkPjUdxUlStaRep ARGS (( -UdxUlStaRep func, -Pst *pst, -Buffer *mBuf -)); - -EXTERN S16 cmUnpkPjUdxDlStaRep ARGS (( -UdxDlStaRep func, -Pst *pst, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjUdxUlFdbkPkt ARGS (( -UdxUlFdbkPkt func, -Pst *pst, -Buffer *mBuf -)); - - -EXTERN S16 cmPkPjUdxUlStaRepInfo ARGS (( -UdxUlStaRepInfo *param, -Pst *pst, -Buffer *mBuf -)); - - -EXTERN S16 cmPkPjUdxDlStaRepInfo ARGS (( -UdxDlStaRepInfo *param, -Pst *pst, -Buffer *mBuf -)); - -EXTERN S16 cmUnpkPjUdxDlStaRepInfo ARGS (( -Pst *pst, -UdxDlStaRepInfo *param, -Buffer *mBuf -)); - -EXTERN S16 cmUnpkPjUdxDlFdbPktInfo ARGS (( -Pst *pst, -UdxDlFdbkPktInfo *param, -Buffer *mBuf -)); - - -EXTERN S16 cmPkPjUdxUlFdbkPkt ARGS(( -Pst * pst, -SpId spId, -UdxUlFdbkPktInfo *fdbkPktInfo -)); - -EXTERN S16 cmPkPjUdxDlFdbkPkt ARGS(( -Pst * pst, -SpId spId, -UdxDlFdbkPktInfo *fdbkPktInfo -)); - -EXTERN S16 cmPkPjUdxUlFdbkPktInfo ARGS(( -UdxUlFdbkPktInfo *fdbkPktInfo, -Pst *pst, -Buffer *mBuf -)); - -EXTERN S16 cmUnpkPjUdxDlFdbkPkt ARGS(( -UdxDlFdbkPkt func, -Pst *pst, -Buffer *mBuf -)); - -EXTERN S16 cmUnpkPjUdxDlFdbkPktInfo ARGS(( -Pst *pst, -UdxDlFdbkPktInfo *fdbkPktInfo, -Buffer *mBuf -)); - -EXTERN S16 cmUnpkPjUdxUlFdbkPktInfo ARGS (( -Pst *pst, -UdxUlFdbkPktInfo *param, -Buffer *mBuf -)); - -EXTERN S16 cmPkPjUdxReEstReq ARGS(( -Pst * pst, -SpId spId, -UdxReEstReqInfo * reEstReq -)); -EXTERN S16 cmUnpkPjUdxReEstReq ARGS(( -UdxReEstReq func, -Pst *pst, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxReEstCfm ARGS(( -Pst * pst, -SuId suId, -UdxReEstCfmInfo * reEstCfm -)); -EXTERN S16 cmUnpkPjUdxReEstCfm ARGS(( -UdxReEstCfm func, -Pst *pst, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxSecCfgReq ARGS(( -Pst * pst, -SpId spId, -UdxSecCfgReqInfo * secCfgReq -)); -EXTERN S16 cmUnpkPjUdxSecCfgReq ARGS(( -UdxSecCfgReq func, -Pst *pst, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxSecCfgCfm ARGS(( -Pst * pst, -SuId suId, -UdxSecCfgCfmInfo * secCfgCfm -)); -EXTERN S16 cmUnpkPjUdxSecCfgCfm ARGS(( -UdxSecCfgCfm func, -Pst *pst, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxUeIdChgReq ARGS(( -Pst * pst, -SpId spId, -U32 transId, -UdxUeInfo * oldUeInfo, -UdxUeInfo * newUeInfo -)); -EXTERN S16 cmUnpkPjUdxUeIdChgReq ARGS(( -UdxUeIdChgReq func, -Pst *pst, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxUeIdChgCfm ARGS(( -Pst * pst, -SuId suId, -U32 transId, -UdxUeInfo * ueInfo, -CmStatus status -)); -EXTERN S16 cmUnpkPjUdxUeIdChgCfm ARGS(( -UdxUeIdChgCfm func, -Pst *pst, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxCountReq ARGS(( -Pst * pst, -SpId spId, -UdxCountReqInfo * countReq -)); -EXTERN S16 cmUnpkPjUdxCountReq ARGS(( -UdxCountReq func, -Pst *pst, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxCountCfm ARGS(( -Pst * pst, -SuId suId, -UdxCountCfmInfo * countCfm -)); -EXTERN S16 cmUnpkPjUdxCountCfm ARGS(( -UdxCountCfm func, -Pst *pst, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxSduStaReq ARGS(( -Pst * pst, -SpId spId, -UdxSduStaReqInfo * staReq -)); -EXTERN S16 cmUnpkPjUdxSduStaReq ARGS(( -UdxSduStaReq func, -Pst *pst, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxSduStaCfm ARGS(( -Pst * pst, -SuId suId, -UdxSduStaCfmInfo * staCfm -)); -EXTERN S16 cmUnpkPjUdxSduStaCfm ARGS(( -UdxSduStaCfm func, -Pst *pst, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxDatResumeCfm ARGS(( -Pst * pst, -SuId suId, -UdxDatResumeCfmInfo * staCfm -)); -EXTERN S16 cmPkPjUdxDatForwardCfm ARGS(( -Pst * pst, -SuId suId, -UdxDatFwdCfmInfo * datFwdCfm -)); -EXTERN S16 cmUnpkPjUdxDatResumeCfm ARGS(( -UdxDatResumeCfm func, -Pst *pst, -Buffer *mBuf -)); - -EXTERN S16 cmUnpkPjUdxDatResumeReq ARGS(( -UdxDatResumeReq func, -Pst *pst, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjUdxDatForwardReq ARGS(( -UdxDatForwardReq func, -Pst *pst, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjUdxDatForwardCfm ARGS(( - UdxDatForwardCfm func, - Pst *pst, - Buffer *mBuf - )); -EXTERN S16 cmPkPjUdxRlcAm ARGS(( -UdxRlcAm *param, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjUdxRlcAm ARGS(( -UdxRlcAm *param, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxRlcUm ARGS(( -UdxRlcUm *param, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjUdxRlcUm ARGS(( -UdxRlcUm *param, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxRlcInfo ARGS(( -UdxRlcInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjUdxRlcInfo ARGS(( -UdxRlcInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxCipherInfo ARGS(( -UdxCipherInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjUdxCipherInfo ARGS(( -UdxCipherInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxIntegInfo ARGS(( -UdxIntegInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjUdxIntegInfo ARGS(( -UdxIntegInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxSecCfg ARGS(( -UdxSecCfg *param, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjUdxSecCfg ARGS(( -UdxSecCfg *param, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxRohcInfo ARGS(( -UdxRohcInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjUdxRohcInfo ARGS(( -UdxRohcInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxHdrCompCfg ARGS(( -UdxHdrCompCfg *param, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjUdxHdrCompCfg ARGS(( -UdxHdrCompCfg *param, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxHoInfo ARGS(( -Pst *pst, -UdxHoInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjUdxHoInfo ARGS(( -Pst *pst, -UdxHoInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxCfgEnt ARGS(( -Pst *pst, -UdxCfgEnt *param, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjUdxCfgEnt ARGS(( -Pst *pst, -UdxCfgEnt *param, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxAddCfgEnt ARGS(( -UdxAddCfgEnt *param, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjUdxAddCfgEnt ARGS(( -UdxAddCfgEnt *param, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxModCfgEnt ARGS(( -Pst *pst, -UdxModCfgEnt *param, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjUdxModCfgEnt ARGS(( -Pst *pst, -UdxModCfgEnt *param, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxCfgReqInfo ARGS(( -Pst *pst, -UdxCfgReqInfo *param, -Buffer *mBuf -)); - -EXTERN S16 cmUnpkPjUdxCfgReqInfo ARGS(( -Pst *pst, -UdxCfgReqInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxCfmEnt ARGS(( -UdxCfmEnt *param, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjUdxCfmEnt ARGS(( -UdxCfmEnt *param, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxCfgCfmInfo ARGS(( -UdxCfgCfmInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjUdxCfgCfmInfo ARGS(( -UdxCfgCfmInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxReEstReqInfo ARGS(( -UdxReEstReqInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjUdxReEstReqInfo ARGS(( -UdxReEstReqInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxReEstCfmInfo ARGS(( -UdxReEstCfmInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjUdxReEstCfmInfo ARGS(( -UdxReEstCfmInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxSecCfgReqInfo ARGS(( -UdxSecCfgReqInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjUdxSecCfgReqInfo ARGS(( -UdxSecCfgReqInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxSecCfgCfmInfo ARGS(( -UdxSecCfgCfmInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjUdxSecCfgCfmInfo ARGS(( -UdxSecCfgCfmInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxUeInfo ARGS(( -UdxUeInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjUdxUeInfo ARGS(( -UdxUeInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxCountReqInfo ARGS(( -UdxCountReqInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjUdxCountReqInfo ARGS(( -UdxCountReqInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxCountInfo ARGS(( -UdxCountInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjUdxCountInfo ARGS(( -UdxCountInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxCountCfmInfo ARGS(( -UdxCountCfmInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjUdxCountCfmInfo ARGS(( -UdxCountCfmInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxSduStaReqInfo ARGS(( -UdxSduStaReqInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjUdxSduStaReqInfo ARGS(( -UdxSduStaReqInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxDlSduStaInfo ARGS(( -UdxDlSduStaInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjUdxDlSduStaInfo ARGS(( -UdxDlSduStaInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxSduStaInfo ARGS(( -Pst *pst, -UdxSduStaInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjUdxSduStaInfo ARGS(( -Pst *pst, -UdxSduStaInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxSduStaCfmInfo ARGS(( -Pst *pst, -UdxSduStaCfmInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjUdxSduStaCfmInfo ARGS(( -Pst *pst, -UdxSduStaCfmInfo *param, -Buffer *mBuf -)); - -EXTERN S16 cmPkPjUdxDatResumeCfmInfo ARGS(( -Pst *pst, -UdxDatResumeCfmInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmPkPjUdxDatForwardCfmInfo ARGS(( -Pst *pst, -UdxDatFwdCfmInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjUdxDatResumeCfmInfo ARGS(( -Pst *pst, -UdxDatResumeCfmInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjUdxDatForwardCfmInfo ARGS(( -Pst *pst, -UdxDatFwdCfmInfo *param, -Buffer *mBuf -)); - -EXTERN S16 cmPkPjUdxDatResumeReq ARGS(( -Pst *pst, -UdxDatResumeInfo *udxDatResumeInfo -)); -EXTERN S16 cmPkPjUdxDatForwardReq ARGS(( -Pst *pst, -UdxDatForwardInfo *udxDatForwardInfo -)); -#ifdef LTE_L2_MEAS -EXTERN S16 cmPkPjUdxL2MeasReq ARGS((Pst *pst, PjL2MeasReqEvt *measReqEvt)); -EXTERN S16 cmPkPjUdxL2MeasSendReq ARGS((Pst *pst, U8 measType)); -EXTERN S16 cmPkPjUdxL2MeasStopReq ARGS((Pst *pst, U8 measType)); -EXTERN S16 cmUnpkPjUdxL2MeasReq ARGS((UdxL2MeasReq func, Pst* pst, Buffer *mBuf)); -EXTERN S16 cmUnpkPjUdxL2MeasSendReq ARGS((UdxL2MeasSendReq func, Pst* pst, Buffer *mBuf)); -EXTERN S16 cmUnpkPjUdxL2MeasStopReq ARGS((UdxL2MeasStopReq func, Pst* pst, Buffer *mBuf)); -#endif -#endif - -/*********************************************************************** - * End of pack/unpack functions * - * *********************************************************************/ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ -#endif /* __UDX_X__ */ - -/********************************************************************30** - - End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_udx_dl.c b/src/5gnrpdcp/pj_udx_dl.c deleted file mode 100755 index c3d64d7e3..000000000 --- a/src/5gnrpdcp/pj_udx_dl.c +++ /dev/null @@ -1,1740 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: LTE-PDCP Layer - Upper Interface Functions - - Type: C file - - Desc: Source code for PDCP Upper Interface Module - This file contains following functions - - --PjDlUdxBndReq - --PjDlUdxUbndReq - --PjDlUdxCfgReq - --PjDlUdxUeIdChgReq - --PjDlUdxReEstReq - --PjDlUdxSecCfgReq - --PjDlUdxSduStaReq - - - File: pj_udx_dl.c - -**********************************************************************/ -static const char* RLOG_MODULE_NAME="PDCP"; -static int RLOG_MODULE_ID=1024; -static int RLOG_FILE_ID=225; -/** @file pj_udx_dl.c -@brief PDCP Upper Interface Module -*/ - - -/* header (.h) include files */ -#include "envopt.h" /* environment options */ -#include "envdep.h" /* environment dependent */ -#include "envind.h" /* environment independent */ - -#include "gen.h" /* general */ -#include "ssi.h" /* system services */ -#include "cm5.h" /* common timer defines */ -#include "cm_tkns.h" /* common tokens defines */ -#include "cm_mblk.h" /* common memory allocation library defines */ -#include "cm_llist.h" /* common link list defines */ -#include "cm_hash.h" /* common hash list defines */ -#include "cm_lte.h" /* common LTE defines */ -#include "lpj.h" /* LPJ define */ -#include "cpj.h" /* RRC layer */ -#include "pju.h" /* PDCP service user */ -#include "pj_env.h" /* RLC environment options */ -#include "pj.h" /* RLC defines */ -#include "pj_dl.h" -#include "pj_udx.h" - -/* extern (.x) include files */ -#include "gen.x" /* general */ -#include "ssi.x" /* system services */ - -#include "cm5.x" /* common timer library */ -#include "cm_tkns.x" /* common tokens */ -#include "cm_mblk.x" /* common memory allocation */ -#include "cm_llist.x" /* common link list */ -#include "cm_hash.x" /* common hash list */ -#include "cm_lte.x" /* common LTE includes */ -#include "cm_lib.x" /* common memory allocation library */ -#include "lpj.x" /* LM(PDCP) */ -#include "cpj.x" /* RRC layer */ -#include "pju.x" /* PDCP service user */ -#include "pj_err.h" -#include "pj.x" -#include "pj_udx.h" /* LIB */ -#include "pj_udx.x" /* LIB */ -#include "pj_dl.x" -#include "pj_udx.x" - -/* kw004.201 Assigned build issue in LTE RLC pj_uim.c */ -#include "pj_lib.x" - - -/***************************************************************************** - * UDX INTERFACE - ****************************************************************************/ -/** - * - * @brief - * - * Handler for binding the PDCP upper layer service user with - * the PDCP layer. - * - * @b Description: - * - * 1. This function is used by PDCP user to request for binding to - * PDCP. @n - * 2. This function is called by the UDX interface to bind - * PDCP's SAP (identified by spId) with the service user's - * SAP (identified by suId). @n - * - * @param[in] pst Post structure - * @param[in] suId Service user SAP ID - * @param[in] spId Service provider ID - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 PjDlUdxBndReq -( -Pst *pst, -SuId suId, -SpId spId -) -#else -PUBLIC S16 PjDlUdxBndReq (pst, suId, spId) -Pst *pst; -SuId suId; -SpId spId; -#endif -{ - PjUdxDlSapCb *udxSap; /* pointer to session SAP */ - S16 ret; /* return value */ - PjCb *tPjCb; - - TRC3(PjDlUdxBndReq) - - ret = ROK; - - tPjCb = PJ_GET_PJCB(pst->dstInst); - - RLOG2(L_DEBUG, "PjDlUdxBndReq(pst, spId(%d), suId(%d))", spId, suId); - - udxSap = (tPjCb->u.dlCb->udxDlSap + spId); - - /* Verify UDX SAP State */ - switch(udxSap->state) - { - /* SAP is configured but not bound */ - case PJ_SAP_CFG: - case PJ_SAP_UBND: - { - /* copy bind configuration parameters in SSAP sap */ - udxSap->suId = suId; - udxSap->pst.dstProcId = pst->srcProcId; - udxSap->pst.dstEnt = pst->srcEnt; - udxSap->pst.dstInst = pst->srcInst; - - /* Update the State */ - udxSap->state = PJ_SAP_BND; - - RLOG1(L_DEBUG, "PjDlUdxBndReq: state (%d)", udxSap->state); - break; - } - - /* SAP is already bound */ - case PJ_SAP_BND: - { - /* - * Sap is already bound check source, destination Entity and - * Proc Id - */ - if (udxSap->pst.dstProcId != pst->srcProcId - || udxSap->pst.dstEnt != pst->srcEnt - || udxSap->pst.dstInst != pst->srcInst - || udxSap->suId != suId) - { - - RLOG1(L_DEBUG, "PjDlUdxBndReq: SAP already bound -- state(%d)", - udxSap->state); - ret = RFAILED; - } - break; - } - - default: - { - RLOG0(L_ERROR, "Invalid UDX DL SAP State in Bind Req"); - ret = RFAILED; - break; - } - } - - if (ret == ROK) - { - PjDlUdxBndCfm(&(udxSap->pst), udxSap->suId, CM_BND_OK); - } - else - { - PjDlUdxBndCfm(&(udxSap->pst), udxSap->suId, CM_BND_NOK); - } - - RETVALUE(ROK); -} /* PjDlUdxBndReq */ - - -/** - * - * @brief - * - * Handler for unbinding the RLC upper layer service user UDX with - * the RLC layer. - * - * @b Description: - * - * 1. This function is used by RLC user to request for unbinding - * with RLC. @n - * 2. This function is called by the UDX interface to - * unbind with RLC. @n - * - * @param[in] pst Post structure - * @param[in] spId Service provider SAP ID - * @param[in] reason Reason for Unbinding - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 PjDlUdxUbndReq -( -Pst *pst, -SpId spId, -Reason reason -) -#else -PUBLIC S16 PjDlUdxUbndReq(pst, spId, reason) -Pst *pst; -SpId spId; -Reason reason; -#endif -{ - PjUdxDlSapCb *udxSap; /* UDX SAP control block */ - PjCb *tPjCb; - - TRC3(PjDlUdxUbndReq) - - tPjCb = PJ_GET_PJCB(pst->dstInst); - RLOG2(L_DEBUG, "PjDlUdxUbndReq(pst, spId(%d), reason(%d))", spId, reason); - - UNUSED(pst); - UNUSED(reason); - - /* disable upper sap (UDX) */ - udxSap = &(tPjCb->u.dlCb->udxDlSap[0]); - - udxSap->state = PJ_SAP_CFG; - - RETVALUE(ROK); -} /* PjDlUdxUbndReq */ - - -/** - * - * @brief - * - * Handler for Sending the PDCP Status Report. - * - * @b Description: - * - * This function is used by PDCP-DL to send PDCP Status Report. - * - * @param[in] pst - Post structure - * @param[in] spId - Serive Provider ID - * @param[in] staRep - PDCP Status Report. - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 PjDlUdxUlStaRep -( -Pst *pst, -SpId spId, -UdxUlStaRepInfo *staRep -) -#else -PUBLIC S16 PjDlUdxUlStaRep(pst, spId, staRep) -Pst *pst; -SpId spId; -UdxUlStaRepInfo *staRep; -#endif -{ - PjCb *tPjCb; - PjDlUeCb *ueCb; - PjDlRbCb *tRbCb; - PjUdxDlSapCb *udxSap; /* UDX SAP Control Block */ - S16 ret; /* Return Value */ - - TRC3(PjDlUdxUlStaRep); - - ret = ROK; - - tPjCb = PJ_GET_PJCB(pst->dstInst); -#ifndef ALIGN_64BIT - RLOG1(L_DEBUG, "PjDlUdxUlStaRep(pst, spId(%d))", spId); -#else - RLOG1(L_DEBUG, "PjDlUdxUlStaRep(pst, spId(%d))", spId); -#endif - - /* Get the udxSap */ - udxSap = (tPjCb->u.dlCb->udxDlSap + spId); - - /* Validate SAP ID under ERRORCLS */ - PJ_VALDATE_SAP(tPjCb,spId, udxSap, ret); - if (ret != ROK) - { - /* pj002.201 Freeing from proper region */ - PJ_FREE_BUF(staRep->sta); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staRep, sizeof(UdxUlStaRepInfo)); - RETVALUE(RFAILED); - } - - /* Fetch Ue Cb */ - ret = pjDbmFetchDlUeCb(tPjCb, staRep->pdcpId.ueId, staRep->pdcpId.cellId, &ueCb); - - /* Ue Cb is not present */ - if( ROK != ret || NULLP == ueCb) - { - RLOG_ARG1(L_ERROR, DBG_CELLID, staRep->pdcpId.cellId,"UeId[%u] not found", - staRep->pdcpId.ueId); - PJ_FREE_BUF(staRep->sta); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staRep, sizeof(UdxUlStaRepInfo)); - RETVALUE(ret); - } - - /* Fetch Rb Cb */ - PJ_DBM_FETCH_DL_RBCB(staRep->pdcpId.rbId, staRep->pdcpId.rbType, ueCb, tRbCb); - - /* Rb Cb is not present or Rb Cb is not configured for PDCP */ - if( NULLP == tRbCb ) - { - RLOG_ARG2(L_WARNING, DBG_UEID,staRep->pdcpId.ueId, "CellId[%u]:RbId[%d] not found", - staRep->pdcpId.cellId, staRep->pdcpId.rbId); - PJ_FREE_BUF(staRep->sta); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staRep, sizeof(UdxUlStaRepInfo)); - RETVALUE(RFAILED); - } - - /* This will go to the RLC as a datReq. So we will get a confirm for it - * we have to make sure that the count does not clash with the existing - * counts. So pick a value that is least expected to clash. */ - if (tRbCb->state != PJ_STATE_NORMAL) - { - if (tRbCb->dlCb.staRep != NULL) - { - PJ_FREE_BUF(tRbCb->dlCb.staRep); - } - tRbCb->dlCb.staRep = staRep->sta; - } - else - { - pjDlmSendDatReq(tPjCb,tRbCb,0xffffffff, staRep->sta); - } - - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staRep, sizeof(UdxUlStaRepInfo)); - - RETVALUE(ROK); -} /* PjDlUdxUlStaRep */ - -/** - * - * @brief - * - * Handler for Handling the PDCP Status Report. - * - * @b Description: - * - * This function is used by PDCP-DL to handle the PDCP Status Report - * from peer PDCP entity. - * - * @param[in] pst - Post structure - * @param[in] spId - Serive Provider ID - * @param[in] staRep - PDCP Status Report. - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 PjDlUdxDlStaRep -( -Pst *pst, -SpId spId, -UdxDlStaRepInfo *staRep -) -#else -PUBLIC S16 PjDlUdxDlStaRep(pst, spId, staRep) -Pst *pst; -SpId spId; -UdxDlStaRepInfo *staRep; -#endif -{ - PjCb *tPjCb; - PjDlUeCb *ueCb; - PjDlRbCb *tRbCb; - PjUdxDlSapCb *udxSap; /* UDX SAP Control Block */ - S16 ret; /* Return Value */ - - TRC3(PjDlUdxDlStaRep); - - ret = ROK; - - tPjCb = PJ_GET_PJCB(pst->dstInst); -#ifndef ALIGN_64BIT - RLOG1(L_DEBUG, "PjDlUdxDlStaRep(pst, spId(%d))", spId); -#else - RLOG1(L_DEBUG, "PjDlUdxDlStaRep(pst, spId(%d))", spId); -#endif - - /* Get the udxSap */ - udxSap = (tPjCb->u.dlCb->udxDlSap + spId); - - /* Validate SAP ID under ERRORCLS */ - PJ_VALDATE_SAP(tPjCb,spId, udxSap, ret); - if (ret != ROK) - { - /* pj002.201 Freeing from proper region */ - PJ_FREE_BUF(staRep->staPdu); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staRep, sizeof(UdxDlStaRepInfo)); - RETVALUE(RFAILED); - } - - /* Fetch Ue Cb */ - ret = pjDbmFetchDlUeCb(tPjCb, staRep->pdcpId.ueId, staRep->pdcpId.cellId, &ueCb); - - /* Ue Cb is not present */ - if( ROK != ret || NULLP == ueCb) - { - RLOG_ARG1(L_ERROR, DBG_CELLID, staRep->pdcpId.cellId,"UeId[%u] not found", - staRep->pdcpId.ueId); - PJ_FREE_BUF(staRep->staPdu); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staRep, sizeof(UdxDlStaRepInfo)); - RETVALUE(ret); - } - - /* Fetch Rb Cb */ - PJ_DBM_FETCH_DL_RBCB(staRep->pdcpId.rbId, staRep->pdcpId.rbType, ueCb, tRbCb); - - /* Rb Cb is not present or Rb Cb is not configured for PDCP */ - if( NULLP == tRbCb ) - { - RLOG_ARG2(L_WARNING, DBG_UEID,staRep->pdcpId.ueId, "CellId[%u]:RbId[%d] not found", - staRep->pdcpId.cellId, staRep->pdcpId.rbId); - PJ_FREE_BUF(staRep->staPdu); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staRep, sizeof(UdxDlStaRepInfo)); - RETVALUE(RFAILED); - } - - ret = pjDlmHndlStaRep(tPjCb, tRbCb, staRep->fmc, staRep->staPdu); - - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staRep, sizeof(UdxDlStaRepInfo)); - - RETVALUE(ret); -} /* PjUdxDlStaRep */ - - - -/** - * - * @brief - * - * Handler for configuring Downlink PDCP entities. - * - * @b Description: - * - * This function is used by RRC to configure(add/delete/modify/ - * reestalish/delete all RB in a UE) one or more PDCP entities. - * - * - UDX_CFG_ADD => pjCfgAddRb - * - UDX_CFG_MODIFY => pjCfgReCfgRb - * - UDX_CFG_DELETE => pjCfgDelRb - * - UDX_CFG_REESTABLISH => pjCfgReEstRb - * - UDX_CFG_DELETE_UE => pjCfgDelUe - * - * @param[in] pst - Post structure - * @param[in] spId - Service Provider ID - * @param[in] cfg - Configuration information for one or more PDCP entities. - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 PjDlUdxCfgReq -( -Pst *pst, -SpId spId, -UdxCfgReqInfo *cfg -) -#else -PUBLIC S16 PjDlUdxCfgReq(pst, spId, cfg) -Pst *pst; -SpId spId; -UdxCfgReqInfo *cfg; -#endif -{ - - UdxCfgCfmInfo *cfgCfm; /* Configuraiton Confirm */ - U8 idx; /* Index */ - PjUdxDlSapCb *udxSap; /* UDX SAP Control Block */ - Bool reEstPres; /* ReEstablishment present */ - Bool startTmr; /* Add present */ - S16 ret; /* Return Value */ - PjDlUeCb *ueCb; /* UE Control Block for storing the - cfg structure in case of ReEstablishment */ - U8 cfmType; - PjCb *tPjCb; - - TRC3(PjDlUdxCfgReq); - - reEstPres = FALSE; - cfmType = 0; - ret = ROK; - cfgCfm = NULLP; - idx = 0; - ueCb = NULLP; - startTmr = 0; - - tPjCb = PJ_GET_PJCB(pst->dstInst); -#ifndef ALIGN_64BIT - RLOG2(L_DEBUG, "PjDlUdxCfgReq(pst, spId(%d), TransId(%ld))", - spId, cfg->transId); -#else - RLOG2(L_DEBUG, "PjDlUdxCfgReq(pst, spId(%d), TransId(%d))", - spId, cfg->transId); -#endif - - /* Get the udxsap */ - udxSap = (tPjCb->u.dlCb->udxDlSap + spId); - - /* Validate SAP ID under ERRORCLS */ - PJ_VALDATE_SAP(tPjCb,spId, udxSap, ret); - if (ret != ROK) - { - /* pj002.201 Freeing from proper region */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, cfg, sizeof(UdxCfgReqInfo)); - RETVALUE(RFAILED); - } - - ret = ROK; - PJ_ALLOC_BUF_SHRABL(udxSap->pst, cfgCfm, - sizeof (UdxCfgCfmInfo), ret); - /* Allocate memory and memset to 0 for cfmInfo */ - if(ret != ROK) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - /* pj002.201 Freeing from proper region */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, cfg, sizeof(UdxCfgReqInfo)); - RETVALUE(RFAILED); - } - - /* Fetch UeCb */ - pjDbmFetchDlUeCb(tPjCb, cfg->ueId, cfg->cellId, &ueCb); - /* KW_FIX : UDX_MAX_CFG , UDX_MAX_CFM have the same value , hence checking for only one */ - /* For every entity configuration process by cfgType */ - for (idx = 0; idx < cfg->numEnt && idx < UDX_MAX_CFG; idx++) - { - UdxCfmEnt *entCfgCfm; - UdxCfgEnt *entCfg; - - entCfg = (UdxCfgEnt *)&(cfg->cfgEnt[idx]); - entCfgCfm = (UdxCfmEnt *)&(cfgCfm->cfmEnt[idx]); - - if (NULL != ueCb) - { - /* Fill the detault values here */ - PJ_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType, UDX_CFG_CFM_OK,\ - UDX_CFG_REAS_NONE); - } - else - { - RLOG_ARG1(L_WARNING, DBG_CELLID,cfg->cellId,"UeId[%u] not found", - cfg->ueId); - PJ_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType, CPJ_CFG_CFM_NOK,\ - CPJ_CFG_REAS_UE_UNKWN); - - RLOG_ARG1(L_WARNING,DBG_UEID,cfg->ueId, - "Dl RB Config Req- UE CB is not found for cellid (%d)",cfg->cellId); - if (entCfg->cfgType != UDX_CFG_ADD) - { - /* all other requests require ueCb mandatorily */ - continue; - } - } - - switch (entCfg->cfgType) - { - case UDX_CFG_ADD: - { - if (entCfg->m.addCfg.rlcInfo.dir & PJ_DIR_DL) - { - U8 isHo; - - isHo = cfg->isHo; - /* Add a new RB entity configuration */ - if (pjCfgAddDlRb(tPjCb,cfg->ueId, cfg->cellId, isHo, - entCfg, &ueCb,entCfgCfm) != ROK) - { - RLOG_ARG3(L_ERROR,DBG_UEID,cfg->ueId, "Dl Cfg RB Add Req" - " for cellId(%d), rbId(%d) Failed: reason (%d)", - cfg->cellId, cfg->cfgEnt[idx].rbId, entCfgCfm->reason); - } - /* Only In case of DRB only we need to set this flag */ -#ifdef PJ_CMP_ASYNC - else if(PJ_DRB == entCfg->rbType) - { - if(entCfg->m.addCfg.hdrCompCfg.hdrCompUsed) - { - cfmType |= PJ_CFG_ASYNC_CFM; - startTmr = TRUE; - } - } -#endif /* PJ_CMP_ASYNC */ - } - break; - } - - case UDX_CFG_MODIFY: - { - /* Re-configure the existing RB entity configuration */ - if ((entCfg->m.modCfg.bitFlag & 0x02) || - (entCfg->m.modCfg.hdrCompCfg.hdrCompUsed) || - (entCfg->m.modCfg.hoInfo.isHoPres & CPJ_HO_DL)) - { - if (pjCfgReCfgDlRb(tPjCb,ueCb, entCfg, entCfgCfm) != ROK) - { - RLOG_ARG3(L_ERROR,DBG_UEID,cfg->ueId,"Dl RB Modify Req" - "for cellId(%d),rbId(%d) not done as RbCb not found: reason(%d)", - cfg->cellId,cfg->cfgEnt[idx].rbId, entCfgCfm->reason); - } -#ifdef PJ_CMP_ASYNC - else if(PJ_DRB == entCfg->rbType) - { - if(entCfg->m.modCfg.hdrCompCfg.hdrCompUsed) - { - cfmType |= PJ_CFG_ASYNC_CFM; - startTmr = TRUE; - } - } -#endif /* PJ_CMP_ASYNC */ - } - break; - } - - case UDX_CFG_DELETE: - { - /* Delete the existing RB entity configuration */ - if (pjCfgDelDlRb(tPjCb, ueCb, entCfg, entCfgCfm) != ROK) - { - RLOG_ARG3(L_WARNING,DBG_UEID,cfg->ueId, "Dl RB Delete Req for" - "for cellId(%d), rbId(%d) not done as RbCb not found: reason (%d)", - cfg->cellId, cfg->cfgEnt[idx].rbId, entCfgCfm->reason); - } - break; - } - - case UDX_CFG_REESTABLISH: - { - if (pjCfgReEstDlRb(tPjCb, ueCb, entCfg, entCfgCfm) != ROK) - { - RLOG_ARG3(L_ERROR,DBG_UEID,cfg->ueId, "Dl RB Re-establih Req" - "for cellId(%d), rbId(%d) Failed: reason (%d)", - cfg->cellId, cfg->cfgEnt[idx].rbId, entCfgCfm->reason); - } - else - { - cfmType |= PJ_CFG_REEST_ASYNC_CFM; - reEstPres= TRUE; - } - - break; - } - - case UDX_CFG_DELETE_UE: - { - /* Delete all RB entity configuration under UE */ - if (pjCfgDelDlUe(tPjCb, ueCb,entCfg, entCfgCfm) != ROK) - { - - RLOG_ARG3(L_ERROR,DBG_UEID,cfg->ueId, "Dl UE Delete Req for" - "cellId(%d), rbId(%d) Failed: reason (%d)", - cfg->cellId, cfg->cfgEnt[idx].rbId, entCfgCfm->reason); - } -#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)) - else - { - /* Wait for any messages in the Demand q to be processed */ - cfmType |= PJ_CFG_UEDEL_ASYNC_CFM; - startTmr = TRUE; - } -#endif /* (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)) */ - break; - } - - default: - { - PJ_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType, UDX_CFG_CFM_NOK,\ - UDX_CFG_REAS_INVALID_CFG); - - RLOG_ARG3(L_ERROR,DBG_UEID,cfg->ueId, "Dl Cfg Req with Invalid" - "config type,cellId(%d),cfgType(%d),rbId(%d) ", - cfg->cellId, entCfg->cfgType, cfg->cfgEnt[idx].rbId); - } - } - } - - /* Assign number of entity configuraitons and suId */ - cfgCfm->transId = cfg->transId; - cfgCfm->ueId = cfg->ueId; - cfgCfm->cellId = cfg->cellId; - cfgCfm->numEnt = cfg->numEnt; - - if (cfmType != 0) - { - if (ueCb != NULLP) - { - if(TRUE == reEstPres ) - { -#ifdef PJ_ASYNC_CFM - pjUtlDlSaveCfmInfo(tPjCb, ueCb, cfmType, startTmr, ENTPJ, (PTR)cfgCfm, (PTR)cfg); -#endif - pjUtlDlUpdUpSecKeys(tPjCb, ueCb); -#ifdef PJ_ASYNC_CFM - PJ_PST_FREE(udxSap->pst.region, udxSap->pst.pool, cfgCfm, sizeof(UdxCfgCfmInfo)); -#else - PjDlUdxCfgCfm(&(udxSap->pst), udxSap->suId, cfgCfm); -#endif - - } - else - { - pjUtlDlSaveCfmInfo(tPjCb, ueCb, cfmType, startTmr, ENTPJ, (PTR)cfgCfm, (PTR)cfg); - PJ_PST_FREE(udxSap->pst.region, udxSap->pst.pool, cfgCfm, sizeof(UdxCfgCfmInfo)); - } - /* Free the cfg */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, cfg, sizeof(UdxCfgReqInfo)); - } - else - { - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, cfg, sizeof(UdxCfgReqInfo)); - PjDlUdxCfgCfm(&(udxSap->pst), udxSap->suId, cfgCfm); - } - } - else - { - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, cfg, sizeof(UdxCfgReqInfo)); - PjDlUdxCfgCfm(&(udxSap->pst), udxSap->suId, cfgCfm); - } - - RETVALUE(ret); -} /* PjDlUdxCfgReq */ - -/** - *@details This primitive is used by RRC to change the UeId for the existing UE - context. - - * @param pst - Point to the pst structure - * @param spId - The ID of the service provider SAP in the PDCP layer - * @param transId - Transaction ID. This field uniquily identifies - * transaction between RRC and PDCP. - * @param ueInfo - Old UE Id Info for which the change request has come - * @param newUeInfo - New UE Id Info for existing UE context - * @return ROK -**/ -#ifdef ANSI -PUBLIC S16 PjDlUdxUeIdChgReq -( -Pst *pst, -SpId spId, -U32 transId, -UdxUeInfo *ueInfo, -UdxUeInfo *newUeInfo -) -#else -PUBLIC S16 PjDlUdxUeIdChgReq(pst,spId,transId,ueInfo,newUeInfo) -Pst *pst; -SpId spId; -U32 transId; -UdxUeInfo *ueInfo; -UdxUeInfo *newUeInfo; -#endif -{ - S16 ret; /* Return Value */ - CmStatus status; /* Status of the request */ - PjUdxDlSapCb *udxSap; /* UDX SAP Control Block */ - UdxUeInfo *tUeInfo; /* Temporary UE info */ - PjCb *tPjCb; - - TRC3(PjDlUdxUeIdChgReq) - - tPjCb = PJ_GET_PJCB(pst->dstInst); - -#ifndef ALIGN_64BIT - RLOG2(L_DEBUG, "PjDlUdxUeIdChgReq(pst, spId(%d), transId(%ld))", spId, transId); -#else - RLOG2(L_DEBUG, "PjDlUdxUeIdChgReq(pst, spId(%d), transId(%d))", spId, transId); -#endif - - ret = ROK; - tUeInfo = NULLP; - udxSap = &(tPjCb->u.dlCb->udxDlSap[0]); - status.reason = UDX_CFG_REAS_NONE; - status.status = UDX_CFG_CFM_OK; - - /* Validate SAP ID under ERRORCLS */ - PJ_VALDATE_SAP(tPjCb,spId, udxSap, ret); - if (ret != ROK) - { - /* kw002.201 Freeing from proper region */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, ueInfo, sizeof(UdxUeInfo)); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, newUeInfo, sizeof(UdxUeInfo)); - RETVALUE(RFAILED); - } - - if (pjCfgDlUeIdChng(tPjCb, ueInfo, - newUeInfo, &status) != ROK) - { - RLOG_ARG4(L_ERROR,DBG_UEID,ueInfo->ueId,"Dl UeId Change Req old-ueId(%d)," - "new-ueId(%d), cellId(%d) Failed: reason (%d)", - ueInfo->ueId, newUeInfo->ueId, newUeInfo->cellId, status.reason); - } - - /* Allocate memory for UdxUeInfo */ - /* Memory leak fix ccpu00135359 */ - PJ_ALLOC_BUF_SHRABL(udxSap->pst, tUeInfo, - sizeof (UdxUeInfo), ret); - if( ret != ROK) - { - /* Free memory for UdxUeInfo */ - /* kw002.201 Freeing from proper region */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, ueInfo, sizeof(UdxUeInfo)); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, newUeInfo, sizeof(UdxUeInfo)); - - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } - - tUeInfo->ueId = ueInfo->ueId; - tUeInfo->cellId = ueInfo->cellId; - - /* Free memory for CkwUeInfo */ - /* kw002.201 Freeing from proper region */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, ueInfo, sizeof(UdxUeInfo)); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, newUeInfo, sizeof(UdxUeInfo)); - - PjDlUdxUeIdChgCfm(&(udxSap->pst), udxSap->suId, transId, tUeInfo, status); - - RETVALUE(ROK); -} /* PjDlUdxUeIdChgReq */ - - -/** - *@details - * 1. RRC uses this primitive to configure PDCP security parameters. - * Integrity protection and/or Ciphering are configured by RRC based on the - * selSecAct flag. @n - * 2. Integirty Protection/Ciphering are configured per UE and applicable - * to all pdcp entities in that UE. Both Integrity protection and ciphering are - * re-configured during re-establishment. @n - * - * @param pst - Point to the pst structure - * @param spId - The ID of the service provider SAP in the PDCP layer - * @param secCfg - Security Configuration Info per UE. - * - * @return - * -# ROK - * -# RFAILED - */ -#ifdef ANSI -PUBLIC S16 PjDlUdxSecCfgReq -( -Pst *pst, -SpId spId, -UdxSecCfgReqInfo *secCfg -) -#else -PUBLIC S16 PjDlUdxSecCfgReq(pst,spId,secCfg) -Pst *pst; -SpId spId; -UdxSecCfgReqInfo *secCfg; -#endif -{ - S16 ret; /* Return Value */ - UdxSecCfgCfmInfo *cfgCfm; /* Security Cfg Confirm structure */ - PjUdxDlSapCb *udxSap; /* UDX SAP Control Block */ -#ifdef PJ_SEC_ASYNC - PjDlUeCb *ueCb; /* UE Control Block */ -#endif - PjCb *tPjCb; - - TRC2(PjDlUdxSecCfgReq) - tPjCb = PJ_GET_PJCB(pst->dstInst); - -#ifndef ALIGN_64BIT - RLOG2(L_DEBUG, "PjDlUdxSecCfgReq(pst, spId(%d), TransId(%ld))", spId, - secCfg->transId); -#else - RLOG2(L_DEBUG, "PjDlUdxSecCfgReq(pst, spId(%d), TransId(%d))", spId, - secCfg->transId); -#endif - - ret = ROK; - cfgCfm = NULLP; - udxSap = NULLP; - - udxSap = &(tPjCb->u.dlCb->udxDlSap[0]); - -#ifdef PJ_SEC_ASYNC - ueCb = NULLP; -#endif - PJ_ALLOC_BUF_SHRABL(udxSap->pst, cfgCfm, - sizeof (UdxSecCfgCfmInfo), ret); - if(ret != ROK) - { - /* Free memory for CfgReqInfo */ - /* kw002.201 Freeing from proper region */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, secCfg, sizeof(UdxSecCfgReqInfo)); - - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } - - if ( pjCfgPrcSecDlCfg(tPjCb,secCfg, - cfgCfm) != ROK ) - { - RLOG_ARG2(L_ERROR,DBG_UEID,secCfg->ueId, " Dl Sec Cfg Req for cellId(%d)" - " Failed: reason (%d)", secCfg->cellId, cfgCfm->reason); - } - -#ifdef PJ_SEC_ASYNC - ret = pjDbmFetchDlUeCb(tPjCb,secCfg->ueId, secCfg->cellId, &ueCb); - if ( ueCb != NULLP ) - { - pjUtlDlSaveCfmInfo(tPjCb, ueCb, PJ_SEC_ASYNC_CFM, TRUE, ENTPJ, (PTR)cfgCfm, NULLP); - PJ_FREE(tPjCb, cfgCfm, sizeof(UdxSecCfgCfmInfo)); - } - else - { - RLOG_ARG1(L_ERROR, DBG_CELLID, secCfg->cellId,"UeId[%u] not found", - secCfg->ueId); - PjDlUdxSecCfgCfm(&(udxSap->pst), udxSap->suId, cfgCfm); - } -#else - PjDlUdxSecCfgCfm(&(udxSap->pst), udxSap->suId, cfgCfm); -#endif - - /* Configuration information needs to be freed from proper region */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, secCfg, sizeof(UdxSecCfgReqInfo)); - - RETVALUE(ret); -} - - - -/** - * @details - * 1. RRC uses this primitive to re-establish the PDCP entity. @n - * 2. This primitive is initiation of re-establishment procedure. @n - * 3. This prmitive and corresponding confirmation shall be followed by - * PjDlUdxCfgReq procedure for entire re-establishment procedure to complete. - * - * @param[in] pst - Pointer to post structure. - * @param[in] spId - Service provider ID. This is the reference number used by - * PDCP to identify its SAP. - * @param[in] reEstReq - PDCP re-establishment request structure. - * - */ -#ifdef ANSI -PUBLIC S16 PjDlUdxReEstReq -( -Pst *pst, -SpId spId, -UdxReEstReqInfo *reEstReq -) -#else -PUBLIC S16 PjDlUdxReEstReq(pst,spId,reEstReq) -Pst *pst; -SpId spId; -UdxReEstReqInfo *reEstReq; -#endif -{ - S16 ret; /* Return Value */ - UdxReEstCfmInfo *reEstCfm; /* Re-Establish Confirm */ - PjUdxDlSapCb *udxSap; /* UDX SAP Control Block */ - PjCb *tPjCb; - - TRC2(PjDlUdxReEstReq); - - tPjCb = PJ_GET_PJCB(pst->dstInst); - RLOG1(L_DEBUG, "PjDlUdxReEstReq(pst, spId(%d))", spId); - - ret = ROK; - udxSap = &(tPjCb->u.dlCb->udxDlSap[0]); - - /* Validate SAP ID under ERRORCLS */ - PJ_VALDATE_SAP(tPjCb,spId, udxSap, ret); - if (ret != ROK) - { - /* pj002.201 Freeing from proper region */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, reEstReq, sizeof(UdxReEstReqInfo)); - RETVALUE(RFAILED); - } - PJ_ALLOC_BUF_SHRABL(udxSap->pst , reEstCfm, - sizeof (UdxReEstCfmInfo), ret); - if(ret != ROK) - { - /* Free memory for CfgReqInfo */ - /* kw002.201 Freeing from proper region */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, reEstReq, sizeof(UdxReEstReqInfo)); - - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } - - if ( pjCfgDlReEstReq(tPjCb,(UdxReEstReqInfo *)reEstReq, - (UdxReEstCfmInfo *)reEstCfm) != ROK ) - { - RLOG_ARG2(L_ERROR,DBG_UEID,reEstReq->pdcpId.ueId, "Dl Re-Est Req Cfg for" - " cellId(%d) Failed: reason (%u)", - reEstReq->pdcpId.cellId, reEstCfm->status); - - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, reEstReq, sizeof(UdxReEstReqInfo)); - PjDlUdxReEstCfm(&(udxSap->pst), udxSap->suId, reEstCfm); - RETVALUE (ROK); - } - - /* kw002.201 Freeing from proper region */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, reEstReq, sizeof(UdxReEstReqInfo)); - -#ifdef PJ_ASYNC_CFM - /* If Async is enabled then we need to wait for confirmation */ - RETVALUE(ROK); -#endif - PjDlUdxReEstCfm(&(udxSap->pst), udxSap->suId, reEstCfm); - RETVALUE(ROK); -} - - -/** - * @details - * 1. RRC uses this primitive to request count value for all DRBs in a UE. @n - * 2. PDCP sends the UL and DL count values in the confirmation of this request. - * - * @param[in] pst - Pointer to post structure. - * @param[in] spId - Service provider ID. This is the reference number used - * by PDCP to identify its SAP. - * @param[in] countReq - PDCP Count Request Information. - * - * @return ROK - */ -#ifdef ANSI -PUBLIC S16 PjDlUdxCountReq -( -Pst *pst, -SpId spId, -UdxCountReqInfo *countReq -) -#else -PUBLIC S16 PjDlUdxCountReq(pst,spId,countReq) -Pst *pst; -SpId spId; -UdxCountReqInfo *countReq; -#endif -{ - - S16 ret; /* Return Value */ - UdxCountCfmInfo *countCfm; /* Count Confirm structure */ - PjUdxDlSapCb *udxSap; /* UDX SAP Control Block */ - PjCb *tPjCb; - - TRC2(PjDlUdxCountReq); - - tPjCb = PJ_GET_PJCB(pst->dstInst); - RLOG1(L_DEBUG, "PjDlUdxCountReq(pst, spId(%d))", spId); - - ret = ROK; - countCfm = NULLP; - udxSap = &(tPjCb->u.dlCb->udxDlSap[0]); - PJ_ALLOC_BUF_SHRABL(udxSap->pst, countCfm, - sizeof (UdxCountCfmInfo), ret); - if( ret != ROK) - { - /* Free memory for CfgReqInfo */ - /* kw002.201 Freeing from proper region */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, countReq, sizeof(UdxCountReqInfo)); - - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } - if ( pjCfgPrcDlCount(tPjCb, countReq, - countCfm) != ROK ) - { - RLOG_ARG2(L_ERROR,DBG_UEID,countReq->ueId, "Dl Count Req for cellId(%d)" - " Failed: reason (%d)", - countReq->cellId, countCfm->reason); - - } - - /* Freeing from proper region */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, countReq, sizeof(UdxCountReqInfo)); - - PjDlUdxCountCfm(&(udxSap->pst), udxSap->suId,countCfm); - - RETVALUE(ROK); - -} - -/** - * - * @details - * 1. RRC uses this primitive to request the status of the SDUs for DRBs in an UE. @n - * 2. Its used as a reestablishment request during handover. @n - * 3. This primitive is used to forward the handover control Information to the target - * eNodeB. - * - * @param[in] pst - Pointer to post structure. - * @param[in] spId - Service provider ID. This is the reference number used - * by PDCP to identify its SAP. - * @param[in] sduStaReq - PDCP SDU Status Request Information. - * - * @return ROK - */ -#ifdef ANSI -PUBLIC S16 PjDlUdxSduStaReq -( -Pst *pst, -SpId spId, -UdxSduStaReqInfo *staReq -) -#else -PUBLIC S16 PjDlUdxSduStaReq(pst,spId,staReq) -Pst *pst; -SpId spId; -UdxSduStaReqInfo *staReq; -#endif -{ - - S16 ret; /* Return Value */ - PjUdxDlSapCb *udxSap; /* UDX SAP Control Block */ - PjCb *tPjCb; - - TRC2(PjDlUdxSduStaReq); - - ret = ROK; - udxSap = NULLP; - - tPjCb = PJ_GET_PJCB(pst->dstInst); - udxSap = &(tPjCb->u.dlCb->udxDlSap[0]); - - RLOG1(L_DEBUG, "PjDlUdxSduStaReq(pst, spId(%d))", spId); - - - /* Validate SAP ID under ERRORCLS */ - PJ_VALDATE_SAP(tPjCb,spId, udxSap, ret); - if (ret != ROK) - { - /* kw002.201 Freeing from proper region */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staReq, sizeof(UdxSduStaReqInfo)); - RETVALUE(RFAILED); - } - - if (pjCfgPrcDlSduSta(tPjCb,(UdxSduStaReqInfo *) staReq) != ROK ) - { - RLOG_ARG1(L_ERROR,DBG_UEID,staReq->ueId, - "Dl Sdu Sta Req for cellId(%d) Failed",staReq->cellId); - ret = RFAILED; - - } - /* kw002.201 Freeing from proper region */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, staReq, sizeof(UdxSduStaReqInfo)); - - RETVALUE(ret); -} - -/** - * - * @brief - * - * Handler for Sending the Feed back Packet Info to DL-RLC. - * - * @b Description: - * - * This function is used by PDCP-DL to send Feedback Packet Info to DL-RLC. - * - * @param[in] pst - Post structure - * @param[in] spId - Serive Provider ID - * @param[in] fdbkPktInfo - Feedback Packet Info. - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 PjDlUdxUlFdbkPktInfo -( -Pst *pst, -SpId spId, -UdxUlFdbkPktInfo *fdbkPktInfo -) -#else -PUBLIC S16 PjDlUdxUlFdbkPktInfo(pst, spId, fdbkPktInfo) -Pst *pst; -SpId spId; -UdxUlFdbkPktInfo *fdbkPktInfo; -#endif -{ - PjCb *tPjCb; - PjDlUeCb *ueCb; - PjDlRbCb *tRbCb; - PjUdxDlSapCb *udxSap; /* UDX SAP Control Block */ - S16 ret; /* Return Value */ - U32 count; - Data hdr = 0; - Buffer *rohcFdbPdu = NULLP; - - TRC3(PjDlUdxUlFdbkPktInfo); - - ret = ROK; - tPjCb = PJ_GET_PJCB(pst->dstInst); -#ifndef ALIGN_64BIT - RLOG1(L_DEBUG, "PjDlUdxUlFdbkPktInfo(pst, spId(%d))", spId); -#else - RLOG1(L_DEBUG, "PjDlUdxUlFdbkPktInfo(pst, spId(%d))", spId); -#endif - - /* Get the udxSap */ - udxSap = (tPjCb->u.dlCb->udxDlSap + spId); - - /* Validate SAP ID under ERRORCLS */ - PJ_VALDATE_SAP(tPjCb,spId, udxSap, ret); - if (ret != ROK) - { - /* pj002.201 Freeing from proper region */ - PJ_FREE_BUF(fdbkPktInfo->fbPkt); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, fdbkPktInfo, sizeof(UdxDlFdbkPktInfo)); - RETVALUE(RFAILED); - } - - /* Fetch Ue Cb */ - ret = pjDbmFetchDlUeCb(tPjCb, fdbkPktInfo->pdcpId.ueId, fdbkPktInfo->pdcpId.cellId, &ueCb); - - /* Ue Cb is not present */ - if( ROK != ret || NULLP == ueCb) - { - RLOG_ARG1(L_ERROR, DBG_CELLID, fdbkPktInfo->pdcpId.cellId,"UeId[%u] not found", - fdbkPktInfo->pdcpId.ueId); - PJ_FREE_BUF(fdbkPktInfo->fbPkt); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, fdbkPktInfo, sizeof(UdxDlFdbkPktInfo)); - RETVALUE(ret); - } - - /* Fetch Rb Cb */ - PJ_DBM_FETCH_DL_RBCB(fdbkPktInfo->pdcpId.rbId, fdbkPktInfo->pdcpId.rbType, ueCb, tRbCb); - - /* Rb Cb is not present or Rb Cb is not configured for PDCP */ - if( NULLP == tRbCb ) - { - RLOG_ARG2(L_WARNING, DBG_UEID,fdbkPktInfo->pdcpId.ueId, "CellId[%u]:RbId[%d] not found", - fdbkPktInfo->pdcpId.cellId, fdbkPktInfo->pdcpId.rbId); - PJ_FREE_BUF(fdbkPktInfo->fbPkt); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, fdbkPktInfo, sizeof(UdxDlFdbkPktInfo)); - RETVALUE(RFAILED); - } - - hdr |= PJ_ROHC_FEEDBACK_HDR; - rohcFdbPdu = fdbkPktInfo->fbPkt; - - ret = SAddPreMsg((Data) hdr, rohcFdbPdu); - if ( ret != ROK ) - { - RLOG0(L_ERROR, "SAddPreMsg failed for ROHC Feedbck pdu"); - PJ_FREE_BUF(rohcFdbPdu); - RETVALUE(RFAILED); - } - - if(tRbCb->mode == PJ_DRB_UM) - { - count = tRbCb->dlCb.nxtToSub - 1; - } - else - { - count = tRbCb->dlCb.cfmExp - 1; - } - - pjDlmSendDatReq(tPjCb, tRbCb, count, rohcFdbPdu); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, fdbkPktInfo, sizeof(UdxDlFdbkPktInfo)); - - RETVALUE(ROK); -} /* PjUlUdxUlFdbkPktInfo*/ - -/** - * - * @brief - * - * Handler for Sending the Feed back Packet Info to Compression entity. - * - * @b Description: - * - * This function is used by PDCP-DL to send Feedback Packet Info to Compression entity. - * - * @param[in] pst - Post structure - * @param[in] spId - Serive Provider ID - * @param[in] fdbkPktInfo - Feedback Packet Info. - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 PjDlUdxDlFdbkPktInfo -( -Pst *pst, -SpId spId, -UdxDlFdbkPktInfo *fdbkPktInfo -) -#else -PUBLIC S16 PjDlUdxDlFdbkPktInfo(pst, spId, fdbkPktInfo) -Pst *pst; -SpId spId; -UdxDlFdbkPktInfo *fdbkPktInfo; -#endif -{ - PjCb *tPjCb; - PjDlUeCb *ueCb; - PjDlRbCb *tRbCb; - PjUdxDlSapCb *udxSap; /* UDX SAP Control Block */ - S16 ret; /* Return Value */ - -#ifdef PJ_CMP_ASYNC - PjLibTrans libTrans; /* Transaction Id for compression */ -#endif /* PJ_SEC_ASYNC */ - - TRC3(PjDlUdxDlFdbkPktInfo); - - ret = ROK; - tPjCb = PJ_GET_PJCB(pst->dstInst); -#ifndef ALIGN_64BIT - RLOG1(L_DEBUG, "PjDlUdxDlFdbkPktInfo(pst, spId(%d))", spId); -#else - RLOG1(L_DEBUG, "PjDlUdxDlFdbkPktInfo(pst, spId(%d))", spId); -#endif - - /* Get the udxSap */ - udxSap = (tPjCb->u.dlCb->udxDlSap + spId); - - /* Validate SAP ID under ERRORCLS */ - PJ_VALDATE_SAP(tPjCb,spId, udxSap, ret); - if (ret != ROK) - { - /* pj002.201 Freeing from proper region */ - PJ_FREE_BUF(fdbkPktInfo->fbPkt); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, fdbkPktInfo, sizeof(UdxDlFdbkPktInfo)); - RETVALUE(RFAILED); - } - - /* Fetch Ue Cb */ - ret = pjDbmFetchDlUeCb(tPjCb, fdbkPktInfo->pdcpId.ueId, fdbkPktInfo->pdcpId.cellId, &ueCb); - - /* Ue Cb is not present */ - if( ROK != ret || NULLP == ueCb) - { - RLOG_ARG1(L_ERROR, DBG_CELLID, fdbkPktInfo->pdcpId.cellId,"UeId[%u] not found", - fdbkPktInfo->pdcpId.ueId); - PJ_FREE_BUF(fdbkPktInfo->fbPkt); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, fdbkPktInfo, sizeof(UdxDlFdbkPktInfo)); - RETVALUE(ret); - } - - /* Fetch Rb Cb */ - PJ_DBM_FETCH_DL_RBCB(fdbkPktInfo->pdcpId.rbId, fdbkPktInfo->pdcpId.rbType, ueCb, tRbCb); - - /* Rb Cb is not present or Rb Cb is not configured for PDCP */ - if( NULLP == tRbCb ) - { - RLOG_ARG2(L_WARNING, DBG_UEID,fdbkPktInfo->pdcpId.ueId, "CellId[%u]:RbId[%d] not found", - fdbkPktInfo->pdcpId.cellId, fdbkPktInfo->pdcpId.rbId); - PJ_FREE_BUF(fdbkPktInfo->fbPkt); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, fdbkPktInfo, sizeof(UdxDlFdbkPktInfo)); - RETVALUE(RFAILED); - } - -#ifdef PJ_CMP_ASYNC - /* Assign transId and cxtId */ - libTrans.count = tRbCb->dlCb.nxtToSub; - /* pj005.201 ccpu00114955 corrected the RB ID calculation */ - libTrans.rbId = tRbCb->rbId - 1; - libTrans.rbType = tRbCb->rbType; - libTrans.ueCb = (PTR)tRbCb->ueCb; - - PjLibObdCmpFbReq(&(tPjCb->pjGenCfg.obdPst.cmpPst), tRbCb->cmpCxtId, libTrans, - fdbkPktInfo->fbPkt); -#else - pjLibCmpFbReq(tRbCb->cmpCxtId, fdbkPktInfo->fbPkt); -#endif - - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, fdbkPktInfo, sizeof(UdxDlFdbkPktInfo)); - - RETVALUE(ROK); -} /* PjDlUdxDlFdbkPktInfo*/ - - -#ifdef LTE_L2_MEAS -/** -*/ -#ifdef ANSI -PUBLIC S16 PjDlUdxL2MeasReq -( -Pst *pst, -PjL2MeasReqEvt *measReqEvt -) -#else -PUBLIC S16 PjDlUdxL2MeasReq (pst, measReqEvt) -Pst *pst; -PjL2MeasReqEvt *measReqEvt; -#endif -{ - U16 cntr; - U8 measType; - - PjCb *tPjCb=NULLP; - TRC3(PjDlUdxL2MeasReq); - - tPjCb = PJ_GET_PJCB(pst->dstInst); - /* Initialize measCfmEvt */ - - - measType = measReqEvt->measReq.measType; - - RLOG1(L_DEBUG, "L2_MEAS START Measurement type is %u", - measType); - - for(cntr = 0; cntr < LPJ_MAX_QCI; cntr++) - { - tPjCb->u.dlCb->pjL2Cb.measOn[cntr] |= measType; - } -#ifdef SS_LOCKLESS_MEMORY - PJ_FREE_SHRABL_BUF(tPjCb,measReqEvt, sizeof(PjL2MeasReqEvt)); -#else - PJ_FREE(tPjCb,measReqEvt, sizeof(PjL2MeasReqEvt)); -#endif - /*stoping Task*/ - - RETVALUE(ROK); -} /* KwDlUdxMeasReq */ - -/** -@brief -This function processes L2 Measurement stop request received from the layer manager. -After receving this request, RLC stops L2 Measurement - * @param[in] pst post structure - * @param[in] measType meas Type - * @return S16 - * -# Success : ROK - * -# Failure : RFAILED -*/ - -#ifdef ANSI -PUBLIC S16 PjDlUdxL2MeasStopReq -( -Pst *pst, -U8 measType -) -#else -PUBLIC S16 PjDlUdxL2MeasStopReq (pst, measType) -Pst *pst; -U8 measType; -#endif -{ - S16 ret = ROK; - PjL2MeasEvtCb *measEvtCb = NULLP; - PjL2MeasCb *measCb = NULLP; - U16 cntr; - U8 status = ROK; - PjL2MeasCfmEvt measCfmEvt; - PjCb *tPjCb=NULLP; - TRC3(PjDlUdxMeasStopReq); - tPjCb = PJ_GET_PJCB(pst->dstInst); - RLOG0(L_DEBUG, "L2_MEAS Received stopReq\n"); - cmMemset((U8*)&measCfmEvt, 0, sizeof(PjL2MeasCfmEvt)); - for(cntr = 0; cntr < LPJ_MAX_L2MEAS; cntr++) - { - measEvtCb = &(tPjCb->u.dlCb->pjL2Cb.pjL2EvtCb[cntr]); - if(measEvtCb->measCb.measType & measType) - { - measCb = &measEvtCb->measCb; - pjUtlResetDlL2MeasCntr(tPjCb, measCb, measType); - - } - } - status = LCM_PRIM_OK; - PjMiLpjL2MeasStopCfm(&tPjCb->pjGenCfg.lmPst, measType,status); - RETVALUE(ret); -} -/** -@brief -This function processes L2 Measurement Send request received from the layer manager. -After receving this request, RLC sends L2 Measurement - * @param[in] pst post structure - * @param[in] measType meas Type - * @return S16 - * -# Success : ROK - * -# Failure : RFAILED -*/ - -#ifdef ANSI -PUBLIC S16 PjDlUdxL2MeasSendReq -( -Pst *pst, -U8 measType -) -#else -PUBLIC S16 PjDlUdxL2MeasSendReq (pst, measType) -Pst *pst; -U8 measType; -#endif -{ - S16 ret = ROK; - PjL2MeasEvtCb *measEvtCb = NULLP; - U16 cntr; - PjCb *tPjCb=NULLP; - TRC3(PjDlUdxMeasSendReq); - - tPjCb = PJ_GET_PJCB(pst->dstInst); - RLOG1(L_DEBUG, "L2_MEAS: Sending Meas for meastype %u", - measType); - - for(cntr = 0; cntr < LPJ_MAX_L2MEAS; cntr++) - { - measEvtCb = &(tPjCb->u.dlCb->pjL2Cb.pjL2EvtCb[cntr]); - if(measEvtCb->measCb.measType & measType) - { - pjUtlSndDlL2MeasCfm(tPjCb, measEvtCb); - - } - } - - RETVALUE(ret); -} -#endif /* LTE_L2_MEAS */ -/** -@brief -This function processes Data Resume request received from the Application. - * @param[in] pst post structure - * @param[in] measType meas Type - * @return S16 - * -# Success : ROK - * -# Failure : RFAILED -*/ - -#ifdef ANSI -PUBLIC S16 PjDlUdxDatResumeReq -( -Pst *pst, -UdxDatResumeInfo *datResumeInfo -) -#else -PUBLIC S16 PjDlUdxDatResumeReq (pst, *datResumeInfo) -Pst *pst; -UdxDatResumeInfo *datResumeInfo; -#endif -{ - U8 rbCnt; - PjDlUeCb *ueCb; - PjDlRbCb *pjRbCb; - PjCb *tPjCb; - S16 ret; - UdxDatResumeCfmInfo *cfmInfo; - PjUdxDlSapCb *udxSap; - - tPjCb = PJ_GET_PJCB(pst->dstInst); - - ret = ROK; - /* Perform processing for filling up cfm structures */ - /* Memory leak fix ccpu00135359 */ - udxSap = &(tPjCb->u.dlCb->udxDlSap[0]); - PJ_ALLOC_BUF_SHRABL(udxSap->pst, cfmInfo, - sizeof (UdxDatResumeCfmInfo), ret); - if(ret != ROK) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datResumeInfo, sizeof(UdxDatResumeInfo)); - RETVALUE(RFAILED); - } - - cfmInfo->ueId = datResumeInfo->ueId; - cfmInfo->cellId = datResumeInfo->cellId; - cfmInfo->transId = datResumeInfo->transId; - cfmInfo->status = CPJ_CFG_CFM_OK; - cfmInfo->reason = CPJ_CFG_REAS_NONE; - - ret = pjDbmFetchDlUeCb(tPjCb, datResumeInfo->ueId, - datResumeInfo->cellId, &ueCb); - - /* Ue Cb is not present */ - if( ROK != ret || NULLP == ueCb) - { - RLOG_ARG1(L_ERROR, DBG_CELLID, datResumeInfo->cellId,"UeId[%u] not found", - datResumeInfo->ueId); - cfmInfo->status = CPJ_CFG_CFM_NOK; - cfmInfo->reason = CPJ_CFG_REAS_UE_UNKWN; - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datResumeInfo, sizeof(UdxDatResumeInfo)); - /* Send Failure SduStaCfm */ - PjDlUdxDatResumeCfm(&tPjCb->u.dlCb->udxDlSap[0].pst, - tPjCb->u.dlCb->udxDlSap[0].suId, cfmInfo); - RETVALUE(ret); - } - - for(rbCnt = 0; rbCnt < PJ_MAX_DRB_PER_UE; rbCnt ++) - { - /* Check of rbCb available */ - if( (pjRbCb = ueCb->drbCb[rbCnt]) == NULLP) - { - continue; - } - - pjDlmRbDataResume(tPjCb,pjRbCb); - pjRbCb->state = PJ_STATE_NORMAL; - } - - ueCb->libInfo.state = PJ_STATE_NORMAL; - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datResumeInfo, sizeof(UdxDatResumeInfo)); - - PjDlUdxDatResumeCfm(&tPjCb->u.dlCb->udxDlSap[0].pst, - tPjCb->u.dlCb->udxDlSap[0].suId, cfmInfo); - RETVALUE(ROK); -} - - - -/** -@brief -This function processes Start Data Forwarding request received from UL - * @param[in] pst post structure - * @param[in] measType meas Type - * @return S16 - * -# Success : ROK - * -# Failure : RFAILED -*/ - -#ifdef ANSI -PUBLIC S16 PjDlUdxDatForwardReq -( -Pst *pst, -UdxDatForwardInfo *datFwdInfo -) -#else -PUBLIC S16 PjDlUdxDatForwardReq (pst, *datFwdInfo) -Pst *pst; -UdxDatForwardInfo *datFwdInfo; -#endif -{ - S16 ret; - U8 rbCnt; - PjDlUeCb *ueCb =NULLP; - PjDlRbCb *pjRbCb = NULLP; - PjCb *tPjCb; - UdxDatFwdCfmInfo *cfmInfo = NULLP; - PjUdxDlSapCb *udxSap; - - tPjCb = PJ_GET_PJCB(pst->dstInst); - - ret = ROK; - udxSap = &(tPjCb->u.dlCb->udxDlSap[0]); - /* Allocate MEM and fill the DatFwd Cfm Struct */ - PJ_ALLOC_BUF_SHRABL(udxSap->pst, cfmInfo, - sizeof (UdxDatFwdCfmInfo), ret); - if( ret != ROK) - { - cfmInfo = NULLP; -#if (ERRCLASS & ERRCLS_DEBUG) - RLOG0(L_FATAL, "Memory Allocation failed."); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datFwdInfo, sizeof(UdxDatForwardInfo)); - RETVALUE(RFAILED); -#endif - } - - cfmInfo->ueId = datFwdInfo->ueId; - cfmInfo->cellId = datFwdInfo->cellId; - cfmInfo->status = CPJ_CFG_CFM_OK; - - ret = pjDbmFetchDlUeCb(tPjCb,datFwdInfo->ueId, - datFwdInfo->cellId, &ueCb); - - /* Ue Cb is not present */ - if( ROK != ret || NULLP == ueCb) - { - RLOG_ARG1(L_ERROR, DBG_CELLID, datFwdInfo->cellId,"UeId[%u] not found", - datFwdInfo->ueId); - cfmInfo->status = CPJ_CFG_CFM_NOK; - cfmInfo->reason = CPJ_CFG_REAS_UE_UNKWN; - /* Send Cfm to UL so that it can fwd the UL Pkts */ - PjDlUdxDatFwdCfm(&tPjCb->u.dlCb->udxDlSap[0].pst, - tPjCb->u.dlCb->udxDlSap[0].suId, cfmInfo); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datFwdInfo, sizeof(UdxDatForwardInfo)); - RETVALUE(ret); - } - - for(rbCnt = 0; rbCnt < PJ_MAX_DRB_PER_UE; rbCnt ++) - { - /* Check of rbCb available */ - if( (pjRbCb = ueCb->drbCb[rbCnt]) == NULLP) - { - continue; - } - - if(pjRbCb->mode == PJ_DRB_AM) - { - pjDlmStartDataFrwdPerRb(tPjCb,pjRbCb); - } - } - /* Send Data Fwd Cfm to the UL PDCP Module - * The UL PDCP Module will forward UL Pkts - * after receiving this cfm Info */ - PjDlUdxDatFwdCfm(&tPjCb->u.dlCb->udxDlSap[0].pst, - tPjCb->u.dlCb->udxDlSap[0].suId, cfmInfo); - - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datFwdInfo, sizeof(UdxDatForwardInfo)); - RETVALUE(ROK); - -} - - - -/********************************************************************30** - End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_udx_ptdl.c b/src/5gnrpdcp/pj_udx_ptdl.c deleted file mode 100755 index fffbe6c82..000000000 --- a/src/5gnrpdcp/pj_udx_ptdl.c +++ /dev/null @@ -1,752 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: LTE-PDCP Layer - Upper Interface - - Type: C file - - Desc: C source code for the upper interface of LTE-PDCP - - File: pj_udx_ptdl.c - -*********************************************************************21*/ - -/** @file pj_udx_ptdl.c -@brief PDCP Upper Interface -*/ - - -/* header (.h) include files */ -#include "envopt.h" /* environment options */ -#include "envdep.h" /* environment dependent */ -#include "envind.h" /* environment independent */ - -#include "gen.h" /* general */ -#include "ssi.h" /* system services */ -#include "cm5.h" /* common timer defines */ -#include "cm_tkns.h" /* common tokens defines */ -#include "cm_mblk.h" /* common memory allocation library defines */ -#include "cm_llist.h" /* common link list defines */ -#include "cm_hash.h" /* common hash list defines */ -#include "cm_lte.h" /* common LTE defines */ -#include "cpj.h" /* UDX defines */ -#include "pju.h" /* PJU defines */ -#include "lpj.h" - -#include "pj_err.h" -#include "pj_env.h" /* RLC environment options */ -#include "pj_udx.h" - -/* extern (.x) include files */ -#include "gen.x" /* general */ -#include "ssi.x" /* system services */ - -#include "cm5.x" /* common timer library */ -#include "cm_tkns.x" /* common tokens */ -#include "cm_mblk.x" /* common memory allocation */ -#include "cm_llist.x" /* common link list */ -#include "cm_hash.x" /* common hash list */ -#include "cm_lte.x" /* common LTE includes */ -#include "cm_lib.x" /* common memory allocation library */ -#include "cpj.x" /* UDX defines */ -#include "pju.x" /* PJU defines */ -#include "lpj.x" /* LPJ defines */ -#include "pj.h" -#include "pj.x" -#include "pj_udx.x" - - -#if !(defined(LCPJULUDX) && defined(PJ)) -#define PTPJUDX -#endif - - -#ifdef __cplusplus -EXTERN "C" { -#endif /* __cplusplus */ - - -/********************************************************************* - * Forward Declartion for UDX Porting Functions - ********************************************************************/ -#ifdef PTPJUDX - -EXTERN S16 PtDlUdxBndCfm ARGS((Pst * pst, SuId suId, U8 status)); - -EXTERN S16 PtDlUdxCfgCfm ARGS((Pst * pst, SuId suId, UdxCfgCfmInfo * cfgCfm)); - -EXTERN S16 PtDlUdxReEstCfm ARGS((Pst * pst, SuId suId, UdxReEstCfmInfo * reEstCfm)); - -EXTERN S16 PtDlUdxSecCfgCfm ARGS((Pst * pst, SuId suId, UdxSecCfgCfmInfo * secCfgCfm)); - -EXTERN S16 PtDlUdxUeIdChgCfm ARGS((Pst * pst, SuId suId, U32 transId, UdxUeInfo * ueInfo, CmStatus status)); - -EXTERN S16 PtDlUdxCountCfm ARGS((Pst * pst, SuId suId, UdxCountCfmInfo * countCfm)); - -EXTERN S16 PtDlUdxSduStaCfm ARGS((Pst * pst, SuId suId, UdxSduStaCfmInfo * staCfm)); - -EXTERN S16 PtDlUdxDatResumeCfm ARGS((Pst * pst, SuId suId, UdxDatResumeCfmInfo * datResume)); - -EXTERN S16 PtDlUdxDatForwardCfm ARGS((Pst * pst, SuId suId, UdxDatFwdCfmInfo * datFwdCfm)); -#endif /* PTPJUDX */ - - -/********************************************************************* - * Forward Declartion for PJU Porting Functions - ********************************************************************/ - - -/********************************************************************* - * Primitives for UDX interface - ********************************************************************/ -PRIVATE CONSTANT UdxBndCfm PjDlUdxBndCfmMt[] = -{ -#ifdef LCPJULUDX - cmPkPjUdxBndCfm, -#else - PtDlUdxBndCfm, -#endif -#ifdef LWLCPJULUDX - cmPkPjUdxBndCfm, -#else - PtDlUdxBndCfm, -#endif -#ifdef PJ - PjUlUdxBndCfm, -#else - PtDlUdxBndCfm, -#endif -}; - - -PRIVATE CONSTANT UdxCfgCfm PjDlUdxCfgCfmMt[] = -{ -#ifdef LCPJULUDX - cmPkPjUdxCfgCfm, -#else - PtDlUdxCfgCfm, -#endif -#ifdef LWLCPJULUDX - cmPkPjUdxCfgCfm, -#else - PtDlUdxCfgCfm, -#endif -#ifdef PJ - PjUlUdxCfgCfm, -#else - PtDlUdxCfgCfm, -#endif -}; - - -PRIVATE CONSTANT UdxReEstCfm PjDlUdxReEstCfmMt[] = -{ -#ifdef LCPJULUDX - cmPkPjUdxReEstCfm, -#else - PtDlUdxReEstCfm, -#endif -#ifdef LWLCPJULUDX - cmPkPjUdxReEstCfm, -#else - PtDlUdxReEstCfm, -#endif -#ifdef PJ - PjUlUdxReEstCfm, -#else - PtDlUdxReEstCfm, -#endif -}; - - -PRIVATE CONSTANT UdxSecCfgCfm PjDlUdxSecCfgCfmMt[] = -{ -#ifdef LCPJULUDX - cmPkPjUdxSecCfgCfm, -#else - PtDlUdxSecCfgCfm, -#endif -#ifdef LWLCPJULUDX - cmPkPjUdxSecCfgCfm, -#else - PtDlUdxSecCfgCfm, -#endif -#ifdef PJ - PjUlUdxSecCfgCfm, -#else - PtDlUdxSecCfgCfm, -#endif -}; - - -PRIVATE CONSTANT UdxUeIdChgCfm PjDlUdxUeIdChgCfmMt[] = -{ -#ifdef LCPJULUDX - cmPkPjUdxUeIdChgCfm, -#else - PtDlUdxUeIdChgCfm, -#endif -#ifdef LWLCPJULUDX - cmPkPjUdxUeIdChgCfm, -#else - PtDlUdxUeIdChgCfm, -#endif -#ifdef PJ - PjUlUdxUeIdChgCfm, -#else - PtDlUdxUeIdChgCfm, -#endif -}; - - -PRIVATE CONSTANT UdxCountCfm PjDlUdxCountCfmMt[] = -{ -#ifdef LCPJULUDX - cmPkPjUdxCountCfm, -#else - PtDlUdxCountCfm, -#endif -#ifdef LWLCPJULUDX - cmPkPjUdxCountCfm, -#else - PtDlUdxCountCfm, -#endif -#ifdef PJ - PjUlUdxCountCfm, -#else - PtDlUdxCountCfm, -#endif -}; - - -PRIVATE CONSTANT UdxSduStaCfm PjDlUdxSduStaCfmMt[] = -{ -#ifdef LCPJULUDX - cmPkPjUdxSduStaCfm, -#else - PtDlUdxSduStaCfm, -#endif -#ifdef LWLCPJULUDX - cmPkPjUdxSduStaCfm, -#else - PtDlUdxSduStaCfm, -#endif -#ifdef PJ - PjUlUdxSduStaCfm, -#else - PtDlUdxSduStaCfm, -#endif -}; - -PRIVATE CONSTANT UdxDatResumeCfm PjDlUdxDatResumeCfmMt[] = -{ -#ifdef LCPJULUDX - cmPkPjUdxDatResumeCfm, -#else - PtDlUdxDatResumeCfm, -#endif -#ifdef LWLCPJULUDX - cmPkPjUdxDatResumeCfm, -#else - PtDlUdxDatResumeCfm, -#endif -#ifdef PJ - PjUlUdxDatResumeCfm, -#else - PtDlUdxDatResumeCfm, -#endif -}; - -PRIVATE CONSTANT UdxDatForwardCfm PjDlUdxDatFwdCfmMt[] = -{ -#ifdef LCPJULUDX - cmPkPjUdxDatForwardCfm, -#else - PtDlUdxDatForwardCfm, -#endif -#ifdef LWLCPJULUDX - cmPkPjUdxDatForwardCfm, -#else - PtDlUdxDatForwardCfm, -#endif -#ifdef PJ - PjUlUdxDatForwardCfm, -#else - PtDlUdxDatForwardCfm, -#endif -}; - - -/**************************************************************************** - * UDX Interface Mt functions - ***************************************************************************/ -#ifdef PJ -#ifdef ANSI -PUBLIC S16 PjDlUdxBndCfm -( -Pst * pst, -SuId suId, -U8 status -) -#else -PUBLIC S16 PjDlUdxBndCfm(pst, suId, status) -Pst * pst; -SuId suId; -U8 status; -#endif -{ - - TRC3(PjDlUdxBndCfm) - - (*PjDlUdxBndCfmMt[pst->selector])(pst, suId, status); - - RETVALUE(ROK); -} - -#ifdef ANSI -PUBLIC S16 PjDlUdxCfgCfm -( -Pst * pst, -SuId suId, -UdxCfgCfmInfo * cfgCfm -) -#else -PUBLIC S16 PjDlUdxCfgCfm(pst, suId, cfgCfm) -Pst * pst; -SuId suId; -UdxCfgCfmInfo * cfgCfm; -#endif -{ - - TRC3(PjDlUdxCfgCfm) - - (*PjDlUdxCfgCfmMt[pst->selector])(pst, suId, cfgCfm); - - RETVALUE(ROK); -} - -#ifdef ANSI -PUBLIC S16 PjDlUdxReEstCfm -( -Pst * pst, -SuId suId, -UdxReEstCfmInfo * reEstCfm -) -#else -PUBLIC S16 PjDlUdxReEstCfm(pst, suId, reEstCfm) -Pst * pst; -SuId suId; -UdxReEstCfmInfo * reEstCfm; -#endif -{ - - TRC3(PjDlUdxReEstCfm) - - (*PjDlUdxReEstCfmMt[pst->selector])(pst, suId, reEstCfm); - - RETVALUE(ROK); -} - -#ifdef ANSI -PUBLIC S16 PjDlUdxSecCfgCfm -( -Pst * pst, -SuId suId, -UdxSecCfgCfmInfo * secCfgCfm -) -#else -PUBLIC S16 PjDlUdxSecCfgCfm(pst, suId, secCfgCfm) -Pst * pst; -SuId suId; -UdxSecCfgCfmInfo * secCfgCfm; -#endif -{ - - TRC3(PjDlUdxSecCfgCfm) - - (*PjDlUdxSecCfgCfmMt[pst->selector])(pst, suId, secCfgCfm); - - RETVALUE(ROK); -} - -#ifdef ANSI -PUBLIC S16 PjDlUdxUeIdChgCfm -( -Pst * pst, -SuId suId, -U32 transId, -UdxUeInfo * ueInfo, -CmStatus status -) -#else -PUBLIC S16 PjDlUdxUeIdChgCfm(pst, suId, transId, ueInfo, status) -Pst * pst; -SuId suId; -U32 transId; -UdxUeInfo * ueInfo; -CmStatus status; -#endif -{ - - TRC3(PjDlUdxUeIdChgCfm) - - (*PjDlUdxUeIdChgCfmMt[pst->selector])(pst, suId, transId, ueInfo, status); - - RETVALUE(ROK); -} - -#ifdef ANSI -PUBLIC S16 PjDlUdxCountCfm -( -Pst * pst, -SuId suId, -UdxCountCfmInfo * countCfm -) -#else -PUBLIC S16 PjDlUdxCountCfm(pst, suId, countCfm) -Pst * pst; -SuId suId; -UdxCountCfmInfo * countCfm; -#endif -{ - - TRC3(PjDlUdxCountCfm) - - (*PjDlUdxCountCfmMt[pst->selector])(pst, suId, countCfm); - - RETVALUE(ROK); -} - -#ifdef ANSI -PUBLIC S16 PjDlUdxSduStaCfm -( -Pst * pst, -SuId suId, -UdxSduStaCfmInfo * staCfm -) -#else -PUBLIC S16 PjDlUdxSduStaCfm(pst, suId, staCfm) -Pst * pst; -SuId suId; -UdxSduStaCfmInfo * staCfm; -#endif -{ - - TRC3(PjDlUdxSduStaCfm) - - (*PjDlUdxSduStaCfmMt[pst->selector])(pst, suId, staCfm); - - RETVALUE(ROK); -} - -#ifdef ANSI -PUBLIC S16 PjDlUdxDatResumeCfm -( -Pst * pst, -SuId suId, -UdxDatResumeCfmInfo * staCfm -) -#else -PUBLIC S16 PjDlUdxDatResumeCfm(pst, suId, staCfm) -Pst * pst; -SuId suId; -UdxDatResumeCfmInfo * staCfm; -#endif -{ - - TRC3(PjDlUdxDatResumeCfm) - - (*PjDlUdxDatResumeCfmMt[pst->selector])(pst, suId, staCfm); - - RETVALUE(ROK); -} - -#ifdef ANSI -PUBLIC S16 PjDlUdxDatFwdCfm -( -Pst * pst, -SuId suId, -UdxDatFwdCfmInfo * datFwdCfm -) -#else -PUBLIC S16 PjDlUdxDatFwdCfm(pst, suId, datFwdCfm) -Pst * pst; -SuId suId; -UdxDatFwdCfmInfo * datFwdCfm; -#endif -{ - - TRC3(PjDlUdxDatFwdCfm) - - (*PjDlUdxDatFwdCfmMt[pst->selector])(pst, suId, datFwdCfm); - - RETVALUE(ROK); -} -#endif - -/************************************************************************* - * UDX Porting Functions - ************************************************************************/ -#ifdef PTPJUDX - -#ifdef ANSI -PUBLIC S16 PtDlUdxBndCfm -( -Pst * pst, -SuId suId, -U8 status -) -#else -PUBLIC S16 PtDlUdxBndCfm(pst, suId, status) -Pst * pst; -SuId suId; -U8 status; -#endif -{ - - TRC3(PtDlUdxBndCfm) - - UNUSED(pst); - UNUSED(suId); - UNUSED(status); - - RETVALUE(ROK); - -} - - -#ifdef ANSI -PUBLIC S16 PtDlUdxCfgCfm -( -Pst * pst, -SuId suId, -UdxCfgCfmInfo * cfgCfm -) -#else -PUBLIC S16 PtDlUdxCfgCfm(pst, suId, cfgCfm) -Pst * pst; -SuId suId; -UdxCfgCfmInfo * cfgCfm; -#endif -{ - - TRC3(PtDlUdxCfgCfm) - - UNUSED(pst); - UNUSED(suId); - UNUSED(cfgCfm); - - RETVALUE(ROK); - -} - - -#ifdef ANSI -PUBLIC S16 PtDlUdxReEstCfm -( -Pst * pst, -SuId suId, -UdxReEstCfmInfo * reEstCfm -) -#else -PUBLIC S16 PtDlUdxReEstCfm(pst, suId, reEstCfm) -Pst * pst; -SuId suId; -UdxReEstCfmInfo *reEstCfm; -#endif -{ - - TRC3(PtDlUdxReEstCfm) - - UNUSED(pst); - UNUSED(suId); - UNUSED(reEstCfm); - - RETVALUE(ROK); - -} - - -#ifdef ANSI -PUBLIC S16 PtDlUdxSecCfgCfm -( -Pst * pst, -SuId suId, -UdxSecCfgCfmInfo * secCfgCfm -) -#else -PUBLIC S16 PtDlUdxSecCfgCfm(pst, suId, secCfgCfm) -Pst * pst; -SuId suId; -UdxSecCfgCfmInfo * secCfgCfm; -#endif -{ - - TRC3(PtDlUdxSecCfgCfm) - - UNUSED(pst); - UNUSED(suId); - UNUSED(secCfgCfm); - - RETVALUE(ROK); - -} - - -#ifdef ANSI -PUBLIC S16 PtDlUdxUeIdChgCfm -( -Pst * pst, -SuId suId, -U32 transId, -UdxUeInfo * ueInfo, -CmStatus status -) -#else -PUBLIC S16 PtDlUdxUeIdChgCfm(pst, suId, transId, ueInfo, status) -Pst * pst; -SuId suId; -U32 transId; -UdxUeInfo * ueInfo; -CmStatus status; -#endif -{ - - TRC3(PtDlUdxUeIdChgCfm) - - UNUSED(pst); - UNUSED(suId); - UNUSED(transId); - UNUSED(ueInfo); - UNUSED(status); - - RETVALUE(ROK); - -} - - -#ifdef ANSI -PUBLIC S16 PtDlUdxCountCfm -( -Pst * pst, -SuId suId, -UdxCountCfmInfo * countCfm -) -#else -PUBLIC S16 PtDlUdxCountCfm(pst, suId, countCfm) -Pst * pst; -SuId suId; -UdxCountCfmInfo * countCfm; -#endif -{ - - TRC3(PtDlUdxCountCfm) - - UNUSED(pst); - UNUSED(suId); - UNUSED(countCfm); - - RETVALUE(ROK); - -} - - -#ifdef ANSI -PUBLIC S16 PtDlUdxSduStaCfm -( -Pst * pst, -SuId suId, -UdxSduStaCfmInfo * staCfm -) -#else -PUBLIC S16 PtDlUdxSduStaCfm(pst, suId, staCfm) -Pst * pst; -SuId suId; -UdxSduStaCfmInfo * staCfm; -#endif -{ - - TRC3(PtDlUdxSduStaCfm) - - UNUSED(pst); - UNUSED(suId); - UNUSED(staCfm); - - RETVALUE(ROK); - -} - -#ifdef ANSI -PUBLIC S16 PtDlUdxDatResumeCfm -( -Pst * pst, -SuId suId, -UdxDatResumeCfmInfo * staCfm -) -#else -PUBLIC S16 PtDlUdxDatResumeCfm(pst, suId, staCfm) -Pst * pst; -SuId suId; -UdxDatResumeCfmInfo * staCfm; -#endif -{ - - TRC3(PtDlUdxDatResumeCfm) - - UNUSED(pst); - UNUSED(suId); - UNUSED(staCfm); - - RETVALUE(ROK); - -} - -#ifdef ANSI -PUBLIC S16 PtDlUdxDatForwardCfm -( - Pst *pst, - SuId suId, - UdxDatFwdCfmInfo *datFwdCfm - ) -#else -PUBLIC S16 PtDlUdxDatForwardCfm(pst, suId, datFwdCfm) - Pst *pst; - SuId suId; - UdxDatFwdCfmInfo *datFwdCfm; -#endif -{ - - TRC3(PtDlUdxDatForwardCfm) - - UNUSED(pst); - UNUSED(suId); - UNUSED(datFwdCfm); - - RETVALUE(ROK); -} -#endif /*--ifdef PTPJUDX--*/ - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ -/********************************************************************30** - End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_udx_ptul.c b/src/5gnrpdcp/pj_udx_ptul.c deleted file mode 100755 index e46c9211c..000000000 --- a/src/5gnrpdcp/pj_udx_ptul.c +++ /dev/null @@ -1,1632 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: LTE-PDCP Layer - Upper Interface - - Type: C file - - Desc: C source code for the upper interface of LTE-PDCP - - File: pj_udx_ptul.c - -*********************************************************************21*/ - -/** @file pj_udx_ptul.c -@brief PDCP Upper Interface -*/ - - -/* header (.h) include files */ -#include "envopt.h" /* environment options */ -#include "envdep.h" /* environment dependent */ -#include "envind.h" /* environment independent */ - -#include "gen.h" /* general */ -#include "ssi.h" /* system services */ -#include "cm5.h" /* common timer defines */ -#include "cm_tkns.h" /* common tokens defines */ -#include "cm_mblk.h" /* common memory allocation library defines */ -#include "cm_llist.h" /* common link list defines */ -#include "cm_hash.h" /* common hash list defines */ -#include "cm_lte.h" /* common LTE defines */ -#include "cpj.h" /* UDX defines */ -#include "pju.h" /* PJU defines */ -#include "lpj.h" -#include "pj_udx.h" - -#include "pj_err.h" -#include "pj_env.h" /* RLC environment options */ - -/* extern (.x) include files */ -#include "gen.x" /* general */ -#include "ssi.x" /* system services */ - -#include "cm5.x" /* common timer library */ -#include "cm_tkns.x" /* common tokens */ -#include "cm_mblk.x" /* common memory allocation */ -#include "cm_llist.x" /* common link list */ -#include "cm_hash.x" /* common hash list */ -#include "cm_lte.x" /* common LTE includes */ -#include "cm_lib.x" /* common memory allocation library */ -#include "cpj.x" /* UDX defines */ -#include "pju.x" /* PJU defines */ -#include "lpj.x" /* LPJ defines */ -#include "pj.h" -#include "pj.x" -#include "pj_udx.x" -#include "pj_ul.x" - - -#if !(defined(LCPJULUDX) && defined(PJ) && defined(LWLCPJULUDX)) -#define PTPJULUDX -#endif - -#ifdef __cplusplus -EXTERN "C" { -#endif /* __cplusplus */ - -#ifdef PTPJULUDX -PRIVATE S16 PtUlUdxBndReq ARGS((Pst *post, SuId suId, SpId spId)); -PRIVATE S16 PtUlUdxUbndReq ARGS((Pst *post, SpId spId, Reason reason)); -PRIVATE S16 PtUlUdxCfgReq ARGS((Pst *post, SpId spId, UdxCfgReqInfo *pdCfgReq)); -PRIVATE S16 PtUlUdxUeIdChgReq ARGS((Pst *post, SpId spId,U32 transId, - UdxUeInfo *oldUeInfo, - UdxUeInfo *newUeInfo)); - -PRIVATE S16 PtUlUdxSecCfgReq ARGS((Pst *post, SpId spId, - UdxSecCfgReqInfo *pdcpSecCfgReq)); -PRIVATE S16 PtUlUdxCountReq ARGS((Pst *post, SpId spId, - UdxCountReqInfo *pdcpCountReq)); -PRIVATE S16 PtUlUdxReEstReq ARGS(( Pst *post, SpId spId, - UdxReEstReqInfo *restbInfo)); -PRIVATE S16 PtUlUdxSduStaReq ARGS(( Pst *post, SpId spId, - UdxSduStaReqInfo *statReqInfo)); - -PRIVATE S16 PtUlUdxUlStaRep ARGS (( - Pst *post, /* Post structure */ - SpId spId, /* Service provider ID */ - UdxUlStaRepInfo *pdStaRep /* PDCP UL ot PDCP DL Reestablishment trigger */ - )); -PRIVATE S16 PtUlUdxDlStaRep ARGS (( - Pst *post, /* Post structure */ - SpId spId, /* Service provider ID */ - UdxDlStaRepInfo *pdStaRep /* Status report from PDCP UL to PDCP DL */ - )); - -PRIVATE S16 PtUlUdxUlFdbkPktInfo ARGS (( - Pst *post, /* Post structure */ - SpId spId, /* Service provider ID */ - UdxUlFdbkPktInfo *fdbkPktInfo /* feedback Packet Info */ - )); - -PRIVATE S16 PtUlUdxDlFdbkPktInfo ARGS (( - Pst *post, /* Post structure */ - SpId spId, /* Service provider ID */ - UdxDlFdbkPktInfo *fdbkPktInfo /* feedback Packet Info */ - )); -#ifdef LTE_L2_MEAS -PRIVATE S16 PtUlUdxL2MeasReq ARGS (( - Pst *pst, - PjL2MeasReqEvt *measReqEvt - )); -PRIVATE S16 PtUlUdxL2MeasSendReq ARGS(( - Pst *pst, - U8 status - )); -PRIVATE S16 PtUlUdxL2MeasStopReq ARGS(( - Pst *pst, - U8 status - )); -#endif -PRIVATE S16 PtUlUdxDatResumeReq ARGS(( - Pst *pst, - UdxDatResumeInfo *udxDatResumeInfo - )); -PRIVATE S16 PtUlUdxDatForwardReq ARGS(( - Pst *pst, - UdxDatForwardInfo *udxDatForwardInfo - )); -#endif /* PTPJULUDX */ - - -/************************************************************************** - * UDX Interface Matrices - *************************************************************************/ - -/* UDX Interface Bind Request primitive */ -PRIVATE CONSTANT UdxBndReq PjUlUdxBndReqMt [PJ_MAX_UDX] = -{ -#ifdef LCPJULUDX - cmPkPjUdxBndReq, /* 0 - loosely coupled */ -#else /* LCPJULUDX */ - PtUlUdxBndReq, /* 0 - loosely coupled, portable */ -#endif /* LCPJULUDX */ -#ifdef LWLCPJULUDX - cmPkPjUdxBndReq, /* 1 - loosely coupled */ -#else /* LCPJULUDX */ - PtUlUdxBndReq, /* 1 - loosely coupled, portable */ -#endif /* LCPJULUDX */ -#ifdef PJ - PjDlUdxBndReq, /* 2 - tightly coupled, CTC */ -#else /* PJ */ - PtUlUdxBndReq, /* 2 - tightly coupled, portable */ -#endif /* PJ */ -}; - -/* UDX Interface Unbind Request primitive */ -PRIVATE CONSTANT UdxUbndReq PjUlUdxUbndReqMt [PJ_MAX_UDX] = -{ -#ifdef LCPJULUDX - cmPkPjUdxUbndReq, /* 0 - loosely coupled */ -#else /* LCPJULUDX */ - PtUlUdxUbndReq, /* 0 - loosely coupled, portable */ -#endif /* LCPJULUDX */ -#ifdef LWLCPJULUDX - cmPkPjUdxUbndReq, /* 1 - loosely coupled */ -#else /* LCPJULUDX */ - PtUlUdxUbndReq, /* 1 - loosely coupled, portable */ -#endif /* LCPJULUDX */ -#ifdef PJ - PjDlUdxUbndReq, /* 2 - tightly coupled, UDX */ -#else /* PJ */ - PtUlUdxUbndReq, /* 2 - tightly coupled, portable */ -#endif /* PJ */ -}; - -/* UDX Interface Config Request primitive */ -PRIVATE CONSTANT UdxCfgReq PjUlUdxCfgReqMt [PJ_MAX_UDX] = -{ -#ifdef LCPJULUDX - cmPkPjUdxCfgReq, /* 0 - loosely coupled */ -#else /* LCPJULUDX */ - PtUlUdxCfgReq, /* 0 - loosely coupled, portable */ -#endif /* LCPJULUDX */ -#ifdef LWLCPJULUDX - cmPkPjUdxCfgReq, /* 1 - loosely coupled */ -#else /* LCPJULUDX */ - PtUlUdxCfgReq, /* 1 - loosely coupled, portable */ -#endif /* LCPJULUDX */ -#ifdef PJ - PjDlUdxCfgReq, /* 2 - tightly coupled, UDX */ -#else /* PJ */ - PtUlUdxCfgReq, /* 2 - tightly coupled, portable */ -#endif /* PJ */ -}; - -/* UDX Interface Status Report from PDCP-UL to PDCP-DL primitive */ -PRIVATE CONSTANT UdxUlStaRep PjUlUdxUlStaRepMt [PJ_MAX_UDX] = -{ -#ifdef LCPJULUDX - cmPkPjUdxUlStaRep, /* 0 - loosely coupled */ -#else /* LCPJULUDX */ - PtUlUdxUlStaRep, /* 0 - loosely coupled, portable */ -#endif /* LCPJULUDX */ -#ifdef LWLCPJULUDX - cmPkPjUdxUlStaRep, /* 1 - loosely coupled */ -#else /* LCPJULUDX */ - PtUlUdxUlStaRep, /* 1 - loosely coupled, portable */ -#endif /* LCPJULUDX */ -#ifdef PJ - PjDlUdxUlStaRep, /* 2 - tightly coupled, UDX */ -#else /* PJ */ - PtUlUdxUlStaRep, /* 2 - tightly coupled, portable */ -#endif /* PJ */ -}; - -/* UDX Interface Status Report from PDCP-UL to PDCP-DL primitive */ -PRIVATE CONSTANT UdxDlStaRep PjUlUdxDlStaRepMt [PJ_MAX_UDX] = -{ -#ifdef LCPJULUDX - cmPkPjUdxDlStaRep, /* 0 - loosely coupled */ -#else /* LCPJULUDX */ - PtUlUdxDlStaRep, /* 0 - loosely coupled, portable */ -#endif /* LCPJULUDX */ -#ifdef LWLCPJULUDX - cmPkPjUdxDlStaRep, /* 1 - loosely coupled */ -#else /* LCPJULUDX */ - PtUlUdxDlStaRep, /* 1 - loosely coupled, portable */ -#endif /* LCPJULUDX */ -#ifdef PJ - PjDlUdxDlStaRep, /* 2 - tightly coupled, UDX */ -#else /* PJ */ - PtUlUdxDlStaRep, /* 2 - tightly coupled, portable */ -#endif /* PJ */ -}; - -/* UDX Interface Status Report from PDCP-UL to PDCP-DL primitive */ -PRIVATE CONSTANT UdxDlFdbkPkt PjUlUdxDlFdbkPktInfoMt [PJ_MAX_UDX] = -{ -#ifdef LCPJULUDX - cmPkPjUdxDlFdbkPkt, /* 0 - loosely coupled */ -#else /* LCPJULUDX */ - PtUlUdxDlFdbkPktInfo, /* 0 - loosely coupled, portable */ -#endif /* LCPJULUDX */ -#ifdef LWLCPJULUDX - cmPkPjUdxDlFdbkPkt, /* 1 - loosely coupled */ -#else /* LCPJULUDX */ - PtUlUdxDlFdbkPktInfo, /* 1 - loosely coupled, portable */ -#endif /* LCPJULUDX */ -#ifdef PJ - PjDlUdxDlFdbkPktInfo, /* 2 - tightly coupled, UDX */ -#else /* PJ */ - PtUlUdxDlFdbkPktInfo, /* 2 - tightly coupled, portable */ -#endif /* PJ */ -}; - - -/* UDX Interface Feedback Pkt Info from PDCP-UL to PDCP-DL primitive */ -PRIVATE CONSTANT UdxUlFdbkPkt PjUlUdxUlFdbkPktInfoMt [3] = -{ -#ifdef LCPJULUDX - cmPkPjUdxUlFdbkPkt, /* 0 - loosely coupled */ -#else /* LCPJULUDX */ - PtUlUdxUlFdbkPktInfo, /* 0 - loosely coupled, portable */ -#endif /* LCPJULUDX */ -#ifdef LWLCPJULUDX - cmPkPjUdxUlFdbkPkt, /* 1 - loosely coupled */ -#else /* LCPJULUDX */ - PtUlUdxUlFdbkPktInfo, /* 1 - loosely coupled, portable */ -#endif /* LCPJULUDX */ -#ifdef PJ - PjDlUdxUlFdbkPktInfo, /* 2 - tightly coupled, UDX */ -#else /* PJ */ - PtUlUdxUlFdbkPktInfo, /* 2 - tightly coupled, portable */ -#endif /* PJ */ -}; - -/* UDX Interface UE Id Change Request primitive */ -PRIVATE CONSTANT UdxUeIdChgReq PjUlUdxUeIdChgReqMt [PJ_MAX_UDX] = -{ -#ifdef LCPJULUDX - cmPkPjUdxUeIdChgReq, /* 0 - loosely coupled */ -#else /* LCPJULUDX */ - PtUlUdxUeIdChgReq, /* 0 - loosely coupled, portable */ -#endif /* LCPJULUDX */ -#ifdef LWLCPJULUDX - cmPkPjUdxUeIdChgReq, /* 1 - loosely coupled */ -#else /* LCPJULUDX */ - PtUlUdxUeIdChgReq, /* 1 - loosely coupled, portable */ -#endif /* LCPJULUDX */ -#ifdef PJ - PjDlUdxUeIdChgReq, /* 2 - tightly coupled, UDX */ -#else /* PJ */ - PtUlUdxUeIdChgReq, /* 2 - tightly coupled, portable */ -#endif /* PJ */ -}; - -/* UDX Interface Security Config Request primitive */ -PRIVATE CONSTANT UdxSecCfgReq PjUlUdxSecCfgReqMt [PJ_MAX_UDX] = -{ -#ifdef LCPJULUDX - cmPkPjUdxSecCfgReq, /* 0 - loosely coupled */ -#else /* LCPJULUDX */ - PtUlUdxSecCfgReq, /* 0 - loosely coupled, portable */ -#endif /* LCPJULUDX */ -#ifdef LWLCPJULUDX - cmPkPjUdxSecCfgReq, /* 1 - loosely coupled */ -#else /* LCPJULUDX */ - PtUlUdxSecCfgReq, /* 1 - loosely coupled, portable */ -#endif /* LCPJULUDX */ -#ifdef PJ - PjDlUdxSecCfgReq, /* 2 - tightly coupled, UDX */ -#else /* PJ */ - PtUlUdxSecCfgReq, /* 2 - tightly coupled, portable */ -#endif/* PJ */ -}; - -/* UDX Interface COUNT Request primitive */ -PRIVATE CONSTANT UdxCountReq PjUlUdxCountReqMt [PJ_MAX_UDX] = -{ -#ifdef LCPJULUDX - cmPkPjUdxCountReq, /* 0 - loosely coupled */ -#else /* LCPJULUDX */ - PtUlUdxCountReq, /* 0 - loosely coupled, portable */ -#endif /* LCPJULUDX */ -#ifdef LWLCPJULUDX - cmPkPjUdxCountReq, /* 1 - loosely coupled */ -#else /* LCPJULUDX */ - PtUlUdxCountReq, /* 1 - loosely coupled, portable */ -#endif /* LCPJULUDX */ -#ifdef PJ - PjDlUdxCountReq, /* 2 - tightly coupled, UDX */ -#else /* PJ */ - PtUlUdxCountReq, /* 2 - tightly coupled, portable */ -#endif /* PJ */ -}; - -/* UDX Interface PDCP Status Request primitive */ -PRIVATE CONSTANT UdxSduStaReq PjUlUdxSduStaReqMt [PJ_MAX_UDX] = -{ -#ifdef LCPJULUDX - cmPkPjUdxSduStaReq, /* 0 - loosely coupled */ -#else /* LCPJULUDX */ - PtUlUdxSduStaReq, /* 0 - loosely coupled, portable */ -#endif /* LCPJULUDX */ -#ifdef LWLCPJULUDX - cmPkPjUdxSduStaReq, /* 1 - loosely coupled */ -#else /* LCPJULUDX */ - PtUlUdxSduStaReq, /* 1 - loosely coupled, portable */ -#endif /* LCPJULUDX */ -#ifdef PJ - PjDlUdxSduStaReq, /* 2 - tightly coupled, UDX */ -#else /* PJ */ - PtUlUdxSduStaReq, /* 2 - tightly coupled, portable */ -#endif /* PJ */ -}; - -/* UDX Interface Re-Establishment Request primitive */ -PRIVATE CONSTANT UdxReEstReq PjUlUdxReEstReqMt [PJ_MAX_UDX] = -{ -#ifdef LCPJULUDX - cmPkPjUdxReEstReq, /* 0 - loosely coupled */ -#else /* LCPJULUDX */ - PtUlUdxReEstReq, /* 0 - loosely coupled, portable */ -#endif /* LCPJULUDX */ -#ifdef LWLCPJULUDX - cmPkPjUdxReEstReq, /* 1 - loosely coupled */ -#else /* LCPJULUDX */ - PtUlUdxReEstReq, /* 1 - loosely coupled, portable */ -#endif /* LCPJULUDX */ -#ifdef PJ - PjDlUdxReEstReq, /* 2 - tightly coupled, UDX */ -#else /* PJ */ - PtUlUdxReEstReq, /* 2 - tightly coupled, portable */ -#endif /* PJ */ -}; - -#ifdef LTE_L2_MEAS -PRIVATE CONSTANT UdxL2MeasReq pjUlUdxL2MeasReqMt[PJ_MAX_UDX] = -{ -#ifdef LCPJULUDX - cmPkPjUdxL2MeasReq, /* 0 - loosely coupled */ -#else - PtUlUdxL2MeasReq, /* 0 - loosely coupled, portable */ -#endif /* LCKWUIKWU */ -#ifdef LWLCPJULUDX - cmPkPjUdxL2MeasReq, /* 1 - loosely coupled */ -#else - PtUlUdxL2MeasReq, /* 1 - loosely coupled, portable */ -#endif /* LCKWUIKWU */ -#ifdef PJ - PjDlUdxL2MeasReq, /* 2 - tightly coupled, RRC */ -#else - PtUlUdxL2MeasReq, /* 2 - tightly coupled, portable */ -#endif /* KW */ -}; - -PRIVATE CONSTANT UdxL2MeasSendReq pjUlUdxL2MeasSendReqMt[PJ_MAX_UDX] = -{ -#ifdef LCPJULUDX - cmPkPjUdxL2MeasSendReq, /* 0 - loosely coupled */ -#else - PtUlUdxL2MeasSendReq, /* 0 - loosely coupled, portable */ -#endif /* LCKWUIKWU */ -#ifdef LWLCPJULUDX - cmPkPjUdxL2MeasSendReq, /* 1 - loosely coupled */ -#else - PtUlUdxL2MeasSendReq, /* 1 - loosely coupled, portable */ -#endif /* LCKWUIKWU */ -#ifdef PJ - PjDlUdxL2MeasSendReq, /* 2 - tightly coupled, RRC */ -#else - PtUlUdxL2MeasSendReq, /* 2 - tightly coupled, portable */ -#endif /* PJ */ -}; - -PRIVATE CONSTANT UdxL2MeasStopReq pjUlUdxL2MeasStopReqMt[PJ_MAX_UDX] = -{ -#ifdef LCPJULUDX - cmPkPjUdxL2MeasStopReq, /* 0 - loosely coupled */ -#else - PtUlUdxL2MeasStopReq, /* 0 - loosely coupled, portable */ -#endif /* LCKWUIKWU */ -#ifdef LWLCPJULUDX - cmPkPjUdxL2MeasStopReq, /* 1 - loosely coupled */ -#else - PtUlUdxL2MeasStopReq, /* 1 - loosely coupled, portable */ -#endif /* LCKWUIKWU */ -#ifdef PJ - PjDlUdxL2MeasStopReq, /* 2 - tightly coupled, RRC */ -#else - PtUlUdxL2MeasStopReq, /* 2 - tightly coupled, portable */ -#endif /* PJ */ -}; -#endif - - -/* UDX Interface PDCP Status Request primitive */ -PRIVATE CONSTANT UdxDatResumeReq pjUlUdxDatResumeReqMt [PJ_MAX_UDX] = -{ -#ifdef LCPJULUDX - cmPkPjUdxDatResumeReq, /* 0 - loosely coupled */ -#else /* LCPJULUDX */ - PtUlUdxDatResumeReq, /* 0 - loosely coupled, portable */ -#endif /* LCPJULUDX */ -#ifdef LWLCPJULUDX - cmPkPjUdxDatResumeReq, /* 1 - loosely coupled */ -#else /* LCPJULUDX */ - PtUlUdxDatResumeReq, /* 1 - loosely coupled, portable */ -#endif /* LCPJULUDX */ -#ifdef PJ - PjDlUdxDatResumeReq, /* 2 - tightly coupled, UDX */ -#else /* PJ */ - PtUlUdxDatResumeReq, /* 2 - tightly coupled, portable */ -#endif /* PJ */ -}; - - -/* UDX Interface PDCP Start Data Forward primitive */ -PRIVATE CONSTANT UdxDatForwardReq pjUlUdxDatForwardReqMt [PJ_MAX_UDX] = -{ -#ifdef LCPJULUDX - cmPkPjUdxDatForwardReq, /* 0 - loosely coupled */ -#else /* LCPJULUDX */ - PtUlUdxDatForwardReq, /* 0 - loosely coupled, portable */ -#endif /* LCPJULUDX */ -#ifdef LWLCPJULUDX - cmPkPjUdxDatForwardReq, /* 1 - loosely coupled */ -#else /* LCPJULUDX */ - PtUlUdxDatForwardReq, /* 1 - loosely coupled, portable */ -#endif /* LCPJULUDX */ -#ifdef PJ - PjDlUdxDatForwardReq, /* 2 - tightly coupled, UDX */ -#else /* PJ */ - PtUlUdxDatForwardReq, /* 2 - tightly coupled, portable */ -#endif /* PJ */ -}; - -/************************************************************************** - * The UDX Interface - *************************************************************************/ -/** - * - * @brief This function binds the RRC service user with the PDCP - * service provider. - * - * @details This function binds the RRC service user with the PDCP - * service provider. The PDCP registers this new service - * user and allocates a Service Access Point (SAP) for - * this bind. The service user specifies the reference - * number that is used for the duration of this bind. - */ -#ifdef ANSI -PUBLIC S16 PjUlUdxBndReq -( -Pst *post, /* Post structure */ -SuId suId, /* Service user ID */ -SpId spId /* Service provider ID */ -) -#else /* ANSI */ -PUBLIC S16 PjUlUdxBndReq(post, suId, spId) -Pst *post; /* Post structure */ -SuId suId; /* Service user ID */ -SpId spId; /* Service provider ID */ -#endif /* ANSI */ -{ - - TRC3(PjUlUdxBndReq); - - RETVALUE((*PjUlUdxBndReqMt[post->selector])(post, suId, spId)); - -} /* end of function PjUlUdxBndReq */ - - -/* -* @brief This function unbinds the RRC service user with the PDCP -* service provider. -* -* @details This function unbinds the RRC service user with the PDCP -* service provider. -* -*/ -#ifdef ANSI -PUBLIC S16 PjUlUdxUbndReq -( -Pst *post, /* Post structure */ -SpId spId, /* Service provider ID */ -Reason reason /* Reason */ -) -#else /* ANSI */ -PUBLIC S16 PjUlUdxUbndReq(post, spId, reason) -Pst *post; /* Post structure */ -SpId spId; /* Service provider ID */ -Reason reason; /* Reason */ -#endif /* ANSI */ -{ - - TRC3(PjUlUdxUbndReq); - - RETVALUE((*PjUlUdxUbndReqMt[post->selector])(post, spId, reason)); - -} /* end of function PjUlUdxUbndReq */ - - -/** -* -* @brief This function is used to pass Signalling Info to PDCP related -* to PDCP configuration. -* -* @details This function is used to pass signaling Info to PDCP related -* to PDCP configuration. -* -*/ -#ifdef ANSI -PUBLIC S16 PjUlUdxCfgReq -( -Pst *post, /* Post structure */ -SpId spId, /* Service provider ID */ -UdxCfgReqInfo *pdCfgReq /* PDCP Config parameters */ -) -#else /* ANSI */ -PUBLIC S16 PjUlUdxCfgReq(post, spId, pdCfgReq) -Pst *post; /* Post structure */ -SpId spId; /* Service provider ID */ -UdxCfgReqInfo *pdCfgReq; /* PDCP Config parameters */ -#endif /* ANSI */ -{ - - TRC3(PjUlUdxCfgReq); - - - RETVALUE((*PjUlUdxCfgReqMt[post->selector])(post, spId, pdCfgReq)); - -} /* end of function PjUlUdxCfgReq */ - - -/** -* -* @brief This function is used to sent the PDCP STATUS report to PDCP-DL during the Reestablishment. -* @details This function is used to sent the PDCP STATUS report to PDCP-DL during the Reestablishment -* -*/ -#ifdef ANSI -PUBLIC S16 PjUlUdxUlStaRep -( -Pst *pst, /* Post structure */ -SpId spId, /* Service provider ID */ -UdxUlStaRepInfo *staRep /*PDCP Status Report*/ -) -#else /* ANSI */ -PUBLIC S16 PjUlUdxUlStaRep (pst, spId, staRep) -Pst *pst; /* Post structure */ -SpId spId; /* Service provider ID */ -UdxUlStaRepInfo *staRep; /* PDCP Status Report*/ -#endif /* ANSI */ -{ - - TRC3(PjUlUdxUlStaRep); - - RETVALUE((*PjUlUdxUlStaRepMt[pst->selector])(pst, spId, staRep)); - -} /* end of function PjUlUdxUlStaRep */ - -/** -* -* @brief This function is used to sent the PDCP STATUS report received from peer RLC to PDCP-DL. -* @details This function is used to sent the PDCP STATUS report received from peer RLC to PDCP-DL -* -*/ -#ifdef ANSI -PUBLIC S16 PjUlUdxDlStaRep -( -Pst *pst, /* Post structure */ -SpId spId, /* Service provider ID */ -UdxDlStaRepInfo *staRep /*PDCP Status Report*/ -) -#else /* ANSI */ -PUBLIC S16 PjUlUdxDlStaRep (pst, spId, staRep) -Pst *pst; /* Post structure */ -SpId spId; /* Service provider ID */ -UdxDlStaRepInfo *staRep; /* PDCP Status Report*/ -#endif /* ANSI */ -{ - - TRC3(PjUlUdxDlStaRep); - - RETVALUE((*PjUlUdxDlStaRepMt[pst->selector])(pst, spId, staRep)); - -} /* end of function PjUlUdxUlStaRep */ - -/** -* -* @brief This function is used to sent the ROHC feedback report received from peer PDCP to PDCP-DL -* @details This function is used to sent the ROHC feedback report received from peer PDCP to PDCP-DL -* -*/ -#ifdef ANSI -PUBLIC S16 PjUlUdxDlFdbkPktInfo -( -Pst *pst, /* Post structure */ -SpId spId, /* Service provider ID */ -UdxDlFdbkPktInfo *fdbk /*ROHC feedback*/ -) -#else /* ANSI */ -PUBLIC S16 PjUlUdxDlFdbkPktInfo (pst, spId, fdbk) -Pst *pst; /* Post structure */ -SpId spId; /* Service provider ID */ -UdxDlFdbkPktInfo *fdbk; /* ROHC feedback*/ -#endif /* ANSI */ -{ - - TRC3(PjUlUdxDlFdbkPktInfo); - - RETVALUE((*PjUlUdxDlFdbkPktInfoMt[pst->selector])(pst, spId, fdbk)); - -} /* end of function PjUlUdxDlFdbkPktInfo */ - -/** - * - * @brief This function is used to sent the Feedback pkt info to DL-PDCP. - * @details This function is used to sent the Feedback pkt info to DL-PDCP. - * - */ -#ifdef ANSI -PUBLIC S16 PjUlUdxUlFdbkPktInfo -( -Pst *pst, /* Post structure */ -SpId spId, /* Service provider ID */ -UdxUlFdbkPktInfo *fdbkPktInfo /*Feedback Packet Info*/ -) -#else /* ANSI */ -PUBLIC S16 PjUlUdxUlFdbkPktInfo (pst, spId, staRep) -Pst *pst; /* Post structure */ -SpId spId; /* Service provider ID */ -UdxUlFdbkPktInfo *fdbkPktInfo; /* Feedback Packet Info*/ -#endif /* ANSI */ -{ - - TRC3(PjUlUdxUlFdbkPktInfo); - - RETVALUE((*PjUlUdxUlFdbkPktInfoMt[pst->selector])(pst, spId, fdbkPktInfo)); - -} /* end of function PjUlUdxUlFdbkPktInfo */ - - -/** - * - * @brief Sends an UE Id Change Indication to PDCP on Ckw interface - * @details Sends an UE Id Change Indication to PDCP on Ckw interface - * - */ -#ifdef ANSI -PUBLIC S16 PjUlUdxUeIdChgReq -( -Pst *post, /* post structure */ -SpId spId, /* service provider */ -U32 transId, /* RRC Transaction Id */ -UdxUeInfo *oldUeInfo, /* current UE Id */ -UdxUeInfo *newUeInfo /* new UE Id */ -) -#else /* ANSI */ -PUBLIC S16 PjUlUdxUeIdChgReq(post, spId, transId, oldUeInfo, newUeInfo) -Pst *post; /* post structure */ -SpId spId; /* service provider */ -U32 transId; /* RRC Transaction Id */ -UdxUeInfo *oldUeInfo; /* current UE Id */ -UdxUeInfo *newUeInfo; /* new UE Id */ -#endif /* ANSI */ -{ - TRC3(PjUlUdxUeIdChgReq); - - RETVALUE((*PjUlUdxUeIdChgReqMt[post->selector])(post, spId, transId, - (UdxUeInfo *)oldUeInfo, (UdxUeInfo *)newUeInfo )); - -} /* end of function PjUlUdxUeIdChgReq */ - -/** -* -* @brief This function is used to configure PDCP security parameters -* (parametrs of Integrity protection and ciphering) -* -* @details This function is used to configure PDCP security parameters -* (parametrs of Integrity protection and ciphering) -* -*/ -#ifdef ANSI -PUBLIC S16 PjUlUdxSecCfgReq -( -Pst *post, /* Post structure */ -SpId spId, /* Service provider ID */ -UdxSecCfgReqInfo *cpjSecConfigReqInfo /* PDCP Security Config parameters */ -) -#else /* ANSI */ -PUBLIC S16 PjUlUdxSecCfgReq(post, spId, cpjSecConfigReqInfo) -Pst *post; /* Post structure */ -SpId spId; /* Service provider ID */ -UdxSecCfgReqInfo *cpjSecConfigReqInfo; /* PDCP Security Config parameters */ -#endif /* ANSI */ -{ - - TRC3(PjUlUdxSecCfgReq); - - RETVALUE((*PjUlUdxSecCfgReqMt[post->selector])(post, spId, - cpjSecConfigReqInfo)); - -} /* end of function PjUlUdxSecCfgReq */ - -/** -* -* @brief This function is used to get COUNT values of each established DRB -* -* @details This function is used to get COUNT values of each established DRB -* -*/ -#ifdef ANSI -PUBLIC S16 PjUlUdxCountReq -( -Pst *post, /* Post structure */ -SpId spId, /* Service provider ID */ -UdxCountReqInfo *pdcpCountReq /* PDCP COUNT request paramters */ -) -#else /* ANSI */ -PUBLIC S16 PjUlUdxCountReq(post, spId, pdcpCountReq) -Pst *post; /* Post structure */ -SpId spId; /* Service provider ID */ -UdxCountReqInfo *pdcpCountReq; /* PDCP COUNT request paramters */ -#endif /* ANSI */ -{ - - TRC3(PjUlUdxCountReq); - - RETVALUE((*PjUlUdxCountReqMt[post->selector])(post, spId, pdcpCountReq)); - -} /* end of function PjUlUdxCountReq */ - -/** -* -* @brief This function is used to get PDCP Sdu Status for all DRBs. -* -* @details This function is used to get PDCP Sdu Status for all DRBs -* from PDCP at source during HO. -* -*/ -#ifdef ANSI -PUBLIC S16 PjUlUdxSduStaReq -( -Pst *post, /* Post structure */ -SpId spId, /* Service provider ID */ -UdxSduStaReqInfo *pdcpSduStaReq /* PDCP SDU status request parameters */ -) -#else /* ANSI */ -PUBLIC S16 PjUlUdxSduStaReq(post, spId, pdcpSduStaReq) -Pst *post; /* Post structure */ -SpId spId; /* Service provider ID */ -UdxSduStaReqInfo *pdcpSduStaReq; /* PDCP SDU status request parameters */ -#endif /* ANSI */ -{ - - TRC3(PjUlUdxSduStaReq); - - RETVALUE((*PjUlUdxSduStaReqMt[post->selector])(post, spId, pdcpSduStaReq)); - -} /* end of function PjUlUdxSduStaReq */ - - -/** - * - * @brief Sends a Re-establish request to PDCP on UDX interface - * @details Sends a Re-establish request to PDCP on UDX interface - * - */ -#ifdef ANSI -PUBLIC S16 PjUlUdxReEstReq -( -Pst *post, /* post structure */ -SpId spId, /* service provider */ -UdxReEstReqInfo *restbInfo /* Re-establishment Info */ -) -#else /* ANSI */ -PUBLIC S16 PjUlUdxReEstReq(post, spId, restbInfo) -Pst *post; /* post structure */ -SpId spId; /* service provider */ -UdxReEstReqInfo *restbInfo; /* new UE Id */ -#endif /* ANSI */ -{ - TRC3(PjUlUdxReEstReq); - - RETVALUE((*PjUlUdxReEstReqMt[post->selector])(post, spId, restbInfo)); - -} /* end of function PjUlUdxReEstReq */ - -#ifdef LTE_L2_MEAS -/** -* @brief Request from ULM to DLM for MeasReq -* -* @details -* -* Function : PjUlUdxL2MeasReq -* -* @param[in] Pst* pst - -* @return S16 -* -# ROK -**/ -#ifdef ANSI -PUBLIC S16 PjUlUdxL2MeasReq -( -Pst* pst, -PjL2MeasReqEvt *measReqEvt -) -#else -PUBLIC S16 PjUlUdxL2MeasReq(pst,measReqEvt) -Pst* pst; -PjL2MeasReqEvt *measReqEvt; -#endif -{ - - TRC3(PjUlUdxStaUpdReq); - - RETVALUE((*pjUlUdxL2MeasReqMt[pst->selector])(pst,measReqEvt)); -} /* end of PjUlUdxMesReq*/ - -/** -* @brief Request from ULM to DLM for MeasSendReq -* -* @details -* -* Function : PjUlUdxMeasSendReq -* -* @param[in] Pst* pst - -* @return S16 -* -# ROK -**/ -#ifdef ANSI -PUBLIC S16 PjUlUdxL2MeasSendReq -( -Pst* pst, -U8 measType -) -#else -PUBLIC S16 PjUlUdxL2MeasSendReq(pst,measReqEvt) -Pst* pst; -U8 measType; -#endif -{ - - TRC3(PjUlUdxL2MeasSendReq); - - RETVALUE((*pjUlUdxL2MeasSendReqMt[pst->selector])(pst,measType)); -} /* end of PjUlUdxMesReq*/ - -/** -* @brief Request from ULM to DLM for MeasStopReq -* -* @details -* -* Function : PjUlUdxL2MeasStopReq -* -* @param[in] Pst* pst - -* @return S16 -* -# ROK -**/ -#ifdef ANSI -PUBLIC S16 PjUlUdxL2MeasStopReq -( -Pst* pst, -U8 measType -) -#else -PUBLIC S16 PjUlUdxL2MeasStopReq(pst,measReqEvt) -Pst* pst; -U8 measType; -#endif -{ - - TRC3(PjUlUdxL2MeasStopReq); - - RETVALUE((*pjUlUdxL2MeasStopReqMt[pst->selector])(pst,measType)); -} /* end of PjUlUdxMesReq*/ -#endif - - - -/** -* @brief Request from ULM to DLM for MeasStopReq -* -* @details -* -* Function : PjUlUdxDatResumeReq -* -* @param[in] Pst* pst - -* @return S16 -* -# ROK -**/ -#ifdef ANSI -PUBLIC S16 PjUlUdxDatResumeReq -( -Pst* pst, -UdxDatResumeInfo *udxDatResumeInfo -) -#else -PUBLIC S16 PjUlUdxDatResumeReq(pst, udxDatResumeInfo) -Pst* pst; -UdxDatResumeInfo *udxDatResumeInfo; -#endif -{ - - TRC3(PjUlUdxDatResumeReq); - - RETVALUE((*pjUlUdxDatResumeReqMt[pst->selector])(pst, udxDatResumeInfo)); -} /* end of PjUlUdxMesReq*/ - - -/** -* @brief -* -* @details -* -* Function : PjUlUdxDatForwardReq -* -* @param[in] Pst* pst - -* @return S16 -* -# ROK -**/ -#ifdef ANSI -PUBLIC S16 PjUlUdxDatForwardReq -( -Pst* pst, -UdxDatForwardInfo *udxDatForwardInfo -) -#else -PUBLIC S16 PjUlUdxDatForwardReq(pst, udxDatForwardInfo) -Pst* pst; -UdxDatForwardInfo *udxDatForwardInfo; -#endif -{ - - TRC3(PjUlUdxDatForwardReq); - - RETVALUE((*pjUlUdxDatForwardReqMt[pst->selector])(pst, udxDatForwardInfo)); -} /* end of PjUlUdxMesReq*/ -/************************************************************************** - * The UDX (Portable) Interface - *************************************************************************/ -#ifdef PTPJULUDX -/************************************************************************** - * - * Fun: PtUlUdxBndReq - * - * Desc: Portable UdxBndReq primitive - * - * Ret: ROK - * - * Notes: - * - * File: nh_ptli.c - * - *************************************************************************/ -#ifdef ANSI -PRIVATE S16 PtUlUdxBndReq -( -Pst *post, /* Post structure */ -SuId suId, /* Service user ID */ -SpId spId /* Service provider ID */ -) -#else /* ANSI */ -PRIVATE S16 PtUlUdxBndReq(post, suId, spId) -Pst *post; /* Post structure */ -SuId suId; /* Service user ID */ -SpId spId; /* Service provider ID */ -#endif /* ANSI */ -{ - - TRC3(PtUlUdxBndReq); - - UNUSED(post); - UNUSED(suId); - UNUSED(spId); - - RETVALUE(ROK); - -} /* end of function PtUlUdxBndReq */ - - -/************************************************************************** -* -* Fun: PtUlUdxUbndReq -* -* Desc: Portable UdxUbndReq primitive -* -* Ret: ROK -* -* Notes: -* -* File: nh_ptli.c -* -*************************************************************************/ -#ifdef ANSI -PRIVATE S16 PtUlUdxUbndReq -( -Pst *post, /* Post structure */ -SpId spId, /* Service provider ID */ -Reason reason /* Reason */ -) -#else /* ANSI */ -PRIVATE S16 PtUlUdxUbndReq(post, spId, reason) -Pst *post; /* Post structure */ -SpId spId; /* Service provider ID */ -Reason reason; /* Reason */ -#endif /* ANSI */ -{ - - TRC3(PtUlUdxUbndReq); - - UNUSED(post); - UNUSED(spId); - UNUSED(reason); - - RETVALUE(ROK); - -} /* end of function PtUlUdxUbndReq */ - - -/************************************************************************** -* -* Fun: PtUlUdxCfgReq -* -* Desc: Portable UdxCfgReq primitive -* -* Ret: ROK -* -* Notes: -* -* File: nh_ptli.c -* -*************************************************************************/ -#ifdef ANSI -PRIVATE S16 PtUlUdxCfgReq -( -Pst *post, /* Post structure */ -SpId spId, /* Service provider ID */ -UdxCfgReqInfo *pdCfgReq /* PDCP Config parameters */ -) -#else /* ANSI */ -PRIVATE S16 PtUlUdxCfgReq(post, spId, pdCfgReq) -Pst *post; /* Post structure */ -SpId spId; /* Service provider ID */ -UdxCfgReqInfo *pdCfgReq; /* PDCP Config parameters */ -#endif /* ANSI */ -{ - - TRC3(PtUlUdxCfgReq); - - UNUSED(post); - UNUSED(spId); - UNUSED(pdCfgReq); - - - RETVALUE(ROK); - -} /* end of function PtUlUdxCfgReq */ - -/************************************************************************** -* -* Fun: PtUlUdxUlStaRep -* -* Desc: Portable UdxUlStaRep primitive -* -* Ret: ROK -* -* Notes: -* -* File: pj_udx_ptul.c -* -*************************************************************************/ -#ifdef ANSI -PRIVATE S16 PtUlUdxUlStaRep -( -Pst *post, /* Post structure */ -SpId spId, /* Service provider ID */ -UdxUlStaRepInfo *pdStaRep /* PDCP UL ot PDCP DL Reestablishment trigger */ -) -#else /* ANSI */ -PRIVATE S16 PtUlUdxUlStaRep(post, spId, pdStaRep) -Pst *post; /* Post structure */ -SpId spId; /* Service provider ID */ -UdxUlStaRepInfo *pdStaRep; /* PDCP UL ot PDCP DL Reestablishment trigger */ -#endif /* ANSI */ -{ - - TRC3(PtUlUdxUlStaRep); - - UNUSED(post); - UNUSED(spId); - UNUSED(pdStaRep); - - - RETVALUE(ROK); - -} /* end of function */ - -/************************************************************************** -* -* Fun: PtUlUdxUlStaRep -* -* Desc: Portable UdxUlStaRep primitive -* -* Ret: ROK -* -* Notes: -* -* File: pj_udx_ptul.c -* -*************************************************************************/ -#ifdef ANSI -PRIVATE S16 PtUlUdxDlStaRep -( -Pst *post, /* Post structure */ -SpId spId, /* Service provider ID */ -UdxDlStaRepInfo *pdStaRep /* Status report from PDCP UL to PDCP DL */ -) -#else /* ANSI */ -PRIVATE S16 PtUlUdxDlStaRep(post, spId, pdStaRep) -Pst *post; /* Post structure */ -SpId spId; /* Service provider ID */ -UdxDlStaRepInfo *pdStaRep; /* Status report from PDCP UL to PDCP DL */ -#endif /* ANSI */ -{ - - TRC3(PtUlUdxDlStaRep); - - UNUSED(post); - UNUSED(spId); - UNUSED(pdStaRep); - - - RETVALUE(ROK); - -} /* end of function */ - - -/************************************************************************** - * - * Fun: PtUlUdxUeIdChgReq - * - * Desc: Portable UdxUeIdChgReq primitive - * - * Ret: ROK - * - * Notes: - * - * File: nh_ptli.c - * - *************************************************************************/ -#ifdef ANSI -PRIVATE S16 PtUlUdxUeIdChgReq -( -Pst *post, /* post structure */ -SpId spId, /* service provider */ -U32 transId, /* TransId */ -UdxUeInfo *oldUeInfo, /* current UE Id */ -UdxUeInfo *newUeInfo /* new UE Id */ -) -#else /* ANSI */ -PRIVATE S16 PtUlUdxUeIdChgReq(post, spId, transId, oldUeInfo, newUeInfo) -Pst *post; /* post structure */ -SpId spId; /* service provider */ -U32 transId; /* TransId */ -UdxUeInfo *oldUeInfo; /* current UE Id */ -UdxUeInfo *newUeInfo; /* new UE Id */ -#endif /* ANSI */ -{ - TRC3(PtUlUdxUeIdChgReq); - - UNUSED(post); - UNUSED(spId); - UNUSED(transId); - UNUSED(oldUeInfo); - UNUSED(newUeInfo); - - RETVALUE(ROK); - -} /* end of function PtUlCkwUeIdChgReq */ - -/************************************************************************** - * - * Fun: PtUlUdxSecCfgReq - * - * Desc: Portable UdxSecCfgReq primitive - * - * Ret: ROK - * - * Notes: - * - * File: nh_ptli.c - * - *************************************************************************/ -#ifdef ANSI -PRIVATE S16 PtUlUdxSecCfgReq -( -Pst *post, /* post structure */ -SpId spId, /* service provider */ -UdxSecCfgReqInfo *secCfgReq /* PDCP Security Config paramters */ -) -#else /* ANSI */ -PRIVATE S16 PtUlUdxSecCfgReq(post, spId, secCfgReq) -Pst *post; /* post structure */ -SpId spId; /* service provider */ -UdxSecCfgReqInfo *secCfgReq; /* PDCP Security Config paramters */ -#endif /* ANSI */ -{ - TRC3(PtUlUdxSecCfgReq); - - UNUSED(post); - UNUSED(spId); - UNUSED(secCfgReq); - - RETVALUE(ROK); - -} /* end of function PtUlUdxSecCfgReq */ - -/************************************************************************** - * - * Fun: PtUlUdxCountReq - * - * Desc: Portable UdxCountReq primitive - * - * Ret: ROK - * - * Notes: - * - * File: nh_ptli.c - * - *************************************************************************/ -#ifdef ANSI -PRIVATE S16 PtUlUdxCountReq -( -Pst *post, /* post structure */ -SpId spId, /* service provider */ -UdxCountReqInfo *countReq /* PDCP Security Config paramters */ -) -#else /* ANSI */ -PRIVATE S16 PtUlUdxCountReq(post, spId, countReq) -Pst *post; /* post structure */ -SpId spId; /* service provider */ -UdxCountReqInfo *countReq; /* Count value paramters */ -#endif /* ANSI */ -{ - TRC3(PtUlUdxCountReq); - - UNUSED(post); - UNUSED(spId); - UNUSED(countReq); - - RETVALUE(ROK); - -} /* end of function PtUlUdxCountReq */ - -/************************************************************************** - * - * Fun: PtUlUdxSduStaReq - * - * Desc: Portable UdxSduStaReq primitive - * - * Ret: ROK - * - * Notes: - * - * File: nh_ptli.c - * - *************************************************************************/ -#ifdef ANSI -PRIVATE S16 PtUlUdxSduStaReq -( -Pst *post, /* post structure */ -SpId spId, /* service provider */ -UdxSduStaReqInfo *sduStaReq /* PDCP SDU status parameters */ -) -#else /* ANSI */ -PRIVATE S16 PtUlUdxSduStaReq(post, spId, sduStaReq) -Pst *post; /* post structure */ -SpId spId; /* service provider */ -UdxSduStaReqInfo *sduStaReq; /* PDCP SDU status parameters */ -#endif /* ANSI */ -{ - TRC3(PtUlUdxSduStaReq); - - UNUSED(post); - UNUSED(spId); - UNUSED(sduStaReq); - - - RETVALUE(ROK); - -} /* end of function PtUlUdxSduStaReq */ - - -/************************************************************************** - * - * Fun: PtUlUdxReEstReq - * - * Desc: Portable UdxReEstReq primitive - * - * Ret: ROK - * - * Notes: - * - * File: nh_ptli.c - * - *************************************************************************/ -#ifdef ANSI -PRIVATE S16 PtUlUdxReEstReq -( -Pst *post, /* post structure */ -SpId spId, /* service provider */ -UdxReEstReqInfo *restbInfo /* PDCP Re-establishment Config paramters */ -) -#else /* ANSI */ -PRIVATE S16 PtUlUdxReEstReq(post, spId, restbInfo) -Pst *post; /* post structure */ -SpId spId; /* service provider */ -UdxReEstReqInfo *restbInfo; /* PDCP Re-establishment Config paramters */ -#endif /* ANSI */ -{ - TRC3(PtUlUdxReEstReq); - - UNUSED(post); - UNUSED(spId); - UNUSED(restbInfo); - - RETVALUE(ROK); - -} /* end of function PtUlUdxReEstReq */ -/************************************************************************** - * - * Fun: PtUlUdxUlFdbkPktInfo - * - * Desc: Portable PtUlUdxUlFdbkPktInfo primitive - * - * Ret: ROK - * - * Notes: - * - * File : nh_ptli.c - * - *************************************************************************/ -#ifdef ANSI -PRIVATE S16 PtUlUdxUlFdbkPktInfo -( -Pst *post, /* post structure */ -SpId spId, /* service provider */ -UdxUlFdbkPktInfo *fdbkPktInfo /* feedback Packet Info */ -) -#else /* ANSI */ -PRIVATE S16 PtUlUdxUlFdbkPktInfo(post, spId, fdbkPktInfo) -Pst *post; /* post structure */ -SpId spId; /* service provider */ -UdxUlFdbkPktInfo *fdbkPktInfo /* feedback Packet Info */ -#endif /* ANSI */ -{ - TRC3(PtUlUdxUlFdbkPktInfo); - - UNUSED(post); - UNUSED(spId); - UNUSED(fdbkPktInfo); - - - RETVALUE(ROK); - -} /* end of function PtUlUdxUlFdbkPktInfo */ - - -/************************************************************************** - * - * Fun: PtUlUdxDlFdbkPktInfo - * - * Desc: Portable PtUlUdxDlFdbkPktInfo primitive - * - * Ret: ROK - * - * Notes: - * - * File : nh_ptli.c - * - *************************************************************************/ -#ifdef ANSI -PRIVATE S16 PtUlUdxDlFdbkPktInfo -( -Pst *post, /* post structure */ -SpId spId, /* service provider */ -UdxDlFdbkPktInfo *fdbkPktInfo /* feedback Packet Info */ -) -#else /* ANSI */ -PRIVATE S16 PtUlUdxDlFdbkPktInfo(post, spId, fdbkPktInfo) -Pst *post; /* post structure */ -SpId spId; /* service provider */ -UdxDlFdbkPktInfo *fdbkPktInfo /* feedback Packet Info */ -#endif /* ANSI */ -{ - TRC3(PtUlUdxDlFdbkPktInfo); - - UNUSED(post); - UNUSED(spId); - UNUSED(fdbkPktInfo); - - - RETVALUE(ROK); - -} /* end of function PtUlUdxDlFdbkPktInfo */ - - - - -#ifdef LTE_L2_MEAS -/** -* @brief Request from ULM to DLM for Measurement -* -* @details -* -* Function : PjUdxUdxL2MeasReq -* -* @param[in] Pst* pst - -* @return S16 -* -# ROK -**/ -#ifdef ANSI -PRIVATE S16 PtUlUdxL2MeasReq -( -Pst* pst, -PjL2MeasReqEvt *measReqEvt -) -#else -PRIVATE S16 PtUlUdxL2MeasReq(pst, measReqEvt ) -Pst* pst; -PjL2MeasReqEvt *measReqEvt; -#endif -{ - - TRC3(PtUlUdxL2MeasReq); - - RETVALUE(ROK); -} - -/** -* @brief Request from ULM to DLM for Measurement -* -* @details -* -* Function : PjUdxUdxL2MeasSendReq -* -* @param[in] Pst* pst - -* @return S16 -* -# ROK -**/ -#ifdef ANSI -PRIVATE S16 PtUlUdxL2MeasSendReq -( -Pst* pst, -U8 status -) -#else -PRIVATE S16 PtUlUdxL2MeasSendReq(pst, status ) -Pst* pst; -U8 status -#endif -{ - - TRC3(PtUlUdxL2MeasSendReq); - - RETVALUE(ROK); -} - -/** -* @brief Request from ULM to DLM for Measurement -* -* @details -* -* Function : PjUdxUdxL2MeasStopReq -* -* @param[in] Pst* pst - -* @return S16 -* -# ROK -**/ -#ifdef ANSI -PRIVATE S16 PtUlUdxL2MeasStopReq -( -Pst* pst, -U8 status -) -#else -PRIVATE S16 PtUlUdxL2MeasStopReq(pst, status ) -Pst* pst; -U8 status -#endif -{ - - TRC3(PtUlUdxL2MeasStopReq); - - RETVALUE(ROK); -} -#endif -/** -* @brief Request from ULM to DLM for ResumeReq -* -* @details -* -* Function : PtUlUdxDatResumeReq -* -* @param[in] Pst* pst - -* @return S16 -* -# ROK -**/ -#ifdef ANSI -PRIVATE S16 PtUlUdxDatResumeReq -( -Pst* pst, -UdxDatResumeInfo *udxDatResumeInfo -) -#else -PRIVATE S16 PtUlUdxDatResumeReq(pst, udxDatResumeInfo ) -Pst* pst; -UdxDatResumeInfo *udxDatResumeInfo; -#endif -{ - - TRC3(PtUlUdxDatResumeReq); - - RETVALUE(ROK); -} - -/** -* @brief -* -* @details -* -* Function : PtUlUdxDatForwardReq -* -* @param[in] Pst* pst - -* @return S16 -* -# ROK -**/ -#ifdef ANSI -PRIVATE S16 PtUlUdxDatForwardReq -( -Pst* pst, -UdxDatForwardInfo *udxDatForwardInfo -) -#else -PRIVATE S16 PtUlUdxDatForwardReq(pst, udxDatForwardInfo ) -Pst* pst; -UdxDatForwardInfo *udxDatForwardInfo; -#endif -{ - - TRC3(PtUlUdxDatForwardReq); - - RETVALUE(ROK); -} - -#endif /* #ifdef PTPJULUDX */ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ -/********************************************************************30** - End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_udx_ul.c b/src/5gnrpdcp/pj_udx_ul.c deleted file mode 100755 index 0d1f6b9ff..000000000 --- a/src/5gnrpdcp/pj_udx_ul.c +++ /dev/null @@ -1,1295 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: LTE-PDCP Layer - Upper Interface - - Type: C file - - Desc: C source code for the upper interface of LTE-PDCP - - File: pj_udx_ul.c - -*********************************************************************21*/ -static const char* RLOG_MODULE_NAME="PDCP"; -static int RLOG_MODULE_ID=1024; -static int RLOG_FILE_ID=226; -/** @file pj_udx_ul.c -@brief PDCP Upper Interface -*/ - - -/* header (.h) include files */ -#include "envopt.h" /* environment options */ -#include "envdep.h" /* environment dependent */ -#include "envind.h" /* environment independent */ - -#include "gen.h" /* general */ -#include "ssi.h" /* system services */ -#include "cm5.h" /* common timer defines */ -#include "cm_tkns.h" /* common tokens defines */ -#include "cm_mblk.h" /* common memory allocation library defines */ -#include "cm_llist.h" /* common link list defines */ -#include "cm_hash.h" /* common hash list defines */ -#include "cm_lte.h" /* common LTE defines */ -#include "cpj.h" /* UDX defines */ -#include "pju.h" /* PJU defines */ -#include "lpj.h" /* LPJ defines */ - -#include "pj_err.h" -#include "pj_env.h" /* RLC environment options */ -#include "pj.h" -#include "pj_ul.h" -#include "pj_udx.h" - -/* extern (.x) include files */ -#include "gen.x" /* general */ -#include "ssi.x" /* system services */ - -#include "cm5.x" /* common timer library */ -#include "cm_tkns.x" /* common tokens */ -#include "cm_mblk.x" /* common memory allocation */ -#include "cm_llist.x" /* common link list */ -#include "cm_hash.x" /* common hash list */ -#include "cm_lte.x" /* common LTE includes */ -#include "cm_lib.x" /* common memory allocation library */ -#include "cpj.x" /* UDX defines */ -#include "pju.x" /* PJU defines */ -#include "lpj.x" /* LPJ defines */ -#include "pj.x" -#include "pj_udx.h" -#include "pj_udx.x" -#include "pj_ul.x" - -PRIVATE S16 pjHdlCpjUlCfgReq ARGS((PjCb *gCb,PjCfgInfo *cfgInfo, - UdxCfgCfmInfo *cfmInfo, CpjCfgCfmInfo *cfgCfm, Bool *sndCfgCfm)); - - - -/** - * @brief - * UDX APIs - */ -/** - * - * @brief - * - * Handler for bind confirmation from DL. - * - * @b Description: - * - * This function handles the bind confirmation received - * from MAC. - * - * @param[in] pst Post structure - * @param[in] suId Service User ID - */ - - - -/**************************************************************************** - * UDX Interface Mt functions - ***************************************************************************/ -#ifdef ANSI -PUBLIC S16 PjUlUdxBndCfm -( -Pst * pst, -SuId suId, -U8 status -) -#else -PUBLIC S16 PjUlUdxBndCfm(pst, suId, status) -Pst * pst; -SuId suId; -U8 status; -#endif -{ - U16 event; /* Event */ - U16 cause; /* Cause */ - PjUdxUlSapCb *udxSap; /* RGU SAP Control Block */ - PjCb *tPjCb; - - TRC3(PjUlUdxBndCfm) - -#if (ERRCLASS & ERRCLS_INT_PAR) - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) - { - RETVALUE (RFAILED); - } -#endif - tPjCb = PJ_GET_PJCB(pst->dstInst); - -#ifdef DEBUGP - RLOG2(L_DEBUG, "PjUlUdxBndCfm(post, suId(%d), status(%d)", suId, status); -#endif - -#if (ERRCLASS & ERRCLS_INT_PAR) - if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE)) - { - /* INNC: ERROR CLASS */ - RLOG0(L_FATAL, "General configuration not done"); - PJ_SEND_SAPID_ALARM(tPjCb,suId, - LPJ_EVENT_LI_BND_CFM, LCM_CAUSE_INV_STATE); - - RETVALUE(RFAILED); - } - - if (suId < 0) - { - /* INNC: ERROR CLASS */ - RLOG0(L_ERROR, "Invalid suId"); - PJ_SEND_SAPID_ALARM(tPjCb,suId, - LPJ_EVENT_LI_BND_CFM, LCM_CAUSE_INV_SUID); - - RETVALUE(RFAILED); - } -#endif /* ERRCLASS & ERRCLS_INT_PAR */ - - udxSap = tPjCb->u.ulCb->udxUlSap + suId; - -#ifdef DEBUGP - RLOG1(L_DEBUG, "PjLiRguBndCfm: For RGU SAP state=%d", - udxSap->state); -#endif - - /* Check rguSap state */ - switch (udxSap->state) - { - case PJ_SAP_BINDING: - { - pjStopTmr (tPjCb,(PTR)udxSap, PJ_EVT_WAIT_UDX_BNDCFM); - - udxSap->retryCnt = 0; - - if (status == CM_BND_OK) - { - udxSap->state = PJ_SAP_BND; - event = LCM_EVENT_BND_OK; - cause = LPJ_CAUSE_SAP_BNDENB; - } - else - { - udxSap->state = PJ_SAP_CFG; - event = LCM_EVENT_BND_FAIL; - cause = LPJ_CAUSE_UNKNOWN; - } - } - break; - - default: - event = LPJ_EVENT_RGU_BND_CFM; - cause = LCM_CAUSE_INV_STATE; - break; - } - - /* Send an alarm with proper event and cause */ - /*PJ_SEND_SAPID_ALARM(tPjCb,suId, event, cause);*/ -#ifdef LTE_L2_MEAS - pjLmmSendAlarm(tPjCb,LCM_CATEGORY_INTERFACE, event, cause, suId, 0,0); -#else - pjLmmSendAlarm(tPjCb,LCM_CATEGORY_INTERFACE, event, cause, suId, 0); -#endif - - RETVALUE(ROK); -} - -#ifdef ANSI -PUBLIC S16 PjUlUdxCfgCfm -( -Pst * pst, -SuId suId, -UdxCfgCfmInfo * cfmInfo -) -#else -PUBLIC S16 PjUlUdxCfgCfm(pst, suId, cfmInfo) -Pst * pst; -SuId suId; -UdxCfgCfmInfo * cfmInfo; -#endif -{ - S16 ret; - PjCpjSapCb *cpjSap; - PjCb *tPjCb; - CpjCfgCfmInfo *cfgCfm; - Bool sndCfgCfm; - PjCfgInfo *cfgInfo; - - TRC3(PjUlUdxCfgCfm) - -#if (ERRCLASS & ERRCLS_INT_PAR) - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) - { - RETVALUE (RFAILED); - } -#endif - tPjCb = PJ_GET_PJCB(pst->dstInst); - -#ifdef DEBUGP - RLOG1(L_DEBUG, "PjUlUdxBndCfm(post, suId(%d), )", suId); -#endif - -#if (ERRCLASS & ERRCLS_INT_PAR) - if (suId < 0) - { - /* INNC: ERROR CLASS */ - RLOG0(L_ERROR, "Invalid suId"); - PJ_SEND_SAPID_ALARM(tPjCb,suId, - LPJ_EVENT_LI_BND_CFM, LCM_CAUSE_INV_SUID); - - RETVALUE(RFAILED); - } -#endif /* ERRCLASS & ERRCLS_INT_PAR */ - - ret = pjDbmFindUlTransIdLst(tPjCb,cfmInfo->transId, &cfgInfo); - if (ret != ROK) - { - RLOG0(L_ERROR, "Invalid transId"); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,cfmInfo, sizeof (UdxCfgCfmInfo)); - RETVALUE (RFAILED); - } - /* Allocate memory and memset to 0 for cfmInfo */ - cpjSap = &(tPjCb->u.ulCb->cpjSap); - if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,(Data **)&cfgCfm, - sizeof (CpjCfgCfmInfo)) != ROK) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - /* pj002.201 Freeing from proper region */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,cfmInfo, sizeof (UdxCfgCfmInfo)); - PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgInfo->cfgInfo, sizeof(CpjCfgReqInfo)); - PJ_FREE(tPjCb,cfgInfo,sizeof(PjCfgInfo)); - RETVALUE(RFAILED); - } - - sndCfgCfm = TRUE; - ret = pjHdlCpjUlCfgReq(tPjCb,cfgInfo, cfmInfo, cfgCfm, &sndCfgCfm); -/* AGHOSH */ - /* Free the cfg confirm allocated from DL, this should actually - be a sharable buffer and not a static buffer */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,cfmInfo, sizeof (UdxCfgCfmInfo)); - PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgInfo->cfgInfo, sizeof(CpjCfgReqInfo)); - PJ_FREE(tPjCb,cfgInfo,sizeof(PjCfgInfo)); -/* AGHOSH */ - - if (sndCfgCfm) - { - cpjSap = &(tPjCb->u.ulCb->cpjSap); - - PjUiCpjCfgCfm(&(cpjSap->pst), cpjSap->suId, cfgCfm); - } - - - RETVALUE(ROK); -} - -#ifdef ANSI -PUBLIC S16 PjUlUdxReEstCfm -( -Pst *pst, -SuId suId, -UdxReEstCfmInfo *reEstCfm -) -#else -PUBLIC S16 PjUlUdxReEstCfm(pst, suId, reEstCfm) -Pst *pst; -SuId suId; -UdxReEstCfmInfo *reEstCfm; -#endif -{ - S16 ret; - PjCpjSapCb *cpjSap; - PjCb *tPjCb; - PjCfgInfo *cfgInfo; - CpjReEstCfmInfo *cpjReEstCfm; - - TRC3(PjUlUdxReEstCfm) - -#if (ERRCLASS & ERRCLS_INT_PAR) - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) - { - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,reEstCfm, sizeof (UdxReEstCfmInfo)); - - RETVALUE (RFAILED); - } -#endif - tPjCb = PJ_GET_PJCB(pst->dstInst); - -#ifdef DEBUGP - RLOG1(L_DEBUG, "PjUlUdxReEstCfm(post, suId(%d), ", suId); -#endif - -#if (ERRCLASS & ERRCLS_INT_PAR) - if (suId < 0) - { - /* INNC: ERROR CLASS */ - RLOG0(L_ERROR, "Invalid suId"); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,reEstCfm, sizeof (UdxReEstCfmInfo)); - RETVALUE(RFAILED); - } -#endif /* ERRCLASS & ERRCLS_INT_PAR */ - - ret = pjDbmFindUlTransIdLst(tPjCb, reEstCfm->transId, &cfgInfo); - if (ret != ROK) - { - RLOG0(L_ERROR, "Invalid transId"); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,reEstCfm, sizeof (UdxReEstCfmInfo)); - RETVALUE (RFAILED); - } - - ret = ROK; - - cpjSap = &(tPjCb->u.ulCb->cpjSap); - if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,(Data **)&cpjReEstCfm, - sizeof (CpjReEstCfmInfo)) != ROK) - { - /* Free memory for CfgReqInfo */ - /* kw002.201 Freeing from proper region */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,reEstCfm, sizeof (UdxReEstCfmInfo)); - PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgInfo->reEstReq, sizeof(CpjReEstReqInfo)); - PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo)); - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } - - cpjReEstCfm->ueId = cfgInfo->reEstReq->pdcpId.ueId; - cpjReEstCfm->cellId = cfgInfo->reEstReq->pdcpId.cellId; - /* Assign number of entity configuraitons and suId */ - cpjReEstCfm->transId = cfgInfo->uprLyrTransId; - cpjReEstCfm->status = reEstCfm->status; - - if (CPJ_CFG_CFM_OK == reEstCfm->status) - { - /* handle ReEstablish here */ - pjCfgUlReEstReq(tPjCb, cfgInfo->reEstReq, cpjReEstCfm); - } - -#ifndef PJ_ASYNC_CFM - PjUiCpjReEstCfm(&(cpjSap->pst), cpjSap->suId, cpjReEstCfm); -#endif - /* Configuration information needs to be freed from proper region */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,reEstCfm, sizeof (UdxReEstCfmInfo)); - PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgInfo->reEstReq, sizeof(CpjReEstReqInfo)); - PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo)); - - RETVALUE(ROK); -} - - - -#ifdef ANSI -PUBLIC S16 PjUlUdxSecCfgCfm -( -Pst * pst, -SuId suId, -UdxSecCfgCfmInfo * secCfgCfm -) -#else -PUBLIC S16 PjUlUdxSecCfgCfm(pst, suId, secCfgCfm) -Pst * pst; -SuId suId; -UdxSecCfgCfmInfo * secCfgCfm; -#endif -{ - S16 ret; - CpjSecCfgCfmInfo *cfgCfm; /* Security Cfg Confirm structure */ - PjCpjSapCb *cpjSap; - PjCb *tPjCb; - PjCfgInfo *cfgInfo; - CpjSecCfgReqInfo *secCfg; -#ifdef PJ_SEC_ASYNC - PjUlUeCb *ueCb = NULLP; -#endif - - TRC3(PjUlUdxSecCfgCfm) - -#if (ERRCLASS & ERRCLS_INT_PAR) - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) - { - RETVALUE (RFAILED); - } -#endif - tPjCb = PJ_GET_PJCB(pst->dstInst); - -#ifdef DEBUGP - RLOG1(L_DEBUG, "PjUlUdxUeIdChgCfm(post, suId(%d), ", suId); -#endif - -#if (ERRCLASS & ERRCLS_INT_PAR) - if (suId < 0) - { - /* INNC: ERROR CLASS */ - RLOG0(L_ERROR, "Invalid suId"); - RETVALUE(RFAILED); - } -#endif /* ERRCLASS & ERRCLS_INT_PAR */ - - cpjSap = &(tPjCb->u.ulCb->cpjSap); - - ret = pjDbmFindUlTransIdLst(tPjCb,secCfgCfm->transId, &cfgInfo); - if (ret != ROK) - { - RLOG0(L_ERROR, "Invalid transId"); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,secCfgCfm, sizeof (UdxSecCfgCfmInfo)); - RETVALUE (RFAILED); - } - - secCfg = cfgInfo->secCfgInfo; - - - if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,(Data **)&cfgCfm, - sizeof (CpjSecCfgCfmInfo)) != ROK) - { - /* Free memory for CfgReqInfo */ - /* kw002.201 Freeing from proper region */ - PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, secCfg, sizeof(CpjSecCfgReqInfo)); - PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo)); - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } - - if ( pjCfgPrcSecUlCfg(tPjCb,secCfg,cfgCfm) != ROK ) - { - RLOG_ARG2(L_ERROR,DBG_UEID,secCfg->ueId, - "PjUiCpjSecCfgReq cellId(%d) pjCfgSecCfg Failed: reason (%d)", - secCfg->cellId, cfgCfm->reason); - - } - else - { - if (secCfgCfm->status != CPJ_CFG_CFM_OK) - { - PJ_MEM_CPY(cfgCfm, secCfgCfm, sizeof (CpjSecCfgCfmInfo)); - } - } - - cfgCfm->transId = cfgInfo->uprLyrTransId; -#ifdef PJ_SEC_ASYNC - ret = pjDbmFetchUlUeCb(tPjCb,secCfg->ueId, secCfg->cellId, &ueCb); - if ( ueCb != NULLP ) - { - pjUtlUlSaveCfmInfo(tPjCb, ueCb, PJ_SEC_ASYNC_CFM, TRUE, ENTPJ, (PTR)cfgCfm, NULLP); - PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgCfm, sizeof(CpjSecCfgCfmInfo)); - } - else - { - RLOG_ARG1(L_ERROR, DBG_CELLID, secCfg->cellId,"UeId[%u] not found", - secCfg->ueId); - PjUiCpjSecCfgCfm(&(cpjSap->pst), cpjSap->suId, cfgCfm); - } -#else - PjUiCpjSecCfgCfm(&(cpjSap->pst), cpjSap->suId, cfgCfm); -#endif - - /* Configuration information needs to be freed from proper region */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,secCfgCfm, sizeof (UdxSecCfgCfmInfo)); - PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, secCfg, sizeof(CpjSecCfgReqInfo)); - PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo)); - - RETVALUE(ROK); -} - -#ifdef ANSI -PUBLIC S16 PjUlUdxUeIdChgCfm -( -Pst * pst, -SuId suId, -U32 transId, -UdxUeInfo * ueInfo, -CmStatus status -) -#else -PUBLIC S16 PjUlUdxUeIdChgCfm(pst, suId, transId, ueInfo, status) -Pst * pst; -SuId suId; -U32 transId; -UdxUeInfo * ueInfo; -CmStatus status; -#endif -{ - S16 ret; - CmStatus tStatus; - PjCpjSapCb *cpjSap; - PjCb *tPjCb; - PjCfgInfo *cfgInfo; - - TRC3(PjUlUdxUeIdChgCfm) - -#if (ERRCLASS & ERRCLS_INT_PAR) - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) - { - RETVALUE (RFAILED); - } -#endif - tPjCb = PJ_GET_PJCB(pst->dstInst); - -#ifdef DEBUGP - RLOG1(L_DEBUG, "PjUlUdxUeIdChgCfm(post, suId(%d), ", suId); -#endif - -#if (ERRCLASS & ERRCLS_INT_PAR) - if (suId < 0) - { - /* INNC: ERROR CLASS */ - RLOG0(L_ERROR, "Invalid suId"); - RETVALUE(RFAILED); - } -#endif /* ERRCLASS & ERRCLS_INT_PAR */ - - ret = pjDbmFindUlTransIdLst(tPjCb, transId, &cfgInfo); - if (ret != ROK) - { - RLOG0(L_ERROR, "Invalid transId"); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,ueInfo, sizeof (UdxUeInfo)); - RETVALUE (RFAILED); - } - - ret = ROK; - tStatus.reason = CPJ_CFG_REAS_NONE; - tStatus.status = CPJ_CFG_CFM_OK; - - if ( (ret = pjCfgUlUeIdChng(tPjCb,cfgInfo->ueInfo, - cfgInfo->newUeInfo, &tStatus)) != ROK) - { -#ifdef DEBUGP - RLOG_ARG4(L_ERROR,DBG_UEID,cfgInfo->ueInfo->ueId, "Cpj UeId Chg Req" - " old-ueId(%d), new-ueId(%d), cellId(%d))Failed: reason (%d)", - cfgInfo->ueInfo->ueId, cfgInfo->newUeInfo->ueId, - cfgInfo->newUeInfo->cellId, status.reason); -#endif - } - - cpjSap = &(tPjCb->u.ulCb->cpjSap); - - if ((status.status == CPJ_CFG_CFM_OK) || - (tStatus.status == CPJ_CFG_CFM_OK)) - { - tStatus.reason = CPJ_CFG_REAS_NONE; - tStatus.status = CPJ_CFG_CFM_OK; - } - - PjUiCpjUeIdChgCfm(&cpjSap->pst,cpjSap->suId,cfgInfo->uprLyrTransId,(CpjUeInfo *)ueInfo,tStatus); - - /* Free the buffers allocated before returning */ - PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgInfo->ueInfo, sizeof(CpjUeInfo)); - PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgInfo->newUeInfo, sizeof(CpjUeInfo)); - PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo)); - - - RETVALUE(ROK); -} - -#ifdef ANSI -PUBLIC S16 PjUlUdxCountCfm -( -Pst * pst, -SuId suId, -UdxCountCfmInfo *cntCfm -) -#else -PUBLIC S16 PjUlUdxCountCfm(pst, suId, cntCfm) -Pst * pst; -SuId suId; -UdxCountCfmInfo *cntCfm; -#endif -{ - - S16 ret; - PjCpjSapCb *cpjSap; - PjCb *tPjCb; - PjCfgInfo *cfgInfo; - CpjCountReqInfo *countReq = NULLP; - CpjCountCfmInfo *countCfm = NULLP; - - TRC3(PjUlUdxCountCfm) - -#if (ERRCLASS & ERRCLS_INT_PAR) - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) - { - RETVALUE (RFAILED); - } -#endif - tPjCb = PJ_GET_PJCB(pst->dstInst); - -#ifdef DEBUGP - RLOG1(L_DEBUG, "PjUlUdxUeIdChgCfm(post, suId(%d), ", suId); -#endif - -#if (ERRCLASS & ERRCLS_INT_PAR) - if (suId < 0) - { - /* INNC: ERROR CLASS */ - RLOG0(L_ERROR, "Invalid suId"); - RETVALUE(RFAILED); - } -#endif /* ERRCLASS & ERRCLS_INT_PAR */ - - ret = pjDbmFindUlTransIdLst(tPjCb, cntCfm->transId, &cfgInfo); - if (ret != ROK) - { - RLOG0(L_ERROR, "Invalid transId"); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,cntCfm, sizeof (UdxCountCfmInfo)); - RETVALUE (RFAILED); - } - cpjSap = &tPjCb->u.ulCb->cpjSap; - countReq = cfgInfo->cntReq; - if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,(Data **)&countCfm, - sizeof (CpjCountCfmInfo)) != ROK) - { - /* Free memory for CfgReqInfo */ - /* kw002.201 Freeing from proper region */ - /* ccpu00136902 */ - /* PJ_PST_FREE(pst->region, pst->pool, countReq, sizeof(CpjCountReqInfo)); */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,cntCfm, sizeof (UdxCountCfmInfo)); - PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, countReq, sizeof(CpjCountReqInfo)); - PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo)); /*MEM_LEAK_FIX */ - RLOG0(L_FATAL, "Memory Allocation failed."); - - RETVALUE(RFAILED); - } - PJ_MEM_CPY(countCfm, cntCfm, sizeof(CpjCountCfmInfo)); /* KW_FIX */ - if ( pjCfgPrcUlCount(tPjCb, countReq, countCfm, cntCfm) != ROK ) - { - RLOG_ARG2(L_ERROR,DBG_UEID,countReq->ueId, - "PjUiCpjCountReq cellId(%d) pjCfgSecCfg Failed: reason (%d)", - countReq->cellId, countCfm->reason); - - } - - countCfm->transId = cfgInfo->uprLyrTransId; - /* Ned to consolidate confirms */ - /* Freeing from proper region */ - - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,cntCfm, sizeof (UdxCountCfmInfo)); - PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, countReq, sizeof(CpjCountReqInfo)); - PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo)); /*MEM_LEAK_FIX */ - - - PjUiCpjCountCfm(&(cpjSap->pst), cpjSap->suId,countCfm); - - RETVALUE(ROK); -} - -#ifdef ANSI -PUBLIC S16 PjUlUdxSduStaCfm -( -Pst *pst, -SuId suId, -UdxSduStaCfmInfo *staCfm -) -#else -PUBLIC S16 PjUlUdxSduStaCfm(pst, suId, staCfm) -Pst *pst; -SuId suId; -UdxSduStaCfmInfo *staCfm; -#endif -{ - S16 ret; - PjCpjSapCb *cpjSap; - PjCb *tPjCb; - PjCfgInfo *cfgInfo; - CpjSduStaReqInfo *staReq; - CpjSduStaCfmInfo *sduStaCfm; - - TRC3(PjUlUdxSduStaCfm) - -#if (ERRCLASS & ERRCLS_INT_PAR) - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) - { - RETVALUE (RFAILED); - } -#endif - tPjCb = PJ_GET_PJCB(pst->dstInst); - -#ifdef DEBUGP - RLOG1(L_DEBUG, "PjUlUdxSduStaCfm(post, suId(%d), ", suId); -#endif - -#if (ERRCLASS & ERRCLS_INT_PAR) - if (suId < 0) - { - /* INNC: ERROR CLASS */ - RLOG0(L_ERROR, "Invalid suId"); - RETVALUE(RFAILED); - } -#endif /* ERRCLASS & ERRCLS_INT_PAR */ - - cpjSap = &(tPjCb->u.ulCb->cpjSap); - ret = pjDbmFindUlTransIdLst(tPjCb, staCfm->transId, &cfgInfo); - if (ret != ROK) - { - RLOG0(L_ERROR, "Invalid transId"); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,staCfm, sizeof (UdxSduStaCfmInfo)); - RETVALUE (RFAILED); - } - - staReq = cfgInfo->staReq; - - if (ROK == staCfm->status) - { - if (pjCfgPrcUlSduSta(tPjCb, staReq, staCfm) != ROK ) - { - RLOG_ARG1(L_ERROR,DBG_UEID,staReq->ueId, - "PjUlUdxSduStaReq ,cellId(%d) pjCfgSecCfg Failed",staReq->cellId); - /* Memory leak fix ccpu00135359 */ - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,staCfm, sizeof (UdxSduStaCfmInfo)); - ret = RFAILED; - } - } - else - { - /* Memory leak fix ccpu00135359 */ - if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,(Data **)&sduStaCfm, - sizeof (CpjSduStaCfmInfo)) != ROK) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,staCfm, sizeof (UdxSduStaCfmInfo)); - PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgInfo->staReq, sizeof(CpjSduStaReqInfo)); - PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo)); - RETVALUE(RFAILED); - } - sduStaCfm->ueId = staCfm->ueId; - sduStaCfm->cellId = staCfm->cellId; - sduStaCfm->transId = cfgInfo->uprLyrTransId; - sduStaCfm->status = RFAILED; - sduStaCfm->reason = staCfm->reason; - sduStaCfm->numRb = staCfm->numRb; - - RLOG_ARG1(L_DEBUG,DBG_UEID,staCfm->ueId, - "PjUlUdxSduStaCfm- UdxSduStaCfm fail - cellId(%d)",staCfm->cellId); - - PjUiCpjSduStaCfm(&(cpjSap->pst), cpjSap->suId, sduStaCfm); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,staCfm, sizeof (UdxSduStaCfmInfo)); - } - - PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgInfo->staReq, sizeof(CpjSduStaReqInfo)); - PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo)); - - RETVALUE(ROK); -} - -#ifdef ANSI -PUBLIC S16 PjUlUdxDatResumeCfm -( -Pst *pst, -SuId suId, -UdxDatResumeCfmInfo *udxDatResumeCfm -) -#else -PUBLIC S16 PjUlUdxDatResumeCfm(pst, suId, udxDatResumeCfm) -Pst *pst; -SuId suId; -UdxDatResumeCfmInfo *udxDatResumeCfm; -#endif -{ - S16 ret; - PjCpjSapCb *cpjSap; - PjCb *tPjCb; - PjCfgInfo *cfgInfo; - CpjDatResumeReqInfo *datResReq; - CpjDatResumeCfmInfo *datResumeCfmInfo; - - TRC3(PjUlUdxDatResumeCfm) - -#if (ERRCLASS & ERRCLS_INT_PAR) - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) - { - RETVALUE (RFAILED); - } -#endif - tPjCb = PJ_GET_PJCB(pst->dstInst); - -#ifdef DEBUGP - RLOG1(L_DEBUG, "PjUlUdxDatResumeCfm(post, suId(%d), ", suId); -#endif - -#if (ERRCLASS & ERRCLS_INT_PAR) - if (suId < 0) - { - /* INNC: ERROR CLASS */ - RLOG0(L_ERROR, "Invalid suId"); - RETVALUE(RFAILED); - } -#endif /* ERRCLASS & ERRCLS_INT_PAR */ - - ret = pjDbmFindUlTransIdLst(tPjCb, udxDatResumeCfm->transId, &cfgInfo); - if (ret != ROK) - { - RLOG0(L_ERROR, "Invalid transId"); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,udxDatResumeCfm, sizeof (UdxDatResumeCfmInfo)); - RETVALUE (RFAILED); - } - - datResReq = cfgInfo->datResReq; - - pjUtlUlPrcsDatResume (tPjCb, datResReq); - - - /* Perform processing for filling up cfm structures */ - cpjSap = &(tPjCb->u.ulCb->cpjSap); - if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,(Data **)&datResumeCfmInfo, - sizeof (CpjDatResumeCfmInfo)) != ROK) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,udxDatResumeCfm, sizeof (UdxDatResumeCfmInfo)); - PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgInfo->datResReq, sizeof(CpjDatResumeReqInfo)); - PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo)); - RETVALUE(RFAILED); - } - datResumeCfmInfo->ueId = datResReq->ueId; - datResumeCfmInfo->cellId = datResReq->cellId; - datResumeCfmInfo->transId = datResReq->transId; - datResumeCfmInfo->status = CPJ_CFG_CFM_OK; - PjUiCpjDatResumeCfm(&(cpjSap->pst), cpjSap->suId, datResumeCfmInfo); - - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool,udxDatResumeCfm, sizeof (UdxDatResumeCfmInfo)); - PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgInfo->datResReq, sizeof(CpjDatResumeReqInfo)); - PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo)); - - RETVALUE(ROK); -} - -/** - * @brief - * This function processes Data Forwarding Confirm received from DL. - * - * Now the UL Module can start forwardng the UL Packets is Application - * has requested for UL Data Forwarding. - * - * @param[in] pst post structure - * @param[in] measType meas Type - * @return S16 - * -# Success : ROK - * -# Failure : RFAILED - */ -#ifdef ANSI -PUBLIC S16 PjUlUdxDatForwardCfm -( - Pst *pst, - SuId suId, - UdxDatFwdCfmInfo *datFwdCfm - ) -#else -PUBLIC S16 PjUlUdxDatForwardCfm(pst, suId, datFwdCfm) - Pst *pst; - SuId suId; - UdxDatFwdCfmInfo *datFwdCfm; -#endif -{ - PjCb *tPjCb; - PjUlUeCb *ueCb; - PjUlRbCb *pjRbCb; - S16 ret; - U8 rbCnt = 0; - - tPjCb = PJ_GET_PJCB(pst->dstInst); - - ret = pjDbmFetchUlUeCb(tPjCb,datFwdCfm->ueId, - datFwdCfm->cellId, &ueCb); - - /* Ue Cb is not present */ - if( ROK != ret || NULLP == ueCb) - { - RLOG_ARG1(L_ERROR, DBG_CELLID, datFwdCfm->cellId,"UeId[%u] not found", - datFwdCfm->ueId); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datFwdCfm, sizeof(UdxDatFwdCfmInfo)); - RETVALUE(ret); - } - - /* Forward UL Packets only if Application has requested */ - if(ueCb->isUlDatFwdReqd == TRUE) - { - /* Call the UL Pkt Fwd Func for each Rab */ - for(rbCnt = 0; rbCnt < PJ_MAX_DRB_PER_UE; rbCnt++) - { - if((pjRbCb = ueCb->drbCb[rbCnt]) == NULLP) - { - continue; - } - /* UL Data Forwarding done only for AM Mode Bearers - * datQ is in Buffer State and only during Handover */ - if((pjRbCb->mode == PJ_DRB_AM) && (ueCb->libInfo.state == PJ_STATE_REEST_HO)) - { - pjUlmStartDataFrwdPerRb(tPjCb, pjRbCb); - } - } - } - - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, datFwdCfm, sizeof(UdxDatFwdCfmInfo)); - RETVALUE(ROK); -} - - -/** - * - * @brief - * - * Handler for Configuration Request on UL - * - * @b Description: - * - * This function handles the configuration on UL after receiving - * the configuration confirm from DL. - * - * @param[in] gCb PDCP Instance Control block - * @param[in] cfgInfo UL Configuration Info - * @param[in] cfmInfo Configuration Confirm Info - * @param[in] cfgCfm Configuration Confirm Info - * @param[in] sndCfgCfm Configuration Confirm Info - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ - -#ifdef ANSI -PRIVATE S16 pjHdlCpjUlCfgReq -( -PjCb *gCb, -PjCfgInfo *cfgInfo, -UdxCfgCfmInfo *cfmInfo, -CpjCfgCfmInfo *cfgCfm, -Bool *sndCfgCfm -) -#else -PRIVATE S16 pjHdlCpjUlCfgReq(gCb, cfgInfo, cfmInfo, cfgCfm, sndCfgCfm) -PjCb *gCb; -PjCfgInfo *cfgInfo; -UdxCfgCfmInfo *cfmInfo; -CpjCfgCfmInfo *cfgCfm; -Bool *sndCfgCfm; -#endif -{ - CpjCfgReqInfo *cfg; - U8 idx; - Bool cfmType = 0; - Bool startTmr; - PjUlUeCb *ueCb; /* UE Control Block for storing the - cfg structure in case of ReEstablishment */ - PjCpjSapCb *cpjSap; - - cfg = cfgInfo->cfgInfo; - startTmr = FALSE; - ueCb = NULLP; - - /* Fetch UeCb */ - pjDbmFetchUlUeCb(gCb, cfg->ueId, cfg->cellId, &ueCb); - /* KW_FIX : CPJ_MAX_CFG,CPJ_MAX_CFM,UDX_MAX_CFM have the same value , hence checking for only one of them */ - for (idx = 0; idx < cfg->numEnt && idx < CPJ_MAX_CFG; idx++) - { - CpjCfmEnt *entCfgCfm; - UdxCfmEnt *entDlCfgCfm; - CpjCfgEnt *entCfg; - - entCfg = &(cfg->cfgEnt[idx]); - entCfgCfm = &(cfgCfm->cfmEnt[idx]); - entDlCfgCfm = &(cfmInfo->cfmEnt[idx]); - - if (NULL != ueCb) - { - /* Fill the detault values here */ - PJ_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType, - CPJ_CFG_CFM_OK,CPJ_CFG_REAS_NONE); - } - else - { - RLOG_ARG1(L_INFO, DBG_CELLID, cfg->cellId,"UeId[%u] not found", - cfg->ueId); - PJ_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType, - CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_UE_UNKWN); - if (entCfg->cfgType != CPJ_CFG_ADD) - { - /* all other requests require ueCb mandatorily */ - continue; - } - } - - switch (entCfg->cfgType) - { - case CPJ_CFG_ADD: - { - if (entCfg->m.addCfg.rlcInfo.dir & PJ_DIR_UL) - { - U8 isHo; - isHo = cfg->isHo; - /* Add a new RB entity configuration */ - if (pjCfgAddUlRb(gCb,cfg->ueId, cfg->cellId, isHo, - entCfg, &ueCb, entCfgCfm) != ROK) - { -#ifdef DEBUGP - RLOG_ARG3(L_ERROR,DBG_UEID,cfg->ueId,"UL RB Addition for" - "cellId(%d),rbId(%d) Failed: reason (%d)", - cfg->cellId, cfg->cfgEnt[idx].rbId, entCfgCfm->reason); -#endif - PJ_CFG_FILL_CFG_CFM(entCfgCfm,entCfg->rbId,entCfg->rbType, - CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_UE_UNKWN); - } - /* Only In case of DRB only we need to set this flag */ -#ifdef PJ_CMP_ASYNC - else if(PJ_DRB == entCfg->rbType) - { - if(entCfg->m.addCfg.hdrCompCfg.hdrCompUsed) - { - cfmType |= PJ_CFG_ASYNC_CFM; - startTmr = TRUE; - } - } -#endif /* PJ_CMP_ASYNC */ - if (entCfg->m.addCfg.rlcInfo.dir & PJ_DIR_DL) - { - if (entDlCfgCfm->status != CPJ_CFG_CFM_OK) - { - PJ_MEM_CPY(entCfgCfm, entDlCfgCfm, - sizeof(CpjCfmEnt)); /* KW_FIX */ - } - } - } - else if (entCfg->m.addCfg.rlcInfo.dir & PJ_DIR_DL) - { - PJ_MEM_CPY(entCfgCfm, entDlCfgCfm, sizeof(CpjCfmEnt)); /* KW_FIX */ - } - break; - } - - case CPJ_CFG_MODIFY: - { - if ((entCfg->m.modCfg.bitFlag & 0x01) || - (entCfg->m.modCfg.hoInfo.isHoPres & CPJ_HO_UL)) - { - /* Re-configure the existing RB entity configuration */ - if (pjCfgReCfgUlRb(gCb,ueCb, entCfg, entCfgCfm) != ROK) - { -#ifdef DEBUGP - RLOG_ARG3(L_ERROR,DBG_UEID,cfg->ueId,"RB Config Modify HO" - "for cellId(%d), rbId(%d) Failed :reason (%d)", - cfg->cellId, cfg->cfgEnt[idx].rbId, entCfgCfm->reason); -#endif - } -#ifdef PJ_CMP_ASYNC - else if(PJ_DRB == entCfg->rbType) - { - if(entCfg->m.modCfg.hdrCompCfg.hdrCompUsed) - { - cfmType |= PJ_CFG_ASYNC_CFM; - startTmr = TRUE; - } - } -#endif /* PJ_CMP_ASYNC */ - if ((entCfg->m.modCfg.bitFlag & 0x02) || - (entCfg->m.modCfg.hdrCompCfg.hdrCompUsed) || - (entCfg->m.modCfg.hoInfo.isHoPres & CPJ_HO_DL)) - { - if (entDlCfgCfm->status != CPJ_CFG_CFM_OK) - { - PJ_MEM_CPY(entCfgCfm, entDlCfgCfm, - sizeof(CpjCfmEnt)); - } - } - } - else if (entCfg->m.modCfg.hdrCompCfg.hdrCompUsed) - { - /* Re-configure the existing RB entity configuration */ - if (pjCfgReCfgUlRb(gCb,ueCb, entCfg, entCfgCfm) != ROK) - { -#ifdef DEBUGP - RLOG_ARG3(L_ERROR,DBG_UEID,cfg->ueId,"UL RB Modify Normal" - " for cellId(%d), rbId(%d) Failed: reason (%d)", - cfg->cellId, cfg->cfgEnt[idx].rbId, entCfgCfm->reason); -#endif - if (entCfgCfm->reason == CPJ_CFG_REAS_PDCPID_UNKWN) - { - PJ_MEM_CPY(entCfgCfm, entDlCfgCfm,sizeof(CpjCfmEnt)); - } - } -#ifdef PJ_CMP_ASYNC - else if(PJ_DRB == entCfg->rbType) - { - if(entCfg->m.modCfg.hdrCompCfg.hdrCompUsed) - { - cfmType |= PJ_CFG_ASYNC_CFM; - startTmr = TRUE; - } - } -#endif /* PJ_CMP_ASYNC */ - - if ((entDlCfgCfm->reason != CPJ_CFG_REAS_PDCPID_UNKWN) && - (entDlCfgCfm->status != CPJ_CFG_CFM_OK)) - { - /* send configuration to DL instance */ - PJ_MEM_CPY(entCfgCfm, entDlCfgCfm,sizeof(CpjCfmEnt)); /* KW_FIX */ - } - } - else if ((entCfg->m.modCfg.bitFlag & 0x02) || - (entCfg->m.modCfg.hoInfo.isHoPres & CPJ_HO_DL)) - { - /* send configuration to DL instance */ - PJ_MEM_CPY(entCfgCfm, entDlCfgCfm,sizeof(CpjCfmEnt)); /* KW_FIX */ - } - break; - } - case CPJ_CFG_DELETE: - { - /* Delete the existing RB entity configuration */ - if (pjCfgDelUlRb(gCb,ueCb,entCfg, entCfgCfm) != ROK) - { -#ifdef DEBUGP - RLOG_ARG3(L_ERROR,DBG_UEID,cfg->ueId, "Ul RB Delete for" - "cellId(%d), rbId(%d) Failed: reason (%d)", - cfg->cellId, cfg->cfgEnt[idx].rbId, entCfgCfm->reason); -#endif - } - if ((entDlCfgCfm->status != CPJ_CFG_CFM_OK) || (entCfgCfm->status != CPJ_CFG_CFM_OK)) - { - PJ_MEM_CPY(entCfgCfm, entDlCfgCfm, - sizeof(CpjCfmEnt)); /* KW_FIX */ - } - break; - } - - case CPJ_CFG_REESTABLISH: - { - /* Re-establish the existing RB entity configuration */ - if (pjCfgReEstUlRb(gCb,ueCb,entCfg, entCfgCfm, entDlCfgCfm) != ROK) - { - RLOG_ARG3(L_ERROR,DBG_UEID,cfg->ueId, "UL RB Re-establish " - "for cellId(%d), rbId(%d) Failed: reason (%d)", - cfg->cellId, cfg->cfgEnt[idx].rbId, entCfgCfm->reason); - - } - else - { - cfmType |= PJ_CFG_REEST_ASYNC_CFM; - startTmr = FALSE; - } - - break; - } - case CPJ_CFG_DELETE_UE: - { - /* Delete all RB entity configuration under UE */ - if (pjCfgDelUlUe(gCb,ueCb,entCfg, entCfgCfm) != ROK) - { -#ifdef DEBUGP - RLOG_ARG3(L_ERROR,DBG_UEID,cfg->ueId, "UL UE Delete for " - "cellId(%d), rbId(%d) Failed: reason (%d)", - cfg->cellId, cfg->cfgEnt[idx].rbId, entCfgCfm->reason); -#endif - } -#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)) - else - { - /* Wait for any messages in the Demand q to be processed */ - cfmType |= PJ_CFG_UEDEL_ASYNC_CFM; - startTmr = TRUE; - } -#endif /* (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)) */ - if (entDlCfgCfm->status == CPJ_CFG_CFM_OK) - { - PJ_MEM_CPY(entCfgCfm, entDlCfgCfm, - sizeof(CpjCfmEnt)); /* KW_FIX */ - } - break; - } - default: - { - PJ_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType, - CPJ_CFG_CFM_NOK, CPJ_CFG_REAS_INVALID_CFG); - -#ifdef DEBUGP - RLOG_ARG4(L_ERROR,DBG_UEID,cfg->ueId, "Cfg Req with Invalid Cfg" - "Type cellId(%d), cfgType(%d), rbId(%d)) Failed: reason (%d)", - cfg->cellId, entCfg->cfgType, - cfg->cfgEnt[idx].rbId, CPJ_CFG_REAS_INVALID_CFG); -#endif - } - } - /* ccpu00137221 : KW Fix */ - if (NULLP == ueCb) - { - PJ_CFG_FILL_CFG_CFM(entCfgCfm, entCfg->rbId, entCfg->rbType, - CPJ_CFG_CFM_NOK,CPJ_CFG_REAS_UE_UNKWN); - } - } - - /* Assign number of entity configuraitons and suId */ - cfgCfm->transId = cfgInfo->uprLyrTransId; - cfgCfm->ueId = cfg->ueId; - cfgCfm->cellId = cfg->cellId; - cfgCfm->numEnt = cfg->numEnt; - /* ccpu00137221 : KW Fix */ - if (NULLP == ueCb) - { - RETVALUE(ROK); - } - - if (cfmType & PJ_CFG_REEST_ASYNC_CFM) - { - if (ueCb->libInfo.numReEstCmp > 0) - { - if (ueCb->libInfo.numReEstCmp > ueCb->libInfo.numReEstDrb) - { - /* Error Case */ - ueCb->libInfo.numReEstDrb = 0; - ueCb->libInfo.numReEstCmp = 0; - } - else - { - ueCb->libInfo.numReEstDrb -= ueCb->libInfo.numReEstCmp; - ueCb->libInfo.numReEstCmp = 0; - } - } - if (ueCb->libInfo.numReEstDrb == 0) - { -#ifdef PJ_ASYNC_CFM - pjUtlUlSaveCfmInfo(gCb, ueCb, cfmType, startTmr, ENTPJ, (PTR)cfgCfm, (PTR)cfg); -#endif - pjUtlUlUpdUpSecKeys(gCb, ueCb); -#ifdef PJ_ASYNC_CFM - /* Memory leak fix ccpu00135359 */ - cpjSap = &(tPjCb->u.ulCb->cpjSap); - PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgCfm, sizeof(CpjCfgCfmInfo)); - *sndCfgCfm = FALSE; -#endif - } - else - { - pjUtlUlSaveCfmInfo(gCb, ueCb, cfmType, startTmr, ENTPJ, (PTR)cfgCfm, (PTR)cfg); - cpjSap = &(gCb->u.ulCb->cpjSap); - PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgCfm, sizeof(CpjCfgCfmInfo)); - *sndCfgCfm = FALSE; - } - } - else - { - if (cfmType != 0) - { - pjUtlUlSaveCfmInfo(gCb, ueCb, cfmType, startTmr, ENTPJ, (PTR)cfgCfm, (PTR)cfg); - /* Memory leak fix ccpu00135359 */ - cpjSap = &(gCb->u.ulCb->cpjSap); - PJ_PST_FREE(cpjSap->pst.region, cpjSap->pst.pool, cfgCfm, sizeof(CpjCfgCfmInfo)); - *sndCfgCfm = FALSE; - } - } - - RETVALUE(ROK); -} - - -/********************************************************************30** - End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_uim.c b/src/5gnrpdcp/pj_uim.c deleted file mode 100755 index 965e1fa54..000000000 --- a/src/5gnrpdcp/pj_uim.c +++ /dev/null @@ -1,2101 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: LTE-PDCP Layer - Upper Interface Functions - - Type: C file - - Desc: Source code for PDCP Upper Interface Module - This file contains following functions - - --PjUiCpjBndReq - --PjUiCpjUbndReq - --PjUiCpjCfgReq - --PjUiCpjUeIdChgReq - --PjUiCpjReEstReq - --PjUiCpjSecCfgReq - --PjUiCpjSduStaReq - - - --PjUiPjuBndReq - --PjUiPjuUbndReq - --PjUiPjuDatReq - --PjUiPjuSduStaReq - - File: pj_uim.c - -**********************************************************************/ -static const char* RLOG_MODULE_NAME="PDCP"; -static int RLOG_MODULE_ID=1024; -static int RLOG_FILE_ID=227; -/** @file pj_uim.c -@brief PDCP Upper Interface Module -*/ - - -/* header (.h) include files */ -#include "envopt.h" /* environment options */ -#include "envdep.h" /* environment dependent */ -#include "envind.h" /* environment independent */ - -#include "gen.h" /* general */ -#include "ssi.h" /* system services */ -#include "cm5.h" /* common timer defines */ -#include "cm_tkns.h" /* common tokens defines */ -#include "cm_mblk.h" /* common memory allocation library defines */ -#include "cm_llist.h" /* common link list defines */ -#include "cm_hash.h" /* common hash list defines */ -#include "cm_lte.h" /* common LTE defines */ -#include "lpj.h" /* LPJ define */ -#include "cpj.h" /* RRC layer */ -#include "pju.h" /* PDCP service user */ -#include "pj_env.h" /* RLC environment options */ -#include "pj.h" /* RLC defines */ -#include "pj_ul.h" -#include "pj_dl.h" -#include "pj_err.h" -#include "pj_udx.h" /* udx interface */ - -/* extern (.x) include files */ -#include "gen.x" /* general */ -#include "ssi.x" /* system services */ - -#include "cm5.x" /* common timer library */ -#include "cm_tkns.x" /* common tokens */ -#include "cm_mblk.x" /* common memory allocation */ -#include "cm_llist.x" /* common link list */ -#include "cm_hash.x" /* common hash list */ -#include "cm_lte.x" /* common LTE includes */ -#include "cm_lib.x" /* common memory allocation library */ -#include "lpj.x" /* LM(PDCP) */ -#include "cpj.x" /* RRC layer */ -#include "pju.x" /* PDCP service user */ -#include "pj.x" -#include "pj_udx.h" -#include "pj_udx.x" -#include "pj_ul.x" -#include "pj_dl.x" -#include "pj_lib.x" -/* kw004.201 Assigned build issue in LTE RLC pj_uim.c */ - -#ifdef __cplusplus -EXTERN "C" { -#endif /* __cplusplus */ - - - -/***************************************************************************** - * CPJ INTERFACE - ****************************************************************************/ -/** - * - * @brief - * - * Handler for binding the PDCP upper layer service user with - * the PDCP layer. - * - * @b Description: - * - * 1. This function is used by PDCP user to request for binding to - * PDCP. @n - * 2. This function is called by the CPJ interface to bind - * PDCP's SAP (identified by spId) with the service user's - * SAP (identified by suId). @n - * - * @param[in] pst Post structure - * @param[in] suId Service user SAP ID - * @param[in] spId Service provider ID - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 PjUiCpjBndReq -( -Pst *pst, -SuId suId, -SpId spId -) -#else -PUBLIC S16 PjUiCpjBndReq (pst, suId, spId) -Pst *pst; -SuId suId; -SpId spId; -#endif -{ - PjCpjSapCb *cpjSap; /* pointer to session SAP */ - S16 ret; /* return value */ - PjCb *tPjCb; - - TRC3(PjUiCpjBndReq) - - ret = ROK; - - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) /* KW_FIX */ - { - RETVALUE(RFAILED); - } - - tPjCb = PJ_GET_PJCB(pst->dstInst); - - RLOG2(L_DEBUG, "PjUiCpjBndReq(pst, spId(%d), suId(%d))", spId, suId); - - - - cpjSap = &(tPjCb->u.ulCb->cpjSap); - - /* Verify CPJ SAP State */ - switch(cpjSap->state) - { - /* SAP is configured but not bound */ - case PJ_SAP_CFG: - case PJ_SAP_UBND: - { - /* copy bind configuration parameters in SSAP sap */ - cpjSap->suId = suId; - cpjSap->pst.dstProcId = pst->srcProcId; - cpjSap->pst.dstEnt = pst->srcEnt; - cpjSap->pst.dstInst = pst->srcInst; - - /* Update the State */ - cpjSap->state = PJ_SAP_BND; - - RLOG1(L_DEBUG, "PjUiCpjBndReq: state (%d)", cpjSap->state); - break; - } - - /* SAP is already bound */ - case PJ_SAP_BND: - { - /* - * Sap is already bound check source, destination Entity and - * Proc Id - */ - if (cpjSap->pst.dstProcId != pst->srcProcId - || cpjSap->pst.dstEnt != pst->srcEnt - || cpjSap->pst.dstInst != pst->srcInst - || cpjSap->suId != suId) - { - PJ_SEND_SAPID_ALARM(tPjCb, spId, LPJ_EVENT_CPJ_BND_REQ, LCM_CAUSE_INV_PAR_VAL); - - RLOG1(L_DEBUG, "PjUiCpjBndReq: SAP already bound -- state(%d)", cpjSap->state); - ret = RFAILED; - } - break; - } - - default: - { - PJ_SEND_SAPID_ALARM(tPjCb,spId, LPJ_EVENT_CPJ_BND_REQ, LCM_CAUSE_INV_STATE); - RLOG0(L_ERROR, "Invalid CPJ SAP State in Bind Req"); - ret = RFAILED; - break; - } - } - - if (ret == ROK) - { - PjUiCpjBndCfm(&(cpjSap->pst), cpjSap->suId, CM_BND_OK); - } - else - { - PjUiCpjBndCfm(&(cpjSap->pst), cpjSap->suId, CM_BND_NOK); - } - - RETVALUE(ROK); -} /* PjUiCpjBndReq */ - - -/** - * - * @brief - * - * Handler for unbinding the RLC upper layer service user CPJ with - * the RLC layer. - * - * @b Description: - * - * 1. This function is used by RLC user to request for unbinding - * with RLC. @n - * 2. This function is called by the CPJ interface to - * unbind with RLC. @n - * - * @param[in] pst Post structure - * @param[in] spId Service provider SAP ID - * @param[in] reason Reason for Unbinding - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 PjUiCpjUbndReq -( -Pst *pst, -SpId spId, -Reason reason -) -#else -PUBLIC S16 PjUiCpjUbndReq(pst, spId, reason) -Pst *pst; -SpId spId; -Reason reason; -#endif -{ - PjCpjSapCb *cpjSap; /* CPJ SAP control block */ -#if (ERRCLASS & ERRCLS_INT_PAR) - S16 ret; /* Return Value */ -#endif - PjCb *tPjCb; - - TRC3(PjUiCpjUbndReq) - - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) /* KW_FIX */ - { - RETVALUE(RFAILED); - } - - tPjCb = PJ_GET_PJCB(pst->dstInst); - RLOG2(L_DEBUG, "PjUiCpjUbndReq(pst, spId(%d), reason(%d))", spId, reason); - - UNUSED(pst); - UNUSED(reason); - - /* disable upper sap (CPJ) */ - cpjSap = &(tPjCb->u.ulCb->cpjSap); - - -#if (ERRCLASS & ERRCLS_INT_PAR) - ret = ROK; - PJ_GET_AND_VALIDATE_CPJSAP(tPjCb,cpjSap, EPJXXX, "PjUiCPjUbndReq", ret); - if ( ret != ROK ) - { - RETVALUE(RFAILED); - } -#endif /* ERRCLASS & ERRCLS_INT_PAR */ - - cpjSap->state = PJ_SAP_CFG; - - RETVALUE(ROK); -} /* CpUiCpjUbndReq */ - - -/** - * - * @brief - * - * Handler for configuring PDCP entities. - * - * @b Description: - * - * This function is used by RRC to configure(add/delete/modify/ - * reestalish/delete all RB in a UE) one or more PDCP entities. - * - * - CPJ_CFG_ADD => pjCfgAddRb - * - CPJ_CFG_MODIFY => pjCfgReCfgRb - * - CPJ_CFG_DELETE => pjCfgDelRb - * - CPJ_CFG_REESTABLISH => pjCfgReEstRb - * - CPJ_CFG_DELETE_UE => pjCfgDelUe - * - * @param[in] pst - Post structure - * @param[in] spId - Serive Provider ID - * @param[in] cfg - Configuration information for one or more PDCP entities. - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 PjUiCpjCfgReq -( -Pst *pst, -SpId spId, -CpjCfgReqInfo *cfg -) -#else -PUBLIC S16 PjUiCpjCfgReq(pst, spId, cfg) -Pst *pst; -SpId spId; -CpjCfgReqInfo *cfg; -#endif -{ - PjCpjSapCb *cpjSap; /* CPJ SAP Control Block */ - PjUdxUlSapCb *udxSap; /* UDX SAP Control Block */ - S16 ret; /* Return Value */ - PjCb *tPjCb; - PjCfgInfo *cfgInfo; /* added here n below */ - UdxCfgReqInfo *udxCfgReqInfo; - - - TRC3(PjUiCpjCfgReq) - - ret = ROK; - - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) /* KW_FIX */ - { - RETVALUE(RFAILED); - } - tPjCb = PJ_GET_PJCB(pst->dstInst); -#ifndef ALIGN_64BIT - RLOG2(L_DEBUG, "PjUiPjuCfgReq(pst, spId(%d), TransId(%ld))", spId, cfg->transId); -#else - RLOG2(L_DEBUG, "PjUiPjuCfgReq(pst, spId(%d), TransId(%d))", spId, cfg->transId); -#endif - - /* Get the cpjSap */ - cpjSap = &(tPjCb->u.ulCb->cpjSap); - - /* Validate SAP ID under ERRORCLS */ - PJ_VALDATE_SAP(tPjCb, spId, cpjSap, ret); - if (ret != ROK) - { - /* pj002.201 Freeing from proper region */ - PJ_PST_FREE(pst->region, pst->pool, cfg, sizeof(CpjCfgReqInfo)); - RETVALUE(RFAILED); - } - - udxSap = PJ_GET_UL_UDX_SAP(tPjCb); - PJ_ALLOC_BUF_SHRABL(udxSap->pst,udxCfgReqInfo,sizeof (UdxCfgReqInfo),ret); - if(ret != ROK) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - PJ_PST_FREE(pst->region, pst->pool, cfg, sizeof(CpjCfgReqInfo)); - RETVALUE(RFAILED); - } - - - PJ_MEM_CPY(udxCfgReqInfo,cfg,sizeof(UdxCfgReqInfo)); - PJ_ALLOC(tPjCb, cfgInfo, sizeof (PjCfgInfo)); - - if (cfgInfo == NULLP) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - PJ_PST_FREE(pst->region, pst->pool, cfg, sizeof(CpjCfgReqInfo)); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, udxCfgReqInfo, sizeof(UdxCfgReqInfo)); - RETVALUE(RFAILED); - } - - cfgInfo->uprLyrTransId = cfg->transId; - cfgInfo->transId = ++tPjCb->u.ulCb->transId; - udxCfgReqInfo->transId = cfgInfo->transId; - cfgInfo->cfgInfo = cfg; - - ret = pjDbmAddUlTransIdLst(tPjCb, cfgInfo); - if (ret != ROK) - { - RLOG0(L_ERROR, "Addition to UL transId List Failed."); - PJ_PST_FREE(pst->region, pst->pool, cfg, sizeof(CpjCfgReqInfo)); - PJ_FREE_SHRABL_BUF_PST(pst->region, pst->pool, udxCfgReqInfo, sizeof(UdxCfgReqInfo)); - PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo)); - - RETVALUE(RFAILED); - } - - udxSap = PJ_GET_UL_UDX_SAP(tPjCb); - - PjUlUdxCfgReq(&(udxSap->pst), udxSap->spId,udxCfgReqInfo); - - RETVALUE(ret); -} /* PjUiPjuCfgReq */ - -/** - *@details This primitive is used by RRC to change the UeId for the existing UE - context. - - * @param pst - Point to the pst structure - * @param spId - The ID of the service provider SAP in the PDCP layer - * @param transId - Transaction ID. This field uniquily identifies - * transaction between RRC and PDCP. - * @param ueInfo - Old UE Id Info for which the change request has come - * @param newUeInfo - New UE Id Info for existing UE context - * @return ROK - */ -#ifdef ANSI -PUBLIC S16 PjUiCpjUeIdChgReq -( -Pst *pst, -SpId spId, -U32 transId, -CpjUeInfo *ueInfo, -CpjUeInfo *newUeInfo -) -#else -PUBLIC S16 PjUiCpjUeIdChgReq(pst,spId,transId,ueInfo,newUeInfo) -Pst *pst; -SpId spId; -U32 transId; -CpjUeInfo *ueInfo; -CpjUeInfo *newUeInfo; -#endif -{ - S16 ret; /* Return Value */ - PjCpjSapCb *cpjSap; /* CPJ SAP Control Block */ - PjUdxUlSapCb *udxSap; /* UDX SAP Control Block */ - PjCfgInfo *cfgInfo; - - UdxUeInfo *udxUeInfo; - UdxUeInfo *udxNewUeInfo; - PjCb *tPjCb; - - TRC3(PjUiCpjUeIdChgReq) - - tPjCb = PJ_GET_PJCB(pst->dstInst); - -#ifndef ALIGN_64BIT - RLOG2(L_DEBUG, "PjUiCpjUeIdChgReq(pst, spId(%d), transId(%ld))", spId, transId); -#else - RLOG2(L_DEBUG, "PjUiCpjUeIdChgReq(pst, spId(%d), transId(%d))", spId, transId); -#endif - - ret = ROK; - cpjSap = &(tPjCb->u.ulCb->cpjSap); - - /* Validate SAP ID under ERRORCLS */ - PJ_VALDATE_SAP(tPjCb, spId, cpjSap, ret); - if (ret != ROK) - { - /* kw002.201 Freeing from proper region */ - PJ_PST_FREE(pst->region, pst->pool, ueInfo, sizeof(CpjUeInfo)); - PJ_PST_FREE(pst->region, pst->pool, newUeInfo, sizeof(CpjUeInfo)); - RETVALUE(RFAILED); - } - - /* Allocate memory for CkwUeInfo */ - udxSap = PJ_GET_UL_UDX_SAP(tPjCb); - PJ_ALLOC_BUF_SHRABL(udxSap->pst, udxUeInfo, - sizeof (UdxUeInfo), ret); - if(ret != ROK) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - /* Free memory for CkwUeInfo */ - /* Freeing from proper region */ - PJ_PST_FREE(pst->region, pst->pool, newUeInfo, sizeof(CpjUeInfo)); - PJ_PST_FREE(pst->region, pst->pool, ueInfo, sizeof(CpjUeInfo)); - RETVALUE(RFAILED); - } - PJ_ALLOC_BUF_SHRABL(udxSap->pst, udxNewUeInfo, - sizeof (UdxUeInfo), ret); - if(ret != ROK) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - /* Free memory for CkwUeInfo */ - /* Freeing from proper region */ - PJ_FREE_SHRABL_BUF_PST(udxSap->pst.region,udxSap->pst.pool, udxUeInfo, sizeof(UdxUeInfo)); - PJ_PST_FREE(pst->region, pst->pool, newUeInfo, sizeof(CpjUeInfo)); - PJ_PST_FREE(pst->region, pst->pool, ueInfo, sizeof(CpjUeInfo)); - RETVALUE(RFAILED); - } - - PJ_MEM_CPY(udxUeInfo,ueInfo, sizeof(UdxUeInfo)); - PJ_MEM_CPY(udxNewUeInfo,newUeInfo, sizeof (UdxUeInfo)); - - PJ_ALLOC(tPjCb, cfgInfo, sizeof (PjCfgInfo)); - if (cfgInfo == NULLP) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - PJ_FREE_SHRABL_BUF_PST(udxSap->pst.region,udxSap->pst.pool, udxUeInfo, sizeof(UdxUeInfo)); - PJ_FREE_SHRABL_BUF_PST(udxSap->pst.region,udxSap->pst.pool, udxNewUeInfo, sizeof(UdxUeInfo)); - PJ_PST_FREE(pst->region, pst->pool, newUeInfo, sizeof(CpjUeInfo)); - PJ_PST_FREE(pst->region, pst->pool, ueInfo, sizeof(CpjUeInfo)); - RETVALUE(RFAILED); - } - - cfgInfo->uprLyrTransId = transId; - cfgInfo->transId = ++tPjCb->u.ulCb->transId; - cfgInfo->ueInfo = ueInfo; - cfgInfo->newUeInfo = newUeInfo; - - if((ret = pjDbmAddUlTransIdLst(tPjCb, cfgInfo)) != ROK) - { - RLOG0(L_ERROR, "Addition to UL transId List Failed."); - PJ_FREE_SHRABL_BUF_PST(udxSap->pst.region,udxSap->pst.pool, udxUeInfo, sizeof(UdxUeInfo)); - PJ_FREE_SHRABL_BUF_PST(udxSap->pst.region,udxSap->pst.pool, udxNewUeInfo, sizeof(UdxUeInfo)); - PJ_PST_FREE(pst->region, pst->pool, newUeInfo, sizeof(CpjUeInfo)); - PJ_PST_FREE(pst->region, pst->pool, ueInfo, sizeof(CpjUeInfo)); - RETVALUE(RFAILED); - } - - - PjUlUdxUeIdChgReq(&(udxSap->pst),udxSap->spId,cfgInfo->transId, - udxUeInfo,udxNewUeInfo); - - RETVALUE(ROK); -} /* PjUiCpjUeIdChgReq */ - - -/** - *@details - * 1. RRC uses this primitive to configure PDCP security parameters. - * Integrity protection and/or Ciphering are configured by RRC based on the - * selSecAct flag. @n - * 2. Integirty Protection/Ciphering are configured per UE and applicable - * to all pdcp entities in that UE. Both Integrity protection and ciphering are - * re-configured during re-establishment. @n - * - * @param pst - Point to the pst structure - * @param spId - The ID of the service provider SAP in the PDCP layer - * @param secCfg - Security Configuration Info per UE. - * - * @return - * -# ROK - * -# RFAILED - */ -#ifdef ANSI -PUBLIC S16 PjUiCpjSecCfgReq -( -Pst *pst, -SpId spId, -CpjSecCfgReqInfo *secCfg -) -#else -PUBLIC S16 PjUiCpjSecCfgReq(pst,spId,secCfg) -Pst *pst; -SpId spId; -CpjSecCfgReqInfo *secCfg; -#endif -{ - S16 ret; /* Return Value */ - PjUdxUlSapCb *udxSap; /* UDX SAP Control Block */ - PjCb *tPjCb; - PjCfgInfo *cfgInfo; - UdxSecCfgReqInfo *udxSecCfgReqInfo; - - TRC2(PjUiCpjSecCfgReq) - - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) /* KW_FIX */ - { - RETVALUE(RFAILED); - } - tPjCb = PJ_GET_PJCB(pst->dstInst); - -#ifndef ALIGN_64BIT - RLOG2(L_DEBUG, "PjUiCpjSecCfgReq(pst, spId(%d), TransId(%ld))", spId, - secCfg->transId); -#else - RLOG2(L_DEBUG, "PjUiCpjSecCfgReq(pst, spId(%d), TransId(%d))", spId, - secCfg->transId); -#endif - - ret = ROK; - - udxSap = PJ_GET_UL_UDX_SAP(tPjCb); - PJ_ALLOC_BUF_SHRABL(udxSap->pst, udxSecCfgReqInfo,sizeof (UdxSecCfgReqInfo), ret); - if(ret != ROK) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } - - PJ_MEM_CPY(udxSecCfgReqInfo,secCfg,sizeof(UdxSecCfgReqInfo)); - PJ_ALLOC(tPjCb, cfgInfo, sizeof (PjCfgInfo)); - - if (cfgInfo == NULLP) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } - - cfgInfo->uprLyrTransId = secCfg->transId; - cfgInfo->transId = ++tPjCb->u.ulCb->transId; - udxSecCfgReqInfo->transId = cfgInfo->transId; - cfgInfo->secCfgInfo = secCfg; - - ret = pjDbmAddUlTransIdLst(tPjCb, cfgInfo); - if (ret != ROK) - { - RLOG0(L_ERROR, "Addition to UL transId List Failed."); - RETVALUE(RFAILED); - } - - PjUlUdxSecCfgReq(&(udxSap->pst), udxSap->spId,udxSecCfgReqInfo); - - RETVALUE(ret); -} - -/** - * @details - * 1. RRC uses this primitive to re-establish the PDCP entity. @n - * 2. This primitive is initiation of re-establishment procedure. @n - * 3. This prmitive and corresponding confirmation shall be followed by - * PjUiCpjCfgReq procedure for entire re-establishment procedure to complete. - * - * @param[in] pst - Pointer to post structure. - * @param[in] spId - Service provider ID. This is the reference number used by - * PDCP to identify its SAP. - * @param[in] reEstReq - PDCP re-establishment request structure. - * - */ -#ifdef ANSI -PUBLIC S16 PjUiCpjReEstReq -( -Pst *pst, -SpId spId, -CpjReEstReqInfo *reEstReq -) -#else -PUBLIC S16 PjUiCpjReEstReq(pst,spId,reEstReq) -Pst *pst; -SpId spId; -CpjReEstReqInfo *reEstReq; -#endif -{ - S16 ret; /* Return Value */ - PjCpjSapCb *cpjSap; /* CPJ SAP Control Block */ - PjUdxUlSapCb *udxSap; /* UDX SAP Control Block */ - PjCb *tPjCb; - PjCfgInfo *cfgInfo; - UdxReEstReqInfo *udxReEstReqInfo; - - TRC2(PjUiCpjReEstReq); - - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) /* KW_FIX */ - { - PJ_PST_FREE(pst->region, pst->pool, reEstReq, sizeof(CpjReEstReqInfo)); - RETVALUE(RFAILED); - } - tPjCb = PJ_GET_PJCB(pst->dstInst); - RLOG1(L_DEBUG, "PjUiCpjReEstReq(pst, spId(%d))", spId); - - ret = ROK; - cpjSap = &(tPjCb->u.ulCb->cpjSap); - - /* Validate SAP ID under ERRORCLS */ - PJ_VALDATE_SAP(tPjCb, spId, cpjSap, ret); - if (ret != ROK) - { - /* pj002.201 Freeing from proper region */ - PJ_PST_FREE(pst->region, pst->pool, reEstReq, sizeof(CpjReEstReqInfo)); - RETVALUE(RFAILED); - } - - udxSap = PJ_GET_UL_UDX_SAP(tPjCb); - PJ_ALLOC_BUF_SHRABL(udxSap->pst, udxReEstReqInfo, - sizeof (UdxReEstReqInfo), ret); - if(ret != ROK) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - PJ_PST_FREE(pst->region, pst->pool, reEstReq, sizeof(CpjReEstReqInfo)); - RETVALUE(RFAILED); - } - - PJ_MEM_CPY(udxReEstReqInfo,reEstReq,sizeof(UdxReEstReqInfo)); - - PJ_ALLOC(tPjCb, cfgInfo, sizeof (PjCfgInfo)); - if (cfgInfo == NULLP) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - PJ_PST_FREE(pst->region, pst->pool, reEstReq, sizeof(CpjReEstReqInfo)); - RETVALUE(RFAILED); - } - - cfgInfo->uprLyrTransId = reEstReq->transId; - cfgInfo->transId = ++tPjCb->u.ulCb->transId; - udxReEstReqInfo->transId = cfgInfo->transId; - cfgInfo->reEstReq = reEstReq; - - ret = pjDbmAddUlTransIdLst(tPjCb, cfgInfo); - if (ret != ROK) - { - RLOG0(L_ERROR, "Addition to UL transId List Failed."); - PJ_PST_FREE(pst->region, pst->pool, reEstReq, sizeof(CpjReEstReqInfo)); - PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo)); - RETVALUE(RFAILED); - } - - udxSap = PJ_GET_UL_UDX_SAP(tPjCb); - PjUlUdxReEstReq(&(udxSap->pst), udxSap->spId,udxReEstReqInfo); - - RETVALUE(ROK); -} - - -/** - * @details - * 1. RRC uses this primitive to request count value for all DRBs in a UE. @n - * 2. PDCP sends the UL and DL count values in the confirmation of this request. - * - * @param[in] pst - Pointer to post structure. - * @param[in] spId - Service provider ID. This is the reference number used - * by PDCP to identify its SAP. - * @param[in] countReq - PDCP Count Request Information. - * - * @return ROK - */ -#ifdef ANSI -PUBLIC S16 PjUiCpjCountReq -( -Pst *pst, -SpId spId, -CpjCountReqInfo *countReq -) -#else -PUBLIC S16 PjUiCpjCountReq(pst,spId,countReq) -Pst *pst; -SpId spId; -CpjCountReqInfo *countReq; -#endif -{ - S16 ret; /* Return Value */ - PjUdxUlSapCb *udxSap; /* UDX SAP Control Block */ - PjCb *tPjCb; - PjCfgInfo *cfgInfo; - UdxCountReqInfo *udxCountReqInfo; - - TRC2(PjUiCpjCountReq); - - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) /* KW_FIX */ - { - PJ_PST_FREE(pst->region, pst->pool, countReq, sizeof(CpjCountReqInfo)); - RETVALUE(RFAILED); - } - - - tPjCb = PJ_GET_PJCB(pst->dstInst); - RLOG1(L_DEBUG, "PjUiCpjCountReq(pst, spId(%d))", spId); - - ret = ROK; - - udxSap = PJ_GET_UL_UDX_SAP(tPjCb); - PJ_ALLOC_BUF_SHRABL(udxSap->pst, udxCountReqInfo, sizeof (UdxCountReqInfo), ret); - if(ret != ROK) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } - - PJ_MEM_CPY(udxCountReqInfo,countReq,sizeof(UdxCountReqInfo)); - PJ_ALLOC(tPjCb, cfgInfo, sizeof (PjCfgInfo)); - - if (cfgInfo == NULLP) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - PJ_PST_FREE(pst->region, pst->pool, countReq, sizeof(CpjCountReqInfo)); - RETVALUE(RFAILED); - } - - cfgInfo->uprLyrTransId = countReq->transId; - cfgInfo->transId = ++tPjCb->u.ulCb->transId; - udxCountReqInfo->transId = cfgInfo->transId; - cfgInfo->cntReq = countReq; - - ret = pjDbmAddUlTransIdLst(tPjCb, cfgInfo); - if (ret != ROK) - { - RLOG0(L_ERROR, "Addition to UL transId List Failed."); - PJ_PST_FREE(udxSap->pst.region, udxSap->pst.pool, udxCountReqInfo, sizeof(UdxCountReqInfo)); - PJ_PST_FREE(pst->region, pst->pool, countReq, sizeof(CpjCountReqInfo)); - PJ_FREE(tPjCb, cfgInfo, sizeof (PjCfgInfo)); - RETVALUE(RFAILED); - } - - - PjUlUdxCountReq(&(udxSap->pst), udxSap->spId,udxCountReqInfo); - - RETVALUE(ROK); -} - -/** - * - * @details - * 1. RRC uses this primitive to request the status of the SDUs for DRBs in an UE. @n - * 2. Its used as a reestablishment request during handover. @n - * 3. This primitive is used to forward the handover control Information to the target - * eNodeB. - * - * @param[in] pst - Pointer to post structure. - * @param[in] spId - Service provider ID. This is the reference number used - * by PDCP to identify its SAP. - * @param[in] sduStaReq - PDCP SDU Status Request Information. - * - * @return ROK - */ -#ifdef ANSI -PUBLIC S16 PjUiCpjSduStaReq -( -Pst *pst, -SpId spId, -CpjSduStaReqInfo *staReq -) -#else -PUBLIC S16 PjUiCpjSduStaReq(pst,spId,staReq) -Pst *pst; -SpId spId; -CpjSduStaReqInfo *staReq; -#endif -{ - - S16 ret; /* Return Value */ - PjCpjSapCb *cpjSap; /* CPJ SAP Control Block */ - PjUlUeCb *ueCb; - PjUdxUlSapCb *udxSap; /* UDX SAP Control Block */ - PjCb *tPjCb; - PjCfgInfo *cfgInfo; /* added here n below */ - UdxSduStaReqInfo *udxSduStaReq; - - TRC2(PjUiCpjSduStaReq); - - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) /* KW_FIX */ - { - PJ_PST_FREE(pst->region, pst->pool, staReq, sizeof(CpjSduStaReqInfo)); - RETVALUE(RFAILED); - } - - tPjCb = PJ_GET_PJCB(pst->dstInst); - - RLOG1(L_DEBUG, "PjUiCpjSduStaReq(pst, spId(%d))", spId); - - ret = ROK; - cpjSap = NULLP; - - cpjSap = &(tPjCb->u.ulCb->cpjSap); - - /* Validate SAP ID under ERRORCLS */ - PJ_VALDATE_SAP(tPjCb, spId, cpjSap, ret); - if (ret != ROK) - { - /* kw002.201 Freeing from proper region */ - PJ_PST_FREE(pst->region, pst->pool, staReq, sizeof(CpjSduStaReqInfo)); - RETVALUE(RFAILED); - } - - ret = pjDbmFetchUlUeCb(tPjCb, staReq->ueId, staReq->cellId, &ueCb); - /* UeCb is not present */ - if( ROK != ret || NULLP == ueCb) - { - RLOG_ARG1(L_ERROR, DBG_CELLID, staReq->cellId,"UL UeId[%u] not found", - staReq->ueId); - CpjSduStaCfmInfo *cfmInfo; - /* Memory leak fix ccpu00135359 */ - cpjSap = &tPjCb->u.ulCb->cpjSap; - if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,(Data **)&cfmInfo, - sizeof (CpjSduStaCfmInfo)) != ROK) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - PJ_PST_FREE(pst->region, pst->pool, staReq, sizeof(CpjSduStaReqInfo)); - RETVALUE(RFAILED); - } - cfmInfo->ueId = staReq->ueId; - cfmInfo->cellId = staReq->cellId; - cfmInfo->transId = staReq->transId; - cfmInfo->status = CPJ_CFG_CFM_NOK; - cfmInfo->reason = CPJ_CFG_REAS_UE_UNKWN; - - /* Caller should return cfm with failure */ - RLOG_ARG1(L_DEBUG,DBG_UEID,staReq->ueId, "Prc Sdu Sta Req - UE Cb is not" - " found in cellId(%d)", staReq->cellId); - - /* Send Failure SduStaCfm */ - PjUiCpjSduStaCfm(&tPjCb->u.ulCb->cpjSap.pst, - tPjCb->u.ulCb->cpjSap.suId, cfmInfo); - - PJ_PST_FREE(pst->region, pst->pool, staReq, sizeof(CpjSduStaReqInfo)); - - RETVALUE(RFAILED); - } - - /* Updating UE state to REEST during HO */ - ueCb->libInfo.numReEstDrb = 0; - ueCb->libInfo.state = PJ_STATE_REEST_HO; - - udxSap = PJ_GET_UL_UDX_SAP(tPjCb); - ret = ROK; - PJ_ALLOC_BUF_SHRABL(udxSap->pst, udxSduStaReq, - sizeof (UdxSduStaReqInfo), ret); - if(ret != ROK) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - PJ_PST_FREE(pst->region, pst->pool, staReq, sizeof(CpjSduStaReqInfo)); - RETVALUE(RFAILED); - } - - PJ_MEM_CPY(udxSduStaReq,staReq,sizeof(UdxSduStaReqInfo)); - - PJ_ALLOC(tPjCb, cfgInfo, sizeof (PjCfgInfo)); - if (cfgInfo == NULLP) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - PJ_PST_FREE(pst->region, pst->pool, staReq, sizeof(CpjSduStaReqInfo)); - PJ_PST_FREE(pst->region, pst->pool, udxSduStaReq, sizeof(UdxSduStaReqInfo)); - RETVALUE(RFAILED); - } - - cfgInfo->uprLyrTransId = staReq->transId; - cfgInfo->transId = ++tPjCb->u.ulCb->transId; - udxSduStaReq->transId = cfgInfo->transId; - cfgInfo->staReq = staReq; - - ret = pjDbmAddUlTransIdLst(tPjCb, cfgInfo); - if (ret != ROK) - { - RLOG0(L_ERROR, "Addition to UL transId List Failed."); - PJ_PST_FREE(pst->region, pst->pool, staReq, sizeof(CpjSduStaReqInfo)); - PJ_PST_FREE(udxSap->pst.region, udxSap->pst.pool, udxSduStaReq, sizeof(UdxSduStaReqInfo)); - PJ_FREE(tPjCb, cfgInfo, sizeof(PjCfgInfo)); - - RETVALUE(RFAILED); - } - - - PjUlUdxSduStaReq(&(udxSap->pst), udxSap->spId,udxSduStaReq); - - RETVALUE(ret); -} - - -/** - * - * @details - * 1. RRC uses this primitive to resume data during Re-establishment and - * handover - * - * @param[in] pst - Pointer to post structure. - * @param[in] spId - Service provider ID. This is the reference number used - * by PDCP to identify its SAP. - * @param[in] sduStaReq - PDCP SDU Status Request Information. - * - * @return ROK - */ -#ifdef ANSI -PUBLIC S16 PjUiCpjDatResumeReq -( -Pst *pst, -SpId spId, -CpjDatResumeReqInfo *datResReq -) -#else -PUBLIC S16 PjUiCpjDatResumeReq(pst,spId, *dataResReq) -Pst *pst; -SpId spId; -CpjDatResumeReqInfo *datResReq; -#endif -{ - - S16 ret; /* Return Value */ - PjCpjSapCb *cpjSap; /* CPJ SAP Control Block */ - PjUdxUlSapCb *udxSap; /* UDX SAP Control Block */ - PjUlUeCb *ueCb; - PjCfgInfo *cfgInfo; - PjCb *tPjCb; - UdxDatResumeInfo *udxDatResumeInfo; - TRC2(PjUiCpjDatResumeReq); - - tPjCb = PJ_GET_PJCB(pst->dstInst); - - RLOG1(L_DEBUG, "PjUiCpjDatResumeReq(pst, spId(%d))", spId); - - ret = ROK; - cpjSap = NULLP; - - cpjSap = &(tPjCb->u.ulCb->cpjSap); - - /* Validate SAP ID under ERRORCLS */ - PJ_VALDATE_SAP(tPjCb, spId, cpjSap, ret); - if (ret != ROK) - { - RETVALUE(RFAILED); - } - ret = pjDbmFetchUlUeCb(tPjCb, datResReq->ueId, - datResReq->cellId, &ueCb); - if (ret != ROK) - { - RLOG_ARG1(L_ERROR, DBG_CELLID, datResReq->cellId,"UL UeId[%u] not found", - datResReq->ueId); - PJ_PST_FREE(pst->region, pst->pool, datResReq, sizeof(CpjDatResumeReqInfo)); - RETVALUE(RFAILED); - } - - /* Memory leak fix ccpu00135359 */ - udxSap = PJ_GET_UL_UDX_SAP(tPjCb); - ret = ROK; - PJ_ALLOC_BUF_SHRABL(udxSap->pst, udxDatResumeInfo, - sizeof (UdxDatResumeInfo), ret); - if(ret != ROK) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - PJ_PST_FREE(pst->region, pst->pool, datResReq, sizeof(CpjDatResumeReqInfo)); - RETVALUE(RFAILED); - } - - PJ_ALLOC(tPjCb, cfgInfo, sizeof (PjCfgInfo)); - if (cfgInfo == NULLP) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - PJ_PST_FREE(pst->region, pst->pool, datResReq, sizeof(CpjDatResumeReqInfo)); - PJ_PST_FREE(udxSap->pst.region, udxSap->pst.pool, udxDatResumeInfo, sizeof(UdxDatResumeInfo)); - RETVALUE(RFAILED); - } - - cfgInfo->uprLyrTransId = datResReq->transId; - cfgInfo->transId = ++tPjCb->u.ulCb->transId; - udxDatResumeInfo->transId = cfgInfo->transId; - cfgInfo->datResReq = datResReq; - udxDatResumeInfo->ueId = datResReq->ueId; - udxDatResumeInfo->cellId = datResReq->cellId; - - ret = pjDbmAddUlTransIdLst(tPjCb, cfgInfo); - if (ret != ROK) - { - RLOG0(L_ERROR, "Addition to UL transId List Failed."); - PJ_PST_FREE(pst->region, pst->pool, datResReq, sizeof(CpjDatResumeReqInfo)); - PJ_FREE(tPjCb, cfgInfo, sizeof(PjCfgInfo)); - PJ_PST_FREE(udxSap->pst.region, udxSap->pst.pool, udxDatResumeInfo, sizeof(UdxDatResumeInfo)); - - RETVALUE(RFAILED); - } - - PjUlUdxDatResumeReq(&(udxSap->pst), udxDatResumeInfo); - - RETVALUE(ret); -} - -/** - * - * @details - * 1. RRC uses this primitive to start data forwarding during - * handover - * - * @param[in] pst - Pointer to post structure. - * @param[in] spId - Service provider ID. This is the reference number used - * by PDCP to identify its SAP. - * @param[in] sduStaReq - PDCP SDU Status Request Information. - * - * @return ROK - */ -#ifdef ANSI -PUBLIC S16 PjUiCpjDatForwardReq -( -Pst *pst, -SpId spId, -CpjDataFwdReqInfo *dataFwdReq -) -#else -PUBLIC S16 PjUiCpjDatForwardReq(pst,spId, *dataFwdReq) -Pst *pst; -SpId spId; -CpjDataFwdReqInfo *dataFwdReq; -#endif -{ - - S16 ret; /* Return Value */ - PjCpjSapCb *cpjSap; /* CPJ SAP Control Block */ - PjUdxUlSapCb *udxSap; /* UDX SAP Control Block */ - PjUlUeCb *ueCb; - CmLteRnti ueId; /*!< UE ID */ - CmLteCellId cellId; /*!< Cell ID */ - UdxDatForwardInfo *udxDatForwardInfo; - - PjCb *tPjCb; - TRC2(PjUiCpjDatForwardReq); - - tPjCb = PJ_GET_PJCB(pst->dstInst); - - RLOG1(L_DEBUG, "PjUiCpjDatForwardReq(pst, spId(%d))", spId); - - ret = ROK; - cpjSap = NULLP; - - ueId = dataFwdReq->ueId; - cellId = dataFwdReq->cellId; - cpjSap = &(tPjCb->u.ulCb->cpjSap); - - /* Validate SAP ID under ERRORCLS */ - PJ_VALDATE_SAP(tPjCb, spId, cpjSap, ret); - if (ret != ROK) - { - PJ_PST_FREE(pst->region, pst->pool, dataFwdReq, sizeof(CpjDataFwdReqInfo)); - RETVALUE(RFAILED); - } - - ret = pjDbmFetchUlUeCb(tPjCb, ueId, cellId, &ueCb); - if (ret != ROK) - { - RLOG_ARG1(L_ERROR, DBG_CELLID, cellId,"UL UeId[%u] not found",ueId); - PJ_PST_FREE(pst->region, pst->pool, dataFwdReq, sizeof(CpjDataFwdReqInfo)); - RETVALUE(RFAILED); - } - /* Store the UL Data Forwarding Req or not in ueCb */ - ueCb->isUlDatFwdReqd = dataFwdReq->isUlDatFwdReq; - - ret = ROK; - /* Memory leak fix ccpu00135359 */ - udxSap = PJ_GET_UL_UDX_SAP(tPjCb); - PJ_ALLOC_BUF_SHRABL(udxSap->pst, udxDatForwardInfo, - sizeof (UdxDatForwardInfo), ret); - if(ret != ROK) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - PJ_PST_FREE(pst->region, pst->pool, dataFwdReq, sizeof(CpjDataFwdReqInfo)); - RETVALUE(RFAILED); - } - - /* TODO :- Need to add code for handling request */ - - /* Forwarding request to DL over UDX interface */ - udxDatForwardInfo->ueId = ueId; - udxDatForwardInfo->cellId = cellId; - udxDatForwardInfo->transId = dataFwdReq->transId; - - PJ_PST_FREE(pst->region, pst->pool, dataFwdReq, sizeof(CpjDataFwdReqInfo)); - if(ueCb->isUlDatFwdReqd == TRUE) - { - /* Snd ULFwd - TRUE to DL - * So that DL will not send isLastDatInd Flag to DAM */ - udxDatForwardInfo->ulFwding = TRUE; - } - PjUlUdxDatForwardReq(&(udxSap->pst), udxDatForwardInfo); - - RETVALUE(ret); -} - - -/***************************************************************************** - * PJU INTERFACE - ****************************************************************************/ -/** - * - * @brief - * - * Handler for binding the PDCP upper layer service user with - * the PDCP layer. - * - * @b Description: - * - * 1. This function is used by PDCP user to request for binding to - * PDCP. @n - * 2. This function is called by the PJU interface to bind - * PDCP's SAP (identified by spId) with the service user's - * SAP (identified by suId). - * - * @param[in] pst Post structure - * @param[in] suId Service user SAP ID - * @param[in] spId Service provider ID - * - * @return S16 - * -# ROK - * -# RFAILED - */ -#ifdef ANSI -PUBLIC S16 PjUiPjuBndReq -( -Pst *pst, -SuId suId, -SpId spId -) -#else -PUBLIC S16 PjUiPjuBndReq (pst, suId, spId) -Pst *pst; -SuId suId; -SpId spId; -#endif -{ - S16 ret; /* Return Value */ - PjPjuSapCb *pjuSap; /* SAP Config Block */ - PjCb *tPjCb; - - TRC3(PjUiPjuBndReq) - - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) /* KW_FIX */ - { - RETVALUE(RFAILED); - } - - tPjCb = PJ_GET_PJCB(pst->dstInst); - RLOG2(L_DEBUG, "PjUiPjuBndReq(pst, spId(%d), suId(%d))", spId, suId); - - ret = ROK; - pjuSap = NULLP; - - /* Validation of input parameters */ -#if (ERRCLASS & ERRCLS_INT_PAR) - if(!((spId < (S16) tPjCb->pjGenCfg.maxPjuSaps) && (spId >=0))) - { - if(pjuSap != NULLP) - { - RLOG0(L_ERROR, "Invalid PJU SAP State in Bind Req"); - PJ_SEND_SAPID_ALARM(tPjCb,spId, LPJ_EVENT_PJU_BND_REQ, LCM_CAUSE_INV_SAP); - RETVALUE(RFAILED); - } - } -#endif - - /* Get Sap control block */ - if (tPjCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL) - { - pjuSap = (PjPjuSapCb*)(tPjCb->u.ulCb->pjuSap + spId); - } - else - { - pjuSap = (PjPjuSapCb*)(tPjCb->u.dlCb->pjuSap + spId); - } - - /* Verify PJU SAP State */ - switch(pjuSap->state) - { - /* SAP is configured but not bound */ - case PJ_SAP_CFG: - case PJ_SAP_UBND: - { - /* copy bind configuration parameters in SSAP sap */ - pjuSap->suId = suId; - pjuSap->pst.dstProcId = pst->srcProcId; - pjuSap->pst.dstEnt = pst->srcEnt; - pjuSap->pst.dstInst = pst->srcInst; - - /* Update the State */ - pjuSap->state = PJ_SAP_BND; - - /* DEBUG_PRINT */ - RLOG1(L_DEBUG, "PjUiPjuBndReq: state (%d)", pjuSap->state); - break; - } - - /* SAP is already bound */ - case PJ_SAP_BND: - { - /* - * Sap is already bound check source, destination Entity and - * Proc Id - */ - if (pjuSap->pst.dstProcId != pst->srcProcId - || pjuSap->pst.dstEnt != pst->srcEnt - || pjuSap->pst.dstInst != pst->srcInst - || pjuSap->suId != suId) - { - RLOG4(L_DEBUG, "Ui Pju Bnd Req suId(%d)<>suId(%d)," - "pst->srcProcId(%d)<>pjuSap->pst.dstProcId(%d)", - suId, pjuSap->suId, pst->srcProcId, pjuSap->pst.dstProcId); - - RLOG4(L_DEBUG,"Ui Pju Bnd Req pst->srcEnt(%d)<>pjuSap->pst.dstEnt" - "(%d),pst->srcInst(%d)<>pjuSap->pst.dstInst(%d))", - pst->srcEnt,pjuSap->pst.dstEnt,pst->srcInst,pjuSap->pst.dstInst); - - PJ_SEND_SAPID_ALARM(tPjCb, spId, LPJ_EVENT_PJU_BND_REQ, LCM_CAUSE_INV_PAR_VAL); - ret = RFAILED; - } - break; - } - - default: - { - /* LOG ERROR */ - RLOG0(L_ERROR, "Invalid PJU SAP State in Bind Req"); - PJ_SEND_SAPID_ALARM(tPjCb,spId, LPJ_EVENT_PJU_BND_REQ, LCM_CAUSE_INV_STATE); - ret = RFAILED; - break; - } - } - - if (ret == ROK) - { - PjUiPjuBndCfm(&(pjuSap->pst), pjuSap->suId, CM_BND_OK); - } - else - { - PjUiPjuBndCfm(&(pjuSap->pst), pjuSap->suId, CM_BND_NOK); - } - - RETVALUE(ROK); - -} /* PjUiPjuBndReq */ - - -/** - * - * @brief - * - * Handler for unbinding the PDCP upper layer service user with - * the PDCP layer. - * - * @b Description: - * - * 1. This function is used by PDCP user to request for unbinding - * with PDCP. @n - * 2. This function is called by the PJU interface to - * unbind with PDCP. - * - * @param[in] pst Post structure - * @param[in] suId Service user SAP ID - * @param[in] reason Reason for Unbinding - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 PjUiPjuUbndReq -( -Pst *pst, -SpId spId, -Reason reason -) -#else -PUBLIC S16 PjUiPjuUbndReq(pst, spId, reason) -Pst *pst; -SpId spId; -Reason reason; -#endif -{ - PjPjuSapCb *pjuSap; /* PJU SAP control block */ -#if (ERRCLASS & ERRCLS_INT_PAR) - S16 ret; -#endif - PjCb *tPjCb; - - TRC3(PjUiPjuUbndReq) - - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) /* KW_FIX */ - { - RETVALUE(RFAILED); - } - - tPjCb = PJ_GET_PJCB(pst->dstInst); - /* DEBUG_PRINT */ - RLOG2(L_DEBUG, "PjUiPjuUbndReq(pst, spId(%d), reason(%d))", spId, reason); - - pjuSap = NULLP; - - UNUSED(pst); - UNUSED(reason); - - /* Get Sap control block */ - if (tPjCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL) - { - pjuSap = (PjPjuSapCb*)(tPjCb->u.ulCb->pjuSap + spId); - } - else - { - pjuSap = (PjPjuSapCb*)(tPjCb->u.dlCb->pjuSap + spId); - } - - -#if (ERRCLASS & ERRCLS_INT_PAR) - PJ_GET_AND_VALIDATE_PJUSAP(tPjCb, pjuSap, EPJXXX, "PjUiPjuUbndReq", ret); - if (ret != ROK ) - { - RETVALUE(RFAILED); - } -#endif /* ERRCLASS & ERRCLS_INT_PAR */ - - pjuSap->state = PJ_SAP_CFG; - - RETVALUE(ROK); -} /* PjUiPjuUbndReq */ - -/** - * @details - * This primitive is used by the PDCP service user to request PDCP - * for data transfer. - * - * @param[in] pst - Pointer to Pst structure. - * @param[in] spId - Service provider ID. This is the reference number - * used by PDCP service user (Relay) to identify its SAP. This reference number - * will be provided by PDCP in any further primitives sent by PDCP - * to the service user. - * @param[in] pdcpId - Pointer to CmLtePdcpId structure, PDCP id is used to - * uniquely identify an PDCP entity. - * @param[in] sduId - SDU ID. - * @param[in] mBuf - Pointer to data buffer. - * - * @return ROK - */ -#ifdef ANSI -PUBLIC S16 PjUiPjuDatReq -( -Pst *pst, -SpId spId, -CmLtePdcpId *pdcpId, -PjuSduId sduId, -Buffer *mBuf -) -#else -PUBLIC S16 PjUiPjuDatReq(pst, spId, pdcpId, sduId, mBuf) -Pst *pst; -SpId spId; -CmLtePdcpId *pdcpId; -PjuSduId sduId; -Buffer *mBuf; -#endif -{ -#ifndef NO_ERRCLS - S16 ret; /* Return Value */ -#endif - PjDlRbCb *pjRbCb; /* RB Control Block */ - PjDlUeCb *ueCb; /* UE Control Block */ -#ifndef CCPU_OPT - MsgLen len; /* Size of the SDU */ -#endif -#ifndef NO_ERRCLS - PjPjuSapCb *pjuSap; /* SAP Config Block */ -#endif - PjCb *tPjCb; - U32 count; /* count for the PDU */ -#ifndef CCPU_OPT - PjuDatCfmInfo *datCfm; - CmLtePdcpId *tPdcpId; - PjPjuSapCb *tPjuSap; -#endif /*CCPU_OPT */ - TRC3(PjUiPjuDatReq) - -#ifdef CA_PHY_BRDCM_61765 - EXTERN U32 dlrate_pju1; - MsgLen len; - SFndLenMsg(mBuf, (MsgLen *) &len); - dlrate_pju1 += len; -#endif - - if ((pst->dstInst >= PJ_MAX_PDCP_INSTANCES) || (mBuf == NULLP)) /* KW_FIX */ - { - PJ_PST_FREE(pst->region, pst->pool, pdcpId, sizeof(CmLtePdcpId)); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - - tPjCb = PJ_GET_PJCB(pst->dstInst); - -#ifndef NO_ERRCLS - pjuSap = NULLP; -#endif - -#ifndef NO_ERRCLS - ret = ROK; - pjuSap = (PjPjuSapCb*)(tPjCb->u.dlCb->pjuSap + spId); - /* Validate SAP ID under ERRORCLS */ - PJ_VALDATE_SAP(tPjCb, spId, pjuSap, ret); - if (ret != ROK) - { - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } -#endif - /* Fetch the RbCb */ - if (pjDbmFetchDlUeCb(tPjCb, pdcpId->ueId, pdcpId->cellId, &ueCb) != ROK) - { - RLOG_ARG1(L_ERROR, DBG_CELLID, pdcpId->cellId,"DL UeId[%u] not found", - pdcpId->ueId); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - /* Fetch the RbCb */ - - PJ_DBM_FETCH_DL_RBCB(pdcpId->rbId, pdcpId->rbType, ueCb,pjRbCb); - if (pjRbCb == NULLP) - { - RLOG_ARG2(L_ERROR, DBG_UEID,pdcpId->ueId, "CellId[%u]: DL RbId[%d] not found", - pdcpId->cellId, pdcpId->rbId); - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } - - /* Update the total packets received for L2 Measurements */ - PJ_UPD_L2_DLDISC_PKT_STS(tPjCb,pjRbCb); - -#ifdef PTPJLIB - /* kw003.201 Control for packet administration */ - if (pjLibPktAdmCtrl(pjRbCb, mBuf) != ROK) - { - RLOG_ARG2(L_DEBUG,DBG_UEID,pdcpId->ueId, "Pju Dat Req: PDCP pkt dropped for" - " cellId(%d),rbId(%d)", pdcpId->cellId, pdcpId->rbId); - PJ_FREE_BUF(mBuf); - gPdcpStats.numPdcpSdusDiscarded++; - PJ_UPD_L2_DLDISC_STS(tPjCb, pjRbCb); - { -#ifdef CA_PHY_BRDCM_61765 - EXTERN U32 gDbgPdcpDropCnt; - gDbgPdcpDropCnt++; -#endif - } - RETVALUE(RFAILED); - } -#endif -#ifndef CCPU_OPT - SFndLenMsg(mBuf, &len); - if ( len > PJ_MAX_SDU_SIZE ) - { -#if (ERRCLASS & ERRCLS_INT_PAR) - RLOG_ARG2(L_ERROR, DBG_RBID, pjRbCb->rbId , "Processing DL Sdu failed, PDU size [%lu] > MAX_LEN [%lu]", - len, PJ_MAX_SDU_SIZE); -#endif /* ERRCLASS & ERRCLS_INT_PAR */ - - if ( pjRbCb->dlCb.cfmReqd) - { - if (pjRbCb->rbType == PJ_SRB) - tPjuSap = (PjPjuSapCb*)(tPjCb->pjuSap + PJ_SRB_SAP); - else - tPjuSap = (PjPjuSapCb*)(tPjCb->pjuSap + PJ_DRB_SAP); - - datCfm = &datCfmTmp; - tpdcpId = &tpdcpIdTmp; - - datCfm->cfmSta[datCfm->numSdus].sduId = sduId; - datCfm->cfmSta[datCfm->numSdus].status = PJU_MAX_SDU_SIZ_EXCEED; - datCfm->numSdus++; - tPdcpId->rbId = pjRbCb->rbId; - tPdcpId->rbType = pjRbCb->rbType; - tPdcpId->ueId = pjRbCb->ueCb->key.ueId; - tPdcpId->cellId = pjRbCb->ueCb->key.cellId; - PjUiPjuDatCfm(&(tPjuSap->pst), tPjuSap->suId, tPdcpId, datCfm); - } - - tPjCb->pjGenSts.numCmpFails++; - - PJ_FREE_BUF(mBuf); - RETVALUE(RFAILED); - } -#endif - - if((pjRbCb->state != PJ_STATE_NORMAL) && (pjRbCb->rbType != PJ_SRB)) - { -#ifdef PRE_DEF_UE_CTX_HO - pjRbCb->state = PJ_STATE_NORMAL; -#endif - if(pjRbCb->dlCb.dlPktQ.count < 500) - { -/* MSPD_DBG(" Queuing the Packets in Reestablish/Ho state ");*/ - pjDlmEnqueueDlPkt(tPjCb, pjRbCb, PJ_DATA_NRM_PKT, NULL, sduId, mBuf); - RETVALUE(ROK); - } - else - { - PJ_FREE_BUF(mBuf); - gPdcpStats.numPdcpSdusDiscarded++; - PJ_UPD_L2_DLDISC_STS(tPjCb, pjRbCb); - RETVALUE(RFAILED); - } - } - PJ_DLM_UPD_VAR(pjRbCb,count); - pjDlmProcessSdus(tPjCb, pjRbCb, mBuf, sduId,count); - - /* kw005.201 ccpu00117318, updated statistics */ - RETVALUE(ROK); -} /* PjUiPjuDatReq */ - - -#ifdef FLAT_BUFFER_OPT -/** - * @details - * This primitive is used by the PDCP service user to request PDCP - * for data transfer. - * - * @param[in] pst - Pointer to Pst structure. - * @param[in] spId - Service provider ID. This is the reference number - * used by PDCP service user (Relay) to identify its SAP. This reference number - * will be provided by PDCP in any further primitives sent by PDCP - * to the service user. - * @param[in] pdcpId - Pointer to CmLtePdcpId structure, PDCP id is used to - * uniquely identify an PDCP entity. - * @param[in] sduId - SDU ID. - * @param[in] mBuf - Pointer to Flat buffer. - * - * @return ROK - */ - -#ifdef ANSI -PUBLIC S16 PjUiPjuDatReqFB -( -Pst *pst, -SpId spId, -CmLtePdcpId *pdcpId, -PjuSduId sduId, -FlatBuffer *mBuf -) -#else -PUBLIC S16 PjUiPjuDatReqFB(pst, spId, pdcpId, sduId, mBuf) -Pst *pst; -SpId spId; -CmLtePdcpId *pdcpId; -PjuSduId sduId; -FlatBuffer *mBuf; -#endif -{ - PjDlRbCb *pjRbCb; /* RB Control Block */ - PjDlUeCb *ueCb; /* UE Control Block */ -#ifndef CCPU_OPT - MsgLen len; /* Size of the SDU */ -#endif -#ifndef NO_ERRCLS - PjPjuSapCb *pjuSap; /* SAP Config Block */ -#endif - PjCb *tPjCb = NULLP;/* KW_FIX */ - PjTxEnt *txEnt=NULLP; -#ifndef NO_ERRCLS - S16 ret; /* Return Value */ - PjUeKey key; -#endif - -#ifdef L2_PDCP_OPTMZ - U8 hashKey; /* Computed HashKey */ - PjBuf *buf; -#endif - TRC3(PjUiPjuDatReqFB) - - if ((pst->dstInst >= PJ_MAX_PDCP_INSTANCES) || (mBuf == NULLP)) /* KW_FIX */ - { - /* PJ_FREE_FLAT_BUF(tPjCb, mBuf); */ - RETVALUE(RFAILED); - } - - tPjCb = PJ_GET_PJCB(pst->dstInst); - -#ifndef NO_ERRCLS - ret = ROK; - pjuSap = NULLP; -#endif - -#ifdef DEBUGP - /* DEBUG_PRINT */ - RLOG1(L_DEBUG, "PjUiPjuDatReq(pst, spId(%d))", spId); -#endif - -#ifndef NO_ERRCLS - pjuSap = (PjPjuSapCb*)(tPjCb->u.dlCb->pjuSap + spId); - /* Validate SAP ID under ERRORCLS */ - PJ_VALDATE_SAP(tPjCb, spId, pjuSap, ret); - if (ret != ROK) - { - PJ_FREE_FLAT_BUF(tPjCb, mBuf); - RETVALUE(RFAILED); - } -#endif - /* Fetch the UeCb */ - if (pjDbmFetchDlUeCb(tPjCb, pdcpId->ueId, pdcpId->cellId, &ueCb) != ROK) - { - RLOG_ARG1(L_ERROR, DBG_CELLID, pdcpId->cellId,"DL UeId[%u] not found", - pdcpId->ueId); - PJ_FREE_FLAT_BUF(tPjCb, mBuf); - RETVALUE(RFAILED); - } - /* Fetch the RbCb */ - PJ_DBM_FETCH_DL_RBCB(pdcpId->rbId, pdcpId->rbType, ueCb,pjRbCb); - - if (pjRbCb == NULLP) - { - RLOG_ARG2(L_ERROR, DBG_UEID,pdcpId->ueId, "CellId[%u]: DL RbId[%d] not found", - pdcpId->cellId, pdcpId->rbId); - PJ_FREE_FLAT_BUF(tPjCb, mBuf); - RETVALUE(RFAILED); - } - - /* Update the total packets received for L2 Measurements */ - PJ_UPD_L2_DLDISC_PKT_STS(tPjCb,pjRbCb); - -#ifdef PTPJLIB - /* kw003.201 Control for packet administration */ - - if (pjLibPktAdmCtrl(pjRbCb, NULL) != ROK) - { - RLOG_ARG2(L_DEBUG,DBG_UEID,pdcpId->ueId,"PDCP pkt Q is Full & pkt dropped" - " for cellId(%d), rbId(%d)", pdcpId->cellId, pdcpId->rbId); - PJ_FREE_FLAT_BUF(tPjCb, mBuf); - gPdcpStats.numPdcpSdusDiscarded++; - PJ_UPD_L2_DLDISC_STS(tPjCb, pjRbCb); - RETVALUE(RFAILED); - } -#endif - - if((ueCb->libInfo.state != PJ_STATE_NORMAL) && (pjRbCb->rbType != PJ_SRB)) - { - if(pjRbCb->dlCb.dlPktQ.count < 500) - { - pjDlmEnqueueDlPktFB(tPjCb, pjRbCb, PJ_DATA_NRM_PKT, NULL, sduId, mBuf); - RETVALUE(ROK); - } - else - { - PJ_FREE_FLAT_BUF(tPjCb, mBuf); - gPdcpStats.numPdcpSdusDiscarded++; - PJ_UPD_L2_DLDISC_STS(tPjCb, pjRbCb); - RETVALUE(RFAILED); - } - } - - PJ_ALLOC(tPjCb, txEnt, sizeof(PjTxEnt)); -#if (ERRCLASS & ERRCLS_ADD_RES) - if (txEnt == NULLP) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - PJ_FREE_FLAT_BUF(gCb,sdu); - RETVALUE(RFAILED); - } -#endif /* ERRCLASS & ERRCLS_RES */ - PJ_DLM_UPD_VAR(pjRbCb,txEnt->count); - PJ_DLM_GET_SN(pjRbCb,txEnt->count,txEnt->sn); - pjRbCb->dlCb.count = txEnt->count; - txEnt->state = PJ_SDU_RECEIVED; - txEnt->sduId = sduId; - txEnt->fb = *mBuf; - txEnt->pdu = NULLP; - txEnt->sdu = NULLP; - /* Insert TxEnt into the transmission buffer */ -#ifndef L2_PDCP_OPTMZ - pjDbmInsTxEnt(tPjCb, &(pjRbCb->dlCb.txBuf), txEnt); - /* kw005.201 added support for L2 Measurement */ -#else - if (pjRbCb->ueCb->secInfo.secAct && pjRbCb->ueCb->secInfo.cipherInfo.algoType != 0) /* If its not NULL Ciphering and Security is enabled */ - { - txEnt->datCfmEnt.node = NULLP; - txEnt->reEstPktEnt.node = NULLP; - txEnt->sduSubmitEnt.node = (PTR)NULLP; - - buf=&(pjRbCb->dlCb.txBuf); - hashKey = (U8)PJ_HASH_FN(buf, txEnt->count); /*KW_FIX*/ - - txEnt->lstEnt.node = (PTR)txEnt; - cmLListAdd2Tail(&buf->datQ[hashKey], &txEnt->lstEnt); - buf->numEntries ++; - /* No Need to add TxEnt in DataCfm Quee as no Cfm from RLC */ - if (pjRbCb->mode == PJ_DRB_AM) - { - txEnt->datCfmEnt.node = (PTR)txEnt; - cmLListAdd2Tail(&pjRbCb->dlCb.txBuf.datCfmQ, &txEnt->datCfmEnt); - } - txEnt->state = PJ_PDU_SUBMITTED; - } - else - { - pjDbmInsTxEnt(tPjCb, &(pjRbCb->dlCb.txBuf), txEnt); - } -#endif - -#ifndef RGL_SPECIFIC_CHANGES -#ifdef MSPD - { - extern U32 dlrate_pju; - dlrate_pju += mBuf->len; - } -#endif -#endif - pjDlmHdlCmp(tPjCb, pjRbCb, txEnt); - /*pjDlmProcessSdusFB(tPjCb, pjRbCb, mBuf, sduId, sn, txHfn);*/ - - /* kw005.201 ccpu00117318, updated statistics */ - RETVALUE(ROK); -} /* PjUiPjuDatReqFB */ -#endif - -/** - * - * @details - * This primitive is used by PDCP user to forward the SDUs along with its SN - * as part of handover (SDUs forwarded from PDCP on source eNB via X2-U - * Interface to the PDCP on target eNB) - * - * @param[in] pst - Pointer to Pst structure. - * @param[in] spId - Service provider ID. This is the reference number - * used by PDCP service user (Relay) to identify its SAP. This reference number - * will be provided by PDCP in any further primitives sent by PDCP - * to the service user. - * @param[in] pdcpId - Pointer to CmLtePdcpId structure, PDCP id is used to - * uniquely identify a PDCP entity. - * @param[in] datFwdReq - Pointer to data forward information structure. - * - * @return ROK. - */ -#ifdef ANSI -PUBLIC S16 PjUiPjuDatFwdReq -( -Pst *pst, -SpId spId, -CmLtePdcpId *pdcpId, -PjuDatFwdReqInfo *datFwdReq -) -#else -PUBLIC S16 PjUiPjuDatFwdReq(pst,spId,pdcpId,datFwdReq) -Pst *pst; -SpId spId; -CmLtePdcpId *pdcpId; -PjuDatFwdReqInfo *datFwdReq; -#endif -{ - - S16 ret; /* Return Value */ - PjPjuSapCb *pjuSap; /* SAP Config Block */ - PjCb *tPjCb; - - TRC3(PjUiPjuDatFwdReq) - /* ccpu00137221 : KW Fix */ - if ( NULLP == datFwdReq ) - { - /* Log an error */ -#if (ERRCLASS & ERRCLS_INT_PAR) - if (pst->dstInst < PJ_MAX_PDCP_INSTANCES) - { - tPjCb = PJ_GET_PJCB(pst->dstInst); - if (tPjCb != NULLP) - { - RLOG0(L_ERROR, "Hndl DatFwdReq failed ,tPjCb is NULLP"); - } - } -#endif /* ERRCLASS & ERRCLS_INT_PAR */ - RETVALUE(RFAILED); - } - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) - { - PJ_PST_FREE(pst->region, pst->pool, datFwdReq->datFwdInfo, - (datFwdReq->numSdus * sizeof(PjuDatFwdInfo))); - PJ_PST_FREE(pst->region, pst->pool, datFwdReq, sizeof(PjuDatFwdReqInfo)); - RETVALUE(RFAILED); - } - tPjCb = PJ_GET_PJCB(pst->dstInst); - - ret = ROK; - pjuSap = NULLP; - - RLOG1(L_DEBUG, "PjUiPjuDatFwdReq(pst, spId(%d))", spId); - - if (( datFwdReq->dir == PJ_DIR_DL ) && - (tPjCb->pjGenCfg.mode == LPJ_MODE_PDCP_DL)) - - { - PjDlUeCb *dlUeCb; /* UE Control Block */ - PjDlRbCb *dlRbCb; /* RB Control Block */ - pjuSap = (PjPjuSapCb*)(tPjCb->u.dlCb->pjuSap + spId); - /* Validate SAP ID under ERRORCLS */ - PJ_VALDATE_SAP(tPjCb, spId, pjuSap, ret); - if (ret != ROK) - { - /* Freeing from proper region */ - PJ_PST_FREE(pst->region, pst->pool, datFwdReq->datFwdInfo, - (datFwdReq->numSdus * sizeof(PjuDatFwdInfo))); - PJ_PST_FREE(pst->region, pst->pool, datFwdReq, sizeof(PjuDatFwdReqInfo)); - RETVALUE(RFAILED); - } - - if (pjDbmFetchDlUeCb(tPjCb, pdcpId->ueId, pdcpId->cellId, &dlUeCb) != ROK) - { - RLOG_ARG1(L_ERROR, DBG_CELLID, pdcpId->cellId,"DL UeId[%u] not found", - pdcpId->ueId); - /* Freeing from proper region */ - PJ_PST_FREE(pst->region, pst->pool, datFwdReq->datFwdInfo, - (datFwdReq->numSdus * sizeof(PjuDatFwdInfo))); - PJ_PST_FREE(pst->region, pst->pool, datFwdReq, sizeof(PjuDatFwdReqInfo)); - RETVALUE(RFAILED); - } - /* Fetch the RbCb */ - PJ_DBM_FETCH_DL_RBCB(pdcpId->rbId, pdcpId->rbType, dlUeCb,dlRbCb); - if (dlRbCb == NULLP) - { - RLOG_ARG2(L_ERROR, DBG_UEID,pdcpId->ueId, "CellId[%u]: DL RbId[%d] not found", - pdcpId->cellId, pdcpId->rbId); - /* Freeing from proper region */ - PJ_PST_FREE(pst->region, pst->pool, datFwdReq->datFwdInfo, - (datFwdReq->numSdus * sizeof(PjuDatFwdInfo))); - PJ_PST_FREE(pst->region, pst->pool, datFwdReq, sizeof(PjuDatFwdReqInfo)); - - RETVALUE(RFAILED); - } - - if (dlRbCb->state == PJ_STATE_HO) - { - pjDlmEnqueueDlPkt(tPjCb,dlRbCb, PJ_DATA_FWD_PKT, datFwdReq, 0, NULLP); - } - else - { - ret = pjDlmHndlDatFwdReq(tPjCb, dlRbCb, datFwdReq); - } - - PJ_PST_FREE(pst->region, pst->pool, datFwdReq->datFwdInfo, - (datFwdReq->numSdus * sizeof(PjuDatFwdInfo))); - PJ_PST_FREE(pst->region, pst->pool, datFwdReq, sizeof(PjuDatFwdReqInfo)); - - } - else if (( datFwdReq->dir == PJ_DIR_UL ) && - (tPjCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL)) - { - PjUlRbCb *ulRbCb; /* RB Control Block */ - PjUlUeCb *ulUeCb; - pjuSap = (PjPjuSapCb*)(tPjCb->u.ulCb->pjuSap + spId); - /* Validate SAP ID under ERRORCLS */ - pjuSap->state = PJ_SAP_BND; - PJ_VALDATE_SAP(tPjCb, spId, pjuSap, ret); - if (ret != ROK) - { - /* Freeing from proper region */ - PJ_PST_FREE(pst->region, pst->pool, datFwdReq->datFwdInfo, - (datFwdReq->numSdus * sizeof(PjuDatFwdInfo))); - PJ_PST_FREE(pst->region, pst->pool, datFwdReq, sizeof(PjuDatFwdReqInfo)); - RETVALUE(RFAILED); - } - - if (pjDbmFetchUlUeCb(tPjCb, pdcpId->ueId, pdcpId->cellId, &ulUeCb) != ROK) - { - RLOG_ARG1(L_ERROR, DBG_CELLID, pdcpId->cellId,"UL UeId[%u] not found", - pdcpId->ueId); - /* Freeing from proper region */ - PJ_PST_FREE(pst->region, pst->pool, datFwdReq->datFwdInfo, - (datFwdReq->numSdus * sizeof(PjuDatFwdInfo))); - PJ_PST_FREE(pst->region, pst->pool, datFwdReq, sizeof(PjuDatFwdReqInfo)); - RETVALUE(RFAILED); - } - /* Fetch the RbCb */ - PJ_DBM_FETCH_UL_RBCB(pdcpId->rbId, pdcpId->rbType, ulUeCb,ulRbCb); - if (ulRbCb == NULLP) - { - RLOG_ARG2(L_ERROR, DBG_UEID,pdcpId->ueId, "CellId[%u]: UL RbId[%d] not found", - pdcpId->cellId, pdcpId->rbId); - /* Freeing from proper region */ - PJ_PST_FREE(pst->region, pst->pool, datFwdReq->datFwdInfo, - (datFwdReq->numSdus * sizeof(PjuDatFwdInfo))); - PJ_PST_FREE(pst->region, pst->pool, datFwdReq, sizeof(PjuDatFwdReqInfo)); - - RETVALUE(RFAILED); - } - - ret = pjUlmHdlDatFwdReq(tPjCb, ulRbCb, datFwdReq); - PJ_PST_FREE(pst->region, pst->pool, datFwdReq->datFwdInfo, - (datFwdReq->numSdus * sizeof(PjuDatFwdInfo))); - PJ_PST_FREE(pst->region, pst->pool, datFwdReq, sizeof(PjuDatFwdReqInfo)); - } - - /* Freeing from proper region */ - - if ( ret != ROK ) - { - /* Log an error */ -#if (ERRCLASS & ERRCLS_INT_PAR) - RLOG0(L_ERROR, "pjDlm/pjUlm HndlDatFwdReq failed"); -#endif /* ERRCLASS & ERRCLS_INT_PAR */ - - } - RETVALUE(ret); -} - - -/** - * @brief Handler for Bind request from RRM towards CL. - * - * @details - * - * Function : YsUiCpjKdfReq - * - * This function handles the bind request from RRM. - * - * - * @param[in] Pst *pst - * @param[in] SuId suId - * @param[in] SpId spId - * @return S16 - * -# ROK - * -# RFAILED - **/ -#ifdef ANSI -PUBLIC S16 PjUiCpjKdfReq -( -Pst *pst, -SpId spId, -CpjCfgTransId transId, -CpjKdfReqInfo *kdfReqInfo -) -#else -PUBLIC S16 PjUiCpjKdfReq(pst, suId, spId) -Pst *pst; -SuId suId; -SpId spId; -#endif -{ - S16 ret; - CpjKdfCfmInfo *kdfCfmInf; - PjCb *tPjCb; - Pst cfmPst; - PjCpjSapCb *cpjSap; - - - TRC2(PjUiCpjKdfReq) - - ret = ROK; - - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) /* KW_FIX */ - { - RETVALUE(RFAILED); - } - tPjCb = PJ_GET_PJCB(pst->dstInst); - - /* Memory leak fix ccpu00135359 */ - cpjSap = &(tPjCb->u.ulCb->cpjSap); - if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,(Data **)&kdfCfmInf, - sizeof (CpjKdfCfmInfo)) != ROK) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } - - cfmPst.dstInst = pst->srcInst; - cfmPst.dstEnt = pst->srcEnt; - cfmPst.dstProcId = pst->srcProcId; - cfmPst.srcInst = pst->dstInst; - cfmPst.srcEnt = pst->dstEnt; - cfmPst.srcProcId = pst->dstProcId; - cfmPst.selector = 0; - cfmPst.region = tPjCb->init.region; - cfmPst.pool = tPjCb->init.pool; - cfmPst.prior = PRIOR0; - cfmPst.route = RTESPEC; - - RLOG1(L_DEBUG, "Key derivation request for Key type %d", - kdfReqInfo->keyDerType); - - switch(kdfReqInfo->keyDerType) - { - case CPJ_KDF_TYPE1: - kdfCfmInf->keyDerType = CPJ_KDF_TYPE1; - ret = pjLibObdPrcKenbCfg(tPjCb, &(kdfReqInfo->u.kEnbInf), - &(kdfCfmInf->u.kEnbInf)); - break; - - case CPJ_KDF_TYPE2: - kdfCfmInf->keyDerType = CPJ_KDF_TYPE2; - ret = pjLibObdPrcKenbStarCfg(tPjCb, &(kdfReqInfo->u.kEnbStarInf), - &(kdfCfmInf->u.kEnbStarInf)); - break; - - case CPJ_KDF_TYPE3: - break; - default: - break; - } - /* Send Cfg confirm */ - if(ret != ROK) - { - PjUiCpjKdfCfm(&cfmPst, PJ_KDF_SAP, - transId, kdfCfmInf, CPJ_CFG_CFM_NOK); - }// Sudhanshu WR Change - else - { - PjUiCpjKdfCfm(&cfmPst, PJ_KDF_SAP, - transId, kdfCfmInf, CPJ_CFG_CFM_OK); - } - - - SPutSBuf (pst->region, pst->pool, (Data *)kdfReqInfo, - sizeof(CpjKdfReqInfo)); - kdfReqInfo = NULLP; - - RETVALUE(ret); - -} /* PjUiCpjKdfReq */ - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ -/********************************************************************30** - End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_ul.h b/src/5gnrpdcp/pj_ul.h deleted file mode 100755 index f9b6f9ea4..000000000 --- a/src/5gnrpdcp/pj_ul.h +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: LTE PDCP file - - Type: C include file - - Desc: This file contain the hash definations for PDCP - - File: pj_ul.h - -*********************************************************************21*/ -/** @file pj_ul.h -@brief PDCP Hash definitions -*/ - -#ifndef __PJ_ULH__ -#define __PJ_ULH__ -#define PJ_MAX_NUM_OF_BITS 4096 - -#define PJ_DBM_FETCH_UL_RBCB(_rbId, _rbType, _ueCb, _rbCb) \ -{ \ - _rbCb = (_rbType==CM_LTE_SRB)?_ueCb->srbCb[_rbId]:_ueCb->drbCb[_rbId];\ -} - -/* HO_FIX: Changed the success value to ROK as RRC expects - ROK or RFAILED */ -#define PJ_FILL_UL_SDU_CFM_INFO(_cb,_cfmInfo,_tempDlStaInfo,_ueCb) \ -{ \ - U8 _rbCnt; \ - U8 _numRb = 0; \ - PjUlHoCfmInfo *_hoCfmInfo; \ - CpjSduStaInfo *_staInfo; \ - Bool _rbPres; \ - _cfmInfo->ueId = _ueCb->key.ueId; \ - _cfmInfo->cellId = _ueCb->key.cellId; \ - _cfmInfo->transId = _ueCb->hoInfo->transId; \ - for(_rbCnt = 0; _rbCnt < PJ_MAX_DRB_PER_UE && _numRb < CPJ_MAX_DRB; _rbCnt++) \ - { \ - _rbPres = FALSE; \ - _hoCfmInfo = &_ueCb->hoInfo->hoCfmInfo[_rbCnt]; \ - _staInfo = &_cfmInfo->sduStaInfo[_numRb]; \ - if(_hoCfmInfo->pres == TRUE) \ - { \ - _rbPres = TRUE; \ - _staInfo->rbId = _hoCfmInfo->rbId; \ - _staInfo->dir |= _hoCfmInfo->dir; \ - _staInfo->ulSduStaInfo.numBits = _hoCfmInfo->numBits; \ - _staInfo->ulSduStaInfo.ulBitMap = _hoCfmInfo->ulBitMap;\ - _staInfo->ulSduStaInfo.count = _hoCfmInfo->count; \ - _hoCfmInfo->ulBitMap = NULLP; \ - } \ - if(tempDlStaInfo[_rbCnt].dlSduStaInfo.hoPres == TRUE) \ - { \ - _rbPres = TRUE; \ - _staInfo->rbId = _tempDlStaInfo[_rbCnt].rbId; \ - _staInfo->dir |= _tempDlStaInfo[_rbCnt].dir; \ - _staInfo->dlSduStaInfo.count = _tempDlStaInfo[_rbCnt].dlSduStaInfo.count; \ - } \ - if(_rbPres != TRUE) \ - { \ - continue; \ - } \ - else \ - { \ - _numRb++; \ - } \ - } \ - _cfmInfo->numRb = _numRb; \ - _cfmInfo->status = ROK; \ - _cfmInfo->reason = CPJ_CFG_REAS_NONE; \ - PJ_FREE(_cb,_ueCb->hoInfo->hoCfmInfo, \ - (PJ_MAX_DRB_PER_UE * sizeof(PjUlHoCfmInfo))); \ - PJ_FREE(_cb,_ueCb->hoInfo, sizeof(PjUlHoInfo)); \ -} - -#define PJ_DBM_DELETE_UL_RBCB(_cb, _rbCb) \ -{ \ - /* Free memory for rbCb */ \ - PJ_FREE(_cb, _rbCb, sizeof(PjUlRbCb)); \ - PJ_LMM_RB_STS_DEC(_cb); \ -} - -#endif /* __PJH__ */ - -/********************************************************************30** - - End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_ul.x b/src/5gnrpdcp/pj_ul.x deleted file mode 100755 index d1fe8407d..000000000 --- a/src/5gnrpdcp/pj_ul.x +++ /dev/null @@ -1,781 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: LTE PDCP file - - Type: C include file - - Desc: This file contains all the data structures and - prototypes for LTE PDCP. - - File: pj_ul.x - -*********************************************************************21*/ -/** @file pj_ul.x -@brief PDCP Product Structures, prototypes -*/ - -#ifndef __PJ_UL_X__ -#define __PJ_UL_X__ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** @struct PjRbCb -RLC RB control block */ -typedef struct pjUlUeCb PjUlUeCb; -typedef struct pjUlRbCb PjUlRbCb; /* PDCP RB control block */ - -/** @addtogroup dldata */ -/*@{*/ - -/** - * @brief - * PDCP SDU Status Information for a DRB mapped to RLC AM. - */ - -typedef struct pjUlHoCfmInfo -{ - U8 rbId; /*!< RB ID */ - Bool pres; /*!< Is handover info present for this RB */ - U8 dir; /*!< Direction of the RB */ - U8 res1; - U8 numBits; /*!< Number of bits in UL bitmap */ - U8 res2[3]; - U8 *ulBitMap; /*!< Status Report bitmap of PDUs */ - U32 count; /*!< UL Count value with FMS */ -}PjUlHoCfmInfo; - -/** - * @brief - * Handover information maintainned during processing of SduStaReq - */ -typedef struct pjUlHoInfo -{ - U32 transId; /*!< Transaction ID */ - UdxSduStaCfmInfo *staCfm; /*!< SduStaCfm received from DL */ - PjUlHoCfmInfo *hoCfmInfo; /*!< SDU Status Confirm */ -}PjUlHoInfo; - -/** @defgroup uldata UL Module Info -*/ -/** @addtogroup uldata */ -/*@{*/ - -/** @struct PjRxEnt -PDCP Rx Entry - PDU received from RLC */ -typedef struct pjRxEnt -{ - CmLList lstEnt; /*!< List entry for PDU */ - CmLList datPktEnt; /*!< List entry for PDU */ - U8 state; /*!< PDU state */ - Bool discFlag; /*!< Whether entry can be discarded - after processing */ - Bool dupEntry; /*!< Duplicate Entry, These entries - are not inserted */ - Bool res; /*!< Reserved */ - U32 count; /*!< COUNT associated with this PDU */ - Buffer *mBuf; /*!< Buffer to store the pdu during processing */ -#ifdef SS_RBUF - PjUlRbCb *rbCb; -#endif - Bool isOutSeq; /*!< flag to tell whether this is a in-sequence packet or not */ -}PjRxEnt; - -/** @struct PjUlCb -PDCP uplink control block */ -typedef struct pjUlCb -{ - - U32 rxNext; /*next expected pdcp pdu counter */ - U32 rxDeliv; /*next delivered pdu count to the upper layer*/ - U32 rxReord; /* Holds the count value of Data PDU which triggered t-Reordering */ - Bool outOfOrderDelivery; /*Out of Delivery is configured or not*/ - Bool staRepReqd; /*!< Flag to indicate if status report - is required */ - Bool discReqd; /*!< Flag to indicate if the PDU can - be discarded during Integrity - failure */ - Bool transCmp; /*!< Whether transmission of PDUs from RLC - during reestablishment is complete */ - U8 state; /*!< RB state for the UL entity */ - PjBuf recBuf; /*!< Reception buffer */ - U32 nxtSubCnt; /*!< Count of next SDU to be submitted - to the upper layer. Used in SRB, DRBUM */ - U32 nxtSubDeCmp; /*!< Count of next PDU to be submitted - to the decompression unit */ - - U32 obdPdu; /*!< Count of the Pdu sent for offboarding */ - U32 firstReEstCnt; /*!< Count of the first PDU received after - reestablishment was triggered */ -#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) - CmTimer obdTmr; /*!< Offboard timer */ - U32 obdCnt; /*!< OBD Count */ -#endif /* (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) */ - CmLListCp ulPktLst; /*!< Queues the message during - Re-establishment/Handover */ - U32 fmsCount; /*!< To store the Count value (FMS + HFN) at the time Out-Of-Sequence */ - /* Added for UL UU LOSS */ -#ifdef LTE_L2_MEAS - PjSn nxtSubSn; /*!< PDCP SN to be submitted to UL next */ -#endif - CmTimer tReordTmr; /*!< t-Reorder timer */ -}PjUlCb; -/*@}*/ - - -/** @struct PjRbCb -PDCP RB control block */ -struct pjUlRbCb -{ - CmLteRbId rbId; /*!< RB Id for PDCP Cb */ - U8 rbType; /*!< RB Type : 0 - PJ_SRB, 1 - PJ_DRB */ - CmLteRlcMode mode; /*!< Mapped RLC entity's mode */ - U8 dir; /*!< Direction for UL/DL/biderctional */ - U8 snLen; /*!< Sequence number length */ - U8 state; /*!< RB state - Used only for DRBs*/ - PjSn firstSn; /*!< SN of the first message sent - for Integrity Protection */ - PjRohc rohc; /*!< ROHC Information */ - PjCmpCxt cmpCxt; /*!< Context for ROHC */ - PTR cmpCxtId; /*!< Context Id for ROHC */ -/* pj005.201 added support for L2 Measurement */ -#ifdef LTE_L2_MEAS - U8 qci; /*!< QCI value associated with rb */ - PjL2MeasRbCb rbL2Cb; /*!< L2 Meas Cb for RB */ -#endif /* LTE_L2_MEAS */ -/** @defgroup dldata DL Module Info -*/ - PjUlCb ulCb; /*!< Uplink PDCP RbCb */ - PjUlUeCb *ueCb; /*!< Pointer to the UE in which RB is present */ - PjSec secInfo; /*!< Security Info */ - U16 reOrdrTmrVal; /* t-Reordering timer value in ms*/ -}; - - -/** @struct PjUeCb -UE control block */ -struct pjUlUeCb -{ - CmHashListEnt ueHlEnt; /*!< Hash list entry for UeCb */ - Inst inst; - PjUeKey key; /*!< Hash list key for UeCb */ - U8 numSrbs; - U8 numDrbs; - PjUlRbCb *srbCb[PJ_MAX_SRB_PER_UE]; /*!< SRB RbCbs within a UE */ - PjUlRbCb *drbCb[PJ_MAX_DRB_PER_UE]; /*!< DRB RbCbs within a UE */ - PjSec secInfo; /*!< Security Info */ - PjUlHoInfo *hoInfo; /*!< SDU Status Confirm */ - PjLibInfo libInfo; /*!< Hook Info - to wait for - Init Cfm */ -/* pj005.201 added support for L2 Measurement */ -#ifdef LTE_L2_MEAS - U16 numActRb[LPJ_MAX_QCI]; /* number of RBs Active */ -#endif /* LTE_L2_MEAS */ - Bool isUlDatFwdReqd; /*!< To identify whether App rqstd for UL Data Fwding or not */ -}; - -typedef struct pjUlPkt -{ - CmLList lnk; - PjSn sn; - Buffer *pdu; - U8 type; -} PjUlPkt; - -/* CFG Module */ -EXTERN S16 pjCfgAddUlRb ARGS ((PjCb *gCb,CmLteRnti ueId,CmLteCellId cellId,U8 isHo, - CpjCfgEnt *entCfg,PjUlUeCb **ueCb, CpjCfmEnt *entCfm )); - -EXTERN S16 pjCfgReCfgUlRb ARGS ((PjCb *gCb,PjUlUeCb *ueCb, - CpjCfgEnt *entCfg, CpjCfmEnt *entCfm)); - -EXTERN S16 pjCfgDelUlRb ARGS ((PjCb *gCb,PjUlUeCb *ueCb, - CpjCfgEnt *entCfg,CpjCfmEnt *entCfm)); - -EXTERN S16 pjCfgReEstUlRb ARGS (( -PjCb *gCb, -PjUlUeCb *ueCb, -CpjCfgEnt *entCfg, -CpjCfmEnt *entCfm, -UdxCfmEnt *entDlCfgCfm -)); - -EXTERN S16 pjCfgDelUlUe ARGS (( -PjCb *gCb, -PjUlUeCb *ueCb, -CpjCfgEnt *entCfg, -CpjCfmEnt *entCfm -)); - -EXTERN S16 pjCfgPrcSecUlCfg ARGS (( -PjCb *gCb, -CpjSecCfgReqInfo *secCfg, -CpjSecCfgCfmInfo *cfgCfm -)); - -EXTERN S16 pjCfgUlUeIdChng ARGS(( -PjCb *gCb, -CpjUeInfo *ueInfo, -CpjUeInfo *newUeInfo, -CmStatus *status -)); - -EXTERN S16 pjCfgPrcUlCount ARGS (( -PjCb *gCb, -CpjCountReqInfo *countReq, -CpjCountCfmInfo *countCfm, -UdxCountCfmInfo *cntCfm -)); - -EXTERN S16 pjCfgDelPjUlRbCb ARGS (( -PjCb *gCb, -PjUlUeCb *ueCb, -PjUlRbCb *rbCb -)); - -EXTERN S16 pjUtlUlCipherClose ARGS(( -PjCb *gCb, -Void *cpCxtId /* Context Id for Ciphering to be closed */ -)); - -EXTERN S16 pjUtlUlIntClose ARGS(( -PjCb *gCb, -Void *intCxtId /* Integration CxtId to be closed */ -)); - -EXTERN S16 pjCfgUlReEstReq ARGS (( -PjCb *gCb, -CpjReEstReqInfo *reEstReq, -CpjReEstCfmInfo *reEstCfm -)); -/* DB Module */ -EXTERN S16 pjDbmInsRxEnt ARGS (( -PjCb *gCb, -PjBuf *buf, -PjRxEnt *rxEnt, -Bool dupFlag -)); -EXTERN S16 pjDbmBufInit ARGS (( -PjCb *gCb, -PjBuf *buf, -U8 numBins -)); -EXTERN PjRxEnt* pjDbmGetRxEnt ARGS (( -PjCb *gCb, -PjBuf *buf, -U32 count -)); -EXTERN PjRxEnt* pjDbmGetRxEntSn ARGS (( -PjCb *gCb, -PjBuf *buf, -U16 sn -)); -EXTERN S16 pjDbmDelRxEnt ARGS (( -PjCb *gCb, -PjBuf *buf, -U32 count -)); -EXTERN S16 pjDbmRxDelAll ARGS(( -PjCb *gCb, -PjBuf *buf -)); -EXTERN S16 pjDbmRxDeInit ARGS (( -PjCb *gCb, -PjBuf *buf -)); - -EXTERN S16 pjDbmUlDeInit ARGS (( -PjCb *gCb -)); - -EXTERN S16 pjDbmFetchUlUeCb ARGS (( -PjCb *gCb, -CmLteRnti ueId, /* UE Identifier */ -CmLteCellId cellId, /* Cell Identifier */ -PjUlUeCb **ueCb /* UE Control Block */ -)); - -EXTERN S16 pjDbmCreateUlUeCb ARGS (( -PjCb *gCb, -CmLteRnti ueId, /* UE Identifier */ -CmLteCellId cellId, /* Cell Identifier */ -PjUlUeCb **ueCb /* UE Control Block */ -)); -EXTERN PjUlRbCb* pjDbmCreateUlRbCb ARGS (( -PjCb *gCb, -U8 rbId, -U8 rbType, -PjUlUeCb *ueCb, -U8 rb -)); - -EXTERN S16 pjDbmFetchUlRbCb ARGS (( -PjCb *gCb, -CmLteRlcId rlcId, /* RLC Identifier */ -PjUlRbCb **rbCb /* RB Cb */ -)); - -EXTERN S16 pjDbmDelUlRbCb ARGS (( -PjCb *gCb, -U8 rbId, -U8 rbType, -PjUlRbCb **rbCb, -U8 rb, -PjUlUeCb *ueCb -)); - -EXTERN S16 pjDbmDelUlUeCb ARGS(( -PjCb *gCb, -PjUlUeCb *ueCb, /* UE Identifier */ -Bool abortFlag /* Abort Flag */ -)); - -EXTERN S16 PjDbmDelAllUlUe ARGS((PjCb *gCb)); -EXTERN S16 pjDbmDelAllUlRb ARGS(( -PjCb *gCb, -PjUlRbCb **rbCbLst, /* RB Cb list */ -U8 numRbCb /* Number of rbCbs */ -)); -EXTERN S16 pjDbmDelAllUlUe ARGS (( -PjCb *gCb -)); - -EXTERN S16 pjDbmUlInit ARGS (( PjCb *gCb)); -EXTERN S16 pjDbmUlShutdown ARGS((PjCb *gCb)); -EXTERN S16 pjDbmAddUlTransIdLst ARGS((PjCb *gCb,PjCfgInfo *cfg)); -EXTERN S16 pjDbmFindUlTransIdLst ARGS((PjCb *gCb,U32 transId, - PjCfgInfo **cfg)); -EXTERN S16 pjDbmDelUlTransIdLst ARGS((PjCb *gCb,PjCfgInfo **cfg)); -EXTERN S16 pjDbmDelAllUlTransIdLst ARGS((PjCb *gCb)); - -EXTERN S16 pjUtlUlUpdUpSecKeys ARGS(( PjCb *gCb, PjUlUeCb *ueCb)); -EXTERN S16 pjUtlUlUpdCpSecKeys ARGS(( PjCb *gCb, PjUlUeCb *ueCb)); -EXTERN S16 pjUtlUlHdlRbReEstComplete ARGS((PjCb *gCb, PjUlRbCb *pjRbCb)); - - -EXTERN S16 pjUtlUlCmpReset ARGS(( -PjCb *gCb, -PjUlRbCb *pjRbCb /* Context to be reset for compression */ -)); - -/* UTL Module */ -EXTERN S16 pjUtlUlCmpInit ARGS(( -PjCb *gCb, -PjUlRbCb *pjRbCb /* PDCP RbCb */ -)); -EXTERN S16 pjUtlUlIntInit ARGS(( -PjCb *gCb, -PjUlUeCb *ueCb /* UE CB Ptr */ -)); -EXTERN S16 pjUtlUlCpInit ARGS(( -PjCb *gCb, -PjUlUeCb *ueCb /* UE CB Ptr */ -)); -EXTERN S16 pjUtlUlUpInit ARGS(( -PjCb *gCb, -PjUlUeCb *ueCb /* UE CB Ptr */ -)); - -EXTERN S16 pjUtlUlCmpReq ARGS(( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* PDCP RbCb */ -Buffer *mBuf, /* SDU to be compressed */ -Buffer **opSdu, /* Compressed SDU */ -U32 count /* COUNT - transaction Id */ -)); -EXTERN S16 pjUtlUlIntProtReq ARGS(( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* PDCP RbCb */ -PjSecInp secInp , /* Input parameters for integrity */ -Buffer *mBuf, /* SDU to be compressed */ -U32 *macI /* Message authentication code for the SDU */ -)); -EXTERN S16 pjUtlDeCmpReq ARGS(( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* PDCP RbCb */ -U32 count, /* COUNT - transaction Id */ -Buffer *mBuf, /* SDU to be compressed */ -Buffer **opSdu /* Compressed SDU */ -)); -EXTERN S16 pjUtlIntVerReq ARGS(( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* PDCP RbCb */ -PjSecInp secInp , /* Input parameters for integrity */ -Buffer *mBuf, /* SDU to be compressed */ -U32 macI, /* MAC-I to be verified with */ -Status *status /* Integrity verification status */ -)); -EXTERN S16 pjUtlDecipherReq ARGS(( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* PDCP RbCb */ -U32 count, /* count of packet */ -Buffer *mBuf, /* Data to be deciphered */ -Buffer **opSdu /* Deciphered SDU */ -)); -EXTERN S16 pjUtlSndFeedback ARGS(( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* PDCP RbCb */ -Buffer *feedback /* ROHC Feedback */ -)); -EXTERN S16 pjUtlUlReEstSrb1 ARGS(( -PjCb *gCb, -PjUlRbCb *pjRbCb /* PDCP Control Block Pointer */ -)); -EXTERN S16 pjUtlUlReEstStart ARGS(( -PjCb *gCb, -PjUlUeCb *ueCb, /* UE Control Block Pointer */ -CpjCfgReqInfo *cfgReq /* CfgReq for Reestablishment */ -)); -EXTERN S16 pjUtlUlReEstHOStart ARGS(( -PjCb *gCb, -PjUlUeCb *ueCb, /* Number of RBs undergoing reestablishment*/ -U32 transId, /* Transaction id of Sdu Status cfm */ -U32 *waitForHoTrig -)); -EXTERN S16 pjUtlUlReEstReconfig ARGS(( -PjCb *gCb, -PjUlUeCb *ueCb /* UE Control Block */ -)); -EXTERN S16 pjUtlUlReEstUl ARGS(( -PjCb *gCb, -PjUlUeCb *ueCb /* UE Control Block */ -)); -EXTERN S16 pjUtlUlSndReEstCfgCfm ARGS(( -PjCb *gCb, -PjUlUeCb *ueCb /* UE Control Block */ -)); -EXTERN S16 pjUtlUlSndSduStaCfm ARGS(( -PjCb *gCb, -PjUlUeCb *ueCb /* UE Control Block */ -)); -EXTERN S16 pjUtlUlShutdown ARGS(( -PjCb *gCb -)); -EXTERN Void pjUtlUlFreeRb ARGS(( -PjCb *gCb, -PjUlRbCb *pjRbCb -)); -/* kw005.201 added function to send data forward indication mesage */ -EXTERN S16 pjUtlUlSndDatFwdInd ARGS(( -PjCb *gCb, -PjUlRbCb *pjRbCb, -PjuDatFwdIndInfo *datFwdInd -)); -EXTERN S16 pjUtlUlSndUlStaRep ARGS (( -PjCb *gCb, -PjUlRbCb *pjRbCb, -Buffer *sta -)); - -EXTERN S16 pjUtlUlHdlObdInitCfm ARGS(( -PjCb *gCb, -PjUlUeCb *ueCb, /* Pointer to UeCb */ -U16 txIdx, /* Transaction Index for UeCb */ -U8 cfmType, /* Confirm type */ -U8 maskVal /* mask value */ -)); -EXTERN S16 pjUtlUlHdlInitObdTmrExp ARGS(( -PjCb *gCb, -PjUlUeCb *ueCb -)); - -EXTERN S16 pjCfgPrcUlSduSta ARGS(( -PjCb *gCb, -CpjSduStaReqInfo *staReq, -UdxSduStaCfmInfo *staCfm -)); - -EXTERN S16 pjUtlUlSaveCfmInfo ARGS(( -PjCb *gCb, -PjUlUeCb *ueCb, /* Pointer to UeCb */ -U8 cfmType, /* Confirm type */ -Bool startTmr, /* Whether to start timer */ -U8 entity, /* Confirm type */ -PTR cfmPtr, /* Pointer to the structure for confirm */ -PTR cfgPtr /* Pointer to the structure for request */ -)); - -/* UL Module */ -EXTERN S16 pjUlmHdlSrbPkt ARGS(( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* !< PDCP Control Block */ -Buffer *pdu /* !< PDU Buffer */ -)); -EXTERN S16 pjUlmHndlDlStaRep ARGS (( -PjCb *gCb, -PjUlRbCb *pjRbCb, -PjSn fmc, -Buffer *staPdu -)); - -#ifndef XEON_SPECIFIC_CHANGES -EXTERN U32 pjMsCheckSpaccQueue ARGS(( -Bool isUl -)); -#else -EXTERN U32 pjMsCheckSpaccQueue ARGS(( - Void - )); -#endif - -EXTERN S16 pjUlmHdlDrbPkt ARGS(( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* !< PDCP Control Block */ -Buffer *pdu, /* !< PDU Buffer */ -Bool isOutOfSeq /* !< To indicate whether this packet is in-sequence or not */ -)); -EXTERN S16 pjUlmProcessSrb ARGS(( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* !< PDCP Control Block */ -PjSn sn, /* !< SN value of PDU */ -Buffer *pdu /* !< PDU message buffer */ -)); -EXTERN S16 pjUlmProcessDrbUm ARGS(( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* !< PDCP Control Block */ -PjSn sn, /* !< SN value of PDU */ -Buffer *pdu /* !< PDU message buffer */ -)); -EXTERN S16 pjUlmProcessDrbAm ARGS(( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* !< PDCP Control Block */ -PjSn sn, /* !< SN value of PDU */ -Buffer *pdu, /* !< PDU message buffer */ -Bool isOutOfSeq /* !< To indicate whether packet received is in-sequence or not */ -)); -EXTERN S16 pjUlmHdlDecipher ARGS(( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* !< PDCP Control Block */ -PjRxEnt *rxEnt /* !< Rx Entry */ -)); -EXTERN S16 pjUlmHdlIntVer ARGS(( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* !< PDCP Control Block */ -PjRxEnt *rxEnt /* !< Rx Entry */ -)); -EXTERN S16 pjUlmHdlDeCmp ARGS(( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* !< PDCP Control Block */ -PjRxEnt *rxEnt /* !< Rx Entry */ -)); -EXTERN S16 pjUlmDeliverSrb ARGS(( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* !< PDCP Control Block */ -PjRxEnt *rxEnt /* !< Recption Buffer Entry */ -)); -EXTERN S16 pjUlmDeliverDrbUm ARGS(( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* !< PDCP Control Block */ -PjRxEnt *rxEnt /* !< Recption Buffer Entry */ -)); -EXTERN S16 pjUlmDeliverDrbAm ARGS(( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* !< PDCP Control Block */ -PjRxEnt *rxEnt /* !< Recption Buffer Entry */ -)); -EXTERN S16 pjUlmReEstSrb ARGS(( -PjCb *gCb, -PjUlRbCb *pjRbCb /*!< PDCP control block */ -)); -EXTERN S16 pjUlmReEstDrbAm ARGS(( -PjCb *gCb, -PjUlRbCb *pjRbCb /*!< PDCP control block */ -)); -EXTERN S16 pjUlmBldStaRep ARGS(( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* !< PDCP Control Block */ -PjSn fmc, /* !< First Missing count */ -U8 *staRep, /* !< Status Report */ -U16 bMapLen /* !< Bitmap Length */ -)); -EXTERN S16 pjUlmHdlDatFwdReq ARGS(( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* !< PDCP ID */ -PjuDatFwdReqInfo *datFwdReq /* !< DatFwdReq Info */ -)); -EXTERN S16 pjUlmSubmitForDecmp ARGS(( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* !< PDCP Control Block */ -PjRxEnt *rxEnt /* Ptr To Rx Entry */ -)); - -EXTERN Void pjUlmHdlObdTmrExpiry ARGS(( -PjCb *gCb, -PjUlRbCb *pjRbCb /* !< PDCP Control Block */ -)); - -EXTERN Void pjUlmHdlErrUpdates ARGS(( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* !< PDCP Control Block */ -U32 errCnt /* !< Count of PDU that raises the error */ -)); - -EXTERN Void pjLimDatInd ARGS(( -PjCb *gCb, -PjUlRbCb *pjRbCb, -Buffer *mBuf, -Bool isOutOfSeq -)); - -EXTERN Void pjLimReEstCmpInd ARGS(( -PjUlRbCb *pjRbCb -)); - -#ifdef LTE_L2_MEAS -S16 pjUtlL2MeasUlInit(PjCb *gCb); - -EXTERN Void pjUtlResetUlL2MeasCntr ARGS(( -PjCb *gCb, -PjL2MeasCb *measCb, -U8 measType -)); - -EXTERN S16 pjUtlSndUlL2MeasNCfm ARGS ((PjCb *gCb, - PjL2MeasCfmEvt *measCfmEvt)); - -EXTERN Void pjUtlPlcMeasDatInUlL2Sts ARGS((PjL2Cntr *, PjL2MeasRbCb *, U8)); -#endif - -EXTERN S16 pjDbmFetchPjUlRbCb ARGS (( -PjUlUeCb *ueCb, -U8 rbId, -U8 rbType, -PjUlRbCb **pjRbCb -)); - -EXTERN S16 pjUtlUlSndUlRohcFdbk ARGS (( -PjCb *gCb, -PjUlRbCb *pjRbCb, -Buffer *fbPkt -)); - -EXTERN S16 pjUtlUlResetBuffrdPkts ARGS (( -PjCb *gCb, -PjUlRbCb *pjRbCb -)); - -EXTERN S16 pjUtlReEstProcUlRb ARGS (( -PjCb *tPjCb, -PjUlUeCb *ueCb, -CpjCfgReqInfo *cfg -)); - -EXTERN S16 pjUtlCheckOnlySrbPresent ARGS(( -PjCb *tPjCb, /* Pdcp UL control block */ -CmLtePdcpId pdcpId, /* PDCP Id*/ -U32 *waitForReEstTrig /* wait for reestablishment trigger */ -)); - -EXTERN Void pjUlmReEstCmpInd ARGS(( -PjCb *tPjCb, -PjUlRbCb *tRbCb /* !< RB control block */ -)); - -EXTERN S16 PjUlUdxDlStaRep ARGS(( -Pst *pst, /* Post structure */ -SpId spId, /* Service provider ID */ -UdxDlStaRepInfo *staRep /*PDCP Status Report*/ -)); - -EXTERN S16 PjUlUdxUlStaRep ARGS (( -Pst *pst, /* Post structure */ -SpId spId, /* Service provider ID */ -UdxUlStaRepInfo *staRep /*PDCP Status Report*/ -)); - -EXTERN S16 pjUtlStartUlReEst ARGS (( -PjCb *gCb, -CpjReEstReqInfo *reEstReq, -CpjReEstCfmInfo *reEstCfm -)); - -EXTERN S16 pjUtlUlPrcsDatResume ARGS (( -PjCb *gCb, -CpjDatResumeReqInfo *datResReq -)); - -EXTERN S16 pjUlmStartDataFrwdPerRb ARGS(( -PjCb *gCb, -PjUlRbCb *pjRbCb -)); - -EXTERN Void pjUlmProcessUlPktQ ARGS (( -PjCb *gCb, -PjUlRbCb *pjRbCb /* !< PDCP Control Block */ -)); - -EXTERN S16 pjUtlUlGetRbCb ARGS (( -PjCb *gCb, -CmLtePdcpId *pdcpId, -PjUlRbCb **rbCb, -U8 *retCause -)); - -EXTERN Void pjUtlEmptyUlPktList ARGS(( -PjCb *gCb, -PjUlRbCb *pjRbCb -)); - -EXTERN S16 pjUtlUlReEstHO ARGS(( -PjCb *gCb, -PjUlUeCb *ueCb -)); - -EXTERN S16 pjDbmFetchUlUeCb ARGS(( -PjCb *gCb, -CmLteRnti ueId, -CmLteCellId cellId, -PjUlUeCb **ueCb -)); -EXTERN S16 pjUlmHndlDatFwdReq ARGS(( -PjCb *gCb, -PjUlRbCb *pjRbCb, -PjuDatFwdReqInfo *datFwdReq -)); -EXTERN Void dumpPDCPUlRbInformation ARGS (( -PjUlRbCb* ulRbCb, -U16 ueId -)); - -EXTERN void DumpPDCPUlDebugInformation ARGS (( -Void -)); - -EXTERN Void pjDeInitDeCipherQ(Void); - -EXTERN Void pjUlmHdlReordTmrExpiry ARGS(( -PjCb *tPjCb,/*pjCb structure */ -PjUlRbCb *pjRbCb -)); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __PJX__ */ - - -/********************************************************************30** - - End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_ul_ex_ms.c b/src/5gnrpdcp/pj_ul_ex_ms.c deleted file mode 100755 index 32d00d834..000000000 --- a/src/5gnrpdcp/pj_ul_ex_ms.c +++ /dev/null @@ -1,658 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: LTE-PDCP Layer - System Services Interface Functions - - Type: C file - - Desc: C source code for the interface to System Services of LTE-PDCP - - File: pj_ul_ex_ms.c - -*********************************************************************21*/ -static const char* RLOG_MODULE_NAME="PDCP"; -static int RLOG_MODULE_ID=1024; -static int RLOG_FILE_ID=243; -/** @file pj_ul_ex_ms.c - @brief PDCP System Services Interface - */ - - -/* header (.h) include files */ -#include "envopt.h" /* environment options */ -#include "envdep.h" /* environment dependent */ -#include "envind.h" /* environment independent */ - -#include "gen.h" /* general */ -#include "ssi.h" /* system services */ -#include "cm5.h" /* common timer defines */ -#include "cm_tkns.h" /* common tokens defines */ -#include "cm_mblk.h" /* common memory allocation library defines */ -#include "cm_llist.h" /* common link list defines */ -#include "cm_hash.h" /* common hash list defines */ -#include "cm_lte.h" /* common LTE defines */ -#include "kwu.h" /* KWU defines */ -#include "cpj.h" /* CPJ defines */ -#include "pju.h" /* PJU defines */ -#include "lpj.h" /* LPJ defines */ -#include "pj_err.h" /* Err defines */ -#include "pj_env.h" /* RLC environment options */ -#include "pj.h" /* RLC defines */ -#include "pj_udx.h" -#include "pj_dl.h" -#include "pj_lib.h" - -/* extern (.x) include files */ -#include "gen.x" /* general */ -#include "ssi.x" /* system services */ - -#include "cm5.x" /* common timer library */ -#include "cm_tkns.x" /* common tokens */ -#include "cm_mblk.x" /* common memory allocation */ -#include "cm_llist.x" /* common link list */ -#include "cm_hash.x" /* common hash list */ -#include "cm_lte.x" /* common LTE includes */ -#include "cm_lib.x" /* common memory allocation library */ -#include "kwu.x" /* KWU */ -#include "cpj.x" /* CPJ defines */ -#include "pju.x" /* PJU defines */ -#include "lpj.x" /* LPJ defines */ -#include "pj.x" -#include "pj_udx.x" -#include "pj_dl.x" -#include "pj_lib.x" -#ifdef TENB_STATS -#ifndef L2_L3_SPLIT -#include "pj_tenb_stats.x" -#else -#include "l2_tenb_stats.x" -#endif -#endif -#if (defined(TENB_STATS) && !(defined(L2_L3_SPLIT))) -#include "l2_tenb_stats.x" -#endif - -EXTERN Void pjMsNativeSpaccProcessUlOutput(Void); -EXTERN Void EgTLSendMsg(Bool); -/*********************************************************************** - System Service Interface Functions - ***********************************************************************/ -/** - * - * @brief - * - * Activates Initialization - * - * @b Description: - * This function is invoked by system services to initialize the LTE-PDCP - * layer. This is an entry point used by LTE_PDCP layer to initialize its - * global variables, before becoming operational. - * - * Allowable values for parameters are specified in ssi.h. - * - * @param[in] ent - Specify the entity id of the LTE-RLC task. - * @param[in] inst - Specify the entity id of the LTE-RLC task. - * @param[in] region - Specifies the memory region from which - * LTE-PDCP should allocate structures and buffers. - * @param[in] reason - Specifies the reason for calling this - * initialization function. - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 pjUlActvInit -( - Ent ent, /* entity */ - Inst inst, /* instance */ - Region region, /* region */ - Reason reason /* reason */ - ) -#else -PUBLIC S16 pjUlActvInit(ent, inst, region, reason) - Ent ent; /* entity */ - Inst inst; /* instance */ - Region region; /* region */ - Reason reason; /* reason */ -#endif -{ - PjCb *tPjCb; - TRC3(pjUlActvInit) - - if (inst >= PJ_MAX_PDCP_INSTANCES) - { - /* intance greater than MAX instances */ - RETVALUE(RFAILED); - } - - if (pjCb[inst] != NULLP) - { - RETVALUE (RFAILED); - } - - if (SGetSBuf(region, 0, (Data **)&tPjCb, - (Size)sizeof (PjCb)) != ROK) - { - RETVALUE(RFAILED); - } - /* Initialize kwCb */ - PJ_MEM_SET(tPjCb, 0, sizeof(PjCb)); - - /* Initialize task configuration parameters */ - /* We will take only entity name */ - tPjCb->init.ent = ent; /* entity */ - tPjCb->init.inst = inst; /* instance */ - tPjCb->init.region = region; /* static region */ - tPjCb->init.pool = 0; /* static pool */ - tPjCb->init.reason = reason; /* reason */ - tPjCb->init.cfgDone = FALSE; /* configuration done */ - tPjCb->init.acnt = TRUE; /* enable accounting */ - tPjCb->init.usta = TRUE; /* enable unsolicited status */ - tPjCb->init.trc = FALSE; /* enable trace */ -#ifdef DEBUGP - tPjCb->init.dbgMask = 0x00000; -#endif - tPjCb->init.procId = SFndProcId(); - - pjCb[inst] = tPjCb; -#if (defined(TENB_STATS) && !(defined(L2_L3_SPLIT))) - TSL2AllocStatsMem(tPjCb->init.region, tPjCb->init.pool); -#endif - - RETVALUE(ROK); -} /* pjActvInit */ - - -/** - * - * @brief - * - * Activation Task - * - * @b Description: - * Processes events received for LTE-PDCP layer via System Services from - * other layers. - * - * @param[in] pst - Pst Structure - * @param[in] mBuf - Message Buffer - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 pjUlActvTsk -( -Pst *pst, /* pst structure */ -Buffer *mBuf /* message buffer */ -) -#else -PUBLIC S16 pjUlActvTsk(pst, mBuf) -Pst *pst; /* pst structure */ -Buffer *mBuf; /* message buffer */ -#endif -{ - S16 ret = ROK; - - TRC3(pjUlActvTsk); - - switch(pst->srcEnt) - { - case ENTSM: - { - switch(pst->event) - { -#ifdef LCLPJ - case LPJ_EVT_CFG_REQ: - { - ret = cmUnpkLpjCfgReq(PjMiLpjCfgReq, pst, mBuf); - break; - } - - case LPJ_EVT_CNTRL_REQ: - { - ret = cmUnpkLpjCntrlReq(PjMiLpjCntrlReq, pst, mBuf); - break; - } - - case LPJ_EVT_STS_REQ: - { - ret = cmUnpkLpjStsReq(PjMiLpjStsReq, pst, mBuf); - break; - } - - case LPJ_EVT_STA_REQ: - { - ret = cmUnpkLpjStaReq(PjMiLpjStaReq, pst, mBuf); - break; - } - /* kw005.201 added support for L2 Measurement */ -#ifdef LTE_L2_MEAS - case LPJ_EVT_L2MEAS_REQ: - { - ret = cmUnpkLpjL2MeasReq(PjMiLpjL2MeasReq, pst, mBuf); - break; - } - case LPJ_EVT_L2MEAS_SEND_REQ: - { - - ret = cmUnpkLpjL2MeasSendReq(PjMiLpjL2MeasSendReq, pst, mBuf); - - break; - } - case LPJ_EVT_L2MEAS_STOP_REQ: - { - ret = cmUnpkLpjL2MeasStopReq(PjMiLpjL2MeasStopReq, pst, mBuf); - break; - } -#endif - - default: - { - RLOG1(L_ERROR, "Received Invalid Event[%d] from SM", pst->event); - ret = RFAILED; - break; - } -#endif /* LCLPJ */ - } - break; - } - - case ENTWR: - { - switch(pst->event) - { - - case EVTCPJKDFREQ: - { - cmUnpkCpjKdfReq(PjUiCpjKdfReq, pst, mBuf); - break; - } - - default: - SPutMsg(mBuf); - RLOG1(L_ERROR, "Received Invalid Event[%d] from APP", pst->event); - ret = RFAILED; - break; - } - break; - } - - case ENTPJ: - { - switch(pst->event) - { -#ifdef LCUDX - case EVTUDXBNDCFM: - { - cmUnpkPjUdxBndCfm(PjUlUdxBndCfm, pst, mBuf); - break; - } - - case EVTUDXCFGCFM: - { - cmUnpkPjUdxCfgCfm(PjUlUdxCfgCfm, pst, mBuf); - break; - } - - case EVTUDXREESTCFM: - { - cmUnpkPjUdxReEstCfm(PjUlUdxReEstCfm, pst, mBuf); - break; - } - - case EVTUDXSECCFGCFM: - { - cmUnpkPjUdxSecCfgCfm(PjUlUdxSecCfgCfm, pst, mBuf); - break; - } - - case EVTUDXUEIDCHGCFM: - { - cmUnpkPjUdxUeIdChgCfm(PjUlUdxUeIdChgCfm, pst, mBuf); - break; - } - - case EVTUDXCOUNTCFM: - { - cmUnpkPjUdxCountCfm(PjUlUdxCountCfm, pst, mBuf); - break; - } - - case EVTUDXSDUSTACFM: - { - cmUnpkPjUdxSduStaCfm(PjUlUdxSduStaCfm, pst, mBuf); - break; - } - case EVTUDXDATRESUMECFM: - { - cmUnpkPjUdxDatResumeCfm(PjUlUdxDatResumeCfm, pst, mBuf); - break; - } - case EVTUDXDATFRWDCFM: - { - cmUnpkPjUdxDatForwardCfm(PjUlUdxDatForwardCfm, pst, mBuf); - break; - } -#endif /* LCCPJ */ - default: - SPutMsg(mBuf); - RLOG1(L_ERROR, "Received Invalid Event[%d] from PDCP DL", pst->event); - ret = RFAILED; - break; - - } - break; - } - - - case ENTNH: - { - switch(pst->event) - { -#ifdef LCCPJ - case EVTCPJBNDREQ: - { - cmUnpkCpjBndReq(PjUiCpjBndReq, pst, mBuf); - break; - } - - case EVTCPJUBNDREQ: - { - cmUnpkCpjUbndReq(PjUiCpjUbndReq, pst, mBuf); - break; - } - - case EVTCPJCFGREQ: - { - cmUnpkCpjCfgReq(PjUiCpjCfgReq, pst, mBuf); - break; - } - - case EVTCPJREESTREQ: - { - cmUnpkCpjReEstReq(PjUiCpjReEstReq, pst, mBuf); - break; - } - - case EVTCPJSECCFGREQ: - { - cmUnpkCpjSecCfgReq(PjUiCpjSecCfgReq, pst, mBuf); - break; - } - - case EVTCPJUEIDCHGREQ: - { - cmUnpkCpjUeIdChgReq(PjUiCpjUeIdChgReq, pst, mBuf); - break; - } - - case EVTCPJCOUNTREQ: - { - cmUnpkCpjCountReq(PjUiCpjCountReq, pst, mBuf); - break; - } - - case EVTCPJSDUSTAREQ: - { - cmUnpkCpjSduStaReq(PjUiCpjSduStaReq, pst, mBuf); - break; - } - case EVTCPJSTARTDATAFWDREQ: /* Start Data Forwarding Request from RRC user for Source eNB during HO */ - { - cmUnpkCpjStartDataFwdReq(PjUiCpjDatForwardReq, pst, mBuf); - break; - } - case EVTCPJDATRESUMEREQ: /* Data Resume Request from RRC user during Re-establishment */ - { - cmUnpkCpjDatResumeReq(PjUiCpjDatResumeReq, pst, mBuf); - break; - } -#endif /* LCCPJ */ -#ifdef LCPJU - case EVTPJUBNDREQ: - { - cmUnpkPjuBndReq(PjUiPjuBndReq, pst, mBuf); - break; - } - - case EVTPJUUBNDREQ: - { - cmUnpkPjuUbndReq(PjUiPjuUbndReq, pst, mBuf); - break; - } - - case EVTPJUDATFWDREQ: - { - cmUnpkPjuDatFwdReq(PjUiPjuDatFwdReq, pst, mBuf); - break; - } -#endif - default: - SPutMsg(mBuf); - RLOG1(L_ERROR, "Received Invalid Event[%d] from RRC",pst->event); - ret = RFAILED; - break; - - } - break; - } - case ENTPX: - { - switch(pst->event) - { -#ifdef LCPJU - case EVTPJUBNDREQ: - { - cmUnpkPjuBndReq(PjUiPjuBndReq, pst, mBuf); - break; - } - - case EVTPJUUBNDREQ: - { - cmUnpkPjuUbndReq(PjUiPjuUbndReq, pst, mBuf); - break; - } - - case EVTPJUDATREQ: - { - cmUnpkPjuDatReq(PjUiPjuDatReq, pst, mBuf); - break; - } - - case EVTPJUDATFWDREQ: - { - cmUnpkPjuDatFwdReq(PjUiPjuDatFwdReq, pst, mBuf); - break; - } -#endif - default: - SPutMsg(mBuf); - RLOG1(L_ERROR, "Received Invalid Event[%d] from Relay", pst->event); - ret = RFAILED; - break; - } - break; - } - - case ENTOC: - { - switch(pst->event) - { -#ifdef PJ_CMP_ASYNC - /* Compression Confirmations */ - case OBD_EVT_CMP_INIT_CFM: - ret = cmUnpkLibObdCmpInitCfm(PjLibObdCmpInitCfm, pst, mBuf); - break; - - case OBD_EVT_DECMP_CFM: - ret = cmUnpkLibObdDecmpCfm(PjLibObdDecmpCfm, pst, mBuf); - break; -#endif /* PJ_CMP_ASYNC */ - default: - SPutMsg(mBuf); - RLOG1(L_ERROR, "Received Invalid Event[%d] from Offboard Compression",pst->event); - ret = RFAILED; - break; - } - break; - } - - case ENTOS: - { - switch(pst->event) - { -#ifdef PJ_SEC_ASYNC - /* Integrity Confirmations */ - case OBD_EVT_INT_INIT_CFM: - ret = cmUnpkLibObdIntInitCfm(PjLibObdIntInitCfm, pst, mBuf); - break; - - case OBD_EVT_INT_VER_CFM: - ret = cmUnpkLibObdIntVerCfm(PjLibObdIntVerCfm, pst, mBuf); - break; - - /* Ciphering Confirmations */ - case OBD_EVT_CP_INIT_CFM: - ret = cmUnpkLibObdCpInitCfm(PjLibObdCpInitCfm, pst, mBuf); /* TODO - Only Dl path? */ - break; - - case OBD_EVT_UP_INIT_CFM: - ret = cmUnpkLibObdUpInitCfm(PjLibObdUpInitCfm, pst, mBuf); /* TODO - Only Dl path? */ - break; - - case OBD_EVT_DECIPHER_CFM: - ret = cmUnpkLibObdDecipherCfm(PjLibObdDecipherCfm, pst, mBuf); - break; -#endif /* PJ_SEC_ASYNC */ - default: - SPutMsg(mBuf); - RLOG1(L_ERROR, "Received Invalid Event[%d] from Offboard Security",pst->event); - ret = RFAILED; - break; - } - break; - } - case ENTKW: - { - switch(pst->event) - { -#ifdef LCKWU - case KWU_EVT_BND_CFM: /* Bind request */ - { - ret = cmUnpkKwuBndCfm(PjLiKwuBndCfm, pst, mBuf ); - break; - } - - case KWU_EVT_DAT_IND: /* Coomon Channel Data request */ - { - ret = cmUnpkKwuDatInd(PjLiKwuDatInd, pst, mBuf); - break; - } - - case KWU_EVT_REEST_CMP_IND: /* Dedicated Channel Status Response */ - { - ret = cmUnpkKwuReEstCmpInd(PjLiKwuReEstCmpInd, pst, mBuf); - break; - } -#ifdef LTE_L2_MEAS - case KWU_EVT_DAT_ACK_IND: /* Harq status indication */ - { - ret = cmUnpkKwuDatAckInd(PjLiKwuDatAckInd, pst, mBuf); - break; - } -#endif - default: - { - SPutMsg(mBuf); - RLOG1(L_ERROR, "Received Invalid Event[%d] from RLC", pst->event); - ret = RFAILED; - break; - } - -#endif /* LCRGU */ - } - break; - } -#if (defined(TENB_STATS) && !(defined(L2_L3_SPLIT))) - case ENTTF: - { - switch(pst->event) - { - case TENBSTATSINIT: - { - PjCb *tPjCb; - tPjCb = PJ_GET_PJCB(pst->dstInst); - TSL2SendStatsToApp(&(tPjCb->pjGenCfg.lmPst), 0); - SPutMsg(mBuf); - break; - } - default: - { - printf("\n ERROR Invalid Event[%d] from CL to PDCPUL\n", - pst->event); - SPutMsg(mBuf); - break; - } - } - break; - } -#endif -#if (defined(TENB_AS_SECURITY) && defined(UL_DL_SPLIT)) - case ENTYS: - { - switch(pst->event) - { - case EVTPJUTTIIND: - { - pjMsNativeSpaccProcessUlOutput(); - SPutMsg(mBuf); - -#ifndef SS_RBUF - EgTLSendMsg(FALSE); /* Arg FALSE is req if ENB_CPU_OVERLOAD_CONTROL is enabled, - just to control the num of pkts to be sent over the socket*/ -#else - EgTLSendMsg(); -#endif - break; - } - } - break; - } -#endif - default: - { - RLOG1(L_ERROR, "Received Invalid Src Entity[%d]", pst->event); - SPutMsg(mBuf); - ret = RFAILED; - break; - } - } - - SExitTsk(); - - RETVALUE(ret); -} /* pjActvTsk */ - - -/********************************************************************30** - End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_ul_utl.c b/src/5gnrpdcp/pj_ul_utl.c deleted file mode 100755 index 6c6011788..000000000 --- a/src/5gnrpdcp/pj_ul_utl.c +++ /dev/null @@ -1,2844 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************** - - Name: LTE-PDCP Layer - - Type: C file - - Desc: Source code for PDCP Utility Module - - This file contains following functions: - - --PjLibObdCmpCfm - --PjLibObdIntProtCfm - --PjLibObdCipherCfm - --PjLibObdDecipherCfm - --PjLibObdIntVerCfm - --PjLibObdDecmpCfm - -- pjUtlCmpReq - -- pjUtlCipherReq - -- pjUtlIntProtReq - - File: pj_ul_utl.c - -**********************************************************************/ -static const char* RLOG_MODULE_NAME="PDCP"; -static int RLOG_FILE_ID=251; -static int RLOG_MODULE_ID=1024; - -/** @file gp_pj_utl.c -@brief PDCP Utility Module -*/ - -/* header (.h) include files */ -#include "envopt.h" /* environment options */ -#include "envdep.h" /* environment dependent */ -#include "envind.h" /* environment independent */ - -#include "gen.h" /* general */ -#include "ssi.h" /* system services */ -#include "cm5.h" /* common timer defines */ -#include "cm_tkns.h" /* common tokens defines */ -#include "cm_mblk.h" /* common memory allocation library defines */ -#include "cm_llist.h" /* common link list defines */ -#include "cm_hash.h" /* common hash list defines */ -#include "cm_lte.h" /* common LTE defines */ -#include "cpj.h" /* CPJ defines */ -#include "pju.h" /* PJU defines */ -#include "lpj.h" /* LPJ defines */ - -#include "pj_env.h" /* RLC environment options */ -#include "pj.h" /* RLC defines */ -#include "pj_ul.h" -#include "pj_dl.h" -#include "pj_err.h" /* Error defines */ - -/* extern (.x) include files */ -#include "gen.x" /* general */ -#include "ssi.x" /* system services */ - -#include "cm5.x" /* common timer library */ -#include "cm_tkns.x" /* common tokens */ -#include "cm_mblk.x" /* common memory allocation */ -#include "cm_llist.x" /* common link list */ -#include "cm_hash.x" /* common hash list */ -#include "cm_lte.x" /* common LTE includes */ -#include "cm_lib.x" /* common memory allocation library */ -#include "cpj.x" /* CPJ */ -#include "pju.x" /* PJU */ -#include "lpj.x" /* LPJ */ -#include "pj.x" -#include "pj_udx.h" /* LIB */ -#include "pj_udx.x" /* LIB */ -#include "pj_ul.x" -#include "pj_dl.x" -#include "pj_lib.x" /* LIB */ - -#ifdef __cplusplus -EXTERN "C" { -#endif /* __cplusplus */ - -PRIVATE S16 pjUtlUlHdlSecInitCfm ARGS((PjCb *gCb,PjUlUeCb *ueCb, - U16 txIdx,PjAsyncCfm *asyncCfm, CpjSecCfgCfmInfo *secCfgCfm,CpjReEstCfmInfo *reEstCfm)); -PRIVATE S16 pjUtlUlHdlCmpInitCfm ARGS((PjCb *gCb,PjUlUeCb *ueCb, - U16 txIdx,PjAsyncCfm *asyncCfm, CpjCfgCfmInfo *cfgCfm)); -#ifdef INTEL_SW_SEC -EXTERN S16 PjLibObdSwDecipherReq(PjLibTrans *libTrans, Buffer *mBuf, PjCb *gCb, Buffer **opSdu); -#endif -/******************************************************************** - * Utility Handler for Sending to Offboarding unit * - *******************************************************************/ - -/** - * - * @brief - * - * Handler for opening the context with the compression unit (either - * synchronous or asynchronous) for RB within an UE. - * - * @b Description: - * - * This function opens the context with the compression unit per RB per - * UE, by sending ROHC configuration elements using synchronous / asynchronous - * function calls with relevant input parameters. - * - * - * @param[in] pjRbCb PDCP RbCb - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 pjUtlUlCmpInit -( -PjCb *gCb, -PjUlRbCb *pjRbCb /* PDCP RbCb */ -) -#else -PUBLIC S16 pjUtlUlCmpInit(pjRbCb) -PjCb *gCb; -PjUlRbCb *pjRbCb; /* PDCP RbCb */ -#endif -{ - TRC3(pjUtlUlCmpInit) - - RLOG2(L_DEBUG, "pjUtlUlCmpInit(pjRbCb(%d,%d))", - pjRbCb->rbId, pjRbCb->rbType); -#ifdef PJ_CMP_ASYNC - - pjRbCb->ueCb->libInfo.tCmpInitBitMask |= (1 << (pjRbCb->rbId - 1)); - pjRbCb->ueCb->libInfo.tLibInitBitMask |= PJ_LIB_COMP_BIT_MASK; - pjRbCb->cmpCxt.cfgTxId = pjRbCb->ueCb->libInfo.nxtAvlbTxId; - - PjLibObdCmpInitReq(&gCb->pjGenCfg.obdPst.cmpPst, - pjRbCb->cmpCxt, pjRbCb->rohc); -#else - pjLibCmpInitReq(pjRbCb->cmpCxt, pjRbCb->rohc, &(pjRbCb->cmpCxtId)); -#endif /* PJ_CMP_ASYNC */ - - RETVALUE(ROK); - -} /* end of pjUtlCmpInit */ - - - -/** - * - * @brief - * - * Handler for opening the context with the Integration unit (either - * synchronous or asynchronous) for all SRBs of an UE. - * - * @b Description: - * - * This function opens the context with the security algo unit per UE - * for Integration protection/verification by sending the configured - * Integrity Info using synchronous / asynchronous function calls with - * relevant input parameters. - * - * @param[in] pjRbCb Pointer to RB control Block - * - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 pjUtlUlIntInit -( -PjCb *gCb, -PjUlUeCb *ueCb /* UE CB Ptr */ -) -#else -PUBLIC S16 pjUtlUlIntInit(ueCb) -PjCb *gCb; -PjUlUeCb *ueCb; /* UE CB Ptr */ -#endif -{ - -#ifndef PJ_SEC_ASYNC - Void *ctxId = NULL; /* KW_FIX */ -#else - U8 txIdx; - U32 *libInitBitMask = NULLP; -#endif - S32 ret=ROK; - - TRC3(pjUtlUlIntInit) - - RLOG2(L_DEBUG, "pjUtlUlIntInit(ueCb(%d,%d))", - ueCb->key.ueId, ueCb->key.cellId); - -#ifdef PJ_SEC_ASYNC - - if(ueCb->libInfo.state == PJ_STATE_REEST) - { - for(txIdx = 0; txIdx < PJ_MAX_ASYNC_CFM; txIdx++) - { - if((ueCb->libInfo.asyncCfm[txIdx] != NULLP) && - (ueCb->libInfo.asyncCfm[txIdx]->cfmType == PJ_REEST_ASYNC_CFM)) - { - libInitBitMask = &ueCb->libInfo.asyncCfm[txIdx]->libInitBitMask; - break; - } - } - } - else if(ueCb->libInfo.state == PJ_STATE_NORMAL) - { - libInitBitMask = &ueCb->libInfo.tLibInitBitMask; - } - - if(libInitBitMask) - { - (*libInitBitMask) = (*libInitBitMask) | PJ_LIB_INT_BIT_MASK; - } - - ret = PjLibObdIntInitReq(&gCb->pjGenCfg.obdPst.secPst, - ueCb->secInfo.secCxt, ueCb->secInfo.intInfo); -#else -#ifdef INTEL_QAT_DP -#ifdef QAT_TWO_INSTNACES - pjLibIntInitReq(gCb->u.ulCb->instHndl, ueCb->secInfo.intInfo,&ctxId); -#else - pjLibIntInitReq(gCb, ueCb->secInfo.intInfo,&ctxId); -#endif - ueCb->secInfo.cpIntSessCxtId = ctxId; -#else - pjLibIntInitReq(ueCb->secInfo.secCxt, ueCb->secInfo.intInfo,&(ctxId)); - ueCb->secInfo.intCxtId = ctxId; -#endif -#endif /* PJ_SEC_ASYNC */ - - RETVALUE(ret); - -} /* end of pjUtlIntInit */ - -/** - * - * @brief - * - * Handler for opening the context with the Ciphering unit (either - * synchronous or asynchronous) for SRBs of an UE. - * - * @b Description: - * - * This function opens the context with the security algo unit per UE - * for ciphering / deciphering by key by sending the configured - * Ciphering Info with control plane key using synchronous / asynchronous - * function calls with relevant input parameters. - * - * @param[in] pjRbCb Pointer to RB control Block - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 pjUtlUlCpInit -( -PjCb *gCb, -PjUlUeCb *ueCb /* UE CB Ptr */ -) -#else -PUBLIC S16 pjUtlUlCpInit(ueCb) -PjCb *gCb; -PjUlUeCb *ueCb; /* UE CB Ptr */ -#endif -{ - -#ifndef PJ_SEC_ASYNC - Void *ctxId = NULL; /* KW_FIX */ -#else - U8 txIdx; - U32 *libInitBitMask = NULLP; -#endif - S16 ret = ROK; - - TRC3(pjUtlUlCpInit) - - RLOG2(L_DEBUG, "pjUtlCpInit(ueCb(%d,%d))", - ueCb->key.ueId, ueCb->key.cellId); - -#ifdef PJ_SEC_ASYNC - - if(ueCb->libInfo.state == PJ_STATE_REEST) - { - for(txIdx = 0; txIdx < PJ_MAX_ASYNC_CFM; txIdx++) - { - if((ueCb->libInfo.asyncCfm[txIdx] != NULLP) && - (ueCb->libInfo.asyncCfm[txIdx]->cfmType == PJ_REEST_ASYNC_CFM)) - { - libInitBitMask = &ueCb->libInfo.asyncCfm[txIdx]->libInitBitMask; - break; - } - } - } - else if(ueCb->libInfo.state == PJ_STATE_NORMAL) - { - libInitBitMask = &ueCb->libInfo.tLibInitBitMask; - } - - if(libInitBitMask) - { - (*libInitBitMask) = (*libInitBitMask) | PJ_LIB_CP_CIP_BIT_MASK; - } - ret = PjLibObdCpInitReq(&gCb->pjGenCfg.obdPst.secPst, ueCb->secInfo.secCxt, - ueCb->secInfo.cipherInfo.algoType, ueCb->secInfo.cipherInfo.cpKey); -#else -#ifdef INTEL_QAT_DP -#ifdef QAT_TWO_INSTANCE - ret = pjLibCpInitReq(gCb->u.ulCb->instHndl, ueCb->secInfo.secCxt, ueCb->secInfo.cipherInfo.algoType, - ueCb->secInfo.cipherInfo.cpKey, &ctxId); -#else - ret = pjLibCpInitReq(gCb, ueCb->secInfo.secCxt, ueCb->secInfo.cipherInfo.algoType, - ueCb->secInfo.cipherInfo.cpKey, &ctxId); -#endif - ueCb->secInfo.cpCiphSessCxtId = ctxId; -#else - ret = pjLibCpInitReq(ueCb->secInfo.secCxt, (U8)ueCb->secInfo.cipherInfo.algoType, - ueCb->secInfo.cipherInfo.cpKey, &ctxId); /*KW_FIX*/ - ueCb->secInfo.cpCxtId = ctxId; -#endif /* INTEL_QAT_DP */ -#endif /* PJ_SEC_ASYNC */ - - RETVALUE(ret); - -} /* end of pjUtlCpInit */ - -/** - * - * @brief - * - * Handler for opening the context with the Ciphering unit (either - * synchronous or asynchronous) for DRBs of an UE. - * - * @b Description: - * - * This function opens the context with the security algo unit per UE - * for ciphering / deciphering by sending the configured - * Ciphering Info with user plane key using synchronous / asynchronous - * function calls with relevant input parameters. - * - * @param[in] pjRbCb Pointer to RB control Block - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 pjUtlUlUpInit -( -PjCb *gCb, -PjUlUeCb *ueCb /* UE CB Ptr */ -) -#else -PUBLIC S16 pjUtlUpInit(gCb,ueCb) -PjCb *gCb; -PjUlUeCb *ueCb; /* UE CB Ptr */ -#endif -{ - -#ifndef PJ_SEC_ASYNC - Void* ctxId = NULL; /* KW_FIX */ -#else - U8 txIdx; - U32 *libInitBitMask = NULLP; -#endif - - TRC3(pjUtlUlUpInit) - - RLOG2(L_DEBUG, "pjUtlUpInit(ueCb(%d,%d))", - ueCb->key.ueId, ueCb->key.cellId); - -#ifdef PJ_SEC_ASYNC - - if(ueCb->libInfo.state == PJ_STATE_REEST) - { - for(txIdx = 0; txIdx < PJ_MAX_ASYNC_CFM; txIdx++) - { - if((ueCb->libInfo.asyncCfm[txIdx] != NULLP) && - (ueCb->libInfo.asyncCfm[txIdx]->cfmType == PJ_REEST_ASYNC_CFM)) - { - libInitBitMask = &ueCb->libInfo.asyncCfm[txIdx]->libInitBitMask; - break; - } - } - } - else if(ueCb->libInfo.state == PJ_STATE_NORMAL) - { - libInitBitMask = &ueCb->libInfo.tLibInitBitMask; - } - - if(libInitBitMask) - (*libInitBitMask) = (*libInitBitMask) | PJ_LIB_UP_CIP_BIT_MASK; - - ret = PjLibObdUpInitReq(&gCb->pjGenCfg.obdPst.secPst, ueCb->secInfo.secCxt, - ueCb->secInfo.cipherInfo.algoType, ueCb->secInfo.cipherInfo.upKey); -#else -#ifdef INTEL_QAT_DP -#ifdef QAT_TWO_INSTANCE - pjLibUpInitReq(gCb->u.ulCb->instHndl, ueCb->secInfo.secCxt, ueCb->secInfo.cipherInfo.algoType, - ueCb->secInfo.cipherInfo.upKey, &ctxId); -#else - pjLibUpInitReq(gCb, ueCb->secInfo.secCxt, ueCb->secInfo.cipherInfo.algoType, - ueCb->secInfo.cipherInfo.upKey, &ctxId); -#endif - ueCb->secInfo.upCiphSessCxtId= ctxId; -#else - pjLibUpInitReq(ueCb->secInfo.secCxt, (U8)ueCb->secInfo.cipherInfo.algoType, - ueCb->secInfo.cipherInfo.upKey, &ctxId); /*KW_FIX*/ - ueCb->secInfo.upCxtId = ctxId; -#endif /* INTEL_QAT_DP */ -#endif /* PJ_SEC_ASYNC */ - - RETVALUE(ROK); - -} /* end of pjUtlUpInit */ - - -/** - * - * @brief - * - * Handler for resetting the context with the compression unit (either - * synchronous or asynchronous) for RB within an UE. - * - * @b Description: - * - * This function resets the context with the compression unit per RB per - * UE by using synchronous / asynchronous function calls. - * - * - * @param[in] cmpCxtId Context to be reset for compression - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 pjUtlUlCmpReset -( -PjCb *gCb, -PjUlRbCb *pjRbCb /* Context to be reset for compression */ -) -#else -PUBLIC S16 pjUtlUlCmpReset(pjRbCb) -PjCb *gCb; -PjUlRbCb *pjRbCb; /* Context to be reset for compression */ -#endif -{ - TRC3(pjUtlUlCmpReset) - - RLOG2(L_DEBUG, "pjUtlUlCmpReset(pjRbCb(%d,%d))", - pjRbCb->rbId, pjRbCb->rbType); - -#ifdef PJ_CMP_ASYNC - PjLibObdCmpResetReq(&gCb->pjGenCfg.obdPst.cmpPst, pjRbCb->cmpCxtId); -#else - pjLibCmpResetReq(pjRbCb->cmpCxtId); -#endif - - RETVALUE(ROK); - -} /* end of pjUtlCmpReset */ - - -/** - * - * @brief - * - * Handler for closing the UL context with the Ciphering unit (either - * synchronous or asynchronous) for SRBs of an UE. - * - * @b Description: - * - * This function closes an existing UL context with the security algo unit per UE - * for ciphering / deciphering with control plane key using synchronous / asynchronous - * function calls with relevant input parameters. - * - * - * @param[in] cpCxtId Context Id for Ciphering to be closed - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 pjUtlUlCipherClose -( -PjCb *gCb, -Void *cpCxtId /* Context Id for Ciphering to be closed */ -) -#else -PUBLIC S16 pjUtlUlCipherClose(cpCxtId) -PjCb *gCb; -Void *cpCxtId; /* Context Id for Ciphering to be closed */ -#endif -{ - S16 ret = ROK; - TRC3(pjUtlUlCipherClose) - RLOG0(L_DEBUG, "pjUtlUlCipherClose"); -#ifndef PJ_SEC_ASYNC -#ifdef INTEL_QAT_DP -#ifdef QAT_TWO_INSTANCE - ret = PjLibObdCipherCloseReq(gCb->u.ulCb->instHndl, cpCxtId); -#else - ret = PjLibObdCipherCloseReq(gCb->instHndl, cpCxtId); -#endif -#else - PjLibObdCipherCloseReq(cpCxtId); -#endif -#else -#ifdef INTEL_QAT_DP -#ifdef QAT_TWO_INSTANCE - ret = PjLibObdCipherCloseReq(gCb->u.ulCb->instHndl, cpCxtId); -#else - ret = PjLibObdCipherCloseReq(gCb->instHndl, cpCxtId); -#endif -#else - PjLibObdCipherCloseReq(&gCb->pjGenCfg.obdPst.secPst, cpCxtId); -#endif -#endif - RETVALUE(ret); -} /* end of pjUtlCipherClose */ -/** - * - * @brief - * - * Handler for closing the UL context with the Integration unit (either - * synchronous or asynchronous) for all RBs of an UE. - * - * @b Description: - * - * This function closes an existing UL context with the security algo unit per UE - * for Integration protection/verification using synchronous / asynchronous function - * calls with relevant input parameters. - * - * - * @param[in] intCxtId Integration CxtId to be closed - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 pjUtlUlIntClose -( -PjCb *gCb, -Void *intCxtId /* Integration CxtId to be closed */ -) -#else -PUBLIC S16 pjUtlUlIntClose(intCxtId) -PjCb *gCb; -Void *intCxtId; /* Integration CxtId to be closed */ -#endif -{ - S16 ret = ROK; - TRC3(pjUtlUlIntClose) - RLOG0(L_DEBUG, "pjUtlUlIntClose"); - -#ifdef TENB_AS_SECURITY -#ifdef INTEL_QAT_DP -#ifdef QAT_TWO_INSTANCE - ret = PjLibObdIntCloseReq(gCb->u.ulCb->instHndl,intCxtId); -#else - ret = PjLibObdIntCloseReq(gCb->instHndl,intCxtId); -#endif -#endif -#else -#ifdef PJ_SEC_ASYNC - PjLibObdIntCloseReq(&gCb->pjGenCfg.obdPst.secPst,intCxtId); -#else - PjLibObdIntCloseReq(intCxtId); -#endif -#endif - RETVALUE(ret); -} /* end of pjUtlIntClose */ - -/** - * - * @brief - * - * Handler for redirecing deciphering request to either synchronous - * or asynchronous module. - * - * @b Description: - * - * This function sends deciphering request as either synchronous or - * asynchronous function calls with relevant input parameters. - * - * @param[in] pjRbCb PDCP RbCb - * @param[in] secInp Input parameters for deciphering - * @param[in] mBuf Data to be deciphered - * @param[in] opSdu Deciphered SDU - * - * @return S16 - * -# ROK - * - */ -/* Uday */ -#ifdef TENB_AS_SECURITY -#ifdef ANSI -PUBLIC S16 pjUtlDecipherReq -( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* PDCP RbCb */ -U32 count, -Buffer *mBuf, /* Data to be deciphered */ -Buffer **opSdu /* Deciphered SDU */ -) -#else -PUBLIC S16 pjUtlDecipherReq(gCb, pjRbCb, count, mBuf, opSdu) -PjCb *gCb; -PjUlRbCb *pjRbCb; /* PDCP RbCb */ -U32 count; -Buffer *mBuf; /* Data to be deciphered */ -Buffer **opSdu; /* Deciphered SDU */ -#endif -{ - S16 ret = ROK; - PjUlUeCb *ulUeCb; - PjLibTrans libTrans; -#ifdef PJ_SEC_ASYNC - Void *cxtId = NULLP; /* Context Identifier */ -#endif - TRC3(pjUtlDecipherReq) - -#ifdef PJ_SEC_ASYNC - if (pjRbCb->rbType == PJ_SRB) - { - cxtId = pjRbCb->ueCb->secInfo.cpCxtId; - } - else - { - cxtId = pjRbCb->ueCb->secInfo.upCxtId; - } -#endif - ulUeCb = pjRbCb->ueCb; - libTrans.pdcpInstance = gCb->init.inst; - libTrans.count = count; - libTrans.rbId = pjRbCb->rbId - 1; - libTrans.dir = PJ_SEC_DIR_UL; - libTrans.rbType = pjRbCb->rbType; - libTrans.snLen = pjRbCb->snLen; - libTrans.ciphAlgoType = ulUeCb->secInfo.cipherInfo.algoType; - libTrans.ueCb = (PTR)ulUeCb; - libTrans.ueId = ulUeCb->key.ueId; - libTrans.cellId = ulUeCb->key.cellId; - if(PJ_SRB == pjRbCb->rbType) - { - libTrans.key = ulUeCb->secInfo.cipherInfo.cpKey; -#ifdef INTEL_QAT_DP - libTrans.sessCxtId = ulUeCb->secInfo.cpCiphSessCxtId; -#ifdef QAT_TWO_INSTANCE - libTrans.instHndl = gCb->u.ulCb->instHndl; -#else - libTrans.instHndl = gCb->instHndl; -#endif -#endif - } - else - { - libTrans.key = ulUeCb->secInfo.cipherInfo.upKey; -#ifdef INTEL_QAT_DP - libTrans.sessCxtId = ulUeCb->secInfo.upCiphSessCxtId; -#ifdef QAT_TWO_INSTANCE - libTrans.instHndl = gCb->u.ulCb->instHndl; -#else - libTrans.instHndl = gCb->instHndl; -#endif -#endif - } - -#ifdef PJ_SEC_ASYNC - /* Start the timer if it is not started already */ - if((pjChkTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_OBD_TMR)) == FALSE) - { - pjRbCb->ulCb.obdPdu = secInp.count; - pjStartTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_OBD_TMR); - } - ret = PjLibObdDecipherReq(&(gCb->pjGenCfg.obdPst.secPst), - cxtId, secInp, libTrans, mBuf); -#else -#ifdef INTEL_QAT_DP - /* TODO: 3rd arg is unused can be removed */ - ret = PjLibObdDecipherReq(&libTrans, mBuf, opSdu); -#else -#ifndef INTEL_SW_SEC - ret = PjLibObdDecipherReq(&libTrans, mBuf, opSdu); -#else - ret = PjLibObdSwDecipherReq(&libTrans, mBuf, gCb,opSdu); -#endif -#endif -#endif - RETVALUE(ret); -} /* end of pjUtlDecipherReq */ -#else -#ifdef ANSI -PUBLIC S16 pjUtlDecipherReq -( -PjCb *gCb, /* Cell Cb */ -PjUlRbCb *pjRbCb, /* PDCP RbCb */ -U32 count, -Buffer *mBuf, /* Data to be deciphered */ -Buffer **opSdu /* Deciphered SDU */ -) -#else -PUBLIC S16 pjUtlDecipherReq(gCb, pjRbCb, count, mBuf, opSdu) -PjCb *gCb; -PjUlRbCb *pjRbCb; /* PDCP RbCb */ -U32 count; -Buffer *mBuf; /* Data to be deciphered */ -Buffer **opSdu; /* Deciphered SDU */ -#endif -{ - S16 ret = ROK; -#ifdef PJ_SEC_ASYNC - PjLibTrans libTrans; /* Transaction Id for deciphering */ -#else - PjSecInp secInp; -#endif /* PJ_SEC_ASYNC */ - PTR cxtId; /* Context Identifier */ - TRC3(pjUtlDecipherReq) - if (pjRbCb->rbType == PJ_SRB) - { - cxtId = (PTR)pjRbCb->ueCb->secInfo.cpCxtId; - } - else - { - cxtId = (PTR)pjRbCb->ueCb->secInfo.upCxtId; - } -#ifdef PJ_SEC_ASYNC - /* Assign transId and cxtId */ - libTrans.count = count; - /* kw005.201 ccpu00114955 corrected the RB ID calculation */ - libTrans.rbId = pjRbCb->rbId - 1; - libTrans.rbType = pjRbCb->rbType; - libTrans.ueCb = pjRbCb->ueCb; - /* Start the timer if it is not started already */ - if((pjChkTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_OBD_TMR)) == FALSE) - { - pjRbCb->ulCb.obdPdu = secInp.count; - pjStartTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_OBD_TMR); - } - ret = PjLibObdDecipherReq(&gCb->pjGenCfg.obdPst.secPst, - cxtId, secInp, libTrans, mBuf); -#else - secInp.count = count; - secInp.rbId = pjRbCb->rbId - 1; - secInp.dir = 0; - ret = pjLibDecipherReq(cxtId, secInp, mBuf, opSdu); -#endif - RETVALUE(ret); -} /* end of pjUtlDecipherReq */ -#endif -/** - * - * @brief - * - * Handler for redirecing Integration request to either synchronous - * or asynchronous module. - * - * @b Description: - * - * This function sends Intergrity verification request as either synchronous or - * asynchronous function calls with relevant input parameters. - * - * @param[in] pjRbCb PDCP RbCb - * @param[in] secInp Input parameters for integrity - * @param[in] mBuf SDU to be compressed - * @param[out] status Integrity verification status - * - * @return S16 - * -# ROK - * - */ -#ifdef TENB_AS_SECURITY -#ifdef ANSI -PUBLIC S16 pjUtlIntVerReq -( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* PDCP RbCb */ -PjSecInp secInp , /* Input parameters for integrity */ -Buffer *mBuf, /* SDU to be compressed */ -U32 macI, /* MAC-I to be verified with */ -Status *status /* Integrity verification status */ -) -#else -PUBLIC S16 pjUtlIntVerReq(pjRbCb, secInp, mBuf, macI, status) -PjCb *gCb; -PjUlRbCb *pjRbCb; /* PDCP RbCb */ -PjSecInp secInp; /* Input parameters for integrity */ -Buffer *mBuf; /* SDU to be compressed */ -U32 macI; /* MAC-I to be verified with */ -Status *status; /* Integrity verification status */ -#endif -{ - S16 ret = ROK; - PjUlUeCb *ulUeCb; - PjLibTrans libTrans; -#ifdef PJ_SEC_ASYNC - Void *cxtId; /* Context Identifier */ -#endif - TRC3(pjUtlIntVerReq) - -#ifdef PJ_SEC_ASYNC - cxtId = pjRbCb->ueCb->secInfo.intCxtId; -#endif - ulUeCb = pjRbCb->ueCb; - libTrans.pdcpInstance = gCb->init.inst; - libTrans.count = secInp.count; - libTrans.rbId = pjRbCb->rbId - 1; - libTrans.dir = secInp.dir; - libTrans.rbType = pjRbCb->rbType; - libTrans.intAlgoType = ulUeCb->secInfo.intInfo.algoType; - libTrans.ueCb = (PTR)ulUeCb; - libTrans.ueId = ulUeCb->key.ueId; - libTrans.cellId = ulUeCb->key.cellId; - libTrans.key = (U8*)&ulUeCb->secInfo.intInfo.intKey[0]; - PJ_SEC_FILL_FRESH(libTrans.fresh, libTrans.rbId); - -#ifdef INTEL_QAT_DP - libTrans.sessCxtId = ulUeCb->secInfo.cpIntSessCxtId; -#ifdef QAT_TWO_INSTANCE - libTrans.instHndl = gCb->u.ulCb->instHndl; -#else - libTrans.instHndl = gCb->instHndl; -#endif -#endif -#ifdef PJ_SEC_ASYNC - /* Start the timer if it is not started already */ - if((pjChkTmr(gCb, (PTR)pjRbCb, PJ_EVT_UL_OBD_TMR)) == FALSE) - { - pjRbCb->ulCb.obdPdu = secInp.count; - pjStartTmr(gCb, (PTR)pjRbCb, PJ_EVT_UL_OBD_TMR); - } - ret = PjLibObdIntVerReq(&(gCb->pjGenCfg.obdPst.secPst), cxtId, - secInp, libTrans, mBuf, macI); -#else -#ifdef INTEL_SW_INTEG - ret = PjLibObdIntVerReq(gCb, &libTrans, mBuf, macI); -#else - ret = PjLibObdIntVerReq(&libTrans, mBuf, macI); -#endif -#endif - RETVALUE(ret); - -} /* end of pjUtlIntVerReq */ -#else -#ifdef ANSI -PUBLIC S16 pjUtlIntVerReq -( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* PDCP RbCb */ -PjSecInp secInp , /* Input parameters for integrity */ -Buffer *mBuf, /* SDU to be compressed */ -U32 macI, /* MAC-I to be verified with */ -Status *status /* Integrity verification status */ -) -#else -PUBLIC S16 pjUtlIntVerReq(gCb, pjRbCb, secInp, mBuf, macI, status) -PjCb *gCb; -PjUlRbCb *pjRbCb; /* PDCP RbCb */ -PjSecInp secInp; /* Input parameters for integrity */ -Buffer *mBuf; /* SDU to be compressed */ -U32 macI; /* MAC-I to be verified with */ -Status *status; /* Integrity verification status */ -#endif -{ - S16 ret = ROK; -#ifdef PJ_SEC_ASYNC - PjLibTrans libTrans; /* Transaction Id for deciphering */ -#endif /* PJ_SEC_ASYNC */ - PTR cxtId; /* Context Identifier */ - - TRC3(pjUtlIntVerReq) - - cxtId = (PTR)pjRbCb->ueCb->secInfo.intCxtId; - -#ifdef PJ_SEC_ASYNC - /* Assign transId and cxtId */ - libTrans.count = secInp.count; - libTrans.rbId = pjRbCb->rbId - 1; - libTrans.rbType = pjRbCb->rbType; - libTrans.ueCb = pjRbCb->ueCb; - - /* Start the timer if it is not started already */ - if((pjChkTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_OBD_TMR)) == FALSE) - { - pjRbCb->ulCb.obdPdu = secInp.count; - pjStartTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_OBD_TMR); - } - - ret = PjLibObdIntVerReq(&gCb->pjGenCfg.obdPst.secPst, cxtId, - secInp, libTrans, mBuf, macI); -#else - /* ccpu00142570 */ - ret = pjLibIntVerReq(cxtId, secInp, mBuf, macI, status); -#endif - - RETVALUE(ret); - -} /* end of pjUtlIntVerReq */ -#endif - - - - -/** - * - * @brief - * - * Utility function that processes the CfgReq with type as - * REESTABLISH sent from RRC. - * - * @b Description: - * - * This function - * 1. Marks the state of the RBs as PJ_STATE_REEST. - * 2. Calculates the number of RBs undergoing reestablishment. - * - * @param[in] ueCb UE Control Block Pointer. - * @param[in] numEnt Number of entities undergoing reestablishment - * @param[in] cfgEnt List of entities configured. - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 pjUtlUlReEstSrb1 -( -PjCb *gCb, -PjUlRbCb *pjRbCb /* PDCP Control Block Pointer */ -) -#else -PUBLIC S16 pjUtlUlReEstSrb1(pjRbCb) -PjCb *gCb; -PjUlRbCb *pjRbCb; /* PDCP Control Block Pointer */ -#endif -{ - PjUlUeCb *ueCb; - - TRC2(pjUtlReEstSrb1) - - RLOG2(L_DEBUG, "pjUtlReEstSrb1(pjRbCb(%d,%d))", - pjRbCb->rbId, pjRbCb->rbType); - - ueCb = pjRbCb->ueCb; - - ueCb->libInfo.state = PJ_STATE_REEST; - - /* SRB Reconfiguration we can update the control Plane keys and - the Integrity Keys in the OBD module */ - - pjUtlUlUpdCpSecKeys(gCb,ueCb); - - /* Perform uplink reestablishment of SRB1 */ - pjUlmReEstSrb(gCb,pjRbCb); - - /* Start security reconfiguration if SRB1 is the only RB */ - if ((ueCb->numSrbs == 1) && (ueCb->numDrbs == 0)) - { - pjUtlUlUpdUpSecKeys(gCb,ueCb); - } - - RETVALUE(ROK); -} /* pjUtlReEstSrb1 */ - -/** - * - * @brief - * - * Handler to start reestablishment processing - * - * @b Description: - * - * This function - * 1. Marks the state of the RBs as PJ_STATE_REEST_HO. - * 2. Calculates the number of RBs undergoing reestablishment. - * - * @param[in] ueCb Number of RBs undergoing reestablishment - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 pjUtlUlReEstHO -( -PjCb *gCb, -PjUlUeCb *ueCb /* Number of RBs undergoing reestablishment*/ -) -#else -PUBLIC S16 pjUtlUlReEstHO(gCb,ueCb) -PjCb *gCb; -PjUlUeCb *ueCb; /* Number of RBs undergoing reestablishment*/ -#endif -{ - U8 rbCnt; - PjUlRbCb **rbCbLst; - PjUlRbCb *pjRbCb; - - TRC2(pjUtlUlReEstHO); - -#ifdef ALIGN_64BIT - RLOG2(L_DEBUG, "pjUtlReEstHOStart(ueCb(%d,%d)))", - ueCb->key.ueId, ueCb->key.cellId); -#else - RLOG2(L_DEBUG, "pjUtlReEstHOStart(ueCb(%d,%d))", - ueCb->key.ueId, ueCb->key.cellId); -#endif - - /* Perform initialisations on the HO Info structure */ - PJ_ALLOC(gCb,ueCb->hoInfo, sizeof(PjUlHoInfo)); -#if (ERRCLASS & ERRCLS_ADD_RES) - if (ueCb->hoInfo == NULLP) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - PJ_ALLOC(gCb,ueCb->hoInfo->hoCfmInfo, - sizeof(PjUlHoCfmInfo) * PJ_MAX_DRB_PER_UE ); - -#if (ERRCLASS & ERRCLS_ADD_RES) - if (ueCb->hoInfo->hoCfmInfo == NULLP ) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - /*ccpu00136858 */ - PJ_PST_FREE(gCb->u.ulCb->cpjSap.pst.region, gCb->u.ulCb->cpjSap.pst.pool, ueCb->hoInfo, sizeof(PjUlHoInfo)); - RETVALUE(RFAILED); - } -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - - /* Initialise the reestablishment states for the RBs */ - rbCbLst = ueCb->drbCb; - for(rbCnt = 0; rbCnt < PJ_MAX_DRB_PER_UE; rbCnt ++) - { - /* Check of rbCb available */ - if( (pjRbCb = rbCbLst[rbCnt]) == NULLP) - { - continue; - } - /* Fetch the rbCb and intialise the states */ - pjRbCb->state = PJ_STATE_REEST_HO; - ueCb->libInfo.numReEstDrb++; - -#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) - pjRbCb->ulCb.obdCnt = 0; - pjRbCb->ulCb.transCmp = 0; - if(pjRbCb->mode == PJ_DRB_AM) - { - pjRbCb->ulCb.firstReEstCnt = pjRbCb->ulCb.rxDeliv; - } -#endif /* (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) */ - - }/* for(rbCnt .. */ - - RETVALUE(ROK); - -} /* pjUtlReEstHOStart */ - -/** - * - * @brief - * - * Handler to apply the new security algorithms and - * reset the compression unit. - * - * @b Description: - * - * This function - * 1. Creates new contexts for Control Plane Ciphering and Integrity. - * 2. Closes the old contexts for Control Plane Ciphering and Integrity. - * - * @param[in] ueCb UE Control Block - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 pjUtlUlUpdUpSecKeys -( -PjCb *gCb, -PjUlUeCb *ueCb /* UE Control Block */ -) -#else -PUBLIC S16 pjUtlUlUpdUpSecKeys(gCb,ueCb) -PjCb *gCb; -PjUlUeCb *ueCb; /* UE Control Block */ -#endif -{ - Void *tmpUpCxt; - - TRC2(pjUtlUlUpdUpSecKeys); - - RLOG2(L_DEBUG, "pjUtlUlUpdUpSecKeys(ueCb(%d,%d))", - ueCb->key.ueId, ueCb->key.cellId); - - if(ueCb->secInfo.secAct == TRUE) - { - /* Initialisation is done first followed by closure since we - * do not want the same ctxId to be returned for the new init. - * In ASYNC case, we drop packets if they are returned from a - * different ctxId. */ - -#ifdef INTEL_QAT_DP - tmpUpCxt = ueCb->secInfo.upCiphSessCxtId; -#else - tmpUpCxt = ueCb->secInfo.upCxtId; -#endif - pjUtlUlUpInit(gCb,ueCb); - pjUtlUlCipherClose(gCb,tmpUpCxt); - } - - RETVALUE(ROK); -} /* pjUtlUlUpdUpSecKeys */ - -/** - * - * @brief - * - * Handler to apply the new security algorithms and - * reset the compression unit. - * - * @b Description: - * - * This function - * 1. Creates new contexts for Control Plane Ciphering and Integrity. - * 2. Closes the old contexts for Control Plane Ciphering and Integrity. - * - * @param[in] ueCb UE Control Block - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 pjUtlUlUpdCpSecKeys -( -PjCb *gCb, -PjUlUeCb *ueCb /* UE Control Block */ -) -#else -PUBLIC S16 pjUtlUlUpdCpSecKeys(gCb,ueCb) -PjCb *gCb; -PjDlUeCb *ueCb; /* UE Control Block */ -#endif -{ - Void *tmpIntCxt; - Void *tmpCpCxt; - - TRC2(pjUtlDlUpdCpSecKeys); - - RLOG2(L_DEBUG, "pjUtlUlUpdCpSecKeys(ueCb(%d,%d))", - ueCb->key.ueId, ueCb->key.cellId); - - if(ueCb->secInfo.secAct == TRUE) - { - /* Initialisation is done first followed by closure since we - * do not want the same ctxId to be returned for the new init. - * In ASYNC case, we drop packets if they are returned from a - * different ctxId. */ -#ifdef INTEL_QAT_DP - tmpIntCxt = ueCb->secInfo.cpIntSessCxtId; - tmpCpCxt = ueCb->secInfo.cpCiphSessCxtId; - -#else - tmpIntCxt = ueCb->secInfo.intCxtId; - tmpCpCxt = ueCb->secInfo.cpCxtId; -#endif - - pjUtlUlCpInit(gCb,ueCb); - pjUtlUlIntInit(gCb,ueCb); - - pjUtlUlIntClose(gCb,tmpIntCxt); - pjUtlUlCipherClose(gCb,tmpCpCxt); - } - - RETVALUE(ROK); -} /* pjUtlDlUpdCpSecKeys */ - -/** - * - * @brief - * - * Function to handle the REESTABLISHMENT COMPLETE - * for each uplink RB - * - * @b Description: - * - * This function - * - * @param[in] ueCb UE Control Block - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 pjUtlUlHdlRbReEstComplete -( -PjCb *gCb, -PjUlRbCb *pjRbCb /*RB Control Block */ -) -#else -PUBLIC S16 pjUtlUlHdlRbReEstComplete(ueCb, pjRbCb) -PjCb *gCb; -PjUlRbCb *pjRbCb; /* RB Control Block */ -#endif -{ - PjUlUeCb *ueCb; - - TRC2(pjUtlUlHdlRbReEstComplete); - - RLOG1(L_DEBUG, "pjUtlUlHdlRbReEstComplete(rbCb(%d)", - pjRbCb->rbId); - - ueCb = pjRbCb->ueCb; - if (ueCb->libInfo.numReEstDrb == 0) - { - ueCb->libInfo.numReEstCmp++; - RETVALUE(ROK); - } - else - { - ueCb->libInfo.numReEstDrb--; - } - - if (ueCb->libInfo.numReEstDrb == 0) - { - if (ueCb->libInfo.state == PJ_STATE_REEST) - { - /* Since we have received all the packets in uplink - we can update the user keys */ - pjUtlUlUpdUpSecKeys(gCb, ueCb); - -#ifdef PJ_ASYNC_CFM - RETVALUE(ROK); -#endif - pjUtlUlSndReEstCfgCfm(gCb,ueCb); - } - else if (ueCb->libInfo.state == PJ_STATE_REEST_HO) - { - pjUtlUlSndSduStaCfm(gCb,ueCb); - } - } - RETVALUE(ROK); - -} /* pjUtlUlHdlRbReEstComplete */ - -/** - * - * @brief - * - * Function to sent the REESTABLISHMENT COMPPLETE - * to the RRC. - * - * @b Description: - * - * This function - * 1. Sends a ReEstablishment Confirm for normal reestablishment. - * 2. Sends a SDU status confirm for handover reestablishment. - * - * @param[in] ueCb UE Control Block - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 pjUtlUlSndReEstCfgCfm -( -PjCb *gCb, -PjUlUeCb *ueCb /* UE Control Block */ -) -#else -PUBLIC S16 pjUtlUlSndReEstCfgCfm(ueCb) -PjCb *gCb; -PjUlUeCb *ueCb; /* UE Control Block */ -#endif -{ - CpjCfgCfmInfo *cfgCfmInfo; - U8 txIdx; - PjAsyncCfm *asyncCfm = NULLP; - PjCpjSapCb *cpjSap; - - TRC2(pjUtlSndReEstCfgCfm); - - RLOG2(L_DEBUG, "pjUtlSndReEstCfgCfm(ueCb(%d,%d))", - ueCb->key.ueId, ueCb->key.cellId); - - /* Pick up the confirm info */ - for(txIdx = 0; txIdx < PJ_MAX_ASYNC_CFM; txIdx++) - { - if((ueCb->libInfo.asyncCfm[txIdx] != NULLP) && - (ueCb->libInfo.asyncCfm[txIdx]->cfmType & PJ_CFG_REEST_ASYNC_CFM)) - { - asyncCfm = ueCb->libInfo.asyncCfm[txIdx]; - break; - } - } - - /* its a reestablishment with only srb1 configured */ - if(asyncCfm == NULLP) - { - RETVALUE(ROK); - } - /* Memory leak fix ccpu00135359 */ - cpjSap = &(gCb->u.ulCb->cpjSap); - if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,(Data **)&cfgCfmInfo, - sizeof (CpjCfgCfmInfo)) != ROK) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } - - PJ_FILL_REEST_CFG_CFM_INFO(cfgCfmInfo, asyncCfm); - PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx); - - PjUiCpjCfgCfm(&gCb->u.ulCb->cpjSap.pst, gCb->u.ulCb->cpjSap.suId, cfgCfmInfo); - - RETVALUE(ROK); -} /* pjUtlSndReEstCfgCfm */ -/** - * - * @brief Handler to store the confirms while we wait for the init - * confirms from the off-board. - * - * - * @b Description - * This function is invoked during security config request, - * reestablishment request and config request if the libraries - * are off-boarded. This stores the entries in a confirm list - * while waiting for the confirm from the offboard. - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ - -#ifdef ANSI -PUBLIC S16 pjUtlUlSaveCfmInfo -( -PjCb *gCb, -PjUlUeCb *ueCb, /* Pointer to UeCb */ -U8 cfmType, /* Confirm type */ -Bool startTmr, /* Start Timer */ -U8 entity, /* Confirm type */ -PTR cfmPtr, /* Pointer to the structure for confirm */ -PTR cfgPtr /* Pointer to the structure for request */ -) -#else -PUBLIC S16 pjUtlUlSaveCfmInfo(ueCb, cfmType, startTmr, entity, cfmPtr, cfgPtr) -PjCb *gCb; -PjUlUeCb *ueCb; /* Pointer to UeCb */ -U8 cfmType; /* Confirm type */ -Bool startTmr; /* Start Timer */ -U8 entity; /* Confirm type */ -PTR cfmPtr; /* Pointer to the structure for confirm */ -PTR cfgPtr; /* Pointer to the structure for request */ -#endif -{ - S16 ret; /* Return value */ - CpjSecCfgCfmInfo *secCfm; /* Security confirm */ - CpjReEstCfmInfo *reEstCfm; /* Reestablishment confirm */ - CpjCfgCfmInfo *cfgCfm; /* Config confirm */ - U16 txId; /* Transaction Id */ - PjAsyncCfm *tAsyncCfm; /* Pointer to the async Cfm*/ - CpjCfgReqInfo *cfgReq; /* Pointer to the config request */ - U8 cfmIdx; /* index for loopoing */ - - - TRC3(pjUtlSaveCfmInfo) - - RLOG_ARG4(L_DEBUG,DBG_UEID, ueCb->key.ueId, - "pjUtlSaveCfmInfo cellId(%d),cfmType(%d),startTmr(%d),entity(%d))", - ueCb->key.cellId, cfmType, startTmr, entity); - - /* Initialisations */ - ret = ROK; - secCfm = NULLP; - reEstCfm = NULLP; - cfgCfm = NULLP; - cfgReq = NULLP; - txId = ueCb->libInfo.nxtAvlbTxId; - - if(txId == PJ_MAX_ASYNC_CFM) - { - /* The entire list is full, have to return negative confirms */ - RETVALUE(RFAILED); - } - - /* is entry already present */ - if(ueCb->libInfo.asyncCfm[txId] != NULLP) - { - RETVALUE(RFAILED); - } - - /* Allocate the structure */ - PJ_ALLOC(gCb,ueCb->libInfo.asyncCfm[txId], sizeof(PjAsyncCfm)); - if(ueCb->libInfo.asyncCfm[txId]== NULLP) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } - - /* Initialise the structure */ - tAsyncCfm = ueCb->libInfo.asyncCfm[txId]; - tAsyncCfm->libInitBitMask = ueCb->libInfo.tLibInitBitMask; - tAsyncCfm->cmpInitBitMask = ueCb->libInfo.tCmpInitBitMask; - tAsyncCfm->entity = entity; - tAsyncCfm->startTmr = startTmr; - - ueCb->libInfo.tLibInitBitMask = 0; - ueCb->libInfo.tCmpInitBitMask = 0; - - /* Assign the values */ - if(cfmType == PJ_SEC_ASYNC_CFM) - { - secCfm = (CpjSecCfgCfmInfo *)cfmPtr; - tAsyncCfm->cfmType = cfmType; - tAsyncCfm->ueId = secCfm->ueId; - tAsyncCfm->cellId = secCfm->cellId; - tAsyncCfm->transId = secCfm->transId; - } - else if(cfmType == PJ_REEST_ASYNC_CFM) - { - reEstCfm = (CpjReEstCfmInfo *)cfmPtr; - tAsyncCfm->cfmType = cfmType; - tAsyncCfm->ueId = reEstCfm->ueId; - tAsyncCfm->cellId = reEstCfm->cellId; - tAsyncCfm->transId = reEstCfm->transId; - } - else if((cfmType & PJ_CFG_ASYNC_CFM) || - (cfmType & PJ_CFG_REEST_ASYNC_CFM)|| - (cfmType & PJ_CFG_UEDEL_ASYNC_CFM)) - { - if(entity == ENTPJ) - { - cfgCfm = (CpjCfgCfmInfo *)cfmPtr; - cfgReq = (CpjCfgReqInfo *)cfgPtr; - - tAsyncCfm->cfmType = cfmType; - tAsyncCfm->ueId = cfgCfm->ueId; - tAsyncCfm->cellId = cfgCfm->cellId; - tAsyncCfm->transId = cfgCfm->transId; - tAsyncCfm->numEnt = cfgReq->numEnt; - - for ( cfmIdx = 0; cfmIdx < cfgReq->numEnt; cfmIdx++ ) - { - tAsyncCfm->cfmEnt[cfmIdx].status = cfgCfm->cfmEnt[cfmIdx].status; - tAsyncCfm->cfmEnt[cfmIdx].reason = cfgCfm->cfmEnt[cfmIdx].reason; - tAsyncCfm->cfmEnt[cfmIdx].rbId = cfgCfm->cfmEnt[cfmIdx].rbId; - tAsyncCfm->cfmEnt[cfmIdx].rbType = cfgCfm->cfmEnt[cfmIdx].rbType; - tAsyncCfm->cfmEnt[cfmIdx].cfgType = cfgReq->cfgEnt[cfmIdx].cfgType; - } - } - else if(entity == ENTPJ) - { - CpjCfgCfmInfo *pjCfgCfm; /* Configuraiton Confirm */ - pjCfgCfm = (CpjCfgCfmInfo *)cfmPtr; - - tAsyncCfm->cfmType = cfmType; - tAsyncCfm->transId = pjCfgCfm->transId; - tAsyncCfm->ueId = pjCfgCfm->ueId; - tAsyncCfm->cellId = pjCfgCfm->cellId; - tAsyncCfm->numEnt = pjCfgCfm->numEnt; - - for ( cfmIdx = 0; cfmIdx < pjCfgCfm->numEnt; cfmIdx++ ) - { - tAsyncCfm->cfmEnt[cfmIdx].status = - pjCfgCfm->cfmEnt[cfmIdx].status; - tAsyncCfm->cfmEnt[cfmIdx].reason = - pjCfgCfm->cfmEnt[cfmIdx].reason; - tAsyncCfm->cfmEnt[cfmIdx].rbId = - pjCfgCfm->cfmEnt[cfmIdx].rbId; - tAsyncCfm->cfmEnt[cfmIdx].rbType = - pjCfgCfm->cfmEnt[cfmIdx].rbType; - } - } - } - - /* Start timer */ - /* Timer should not be started when SEC is SYNC for ReEst Req - * and for the subsequent config req for REEST. The config req - * after reest req can still start the timer in the case comp being - * async and sec being sync if it also adds a RB and a compInit has - * to be sent . - * */ - - if(tAsyncCfm->startTmr == TRUE) - { - if((pjChkTmr(gCb,(PTR)ueCb, PJ_EVT_OBD_WAIT_TMR)) == FALSE) - { - pjStartTmr(gCb,(PTR)ueCb, PJ_EVT_OBD_WAIT_TMR); - ueCb->libInfo.crntTmrTxId = ueCb->libInfo.nxtAvlbTxId; - } - } - - /* update nxtAvlbTxId to the next empty slot */ - for(cfmIdx = 0; cfmIdx < PJ_MAX_ASYNC_CFM; cfmIdx++) - { - ueCb->libInfo.nxtAvlbTxId = - (U16)((ueCb->libInfo.nxtAvlbTxId + 1) % PJ_MAX_ASYNC_CFM); /*KW_FIX*/ - - if(ueCb->libInfo.asyncCfm[ueCb->libInfo.nxtAvlbTxId] == NULLP) - { - break; - } - } - - /* Cant find an empty slot ? */ - if(cfmIdx == PJ_MAX_ASYNC_CFM) - { - ueCb->libInfo.nxtAvlbTxId = PJ_MAX_ASYNC_CFM; - } - - RETVALUE(ret); -}/* pjUtlSaveCfmInfo */ - -/** - * - * @brief Handler to store update the bitmaks and send confirms if necessary. - * - * - * @b Description - * This function is invoked when receiving a InitCfm from Offboard. - * It updates the bit masks and checks if it is necesary to send a - * confirm. - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ - -#ifdef ANSI -PUBLIC S16 pjUtlUlHdlObdInitCfm -( -PjCb *gCb, -PjUlUeCb *ueCb, /* Pointer to UeCb */ -U16 txIdx, /* Transaction Index for UeCb */ -U8 cfmType, /* Confirm type */ -U8 maskVal /* mask value */ -) -#else -PUBLIC S16 pjUtlUlHdlObdInitCfm(ueCb, txIdx, cfmType, maskVal) -PjCb *gCb; -PjUlUeCb *ueCb; /* Pointer to UeCb */ -U16 txIdx; /* Transaction Index for UeCb */ -U8 cfmType; /* Confirm type */ -U8 maskVal; /* mask value */ -#endif -{ - CpjSecCfgCfmInfo *secCfgCfm; /* Security config confirm */ - CpjReEstCfmInfo *reEstCfm; /* Reest config confirm */ - PjAsyncCfm *asyncCfm; - CpjCfgCfmInfo *cfgCfm; - U8 idx; - S16 ret; - TRC3(pjUtlUlHdlObdInitCfm) - - RLOG_ARG4(L_DEBUG,DBG_UEID, ueCb->key.ueId, - "pjUtlHdlUlObdInitCfm(ueCb(%d,%d),txIdx(%d),cfmType(%d),maskVal(%d))", - ueCb->key.cellId, txIdx, cfmType, maskVal); - - /* Initialisations */ - secCfgCfm = NULLP; - reEstCfm = NULLP; - cfgCfm = NULLP; - asyncCfm = NULLP; - ret = ROK; - - if((txIdx == PJ_MAX_ASYNC_CFM) || - (ueCb->libInfo.asyncCfm[txIdx] == NULLP)) - { - RETVALUE(RFAILED); - } - - asyncCfm = ueCb->libInfo.asyncCfm[txIdx]; - - if(cfmType & PJ_SEC_INIT_CFM) - { - /* Update bit mask and check if all confirms have been received */ - asyncCfm->libInitBitMask ^= (maskVal); - ret = pjUtlUlHdlSecInitCfm(gCb,ueCb,txIdx,asyncCfm,secCfgCfm,reEstCfm); - } - else if(cfmType & PJ_CMP_INIT_CFM) - { - /* Check if all confirms have been received */ - asyncCfm->cmpInitBitMask &= ~(1 << (maskVal - 1)); - - /* Update the status and reason for the received CmpInitCfm */ - for ( idx = 0; idx < asyncCfm->numEnt; idx++ ) - { - if ( asyncCfm->cfmEnt[idx].rbId == maskVal) - { - asyncCfm->cfmEnt[idx].status = CPJ_CFG_CFM_OK; - asyncCfm->cfmEnt[idx].reason = CPJ_CFG_REAS_NONE; - break; - } - } - - ret = pjUtlUlHdlCmpInitCfm(gCb,ueCb,txIdx,asyncCfm,cfgCfm); - } - - RETVALUE(ret); -}/* pjUtlHdlUlObdInitCfm */ - -/** - * - * @brief Handler for init off-board timer expiry. - * - * - * @b Description - * This function is called when the off-board timer expires for - * a Init Req of a channel (either for ciphering/integrity/compression). - * This function sends a confirm with failure for SecCfgReq if the - * state of the RB is normal. It sends a confirm with failure - * for config request(only for RBs with Re-establishment Req, a failure - * is stored in the confirm) if the state of the RB is re-establishment. - * - * @param[in] ueCb UE control block. - * - * - * @return S16 - * -# ROK - */ - -#ifdef ANSI -PUBLIC S16 pjUtlUlHdlInitObdTmrExp -( -PjCb *gCb, -PjUlUeCb *ueCb -) -#else -PUBLIC S16 pjUtlUlHdlInitObdTmrExp(ueCb) -PjCb *gCb; -PjUlUeCb *ueCb; -#endif -{ - S16 ret; /* Return Value */ - CpjSecCfgCfmInfo *secCfgCfm; /* Security Cfg Confirm Info */ - CpjCfgCfmInfo *cfgCfm; /* Config Confirm Info */ - CpjReEstCfmInfo *reEstCfm; /* Reest config confirm */ - CpjCfgCfmInfo *pjCfgCfm; - PjLibInfo *libInfo; /* Off-board Info */ - PjAsyncCfm *asyncCfm; /* Async Cfm Info */ - PjCpjSapCb *cpjSap; /* CPJ SAP Control Block */ - U16 txIdx; /* Tx Idx */ - U16 idx; /* Index for looping */ - U16 cfgIdx; - - TRC3(pjUtlHdlInitObdTmrExp) - - RLOG2(L_DEBUG, "pjUtlHdlInitObdTmrExp(ueCb(%d,%d))", - ueCb->key.ueId, ueCb->key.cellId); - - ret = ROK; - cpjSap = &(gCb->u.ulCb->cpjSap); - secCfgCfm = NULLP; - libInfo = &ueCb->libInfo; - txIdx = libInfo->crntTmrTxId; - - /* Restart the timer */ - PJ_CHK_RESTART_OBD_TIMER(gCb,ueCb, txIdx); - - /* Shouldnt happen, nevertheless, check */ - if( txIdx >= PJ_MAX_ASYNC_CFM || libInfo->asyncCfm[txIdx] == NULLP) - { - RETVALUE(ROK); - } - - asyncCfm = libInfo->asyncCfm[txIdx]; - - /* Security confirm */ - if(asyncCfm->cfmType & PJ_SEC_ASYNC_CFM) - { - PJ_ALLOC(gCb,secCfgCfm, sizeof(CpjSecCfgCfmInfo)); -#if (ERRCLASS & ERRCLS_ADD_RES) - if (secCfgCfm == NULLP) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - PJ_FILL_SEC_CFM_INFO(secCfgCfm, asyncCfm); - secCfgCfm->status = CPJ_CFG_CFM_NOK; - secCfgCfm->reason = CPJ_CFG_REAS_OBD_TIMEOUT; - - PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx); - - PjUiCpjSecCfgCfm(&(cpjSap->pst), cpjSap->suId, secCfgCfm); - } - - /* Configuration confirms */ - else if ((asyncCfm->cfmType & PJ_CFG_ASYNC_CFM) || - (asyncCfm->cfmType & PJ_CFG_REEST_ASYNC_CFM)) - { - PJ_FILL_TIMEOUT_CFG_CFM_INFO(gCb,cfgCfm, asyncCfm); - - PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx); - - PjUiCpjCfgCfm(&(cpjSap->pst), cpjSap->suId, cfgCfm); - } - else if (asyncCfm->cfmType & PJ_REEST_ASYNC_CFM) - { - /* Send ReEstCfm */ - PJ_ALLOC(gCb,reEstCfm, sizeof(CpjReEstCfmInfo)); -#if (ERRCLASS & ERRCLS_ADD_RES) - if (reEstCfm == NULLP) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - PJ_FILL_REEST_CFM_INFO(reEstCfm, asyncCfm, LCM_PRIM_NOK); - - PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx); - - PjUiCpjReEstCfm(&gCb->u.ulCb->cpjSap.pst, - gCb->u.ulCb->cpjSap.suId, reEstCfm); - - /* Send the config confirm also if any exists */ - cfgIdx = (U16)(txIdx + 1); /*KW_FIX*/ - - for(idx = 0; idx < PJ_MAX_ASYNC_CFM; idx++, cfgIdx++) - { - cfgIdx %= PJ_MAX_ASYNC_CFM; - if((libInfo->asyncCfm[cfgIdx] != NULLP) && - (libInfo->asyncCfm[cfgIdx]->cfmType & PJ_CFG_REEST_ASYNC_CFM)) - { - break; - } - } - - /* This scenario occurs when only SRB1 is configured */ - if(idx == PJ_MAX_ASYNC_CFM) - { - RETVALUE(ROK); - } - - PJ_CHK_RESTART_OBD_TIMER(gCb,ueCb, cfgIdx); - asyncCfm = libInfo->asyncCfm[cfgIdx]; - - PJ_FILL_TIMEOUT_CFG_CFM_INFO(gCb,cfgCfm, asyncCfm); - - PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx); - - PjUiCpjCfgCfm(&(cpjSap->pst), cpjSap->suId, cfgCfm); - } - else if(asyncCfm->cfmType & PJ_CFG_UEDEL_ASYNC_CFM) - { - /* Delete ueCb entry from ueLstCp */ - pjStopTmr(gCb,(PTR)ueCb, PJ_EVT_OBD_WAIT_TMR); - ret = cmHashListDelete(&(gCb->u.ulCb->ueLstCp), (PTR) ueCb); - if (ret != ROK) - { - -#ifdef DEBUGP - RLOG_ARG0(L_DEBUG,DBG_UEID,ueCb->key.ueId, - "pjUtlHdlInitObdTmrExp: cmHashListDelete Failed for ueCb."); -#endif - } - - if ( asyncCfm->entity == ENTPJ ) - { - PJ_ALLOC(gCb,cfgCfm, sizeof(CpjCfgCfmInfo)); -#if (ERRCLASS & ERRCLS_ADD_RES) - if (cfgCfm == NULLP) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - - for ( idx = 0; idx < asyncCfm->numEnt; idx++) - { - cfgCfm->cfmEnt[idx].status = asyncCfm->cfmEnt[idx].status; - cfgCfm->cfmEnt[idx].reason = asyncCfm->cfmEnt[idx].reason; - cfgCfm->cfmEnt[idx].rbId = asyncCfm->cfmEnt[idx].rbId; - cfgCfm->cfmEnt[idx].rbType = asyncCfm->cfmEnt[idx].rbType; - } - cfgCfm->ueId = asyncCfm->ueId; - cfgCfm->cellId = asyncCfm->cellId; - cfgCfm->transId = asyncCfm->transId; - cfgCfm->numEnt = asyncCfm->numEnt; - - /* delete all confirms present there */ - for(idx = 0; idx < PJ_MAX_ASYNC_CFM; idx++) - { - if(libInfo->asyncCfm[idx] != NULLP) - { - PJ_FREE(gCb,ueCb->libInfo.asyncCfm[idx], sizeof(PjAsyncCfm)); - ueCb->libInfo.asyncCfm[idx] = NULLP; - } - } - - PJ_FREE(gCb,ueCb, sizeof(PjUlUeCb)); - PjUiCpjCfgCfm(&(cpjSap->pst), cpjSap->suId, cfgCfm); - } - else if ( asyncCfm->entity == ENTPJ ) - { - PJ_ALLOC(gCb,pjCfgCfm, sizeof(CpjCfgCfmInfo)); -#if (ERRCLASS & ERRCLS_ADD_RES) - if (pjCfgCfm == NULLP) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - for ( idx = 0; idx < asyncCfm->numEnt; idx++) - { - pjCfgCfm->cfmEnt[idx].status = asyncCfm->cfmEnt[idx].status; - pjCfgCfm->cfmEnt[idx].reason = asyncCfm->cfmEnt[idx].reason; - pjCfgCfm->cfmEnt[idx].rbId = asyncCfm->cfmEnt[idx].rbId; - pjCfgCfm->cfmEnt[idx].rbType = asyncCfm->cfmEnt[idx].rbType; - } - pjCfgCfm->ueId = asyncCfm->ueId; - pjCfgCfm->cellId = asyncCfm->cellId; - pjCfgCfm->transId = asyncCfm->transId; - pjCfgCfm->numEnt = asyncCfm->numEnt; - - /* delete all confirms present there */ - for(idx = 0; idx < PJ_MAX_ASYNC_CFM; idx++) - { - if(libInfo->asyncCfm[idx] != NULLP) - { - PJ_FREE(gCb,ueCb->libInfo.asyncCfm[idx], sizeof(PjAsyncCfm)); - ueCb->libInfo.asyncCfm[idx] = NULLP; - } - } - - PJ_FREE(gCb,ueCb, sizeof(PjUlUeCb)); - PjUiCpjCfgCfm(&(cpjSap->pst), cpjSap->suId, pjCfgCfm); - } - } - - RETVALUE(ret); -} /* pjHdlUeDelWaitTmrExp */ - - -/** - * - * @brief - * - * Function to sent the REESTABLISHMENT COMPPLETE - * to the RRC. - * - * @b Description: - * - * This function - * 1. Sends a ReEstablishment Confirm for normal reestablishment. - * 2. Sends a SDU status confirm for handover reestablishment. - * - * @param[in] ueCb UE Control Block - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 pjUtlUlSndSduStaCfm -( -PjCb *gCb, -PjUlUeCb *ueCb /* UE Control Block */ -) -#else -PUBLIC S16 pjUtlUlSndSduStaCfm(gCb, ueCb) -PjCb *gCb; -PjUlUeCb *ueCb; /* UE Control Block */ -#endif -{ - U8 rbCnt; - CpjSduStaCfmInfo *cfmInfo; - UdxSduStaCfmInfo *udxCfmInfo; - UdxSduStaInfo tempDlStaInfo[PJ_MAX_DRB_PER_UE] = {{0}}; - U8 rbId; - U8 numRb = 0; - PjUlHoCfmInfo *hoCfmInfo; - CpjSduStaInfo *staInfo; - Bool rbPres; - PjCpjSapCb *cpjSap; - PjUdxUlSapCb *udxSap; - - - TRC2(pjUtlUlSndSduStaCfm); - - RLOG2(L_DEBUG, "pjUtlUlSndSduStaCfm(ueCb(%d,%d))", - ueCb->key.ueId, ueCb->key.cellId); - - cpjSap = &(gCb->u.ulCb->cpjSap); - if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool,(Data **)&cfmInfo, - sizeof (CpjSduStaCfmInfo)) != ROK) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } - - cfmInfo->ueId = ueCb->key.ueId; - cfmInfo->cellId = ueCb->key.cellId; - cfmInfo->transId = ueCb->hoInfo->transId; - cfmInfo->reason = CPJ_CFG_REAS_NONE; - udxCfmInfo = ueCb->hoInfo->staCfm; - - for(rbCnt = 0; rbCnt < udxCfmInfo->numRb; rbCnt++) - { - /* - - Check for rbId and copy the info to index=(rbId) - */ - rbId = udxCfmInfo->sduStaInfo[rbCnt].rbId; - if(udxCfmInfo->sduStaInfo[rbCnt].dlSduStaInfo.hoPres == TRUE) - { - tempDlStaInfo[rbId].rbId = udxCfmInfo->sduStaInfo[rbCnt].rbId; - tempDlStaInfo[rbId].dir = udxCfmInfo->sduStaInfo[rbCnt].dir; - tempDlStaInfo[rbId].dlSduStaInfo.count = udxCfmInfo->sduStaInfo[rbCnt].dlSduStaInfo.count; - tempDlStaInfo[rbId].dlSduStaInfo.hoPres = TRUE; - } - } - - for(rbCnt = 0; - ((rbCnt < PJ_MAX_DRB_PER_UE) && (numRb < CPJ_MAX_DRB)); rbCnt++) - { - rbPres = FALSE; - hoCfmInfo = &ueCb->hoInfo->hoCfmInfo[rbCnt]; - staInfo = &cfmInfo->sduStaInfo[numRb]; - memset((void *)staInfo,0,sizeof(CpjSduStaInfo)); - if(hoCfmInfo->pres == TRUE) - { - rbPres = TRUE; - staInfo->rbId = hoCfmInfo->rbId; - staInfo->dir |= hoCfmInfo->dir; - staInfo->snLen = ueCb->drbCb[hoCfmInfo->rbId]->snLen; - staInfo->ulSduStaInfo.numBits = hoCfmInfo->numBits; - if (hoCfmInfo->numBits > 0) - { - /* numBits is always filled as multiple's of 8 */ - cpjSap = &(gCb->u.ulCb->cpjSap); - if(SGetSBuf(cpjSap->pst.region,cpjSap->pst.pool, - (Data **)&staInfo->ulSduStaInfo.ulBitMap, - sizeof (U8) * (hoCfmInfo->numBits / 8)) != ROK) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } - PJ_MEM_CPY(staInfo->ulSduStaInfo.ulBitMap, hoCfmInfo->ulBitMap, (hoCfmInfo->numBits / 8)); - PJ_FREE(gCb, hoCfmInfo->ulBitMap, sizeof(U8) * (hoCfmInfo->numBits / 8)); - } - staInfo->ulSduStaInfo.count = hoCfmInfo->count; - } - if(tempDlStaInfo[rbCnt].dlSduStaInfo.hoPres == TRUE) - { - rbPres = TRUE; - staInfo->rbId = tempDlStaInfo[rbCnt].rbId; - staInfo->dir |= tempDlStaInfo[rbCnt].dir; - staInfo->snLen = ueCb->drbCb[staInfo->rbId]->snLen; - staInfo->dlSduStaInfo.count = tempDlStaInfo[rbCnt].dlSduStaInfo.count; - } - if(rbPres != TRUE) - { - continue; - } - else - { - numRb++; - } - } - - cfmInfo->numRb = numRb; - cfmInfo->status = ROK; - cfmInfo->reason = CPJ_CFG_REAS_NONE; - PJ_FREE(gCb,ueCb->hoInfo->hoCfmInfo, - (PJ_MAX_DRB_PER_UE * sizeof(PjUlHoCfmInfo))); - /* Memory leak fix ccpu00135359 */ - udxSap = PJ_GET_UL_UDX_SAP(gCb); - PJ_PST_FREE(udxSap->pst.region, udxSap->pst.pool,ueCb->hoInfo->staCfm, - sizeof (UdxSduStaCfmInfo)); - PJ_FREE(gCb,ueCb->hoInfo, sizeof(PjUlHoInfo)); - - PjUiCpjSduStaCfm(&gCb->u.ulCb->cpjSap.pst, - gCb->u.ulCb->cpjSap.suId, cfmInfo); - - RETVALUE(ROK); -} /* pjUtlSndSduStaCfm */ - -/** - * - * @brief Handler to clean up all the PDCP Control Blocks. - * - * - * @b Description - * This function is invoked by LMM to shutdown the - * layer. This cleans up recBuf and txBuf of all the - * PDCP RBs in all the UEs. - * - * @return S16 - * -# ROK - * -# RFAILED - * -*/ - -#ifdef ANSI -PUBLIC S16 pjUtlUlShutdown -( -PjCb *gCb -) -#else -PUBLIC S16 pjUtlUlShutdown() -PjCb *gCb; -#endif -{ - S16 ret; /* Return Value */ - PjUlUeCb *ueCb; /* UE Control Block */ - PjUlUeCb *prevUeCb; /* Previos UE Control Block */ - PjUlRbCb *rbCb; /* RB Control Block */ - PjUlRbCb **rbCbLst; /* RB Control Block List */ - PjSec *secInfo; /* Security info of UE */ - U8 idx; /* Index for RBs */ -#ifdef LTE_L2_MEAS_COMMENT - PjL2MeasEvtCb *measEvtCb = NULLP; -#endif - TRC3(pjUtlShutdown) - - RLOG0(L_DEBUG, "pjUtlShutdown()"); - - ret = ROK; - ueCb = NULLP; - prevUeCb = NULLP; - rbCb = NULLP; - rbCbLst = NULLP; - idx = 0; - - /* Until no more ueCb is ueLstCp hash list get and delete ueCb */ - while (cmHashListGetNext(&(gCb->u.ulCb->ueLstCp), (PTR) prevUeCb, (PTR *)&ueCb) == ROK) - { - if ( ueCb != NULLP ) - { -#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) - if (ueCb->libInfo.obdTmr.tmrEvnt == PJ_EVT_OBD_TMR) - { - pjStopTmr(gCb,(PTR)ueCb, PJ_EVT_OBD_TMR); - } -#endif - rbCbLst = ueCb->srbCb; - for (idx = 0; idx < PJ_MAX_SRB_PER_UE; idx++) - { - rbCb = rbCbLst[idx]; - if (rbCb != NULLP) - { - /* Free the Buffers of RbCb */ - pjUtlUlFreeRb(gCb,rbCb); - } - } - rbCbLst = ueCb->drbCb; - for (idx = 0; idx < PJ_MAX_DRB_PER_UE; idx++) - { - rbCb = rbCbLst[idx]; - if (rbCb != NULLP) - { - pjUtlUlFreeRb(gCb,rbCb); - } - } - /* Close all the context info for offboarding */ - secInfo = &(ueCb->secInfo); -#ifdef INTEL_QAT_DP - pjUtlUlIntClose(gCb,ueCb->secInfo.cpIntSessCxtId); - pjUtlUlCipherClose(gCb,ueCb->secInfo.cpCiphSessCxtId); - pjUtlUlCipherClose(gCb,ueCb->secInfo.upCiphSessCxtId); -#else - pjUtlUlCipherClose(gCb,secInfo->cpCxtId); - pjUtlUlCipherClose(gCb,secInfo->upCxtId); - pjUtlUlIntClose(gCb,secInfo->intCxtId); -#endif - /* Delete hoInfo if present */ - if (ueCb->hoInfo != NULLP) - { - for (idx = 0; idx < PJ_MAX_DRB_PER_UE; idx++) - { - if (ueCb->hoInfo->hoCfmInfo[idx].pres == TRUE) - { - PJ_FREE(gCb,ueCb->hoInfo->hoCfmInfo[idx].ulBitMap, - (ueCb->hoInfo->hoCfmInfo[idx].numBits % 8)? - ((ueCb->hoInfo->hoCfmInfo[idx].numBits / 8) + 1): - (ueCb->hoInfo->hoCfmInfo[idx].numBits / 8 )); - } - } - - PJ_FREE(gCb,ueCb->hoInfo->hoCfmInfo, \ - (PJ_MAX_DRB_PER_UE * sizeof(PjUlHoCfmInfo))); - PJ_FREE(gCb,ueCb->hoInfo, sizeof(PjUlHoInfo)); - } - } - prevUeCb = ueCb; - } -#ifdef LTE_L2_MEAS_COMMENT - for(idx = 0; idx < PJ_MAX_L2MEAS_EVT; idx++) - { - if(pjCb.pjL2Cb.pjMeasEvtCb[idx] != NULLP) - { - measEvtCb = pjCb.pjL2Cb.pjMeasEvtCb[idx]; - pjStopTmr(gCb,(PTR)measEvtCb, PJ_EVT_L2_TMR); - gCb.pjL2Cb.pjNumMeas--; - PJ_FREE(gCb,measEvtCb, sizeof(PjL2MeasEvtCb)); - pjCb.pjL2Cb.pjMeasEvtCb[idx] = NULLP; - } - } -#endif - ret = pjDbmUlDeInit(gCb); -#if (ERRCLASS & ERRCLS_DEBUG) - if (ret != ROK) - { - RLOG0(L_FATAL, "PDCP UL DeInitialization Failed.\n"); - } -#endif /* ERRCLASS & ERRCLS_DEBUG */ - RETVALUE(ret); -} - -/** - * - * @brief - * - * Handler to free a PDCP Control Block. - * - * @b Description: - * - * This function frees the txBuf and rxBuf in a PDCP control block. - * and closes the compression channel opened. It stops the timers - * of this control block if they are running. - * - * @param[in] pst Post structure - * @param[in] secCxt Context for Integrity protection/verification - * @param[in] ctxId Integrity Context Id - * - * - * @return S16 - * -# ROK - * - */ - -#ifdef ANSI -PUBLIC Void pjUtlUlFreeRb -( -PjCb *gCb, -PjUlRbCb *pjRbCb -) -#else -PUBLIC Void pjUtlUlFreeRb(pjRbCb) -PjCb *gCb; -PjUlRbCb *pjRbCb; -#endif -{ - TRC3(pjUtlFreeUlRb) - - RLOG0(L_DEBUG, "pjUtlFreeRb()"); - -#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) - if (pjRbCb->ulCb.obdTmr.tmrEvnt == PJ_EVT_UL_OBD_TMR) - { - pjStopTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_OBD_TMR); - } -#endif - pjDbmRxDeInit(gCb,&(pjRbCb->ulCb.recBuf)); - - pjUtlCmpClose(gCb,pjRbCb->cmpCxtId); - /*pj004.201 Adding of Missing Trace in LTE RLC PDCP*/ - RETVOID; -} - -/* pj005.201 added function to send data forward indication message */ -/** - * - * @brief - * - * Handler to send Data Fwd Indication - * - * @b Description: - * This function sends Data Fwd Indication message to PDCP user - * - * @param[in] pjRbCb PDCP RbCb - * @param[in] datFwdInd Data forward indication - * - * - * @return S16 - * -# ROK - * - */ - -#ifdef ANSI -PUBLIC S16 pjUtlUlSndDatFwdInd -( -PjCb *gCb, -PjUlRbCb *pjRbCb, -PjuDatFwdIndInfo *datFwdInd -) -#else -PUBLIC S16 pjUtlUlSndDatFwdInd(pjRbCb, datFwdInd) -PjCb *gCb; -PjUlRbCb *pjRbCb; -PjuDatFwdIndInfo *datFwdInd; -#endif -{ - CmLtePdcpId *pdcpId; - PjPjuSapCb *pjuSap; - CmLtePdcpId pdcpIdTmp; - - TRC3(pjUtlUlSndDatFwdInd) - - RLOG0(L_DEBUG, "pjUtlSndDatFwdInd()"); - - pjuSap = &(gCb->u.ulCb->pjuSap[PJ_DRB_SAP]); - pdcpId = &pdcpIdTmp; - - if(pdcpId != NULLP) - { - pdcpId->ueId = pjRbCb->ueCb->key.ueId; - pdcpId->cellId = pjRbCb->ueCb->key.cellId; - pdcpId->rbId = pjRbCb->rbId; - pdcpId->rbType = pjRbCb->rbType; - - gCb->pjGenSts.numPktsFrwd += datFwdInd->numSdus; - /* If trace flag is enabled send the trace indication */ - if(gCb->init.trc == TRUE) - { - /* Populate the trace params */ - pjLmmSendTrc(gCb,EVTPJUDATFWDIND, NULLP); - } - PjUiPjuDatFwdInd(&(pjuSap->pst), pjuSap->suId, pdcpId, datFwdInd); - } - - RETVALUE(ROK); - -}/* end of pjUtlSndDatFwdInd */ - -/** - * - * @brief - * - * Handler to send Data Fwd Indication - * - * @b Description: - * This function sends Data Fwd Indication message to PDCP user - * - * @param[in] pjRbCb PDCP RbCb - * @param[in] datFwdInd Data forward indication - * - * - * @return S16 - * -# ROK - * - */ - -#ifdef ANSI -PUBLIC S16 pjUtlUlSndUlStaRep -( -PjCb *gCb, -PjUlRbCb *pjRbCb, -Buffer *sta -) -#else -PUBLIC S16 pjUtlUlSndUlStaRep(pjRbCb, sta) -PjCb *gCb; -PjUlRbCb *pjRbCb; -Buffer *sta; -#endif -{ - PjUdxUlSapCb *udxSap; - UdxUlStaRepInfo *staRep; - S16 ret = ROK; /* Return Value */ - - udxSap = PJ_GET_UL_UDX_SAP(gCb); - - TRC3(pjUtlUlSndUlStaRep) - - RLOG0(L_DEBUG, "pjUtlUlSndUlStaRep()"); - - PJ_ALLOC_BUF_SHRABL(udxSap->pst, staRep, - sizeof (UdxUlStaRepInfo), ret); - - if(ret != ROK) - { - staRep = NULLP; - } - - if(staRep != NULLP) - { - staRep->pdcpId.ueId = pjRbCb->ueCb->key.ueId; - staRep->pdcpId.cellId = pjRbCb->ueCb->key.cellId; - staRep->pdcpId.rbId = pjRbCb->rbId; - staRep->pdcpId.rbType = pjRbCb->rbType; - staRep->sta = sta; - - PjUlUdxUlStaRep(&(udxSap->pst), udxSap->spId, staRep); - } - else - { - PJ_FREE_BUF(sta); - } - - RETVALUE(ROK); -}/* end of pjUtlSndDatFwdInd */ - - -/** - * - * @brief - * - * Handler to send Feedback packet to DL-PDCP - * - * @b Description: - * This function sends Feedback packet to DL-PDCP - * - * @param[in] pjCb PDCP global control block - * @param[in] pjRbCb PDCP RbCb - * @param[in] fbPkt Feedback packet - * - * - * @return S16 - * -# ROK - * - */ - -#ifdef ANSI -PUBLIC S16 pjUtlUlSndUlRohcFdbk -( -PjCb *gCb, -PjUlRbCb *pjRbCb, -Buffer *fbPkt -) -#else -PUBLIC S16 pjUtlUlSndUlRohcFdbk(gCb, pjRbCb, fbPkt) -PjCb *gCb; -PjUlRbCb *pjRbCb; -Buffer *fbPkt; -#endif -{ - PjUdxUlSapCb *udxSap; - UdxUlFdbkPktInfo *fdbkPktInfo; - S16 ret = ROK; - - udxSap = PJ_GET_UL_UDX_SAP(gCb); - - TRC3(pjUtlUlSndUlRohcFdbk) - - RLOG0(L_DEBUG, "pjUtlUlSndUlRohcFdbk()"); - - PJ_ALLOC_BUF_SHRABL(udxSap->pst, fdbkPktInfo, - sizeof (UdxUlFdbkPktInfo), ret); - if(ret != ROK) - { - fdbkPktInfo= NULLP; - } - - if(fdbkPktInfo != NULLP) - { - fdbkPktInfo->pdcpId.ueId = pjRbCb->ueCb->key.ueId; - fdbkPktInfo->pdcpId.cellId = pjRbCb->ueCb->key.cellId; - fdbkPktInfo->pdcpId.rbId = pjRbCb->rbId; - fdbkPktInfo->pdcpId.rbType = pjRbCb->rbType; - fdbkPktInfo->fbPkt = fbPkt; - - PjUlUdxUlFdbkPktInfo(&(udxSap->pst), udxSap->spId, fdbkPktInfo); - } - else - { - PJ_FREE_BUF(fbPkt); - } - - RETVALUE(ROK); -}/* end of pjUtlUlSndUlRohcFdbk */ - -/* pj005.201 added support for L2 Measurement */ -#ifdef LTE_L2_MEAS -/** - * - * @brief Function to initialise measurement - * - * @b Description - * - * @param[in] gCb PDCP Instance Control Block - * - * @return Void - * - */ -S16 pjUtlL2MeasUlInit(PjCb *gCb) -{ - U16 cntr; - - gCb->u.ulCb->pjL2Cb.pjNumMeas=0; - for(cntr = 0; cntr < LPJ_MAX_L2MEAS; cntr++) - { - cmMemset((U8 *)&(gCb->u.ulCb->pjL2Cb.pjL2EvtCb[cntr]), 0, sizeof(PjL2MeasEvtCb)); - } - gCb->u.ulCb->pjL2Cb.pjL2EvtCb[PJ_L2MEAS_UL_LOSS].measCb.measType = LPJ_L2MEAS_UL_LOSS; - gCb->u.ulCb->pjL2Cb.pjL2EvtCb[PJ_L2CPU_PERCORE_STATS].measCb.measType = LPJ_L2CPU_PERCORE_STATS; - gCb->u.ulCb->pjL2Cb.pjL2EvtCb[PJ_L2MEM_PERPOOL_STATS].measCb.measType = LPJ_L2MEM_PERPOOL_STATS; - /* initialize the timer value for memory and CPU utilization */ - gCb->u.ulCb->pjL2Cb.measTmrCfg.enb = TRUE; - gCb->u.ulCb->pjL2Cb.measTmrCfg.val = CM_MEM_CPU_UITL_INFO_TMR_VAL; - cmInitTimers(&gCb->u.ulCb->pjL2Cb.measTmr,PJ_L2_MAX_TIMERS); - - RETVALUE(ROK); -} -/** - * - * @brief Handler for resetting the DL measurement counters - * - * - * @b Description - * - * @param[in] measCb Measurement Control Block. - * - * - * @return Void - */ -#ifdef ANSI - -PUBLIC Void pjUtlResetUlL2MeasCntr -( -PjCb *tPjCb, -PjL2MeasCb *measCb, -U8 measType -) -#else -PUBLIC Void pjUtlResetUlL2MeasCntr(tPjCb, measCb, measType) -PjCb *tPjCb; -PjL2MeasCb *measCb; -U8 measType; -#endif -{ - if (measCb->measType & LPJ_L2MEAS_UL_LOSS) - { - U32 qciIdx; - for(qciIdx = 1; qciIdx < LPJ_MAX_QCI; qciIdx++) - { - U8 qci = measCb->qci[qciIdx]; - - measCb->measData[qci].ulLoss.val = 0; - measCb->measData[qci].ulLoss.numPkts = 0; - tPjCb->u.ulCb->pjL2Cb.measOn[qci] &= ~LPJ_L2MEAS_UL_LOSS; - } - } - if (measCb->measType & LPJ_L2MEM_PERPOOL_STATS) - { - tPjCb->u.ulCb->pjL2Cb.memUtilizationMask = 0; - /* Clear Memory Statistics */ - cmClearMemUtilizationCounter(&(measCb->memInfo)); - } - if(measCb->measType & LPJ_L2CPU_PERCORE_STATS ) - { - tPjCb->u.ulCb->pjL2Cb.cpuUtilizationMask = 0; - } - -} - - -/** - * - * @brief Handler for Sending Negative confirm . - * - * - * @b Description - * This function is called when the l2 measurement cannot be started - * This function sends negative confirm for all the requests - * - * @param[in] measReqEvt Measurement Req Structure - * - * - * @return S16 - * -# ROK - */ - -#ifdef ANSI -PUBLIC S16 pjUtlSndUlL2MeasNCfm -( -PjCb *gCb, -PjL2MeasCfmEvt *measCfmEvt -) -#else -PUBLIC S16 pjUtlSndUlL2MeasNCfm(gCb, measCfmEvt) -PjCb *gCb; -PjL2MeasCfmEvt *measCfmEvt; -#endif -{ - - TRC3(pjUtlSndL2MeasNCfm) - - PjMiLpjL2MeasCfm(&gCb->pjGenCfg.lmPst, measCfmEvt); - - RETVALUE(ROK); -} /* pjUtlSndL2MeasNCfm */ - -/** - * - * @brief Handler for storing address of MeasData in rbCb at right index - * - * - * @b Description - * Handler for storing address of MeasData in rbCb at right index. - * - * @param[in] - * @param[out] - * @param[in] - * - * - * @return S16 - * -# ROK - */ -#ifdef ANSI -PUBLIC Void pjUtlPlcMeasDatInUlL2Sts -( -PjL2Cntr *measData, -PjL2MeasRbCb *rbL2Cb, -U8 measType -) -#else -PUBLIC Void pjUtlPlcMeasDatInUlL2Sts(measData, rbL2Cb, measType) -PjL2Cntr *measData; -PjL2MeasRbCb *rbL2Cb; -U8 measType; -#endif -{ - TRC3(pjUtlPlcMeasDatInUlL2Sts) - - /* We should check the number of measType in the request. This can be done - * by looking at each bit in the measType. Also store the measData in the - * correct index of l2Sts in RbCb. - * */ - - if(measType & LPJ_L2MEAS_UL_LOSS) - { - rbL2Cb->l2Sts[PJ_L2MEAS_UL_LOSS] = measData; - } - -}/* End of pjUtlPlcMeasDatInUlL2Sts */ -#endif /* LTE_L2_MEAS */ - - -/** -@brief -This function processes Data Resume request received from the Application. - * @param[in] gCb PDCP Instance Control block - * @param[in] ueCb Uplink UeCb - * @return S16 - * -# Success : ROK - * -# Failure : RFAILED -*/ -#ifdef ANSI -PUBLIC S16 pjUtlUlPrcsDatResume -( -PjCb *gCb, -CpjDatResumeReqInfo *datResReq -) -#else -PUBLIC S16 pjUtlUlPrcsDatResume(gCb, datResReq) -PjCb *gCb; -CpjDatResumeReqInfo *datResReq; -#endif -{ - U8 rbCnt; - PjUlRbCb *pjRbCb = NULLP; - PjUlUeCb *ueCb= NULLP; - - pjDbmFetchUlUeCb(gCb, datResReq->ueId, datResReq->cellId, &ueCb); - if(!ueCb) - { - RLOG_ARG1(L_ERROR, DBG_CELLID, datResReq->cellId,"UeId[%u] not found", - datResReq->ueId); - RETVALUE(RFAILED); - } - - for(rbCnt = 0; rbCnt < PJ_MAX_DRB_PER_UE; rbCnt ++) - { - /* Check of rbCb available */ - if( (pjRbCb = ueCb->drbCb[rbCnt]) == NULLP) - { - continue; - } -#ifdef LTE_L2_MEAS - pjRbCb->ulCb.nxtSubSn = (pjRbCb->ulCb.rxNext % (1 << pjRbCb->snLen)); -#endif - - /* Process the packets in dlPktQ */ - pjUlmProcessUlPktQ(gCb, pjRbCb); - pjRbCb->state = PJ_STATE_NORMAL; - } - ueCb->libInfo.state = PJ_STATE_NORMAL; - RETVALUE(ROK); -} - -PUBLIC Void pjUtlEmptyUlPktList(PjCb *gCb, PjUlRbCb *pjRbCb) -{ - PjUlPkt *ulPkt; - CmLListCp *ulPktLst = &pjRbCb->ulCb.ulPktLst; - while(ulPktLst->first) - { - ulPkt = (PjUlPkt *)(ulPktLst->first->node); - cmLListDelFrm(ulPktLst, ulPktLst->first); - PJ_FREE_BUF(ulPkt->pdu); - PJ_FREE(gCb, ulPkt, sizeof(PjUlPkt)); - } - RETVOID; -} - -void dumpPDCPUlRbInformation(PjUlRbCb* ulRbCb, U16 ueId) -{ - PjUlCb* ulCb = &ulRbCb->ulCb; - -#ifndef ALIGN_64BIT - RTLIN_DUMP_DEBUG("UE [%u] PDCP UL RB numEntries = %lu\n",ueId, ulCb->recBuf.numEntries); -#else - RTLIN_DUMP_DEBUG("UE [%u] PDCP UL RB numEntries = %u\n",ueId, ulCb->recBuf.numEntries); -#endif -} - - -void DumpPDCPUlDebugInformation(void) -{ - PjCb* ulInst = pjCb[0]; /* TODO: check whether UL is 0 or 1 */ - - PjUlgCb* ulgCb = ulInst->u.ulCb; - - PjUlUeCb *ueCb = NULLP; - RTLIN_DUMP_DEBUG("PDCP UL Information\n"); - RTLIN_DUMP_DEBUG("===================\n"); - - /* Until no more ueCb is ueLstCp hash list get and delete ueCb */ - while (ROK == cmHashListGetNext(&ulgCb->ueLstCp, - (PTR) ueCb, - (PTR *)&ueCb)) - { - U32 i; - for(i = 0; i < PJ_MAX_SRB_PER_UE; i++) - { - PjUlRbCb* rbCb = ueCb->srbCb[i]; - if(rbCb != NULLP) - { - dumpPDCPUlRbInformation(rbCb, ueCb->key.ueId); - } - } - for(i = 0; i < PJ_MAX_DRB_PER_UE; i++) - { - PjUlRbCb* rbCb = ueCb->drbCb[i]; - if(rbCb != NULLP) - { - dumpPDCPUlRbInformation(rbCb, ueCb->key.ueId); - } - } - }/* end while */ -} - -#ifdef TENB_DPDK_BUF - -#ifdef ANSI -PUBLIC S16 pjUpdRxEntBuf -( -PjRxEnt *rxEnt -) -#else -PUBLIC S16 pjUpdRxEntBuf(rxEnt) -PjRxEnt *rxEnt; -#endif -{ - MsgLen msgLen; - Data *dpdkFBuf; - -#define PDCP_NW_OFFSET 8 - - TRC2(pjUpdRxEntBuf) - - - RETVALUE(ROK); -} - -#endif /* TENB_DPDK_BUF */ -#ifdef ANSI -PRIVATE S16 pjUtlUlHdlSecInitCfm -( -PjCb *gCb, /* Pointer to PJ DL Control Block */ -PjUlUeCb *ueCb, /* Pointer to UeCb */ -U16 txIdx, /* Transaction Index for UeCb */ -PjAsyncCfm *asyncCfm, /* Async Confirm */ -CpjSecCfgCfmInfo *secCfgCfm, /* Security config confirm */ -CpjReEstCfmInfo *reEstCfm /* Reest config confirm */ -) -#else -PRIVATE S16 pjUtlUlHdlSecInitCfm(gCb,ueCb,txIdx, asyncCfm,secCfgCfm,reEstCfm) -( -PjCb *gCb; /* Pointer to PJ DL Control Block */ -PjUlUeCb *ueCb; /* Pointer to UeCb */ -U16 txIdx; /* Transaction Index for UeCb */ -PjAsyncCfm *asyncCfm; /* Async Confirm */ -CpjSecCfgCfmInfo *secCfgCfm; /* Security config confirm */ -CpjReEstCfmInfo *reEstCfm; /* Reest config confirm */ -) -#endif -{ - TRC3(pjUtlUlHdlSecInitCfm) - - if(asyncCfm->libInitBitMask == 0) - { - PJ_CHK_RESTART_OBD_TIMER(gCb,ueCb, txIdx); - if(ueCb->libInfo.state == PJ_STATE_NORMAL) - { - /* Send security config confirm */ - PJ_ALLOC(gCb,secCfgCfm, sizeof(CpjSecCfgCfmInfo)); -#if (ERRCLASS & ERRCLS_DEBUG) - if (secCfgCfm == NULLP) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } -#endif /* (ERRCLASS & ERRCLS_DEBUG) */ - PJ_FILL_SEC_CFM_INFO(secCfgCfm, asyncCfm); - - PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx); - - PjUiCpjSecCfgCfm(&gCb->u.ulCb->cpjSap.pst, gCb->u.ulCb->cpjSap.suId, secCfgCfm); - } - else if(ueCb->libInfo.state == PJ_STATE_REEST) - { - /* Send ReEstCfm */ - PJ_ALLOC(gCb,reEstCfm, sizeof(CpjReEstCfmInfo)); -#if (ERRCLASS & ERRCLS_DEBUG) - if (reEstCfm == NULLP) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } -#endif /* (ERRCLASS & ERRCLS_DEBUG) */ - - PJ_FILL_REEST_CFM_INFO(reEstCfm, asyncCfm, LCM_PRIM_OK); - - /* Some house keeping work */ - PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx); - -#ifdef PJ_SEC_ASYNC - /*Change the state from REEST to NORMAL*/ - ueCb->libInfo.reEstCfmSent = TRUE; -#endif - PjUiCpjReEstCfm(&gCb->u.ulCb->cpjSap.pst, gCb->u.ulCb->cpjSap.suId, reEstCfm); - } - } - - RETVALUE(ROK); -} - - -#ifdef ANSI -PRIVATE S16 pjUtlUlHdlCmpInitCfm -( -PjCb *gCb, /* Pointer to PJ DL Control Block */ -PjUlUeCb *ueCb, /* Pointer to UeCb */ -U16 txIdx, /* Transaction Index for UeCb */ -PjAsyncCfm *asyncCfm, /* Async Confirm */ -CpjCfgCfmInfo *cfgCfm /* UDX Config Confirm */ -) -#else -PRIVATE S16 pjUtlUlHdlCmpInitCfm(gCb,ueCb,txIdx,asyncCfm,cfgCfm) -( -PjCb *gCb; /* Pointer to PJ DL Control Block */ -PjUlUeCb *ueCb; /* Pointer to UeCb */ -U16 txIdx; /* Transaction Index for UeCb */ -PjAsyncCfm *asyncCfm; /* Async Confirm */ -CpjCfgCfmInfo *cfgCfm; /* UDX Config Confirm */ -) -#endif -{ - U32 idx; - - TRC3(pjUtlUlHdlCmpInitCfm) - - if(asyncCfm->cmpInitBitMask == 0) - { - asyncCfm->libInitBitMask ^= (PJ_LIB_COMP_BIT_MASK); - - if((asyncCfm->libInitBitMask == 0) && - !(asyncCfm->cfmType & PJ_CFG_REEST_ASYNC_CFM)) - { - - /* Send config confirm */ - PJ_ALLOC(gCb,cfgCfm, sizeof(CpjCfgCfmInfo)); -#if (ERRCLASS & ERRCLS_ADD_RES) - if (cfgCfm == NULLP) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - cfgCfm->transId = asyncCfm->transId; - cfgCfm->ueId = asyncCfm->ueId; - cfgCfm->cellId = asyncCfm->cellId; - cfgCfm->numEnt = asyncCfm->numEnt; - for ( idx = 0; idx < asyncCfm->numEnt; idx++ ) - { - cfgCfm->cfmEnt[idx].status = asyncCfm->cfmEnt[idx].status; - cfgCfm->cfmEnt[idx].reason = asyncCfm->cfmEnt[idx].reason; - cfgCfm->cfmEnt[idx].rbId = asyncCfm->cfmEnt[idx].rbId; - cfgCfm->cfmEnt[idx].rbType = asyncCfm->cfmEnt[idx].rbType; - } - - /* Some house keeping work */ - PJ_CHK_RESTART_OBD_TIMER(gCb,ueCb, txIdx); - PJ_CLEAN_AND_UPD_ASYNCINFO(gCb,ueCb, txIdx); - - /* Send confirmtion to the User */ - PjUiCpjCfgCfm(&(gCb->u.ulCb->cpjSap.pst), gCb->u.ulCb->cpjSap.suId, cfgCfm); - } - } - RETVALUE(ROK); -} -#ifdef __cplusplus -} -#endif /* __cplusplus */ -/********************************************************************30** - End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_ulm.c b/src/5gnrpdcp/pj_ulm.c deleted file mode 100755 index 29d0a50d0..000000000 --- a/src/5gnrpdcp/pj_ulm.c +++ /dev/null @@ -1,3085 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************** - - Name: LTE-PDCP Layer - - Type: C file - - Desc: Source code for PDCP Uplink module. - This file contains following functions - -- pjUlmHdlSrbPkt - -- pjUlmHdlDrbPkt - -- pjUlmProcessRb - -- pjUlmDeliverSrb - -- pjUlmDeliverDrbUm - -- pjUlmDeliverDrbAm - -- pjUlmReEstSrb - -- pjUlmReEstDrbAm - -- pjUlmBldStaRep - -- pjUlmHdlDatFwdReq - -- pjUlmHdlObdTmrExpiry - - File: pj_ulm.c - -**********************************************************************/ -static const char* RLOG_MODULE_NAME="PDCP"; -static int RLOG_FILE_ID=245; -static int RLOG_MODULE_ID=1024; -/** @file pj_ulm.c -@brief PDCP Uplink module -*/ - -/* header (.h) include files */ -#include "envopt.h" /* environment options */ -#include "envdep.h" /* environment dependent */ -#include "envind.h" /* environment independent */ - -#include "gen.h" /* general */ -#include "ssi.h" /* system services interface */ -#include "cm5.h" /* Timer Functions */ -#include "cm_lte.h" /* common LTE header file */ -#include "cm_hash.h" /* common hash module file */ -#include "cm_llist.h" /* common list header file */ -#include "cpj.h" /* RRC layer */ -#include "pju.h" /* PDCP service user */ -#include "lpj.h" /* RRC layer */ -#include "pj_env.h" /* RLC environment options */ -#include "pj.h" /* RLC layer */ -#include "pj_ul.h" -#include "pj_err.h" -#include "pj_ptsec.h" - - - -/* header/extern include files (.x) */ - -#include "gen.x" /* general */ -#include "ssi.x" /* system services interface */ -#include "cm_lib.x" /* common library */ -#include "cm5.x" /* Timer Functions */ -#include "cm_hash.x" /* common hash module */ -#include "cm_lte.x" /* common LTE file */ -#include "cm_llist.x" /* common list header file */ -#include "cpj.x" /* RRC layer */ -#include "pju.x" /* PDCP service user */ -#include "lpj.x" /* LM Interface */ -#include "pj.h" /* LM Interface */ -#include "pj.x" /* RLC layer */ -#include "pj_udx.h" -#include "pj_udx.x" -#include "pj_dl.x" -#include "pj_ul.x" - - -/* local defines */ - -/* local externs */ -#ifdef TENB_AS_SECURITY -EXTERN U8 isSecBatchMode; -#endif - -/* forward references */ -PUBLIC S16 pjUtlChekTxEnqReq(PjCb *gCb, PjDlRbCb *pjRbCb, PjTxEnt *txEnt); -PUBLIC S16 pjUtlChekRxEnqReq(PjCb *gCb, PjUlRbCb *pjRbCb, PjRxEnt *rxEnt); - -/* public variable declarations */ - -/* This structure holds all the global structs we need. */ - -/* private variable declarations */ - -/* private function declarations */ - -PRIVATE S16 pjUlmDrbFetchSn -( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* !< PDCP Control Block */ -Buffer *pdu, /* !< PDU Buffer */ -U8 hdrByte, /* !< one byte extracted from pdu */ -PjSn *sn /* PDCP SN*/ -); -PRIVATE S16 pjUlmProcessRb -( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* !< PDCP Control Block */ -PjSn rcvdSn, /* !< SN value of PDU */ -Buffer *pdu, /* !< PDU message buffer */ -Bool isOutOfSeq /* !< To indicate whether packet received is in-sequence or not */ -); -/** @addtogroup uldata */ -/*@{*/ - -/***************************************************************************** - * HEADER PARSING FUNCTIONS - ****************************************************************************/ - -PRIVATE Void pjUlmEnqueueUlPkt ARGS(( PjCb *gCb, PjUlRbCb *pjRbCb,PjSn sn, Buffer *pdu)); - - - -PUBLIC S16 pjUlmHndlDlFdbk ARGS (( -PjCb *gCb, -PjUlRbCb *pjRbCb, -Buffer *mBuf -)); -/** - * - * @brief - * - * Function to extract the SRB header. - * - * @b Description: - * - * This function extracts the SN and the MAC-I from the pdu buffer and - * places them in the SrbHdr structure. - * - * @param[in] pjRbCb PDCP control block - * @param[in] pdu PDU to be processed - * @return S16 - * -# ROK - * -# RFAILED - */ - -#ifdef ANSI -PUBLIC S16 pjUlmHdlSrbPkt -( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* !< PDCP Control Block */ -Buffer *pdu /* !< PDU Buffer */ -) -#else -PUBLIC S16 pjUlmHdlSrbPkt(gCb, pjRbCb, pdu) -PjCb *gCb; -PjUlRbCb *pjRbCb; /* !< PDCP Control Block */ -Buffer *pdu; /* !< PDU Buffer */ -#endif -{ - S16 ret = ROK; /* Return Value */ - PjSn sn; /* SN value */ - U8 hdrByte; /* First byte storing hdr values */ - U8 res; /* Reserved values */ - - TRC2(pjUlmHdlSrbPkt); - - - /* Initialistaions */ - - /* Get the first byte */ - ret = SRemPreMsg(&hdrByte, pdu); -#if (ERRCLASS & ERRCLS_DEBUG) - if (ret != ROK) - { - RLOG_ARG0(L_ERROR, DBG_UEID,pjRbCb->ueCb->key.ueId," SRemPreMsg Failed "); - PJ_FREE_BUF(pdu); - PJ_STS_INC_GEN_CNT(gCb,errorPdusRecv); - RETVALUE(RFAILED); - } -#endif /* (ERRCLASS & ERRCLS_DEBUG) */ - - /* Verify that reserved values are zero */ - res = (hdrByte >> 4); - if(res != 0) - { - RLOG_ARG0(L_ERROR,DBG_UEID,pjRbCb->ueCb->key.ueId, - "Reserved Values Non-zero "); - PJ_FREE_BUF(pdu); - PJ_STS_INC_GEN_CNT(gCb,errorPdusRecv); - RETVALUE(RFAILED); - } - - /* Directly assigning since the reserved values are zero */ - sn = hdrByte; - sn = sn << PJ_BYTE_SIZE; - ret = SRemPreMsg(&hdrByte, pdu); -#if (ERRCLASS & ERRCLS_DEBUG) - if (ret != ROK) - { - PJDBGP(gCb,(PJ_DBGMASK_ULM | PJ_DBGMASK_ERROR), - (gCb->init.prntBuf," SRemPreMsg Failed \n")); - RETVALUE(RFAILED); - } -#endif - sn |= hdrByte; - - /* Start processing */ - ret = pjUlmProcessRb(gCb, pjRbCb, sn, pdu, FALSE); - - RETVALUE(ret); -}/* pjUlmHdlSrbPkt */ - -/** - * - * @brief - * - * Handler to forward the status report to PDCP-DL. - * - * @b Description: - * - * 1. This function is called when a status report is received from the - * peer. @n - * 2. This function forwards the status report to PDCP-DL. @n - * - * @param[in] pjRbCb PDCP control block. - * @param[in] staPdu Status report. - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ - -#ifdef ANSI -PUBLIC S16 pjUlmHndlDlStaRep -( -PjCb *gCb, -PjUlRbCb *pjRbCb, -PjSn fmc, -Buffer *staPdu -) -#else -PUBLIC S16 pjUlmHndlDlStaRep(gCb, pjRbCb, fmc, staPdu) -PjCb *gCb; -PjUlRbCb *pjRbCb; -PjSn fmc, -Buffer *staPdu; -#endif -{ - UdxDlStaRepInfo *staRep; - PjUdxUlSapCb *udxSap; - S16 ret = ROK; /* Return Value */ - - TRC3(pjUlmHndlDlStaRep) - - udxSap = PJ_GET_UL_UDX_SAP(gCb); - PJ_ALLOC_BUF_SHRABL(udxSap->pst ,staRep, - sizeof (UdxUlStaRepInfo), ret); - if(ret != ROK) - { - staRep = NULLP; - } - - if (NULLP != staRep) - { - staRep->pdcpId.cellId = pjRbCb->ueCb->key.cellId; - staRep->pdcpId.ueId = pjRbCb->ueCb->key.ueId; - staRep->pdcpId.rbId = pjRbCb->rbId; - staRep->pdcpId.rbType = pjRbCb->rbType; - staRep->fmc = fmc; - staRep->staPdu = staPdu; - - PjUlUdxDlStaRep(&(udxSap->pst), udxSap->spId, staRep); - } - else - { - RETVALUE(RFAILED); - } - - RETVALUE(ROK); -} - -/** - * - * @brief - * - * Handler to forward the ROHC feedback packet received from UE to PDCP-DL. - * - * @b Description: - * - * 1. This function is called when a ROHC feedback packet received from - * peer. @n - * 2. This function forwards the ROHC feedback packet to PDCP-DL. @n - * - * @param[in] gCb global control block. - * @param[in] pjRbCb PDCP control block. - * @param[in] mBuf ROHC feedback packet. - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ - -#ifdef ANSI -PUBLIC S16 pjUlmHndlDlFdbk -( -PjCb *gCb, -PjUlRbCb *pjRbCb, -Buffer *mBuf -) -#else -PUBLIC S16 pjUlmHndlDlFdbk(gCb, pjRbCb, mBuf) -PjCb *gCb; -PjUlRbCb *pjRbCb; -Buffer *mBuf; -#endif -{ - UdxDlFdbkPktInfo *fbPkt; - PjUdxUlSapCb *udxSap; - S16 ret = ROK; - - TRC3(pjUlmHndlDlFdbk) - - udxSap = PJ_GET_UL_UDX_SAP(gCb); - - PJ_ALLOC_BUF_SHRABL(udxSap->pst, fbPkt, - sizeof (UdxDlFdbkPktInfo), ret); - if(ret != ROK) - { - fbPkt = NULLP; - } - - if (NULLP != fbPkt) - { - fbPkt->pdcpId.cellId = pjRbCb->ueCb->key.cellId; - fbPkt->pdcpId.ueId = pjRbCb->ueCb->key.ueId; - fbPkt->pdcpId.rbId = pjRbCb->rbId; - fbPkt->pdcpId.rbType = pjRbCb->rbType; - - fbPkt->fbPkt= mBuf; - - PjUlUdxDlFdbkPktInfo(&(udxSap->pst), udxSap->spId, fbPkt); - } - else - { - RETVALUE(RFAILED); - } - - RETVALUE(ROK); -} - -/** - * - * @brief - * - * Function to extract the DRB SN from hdr. - * - * @b Description: - * - * This function extracts the SN in case of a data packet - * - * @param[in] pjRbCb PDCP control block - * @param[in] pdu PDU to be processed - * @return S16 - * -# ROK - * -# RFAILED - */ -#ifdef ANSI -PRIVATE S16 pjUlmDrbFetchSn -( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* !< PDCP Control Block */ -Buffer *pdu, /* !< PDU Buffer */ -U8 hdrByte, /* !< one byte extracted from pdu */ -PjSn *sn /* PDCP SN*/ -) -#else -PRIVATE S16 pjUlmDrbFetchSn(gCb, pjRbCb, pdu, hdrByte, sn) -PjCb *gCb; -PjUlRbCb *pjRbCb; /* !< PDCP Control Block */ -Buffer *pdu; /* !< PDU Buffer */ -U8 hdrByte; /* !< one byte extracted from pdu */ -PjSn *sn; /* PDCP SN*/ -#endif -{ - U8 res; /* Reserved values */ - S16 ret = ROK; /* Return Value */ - /* Pack the SN */ - - if (pjRbCb->snLen == PJ_12_BIT_SN) /* Its 12 bit */ - { - /* Verify that reserved values are zero */ - res = (hdrByte >> 4); - if (res != 8) - { - PJDBGP(gCb,(PJ_DBGMASK_ULM | PJ_DBGMASK_ERROR), - (gCb->init.prntBuf," Reserved Values Non-zero \n")); - RETVALUE(RFAILED); - } - - *sn = (hdrByte & PJ_12_BIT_SN_MSB_MASK); /*KW_FIX*/ - *sn = *sn << PJ_BYTE_SIZE; - ret = SRemPreMsg(&hdrByte, pdu); -#if (ERRCLASS & ERRCLS_DEBUG) - if (ret != ROK) - { - PJDBGP(gCb,(PJ_DBGMASK_ULM | PJ_DBGMASK_ERROR), - (gCb->init.prntBuf," SRemPreMsg Failed \n")); - RETVALUE(RFAILED); - } -#endif /* (ERRCLASS & ERRCLS_DEBUG) */ - *sn |= hdrByte; - } - else if (pjRbCb->snLen == PJ_18_BIT_SN) - { - *sn = ((hdrByte & PJ_18_BIT_SN_MSB_MASK)); /*KW_FIX*/ - *sn = *sn << PJ_BYTE_SIZE; - ret = SRemPreMsg(&hdrByte, pdu); -#if (ERRCLASS & ERRCLS_DEBUG) - if (ret != ROK) - { - PJDBGP(gCb,(PJ_DBGMASK_ULM | PJ_DBGMASK_ERROR), - (gCb->init.prntBuf," SRemPreMsg Failed \n")); - RETVALUE(RFAILED); - } -#endif /* (ERRCLASS & ERRCLS_DEBUG) */ - *sn |= hdrByte; - *sn = *sn << PJ_BYTE_SIZE; - ret = SRemPreMsg(&hdrByte, pdu); -#if (ERRCLASS & ERRCLS_DEBUG) - if (ret != ROK) - { - PJDBGP(gCb,(PJ_DBGMASK_ULM | PJ_DBGMASK_ERROR), - (gCb->init.prntBuf," SRemPreMsg Failed \n")); - RETVALUE(RFAILED); - } -#endif /* (ERRCLASS & ERRCLS_DEBUG) */ - *sn |= hdrByte; - } - - RETVALUE(ret); -} - -/** - * - * @brief - * - * Function to extract the FMC. - * - * @b Description: - * - * This function extracts the FMC and Bitmap incase of a - * PDCP status packet places them in the DrbHdr structure. - * - * @param[in] pjRbCb PDCP control block - * @param[in] pdu PDU to be processed - */ -#ifdef ANSI -PUBLIC S16 pjUlmGetFmc -( -U8 hdrByte, -PjUlRbCb *pjRbCb, /* !< PDCP Control Block */ -Buffer *pdu, /* !< PDU Buffer */ -U32 *fmc -) -#else -PUBLIC S16 pjUlmGetFmc(hdrByte,pjRbCb, pdu, fmc) -U8 hdrByte; -PjUlRbCb *pjRbCb; /* !< PDCP Control Block */ -Buffer *pdu; /* !< PDU Buffer */ -U32 *fmc; -#endif -{ - - S16 ret = ROK; - TRC2(pjUlmGetFmc) - ret = SRemPreMsg(&hdrByte, pdu); -#if (ERRCLASS & ERRCLS_DEBUG) - if(ret != ROK) - { - RLOG_ARG0(L_DEBUG, DBG_UEID,pjRbCb->ueCb->key.ueId,"SRemPreMsg Failed"); - PJ_FREE_BUF(pdu); - RETVALUE(RFAILED); - } -#endif - *fmc = hdrByte; - *fmc = *fmc << PJ_BYTE_SIZE; - ret = SRemPreMsg(&hdrByte, pdu); -#if (ERRCLASS & ERRCLS_DEBUG) - if(ret != ROK) - { - RLOG_ARG0(L_DEBUG, DBG_UEID,pjRbCb->ueCb->key.ueId,"SRemPreMsg Failed"); - - PJ_FREE_BUF(pdu); - RETVALUE(RFAILED); - } -#endif /* (ERRCLASS & ERRCLS_DEBUG) */ - *fmc |= hdrByte; - *fmc = *fmc << PJ_BYTE_SIZE; - ret = SRemPreMsg(&hdrByte, pdu); -#if (ERRCLASS & ERRCLS_DEBUG) - if(ret != ROK) - { - RLOG_ARG0(L_DEBUG, DBG_UEID,pjRbCb->ueCb->key.ueId,"SRemPreMsg Failed"); - - PJ_FREE_BUF(pdu); - RETVALUE(RFAILED); - } -#endif /* (ERRCLASS & ERRCLS_DEBUG) */ - *fmc |= hdrByte; - *fmc = *fmc << PJ_BYTE_SIZE; - ret = SRemPreMsg(&hdrByte, pdu); -#if (ERRCLASS & ERRCLS_DEBUG) - if(ret != ROK) - { - RLOG_ARG0(L_DEBUG, DBG_UEID,pjRbCb->ueCb->key.ueId,"SRemPreMsg Failed"); - - PJ_FREE_BUF(pdu); - RETVALUE(RFAILED); - } -#endif /* (ERRCLASS & ERRCLS_DEBUG) */ - *fmc |= hdrByte; - RETVALUE(ret); - -} - - - -/** - * - * @brief - * - * Function to extract the DRB header. - * - * @b Description: - * - * This function extracts the SN in case of a data packet - * or feedback packet and the FMS and Bitmap incase of a - * PDCP status packet places them in the DrbHdr structure. - * - * @param[in] pjRbCb PDCP control block - * @param[in] pdu PDU to be processed - * @return S16 - * -# ROK - * -# RFAILED - */ -#ifdef ANSI -PUBLIC S16 pjUlmHdlDrbPkt -( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* !< PDCP Control Block */ -Buffer *pdu, /* !< PDU Buffer */ -Bool isOutOfSeq /*!< To indicate whether this packet is in-sequence or not */ -) -#else -PUBLIC S16 pjUlmHdlDrbPkt(gCb, pjRbCb, pdu, isOutOfSeq) -PjCb *gCb; -PjUlRbCb *pjRbCb; /* !< PDCP Control Block */ -Buffer *pdu; /* !< PDU Buffer */ -Bool isOutOfSeq; /* !< To indicate whether this packet is in-sequence or not */ -#endif -{ - S16 ret = ROK; /* Return Value */ - PjSn sn = 0; /* SN value */ - U8 hdrByte; /* First byte storing hdr values */ - U8 pduType; /* Type of PDU */ - U8 res; /* Reserved values */ - U32 fmc; /*First Missing Count 5G Nr*/ - - TRC2(pjUlmHdlDrbPkt) -#ifndef RGL_SPECIFIC_CHANGES -#ifndef TENB_ACC -#ifndef LTE_PAL_ENB -extern U32 ulrate_kwu; -MsgLen len; -SFndLenMsg(pdu, &len); -ulrate_kwu += len; -#endif -#endif -#endif - /* Get the first byte */ - ret = SRemPreMsg(&hdrByte, pdu); -#if (ERRCLASS & ERRCLS_DEBUG) - if (ret != ROK) - { - RLOG_ARG0(L_DEBUG, DBG_UEID,pjRbCb->ueCb->key.ueId," SRemPreMsg Failed "); - PJ_FREE_BUF(pdu); - PJ_STS_INC_GEN_CNT(gCb,errorPdusRecv); - RETVALUE(RFAILED); - } -#endif /* (ERRCLASS & ERRCLS_DEBUG) */ - - /* check if its a data PDU */ - if((hdrByte & PJ_TYPE_DRB_DATA) == PJ_TYPE_DRB_DATA) - { - ret = pjUlmDrbFetchSn (gCb, pjRbCb, pdu, hdrByte, &sn); -#if (ERRCLASS & ERRCLS_DEBUG) - if (ret != ROK) - { - PJDBGP(gCb,(PJ_DBGMASK_ULM | PJ_DBGMASK_ERROR), - (gCb->init.prntBuf," Failed to extract SN from PDU\n")); - PJ_FREE_BUF(pdu); - PJ_STS_INC_GEN_CNT(gCb,errorPdusRecv); - RETVALUE(RFAILED); - } -#endif /* (ERRCLASS & ERRCLS_DEBUG) */ - - /* Call the processing function */ - if(pjRbCb->mode == PJ_DRB_AM) - { - if (pjRbCb->state == PJ_STATE_HO) - { - pjUlmEnqueueUlPkt(gCb,pjRbCb,sn,pdu); - } - else - { - ret = pjUlmProcessRb(gCb, pjRbCb, sn, pdu, isOutOfSeq); - } - } - else /* (pjRbCb->type == PJ_DRB_UM) */ - { - ret = pjUlmProcessRb(gCb, pjRbCb, sn, pdu, FALSE); - } - } - else /* Its a control PDU */ - { - - pduType = (U8)((hdrByte & PJ_PDU_BIT_MASK) >> 4); /*KW_FIX*/ - - if(pduType == PJ_TYPE_STATUS_REPORT) - { - pjUlmGetFmc(hdrByte,pjRbCb,pdu,&fmc); - ret = pjUlmHndlDlStaRep(gCb, pjRbCb, fmc, pdu); - if (ret != ROK) - { - RLOG_ARG0(L_DEBUG,DBG_UEID,pjRbCb->ueCb->key.ueId, - " pjUlmHndlDlStaRep() returned Failed "); - PJ_FREE_BUF(pdu); - RETVALUE(RFAILED); - } - } - else if(pduType == PJ_TYPE_ROHC_FEEDBACK) - { - - /* validate that reserved values are 0*/ - res = (U8)(hdrByte & PJ_CPDU_RES_VAL_MASK); /*KW_FIX*/ - if(res != 0) - { - RLOG_ARG0(L_DEBUG,DBG_UEID,pjRbCb->ueCb->key.ueId, - " Reserved values non-null "); - PJ_FREE_BUF(pdu); - PJ_STS_INC_GEN_CNT(gCb,errorPdusRecv); - RETVALUE(RFAILED); - } - - ret = pjUlmHndlDlFdbk(gCb, pjRbCb, pdu); - if (ret != ROK) - { - RLOG_ARG0(L_DEBUG,DBG_UEID,pjRbCb->ueCb->key.ueId, - " pjUlmHndlDlStaRep() returned Failed "); - PJ_FREE_BUF(pdu); - RETVALUE(RFAILED); - } - } - else - { - /* Invalid PDU type */ - RLOG_ARG0(L_DEBUG,DBG_UEID,pjRbCb->ueCb->key.ueId, - " Invalid PDU Type "); - PJ_FREE_BUF(pdu); - PJ_STS_INC_GEN_CNT(gCb,errorPdusRecv); - RETVALUE(RFAILED); - } - } - RETVALUE(ret); -}/* pjUlmHdlDrbPkt */ - -/***************************************************************************** - * PROCESSING FUNCTIONS - ****************************************************************************/ -/** - * - * @brief - * - * Function to process the PDCP RB Pdu and updates the state variables. - * - * @b Description: - * - * This function performs the follwing steps: @n - * 1. Create and Insert the entry in the reception buffer. @n - * 2. Check for firstSn in reestablish state. @n - * 3. Update nxtSubCnt and nxtSubDeCmp. @n - * 4. Call pjUtlDecipher to perform deciphering. @n - * 5. Call pjUtlDecomp to perform integrity verification. @n - * 6. Call pjUlmDeliverDrbUm for performing state updations and - * submitting to upper layers. @n - * - * @param[in] pjRbCb PDCP control block - * @param[in] rcvdSn SN value of the pdu - * @param[in] pdu PDU message buffer. - * - * @return S16 - * -# ROK - * -# RFAILED - */ -#ifdef ANSI -PUBLIC S16 pjUlmProcessRb -( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* !< PDCP Control Block */ -PjSn rcvdSn, /* !< SN value of PDU */ -Buffer *pdu, /* !< PDU message buffer */ -Bool isOutOfSeq /* !< To indicate whether packet received is in-sequence or not */ -) -#else -PUBLIC S16 pjUlmProcessRb(gCb, pjRbCb, rcvdSn, pdu, isOutOfSeq) -PjCb *gCb; -PjUlRbCb *pjRbCb; /* !< PDCP Control Block */ -PjSn rcvdSn; /* !< SN value of PDU */ -Buffer *pdu; /* !< PDU message buffer */ -Bool isOutOfSeq; /* !< To indicate whether packet received is in-sequence or not */ -#endif -{ - PjUlCb *ulCb; /* PTR to UL Control Block */ - PjRxEnt *rxEnt; /* Ptr to Rx Entry */ - S16 ret = ROK; /* Return value */ - U32 rcvdCount; /* Count value */ - U32 rcvdHfn; - Bool dupEntry; - U32 rxDelivHfn; -#ifdef PJ_SEC_ASYNC - U32 oldRxCnt; /* Old Count value used for decomp */ -#endif - - TRC2(pjUlmProcessRb) - - /* 1. Initialisations */ - ulCb = &pjRbCb->ulCb; - - /*1.5G-NR Determine the Hfn and count value of the received PDCP data pdu*/ - PJ_CALC_RCVD_HFN(rcvdSn,pjRbCb->snLen,ulCb->rxDeliv,rcvdHfn); - - /*2.5G-NR Get the count value of the receiced PDCP data pdu from rcvdSn and rcvdHfn */ - PJ_GET_COUNT(rcvdCount, pjRbCb->snLen, rcvdSn, rcvdHfn); - - - /* 3. Create the entry */ - PJ_ALLOC(gCb,rxEnt, sizeof(PjRxEnt)); -#if (ERRCLASS & ERRCLS_DEBUG) - if(rxEnt == NULLP) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } -#endif /* (ERRCLASS & ERRCLS_DEBUG) */ - - /* 4. Fill values and Insert into hash list */ - rxEnt->count = rcvdCount; - rxEnt->state = PJ_RDY_TO_DCIPHER; - rxEnt->mBuf = pdu; - rxEnt->lstEnt.next = NULLP; - rxEnt->lstEnt.prev = NULLP; - rxEnt->lstEnt.node = NULLP; - rxEnt->discFlag = rxEnt->dupEntry = 0; - rxEnt->isOutSeq = isOutOfSeq; - - PJ_GET_HFN(ulCb->rxDeliv,pjRbCb->snLen,rxDelivHfn) - - if((rcvdCount < ulCb->rxDeliv) &&(rxDelivHfn != PJ_MAX_HFN(pjRbCb->snLen))) - { - rxEnt->discFlag = TRUE; - PJ_FREE_BUF(rxEnt->mBuf); - PJ_FREE(gCb,rxEnt, sizeof(PjRxEnt)); - RETVALUE(ROK); - } - - ret = pjDbmInsRxEnt(gCb, &ulCb->recBuf, rxEnt, TRUE); - if(ret == ROKDUP) - { - /* Duplicates are not to be inserted */ - /* marked to be freed up later */ - rxEnt->dupEntry = TRUE; - } - dupEntry = rxEnt->dupEntry; - - /* 7. Cleanup the duplicates */ - if(dupEntry == TRUE) - { - /* duplicate entry, Need to add a counter to print it on console periodically */ - PJ_FREE_BUF(rxEnt->mBuf); - PJ_FREE(gCb,rxEnt, sizeof(PjRxEnt)); - RETVALUE(ROK); - } - - /*3.Update the RX_NEXT */ - PJ_ULM_UPDATE_RX_NEXT(pjRbCb,rxEnt); - -#ifdef PJ_SEC_ASYNC - oldRxCnt = ulCb->rxNext; - PJ_ULM_UPD_NXT2DCOMP(ulCb, (pjRbCb->snLen), rcvdCount,oldRxCnt); - PJ_ULM_UPD_NXT2SUB(ulCb, rcvdCount); -#endif - - /* 5. Update OBD count */ - PJ_INC_OBD_COUNT(pjRbCb,rxEnt->count); - - /* Check whether the received packet is in-sequence or not - * For every inSeq packet store the FMS Count value corresponding - * to the FMS + HFN now */ - if((isOutOfSeq == FALSE) && - (pjRbCb->rbType == PJ_DRB) && - (pjRbCb->mode == PJ_DRB_AM)) - { - /*Need to be check again */ - pjRbCb->ulCb.fmsCount = ulCb->rxNext ; - } - - /* 6. Send for deciphering */ - ret = pjUlmHdlDecipher(gCb, pjRbCb, rxEnt); - - RETVALUE(ret); -}/* pjUlmProcessRb */ - - -/** - * - * @brief - * - * Function is called when the offboard timer expires. - * - * @b Description: - * - * The function performs the following - * 1. If the SDU associated with the timer is not delivered, we - * delete the entry . @n - * 2. A status indication is sent to the user with error cause. @n - * 3. We associate the nextToSubmit value to the next SDU that has - * to be submitted. @n - * 4. The timer is associated with the nextToSubmit SDU and restarted.@n - * - * @param[in] pjRbCb PDCP control block - * @param[in] rxEnt Rx Entry - * - * @return S16 - * -# ROK - * -# RFAILED - */ -#ifdef ANSI -PUBLIC S16 pjUlmHdlDecipher -( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* !< PDCP Control Block */ -PjRxEnt *rxEnt /* !< Rx Entry */ -) -#else -PUBLIC S16 pjUlmHdlDecipher(gCb, pjRbCb, rxEnt) -PjCb *gCb; -PjUlRbCb *pjRbCb; /* !< PDCP Control Block */ -PjRxEnt *rxEnt; /* !< Rx Entry */ -#endif -{ - PjUlCb *ulCb; /* ULM Control Block */ - S16 ret = ROK; /* Return values */ - Buffer *mBuf = NULLP; /* Output Buffer */ - PjSec *secInfo; - U32 macI = 0; /*5G_NR for DRB, its a 4 byte field */ - TRC2(pjUlmHdlDecipher); - -#ifndef ALIGN_64BIT - PJDBGP(gCb,(PJ_DBGMASK_ULM | PJ_DBGMASK_DETAIL ), - (gCb->init.prntBuf, "pjUlmHdlDecipher(pjRbCb(%d,%d),rxEnt(%ld)) \n", \ - pjRbCb->rbId, pjRbCb->rbType, rxEnt->count)); -#else - PJDBGP(gCb,(PJ_DBGMASK_ULM | PJ_DBGMASK_DETAIL ), - (gCb->init.prntBuf, "pjUlmHdlDecipher(pjRbCb(%d,%d),rxEnt(%d)) \n", \ - pjRbCb->rbId, pjRbCb->rbType, rxEnt->count)); -#endif - - /* 1. Initialistions */ - ulCb = &pjRbCb->ulCb; - - secInfo = &(pjRbCb->ueCb->secInfo); - /* 2. Process for Deciphering */ - if(secInfo->secAct == TRUE && secInfo->cipherInfo.algoType != 0) - { - /* 2.1 Check that it is not the first pkt, with selectively enabled */ - if((pjRbCb->rbType == PJ_SRB) && - (pjRbCb->ueCb->secInfo.firstMsg && pjRbCb->ueCb->secInfo.selSecAct)) - { - /* first pkt */ - pjRbCb->ueCb->secInfo.firstMsg = FALSE; - } - else - { -#ifndef TENB_ACC -#ifndef LTE_PAL_ENB - pjUtlChekRxEnqReq(gCb, pjRbCb, rxEnt); -#endif -#endif -#ifdef SS_RBUF - if(rxEnt->rbCb) - { - RETVALUE(ROK); - } -#endif - /* 2.3 call deciphering hook */ - if( pjUtlDecipherReq(gCb, pjRbCb, rxEnt->count, rxEnt->mBuf, &mBuf) != ROK) - { - RLOG1(L_ERROR, "Deciphering Req failed Rx Count [%lu]", rxEnt->count); - PJ_SND_PJU_STA_IND(gCb,pjRbCb, rxEnt); - pjDbmDelRxEnt(gCb, &ulCb->recBuf, rxEnt->count); - PJ_STS_INC_GEN_CNT(gCb,numDeciphFails); - RETVALUE(RFAILED); - } - - - /* 2.4 wait for output before processing further */ - /* Batch Mode processing, Packets queued will be sent to spacc - together upon trigger */ -#ifdef TENB_AS_SECURITY - if(isSecBatchMode) - { - rxEnt->state = PJ_SENT_TO_DCIPHER; - RETVALUE(ROK); - } -#endif - -#if defined (PJ_SEC_ASYNC) || defined (INTEL_QAT_DP) - /* 2.4 wait for output before processing further */ - rxEnt->state = PJ_SENT_TO_DCIPHER; - RETVALUE(ROK); -#else /* PJ_SEC_ASYNC */ - /* 2.3 Validate output of deciphering */ - if(mBuf == NULLP) - { - RLOG1(L_ERROR, "Deciphering Req failed Rx Count [%lu]", rxEnt->count); - PJ_SND_PJU_STA_IND(gCb,pjRbCb, rxEnt); - pjDbmDelRxEnt(gCb, &ulCb->recBuf, rxEnt->count); - PJ_STS_INC_GEN_CNT(gCb,numDeciphFails); - RETVALUE(RFAILED); - } - - /* 2.5 copy output buffer */ -#ifdef TENB_AS_SECURITY - /* If not batch mode, free PDU. If batch mode, free will be done upon - SPAcc return */ - if(!(isSecBatchMode)) - { - PJ_FREE_BUF(rxEnt->mBuf); - } -#endif - rxEnt->mBuf = mBuf; -#endif - } - } -#ifdef TENB_DPDK_BUF - else if(pjRbCb->rbType == PJ_DRB) - { - pjUpdRxEntBuf(rxEnt); - } -#endif - /* 3. Post ciphering updations */ - if(pjRbCb->rbType == PJ_DRB) - { - rxEnt->state = PJ_RDY_TO_DCOMP; - /*Adding MACI for 5G NR for DRB in case of intergrity protection is enabled*/ - if(pjRbCb->ueCb->secInfo.intProtEnbForDrb) - { - PJ_UNPK_MACI(rxEnt->mBuf, macI); - } - ret = pjUlmHdlDeCmp(gCb, pjRbCb, rxEnt); - } - else - { - rxEnt->state = PJ_RDY_TO_INTVER; - ret = pjUlmHdlIntVer(gCb, pjRbCb, rxEnt); - } - - RETVALUE(ret); -}/* end of pjUlmHdlDecipher */ - - -/** - * - * @brief - * - * Function is called to perform integrity verification. - * - * @b Description: - * - * The function performs the following - * 1. Extract the mac-I. - * 2. Add sn to the buffer. - * 3. Call Integrity Verification hook. - * 4. Return in case of Async. - * 5. Validate output and submit for delivery. - * - * @param[in] pjRbCb PDCP control block - * @param[in] rxEnt Rx Entry - * - * @return S16 - * -# ROK - * -# RFAILED - */ -#ifdef ANSI -PUBLIC S16 pjUlmHdlIntVer -( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* !< PDCP Control Block */ -PjRxEnt *rxEnt /* !< Rx Entry */ -) -#else -PUBLIC S16 pjUlmHdlIntVer(gCb, pjRbCb, rxEnt) -PjCb *gCb; -PjUlRbCb *pjRbCb; /* !< PDCP Control Block */ -PjRxEnt *rxEnt; /* !< Rx Entry */ -#endif -{ - PjUlCb *ulCb; /* ULM Control Block */ - PjSn sn; /* Sn Value */ /*KW_FIX*/ - S16 ret = ROK; /* Return value */ - U32 macI = 0; /* Mac-I value */ - PjSecInp inParam; /* Input Params */ - Status status = ROK; /* Status of IntVer */ - - TRC2(pjUlmHdlIntVer); - -#ifndef ALIGN_64BIT - PJDBGP(gCb,(PJ_DBGMASK_ULM | PJ_DBGMASK_DETAIL ), - (gCb->init.prntBuf, "pjUlmHdlIntVer(pjRbCb(%d,%d),rxEnt(%ld)) \n", \ - pjRbCb->rbId, pjRbCb->rbType, rxEnt->count)); -#else - PJDBGP(gCb,(PJ_DBGMASK_ULM | PJ_DBGMASK_DETAIL ), - (gCb->init.prntBuf, "pjUlmHdlIntVer(pjRbCb(%d,%d),rxEnt(%d)) \n", \ - pjRbCb->rbId, pjRbCb->rbType, rxEnt->count)); -#endif - - /* 1. Initialistions */ - ulCb = &pjRbCb->ulCb; - - /* 2. Xtract the last four bits irrescpective of whether you - * are going to do integrity verification or not */ - - /* RANGELEY Fix */ -#ifndef INTEL_QAT_DP - PJ_UNPK_MACI(rxEnt->mBuf, macI); -#endif - - /* 3. Process for Integrity Verification */ - if(pjRbCb->ueCb->secInfo.secAct == TRUE && pjRbCb->ueCb->secInfo.intInfo.algoType != 0) - { - - /* 3.1 Prepare the input Parameters */ - inParam.dir = PJ_SEC_DIR_UL; - inParam.rbId = pjRbCb->rbId; - inParam.count = rxEnt->count; - - /* 3.2. Add the SN to the buffer */ - sn = (U32)(rxEnt->count % (1 << PJ_SRB_SN_LEN)); /*KW_FIX*/ - ret = SAddPreMsg((Data)sn, rxEnt->mBuf); -#if (ERRCLASS & ERRCLS_DEBUG) - if (ret != ROK) - { - RLOG_ARG0(L_ERROR, DBG_UEID,pjRbCb->ueCb->key.ueId, - " pjUlmProcessRb: SRemPreMsgMult Failed "); - pjDbmDelRxEnt(gCb, &ulCb->recBuf, rxEnt->count); - RETVALUE(RFAILED); - } -#endif /* (ERRCLASS & ERRCLS_DEBUG) */ - - /* 3.3 call deciphering hook */ - if( pjUtlIntVerReq(gCb, pjRbCb, inParam, rxEnt->mBuf, macI, &status) != ROK) - { - RLOG1(L_ERROR, "Integrity Verification Req failed Rx Count[%lu]", rxEnt->count); - ret = SRemPreMsg((Data *)&sn, rxEnt->mBuf); - if (ret != ROK) - { - } - PJ_SND_PJU_STA_IND(gCb,pjRbCb, rxEnt); - rxEnt->state = PJ_RX_INTVER_FAIL; - pjDbmDelRxEnt(gCb, &ulCb->recBuf, rxEnt->count); - PJ_STS_INC_GEN_CNT(gCb,numIntgVrfFails); - RETVALUE(RFAILED); - } -#ifdef INTEL_QAT_DP - /* 3.5 wait for output before processing further */ - rxEnt->state = PJ_SENT_TO_INTVER; - RETVALUE(ROK); -#else - /* 3.4. Remove the SN from the buffer */ - ret = SRemPreMsg((Data *)&sn, rxEnt->mBuf); -#if (ERRCLASS & ERRCLS_DEBUG) - if (ret != ROK) - { - RLOG1(L_ERROR, "SRemPreMsg failed Rx Count [%lu]", rxEnt->count); - PJ_FREE_BUF(rxEnt->mBuf); - pjDbmDelRxEnt(gCb, &ulCb->recBuf, rxEnt->count); - RETVALUE(RFAILED); - } -#endif /* (ERRCLASS & ERRCLS_DEBUG) */ - -#ifdef PJ_SEC_ASYNC - /* 3.5 wait for output before processing further */ - rxEnt->state = PJ_SENT_TO_INTVER; - RETVALUE(ROK); -#else - /* 3.6 Post integrity verification updations */ - if(status != ROK) - { - RLOG1(L_ERROR, "Integrity Verification Req failed Rx Count[%lu]", rxEnt->count); - PJ_SND_PJU_STA_IND(gCb,pjRbCb, rxEnt); - pjDbmDelRxEnt(gCb, &ulCb->recBuf, rxEnt->count); - PJ_STS_INC_GEN_CNT(gCb,numIntgVrfFails); - RETVALUE(RFAILED); - } - -#endif /* PJ_SEC_ASYNC */ -#endif /*INTEL_QAT_DP */ - } -#ifdef INTEL_QAT_DP - else - { -#endif - /* 4. Update state and send for delivery */ - rxEnt->state = PJ_RDY_TO_SUBMIT; - ret = pjUlmDeliverSrb(gCb, pjRbCb, rxEnt); -#ifdef INTEL_QAT_DP - } -#endif - - RETVALUE(ret); -}/* end of pjUlmHdlIntVer */ - - -/** - * - * @brief - * - * Function is called to handle decompression. - * - * @b Description: - * - * The function performs the following - * 1. Call decompression handler function. - * 2. For sync, validate output and submit for delivery. - * - * @param[in] pjRbCb PDCP control block - * @param[in] rxEnt Rx Entry - * - * @return S16 - * -# ROK - * -# RFAILED - */ -#ifdef ANSI -PUBLIC S16 pjUlmHdlDeCmp -( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* !< PDCP Control Block */ -PjRxEnt *rxEnt /* !< Rx Entry */ -) -#else -PUBLIC S16 pjUlmHdlDeCmp(gCb, pjRbCb, rxEnt) -PjCb *gCb; -PjUlRbCb *pjRbCb; /* !< PDCP Control Block */ -PjRxEnt *rxEnt; /* !< Rx Entry */ -#endif -{ - PjUlCb *ulCb; /* ULM Control Block */ - Buffer *mBuf = NULLP; /* Output Buffer */ - - TRC2(pjUlmHdlDeCmp); - -#ifndef ALIGN_64BIT - PJDBGP(gCb,(PJ_DBGMASK_ULM | PJ_DBGMASK_DETAIL ), - (gCb->init.prntBuf, "pjUlmHdlDeCmp(pjRbCb(%d,%d),rxEnt(%ld)) \n", \ - pjRbCb->rbId, pjRbCb->rbType, rxEnt->count)); -#else - PJDBGP(gCb,(PJ_DBGMASK_ULM | PJ_DBGMASK_DETAIL ), - (gCb->init.prntBuf, "pjUlmHdlDeCmp(pjRbCb(%d,%d),rxEnt(%d)) \n", \ - pjRbCb->rbId, pjRbCb->rbType, rxEnt->count)); -#endif - - /* 1. Initialistions */ - ulCb = &pjRbCb->ulCb; - - /* 2. process for decompression */ - if(pjRbCb->rohc.hdrCmpUsed == TRUE) - { - /* 2.1 call decompression hook */ - if(pjUtlDeCmpReq(gCb, pjRbCb,rxEnt->count, rxEnt->mBuf, &mBuf) != ROK) - { - RLOG1(L_ERROR, "DeCompression Req failed Rx Count[%lu]", rxEnt->count); - PJ_SND_PJU_STA_IND(gCb,pjRbCb, rxEnt); - pjDbmDelRxEnt(gCb, &ulCb->recBuf, rxEnt->count); - PJ_STS_INC_GEN_CNT(gCb,numDecmpFails); - RETVALUE(RFAILED); - } - -#ifdef PJ_CMP_ASYNC - /* 2.2 Wait for output before processing further */ - rxEnt->state = PJ_SENT_TO_DCOMP; - RETVALUE(ROK); -#else /* PJ_CMP_ASYNC */ - - /* 2.3 Validate output of decomp */ - if(mBuf == NULLP) - { - RLOG1(L_ERROR, "DeCompression Req failed Rx Count[%lu]", rxEnt->count); - PJ_SND_PJU_STA_IND(gCb,pjRbCb, rxEnt); - pjDbmDelRxEnt(gCb, &ulCb->recBuf, rxEnt->count); - PJ_STS_INC_GEN_CNT(gCb,numDecmpFails); - RETVALUE(RFAILED); - } - - /* 2.4 Copy output buffer */ - PJ_FREE_BUF(rxEnt->mBuf); - rxEnt->mBuf = mBuf; -#endif - } - - /* 3. Return for discardable entries */ - if((rxEnt->discFlag == TRUE) || - (rxEnt->dupEntry == TRUE)) - { - RLOG2(L_ERROR,"Dropping packets...discflag is [%d], dupEntry is [%d]", rxEnt->discFlag, rxEnt->dupEntry); - RETVALUE(ROK); - } - - /* 4. Post decomp updations */ - rxEnt->state = PJ_RDY_TO_SUBMIT; - PJ_DEC_OBD_COUNT(gCb, pjRbCb, rxEnt->count); - PJ_ULM_DELIVER_DRB(gCb,pjRbCb, rxEnt); - - RETVALUE(ROK); -}/* end of pjUlmHdlDeCmp */ - -#ifdef ANSI -PUBLIC S16 pjUlmDeliverPdu -( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* !< PDCP Control Block */ -PjRxEnt *rxEnt /* !< Recption Buffer Entry */ -) -#else -PUBLIC S16 pjUlmDeliverPdu(gCb,pjRbCb, rxEnt) -PjCb *gCb; -PjUlRbCb *pjRbCb; /* !< PDCP Control Block */ -PjRxEnt *rxEnt; /* !< Recption Buffer Entry */ -#endif -{ - PjUlCb *ulCb; - PjRxEnt *tmpEnt; /* Temp Entry - loop counter */ - U32 rxReOrdHfn,rxNextHfn, rxDelivHfn; - - - TRC2(pjUlmDeliverPdu) - - /* Initialisations */ - ulCb = &pjRbCb->ulCb; - if(rxEnt->state != PJ_RDY_TO_SUBMIT) - { - /* PDU still under processing, return */ - RETVALUE(ROK); - } - ulCb->outOfOrderDelivery = FALSE; - - if(ulCb->outOfOrderDelivery == FALSE ) - { - - /* submit to upper layers and delete entry */ - /* submit all the stored pdu's with consecutively associated COUNT value(s) starting from COUNT = RX_DELIV*/ - if(rxEnt->count == ulCb->rxDeliv) - { - cmLListFirst(&pjRbCb->ulCb.recBuf.datPktQ); - if(cmLListCrnt(&pjRbCb->ulCb.recBuf.datPktQ)) - { - - tmpEnt = (PjRxEnt *) cmLListNode(cmLListCrnt(&pjRbCb->ulCb.recBuf.datPktQ)); - do - { - PJ_SND_PJU_DAT_IND(gCb,pjRbCb, tmpEnt); - pjDbmDelRxEnt(gCb, &ulCb->recBuf, tmpEnt->count); - /*updating the stateVariable*/ - ulCb->rxDeliv = ulCb->rxDeliv + 1; - cmLListFirst(&pjRbCb->ulCb.recBuf.datPktQ); - if(cmLListCrnt(&pjRbCb->ulCb.recBuf.datPktQ) == NULLP) - { - break; - } - tmpEnt = (PjRxEnt *) cmLListNode(cmLListCrnt(&pjRbCb->ulCb.recBuf.datPktQ)); - }while(tmpEnt->count == ulCb->rxDeliv); - } - } - } - /*If out of order Delivery is configured*/ - else - { - PJ_SND_PJU_DAT_IND(gCb,pjRbCb, rxEnt); - pjDbmDelRxEnt(gCb, &ulCb->recBuf, rxEnt->count); - /*updating the stateVariable*/ - ulCb->rxDeliv = ulCb->rxDeliv + 1; - - } - - /* Update the Reordering state variable reffer sec 5.2.2.2 of 38.323 */ - Bool tmrRunning; - PJ_GET_HFN(ulCb->rxDeliv,pjRbCb->snLen,rxDelivHfn); - tmrRunning = pjChkTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_REORD_TMR); - if (tmrRunning) - { - PJ_GET_HFN(ulCb->rxDeliv,pjRbCb->snLen,rxReOrdHfn); - if ((ulCb->rxDeliv >= ulCb->rxReord) || - ((PJ_MAX_HFN(pjRbCb->snLen) == rxReOrdHfn) && - (0 == rxDelivHfn))) - { - pjStopTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_REORD_TMR); - tmrRunning = FALSE; - } - } - - if (!tmrRunning) - { - PJ_GET_HFN(ulCb->rxNext, pjRbCb->snLen,rxNextHfn); - if ((ulCb->rxDeliv < ulCb->rxNext) || - (((PJ_MAX_HFN(pjRbCb->snLen) == rxDelivHfn)) && - (0 == rxNextHfn))) - { - ulCb->rxReord = ulCb->rxNext; - pjStartTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_REORD_TMR); - } - } - -RETVALUE(ROK); -} - - - -/** - * - * @brief - * - * Function to perform updations and deliver the SDU to the upper layer. - * It is called for SRBs . - * - * @b Description: - * - * This function performs the following functions, @n - * 1. Call PjUiPjuDatInd to deliver the SDU to the upper layer. @n - * 2. In async mode, check if any subsequent SDUs can also be sent up.@n - * - * @param[in] pjRbCb PDCP control block - * @param[in] rxEn reception entry for the PDU - * @return S16 - * -# ROK - * -# RFAILED - */ -#ifdef ANSI -PUBLIC S16 pjUlmDeliverSrb -( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* !< PDCP Control Block */ -PjRxEnt *rxEnt /* !< Recption Buffer Entry */ -) -#else -PUBLIC S16 pjUlmDeliverSrb(gCb, pjRbCb, rxEnt) -PjCb *gCb; -PjUlRbCb *pjRbCb; /* !< PDCP Control Block */ -PjRxEnt *rxEnt; /* !< Recption Buffer Entry */ -#endif -{ -#ifdef PJ_SEC_ASYNC - PjUlCb *ulCb; - U32 count; /* Count for looping through the entries */ - U32 nxtRxCnt; /* Count for looping through the entries */ - PjRxEnt *tmpEnt; /* Temp var for looping through the entries */ -#endif - - TRC2(pjUlmDeliverSrb); -#ifndef ALIGN_64BIT - PJDBGP(gCb,(PJ_DBGMASK_ULM | PJ_DBGMASK_DETAIL ), - (gCb->init.prntBuf, "pjUlmDeliverSrb(pjRbCb(%d,%d),rxEnt(%ld)) \n", \ - pjRbCb->rbId, pjRbCb->rbType, rxEnt->count)); -#else - PJDBGP(gCb,(PJ_DBGMASK_ULM | PJ_DBGMASK_DETAIL ), - (gCb->init.prntBuf, "pjUlmDeliverSrb(pjRbCb(%d,%d),rxEnt(%d)) \n", \ - pjRbCb->rbId, pjRbCb->rbType, rxEnt->count)); -#endif - - /* Post integrity verification updations */ -#ifdef PJ_SEC_ASYNC - count = rxEnt->count; - ulCb = &pjRbCb->ulCb; -#endif - pjUlmDeliverPdu(gCb,pjRbCb,rxEnt); - -#ifdef PJ_SEC_ASYNC - tmpEnt = NULLP; - /* Search and see if any of the successive SDUs can - * also be sent to the upper layer */ - count++; - nxtRxCnt = ulCb->rxNext; - - /* Check till nxtRxCnt */ - while(count < nxtRxCnt) - { - /* Get the next node */ - tmpEnt = (PjRxEnt *)pjDbmGetRxEnt(gCb, &ulCb->recBuf, count); - count ++; - - if(tmpEnt == NULLP) - { - /* Such an entry does not exist, search for the next */ - continue; - } - if(tmpEnt->state != PJ_RDY_TO_SUBMIT) - { - /* Integrity verification not yet done so we have to wait */ - ulCb->nxtSubCnt = tmpEnt->count; - /* Cant send anymore messages up, break*/ - break; - } - else - { - /* call the PJU Primitive to deliver it to upper layers */ - PJ_SND_PJU_DAT_IND(gCb,pjRbCb, tmpEnt); - - /* cleanup the entry */ - pjDbmDelRxEnt(gCb, &ulCb->recBuf, tmpEnt->count); - } - } - - if( ((count == nxtRxCnt) &&(tmpEnt != NULLP) &&(tmpEnt->state == PJ_RDY_TO_SUBMIT)) || - ((count == nxtRxCnt) &&(tmpEnt == NULLP)) ) - { - if((pjChkTmr(gCb, (PTR)pjRbCb, PJ_EVT_UL_OBD_TMR)) == TRUE) - { - pjStopTmr(gCb, (PTR)pjRbCb, PJ_EVT_UL_OBD_TMR); - } - } -#endif /* PJ_SEC_ASYNC */ - - - RETVALUE(ROK); -}/* pjUlmDeliverSrb */ - - -/** - * - * @brief - * - * Function to deliver the SDU to the upper layer. - * It is called for DRB UM - * - * @b Description: - * - * This function performs the following functions. @n - * 1. Deliver the SDU to the upper layer @n - * 2. Clean up the hash list entry for this SDU. @n - * 3. For asynchronous mode, it checks if any subsequent - * messages can also be sent up. @n - * 4. Mark the next SDU to be submitted to the upper layers. @n - * - * @param[in] pjRbCb PDCP control block - * @param[in] rxEnt reception entry for the PDU - * @return S16 - * -# ROK - * -# RFAILED - */ -#ifdef ANSI -PUBLIC S16 pjUlmDeliverDrbUm -( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* !< PDCP Control Block */ -PjRxEnt *rxEnt /* !< Recption Buffer Entry */ -) -#else -PUBLIC S16 pjUlmDeliverDrbUm(gCb, pjRbCb, rxEnt) -PjCb *gCb; -PjUlRbCb *pjRbCb; /* !< PDCP Control Block */ -PjRxEnt *rxEnt; /* !< Recption Buffer Entry */ -#endif -{ - -#ifdef PJ_CMP_ASYNC - PjUlCb *ulCb; /* Uplink Cb Ptr */ - U32 nxtRxCnt; /* Count for looping through the entries */ - PjRxEnt *tmpEnt; /* Temp var for looping through the entries */ - U32 count; /* count varaible */ - ulCb = &pjRbCb->ulCb; -#endif - - TRC2(pjUlmDeliverDrbUm) -#ifndef ALIGN_64BIT - PJDBGP(gCb, (PJ_DBGMASK_ULM | PJ_DBGMASK_DETAIL ), - (gCb->init.prntBuf, "pjUlmDeliverDrbUm(pjRbCb(%d,%d),rxEnt(%ld)) \n", \ - pjRbCb->rbId, pjRbCb->rbType, rxEnt->count)); -#else - PJDBGP(gCb, (PJ_DBGMASK_ULM | PJ_DBGMASK_DETAIL ), - (gCb->init.prntBuf, "pjUlmDeliverDrbUm(pjRbCb(%d,%d),rxEnt(%d)) \n", \ - pjRbCb->rbId, pjRbCb->rbType, rxEnt->count)); -#endif - - /* Initialisations */ - - /* Update state */ - rxEnt->state = PJ_RDY_TO_SUBMIT; - -#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) - if(rxEnt->count != ulCb->nxtSubCnt) - { - RETVALUE(ROK); - } -#endif /* (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) */ -#ifndef PJ_CMP_ASYNC -#endif -#ifndef RGL_SPECIFIC_CHANGES -#ifndef TENB_ACC -#ifndef LTE_PAL_ENB - EXTERN U32 ulrate_pju; - MsgLen len; - SFndLenMsg(rxEnt->mBuf, &len); - ulrate_pju += len; -#endif -#endif -#endif - - pjUlmDeliverPdu(gCb,pjRbCb,rxEnt); - - -#ifdef PJ_CMP_ASYNC - - /* Search and see if any of the succeeding SNs can - * also be sent to the upper layer */ - nxtRxCnt = ulCb->rxNext; - - /* Search till nextRxCnt */ - for(count = ulCb->nxtSubCnt + 1; count < nxtRxCnt; count++) - { - /* Get the next node */ - tmpEnt = (PjRxEnt *)pjDbmGetRxEnt(gCb, &(ulCb->recBuf), count); - - if(tmpEnt == NULLP) - { - /* pj005.201 added support for L2 Measurement */ - /* Such an entry does not exist, search for the next */ - continue; - } - if(tmpEnt->state != PJ_RDY_TO_SUBMIT) - { - /* Cant send anymore messages up, break*/ - break; - } - else - { - /* pj005.201 added support for L2 Measurement */ - /* call the PJU Primitive to deliver it to upper layers */ - PJ_SND_PJU_DAT_IND(gCb,pjRbCb, tmpEnt); - - /* cleanup the entry */ - pjDbmDelRxEnt(gCb, &ulCb->recBuf, tmpEnt->count); - } - }/* end of while */ - - /* Update nxtSubCnt */ - ulCb->nxtSubCnt = count; -#endif /* PJ_CMP_ASYNC */ - -#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) - if(pjRbCb->state != PJ_STATE_NORMAL) - { - /* start reestablishment procedures if last message has been processed */ - if((ulCb->transCmp == TRUE) && - (ulCb->obdCnt == 0)) - { - /* It has received all messages from RLC and finished - * processing them. Possibility only when the last last message - * from deciphering fails. */ - PJ_ULM_DRBUM_REEST(gCb, pjRbCb); - } - } -#endif /* (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) */ - - RETVALUE(ROK); -}/* pjUlmDeliverDrbUm */ - -/** - * - * @brief - * - * Function to deliver the SDU to the upper layer. It is called for DRB AM - * - * @b Description: - * - * This function performs the following functions. @n - * 1. Delete duplicates and SDUs marked for discard. @n - * 2. Deliver the SDU to the upper layer @n - * 3. Perform sequential delivery for SDUs received during reestablishment. @n - * 4. Clean up the hash list entry for this SDU. @n - * 5. For asynchronous mode, check if any subsequent messages can also be sent up. @n - * 6. Mark the next SDU to be submitted to the upper layers. @n - * - * @param[in] pjRbCb PDCP control block - * @param[in] rxEnt Rx Entry - * - * @return S16 - * -# ROK - * -# RFAILED - */ -#ifdef ANSI -PUBLIC S16 pjUlmDeliverDrbAm -( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* !< PDCP Control Block */ -PjRxEnt *rxEnt /* !< Recption Buffer Entry */ -) -#else -PUBLIC S16 pjUlmDeliverDrbAm(gCb, pjRbCb, rxEnt) -PjCb *gCb; -PjUlRbCb *pjRbCb; /* !< PDCP Control Block */ -PjRxEnt *rxEnt; /* !< Recption Buffer Entry */ -#endif -{ -#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) - PjUlCb *ulCb; /* RB uplink Control Block */ -#endif - S16 ret; /* Return value */ - - TRC2(pjUlmDeliverDrbAm) -#ifndef ALIGN_64BIT - PJDBGP(gCb,(PJ_DBGMASK_ULM | PJ_DBGMASK_DETAIL ), - (gCb->init.prntBuf, "pjUlmDeliverDrbAm(pjRbCb(%d,%d),rxEnt(%ld)) \n", \ - pjRbCb->rbId, pjRbCb->rbType, rxEnt->count)); -#else - PJDBGP(gCb,(PJ_DBGMASK_ULM | PJ_DBGMASK_DETAIL ), - (gCb->init.prntBuf, "pjUlmDeliverDrbAm(pjRbCb(%d,%d),rxEnt(%d)) \n", \ - pjRbCb->rbId, pjRbCb->rbType, rxEnt->count)); -#endif - - /* Initialisations */ - ret = ROK; -#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) - ulCb = &pjRbCb->ulCb; -#endif -#ifndef RGL_SPECIFIC_CHANGES -#ifndef TENB_ACC -#ifndef LTE_PAL_ENB -extern U32 ulrate_pju; -MsgLen len; -SFndLenMsg(rxEnt->mBuf, &len); -ulrate_pju += len; -#endif -#endif -#endif - pjUlmDeliverPdu(gCb,pjRbCb,rxEnt); - #if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) - /* start reestablishment procedures if last message has been processed */ - if(pjRbCb->state != PJ_STATE_NORMAL) - { - if((ulCb->transCmp == TRUE) && - (ulCb->obdCnt == 0)) - { - /* It has received all messages from RLC and finished - * processing them. Possibility only when the last last message - * from deciphering fails. */ - pjUlmReEstDrbAm(gCb, pjRbCb); - } - } -#endif /* (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) */ - - RETVALUE(ret); -}/* pjUlmDeliverDrbAm */ - -/***************************************************************************** - * REESTABLISHMENT FUNCTIONS - ****************************************************************************/ - -/** - * - * @brief - * - * Function to is called to reestablish the SRB. It is called as when the - * reestablishment request is received. - * - * @b Description: - * - * This function performes the following. @n - * 1. Reset NEXT_PDCP_RX_SN and RX_HFN @n - * 2. Deinitialise the hashlist. @n - * - * @param[in] pjRbCb PDCP control block - * @return S16 - * -# ROK - * -# RFAILED - */ -#ifdef ANSI -PUBLIC S16 pjUlmReEstSrb -( -PjCb *gCb, -PjUlRbCb *pjRbCb /*!< PDCP control block */ -) -#else -PUBLIC S16 pjUlmReEstSrb(gCb,pjRbCb) -PjCb *gCb; -PjUlRbCb *pjRbCb; /*!< PDCP control block */ -#endif -{ - TRC2(pjUlmReEstSrb); - - /* Reset NEXT_PDCP_RX_SN and RX_HFN */ - pjRbCb->ulCb.rxNext = 0; - pjRbCb->ulCb.rxDeliv = 0; - - /* Deinitialise the hashlist */ - pjDbmRxDelAll(gCb, &pjRbCb->ulCb.recBuf); - - RETVALUE(ROK); -} /* pjUlmResetSrb */ - - - -/** - * - * @brief - * - * Function to is called to reestablish the DRB . - * - * @b Description: - * - * This function is called after the last pdu is received from RLC - * as part of reestablishment procedures. This function builds the staPdu - * and store it - * - * @param[in] pjCb PDCP Instance control block - * @param[in] pjRbCb PDCP control block - * @return S16 - * -# ROK - * -# RFAILED - */ -#ifdef ANSI -PUBLIC S16 pjUlmReEstDrbAm -( -PjCb *gCb, -PjUlRbCb *pjRbCb -) -#else -PUBLIC S16 pjUlmReEstDrbAm(gCb, pjRbCb) -PjCb *gCb; -PjUlRbCb *pjRbCb; -#endif -{ - U16 fms; /* First Missing SN */ - PjUlCb *ulCb; /* RB uplink Control Block */ - PjSn sn; /* temp sn */ - PjRxEnt *tmpEnt = NULLP; /* Temporary entity used in loop */ - U32 count; /* Counter variable */ - U32 idx; - U16 byteIdx = 0; - U8 bitIdx; - U8 numBits = 0; /*KW_FIX */ - Bool nxtSnNotFnd; - PjUlHoCfmInfo *hoInfo = NULLP; /* To store the numBits and bitMap */ - U8 packByte[512] = {0}; - - TRC2(pjUlmReEstDrbAm); - - RLOG2(L_DEBUG,"pjUlmReEstDrbAm(pjRbCb(%d,%d))",pjRbCb->rbId,pjRbCb->rbType); - - /* Initialisations */ - ulCb = &pjRbCb->ulCb; - PJ_MEM_SET(&(packByte), 0, (sizeof(packByte))); /*KW_FIX : ccpu00136902*/ - /* Its DRB AM from now on */ - if(pjRbCb->state == PJ_STATE_REEST) - { - /* if status report generation not necessary, quit */ - if(ulCb->staRepReqd == FALSE) - { - RETVALUE(ROK); - } - } - - /* If out-of-seq Pkts are stored in datPktQ then process the - * bitMap the following way */ - fms = (U16)(pjRbCb->ulCb.fmsCount & (0x0fff)); /*KW_FIX*/ - /* Setting the bitIdx to start from 8 */ - bitIdx = PJ_BYTE_SIZE; - /* Initialize idx as 1 since Bitmap starts from FMS + 1 */ - idx = 1; - cmLListFirst(&pjRbCb->ulCb.recBuf.datPktQ); - while(cmLListCrnt(&pjRbCb->ulCb.recBuf.datPktQ)) - { - nxtSnNotFnd = TRUE; - tmpEnt = (PjRxEnt *) cmLListNode(cmLListCrnt(&pjRbCb->ulCb.recBuf.datPktQ)); - /* Retrieve the SN from Count of RxEnt */ - sn = (U16)((tmpEnt->count) & (0x0fff)); /*KW_FIX*/ - if(tmpEnt->isOutSeq == FALSE) - { - /* This Packet is In-Seq so no need to compute this for Bitmap - * As this Packet should have SN less than FMS. */ - cmLListNext(&pjRbCb->ulCb.recBuf.datPktQ); - continue; - } - while((nxtSnNotFnd == TRUE) && (byteIdx < 512)) - { - /* BitMap start from FMS + 1 */ - count = fms + idx; - if(count >= (1 << pjRbCb->snLen)) - { - count = count % (1 << pjRbCb->snLen); - } - if(count != sn) - { - /* This SN is missing so set bitMap value to 0 */ - packByte[byteIdx] |= (0 << (--bitIdx)); - numBits++; - idx++; - } - else - { - /* This SN is present so set bitMap value to 1 */ - packByte[byteIdx] |= (1 << (--bitIdx)); - numBits++; - idx++; - nxtSnNotFnd = FALSE; - cmLListNext(&pjRbCb->ulCb.recBuf.datPktQ); - } - if(numBits % PJ_BYTE_SIZE == 0) - { - byteIdx++; - bitIdx = PJ_BYTE_SIZE; - } - } - if(byteIdx >= 512) - break; - } - /* if bitmap is not byte aligned, then append/pad - * with 0s (to indicate from here Packets not received) - * to make it byte aligned and send to App */ - while(numBits % 8 != 0) - { - packByte[byteIdx] |= (0 << (--bitIdx)); - numBits++; - } - - /* Store the numOfBits and bitMap in ueCb */ - if(pjRbCb->state == PJ_STATE_REEST_HO) - { - hoInfo = &pjRbCb->ueCb->hoInfo->hoCfmInfo[pjRbCb->rbId]; - hoInfo->pres = TRUE; - hoInfo->rbId = pjRbCb->rbId; - hoInfo->dir |= PJ_DIR_UL; - /* numBits sent from PDCP is always a multiple of 8 */ - hoInfo->numBits = numBits; - if (numBits > 0) - { - RLOG_ARG1(L_DEBUG,DBG_UEID,pjRbCb->ueCb->key.ueId, - "pjUlmReEstDrbAm : OutOfSeq UL Pkts are present for rbId = %d ", - pjRbCb->rbId); - /* ByteAlign the computed Bits, numBits is always a multiple of 8 */ -#ifndef XEON_SPECIFIC_CHANGES - SGetStaticBuffer(gCb->init.region, gCb->init.pool, (Data **)&hoInfo->ulBitMap, sizeof(U8) * (numBits / 8), 0); -#else - PJ_ALLOC(gCb, hoInfo->ulBitMap, sizeof(U8) * (numBits / 8)); -#endif -#if (ERRCLASS & ERRCLS_DEBUG) - if(hoInfo->ulBitMap == NULLP) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } -#endif /* (ERRCLASS & ERRCLS_DEBUG) */ - PJ_MEM_CPY(hoInfo->ulBitMap, packByte, (numBits / 8)); - } - hoInfo->count = pjRbCb->ulCb.fmsCount; - } - else - { - /* Send the status report only in case of Re-Establishment - * not during Handover as this part is hit when eNB is Source */ - RLOG_ARG0(L_DEBUG,DBG_UEID,pjRbCb->ueCb->key.ueId, - "pjUlmReEstDrbAm : Sending PDCP Status Report "); - pjUlmBldStaRep(gCb, pjRbCb, pjRbCb->ulCb.fmsCount, packByte, numBits); - } - /*No error check required here*/ - - RETVALUE(ROK); -} /* pjUlmReEstDrbAm */ - - -/** - * - * @brief - * - * Function is called to build and send the SDU Status report. - * - * @b Description: - * - * This function is called to build the SDU status report and send it to the - * lower layer after reestablishment. - * - * @param[in] pjRbCb PDCP control block - * @param[in] fms First Missing sequence number - * @param[in] staReq Buffer containing status report bitmap - * @return S16 - * -# ROK - * -# RFAILED - */ -#ifdef ANSI -PUBLIC S16 pjUlmBldStaRep -( -PjCb *gCb, -PjUlRbCb *pjRbCb, -PjSn fmc, -U8 *bitMap, -U16 bMapLen -) -#else -PUBLIC S16 pjUlmBldStaRep(gCb, pjRbCb, fmc, bitMap, bMapLen) -PjCb *gCb; -PjUlRbCb *pjRbCb; -PjSn fmc; -U8 *bitMap; -U16 bMapLen; -#endif -{ - Buffer *staRep = NULLP; - U8 packByte = 0; /* Temp Var for packing bytes */ - S16 ret = ROK; /* Return value */ - U16 byteLen = 0; - - TRC2(pjUlmBldStaRep); - - RLOG2(L_DEBUG, "pjUlmBldStaRep(pjRbCb(%d,%d))",pjRbCb->rbId, pjRbCb->rbType); - - PJ_ALLOC_BUF(gCb, staRep); -#if (ERRCLASS & ERRCLS_DEBUG) - if(staRep == NULLP) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } -#endif /* (ERRCLASS & ERRCLS_DEBUG) */ - SAddPstMsg(packByte, staRep); - packByte = (U8)((fmc & 0xff000000) >> 24); - - SAddPstMsg(packByte, staRep); - - packByte = (U8)((fmc & 0x00ff0000) >> 16); - SAddPstMsg(packByte, staRep); - - packByte = (U8)((fmc & 0x0000ff00) >> 8); - SAddPstMsg(packByte, staRep); - - packByte = (U8)((fmc & 0x000000ff)); - SAddPstMsg(packByte, staRep); - - /* Pack the bitmap */ - if(bMapLen != 0) - { - /* bMapLen will always be a multiple of 8 */ - byteLen = (U16)(bMapLen / 8); /*KW_FIX*/ - SAddPstMsgMult(bitMap, byteLen, staRep); - } - - /*send the status report to DLPDCP */ - - pjUtlUlSndUlStaRep(gCb, pjRbCb, staRep); - - RETVALUE(ret); - -}/*pjUlmBldStaRep*/ - - -/** - * - * @brief - * - * Function is called during handover to transfer the undeliverd SDUs - * at the target side. - * - * @b Description: - * - * This function performs the following. @n - * 1. Calculate lastSubCnt. @n - * 2. Compute count for each SDU. @n - * 3. Create an rxEnt for each SDU and insert it into the hashlist.@n - * - * @param[in] pjRbCb PDCP control block - * @param[in] datFwdReq Data Forward Request info - * @return S16 - * -# ROK - * -# RFAILED - */ -#ifdef ANSI -PUBLIC S16 pjUlmHdlDatFwdReq -( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* !< PDCP ID */ -PjuDatFwdReqInfo *datFwdReq /* !< DatFwdReq Info */ -) -#else -PUBLIC S16 pjUlmHdlDatFwdReq(gCb, pjRbCb, datFwdReq) -PjCb *gCb; -PjUlRbCb *pjRbCb; /* !< PDCP ID */ -PjuDatFwdReqInfo *datFwdReq; /* !< DatFwdReq Info */ -#endif -{ - U32 datFwdCnt; /* Temp value to store SDU count */ - PjRxEnt *rxEnt = NULLP; /* Rx Entry pointer */ - PjuDatFwdInfo *info; /* Loop var - pointer to DatFwdInfo */ - PjUlCb *ulCb = NULLP; /* UL Control block */ - U8 sduIndex; /* loop index */ - U32 rcvdHfn; - - TRC2(pjUlmHdlDatFwdReq); - - RLOG2(L_DEBUG, "pjUlmHdlDatFwdReq(pjRbCb(%d,%d), datFwdReq) ", - pjRbCb->rbId, pjRbCb->rbType); - - /* Initialisations */ - ulCb = &pjRbCb->ulCb; - - /* Loop through all SDUs */ - for( sduIndex = 0; sduIndex < datFwdReq->numSdus; sduIndex++) - { - info = &datFwdReq->datFwdInfo[sduIndex]; - PJ_STS_INC_GEN_CNT(gCb,numPktsRcvd); - - /*1.5G-NR Determine the Hfn and count value of the received PDCP data pdu*/ - PJ_CALC_RCVD_HFN((info->sn),pjRbCb->snLen,ulCb->rxDeliv,rcvdHfn); - /*2.5G-NR Get the count value of the receiced PDCP data pdu from rcvdSn and rcvdHfn */ - PJ_GET_COUNT(datFwdCnt, pjRbCb->snLen, (info->sn), rcvdHfn); - -#ifdef PJ_SEC_ASYNC - PJ_ULM_UPD_NXT2DCOMP(pjRbCb->ulCb, (pjRbCb->snLen), rcvdCount, oldRxCnt); -#endif - - /* PJ_ULM_UPD_RX_VAR(info->sn, pjRbCb); */ - - /* Create and insert the entry in the buffer */ - PJ_ALLOC(gCb,rxEnt, sizeof(PjRxEnt)); - -#if (ERRCLASS & ERRCLS_DEBUG) - if(rxEnt == NULLP) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } -#endif /* (ERRCLASS & ERRCLS_DEBUG) */ - - rxEnt->count = datFwdCnt; - rxEnt->state = PJ_RDY_TO_SUBMIT; - rxEnt->mBuf = info->sdu; - - if(pjRbCb->state == PJ_STATE_HO) - { - /* If RbCb State = PJ_STATE_HO, then this is Target and Forwarded Packets - * are received before Status Transfer so buffer this Packet */ - rxEnt->isOutSeq = TRUE; - } - /* Insert the entry in the buffer */ - pjDbmInsRxEnt(gCb, &ulCb->recBuf, rxEnt, FALSE); - } - - RETVALUE(ROK); -}/*pjUlmHdlDatFwdReq*/ - -/** - * - * @brief - * - * Function is called when - * 1. The offboard timer expires. - * 2. Deciphering returns. - * - * @b Description: - * - * The function is called when the pdu is next in line for decompression - * It performs the following. @n - * 1. Submit the pdu for decompression. @n - * 2. Check if any successive messages can be sent to for decompression @n - * 3. Update the nxtSubDeCmp value appropriately . @n - * - * @param[in] pjRbCb PDCP control block - * @param[in] rxEnt Reception Entry - * - * @return S16 - * -# ROK - * -# RFAILED - */ -#ifdef ANSI -PUBLIC S16 pjUlmSubmitForDecmp -( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* !< PDCP Control Block */ -PjRxEnt *rxEnt /* Ptr To Rx Entry */ -) -#else -PUBLIC S16 pjUlmSubmitForDecmp(gCb, pjRbCb, rxEnt) -PjCb *gCb; -PjUlRbCb *pjRbCb; /* !< PDCP Control Block */ -PjRxEnt *rxEnt; /* Ptr To Rx Entry */ -#endif -{ - PjUlCb *ulCb; /* ULM Control Block */ -#ifdef PJ_SEC_ASYNC - U32 count; /* count to go through the list and check */ - U32 nxtRxCnt; /* count of Sdu to receive next */ - PjRxEnt *tmpEnt; /* Temporary variable for looping */ -#endif /* PJ_SEC_ASYNC */ - U32 macI=0; - - TRC2(pjUlmSubmitForDecmp); - -#ifndef ALIGN_64BIT - RLOG3(L_DEBUG, "pjUlmSubmitForDecmp(pjRbCb(%d,%d),rxEnt(%ld)) ", - pjRbCb->rbId, pjRbCb->rbType, rxEnt->count); -#else - RLOG3(L_DEBUG, "pjUlmSubmitForDecmp(pjRbCb(%d,%d),rxEnt(%d)) ", - pjRbCb->rbId, pjRbCb->rbType, rxEnt->count); -#endif - - /* 1. Initialisations */ - ulCb = &pjRbCb->ulCb; - rxEnt->state = PJ_RDY_TO_DCOMP; - /*Adding MACI for 5G NR for DRB in case of intergrity protection is enabled*/ - if(pjRbCb->ueCb->secInfo.intProtEnbForDrb) - { - PJ_UNPK_MACI(rxEnt->mBuf, macI); - } - - /* 2. If decomp is disabled, start delivery procedures */ - if(pjRbCb->rohc.hdrCmpUsed != TRUE) - { - rxEnt->state = PJ_RDY_TO_SUBMIT; - PJ_DEC_OBD_COUNT(gCb, pjRbCb, rxEnt->count); - PJ_ULM_DELIVER_DRB(gCb,pjRbCb, rxEnt); - RETVALUE(ROK); - } - - /* 3. If not the next in line for decompression, wait.. */ - if(ulCb->nxtSubDeCmp != rxEnt->count) - { - RETVALUE(ROK); - } - - /* 4. Calling decompression hook */ - if(pjUlmHdlDeCmp(gCb, pjRbCb, rxEnt) != ROK) - { - RETVALUE(RFAILED); - } - -#ifdef PJ_SEC_ASYNC - /* 5. cycle through the subsequent entries to see if any of them are also - * available for decompression */ - nxtRxCnt = ulCb->rxNext; - - for(count = ulCb->nxtSubDeCmp + 1; count < nxtRxCnt; count ++) - { - /* 5.1 Get the next node */ - tmpEnt = pjDbmGetRxEnt(gCb, &ulCb->recBuf, count); - - /* 5.2 If such an entry does not exist, search for the next */ - if(tmpEnt == NULLP) - { - continue; - } - - /* 5.3 During post reestablishment phase, there might me some PDUs in - * the Rx Buffer that were received prior to reestablishment and - * have been fully processed but are not sent up because they are - * waiting for the arrival of a previous PDU. We can safely skip - * such an entry */ - if(tmpEnt->state == PJ_RDY_TO_SUBMIT) - { - continue; - } - - /* 5.4 Deciphering not yet done so we have to wait */ - if(tmpEnt->state != PJ_RDY_TO_DCOMP) - { - break; - } - - /*Adding MACI for 5G NR for DRB in case of intergrity protection is enabled*/ - if(pjRbCb->ueCb->secInfo.intProtEnbForDrb) - { - PJ_UNPK_MACI(rxEnt->mBuf, macI); - } - /* 5.5 Send it to decompression */ - if(pjUlmHdlDeCmp(gCb, pjRbCb, tmpEnt) != ROK) - { - RETVALUE(RFAILED); - } - - } /* while(!((sn == ulCb->nxtRxSn)... */ - - /* 6. Update nxtSubDeCmp */ - ulCb->nxtSubDeCmp = count; - -#endif /* PJ_SEC_ASYNC */ - - RETVALUE(ROK); - -}/* end of pjUlmSubmitForDecmp */ -/** - * - * @brief - * - * Function is called when the offboard timer expires. - * - * @b Description: - * - * The function performs the following - * 1. If the SDU associated with the timer is not delivered, we - * delete the entry . @n - * 2. A status indication is sent to the user with error cause. @n - * 3. In case of failure call pjUlmHdlErrUpdates to recalculate - * nxtSubCnt and if necessary nxtSubDeCmp. @n - * 4. The timer is associated with the nextToSubmit SDU and restarted.@n - * - * @param[in] pjRbCb PDCP control block - * - * @return S16 - * -# ROK - * -# RFAILED - */ -#ifdef ANSI -PUBLIC Void pjUlmHdlReordTmrExpiry -( -PjCb *gCb, -PjUlRbCb *pjRbCb /* !< PDCP Control Block */ -) -#else -PUBLIC Void pjUlmHdlReordTmrExpiry(gCb,pjRbCb) -PjCb *gCb; -PjUlRbCb *pjRbCb; /* !< PDCP Control Block */ -#endif -{ - PjRxEnt *tmpEnt = NULLP; - PjUlCb *ulCb; - U32 tmpNxtDelvrCnt; - U32 rxReOrdHfn, tmpNxtDlvrHfn; - - ulCb = &pjRbCb->ulCb; - - gPdcpStats.numPdcpCellReorderTmrExp++; - - cmLListFirst(&pjRbCb->ulCb.recBuf.datPktQ); - if(cmLListCrnt(&pjRbCb->ulCb.recBuf.datPktQ)) - { - tmpEnt = (PjRxEnt *) cmLListNode(cmLListCrnt(&pjRbCb->ulCb.recBuf.datPktQ)); - - /* all stored PDCP SDU(s) with associated COUNT value(s) < RX_REORD; */ - while(tmpEnt && (tmpEnt->count < ulCb->rxReord)) - { - PJ_SND_PJU_DAT_IND(gCb,pjRbCb, tmpEnt); - pjDbmDelRxEnt(gCb, &ulCb->recBuf, tmpEnt->count); - cmLListFirst(&pjRbCb->ulCb.recBuf.datPktQ); - if(cmLListCrnt(&pjRbCb->ulCb.recBuf.datPktQ) == NULLP) - { - break; - } - tmpEnt = (PjRxEnt *) cmLListNode(cmLListCrnt(&pjRbCb->ulCb.recBuf.datPktQ)); - } - } - - tmpNxtDelvrCnt = ulCb->rxReord; - cmLListFirst(&pjRbCb->ulCb.recBuf.datPktQ); - if(cmLListCrnt(&pjRbCb->ulCb.recBuf.datPktQ)) - { - tmpEnt = (PjRxEnt *) cmLListNode(cmLListCrnt(&pjRbCb->ulCb.recBuf.datPktQ)); - /* all stored PDCP SDU(s) with consecutively associated COUNT value(s) starting from RX_REORD */ - while(tmpEnt && ( tmpEnt->count == tmpNxtDelvrCnt )) - { - PJ_SND_PJU_DAT_IND(gCb,pjRbCb, tmpEnt); - tmpNxtDelvrCnt++; - pjDbmDelRxEnt(gCb, &ulCb->recBuf, tmpEnt->count); - cmLListFirst(&pjRbCb->ulCb.recBuf.datPktQ); - if(cmLListCrnt(&pjRbCb->ulCb.recBuf.datPktQ) == NULLP) - { - break; - } - tmpEnt = (PjRxEnt *) cmLListNode(cmLListCrnt(&pjRbCb->ulCb.recBuf.datPktQ)); - } - } - - /* update RX_DELIV to the COUNT value of the first PDCP SDU - which has not been delivered to upper layers, - with COUNT value >= RX_REORD;*/ - PJ_GET_HFN(ulCb->rxDeliv,pjRbCb->snLen,rxReOrdHfn); - PJ_GET_HFN(tmpNxtDelvrCnt,pjRbCb->snLen,tmpNxtDlvrHfn); - if ((tmpNxtDelvrCnt > ulCb->rxReord) || - ((PJ_MAX_HFN(pjRbCb->snLen) == rxReOrdHfn ) && (0 == tmpNxtDlvrHfn))) - { - ulCb->rxDeliv = tmpNxtDelvrCnt; - } - - if (ulCb->rxDeliv < ulCb->rxNext) - { - ulCb->rxReord = ulCb->rxNext; - pjStartTmr(gCb,(PTR)pjRbCb, PJ_EVT_UL_REORD_TMR); - } -} - - -#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) -/** - * - * @brief - * - * Function is called when the offboard timer expires. - * - * @b Description: - * - * The function performs the following - * 1. If the SDU associated with the timer is not delivered, we - * delete the entry . @n - * 2. A status indication is sent to the user with error cause. @n - * 3. In case of failure call pjUlmHdlErrUpdates to recalculate - * nxtSubCnt and if necessary nxtSubDeCmp. @n - * 4. The timer is associated with the nextToSubmit SDU and restarted.@n - * - * @param[in] pjRbCb PDCP control block - * - * @return S16 - * -# ROK - * -# RFAILED - */ -#ifdef ANSI -PUBLIC Void pjUlmHdlObdTmrExpiry -( -PjCb *gCb, -PjUlRbCb *pjRbCb /* !< PDCP Control Block */ -) -#else -PUBLIC Void pjUlmHdlObdTmrExpiry(gCb,pjRbCb) -PjCb *gCb; -PjUlRbCb *pjRbCb; /* !< PDCP Control Block */ -#endif -{ - PjUlCb *ulCb; /* ULM Control Block */ - PjRxEnt *rxEnt; /* Ptr To Rx Entry */ - U32 subCnt; /* Count that was/will be submitted */ - - TRC2(pjUlmHdlObdTmrExpiry); - - RLOG2(L_DEBUG, "pjUlmHdlObdTmrExpiry(pjRbCb(%d,%d)) ", - pjRbCb->rbId, pjRbCb->rbType); - - /* 1. Initialistions */ - ulCb = &pjRbCb->ulCb; - PJ_STS_INC_GEN_CNT(gCb,numPdusDiscObdTmrExp); - - - /* 2. For SDUs that have not yet been delivered */ - PJ_ULM_GET_SUBCNT(pjRbCb, subCnt, gCb); - if(ulCb->obdPdu == subCnt) - { - /* 2.1 Send failure indication and delete the entry */ - rxEnt = (PjRxEnt *)pjDbmGetRxEnt(gCb, &(ulCb->recBuf), ulCb->obdPdu); - if(rxEnt == NULLP) - { - if( ulCb->recBuf.numEntries == 0) - { - RETVOID; - } -#if (ERRCLASS & ERRCLS_DEBUG) - RLOG1(L_ERROR, "rxEnt not found for subCnt [%lu]", subCnt); -#endif /* (ERRCLASS & ERRCLS_DEBUG) */ - RETVOID; - } - else - { - RLOG1(L_ERROR, "Obd Timer expires without reply for subCnt [%lu]", subCnt); - PJ_SND_PJU_STA_IND(gCb,pjRbCb, rxEnt); - pjDbmDelRxEnt(gCb, &ulCb->recBuf, rxEnt->count); - } - - /* 2.2 Update nxtSubCnt */ - pjUlmHdlErrUpdates(gCb, pjRbCb, ulCb->obdPdu); - - /* 2.3 Restart timer if it has not been restarted already */ - if( ulCb->recBuf.numEntries != 0) - { - if((pjChkTmr(gCb, (PTR)pjRbCb, PJ_EVT_UL_OBD_TMR)) == FALSE) - { - PJ_ULM_GET_SUBCNT(pjRbCb, (ulCb->obdPdu), gCb); - if(!PJ_DRBAM_ALL_PDU_RECVD(pjRbCb)) - { - pjStartTmr(gCb, (PTR)pjRbCb, PJ_EVT_UL_OBD_TMR); - } - } - } - } - /* 3. For SDUs that have been delivered */ - else - { - if( ulCb->recBuf.numEntries != 0) - { - /* 3.1 Associate the nxtToSub with the timer */ - PJ_ULM_GET_SUBCNT(pjRbCb, (ulCb->obdPdu), gCb); - if(!PJ_DRBAM_ALL_PDU_RECVD(pjRbCb)) - { - pjStartTmr(gCb, (PTR)pjRbCb, PJ_EVT_UL_OBD_TMR); - } - } - } - - RETVOID; -}/* end of pjUlmHdlObdTmrExpiry */ -#endif /* (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) */ - - -/** - * - * @brief - * - * Function is called when - * 1. The offboard timer expires - * 2. The library functions fail. - * - * @b Description: - * - * The function performs the following - * 1. Update nxtSubCnt if necessary. - * 2. Update nxtSubDeCmp if necessary. - * 3. Check if reestablishment has to be triggered. - * - * @param[in] pjRbCb PDCP control block. - * @param[in] errCnt Count of the error PDU. - * - * @return Void - */ -#ifdef ANSI -PUBLIC Void pjUlmHdlErrUpdates -( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* !< PDCP Control Block */ -U32 errCnt /* !< Count of PDU that raises the error */ -) -#else -PUBLIC Void pjUlmHdlErrUpdates(gCb, pjRbCb, errCnt) -PjCb *gCb; -PjUlRbCb *pjRbCb; /* !< PDCP Control Block */ -U32 errCnt; /* !< Count of PDU that raises the error */ -#endif -{ -#ifdef PJ_SEC_ASYNC - U32 nxtToDeCmp; -#endif /* PJ_SEC_ASYNC */ - -#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)) - PjUlCb *ulCb; /* ULM Control Block */ - U32 nxtRxCnt; - U32 nxtToSub; - PjRxEnt *rxEnt = NULLP; /* Ptr To Rx Entry */ -#endif /* (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)) */ - - TRC2(pjUlmHdlErrUpdates); - -#if (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)) - /* 1. Initialistions */ - ulCb = &pjRbCb->ulCb; - nxtRxCnt = ulCb->rxNext; - - /* 2. Decrement obd counter */ - PJ_DEC_OBD_COUNT(gCb, pjRbCb, errCnt); - - /* 3. For DRB AM , check if we can deliver anything */ - if((pjRbCb->rbType == PJ_DRB) && (pjRbCb->mode == PJ_DRB_AM)) - { - /* if any successive entries can be sent up , send it */ - for(nxtToSub = ulCb->rxDeliv; nxtToSub < nxtRxCnt; nxtToSub++) - { - if( (rxEnt = pjDbmGetRxEnt(gCb, &ulCb->recBuf, nxtToSub)) != NULLP) - { - /* As soon as we get an entry, we break */ - if(rxEnt->state == PJ_RDY_TO_SUBMIT) - { - pjUlmDeliverDrbAm(gCb, pjRbCb, rxEnt); - } - break; - } - - } - if(nxtToSub == nxtRxCnt) - { - /* This situation occurs, if this is the only pdu in the hashlist - * and obd fails for it. In this case, we have to trigger reestablishment - * procedures */ - if(pjRbCb->state != PJ_STATE_NORMAL) - { - if((ulCb->transCmp == TRUE) && - (ulCb->obdCnt == 0)) - { - PJ_ULM_DRBUM_REEST(gCb, pjRbCb); - } - } - } - } - /* 4. For SRB/DRB UM Update nxtSubCnt */ - else - { - if(errCnt == ulCb->nxtSubCnt) - { - for(nxtToSub = ulCb->nxtSubCnt + 1; nxtToSub < nxtRxCnt; nxtToSub++) - { - if( (rxEnt = pjDbmGetRxEnt(gCb, &ulCb->recBuf, nxtToSub)) != NULLP) - { - ulCb->nxtSubCnt = nxtToSub; - break; - } - } - if(nxtToSub == ulCb->nxtSubCnt ) - { - if(rxEnt->state == PJ_RDY_TO_SUBMIT) - { - PJ_ULM_DELIVER_PDU(gCb, pjRbCb, rxEnt); - } - } - else - { - /* Update nxtSubCnt to point to nxtRxCnt so that - * updations at pjUlmProcessRb can happen properly */ - ulCb->nxtSubCnt = nxtRxCnt; - - /* Check if its necessary to reestablish */ - if(pjRbCb->state != PJ_STATE_NORMAL) - { - if((ulCb->transCmp == TRUE) && - (ulCb->obdCnt == 0)) - { - PJ_ULM_DRBUM_REEST(gCb, pjRbCb); - } - } - } - } - } - -#endif /* (defined(PJ_SEC_ASYNC) || defined(PJ_CMP_ASYNC)) */ - - /* Notes : Update nxSubCnt first and then nxtSubDeCmp because we dont want a case - * where nxtSubDeCmp becomes greater that nxtSubCnt */ -#ifdef PJ_SEC_ASYNC - /* 5. Update nxtSubDeCmp */ - if((pjRbCb->rbType == PJ_DRB) && (errCnt == ulCb->nxtSubDeCmp)) - { - nxtToDeCmp = ulCb->nxtSubDeCmp + 1; - - for(; nxtToDeCmp < nxtRxCnt; nxtToDeCmp++) - { - rxEnt = pjDbmGetRxEnt(gCb, &ulCb->recBuf, nxtToDeCmp); - - if(rxEnt == NULLP) - { - continue; - } - - /* A pdu existing after reestablishment */ - if(rxEnt->state == PJ_RDY_TO_SUBMIT) - { - continue; - } - - ulCb->nxtSubDeCmp = nxtToDeCmp; - break; - } - - if(nxtToDeCmp == ulCb->nxtSubDeCmp) - { - if(rxEnt && (rxEnt->state == PJ_RDY_TO_DCOMP)) - { - pjUlmSubmitForDecmp(gCb, pjRbCb, rxEnt); - } - } - else - { - /* Update nxtSubDeCmp to point to nxtRxCnt so that - * updations at pjUlmProcessRb can happen properly */ - ulCb->nxtSubDeCmp = nxtRxCnt; - - } - } -#endif /* PJ_SEC_ASYNC */ - - RETVOID; -}/* end of pjUlmHdlErrUpdates */ - -/** - * - * @brief - * - * Function is called when - * 1. PjLiKwuReEstCmpInd received from RLC in case of Re-establishment and HO - * - * @b Description: - * - * The function performs the following - * 1. Checks the RB state, if it is not equal to PJ_STATE_NORMAL calls - * PJ_ULM_DRBUM_REEST or pjUlmReEstDrbAm - * - * @param[in] tPjCb PDCP control block. - * @param[in] tRbCb RB control block. - * - * @return Void - */ -#ifdef ANSI -PUBLIC Void pjUlmReEstCmpInd -( -PjCb *gCb, -PjUlRbCb *tRbCb /* !< RB control block */ -) -#else -PUBLIC Void pjUlmReEstCmpInd(tPjCb, tRbCb) -PjCb *gCb; -PjUlRbCb *tRbCb; /* !< PDCP Control Block */ -#endif -{ - - TRC3(pjUlmReEstCmpInd) - - /* No need to update state for SRB */ - if(tRbCb->ueCb->libInfo.state == PJ_STATE_NORMAL) - { - RETVOID; - } - - if(tRbCb->rbType == PJ_SRB) - { - RETVOID; - } - -#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) - /* If Async mode, set variable to true and return */ - tRbCb->ulCb.transCmp = TRUE; - if(tRbCb->ulCb.obdCnt == 0) - { -#endif /* (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) */ - /* In synchronous mode, we can proceed with reestablishment */ - if (tRbCb->mode == PJ_DRB_UM) - { - tRbCb->ulCb.rxNext = 0; - tRbCb->ulCb.rxDeliv = 0; -#ifdef LTE_L2_MEAS - tRbCb->ulCb.nxtSubSn = 0; -#endif - } - else - { - (Void)pjUlmReEstDrbAm(gCb, tRbCb); - } - - pjUtlUlHdlRbReEstComplete(gCb,tRbCb); - -#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) - } -#endif /* (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) */ - - RETVOID; -} - - -/** - * - * @brief - * - * Handler to forward the uplink data to the upper layer. - * - * @b Description: - * - * 1. This function is used to forward the uplink data to the upper layer - * during handover. @n - * 2. The out-of-sequene data SDUs are sent to the upper - * layer. @n - * - * @param[in] pjRbCb PDCP control block. - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 pjUlmStartDataFrwdPerRb -( -PjCb *gCb, -PjUlRbCb *pjRbCb -) -#else -PUBLIC S16 pjUlmStartDataFrwdPerRb(gCb, pjRbCb) -PjCb *gCb; -PjUlRbCb *pjRbCb; -#endif -{ - - U32 numSdu =0; - U16 count; - U32 numSduCnt =0,numSduTx = 0; - PjRxEnt *tmpRxEnt = NULLP; /* temporary Rx Entity */ - PjuDatFwdIndInfo *datFwdInd = NULLP; - U32 numEntries = 0; - U16 sn = 0; - PjPjuSapCb *pjuSap; - - TRC3(pjUlmStartDataFrwdPerRb) - - RLOG1(L_DEBUG, "pjUlmStartDataFrwdPerRb (%d )) ", pjRbCb->rbId); - - pjuSap = &(gCb->u.ulCb->pjuSap[PJ_DRB_SAP]); - if((pjRbCb->ulCb.rxNext == 0)) - { - if(SGetSBuf(pjuSap->pst.region,pjuSap->pst.pool,(Data **)&datFwdInd, - sizeof (PjuDatFwdIndInfo)) != ROK) - { - datFwdInd = NULLP; - } -#if (ERRCLASS & ERRCLS_ADD_RES) - if (datFwdInd == NULLP) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - datFwdInd->dir = PJ_DIR_UL; - datFwdInd->numSdus = 0; - datFwdInd->isLastDatFwdInd = TRUE; - - /* sending DatFwdInd even if numSdu is zero */ - pjUtlUlSndDatFwdInd(gCb,pjRbCb, datFwdInd); - - RETVALUE(ROK); - } - - /* Find the total number of RxEnts present */ - numEntries = pjRbCb->ulCb.recBuf.numEntries; - /* Find the total count of the txEnts present */ - numSduCnt = numSdu = numEntries; - - /* Traverse the datPktQ and send the UL Packets to DAM */ - cmLListFirst(&pjRbCb->ulCb.recBuf.datPktQ); - -while(numSduCnt >0) -{ - count = 0; - if(numSduCnt > PJ_FWD_MAX_SDU_CNT) - { - numSduTx = PJ_FWD_MAX_SDU_CNT; - numSduCnt = numSduCnt - PJ_FWD_MAX_SDU_CNT; - } - else - { - numSduTx = numSduCnt; - numSduCnt = 0; - } - - if(SGetSBuf(pjuSap->pst.region,pjuSap->pst.pool,(Data **)&datFwdInd, - sizeof (PjuDatFwdIndInfo)) != ROK) - { - datFwdInd = NULLP; - } -#if (ERRCLASS & ERRCLS_ADD_RES) - if (datFwdInd == NULLP) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - - if(SGetSBuf(pjuSap->pst.region,pjuSap->pst.pool, - (Data **)&datFwdInd->datFwdInfo, (sizeof (PjuDatFwdInfo)* numSduTx)) != ROK) - { - datFwdInd->datFwdInfo = NULLP; - } -#if (ERRCLASS & ERRCLS_ADD_RES) - if (datFwdInd->datFwdInfo == NULLP) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - - while (numSduTx>0) - { - /* Retrieve the Packet Info by typecasting to RxEnt */ - tmpRxEnt = (PjRxEnt *) cmLListNode(cmLListCrnt(&pjRbCb->ulCb.recBuf.datPktQ)); - sn = (U16)((tmpRxEnt->count) & (0x0fff)); /*KW_FIX*/ - - datFwdInd->datFwdInfo[count].sn = sn; - /* Copy the SDU Buffer as it is into datFwdInfo */ -#ifdef SS_RBUF - datFwdInd->datFwdInfo[count].sdu = tmpRxEnt->mBuf; -#else - SCpyMsgMsg(tmpRxEnt->mBuf, 0, 0, - &datFwdInd->datFwdInfo[count].sdu); -#endif - cmLListNext(&pjRbCb->ulCb.recBuf.datPktQ); - numSduTx--; - count++; - } - /* Fill the datFwdInd struct and send it to DAM */ - datFwdInd->dir = PJ_DIR_UL; - datFwdInd->numSdus = count; - datFwdInd->isLastDatFwdInd = FALSE; - /* Send the datFwdInd to DAM */ - pjUtlUlSndDatFwdInd(gCb,pjRbCb, datFwdInd); - -} - - if(SGetSBuf(pjuSap->pst.region,pjuSap->pst.pool,(Data **)&datFwdInd, - sizeof (PjuDatFwdIndInfo)) != ROK) - { - datFwdInd = NULLP; - } -#if (ERRCLASS & ERRCLS_ADD_RES) - if (datFwdInd == NULLP) - { - RLOG0(L_FATAL, "Memory Allocation failed."); - RETVALUE(RFAILED); - } -#endif /* ERRCLASS & ERRCLS_ADD_RES */ - datFwdInd->dir = PJ_DIR_UL; - datFwdInd->numSdus = 0; - datFwdInd->isLastDatFwdInd = TRUE; - - /* sending DatFwdInd even if numSdu is zero */ - pjUtlUlSndDatFwdInd(gCb,pjRbCb, datFwdInd); - - RETVALUE(ROK); -} - - -/** - * - * @brief - * - * Handler to process the forwarded data received from upper layer. - * - * @b Description: - * - * 1. This function is used to process the SDUs received from the upper - * layer as part of handover. @n - * 2. This function calls pjDlmProcessSdus function with the correct - * SN and HFN values. @n - * - * @param[in] gCb PDCP Instance control block. - * @param[in] pjUlRbCb Uplink Rb control block. - * @param[in] datFwdReq Data Forward Info. - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 pjUlmHndlDatFwdReq -( -PjCb *gCb, -PjUlRbCb *pjRbCb, -PjuDatFwdReqInfo *datFwdReq -) -#else -PUBLIC S16 pjUlmHndlDatFwdReq(gCb,pjRbCb,datFwdReq) -PjCb *gCb; -PjUlRbCb *pjRbCb; -PjuDatFwdReqInfo *datFwdReq; -#endif -{ - - PjRxEnt *rxEnt; /* Transmission Entity */ - PjSn sn; - int ret; - U32 numSdus=0; - U32 macI=0; - U32 rcvdHfn; /*Hfn for received PDU */ - U32 rcvdCount; /*Count for received Pdu */ - PjUlCb *ulCb; /* PTR to UL Control Block */ - U32 rxDelivHfn; /*Hfn of the rxDeliv */ - - TRC3(pjUlmHndlDatFwdReq) - - /* 1. Initialisations */ - ulCb = &pjRbCb->ulCb; - - - RLOG2(L_DEBUG, "pjDlmHndlDatFwdReq(pjRbCb (%d),datFwdReq(%d)) ", - pjRbCb->rbId, datFwdReq->numSdus); - - ret = ROK; - sn =datFwdReq->datFwdInfo[numSdus].sn; - gCb->pjGenSts.numPktsRcvd += datFwdReq->numSdus; - /* Process each of the SDUs with received SN and sduId */ - for ( numSdus = 0; numSdus < datFwdReq->numSdus; numSdus++ ) - { - /* - The variables nxtTxSn and COUNT are assumed to be - already updated in dlCb to continue with the - transmission ( in the target eNodeB ). - */ - - PJ_CALC_RCVD_HFN(sn,pjRbCb->snLen,ulCb->rxDeliv,rcvdHfn); - - /* 2.5G-NR Get the count value of the receiced PDCP data pdu from rcvdSn and rcvdHfn */ - PJ_GET_COUNT(rcvdCount, pjRbCb->snLen, sn, rcvdHfn); - - /* 2. Allocate memory for the rxEnt */ - PJ_ALLOC(gCb,rxEnt, sizeof(PjRxEnt)); -#if (ERRCLASS & ERRCLS_DEBUG) - if(rxEnt == NULLP) - { - RLOG0(L_FATAL, "Memory allocation failure"); - RETVALUE(RFAILED); - } -#endif /* (ERRCLASS & ERRCLS_DEBUG) */ - - - /* 4. Fill up the structures and insert into hashlist */ - rxEnt->count = rcvdCount; - rxEnt->state = PJ_RDY_TO_DCIPHER; - rxEnt->mBuf = datFwdReq->datFwdInfo[numSdus].sdu; - - - PJ_ULM_UPD_NXT2SUB(pjRbCb->ulCb, rxEnt->count); - ret = pjDbmInsRxEnt(gCb, &pjRbCb->ulCb.recBuf, rxEnt, TRUE); - if(ret == ROKDUP) - { - /* Duplicates are not to be inserted */ - /* marked to be freed up later */ - rxEnt->dupEntry = TRUE; - } - - PJ_GET_HFN(pjRbCb->ulCb.rxDeliv,pjRbCb->snLen,rxDelivHfn) - if((rcvdCount < ulCb->rxDeliv) && (rxDelivHfn != PJ_MAX_HFN(pjRbCb->snLen))) - { - rxEnt->discFlag = TRUE; - - } - if(rxEnt->dupEntry == TRUE) - { - /* duplicate entry */ - PJ_FREE_BUF(rxEnt->mBuf); - PJ_FREE(gCb,rxEnt, sizeof(PjRxEnt)); - } - else if(rxEnt->discFlag == TRUE) - { - /* duplicate entry */ - pjDbmDelRxEnt(gCb, &pjRbCb->ulCb.recBuf, rxEnt->count); - } - - - /*3.Update the RX_NEXT */ - PJ_ULM_UPDATE_RX_NEXT(pjRbCb,rxEnt); - - if(pjRbCb->rbType == PJ_DRB) - { - rxEnt->state = PJ_RDY_TO_DCOMP; - /*Adding MACI for 5G NR for DRB in case of intergrity protection is enabled*/ - if(pjRbCb->ueCb->secInfo.intProtEnbForDrb) - { - PJ_UNPK_MACI(rxEnt->mBuf, macI); - } - ret = pjUlmHdlDeCmp(gCb, pjRbCb, rxEnt); - } - else - { - rxEnt->state = PJ_RDY_TO_INTVER; - ret = pjUlmHdlIntVer(gCb, pjRbCb, rxEnt); - } - - } - RETVALUE(ROK); -} -/** - * - * @brief It processes the packets queued up in ULPktQ - * - * @Description - * This ulPktQ queues the forwarded message at targe enodeb - * during handover. - * - * @param[in] pjCb PDCP Instance control block. - * @param[in] pjUlRbCb Uplink Rb Control block - * - * @return Void - */ -#ifdef ANSI -PUBLIC Void pjUlmProcessUlPktQ -( -PjCb *gCb, -PjUlRbCb *pjRbCb /* !< PDCP Control Block */ -) -#else -PUBLIC Void pjUlmProcessUlPktQ(gCb, pjRbCb) -PjCb *gCb; -PjUlRbCb *pjRbCb; /* !< PDCP Control Block */ -#endif -{ - PjUlPkt *pkt; - CmLList *node; - - TRC2(pjUlmProcessUlPktQ); - - CM_LLIST_FIRST_NODE(&(pjRbCb->ulCb.ulPktLst), node); - while (node != NULLP) - { - pkt = (PjUlPkt *) node->node; - - cmLListDelFrm(&(pjRbCb->ulCb.ulPktLst), node); - pkt->lnk.node = NULLP; - pjUlmProcessRb(gCb,pjRbCb, pkt->sn, pkt->pdu, TRUE); - PJ_FREE(gCb,pkt, sizeof (PjUlPkt)); - - CM_LLIST_FIRST_NODE(&(pjRbCb->ulCb.ulPktLst), node); - } - - RETVOID; -}/* end of pjDlmProcessDlPktQ */ - -/** - * - * @brief - * - * @param[in] pjRbCb PDCP control block. - @param[in] PjRxEnt *rxEnt - * - * @return Void - */ -#ifdef ANSI -PRIVATE Void pjUlmEnqueueUlPkt -( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* !< PDCP Control Block */ -PjSn sn, /* !< SN value of PDU */ -Buffer *pdu /* !< PDU message buffer */ -) -#else -PRIVATE Void pjUlmEnqueueUlPkt(gCb,pjRbCb, sn, pdu) -PjCb *gCb; -PjUlRbCb *pjRbCb; /* !< PDCP Control Block */ -PjSn sn; /* !< SN value of PDU */ -Buffer *pdu; /* !< PDU message buffer */ -#endif -{ - PjUlPkt *pkt; - - TRC2(pjUlmEnqueueUlPkt) - - PJ_ALLOC(gCb,pkt, sizeof(PjUlPkt)); - if (pkt != NULLP) - { - pkt->sn = sn; - pkt->pdu = pdu; - pkt->type = PJ_DATA_NRM_PKT; - pkt->lnk.node = (PTR)pkt; - cmLListAdd2Tail (&pjRbCb->ulCb.ulPktLst, &pkt->lnk); - } - else - { - RLOG0(L_FATAL, "Memory allocation failure"); - PJ_FREE_BUF(pdu); - } - - RETVOID; -} - -/*@}*/ - -/********************************************************************30** - - End of file -**********************************************************************/ diff --git a/src/5gnrpdcp/pj_utl.c b/src/5gnrpdcp/pj_utl.c deleted file mode 100755 index 127ad4cf4..000000000 --- a/src/5gnrpdcp/pj_utl.c +++ /dev/null @@ -1,1977 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************** - - Name: LTE-PDCP Layer - - Type: C file - - Desc: Source code for PDCP Utility Module - - This file contains following functions: - - --PjLibObdCmpCfm - --PjLibObdIntProtCfm - --PjLibObdCipherCfm - --PjLibObdDecipherCfm - --PjLibObdIntVerCfm - --PjLibObdDecmpCfm - -- pjUtlCmpReq - -- pjUtlIntProtReq - - File: pj_utl.c - -**********************************************************************/ -static const char* RLOG_MODULE_NAME="PDCP"; -static int RLOG_MODULE_ID=1024; -static int RLOG_FILE_ID=231; -/** @file pj_utl.c -@brief PDCP Utility Module -*/ - -/* header (.h) include files */ -#include "envopt.h" /* environment options */ -#include "envdep.h" /* environment dependent */ -#include "envind.h" /* environment independent */ - -#include "gen.h" /* general */ -#include "ssi.h" /* system services */ -#include "cm5.h" /* common timer defines */ -#include "cm_tkns.h" /* common tokens defines */ -#include "cm_mblk.h" /* common memory allocation library defines */ -#include "cm_llist.h" /* common link list defines */ -#include "cm_hash.h" /* common hash list defines */ -#include "cm_lte.h" /* common LTE defines */ -#include "cpj.h" /* CPJ defines */ -#include "pju.h" /* PJU defines */ -#include "lpj.h" /* LPJ defines */ - -#include "pj_env.h" /* RLC environment options */ -#include "pj.h" /* RLC defines */ -#include "pj_ul.h" -#include "pj_dl.h" -#include "pj_err.h" /* Error defines */ - -/* extern (.x) include files */ -#include "gen.x" /* general */ -#include "ssi.x" /* system services */ - -#include "cm5.x" /* common timer library */ -#include "cm_tkns.x" /* common tokens */ -#include "cm_mblk.x" /* common memory allocation */ -#include "cm_llist.x" /* common link list */ -#include "cm_hash.x" /* common hash list */ -#include "cm_lte.x" /* common LTE includes */ -#include "cm_lib.x" /* common memory allocation library */ -#include "cpj.x" /* CPJ */ -#include "pju.x" /* PJU */ -#include "lpj.x" /* LPJ */ -#include "pj.x" -#include "pj_udx.h" /* LIB */ -#include "pj_udx.x" /* LIB */ -#include "pj_ul.x" -#include "pj_dl.x" - -#include "pj_lib.x" /* LIB */ - -#ifdef __cplusplus -EXTERN "C" { -#endif /* __cplusplus */ - -/** @addtogroup dldata */ -/*@{*/ - -#ifdef PJ_CMP_ASYNC -/******************************************************************** - * Input Handler from Offboarding unit * - *******************************************************************/ -/** - * - * @brief - * - * Asynchronous handler to received that Init Confirm for - * compression for the offboarding unit. - * - * @b Description: - * - * This function gets the context Id passed as the parameter and stores it - * in the RbCb. - * - * @param[in] pst Post structure - * @param[in] cmpCxt Context for ROHC - * @param[in] ctxId Context Id - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 PjLibObdCmpInitCfm -( -Pst *pst, /* post structure */ -PjCmpCxt cmpCxt, /* Context for ROHC */ -PTR ctxId /* Compression Context ID */ -) -#else -PUBLIC S16 PjLibObdCmpInitCfm(pst, cmpCxt, ctxId) -Pst *pst; /* post structure */ -PjCmpCxt cmpCxt; /* Context for ROHC */ -PTR ctxId; /* Compression Context ID */ -#endif -{ - PjCb *tPjCb; - - TRC3(PjLibObdCmpInitCfm); - - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) - { - RETVALUE (RFAILED); - } - - tPjCb = PJ_GET_PJCB(pst->dstInst); - - RLOG4(L_DEBUG, "PjLibObdCmpInitCfm(pst, cmpCxt(%d,%d,%d,%d)" - cmpCxt.ueId, cmpCxt.rbId, cmpCxt.rbType, cmpCxt.cfgTxId); - RLOG1(L_DEBUG ," ctxId(%ld))",ctxId); - - if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE)) - { - RETVALUE(RFAILED); - } - - if (tPjCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL) - { - PjUlUeCb *ueCb = NULLP; /* UeCb control block */ - PjUlRbCb *pjRbCb = NULLP; /* PDCP RB control block */ - - pjDbmFetchUlUeCb(tPjCb,cmpCxt.ueId, cmpCxt.cellId, &ueCb); - if(ueCb == NULLP) - { - RLOG_ARG1(L_ERROR, DBG_CELLID, cmpCxt.cellId,"UL UeId[%u] not found", - cmpCxt.ueId); - RETVALUE(RFAILED); - } - - pjDbmFetchPjUlRbCb(ueCb, cmpCxt.rbId, cmpCxt.rbType,&pjRbCb); - if(pjRbCb == NULLP) - { - RLOG_ARG2(L_ERROR, DBG_UEID,cmpCxt.ueId,"CellId[%u]: UL RbId[%d] not found", - cmpCxt.cellId, cmpCxt.rbId); - RETVALUE(RFAILED); - } - - pjRbCb->cmpCxtId = ctxId; - - /* Check if all confirms have been received */ - pjUtlUlHdlObdInitCfm(tPjCb,ueCb, cmpCxt.cfgTxId, PJ_CMP_INIT_CFM, cmpCxt.rbId); - } - else - { - PjDlUeCb *ueCb = NULLP; /* UeCb control block */ - PjDlRbCb *pjRbCb = NULLP; /* PDCP RB control block */ - - pjDbmFetchDlUeCb(tPjCb,cmpCxt.ueId, cmpCxt.cellId, &ueCb); - if(ueCb == NULLP) - { - RLOG_ARG1(L_ERROR, DBG_CELLID, cmpCxt.cellId,"DL UeId[%u] not found", - cmpCxt.ueId); - RETVALUE(RFAILED); - } - - pjDbmFetchPjDlRbCb(ueCb, cmpCxt.rbId, cmpCxt.rbType,&pjRbCb); - if(pjRbCb == NULLP) - { - RLOG_ARG2(L_ERROR, DBG_UEID,cmpCxt.ueId, "CellId[%u]: DL RbId[%d] not found", - cmpCxt.cellId, cmpCxt.rbId); - RETVALUE(RFAILED); - } - - pjRbCb->cmpCxtId = ctxId; - - /* Check if all confirms have been received */ - pjUtlDlHdlObdInitCfm(tPjCb,ueCb, cmpCxt.cfgTxId, PJ_CMP_INIT_CFM, cmpCxt.rbId); - } - - - RETVALUE(ROK); - -} /* end of PjLibObdCmpInitCfm */ -#endif /* PJ_SEC_ASYNC */ - -#ifdef PJ_SEC_ASYNC -/** - * - * @brief - * - * Asynchronous handler to received that Init Confirm for - * Integrity for the offboarding unit. - * - * @b Description: - * - * This function gets the context Id passed as the parameter and stores it - * in the UeCb. - * - * @param[in] pst Post structure - * @param[in] secCxt Context for Integrity protection/verification - * @param[in] ctxId Integrity Context Id - * - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 PjLibObdIntInitCfm -( -Pst *pst, /* post structure */ -PjSecCxt secCxt, /* Secutiry Context */ -PTR ctxId /* Integrity Context ID */ -) -#else -PUBLIC S16 PjLibObdIntInitCfm(pst, secCxt, ctxId) -Pst *pst; /* post structure */ -PjSecCxt secCxt; /* Secutriy Context */ -PTR ctxId; /* Integrity Context ID */ -#endif -{ - PjCb *tPjCb; - - TRC3(PjLibObdIntInitCfm) - - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) - { - RETVALUE (RFAILED); - } - - tPjCb = PJ_GET_PJCB(pst->dstInst); - - - RLOG4(L_DEBUG, "PjLibObdCmpInitCfm(pst, secCxt(%d,%d,%d), ctxId(%ld))", - secCxt.cellId, secCxt.ueId, secCxt.cfgTxId, ctxId); - - if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE)) - { - RETVALUE(RFAILED); - } - - if (tPjCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL) - { - PjUlUeCb *ueCb = NULLP; /* UeCb control block */ - - /* Fetch UeCb */ - pjDbmFetchUlUeCb(tPjCb, secCxt.ueId, secCxt.cellId, &ueCb); - if(ueCb == NULLP) - { - RLOG_ARG1(L_ERROR, DBG_CELLID, secCxt.cellId,"UL UeId[%u] not found", - secCxt.ueId); - RETVALUE(RFAILED); - } - - /* Update context Id */ - ueCb->secInfo.intCxtId = ctxId; - - pjUtlUlHdlObdInitCfm(tPjCb, ueCb, secCxt.cfgTxId, PJ_SEC_INIT_CFM, - PJ_LIB_INT_BIT_MASK); - } - else - { - PjDlUeCb *ueCb = NULLP; /* UeCb control block */ - - /* Fetch UeCb */ - pjDbmFetchDlUeCb(tPjCb, secCxt.ueId, secCxt.cellId, &ueCb); - if(ueCb == NULLP) - { - RLOG_ARG1(L_ERROR, DBG_CELLID, secCxt.cellId,"DL UeId[%u] not found", - secCxt.ueId); - RETVALUE(RFAILED); - } - - /* Update context Id */ - ueCb->secInfo.intCxtId = ctxId; - - pjUtlDlHdlObdInitCfm(tPjCb, ueCb, secCxt.cfgTxId, PJ_SEC_INIT_CFM, - PJ_LIB_INT_BIT_MASK); - } - - RETVALUE(ROK); - -} /* end of PjLibObdIntInitCfm */ - -/** - * - * @brief - * - * Asynchronous handler to received that Init Confirm for - * Ciphering Cp Key for the offboarding unit. - * - * @b Description: - * - * This function gets the context Id passed as the parameter and stores it - * in the UeCb. - * - * @param[in] pst Post structure - * @param[in] secCxt Context for Ciphering - * @param[in] ctxId Ciphering CP Context Id - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 PjLibObdCpInitCfm -( -Pst *pst, /* post structure */ -PjSecCxt secCxt, /* Secutiry Context */ -PTR ctxId /* Ciphering Context ID */ -) -#else -PUBLIC S16 PjLibObdCpInitCfm(pst, secCxt, ctxId) -Pst *pst; /* post structure */ -PjSecCxt secCxt; /* Secutriy Context */ -PTR ctxId; /* Ciphering Context ID */ -#endif -{ - PjCb *tPjCb; - - TRC3(PjLibObdCpInitCfm); - - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) - { - RETVALUE (RFAILED); - } - - tPjCb = PJ_GET_PJCB(pst->dstInst); - - - RLOG4(L_DEBUG, "PjLibObdCpInitCfm(pst, secCxt(%d,%d,%d), ctxId(%ld))", - secCxt.cellId, secCxt.ueId, secCxt.cfgTxId, ctxId); - - if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE)) - { - RETVALUE(RFAILED); - } - - if (tPjCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL) - { - PjUlUeCb *ueCb = NULLP; /* UeCb control block */ - - pjDbmFetchUlUeCb(tPjCb, secCxt.ueId, secCxt.cellId, &ueCb); - if(ueCb == NULLP) - { - RLOG_ARG1(L_ERROR, DBG_CELLID, secCxt.cellId,"UL UeId[%u] not found", - secCxt.ueId); - RETVALUE(RFAILED); - } - - ueCb->secInfo.cpCxtId = ctxId; - - /* Update bit mask and check if all confirms have been received */ - pjUtlUlHdlObdInitCfm(tPjCb, ueCb, secCxt.cfgTxId, PJ_SEC_INIT_CFM, - (U8)PJ_LIB_CP_CIP_BIT_MASK); - } - else - { - PjDlUeCb *ueCb = NULLP; /* UeCb control block */ - - pjDbmFetchDlUeCb(tPjCb, secCxt.ueId, secCxt.cellId, &ueCb); - if(ueCb == NULLP) - { - RLOG_ARG1(L_ERROR, DBG_CELLID, secCxt.cellId,"DL UeId[%u] not found", - secCxt.ueId); - RETVALUE(RFAILED); - } - - ueCb->secInfo.cpCxtId = ctxId; - - /* Update bit mask and check if all confirms have been received */ - pjUtlDlHdlObdInitCfm(tPjCb, ueCb, secCxt.cfgTxId, PJ_SEC_INIT_CFM, - (U8)PJ_LIB_CP_CIP_BIT_MASK); - } - - RETVALUE(ROK); -} /* end of PjLibObdCpInitCfm */ - -/** - * - * @brief - * - * Asynchronous handler to received that Init Confirm for - * Ciphering Up Key for the offboarding unit. - * - * @b Description: - * - * This function gets the context Id passed as the parameter and stores it - * in the UeCb. - * - * @param[in] pst Post structure - * @param[in] secCxt Context for Ciphering - * @param[in] ctxId Ciphering UP Context Id - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 PjLibObdUpInitCfm -( -Pst *pst, /* post structure */ -PjSecCxt secCxt, /* Secutiry Context */ -PTR ctxId /* Ciphering Context ID */ -) -#else -PUBLIC S16 PjLibObdUpInitCfm(pst, secCxt, ctxId) -Pst *pst; /* post structure */ -PjSecCxt secCxt; /* Secutriy Context */ -PTR ctxId; /* Ciphering Context ID */ -#endif -{ - PjCb *tPjCb; - - TRC3(PjLibObdUpInitCfm); - - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) - { - RETVALUE (RFAILED); - } - - tPjCb = PJ_GET_PJCB(pst->dstInst); - - RLOG4(L_DEBUG, "PjLibObdUpInitCfm(pst, secCxt(%d,%d,%d), ctxId(%ld))", - secCxt.cellId, secCxt.ueId, secCxt.cfgTxId, ctxId); - - if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE)) - { - RETVALUE(RFAILED); - } - - if (tPjCb->pjGenCfg.mode == LPJ_MODE_PDCP_UL) - { - PjUlUeCb *ueCb = NULLP; /* UeCb control block */ - - pjDbmFetchUlUeCb(tPjCb, secCxt.ueId, secCxt.cellId, &ueCb); - if(ueCb == NULLP) - { - RLOG_ARG1(L_ERROR, DBG_CELLID, secCxt.cellId,"UL UeId[%u] not found", - secCxt.ueId); - RETVALUE(RFAILED); - } - - ueCb->secInfo.upCxtId = ctxId; - - /* Update bit mask and check if all confirms have been received */ - pjUtlUlHdlObdInitCfm(tPjCb, ueCb, secCxt.cfgTxId, PJ_SEC_INIT_CFM, - (U8)PJ_LIB_UP_CIP_BIT_MASK); - } - else - { - PjDlUeCb *ueCb = NULLP; /* UeCb control block */ - - pjDbmFetchDlUeCb(tPjCb, secCxt.ueId, secCxt.cellId, &ueCb); - if(ueCb == NULLP) - { - RLOG_ARG1(L_ERROR, DBG_CELLID, secCxt.cellId,"DL UeId[%u] not found", - secCxt.ueId); - RETVALUE(RFAILED); - } - - ueCb->secInfo.upCxtId = ctxId; - - /* Update bit mask and check if all confirms have been received */ - pjUtlDlHdlObdInitCfm(tPjCb, ueCb, secCxt.cfgTxId, PJ_SEC_INIT_CFM, - (U8)PJ_LIB_UP_CIP_BIT_MASK); - } - - RETVALUE(ROK); - -} /* end of PjLibObdUpInitCfm */ - -#endif /* PJ_SEC_ASYNC */ - -#ifdef PJ_CMP_ASYNC -/** - * - * @brief - * - * Asynchronous handler to receive the compressed SDU from off-board - * entity. - * - * @b Description: - * - * This function receives an output from compression unit and - * sends the same for ciphering with relevant input paramenters. - * - * @param[in] pst Post structure - * @param[in] cmpCxtId Context Id for compression - * @param[in] libTrans Transaction Id - * @param[in] opSdu compressed SDU - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 PjLibObdCmpCfm -( -Pst *pst, /* post structure */ -PTR cmpCxtId, /* Context Id for compression */ -PjLibTrans libTrans, /* Transaction Id */ -Buffer *opSdu /* compressed SDU */ -) -#else -PUBLIC S16 PjLibObdCmpCfm(pst, cmpCxtId, libTrans, opSdu) -Pst *pst; /* post structure */ -PTR cmpCxtId; /* Context Id for compression */ -PjLibTrans libTrans; /* Transaction Id */ -Buffer *opSdu; /* compressed SDU */ -#endif -{ - PjCb *tPjCb; - PjDlRbCb *pjRbCb; - PjTxEnt *txEnt; - S16 ret; - U32 macI; /* MAC-I value to be padded to the PDU */ - /* pj005.201 ccpu00114955 corrected the RB ID calculation */ - CmLteRbId rbId; - - TRC3(PjLibObdCmpCfm) - - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) - { - RETVALUE (RFAILED); - } - - tPjCb = PJ_GET_PJCB(pst->dstInst); - -#ifdef ALIGN_64BIT - RLOG4(L_DEBUG, "PjLibObdCmpCfm(pst, cmpCxtId(%ld), libTrans(%d,%d,%d))", - cmpCxtId, libTrans.rbId, libTrans.rbType, libTrans.count); -#else - RLOG4(L_DEBUG, "PjLibObdCmpCfm(pst, cmpCxtId(%ld), libTrans(%d,%d,%ld))", - cmpCxtId, libTrans.rbId, libTrans.rbType, libTrans.count); -#endif - - /* If PDCP Layer is not configured and recieved message from Off-board, then - * clean the resources recieved and return RFAILED. - * Else proceed with processing.*/ - if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE)) - { - PJ_FREE_BUF(opSdu); - RETVALUE(RFAILED); - } - - /* pj005.201 ccpu00114955 corrected the RB ID calculation */ - rbId = libTrans.rbId + 1; - pjDbmFetchPjDlRbCb((PjDlUeCb*)libTrans.ueCb, rbId, libTrans.rbType,&pjRbCb); - if ( pjRbCb == NULLP ) - { - RLOG_ARG2(L_ERROR, DBG_UEID,libTrans.ueId, "CellId[%u]: DL RbId[%d] not found", - libTrans.cellId, rbId); - PJ_FREE_BUF(opSdu); - RETVALUE(RFAILED); - } - - if ( pjRbCb->state == PJ_STATE_REEST || pjRbCb->state == PJ_STATE_REEST_HO) - { - PJ_FREE_BUF(opSdu); - RETVALUE(ret); - } - - txEnt = pjDbmGetTxEnt(tPjCb,&(pjRbCb->dlCb.txBuf), libTrans.count); - if ( txEnt == NULLP ) - { - RLOG1(L_ERROR, "txEnt not found for Cnt [%lu]", libTrans.count); - PJ_FREE_BUF(opSdu); - RETVALUE(RFAILED); - } - if ( opSdu == NULLP ) - { - RLOG_ARG0(L_ERROR, DBG_RBID, rbId ,"Compression Failed , Count [%lu]", libTrans.count); - PJ_UPD_DL_VAR(tPjCb, pjRbCb, txEnt->count); - txEnt->sdu = NULLP; - if ( pjRbCb->dlCb.cfmReqd) - { - PJ_SND_CFM(tPjCb,pjRbCb, txEnt, PJU_COMP_FAILED); - } - else - { - pjDbmDelTxEnt( tPjCb,&(pjRbCb->dlCb.txBuf), txEnt->count); - } - tPjCb->pjGenSts.numCmpFails++; - RETVALUE(RFAILED); - } - - txEnt->pdu = opSdu; - if(pjRbCb->ueCb->secInfo.intProtEnbForDrb) - { - macI = 0; - PJ_PACK_MACI(txEnt->sdu, macI); - } - if ( pjRbCb->ueCb->secInfo.secAct ) - { - ret = pjDlmHdlCiph(tPjCb,pjRbCb, txEnt); - if ( ret != ROK ) - { - RLOG_ARG0(L_ERROR, DBG_RBID, rbId ,"CipherReq Failed , Count [%lu]", libTrans.count); - RETVALUE(RFAILED); - } -#ifdef PJ_SEC_ASYNC - RETVALUE(ret); -#endif - } - ret = pjDlmDeliverPdu(tPjCb,pjRbCb, txEnt); - - RETVALUE(ret); -} /* end of PjLibObdCmpCfm */ - -/** - * - * @brief - * - * Asynchronous handler to receive the decompressed SDU from off-board - * entity. - * - * @b Description: - * - * This function receives an output from decompression unit and - * sends the SDU to upper layer in sequence. - * - * @param[in] pst post structure - * @param[in] cmpCxtId Context Id for decompression - * @param[in] libTrans Transaction Id - * @param[in] opSdu decompressed SDU - * @param[in] fbPkt Feedback Pkt - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 PjLibObdDecmpCfm -( -Pst *pst, /* post structure */ -PTR cmpCxtId, /* Context Id for decompression */ -PjLibTrans libTrans, /* Transaction Id */ -Buffer *opSdu, /* decompressed SDU */ -Buffer *fbPkt /* Feedback pkt */ -) -#else -PUBLIC S16 PjLibObdDecmpCfm(pst, cmpCxtId, libTrans, opSdu, fbPkt) -Pst *pst; /* post structure */ -PTR cmpCxtId; /* Context Id for decompression */ -PjLibTrans libTrans; /* Transaction Id */ -Buffer *opSdu; /* decompressed SDU */ -Buffer *fbPkt; /* feedback Pkt */ -#endif -{ - PjCb *tPjCb; - PjUlRbCb *pjRbCb; - PjUlCb *ulCb; - PjRxEnt *rxEnt; - - /* pj005.201 ccpu00114955 corrected the RB ID calculation */ - CmLteRbId rbId; - - TRC2(PjLibObdDecmpCfm); - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) - { - RETVALUE (RFAILED); - } - - tPjCb = PJ_GET_PJCB(pst->dstInst); - -#ifdef ALIGN_64BIT - RLOG4(L_DEBUG, "PjLibObdDecmpCfm(pst, cmpCxtId(%ld), libTrans(%d,%d,%d))", - cmpCxtId, libTrans.rbId, libTrans.rbType, libTrans.count); -#else - RLOG4(L_DEBUG, "PjLibObdDecmpCfm(pst, cmpCxtId(%ld), libTrans(%d,%d,%ld))", - cmpCxtId, libTrans.rbId, libTrans.rbType, libTrans.count); -#endif - - /* If PDCP Layer is not configured and recieved message from Off-board, then - * clean the resources recieved and return RFAILED. - * Else proceed with processing.*/ - if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE)) - { - PJ_FREE_BUF(opSdu); - PJ_FREE_BUF(fbPkt); - RETVALUE(RFAILED); - } - - /* 1. Initialisations */ - /* pj005.201 ccpu00114955 corrected the RB ID calculation */ - rbId = libTrans.rbId + 1; - pjDbmFetchPjUlRbCb((PjUlUeCb*)libTrans.ueCb, rbId, libTrans.rbType,&pjRbCb); - if(pjRbCb == NULLP) - { - RLOG_ARG2(L_ERROR, DBG_UEID,libTrans.ueId, "CellId[%u]: UL RbId[%d] not found", - libTrans.cellId, rbId); - RETVALUE(RFAILED); - } - ulCb = &pjRbCb->ulCb; - - /* 2. Send the feedback packet */ - if(fbPkt != NULLP) - { - pjUtlUlSndUlRohcFdbk(tPjCb,pjRbCb,fbPkt); - } - - - /* 3. Get the rxEnt */ - rxEnt = pjDbmGetRxEnt(tPjCb,&ulCb->recBuf, libTrans.count ); - if((rxEnt == NULLP) || (rxEnt->state != PJ_SENT_TO_DCOMP)) - { - /* We have got a duplicate . - * It is NULLP if the original has been sent up, - * Or, the original is in another state - * (if both are in the same state, we accept the - * first output) */ - PJ_FREE_BUF(opSdu); - RETVALUE(ROK); - } - - /* 4. check decompression status */ - if(opSdu == NULLP) - { - RLOG_ARG0(L_ERROR,DBG_RBID,rbId,"opSdu is NULLP"); - PJ_FREE_BUF(opSdu); - PJ_SND_PJU_STA_IND(tPjCb,pjRbCb, rxEnt); - PJ_STS_INC_GEN_CNT(tPjCb,numDecmpFails); - pjUlmHdlErrUpdates(tPjCb,pjRbCb, rxEnt->count); - pjDbmDelRxEnt(tPjCb,&ulCb->recBuf, rxEnt->count); - RETVALUE(RFAILED); - } - - /* 5. check for discardable entries */ - if(rxEnt->discFlag == TRUE) - { - pjDbmDelRxEnt(tPjCb,&ulCb->recBuf, rxEnt->count); - PJ_FREE_BUF(opSdu); - RETVALUE(ROK); - } - - /* 6. Post decomp updations */ - rxEnt->state = PJ_RDY_TO_SUBMIT; - PJ_FREE_BUF(rxEnt->mBuf); - rxEnt->mBuf = opSdu; - - /* 7. Call the function to deliver the pdu*/ - PJ_DEC_OBD_COUNT(tPjCb,pjRbCb, rxEnt->count); - PJ_ULM_DELIVER_DRB(tPjCb,pjRbCb, rxEnt); - - RETVALUE(ROK); -} /* end of PjLibObdDecmpCfm */ - -#endif /* PJ_CMP_ASYNC */ - -#ifdef PJ_SEC_ASYNC -/** - * - * @brief - * - * Asynchronous handler to receive the MAC-I from off-board - * entity. - * - * @b Description: - * - * This function receives an output, MAC-I from Integration unit and - * sends the data for ciphering with relevant input paramenters. - * - * @param[in] pst Post structure - * @param[in] cxtId Context Id for Integrity protection - * @param[in] libTrans Transaction Id - * @param[in] macI Message authentication code - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 PjLibObdIntProtCfm -( -Pst *pst, /* post structure */ -PTR cxtId, /* Context Id for Integrity protection*/ -PjLibTrans libTrans, /* Transaction Id */ -U32 macI /* Message authentication code */ -) -#else -PUBLIC S16 PjLibObdIntProtCfm(pst, cxtId, libTrans, macI) -Pst *pst; /* post structure */ -PTR cxtId; /* Context Id for Integrity protection */ -PjLibTrans libTrans; /* Transaction Id */ -U32 macI; /* Message authentication code */ -#endif -{ - PjCb *tPjCb; - U8 hdr; - PjDlRbCb *pjRbCb; - Buffer *ciphSdu; - S16 ret; - U32 count; - PjTxEnt *txEnt; - /* pj005.201 ccpu00114955 corrected the RB ID calculation */ - CmLteRbId rbId; - - TRC3(PjLibObdIntProtCfm) - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) - { - RETVALUE (RFAILED); - } - - tPjCb = PJ_GET_PJCB(pst->dstInst); - -#ifdef ALIGN_64BIT - RLOG4(L_DEBUG, "PjLibObdIntProtCfm(pst, cxtId(%ld), libTrans(%d,%d,%d))", - cxtId, libTrans.rbId, libTrans.rbType, libTrans.count); -#else - RLOG4(L_DEBUG, "PjLibObdIntProtCfm(pst, cxtId(%ld), libTrans(%d,%d,%ld))", - cxtId, libTrans.rbId, libTrans.rbType, libTrans.count); -#endif - - - /* If PDCP Layer is not configured and recieved message from Off-board, then - * clean the resources recieved and return RFAILED. - * Else proceed with processing.*/ - if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE)) - { - RETVALUE(RFAILED); - } - - count = libTrans.count; - ret = ROK; - txEnt = NULLP; - ciphSdu = NULLP; - /* pj005.201 ccpu00114955 corrected the RB ID calculation */ - rbId = libTrans.rbId + 1; - pjDbmFetchPjDlRbCb((PjDlUeCb*)libTrans.ueCb, rbId, libTrans.rbType,&pjRbCb); - if ( pjRbCb == NULLP ) - { - RLOG_ARG2(L_ERROR, DBG_UEID,libTrans.ueId, "CellId[%u]: DL RbId[%d] not found", - libTrans.cellId, rbId); - RETVALUE(RFAILED); - } - if ( pjRbCb->state == PJ_STATE_REEST || pjRbCb->state == PJ_STATE_REEST_HO) - { - RETVALUE(ret); - } - - txEnt = pjDbmGetTxEnt(tPjCb,&(pjRbCb->dlCb.txBuf), count); - if ( txEnt == NULLP) - { - RLOG_ARG1(L_ERROR,DBG_RBID,rbId,"txEnt is NULLP, Count[%lu]", - count); - RETVALUE(RFAILED); - } - - - PJ_PACK_MACI(txEnt->sdu, macI); - - ret = SRemPreMsg(&hdr, txEnt->sdu); - if ( ret != ROK ) - { - RLOG_ARG1(L_ERROR,DBG_RBID,rbId,"SRemPreMsg failed , Count [%lu]", - count); - PJ_UPD_DL_VAR(tPjCb,pjRbCb, txEnt->count); - PJ_SND_CFM(tPjCb,pjRbCb, txEnt, PJ_REM_MSG_FAILED); - pjDbmDelTxEnt(tPjCb,&(pjRbCb->dlCb.txBuf), txEnt->count); - RETVALUE(RFAILED); - } - - txEnt->pdu = txEnt->sdu; - - if (pjRbCb->firstDlMsg == TRUE && pjRbCb->firstSn == txEnt->sn) - { - pjRbCb->firstDlMsg = FALSE; - txEnt->sdu = NULLP; - ret = pjDlmDeliverPdu(tPjCb,pjRbCb, txEnt); - } - else - { - ret = pjDlmHdlCiph(tPjCb,pjRbCb, txEnt); - if ( ret != ROK ) - { - RLOG_ARG1(L_ERROR,DBG_RBID,rbId,"CipherReq failed, Count[%lu]", - libTrans.count); - } - } - - RETVALUE(ret); - -} /* end of PjLibObdIntProtCfm */ - -/** - * - * @brief - * - * Asynchronous handler to receive the ciphered SDU from off-board - * entity. - * - * @b Description: - * - * This function receives an output from ciphering unit and - * sends the PDU to lower layer in sequence. - * - * @param[in] pst Post structure - * @param[in] cxtId Context Id for Ciphering - * @param[in] libTrans Transaction Id - * @param[in] opSdu ciphered SDU - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 PjLibObdCipherCfm -( -Pst *pst, /* post structure */ -PTR cxtId, /* Context Id for Ciphering */ -PjLibTrans libTrans, /* Transaction Id */ -Buffer *opSdu /* ciphered SDU */ -) -#else -PUBLIC S16 PjLibObdCipherCfm(pst, cxtId, libTrans, opSdu) -Pst *pst; /* post structure */ -PTR cxtId; /* Context Id for Integrity protection */ -PjLibTrans libTrans; /* Transaction Id */ -Buffer *opSdu; /* ciphered SDU */ -#endif -{ - PjCb *tPjCb; - PjDlRbCb *pjRbCb; - S16 ret; - PjTxEnt *txEnt; - U32 count; - /* pj005.201 ccpu00114955 corrected the RB ID calculation */ - CmLteRbId rbId; - - TRC3(PjLibObdCipherCfm) - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) - { - RETVALUE (RFAILED); - } - - tPjCb = PJ_GET_PJCB(pst->dstInst); - -#ifdef ALIGN_64BIT - RLOG4(L_DEBUG, "PjLibObdCipherCfm(pst, cxtId(%ld), libTrans(%d,%d,%d))", - cxtId, libTrans.rbId, libTrans.rbType, libTrans.count); -#else - RLOG4(L_DEBUG, "PjLibObdCipherCfm(pst, cxtId(%ld), libTrans(%d,%d,%ld))", - cxtId, libTrans.rbId, libTrans.rbType, libTrans.count); -#endif - - count = libTrans.count; - ret = ROK; - - /* If PDCP Layer is not configured and recieved message from Off-board, then - * clean the resources recieved and return RFAILED. - * Else proceed with processing.*/ - if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE)) - { - PJ_FREE_BUF(opSdu); - RETVALUE(RFAILED); - } - - /* pj005.201 ccpu00114955 corrected the RB ID calculation */ - rbId = libTrans.rbId + 1; - pjDbmFetchPjDlRbCb((PjDlUeCb*)libTrans.ueCb, rbId, libTrans.rbType,&pjRbCb); - if ( pjRbCb == NULLP ) - { - RLOG_ARG2(L_ERROR, DBG_UEID,libTrans.ueId, "CellId[%u]: DL RbId[%d] not found", - libTrans.cellId, rbId); - PJ_FREE_BUF(opSdu); - RETVALUE(RFAILED); - } - if ( pjRbCb->state == PJ_STATE_REEST || pjRbCb->state == PJ_STATE_REEST_HO) - { - PJ_FREE_BUF(opSdu); - RETVALUE(ret); - } - txEnt = pjDbmGetTxEnt(tPjCb,&(pjRbCb->dlCb.txBuf), count); - if ( txEnt == NULLP ) - { - /* Log an error and return */ - RLOG_ARG1(L_ERROR,DBG_RBID,rbId,"txEnt is NULLP, Count[%lu]", - count); - PJ_FREE_BUF(opSdu); - RETVALUE(RFAILED); - } - if ( opSdu == NULLP ) - { - RLOG_ARG0(L_ERROR,DBG_RBID,rbId,"opSdu is NULLP"); - PJ_UPD_DL_VAR(tPjCb,pjRbCb, txEnt->count); - if (!pjRbCb->rohc.hdrCmpUsed) - { - txEnt->sdu = NULLP; - } - if ( pjRbCb->dlCb.cfmReqd) - { - PJ_SND_CFM(tPjCb,pjRbCb, txEnt, PJU_CIPHER_FAILED); - } - else - { - pjDbmDelTxEnt(tPjCb, &(pjRbCb->dlCb.txBuf), txEnt->count); - } - tPjCb->pjGenSts.numCiphFails++; - RETVALUE(RFAILED); - } - - if ( pjRbCb->rohc.hdrCmpUsed ) - { - PJ_FREE_BUF(txEnt->pdu); - } - txEnt->pdu = opSdu; - ret = pjDlmDeliverPdu(tPjCb,pjRbCb, txEnt); - - RETVALUE(ret); - -} /* end of PjLibObdCipherCfm */ -/*@}*/ - -/** - * - * @brief - * - * Asynchronous handler to receive the deciphered SDU from off-board - * entity. - * - * @b Description: - * - * This function receives an output from deciphering unit and - * sends the same for Integrity verification or decompression - * based on the rbType. - * - * @param[in] pst Post structure - * @param[in] cxtId Context Id for Integrity protection - * @param[in] libTrans Transaction Id - * @param[in] opPdu Deciphered SDU - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 PjLibObdDecipherCfm -( -Pst *pst, /* post structure */ -PTR cxtId, /* Context Id for Integrity protection*/ -PjLibTrans libTrans, /* Transaction Id */ -Buffer *opPdu /* deciphered SDU */ -) -#else -PUBLIC S16 PjLibObdDecipherCfm(pst, cxtId, libTrans, opPdu) -Pst *pst; /* post structure */ -PTR cxtId; /* Context Id for Integrity protection*/ -PjLibTrans libTrans; /* Transaction Id */ -Buffer *opPdu; /* deciphered SDU */ -#endif -{ - PjCb *tPjCb; - PjUlCb *ulCb; - PjRxEnt *rxEnt; - PjUlRbCb *pjRbCb; - Buffer *outPdu = NULLP; - S16 ret = ROK; - /* pj005.201 ccpu00114955 corrected the RB ID calculation */ - CmLteRbId rbId; - - TRC2(PjLibObdDecipherCfm); - - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) - { - RETVALUE (RFAILED); - } - - tPjCb = PJ_GET_PJCB(pst->dstInst); - -#ifdef ALIGN_64BIT - RLOG4(L_DEBUG, "PjLibObdDecipherCfm(pst, cxtId(%ld), libTrans(%d,%d,%d))", - cxtId, libTrans.rbId, libTrans.rbType, libTrans.count); -#else - RLOG4(L_DEBUG, "PjLibObdDecipherCfm(pst, cxtId(%ld), libTrans(%d,%d,%ld))", - cxtId, libTrans.rbId, libTrans.rbType, libTrans.count); -#endif - - /* If PDCP Layer is not configured and recieved message from Off-board, then - * clean the resources recieved and return RFAILED. - * Else proceed with processing.*/ - if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE)) - { - PJ_FREE_BUF(opPdu); - RETVALUE(RFAILED); - } - - /* pj005.201 ccpu00114955 corrected the RB ID calculation */ - rbId = libTrans.rbId + 1; - /* 1. Initialisations */ - pjDbmFetchPjUlRbCb((PjUlUeCb*)libTrans.ueCb, rbId, libTrans.rbType,&pjRbCb); - if(pjRbCb == NULLP) - { - RLOG_ARG2(L_ERROR, DBG_UEID,libTrans.ueId, "CellId[%u]: UL RbId[%d] not found", - libTrans.cellId, rbId); - PJ_FREE_BUF(opPdu); - PJ_STS_INC_GEN_CNT(tPjCb,numDeciphFails); - RETVALUE(RFAILED); - } - - ulCb = &pjRbCb->ulCb; - - /* Validating rxEnt will be done later in code */ - rxEnt = pjDbmGetRxEnt(tPjCb,&ulCb->recBuf, libTrans.count); - - /* 2. check decipher status */ - if( opPdu == NULLP) - { - RLOG_ARG0(L_ERROR, DBG_RBID, rbId,"opPdu is NULL"); - PJ_FREE_BUF(opPdu); - PJ_STS_INC_GEN_CNT(tPjCb,numDecmpFails); - if ( rxEnt != NULLP ) - { - PJ_SND_PJU_STA_IND(tPjCb,pjRbCb, rxEnt); - pjUlmHdlErrUpdates(tPjCb,pjRbCb, rxEnt->count); - pjDbmDelRxEnt(tPjCb,&ulCb->recBuf, rxEnt->count); - } - RETVALUE(RFAILED); - } - - - /* 3. Check if it is SRB */ - if(pjRbCb->rbType == PJ_SRB) - { - /* 3.1 For reestablishment scenarios, discard */ - if(pjRbCb->state != PJ_STATE_NORMAL ) - { - /* Discard the mBuf */ - PJ_FREE_BUF(opPdu); - RETVALUE(ROK); - } - - /* 3.2 Validate the rxEnt */ - if(rxEnt == NULLP) - { - RLOG_ARG0(L_ERROR, DBG_RBID,rbId,"rxEnt not found"); - PJ_FREE_BUF(opPdu); - PJ_STS_INC_GEN_CNT(tPjCb,numDeciphFails); - RETVALUE(RFAILED); - } - - /* 3.3 Post deciphering updations */ - rxEnt->state = PJ_RDY_TO_INTVER; - PJ_FREE_BUF(rxEnt->mBuf); - rxEnt->mBuf = opPdu; - - /* 3.4 Send for IntVer. This will be ASYNC */ - ret = pjUlmHdlIntVer(tPjCb,pjRbCb, rxEnt); - - RETVALUE(ret); - } - else /* DRB */ - { - - /* 4. Special case, - * Duplicate entries, can be sent out of order */ - if((rxEnt == NULLP)|| - (rxEnt->discFlag == TRUE) || - (rxEnt->state != PJ_SENT_TO_DCIPHER)) - { - /* 4.1 is decompression applicable */ - if(pjRbCb->rohc.hdrCmpUsed == TRUE) - { - - /* 4.1.1 Calling decompression hook */ - if(pjUtlDeCmpReq(tPjCb,pjRbCb, libTrans.count, opPdu, &outPdu) != ROK) - { - RETVALUE(RFAILED); - } - -#ifdef PJ_CMP_ASYNC - PJ_FREE_BUF(opPdu); - RETVALUE(ROK); -#endif /* PJ_CMP_ASYNC */ - } - - /* 4.1.2 discard output and exit */ - PJ_FREE_BUF(opPdu); - PJ_FREE_BUF(outPdu); - if((rxEnt != NULLP) && - (rxEnt->discFlag == TRUE)) - { - pjDbmDelRxEnt(tPjCb,&ulCb->recBuf, rxEnt->count); - } - - RETVALUE(ROK); - } - - - /* 5. Post deciphering updations */ - rxEnt->state = PJ_RDY_TO_SUBMIT; - PJ_FREE_BUF(rxEnt->mBuf); - rxEnt->mBuf = opPdu; - - /* 6. Submit it for decompression */ - pjUlmSubmitForDecmp(tPjCb,pjRbCb, rxEnt); - - }/* if(pjRbCb->rbType == PJ_DRB) */ - - RETVALUE(ROK); - -} /* end of PjLibObdDecipherCfm */ - -/** - * - * @brief - * - * Asynchronous handler to receive the status for Integrity verification - * from off-board entity. - * - * @b Description: - * - * This function receives status, success or failure for Integrity - * verification and sends the data for deciphering with relevant input paramenters. - * - * @param[in] pst post structure - * @param[in] cxtId Context Id for Integrity protection - * @param[in] libTrans Transaction Id - * @param[in] status Integrity verification status - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ -#ifdef ANSI -PUBLIC S16 PjLibObdIntVerCfm -( -Pst *pst, /* post structure */ -PTR cxtId, /* Context Id for Integrity protection*/ -PjLibTrans libTrans, /* Transaction Id */ -Status status /* Integrity verification status */ -) -#else -PUBLIC S16 PjLibObdIntVerCfm(pst, cxtId, libTrans, status) -Pst *pst; /* post structure */ -PTR cxtId; /* Context Id for Integrity protection */ -PjLibTrans libTrans; /* Transaction Id */ -Status status; /* Integrity verification status */ -#endif -{ - PjCb *tPjCb; - PjUlRbCb *pjRbCb; - PjUlCb *ulCb; - PjRxEnt *rxEnt; - /* pj005.201 ccpu00114955 corrected the RB ID calculation */ - CmLteRbId rbId; - - TRC2(PjLibObdIntVerCfm) - - if (pst->dstInst >= PJ_MAX_PDCP_INSTANCES) - { - RETVALUE (RFAILED); - } - - tPjCb = PJ_GET_PJCB(pst->dstInst); - -#ifdef ALIGN_64BIT - RLOG4(L_DEBUG, "PjLibObdIntVerCfm(cxtId(%ld), libTrans(%d,%d,%d))", - cxtId, libTrans.rbId, libTrans.rbType, libTrans.count); -#else - RLOG4(L_DEBUG, "PjLibObdIntVerCfm(cxtId(%ld), libTrans(%d,%d,%ld))", - cxtId, libTrans.rbId, libTrans.rbType, libTrans.count, status); -#endif - RLOG1(L_DEBUG," status(%d)",status); - - /* If PDCP Layer is not configured and recieved message from Off-board, then - * clean the resources recieved and return RFAILED. - * Else proceed with processing.*/ - if (!(tPjCb->init.cfgDone & PJ_LMM_GENCFG_DONE)) - { - RETVALUE(RFAILED); - } - - /* Initialisations */ - /* pj005.201 ccpu00114955 corrected the RB ID calculation */ - rbId = libTrans.rbId + 1; - pjDbmFetchPjUlRbCb((PjUlUeCb*)libTrans.ueCb, rbId, libTrans.rbType,&pjRbCb); - if(pjRbCb == NULLP) - { - RLOG_ARG2(L_ERROR, DBG_UEID,libTrans.ueId, "CellId[%u]: UL RbId[%d] not found", - libTrans.cellId, rbId); - PJ_STS_INC_GEN_CNT(tPjCb, numIntgVrfFails); - RETVALUE(RFAILED); - } - ulCb = &pjRbCb->ulCb; - - /* For reestablishment cases, exit */ - if(pjRbCb->state != PJ_STATE_NORMAL) - { - RETVALUE(ROK); - } - - /* Get the rxEnt */ - rxEnt = pjDbmGetRxEnt(tPjCb,&ulCb->recBuf, libTrans.count); - if(rxEnt == NULLP) - { - RLOG_ARG1(L_ERROR, DBG_RBID, rbId, "rxEnt not found for Count [%lu]", libTrans.count); - PJ_STS_INC_GEN_CNT(tPjCb, numIntgVrfFails); - PJ_PERFORM_ERR_UPDATES(tPjCb, pjRbCb, libTrans.count); - RETVALUE(RFAILED); - } - - /* Validate status */ - if(status != ROK) - { - RLOG_ARG1(L_ERROR, DBG_RBID, rbId, "Integrity Verification Failed , Count [%lu]" - , rxEnt->count); - PJ_SND_PJU_STA_IND(tPjCb,pjRbCb, rxEnt); - PJ_STS_INC_GEN_CNT(tPjCb,numIntgVrfFails); - PJ_PERFORM_ERR_UPDATES(tPjCb,pjRbCb, rxEnt->count); -/* pjDbmDelRxEnt(&ulCb->recBuf, rxEnt->count); */ - RETVALUE(RFAILED); - } - - /* Check if next in line for delivery */ - rxEnt->state = PJ_RDY_TO_SUBMIT; - if(rxEnt->count != ulCb->nxtSubCnt) - { - RETVALUE(ROK); - } - - /* Send for delivery */ - pjUlmDeliverSrb(tPjCb,pjRbCb, rxEnt); - - RETVALUE(ROK); - -} /* end of PjLibObdIntVerCfm */ -#endif /* PJ_SEC_ASYNC */ - - -/** - * - * @brief - * - * Handler for redirecing compression request to either synchronous - * or asynchronous module. - * - * @b Description: - * - * This function sends compression request as either synchronous or - * asynchronous function calls with relevant input parameters. - * - * @param[in] pjRbCb PDCP RbCb - * @param[in] mBuf SDU to be compressed - * @param[in] opSdu Compressed SDU - * @param[in] count COUNT - transaction Id - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 pjUtlCmpReq -( -PjCb *gCb, -PjDlRbCb *pjRbCb, /* PDCP RbCb */ -Buffer *mBuf, /* SDU to be compressed */ -Buffer **opSdu, /* Compressed SDU */ -U32 count /* COUNT - transaction Id */ -) -#else -PUBLIC S16 pjUtlCmpReq(gCb,pjRbCb, mBuf, opSdu, count) -PjCb *gCb; -PjDlRbCb *pjRbCb; /* PDCP RbCb */ -Buffer *mBuf; /* SDU to be compressed */ -Buffer **opSdu; /* Compressed SDU */ -U32 count; /* COUNT - transaction Id */ -#endif -{ -#ifdef PJ_CMP_ASYNC - PjLibTrans libTrans; /* Transaction Id for compression */ -#endif - S16 ret; - - ret = ROK; - - TRC3(pjUtlCmpReq) - -#ifdef ALIGN_64BIT - PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), - (gCb->init.prntBuf, "pjUtlCmpReq(pjRbCb(%d,%d), count(%d))\n",\ - pjRbCb->rbId, pjRbCb->rbType, count)); -#else - PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), - (gCb->init.prntBuf, "pjUtlCmpReq(pjRbCb(%d,%d), count(%ld))\n",\ - pjRbCb->rbId, pjRbCb->rbType, count)); -#endif - - -#ifdef PJ_CMP_ASYNC - /* Assign transId and cxtId */ - libTrans.count = count; - /* pj005.201 ccpu00114955 corrected the RB ID calculation */ - libTrans.rbId = pjRbCb->rbId - 1; - libTrans.rbType = pjRbCb->rbType; - libTrans.ueCb = (PTR)pjRbCb->ueCb; - - /* Start the timer if it is not started already */ - if((pjChkTmr(gCb, (PTR)pjRbCb, PJ_EVT_DL_OBD_TMR)) == FALSE) - { - pjStartTmr(gCb, (PTR)pjRbCb, PJ_EVT_DL_OBD_TMR); - } - - /* Send to the library */ - ret = PjLibObdCmpReq(&(gCb->pjGenCfg.obdPst.cmpPst), pjRbCb->cmpCxtId, - libTrans, mBuf); -#else - ret = pjLibCmpReq(pjRbCb->cmpCxtId, mBuf, opSdu); -#endif - - RETVALUE(ret); - -} /* end of pjUtlCmpReq */ - - - -/** - * - * @brief - * - * Handler for redirecing decompression request to either synchronous - * or asynchronous module. - * - * @b Description: - * - * This function sends decompression protection request as either synchronous or - * asynchronous function calls with relevant input parameters. - * - * @param[in] pjRbCb PDCP RbCb - * @param[in] mBuf SDU to be compressed - * @param[in] opSdu Compressed SDU - * @param[in] count COUNT - transaction Id - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 pjUtlDeCmpReq -( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* PDCP RbCb */ -U32 count, /* COUNT - transaction Id */ -Buffer *mBuf, /* SDU to be compressed */ -Buffer **opSdu /* Compressed SDU */ -) -#else -PUBLIC S16 pjUtlDeCmpReq(pjRbCb, count, mBuf, opSdu) -PjCb *gCb; -PjUlRbCb *pjRbCb; /* PDCP RbCb */ -U32 count; /* COUNT - transaction Id */ -Buffer *mBuf; /* SDU to be compressed */ -Buffer **opSdu; /* Compressed SDU */ -#endif -{ - S16 ret = ROK; -#ifdef PJ_CMP_ASYNC - PjLibTrans libTrans; /* Transaction Id for compression */ -#else - Buffer *feedback = NULLP; -#endif /* PJ_CMP_ASYNC */ - - TRC3(pjUtlDeCmpReq) - -#ifdef ALIGN_64BIT - PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), - (gCb->init.prntBuf, "pjUtlDeCmpReq(pjRbCb(%d,%d), count(%d))\n",\ - pjRbCb->rbId, pjRbCb->rbType, count)); -#else - PJDBGP(gCb,(PJ_DBGMASK_UTL | PJ_DBGMASK_DETAIL), - (gCb->init.prntBuf, "pjUtlDeCmpReq(pjRbCb(%d,%d), count(%ld))\n",\ - pjRbCb->rbId, pjRbCb->rbType, count)); -#endif -#ifdef PJ_CMP_ASYNC - /* Assign transId and cxtId */ - libTrans.count = count; - /* pj005.201 ccpu00114955 corrected the RB ID calculation */ - libTrans.rbId = pjRbCb->rbId - 1; - libTrans.rbType = pjRbCb->rbType; - libTrans.ueCb = (PTR)pjRbCb->ueCb; - - /* Start the timer if it is not started already */ - if((pjChkTmr(gCb, (PTR)pjRbCb, PJ_EVT_UL_OBD_TMR)) == FALSE) - { - pjRbCb->ulCb.obdPdu = count; - pjStartTmr(gCb, (PTR)pjRbCb, PJ_EVT_UL_OBD_TMR); - } - - ret = PjLibObdDecmpReq(&(gCb->pjGenCfg.obdPst.cmpPst), - pjRbCb->cmpCxtId, libTrans, mBuf); -#else - ret = pjLibDecmpReq(pjRbCb->cmpCxtId, mBuf, &feedback, opSdu); - - if(feedback != NULLP) - { - pjUtlUlSndUlRohcFdbk(gCb,pjRbCb,feedback); - } -#endif - - RETVALUE(ret); - -} /* end of pjUtlDeCmpReq */ - - -/** - * - * @brief - * - * Handler for redirecing compression request to either synchronous - * or asynchronous module. - * - * @b Description: - * - * This function sends compression request as either synchronous or - * asynchronous function calls with relevant input parameters. - * - * @param[in] pjRbCb PDCP RbCb - * @param[in] feedback ROHC Feedback - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 pjUtlSndFeedback -( -PjCb *gCb, -PjUlRbCb *pjRbCb, /* PDCP RbCb */ -Buffer *feedback /* ROHC Feedback */ -) -#else -PUBLIC S16 pjUtlSndFeedback(pjRbCb, feedback) -PjCb *gCb; -PjUlRbCb *pjRbCb; /* PDCP RbCb */ -Buffer *feedback; /* Feedback */ -#endif -{ -#ifdef PJ_CMP_ASYNC - PjLibTrans libTrans; /* Transaction Id for compression */ -#endif /* PJ_SEC_ASYNC */ - - TRC3(pjUtlSndFeedback) - - RLOG2(L_DEBUG, "pjUtlCmpReq(pjRbCb(%d,%d))", - pjRbCb->rbId, pjRbCb->rbType); - -#ifdef PJ_CMP_ASYNC - /* Assign transId and cxtId */ - libTrans.count = pjRbCb->ulCb.rxDeliv - 1; - /* pj005.201 ccpu00114955 corrected the RB ID calculation */ - libTrans.rbId = pjRbCb->rbId - 1; - libTrans.rbType = pjRbCb->rbType; - libTrans.ueCb = (PTR)pjRbCb->ueCb; - - PjLibObdCmpFbReq(&(gCb->pjGenCfg.obdPst.cmpPst), pjRbCb->cmpCxtId, libTrans, - feedback); -#else - pjLibCmpFbReq(pjRbCb->cmpCxtId, feedback); -#endif - - RETVALUE(ROK); - -} /* end of pjUtlSndFeedback */ - -/** - * - * @brief - * - * Handler for closing the context with the compression unit (either - * synchronous or asynchronous) for RB within an UE. - * - * @b Description: - * - * This function closes an existing context with the compression unit per RB per - * UE, either using synchronous / asynchronous function calls with relevant input parameters. - * - * - * @param[in] cmpCxtId ROHC Context to be closed - * - * @return S16 - * -# ROK - * - */ -#ifdef ANSI -PUBLIC S16 pjUtlCmpClose -( -PjCb *gCb, -PTR cmpCxtId /* ROHC Context to be closed */ -) -#else -PUBLIC S16 pjUtlCmpClose(cmpCxtId) -PjCb *gCb; -PTR cmpCxtId; /* ROHC Context to be closed */ -#endif -{ - TRC3(pjUtlCmpClose) - - RLOG1(L_DEBUG, "pjUtlCmpClose(cmpCxtId(%ld))", cmpCxtId); - -#ifndef PJ_CMP_ASYNC - pjLibCmpCloseReq(cmpCxtId); -#else - PjLibObdCmpCloseReq(&gCb->pjGenCfg.obdPst.cmpPst, cmpCxtId); -#endif - - RETVALUE(ROK); - -} /* end of pjUtlCmpClose */ - - - -/* pj005.201 added support for L2 Measurement */ -#ifdef LTE_L2_MEAS_COMMENT - -/** - * - * @brief Handler for L2 Measurement timer expiry. - * - * - * @b Description - * This function is called when the l2 measurement timer expires. - * This function sends a consolidates the mesaurements taken during - * this time and sends the confirm . - * - * @param[in] measEvtCb Measurement Event Control Block. - * - * - * @return S16 - * -# ROK - */ - -#ifdef ANSI -PUBLIC S16 pjUtlHdlL2TmrExp -( -PjL2MeasEvtCb *measEvtCb -) -#else -PUBLIC S16 pjUtlHdlL2TmrExp(measEvtCb) -PjL2MeasEvtCb *measEvtCb; -#endif -{ - CmLList *node; - U32 idx; - PjL2MeasCb *measCb; - PjL2MeasCfmEvt measCfmEvt; - PjRbCb *pjRbCb; - PjTxEnt *txEnt = NULLP; - U8 qciIdx; - - TRC3(pjUtlHdlL2TmrExp) - - RLOG1,"pjUtlHdlL2TmrExp(transId(%ld))", measEvtCb->transId); - - measCb = &measEvtCb->measCb; - while((node = cmLListFirst(&measCb->rbList))) - { - node = cmLListDelFrm(&measCb->rbList, node); - pjRbCb = (PjRbCb *) node->node; - - /* Cleanup any pending buffers which were not acked */ - if(measCb->measType & LPJ_L2MEAS_DL_DELAY) - { - for(idx = pjRbCb->rbL2Cb.startCount; idx < pjRbCb->dlCb.count; idx++) - { - if((txEnt = pjDbmGetTxEnt( &(pjRbCb->dlCb.txBuf), idx)) == NULLP) - { - continue; - } - if(txEnt->state != PJ_PDU_SUBMITTED) - { - break; - } - pjDbmDelTxEnt( &(pjRbCb->dlCb.txBuf), idx); - } - pjRbCb->rbL2Cb.l2Sts[PJ_L2MEAS_DL_DELAY] = NULLP; - } - if(measCb->measType & PJ_L2MEAS_ACT_UE) - { - pjRbCb->rbL2Cb.l2Sts[PJ_L2MEAS_ACT_UE] = NULLP; - } - if(measCb->measType & PJ_L2MEAS_DL_DISC ) - { - pjRbCb->rbL2Cb.l2Sts[PJ_L2MEAS_DL_DISC] = NULLP; - } - if(measCb->measType & PJ_L2MEAS_UL_LOSS) - { - pjRbCb->rbL2Cb.l2Sts[PJ_L2MEAS_UL_LOSS] = NULLP; - } - }/* End of while loop */ - /* Initialize measCfmEvt */ - cmMemset((U8 *) &measCfmEvt, 0, sizeof(PjL2MeasCfmEvt)); - - measCfmEvt.transId = measEvtCb->transId; - measCfmEvt.numQciCfm = 0; - /* Fill the measCfmEvt structure */ - for(qciIdx = 0; qciIdx < measCb->numQci; qciIdx++) - { - pjCb.pjL2Cb.measOn[measCb->qci[qciIdx]] &= ~measCb->measType; - measCfmEvt.measType = measCb->measType; - measCfmEvt.measCfm[measCfmEvt.numQciCfm].qci = measCb->qci[qciIdx]; - measCfmEvt.status.status = LCM_PRIM_OK; - measCfmEvt.status.reason = LCM_REASON_NOT_APPL; - if((measCb->measType & LPJ_L2MEAS_DL_DELAY) && - (measCb->measData[measCb->qci[qciIdx]].dlDelay.numPkts > 0)) - { - /* Packed delay is in ms */ - measCfmEvt.measCfm[measCfmEvt.numQciCfm].dlDelay = - (measCb->measData[measCb->qci[qciIdx]].dlDelay.val / - measCb->measData[measCb->qci[qciIdx]].dlDelay.numPkts); - } - if((measCb->measType & LPJ_L2MEAS_DL_DISC) && - (measCb->measData[measCb->qci[qciIdx]].dlDisc.numPkts > 0)) - { - /* dlDisc = num of Pkts Discarded * 10^6 / total no of pkts. */ - measCfmEvt.measCfm[measCfmEvt.numQciCfm].dlDisc = - measCb->measData[measCb->qci[qciIdx]].dlDisc.val * (1000000) / - measCb->measData[measCb->qci[qciIdx]].dlDisc.numPkts; - } - if((measCb->measType & LPJ_L2MEAS_UL_LOSS) && - (measCb->measData[measCb->qci[qciIdx]].ulLoss.numPkts > 0)) - { - /* ul Loss = num of Pkts lost * 10^6 / total no of pkts. */ - measCfmEvt.measCfm[measCfmEvt.numQciCfm].ulLoss = - measCb->measData[measCb->qci[qciIdx]].ulLoss.val * (1000000) / - measCb->measData[measCb->qci[qciIdx]].ulLoss.numPkts; - } - measCfmEvt.numQciCfm++; - } - - pjCb.pjL2Cb.pjMeasEvtCb[measEvtCb->cbIdx] = NULLP; - PJ_FREE(measEvtCb, sizeof(PjL2MeasEvtCb)); - pjCb.pjL2Cb.pjNumMeas--; - - /* Send Measurement confirmation to layer manager */ - PjMiLpjL2MeasCfm(&pjCb.pjGenCfg.lmPst,&measCfmEvt); - - RETVALUE(ROK); -} /* pjUtlHdlL2TmrExp */ - -/** - * - * @brief Handler for Sending Negative confirm . - * - * - * @b Description - * This function is called when the l2 measurement cannot be started - * This function sends negative confirm for all the requests - * - * @param[in] measReqEvt Measurement Req Structure - * - * - * @return S16 - * -# ROK - */ - -#ifdef ANSI -PUBLIC S16 pjUtlSndL2MeasNCfm -( -PjL2MeasReqEvt *measReqEvt, -PjL2MeasCfmEvt *measCfmEvt -) -#else -PUBLIC S16 pjUtlSndL2MeasNCfm(measReqEvt, measCfmEvt) -PjL2MeasReqEvt *measReqEvt; -PjL2MeasCfmEvt *measCfmEvt; -#endif -{ - - TRC3(pjUtlSndL2MeasNCfm) - - RLOG1,"pjUtlSndL2MeasNCfm(transId(%ld))", measReqEvt->transId); - - PjMiLpjL2MeasCfm(&pjCb.pjGenCfg.lmPst, measCfmEvt); - - RETVALUE(ROK); -} /* pjUtlSndL2MeasNCfm */ -#endif - -#ifdef FLAT_BUFFER_OPT -/** - * - * @brief - * - * Handler to move the 'FlatBuffer' into 'Buffer' - * - * @b Description: - * - * - * @param[in] gCb Global PDCP control block. - * @param[in] FlatBuffer 'FlatBuffer' ptr to be converted. - * @param[in_out] Buffer Output mBuf. - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ - -#ifdef ANSI -PUBLIC S16 pjUtlConvFbToBuf -( -PjCb *gCb, -FlatBuffer *fb, -Buffer **mBuf -) -#else -PUBLIC S16 pjUtlConvFbToBuf(gCb, fb, mBuf) -PjCb *gCb; -FlatBuffer *fb; -Buffer **mBuf; -#endif -{ - S16 ret; - - TRC3(pjUtlConvFbToBuf); -#ifdef T2K_MEM_LEAK_DBG - ret = SAttachPtrToBufNew(gCb->init.region, - gCb->init.pool, - fb->ptr, - fb->len, - mBuf, - __FILE__, - __LINE__); -#else - ret = SAttachPtrToBuf(gCb->init.region, - gCb->init.pool, - fb->ptr, - fb->len, - mBuf); - -#endif - if(ret != ROK) - { - RLOG0(L_ERROR,"SAttachPtrToBuf failed !!!!!"); - } - - RETVALUE(ret); -} - - -/** - * - * @brief - * - * Handler to copy a 'FlatBuffer' to 'Buffer' - * - * @b Description: - * - * - * @param[in] gCb Global PDCP control block. - * @param[in] FlatBuffer 'FlatBuffer' to be converted. - * @param[in_out] Buffer Output mBuf. - * - * @return S16 - * -# ROK - * -# RFAILED - * - */ - -#ifdef ANSI -PUBLIC S16 pjUtlCopyFbToBuf -( -PjCb *gCb, -FlatBuffer *fb, -Buffer **mBuf -) -#else -PUBLIC S16 pjUtlCopyFbToBuf(gCb, fb, mBuf) -PjCb *gCb; -FlatBuffer *fb; -Buffer **mBuf; -#endif -{ - U8 *opPdu; - S16 ret; - - TRC3(pjUtlCopyFbToBuf); -#ifdef INTEL_WLS - SGetSBufWls(gCb->init.region, gCb->init.pool, - (Data **)&(opPdu), fb->len + 128); - - //cmMemcpy(opPdu + 2, fb->ptr, fb->len); - cmMemcpy(opPdu + 128, fb->ptr, fb->len); - - ret = SAttachWlsPtrToMBuf(gCb->init.region, - gCb->init.pool, - opPdu, - opPdu + 128, - fb->len, - fb->len + 128, - mBuf); -#else - - if((SGetStaticBuffer(gCb->init.region, - gCb->init.pool, - (Data - **)&(opPdu), - fb->len, - SS_SHARABLE_MEMORY) - != ROK)) - { - RLOG0(L_ERROR,"SGetStaticBuffer failed !!!!!"); - RETVALUE(RFAILED); - } - - cmMemcpy(opPdu, fb->ptr, fb->len); - /*RLOG1(L_ERROR,"Data forwarding: PDCP SN %d is converted to mBuf", - * txEnt->sn); */ -#ifdef T2K_MEM_LEAK_DBG - ret = SAttachPtrToBufNew(gCb->init.region, - gCb->init.pool, - opPdu, - fb->len, - mBuf, - __FILE__, - __LINE__); -#else - ret = SAttachPtrToBuf(gCb->init.region, - gCb->init.pool, - opPdu, - fb->len, - mBuf); -#endif - -#endif - if(ret != ROK) - { - RLOG0(L_ERROR,"SAttachPtrToBuf failed !!!!!"); - } - - RETVALUE(ret); -} -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ -/********************************************************************30** - End of file -**********************************************************************/ diff --git a/src/5gnrrlc/kw_tmm_ul.c b/src/5gnrrlc/kw_tmm_ul.c index 4011621f4..4e3b48738 100755 --- a/src/5gnrrlc/kw_tmm_ul.c +++ b/src/5gnrrlc/kw_tmm_ul.c @@ -124,8 +124,9 @@ U8 rrcUeCapabilityInfo[] = Buffer *pdu; Pst ulPst1 ={100,100,217,0,215,0,PRIOR0,0,81,1,1,0,0}; +#ifdef PJ Pst ulPst2 ={100,100,217,0,216,0,PRIOR0,0,68,0,1,0,0}; - +#endif TRC2(kwTmmRcvFrmLi) if(1 == rrcMsgType) @@ -150,29 +151,33 @@ U8 rrcUeCapabilityInfo[] = } else if(2 == rrcMsgType) { +#ifdef PJ CmLtePdcpId pdcpId; pdcpId.cellId = 1; pdcpId.ueId = crnti; pdcpId.rbId = 1; pdcpId.rbType = 0; - +#endif SGetMsg(DFLT_REGION, DFLT_POOL, (Buffer **) &pdu); SAddPstMsgMult(rrcConSetupComplete,34,pdu); RLOG1(L_INFO,"Profiling Framework: Sending RRC Connection Setup Complete to RRC for UE :%d\n",crnti); printf("Profiling Framework: Sending RRC Connection Setup Complete to RRC for UE :%d\n",crnti); +#ifdef PJ PjUiPjuDatInd(&ulPst2, 1, &pdcpId, pdu); +#endif } else if(3 == rrcMsgType) { +#ifdef PJ CmLtePdcpId pdcpId; pdcpId.cellId = 1; pdcpId.ueId = crnti; pdcpId.rbId = 1; pdcpId.rbType = 0; - +#endif SGetMsg(DFLT_REGION, DFLT_POOL, (Buffer **) &pdu); #ifndef CA_PAL_5GTF @@ -182,15 +187,20 @@ U8 rrcUeCapabilityInfo[] = #endif RLOG1(L_INFO,"Profiling Framework: Sending RRC UE Capability Info to RRC for UE :%d\n",crnti); printf("Profiling Framework: Sending RRC UE Capability Info to RRC for UE :%d\n",crnti); +#ifdef PJ PjUiPjuDatInd(&ulPst2, 1, &pdcpId, pdu); +#endif + } else if(4 == rrcMsgType) { +#ifdef PJ CmLtePdcpId pdcpId; pdcpId.cellId = 1; pdcpId.ueId = crnti; pdcpId.rbId = 1; pdcpId.rbType = 0; +#endif SGetMsg(DFLT_REGION, DFLT_POOL, (Buffer **) &pdu); @@ -198,15 +208,19 @@ U8 rrcUeCapabilityInfo[] = RLOG1(L_INFO,"Profiling Framework: Sending RRC Security Mode Complete to RRC for UE :%d\n",crnti); printf("Profiling Framework: Sending RRC Security Mode Complete to RRC for UE :%d\n",crnti); +#ifdef PJ PjUiPjuDatInd(&ulPst2, 1, &pdcpId, pdu); +#endif } else if(5 == rrcMsgType) { +#ifdef PJ CmLtePdcpId pdcpId; pdcpId.cellId = 1; pdcpId.ueId = crnti; pdcpId.rbId = 1; pdcpId.rbType = 0; +#endif SGetMsg(DFLT_REGION, DFLT_POOL, (Buffer **) &pdu); @@ -214,9 +228,11 @@ U8 rrcUeCapabilityInfo[] = RLOG1(L_INFO,"Profiling Framework: Sending RRC Reconfig Complete to RRC for UE :%d\n",crnti); printf("Profiling Framework: Sending RRC Reconfig Complete to RRC for UE :%d\n",crnti); +#ifdef PJ PjUiPjuDatInd(&ulPst2, 1, &pdcpId, pdu); #ifdef EG_GEN_LOAD_5GTF loadStart=1; +#endif #endif } RETVOID; diff --git a/src/cm/ckw.c b/src/cm/ckw.c new file mode 100755 index 000000000..7b92609e0 --- /dev/null +++ b/src/cm/ckw.c @@ -0,0 +1,1776 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/********************************************************************20** + + Name: CKW RRC Control Interface + + Type: C file + + Desc: This file Contains the packing and unpacking functions for + CKW Interface + + File: ckw.c + +*********************************************************************21*/ + +#include "envopt.h" /* environment options */ +#include "envdep.h" /* environment dependent */ +#include "envind.h" /* environment independent */ + +#include "gen.h" /* general */ +#include "ssi.h" /* system services */ +#include "cm5.h" /* common timer defines */ +#include "cm_tkns.h" /* common tokens defines */ +#include "cm_mblk.h" /* common memory allocation library defines */ +#include "cm_llist.h" /* common link list defines */ +#include "cm_hash.h" /* common hash list defines */ +#include "cm_lte.h" /* common LTE defines */ +#include "ckw.h" /* CKW defines */ + +/* extern (.x) include files */ +#include "gen.x" /* general */ +#include "ssi.x" /* system services */ + +#include "cm5.x" /* common timer library */ +#include "cm_tkns.x" /* common tokens */ +#include "cm_mblk.x" /* common memory allocation */ +#include "cm_llist.x" /* common link list */ +#include "cm_hash.x" /* common hash list */ +#include "cm_lte.x" /* common LTE includes */ +#include "cm_lib.x" /* common memory allocation library */ +#include "ckw.x" /* CKW */ + + +#ifdef __cplusplus +EXTERN "C" { +#endif /*for extern "C"*/ + +#ifdef LCCKW +/* +* +* Fun: cmPkCkwBndReq +* +* Desc: pack the primitive CkwBndReq +* +* Ret: ROK -ok +* +* Notes: None +* +* File: ckw.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmPkCkwBndReq +( +Pst *pst, +SuId suId, +SpId spId +) +#else +PUBLIC S16 cmPkCkwBndReq(pst, suId, spId) +Pst *pst; +SuId suId; +SpId spId; +#endif +{ + S16 ret1; + Buffer *mBuf; + mBuf = NULLP; + TRC3(cmPkCkwBndReq) + + if((ret1 = SGetMsg(pst->region, pst->pool, &mBuf)) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECKW001, (ErrVal)0, "SGetMsg() failed"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(ret1); + } + CMCHKPKLOG(SPkS16, spId, mBuf, ECKW002, pst); + CMCHKPKLOG(SPkS16, suId, mBuf, ECKW003, pst); + pst->event = (Event) CKW_EVT_BND_REQ; + + RETVALUE(SPstTsk(pst,mBuf)); +} /*end of function cmPkCkwBndReq*/ + +/* +* +* Fun: cmPkCkwUbndReq +* +* Desc: pack the primitive CkwUbndReq +* +* Ret: ROK -ok +* +* Notes: None +* +* File: ckw.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmPkCkwUbndReq +( +Pst *pst, +SpId spId, +Reason reason +) +#else +PUBLIC S16 cmPkCkwUbndReq(pst, spId, reason) +Pst *pst; +SpId spId; +Reason reason; +#endif +{ + S16 ret1; + Buffer *mBuf; + mBuf = NULLP; + TRC3(cmPkCkwUbndReq) + + if((ret1 = SGetMsg(pst->region, pst->pool, &mBuf)) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECKW004, (ErrVal)0, "SGetMsg() failed"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(ret1); + } + CMCHKPKLOG(SPkS16, reason, mBuf, ECKW005, pst); + CMCHKPKLOG(SPkS16, spId, mBuf, ECKW006, pst); + pst->event = (Event) CKW_EVT_UBND_REQ; + + RETVALUE(SPstTsk(pst,mBuf)); +} /*end of function cmPkCkwUbndReq*/ + +/* +* +* Fun: cmPkCkwBndCfm +* +* Desc: pack the primitive CkwBndCfm +* +* Ret: ROK -ok +* +* Notes: None +* +* File: ckw.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmPkCkwBndCfm +( +Pst *pst, +SuId suId, +U8 status +) +#else +PUBLIC S16 cmPkCkwBndCfm(pst, suId, status) +Pst *pst; +SuId suId; +U8 status; +#endif +{ + S16 ret1; + Buffer *mBuf; + mBuf = NULLP; + TRC3(cmPkCkwBndCfm) + + if((ret1 = SGetMsg(pst->region, pst->pool, &mBuf)) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECKW007, (ErrVal)0, "SGetMsg() failed"); + } + +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(ret1); + } + CMCHKPKLOG(SPkU8, status, mBuf, ECKW008, pst); + CMCHKPKLOG(SPkS16, suId, mBuf, ECKW009, pst); + pst->event = (Event) CKW_EVT_BND_CFM; + + RETVALUE(SPstTsk(pst,mBuf)); +} /*end of function cmPkCkwBndCfm*/ + + +/* +* +* Fun: cmPkCkwTmInfo +* +* Desc: pack the structure CkwTmInfo +* +* Ret: ROK -ok +* +* Notes: None +* +* File: ckw.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmPkCkwTmInfo +( +CkwTmInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCkwTmInfo(param, mBuf) +CkwTmInfo *param; +Buffer *mBuf; +#endif +{ + TRC3(cmPkCkwTmInfo) + + CMCHKPK(SPkU32, param->dl.buffSize, mBuf); + + RETVALUE(ROK); +} /* cmPkCkwTmInfo */ + + +/* +* +* Fun: cmPkCkwUmInfo +* +* Desc: pack the structure CkwUmInfo +* +* Ret: ROK -ok +* +* Notes: None +* +* File: ckw.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmPkCkwUmInfo +( +CkwEntCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCkwUmInfo(param, mBuf) +CkwEntCfgInfo *param; +Buffer *mBuf; +#endif +{ + TRC3(cmPkCkwUmInfo) + + switch(param->dir) + { + case CKW_CFG_DIR_DL: + { + CMCHKPK(SPkU8, param->m.umInfo.dl.snLen, mBuf); + break; + } + case CKW_CFG_DIR_UL: + { + CMCHKPK(SPkU8, param->m.umInfo.ul.reOrdTmr, mBuf); + CMCHKPK(SPkU8, param->m.umInfo.ul.snLen, mBuf); + break; + } + /* Patch ckw_c_001.main_3 */ + case CKW_CFG_DIR_BOTH: + { + CMCHKPK(SPkU8, param->m.umInfo.dl.snLen, mBuf); + CMCHKPK(SPkU8, param->m.umInfo.ul.reOrdTmr, mBuf); + CMCHKPK(SPkU8, param->m.umInfo.ul.snLen, mBuf); + break; + } + } + + RETVALUE(ROK); +} /* cmPkCkwUmInfo */ + + +/* +* +* Fun: cmPkCkwAmInfo +* +* Desc: pack the structure CkwAmInfo +* +* Ret: ROK -ok +* +* Notes: None +* +* File: ckw.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmPkCkwAmInfo +( +CkwAmInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCkwAmInfo(param, mBuf) +CkwAmInfo *param; +Buffer *mBuf; +#endif +{ + TRC3(cmPkCkwAmInfo) + + /* UP LINK */ + CMCHKPK(SPkU8, param->ul.reOrdTmr, mBuf); + CMCHKPK(SPkU16, param->ul.staProhTmr, mBuf); + CMCHKPK(SPkU8, param->ul.snLen, mBuf); + + /* DOWN LINK */ + CMCHKPK(SPkU8, param->dl.maxRetx, mBuf); + CMCHKPK(SPkS32, param->dl.pollByte, mBuf); + CMCHKPK(SPkS16, param->dl.pollPdu, mBuf); + CMCHKPK(SPkU16, param->dl.pollRetxTmr, mBuf); + CMCHKPK(SPkU8, param->dl.snLen, mBuf); + + RETVALUE(ROK); +} /* cmPkCkwAmInfo */ + + +/* +* +* Fun: cmPkCkwLInfo +* +* Desc: pack the structure CkwLChInfo +* +* Ret: ROK -ok +* +* Notes: None +* +* File: ckw.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmPkCkwLChInfo +( +CkwLChInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCkwLChInfo(param, mBuf) +CkwLChInfo *param; +Buffer *mBuf; +#endif +{ + TRC3(cmPkCkwLChInfo) + + CMCHKPK(SPkU8, param->type, mBuf); + CMCHKPK(SPkU8, param->lChId, mBuf); + + RETVALUE(ROK); +} /* cmPkCkwLChInfo */ + + +/* +* +* Fun: cmPkCkwEntCfgInfo +* +* Desc: pack the structure CkwEntCfgInfo +* +* Ret: ROK -ok +* +* Notes: None +* +* File: ckw.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmPkCkwEntCfgInfo +( +CkwEntCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCkwEntCfgInfo(param, mBuf) +CkwEntCfgInfo *param; +Buffer *mBuf; +#endif +{ + TRC3(cmPkCkwEntCfgInfo) + + switch(param->entMode) + { + case CM_LTE_MODE_TM: + { + CMCHKPK(cmPkCkwTmInfo, &(param->m.tmInfo), mBuf); + break; + } + case CM_LTE_MODE_UM: + { + CMCHKPK(cmPkCkwUmInfo, param, mBuf); + break; + } + case CM_LTE_MODE_AM: + { + CMCHKPK(cmPkCkwAmInfo, &(param->m.amInfo), mBuf); + break; + } + } + + /* Logical Channel Information */ + switch(param->entMode) + { + case CM_LTE_MODE_TM: + { + CMCHKPK(cmPkCkwLChInfo, &(param->lCh[0]), mBuf); + break; + } + /* ccpu00128195: Packing lCh[0] and lCh[1] for UM bearer as well */ + case CM_LTE_MODE_UM: + case CM_LTE_MODE_AM: + { + CMCHKPK(cmPkCkwLChInfo, &(param->lCh[1]), mBuf); + CMCHKPK(cmPkCkwLChInfo, &(param->lCh[0]), mBuf); + break; + } + } + +#ifdef TENB_MULT_CELL_SUPPRT + CMCHKPK(SPkS16, param->rguSapId, mBuf); +#endif + CMCHKPK(SPkS16, param->discardTmr, mBuf); + CMCHKPK(SPkU8, param->dir, mBuf); + CMCHKPK(cmPkLteRlcMode, param->entMode, mBuf); + CMCHKPK(SPkU8, param->qci, mBuf); + CMCHKPK(SPkU8, param->rbType, mBuf); + CMCHKPK(SPkU8, param->rbId, mBuf); + CMCHKPK(SPkU8, param->cfgType, mBuf); + + RETVALUE(ROK); +} /* cmPkCkwEntCfgInfo */ + + +/* +* +* Fun: cmPkCkwCfgInfo +* +* Desc: pack the structure CkwCfgInfo +* +* Ret: ROK -ok +* +* Notes: None +* +* File: ckw.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmPkCkwCfgInfo +( +CkwCfgInfo *param, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCkwCfgInfo(param, pst, mBuf) +CkwCfgInfo *param; +Pst *pst; +Buffer *mBuf; +#endif +{ + S16 idx; + + TRC3(cmPkCkwCfgInfo) + + for (idx = param->numEnt-1; idx >= 0; idx--) + { + CMCHKPK(cmPkCkwEntCfgInfo, &(param->entCfg[idx]), mBuf); + } + + CMCHKPK(SPkU8, param->numEnt, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + CMCHKPK(cmPkLteRnti, param->ueId, mBuf); + CMCHKPKLOG(SPkU32, param->transId, mBuf, ECKW010, pst); + + RETVALUE(ROK); +} /* cmPkCkwCfgInfo */ + + +/* +* +* Fun: cmPkCkwCfgReq +* +* Desc: pack the primitive KwUiCkwCfgReq +* +* Ret: ROK -ok +* +* Notes: None +* +* File: ckw.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmPkCkwCfgReq +( +Pst *pst, +SpId spId, +CkwCfgInfo *cfgInfo +) +#else +PUBLIC S16 cmPkCkwCfgReq(pst, spId, cfgInfo) +Pst *pst; +SpId spId; +CkwCfgInfo *cfgInfo; +#endif +{ + S16 ret1; + Buffer *mBuf; + mBuf = NULLP; + TRC3(cmPkCkwCfgReq) + + if((ret1 = SGetMsg(pst->region, pst->pool, &mBuf)) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECKW011, (ErrVal)0, "SGetMsg() failed"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(ret1); + } + + switch(pst->selector) + { +#ifdef LCCKW + case CKW_SEL_LC: + { + ret1 = cmPkCkwCfgInfo( (cfgInfo), pst, mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + SPutMsg(mBuf); + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECKW012, (ErrVal)ret1, "Packing failure"); + RETVALUE( ret1 ); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + if (SPutSBuf(pst->region, pst->pool, (Data *)cfgInfo, + sizeof(CkwCfgInfo)) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + break; + } +#endif /* LCCKW */ + } + + CMCHKPKLOG(SPkS16, spId, mBuf, ECKW013, pst); + pst->event = (Event) CKW_EVT_CFG_REQ; + + RETVALUE(SPstTsk(pst,mBuf)); +} /* cmPkCkwCfgReq */ + + +/* +* +* Fun: cmPkCkwEntCfgCfmInfo +* +* Desc: pack the structure CkwEntCfgInfo +* +* Ret: ROK -ok +* +* Notes: None +* +* File: ckw.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmPkCkwEntCfgCfmInfo +( +CkwEntCfgCfmInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCkwEntCfgCfmInfo(param, mBuf) +CkwEntCfgCfmInfo *param; +Buffer *mBuf; +#endif +{ + TRC3(cmPkCkwEntCfgCfmInfo) + + CMCHKPK(cmPkCmStatus, &(param->status), mBuf); + CMCHKPK(SPkU8, param->rbType, mBuf); + CMCHKPK(SPkU8, param->rbId, mBuf); + + RETVALUE(ROK); +} /* cmPkCkwEntCfgCfmInfo */ + + +/* +* +* Fun: cmPkCkwCfgCfmInfo +* +* Desc: pack the structure CkwCfgCfmInfo +* +* Ret: ROK -ok +* +* Notes: None +* +* File: ckw.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmPkCkwCfgCfmInfo +( +CkwCfgCfmInfo *param, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCkwCfgCfmInfo(param, pst, mBuf) +CkwCfgCfmInfo *param; +Pst *pst; +Buffer *mBuf; +#endif +{ + S16 idx; + + TRC3(cmPkCkwCfgCfmInfo) + + for (idx = param->numEnt-1; idx >= 0; idx--) + { + CMCHKPK(cmPkCkwEntCfgCfmInfo, &(param->entCfgCfm[(U8)idx]), mBuf); + } + + CMCHKPK(SPkU8, param->numEnt, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + CMCHKPK(cmPkLteRnti, param->ueId, mBuf); + CMCHKPKLOG(SPkU32, param->transId, mBuf, ECKW014, pst); + + RETVALUE(ROK); +} /* cmPkCkwCfgCfmInfo */ + + +/* +* +* Fun: cmPkCkwCfgCfm +* +* Desc: pack the primitive KwUiCkwCfgCfm +* +* Ret: ROK -ok +* +* Notes: None +* +* File: ckw.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmPkCkwCfgCfm +( +Pst *pst, +SuId suId, +CkwCfgCfmInfo *cfgCfmInfo +) +#else +PUBLIC S16 cmPkCkwCfgCfm(pst, suId, cfgCfmInfo) +Pst *pst; +SuId suId; +CkwCfgCfmInfo *cfgCfmInfo; +#endif +{ + S16 ret1; + Buffer *mBuf; + mBuf = NULLP; + TRC3(cmPkCkwCfgCfm) + + if((ret1 = SGetMsg(pst->region, pst->pool, &mBuf)) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECKW015, (ErrVal)0, "SGetMsg() failed"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(ret1); + } + + switch(pst->selector) + { +#ifdef LCCKW + case CKW_SEL_LC: + { + ret1 = cmPkCkwCfgCfmInfo( (cfgCfmInfo), pst, mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + SPutMsg(mBuf); + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECKW016, (ErrVal)ret1, "Packing failure"); + RETVALUE( ret1 ); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + if (SPutSBuf(pst->region, pst->pool, (Data *)cfgCfmInfo, + sizeof(CkwCfgCfmInfo)) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + break; + } +#endif /* LCCKW */ + } + + CMCHKPKLOG(SPkS16, suId, mBuf, ECKW017, pst); + pst->event = (Event) CKW_EVT_CFG_CFM; + + RETVALUE(SPstTsk(pst,mBuf)); +} /* cmPkCkwCfgCfm */ + +/* +* +* Fun: cmPkCkwUeInfo +* +* Desc: pack the primitive KwUiCkwUeInfo +* +* Ret: ROK -ok +* +* Notes: None +* +* File: ckw.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmPkCkwUeInfo +( +CkwUeInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCkwUeInfo(param, mBuf) +CkwUeInfo *param; +Buffer *mBuf; +#endif +{ + TRC2(cmPkCkwUeInfo) + + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + CMCHKPK(cmPkLteRnti, param->ueId, mBuf); + + RETVALUE(ROK); +} + +/* +* +* Fun: cmPkCkwUeIdChgReq +* +* Desc: pack the primitive KwUiCkwUeIdChgReq +* +* Ret: ROK -ok +* +* Notes: None +* +* File: ckw.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmPkCkwUeIdChgReq +( +Pst *pst, +SpId spId, +U32 transId, +CkwUeInfo *ueInfo, +CkwUeInfo *newUeInfo +) +#else +PUBLIC S16 cmPkCkwUeIdChgReq(pst, spId, transId, ueInfo, newUeInfo) +Pst *pst; +SpId spId; +U32 transId; +CkwUeInfo *ueInfo; +CkwUeInfo *newUeInfo; +#endif +{ + S16 ret1; + Buffer *mBuf = NULLP; + + TRC3(cmPkCkwUeIdChgReq) + + if((ret1 = SGetMsg(pst->region, pst->pool, &mBuf)) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECKW018, (ErrVal)0, "SGetMsg() failed"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + + RETVALUE(ret1); + } + + CMCHKPK(cmPkCkwUeInfo, newUeInfo, mBuf); + if (SPutSBuf(pst->region, pst->pool, (Data *)newUeInfo, + sizeof(CkwUeInfo)) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + CMCHKPK(cmPkCkwUeInfo, ueInfo, mBuf); + if (SPutSBuf(pst->region, pst->pool, (Data *)ueInfo, + sizeof(CkwUeInfo)) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + CMCHKPKLOG(SPkU32, transId, mBuf, ECKW019, pst); + CMCHKPKLOG(SPkS16, spId, mBuf, ECKW020, pst); + pst->event = (Event) CKW_EVT_UEIDCHG_REQ; + + RETVALUE(SPstTsk(pst, mBuf)); + +} /* cmPkCkwUeIdChgReq */ + +/* +* +* Fun: cmPkCkwUeIdChgCfm +* +* Desc: pack the primitive KwUiCkwUeIdChgCfm +* +* Ret: ROK -ok +* +* Notes: None +* +* File: ckw.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmPkCkwUeIdChgCfm +( +Pst *pst, +SuId suId, +U32 transId, +CkwUeInfo *ueInfo, +CmStatus status +) +#else +PUBLIC S16 cmPkCkwUeIdChgCfm(pst, suId, transId, ueInfo, status) +Pst *pst; +SuId suId; +U32 transId; +CkwUeInfo *ueInfo; +CmStatus status; +#endif +{ + S16 ret1; + Buffer *mBuf = NULLP; + + TRC3(cmPkCkwUeIdChgCfm) + + if((ret1 = SGetMsg(pst->region, pst->pool, &mBuf)) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECKW021, (ErrVal)0, "SGetMsg() failed"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + + RETVALUE(ret1); + } + + CMCHKPK(cmPkCmStatus, &status, mBuf); + CMCHKPK(cmPkCkwUeInfo, ueInfo, mBuf); + if (SPutSBuf(pst->region, pst->pool, (Data *)ueInfo, + sizeof(CkwUeInfo)) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + CMCHKPKLOG(SPkU32, transId, mBuf, ECKW022, pst); + CMCHKPKLOG(SPkS16, suId, mBuf, ECKW023, pst); + pst->event = (Event) CKW_EVT_UEIDCHG_CFM; + + RETVALUE(SPstTsk(pst, mBuf)); + +} /* cmPkCkwUeIdChgCfm */ + + +/****************************************************************************** + * UNPACK FUNCTIONS + *****************************************************************************/ + +/* +* +* Fun: cmUnpkCkwBndReq +* +* Desc: unpack the primitive CkwBndReq +* +* Ret: ROK -ok +* +* Notes: None +* +* File: ckw.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmUnpkCkwBndReq +( +CkwBndReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCkwBndReq(func, pst, mBuf) +CkwBndReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId = 0; + SpId spId = 0; + + TRC3(cmUnpkCkwBndReq) + + CMCHKUNPKLOG(SUnpkS16, &suId, mBuf, ECKW024, pst); + CMCHKUNPKLOG(SUnpkS16, &spId, mBuf, ECKW025, pst); + SPutMsg(mBuf); + + RETVALUE((*func)(pst, suId, spId)); +} /*end of function cmUnpkCkwBndReq*/ + +/* +* +* Fun: cmUnpkCkwUbndReq +* +* Desc: unpack the primitive CkwUbndReq +* +* Ret: ROK -ok +* +* Notes: None +* +* File: ckw.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmUnpkCkwUbndReq +( +CkwUbndReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCkwUbndReq(func, pst, mBuf) +CkwUbndReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SpId spId = 0; + Reason reason = 0; + + TRC3(cmUnpkCkwUbndReq) + + CMCHKUNPKLOG(SUnpkS16, &spId, mBuf, ECKW026, pst); + CMCHKUNPKLOG(SUnpkS16, &reason, mBuf, ECKW027, pst); + SPutMsg(mBuf); + RETVALUE((*func)(pst, spId, reason)); +} /*end of function cmUnpkCkwUbndReq*/ + +/* +* +* Fun: cmUnpkCkwBndCfm +* +* Desc: unpack the primitive CkwBndCfm +* +* Ret: ROK -ok +* +* Notes: None +* +* File: ckw.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmUnpkCkwBndCfm +( +CkwBndCfm func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCkwBndCfm(func, pst, mBuf) +CkwBndCfm func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId = 0; + U8 status = 0; + + TRC3(cmUnpkCkwBndCfm) + + CMCHKUNPKLOG(SUnpkS16, &suId, mBuf, ECKW028, pst); + CMCHKUNPKLOG(SUnpkU8, &status, mBuf, ECKW029, pst); + SPutMsg(mBuf); + + RETVALUE((*func)(pst, suId, status)); +} /*end of function cmUnpkCkwBndCfm*/ + + +/* +* +* Fun: cmUnpkCkwTmInfo +* +* Desc: pack the structure CkwTmInfo +* +* Ret: ROK -ok +* +* Notes: None +* +* File: ckw.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmUnpkCkwTmInfo +( +CkwTmInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCkwTmInfo(param, mBuf) +CkwTmInfo *param; +Buffer *mBuf; +#endif +{ + TRC3(cmUnpkCkwTmInfo) + + CMCHKUNPK(SUnpkU32, &(param->dl.buffSize), mBuf); + + RETVALUE(ROK); +} /* cmUnpkCkwTmInfo */ + + +/* +* +* Fun: cmUnpkCkwUmInfo +* +* Desc: pack the structure CkwUmInfo +* +* Ret: ROK -ok +* +* Notes: None +* +* File: ckw.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmUnpkCkwUmInfo +( +CkwEntCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCkwUmInfo(param, mBuf) +CkwEntCfgInfo *param; +Buffer *mBuf; +#endif +{ + TRC3(cmUnpkCkwUmInfo) + + switch(param->dir) + { + case CKW_CFG_DIR_DL: + { + CMCHKUNPK(SUnpkU8, &(param->m.umInfo.dl.snLen), mBuf); + break; + } + case CKW_CFG_DIR_UL: + { + CMCHKUNPK(SUnpkU8, &(param->m.umInfo.ul.snLen), mBuf); + CMCHKUNPK(SUnpkU8, &(param->m.umInfo.ul.reOrdTmr), mBuf); + break; + } + /* Patch ckw_c_001.main_3 */ + case CKW_CFG_DIR_BOTH: + { + CMCHKUNPK(SUnpkU8, &(param->m.umInfo.ul.snLen), mBuf); + CMCHKUNPK(SUnpkU8, &(param->m.umInfo.ul.reOrdTmr), mBuf); + CMCHKUNPK(SUnpkU8, &(param->m.umInfo.dl.snLen), mBuf); + break; + } + } + + RETVALUE(ROK); +} /* cmUnpkCkwUmInfo */ + + +/* +* +* Fun: cmUnpkCkwAmInfo +* +* Desc: pack the structure CkwAmInfo +* +* Ret: ROK -ok +* +* Notes: None +* +* File: ckw.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmUnpkCkwAmInfo +( +CkwAmInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCkwAmInfo(param, mBuf) +CkwAmInfo *param; +Buffer *mBuf; +#endif +{ + TRC3(cmUnpkCkwAmInfo) + + /* DOWN LINK */ + CMCHKUNPK(SUnpkU8, &(param->dl.snLen), mBuf); + CMCHKUNPK(SUnpkU16, &(param->dl.pollRetxTmr), mBuf); + CMCHKUNPK(SUnpkS16, &(param->dl.pollPdu), mBuf); + CMCHKUNPK(SUnpkS32, &(param->dl.pollByte), mBuf); + CMCHKUNPK(SUnpkU8, &(param->dl.maxRetx), mBuf); + + /* UP LINK */ + CMCHKUNPK(SUnpkU8, &(param->ul.snLen), mBuf); + CMCHKUNPK(SUnpkU16, &(param->ul.staProhTmr), mBuf); + CMCHKUNPK(SUnpkU8, &(param->ul.reOrdTmr), mBuf); + + RETVALUE(ROK); +} /* cmUnpkCkwAmInfo */ + + +/* +* +* Fun: cmUnpkCkwLChInfo +* +* Desc: pack the structure CkwLChInfo +* +* Ret: ROK -ok +* +* Notes: None +* +* File: ckw.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmUnpkCkwLChInfo +( +CkwLChInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCkwLChInfo(param, mBuf) +CkwLChInfo *param; +Buffer *mBuf; +#endif +{ + TRC3(cmUnpkCkwLChInfo) + + CMCHKUNPK(SUnpkU8, &(param->lChId), mBuf); + CMCHKUNPK(SUnpkU8, &(param->type), mBuf); + + RETVALUE(ROK); +} /* cmUnpkCkwLChInfo */ + + +/* +* +* Fun: cmUnpkCkwEntCfgCfmInfo +* +* Desc: unpack the structure CkwEntCfgInfo +* +* Ret: ROK -ok +* +* Notes: None +* +* File: ckw.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmUnpkCkwEntCfgCfmInfo +( +CkwEntCfgCfmInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCkwEntCfgCfmInfo(param, mBuf) +CkwEntCfgCfmInfo *param; +Buffer *mBuf; +#endif +{ + TRC3(cmUnpkCkwEntCfgCfmInfo) + + CMCHKUNPK(SUnpkU8, &(param->rbId), mBuf); + CMCHKUNPK(SUnpkU8, &(param->rbType), mBuf); + CMCHKUNPK(cmUnpkCmStatus, &(param->status), mBuf); + + RETVALUE(ROK); +} /* cmUnpkCkwEntCfgCfmInfo */ + + +/* +* +* Fun: cmUnpkCkwCfgCfmInfo +* +* Desc: pack the structure CkwCfgCfmInfo +* +* Ret: ROK -ok +* +* Notes: None +* +* File: ckw.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmUnpkCkwCfgCfmInfo +( +CkwCfgCfmInfo *param, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCkwCfgCfmInfo(param, pst, mBuf) +CkwCfgCfmInfo *param; +Pst *pst; +Buffer *mBuf; +#endif +{ + U8 idx; + + TRC3(cmUnpkCkwCfgCfmInfo) + + CMCHKUNPKLOG(SUnpkU32, &(param->transId), mBuf, ECKW030, pst); + CMCHKUNPK(cmUnpkLteRnti, &(param->ueId), mBuf); + CMCHKUNPK(cmUnpkLteCellId, &(param->cellId), mBuf); + CMCHKUNPK(SUnpkU8, &(param->numEnt), mBuf); + + for (idx = 0; idx < param->numEnt; idx++) + { + CMCHKUNPK(cmUnpkCkwEntCfgCfmInfo, &(param->entCfgCfm[idx]), mBuf); + } + + RETVALUE(ROK); +} /* cmUnpkCkwCfgCfmInfo */ + + +/* +* +* Fun: cmUnpkCkwEntCfgInfo +* +* Desc: pack the structure CkwEntCfgCfmInfo +* +* Ret: ROK -ok +* +* Notes: None +* +* File: ckw.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmUnpkCkwEntCfgInfo +( +CkwEntCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCkwEntCfgInfo(param, mBuf) +CkwEntCfgInfo *param; +Buffer *mBuf; +#endif +{ + TRC3(cmUnpkCkwEntCfgInfo) + + CMCHKUNPK(SUnpkU8, &(param->cfgType), mBuf); + CMCHKUNPK(SUnpkU8, &(param->rbId), mBuf); + CMCHKUNPK(SUnpkU8, &(param->rbType), mBuf); + CMCHKUNPK(SUnpkU8, &(param->qci), mBuf); + CMCHKUNPK(cmUnpkLteRlcMode, &(param->entMode), mBuf); + CMCHKUNPK(SUnpkU8, &(param->dir), mBuf); + CMCHKUNPK(SUnpkS16, &(param->discardTmr), mBuf); +#ifdef TENB_MULT_CELL_SUPPRT + CMCHKUNPK(SUnpkS16, &(param->rguSapId), mBuf); +#endif + + /* Logical Channel Information */ + switch(param->entMode) + { + case CM_LTE_MODE_TM: + { + CMCHKUNPK(cmUnpkCkwLChInfo, &(param->lCh[0]), mBuf); + break; + } + /* ccpu00128195: Unpacking lCh[0] and lCh[1] for UM bearer as well */ + case CM_LTE_MODE_UM: + case CM_LTE_MODE_AM: + { + CMCHKUNPK(cmUnpkCkwLChInfo, &(param->lCh[0]), mBuf); + CMCHKUNPK(cmUnpkCkwLChInfo, &(param->lCh[1]), mBuf); + break; + } + } + + /* TM/UM/AM Info */ + switch(param->entMode) + { + case CM_LTE_MODE_TM: + { + CMCHKUNPK(cmUnpkCkwTmInfo, &(param->m.tmInfo), mBuf); + break; + } + case CM_LTE_MODE_UM: + { + CMCHKUNPK(cmUnpkCkwUmInfo, param, mBuf); + break; + } + case CM_LTE_MODE_AM: + { + CMCHKUNPK(cmUnpkCkwAmInfo, &(param->m.amInfo), mBuf); + break; + } + } + + RETVALUE(ROK); +} /* cmUnpkCkwEntCfgInfo */ + + +/* +* +* Fun: cmUnpkCkwCfgInfo +* +* Desc: unpack the structure CkwCfgInfo +* +* Ret: ROK -ok +* +* Notes: None +* +* File: ckw.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmUnpkCkwCfgInfo +( +CkwCfgInfo *param, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCkwCfgInfo(param, pst, mBuf) +CkwCfgInfo *param; +Pst *pst; +Buffer *mBuf; +#endif +{ + U8 idx; + + TRC3(cmUnpkCkwCfgInfo) + + CMCHKUNPKLOG(SUnpkU32, &(param->transId), mBuf, ECKW031, pst); + CMCHKUNPK(cmUnpkLteRnti, &(param->ueId), mBuf); + CMCHKUNPK(cmUnpkLteCellId, &(param->cellId), mBuf); + CMCHKUNPK(SUnpkU8, &(param->numEnt), mBuf); + + for (idx = 0; idx < param->numEnt; idx++) + { + CMCHKUNPKLOG(cmUnpkCkwEntCfgInfo,&(param->entCfg[idx]), mBuf, ECKW032, pst); + } + + RETVALUE(ROK); +} /* cmUnpkCkwCfgInfo */ + + +/* +* +* Fun: cmUnpkCkwCfgReq +* +* Desc: unpack the primitive KwUiCkwCfgReq +* +* Ret: ROK -ok +* +* Notes: None +* +* File: ckw.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmUnpkCkwCfgReq +( +CkwCfgReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCkwCfgReq(func, pst, mBuf) +CkwCfgReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + S16 ret1; + SpId spId = 0; + CkwCfgInfo *cfgInfo = NULLP; + + TRC3(cmUnpkCkwCfgReq) + + if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&cfgInfo,\ + sizeof(CkwCfgInfo))) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + /*MBUF_FIXX*/ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECKW033, (ErrVal)0, "SGetMsg() failed"); + +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(ret1); + } + + cmMemset((U8 *)cfgInfo, 0, sizeof(CkwCfgInfo)); + + CMCHKUNPK(SUnpkS16, &(spId), mBuf); + switch(pst->selector) + { +#ifdef LCCKW + case CKW_SEL_LC: + { + ret1 = cmUnpkCkwCfgInfo( (cfgInfo), pst, mBuf); +#if(ERRCLASS & ERRCLS_DEBUG) + if(ret1 != ROK) + { + SPutMsg(mBuf); + SLogError(pst->dstEnt, pst->dstInst, pst->dstProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG, + (ErrVal)ECKW034, (ErrVal)ret1, "Unpacking failure"); + RETVALUE( ret1 ); + } +#endif /* ERRCLASS & ERRCLS_DEBUG */ + break; + } +#endif /* LCCKW */ + } + SPutMsg(mBuf); + + RETVALUE((*func)(pst, spId, cfgInfo)); +} /* cmUnpkCkwCfgReq */ + + +/* +* +* Fun: cmUnpkCkwCfgCfm +* +* Desc: unpack the primitive KwUiCkwCfgCfm +* +* Ret: ROK -ok +* +* Notes: None +* +* File: ckw.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmUnpkCkwCfgCfm +( +CkwCfgCfm func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCkwCfgCfm(func, pst, mBuf) +CkwCfgCfm func; +Pst *pst; +Buffer *mBuf; +#endif +{ + S16 ret1; + SuId suId = 0; + CkwCfgCfmInfo *cfgCfmInfo = NULLP; + + TRC3(cmUnpkCkwCfgCfm) + + if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&cfgCfmInfo,\ + sizeof(CkwCfgCfmInfo))) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECKW035, (ErrVal)0, "SGetMsg() failed"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(ret1); + } + + cmMemset((U8 *)cfgCfmInfo, 0, sizeof(CkwCfgCfmInfo)); + + CMCHKUNPK(SUnpkS16, &suId, mBuf); + + switch(pst->selector) + { +#ifdef LCCKW + case CKW_SEL_LC: + { + ret1 = cmUnpkCkwCfgCfmInfo( (cfgCfmInfo), pst, mBuf); +#if(ERRCLASS & ERRCLS_DEBUG) + if(ret1 != ROK) + { + SPutMsg(mBuf); + SLogError(pst->dstEnt, pst->dstInst, pst->dstProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG, + (ErrVal)ECKW036, (ErrVal)ret1, "Unpacking failure"); + RETVALUE( ret1 ); + } +#endif /* ERRCLASS & ERRCLS_DEBUG */ + break; + } +#endif /* LCCKW */ + } + SPutMsg(mBuf); + + RETVALUE((*func)(pst, suId, cfgCfmInfo)); +} /* cmUnpkCkwCfgCfm */ + +/* +* +* Fun: cmUnpkCkwUeInfo +* +* Desc: Unpack the primitive KwUiCkwUeInfo +* +* Ret: ROK -ok +* +* Notes: None +* +* File: ckw.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmUnpkCkwUeInfo +( +CkwUeInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCkwUeInfo(param, mBuf) +CkwUeInfo *param; +Buffer *mBuf; +#endif +{ + TRC2(cmUnpkCkwUeInfo) + + CMCHKUNPK(cmUnpkLteRnti, &(param->ueId), mBuf); + CMCHKUNPK(cmUnpkLteCellId, &(param->cellId), mBuf); + + RETVALUE(ROK); +} + +/* +* +* Fun: cmUnpkCkwUeIdChgReq +* +* Desc: unpack the primitive KwUiCkwUeIdChgReq +* +* Ret: ROK -ok +* +* Notes: None +* +* File: ckw.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmUnpkCkwUeIdChgReq +( +CkwUeIdChgReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCkwUeIdChgReq(func, pst, mBuf) +CkwUeIdChgReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + S16 ret1; + SpId spId = 0; + U32 transId = 0; + CkwUeInfo *ueInfo = NULLP; + CkwUeInfo *newUeInfo = NULLP; + + TRC3(cmUnpkCkwUeIdChgReq) + + + CMCHKUNPK(SUnpkS16, &(spId), mBuf); + CMCHKUNPKLOG(SUnpkU32, &transId, mBuf, ECKW037, pst); + + if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&ueInfo,\ + sizeof(CkwUeInfo))) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + /*MBUF_FIXX*/ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECKW038, (ErrVal)0, "SGetMsg() failed"); + +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(ret1); + } + + cmMemset((U8 *)ueInfo, 0, sizeof(CkwUeInfo)); + + ret1 = cmUnpkCkwUeInfo((ueInfo), mBuf); +#if(ERRCLASS & ERRCLS_DEBUG) + if(ret1 != ROK) + { + SPutMsg(mBuf); + SLogError(pst->dstEnt, pst->dstInst, pst->dstProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG, + (ErrVal)ECKW039, (ErrVal)ret1, "Unpacking failure"); + RETVALUE( ret1 ); + } +#endif /* ERRCLASS & ERRCLS_DEBUG */ + + if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&newUeInfo,\ + sizeof(CkwUeInfo))) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + /*MBUF_FIXX*/ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECKW040, (ErrVal)0, "SGetMsg() failed"); + +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(ret1); + } + + cmMemset((U8 *)newUeInfo, 0, sizeof(CkwUeInfo)); + + ret1 = cmUnpkCkwUeInfo((newUeInfo), mBuf); +#if(ERRCLASS & ERRCLS_DEBUG) + if(ret1 != ROK) + { + SPutMsg(mBuf); + SLogError(pst->dstEnt, pst->dstInst, pst->dstProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG, + (ErrVal)ECKW041, (ErrVal)ret1, "Unpacking failure"); + RETVALUE( ret1 ); + } +#endif /* ERRCLASS & ERRCLS_DEBUG */ + + SPutMsg(mBuf); + + RETVALUE((*func)(pst, spId, transId, ueInfo, newUeInfo)); + +} /* cmUnpkCkwUeIdChgReq */ + +/* +* +* Fun: cmUnpkCkwUeIdChgCfm +* +* Desc: unpack the primitive KwUiCkwUeIdChgCfm +* +* Ret: ROK -ok +* +* Notes: None +* +* File: ckw.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmUnpkCkwUeIdChgCfm +( +CkwUeIdChgCfm func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCkwUeIdChgCfm(func, pst, mBuf) +CkwUeIdChgCfm func; +Pst *pst; +Buffer *mBuf; +#endif +{ + S16 ret1; + SuId suId = 0; + U32 transId = 0; + CkwUeInfo *ueInfo = NULLP; + CmStatus status; + + TRC3(cmUnpkCkwUeIdChgCfm) + + cmMemset((U8 *)&status, (U8)0, (PTR)sizeof(CmStatus)); + + CMCHKUNPK(SUnpkS16, &suId, mBuf); + CMCHKUNPKLOG(SUnpkU32, &transId, mBuf, ECKW042, pst); + + if((ret1 = SGetSBuf(pst->region, pst->pool, (Data **)&ueInfo,\ + sizeof(CkwUeInfo))) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECKW043, (ErrVal)0, "SGetMsg() failed"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(ret1); + } + + cmMemset((U8 *)ueInfo, 0, sizeof(CkwUeInfo)); + + ret1 = cmUnpkCkwUeInfo((ueInfo), mBuf); +#if(ERRCLASS & ERRCLS_DEBUG) + if(ret1 != ROK) + { + SPutMsg(mBuf); + SLogError(pst->dstEnt, pst->dstInst, pst->dstProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG, + (ErrVal)ECKW044, (ErrVal)ret1, "Unpacking failure"); + RETVALUE( ret1 ); + } +#endif /* ERRCLASS & ERRCLS_DEBUG */ + + CMCHKUNPK(cmUnpkCmStatus, &status, mBuf); + + SPutMsg(mBuf); + + RETVALUE((*func)(pst, suId, transId, ueInfo, status)); + +} /* cmUnpkCkwUeIdChgCfm */ + +#endif /* LCCKW */ +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/cm/cm_bdy5.c b/src/cm/cm_bdy5.c new file mode 100644 index 000000000..001673f49 --- /dev/null +++ b/src/cm/cm_bdy5.c @@ -0,0 +1,514 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/********************************************************************20** + + Name: common functions - 5 + + Type: C source file + + Desc: C source code for common timer routines; + + File: cm_bdy5.c + +*********************************************************************21*/ + + +/* header include files -- defines (.h) */ + +#include "envopt.h" /* environment options */ +#include "envdep.h" /* environment dependent */ +#include "envind.h" /* environment independent */ + +#include "gen.h" /* general */ +#include "ssi.h" /* system services */ +#include "cm5.h" /* common functions */ + +/* header/extern include files (.x) */ + +#include "gen.x" /* general */ +#include "ssi.x" /* system services */ +#include "cm5.x" /* common functions */ + + +/* local defines */ + +#define CM_RMV_TQCP(tqEnt, tgt) \ +{ \ + ((tgt)->prev) ? ((tgt)->prev->next = (tgt)->next): \ + ((tqEnt)->first = (tgt)->next); \ + ((tgt)->next) ? ((tgt)->next->prev = (tgt)->prev): \ + ((tqEnt)->tail = (tgt)->prev); \ + (tgt)->prev = NULLP; \ + (tgt)->next = NULLP; \ + (tgt)->ent2bUpd = FALSE; \ +} + +#define CM_PLC_TQCP(tqEnt, tgt) \ +{ \ + if ((tqEnt)->tail) \ + { \ + (tqEnt)->tail->next = tgt; \ + (tgt)->prev = (tqEnt)->tail; \ + (tqEnt)->tail = tgt; \ + } \ + else \ + { \ + (tqEnt)->first = (tqEnt)->tail = tgt; \ + } \ +} + +/* local externs */ + +/* forward references */ + +/* functions in other modules */ + + +/* +* +* Fun: cmPrcTmr +* +* Desc: Handle a timer entry +* +* Ret: RETVOID +* +* Notes: +* +* File: cm_bdy5.c +* +*/ + +#ifdef SS_FAP +#ifdef ANSI +PUBLIC Void cmPrcTmr +( +CmTqCp *tqCp, /* timing que control point */ +CmTqType *tq, /* timing queue */ +PFV func /* function */ +) +#else +PUBLIC Void cmPrcTmr(tqCp, tq, func) +CmTqCp *tqCp; /* connection control block */ +CmTqType *tq; /* message buffer */ +PFV func; /* function */ +#endif +{ +/**/ + U32 expire; + U32 entry; + S16 event; + PTR cb; + CmTimer *tmp1; + CmTimer **tmp2; + + TRC2(cmPrcTmr) + +#ifdef CMDBG +{ + DateTime dt; + Txt prntBuf[PRNTSZE]; + + SGetDateTime(&dt); + /* Here the year was being printed as 2 letter value and hence did + * not represent accurate information. It has been modified as + * recommended to include the offset of year 1900 used in all Trillium + * SSI implementations. Patch cmbdy5c_001.113 + */ + sprintf(prntBuf,"%s: date: %02d/%02d/%04d time: %02d:%02d:%02d\n", + msArgv[0],dt.month,dt.day,(int)(dt.year + 1900), dt.hour, + dt.min, dt.sec); + SPrint(prntBuf); +} +#endif + + ++tqCp->nxtEnt; + expire = tqCp->nxtEnt; + /* cm_bdy5_c_002.113 - Modification for SRegCfgTmr support */ + entry = (U32) (expire % (U32)(tqCp->tmrLen)); + + tmp2 = &tq[entry].first; + while ((tmp1 = *tmp2) != NULLP) + { + if (tmp1->tqExpire == expire) + { + event = tmp1->tmrEvnt; + cb = tmp1->cb; + /* remove and reset this timer control block */ + (*tmp2) = tmp1->next; + tmp1->tmrEvnt = TMR_NONE; + tmp1->tqExpire = 0; + tmp1->cb = NULLP; + tmp1->next = NULLP; + func(cb, event); + } + else + tmp2 = &tmp1->next; + } + RETVOID; +} /* end of cmPrcTmr */ + +#else /* not defined SS_FAP */ + +#ifdef ANSI +PUBLIC Void cmPrcTmr +( +CmTqCp *tqCp, /* timing que control point */ +CmTqType *tq, /* timing queue */ +PFV func /* function */ +) +#else +PUBLIC Void cmPrcTmr(tqCp, tq, func) +CmTqCp *tqCp; /* connection control block */ +CmTqType *tq; /* message buffer */ +PFV func; /* function */ +#endif +{ +/**/ + U32 expire; + U32 entry, entry1; + S16 event; + CmTqType *tqEnt, *tqEnt1; + PTR cb; + CmTimer *tmp1; + VOLATILE U32 startTime = 0; + + TRC2(cmPrcTmr) + + /*starting Task*/ + SStartTask(&startTime, PID_CM_PRC_TMR); + +#ifdef CMDBG +{ + DateTime dt; + Txt prntBuf[PRNTSZE]; + + SGetDateTime(&dt); + /* Here the year was being printed as 2 letter value and hence did + * not represent accurate information. It has been modified as + * recommended to include the offset of year 1900 used in all Trillium + * SSI implementations. + */ + sprintf(prntBuf,"%s: date: %02d/%02d/%04d time: %02d:%02d:%02d\n", + msArgv[0],dt.month,dt.day,(int)(dt.year + 1900), dt.hour, + dt.min, dt.sec); + SPrint(prntBuf); +} +#endif + + ++tqCp->nxtEnt; + expire = tqCp->nxtEnt; + entry = (U32) (expire % (U32)(tqCp->tmrLen)); + + tqCp->tmp = (tqEnt = &tq[entry])->first; + while ((tmp1 = tqCp->tmp) != NULLP) + { + tqCp->tmp = tmp1->next; + /* SRIKY - Temp Fix to overcome timer not firing. Need to take */ + /* care of wrap around case */ + if ((tmp1->tqExpire <= expire) || (tmp1->ent2bUpd)) + { + event = tmp1->tmrEvnt; + cb = tmp1->cb; + + if (!(tmp1->ent2bUpd)) + { + CM_RMV_TQCP(tqEnt, tmp1); + tmp1->tmrEvnt = TMR_NONE; + tmp1->tqExpire = 0; + tmp1->cb = NULLP; + + func(cb, event); + } + else + { + entry1 = (U32) (tmp1->tqExpire % (U32)(tqCp->tmrLen)); + tqEnt1 = &tq[entry1]; + CM_RMV_TQCP(tqEnt, tmp1); + tmp1->entIdx = entry1; + CM_PLC_TQCP(tqEnt1, tmp1); + } + } + } + + /*stoping Task*/ + SStopTask(startTime, PID_CM_PRC_TMR); + RETVOID; +} /* end of cmPrcTmr */ +#endif /* SS_FAP */ + + + +/* +* +* Fun: cmInitTimers +* +* Desc: initialize timers +* +* Ret: RETVOID +* +* Notes: Connection Oriented Control +* +* File: cm_bdy5.c +* +*/ +#ifdef ANSI +PUBLIC Void cmInitTimers +( +CmTimer *timers, /* timer list */ +U8 max /* maximum tmrs */ +) +#else +PUBLIC Void cmInitTimers(timers, max) +CmTimer *timers; /* timer list */ +U8 max; /* maximum tmrs */ +#endif +{ + CmTimer *tPtr; + REG1 U8 i; + + TRC2(cmInitTimers) + + for (i = 0, tPtr = timers; i < max; i++, tPtr++) + { + tPtr->tmrEvnt = TMR_NONE; + tPtr->tqExpire = 0; + tPtr->cb = 0; + tPtr->next = (struct cmTimer *)NULLP; + tPtr->prev = (struct cmTimer *)NULLP; + tPtr->ent2bUpd = FALSE; + } + RETVOID; +} /* end of cmInitTimers */ + +/* +* +* Fun: cmPlcCbTq +* +* Desc: Places Control Block on Timing Queue +* +* Ret: RETVOID +* +* Notes: None +* +* File: cm_bdy5.c +* +*/ + +#ifdef ANSI +PUBLIC Void cmPlcCbTq +( +CmTmrArg *arg +) +#else +PUBLIC Void cmPlcCbTq(arg) +CmTmrArg *arg; +#endif +{ +/*added FAP modifications*/ +#ifdef SS_FAP + REG1 U8 tmrNum; + /* cm_bdy5_c_001.main_20 - Modification for SRegCfgTmr support */ + U32 ent; + U32 expire; + CmTimer **tmp; + + TRC2(cmPlcCbTq) + + expire = (arg->tqCp->nxtEnt + arg->wait); + /* cm_bdy5_c_002.113 - Modification for SRegCfgTmr support */ + ent = (U32)(expire % (U32)(arg->tqCp->tmrLen)); + + for (tmrNum = 0; tmrNum < arg->max; tmrNum++) + { + if (arg->timers[tmrNum].tmrEvnt == TMR_NONE) + { + arg->timers[tmrNum].tmrEvnt = arg->evnt; + arg->timers[tmrNum].tqExpire = expire; + arg->timers[tmrNum].cb = arg->cb; + arg->timers[tmrNum].next = NULLP; + + tmp = &(arg->tq[ent].first); + while (*tmp) + tmp = &((*tmp)->next); + *tmp = &arg->timers[tmrNum]; + + RETVOID; + } + } + RETVOID; +#else + REG1 U8 tmrNum; + U32 ent; + CmTqType *tq; + CmTimer *target; + U32 expire; + TRC2(cmPlcCbTq) + + expire = (arg->tqCp->nxtEnt + arg->wait); + ent = (U32)(expire % (U32)(arg->tqCp->tmrLen)); + + for (tmrNum = 0; tmrNum < arg->max; tmrNum++) + { + if (arg->timers[tmrNum].tmrEvnt == TMR_NONE) + { + target = &arg->timers[tmrNum]; + tq = &arg->tq[ent]; + + target->tmrEvnt = arg->evnt; + target->tqExpire = expire; + target->cb = arg->cb; + target->ent2bUpd = FALSE; + target->entIdx = ent; + + /* Place the timer block in the timer list */ + CM_PLC_TQCP(tq, target); + + RETVOID; + } + } + RETVOID; +#endif +} /* end of cmPlcCbTq */ + +/* +* +* Fun: cmRstCbTq +* +* Desc: Places Control Block on Timing Queue +* +* Ret: RETVOID +* +* Notes: None +* +* File: cm_bdy5.c +* +*/ + +#ifdef ANSI +PUBLIC Void cmRstCbTq +( +CmTmrArg *arg +) +#else +PUBLIC Void cmRstCbTq(arg) +CmTmrArg *arg; +#endif +{ + TRC2(cmRstCbTq) + + arg->timers[arg->tNum].tqExpire = arg->tqCp->nxtEnt + arg->wait; + arg->timers[arg->tNum].ent2bUpd = TRUE; + + RETVOID; +} /* end of cmRstCbTq */ + +/* +* +* Fun: cmRmvCbTq +* +* Desc: Removes control block from Timing Queue +* +* Ret: RETVOID +* +* Notes: None +* +* File: cm_bdy5.c +* +*/ + +#ifdef ANSI +PUBLIC Void cmRmvCbTq +( +CmTmrArg *arg +) +#else +PUBLIC Void cmRmvCbTq(arg) +CmTmrArg *arg; +#endif +{ +/*Added FAP modifications*/ +#ifdef SS_FAP +/* cm_bdy5_c_002.113 - Modification for SRegCfgTmr support */ + U32 ent; + CmTimer *target; + CmTimer *tmp1; + CmTimer **tmp2; + + TRC2(cmRmvCbTq) + + target = &arg->timers[arg->tNum]; + if (target->tmrEvnt != TMR_NONE) + { + /* cm_bdy5_c_002.113 - Modification for SRegCfgTmr support */ + ent = (U32) (target->tqExpire % (U32)(arg->tqCp->tmrLen)); + tmp2 = &arg->tq[ent].first; + + while ((tmp1 = *tmp2) != NULLP) + { + if (tmp1 == target) + { + /* find the timer control block to be removed */ + (*tmp2) = tmp1->next; + tmp1->tmrEvnt = TMR_NONE; + tmp1->tqExpire = 0; + tmp1->cb = NULLP; + tmp1->next = NULLP; + break; + } + else + /* find the next timer control block */ + tmp2 = &tmp1->next; + } + } + RETVOID; +#else + U32 ent; + CmTimer *target; + CmTqType *tq; + + + TRC2(cmRmvCbTq) + + target = &arg->timers[arg->tNum]; + if (target->tmrEvnt != TMR_NONE) + { + ent = (U32) (target->entIdx); + tq = &arg->tq[ent]; + + /* + * Update the timer pointer in the for correct processing in + * CmPrcTmr. + */ + if (target == arg->tqCp->tmp) + arg->tqCp->tmp = target->next; + + /* Remove the entru from the list */ + CM_RMV_TQCP( tq , target); + target->tmrEvnt = TMR_NONE; + target->tqExpire = 0; + target->cb = NULLP; + + } + RETVOID; +#endif +} /* end of cmRmvCbTq */ + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/cm/cm_gen.c b/src/cm/cm_gen.c new file mode 100644 index 000000000..a39e3ecd6 --- /dev/null +++ b/src/cm/cm_gen.c @@ -0,0 +1,3558 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + + +/********************************************************************20** + + Name: common body 6 + + Type: C source file + + Desc: common functions used to pack and unpack primitives and + structures that are: + + - Common to all interfaces e.g. Addrs, etc. + These functions are always compiled. + + All functions pack/unpack assuming that the most significant + bit is towards the head of the buffer. + + File: cm_gen.c + +*********************************************************************21*/ + + +/* header include files (.h) */ + +#include "envopt.h" /* environment options */ +#include "envdep.h" /* environment dependent */ +#include "envind.h" /* environment independent */ + +#include "gen.h" /* general layer */ +#include "ssi.h" /* system services */ + +#ifndef CMFILE_REORG_1 +#include "cm_gen.h" /* common pack/unpack functions */ +#endif + +#include "cm_err.h" /* common error */ + +/* header/extern include files (.x) */ + +#include "gen.x" /* general layer */ +#include "ssi.x" /* system services */ + +#ifndef CMFILE_REORG_1 +#include "cm_gen.x" /* common pack/unpack functions */ +#endif + + +/* local defines */ + +/* local typedefs */ + +/* local externs */ + +/* forward references */ + +/* functions in other modules */ + +/* public variable declarations */ + +/* private variable declarations */ + + +/* + * common packing functions + */ + + +/* +* +* Fun: cmPkDateTime +* +* Desc: This function packs the Date Time structure +* +* Ret: ROK - ok +* +* Notes: None. +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmPkDateTime +( +DateTime *dateTime, /* date and time */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkDateTime(dateTime, mBuf) +DateTime *dateTime; /* date and time */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmPkDateTime) + + /*-- cm_gen_c_001.main_36 - added for micro seconds --*/ +#ifdef SS_DATETIME_USEC + CMCHKPK(SPkU32, dateTime->usec, mBuf); +#endif /*-- SS_DATETIME_USEC --*/ + CMCHKPK(SPkU8, dateTime->tenths, mBuf); + CMCHKPK(SPkU8, dateTime->sec, mBuf); + CMCHKPK(SPkU8, dateTime->min, mBuf); + CMCHKPK(SPkU8, dateTime->hour, mBuf); + CMCHKPK(SPkU8, dateTime->year, mBuf); + CMCHKPK(SPkU8, dateTime->day, mBuf); + CMCHKPK(SPkU8, dateTime->month, mBuf); + + RETVALUE(ROK); +} /* end of cmPkDateTime */ + + +/* +* +* Fun: cmPkDuration +* +* Desc: This function packs the Duration structure +* +* Ret: ROK - ok +* +* Notes: None. +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmPkDuration +( +Duration *duration, /* duration */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkDuration(duration, mBuf) +Duration *duration; /* duration */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmPkDuration) + + CMCHKPK(SPkU8, duration->tenths, mBuf); + CMCHKPK(SPkU8, duration->secs, mBuf); + CMCHKPK(SPkU8, duration->mins, mBuf); + CMCHKPK(SPkU8, duration->hours, mBuf); + CMCHKPK(SPkU8, duration->days, mBuf); + + RETVALUE(ROK); +} /* end of cmPkDuration */ + +/* +* +* Fun: cmPkPtr +* +* Desc: This function packs the pointer +* +* Ret: ROK - ok +* +* Notes: None. +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmPkPtr +( +PTR ptr, /* pointer */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkPtr(ptr, mBuf) +PTR ptr; /* pointer */ +Buffer *mBuf; /* message buffer */ +#endif +{ + Data pkArray[PTRSIZE]; /* array for packing */ + S16 ret; /* return code */ + U16 tmp; /* temporary value */ + +#if (defined(ALPHA) || defined(BIT_64)) + U32 tmp32; +#endif + + TRC2(cmPkPtr) + + ret = ROK; + switch (PTRSIZE) + { + case 2: +#ifndef FCSPKINT /* backward compatibility, packing order */ + pkArray[0] = (Data) GetHiByte(ptr); + pkArray[1] = (Data) GetLoByte(ptr); +#else /* forward compatibility, packing order */ + pkArray[1] = (Data) GetHiByte(ptr); + pkArray[0] = (Data) GetLoByte(ptr); +#endif + ret = SAddPreMsgMult(pkArray, (MsgLen) 2, mBuf); + break; + + case 4: +#ifndef FCSPKINT /* backward compatibility, packing order */ + tmp = (U16) GetHiWord(ptr); + pkArray[0] = (Data) GetHiByte(tmp); + pkArray[1] = (Data) GetLoByte(tmp); + tmp = (U16) GetLoWord(ptr); + pkArray[2] = (Data) GetHiByte(tmp); + pkArray[3] = (Data) GetLoByte(tmp); +#else /* forward compatibility, packing order */ + tmp = (U16) GetHiWord(ptr); + pkArray[3] = (Data) GetHiByte(tmp); + pkArray[2] = (Data) GetLoByte(tmp); + tmp = (U16) GetLoWord(ptr); + pkArray[1] = (Data) GetHiByte(tmp); + pkArray[0] = (Data) GetLoByte(tmp); +#endif + ret = SAddPreMsgMult(pkArray, (MsgLen) 4, mBuf); + break; + + case 8: +#if (defined(ALPHA) || defined(BIT_64)) +#ifndef FCSPKINT /* backward compatibility, packing order */ + tmp32 = (U32) GetHi32Bit(ptr); + tmp = (U16) GetHiWord(tmp32); + pkArray[0] = (Data) GetHiByte(tmp); + pkArray[1] = (Data) GetLoByte(tmp); + tmp = (U16) GetLoWord(tmp32); + pkArray[2] = (Data) GetHiByte(tmp); + pkArray[3] = (Data) GetLoByte(tmp); + tmp32 = (U32) GetLo32Bit(ptr); + tmp = (U16) GetHiWord(tmp32); + pkArray[4] = (Data) GetHiByte(tmp); + pkArray[5] = (Data) GetLoByte(tmp); + tmp = (U16) GetLoWord(tmp32); + pkArray[6] = (Data) GetHiByte(tmp); + pkArray[7] = (Data) GetLoByte(tmp); +#else /* forward compatibility, packing order */ + tmp32 = (U32) GetHi32Bit(ptr); + tmp = (U16) GetHiWord(tmp32); + pkArray[7] = (Data) GetHiByte(tmp); + pkArray[6] = (Data) GetLoByte(tmp); + tmp = (U16) GetLoWord(tmp32); + pkArray[5] = (Data) GetHiByte(tmp); + pkArray[4] = (Data) GetLoByte(tmp); + tmp32 = (U32) GetLo32Bit(ptr); + tmp = (U16) GetHiWord(tmp32); + pkArray[3] = (Data) GetHiByte(tmp); + pkArray[2] = (Data) GetLoByte(tmp); + tmp = (U16) GetLoWord(tmp32); + pkArray[1] = (Data) GetHiByte(tmp); + pkArray[0] = (Data) GetLoByte(tmp); +#endif + ret = SAddPreMsgMult(pkArray, (MsgLen) 8, mBuf); + break; +#endif + default: + /* no support for U64 */ + ret = RFAILED; + } + + RETVALUE(ret); +} /* end of cmPkPtr */ + + +/* +* +* Fun: cmPkEntityId +* +* Desc: This function packs the EntityId structure +* +* Ret: ROK - ok +* +* Notes: None. +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmPkEntityId +( +EntityId *entityId, /* entity id */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkEntityId(entityId, mBuf) +EntityId *entityId; /* entity id */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmPkEntityId) + + CMCHKPK(cmPkInst, entityId->inst, mBuf); + CMCHKPK(cmPkEnt, entityId->ent, mBuf); + + RETVALUE(ROK); +} /* end of cmPkEntityId */ + + +/* +* +* Fun: cmPkElmntId +* +* Desc: This function packs the ElmntId structure +* +* Ret: ROK - ok +* +* Notes: None. +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmPkElmntId +( +ElmntId *elmntId, /* element id */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkElmntId(elmntId, mBuf) +ElmntId *elmntId; /* element id */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmPkElmntId) + + CMCHKPK(cmPkElmntInst3, elmntId->elmntInst3, mBuf); + CMCHKPK(cmPkElmntInst2, elmntId->elmntInst2, mBuf); + CMCHKPK(cmPkElmntInst1, elmntId->elmntInst1, mBuf); + CMCHKPK(cmPkElmnt, elmntId->elmnt, mBuf); + + RETVALUE(ROK); +} /* end of cmPkElmntId */ + + +/* +* +* Fun: cmPkMemoryId +* +* Desc: This function packs the MemoryId structure +* +* Ret: ROK - ok +* +* Notes: None. +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmPkMemoryId +( +MemoryId *memoryId, /* memoryId */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkMemoryId(memoryId, mBuf) +MemoryId *memoryId; /* memoryId */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmPkMemoryId) + + CMCHKPK(cmPkPool, memoryId->pool, mBuf); + CMCHKPK(cmPkRegion, memoryId->region, mBuf); + + RETVALUE(ROK); +} /* end of cmPkMemoryId */ + + +/* +* +* Fun: cmPkSystemId +* +* Desc: This function packs the System Id structure +* +* Ret: ROK - ok +* +* Notes: None. +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmPkSystemId +( +SystemId *systemId, /* system id */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkSystemId(systemId, mBuf) +SystemId *systemId; /* system id */ +Buffer *mBuf; /* message buffer */ +#endif +{ + Txt *p; /* part number string */ + + TRC2(cmPkSystemId) + + for (p = systemId->ptNmb; *p; p++); + + for (; p != systemId->ptNmb; p--) + { + CMCHKPK(cmPkTxt, *p, mBuf); + } + CMCHKPK(cmPkTxt, *p, mBuf); + + CMCHKPK(SPkS16, systemId->bRev, mBuf); + CMCHKPK(SPkS16, systemId->bVer, mBuf); + CMCHKPK(SPkS16, systemId->mRev, mBuf); + CMCHKPK(SPkS16, systemId->mVer, mBuf); + + RETVALUE(ROK); +} /* end of cmPkSystemId */ + + + +/* + * + * Fun: cmPkProtAddr + * + * Desc: This function will pack protocol address. + * + * Ret: ROK on success + * RFAILED on error + * + * Notes: None + * + File: cm_gen.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmPkProtAddr +( +ProtAddr *pAddr, /* protocol address */ +Buffer *mBuf /* buffer */ +) +#else +PUBLIC S16 cmPkProtAddr(pAddr, mBuf) +ProtAddr *pAddr; /* protocol address */ +Buffer *mBuf; /* buffer */ +#endif +{ + U8 j; /* Index */ + + TRC3(cmPkProtAddr) + +#ifdef CM_ARI2 + CMCHKPK(SPkU32, pAddr->autoSysId, mBuf); + CMCHKPK(cmPkBool, pAddr->autoSysIdPres, mBuf); +#endif /* CM_ARI2 */ + + for (j = pAddr->len; j; j--) + CMCHKPK(SPkU8, pAddr->address[j - 1], mBuf); + + CMCHKPK(SPkU8, pAddr->preLen, mBuf); + CMCHKPK(SPkU8, pAddr->len, mBuf); + CMCHKPK(SPkU16, pAddr->protType, mBuf); + + RETVALUE(ROK); + +} /* end of cmPkProtAddr */ + + + +/* + * + * Fun: cmPkProtAddrTbl + * + * Desc: This function will pack protocol addresses. + * + * Ret: ROK on success + * RFAILED on error + * + * Notes: None + * + File: cm_gen.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmPkProtAddrTbl +( +ProtAddrTbl *protAddr, /* protocol address table */ +Buffer *mBuf /* buffer */ +) +#else +PUBLIC S16 cmPkProtAddrTbl(protAddr, mBuf) +ProtAddrTbl *protAddr; /* protocol address table */ +Buffer *mBuf; /* buffer */ +#endif +{ + U8 i; /* index */ + U8 j; /* Index */ + ProtAddr *pAddr; /* protocol Address */ + + TRC3(cmPkProtAddrTbl) + + if (protAddr->count > MAX_PROT_ADDRS) + RETVALUE(RFAILED); + + for (i = protAddr->count; i; i--) + { + pAddr = &(protAddr->addr[i - 1]); + +#ifdef CM_ARI2 + CMCHKPK(SPkU32, pAddr->autoSysId, mBuf); + CMCHKPK(cmPkBool, pAddr->autoSysIdPres, mBuf); +#endif /* CM_ARI2 */ + + for (j = pAddr->len; j; j--) + CMCHKPK(SPkU8, pAddr->address[j - 1], mBuf); + + CMCHKPK(SPkU8, pAddr->preLen, mBuf); + CMCHKPK(SPkU8, pAddr->len, mBuf); + CMCHKPK(SPkU16, pAddr->protType, mBuf); + + } + CMCHKPK(SPkU8, protAddr->count, mBuf); + + RETVALUE(ROK); +} /* end of cmPkProtAddrTbl */ + + +/* +* +* Fun: cmPkAddrs +* +* Desc: This function packs the address structure for a loosely +* coupled interface +* +* Ret: ROK - ok +* +* Notes: None. +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmPkAddrs +( +Addrs *addrs, /* address */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkAddrs(addrs, mBuf) +Addrs *addrs; /* address */ +Buffer *mBuf; /* message buffer */ +#endif +{ + U8 i; /* loop counter */ + + TRC2(cmPkAddrs) + + if (addrs->length > ADRLEN) + RETVALUE(RFAILED); + + for (i = addrs->length; i; i--) + { + CMCHKPK(SPkU8, addrs->strg[i-1], mBuf); + } + + CMCHKPK(SPkU8, addrs->length, mBuf); + + RETVALUE(ROK); +} /* end of cmPkAddrs */ + + +/* +* +* Fun: cmPkShrtAddrs +* +* Desc: This function packs the short address structure for a loosely +* coupled interface +* +* Ret: ROK - ok +* +* Notes: None. +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmPkShrtAddrs +( +ShrtAddrs *addrs, /* address */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkShrtAddrs(addrs, mBuf) +ShrtAddrs *addrs; /* address */ +Buffer *mBuf; /* message buffer */ +#endif +{ + U8 i; /* loop counter */ + + TRC2(cmPkShrtAddrs) + + if (addrs->length > SHRTADRLEN) + RETVALUE(RFAILED); + + for (i = addrs->length; i; i--) + { + CMCHKPK(SPkU8, addrs->strg[i-1], mBuf); + } + + CMCHKPK(SPkU8, addrs->length, mBuf); + + RETVALUE(ROK); +} /* end of cmPkShrtAddrs */ + + +/* +* +* Fun: cmPkAddrMask +* +* Desc: This function address mask array. +* +* Ret: ROK - ok +* +* Notes: None +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmPkAddrMask +( +U8 *mask, /* pointer to address mask array */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkAddrMask(mask, mBuf) +U8 *mask; /* pointer to address mask array */ +Buffer *mBuf; /* message buffer */ +#endif +{ + S16 i; /* counter */ + + TRC2(cmPkAddrMask) + + /* pack address mask */ + for (i = (ADRLEN - 1); i >= 0; i--) + { + CMCHKPK(SPkU8, mask[i], mBuf); + } + + RETVALUE(ROK); +} /* end of cmPkAddrMask */ + + +/* +* +* Fun: cmPkBndCfg +* +* Desc: This function packs the BndCfg structure +* +* Ret: ROK - ok +* +* Notes: None. +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmPkBndCfg +( +BndCfg *bndCfg, /* bndCfg */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkBndCfg(bndCfg, mBuf) +BndCfg *bndCfg; /* bndCfg */ +Buffer *mBuf; /* message buffer */ +#endif +{ + Txt *p; /* temporary */ + + TRC2(cmPkBndCfg) + + CMCHKPK(cmPkSelector, bndCfg->selector, mBuf); + CMCHKPK(cmPkAddrs, &bndCfg->sapAdr, mBuf); + CMCHKPK(cmPkRoute, bndCfg->route, mBuf); + CMCHKPK(cmPkPrior, bndCfg->prior, mBuf); + CMCHKPK(cmPkPool, bndCfg->pool, mBuf); + CMCHKPK(cmPkRegion, bndCfg->region, mBuf); + CMCHKPK(cmPkInst, bndCfg->inst, mBuf); + CMCHKPK(cmPkEnt, bndCfg->ent, mBuf); + CMCHKPK(SPkU8, bndCfg->wdw, mBuf); + CMCHKPK(SPkU8, bndCfg->flcTyp, mBuf); + CMCHKPK(SPkU8, bndCfg->bufOwnshp, mBuf); + + for (p = bndCfg->usrId; *p; p++); + for (; p != bndCfg->usrId; p--); + CMCHKPK(cmPkTxt, *p, mBuf); + + RETVALUE(ROK); +} /* end of cmPkBndCfg */ + + +/* +* +* Fun: cmPkPst +* +* Desc: pack post structure +* +* Ret: ROK +* +* Notes: None. +* +* File: cm_gen.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmPkPst +( +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkPst(pst, mBuf) +Pst *pst; +Buffer *mBuf; +#endif +{ + TRC2(cmPkPst) + + CMCHKPK(cmPkEvent, pst->event, mBuf); + CMCHKPK(cmPkInst, pst->srcInst, mBuf); + CMCHKPK(cmPkEnt, pst->srcEnt, mBuf); + CMCHKPK(cmPkProcId, pst->srcProcId, mBuf); + CMCHKPK(cmPkInst, pst->dstInst, mBuf); + CMCHKPK(cmPkEnt, pst->dstEnt, mBuf); + CMCHKPK(cmPkProcId, pst->dstProcId, mBuf); + CMCHKPK(cmPkRoute, pst->route, mBuf); + CMCHKPK(cmPkPrior, pst->prior, mBuf); + CMCHKPK(cmPkPool, pst->pool, mBuf); + CMCHKPK(cmPkRegion, pst->region, mBuf); + CMCHKPK(cmPkSelector, pst->selector, mBuf); +#ifdef TDS_ROLL_UPGRADE_SUPPORT + CMCHKPK(cmPkIntfVer, pst->intfVer, mBuf); +#endif + + RETVALUE(ROK); +} /* end of cmPkPst */ + +/* + * + * Fun: cmPkElmtHdr + * + * Desc: Pack element header + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_gen.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmPkElmtHdr +( +ElmtHdr *m, /* element header */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkElmtHdr(m, mBuf) +ElmtHdr *m; /* element header */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmPkElmtHdr) + +#if (LCAMT || ATM_BISUP) + CMCHKPK(SPkU16, m->compInd, mBuf); +#endif /* LCAMT || ATM_BISUP */ + +#if (LCAMT || ATM_BISUP) + /* Pack action indicator field */ + if (m->pres) + { + CMCHKPK(SPkU8, m->actnInd, mBuf); + } +#endif + + /* Present */ + CMCHKPK(cmPkBool, m->pres, mBuf); + + RETVALUE(ROK); +} /* end of cmPkElmtHdr */ + + +/* + * + * Fun: cmPkTknU8 + * + * Desc: This function packs a token U8 + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_gen.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmPkTknU8 +( +TknU8 *tknU8, /* token U8 */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkTknU8(tknU8, mBuf) +TknU8 *tknU8; /* token U8 */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmPkTknU8) + + if (tknU8->pres) + { + /* Value */ + CMCHKPK(SPkU8, tknU8->val, mBuf); + } + + /* Token Header */ + CMCHKPK(SPkU8, tknU8->pres, mBuf); + + RETVALUE(ROK); +} /* end of cmPkTknU8 */ + + +/* + * + * Fun: cmPkTknS8 + * + * Desc: This function packs a token S8 + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_gen.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmPkTknS8 +( +TknS8 *tknS8, /* token S8 */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkTknS8(tknS8, mBuf) +TknS8 *tknS8; /* token S8 */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmPkTknS8) + + if (tknS8->pres) + { + /* Value */ + CMCHKPK(SPkS8, tknS8->val, mBuf); + } + + /* Token Header */ + CMCHKPK(SPkU8, tknS8->pres, mBuf); + + RETVALUE(ROK); +} /* end of cmPkTknS8 */ + + +/* + * + * Fun: cmPkTknU16 + * + * Desc: This function packs a token U16 + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_gen.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmPkTknU16 +( +TknU16 *tknU16, /* token U16 */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkTknU16(tknU16, mBuf) +TknU16 *tknU16; /* token U16 */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmPkTknU16) + + if (tknU16->pres) + { + /* Value */ + CMCHKPK(SPkU16, tknU16->val, mBuf); + } + + /* Token Header */ + CMCHKPK(SPkU8, tknU16->pres, mBuf); + + RETVALUE(ROK); +} /* end of cmPkTknU16 */ + + +/* + * + * Fun: cmPkTknU32 + * + * Desc: This function packs a token U32 + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_gen.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmPkTknU32 +( +TknU32 *tknU32, /* token U32 */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkTknU32(tknU32, mBuf) +TknU32 *tknU32; /* token U32 */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmPkTknU32) + + if (tknU32->pres) + { + /* Value */ + CMCHKPK(SPkU32, tknU32->val, mBuf); + } + + /* Token Header */ + CMCHKPK(SPkU8, tknU32->pres, mBuf); + + RETVALUE(ROK); +} /* end of cmPkTknU32 */ + + +/* + * + * Fun: cmPkTknStr + * + * Desc: This function packs a token string - regular size + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_gen.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmPkTknStr +( +TknStr *tknStr, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkTknStr(tknStr, mBuf) +TknStr *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + Cntr i; /* counter */ + + TRC2(cmPkTknStr) + + if (tknStr->pres) + { + /* Value */ + for (i = 0; i < (S16) tknStr->len; i++) + { + CMCHKPK(SPkU8, tknStr->val[i], mBuf); + } + + /* Length */ + CMCHKPK(SPkU8, tknStr->len, mBuf); + } + + /* Token Header */ + CMCHKPK(SPkU8, tknStr->pres, mBuf); + + RETVALUE(ROK); +} /* end of cmPkTknStr */ + + +/* + * + * Fun: cmPkTknStrM + * + * Desc: This function packs a token string - medium size + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_gen.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmPkTknStrM +( +TknStrM *tknStr, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkTknStrM(tknStr, mBuf) +TknStrM *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + Cntr i; /* counter */ + + TRC2(cmPkTknStrM) + + if(tknStr->pres) + { + /* Value */ + for (i = 0; i < (S16) tknStr->len; i++) + { + CMCHKPK(SPkU8, tknStr->val[i], mBuf); + } + + /* Length */ + CMCHKPK(SPkU8, tknStr->len, mBuf); + } + + /* Token Header */ + CMCHKPK(SPkU8, tknStr->pres, mBuf); + + RETVALUE(ROK); +} /* end of cmPkTknStrM */ + + +/* + * + * Fun: cmPkTknStrS + * + * Desc: This function packs a token string - small size + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_gen.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmPkTknStrS +( +TknStrS *tknStr, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkTknStrS(tknStr, mBuf) +TknStrS *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + Cntr i; /* counter */ + + TRC2(cmPkTknStrS) + + if(tknStr->pres) + { + /* Value */ + for (i = 0; i < (S16) tknStr->len; i++) + { + CMCHKPK(SPkU8, tknStr->val[i], mBuf); + } + + /* Length */ + CMCHKPK(SPkU8, tknStr->len, mBuf); + } + + /* Token Header */ + CMCHKPK(SPkU8, tknStr->pres, mBuf); + + RETVALUE(ROK); +} /* end of cmPkTknStrS */ + + +/* + * + * Fun: cmPkTknStrE + * + * Desc: This function packs a token string - extended size + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_gen.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmPkTknStrE +( +TknStrE *tknStr, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkTknStrE(tknStr, mBuf) +TknStrE *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + Cntr i; /* counter */ + + TRC2(cmPkTknStrE) + + if(tknStr->pres) + { + /* Value */ + for (i = 0; i < (S16) tknStr->len; i++) + { + CMCHKPK(SPkU8, tknStr->val[i], mBuf); + } + + /* Length */ + CMCHKPK(SPkU8, tknStr->len, mBuf); + } + + /* Token Header */ + CMCHKPK(SPkU8, tknStr->pres, mBuf); + + RETVALUE(ROK); +} /* end of cmPkTknStrE */ + +#ifndef CMFILE_REORG_1 + + +/* +* +* Fun: cmPkPnNodeId +* +* Desc: This function packs a PnNodeId structure into a buffer +* +* Ret: Void +* +* Notes: None +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmPkPnNodeId +( +PnNodeId *src, /* source PNNI Node Id */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkPnNodeId (src, mBuf) +PnNodeId *src; /* source PNNI Node Id */ +Buffer *mBuf; /* message buffer */ +#endif +{ + S16 i; + + TRC3(cmPkPnNodeId); + + for (i = PN_NODEID_LEN - 1; i >= 0; i--) + { + CMCHKPK(SPkU8, src->id[i], mBuf); + } + + RETVALUE(ROK); +} /* cmPkPnNodeId */ + +#endif /* CMFILE_REORG_1 */ + + +/* + * + * Fun: cmPkTknStr4 + * + * Desc: This function packs a token string of size 4 + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_gen.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmPkTknStr4 +( +TknStr4 *tknStr, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkTknStr4(tknStr, mBuf) +TknStr4 *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmPkTknStr4) + + CMPKTKNSTR(tknStr, mBuf); + + RETVALUE(ROK); + +} /* end of cmPkTknStr4 */ + + + +/* + * + * Fun: cmPkTknStr12 + * + * Desc: This function packs a token string of size 4 + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_gen.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmPkTknStr12 +( +TknStr12 *tknStr, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkTknStr12(tknStr, mBuf) +TknStr12 *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmPkTknStr12) + + CMPKTKNSTR(tknStr, mBuf); + + RETVALUE(ROK); + +} /* end of cmPkTknStr12 */ + + +/* + * + * Fun: cmPkTknStr32 + * + * Desc: This function packs a token string of size 4 + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_gen.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmPkTknStr32 +( +TknStr32 *tknStr, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkTknStr32(tknStr, mBuf) +TknStr32 *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmPkTknStr32) + + CMPKTKNSTR(tknStr, mBuf); + + RETVALUE(ROK); + +} /* end of cmPkTknStr32 */ + + +/* + * + * Fun: cmPkTknStr64 + * + * Desc: This function packs a token string of size 4 + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_gen.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmPkTknStr64 +( +TknStr64 *tknStr, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkTknStr64(tknStr, mBuf) +TknStr64 *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmPkTknStr64) + + CMPKTKNSTR(tknStr, mBuf); + + RETVALUE(ROK); + +} /* end of cmPkTknStr64 */ + + +/* + * + * Fun: cmPkTknStr132 + * + * Desc: This function packs a token string of size 4 + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_gen.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmPkTknStr132 +( +TknStr132 *tknStr, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkTknStr132(tknStr, mBuf) +TknStr132 *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmPkTknStr132) + + CMPKTKNSTR(tknStr, mBuf); + + RETVALUE(ROK); + +} /* end of cmPkTknStr132 */ + + +/* + * + * Fun: cmPkTknStr256 + * + * Desc: This function packs a token string of size 4 + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_gen.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmPkTknStr256 +( +TknStr256 *tknStr, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkTknStr256(tknStr, mBuf) +TknStr256 *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmPkTknStr256) + + CMPKTKNSTR(tknStr, mBuf); + + RETVALUE(ROK); + +} /* end of cmPkTknStr256 */ + + +/* + * + * Fun: cmPkTknOid + * + * Desc: This function packs a Object Identifier token + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_gen.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmPkTknOid +( +TknOid *tknOid, /* Object Identifier token */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkTknOid(tknOid, mBuf) +TknOid *tknOid; /* Object Identifier token */ +Buffer *mBuf; /* message buffer */ +#endif +{ + U16 i; + + TRC2(cmPkTknOid) + + if (tknOid->pres == TRUE) + { + /* Pack the value */ + for (i = 0; i < (U16)tknOid->len; i++) + { + /* cm_gen_c_001.main_33: changes for TknOid value from U16 to U32 + * with compilation flag TKNOID_U16 */ +#ifndef TKNOID_U16 + CMCHKPK(SPkU32, tknOid->val[i], mBuf); +#else + CMCHKPK(SPkU16, tknOid->val[i], mBuf); +#endif /* !TKNOID_U16 */ + } + /* Pack the length */ + CMCHKPK(SPkU8, tknOid->len, mBuf); + } + /* Pack the token header */ + CMCHKPK(SPkU8, tknOid->pres, mBuf); + + RETVALUE(ROK); +} /* end of cmPkTknOid */ + + +/* +* +* Fun: cmPkTknS32 +* +* Desc: This function packs a token S32 +* +* Ret: ROK - ok +* +* Notes: None +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmPkTknS32 +( +TknS32 *tknS32, /* token S32 */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkTknS32(tknS32, mBuf) +TknS32 *tknS32; /* token S32 */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmPkTknS32) + + if (tknS32->pres) + { + /* Value */ + CMCHKPK(SPkS32, tknS32->val, mBuf); + } + + /* Token Header */ + CMCHKPK(SPkU8, tknS32->pres, mBuf); + + RETVALUE(ROK); +} /* end of cmPkTknS32 */ + + +/* +* +* Fun: cmPkHeader +* +* Desc: This function packs the header structure +* +* Ret: ROK - ok +* +* Notes: None. +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmPkHeader +( +Header *header, /* header */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkHeader(header, mBuf) +Header *header; /* header */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmPkHeader) + +#ifdef LMINT3 + CMCHKPK(cmPkMemoryId, &header->response.mem, mBuf); + CMCHKPK(cmPkRoute, header->response.route, mBuf); + CMCHKPK(cmPkPriority, header->response.prior, mBuf); + CMCHKPK(cmPkSelector, header->response.selector, mBuf); + CMCHKPK(cmPkTranId, header->transId, mBuf); +#endif /* LMINT3 */ + CMCHKPK(cmPkElmntId, &header->elmId, mBuf); + CMCHKPK(cmPkEntityId, &header->entId, mBuf); + CMCHKPK(SPkU16, header->seqNmb, mBuf); + CMCHKPK(SPkU8, header->version, mBuf); + CMCHKPK(SPkU8, header->msgType, mBuf); + CMCHKPK(SPkU16, header->msgLen, mBuf); + + RETVALUE(ROK); +} /* end of cmPkHeader */ + + +/* +* +* Fun: cmPkCmStatus +* +* Desc: This function packs common management status structure +* +* Ret: ROK - ok +* +* Notes: None. +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmPkCmStatus +( +CmStatus *sta, /* status structure */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkCmStatus(sta, mBuf) +CmStatus *sta; /* status structure */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmPkCmStatus) + + CMCHKPK(SPkU16, sta->reason, mBuf); + CMCHKPK(SPkU16, sta->status, mBuf); + + RETVALUE(ROK); +} /* end of cmPkCmStatus */ + + +/* +* +* Fun: cmPkCmAlarm +* +* Desc: This function packs common management alarm structure +* +* Ret: ROK - ok +* +* Notes: None. +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmPkCmAlarm +( +CmAlarm *alarm, /* alarm structure */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkCmAlarm(alarm, mBuf) +CmAlarm *alarm; /* alarm structure */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmPkCmAlarm) + + CMCHKPK(SPkU16, alarm->cause, mBuf); + CMCHKPK(SPkU16, alarm->event, mBuf); + CMCHKPK(SPkU16, alarm->category, mBuf); + CMCHKPK(cmPkDateTime, &alarm->dt, mBuf); + + RETVALUE(ROK); +} /* end of cmPkCmAlarm */ + + +/* +* +* Fun: cmPkSmCfg +* +* Desc: This function packs the stack manager structure +* +* Ret: ROK - ok +* +* Notes: None. +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmPkSmCfg +( +SmCfg *smCfg, /* stack manager */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkSmCfg(smCfg, mBuf) +SmCfg *smCfg; /* stack manager */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmPkSmCfg) + + CMCHKPK(cmPkSelector, smCfg->selector, mBuf); + CMCHKPK(cmPkRoute, smCfg->route, mBuf); + CMCHKPK(cmPkPrior, smCfg->prior, mBuf); + CMCHKPK(cmPkPool, smCfg->pool, mBuf); + CMCHKPK(cmPkRegion, smCfg->region, mBuf); + CMCHKPK(cmPkInst, smCfg->inst, mBuf); + CMCHKPK(cmPkEnt, smCfg->ent, mBuf); + + RETVALUE(ROK); +} /* end of cmPkSmCfg */ + + +/* +* +* Fun: cmPkTmrCfg +* +* Desc: This function packs the timer configuration structure +* +* Ret: ROK - ok +* +* Notes: None. +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmPkTmrCfg +( +TmrCfg *tmrCfg, /* timer configuration */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkTmrCfg(tmrCfg, mBuf) +TmrCfg *tmrCfg; /* timer configuration */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmPkTmrCfg) + + CMCHKPK(SPkU16, tmrCfg->val, mBuf); + CMCHKPK(cmPkBool, tmrCfg->enb, mBuf); + + RETVALUE(ROK); +} /* end of cmPkTmrCfg */ + + +/* + * + * Fun: cmPkTknBuf + * + * Desc: This function packs a token buffer + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_gen.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmPkTknBuf +( +TknBuf *tknBuf, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkTknBuf(tknBuf, mBuf) +TknBuf *tknBuf; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmPkTknBuf) + + if(tknBuf->pres) + { + MsgLen msgLen; + + SFndLenMsg(tknBuf->val, &msgLen); + if( SCatMsg(mBuf, tknBuf->val, M2M1) != ROK ) + { + RETVALUE(RFAILED); + } + cmPkMsgLen(msgLen, mBuf); + SPutMsg(tknBuf->val); + } + + /* Token Header */ + CMCHKPK(SPkU8, tknBuf->pres, mBuf); + + RETVALUE(ROK); +} /* end of cmPkTknBuf */ + +#ifdef TDS_ROLL_UPGRADE_SUPPORT +/* +* +* Fun: cmPkIntf +* +* Desc: This function packs the interface information +* +* Ret: ROK - ok +* +* Notes: None. +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmPkIntf +( +CmIntf *intf, /* interface info */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkIntf(intf, mBuf) +CmIntf *intf; /* interface info */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmPkIntf) + + CMCHKPK(cmPkIntfId, intf->intfId, mBuf); + CMCHKPK(cmPkIntfVer, intf->intfVer, mBuf); + + RETVALUE(ROK); +} /* end of cmPkIntf */ +#endif /* TDS_ROLL_UPGRADE_SUPPORT */ + + +/* + * common unpacking functions + */ + + +/* +* +* Fun: cmUnpkDateTime +* +* Desc: This function is used to Unpack Pack Date Time structure +* +* Ret: ROK - ok +* +* Notes: None +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmUnpkDateTime +( +DateTime *dateTime, /* date/time structure */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkDateTime(dateTime, mBuf) +DateTime *dateTime; /* date/time structure */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmUnpDateTime) + + CMCHKUNPK(SUnpkU8, &dateTime->month, mBuf); + CMCHKUNPK(SUnpkU8, &dateTime->day, mBuf); + CMCHKUNPK(SUnpkU8, &dateTime->year, mBuf); + CMCHKUNPK(SUnpkU8, &dateTime->hour, mBuf); + CMCHKUNPK(SUnpkU8, &dateTime->min, mBuf); + CMCHKUNPK(SUnpkU8, &dateTime->sec, mBuf); + CMCHKUNPK(SUnpkU8, &dateTime->tenths, mBuf); + + /*-- added for micro seconds --*/ +#ifdef SS_DATETIME_USEC + CMCHKUNPK(SUnpkU32, &dateTime->usec, mBuf); +#endif /*-- SS_DATETIME_USEC --*/ + + RETVALUE(ROK); +} /* end of cmUnpkDateTime */ + + +/* +* +* Fun: cmUnpkDuration +* +* Desc: This function is used to Unpack Pack Duration structure +* +* Ret: ROK - ok +* +* Notes: None +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmUnpkDuration +( +Duration *duration, /* duration structure */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkDuration(duration, mBuf) +Duration *duration; /* duration structure */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmUnpDuration) + + CMCHKUNPK(SUnpkU8, &duration->days, mBuf); + CMCHKUNPK(SUnpkU8, &duration->hours, mBuf); + CMCHKUNPK(SUnpkU8, &duration->mins, mBuf); + CMCHKUNPK(SUnpkU8, &duration->secs, mBuf); + CMCHKUNPK(SUnpkU8, &duration->tenths, mBuf); + + RETVALUE(ROK); +} /* end of cmUnpkDuration */ + +/* +* +* Fun: cmUnpkPtr +* +* Desc: This function is used to Unpack Ptr type +* +* Ret: ROK - ok +* +* Notes: None +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmUnpkPtr +( +PTR *ptr, /* duration structure */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkPtr(ptr, mBuf) +PTR *ptr; /* duration structure */ +Buffer *mBuf; /* message buffer */ +#endif +{ + U16 tmp16; /* temporary value */ + U32 tmp32; /* temporary value */ + Data unpkArray[PTRSIZE]; /* unpacking array */ + S16 ret; /* return code */ + +#if (defined(ALPHA) || defined(BIT_64)) + U64 tmp64; +#endif + + TRC2(cmUnpkPtr) + + switch (PTRSIZE) + { + case 2: + ret = SRemPreMsgMult(unpkArray, (MsgLen) 2, mBuf); + if (ret != ROK) + RETVALUE(ret); + + tmp16 = 0; +#ifndef FCSPKINT /* backward compatibility, packing order */ + tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[1]); + tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[0]); +#else /* forward compatibility, packing order */ + tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[0]); + tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[1]); +#endif + *ptr = tmp16; + break; + + case 4: + ret = SRemPreMsgMult(unpkArray, (MsgLen) 4, mBuf); + if (ret != ROK) + RETVALUE(ret); + + tmp16 = 0; + tmp32 = 0; +#ifndef FCSPKINT /* backward compatibility, packing order */ + tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[3]); + tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[2]); + tmp32 = (U32) PutHiWord(tmp32, (U16) tmp16); + tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[1]); + tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[0]); + tmp32 = (U32) PutLoWord(tmp32, (U16) tmp16); +#else /* forward compatibility, packing order */ + tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[0]); + tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[1]); + tmp32 = (U32) PutHiWord(tmp32, (U16) tmp16); + tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[2]); + tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[3]); + tmp32 = (U32) PutLoWord(tmp32, (U16) tmp16); +#endif + *ptr = tmp32; + break; + + case 8: +#if(defined(ALPHA) || defined(BIT_64)) + ret = SRemPreMsgMult(unpkArray, (MsgLen) 8, mBuf); + if (ret != ROK) + RETVALUE(ret); + + tmp16 = 0; + tmp32 = 0; + tmp64 = 0; +#ifndef FCSPKINT /* backward compatibility, packing order */ + tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[7]); + tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[6]); + tmp32 = (U32) PutHiWord(tmp32, (U16) tmp16); + tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[5]); + tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[4]); + tmp32 = (U32) PutLoWord(tmp32, (U16) tmp16); + tmp64 = (U64) PutHi32Bit(tmp64, tmp32); + tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[3]); + tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[2]); + tmp32 = (U32) PutHiWord(tmp32, (U16) tmp16); + tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[1]); + tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[0]); + tmp32 = (U32) PutLoWord(tmp32, (U16) tmp16); + tmp64 = (U64) PutLo32Bit(tmp64, tmp32); +#else /* forward compatibility, packing order */ + tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[0]); + tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[1]); + tmp32 = (U32) PutHiWord(tmp32, (U16) tmp16); + tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[2]); + tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[3]); + tmp32 = (U32) PutLoWord(tmp32, (U16) tmp16); + tmp64 = (U64) PutHi32Bit(tmp64, tmp32); + tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[4]); + tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[5]); + tmp32 = (U32) PutHiWord(tmp32, (U16) tmp16); + tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[6]); + tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[7]); + tmp32 = (U32) PutLoWord(tmp32, (U16) tmp16); + tmp64 = (U64) PutLo32Bit(tmp64, tmp32); +#endif + *ptr = tmp64; + break; +#endif + default: + /* no support for U64 */ + ret = RFAILED; + } + + RETVALUE(ret); +} /* end of cmUnpkPtr */ + + +/* +* +* Fun: cmUnpkEntityId +* +* Desc: This function unpacks the EntityId structure +* +* Ret: ROK - ok +* +* Notes: None. +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmUnpkEntityId +( +EntityId *entityId, /* entity id */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkEntityId(entityId, mBuf) +EntityId *entityId; /* entity id */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmUnpkEntityId) + + CMCHKUNPK(cmUnpkEnt, &entityId->ent, mBuf); + CMCHKUNPK(cmUnpkInst, &entityId->inst, mBuf); + + RETVALUE(ROK); +} /* end of cmUnpkEntityId */ + + +/* +* +* Fun: cmUnpkElmntId +* +* Desc: This function unpacks the ElmntId structure +* +* Ret: ROK - ok +* +* Notes: None. +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmUnpkElmntId +( +ElmntId *elmntId, /* element id */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkElmntId(elmntId, mBuf) +ElmntId *elmntId; /* element id */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmUnpkElmntId) + + CMCHKUNPK(cmUnpkElmnt, &elmntId->elmnt, mBuf); + CMCHKUNPK(cmUnpkElmntInst1, &elmntId->elmntInst1, mBuf); + CMCHKUNPK(cmUnpkElmntInst2, &elmntId->elmntInst2, mBuf); + CMCHKUNPK(cmUnpkElmntInst3, &elmntId->elmntInst3, mBuf); + + RETVALUE(ROK); +} /* end of cmUnpkElmntId */ + + +/* +* +* Fun: cmUnpkMemoryId +* +* Desc: This function unpacks the MemoryId structure +* +* Ret: ROK - ok +* +* Notes: None. +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmUnpkMemoryId +( +MemoryId *memoryId, /* memoryId */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkMemoryId(memoryId, mBuf) +MemoryId *memoryId; /* memoryId */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmUnpkMemoryId) + + CMCHKUNPK(cmUnpkRegion, &memoryId->region, mBuf); + CMCHKUNPK(cmUnpkPool, &memoryId->pool, mBuf); + + RETVALUE(ROK); +} /* end of cmUnpkMemoryId */ + + +/* +* +* Fun: cmUnpkSystemId +* +* Desc: This function packs the System Id structure +* +* Ret: ROK - ok +* +* Notes: None. +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmUnpkSystemId +( +SystemId *systemId, /* system id */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkSystemId(systemId, mBuf) +SystemId *systemId; /* system id */ +Buffer *mBuf; /* message buffer */ +#endif +{ + S16 i; /* loop counter */ + MsgLen len; + + TRC2(cmUnpkSystemId) + + CMCHKUNPK(SUnpkS16, &systemId->mVer, mBuf); + CMCHKUNPK(SUnpkS16, &systemId->mRev, mBuf); + CMCHKUNPK(SUnpkS16, &systemId->bVer, mBuf); + CMCHKUNPK(SUnpkS16, &systemId->bRev, mBuf); + + SFndLenMsg(mBuf, &len); + + for (i = 0; i < len; i++) + { + CMCHKUNPK(cmUnpkTxt, &systemId->ptNmb[i], mBuf); + } + + RETVALUE(ROK); +} /* end of cmUnpkSystemId */ + + + +/* + * + * Fun: cmUnpkProtAddr + * + * Desc: This function will unpack protocol address. + * + * Ret: ROK on success + * RFAILED on error + * + * Notes: None + * + File: cm_gen.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmUnpkProtAddr +( +ProtAddr *pAddr, /* protocol address */ +Buffer *mBuf /* buffer */ +) +#else +PUBLIC S16 cmUnpkProtAddr(pAddr, mBuf) +ProtAddr *pAddr; /* protocol address table */ +Buffer *mBuf; /* buffer */ +#endif +{ + U8 j; /* Index */ + + TRC3(cmUnpkProtAddr) + + CMCHKUNPK(SUnpkU16, &(pAddr->protType), mBuf); + CMCHKUNPK(SUnpkU8, &(pAddr->len), mBuf); + CMCHKUNPK(SUnpkU8, &(pAddr->preLen), mBuf); + + for (j =0; j < pAddr->len; j++) + CMCHKUNPK(SUnpkU8, &pAddr->address[j], mBuf); + +#ifdef CM_ARI2 + CMCHKUNPK(cmUnpkBool, &(pAddr->autoSysIdPres), mBuf); + CMCHKUNPK(SUnpkU32, &(pAddr->autoSysId), mBuf); +#endif /* CM_ARI2 */ + RETVALUE(ROK); + +} /* end of cmUnpkProtAddr */ + + +/* + * + * Fun: cmUnpkProtAddrTbl + * + * Desc: This function will pack protocol addresses. + * + * Ret: ROK on success + * RFAILED on error + * + * Notes: None + * + File: cm_gen.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmUnpkProtAddrTbl +( +ProtAddrTbl *protAddr, /* protocol address table */ +Buffer *mBuf /* buffer */ +) +#else +PUBLIC S16 cmUnpkProtAddrTbl(protAddr, mBuf) +ProtAddrTbl *protAddr; /* protocol address table */ +Buffer *mBuf; /* buffer */ +#endif +{ + U8 i; /* index */ + U8 j; /* Index */ + ProtAddr *pAddr; /* Protocol Address */ + + TRC3(cmUnpkProtAddrTbl) + + CMCHKUNPK(SUnpkU8, &protAddr->count, mBuf); + for (i = 0; i < protAddr->count; i++) + { + pAddr = &(protAddr->addr[i]); + + CMCHKUNPK(SUnpkU16, &(pAddr->protType), mBuf); + CMCHKUNPK(SUnpkU8, &(pAddr->len), mBuf); + CMCHKUNPK(SUnpkU8, &(pAddr->preLen), mBuf); + + + for (j =0; j < pAddr->len; j++) + CMCHKUNPK(SUnpkU8, &pAddr->address[j], mBuf); + +#ifdef CM_ARI2 + CMCHKUNPK(cmUnpkBool, &(pAddr->autoSysIdPres), mBuf); + CMCHKUNPK(SUnpkU32, &(pAddr->autoSysId), mBuf); +#endif /* CM_ARI2 */ + } + RETVALUE(ROK); +} /* end of cmUnpkProtAddrTbl */ + + +/* +* +* Fun: cmUnpkAddrs +* +* Desc: This function is used to unpack the Addrs structure +* +* Ret: ROK - ok +* +* Notes: None +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmUnpkAddrs +( +Addrs *addrs, /* address */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkAddrs(addrs, mBuf) +Addrs *addrs; /* address */ +Buffer *mBuf; /* message buffer */ +#endif +{ + U8 i; /* loop counter */ + + TRC2(cmUnpAddrs) + + CMCHKUNPK(SUnpkU8, &addrs->length, mBuf); + + if (addrs->length > ADRLEN) + RETVALUE(RFAILED); + + for(i = 0; i < addrs->length; i++) + { + CMCHKUNPK(SUnpkU8, &addrs->strg[i], mBuf); + } + + RETVALUE(ROK); +} /* end of cmUnpkAddrs */ + +/* +* +* Fun: cmUnpkShrtAddrs +* +* Desc: This function is used to unpack the ShrtAddrs structure +* +* Ret: ROK - ok +* +* Notes: None +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmUnpkShrtAddrs +( +ShrtAddrs *addrs, /* address */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkShrtAddrs(addrs, mBuf) +ShrtAddrs *addrs; /* address */ +Buffer *mBuf; /* message buffer */ +#endif +{ + U8 i; /* loop counter */ + + TRC2(cmUnpShrtAddrs) + + CMCHKUNPK(SUnpkU8, &addrs->length, mBuf); + + if (addrs->length > SHRTADRLEN) + RETVALUE(RFAILED); + + for(i = 0; i < addrs->length; i++) + { + CMCHKUNPK(SUnpkU8, &addrs->strg[i], mBuf); + } + RETVALUE(ROK); +} /* end of cmUnpkShrtAddrs */ + + +/* +* +* Fun: cmUnpkAddrMask +* +* Desc: This unpacks address mask. +* +* Ret: ROK - ok +* +* Notes: None +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmUnpkAddrMask +( +U8 *mask, /* pointer to address mask */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkAddrMask(mask, mBuf) +U8 *mask; /* pointer to address mask */ +Buffer *mBuf; /* message buffer */ +#endif +{ + S16 i; /* counter */ + + TRC2(cmUnpAddrMask) + + /* unpack address mask */ + for (i = 0; i< ADRLEN; i++) + { + CMCHKUNPK(SUnpkU8, &mask[i], mBuf); + } + RETVALUE(ROK); +} /* end of cmUnpkAddrMask */ + + +/* +* +* Fun: cmUnpkBndCfg +* +* Desc: This function unpacks the BndCfg structure +* +* Ret: ROK - ok +* +* Notes: None. +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmUnpkBndCfg +( +BndCfg *bndCfg, /* bndCfg */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkBndCfg(bndCfg, mBuf) +BndCfg *bndCfg; /* bndCfg */ +Buffer *mBuf; /* message buffer */ +#endif +{ + S16 i; /* loop counter */ + + TRC2(cmUnpBndCfg) + + for (i = 0; bndCfg->usrId[i]; i++); + CMCHKUNPK(cmUnpkTxt, bndCfg->usrId+i, mBuf); + + CMCHKUNPK(SUnpkU8, &bndCfg->bufOwnshp, mBuf); + CMCHKUNPK(SUnpkU8, &bndCfg->flcTyp, mBuf); + CMCHKUNPK(SUnpkU8, &bndCfg->wdw, mBuf); + CMCHKUNPK(cmUnpkEnt, &bndCfg->ent, mBuf); + CMCHKUNPK(cmUnpkInst, &bndCfg->inst, mBuf); + CMCHKUNPK(cmUnpkRegion, &bndCfg->region, mBuf); + CMCHKUNPK(cmUnpkPool, &bndCfg->pool, mBuf); + CMCHKUNPK(cmUnpkPrior, &bndCfg->prior, mBuf); + CMCHKUNPK(cmUnpkRoute, &bndCfg->route, mBuf); + CMCHKUNPK(cmUnpkAddrs, &bndCfg->sapAdr, mBuf); + CMCHKUNPK(cmUnpkSelector, &bndCfg->selector, mBuf); + + RETVALUE(ROK); +} /* end of cmUnpkBndCfg */ + + +/* +* +* Fun: cmUnpkPst +* +* Desc: pack post structure +* +* Ret: ROK +* +* Notes: None. +* +* File: cm_gen.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmUnpkPst +( +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkPst(pst, mBuf) +Pst *pst; +Buffer *mBuf; +#endif +{ + TRC2(cmUnpkPst) + +#ifdef TDS_ROLL_UPGRADE_SUPPORT + CMCHKUNPK(cmUnpkIntfVer, &pst->intfVer, mBuf); +#endif + CMCHKUNPK(cmUnpkSelector, &pst->selector, mBuf); + CMCHKUNPK(cmUnpkRegion, &pst->region, mBuf); + CMCHKUNPK(cmUnpkPool, &pst->pool, mBuf); + CMCHKUNPK(cmUnpkPrior, &pst->prior, mBuf); + CMCHKUNPK(cmUnpkRoute, &pst->route, mBuf); + CMCHKUNPK(cmUnpkProcId, &pst->dstProcId, mBuf); + CMCHKUNPK(cmUnpkEnt, &pst->dstEnt, mBuf); + CMCHKUNPK(cmUnpkInst, &pst->dstInst, mBuf); + CMCHKUNPK(cmUnpkProcId, &pst->srcProcId, mBuf); + CMCHKUNPK(cmUnpkEnt, &pst->srcEnt, mBuf); + CMCHKUNPK(cmUnpkInst, &pst->srcInst, mBuf); + CMCHKUNPK(cmUnpkEvent, &pst->event, mBuf); + + RETVALUE(ROK); +} /* end of cmUnpkPst */ + +/* +* +* Fun: cmUnpkElmtHdr +* +* Desc: Unpack element header +* +* Ret: ROK - ok +* +* Notes: None +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmUnpkElmtHdr +( +ElmtHdr *m, /* element header */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkElmtHdr(m, mBuf) +ElmtHdr *m; /* element header */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmUnpElmtHdr) + + /* Present */ + CMCHKUNPK(cmUnpkBool, &m->pres , mBuf); + +#if (LCAMT || ATM_BISUP) + /* Unpack action indicator field */ + if (m->pres) + { + CMCHKUNPK(SUnpkU8, &m->actnInd, mBuf); + } +#endif + +#if (LCAMT || ATM_BISUP) + CMCHKUNPK(SUnpkU16, &m->compInd, mBuf); +#endif /* LCAMT || ATM_BISUP */ + + RETVALUE(ROK); +} /* end of cmUnpkElmtHdr */ + + +/* +* +* Fun: cmUnpkTknU8 +* +* Desc: This function unpacks a token U8 +* +* Ret: ROK - ok +* +* Notes: None +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmUnpkTknU8 +( +TknU8 *tknU8, /* token U8 */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkTknU8(tknU8, mBuf) +TknU8 *tknU8; /* token U8 */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmUnpTknU8) + + /* Token Header */ + CMCHKUNPK(SUnpkU8, &tknU8->pres, mBuf); + + if (tknU8->pres) + { + /* Value */ + CMCHKUNPK(SUnpkU8, &tknU8->val, mBuf); + } + + RETVALUE(ROK); +} /* end of cmUnpkTknU8 */ + + +/* +* +* Fun: cmUnpkTknS8 +* +* Desc: This function unpacks a token S8 +* +* Ret: ROK - ok +* +* Notes: None +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmUnpkTknS8 +( +TknS8 *tknS8, /* token S8 */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkTknS8(tknS8, mBuf) +TknS8 *tknS8; /* token S8 */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmUnpTknS8) + + /* Token Header */ + CMCHKUNPK(SUnpkU8, &tknS8->pres, mBuf); + + if (tknS8->pres) + { + /* Value */ + CMCHKUNPK(SUnpkS8, &tknS8->val, mBuf); + } + + RETVALUE(ROK); +} /* end of cmUnpkTknS8 */ + + +/* +* +* Fun: cmUnpkTknU16 +* +* Desc: This function unpacks a token U16 +* +* Ret: ROK - ok +* +* Notes: None +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmUnpkTknU16 +( +TknU16 *tknU16, /* token U16 */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkTknU16(tknU16, mBuf) +TknU16 *tknU16; /* token U16 */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmUnpTknU16) + + /* Token Header */ + CMCHKUNPK(SUnpkU8, &tknU16->pres, mBuf); + + if (tknU16->pres) + { + /* Value */ + CMCHKUNPK(SUnpkU16, &tknU16->val, mBuf); + } + + RETVALUE(ROK); +} /* end of cmUnpkTknU16 */ + + +/* +* +* Fun: cmUnpkTknU32 +* +* Desc: This function unpacks a token U32 +* +* Ret: ROK - ok +* +* Notes: None +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmUnpkTknU32 +( +TknU32 *tknU32, /* token U32 */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkTknU32(tknU32, mBuf) +TknU32 *tknU32; /* token U32 */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmUnpTknU32) + + /* Token Header */ + CMCHKUNPK(SUnpkU8, &tknU32->pres, mBuf); + + if (tknU32->pres) + { + /* Value */ + CMCHKUNPK(SUnpkU32, &tknU32->val, mBuf); + } + + RETVALUE(ROK); +} /* end of cmUnpkTknU32 */ + +/* +* +* Fun: cmUnpkTknStr +* +* Desc: This function unpacks a token string - regular size +* +* Ret: ROK - ok +* +* Notes: None +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmUnpkTknStr +( +TknStr *tknStr, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkTknStr(tknStr, mBuf) +TknStr *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + Cntr i; /* counter */ + + TRC2(cmUnpTknStr) + + /* Token Header */ + CMCHKUNPK(SUnpkU8, &tknStr->pres, mBuf); + + if (tknStr->pres) + { + /* Length */ + CMCHKUNPK(SUnpkU8, &tknStr->len, mBuf); + + /* Value */ + for (i = (tknStr->len - 1); i >= 0; i--) + { + CMCHKUNPK(SUnpkU8, &tknStr->val[i], mBuf); + } + } + else + tknStr->len = 0; + + RETVALUE(ROK); +} /* end of cmUnpkTknStr */ + +/* +* +* Fun: cmUnpkTknStrM +* +* Desc: This function unpacks a token string - medium size +* +* Ret: ROK - ok +* +* Notes: None +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmUnpkTknStrM +( +TknStrM *tknStr, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkTknStrM(tknStr, mBuf) +TknStrM *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + Cntr i; /* counter */ + + TRC2(cmUnpTknStrM) + + /* Token Header */ + CMCHKUNPK(SUnpkU8, &tknStr->pres, mBuf); + + if (tknStr->pres) + { + /* Length */ + CMCHKUNPK(SUnpkU8, &tknStr->len, mBuf); + + /* Value */ + for (i = (tknStr->len - 1); i >= 0; i--) + { + CMCHKUNPK(SUnpkU8, &tknStr->val[i], mBuf); + } + } + else + tknStr->len = 0; + + RETVALUE(ROK); +} /* end of cmUnpkTknStrM */ + + +/* +* +* Fun: cmUnpkTknStrS +* +* Desc: This function unpacks a token string - small size +* +* Ret: ROK - ok +* +* Notes: None +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmUnpkTknStrS +( +TknStrS *tknStr, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkTknStrS(tknStr, mBuf) +TknStrS *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + Cntr i; /* counter */ + + TRC2(cmUnpTknStrS) + + /* Token Header */ + CMCHKUNPK(SUnpkU8, &tknStr->pres, mBuf); + + if (tknStr->pres) + { + /* Length */ + CMCHKUNPK(SUnpkU8, &tknStr->len, mBuf); + + /* Value */ + for (i = (tknStr->len - 1); i >= 0; i--) + { + CMCHKUNPK(SUnpkU8, &tknStr->val[i], mBuf); + } + } + else + tknStr->len = 0; + + RETVALUE(ROK); +} /* end of cmUnpkTknStrS */ + + +/* +* +* Fun: cmUnpkTknStrE +* +* Desc: This function unpacks a token string - extended size +* +* Ret: ROK - ok +* +* Notes: None +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmUnpkTknStrE +( +TknStrE *tknStr, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkTknStrE(tknStr, mBuf) +TknStrE *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + Cntr i; /* counter */ + + TRC2(cmUnpTknStrE) + + /* Token Header */ + CMCHKUNPK(SUnpkU8, &tknStr->pres, mBuf); + + if (tknStr->pres) + { + /* Length */ + CMCHKUNPK(SUnpkU8, &tknStr->len, mBuf); + + /* Value */ + for (i = (tknStr->len - 1); i >= 0; i--) + { + CMCHKUNPK(SUnpkU8, &tknStr->val[i], mBuf); + } + } + else + tknStr->len = 0; + + RETVALUE(ROK); +} /* end of cmUnpkTknStrE */ + +#ifndef CMFILE_REORG_1 + + +/* +* +* Fun: cmUnpkPnNodeId +* +* Desc: This function unpacks a PnNodeId structure from a buffer +* +* Ret: Void +* +* Notes: None +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmUnpkPnNodeId +( +PnNodeId *dst, /* source PNNI Node Id */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkPnNodeId (dst, mBuf) +PnNodeId *dst; /* source PNNI Node Id */ +Buffer *mBuf; /* message buffer */ +#endif +{ + S16 i; + + TRC3(cmUnpkPnNodeId); + + for (i = 0; i < PN_NODEID_LEN; i++) + { + CMCHKUNPK(SUnpkU8, &dst->id[i], mBuf); + } + + RETVALUE(ROK); +} /* cmUnpkPnNodeId */ + +#endif /* CMFILE_REORG_1 */ + + +/* + * + * Fun: cmUnpkTknStr4 + * + * Desc: This function packs a token string of size 4 + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_gen.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmUnpkTknStr4 +( +TknStr4 *tknStr, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkTknStr4(tknStr, mBuf) +TknStr4 *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmUnpkTknStr4) + + CMUNPKTKNSTR(tknStr, mBuf); + + RETVALUE(ROK); + +} /* end of cmUnpkTknStr4 */ + + + +/* + * + * Fun: cmUnpkTknStr12 + * + * Desc: This function packs a token string of size 4 + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_gen.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmUnpkTknStr12 +( +TknStr12 *tknStr, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkTknStr12(tknStr, mBuf) +TknStr12 *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmUnpkTknStr12) + + CMUNPKTKNSTR(tknStr, mBuf); + + RETVALUE(ROK); + +} /* end of cmUnpkTknStr12 */ + + +/* + * + * Fun: cmUnpkTknStr32 + * + * Desc: This function packs a token string of size 4 + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_gen.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmUnpkTknStr32 +( +TknStr32 *tknStr, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkTknStr32(tknStr, mBuf) +TknStr32 *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmUnpkTknStr32) + + CMUNPKTKNSTR(tknStr, mBuf); + + RETVALUE(ROK); + +} /* end of cmUnpkTknStr32 */ + + +/* + * + * Fun: cmUnpkTknStr64 + * + * Desc: This function packs a token string of size 4 + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_gen.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmUnpkTknStr64 +( +TknStr64 *tknStr, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkTknStr64(tknStr, mBuf) +TknStr64 *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmUnpkTknStr64) + + CMUNPKTKNSTR(tknStr, mBuf); + + RETVALUE(ROK); + +} /* end of cmUnpkTknStr64 */ + + +/* + * + * Fun: cmUnpkTknStr132 + * + * Desc: This function packs a token string of size 4 + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_gen.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmUnpkTknStr132 +( +TknStr132 *tknStr, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkTknStr132(tknStr, mBuf) +TknStr132 *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmUnpkTknStr132) + + CMUNPKTKNSTR(tknStr, mBuf); + + RETVALUE(ROK); + +} /* end of cmUnpkTknStr132 */ + + +/* + * + * Fun: cmUnpkTknStr256 + * + * Desc: This function packs a token string of size 4 + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_gen.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmUnpkTknStr256 +( +TknStr256 *tknStr, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkTknStr256(tknStr, mBuf) +TknStr256 *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmUnpkTknStr256) + + CMUNPKTKNSTR(tknStr, mBuf); + + RETVALUE(ROK); + +} /* end of cmUnpkTknStr256 */ + + +/* + * + * Fun: cmUnpkTknOid + * + * Desc: This function packs a Object Identifier token + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_gen.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmUnpkTknOid +( +TknOid *tknOid, /* Object Identifier token */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkTknOid(tknOid, mBuf) +TknOid *tknOid; /* Object Identifier token */ +Buffer *mBuf; /* message buffer */ +#endif +{ + U16 i; + + TRC2(cmUnpkTknOid) + + /* Unpack the token header */ + CMCHKUNPK(SUnpkU8, &tknOid->pres, mBuf); + + if (tknOid->pres == TRUE) + { + /* Unpack the length */ + CMCHKUNPK(SUnpkU8, &tknOid->len, mBuf); + + /* Pack the value */ + for (i = 1; i <= (U16)tknOid->len; i++) + { + /* cm_gen_c_001.main_33: changes for TknOid value from U16 to U32 + * with compilation flag TKNOID_U16 */ +#ifndef TKNOID_U16 + CMCHKUNPK(SUnpkU32, &tknOid->val[tknOid->len - i], mBuf); +#else + CMCHKUNPK(SUnpkU16, &tknOid->val[tknOid->len - i], mBuf); +#endif /* !TKNOID_U16 */ + } + } + + RETVALUE(ROK); +} /* end of cmUnpkTknOid */ + + +/* +* +* Fun: cmUnpkTknS32 +* +* Desc: This function unpacks a token S32 +* +* Ret: ROK - ok +* +* Notes: None +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmUnpkTknS32 +( +TknS32 *tknS32, /* token S32 */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkTknS32(tknS32, mBuf) +TknS32 *tknS32; /* token S32 */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmUnpTknS32) + + /* Token Header */ + CMCHKUNPK(SUnpkU8, &tknS32->pres, mBuf); + + if (tknS32->pres) + { + /* Value */ + CMCHKUNPK(SUnpkS32, &tknS32->val, mBuf); + } + + RETVALUE(ROK); +} /* end of cmUnpkTknS32 */ + + +/* +* +* Fun: cmUnpkHeader +* +* Desc: This function is used to Unpack Header structure +* +* Ret: ROK - ok +* +* Notes: None. +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmUnpkHeader +( +Header *header, /* header structure */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkHeader(header, mBuf) +Header *header; /* header structure */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmUnpHeader) + + CMCHKUNPK(SUnpkU16, &header->msgLen, mBuf); + CMCHKUNPK(SUnpkU8, &header->msgType, mBuf); + CMCHKUNPK(SUnpkU8, &header->version, mBuf); + CMCHKUNPK(SUnpkU16, &header->seqNmb, mBuf); + CMCHKUNPK(cmUnpkEntityId, &header->entId, mBuf); + CMCHKUNPK(cmUnpkElmntId, &header->elmId, mBuf); +#ifdef LMINT3 + CMCHKUNPK(cmUnpkTranId, &header->transId, mBuf); + CMCHKUNPK(cmUnpkSelector, &header->response.selector, mBuf); + CMCHKUNPK(cmUnpkPriority, &header->response.prior, mBuf); + CMCHKUNPK(cmUnpkRoute, &header->response.route, mBuf); + CMCHKUNPK(cmUnpkMemoryId, &header->response.mem, mBuf); +#endif /* LMINT3 */ + + RETVALUE(ROK); +} /* end of cmUnpkHeader */ + + +/* +* +* Fun: cmUnpkCmStatus +* +* Desc: This function unpacks common management status structure +* +* Ret: ROK - ok +* +* Notes: None. +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmUnpkCmStatus +( +CmStatus *sta, /* status structure */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkCmStatus(sta, mBuf) +CmStatus *sta; /* status structure */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmUnpkCmStatus) + + CMCHKUNPK(SUnpkU16, &sta->status, mBuf); + CMCHKUNPK(SUnpkU16, &sta->reason, mBuf); + + RETVALUE(ROK); +} /* end of cmUnpkCmStatus */ + + +/* +* +* Fun: cmUnpkCmAlarm +* +* Desc: This function unpacks common management alarm structure +* +* Ret: ROK - ok +* +* Notes: None. +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmUnpkCmAlarm +( +CmAlarm *alarm, /* alarm structure */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkCmAlarm(alarm, mBuf) +CmAlarm *alarm; /* alarm structure */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmUnpkCmAlarm) + + CMCHKUNPK(cmUnpkDateTime, &alarm->dt, mBuf); + CMCHKUNPK(SUnpkU16, &alarm->category, mBuf); + CMCHKUNPK(SUnpkU16, &alarm->event, mBuf); + CMCHKUNPK(SUnpkU16, &alarm->cause, mBuf); + + RETVALUE(ROK); +} /* end of cmUnpkCmAlarm */ + + +/* +* +* Fun: cmUnpkSmCfg +* +* Desc: This function unpacks the stack manager structure +* +* Ret: ROK - ok +* +* Notes: None. +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmUnpkSmCfg +( +SmCfg *smCfg, /* stack manager */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkSmCfg(smCfg, mBuf) +SmCfg *smCfg; /* stack manager */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmUnpSmCfg) + + CMCHKUNPK(cmUnpkEnt, &smCfg->ent, mBuf); + CMCHKUNPK(cmUnpkInst, &smCfg->inst, mBuf); + CMCHKUNPK(cmUnpkRegion, &smCfg->region, mBuf); + CMCHKUNPK(cmUnpkPool, &smCfg->pool, mBuf); + CMCHKUNPK(cmUnpkPrior, &smCfg->prior, mBuf); + CMCHKUNPK(cmUnpkRoute, &smCfg->route, mBuf); + CMCHKUNPK(cmUnpkSelector, &smCfg->selector, mBuf); + + RETVALUE(ROK); +} /* end of cmUnpkSmCfg */ + + +/* +* +* Fun: cmUnpkTmrCfg +* +* Desc: This function unpacks the timer configuration structure +* +* Ret: ROK - ok +* +* Notes: None. +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmUnpkTmrCfg +( +TmrCfg *tmrCfg, /* timer configuration */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkTmrCfg(tmrCfg, mBuf) +TmrCfg *tmrCfg; /* timer configuration */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmUnpTmrCfg) + + CMCHKUNPK(cmUnpkBool, &tmrCfg->enb, mBuf); + CMCHKUNPK(SUnpkU16, &tmrCfg->val, mBuf); + + RETVALUE(ROK); +} /* end of cmUnpkTmrCfg */ + +/* + * + * Fun: cmUnpkTknBuf + * + * Desc: This function unpacks a token buffer + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_gen.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmUnpkTknBuf +( +TknBuf *tknBuf, /* token string */ +Buffer **tBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkTknBuf(tknBuf, tBuf) +TknBuf *tknBuf; /* token string */ +Buffer **tBuf; /* message buffer */ +#endif +{ + Buffer *mBuf; + + + TRC2(cmUnpkTknBuf) + + mBuf = *tBuf; + + /* Token Header */ + CMCHKUNPK(SUnpkU8, &tknBuf->pres, mBuf); + + if(tknBuf->pres) + { + MsgLen msgLen, buflen; + Region region; /* region */ + Pool pool; /* pool */ + + cmUnpkMsgLen(&msgLen, mBuf); + SFndLenMsg(mBuf, &buflen); + if (buflen > msgLen) + { + if( SSegMsg(mBuf, msgLen, &tknBuf->val) != ROK ) + { + RETVALUE(RFAILED); + } + } + else + { + /* Allocate the buffer for tknbuf->val */ + SGetBufRegionPool(mBuf, ®ion, &pool); + SGetMsg(region, pool, &(tknBuf->val)); + } + + /* now Swap the two Buffer pointers */ + SSwapMsg(mBuf,tknBuf->val); + + } + + *tBuf = mBuf; + + RETVALUE(ROK); +} /* end of cmUnpkTknBuf */ + +#ifdef TDS_ROLL_UPGRADE_SUPPORT +/* +* +* Fun: cmUnpkIntf +* +* Desc: This function unpacks the interface information +* +* Ret: ROK - ok +* +* Notes: None. +* +* File: cm_gen.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmUnpkIntf +( +CmIntf *intf, /* interface info */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkIntf(intf, mBuf) +CmIntf *intf; /* interface info */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmUnpkIntf) + + CMCHKUNPK(cmUnpkIntfVer, &intf->intfVer, mBuf); + CMCHKUNPK(cmUnpkIntfId, &intf->intfId, mBuf); + + RETVALUE(ROK); +} /* end of cmUnpkIntf */ +#endif /* TDS_ROLL_UPGRADE_SUPPORT */ + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/cm/cm_gen.h b/src/cm/cm_gen.h new file mode 100644 index 000000000..9c7bfad0c --- /dev/null +++ b/src/cm/cm_gen.h @@ -0,0 +1,308 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/********************************************************************20** + + Name: common general functions + + Type: C include file + + Desc: Defines required by common functions. + Macros for packing and unpacking coomon scalar typedefs. + + File: cm_gen.h + + Sid: cm_gen.h@@/main/6 - Fri Sep 16 02:55:20 2005 + + Prg: nkk + +*********************************************************************21*/ + +#ifdef CMFILE_REORG_1 +#define __CMGENH__ +#endif + +#ifndef __CMGENH__ +#define __CMGENH__ + + +/* defines */ + +/* packing macros */ + +/* system services typedefs */ + +#define cmPkBool(x, mBuf) SPkU8(x, mBuf) /* pack Bool */ +#define cmPkStatus(x, mBuf) SPkS16(x, mBuf) /* pack Status */ +#define cmPkTicks(x, mBuf) SPkU32(x, mBuf) /* pack Ticks */ +#define cmPkQLen(x, mBuf) SPkS16(x, mBuf) /* pack QLen */ +#define cmPkOrder(x, mBuf) SPkS16(x, mBuf) /* pack Order */ +#define cmPkData(x, mBuf) SPkU8(x, mBuf) /* pack Data */ +#define cmPkRandom(x, mBuf) SPkU16(x, mBuf) /* pack Random */ +#define cmPkSeq(x, mBuf) SPkS16(x, mBuf) /* pack Seq */ +#define cmPkReason(x, mBuf) SPkS16(x, mBuf) /* pack Reason */ +#define cmPkProcId(x, mBuf) SPkU16(x, mBuf) /* pack ProcId */ +#define cmPkVectNmb(x, mBuf) SPkS16(x, mBuf) /* pack VectNmb */ +#define cmPkPrior(x, mBuf) SPkU8(x, mBuf) /* pack Prior*/ +#define cmPkPriority(x, mBuf) cmPkPrior(x, mBuf) /* pack Priority */ +#define cmPkRoute(x, mBuf) SPkU8(x, mBuf) /* pack Route */ +#define cmPkTtype(x, mBuf) SPkS16(x, mBuf) /* pack Ttype */ +#define cmPkSema(x, mBuf) SPkS8(x, mBuf) /* pack Sema */ +#define cmPkTxt(x, mBuf) SPkS8(x, mBuf) /* pack Txt */ +#define cmPkEnt(x, mBuf) SPkU8(x, mBuf) /* pack Ent */ +#define cmPkInst(x, mBuf) SPkU8(x, mBuf) /* pack Inst */ +#define cmPkElmnt(x, mBuf) SPkS16(x, mBuf) /* pack Elmnt */ +#define cmPkElmntInst1(x, mBuf) SPkS16(x, mBuf) /* pack ElmntInst1 */ +#define cmPkElmntInst2(x, mBuf) SPkS16(x, mBuf) /* pack ElmntInst2 */ +#define cmPkElmntInst3(x, mBuf) SPkS16(x, mBuf) /* pack ElmntInst3 */ +#define cmPkRegion(x, mBuf) SPkU8(x, mBuf) /* pack Region */ +#define cmPkPool(x, mBuf) SPkU8(x, mBuf) /* pack Pool */ +#ifdef LONG_MSG +#define cmPkMsgLen(x, mBuf) SPkS32(x, mBuf) /* pack MsgLen */ +#else +#define cmPkMsgLen(x, mBuf) SPkS16(x, mBuf) /* pack MsgLen */ +#endif +#ifdef DOS +#define cmPkSize(x, mBuf) SPkU16(x, mBuf) /* pack Size */ +#else +#define cmPkSize(x, mBuf) SPkU32(x, mBuf) /* pack Size */ +#endif /* DOS */ + +/* general typedefs */ + +#define cmPkSelector(x, mBuf) SPkU8(x, mBuf) /* pack Selector */ +#define cmPkEvent(x, mBuf) SPkU8(x, mBuf) /* pack Event */ +#define cmPkCntr(x, mBuf) SPkS32(x, mBuf) /* pack Cntr */ +#define cmPkStsCntr(x, mBuf) SPkU32(x, mBuf) /* pack StsCntr */ +#define cmPkLnkNmb(x, mBuf) SPkS16(x, mBuf) /* pack LnkNmb */ +#define cmPkSuId(x, mBuf) SPkS16(x, mBuf) /* pack SuId */ +#define cmPkSpId(x, mBuf) SPkS16(x, mBuf) /* pack SpId */ +#define cmPkSuInstId(x, mBuf) SPkS16(x, mBuf) /* pack SuInstId */ +#define cmPkSpInstInd(x, mBuf) SPkS16(x, mBuf) /* pack SpInstInd */ +#define cmPkSapi(x, mBuf) SPkU8(x, mBuf) /* pack Sapi */ +#define cmPkTei(x, mBuf) SPkU8(x, mBuf) /* pack Tei */ +#define cmPkCes(x, mBuf) SPkU8(x, mBuf) /* pack Ces */ +#define cmPkDlci(x, mBuf) SPkU32(x, mBuf) /* pack Dlci */ +#define cmPkCalRef(x, mBuf) SPkU16(x, mBuf) /* pack CalRef */ +#define cmPkOrigin(x, mBuf) SPkS16(x, mBuf) /* pack Origin */ +#define cmPkSwtch(x, mBuf) SPkS16(x, mBuf) /* pack Swtch */ +#define cmPkCause(x, mBuf) SPkU8(x, mBuf) /* pack Cause */ +#define cmPkDgn(x, mBuf) SPkU8(x, mBuf) /* pack Dgn */ +#define cmPkAction(x, mBuf) SPkS16(x, mBuf) /* pack Action */ +#define cmPkSeqS16(x, mBuf) SPkS16(x, mBuf) /* pack SeqS16 */ +#define cmPkSeqU16(x, mBuf) SPkU16(x, mBuf) /* pack SeqU16 */ +#define cmPkSeqS24(x, mBuf) SPkS32(x, mBuf) /* pack SeqS24 */ +#define cmPkSeqU24(x, mBuf) SPkU32(x, mBuf) /* pack SeqU24 */ +#define cmPkSetUpArb(x, mBuf) SPkU8(x, mBuf) /* pack SetUpArb */ +#define cmPkEvntType(x, mBuf) SPkU8(x, mBuf) /* pack EvntType */ +#define cmPkState(x, mBuf) SPkU8(x, mBuf) /* pack State */ +#define cmPkMode(x, mBuf) SPkU8(x, mBuf) /* pack Mode */ +#define cmPkConnId(x, mBuf) SPkS32(x, mBuf) /* pack ConnId */ + +/* scc specific typedefs */ + +#define cmPkBaud(x, mBuf) SPkS16(x, mBuf) /* pack Baud */ +#define cmPkPhysIntType(x, mBuf) SPkS16(x, mBuf) /* pack PhysIntType */ +#define cmPkPathConnType(x, mBuf) SPkS16(x, mBuf) /* pack PathConnType */ +#define cmPkParity(x, mBuf) SPkS16(x, mBuf) /* pack Parity */ +#define cmPkCharLength(x, mBuf) SPkS16(x, mBuf) /* pack CharLength */ +#define cmPkStopBits(x, mBuf) SPkS16(x, mBuf) /* pack StopBits */ + +/* tcp/ip specific typedefs */ + +#define cmPkIpAddr(x, mBuf) SPkU32(x, mBuf) /* pack IpAddr */ +#define cmPkPort(x, mBuf) SPkU16(x, mBuf) /* pack Port */ +#define cmPkCmd(x, mBuf) SPkU8(x, mBuf) /* pack Cmd */ +#define cmPkFlags(x, mBuf) SPkU8(x, mBuf) /* pack Flags */ +#define cmPkTtl(x, mBuf) SPkU8(x, mBuf) /* pack Ttl */ +#define cmPkPrec(x, mBuf) SPkU8(x, mBuf) /* pack Prec */ +#define cmPkWindow(x, mBuf) SPkU32(x, mBuf) /* pack Window */ + +/* ISUP specific typedefs */ + +#define cmPkCirId(x, mBuf) SPkU16(x, mBuf) /* pack CirId */ +#define cmPkCic(x, mBuf) SPkU16(x, mBuf) /* pack Cic */ +#define cmPkSiInstId(x, mBuf) SPkU32(x, mBuf) /* pack SiInstId */ + +/* TUP specific typedefs */ + +#define cmPkTpInstId(x, mBuf) SPkU32(x, mBuf) /* pack TpInstId */ + +/* PNNI specific typedefs */ +#define cmPkPnPortId(x, mBuf) SPkU32(x, mBuf) + + +/* unpacking macros */ + +/* system services typedefs */ + +#define cmUnpkBool(x, mBuf) SUnpkU8(x, mBuf) /* unpack Bool */ +#define cmUnpkStatus(x, mBuf) SUnpkS16(x, mBuf) /* unpack Status */ +#define cmUnpkTicks(x, mBuf) SUnpkU32(x, mBuf) /* unpack Ticks */ +#define cmUnpkQLen(x, mBuf) SUnpkS16(x, mBuf) /* unpack QLen */ +#define cmUnpkOrder(x, mBuf) SUnpkS16(x, mBuf) /* unpack Order */ +#define cmUnpkData(x, mBuf) SUnpkU8(x, mBuf) /* unpack Data */ +#define cmUnpkRandom(x, mBuf) SUnpkU16(x, mBuf) /* unpack Random */ +#define cmUnpkSeq(x, mBuf) SUnpkS16(x, mBuf) /* unpack Seq */ +#define cmUnpkReason(x, mBuf) SUnpkS16(x, mBuf) /* unpack Reason */ +#define cmUnpkProcId(x, mBuf) SUnpkU16(x, mBuf) /* unpack ProcId */ +#define cmUnpkVectNmb(x, mBuf) SUnpkS16(x, mBuf) /* unpack VectNmb */ +#define cmUnpkPrior(x, mBuf) SUnpkU8(x, mBuf) /* unpack Prior */ +#define cmUnpkPriority(x, mBuf) cmUnpkPrior(x, mBuf) /* unpack Priority */ +#define cmUnpkRoute(x, mBuf) SUnpkU8(x, mBuf) /* unpack Route */ +#define cmUnpkTtype(x, mBuf) SUnpkS16(x, mBuf) /* unpack Ttype */ +#define cmUnpkSema(x, mBuf) SUnpkS8(x, mBuf) /* unpack Sema */ +#define cmUnpkTxt(x, mBuf) SUnpkS8(x, mBuf) /* unpack Txt */ +#define cmUnpkEnt(x, mBuf) SUnpkU8(x, mBuf) /* unpack Ent */ +#define cmUnpkInst(x, mBuf) SUnpkU8(x, mBuf) /* unpack Inst */ +#define cmUnpkElmnt(x, mBuf) SUnpkS16(x, mBuf) /* unpack Elmnt */ +#define cmUnpkElmntInst1(x, mBuf) SUnpkS16(x, mBuf) /* unpack ElmntInst1 */ +#define cmUnpkElmntInst2(x, mBuf) SUnpkS16(x, mBuf) /* unpack ElmntInst2 */ +#define cmUnpkElmntInst3(x, mBuf) SUnpkS16(x, mBuf) /* unpack ElmntInst3 */ +#define cmUnpkRegion(x, mBuf) SUnpkU8(x, mBuf) /* unpack Region */ +#define cmUnpkPool(x, mBuf) SUnpkU8(x, mBuf) /* unpack Pool */ +#ifdef LONG_MSG +#define cmUnpkMsgLen(x, mBuf) SUnpkS32(x, mBuf) /* unpack MsgLen */ +#else +#define cmUnpkMsgLen(x, mBuf) SUnpkS16(x, mBuf) /* unpack MsgLen */ +#endif +#ifdef DOS +#define cmUnpkSize(x, mBuf) SUnpkU16(x, mBuf) /* unpack Size */ +#else +#define cmUnpkSize(x, mBuf) SUnpkU32(x, mBuf) /* unpack Size */ +#endif /* DOS */ + +/* general typedefs */ + +#define cmUnpkSelector(x, mBuf) SUnpkU8(x, mBuf) /* unpack Selector */ +#define cmUnpkEvent(x, mBuf) SUnpkU8(x, mBuf) /* unpack Event */ +#define cmUnpkCntr(x, mBuf) SUnpkS32(x, mBuf) /* unpack Cntr */ +#define cmUnpkStsCntr(x, mBuf) SUnpkU32(x, mBuf) /* unpack StsCntr */ +#define cmUnpkLnkNmb(x, mBuf) SUnpkS16(x, mBuf) /* unpack LnkNmb */ +#define cmUnpkSuId(x, mBuf) SUnpkS16(x, mBuf) /* unpack SuId */ +#define cmUnpkSpId(x, mBuf) SUnpkS16(x, mBuf) /* unpack SpId */ +#define cmUnpkSuInstId(x, mBuf) SUnpkS16(x, mBuf) /* unpack SuInstId */ +#define cmUnpkSpInstInd(x, mBuf) SUnpkS16(x, mBuf) /* unpack SpInstInd */ +#define cmUnpkSapi(x, mBuf) SUnpkU8(x, mBuf) /* unpack Sapi */ +#define cmUnpkTei(x, mBuf) SUnpkU8(x, mBuf) /* unpack Tei */ +#define cmUnpkCes(x, mBuf) SUnpkU8(x, mBuf) /* unpack Ces */ +#define cmUnpkDlci(x, mBuf) SUnpkU32(x, mBuf) /* unpack Dlci */ +#define cmUnpkCalRef(x, mBuf) SUnpkU16(x, mBuf) /* unpack CalRef */ +#define cmUnpkOrigin(x, mBuf) SUnpkS16(x, mBuf) /* unpack Origin */ +#define cmUnpkSwtch(x, mBuf) SUnpkS16(x, mBuf) /* unpack Swtch */ +#define cmUnpkCause(x, mBuf) SUnpkU8(x, mBuf) /* unpack Cause */ +#define cmUnpkDgn(x, mBuf) SUnpkU8(x, mBuf) /* unpack Dgn */ +#define cmUnpkAction(x, mBuf) SUnpkS16(x, mBuf) /* unpack Action */ +#define cmUnpkSeqS16(x, mBuf) SUnpkS16(x, mBuf) /* unpack SeqS16 */ +#define cmUnpkSeqU16(x, mBuf) SUnpkU16(x, mBuf) /* unpack SeqU16 */ +#define cmUnpkSeqS24(x, mBuf) SUnpkS32(x, mBuf) /* unpack SeqS24 */ +#define cmUnpkSeqU24(x, mBuf) SUnpkU32(x, mBuf) /* unpack SeqU24 */ +#define cmUnpkSetUpArb(x, mBuf) SUnpkU8(x, mBuf) /* unpack SetUpArb */ +#define cmUnpkEvntType(x, mBuf) SUnpkU8(x, mBuf) /* unpack EvntType */ +#define cmUnpkState(x, mBuf) SUnpkU8(x, mBuf) /* unpack State */ +#define cmUnpkMode(x, mBuf) SUnpkU8(x, mBuf) /* unpack Mode */ +#define cmUnpkConnId(x, mBuf) SUnpkS32(x, mBuf) /* unpack ConnId */ + +/* scc specific typedefs */ + +#define cmUnpkBaud(x, mBuf) SUnpkS16(x, mBuf) /* unpack Baud */ +#define cmUnpkPhysIntType(x, mBuf) SUnpkS16(x, mBuf) /* unpack PhysIntType */ +#define cmUnpkPathConnType(x, mBuf) SUnpkS16(x, mBuf) /* unpack PathConnType */ +#define cmUnpkParity(x, mBuf) SUnpkS16(x, mBuf) /* unpack Parity */ +#define cmUnpkCharLength(x, mBuf) SUnpkS16(x, mBuf) /* unpack CharLength */ +#define cmUnpkStopBits(x, mBuf) SUnpkS16(x, mBuf) /* unpack StopBits */ + +/* tcp/ip specific typedefs */ + +#define cmUnpkIpAddr(x, mBuf) SUnpkU32(x, mBuf) /* unpack IpAddr */ +#define cmUnpkPort(x, mBuf) SUnpkU16(x, mBuf) /* unpack Port */ +#define cmUnpkCmd(x, mBuf) SUnpkU8(x, mBuf) /* unpack Cmd */ +#define cmUnpkFlags(x, mBuf) SUnpkU8(x, mBuf) /* unpack Flags */ +#define cmUnpkTtl(x, mBuf) SUnpkU8(x, mBuf) /* unpack Ttl */ +#define cmUnpkPrec(x, mBuf) SUnpkU8(x, mBuf) /* unpack Prec */ +#define cmUnpkWindow(x, mBuf) SUnpkU32(x, mBuf) /* unpack Window */ + +/* ISUP specific typedefs */ + +#define cmUnpkCirId(x, mBuf) SUnpkU16(x, mBuf) /* unpack CirId */ +#define cmUnpkCic(x, mBuf) SUnpkU16(x, mBuf) /* unpack Cic */ +#define cmUnpkSiInstId(x, mBuf) SUnpkU32(x, mBuf) /* unpack SiInstId */ + +/* TUP specific typedefs */ + +#define cmUnpkTpInstId(x, mBuf) SUnpkU32(x, mBuf) /* unpack TpInstId */ + +/* PNNI specific typedefs */ +#define cmUnpkPnPortId(x, mBuf) SUnpkU32(x, mBuf) +#define cmCmpPnNodeId(nodeId1, nodeId2) \ + cmCmpStr(&(nodeId1)->id[0], PN_NODEID_LEN, \ + &(nodeId2)->id[0], PN_NODEID_LEN) + +/* PLOA - HCC profileId */ +#define cmPkProfileId(x, mBuf) SPkU8(x, mBuf) /* pack ProfileId */ + +#define cmUnpkProfileId(x, mBuf) SUnpkU8(x, mBuf) /* unpack ProfileId */ + +/* packing and unpacking for token strings */ + +#define CMPKTKNSTR(tknStr, mBuf) \ +{ \ + Cntr i; \ + \ + if(tknStr->pres) \ + { \ + /* Value */ \ + for (i = 0; i < (S16) tknStr->len; i++) \ + { \ + CMCHKPK(SPkU8, tknStr->val[i], mBuf); \ + } \ + \ + /* Length */ \ + CMCHKPK(SPkU8, tknStr->len, mBuf); \ + } \ + \ + /* Token Header */ \ + CMCHKPK(SPkU8, tknStr->pres, mBuf); \ +} + +#define CMUNPKTKNSTR(tknStr, mBuf) \ +{ \ + Cntr i; \ + \ + /* Token Header */ \ + CMCHKUNPK(SUnpkU8, &tknStr->pres, mBuf); \ + \ + if(tknStr->pres) \ + { \ + /* Length */ \ + CMCHKUNPK(SUnpkU8, &tknStr->len, mBuf); \ + \ + /* Value */ \ + for (i = 1; i <= (S16) tknStr->len; i++) \ + { \ + CMCHKUNPK(SUnpkU8, &tknStr->val[tknStr->len - i], mBuf); \ + } \ + } \ + \ +} + +#endif /* __CMGENH__ */ + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/cm/cm_hash.c b/src/cm/cm_hash.c new file mode 100644 index 000000000..cd0427979 --- /dev/null +++ b/src/cm/cm_hash.c @@ -0,0 +1,1763 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/********************************************************************20** + + Name: common hash functions + + Type: C source file + + Desc: Hashing functions used by various layers. + (Newer version of functions in cm_bdy1) + + Using hash lists in a product: + ------------------------------ + + Wherever a hash list is needed, a corresponding hash list + control point (CmHashListCp) should be declared. The structure + definition of the entries that belong to the hash list must + include a declaration of the hash list entry header + (CmHashListEnt) along with the key for the hash list (this + may be any scalar or structure type subfield of the entry). + For example, we need a hash list in a SAP to maintain a table + of addresses: + + typedef struct xySAPCb (SAP control block) + { + ... + CmHashListCp addrHlCp; (hash list for addresses) + ... + } XySAPCb; + + typedef struct xyAddrEnt (hash list entry for an address) + { + ... + CmHashListEnt hl; (hash list entry header) + ... + XyAddr addr; (hash list key) + ... + } XyAddrEnt; + + Functions available: + -------------------- + + The functions available for using hash lists are defined + below. The accompanying comments explain the usage in detail. + + Implementation details: + ----------------------- + + A hash list is identified by its control point + (CmHashListCp). This control point stores the characteristics + of the hash list as well as a pointer to the hash list bins. + The storage for the bins is allocated when the hash list is + initialized. Each bin is organized as a doubly linked list of + entries whose key maps to this bin. The hash function used to + map keys to a bin simply adds up all the octets of the key + and then divides the sum by the number of bins. Variable size + keys are allowed. Duplicate keys may be present if explicitly + allowed; if so, they can be retrieved by supplying a sequence + number in the find routine. A given structure may be attached + to more than one hash list if it contains multiple hash list + entry header fields. + + File: cm_hash.c + +*********************************************************************21*/ + + +/* header include files -- defines (.h) */ + +#include "envopt.h" /* environment options */ +#include "envdep.h" /* environment dependent */ +#include "envind.h" /* environment independent */ + +#include "gen.h" /* general */ +#include "ssi.h" /* system services */ +#include "cm_hash.h" /* common hash functions */ +#include "cm_err.h" /* common functions error */ + +/* header include -- typedef structs (.x) */ + +#include "gen.x" /* general */ +#include "ssi.x" /* system services */ +#include "cm_lib.x" /* common library functions */ +#include "cm_hash.x" /* common hash functions */ + + +/* local defines */ + +/* local externs */ + +/* forward references */ +/* cm_hash_c_001.main_22: Fixing warnings on GCC compiler */ +#ifdef __cplusplus + extern "C" { +#endif + +PRIVATE S16 cmHashFuncBCD8 ARGS((CmHashListCp *hashListCp, U8 *key, + U16 keyLen, U16 *idx)); + +PRIVATE S16 cmHashFuncConId ARGS((CmHashListCp *hashListCp, U8 *key, + U16 keyLen, U16 *idx)); + +PRIVATE S16 cmHashFuncU32Mod ARGS((CmHashListCp *hashListCp, U8 *key, + U16 keyLen, U16 *idx)); + +PRIVATE S16 cmHashFuncString ARGS((CmHashListCp *hashListCp, U8 *key, + U16 keyLen, U16 *idx)); + +PRIVATE S16 cmHashFuncDefault ARGS((CmHashListCp *hashListCp, U8 *key, + U16 keyLen, U16 *idx)); + +PRIVATE S16 cmHashFuncAnyKey ARGS((CmHashListCp *hashListCp, U8 *key, + U16 keyLen, U16 *idx)); + +PRIVATE S16 cmHashMatchKey ARGS((U8 *key1, U16 keyLen1, U8 *key2, U16 keyLen2)); + +PRIVATE S16 cmListInsert ARGS((CmListEnt *oldEntry, CmListEnt *newEntry)); + +PRIVATE S16 cmListDelete ARGS((CmListEnt *entry)); + +/* cm_hash_c_001.main_22: Fixing warnings on GCC compiler */ +PRIVATE S16 cmHashFuncMult24 ARGS((CmHashListCp *hashListCp, U8 *key, U16 keyLen, U16 *idx)); + +PRIVATE S16 cmHashFuncDirIdx ARGS((CmHashListCp *hashListCp, U8 *key, U16 keyLen, U16 *idx)); + +#ifdef __cplusplus + } +#endif + +/* functions in other modules */ + +/* public variable declarations */ + +/* private variable declarations */ + + +/* + * private support functions + */ + +/* +* +* Fun: cmHashFuncAnyKey +* +* Desc: Computes the hash list index (bin number) for a specified +* key of type CM_HASH_KEYTYPE_ANY. +* +* return index to hash table +* +* Ret: ROK - successful, *idx contains computed index +* +* Notes: None. +* +* File: cm_hash.c +* +*/ + +#ifdef ANSI +PRIVATE S16 cmHashFuncAnyKey +( +CmHashListCp *hashListCp, /* hash list control point */ +U8 *key, /* key string */ +U16 keyLen, /* length of key string */ +U16 *idx /* idx to return */ +) +#else +PRIVATE S16 cmHashFuncAnyKey (hashListCp, key, keyLen, idx) +CmHashListCp *hashListCp; /* hash list control point */ +U8 *key; /* key string */ +U16 keyLen; /* length of key string */ +U16 *idx; /* idx to return */ +#endif +{ + U32 a; /* hash variables */ + U32 b; /* hash variables */ + U32 c; /* hash variables */ + U32 len; /* length */ + + /*cm_hash_c_001.main_23 : Fix for TRACE5 feature crash due to missing TRC MACRO*/ + TRC2(cmHashFuncAnyKey); + /* Set up the internal state */ + len = keyLen; /* key length */ + a = 0x9e3779b9; /* a = b = the golden ratio; an arbitrary value */ + b = 0x9e3779b9; + c = 0x12345678; /* some value */ + + /*---------------------------------------- handle most of the key */ + while (len >= 12) + { + a += (key[0] +((U32)key[1]<<8) +((U32)key[2]<<16) +((U32)key[3]<<24)); + b += (key[4] +((U32)key[5]<<8) +((U32)key[6]<<16) +((U32)key[7]<<24)); + c += (key[8] +((U32)key[9]<<8) +((U32)key[10]<<16)+((U32)key[11]<<24)); + CM_HASH_MIX(a, b, c); + key += 12; len -= 12; + } + + /*------------------------------------- handle the last 11 bytes */ + c += keyLen; + switch(len) /* all the case statements fall through */ + { + case 11: c+=((U32)key[10]<<24); + case 10: c+=((U32)key[9]<<16); + case 9 : c+=((U32)key[8]<<8); + /* the first byte of c is reserved for the keyLen */ + case 8 : b+=((U32)key[7]<<24); + case 7 : b+=((U32)key[6]<<16); + case 6 : b+=((U32)key[5]<<8); + case 5 : b+=key[4]; + case 4 : a+=((U32)key[3]<<24); + case 3 : a+=((U32)key[2]<<16); + case 2 : a+=((U32)key[1]<<8); + case 1 : a+=key[0]; + /* case 0: nothing left to add */ + } + CM_HASH_MIX(a,b,c); + /*-------------------------------------------- report the result */ + + /* if nmbBins is a power of 2, use shift, else use division */ + if (hashListCp->binBitMask != CM_HASH_NOBITMASK) + *idx = (U16) (c & hashListCp->binBitMask); + else + *idx = (U16) (c % hashListCp->nmbBins); + + RETVALUE(ROK); +} /* end of cmHashFuncAnyKey */ + + +/* +* +* Fun: cmHashFuncU32Mod +* +* Desc: Computes the hash list index (bin number) for a specified +* key of type CM_HASH_KEYTYPE_MOD. +* +* return (idx % hash_table_size); +* +* Ret: ROK - successful, *idx contains computed index +* +* Notes: None. +* +* File: cm_hash.c +* +*/ + +#ifdef ANSI +PRIVATE S16 cmHashFuncU32Mod +( +CmHashListCp *hashListCp, /* hash list control point */ +U8 *key, /* key string */ +U16 keyLen, /* length of key string */ +U16 *idx /* idx to return */ +) +#else +PRIVATE S16 cmHashFuncU32Mod (hashListCp, key, keyLen, idx) +CmHashListCp *hashListCp; /* hash list control point */ +U8 *key; /* key string */ +U16 keyLen; /* length of key string */ +U16 *idx; /* idx to return */ +#endif +{ + U32 sum; /* Sum of octets for hash function */ + + TRC2(cmHashFuncU32Mod); + + /* keyLen is marked Unused to remove compilation + * warnings. */ + UNUSED(keyLen); + + sum = *((U32 *)key); + + /* if nmbBins is a power of 2, use shift, else use division */ + if (hashListCp->binBitMask != CM_HASH_NOBITMASK) + *idx = (U16) (sum & hashListCp->binBitMask); + else + *idx = (U16) (sum % hashListCp->nmbBins); + + RETVALUE(ROK); + +} /* end of cmHashFuncU32Mod () */ + +/* +* +* Fun: cmHashFuncBCD8 +* +* Desc: Computes the hash list index (bin number) for a specified +* key of type CM_HASH_KEYTYPE_BCD8. +* +* Steps: +* 1. Converts the 8 BCD coded octets into 2 U32s +* 2. Adds 2 U32s to get one U32. +* 3. Apply U32Mod technique to get the index +* 4. Return the index +* +* Note: +* Here we are no bothered if the keyLen is more than 8. +* We are interested only in the first 8 octets. +* +* Ret: ROK - successful, *idx contains computed index +* +* Notes: None. +* +* File: cm_hash.c +* +*/ + +#ifdef ANSI +PRIVATE S16 cmHashFuncBCD8 +( +CmHashListCp *hashListCp, /* hash list control point */ +U8 *key, /* key string */ +U16 keyLen, /* length of key string */ +U16 *idx /* idx to return */ +) +#else +PRIVATE S16 cmHashFuncBCD8 (hashListCp, key, keyLen, idx) +CmHashListCp *hashListCp; /* hash list control point */ +U8 *key; /* key string */ +U16 keyLen; /* length of key string */ +U16 *idx; /* idx to return */ +#endif +{ + U16 tmp16 = 0; + U32 firstU32 = 0; /* First U32 prepared for lower 4 octets */ + U32 secondU32 = 0; /* Second U32 prepared for higher 4 octets */ + U32 sum; /* Sum of the above 2 octets to get the index */ + + TRC2(cmHashFuncBCD8); + + /* keyLen is marked Unused to remove compilation + * warnings. */ + UNUSED(keyLen); + + /* Compute second U32 */ + tmp16 = (U16) PutHiByte(tmp16, (U8) key[0]); + tmp16 = (U16) PutLoByte(tmp16, (U8) key[1]); + secondU32 = (U32) PutHiWord(secondU32, (U16) tmp16); + tmp16 = (U16) PutHiByte(tmp16, (U8) key[2]); + tmp16 = (U16) PutLoByte(tmp16, (U8) key[3]); + secondU32 = (U32) PutLoWord(secondU32, (U16) tmp16); + + + /* Compute first U32 */ + tmp16 = (U16) PutHiByte(tmp16, (U8) key[4]); + tmp16 = (U16) PutLoByte(tmp16, (U8) key[5]); + firstU32 = (U32) PutHiWord(firstU32, (U16) tmp16); + tmp16 = (U16) PutHiByte(tmp16, (U8) key[6]); + tmp16 = (U16) PutLoByte(tmp16, (U8) key[7]); + firstU32 = (U32) PutLoWord(firstU32, (U16) tmp16); + + sum = firstU32 + secondU32; + + /* if nmbBins is a power of 2, use shift, else use division */ + if (hashListCp->binBitMask != CM_HASH_NOBITMASK) + *idx = (U16) (sum & hashListCp->binBitMask); + else + *idx = (U16) (sum % hashListCp->nmbBins); + + RETVALUE(ROK); +} /* end of cmHashFuncBCD8 () */ + +/* +* +* Fun: cmHashFuncString +* +* Desc: Computes the hash list index (bin number) for a specified +* key of type CM_HASH_KEYTYPE_STR. +* +* for (length of string) +* idx = (31 * idx) + *string; +* +* return (idx % hash_table_size); +* +* Ret: ROK - successful, *idx contains computed index +* +* Notes: None. +* +* File: cm_hash.c +* +*/ + +#ifdef ANSI +PRIVATE S16 cmHashFuncString +( +CmHashListCp *hashListCp, /* hash list control point */ +U8 *key, /* key string */ +U16 keyLen, /* length of key string */ +U16 *idx /* idx to return */ +) +#else +PRIVATE S16 cmHashFuncString (hashListCp, key, keyLen, idx) +CmHashListCp *hashListCp; /* hash list control point */ +U8 *key; /* key string */ +U16 keyLen; /* length of key string */ +U16 *idx; /* idx to return */ +#endif +{ + U16 cntr; /* Index */ + U32 sum; /* Sum of octets for hash function */ + + TRC2(cmHashFuncString) + + sum = 0; + + for (cntr = 0; cntr < keyLen; cntr++) + { + sum = (CM_STR_HASHFUNC_CONSTANT * sum) + key[cntr]; + } + + /* if nmbBins is a power of 2, use shift, else use division */ + if (hashListCp->binBitMask != CM_HASH_NOBITMASK) + *idx = (U16) (sum & hashListCp->binBitMask); + else + *idx = (U16) (sum % hashListCp->nmbBins); + + RETVALUE(ROK); + +} /* end of cmHashFuncString () */ + + + +/* +* +* Fun: cmHashFuncDefault +* +* Desc: Computes the hash list index (bin number) for a specified +* key of type CM_HASH_KEYTYPE_DEF. +* +* Adds up all the octets of the key string +* and divides the sum by the range to get the desired index. +* +* Ret: ROK - successful, *idx contains computed index +* +* Notes: None. +* +* File: cm_hash.c +* +*/ + +#ifdef ANSI +PRIVATE S16 cmHashFuncDefault +( +CmHashListCp *hashListCp, /* hash list control point */ +U8 *key, /* key string */ +U16 keyLen, /* length of key string */ +U16 *idx /* index to return */ +) +#else +PRIVATE S16 cmHashFuncDefault(hashListCp, key, keyLen, idx) +CmHashListCp *hashListCp; /* hash list control point */ +U8 *key; /* key string */ +U16 keyLen; /* length of key string */ +U16 *idx; /* index to return */ +#endif +{ + U32 sum; /* sum of key string octets */ + + TRC2(cmHashFuncDefault); + + /* add all bytes of the key */ + sum = 0; + while (keyLen--) + sum += (U32) (*key++); + + /* compute index by dividing the range into the sum */ + + /* if nmbBins is a power of 2, use shift, else use division */ + if (hashListCp->binBitMask != CM_HASH_NOBITMASK) + *idx = (U16) (sum & hashListCp->binBitMask); + else + *idx = (U16) (sum % hashListCp->nmbBins); + + RETVALUE(ROK); + +} /* end of cmHashFuncDefault */ + + +/* +* +* Fun: cmHashFuncMult24 +* +* Desc: Computes the hash list index (bin number) for a specified +* key of type CM_HASH_KEYTYPE_MULT24. +* +* Multiplies the given key (max k bits) with a constant +* multiplier and extracts p bits of the result, from the +* bit position k-1 to bit position k-p, to get the hash +* list index. p is such that 2^p is number of bins. +* +* The constant multiplier is the floor of A * 2^k, for +* some constant A. +* +* This function uses a pre-computed constant multiplier +* CM_HASH_MULTMETHOD_CNST24, which is computed for +* A = (sqrt(5) - 1)/2, and k = 24 bits. +* +* This hashing method is explained in section 12.3.2 of +* "Introduction to Algorithms" by Thomas H. Cormen et al., +* The MIT Press. +* +* Ret: ROK - successful, *idx contains computed index +* +* Notes: None. +* +* File: cm_hash.c +* +*/ + +#ifdef ANSI +PRIVATE S16 cmHashFuncMult24 +( +CmHashListCp *hashListCp, /* hash list control point */ +U8 *key, /* key string */ +U16 keyLen, /* length of key string */ +U16 *idx /* index to return */ +) +#else +PRIVATE S16 cmHashFuncMult24(hashListCp, key, keyLen, idx) +CmHashListCp *hashListCp; /* hash list control point */ +U8 *key; /* key string */ +U16 keyLen; /* length of key string */ +U16 *idx; /* index to return */ +#endif +{ + U32 prod; /* (constant multiplier * key) */ + U8 shift; /* Bits to be shifted to get index */ + + TRC2(cmHashFuncMult24); + + UNUSED(keyLen); + +#if (ERRCLASS & ERRCLS_DEBUG) + /* error check on parameters */ + if (hashListCp->binBitMask == CM_HASH_NOBITMASK) + RETVALUE(RFAILED); +#endif + + prod = CM_HASH_MULT24_CONST * *((U32 *)key); + + shift = CM_HASH_MULT24_BITPOS - hashListCp->nmbBinBits; + *idx = ((U16) (prod & (hashListCp->binBitMask << shift))) >> shift; + + RETVALUE(ROK); +} /* end of cmHashFuncMult24 */ + + + + +/* +* +* Fun: cmHashFuncConId +* +* Desc: Computes the hash list index (bin number) for a specified +* key of type CM_HASH_KEYTYPE_CONID. +* +* This function can be used for keys that are an integer whose +* size is U8, U16 or U32. Instead of adding all octets of the key, +* this fn computes the "index" of the bin in which the entry +* needs to be inserted by taking a modulo of the integer with the +* total number of bins. +* This function is typically suitable for a sequentially increasing +* number like suConnId/spConnId +* +* Ret: ROK - successful, *idx contains computed index +* +* Notes: None. +* +* File: cm_hash.c +* +*/ + +#ifdef ANSI +PRIVATE S16 cmHashFuncConId +( +CmHashListCp *hashListCp, /* hash list control point */ +U8 *key, /* key string */ +U16 keyLen, /* length of key string */ +U16 *idx /* index to return */ +) +#else +PRIVATE S16 cmHashFuncConId(hashListCp, key, keyLen, idx) +CmHashListCp *hashListCp; /* hash list control point */ +U8 *key; /* key string */ +U16 keyLen; /* length of key string */ +U16 *idx; /* index to return */ +#endif +{ + + TRC2(cmHashFuncConId); + + /* switch based on the length of the key */ + switch (keyLen) + { + case CM_HASHKEYLEN_U32: + if (hashListCp->binBitMask != CM_HASH_NOBITMASK) + *idx = (U16) (((U32) *((U32 *)key)) & hashListCp->binBitMask); + else + *idx = (U16) (((U32) *((U32 *)key)) % hashListCp->nmbBins); + break; + + case CM_HASHKEYLEN_U16: + if (hashListCp->binBitMask != CM_HASH_NOBITMASK) + *idx = (U16) (((U16)*((U16 *)key)) & hashListCp->binBitMask); + else + *idx = (U16) (((U16)*((U16 *)key)) % hashListCp->nmbBins); + break; + + case CM_HASHKEYLEN_U8: + if (hashListCp->binBitMask != CM_HASH_NOBITMASK) + *idx = (U16) (((U8)*((U8 *)key)) & hashListCp->binBitMask); + else + *idx = (U16) (((U8)*((U8 *)key)) % hashListCp->nmbBins); + break; + + default: + RETVALUE(RFAILED); + } + RETVALUE(ROK); + +} /* end of cmHashFuncConId */ + + + +/* +* +* Fun: cmHashFuncDirIdx +* +* Desc: Computes the hash list index (bin number) for a specified +* key of type CM_HASH_KEYTYPE_DIRINDEX. +* +* The key is the hash table index. +* +* Ret: ROK - successful, *idx contains computed index +* +* Notes: None. +* +* File: cm_hash.c +* +*/ + +#ifdef ANSI +PRIVATE S16 cmHashFuncDirIdx +( +CmHashListCp *hashListCp, /* hash list control point */ +U8 *key, /* key string */ +U16 keyLen, /* length of key string */ +U16 *idx /* index to return */ +) +#else +PRIVATE S16 cmHashFuncDirIdx(hashListCp, key, keyLen, idx) +CmHashListCp *hashListCp; /* hash list control point */ +U8 *key; /* key string */ +U16 keyLen; /* length of key string */ +U16 *idx; /* index to return */ +#endif +{ + TRC2(cmHashFuncDirIdx); + + UNUSED(hashListCp); + UNUSED(keyLen); + + *idx = *((U16 *) key); + + RETVALUE(ROK); +} /* end of cmHashFuncDirIdx */ + + +/* +* +* Fun: cmHashMatchKey +* +* Desc: Compares two keys and determines if they match. +* +* Ret: ROK - match successful +* RFAILED - match failed (non-matching key values) +* +* Notes: None. +* +* File: cm_hash.c +* +*/ + +#ifdef ANSI +PRIVATE S16 cmHashMatchKey +( +U8 *key1, /* first key string */ +U16 keyLen1, /* length of first key string */ +U8 *key2, /* second key string */ +U16 keyLen2 /* length of second key string */ +) +#else +PRIVATE S16 cmHashMatchKey(key1, keyLen1, key2, keyLen2) +U8 *key1; /* first key string */ +U16 keyLen1; /* length of first key string */ +U8 *key2; /* second key string */ +U16 keyLen2; /* length of second key string */ +#endif +{ + TRC2(cmHashMatchKey); + + /* compare key lengths */ + if (keyLen1 != keyLen2) + RETVALUE(RFAILED); + + /* compare key strings */ + RETVALUE(cmMemcmp(key1, key2, (PTR) keyLen1)); +} /* end of cmHashMatchKey */ + + +/* +* +* Fun: cmListInsert +* +* Desc: Adds an entry into a doubly linked list +* +* Ret: ROK - insertion successful +* +* Notes: None +* +* File: cm_hash.c +* +*/ + +#ifdef ANSI +PRIVATE S16 cmListInsert +( +CmListEnt *oldEntry, /* add new entry after this entry */ +CmListEnt *newEntry /* new entry to add */ +) +#else +PRIVATE S16 cmListInsert(oldEntry, newEntry) +CmListEnt *oldEntry; /* add new entry after this entry */ +CmListEnt *newEntry; /* new entry to add */ +#endif +{ + TRC2(cmListInsert); + + newEntry->next = oldEntry->next; + newEntry->prev = oldEntry; + oldEntry->next = newEntry; + (newEntry->next)->prev = newEntry; + + RETVALUE(ROK); +} /* end of cmListInsert */ + + +/* +* +* Fun: cmListDelete +* +* Desc: Deletes an entry from a doubly linked list +* +* Ret: ROK - deletion successful +* +* Notes: None +* +* File: cm_hash.c +* +*/ + +#ifdef ANSI +PRIVATE S16 cmListDelete +( +CmListEnt *entry /* entry to delete */ +) +#else +PRIVATE S16 cmListDelete(entry) +CmListEnt *entry; /* entry to delete */ +#endif +{ + TRC2(cmListDelete); + + if (entry == NULLP) + RETVALUE(RFAILED); + + if (entry->prev != NULLP) + (entry->prev)->next = entry->next; + + if (entry->next != NULLP) + (entry->next)->prev = entry->prev; + + RETVALUE(ROK); +} /* end of cmListDelete */ + + + +/* + * public functions + */ + + +/* +* +* Fun: cmHashListInit +* +* Desc: Initializes a hash list. Parameters are: +* +* hashListCp control point for hash list +* nmbBins number of bins in the hash list. Storage will +* be allocated for them from the indicated memory +* region and pool. +* offset if the entries in this hash list are also going +* to be attached to another hash list, they will +* contain multiple hash list entry headers. The +* offset indicates the offset of the entry header +* for this hash list in the entry structure. +* dupFlg whether entries with duplicate keys are allowed +* to be inserted in the hash list. +* keyType indicates type of key which can be used to select +* different hash functions. Ignored in this +* implementation. +* region +* pool for allocating storage for bins. +* +* Ret: ROK - initialization successful +* RFAILED - initialization failed, lack of memory +* +* Notes: None +* +* File: cm_hash.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmHashListInit +( +CmHashListCp *hashListCp, /* hash list to initialize */ +U16 nmbBins, /* number of hash list bins */ +U16 offset, /* offset of CmHashListEnt in entries */ +Bool dupFlg, /* allow duplicate keys */ +U16 keyType, /* key type for selecting hash fn */ +Region region, /* memory region to allocate bins */ +Pool pool /* memory pool to allocate bins */ +) +#else +PUBLIC S16 cmHashListInit(hashListCp, nmbBins, offset, dupFlg, keyType, region, pool) +CmHashListCp *hashListCp; /* hash list to initialize */ +U16 nmbBins; /* number of hash list bins */ +U16 offset; /* offset of CmHashListEnt in entries */ +Bool dupFlg; /* allow duplicate keys */ +U16 keyType; /* key type for selecting hash fn */ +Region region; /* memory region to allocate bins */ +Pool pool; /* memory pool to allocate bins */ +#endif +{ + U16 i; +#ifndef CM_MT_HASH_BIN + CmListEnt *hl; +#else + CmListBinEnt *hl; +#endif + + TRC2(cmHashListInit); + +#if (ERRCLASS & ERRCLS_DEBUG) + /* error check on parameters */ + if (hashListCp == NULLP) + RETVALUE(RFAILED); +#endif + + /* initialize control point fields */ + hashListCp->hl = NULLP; + hashListCp->region = region; + hashListCp->pool = pool; + hashListCp->nmbBins = 0; + hashListCp->binBitMask = CM_HASH_NOBITMASK; + hashListCp->nmbBinBits = 0; +#ifndef CM_MT_HASH_BIN + hashListCp->nmbEnt = 0; +#endif + hashListCp->offset = offset; + hashListCp->dupFlg = dupFlg; + hashListCp->keyType = keyType; + hashListCp->hashFunc = NULLP; + + /* initialize hash function for this key type */ + switch (keyType) + { + case CM_HASH_KEYTYPE_MULT24: + /* return failure if number of bins is not a power of 2 */ + if (((nmbBins) & (nmbBins - 1)) != 0) + RETVALUE (RFAILED); + + hashListCp->hashFunc = cmHashFuncMult24; + break; + + case CM_HASH_KEYTYPE_DIRIDX: + hashListCp->hashFunc = cmHashFuncDirIdx; + break; + + case CM_HASH_KEYTYPE_STR: + hashListCp->hashFunc = cmHashFuncString; + break; + + case CM_HASH_KEYTYPE_U32MOD: + hashListCp->hashFunc = cmHashFuncU32Mod; + break; + + case CM_HASH_KEYTYPE_BCD8: + hashListCp->hashFunc = cmHashFuncBCD8; + break; + + case CM_HASH_KEYTYPE_ANY: + hashListCp->hashFunc = cmHashFuncAnyKey; + break; + + case CM_HASH_KEYTYPE_CONID: + hashListCp->hashFunc = cmHashFuncConId; + break; + + case CM_HASH_KEYTYPE_DEF: /* default hash function */ + default: /* illegal key type */ + hashListCp->hashFunc = cmHashFuncDefault; + break; + } + + /* allocate memory for bins */ + if (nmbBins) + { +#ifndef CM_MT_HASH_BIN + if (SGetSBuf(region, pool, (Data **) &hashListCp->hl, + (Size) (nmbBins * sizeof(CmListEnt))) != ROK) + RETVALUE(RFAILED); +#else + if (SGetSBuf(region, pool, (Data **) &hashListCp->hl, + (Size) (nmbBins * sizeof(CmListBinEnt))) != ROK) + RETVALUE(RFAILED); +#endif + + /* initialize bin pointers */ + hl = hashListCp->hl; + for(i = 0; i < nmbBins; i++) + { +#ifndef CM_MT_HASH_BIN + hl[i].next = hl[i].prev = &hl[i]; +#else + /* This initialization is being done as a part of checking + * the presence of empty/non-empty bins. + */ + hl[i].next = hl[i].prev = (CmListEnt*)&hl[i]; + hl[i].nmbEnt = 0; +#endif + } + + /* initialize bin size */ + hashListCp->nmbBins = nmbBins; + + /* initialize bin bit mask */ + if (((nmbBins) & (nmbBins - 1)) == 0) + { + U16 binBitMask; + + /* number of bins is a power of 2 */ + hashListCp->binBitMask = nmbBins - 1; + + /* compute number of bits in the bit mask */ + for (binBitMask = hashListCp->binBitMask; binBitMask; binBitMask >>= 1) + hashListCp->nmbBinBits++; + + } + } + + RETVALUE(ROK); +} /* end of cmHashListInit */ + + +/* +* +* Fun: cmHashListDeinit +* +* Desc: Deinitializes a hash list. Deallocates memory for bins +* and resets header fields. Parameters are: +* +* hashListCp control point for hash list +* +* Ret: ROK - successful +* +* Notes: None +* +* File: cm_hash.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmHashListDeinit +( +CmHashListCp *hashListCp /* hash list to deinitialize */ +) +#else +PUBLIC S16 cmHashListDeinit(hashListCp) +CmHashListCp *hashListCp; /* hash list to deinitialize */ +#endif +{ + TRC2(cmHashListDeinit); + +#if (ERRCLASS & ERRCLS_DEBUG) + /* error check on parameters */ + if (hashListCp == NULLP) + RETVALUE(RFAILED); +#endif + + /* deallocate memory for bins */ + if (hashListCp->nmbBins) +#ifndef CM_MT_HASH_BIN + (Void) SPutSBuf(hashListCp->region, hashListCp->pool, + (Data *) hashListCp->hl, + (Size) (hashListCp->nmbBins * sizeof(CmListEnt))); +#else + (Void) SPutSBuf(hashListCp->region, hashListCp->pool, + (Data *) hashListCp->hl, + (Size) (hashListCp->nmbBins * sizeof(CmListBinEnt))); +#endif + + /* deinitialize control point fields */ + hashListCp->hl = NULLP; + hashListCp->region = REGIONNC; + hashListCp->pool = 0; + hashListCp->nmbBins = 0; + hashListCp->binBitMask = CM_HASH_NOBITMASK; +#ifndef CM_MT_HASH_BIN + hashListCp->nmbEnt = 0; +#endif + hashListCp->offset = 0; + hashListCp->dupFlg = FALSE; + hashListCp->keyType = CM_HASH_KEYTYPE_DEF; + hashListCp->hashFunc = NULLP; + + RETVALUE(ROK); +} /* end of cmHashListDeinit */ + + +/* +* +* Fun: cmHashListInsert +* +* Desc: Inserts a new entry in the hash list. Parameters are: +* +* hashListCp control point for hash list +* entry pointer to new entry to add in the hash list +* key pointer to key string in the new entry +* keyLen length of key string +* +* Ret: ROK - insertion successful +* ROKDUP - insertion failed (duplicate key not allowed) +* RFAILED - insertion failed (incorrect parameter values) +* +* Notes: None +* +* File: cm_hash.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmHashListInsert +( +CmHashListCp *hashListCp, /* hash list to add to */ +PTR entry, /* entry to add */ +U8 *key, /* pointer to key */ +U16 keyLen /* length of key */ +) +#else +PUBLIC S16 cmHashListInsert(hashListCp, entry, key, keyLen) +CmHashListCp *hashListCp; /* hash list to add to */ +PTR entry; /* entry to add */ +U8 *key; /* pointer to key */ +U16 keyLen; /* length of key */ +#endif +{ + CmHashListEnt *hashListEnt; /* pointer to hash list entry header */ + PTR dupEntry; /* pointer to entry with duplicate key */ + U16 idx; /* index for insertion into hash list */ + + TRC2(cmHashListInsert); + +#if (ERRCLASS & ERRCLS_DEBUG) + /* error check on parameters */ + if ((hashListCp == NULLP) || (entry == NULLP) || + (key == NULLP) || (keyLen == 0)) + RETVALUE(RFAILED); +#endif + + /* check for duplicates */ + if (hashListCp->dupFlg == FALSE) + { + /* no duplicates allowed, check if key already exists */ + if (cmHashListFind(hashListCp, key, keyLen, 0, &dupEntry) == ROK) + RETVALUE(ROKDUP); + } + + /* get pointer to hash list entry header */ + hashListEnt = (CmHashListEnt *) (((U8 *) entry) + hashListCp->offset); + + /* initialize hash list entry header */ + hashListEnt->list.next = NULLP; + hashListEnt->list.prev = NULLP; + hashListEnt->keyLen = keyLen; + hashListEnt->key = key; + + /* compute index for insertion */ + if ((*hashListCp->hashFunc)(hashListCp, key, keyLen, &idx) != ROK) + RETVALUE(RFAILED); + + hashListEnt->hashVal = idx; + + /* insert into list */ + cmListInsert(hashListCp->hl[idx].prev, &hashListEnt->list); + + /* increment count of entries in hash list */ +#ifndef CM_MT_HASH_BIN + hashListCp->nmbEnt++; +#else + hashListCp->hl[idx].nmbEnt++; +#endif /* #ifndef CM_MT_HASH_BIN */ + + RETVALUE(ROK); +} /* end of cmHashListInsert */ + + +/* +* +* Fun: cmHashListDelete +* +* Desc: Deletes an entry from the hash list. Parameters are: +* +* hashListCp control point for hash list +* entry pointer to entry to delete from the hash list +* +* Ret: ROK - deletion successful +* RFAILED - deletion failed (incorrect parameter values) +* +* Notes: None +* +* File: cm_hash.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmHashListDelete +( +CmHashListCp *hashListCp, /* hash list to delete from */ +PTR entry /* entry to delete */ +) +#else +PUBLIC S16 cmHashListDelete(hashListCp, entry) +CmHashListCp *hashListCp; /* hash list to delete from */ +PTR entry; /* entry to delete */ +#endif +{ + CmHashListEnt *hashListEnt; /* pointer to hash list entry header */ +#ifdef CM_MT_HASH_BIN + U16 idx; /* index for selecting the right hash list bin */ +#endif + + TRC2(cmHashListDelete); + +#if (ERRCLASS & ERRCLS_DEBUG) + /* error check on parameters */ + if ((hashListCp == NULLP) || (entry == NULLP)) + RETVALUE(RFAILED); +#endif + + /* get pointer to hash list entry header */ + hashListEnt = (CmHashListEnt *) (((U8 *) entry) + hashListCp->offset); + + /* check if entry is already deleted if yes then return OK */ + if((hashListEnt->list.next == NULLP) || + (hashListEnt->list.prev == NULLP)) + RETVALUE(ROK); + +#ifdef CM_MT_HASH_BIN + /* compute index for insertion */ + if ((*hashListCp->hashFunc)(hashListCp, hashListEnt->key, + hashListEnt->keyLen, &idx) != ROK) + RETVALUE(RFAILED); +#endif /* #ifdef CM_MT_HASH_BIN */ + + /* delete entry from list */ + cmListDelete(&hashListEnt->list); + + /* reinitialize hash list entry header */ + hashListEnt->list.next = NULLP; + hashListEnt->list.prev = NULLP; + hashListEnt->keyLen = 0; + hashListEnt->key = NULLP; + hashListEnt->hashVal = 0; + + /* decrement count of entries in hash list */ +#ifndef CM_MT_HASH_BIN + hashListCp->nmbEnt--; +#else + /* Find the right bin index and decrement the nmbEnt counter */ + hashListCp->hl[idx].nmbEnt--; +#endif /* #ifndef CM_MT_HASH_BIN */ + + RETVALUE(ROK); +} /* end of cmHashListDelete */ + + +/* +* +* Fun: cmHashListFind +* +* Desc: Finds an entry in the hash list. Parameters are: +* +* hashListCp control point for hash list +* key pointer to key string for search +* keyLen length of key string +* seqNmb sequence number in case duplicates allowed +* entry pointer to found entry +* +* Ret: ROK - find successful, *entry points to found entry +* RFAILED - find failed, *entry is unchanged +* (incorrect parameter values, key not found) +* +* Notes: None +* +* File: cm_hash.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmHashListFind +( +CmHashListCp *hashListCp, /* hash list to search */ +U8 *key, /* pointer to key */ +U16 keyLen, /* length of key */ +U16 seqNmb, /* used in case of duplicate keys */ +PTR *entry /* entry to be returned */ +) +#else +PUBLIC S16 cmHashListFind(hashListCp, key, keyLen, seqNmb, entry) +CmHashListCp *hashListCp; /* hash list to search */ +U8 *key; /* pointer to key */ +U16 keyLen; /* length of key */ +U16 seqNmb; /* used in case of duplicate keys */ +PTR *entry; /* entry to be returned */ +#endif +{ + CmHashListEnt *hashListEnt; /* pointer to hash list entry header */ +#ifndef CM_MT_HASH_BIN + CmListEnt *hashListBin; /* pointer to hash list bin */ +#else + CmListBinEnt *hashListBin; /* pointer to hash list bin */ + U16 entCnt=0; /* counter for number of entries */ +#endif + U16 i; /* counter for sequence number */ + U16 idx; /* index for insertion into hash list */ + + TRC2(cmHashListFind); + +#if (ERRCLASS & ERRCLS_DEBUG) + /* error check on parameters */ + if ((hashListCp == NULLP) || (key == NULLP) || + (keyLen == 0) || (entry == NULLP)) + RETVALUE(RFAILED); +#endif + + /* compute hash table index */ + if ((*hashListCp->hashFunc)(hashListCp, key, keyLen, &idx) != ROK) + RETVALUE(RFAILED); + + /* search this bin for exact key match */ + hashListBin = &hashListCp->hl[idx]; + hashListEnt = (CmHashListEnt *) hashListBin->next; + + /* examine each entry in bin */ + i = 0; +#ifndef CM_MT_HASH_BIN + while (hashListBin != (CmListEnt *) hashListEnt) +#else + for (entCnt=0; entCnt < hashListBin->nmbEnt; entCnt++) +#endif + { + /* check if key matches */ + if (cmHashMatchKey(hashListEnt->key, hashListEnt->keyLen, key, keyLen) + == ROK) + { + /* matching key */ + *entry = (PTR) (((U8 *) hashListEnt) - hashListCp->offset); + + /* check for duplicates */ + if (!hashListCp->dupFlg) + RETVALUE(ROK); + + /* for duplicate key, check sequence number */ + if (i++ == seqNmb) + RETVALUE(ROK); + } + + /* go to next entry */ + hashListEnt = (CmHashListEnt *) hashListEnt->list.next; + } + + /* no matching key found */ + RETVALUE(RFAILED); +} /* end of cmHashListFind */ + + +/* +* +* Fun: cmHashListGetNext +* +* Desc: Gets next entry in hash list with respect to the specified +* previous entry. If previous entry is NULLP, gets first +* entry in hash list. Parameters are: +* +* hashListCp control point for hash list +* prevEnt pointer to previous entry +* entry pointer to next entry to be returned +* +* Ret: ROK - get successful, *entry points to found entry +* (at beginning of list or in the list) +* RFAILED - get failed, *entry is unchanged +* (incorrect parameter values) +* ROKDNA - get failed, *entry is unchanged. +* (end of list) +* +* Notes: This function has to be used cautiously while the +* CM Hash Module is being compiled with CM_MT_HASH_BIN. +* In such cases, this function should be used only after +* ensuring that none of the other threads are operating +* on the common hash list. +* +* File: cm_hash.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmHashListGetNext +( +CmHashListCp *hashListCp, /* hash list to get from */ +PTR prevEnt, /* previous entry */ +PTR *entry /* entry to be returned */ +) +#else +PUBLIC S16 cmHashListGetNext(hashListCp, prevEnt, entry) +CmHashListCp *hashListCp; /* hash list to get from */ +PTR prevEnt; /* previous entry */ +PTR *entry; /* entry to be returned */ +#endif +{ +#ifndef CM_MT_HASH_BIN + CmListEnt *hashListBin; /* temporary hash list bin pointer */ +#else + CmListBinEnt *hashListBin; /* temporary hash list bin pointer */ +#endif + CmHashListEnt *hashListEnt; /* temporary hash list entry pointer */ + CmHashListEnt *prevListEnt; /* previous hash list entry pointer */ + U16 i; /* hash list counter */ + + TRC2(cmHashListGetNext); + +#if (ERRCLASS & ERRCLS_DEBUG) + /* error check on parameters */ + if ((hashListCp == NULLP) || (entry == NULLP)) + RETVALUE(RFAILED); +#endif + + /* check if need to get first entry */ + if (prevEnt == NULLP) + { + /* get first entry in hash list */ + for (i = 0; i < hashListCp->nmbBins; i++) + /* check for non-empty bin */ +#ifndef CM_MT_HASH_BIN + if (hashListCp->hl[i].next != &hashListCp->hl[i]) +#else + if (hashListCp->hl[i].next != (CmListEnt*)&hashListCp->hl[i]) +#endif + { + /* get first entry in bin */ + hashListEnt = (CmHashListEnt *) hashListCp->hl[i].next; + + /* requested entry is in nxtEnt */ + *entry = (PTR) (((U8 *) hashListEnt) - hashListCp->offset); + + RETVALUE(ROK); + } + + /* no more entries */ + RETVALUE(ROKDNA); + } + + /* use previous entry to find next entry */ + + /* get pointer to previous hash list entry header */ + prevListEnt = (CmHashListEnt *) (((U8 *) prevEnt) + hashListCp->offset); + + /* get index of previous entry */ + i = prevListEnt->hashVal; + + /* set pointers to get next entry */ + hashListBin = &hashListCp->hl[i]; + prevListEnt = (CmHashListEnt *) prevListEnt->list.next; + for (;;) + { + /* check if more entries in this bin */ + if (prevListEnt != (CmHashListEnt *) hashListBin) + { + /* found next entry */ + *entry = (PTR) (((U8 *) prevListEnt) - hashListCp->offset); + + RETVALUE(ROK); + } + + /* no more entries in this bin, go to next bin, check if more bins */ + if (++i >= hashListCp->nmbBins) + /* no more entries */ + break; + + /* reset pointers for next bin */ + hashListBin = &hashListCp->hl[i]; + prevListEnt = (CmHashListEnt *) hashListBin->next; + } + + /* no more entries */ + RETVALUE(ROKDNA); +} /* end of cmHashListGetNext */ + +#ifdef CM_MT_HASH_BIN + +/* +* +* Fun: cmHashListBinGetNextEntry +* +* Desc: Gets next entry in a given hash bin respect to the specified +* previous entry. If previous entry is NULLP, gets first +* entry in hash bin. Parameters are: +* +* hashListCp control point for hash list +* binIdx Bin Index to find the entry in +* prevEnt pointer to previous entry +* entry pointer to next entry to be returned +* +* Ret: ROK - get successful, *entry points to found entry +* (at beginning of list or in the list) +* RFAILED - get failed, *entry is unchanged +* (incorrect parameter values) +* ROKDNA - get failed, *entry is unchanged. +* (end of list) +* Notes: None. +* +* File: cm_hash.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmHashListBinGetNextEntry +( +CmHashListCp *hashListCp, /* hash list to get from */ +U16 binIdx, /* Bin Index to retreive the entry */ +PTR prevEnt, /* previous entry */ +PTR *entry /* entry to be returned */ +) +#else +PUBLIC S16 cmHashListBinGetNextEntry(hashListCp, binIdx, prevEnt, entry) +CmHashListCp *hashListCp; /* hash list to get from */ +U16 binIdx; /* Bin Index to retreive the entry */ +PTR prevEnt; /* previous entry */ +PTR *entry; /* entry to be returned */ +#endif +{ + CmListBinEnt *hashListBin; /* temporary hash list bin pointer */ + CmHashListEnt *hashListEnt; /* temporary hash list entry pointer */ + CmHashListEnt *prevListEnt; /* previous hash list entry pointer */ + + TRC2(cmHashListBinGetNextEntry); + +#if (ERRCLASS & ERRCLS_DEBUG) + /* error check on parameters */ + if ((hashListCp == NULLP) || (entry == NULLP)) + RETVALUE(RFAILED); +#endif + + /* check if need to get first entry */ + if (prevEnt == NULLP) + { + /* get first entry in hash list */ + /* check for non-empty bin */ + if (hashListCp->hl[binIdx].next != (CmListEnt*)&hashListCp->hl[binIdx]) + { + /* get first entry in bin */ + hashListEnt = (CmHashListEnt *) hashListCp->hl[binIdx].next; + + /* requested entry is in nxtEnt */ + *entry = (PTR) (((U8 *) hashListEnt) - hashListCp->offset); + + RETVALUE(ROK); + } + + /* no more entries */ + RETVALUE(ROKDNA); + } + + /* use previous entry to find next entry */ + + /* get pointer to previous hash list entry header */ + prevListEnt = (CmHashListEnt *) (((U8 *) prevEnt) + hashListCp->offset); + + /* set pointers to get next entry */ + hashListBin = &hashListCp->hl[binIdx]; + prevListEnt = (CmHashListEnt *) prevListEnt->list.next; + + /* check if more entries in this bin */ + if (prevListEnt != (CmHashListEnt *) hashListBin) + { + /* found next entry */ + *entry = (PTR) (((U8 *) prevListEnt) - hashListCp->offset); + + RETVALUE(ROK); + } + + /* no more entries */ + RETVALUE(ROKDNA); +} /* end of cmHashListBinGetNextEntry */ +#endif + + +/* +* +* Fun: cmHashListQuery +* +* Desc: Gets hash list attributes. Parameters are: +* +* hashListCp control point for hash list +* queryType type of attribute being queried +* result result of query, to be returned +* +* Ret: ROK - successful, *result contains query result +* RFAILED - failed, *result unchanged (incorrect parameter values) +* +* Notes: This function is obsoleted! +* Use macros defined in cm_hash.h instead +* +* File: cm_hash.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmHashListQuery +( +CmHashListCp *hashListCp, /* hash list to query */ +U8 queryType, /* type of query */ +U16 *result /* result of query */ +) +#else +PUBLIC S16 cmHashListQuery(hashListCp, queryType, result) +CmHashListCp *hashListCp; /* hash list to query */ +U8 queryType; /* type of query */ +U16 *result; /* result of query */ +#endif +{ +#ifdef CM_MT_HASH_BIN + U8 i; +#endif + + TRC2(cmHashListQuery); + + /* deal with queries that do not need hashListCp */ + +#if (ERRCLASS & ERRCLS_DEBUG) + /* error check on parameters */ + if (result == NULLP) + RETVALUE(RFAILED); +#endif + + /* respond depending on query type */ + if (queryType == CM_HASH_QUERYTYPE_BINSIZE) + { + /* storage for each bin */ +#ifndef CM_MT_HASH_BIN + *result = (U16) sizeof(CmListEnt); +#else + *result = (U16) sizeof(CmListBinEnt); +#endif + RETVALUE(ROK); + } + + /* deal with queries that do need hashListCp */ + +#if (ERRCLASS & ERRCLS_DEBUG) + /* error check on parameters */ + if (hashListCp == NULLP) + RETVALUE(RFAILED); +#endif + + /* respond depending on query type */ + switch (queryType) + { + case CM_HASH_QUERYTYPE_ENTRIES: /* current number of entries */ +#ifndef CM_MT_HASH_BIN + *result = (U16) hashListCp->nmbEnt; +#else + *result = 0; + for (i=0; i < hashListCp->nmbBins; i++) + { + *result += hashListCp->hl[i].nmbEnt; + } +#endif + RETVALUE(ROK); + + case CM_HASH_QUERYTYPE_BINS: /* number of bins */ + *result = (U16) hashListCp->nmbBins; + RETVALUE(ROK); + + case CM_HASH_QUERYTYPE_OFFSET: /* offset of CmHashListEnt in entries */ + *result = (U16) hashListCp->offset; + RETVALUE(ROK); + + case CM_HASH_QUERYTYPE_DUPFLG: /* allow duplicate keys */ + *result = (U16) hashListCp->dupFlg; + RETVALUE(ROK); + + case CM_HASH_QUERYTYPE_KEYTYPE: /* key type for selecting hash functions */ + *result = (U16) hashListCp->keyType; + RETVALUE(ROK); + + default: /* process other query types */ + break; + } + + /* illegal query type */ + RETVALUE(RFAILED); +} /* end of cmHashListQuery */ + +#ifdef HASH_OPEN_ADDRESSING + +/* +* +* Fun: cmHashListOAInsert +* +* Desc: Inserts a new entry in the hash list with open addressing. +* Parameters are: +* +* hashListCp control point for hash list +* entry pointer to new entry to add in the hash list +* key pointer to key string in the new entry +* keyLen length of key string +* +* Ret: ROK - insertion successful +* ROKDUP - insertion failed (duplicate key not allowed) +* RFAILED - insertion failed (incorrect parameter values) +* +* Notes: None +* +* File: cm_hash.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmHashListOAInsert +( +CmHashListCp *hashListCp, /* hash table to add to */ +PTR entry, /* entry to add */ +U8 *key, /* pointer to key */ +U16 keyLen /* length of key */ +) +#else +PUBLIC S16 cmHashListOAInsert(hashListCp, entry, key, keyLen) +CmHashListCp *hashListCp; /* hash table to add to */ +PTR entry; /* entry to add */ +U8 *key; /* pointer to key */ +U16 keyLen; /* length of key */ +#endif +{ +/* cm_hash_c_001.main_21. Modify. Compilation Issue resolved. */ +#ifndef CM_MT_HASH_BIN + CmListEnt *hashBin; /* temporary hash list bin pointer */ +#else + CmListBinEnt *hashBin; /* temporary hash list bin pointer */ +#endif + CmHashListEnt *hashListEnt; /* pointer to hash list entry header */ + U16 idx; /* index for insertion into hash list */ + U16 hashSize; /* hash size */ + U16 i; + /* cm_hash_c_001.main_21. Modify. Compilation Issue resolved. */ + U16 nmbEnt; + + TRC2(cmHashListOAInsert); + +#if (ERRCLASS & ERRCLS_DEBUG) + /* error check on parameters */ + if ((hashListCp == NULLP) || (entry == NULLP) || + (key == NULLP) || (keyLen == 0)) + RETVALUE(RFAILED); +#endif + +#ifndef CM_MT_HASH_BIN + nmbEnt = hashListCp->nmbEnt; +#else + nmbEnt = 0; + for (i=0; i < hashListCp->nmbBins; i++) + { + nmbEnt += hashListCp->hl[i].nmbEnt; + } +#endif + /* check if table is full */ + if (hashListCp->nmbBins == nmbEnt) + RETVALUE(ROUTRES); + + /* get pointer to hash list entry header */ + hashListEnt = (CmHashListEnt *) (((U8 *) entry) + hashListCp->offset); + + /* initialize hash list entry header */ + hashListEnt->list.next = NULLP; + hashListEnt->list.prev = NULLP; + hashListEnt->keyLen = keyLen; + hashListEnt->key = key; + + /* compute index for insertion */ + if ((*hashListCp->hashFunc)(hashListCp, key, keyLen, &idx) != ROK) + RETVALUE(RFAILED); + + /* + * find an empty bin + */ + hashSize = hashListCp->nmbBins; + hashBin = &hashListCp->hl[idx]; + for (i = hashSize; i > 0; i--) + { + if (hashBin->next == hashBin) + break; /* found */ + if (++idx >= hashSize) + { + idx = 0; + hashBin = &hashListCp->hl[0]; + } + else + hashBin++; + } + + /* insert into list */ + if (cmListInsert(hashBin->prev, &hashListEnt->list) != ROK) + RETVALUE(RFAILED); + + hashListEnt->hashVal = idx; + +#ifndef CM_MT_HASH_BIN + /* increment count of entries in hash list */ + hashListCp->nmbEnt++; +#else + hashBin->nmbEnt++; +#endif + + RETVALUE(ROK); +} /* end of cmHashListOAInsert */ + + +#endif /* HASH_OPENADDRESSING */ + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/cm/cm_inet.c b/src/cm/cm_inet.c new file mode 100644 index 000000000..1785db483 --- /dev/null +++ b/src/cm/cm_inet.c @@ -0,0 +1,10869 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + + +/********************************************************************20** + + Name: common Internet socket library + + Type: C Source file + + Desc: common library for Internet sockets, + always link this library with following libraries: + Trillium's libos.a + Solaris nsl, socket + + File: cm_inet.c + +*********************************************************************21*/ + + +/* + * This software may be combined with the following TRILLIUM + * software: + * + * part no. description + * -------- ---------------------------------------------- + * 1000151 TCAP over TCP/IP + */ + + +/* header include files (.h) */ + +#include "envopt.h" /* environment options */ +#include "envdep.h" /* environment dependent */ +#include "envind.h" /* environment independent */ + +#include "gen.h" /* general */ +#include "ssi.h" /* system services interface */ +#include "cm_inet.h" /* socket library file */ + +/*cm_inet_c_001.main_35 : Updated for C++ compilation */ +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* environment dependent include files */ +#ifdef WIN32 +#ifndef IN +#define IN +#endif +#include +#include +#ifdef WIN2K +#include +#endif /* WIN2K */ +#else /* WIN32 */ +#include +#if (!defined(SS_VW) && !defined(SS_PS)) +#include +#endif +#ifndef SS_PS +#include +#endif +#include +#include +#ifdef SS_PS +#include +#else +#include +#include +#endif /* SS_PS */ +#ifdef SS_VW +#include +#include +#include +#include +#include +#else +#if (!defined (SS_PS) && !defined(HPOS)) +#include +#include +#ifdef SS_LINUX +#include +#else +#include +#endif /* SS_LINUX */ +#endif /* SS_PS && HPOS */ +#ifdef HPOS +#include +#endif /* HPOS */ +#endif /* SS_VW */ +#ifndef SS_PS +#include +#include +#include +#ifdef IPV6_SUPPORTED + +/* cm_inet_c_001.main_54: Fix for vxworks 6.7 adding the new header includes */ +#if (defined(SS_VW) && defined(SS_VW6_7)) +#include +#include +#include +#else +#include +#endif + +#endif /* IPV6_SUPPORTED */ +#endif /* SS_PS */ +#endif /* WIN32 */ + +/*cm_inet_c_001.main_38 Updated for TUCL 2.1 Release (Kernel SCTP Support) */ +#ifdef CM_LKSCTP +#include +#endif + + /* cm_inet_c_001.main_58: Added new header files to support filteration + * of ICMP messages */ +#ifdef SS_LINUX +#ifdef CM_ICMP_FILTER_SUPPORT +#include +#include +#endif +#endif + /* cm_inet_c_001.main_62:Warning fix */ +#if (!defined(SS_VW) && !defined(SS_PS) && !defined(WIN32)) +#include +#endif +#ifdef __cplusplus +} +#endif /* __cplusplus */ +/* header/extern include files (.x) */ + +#include "gen.x" /* general */ +#include "ssi.x" /* system services interface */ +#include "cm_inet.x" /* socket library file */ +#include "cm_lib.x" /* lib library file */ +#ifdef NTL_LIB +#include "ntl_lib.h" +#endif + + +/* local defines */ + +/* BSD and Winsock error handling is different */ +#ifdef WIN32 +#define INET_ERR SOCKET_ERROR +#define INET_ERR_CODE WSAGetLastError() +#define ERR_INPROGRESS WSAEINPROGRESS +#define ERR_ISCONN WSAEISCONN +#define ERR_WOULDBLOCK WSAEWOULDBLOCK +#define ERR_INADDRNONE INADDR_NONE +#define ERR_NOTCONN WSAENOTCONN +#define ERR_ALREADY WSAEALREADY +#define ERR_AGAIN WSAEWOULDBLOCK +#define ERR_INVAL WSAEINVAL +#define ERR_CONNREFUSED WSAECONNREFUSED +#define ERR_PIPE WSAENOTCONN +/* Changed ERR_TIMEOUT for pSos compilation */ +#define ERR_TIMEDOUT WSAETIMEDOUT +#define ERR_CONNRESET WSAECONNRESET +#define ERR_CONNABORTED WSAECONNABORTED +/* cm_inet_c_001.main_36 Do select again in case of interrupt */ +#define ERR_EINTR WSAEINTR +/* cm_inet_c_001.main_37 network unreacheble error is added */ +#define ERR_NETUNREACH WSAENETUNREACH +/* cm_inet_c_001.main_61: host unreachable is added */ +#define ERR_HOSTUNREACH WSAEHOSTUNREACH +#else +#define INET_ERR -1 +#define INET_ERR_CODE errno +#define ERR_INPROGRESS EINPROGRESS +#define ERR_ISCONN EISCONN +#define ERR_WOULDBLOCK EWOULDBLOCK +#define ERR_INADDRNONE -1 +#define ERR_NOTCONN ENOTCONN +#define ERR_ALREADY EALREADY +#define ERR_AGAIN EAGAIN +/* cm_inet_c_001.main_36 Do select again in case of interrupt */ +#define ERR_EINTR EINTR +/* EINVAL is not mapped because it is a valid error code here */ +#define ERR_INVAL 0 +#define ERR_CONNREFUSED ECONNREFUSED +#define ERR_PIPE EPIPE +/* Changed ERR_TIMEOUT for pSos compilation */ +#define ERR_TIMEDOUT ETIMEDOUT +#define ERR_CONNRESET ECONNRESET +#define ERR_CONNABORTED ECONNABORTED +/* cm_inet_c_001.main_37 network unreacheble error is added */ +#define ERR_NETUNREACH ENETUNREACH +/* cm_inet_c_001.main_61: host unreachable is added */ +#define ERR_HOSTUNREACH EHOSTUNREACH +#endif /* WIN32 */ + +/* back log range */ +#define MIN_BACK_LOG 0 + +/* added a win2k specific defines in. */ +#ifdef WIN32 +#ifdef WIN2K +#ifndef SIO_UDP_CONNRESET +#define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR, 12) +#endif +#endif /* WIN2K */ +#define MAX_BACK_LOG 1 +#else +#define MAX_BACK_LOG 5 +#endif /* WIN32 */ + +#ifdef IPV6_OPTS_SUPPORTED +#ifndef IPV6_SUPPORTED +#error "Enable IPV6_SUPPORTED flag if IPV6_OPTS_SUPPORTED is defined." +#endif +#if (!defined(SS_LINUX) && !defined(_XPG4_2)) +#error "Enable _XPG4_2 or SS_LINUX if IPV6_OPTS_SUPPORTED is defined." +#endif /* SS_LINUX || _XPG4_2 */ +#endif /* IPV6_OPTS_SUPPORTED */ + +#ifdef LOCAL_INTF +#if (!defined(SS_LINUX) && !defined(_XPG4_2)) +#error "Enable _XPG4_2 or SS_LINUX if LOCAL_INTF is defined." +#endif /* SS_LINUX || _XPG4_2 */ +#endif /* LOCAL_INTF */ + +/* local typedefs */ + +/* local externs */ + +/* forward references */ + +/* added !(defined(CMINETFLATBUF) */ +#if (!(defined(WIN32)) && !(defined(CMINETFLATBUF))) +/* Added another function parameter */ +PRIVATE S16 buildRecvBuf ARGS((CmInetMemInfo *info, MsgLen len, + CmInetIovec rxArr[], Buffer *dBuf[], U16 maxSize, + struct msghdr *msg, Bool isStrmMsg)); +PRIVATE S16 buildRecvMsg ARGS((CmInetMemInfo *info, CmInetIovec rxArr[], + S16 numBduf, MsgLen msgLen, Buffer *dBufs[], + Buffer **mPtr)); +/* cm_inet_c_001.main_50 - Added parameter to get length of dbufs packed for partial + * send handling + */ +PRIVATE S16 buildSendIovec ARGS((Buffer *mBuf, MsgLen msgLen, + CmInetIovec txArr[], S16 numDBuf, + S16 *numIovElems, U32 *strtEndDBufNum, + MsgLen *ioLen)); +#endif /* (defined(WIN32)) && !(defined(CMINETFLATBUF)) */ + +/* prototypes of new functions needed to send and + * process after receiving the extension headers through ancillary data */ + +#ifdef IPV6_SUPPORTED +#ifdef IPV6_OPTS_SUPPORTED +PRIVATE S16 cmInet6BuildSendHBHOpts ARGS((CmInetIpv6HBHHdrArr *hbhOptsArr, + U8 *cmsgBuf, U32 *curMsgIdx, + U8 hdrId)); +PRIVATE S16 cmInet6BuildSendRouteOpts ARGS((CmInetIpv6RtHdr *rtOptsArr, + U8 *cmsgBuf, U32 *curMsgIdx)); + +PRIVATE S16 cmInet6BuildRecvRtHdr ARGS((U8 *cmsgData, U32 rtDataLen, + CmInetIpv6RtHdr0 *rtHdr0, + CmInetIpv6RtHdr *rtOptsArr, + CmInetMemInfo *info)); +PRIVATE S16 cmInet6BuildRecvHopOptsArr ARGS((U8 *cmsgData, U32 hbhDataLen, + CmInetIpv6HBHHdrArr *hbhOptsArr, + U8 hdrId, CmInetMemInfo *info)); +PRIVATE S16 cmInet6GetHopLimitValue ARGS((U8 *cmsgData, U32 hopLimitDataLen, + CmInetIpv6HdrParm *ipv6HdrParam)); + +#ifdef SS_LINUX +PRIVATE S16 cmInetBuildSendHoplimit ARGS((U32 hoplimit, U8 *cmsgBuf, + U32 *curMsgIdx)); +#endif /* SS_LINUX */ +#ifdef LOCAL_INTF +PRIVATE S16 cmInet6BuildSendPktinfo ARGS((CmInetIpAddr6 *srcAddr, + U8 *cmsgBuf, U32 *curMsgIdx, + U8 protType)); +#endif /* LOCAL_INTF */ +#endif /* IPV6_OPTS_SUPPORTED */ +#endif /* IPV6_SUPPORTED */ + +/* public variable declarations */ + +/* private variable declarations */ + +#ifdef CMINETDBG +/* Global buffer for debug prints */ +/*cm_inet_c_001.main_62:Warning fix*/ +Txt prntBuf[CMINET_PRNT_BUF_SIZE]; +#endif /* CMINETDBG */ + +/* cm_inet_c_001.main_60 POLL Specific Functions defined */ + +/* +* +* Fun: cmInetPoll +* +* Desc: Poll on pollfdarr +* +* Ret: Number of File Descriptor Selected +* +* Notes: None +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmInetPoll +( +CmInetPollFd *pollFdArr, /* poll FD Array */ +U32 numFds, /* Number of Fds to be monitored */ +S16 *numRdyFds, /* number of ready descriptors */ +U32 timeout /* timeout value for Poll */ +) +#else +PUBLIC S16 cmInetPoll(pollFdArr,numFds,numRdyFds,timeout) +CmInetPollFd *pollFdArr; /* poll FD Array */ +U32 numFds; /* Number of Fds to be monitored */ +S16 *numRdyFds; /* number of ready descriptors */ +U32 timeout; /* timeout value for Poll */ +#endif +{ + S32 ret; + + TRC2(cmInetPoll); + ret = 0; + *numRdyFds = 0; + + if(numFds > CM_INET_POLL_MAXFDSUPP) + { +#ifdef CMINETDBG +/* cm_inet_c_001.main_62:Warning fix */ +#ifndef ALIGN_64BIT + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetPoll() : number of file descriptor (%lu) invalid \n",numFds); +#else + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetPoll() : number of file descriptor (%u) invalid \n",numFds); +#endif + CMINETLOGERROR(ERRCLS_DEBUG, ECMINETXXX, 0, prntBuf); +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if (pollFdArr == NULLP) + { +#ifdef CMINETDBG + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetPoll() : Invalid Parameter (pollFdArr is NULL)"); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINETXXX, 0, prntBuf); +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + ret = poll(pollFdArr,numFds,timeout); + if (ret == 0) + { + RETVALUE(RTIMEOUT); + } + if (ret == INET_ERR) + { + switch(INET_ERR_CODE) + { + case ERR_EINTR: + RETVALUE(ROKDNA); + + default: +#ifdef CMINETDBG + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "File: %s, cmInetPoll() failed on line: %d \n\ + error(%d)\n", __FILE__, __LINE__, INET_ERR_CODE); + SPrint(prntBuf); +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + + } /* end of switch */ + } + + *numRdyFds = (S16)ret; + + RETVALUE(ROK); + +} + +/* +* +* Fun: cmInetPollSetFd +* +* Desc: Set the selected fd in pollFdArr with event eventMask +* +* Ret: RFAILED : if file descriptor is out of range +* ROK : if pollFdArr is set. +* +* Notes: None +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmInetPollSetFd +( +CmInetFd *sockFd, /* socket file descriptor */ +CmInetPollFd *pollFdArr, /* poll FD Array */ +S16 idx, /* poll Fd Array Index */ +U16 eventMask /* Event Mask to be set */ +) +#else +PUBLIC S16 cmInetPollSetFd(sockFd,pollFdArr,idx,eventMask) +CmInetFd *sockFd; /* socket file descriptor */ +CmInetPollFd *pollFdArr; /* poll FD Array */ +S16 idx; /* poll Fd Array Index */ +U16 eventMask; /* Event Mask to be set */ +#endif +{ + + TRC2(cmInetPollSetFd); + + if ((idx) >= CM_INET_POLL_MAXFDSUPP || (idx) < 0) + { +#ifdef CMINETDBG + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetPollSetFd() : Invalid idx(%d) \n",idx); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINETXXX, 0, prntBuf); +#endif /* CMINETDBG */ + + RETVALUE(RFAILED); + } + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if (pollFdArr == NULLP) + { +#ifdef CMINETDBG + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetPollSetFd() : Invalid Parameter (pollFdArr is NULL)"); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINETXXX, 0, prntBuf); +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, + "cmInetPollSetFd() Before Setting fd : sockFd->fd(%d) Index(%d) Event(%d) \n Fd and event to be set fd(%ld) event(%d) \n", + pollFdArr[idx].fd,idx, pollFdArr[idx].events,sockFd->fd,eventMask); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINETXXX, 0, prntBuf); +#else + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, + "cmInetPollSetFd() Before Setting fd: sockFd->fd(%d) Index(%d) Event(%d) \n Fd and event to be set fd(%d) event(%d) \n", + pollFdArr[idx].fd,idx, pollFdArr[idx].events,sockFd->fd,eventMask); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINETXXX, 0, prntBuf); +#endif /*ALIGN_64BIT */ +#endif /* CMINETDBG */ + +/* Setting fd and events with eventMask */ + pollFdArr[idx].fd = sockFd->fd; + pollFdArr[idx].events |= eventMask; + + +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetPollSetFd() After Setting fd: sockFd->fd(%d) Index(%d) Event(%d) \n", + pollFdArr[idx].fd,idx, pollFdArr[idx].events); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINETXXX, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetPollSetFd() After Setting fd: sockFd->fd(%d) Index(%d) Event(%d) \n", + pollFdArr[idx].fd,idx, pollFdArr[idx].events); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINETXXX, 0, prntBuf); +#endif /*ALIGN_64BIT */ +#endif /* CMINETDBG */ + + RETVALUE(ROK); + +} + + +/* +* +* Fun: cmInetPollFdIsSet +* +* Desc: Checks whether fd is selected +* +* Ret: TRUE : If Fd is Selected +* FALSE: If Fd is not Selected +* +* Notes: None +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmInetPollFdIsSet +( +CmInetPollFd *pollFdArr, /* poll FD Array */ +S16 idx, /* poll Fd Array Index */ +U16 eventMask /* Event Mask to be set */ +) +#else +PUBLIC S16 cmInetPollFdIsSet(pollFdArr,idx,eventMask) +CmInetPollFd *pollFdArr; /* poll FD Array */ +S16 idx; /* poll Fd Array Index */ +U16 eventMask; /* Event Mask to be set */ +#endif +{ + S16 ret; + + TRC2(cmInetPollFdIsSet); + + if((idx < 0) || (idx > CM_INET_POLL_MAXFDSUPP)) + { +#ifdef CMINETDBG + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetPollFdIsSet() : Invalid Index (%d) \n",idx); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINETXXX, 0, prntBuf); +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if (pollFdArr == NULLP) + { +#ifdef CMINETDBG + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetPollFdIsSet() : Invalid Parameter (pollFdArr is NULL)"); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINETXXX, 0, prntBuf); +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + ret = (pollFdArr[idx].revents & eventMask); + + RETVALUE(ret); +} + +/* +* +* Fun: cmInetPollClearFdREvent +* +* Desc: clears the reventMask in revent of the givent FD. +* +* Ret: ROK +* +* +* Notes: None +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmInetPollClearFdREvent +( +CmInetPollFd *pollFdArr, /* poll FD Array */ +S16 idx, /* poll Fd Array Index */ +U16 eventMask /* Event Mask to be set */ +) +#else +PUBLIC S16 cmInetPollClearFdREvent(sockFd,pollFdArr,eventMask) +CmInetPollFd *pollFdArr; /* poll FD Array */ +S16 idx; /* poll Fd Array Index */ +U16 eventMask; /* Event Mask to be set */ +#endif +{ + + TRC2(cmInetPollClearFdREvent); + + + if((idx < 0) || (idx > CM_INET_POLL_MAXFDSUPP)) + { +#ifdef CMINETDBG + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetPollClearFdREvent() : Invalid Index (%d) \n",idx); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINETXXX, 0, prntBuf); +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if (pollFdArr == NULLP) + { +#ifdef CMINETDBG + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetPollClearFdREvent() : Invalid Parameter (pollFdArr is NULL)"); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINETXXX, 0, prntBuf); +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetPollClearFdREvent() Before clearing fd revents with eventMask: \n sockFd->fd(%d) Index(%d) REvent(%d) EventMask(%d) \n", + pollFdArr[idx].fd,idx, pollFdArr[idx].revents,eventMask); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINETXXX, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetPollClearFdREvent() Before clearing fd revents with eventMask: \n sockFd->fd(%d) Index(%d) REvent(%d) EventMask(%d) \n", + pollFdArr[idx].fd,idx, pollFdArr[idx].revents,eventMask); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINETXXX, 0, prntBuf); +#endif /*ALIGN_64BIT */ +#endif /* CMINETDBG */ + +/* Clearing the events with eventMask */ + pollFdArr[idx].revents = (pollFdArr[idx].revents & (~(eventMask))); + +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetPollClearFdREvent() After clearing fd revents with eventMask: \n sockFd->fd(%d) Index(%d) REvent(%d) EventMask(%d) \n", + pollFdArr[idx].fd,idx, pollFdArr[idx].revents,eventMask); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINETXXX, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetPollClearFdREvent() After clearing fd revents with eventMask: \n sockFd->fd(%d) Index(%d) REvent(%d) EventMask(%d) \n", + pollFdArr[idx].fd,idx, pollFdArr[idx].revents,eventMask); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINETXXX, 0, prntBuf); +#endif /*ALIGN_64BIT */ +#endif /* CMINETDBG */ + + RETVALUE(ROK); + +} + + +/* +* +* Fun: cmInetPollClearFdEvent +* +* Desc: clears the eventMask in event of the givent FD. +* +* Ret: ROK +* +* +* Notes: None +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmInetPollClearFdEvent +( +CmInetPollFd *pollFdArr, /* poll FD Array */ +S16 idx, /* poll Fd Array Index */ +U16 eventMask /* Event Mask to be set */ +) +#else +PUBLIC S16 cmInetPollClearFdEvent(sockFd,pollFdArr,eventMask) +CmInetPollFd *pollFdArr; /* poll FD Array */ +S16 idx; /* poll Fd Array Index */ +U16 eventMask; /* Event Mask to be set */ +#endif +{ + + TRC2(cmInetPollClearFdEvent); + + + if((idx < 0) || (idx > CM_INET_POLL_MAXFDSUPP)) + { +#ifdef CMINETDBG + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetPollClearFdEvent() : Invalid Index (%d) \n",idx); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINETXXX, 0, prntBuf); +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if (pollFdArr == NULLP) + { +#ifdef CMINETDBG + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetPollClearFdEvent() : Invalid Parameter (pollFdArr is NULL)"); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINETXXX, 0, prntBuf); +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetPollClearFdEvent() Before clearing fd events with eventMask: \n sockFd->fd(%d) Index(%d) Event(%d) EventMask(%d) \n", + pollFdArr[idx].fd,idx, pollFdArr[idx].events,eventMask); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINETXXX, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetPollClearFdEvent() Before clearing fd events with eventMask:\n sockFd->fd(%d) Index(%d) Event(%d) EventMask(%d) \n", + pollFdArr[idx].fd,idx, pollFdArr[idx].events,eventMask); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINETXXX, 0, prntBuf); +#endif /*ALIGN_64BIT */ +#endif /* CMINETDBG */ + +/* Clearing events with eventMask */ + pollFdArr[idx].events = (pollFdArr[idx].events & (~(eventMask))); + +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetPollClearFdEvent() After clearing fd events with eventMask: sockFd->fd(%d) Index(%d) Event(%d) EventMask(%d) \n", + pollFdArr[idx].fd,idx, pollFdArr[idx].events,eventMask); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINETXXX, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetPollClearFdEvent() After clearing fd events with eventMask: sockFd->fd(%d) Index(%d) Event(%d) EventMask(%d) \n", + pollFdArr[idx].fd,idx, pollFdArr[idx].events,eventMask); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINETXXX, 0, prntBuf); +#endif /*ALIGN_64BIT */ +#endif /* CMINETDBG */ + + RETVALUE(ROK); + +} + + +/* +* +* Fun: cmInetPollDelFd +* +* Desc: Delete the given FD from the pollFdArray +* delIdx : Poll Fd Array Index at which fd has to be deleted. +* lastIdx: Last index of poll fd array. +* +* It deletes fd from array by swapping lastIdx pollFd +* values to index to be deleted and deinitializes the +* lastIdx values. +* +* Ret: ROK +* +* +* Notes: It does not decrement the lastIdx and it has to be +* decremented by the caller of this function. +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmInetPollDelFd +( +CmInetPollFd *pollFdArr, /* poll FD Array */ +S16 delIdx, /* poll Fd Array Index for which fd has to be deleted*/ +S16 lastIdx /* Last index of poll Fd Array */ +) +#else +PUBLIC S16 cmInetPollDelFd(pollFdArr, delIdx, lastIdx) +CmInetPollFd *pollFdArr; /* poll FD Array */ +S16 delIdx; /* poll Fd Array Index for which fd has to be deleted*/ +S16 lastIdx; /* Last index of poll Fd Array */ +#endif +{ + + TRC2(cmInetPollDelFd); + + if(lastIdx < delIdx || lastIdx < 0 || delIdx < 0) + { +#ifdef CMINETDBG + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetPollDelFd() : Invalid Index \n Current Index (%d) Delete Index (%d) \n",lastIdx,delIdx); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINETXXX, 0, prntBuf); +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if (pollFdArr == NULLP) + { +#ifdef CMINETDBG + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetPollDelFd() : Invalid Parameter (pollFdArr is NULL)"); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINETXXX, 0, prntBuf); +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetPollDelFd() Deleting the sockFd->fd(%d) Index(%d) Event(%d) revent(%d) \n", + pollFdArr[delIdx].fd,delIdx, pollFdArr[delIdx].events,pollFdArr[delIdx].revents); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINETXXX, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetPollDelFd() After clearing fd events with eventMask: sockFd->fd(%d) Index(%d) Event(%d) EventMask(%d) \n", + pollFdArr[delIdx].fd,delIdx, pollFdArr[delIdx].events,pollFdArr[delIdx].revents); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINETXXX, 0, prntBuf); +#endif /*ALIGN_64BIT */ +#endif /* CMINETDBG */ + + pollFdArr[delIdx].fd = pollFdArr[lastIdx].fd; + pollFdArr[delIdx].events = pollFdArr[lastIdx].events; + pollFdArr[delIdx].revents = pollFdArr[lastIdx].revents; + + pollFdArr[lastIdx].fd = -1; + pollFdArr[lastIdx].events = 0; + pollFdArr[lastIdx].revents = 0; + + RETVALUE(ROK); + +} + +/* +* +* Fun: cmInetPollInitFdArr +* +* Desc: Cleans all elements of fd array. +* +* Ret: ROK +* +* +* Notes: It does not allocates/deallocates memory for Poll Fd Array. +* Caller of function has to allocate/deallocate memory for +* array. +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmInetPollInitFdArr +( +CmInetPollFd *pollFdArr /* poll FD Array */ +) +#else +PUBLIC S16 cmInetPollInitFdArr(pollFdArr) +CmInetPollFd *pollFdArr; /* poll FD Array */ +#endif +{ + S16 idx; + + TRC2(cmInetPollInitFdArr); +/* Sets each element of pollFdArr to initial value + fd = -1 + events = 0 + revents = 0 +*/ +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if (pollFdArr == NULLP) + { +#ifdef CMINETDBG + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetPollInitFdArr() : Invalid Parameter (pollFdArr is NULL)"); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINETXXX, 0, prntBuf); +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + for(idx=0; idx < CM_INET_POLL_MAXFDSUPP; idx++) + { + pollFdArr[idx].fd = -1; + pollFdArr[idx].events = 0; + pollFdArr[idx].revents = 0; + } + RETVALUE(ROK); +} + +#if (!(defined(WIN32)) && !(defined(CMINETFLATBUF))) +/* +* +* Fun: buildRecvBuf +* +* Desc: Allocates dBufs to receive an entire message. +* +* Ret: ROK - successful +* RFAILED - failed +* ROUTRES - failed, out of resources +* +* Notes: None +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PRIVATE S16 buildRecvBuf +( +CmInetMemInfo *info, /* buffer allocation info */ +MsgLen len, /* message length */ +CmInetIovec rxArr[], /* gather array */ +Buffer *dBuf[], /* allocated dBufs */ +U16 maxSize, /* size of rxArr/dBuf array */ +struct msghdr *msg, /* message header for recvmsg() */ +Bool isStrmMsg /* Is a TCP message */ +) +#else +PRIVATE S16 buildRecvBuf(info, len, rxArr, dBuf, maxSize, msg, isStrmMsg) + CmInetMemInfo *info; /* buffer allocation info */ + MsgLen len; /* message length */ + CmInetIovec rxArr[]; /* gather array */ + Buffer *dBuf[]; /* allocated dBufs */ + U16 maxSize; /* size of rxArr/dBuf array */ + struct msghdr *msg; /* message header for recvmsg() */ + Bool isStrmMsg; /* Is a TCP message */ +#endif +{ + S16 ret; /* temporary return value */ + U16 numBuf; /* number of dBufs */ + U16 i; /* dBuf index counter */ + Data *dPtr; /* data pointer */ + /* cm_inet_c_001.main_47: 102069 Changed from S32 to MsgLen for bufLen*/ + MsgLen bufLen; /* entire receive buffer length, if S16 + could wrap to negative number */ + MsgLen dLen; /* buffer length */ + + numBuf = 0; + bufLen = 0; + + /* Initialise ret and part of msg here */ + ret = ROK; + + /* added defined(_XPG4_2) */ + /* Moved initialisation of msg here. */ + +#if (defined(SS_LINUX) || defined(_XPG4_2)) + msg->msg_control = NULLP; + msg->msg_controllen = 0; +#else + msg->msg_accrights = NULLP; + msg->msg_accrightslen = 0; +#endif /* SS_LINUX */ + + /* Check if maxSize if enough to hold the entire message length before + * going into the loop. If the boolean isStrmMsg is TRUE then the recv + * buf is built even if the whole message cannot be accomodated. */ + +#ifdef T2K_MEM_LEAK_DBG + char * file = __FILE__; + U32 line = __LINE__; + ret = SGetDBuf(info->region, info->pool, &dBuf[numBuf]); +#else + ret = SGetDBuf(info->region, info->pool, &dBuf[numBuf]); +#endif + if (ret != ROK) + RETVALUE(ret); + + /* Get the data part */ + ret = SGetDataRx(dBuf[numBuf], 0, &dPtr, &dLen); + if (ret != ROK) + { + numBuf++; /* because of cleanup */ + goto cleanup; + } + + if (!isStrmMsg) + { + /* The assumption here is that all dBuf's from a given region and + * pool have a constance size */ + if (len > (maxSize * dLen)) + { + ret = RNA; + numBuf++; /* because of cleanup */ + goto cleanup; + } + } + +#ifdef SS_LINUX + rxArr[numBuf].iov_base = (Void*)dPtr; + rxArr[numBuf].iov_len = (U32)dLen; +#else + rxArr[numBuf].iov_base = (S8*)dPtr; + rxArr[numBuf].iov_len = dLen; +#endif /* SS_LINUX */ + + bufLen += dLen; + numBuf++; + + /* allocate buffer space for entire message length */ + while (bufLen < len) + { + if (numBuf >= maxSize) + { + /* to big to fit in gather vector array */ + ret = RNA; + break; + } + ret = SGetDBuf(info->region, info->pool, &dBuf[numBuf]); + if (ret != ROK) + { + goto cleanup; + } + ret = SGetDataRx(dBuf[numBuf], 0, &dPtr, &dLen); + if (ret != ROK) + { + numBuf++; /* because of cleanup */ + goto cleanup; + } +#ifdef SS_LINUX + rxArr[numBuf].iov_base = (Void*)dPtr; + rxArr[numBuf].iov_len = (U32)dLen; +#else + rxArr[numBuf].iov_base = (S8*)dPtr; + rxArr[numBuf].iov_len = dLen; +#endif /* SS_LINUX */ + + bufLen += dLen; + numBuf++; + } + /* adjust last buffer length */ + /* check if we broke out because numBuf >= maxSize */ + if (bufLen < len) + rxArr[numBuf - 1].iov_len = dLen; + else + rxArr[numBuf - 1].iov_len = dLen - (bufLen - len); + + /* setup recvmsg() message header */ + msg->msg_iov = rxArr; + msg->msg_iovlen = numBuf; + + RETVALUE(ret); + +cleanup: + /* cleanup */ + for (i = 0; i < numBuf; i++) + SPutDBuf(info->region, info->pool, dBuf[i]); + + msg->msg_iovlen = 0; + + RETVALUE(ret); +} /* end of buildRecvBuf */ + +/* +* +* Fun: buildRecvMsg +* +* Desc: Builds a message out of the received dBufs. +* +* Ret: ROK - successful +* RFAILED - failed +* ROUTRES - failed, out of resources +* +* Notes: None +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PRIVATE S16 buildRecvMsg +( +CmInetMemInfo *info, /* buffer allocation info */ +CmInetIovec rxArr[], /* scatter array */ +S16 numBuf, /* number of allocated dBufs */ +MsgLen msgLen, /* message length */ +Buffer *dBufs[], /* dBufs */ +Buffer **mPtr /* message built from dBufs */ +) +#else +PRIVATE S16 buildRecvMsg(info, rxArr, numBuf, msgLen, dBufs, mPtr) +CmInetMemInfo *info; /* buffer allocation info */ +CmInetIovec rxArr[]; /* scatter array */ +S16 numBuf; /* number of allocated dBufs */ +MsgLen msgLen; /* length of one particular dBuf */ +Buffer *dBufs[]; /* dBufs */ +Buffer **mPtr; /* message built from dBufs */ +#endif +{ + S16 ret; /* return value */ + S16 i; /* dBuf index counter */ + MsgLen bufLen; /* length of one particular dBuf */ + /* cm_inet_c_001.main_54: Fix for Klockworks issue */ + Buffer *mBuf = NULLP; /* allocated message */ + + ret = RFAILED; + i = 0; + + /* build message */ + ret = SGetMsg(info->region, info->pool, &mBuf); + if (ret != ROK) + { + goto cleanup; + } + + /* link buffers to message */ + while (i < numBuf) + { + /* cm_inet_c_001.main_58: fix for klockwork issue */ + bufLen = (MsgLen)rxArr[i].iov_len; + if (msgLen < bufLen) + { + bufLen = msgLen; + } + ret = SUpdMsg(mBuf, dBufs[i], bufLen); + if (ret != ROK) + { + SPutMsg(mBuf); + goto cleanup; + } + msgLen -= bufLen; + i++; + if (msgLen <= 0) + { + ret = ROK; + break; + } + } + + *mPtr = mBuf; + +cleanup: + /* cleanup unused buffers */ + while (i < numBuf) + { +#ifdef T2K_MEM_LEAK_DBG + char * file = __FILE__; + U32 line = __LINE__; + SPutDBuf(info->region, info->pool, dBufs[i]); +#else + SPutDBuf(info->region, info->pool, dBufs[i]); +#endif + i++; + } + + RETVALUE(ret); +} /* end of buildRecvMsg */ + + + +/* +* +* Fun: buildSendIovec +* +* Desc: Builds a io vector to send a message. +* +* Ret: ROK - successful +* RFAILED - failed +* ROUTRES - failed, out of resources +* RNA - failed, not available, indicates that the +* maximum number of dBufs are not sufficient +* to hold the entire message. +* +* Notes: None +* +* File: cm_inet.c +* +*/ +#ifdef ANSI +PRIVATE S16 buildSendIovec +( +Buffer *mBuf, /* Message buffer */ +MsgLen msgLen, /* Length of mBuf */ +CmInetIovec txArr[], /* transmit scatter vector array */ +S16 numDBufs, /* Maximum number of dBufs to use */ +S16 *numIovElems, /* Number of iov elements in array */ +U32 *strtEndDBufNum, /* dBuf number to start and end */ +MsgLen *ioLen /* cm_inet_c_001.main_50 - Len of dbuf packed into IO-vector */ +) +#else +PRIVATE S16 buildSendIovec(mBuf, msgLen, txArr, numDBufs, numIovElems, + strtEndDBufNum,ioLen) +Buffer *mBuf; /* Message buffer */ +MsgLen msgLen; /* Length of mBuf */ +CmInetIovec txArr[]; /* transmit scatter vector array */ +S16 numDBufs; /* Maximum number of dBufs to use */ +S16 *numIovElems; /* Number of iov elements in array */ +U32 *strtEndDBufNum; /* dBuf number to start and end */ +MsgLen *ioLen; /* cm_inet_c_001.main_50 - Len of dbuf packed into IO-vector */ +#endif +{ + S16 ret; + MsgLen dLen; + S16 iovIdx; + Buffer *dBuf; + Data *dPtr; + MsgLen allocLen; + U32 dBufsToSkip; + + /* Initialisations */ + (*numIovElems) = 0; + iovIdx = 0; + allocLen = 0; + + /* cm_inet_c_001.main_50 - Intialize the newly added parameter */ + *ioLen = 0; + + /* Set up vector for gathering send */ + ret = SInitNxtDBuf(mBuf); + if (ret != ROK) + { + RETVALUE(RFAILED); + } + + iovIdx = 0; + txArr[iovIdx].iov_len = 0; + + if ((*strtEndDBufNum != 0)) + { + /* Skip through the required number of dBufs */ + dBufsToSkip = *strtEndDBufNum; + + while(dBufsToSkip) + { + ret = SGetNxtDBuf(mBuf, &dBuf); + if (ret != ROK) + RETVALUE(RFAILED); + dBufsToSkip --; + } + } + + for (;;) + { + ret = SGetNxtDBuf(mBuf, &dBuf); + if (ret == ROK) + { + ret = SGetDataTx(dBuf, &dPtr, &dLen); + if (ret != ROK) + { + ret = RFAILED; + break; + } + + txArr[iovIdx].iov_base = (S8 *)dPtr; + txArr[iovIdx].iov_len = dLen; + + allocLen += dLen; + } + else if (ret == ROKDNA) + { + ret = ROK; + break; + } + else + { + ret = RFAILED; + break; + } + + iovIdx += 1; + + if (iovIdx >= numDBufs) + { + if (allocLen >= msgLen) + ret = ROK; + else + ret = RNA; + break; + } + } + + (*numIovElems) = iovIdx; + (*strtEndDBufNum) += iovIdx; + + /* cm_inet_c_001.main_50 - Assign the value of dbufs packed in IO-vector */ + *ioLen = allocLen; + + RETVALUE(ret); + +} /* end of buildSendIovec */ +#endif /* (defined(WIN32)) && !(defined(CMINETFLATBUF)) */ + + +/* +* +* Fun: cmInetSocket +* +* Desc: Creates an Internet socket descriptor. +* On default the socket is non-blocking ( can be changed +* with the function cmInetSetOpt()). +* Values for type: +* +* CM_INET_STREAM (TCP) +* CM_INET_DGRAM (UDP) +* +* Ret: ROK - successful +* RFAILED - failed +* +* Notes: None +* +* File: cm_inet.c +* +*/ +#ifdef ANSI +#ifdef CM_INET2 +#ifdef IPV6_SUPPORTED +PUBLIC S16 cmInetSocket +( +U8 type, /* socket type */ +CmInetFd *sockFd, /* socket file descriptor */ +U8 protocol, /* protocol value */ +U8 domain /* domain */ +) +#else +PUBLIC S16 cmInetSocket +( +U8 type, /* socket type */ +CmInetFd *sockFd, /* socket file descriptor */ +U8 protocol /* protocol value */ +) +#endif /* IPV6_SUPPORTED */ +#else /* CM_INET2 */ +PUBLIC S16 cmInetSocket +( +U8 type, /* socket type */ +CmInetFd *sockFd /* socket file descriptor */ +) +#endif /* CM_INET2 */ +#else +#ifdef CM_INET2 +#ifdef IPV6_SUPPORTED +PUBLIC S16 cmInetSocket(type, sockFd, protocol, domain) +U8 type; /* socket type */ +CmInetFd *sockFd; /* socket file descriptor */ +U8 protocol; /* protocol value */ +U8 domain; /* domain */ +#else +PUBLIC S16 cmInetSocket(type, sockFd, protocol) +U8 type; /* socket type */ +CmInetFd *sockFd; /* socket file descriptor */ +U8 protocol; /* protocol value */ +#endif /* IPV6_SUPPORTED */ +#else /* CM_INET2 */ +PUBLIC S16 cmInetSocket(type, sockFd) +U8 type; /* socket type */ +CmInetFd *sockFd; /* socket file descriptor */ +#endif /* CM_INET2 */ +#endif /* ANSI */ +{ + S32 ret; /* temporary return value */ + + U32 optVal; + +#if (defined(WIN32) && defined(WIN2K)) + S32 bytesReturned; + Bool bNewBehavior; +#endif /* WIN2K && WIN32 */ + + TRC2(cmInetSocket); + +#if (defined(WIN32) && defined(WIN2K)) + bytesReturned = 0; + bNewBehavior = FALSE; +#endif /* WIN32 && WIN2K */ + + /* create socket */ +#ifdef CM_INET2 +#ifdef IPV6_SUPPORTED + sockFd->fd = socket(domain, type, protocol); +#else + sockFd->fd = socket(AF_INET, type, protocol); +#endif /* IPV6_SUPPORTED */ +#else /* CM_INET2 */ + sockFd->fd = socket(AF_INET, type, 0); +#endif /* CM_INET2 */ + if (CM_INET_INV_SOCK_FD(sockFd)) + { +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetSocket() Failed : errno(%d), sockFd->fd(%ld)\n", + INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET001, 0, prntBuf); +#else + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetSocket() Failed : errno(%d), sockFd->fd(%d)\n", + INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET001, 0, prntBuf); +#endif /*ALIGN_64BIT */ +#endif /* CMINETDBG */ + /* Set sockFd->fd to invalid socket */ + sockFd->fd = CM_INET_INV_SOCKFD; + RETVALUE(RFAILED); + } + + /* set socket type */ + sockFd->type = type; + + /* set socket protocol type (IPv4/IPv6) */ +#ifdef IPV6_SUPPORTED + sockFd->protType = domain; +#endif /* IPV6_SUPPORTED */ + + /*cm_inet_c_001.main_38 Updated for TUCL 2.1 Release (Kernel SCTP Support) */ +#ifdef CM_LKSCTP + if (protocol != IPPROTO_SCTP) + { +#endif + /* set default options */ + optVal = CM_INET_OPT_DISABLE; + ret = cmInetSetOpt(sockFd, SOL_SOCKET, CM_INET_OPT_BLOCK, (Ptr)&optVal); + if (ret != ROK) + { + ret = cmInetClose(sockFd); + RETVALUE(RFAILED); + } + +#ifdef SS_LINUX +#ifndef CMINET_BSDCOMPAT + optVal = CM_INET_OPT_ENABLE; + ret = cmInetSetOpt(sockFd, SOL_SOCKET, CM_INET_OPT_BSD_COMPAT, (Ptr)&optVal); + if (ret != ROK) + { + ret = cmInetClose(sockFd); + RETVALUE(RFAILED); + } +#endif /* CMINET_BSDCOMPAT */ +#endif /* SS_LINUX */ + +#if (defined(WIN32) && defined(WIN2K)) + if(type == CM_INET_DGRAM) + { + ret = WSAIoctl(sockFd->fd, SIO_UDP_CONNRESET, &bNewBehavior, + sizeof(bNewBehavior), NULLP, 0, &bytesReturned, + NULLP, NULLP); + if(ret == INET_ERR) + { +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54: CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "WSAIoctl() Failed : error(%d), sockFd->fd(%ld)\n", + INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET002, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "WSAIoctl() Failed : error(%d), sockFd->fd(%d)\n", + INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET002, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + ret = cmInetClose(sockFd); + RETVALUE(RFAILED); + } + } +#endif /* WIN2K && WIN32 */ + /*cm_inet_c_001.main_38 Updated for TUCL 2.1 Release (Kernel SCTP Support) */ +#ifdef CM_LKSCTP + } +#ifdef CM_LKSCTP_NONBLOCK + else + { + /* cm_inet_c_001.main_47:if non-blocking SCTP socket compile time + * * flag is set then even for kernel SCTP make the socket + * * non-blocking + * */ + optVal = CM_INET_OPT_DISABLE; + ret = cmInetSetOpt(sockFd, SOL_SOCKET, CM_INET_OPT_BLOCK, (Ptr)&optVal); + if (ret != ROK) + { + ret = cmInetClose(sockFd); + RETVALUE(RFAILED); + } + } +#endif /* CM_LKSCTP_NONBLOCK ends */ +#endif + RETVALUE(ROK); +} /* end of cmInetSocket */ + + +/* +* +* Fun: cmInetBind +* +* Desc: Binds a socket file descriptor to a local Internet +* address/port. +* +* Ret: ROK - successful +* RFAILED - failed +* +* Notes: None. +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmInetBind +( +CmInetFd *sockFd, /* socket file descriptor */ +CmInetAddr *myAddr /* locale Internet address/port */ +) +#else +PUBLIC S16 cmInetBind(sockFd, myAddr) +CmInetFd *sockFd; /* socket file descriptor */ +CmInetAddr *myAddr; /* locale Internet address/port */ +#endif +{ + S32 ret; /* temporary return value */ + struct sockaddr_in srcAddr; /* local Internet address/port */ +#ifdef IPV6_SUPPORTED + struct sockaddr_in6 srcAddr6; /* local IPV6 address/port */ +#ifdef CMINETDBG + U16 port; +#endif /* CMINETDBG */ +#endif /* IPV6_SUPPORTED */ + U32 sizeOfAddr; /* sizeof address passed to the bind call */ + CmInetSockAddr *sockAddrPtr; + + TRC2(cmInetBind); + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if ((sockFd == NULLP) || CM_INET_INV_SOCK_FD(sockFd) || + (myAddr == NULLP)) + { + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + +#ifdef IPV6_SUPPORTED + if (myAddr->type == CM_INET_IPV6ADDR_TYPE) + { + cmMemset((U8*)&srcAddr6, 0, sizeof(srcAddr6)); + srcAddr6.sin6_family = AF_INET6; + srcAddr6.sin6_port = CM_INET_HTON_U16(myAddr->u.ipv6Addr.port); + CM_INET_COPY_IPV6ADDR(&srcAddr6.sin6_addr, + &myAddr->u.ipv6Addr.ipv6NetAddr); + sizeOfAddr = sizeof(struct sockaddr_in6); + sockAddrPtr = (CmInetSockAddr *)&srcAddr6; + } + else + { + cmMemset((U8*)&srcAddr, 0, sizeof(srcAddr)); + srcAddr.sin_family = AF_INET; + srcAddr.sin_port = CM_INET_HTON_U16(myAddr->u.ipv4Addr.port); + srcAddr.sin_addr.s_addr = CM_INET_HTON_U32(myAddr->u.ipv4Addr.address); + sizeOfAddr = sizeof(struct sockaddr_in); + sockAddrPtr = (CmInetSockAddr *)&srcAddr; + } +#else + cmMemset((U8*)&srcAddr, 0, sizeof(srcAddr)); + srcAddr.sin_family = AF_INET; + srcAddr.sin_port = CM_INET_HTON_U16(myAddr->port); + srcAddr.sin_addr.s_addr = CM_INET_HTON_U32(myAddr->address); + sizeOfAddr = sizeof(struct sockaddr_in); + sockAddrPtr = (CmInetSockAddr *)&srcAddr; +#endif /* IPV6_SUPPORTED */ + + ret = bind(sockFd->fd, sockAddrPtr, sizeOfAddr); + if (ret == INET_ERR) + { +#ifdef CMINETDBG +#ifdef IPV6_SUPPORTED + if (myAddr->type == CM_INET_IPV6ADDR_TYPE) + port = myAddr->u.ipv6Addr.port; + else + port = myAddr->u.ipv4Addr.port; +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetBind() Failed : error(%d), addrType(%d)," + " port(%d), sockFd->fd(%ld)\n", + INET_ERR_CODE , myAddr->type, port, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET003, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetBind() Failed : error(%d), addrType(%d)," + " port(%d), sockFd->fd(%d)\n ", + INET_ERR_CODE , myAddr->type, port, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET003, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#else +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetBind() Failed : error(%d), addr(0x%lx), port(%d)," + "sockFd->fd(%ld)\n", + INET_ERR_CODE , myAddr->address, myAddr->port, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET004, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetBind() Failed : error(%d), addr(0x%x), port(%d)," + " sockFd->fd(%d)\n", + INET_ERR_CODE , myAddr->address, myAddr->port, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET004, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* IPV6_SUPPORTED */ +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + + RETVALUE(ROK); +} /* end of cmInetBind */ + +/*cm_inet_c_001.main_38 Updated for TUCL 2.1 Release (Kernel SCTP Support) */ +/* cm_inet_c_001.main_51 Added Ipv6 support to KSCtP implementation */ +#ifdef CM_LKSCTP +/* +* +* Fun: cmInetSctpBindx +* +* Desc: Binds a SCTP socket file descriptor to local Internet +* address list +* +* Ret: ROK - successful +* RFAILED - failed +* +* Notes: None. +* +* File: cm_inet.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmInetSctpBindx +( +CmInetFd *sockFd, /* socket file descriptor */ +CmInetNetAddrLst *addrLst, /* local Internet address list */ +U16 port /* port number */ +) +#else +PUBLIC S16 cmInetSctpBindx(sockFd, addrLst, port) +CmInetFd *sockFd; /* socket file descriptor */ +CmInetNetAddrLst *addrLst; /* locale Internet address list */ +U16 port; /* port number */ +#endif +{ + S32 ret; /* temporary return value */ + S32 idx; + S32 idx4 = 0; + U32 ipv4_array_size = 0; + struct sockaddr_in addrs[CM_INET_NUM_NET_ADDR]; +#ifndef IPV6_SUPPORTED + Data address_array[(CM_INET_NUM_NET_ADDR * sizeof(struct sockaddr_in))]; +#else + Data address_array[(CM_INET_NUM_NET_ADDR * sizeof(struct sockaddr_in6))]; +#endif /* IPV6_SUPPORTED */ + +#ifdef SUN_KSCTP + Data *tempAddrPtr = NULLP; +#endif + U32 addresses_array_size = 0; +#ifdef IPV6_SUPPORTED +#ifdef SUN_KSCTP + S8 *addrString = NULLP; + U32 addrLen = 0; + S8 ipv4Format[23] = "::ffff:"; +#endif /* SUN_KSCTP */ + S32 idx6 = 0; + U32 ipv6_array_size = 0; + struct sockaddr_in6 addrs6[CM_INET_NUM_NET_ADDR]; +#endif /* IPV6_SUPPORTED */ + struct sockaddr *sockAddrPtr = NULLP; + U32 sockAddrLen = 0; + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if ((sockFd == NULLP) || CM_INET_INV_SOCK_FD(sockFd) || + (addrLst == NULLP)) + { + RETVALUE(RFAILED); + } + + if(addrLst->count > CM_INET_NUM_NET_ADDR) + { +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "No of address(%d) is greater than Max(%d)," + " sockFd->fd(%ld)\n", + addrLst->count, CM_INET_NUM_NET_ADDR, sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET005, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "No of address(%d) is greater than Max(%d)," + " sockFd->fd(%d)\n", + addrLst->count, CM_INET_NUM_NET_ADDR, sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET005, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + cmMemset((U8*)&addrs, 0, (sizeof(struct sockaddr_in) * CM_INET_NUM_NET_ADDR)); +#ifdef IPV6_SUPPORTED + cmMemset((U8*)&addrs6, 0, (sizeof(struct sockaddr_in6) * CM_INET_NUM_NET_ADDR)); +#endif /* IPV6_SUPPORTED */ + + for (idx = 0; idx < addrLst->count; idx++) + { +#ifdef IPV6_SUPPORTED + if (addrLst->addrs[idx].type == CM_INET_IPV6ADDR_TYPE) + { + ipv6_array_size += sizeof(struct sockaddr_in6); + addresses_array_size += sizeof(struct sockaddr_in6); + if (sockFd->protType == AF_INET) + { +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "can't bind IPV6 address on IPV4 socket," + " sockFd->fd(%ld)\n", sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET057, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "can't bind IPV6 address on IPV4 socket," + " sockFd->fd(%d)\n", sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET057, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + + addrs6[idx6].sin6_family = AF_INET6; + addrs6[idx6].sin6_port = CM_INET_HTON_U16(port); + CM_INET_COPY_IPV6ADDR((addrs6[idx6].sin6_addr.s6_addr), &(addrLst->addrs[idx].u.ipv6NetAddr)); + idx6++; + } + else + { +#ifdef SUN_KSCTP + + ipv6_array_size += sizeof(struct sockaddr_in6); + addresses_array_size += sizeof(struct sockaddr_in6); + if (sockFd->protType == AF_INET) + { +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "can't bind IPV6 address on IPV4 socket," + " sockFd->fd(%ld)\n", sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET058, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "can't bind IPV6 address on IPV4 socket," + " sockFd->fd(%d)\n", sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET058, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + + addrs6[idx6].sin6_family = AF_INET6; + addrs6[idx6].sin6_port = CM_INET_HTON_U16(port); + addrLst->addrs[idx].u.ipv4NetAddr = CM_INET_HTON_U32(addrLst->addrs[idx].u.ipv4NetAddr); + cmInetNtoa(addrLst->addrs[idx].u.ipv4NetAddr, &addrString); + addrLen = cmStrlen((U8*)addrString); + cmMemcpy((U8*)(ipv4Format+7), (U8*)addrString, addrLen); + ipv4Format[7+addrLen] = '\0'; + cmInetPton6((CmInetIpAddr6*)(addrs6[idx6].sin6_addr.s6_addr), ipv4Format); + idx6++; +#else + ipv4_array_size += sizeof(struct sockaddr_in); + addresses_array_size += sizeof(struct sockaddr_in); + addrs[idx4].sin_family = AF_INET; + addrs[idx4].sin_port = CM_INET_HTON_U16(port); + addrs[idx4].sin_addr.s_addr = CM_INET_HTON_U32(addrLst->addrs[idx].u.ipv4NetAddr); + idx4++; +#endif /* SUN_KSCTP */ + } +#else + ipv4_array_size += sizeof(struct sockaddr_in); + addresses_array_size += sizeof(struct sockaddr_in); + addrs[idx4].sin_family = AF_INET; + addrs[idx4].sin_port = CM_INET_HTON_U16(port); + addrs[idx4].sin_addr.s_addr = CM_INET_HTON_U32(addrLst->addrs[idx].u.ipv4NetAddr); + idx4++; +#endif /* IPV6_SUPPORTED */ + } + + + if(ipv4_array_size > 0) + { + sockAddrPtr = (struct sockaddr*)address_array; + sockAddrLen = sizeof(struct sockaddr_in); + cmMemcpy((U8*)address_array, (U8*)addrs, ipv4_array_size); + } +#ifdef IPV6_SUPPORTED + else + { + sockAddrPtr = (struct sockaddr*)address_array; + sockAddrLen = sizeof(struct sockaddr_in6); + } + + if(ipv6_array_size > 0) + { + cmMemcpy((U8*)(address_array + ipv4_array_size), (U8*)addrs6, ipv6_array_size); + } +#endif /* IPV6_SUPPORTED */ + + +#ifdef SUN_KSCTP + ret = bind(sockFd->fd, sockAddrPtr, sockAddrLen); + if (ret == INET_ERR) + { + +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetSctpBindx() Failed : error(%d), port(%d)," + " sockFd->fd(%ld)\n",INET_ERR_CODE, port, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET006, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetSctpBindx() Failed : error(%d), port(%d)," + " sockFd->fd(%d)\n",INET_ERR_CODE, port, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET006, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + + if (addrLst->count > 1) + { + if(((struct sockaddr*)address_array)->sa_family == AF_INET) + { + tempAddrPtr = address_array + (sizeof(struct sockaddr_in)); + } + else if(((struct sockaddr*)address_array)->sa_family == AF_INET6) + { + tempAddrPtr = address_array + (sizeof(struct sockaddr_in6)); + } + else + { +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetSctpBindx(Invalid address Type) failed:" + " sockFd->fd(%ld), error(%d), port(%d)\n ", + INET_ERR_CODE, port, sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET059, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetSctpBindx(Invalid address Type) failed:" + " sockFd->fd(%d), error(%d), port(%d)\n ", + INET_ERR_CODE, port, sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET059, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + + ret = sctp_bindx(sockFd->fd, (Void*)tempAddrPtr, addrLst->count - 1, SCTP_BINDX_ADD_ADDR); + } +#else + /* linux */ + ret = sctp_bindx(sockFd->fd, (struct sockaddr*)address_array, addrLst->count, SCTP_BINDX_ADD_ADDR); +#endif + if (ret == INET_ERR) + { +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54: CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetSctpBindx() Failed : error(%d), port(%d)," + " sockFd->fd(%ld)\n",INET_ERR_CODE, port, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET007, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetSctpBindx() Failed : error(%d), port(%d)," + " sockFd->fd(%d)\n",INET_ERR_CODE, port, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET007, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + + RETVALUE(ROK); +} + +/* +* +* Fun: cmInetSctpConnectx +* +* Desc: Establishes a sctp connection with remote addresses +* +* Ret: ROK - successful +* RFAILED - failed +* +* Notes: None. +* +* File: cm_inet.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmInetSctpConnectx +( +CmInetFd *sockFd, /* socket file descriptor */ +CmInetNetAddr *primAddr, /* primary destination Internet address */ +CmInetNetAddrLst *addrLst, /* destination Internet address list */ +U16 port /* port number */ +) +#else +PUBLIC S16 cmInetSctpConnectx(sockFd, primAddr, addrLst, port) +CmInetFd *sockFd; /* socket file descriptor */ +CmInetNetAddr *primAddr; /* primary destination Internet address */ +CmInetNetAddrLst *addrLst; /* destination Internet address list */ +U16 port; /* port number */ +#endif +{ + S32 ret; + U32 cnt; + /* cm_inet_c_001.main_46: Removed SS_LINUX flag */ + S32 idx; + + U32 addresses_array_size = 0; + U32 idx4 = 0; + struct sockaddr_in addrs[CM_INET_NUM_NET_ADDR]; + U32 ipv4_array_size = 0; + +#ifndef IPV6_SUPPORTED + Data address_array[(CM_INET_NUM_NET_ADDR * sizeof(struct sockaddr_in))]; +#else + Data address_array[(CM_INET_NUM_NET_ADDR * sizeof(struct sockaddr_in6))]; +#endif /* IPV6_SUPPORTED */ + +#ifdef IPV6_SUPPORTED +#ifdef SUN_KSCTP + S8 *addrString = NULLP; + U32 addrLen = 0; + S8 ipv4Format[23] = "::ffff:"; + CmInetIpAddr ipv4NetAddr; +#endif /* SUN_KSCTP */ + U32 idx6 = 0; + struct sockaddr_in6 addrs6[CM_INET_NUM_NET_ADDR]; + U32 ipv6_array_size = 0; +#endif /* IPV6_SUPPORTED */ +#ifndef SS_LINUX + U32 sockAddrLen = 0; +#endif /* sockAddrLen */ + +#ifndef SS_LINUX + CmInetSockAddr *sockAddrPtr = NULLP; +#endif /* SS_LINUX */ +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if ((sockFd == NULLP) || CM_INET_INV_SOCK_FD(sockFd) || + (primAddr == NULLP)) + { + RETVALUE(RFAILED); + } + /* cm_inet_c_001.main_58 : Added check for addrLst to fix klockwork issue */ + if (addrLst == NULLP) + { + RETVALUE(RFAILED); + } + /* cm_inet_c_001.main_46: Included check for no of address aginst max */ + if( addrLst->count > CM_INET_NUM_NET_ADDR ) + { +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "No of address(%d) is greater than Max(%d)," + " sockFd->fd(%ld)\n", + addrLst->count, CM_INET_NUM_NET_ADDR, sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET060, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "No of address(%d) is greater than Max(%d)," + " sockFd->fd(%d)\n", + addrLst->count, CM_INET_NUM_NET_ADDR, sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET060, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + + cmMemset((U8*)&addrs, 0, (sizeof(struct sockaddr_in) * CM_INET_NUM_NET_ADDR)); +#ifdef IPV6_SUPPORTED + cmMemset((U8*)&addrs6, 0, (sizeof(struct sockaddr_in6) * CM_INET_NUM_NET_ADDR)); +#endif /* IPV6_SUPPORTED */ + + cnt = 0; + +#ifdef IPV6_SUPPORTED + if (primAddr->type == CM_INET_IPV6ADDR_TYPE) + { + if (sockFd->protType == AF_INET) + { +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54: CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "Can't connect to IPV6 address through IPV4 socket," + " sockFd->fd(%ld)\n", sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET008, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "Can't connect to IPV6 address through IPV4 socket," + " sockFd->fd(%d)\n", sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET008, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + + addrs6[idx6].sin6_family = AF_INET6; + addrs6[idx6].sin6_port = CM_INET_HTON_U16(port); + CM_INET_COPY_IPV6ADDR(&(addrs6[idx6].sin6_addr.s6_addr), &(primAddr->u.ipv6NetAddr)); + addresses_array_size += sizeof(struct sockaddr_in6); + ipv6_array_size += sizeof(struct sockaddr_in6); + idx6++; + } + else + { +#ifdef SUN_KSCTP + if (sockFd->protType == AF_INET) + { +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "can't connect to IPV6 address through IPV4 socket," + " sockFd->fd(%ld)\n", sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET061, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "can't connect to IPV6 address through IPV4 socket," + " sockFd->fd(%d)\n", sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET061, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + addrs6[idx6].sin6_family = AF_INET6; + addrs6[idx6].sin6_port = CM_INET_HTON_U16(port); + ipv4NetAddr = CM_INET_HTON_U32(primAddr->u.ipv4NetAddr); + cmInetNtoa(ipv4NetAddr, &addrString); + addrLen = cmStrlen((U8*)addrString); + cmMemcpy((U8*)(ipv4Format+7), (U8*)addrString, addrLen); + ipv4Format[7+addrLen] = '\0'; + cmInetPton6((CmInetIpAddr6*)&(addrs6[idx6].sin6_addr), ipv4Format); + addresses_array_size += sizeof(struct sockaddr_in6); + ipv6_array_size += sizeof(struct sockaddr_in6); + idx6++; +#else + addrs[idx4].sin_family = AF_INET; + addrs[idx4].sin_port = CM_INET_HTON_U16(port); + addrs[idx4].sin_addr.s_addr = CM_INET_HTON_U32(primAddr->u.ipv4NetAddr); + addresses_array_size += sizeof(struct sockaddr_in); + ipv4_array_size += sizeof(struct sockaddr_in); + idx4++; +#endif + } +#else + addrs[idx4].sin_family = AF_INET; + addrs[idx4].sin_port = CM_INET_HTON_U16(port); + addrs[idx4].sin_addr.s_addr = CM_INET_HTON_U32(primAddr->u.ipv4NetAddr); + addresses_array_size += sizeof(struct sockaddr_in); + ipv4_array_size += sizeof(struct sockaddr_in); + idx4++; +#endif /* IPV6_SUPPORTED */ + + cnt++; + + /* cm_inet_c_001.main_46: Moved the SS_LINUX flag down, + * copy addresses in Solaris also */ + if (addrLst != NULLP) + { + for (idx = 0; idx < addrLst->count; idx++) + { + + /* cm_inet_c_001.main_46: Don't include the primary address + * if its prersent in list */ + if ( addrLst->addrs[idx].type == CM_INET_IPV4ADDR_TYPE ) + { + if ( addrLst->addrs[idx].u.ipv4NetAddr == primAddr->u.ipv4NetAddr ) + { + continue; + } + } +#ifdef IPV6_SUPPORTED + else if ( addrLst->addrs[idx].type == CM_INET_IPV6ADDR_TYPE ) + { + if (( cmMemcmp(addrLst->addrs[idx].u.ipv6NetAddr, + primAddr->u.ipv6NetAddr, sizeof(CmInetIpAddr6) )) == 0 ) + { + continue; + } + } + + if (addrLst->addrs[idx].type == CM_INET_IPV6ADDR_TYPE) + { + if (sockFd->protType == AF_INET) + { +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54: CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "Can't connect to IPV6 address through IPV4 socket," + " sockFd->fd(%ld)\n", sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET009, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "Can't connect to IPV6 address through IPV4 socket," + " sockFd->fd(%d)\n", sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET009, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + + addrs6[idx6].sin6_family = AF_INET6; + addrs6[idx6].sin6_port = CM_INET_HTON_U16(port); + CM_INET_COPY_IPV6ADDR(&(addrs6[idx6].sin6_addr.s6_addr), + &(addrLst->addrs[idx].u.ipv6NetAddr)); + addresses_array_size += sizeof(struct sockaddr_in6); + ipv6_array_size += sizeof(struct sockaddr_in6); + idx6++; + } + else + { +#ifdef SUN_KSCTP + if (sockFd->protType == AF_INET) + { +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "can't connect to IPV6 address through IPV4 socket," + " sockFd->fd(%ld)\n", sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET062, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "can't connect to IPV6 address through IPV4 socket," + " sockFd->fd(%d)\n", sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET062, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + addrs6[idx6].sin6_family = AF_INET6; + addrs6[idx6].sin6_port = CM_INET_HTON_U16(port); + ipv4NetAddr = CM_INET_HTON_U32(addrLst->addrs[idx].u.ipv4NetAddr); + cmInetNtoa(ipv4NetAddr, &addrString); + addrLen = cmStrlen((U8*)addrString); + cmMemcpy((U8*)(ipv4Format+7), (U8*)addrString, addrLen); + ipv4Format[7+addrLen] = '\0'; + cmInetPton6((CmInetIpAddr6*)(addrs6[idx6].sin6_addr.s6_addr), ipv4Format); + addresses_array_size += sizeof(struct sockaddr_in6); + ipv6_array_size += sizeof(struct sockaddr_in6); + idx6++; +#else + addrs[idx4].sin_family = AF_INET; + addrs[idx4].sin_port = CM_INET_HTON_U16(port); + addrs[idx4].sin_addr.s_addr = CM_INET_HTON_U32(addrLst->addrs[idx].u.ipv4NetAddr); + addresses_array_size += sizeof(struct sockaddr_in); + ipv4_array_size += sizeof(struct sockaddr_in); + idx4++; +#endif /* SUN_KSCTP */ + } +#else + addrs[idx4].sin_family = AF_INET; + addrs[idx4].sin_port = CM_INET_HTON_U16(port); + addrs[idx4].sin_addr.s_addr = CM_INET_HTON_U32(addrLst->addrs[idx].u.ipv4NetAddr); + addresses_array_size += sizeof(struct sockaddr_in); + ipv4_array_size += sizeof(struct sockaddr_in); + idx4++; +#endif /* IPV6_SUPPORTED */ + /*cm_inet_c_001.main_39 */ + cnt++; + } + } + + /* cm_inet_c_001.main_46: Moved SS_LINUX flag to here */ +#ifdef SS_LINUX + /*cm_inet_c_001.main_58 : Added check array_size to fix klockwork issue */ + if((ipv4_array_size > 0) && (ipv4_array_size <= (CM_INET_NUM_NET_ADDR * \ + sizeof(struct sockaddr_in)))) + { + cmMemcpy((U8*)address_array, (U8*)&addrs[0], ipv4_array_size); + } + else + { + RETVALUE(RFAILED); + } +#ifdef IPV6_SUPPORTED + if((ipv6_array_size > 0) && (ipv6_array_size <= (CM_INET_NUM_NET_ADDR * \ + sizeof(struct sockaddr_in)))) + { + cmMemcpy((U8*)(address_array + ipv4_array_size), (U8*)addrs6, ipv6_array_size); + } + else + { + RETVALUE(RFAILED); + } +#endif /* IPV6_SUPPORTED */ + + ret = sctp_connectx(sockFd->fd, (struct sockaddr*)address_array, cnt); + +#else + /* solaris */ + /* cm_inet_c_001.main_46: Use next provided address to connect if + * first one fails */ + +#ifdef CMINET_SUN_CONNECTX + idx4 = 0; +#ifdef IPV6_SUPPORTED + idx6 = 0; +#endif /* IPV6_SUPPORTED */ + for (idx = 0; idx < cnt; idx++) + { + if( addrs[idx4].sin_family == AF_INET) + { + sockAddrPtr = (CmInetSockAddr *)&addrs[idx4]; + sockAddrLen = sizeof(struct sockaddr_in); + idx4++; + } +#ifdef IPV6_SUPPORTED + else + { + sockAddrPtr = (CmInetSockAddr *)&addrs6[idx6]; + sockAddrLen = sizeof(struct sockaddr_in6); + idx6++; + } +#endif/* IPV6_SUPPORTED */ + + ret = connect(sockFd->fd, sockAddrPtr, sockAddrLen); + + if ( ret != INET_ERR ) + { + break; + } +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetSctpConnectx() failed:error(%d), port(0x%1x)," + " sockFd->fd(%ld)\n", INET_ERR_CODE, port, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET063, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetSctpConnectx() failed:error(%d), port(0x%1x)," + " sockFd->fd(%d)\n", INET_ERR_CODE, port, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET063, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + + } +#else + + if( addrs[0].sin_family == AF_INET) + { + sockAddrPtr = (CmInetSockAddr*)&addrs[0]; + sockAddrLen = sizeof(struct sockaddr_in); + idx4++; + } +#ifdef IPV6_SUPPORTED + else + { + sockAddrPtr = (CmInetSockAddr*)&addrs6[0]; + sockAddrLen = sizeof(struct sockaddr_in6); + idx6++; + } +#endif/* IPV6_SUPPORTED */ + + ret = connect(sockFd->fd, sockAddrPtr, sockAddrLen); + +#endif /* CMINET_SUN_CONNECTX */ +#endif /* SS_LINUX */ + + if (ret == INET_ERR) + { +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54: CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "CmInetSctpConnectx() Failed : error(%d), port(0x%1x)," + " sockFd->fd(%ld)\n", INET_ERR_CODE, port, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET010, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "CmInetSctpConnectx() Failed : error(%d), port(0x%1x)," + " sockFd->fd(%d)\n", INET_ERR_CODE, port, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET010, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + + switch (INET_ERR_CODE) + { + /* non-blocking: connection is in progress */ + case ERR_INPROGRESS: + RETVALUE(RINPROGRESS); + break; + + /* + * non-blocking: connection is established + * blocking : connection is already established + */ + case ERR_ISCONN: + RETVALUE(RISCONN); + break; + + /* resource temporarily unavailable */ + case ERR_WOULDBLOCK: + RETVALUE(ROKDNA); + break; + + /* non-blocking: connection is in progress */ + case ERR_ALREADY: + RETVALUE(RINPROGRESS); + break; + + case ERR_INVAL: + RETVALUE(RINPROGRESS); + break; + + /* Check for connection refused and timeout errors */ + case ERR_CONNREFUSED: + case ERR_TIMEDOUT: + RETVALUE(RCLOSED); + break; + + /* it is a real error */ + default: + RETVALUE(RFAILED); + break; + } + } + + RETVALUE(ROK); +} + +/* +* +* Fun: cmInetSctpPeelOff +* +* Desc: Branches an existing sctp association off to a seperate socket +* +* Ret: ROK - successful +* RFAILED - failed +* +* Notes: None. +* +* File: cm_inet.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmInetSctpPeelOff +( +CmInetFd *sockFd, /* socket file descriptor */ +U32 assocId, /* association id */ +CmInetFdType *assocFd /* association fd */ +) +#else +PUBLIC S16 cmInetSctpPeelOff(sockFd, assocId, assocFd) +CmInetFd *sockFd; /* socket file descriptor */ +U32 assocId; /* association id */ +CmInetFdType *assocFd; /* association fd */ +#endif +{ + S32 ret; + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if ((sockFd == NULLP) || CM_INET_INV_SOCK_FD(sockFd) || (assocFd == NULLP)) + { + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + + ret = sctp_peeloff(sockFd->fd, assocId); + if (ret == INET_ERR) + { +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54: CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetSctpPeelOff() Failed : error(%d) assocId(%ld)," + " sockFd->fd(%ld)\n", INET_ERR_CODE, assocId, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET011, 0, prntBuf); +#else + /* cm_inet_c_001.main_55: Fix for compilation warning */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetSctpPeelOff() Failed : error(%d) assocId(%d)," + " sockFd->fd(%d)\n", INET_ERR_CODE, assocId, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET011, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + + RETVALUE(RFAILED); + } + + *assocFd = ret; + + RETVALUE(ROK); +} + +/* +* +* Fun: cmInetSctpSendMsg +* +* Desc: invokes sctp socket API to send message to the remote addresses +* +* Ret: ROK - successful +* RFAILED - failed +* +* Notes: None. +* +* File: cm_inet.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmInetSctpSendMsg +( +CmInetFd *sockFd, /* socket file descriptor */ +CmInetNetAddr *dstAddr, /* destination Internet address/port */ +U16 port, /* destination port no. */ +CmInetMemInfo *info, /* buffer allocation info */ +Buffer *mBuf, /* buffer structure to send */ +MsgLen *len, /* number of actually sent octets */ +U16 strmId, /* sctp stream identifier */ +Bool unorderFlg, /* flag to enable the unordered delivery */ +U16 ttl, /* time to live */ +U32 ppId, /* opaque value passed along with the message */ +U32 context /* value to be passed back, if error occurs */ +) +#else +PUBLIC S16 cmInetSctpSendMsg(sockFd, dstAddr, port, info, mBuf, len, strmId, + unorderFlg, ttl, ppId, context) +CmInetFd *sockFd; /* socket file descriptor */ +CmInetNetAddr *dstAddr; /* destination Internet address/port */ +U16 port; /* destination port no. */ +CmInetMemInfo *info; /* buffer allocation info */ +Buffer *mBuf; /* buffer structure to send */ +MsgLen *len; /* number of actually sent octets */ +U16 strmId; /* sctp stream identifier */ +Bool unorderFlg; /* flag to enable the unordered delivery */ +U16 ttl; /* time to live */ +U32 ppId; /* opaque value passed along with the message */ +U32 context; /* value to be passed back, if error occurs */ +#endif +{ + S32 ret; + /* cm_inet_c_001.main_58 : Fix for klockwork issue */ + MsgLen msgLen = 0; /* message length */ + MsgLen bufLen = 0; /* send buffer length */ + Data *sendBuf = NULLP; /* plain send buffer */ + U32 flags; + CmInetSockAddr *sockAddrPtr = NULLP; + /* cm_inet_c_001.main_58 : Fix for klockwork issue */ + MsgLen sockAddrLen = 0; + struct sockaddr_in addr; +#ifdef IPV6_SUPPORTED +#ifdef SUN_KSCTP + S8 *addrString = NULLP; + U32 addrLen = 0; + S8 ipv4Format[23] = "::ffff:"; + CmInetIpAddr ipv4NetAddr; +#endif /* SUN_KSCTP */ + struct sockaddr_in6 addr6; +#endif /* IPV6_SUPPORTED */ + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if ((sockFd == NULLP) || CM_INET_INV_SOCK_FD(sockFd) + || (info == NULLP) || (mBuf == NULLP) || (len == NULLP)) + { + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + + cmMemset((U8*)&addr, 0, sizeof(struct sockaddr_in)); +#ifdef IPV6_SUPPORTED + cmMemset((U8*)&addr6, 0, sizeof(struct sockaddr_in6)); +#endif /* IPV6_SUPPORTED */ + + /* copy message to a flat buffer */ + ret = SFndLenMsg(mBuf, &bufLen); + if (ret != ROK) + { + RETVALUE(RFAILED); + } + /* max message length is limited to control the memory usage */ + /* casting bufLen to avoid warnings */ + if ((bufLen > 0) && ((U32)bufLen > CM_INET_MAX_MSG_LEN)) + { + RETVALUE(RFAILED); + } + ret = SGetSBuf(info->region, info->pool, &sendBuf, bufLen); + if (ret != ROK) + { + RETVALUE(ROUTRES); + } + ret = SCpyMsgFix(mBuf, 0, bufLen, sendBuf, &msgLen); + if ((ret != ROK) || (msgLen != bufLen)) + { + SPutSBuf(info->region, info->pool, sendBuf, bufLen); + RETVALUE(RFAILED); + } + + if ( dstAddr != NULLP) + { +#ifdef IPV6_SUPPORTED + if (dstAddr->type == CM_INET_IPV6ADDR_TYPE) + { + if (sockFd->protType == AF_INET) + { + SPutSBuf(info->region, info->pool, sendBuf, bufLen); +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54: CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "Can't send message to IPV6 address through" + " IPV4 socket, sockFd->fd(%ld)\n", sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET012, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "Can't send message to IPV6 address through" + " IPV4 socket, sockFd->fd(%d)\n", sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET012, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + + addr6.sin6_family = AF_INET6; + addr6.sin6_port = CM_INET_HTON_U16(port); + CM_INET_COPY_IPV6ADDR(&addr6.sin6_addr.s6_addr, &dstAddr->u.ipv6NetAddr); + sockAddrLen = sizeof(struct sockaddr_in6); + sockAddrPtr = (CmInetSockAddr*)&addr6; + } + else + { + +#ifdef SUN_KSCTP + if (sockFd->protType == AF_INET) + { +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "can't connect to IPV6 address through IPV4" + " socket, sockFd->fd(%ld)\n", sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET064, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "can't connect to IPV6 address through IPV4" + " socket, sockFd->fd(%d)\n", sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET064, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + addr6.sin6_family = AF_INET6; + addr6.sin6_port = CM_INET_HTON_U16(port); + ipv4NetAddr = CM_INET_HTON_U32(dstAddr->u.ipv4NetAddr); + cmInetNtoa(ipv4NetAddr, &addrString); + addrLen = cmStrlen((U8*)addrString); + cmMemcpy((U8*)(ipv4Format+7), (U8*)addrString, addrLen); + ipv4Format[7+addrLen] = '\0'; + cmInetPton6((CmInetIpAddr6*)(addr6.sin6_addr.s6_addr), ipv4Format); + sockAddrLen = sizeof(struct sockaddr_in6); + sockAddrPtr = (CmInetSockAddr*)&addr6; +#else + addr.sin_family = AF_INET; + addr.sin_port = CM_INET_HTON_U16(port); + addr.sin_addr.s_addr = CM_INET_HTON_U32(dstAddr->u.ipv4NetAddr); + sockAddrLen = sizeof(struct sockaddr_in); + sockAddrPtr = (CmInetSockAddr*)&addr; +#endif /* SUN_KSCTP */ + } +#else + addr.sin_family = AF_INET; + addr.sin_port = CM_INET_HTON_U16(port); + addr.sin_addr.s_addr = CM_INET_HTON_U32(dstAddr->u.ipv4NetAddr); + /* cm_inet_c_001.main_58 : Fix for Klockwork issue */ + sockAddrLen = (MsgLen)sizeof(struct sockaddr_in); + sockAddrPtr = (CmInetSockAddr*)&addr; +#endif /* IPV6_SUPPORTED */ + } + else + { +#ifdef SUN_KSCTP + sockAddrPtr = NULL; +#else + sockAddrPtr = (CmInetSockAddr*)&addr; +#endif + /* cm_inet_c_001.main_58 : initialized sockAddrLen properly */ +#ifdef IPV6_SUPPORTED + sockAddrLen = sizeof(struct sockaddr_in6); +#else + sockAddrLen = sizeof(struct sockaddr_in); +#endif + } + + /* Not validating the address, whether addr is a valid address or not */ + + *len = 0; + flags = 0x00000000; + + if (unorderFlg == TRUE) + { +#ifdef SUN_KSCTP + flags |= MSG_UNORDERED; +#else + /* linux */ + flags |= SCTP_UNORDERED; +#endif + } + /*cm_inet_c_001.main_54: converting ppid to network*/ + ppId = CM_INET_HTON_U32(ppId); + ret = sctp_sendmsg(sockFd->fd, (Void*)sendBuf, bufLen, + (struct sockaddr*)sockAddrPtr, (size_t)sockAddrLen, + ppId, flags, strmId, ttl, context); + if (ret == INET_ERR) + { + SPutSBuf(info->region, info->pool, sendBuf, bufLen); +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54: CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetSctpSendMsg() Failed : error(%d) ppId(%ld)," + " strmId(%u),sockFd->fd(%ld)\n", + INET_ERR_CODE, ppId, strmId, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET013, 0, prntBuf); +#else + /* cm_inet_c_001.main_55: Fix for compilation warning */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetSctpSendMsg() Failed : error(%d) ppId(%d)," + " strmId(%u),sockFd->fd(%d)\n", + INET_ERR_CODE, ppId, strmId, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET013, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + + if ((INET_ERR_CODE == ERR_AGAIN) || (INET_ERR_CODE == ERR_WOULDBLOCK)) + RETVALUE(RWOULDBLOCK); + else if (INET_ERR_CODE == ERR_PIPE) + RETVALUE(RCLOSED); + else + RETVALUE(RFAILED); + } + + /* cm_inet_c_001.main_58 : Fix for klockwork issue */ + *len = (MsgLen)ret; + + /* cleanup */ + SPutSBuf(info->region, info->pool, sendBuf, bufLen); + + RETVALUE(ROK); +} + +/* +* +* Fun: cmInetSctpRecvMsg +* +* Desc: invokes sctp API to get the message received at sctp socket +* +* Ret: ROK - successful +* RFAILED - failed +* +* Notes: None. +* +* File: cm_inet.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmInetSctpRecvMsg +( +CmInetFd *sockFd, /* socket file descriptor */ +CmInetNetAddr *srcAddr, /* source Internet address/port */ +U16 *port, /* source port no. */ +CmInetMemInfo *meminfo, /* buffer allocation info */ +Buffer **mBuf, /* buffer structure received */ +MsgLen *len, /* number of octets received */ +CmInetSctpSndRcvInfo *sinfo, /* sctp send-receive info */ +U32 *flag, /* flags */ +CmInetSctpNotification *ntfy /* notification parameters */ +) +#else +PUBLIC S16 cmInetSctpRecvMsg(sockFd, srcAddr, port, meminfo, mBuf, len, + sinfo, flag, ntfy) +CmInetFd *sockFd; /* socket file descriptor */ +CmInetNetAddr *srcAddr; /* source Internet address/port */ +U16 *port; /* source port no. */ +CmInetMemInfo *meminfo; /* buffer allocation info */ +Buffer **mBuf; /* buffer structure received */ +MsgLen *len; /* number of octets received */ +CmInetSctpSndRcvInfo *sinfo; /* sctp send-receive info */ +U32 *flag; /* flags */ +CmInetSctpNotification *ntfy; /* notification parameters */ +#endif +{ + S32 ret; + S32 msgFlags; + struct sctp_sndrcvinfo info; + struct sockaddr_storage addr; + struct sockaddr_in *pAddr = NULLP; +#ifdef IPV6_SUPPORTED + struct sockaddr_in6 *pAddr6 = NULLP; +#endif + socklen_t addrlen; + Data *recvbuf = NULLP; + MsgLen buflen; + union sctp_notification *sctpNtfy = NULLP; + /* cm_inet_c_001.main_46: Defined new variable to store length of data */ +#ifdef SS_LINUX + MsgLen datlen; +#endif /* SS_LINUX */ + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if ((sockFd == NULLP) || CM_INET_INV_SOCK_FD(sockFd) || + (srcAddr == NULLP) || (port == NULLP) || (meminfo == NULLP) || + (mBuf == NULLP) || (len == NULLP) || (sinfo == NULLP) || (flag == NULLP)) + { + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + + *mBuf = NULLP; + *len = 0; + cmMemset((U8*)ntfy, 0, sizeof(CmInetSctpNotification)); + + buflen = CM_INET_MAX_MSG_LEN; + + /* allocate flat receive buffer */ + ret = SGetSBuf(meminfo->region, meminfo->pool, &recvbuf, buflen); + if (ret != ROK) + { +#ifdef CMINETDBG + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "SGetSBuf failed to allocate memory\n"); + CMINETLOGERROR(ERRCLS_ADD_RES, ECMINET065, 0, prntBuf); +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + + addrlen = sizeof(struct sockaddr_storage); + msgFlags = 0; + cmMemset((U8*)&addr, 0, sizeof(struct sockaddr_storage)); + cmMemset((U8*)&info, 0, sizeof(struct sctp_sndrcvinfo)); + + ret = sctp_recvmsg(sockFd->fd, (Void *)recvbuf, (size_t)buflen, + (struct sockaddr*)&addr, &addrlen, &info, + (int*)&msgFlags); + if (ret == INET_ERR) + { + /* cleanup */ + SPutSBuf(meminfo->region, meminfo->pool, recvbuf, buflen); +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54: CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetSctpRecvMsg() Failed : error(%d)," + " sockFd->fd(%ld)\n", INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET014, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetSctpRecvMsg() Failed : error(%d)," + " sockFd->fd(%d)\n", INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET014, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + + RETVALUE(RFAILED); + } + + /* save the length of the received message */ + /* cm_inet_c_001.main_58 : Fix for klockwork issue */ + *len = (MsgLen)ret; + +#ifdef IPV6_SUPPORTED + if (addr.ss_family == AF_INET6) + { + U8 ipv4Format[12] = {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0xff}; + pAddr6 = (struct sockaddr_in6*)&addr; + *port = CM_INET_NTOH_U16(pAddr6->sin6_port); + + if((cmMemcmp(ipv4Format, pAddr6->sin6_addr.s6_addr, 12)) == 0) + { + srcAddr->type = CM_INET_IPV4ADDR_TYPE; + cmMemcpy((U8*)&srcAddr->u.ipv4NetAddr, (U8*)((pAddr6->sin6_addr.s6_addr) + 12), sizeof(U32)); + srcAddr->u.ipv4NetAddr = CM_INET_HTON_U32(srcAddr->u.ipv4NetAddr); + } + + else + { + srcAddr->type = CM_INET_IPV6ADDR_TYPE; + CM_INET_COPY_IPV6ADDR(&srcAddr->u.ipv6NetAddr, &pAddr6->sin6_addr.s6_addr); + } + } + else + { + pAddr = (struct sockaddr_in*)&addr; + *port = CM_INET_NTOH_U16(pAddr->sin_port); + srcAddr->type = CM_INET_IPV4ADDR_TYPE; + srcAddr->u.ipv4NetAddr = CM_INET_NTOH_U32(pAddr->sin_addr.s_addr); + } +#else + pAddr = (struct sockaddr_in*)&addr; + *port = CM_INET_NTOH_U16(pAddr->sin_port); + srcAddr->type = CM_INET_IPV4ADDR_TYPE; + srcAddr->u.ipv4NetAddr = CM_INET_NTOH_U32(pAddr->sin_addr.s_addr); +#endif /* IPV6_SUPPORTED */ + + /* fill sndrcv info */ + sinfo->stream = info.sinfo_stream; + sinfo->ssn = info.sinfo_ssn; + sinfo->flags = info.sinfo_flags; + /*cm_inet_c_001.main_54: converting ppid to host*/ + sinfo->ppid = CM_INET_NTOH_U32(info.sinfo_ppid); + sinfo->context = info.sinfo_context; + sinfo->timetolive = info.sinfo_timetolive; + sinfo->tsn = info.sinfo_tsn; + sinfo->cumtsn = info.sinfo_cumtsn; + sinfo->assocId = info.sinfo_assoc_id; + + /* fill message flags */ + *flag = 0; + if ((msgFlags & MSG_EOR) != 0) + *flag |= CM_INET_SCTP_MSG_EOR; + + if ((msgFlags & MSG_NOTIFICATION) != 0) + { + *flag |= CM_INET_SCTP_MSG_NOTIFICATION; + *mBuf = NULLP; + + sctpNtfy = (union sctp_notification*)recvbuf; + + ntfy->header.nFlags = sctpNtfy->sn_header.sn_flags; + ntfy->header.nLen = sctpNtfy->sn_header.sn_length; + + switch(sctpNtfy->sn_header.sn_type) + { + case SCTP_ASSOC_CHANGE: + ntfy->header.nType = CM_INET_SCTP_ASSOC_CHANGE; + switch(sctpNtfy->sn_assoc_change.sac_state) + { + case SCTP_COMM_UP: + ntfy->u.assocChange.state = CM_INET_SCTP_COMM_UP; + break; + case SCTP_COMM_LOST: + ntfy->u.assocChange.state = CM_INET_SCTP_COMM_LOST; + break; + case SCTP_RESTART: + ntfy->u.assocChange.state = CM_INET_SCTP_RESTART; + break; + case SCTP_SHUTDOWN_COMP: + ntfy->u.assocChange.state = CM_INET_SCTP_SHUTDOWN_COMP; + break; + case SCTP_CANT_STR_ASSOC: + ntfy->u.assocChange.state = CM_INET_SCTP_CANT_STR_ASSOC; + break; + default: + break; + } + ntfy->u.assocChange.error = sctpNtfy->sn_assoc_change.sac_error; + ntfy->u.assocChange.outStreams = sctpNtfy->sn_assoc_change.sac_outbound_streams; + ntfy->u.assocChange.inStreams = sctpNtfy->sn_assoc_change.sac_inbound_streams; + ntfy->u.assocChange.assocId = sctpNtfy->sn_assoc_change.sac_assoc_id; +#ifdef SS_LINUX + ntfy->u.assocChange.info = sctpNtfy->sn_assoc_change.sac_info; +#endif + break; + case SCTP_PEER_ADDR_CHANGE: + ntfy->header.nType = CM_INET_SCTP_PEER_ADDR_CHANGE; + switch(sctpNtfy->sn_paddr_change.spc_state) + { + case SCTP_ADDR_AVAILABLE: + ntfy->u.paddrChange.state = CM_INET_SCTP_ADDR_AVAILABLE; + break; + case SCTP_ADDR_UNREACHABLE: + ntfy->u.paddrChange.state = CM_INET_SCTP_ADDR_UNREACHABLE; + break; + case SCTP_ADDR_REMOVED: + ntfy->u.paddrChange.state = CM_INET_SCTP_ADDR_REMOVED; + break; + case SCTP_ADDR_ADDED: + ntfy->u.paddrChange.state = CM_INET_SCTP_ADDR_ADDED; + break; + case SCTP_ADDR_MADE_PRIM: + ntfy->u.paddrChange.state = CM_INET_SCTP_ADDR_MADE_PRIM; + break; +#ifdef SS_LINUX + case SCTP_ADDR_CONFIRMED: + ntfy->u.paddrChange.state = CM_INET_SCTP_ADDR_CONFIRMED; + break; +#endif + default: + break; + } + +#ifdef IPV6_SUPPORTED + if (sctpNtfy->sn_paddr_change.spc_aaddr.ss_family == AF_INET6) + { + pAddr6 = (struct sockaddr_in6*)&(sctpNtfy->sn_paddr_change.spc_aaddr); + ntfy->u.paddrChange.addr.type = CM_INET_IPV6ADDR_TYPE; + CM_INET_COPY_IPV6ADDR(&ntfy->u.paddrChange.addr.u.ipv6NetAddr, + &pAddr6->sin6_addr.s6_addr); + } + else + { + pAddr = (struct sockaddr_in*)&(sctpNtfy->sn_paddr_change.spc_aaddr); + ntfy->u.paddrChange.addr.type = CM_INET_IPV4ADDR_TYPE; + ntfy->u.paddrChange.addr.u.ipv4NetAddr = CM_INET_NTOH_U32(pAddr->sin_addr.s_addr); + } +#else + pAddr = (struct sockaddr_in*)&(sctpNtfy->sn_paddr_change.spc_aaddr); + ntfy->u.paddrChange.addr.type = CM_INET_IPV4ADDR_TYPE; + ntfy->u.paddrChange.addr.u.ipv4NetAddr = CM_INET_NTOH_U32(pAddr->sin_addr.s_addr); +#endif /* IPV6_SUPPORTED */ + + ntfy->u.paddrChange.error = sctpNtfy->sn_paddr_change.spc_error; + ntfy->u.paddrChange.assocId = sctpNtfy->sn_paddr_change.spc_assoc_id; + break; + case SCTP_REMOTE_ERROR: + ntfy->header.nType = CM_INET_SCTP_REMOTE_ERROR; + + ntfy->u.remoteErr.error = sctpNtfy->sn_remote_error.sre_error; + ntfy->u.remoteErr.assocId = sctpNtfy->sn_remote_error.sre_assoc_id; +#ifdef SS_LINUX + /* cm_inet_c_001.main_46: Allocate memory for data before copying */ + datlen = cmStrlen(sctpNtfy->sn_remote_error.sre_data) + 1; + + ret = SGetSBuf( meminfo->region, meminfo->pool, \ + &ntfy->u.remoteErr.data, datlen ); + if( ret != ROK ) + { + ntfy->u.remoteErr.data = NULLP; + break; + } + cmMemcpy(ntfy->u.remoteErr.data,\ + sctpNtfy->sn_remote_error.sre_data, datlen); +#endif + break; + case SCTP_SEND_FAILED: + ntfy->header.nType = CM_INET_SCTP_SEND_FAILED; + + ntfy->u.sndFailed.error = sctpNtfy->sn_send_failed.ssf_error; + ntfy->u.sndFailed.assocId = sctpNtfy->sn_send_failed.ssf_assoc_id; +#ifdef SS_LINUX + /* cm_inet_c_001.main_46: Allocate memory for data before copying */ + datlen = cmStrlen(sctpNtfy->sn_send_failed.ssf_data) + 1; + + ret = SGetSBuf( meminfo->region, meminfo->pool, \ + &ntfy->u.sndFailed.data, datlen ); + if( ret != ROK ) + { + ntfy->u.sndFailed.data = NULLP; + break; + } + cmMemcpy(ntfy->u.sndFailed.data,\ + sctpNtfy->sn_send_failed.ssf_data, datlen ); +#endif + ntfy->u.sndFailed.info.stream = sctpNtfy->sn_send_failed.ssf_info.sinfo_stream; + ntfy->u.sndFailed.info.ssn = sctpNtfy->sn_send_failed.ssf_info.sinfo_ssn; + ntfy->u.sndFailed.info.flags = sctpNtfy->sn_send_failed.ssf_info.sinfo_flags; + ntfy->u.sndFailed.info.ppid = sctpNtfy->sn_send_failed.ssf_info.sinfo_ppid; + ntfy->u.sndFailed.info.context = sctpNtfy->sn_send_failed.ssf_info.sinfo_context; + ntfy->u.sndFailed.info.timetolive = sctpNtfy->sn_send_failed.ssf_info.sinfo_timetolive; + ntfy->u.sndFailed.info.tsn = sctpNtfy->sn_send_failed.ssf_info.sinfo_tsn; + ntfy->u.sndFailed.info.cumtsn = sctpNtfy->sn_send_failed.ssf_info.sinfo_cumtsn; + ntfy->u.sndFailed.info.assocId = sctpNtfy->sn_send_failed.ssf_info.sinfo_assoc_id; + break; + case SCTP_SHUTDOWN_EVENT: + ntfy->header.nType = CM_INET_SCTP_SHUTDOWN_EVENT; + + ntfy->u.shutdownEvt.assocId = sctpNtfy->sn_shutdown_event.sse_assoc_id; + break; +#ifdef SUN_KSCTP + case SCTP_ADAPTION_INDICATION : +#else + /* linux */ + case SCTP_ADAPTATION_INDICATION : +#endif + ntfy->header.nType = CM_INET_SCTP_ADAPTATION_INDICATION; + +#ifdef SUN_KSCTP + ntfy->u.adaptationEvt.adaptationInd = sctpNtfy->sn_adaption_event.sai_adaption_ind; + ntfy->u.adaptationEvt.assocId = sctpNtfy->sn_adaption_event.sai_assoc_id; +#else + /* linux */ + ntfy->u.adaptationEvt.adaptationInd = sctpNtfy->sn_adaptation_event.sai_adaptation_ind; + ntfy->u.adaptationEvt.assocId = sctpNtfy->sn_adaptation_event.sai_assoc_id; +#endif + break; + case SCTP_PARTIAL_DELIVERY_EVENT: + ntfy->header.nType = CM_INET_SCTP_PARTIAL_DELIVERY_EVENT; + + ntfy->u.pdapiEvt.indication = sctpNtfy->sn_pdapi_event.pdapi_indication; + ntfy->u.pdapiEvt.assocId = sctpNtfy->sn_pdapi_event.pdapi_assoc_id; + break; + default: + break; + } + } + else + { + /* get a message buffer */ + ret = SGetMsg(meminfo->region, meminfo->pool, mBuf); + if (ret != ROK) + { + SPutSBuf(meminfo->region, meminfo->pool, recvbuf, buflen); + RETVALUE(RFAILED); + } + + ret = SAddPstMsgMult(recvbuf, *len, *mBuf); + if (ret != ROK) + { + SPutMsg(*mBuf); + SPutSBuf(meminfo->region, meminfo->pool, recvbuf, buflen); + RETVALUE(RFAILED); + } + } + + /* cleanup */ + SPutSBuf(meminfo->region, meminfo->pool, recvbuf, buflen); + + RETVALUE(ROK); +} + +/* +* +* Fun: cmInetSctpGetPAddrs +* +* Desc: returns the list of peer addresses +* +* Ret: ROK - successful +* RFAILED - failed +* +* Notes: None. +* +* File: cm_inet.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmInetSctpGetPAddrs +( +CmInetFd *sockFd, /* socket file descriptor */ +U32 assocId, /* association id */ +CmInetNetAddrLst *addrlst /* peer address list */ +) +#else +PUBLIC S16 cmInetSctpGetPAddrs(sockFd, assocId, addrlst) +CmInetFd *sockFd; /* socket file descriptor */ +U32 assocId; /* association id */ +CmInetNetAddrLst *addrlst; /* peer address list */ +#endif +{ + /* cm_inet_c_001.main_58 : Fix for Klockwork issue */ + S32 cnt; + S32 idx; + U8 *byteAddress; + struct sockaddr *peerAddrList; + struct sockaddr_in *pAddr; +#ifdef IPV6_SUPPORTED + struct sockaddr_in6 *pAddr6; +#endif /* IPV6_SUPPORTED */ + +#ifdef SUN_KSCTP + if((cnt = sctp_getpaddrs(sockFd->fd, assocId, (Void**)&peerAddrList)) == -1) +#else + if((cnt = sctp_getpaddrs(sockFd->fd, assocId, &peerAddrList)) == -1) +#endif + { +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetSctpGetPAddrs() Failed : error(%d)," + " sockFd->fd(%ld), assocId(%ld)\n", + INET_ERR_CODE, sockFd->fd, assocId); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET015, 0, prntBuf); +#else + /* cm_inet_c_001.main_55: Fix for compilation warning */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetSctpGetPAddrs() Failed : error(%d)," + " sockFd->fd(%d),assocId(%d)\n", + INET_ERR_CODE, sockFd->fd, assocId); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET015, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + + RETVALUE(RFAILED); + } + + byteAddress = (U8*)peerAddrList; + for (idx = 0; idx < cnt; idx++) + { +#ifdef IPV6_SUPPORTED + + if (((struct sockaddr*)byteAddress)->sa_family == AF_INET6) + { + if (sockFd->protType == AF_INET) + { +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54: CMINETLOGERROR added insted of SDisp */ + sprintf(prntBuf, "cmInetSctpGetPAddrs() Failed : Invalid address" + " sockFd->fd(%ld)", sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET016, 0, prntBuf); +#else + sprintf(prntBuf, "cmInetSctpGetPAddrs() Failed : Invalid address" + " sockFd->fd(%d)", sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET016, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + + sctp_freepaddrs(peerAddrList); + RETVALUE(RFAILED); + } + + pAddr6 = (struct sockaddr_in6*)byteAddress; + + addrlst->addrs[idx].type = CM_INET_IPV6ADDR_TYPE; + CM_INET_COPY_IPV6ADDR(&(addrlst->addrs[idx].u.ipv6NetAddr), &(pAddr6->sin6_addr.s6_addr)); + byteAddress += sizeof(struct sockaddr_in6); + } + else + { + pAddr = (struct sockaddr_in*)byteAddress; + addrlst->addrs[idx].type = CM_INET_IPV4ADDR_TYPE; + addrlst->addrs[idx].u.ipv4NetAddr = CM_INET_NTOH_U32(pAddr->sin_addr.s_addr); + byteAddress += sizeof(struct sockaddr_in); + } +#else + pAddr = (struct sockaddr_in*)byteAddress; + addrlst->addrs[idx].type = CM_INET_IPV4ADDR_TYPE; + addrlst->addrs[idx].u.ipv4NetAddr = CM_INET_NTOH_U32(pAddr->sin_addr.s_addr); + byteAddress += sizeof(struct sockaddr_in); +#endif /* IPV6_SUPPORTED */ + } + + /* cm_inet_c_001.main_58 : Fix for klockwork issue */ + addrlst->count = (U8)cnt; + + sctp_freepaddrs(peerAddrList); + + RETVALUE(ROK); +} + +/* +* +* Fun: cmInetGetOpt +* +* Desc: invokes socket API to retrive specified socket options +* +* Ret: ROK - successful +* RFAILED - failed +* +* Notes: +* +* File: cm_inet.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmInetGetOpt +( +CmInetFd *sockFd, /* socket file descriptor */ +U32 level, /* option level */ +U32 type, /* option type */ +Ptr value /* option value */ +) +#else +PUBLIC S16 cmInetGetOpt(sockFd, level, type, value) +CmInetFd *sockFd; /* socket file descriptor */ +U32 level; /* option level */ +U32 type; /* option type */ +Ptr value; /* option value */ +#endif +{ + socklen_t len; + struct sctp_status status; + struct sctp_paddrinfo addrInfo; + struct sockaddr_in *pAddr; +#ifdef IPV6_SUPPORTED + struct sockaddr_in6 *pAddr6; +#endif /* IPV6_SUPPORTED */ + struct sctp_assocparams assocParams; +/*cm_inet_c_001.main_40 Updated for the support of configurable RTO parameters, + HBeat value Max retransmissions (Init, Path, Association)*/ + struct sctp_initmsg initMsg; + struct sctp_rtoinfo rtoInfo; + struct sctp_paddrparams addrParams; + CmInetSctpStatus *pSctpStatus; + CmInetSctpPeerAddrInfo *pPeerAddrInfo; + CmInetSctpInitMsg *pInitMsg; + CmInetSctpAssocParams *pAssocParams; + CmInetSctpRtoInfo *pRtoInfo; + CmInetSctpPeerAddrParams *pPeerAddrParams; + /*cm_inet_c_001.main_58 : fix for klockwork issue */ + S32 ret; + + TRC2(cmInetGetOpt); + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if ((sockFd == NULLP) || CM_INET_INV_SOCK_FD(sockFd)) + { + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + switch (type) + { + case CM_INET_OPT_SCTP_GET_ASSOC_STA: + pSctpStatus = (CmInetSctpStatus*)value; + cmMemset((U8*)&status, 0, sizeof(struct sctp_status)); + len = sizeof(status); + status.sstat_assoc_id = pSctpStatus->assocId; + + ret = getsockopt(sockFd->fd, level, SCTP_STATUS, &status, &len); + + pSctpStatus->rwnd = status.sstat_rwnd; + pSctpStatus->unackdata = status.sstat_unackdata; + pSctpStatus->penddata = status.sstat_penddata; + pSctpStatus->instrms = status.sstat_instrms; + pSctpStatus->outstrms = status.sstat_outstrms; + pSctpStatus->fragPoint = status.sstat_fragmentation_point; + + switch (status.sstat_state) + { +#ifdef SUN_KSCTP + case SCTPS_IDLE: + case SCTPS_BOUND: + case SCTPS_LISTEN: +#else + case SCTP_EMPTY: +#endif + { + pSctpStatus->state = CM_INET_SCTP_STA_EMPTY; + } + break; + +#ifdef SS_LINUX + case SCTP_CLOSED: + { + pSctpStatus->state = CM_INET_SCTP_STA_CLOSED; + } + break; +#endif + +#ifdef SUN_KSCTP + case SCTPS_COOKIE_WAIT: +#else + case SCTP_COOKIE_WAIT: +#endif + { + pSctpStatus->state = CM_INET_SCTP_STA_COOKIE_WAIT; + } + break; + +#ifdef SUN_KSCTP + case SCTPS_COOKIE_ECHOED: +#else + case SCTP_COOKIE_ECHOED: +#endif + { + pSctpStatus->state = CM_INET_SCTP_STA_COOKIE_ECHOED; + } + break; + +#ifdef SUN_KSCTP + case SCTPS_ESTABLISHED: +#else + case SCTP_ESTABLISHED: +#endif + { + pSctpStatus->state = CM_INET_SCTP_STA_ESTABLISHED; + } + break; + +#ifdef SUN_KSCTP + case SCTPS_SHUTDOWN_PENDING: +#else + case SCTP_SHUTDOWN_PENDING: +#endif + { + pSctpStatus->state = CM_INET_SCTP_STA_SHUTDOWN_PENDING; + } + break; + +#ifdef SUN_KSCTP + case SCTPS_SHUTDOWN_SENT: +#else + case SCTP_SHUTDOWN_SENT: +#endif + { + pSctpStatus->state = CM_INET_SCTP_STA_SHUTDOWN_SENT; + } + break; + +#ifdef SUN_KSCTP + case SCTPS_SHUTDOWN_RECEIVED: +#else + case SCTP_SHUTDOWN_RECEIVED: +#endif + { + pSctpStatus->state = CM_INET_SCTP_STA_SHUTDOWN_RECEIVED; + } + break; + +#ifdef SUN_KSCTP + case SCTPS_SHUTDOWN_ACK_SENT: +#else + case SCTP_SHUTDOWN_ACK_SENT: +#endif + { + pSctpStatus->state = CM_INET_SCTP_STA_SHUTDOWN_ACK_SENT; + } + break; + + default: + { + RETVALUE(RFAILED); + } + break; + } + +#ifdef IPV6_SUPPORTED + if (status.sstat_primary.spinfo_address.ss_family == AF_INET6) + { + pAddr6 = (struct sockaddr_in6*)&(status.sstat_primary.spinfo_address); + pSctpStatus->primary.port = CM_INET_NTOH_U16(pAddr6->sin6_port); + + pSctpStatus->primary.addr.type = CM_INET_IPV6ADDR_TYPE; + CM_INET_COPY_IPV6ADDR(&pSctpStatus->primary.addr.u.ipv6NetAddr, + &pAddr6->sin6_addr.s6_addr); + } + else + { + pAddr = (struct sockaddr_in*)&(status.sstat_primary.spinfo_address); + pSctpStatus->primary.port = CM_INET_NTOH_U16(pAddr->sin_port); + pSctpStatus->primary.addr.type = CM_INET_IPV4ADDR_TYPE; + pSctpStatus->primary.addr.u.ipv4NetAddr = CM_INET_NTOH_U32(pAddr->sin_addr.s_addr); + } +#else + pAddr = (struct sockaddr_in*)&(status.sstat_primary.spinfo_address); + pSctpStatus->primary.port = CM_INET_NTOH_U16(pAddr->sin_port); + pSctpStatus->primary.addr.type = CM_INET_IPV4ADDR_TYPE; + pSctpStatus->primary.addr.u.ipv4NetAddr = CM_INET_NTOH_U32(pAddr->sin_addr.s_addr); +#endif /* IPV6_SUPPORTED */ + + pSctpStatus->primary.assocId = status.sstat_primary.spinfo_assoc_id; + if (status.sstat_primary.spinfo_state == SCTP_ACTIVE) + pSctpStatus->primary.isActive = TRUE; + else + pSctpStatus->primary.isActive = FALSE; + pSctpStatus->primary.cwnd = status.sstat_primary.spinfo_cwnd; + pSctpStatus->primary.srtt = status.sstat_primary.spinfo_srtt; + pSctpStatus->primary.rto = status.sstat_primary.spinfo_rto; + pSctpStatus->primary.mtu = status.sstat_primary.spinfo_mtu; + break; + + case CM_INET_OPT_SCTP_GET_PADDR_INFO: + pPeerAddrInfo = (CmInetSctpPeerAddrInfo*)value; + cmMemset((U8*)&addrInfo, 0, sizeof(struct sctp_paddrinfo)); + len = sizeof(addrInfo); + addrInfo.spinfo_assoc_id = pPeerAddrInfo->assocId; + +#ifdef IPV6_SUPPORTED + if (pPeerAddrInfo->addr.type == CM_INET_IPV6ADDR_TYPE) + { + if (sockFd->protType == AF_INET) + { +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54: CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetGetOpt() Failed : Invalid address," + " sockFd->fd(%ld)\n", sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET017, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetGetOpt() Failed : Invalid address," + " sockFd->fd(%d)\n", sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET017, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + + pAddr6 = (struct sockaddr_in6*)&(addrInfo.spinfo_address); + pAddr6->sin6_family = AF_INET6; + pAddr6->sin6_port = CM_INET_HTON_U16(pPeerAddrInfo->port); + CM_INET_COPY_IPV6ADDR(&pAddr6->sin6_addr.s6_addr, &pPeerAddrInfo->addr.u.ipv6NetAddr); + } + else + { + pAddr = (struct sockaddr_in*)&(addrInfo.spinfo_address); + pAddr->sin_family = AF_INET; + pAddr->sin_port = CM_INET_HTON_U16(pPeerAddrInfo->port); + pAddr->sin_addr.s_addr = CM_INET_HTON_U32(pPeerAddrInfo->addr.u.ipv4NetAddr); + } +#else + pAddr = (struct sockaddr_in*)&(addrInfo.spinfo_address); + pAddr->sin_family = AF_INET; + pAddr->sin_port = CM_INET_HTON_U16(pPeerAddrInfo->port); + pAddr->sin_addr.s_addr = CM_INET_HTON_U32(pPeerAddrInfo->addr.u.ipv4NetAddr); +#endif /* IPV6_SUPPORTED */ + + /* Not validating the address, whether Addr is a valid address or not */ + + ret = getsockopt(sockFd->fd, level, SCTP_GET_PEER_ADDR_INFO, &addrInfo, &len); + + if (addrInfo.spinfo_state == SCTP_ACTIVE) + pPeerAddrInfo->isActive = TRUE; + else + pPeerAddrInfo->isActive = FALSE; + pPeerAddrInfo->cwnd = addrInfo.spinfo_cwnd; + pPeerAddrInfo->srtt = addrInfo.spinfo_srtt; + pPeerAddrInfo->rto = addrInfo.spinfo_rto; + pPeerAddrInfo->mtu = addrInfo.spinfo_mtu; + break; + + case CM_INET_OPT_SCTP_PEERADDR_PARAMS: + + pPeerAddrParams = (CmInetSctpPeerAddrParams *)value; + + cmMemset((U8*)&addrParams, 0, sizeof(struct sctp_paddrparams)); + + addrParams.spp_assoc_id = pPeerAddrParams->assocId; + + if (pPeerAddrParams->s.addrPres == TRUE) + { +#ifdef IPV6_SUPPORTED + if (pPeerAddrParams->s.addr.type == CM_INET_IPV6ADDR_TYPE) + { + if (sockFd->protType == AF_INET) + { +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "invalid address line:sockFd->fd(%ld)\n", + sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET066, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "invalid address line:sockFd->fd(%d)\n", + sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET066, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + + pAddr6 = (struct sockaddr_in6*)&(addrParams.spp_address); + pAddr6->sin6_family = AF_INET6; + pAddr6->sin6_port = CM_INET_HTON_U16(pPeerAddrParams->s.port); + CM_INET_COPY_IPV6ADDR(&pAddr6->sin6_addr.s6_addr, &pPeerAddrParams->s.addr.u.ipv6NetAddr); + } + else + { + pAddr = (struct sockaddr_in*)&(addrParams.spp_address); + pAddr->sin_family = AF_INET; + pAddr->sin_port = CM_INET_HTON_U16(pPeerAddrParams->s.port); + pAddr->sin_addr.s_addr = CM_INET_HTON_U32(pPeerAddrParams->s.addr.u.ipv4NetAddr); + } +#else + pAddr = (struct sockaddr_in*)&(addrParams.spp_address); + pAddr->sin_family = AF_INET; + pAddr->sin_port = CM_INET_HTON_U16(pPeerAddrParams->s.port); + pAddr->sin_addr.s_addr = CM_INET_HTON_U32(pPeerAddrParams->s.addr.u.ipv4NetAddr); +#endif /* IPV6_SUPPORTED */ + } + else + { +#ifdef IPV6_SUPPORTED + if (sockFd->protType == AF_INET6) + addrParams.spp_address.ss_family = AF_INET6; + else + addrParams.spp_address.ss_family = AF_INET; +#else + addrParams.spp_address.ss_family = AF_INET; +#endif + } + + len = sizeof(addrParams); + + ret = getsockopt(sockFd->fd, level, SCTP_PEER_ADDR_PARAMS, &addrParams, &len); + /* cm_inet_c_001.main_41 : Fixed the Solaris compilation problem */ +#ifndef SUN_KSCTP + + pPeerAddrParams->hbInterval = addrParams.spp_hbinterval; + pPeerAddrParams->pathMaxRxt = addrParams.spp_pathmaxrxt; + pPeerAddrParams->assocId = addrParams.spp_assoc_id; + pPeerAddrParams->pathMtu = addrParams.spp_pathmtu; + pPeerAddrParams->sackDelay = addrParams.spp_sackdelay; + + if (addrParams.spp_flags & SPP_HB_ENABLE) + pPeerAddrParams->hbEnblFlag = CM_INET_OPT_ENABLE; + else + pPeerAddrParams->hbEnblFlag = CM_INET_OPT_DISABLE; + + if (addrParams.spp_flags & SPP_PMTUD_ENABLE) + pPeerAddrParams->pmtudFlag = CM_INET_OPT_ENABLE; + else + pPeerAddrParams->pmtudFlag = CM_INET_OPT_DISABLE; + + if (addrParams.spp_flags & SPP_SACKDELAY_ENABLE) + pPeerAddrParams->sackDelayFlag = CM_INET_OPT_ENABLE; + else + pPeerAddrParams->sackDelayFlag = CM_INET_OPT_DISABLE; +#endif + + break; + + case CM_INET_OPT_SCTP_ASSOC_PARAMS: + + pAssocParams = (CmInetSctpAssocParams *)value; + + cmMemset((U8*)&assocParams, 0, sizeof(struct sctp_assocparams)); + + assocParams.sasoc_assoc_id = pAssocParams->assocId; + + len = sizeof(assocParams); + + ret = getsockopt(sockFd->fd, level, SCTP_ASSOCINFO, &assocParams, &len); + + pAssocParams->assocMaxReTx = assocParams.sasoc_asocmaxrxt; + pAssocParams->cookieLife = assocParams.sasoc_cookie_life; + pAssocParams->assocId = assocParams.sasoc_assoc_id; + pAssocParams->numberOfPeerDest = assocParams.sasoc_number_peer_destinations; + pAssocParams->peerRwnd = assocParams.sasoc_peer_rwnd; + pAssocParams->localRwnd = assocParams.sasoc_local_rwnd; + + break; + + case CM_INET_OPT_SCTP_RTO_INFO: + + pRtoInfo = (CmInetSctpRtoInfo *)value; + + cmMemset((U8*)&rtoInfo, 0, sizeof(struct sctp_rtoinfo)); + + len = sizeof(rtoInfo); + + ret = getsockopt(sockFd->fd, level, SCTP_RTOINFO, &rtoInfo, &len); + + pRtoInfo->assocId = rtoInfo.srto_assoc_id; + pRtoInfo->rtoInitial = rtoInfo.srto_initial; + pRtoInfo->rtoMax = rtoInfo.srto_max; + pRtoInfo->rtoMin = rtoInfo.srto_min; + + break; + + case CM_INET_OPT_SCTP_INIT_MSG: + + pInitMsg = (CmInetSctpInitMsg *)value; + + cmMemset((U8*)&initMsg, 0, sizeof(struct sctp_initmsg)); + + len = sizeof(initMsg); + + ret = getsockopt(sockFd->fd, level, SCTP_INITMSG, &initMsg, &len); + + pInitMsg->maxInitReTx = initMsg.sinit_max_attempts; + pInitMsg->maxInitTimeout = initMsg.sinit_max_init_timeo; + pInitMsg->numOstreams = initMsg.sinit_num_ostreams; + pInitMsg->maxInstreams = initMsg.sinit_max_instreams; + + break; + + default: + RETVALUE(RFAILED); + } + + if (ret == INET_ERR) + { +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetGetOpt() failed on line:" + " error(%d), sockFd->fd(%ld)\n", INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET067, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetGetOpt() failed on line:" + " error(%d), sockFd->fd(%d)\n", INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET067, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + + RETVALUE(ROK); +} + +/* cm_inet_c_001.main_54: Added new function cmInetShutDownSctp()*/ +/* + * + * Fun: cmInetShutDownSctp + * + * Desc: Shutdown the SCTP association gracefully. + * + * Ret: ROK - successful + * RFAILED - failed + * + * Notes: None. + * + * File: cm_inet.c + * + */ +#ifdef ANSI +PUBLIC S16 cmInetShutDownSctp +( + CmInetFd *sockFd /* socket file descriptor */ + ) +#else +PUBLIC S16 cmInetShutDownSctp(sockFd) + CmInetFd *sockFd; /* socket file descriptor */ +#endif +{ + /*cm_inet_c_001.main_58 : fix for klockwork issue */ + S32 ret; + struct sctp_sndrcvinfo sndRcvInfo; + + TRC2(cmInetShutDownSctp); + + cmMemset((U8*)&sndRcvInfo, 0, sizeof(sndRcvInfo)); + +#ifdef SUN_KSCTP + sndRcvInfo.sinfo_flags = MSG_EOF; +#else + sndRcvInfo.sinfo_flags = SCTP_EOF; +#endif + + /* Call the sctp_send with flag set to termiante the association */ + + ret = sctp_send(sockFd->fd, NULLP, 0, &sndRcvInfo, sndRcvInfo.sinfo_flags); + + if(ret == INET_ERR) + { +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetShutDownSctp() Failed : error(%d), sockFd->fd(%ld)\n", + INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET018, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetShutDownSctp() Failed : error(%d), sockFd->fd(%d)\n", + INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET018, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + + RETVALUE(RFAILED); + } + + RETVALUE(ROK); +} + +/* cm_inet_c_001.main_61: Added new function cmInetAbortSctpAssoc()*/ +/* + * + * Fun: cmInetAbortSctpAssoc + * + * Desc: ABORT the association. + * + * Ret: ROK - successful + * RFAILED - failed + * + * Notes: None. + * + * File: cm_inet.c + * + */ +#ifdef ANSI +PUBLIC S16 cmInetAbortSctpAssoc +( + CmInetFd *sockFd, /* socket file descriptor */ + UConnId assocId /* Association ID */ + ) +#else +PUBLIC S16 cmInetAbortSctpAssoc(sockFd, assocId) + CmInetFd *sockFd; /* socket file descriptor */ + UConnId assocId; /* Association ID */ +#endif +{ + S32 ret; + struct sctp_sndrcvinfo sndRcvInfo; + + TRC2(cmInetAbortSctpAssoc); + + cmMemset((U8*)&sndRcvInfo, 0, sizeof(sndRcvInfo)); + +#ifdef SUN_KSCTP + sndRcvInfo.sinfo_flags = MSG_ABORT; +#else + sndRcvInfo.sinfo_flags = SCTP_ABORT; +#endif + + sndRcvInfo.sinfo_assoc_id = assocId; + + /* Call the sctp_send with flag set to termiante the association */ + + ret = sctp_send(sockFd->fd, NULLP, 0, &sndRcvInfo, sndRcvInfo.sinfo_flags); + + if(ret == INET_ERR) + { +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetAbortSctpAssoc() Failed : error(%d), sockFd->fd(%ld)\n", + INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET018, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetAbortSctpAssoc() Failed : error(%d), sockFd->fd(%d)\n", + INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET018, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + + RETVALUE(RFAILED); + } + + RETVALUE(ROK); +} + +#endif + + +/* + * + * Fun: cmInetConnect + * + * Desc: Establishs a connection to a foreign address (TCP) or associates + * a UDP socket to a foreign address. + * + * Ret: ROK - successful +* ROKDNA - resource temporarily unavaiable +* RINPROGRESS - connection is in progress (only non-blocking) +* RISCONN - connection is established (only non-blocking) +* RFAILED - failed +* +* Notes: None. +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmInetConnect +( +CmInetFd *sockFd, /* socket file descriptor */ +CmInetAddr *servAddr /* foreign Internet address/port */ +) +#else +PUBLIC S16 cmInetConnect(sockFd, servAddr) + CmInetFd *sockFd; /* socket file descriptor */ + CmInetAddr *servAddr; /* foreign Internet address/port */ +#endif +{ + S32 ret; /* temporary return value */ + struct sockaddr_in dstAddr; /* foreign Internet address/port */ +#ifdef IPV6_SUPPORTED + struct sockaddr_in6 dstAddr6; /* foreign Internet IPV6 address/port */ +#ifdef CMINETDBG + U16 port; +#endif /* CMINETDBG */ +#endif /* IPV6_SUPPORTED */ + S32 sizeOfAddr; + CmInetSockAddr *sockAddrPtr; + + TRC2(cmInetConnect); + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if ((sockFd == NULLP) || CM_INET_INV_SOCK_FD(sockFd) || + (servAddr == NULLP)) + { + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + +#ifdef IPV6_SUPPORTED + if (servAddr->type == CM_INET_IPV6ADDR_TYPE) + { + cmMemset((U8*)&dstAddr6, 0, sizeof(dstAddr6)); + dstAddr6.sin6_family = AF_INET6; + dstAddr6.sin6_port = CM_INET_HTON_U16(servAddr->u.ipv6Addr.port); + CM_INET_COPY_IPV6ADDR(&dstAddr6.sin6_addr, + &servAddr->u.ipv6Addr.ipv6NetAddr); + sizeOfAddr = sizeof(struct sockaddr_in6); + sockAddrPtr = (CmInetSockAddr *)&dstAddr6; + } + else + { + cmMemset((U8*)&dstAddr, 0, sizeof(dstAddr)); + dstAddr.sin_family = AF_INET; + dstAddr.sin_port = CM_INET_HTON_U16(servAddr->u.ipv4Addr.port); + dstAddr.sin_addr.s_addr = CM_INET_HTON_U32(servAddr->u.ipv4Addr.address); + sizeOfAddr = sizeof(struct sockaddr_in); + sockAddrPtr = (CmInetSockAddr *)&dstAddr; + } +#else + cmMemset((U8*)&dstAddr, 0, sizeof(dstAddr)); + dstAddr.sin_family = AF_INET; + dstAddr.sin_port = CM_INET_HTON_U16(servAddr->port); + dstAddr.sin_addr.s_addr = CM_INET_HTON_U32(servAddr->address); + sizeOfAddr = sizeof(struct sockaddr_in); + sockAddrPtr = (CmInetSockAddr *)&dstAddr; +#endif /* IPV6_SUPPORTED */ + + ret = connect(sockFd->fd, sockAddrPtr, sizeOfAddr); + if (ret == INET_ERR) + { + switch (INET_ERR_CODE) + { + /* non-blocking: connection is in progress */ + case ERR_INPROGRESS: + RETVALUE(RINPROGRESS); + break; + + /* + * non-blocking: connection is established + * blocking : connection is already established + */ + case ERR_ISCONN: + RETVALUE(RISCONN); + break; + + /* resource temporarily unavailable */ + case ERR_WOULDBLOCK: + RETVALUE(ROKDNA); + break; + + /* non-blocking: connection is in progress */ + case ERR_ALREADY: + RETVALUE(RINPROGRESS); + break; + + case ERR_INVAL: + RETVALUE(RINPROGRESS); + break; + + /* Check for connection refused and timeout errors */ + case ERR_CONNREFUSED: + case ERR_TIMEDOUT: + RETVALUE(RCLOSED); + break; + + /* it is a real error */ + default: +#ifdef CMINETDBG +#ifdef IPV6_SUPPORTED + if (servAddr->type == CM_INET_IPV6ADDR_TYPE) + port = servAddr->u.ipv6Addr.port; + else + port = servAddr->u.ipv4Addr.port; + + /* cm_inet_c_001.main_54: CMINETLOGERROR added insted of SDisp */ +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetConnect() Failed : error(%d)," + " addrtype(0x%x), port(0x%1x), sockFd->fd(%ld)\n", + INET_ERR_CODE, servAddr->type, port, sockFd->fd); + CMINETLOGERROR(ERRCLS_ADD_RES, ECMINET019, 0, prntBuf); +#else + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetConnect() Failed : error(%d)," + " addrtype(0x%x), port(0x%1x), sockFd->fd(%d)\n", + INET_ERR_CODE, servAddr->type, port, sockFd->fd); + CMINETLOGERROR(ERRCLS_ADD_RES, ECMINET019, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#else +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetConnect() Failed : error(%d), addr(0x%lx)," + "port(0x%1x), sockFd->fd(%ld)\n", INET_ERR_CODE , + servAddr->address, servAddr->port, sockFd->fd); + CMINETLOGERROR(ERRCLS_ADD_RES, ECMINET020, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetConnect() Failed : error(%d), addr(0x%x)," + "port(0x%x), sockFd->fd(%d)\n", INET_ERR_CODE , + servAddr->address, servAddr->port, sockFd->fd); + CMINETLOGERROR(ERRCLS_ADD_RES, ECMINET020, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* IPV6_SUPPORTED */ +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + break; + } + } + + RETVALUE(ROK); +} /* end of cmInetConnect */ + + +/* +* +* Fun: cmInetListen +* +* Desc: Indicates the willingness of a socket to listen for incomming +* connection requests. +* +* Ret: ROK - successful +* RFAILED - failed +* +* Notes: The backLog value has to be within 0..5 +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmInetListen +( +CmInetFd *sockFd, /* socket file descriptor */ +S16 backLog /* max. number of outstandig connections 0..5 */ +) +#else +PUBLIC S16 cmInetListen(sockFd, backLog) +CmInetFd *sockFd; /* socket file descriptor */ +S16 backLog; /* max. number of outstandig connections 0..5 */ +#endif +{ + S32 ret; /* temporary return value */ + + TRC2(cmInetListen); + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if ((sockFd == NULLP) || CM_INET_INV_SOCK_FD(sockFd) || + (backLog < MIN_BACK_LOG) || (backLog > MAX_BACK_LOG)) + { + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + ret = listen(sockFd->fd, backLog); + if (ret == INET_ERR) + { +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetListen() Failed : error(%d), backLog(%d)," + " sockFd->fd(%ld)\n", INET_ERR_CODE, backLog, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET021, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetListen() Failed : error(%d), backLog(%d)," + " sockFd->fd(%d)\n", INET_ERR_CODE, backLog, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET021, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + + RETVALUE(ROK); +} /* end of cmInetListen */ + + +/* +* +* Fun: cmInetAccept +* +* Desc: Accepts an incoming connection. +* On default the new socket is non-blocking. The options can be +* changed with the function cmInetSetOpt(). +* +* Ret: ROK - successful +* ROKDNA - there is no connection present to accept (only +* non-blocking) +* RFAILED - failed +* +* Notes: None. +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmInetAccept +( +CmInetFd *sockFd, /* socket file descriptor */ +CmInetAddr *fromAddr, /* calling Internet address/port */ +CmInetFd *newSockFd /* socket file descriptor for new connection*/ +) +#else +PUBLIC S16 cmInetAccept(sockFd, fromAddr, newSockFd) +CmInetFd *sockFd; /* socket file descriptor */ +CmInetAddr *fromAddr; /* calling Internet address/port */ +CmInetFd *newSockFd; /* socket file descriptor for new connection*/ +#endif +{ + S32 ret; /* temporary return value */ + S32 addrLen; /* address structure length */ + struct sockaddr_in *peerAddr; /* calling Internet address/port */ +#ifdef IPV6_SUPPORTED + struct sockaddr_in6 *peerAddr6; /* calling Internet address/port */ + struct sockaddr_in6 sockAddr; +#else + CmInetSockAddr sockAddr; +#endif /* IPV6_SUPPORTED */ + + U32 optVal; + + /* added */ + TRC2(cmInetAccept) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if ((sockFd == NULLP) || CM_INET_INV_SOCK_FD(sockFd)) + { + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + /* change CmInetSockAddr to sockAddr */ + addrLen = sizeof(sockAddr); + + /* INSURE fix */ +#if ( defined(SUNOS) || defined(SS_LINUX)) + newSockFd->fd = accept(sockFd->fd, (CmInetSockAddr*)&sockAddr, + (socklen_t *)&addrLen); +#else + newSockFd->fd = accept(sockFd->fd, (CmInetSockAddr*)&sockAddr, + (int*)&addrLen); +#endif /* SUNOS || SS_LINUX */ + + /* cm_inet_c_001.main_58: Moved setting of protType below */ + + if (CM_INET_INV_SOCK_FD(newSockFd)) + { + if (INET_ERR_CODE == ERR_WOULDBLOCK) + { + /* no connection present to accept */ + RETVALUE(ROKDNA); + } + else + { +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54: CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetAccept() Failed : error(%d)," + " sockFd->fd(%ld)\n", INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET022, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetAccept() Failed : error(%d)," + " sockFd->fd(%d)\n", INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET022, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + } + + + /* cm_inet_c_001.main_58: Fix for g++ compilation warning */ + /* added for IPv6/IPv4 socket distinguishing */ +#ifdef IPV6_SUPPORTED + if (addrLen == sizeof(struct sockaddr_in)) + newSockFd->protType = AF_INET; + else if(addrLen == sizeof(struct sockaddr_in6)) + newSockFd->protType = AF_INET6; + else + { +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetAccept() Failed : sockFd->fd(%ld)\n", sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET071, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetAccept() Failed : sockFd->fd(%d)\n", sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET071, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } +#endif /* IPV6_SUPPORTED */ + + /* set the new socket file descriptor type */ + newSockFd->type = CM_INET_STREAM; + + /* set default options for new socket file descriptor */ + optVal = CM_INET_OPT_DISABLE; + ret = cmInetSetOpt(newSockFd, SOL_SOCKET, CM_INET_OPT_BLOCK, &optVal); + if ( ret != ROK) + { + ret = cmInetClose(newSockFd); + RETVALUE(RFAILED); + } + +#ifdef IPV6_SUPPORTED + cmMemset((U8*)fromAddr, 0, sizeof(fromAddr)); + if (addrLen == sizeof(struct sockaddr_in)) + { + peerAddr = (struct sockaddr_in *)&sockAddr; + fromAddr->type = CM_INET_IPV4ADDR_TYPE; + fromAddr->u.ipv4Addr.port = CM_INET_NTOH_U16(peerAddr->sin_port); + fromAddr->u.ipv4Addr.address = + CM_INET_NTOH_U32(peerAddr->sin_addr.s_addr); + } + else if (addrLen == sizeof(struct sockaddr_in6)) + { + peerAddr6 = (struct sockaddr_in6 *)&sockAddr; + fromAddr->type = CM_INET_IPV6ADDR_TYPE; + fromAddr->u.ipv6Addr.port = CM_INET_NTOH_U16(peerAddr6->sin6_port); + CM_INET_COPY_IPV6ADDR(&fromAddr->u.ipv6Addr.ipv6NetAddr, + &peerAddr6->sin6_addr); + } +#else + peerAddr = (struct sockaddr_in *)&sockAddr; + fromAddr->port = CM_INET_NTOH_U16(peerAddr->sin_port); + fromAddr->address = CM_INET_NTOH_U32(peerAddr->sin_addr.s_addr); +#endif /* IPV6_SUPPORTED */ + RETVALUE(ROK); +} /* end of cmInetAccept */ + + +/* +* +* Fun: cmInet4FillTos +* +* Desc: This function inserts tos (into ancillary data) which +* will be used to fill tos value in ip header in outgoing IP packet +* when sending that packet using sendmsg()function. +* +* Ret: ROK +* +* Notes: +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PRIVATE S16 cmInet4FillTos +( +U8 tos, /* tos value to be filled in ipheader */ +U8 *cmsgBuf, /* flat buffer where to build ext hdrs */ +U32 *curMsgIdx /* idx in cmsgBuf where HBH/Dest ext hdr ends */ +) +#else +PRIVATE S16 cmInet4FillTos(tos, cmsgBuf, curMsgIdx, protType) +U8 tos; /* tos value to be filled in ipheader */ +U8 *cmsgBuf; /* flat buffer where to build ext hdrs */ +U32 *curMsgIdx; /* idx in cmsgBuf where HBH/Dest ext hdr ends */ +#endif /* ANSI */ +{ + struct cmsghdr *tempHdr; + U8 len; + + TRC2(cmInet4FillTos) + + len = 0; + + + /* cmsghdr struc will appear before data in the ancillary data object. + * So put cmsghdr struc in flat buffer first. */ + + /* cmsghdr struc points to flat buffer's starting address */ + tempHdr = (struct cmsghdr *)cmsgBuf; + + /* fill up level & type of cmsghdr structure */ + tempHdr->cmsg_level = IPPROTO_IPV6; + tempHdr->cmsg_type = IP_TOS; + (*(U8*)CMSG_DATA(tempHdr)) = tos; + len = CMSG_SPACE(sizeof tos); + + + /* fill up the length of cmsghdr structure */ + tempHdr->cmsg_len = len; + *curMsgIdx += len; + + RETVALUE(ROK); + +}/* end of cmInet4FillTos */ +/* +* +* Fun: cmInetSendDscpMsg +* +* Desc: Sends the message data hold by mBuf. +* The len paramter gives the actual written octets. If the socket +* is non-blocking this value can be differ from the mBuf length +* because there was not enough transmit buffer space available. If +* this occurs, RWOULDBLOCK is returned and only a part of the mBuf +* is sent. +* Values for flag parameter: +* +* CM_INET_NO_FLAG - no additional control flag +* +* Ret: ROK - successful +* RWOULDBLOCK - no or not entire mBuf sent because would block +* ROUTRES - failed, out of resources +* RCLOSED - connection was closed by the peer +* RFAILED - failed +* +* Notes: The successful completion of a send call does not indicate that +* the data has been successfully delivered! +* +* This function does not free any sent buffers. +* +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmInetSendDscpMsg +( +CmInetFd *sockFd, /* socket file descriptor */ +CmInetAddr *dstAddr, /* destination Internet address/port */ +CmInetMemInfo *info, /* buffer allocation info */ +Buffer *mBuf, /* buffer structure to send */ +MsgLen *len, /* number of actually sent octets */ +/* added for IPv6 ext hdr */ +CmInetIpHdrParm *ipHdrParams, /* IPv6 extensions headers */ +S16 flags /* additional control flags, unused */ +) +#else +/* added for IPv6 ext hdr */ +PUBLIC S16 cmInetSendDscpMsg(sockFd, dstAddr, info, mBuf, len, ipHdrParams, flags) +CmInetFd *sockFd; /* socket file descriptor */ +CmInetAddr *dstAddr; /* destination Internet address/port */ +CmInetMemInfo *info; /* buffer allocation info */ +Buffer *mBuf; /* buffer structure to send */ +MsgLen *len; /* number of actually sent octets */ +CmInetIpHdrParm *ipHdrParams; /* IPv6 extensions headers */ +S16 flags; /* additional control flags, unused */ +#endif /* ANSI */ +{ +#if (defined(WIN32) || defined(CMINETFLATBUF)) + S32 ret; /* temporary return value */ + MsgLen msgLen; /* message length */ + MsgLen bufLen; /* send buffer length */ + Data *sendBuf; /* plain send buffer */ +#else + S32 ret; /* temporary return value */ + S32 retVal; /* temporary return value */ + S16 i; /* loop index */ + CmInetIovec txArr[CM_INET_MAX_DBUF]; /* scatter vector */ + S16 numDBufs; /* number of dBufs in message */ + struct msghdr msg; /* sendmsg() message header */ + MsgLen msgLen; /* message length */ + U32 strtEndDBufNum; /* starting/ending DBuf number */ + MsgLen unSentLen; /* sent len */ +#ifdef IPV6_SUPPORTED + U32 curMsgIdx; /* indx in cmsgData where to write an ext hdr */ + /* added for IPv6 ext hdr */ +#if (defined(SS_LINUX) || defined(_XPG4_2)) + /* alloc from stack for IPv6 ancill data */ + U8 cmsgData[CM_INET_IPV6_ANCIL_DATA]; +#endif /* SS_LINUX || _XPG4_2 */ +#else + U32 curMsgIdx; /* indx in cmsgData where to write an ext hdr */ +#if (defined(SS_LINUX) || defined(_XPG4_2)) + /* alloc from stack for IPv4 ancill data */ + U8 cmsgData[CM_INET_IPV4_ANCIL_DATA]; +#endif /* SS_LINUX || _XPG4_2 */ +#endif /* IPV6_SUPPORTED */ +#endif /* WIN32 | CMINETFLATBUF */ + + struct sockaddr_in remAddr; /* remote Internet address */ +#ifdef IPV6_SUPPORTED + struct sockaddr_in6 remAddr6; /* remote Internet address */ +#endif /* IPV8_SUPPORTED */ + CmInetSockAddr *sockAddrPtr; + /* cm_inet_c_001.main_58 : Fix for klockwork issue */ + U32 sizeOfAddr; + + /* cm_inet_c_001.main_50 - Added for partial send handling */ + /* cm_inet_c_001.main_59: Protected under if not defined WIN32*/ +#if (!defined(WIN32)) + MsgLen ioLen; +#endif + + TRC2(cmInetSendDscpMsg) + + UNUSED(flags); + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if ((sockFd == NULLP) || CM_INET_INV_SOCK_FD(sockFd) || + (info == NULLP) || (len == NULLP)) + { + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + /* added for IPv6 ext hdr */ +#if !(defined(WIN32) || defined(CMINETFLATBUF)) +#if (defined(SS_LINUX) || defined(_XPG4_2)) +/* cmMemset((U8*)cmsgData, 0, sizeof(cmsgData)); */ +#endif /* SS_LINUX || _XPG4_2 */ + curMsgIdx = 0; +#endif /* WIN32 | CMINETFLATBUF */ + + msgLen = 0; /* need by CC to pass without warning */ + sockAddrPtr = NULLP; + sizeOfAddr = 0; + + /* setup remote address */ + if (dstAddr != NULLP) + { +#ifdef IPV6_SUPPORTED + if (dstAddr->type == CM_INET_IPV6ADDR_TYPE) + { + cmMemset((U8*)&remAddr6, 0, sizeof(remAddr6)); + remAddr6.sin6_family = AF_INET6; + remAddr6.sin6_port = CM_INET_HTON_U16(dstAddr->u.ipv6Addr.port); + CM_INET_COPY_IPV6ADDR(&remAddr6.sin6_addr, + &dstAddr->u.ipv6Addr.ipv6NetAddr); + sizeOfAddr = sizeof(remAddr6); + sockAddrPtr = (CmInetSockAddr *)&remAddr6; + } + else + { + cmMemset((U8*)&remAddr, 0, sizeof(remAddr)); + remAddr.sin_family = AF_INET; + remAddr.sin_port = CM_INET_HTON_U16(dstAddr->u.ipv4Addr.port); + remAddr.sin_addr.s_addr = + CM_INET_HTON_U32(dstAddr->u.ipv4Addr.address); + sizeOfAddr = sizeof(remAddr); + sockAddrPtr = (CmInetSockAddr *)&remAddr; + } +#else +/* cmMemset((U8*)&remAddr, 0, sizeof(remAddr)); */ + remAddr.sin_family = AF_INET; + remAddr.sin_port = CM_INET_HTON_U16(dstAddr->port); + remAddr.sin_addr.s_addr = CM_INET_HTON_U32(dstAddr->address); + sizeOfAddr = sizeof(remAddr); + sockAddrPtr = (CmInetSockAddr *)&remAddr; +#endif /* IPV6_SUPPORTED */ + } + +#if (defined(WIN32) || defined(CMINETFLATBUF)) + /* copy message to a flat buffer */ + ret = SFndLenMsg(mBuf, &bufLen); + if (ret != ROK) + { + RETVALUE(RFAILED); + } + /* max message length is limited to control the memory usage */ + /* casting bufLen to avoid warnings */ + if ((bufLen > 0) && ((U32)bufLen > CM_INET_MAX_MSG_LEN)) + { + RETVALUE(RFAILED); + } + ret = SGetSBuf(info->region, info->pool, &sendBuf, bufLen); + if (ret != ROK) + { + RETVALUE(ROUTRES); + } + ret = SCpyMsgFix(mBuf, 0, bufLen, sendBuf, &msgLen); + if ((ret != ROK) || (msgLen != bufLen)) + { + /* cleanup */ + SPutSBuf(info->region, info->pool, sendBuf, bufLen); + RETVALUE(RFAILED); + } + + if (dstAddr == NULLP) + { + /* VxWorks sendto has some problem + * with connected UDP socket, use send */ +#ifndef SS_VW + ret = sendto(sockFd->fd, (S8 *)sendBuf, bufLen, 0, + NULLP, sizeOfAddr); +#else + ret = send(sockFd->fd, (S8 *)sendBuf, bufLen, 0); +#endif /* end of SS_VW */ + } + else + /* cm_inet_c_001.main_54: Fix for vxworks 6.7 sending data on TCP sockets */ + { +#if (defined(SS_VW) && defined(SS_VW6_7)) + if ((sockFd->type == CM_INET_STREAM) || (sockFd->type == SOCK_RDM) ) + { + ret = send(sockFd->fd, (S8 *)sendBuf, bufLen, 0); + } + else +#endif /* end of SS_VW6_7 and SS_VW */ + { + ret = sendto(sockFd->fd, (S8 *)sendBuf, bufLen, 0, + sockAddrPtr, sizeOfAddr); + } + } + if (ret == INET_ERR) + { + /* cleanup */ + SPutSBuf(info->region, info->pool, sendBuf, bufLen); + + if(INET_ERR_CODE == ERR_AGAIN) + { + *len = 0; + RETVALUE(RWOULDBLOCK); + } + + /* Check for ERR_WOULDBLOCK */ + if(INET_ERR_CODE == ERR_WOULDBLOCK) + { + *len = 0; + RETVALUE(RWOULDBLOCK); + } + +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetSendDscpMsg() Failed : error(%d), msgLen(%d)," + " sockFd->fd(%ld)\n", INET_ERR_CODE, bufLen, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET023, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetSendDscpMsg() Failed : error(%d), msgLen(%d)," + " sockFd->fd(%d)\n", INET_ERR_CODE, bufLen, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET023, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + + /* cm_inet_c_001.main_37 network unreacheble error is added */ + /* check if network is reacheble*/ + if ((INET_ERR_CODE == ERR_NETUNREACH)) + { + RETVALUE(RNETFAILED); + } + + + /* Check if connection was closed */ + if ((INET_ERR_CODE == ERR_PIPE) || + (INET_ERR_CODE == ERR_CONNABORTED) || + (INET_ERR_CODE == ERR_CONNRESET)) + { + *len = 0; + RETVALUE(RCLOSED); + } + + RETVALUE(RFAILED); + } + + *len = ret; + + /* check if entire message could be sent */ + + if (ret < bufLen) + { + /* cleanup */ + SPutSBuf(info->region, info->pool, sendBuf, bufLen); + RETVALUE(RWOULDBLOCK); + } + + /* cleanup */ + SPutSBuf(info->region, info->pool, sendBuf, bufLen); + +#else /* end of Win NT/flat buffer specific part */ + ret = SFndLenMsg(mBuf, &msgLen); + if (ret != ROK) + { + RETVALUE(RFAILED); + } + + /* added */ +/* cmMemset((U8*)&msg, 0, sizeof(msg)); */ + msg.msg_flags = 0; + + if (dstAddr != NULLP) + { +#ifdef SS_LINUX + msg.msg_name = (Void*)sockAddrPtr; +#else +#ifdef SS_PS + msg.msg_name = (char *)sockAddrPtr; +#else + msg.msg_name = (caddr_t)sockAddrPtr; +#endif /* SS_PS */ +#endif /* SS_LINUX */ + msg.msg_namelen = sizeOfAddr; + } + else + { + msg.msg_name = NULLP; + msg.msg_namelen = 0; + } + /* added defined(_XPG4_2) */ +#if (defined(SS_LINUX) || defined(_XPG4_2)) + msg.msg_control = NULLP; + msg.msg_controllen = 0; +#else + msg.msg_accrights = 0; + msg.msg_accrightslen = NULLP; +#endif /* SS_LINUX */ + + /* allocate scatter vector */ + numDBufs = CM_INET_MAX_DBUF; + retVal = RNA; + ret = ROK; + unSentLen = msgLen; + strtEndDBufNum = 0; + *len = 0; + if (ipHdrParams != NULLP && (ipHdrParams->type == CM_INET_IPV4ADDR_TYPE)) + if((ipHdrParams->u.hdrParmIpv4.tos.pres == TRUE)&& \ + (ipHdrParams->u.hdrParmIpv4.tos.val != 0)) + { + cmInet4FillTos(ipHdrParams->u.hdrParmIpv4.tos.val, + (U8 *)(cmsgData + curMsgIdx), &curMsgIdx); + msg.msg_control = cmsgData; /* pointer to Ancillary Data */ + msg.msg_controllen = curMsgIdx; /* total length of ancillary Data */ + } + /* if the sender wants to send Ipv6 exten. headers */ +#ifdef IPV6_OPTS_SUPPORTED + if (ipHdrParams != NULLP && (ipHdrParams->type == CM_INET_IPV6ADDR_TYPE)) + { +#ifdef SS_LINUX + if(ipHdrParams->u.ipv6HdrParm.ttl.pres == TRUE) + { + cmInetBuildSendHoplimit((U32)ipHdrParams->u.ipv6HdrParm.ttl.val, + (U8 *)(cmsgData + curMsgIdx), &curMsgIdx); + } +#endif /* SS_LINUX */ + +#ifdef LOCAL_INTF + /* have to decide how to get the src addr to add in in6_pktinfo */ + if(ipHdrParams->u.ipv6HdrParm.srcAddr6.type == 6) + { + cmInet6BuildSendPktinfo( + &ipHdrParams->u.ipv6HdrParm.srcAddr6.u.ipv6NetAddr, + (U8 *)(cmsgData + curMsgIdx), &curMsgIdx, + sockFd->protType); + } +#endif /* LOCAL_INTF */ + + /* copy each ipv6 ext header from ipHdrParams to the flat buffer + * cmsgData one by one. */ + + if (ipHdrParams->u.ipv6HdrParm.ipv6ExtHdr.hbhHdrPrsnt == TRUE) + /* build HBH ext header in cmsgData starting at indx 0 */ + cmInet6BuildSendHBHOpts( + &ipHdrParams->u.ipv6HdrParm.ipv6ExtHdr.hbhOptsArr, + (U8 *)(cmsgData + curMsgIdx), &curMsgIdx, 0); + + /* now copy the elements from the Destination Option array one by + * one to the Flat Buffer cmsgData. Start filling at indx curMsgIdx + * which is the end of HBH hdr. */ + if (ipHdrParams->u.ipv6HdrParm.ipv6ExtHdr.destOptsPrsnt == TRUE) + /* build Dest opt hdr starting at (cmsgData + curMsgIdx) */ + cmInet6BuildSendDestOpts( + &(ipHdrParams->u.ipv6HdrParm.ipv6ExtHdr.destOptsArr), + (U8 *)(cmsgData + curMsgIdx), &curMsgIdx, 1); + + /* copy Route header to to the Flat Buffer cmsgData */ + if (ipHdrParams->u.ipv6HdrParm.ipv6ExtHdr.rtOptsPrsnt == TRUE) + /* curMsgIdx will be the indx where Dest opt ends in cmsgData */ + cmInet6BuildSendRouteOpts( + &ipHdrParams->u.ipv6HdrParm.ipv6ExtHdr.rtOptsArr, + (U8 *)(cmsgData + curMsgIdx), &curMsgIdx); + + /* msghrd struc's msg_control will point cmsgData and msg_controllen + * will be the curMsgIdx */ + msg.msg_control = cmsgData; /* pointer to Ancillary Data */ + msg.msg_controllen = curMsgIdx; /* total length of ancillary Data */ + + } +#endif /* IPV6_OPTS_SUPPORTED */ + + /* Loop till all the data is sent or till the sendmsg call cannot send + * any more data. */ + do + { + /* build the send vector */ + /* cm_inet_c_001.main_50 - Partial send handling. Added variable to hold + total length of the packed dbufs */ + retVal = buildSendIovec(mBuf, unSentLen, txArr, numDBufs, &i, + &strtEndDBufNum, &ioLen); + if (retVal != ROK) + { + if (retVal == RNA) + { + /* Incase of UDP/RAW messages call SCompressMsg. */ + if (sockFd->type != CM_INET_STREAM) + { + /* Compress the message into a single dBuf */ + ret = SCompressMsg(mBuf); + if (ret != ROK) + RETVALUE(RFAILED); + + strtEndDBufNum = 0; + /* Rebuild the send vector */ + /* cm_inet_c_001.main_50 - Partial send handling. Added variable to hold + total length of the packed dbuf */ + ret = buildSendIovec(mBuf, unSentLen, txArr, numDBufs, &i, + &strtEndDBufNum, &ioLen); + if (ret != ROK) + RETVALUE(RFAILED); + + retVal = ROK; + } + } + else + RETVALUE(RFAILED); + } + msg.msg_iov = txArr; + msg.msg_iovlen = i; + + +#ifdef NTL_LIB + { + extern int ntl_hLib; + if ( sockFd->fd >= 0xD001) + ret = ntl_sendmsg(ntl_hLib, sockFd->fd, &msg, 0); + else + ret = sendmsg(sockFd->fd, &msg, 0); + } +#else + ret = sendmsg(sockFd->fd, &msg, 0); +#endif + /* cm_inet_c_001.main_50 - Update the length only in successful cases */ + if (ret == INET_ERR) + { + if((INET_ERR_CODE == ERR_AGAIN) || + (INET_ERR_CODE == ERR_WOULDBLOCK)) + { + /* cm_inet_c_001.main_50 - Return without making length 0, if in case the partial + message was sent earlier */ + RETVALUE(RWOULDBLOCK); + } +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetSendDscpMsg() Failed : error(%d)," + " sockFd->fd(%ld)\n", INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET024, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetSendDscpMsg() Failed : error(%d)," + " sockFd->fd(%d)\n", INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET024, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + + /* cm_inet_c_001.main_37 network unreacheble error is added */ + /* check if network is reacheble or not */ + if ((INET_ERR_CODE == ERR_NETUNREACH)) + { + RETVALUE(RNETFAILED); + } + + /* Check if connection was closed by the peer */ + if ((INET_ERR_CODE == ERR_PIPE) || + (INET_ERR_CODE == ERR_CONNREFUSED) || + (INET_ERR_CODE == ERR_CONNABORTED)) + { + *len = 0; + RETVALUE(RCLOSED); + } + RETVALUE(RFAILED); + } + + /* cm_inet_c_001.main_50 - Update the length only in successful cases */ + *len += ret; + + /* cm_inet_c_001.main_50 - if what is actually sent is less than what is attemped + * to be sent, then return WOULDBLOCK + */ + if (ret < ioLen) + RETVALUE(RWOULDBLOCK); + + unSentLen -= ret; + + } while (*len < msgLen); +#endif /* WIN32 | CMINETFLATBUF */ + + RETVALUE(ROK); + +} /* end of cmInetSendDscpMsg */ + +/* +* +* Fun: cmInetSendMsg +* +* Desc: Sends the message data hold by mBuf. +* The len paramter gives the actual written octets. If the socket +* is non-blocking this value can be differ from the mBuf length +* because there was not enough transmit buffer space available. If +* this occurs, RWOULDBLOCK is returned and only a part of the mBuf +* is sent. +* Values for flag parameter: +* +* CM_INET_NO_FLAG - no additional control flag +* +* Ret: ROK - successful +* RWOULDBLOCK - no or not entire mBuf sent because would block +* ROUTRES - failed, out of resources +* RCLOSED - connection was closed by the peer +* RFAILED - failed +* +* Notes: The successful completion of a send call does not indicate that +* the data has been successfully delivered! +* +* This function does not free any sent buffers. +* +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmInetSendMsg +( +CmInetFd *sockFd, /* socket file descriptor */ +CmInetAddr *dstAddr, /* destination Internet address/port */ +CmInetMemInfo *info, /* buffer allocation info */ +Buffer *mBuf, /* buffer structure to send */ +MsgLen *len, /* number of actually sent octets */ +/* added for IPv6 ext hdr */ +#ifdef IPV6_OPTS_SUPPORTED +CmInetIpHdrParm *ipHdrParams, /* IPv6 extensions headers */ +#endif /* IPV6_OPTS_SUPPORTED */ +S16 flags /* additional control flags, unused */ +) +#else +/* added for IPv6 ext hdr */ +#ifdef IPV6_OPTS_SUPPORTED +PUBLIC S16 cmInetSendMsg(sockFd, dstAddr, info, mBuf, len, ipHdrParams, flags) +CmInetFd *sockFd; /* socket file descriptor */ +CmInetAddr *dstAddr; /* destination Internet address/port */ +CmInetMemInfo *info; /* buffer allocation info */ +Buffer *mBuf; /* buffer structure to send */ +MsgLen *len; /* number of actually sent octets */ +CmInetIpHdrParm *ipHdrParams; /* IPv6 extensions headers */ +S16 flags; /* additional control flags, unused */ +#else +PUBLIC S16 cmInetSendMsg(sockFd, dstAddr, info, mBuf, len, flags) +CmInetFd *sockFd; /* socket file descriptor */ +CmInetAddr *dstAddr; /* destination Internet address/port */ +CmInetMemInfo *info; /* buffer allocation info */ +Buffer *mBuf; /* buffer structure to send */ +MsgLen *len; /* number of actually sent octets */ +S16 flags; /* additional control flags, unused */ +#endif /* IPV6_OPTS_SUPPORTED */ +#endif /* ANSI */ +{ +#if (defined(WIN32) || defined(CMINETFLATBUF)) + S32 ret; /* temporary return value */ + MsgLen msgLen; /* message length */ + MsgLen bufLen; /* send buffer length */ + Data *sendBuf; /* plain send buffer */ +#else + S32 ret; /* temporary return value */ + S32 retVal; /* temporary return value */ + S16 i; /* loop index */ + CmInetIovec txArr[CM_INET_MAX_DBUF]; /* scatter vector */ + S16 numDBufs; /* number of dBufs in message */ + struct msghdr msg; /* sendmsg() message header */ + MsgLen msgLen; /* message length */ + U32 strtEndDBufNum; /* starting/ending DBuf number */ + MsgLen unSentLen; /* sent len */ +#ifdef IPV6_SUPPORTED + /* added for IPv6 ext hdr */ +#ifdef IPV6_OPTS_SUPPORTED + U32 curMsgIdx; /* indx in cmsgData where to write an ext hdr */ +#if (defined(SS_LINUX) || defined(_XPG4_2)) + /* alloc from stack for IPv6 ancill data */ + U8 cmsgData[CM_INET_IPV6_ANCIL_DATA]; +#endif /* SS_LINUX || _XPG4_2 */ +#endif /* IPV6_OPTS_SUPPORTED */ +#else +#if (defined(SS_LINUX) || defined(_XPG4_2)) + /* alloc from stack for IPv4 ancill data */ + /* U8 cmsgData[CM_INET_IPV4_ANCIL_DATA];*/ +#endif /* SS_LINUX || _XPG4_2 */ +#endif /* IPV6_SUPPORTED */ +#endif /* WIN32 | CMINETFLATBUF */ + + struct sockaddr_in remAddr; /* remote Internet address */ +#ifdef IPV6_SUPPORTED + struct sockaddr_in6 remAddr6; /* remote Internet address */ +#endif /* IPV8_SUPPORTED */ + CmInetSockAddr *sockAddrPtr; + /* cm_inet_c_001.main_58 : Fix for klockwork issue */ + U32 sizeOfAddr; + + /* cm_inet_c_001.main_50 - Added for partial send handling */ + /* cm_inet_c_001.main_59: Protected under if not defined WIN32*/ +#if (!defined(WIN32)) + MsgLen ioLen; +#endif + + TRC2(cmInetSendMsg) + + UNUSED(flags); + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if ((sockFd == NULLP) || CM_INET_INV_SOCK_FD(sockFd) || + (info == NULLP) || (len == NULLP)) + { + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + /* added for IPv6 ext hdr */ +#if !(defined(WIN32) || defined(CMINETFLATBUF)) +#if (defined(SS_LINUX) || defined(_XPG4_2)) +/* cmMemset((U8*)cmsgData, 0, sizeof(cmsgData)); */ +#endif /* SS_LINUX || _XPG4_2 */ +#ifdef IPV6_OPTS_SUPPORTED + curMsgIdx = 0; +#endif /* IPV6_SUPPORTED */ +#endif /* WIN32 | CMINETFLATBUF */ + + msgLen = 0; /* need by CC to pass without warning */ + sockAddrPtr = NULLP; + sizeOfAddr = 0; + + /* setup remote address */ + if (dstAddr != NULLP) + { +#ifdef IPV6_SUPPORTED + if (dstAddr->type == CM_INET_IPV6ADDR_TYPE) + { + cmMemset((U8*)&remAddr6, 0, sizeof(remAddr6)); + remAddr6.sin6_family = AF_INET6; + remAddr6.sin6_port = CM_INET_HTON_U16(dstAddr->u.ipv6Addr.port); + CM_INET_COPY_IPV6ADDR(&remAddr6.sin6_addr, + &dstAddr->u.ipv6Addr.ipv6NetAddr); + sizeOfAddr = sizeof(remAddr6); + sockAddrPtr = (CmInetSockAddr *)&remAddr6; + } + else + { + cmMemset((U8*)&remAddr, 0, sizeof(remAddr)); + remAddr.sin_family = AF_INET; + remAddr.sin_port = CM_INET_HTON_U16(dstAddr->u.ipv4Addr.port); + remAddr.sin_addr.s_addr = + CM_INET_HTON_U32(dstAddr->u.ipv4Addr.address); + sizeOfAddr = sizeof(remAddr); + sockAddrPtr = (CmInetSockAddr *)&remAddr; + } +#else +/* cmMemset((U8*)&remAddr, 0, sizeof(remAddr)); */ + remAddr.sin_family = AF_INET; + remAddr.sin_port = CM_INET_HTON_U16(dstAddr->port); + remAddr.sin_addr.s_addr = CM_INET_HTON_U32(dstAddr->address); + sizeOfAddr = sizeof(remAddr); + sockAddrPtr = (CmInetSockAddr *)&remAddr; +#endif /* IPV6_SUPPORTED */ + } + +#if (defined(WIN32) || defined(CMINETFLATBUF)) + /* copy message to a flat buffer */ + ret = SFndLenMsg(mBuf, &bufLen); + if (ret != ROK) + { + RETVALUE(RFAILED); + } + /* max message length is limited to control the memory usage */ + /* casting bufLen to avoid warnings */ + if ((bufLen > 0) && ((U32)bufLen > CM_INET_MAX_MSG_LEN)) + { + RETVALUE(RFAILED); + } + ret = SGetSBuf(info->region, info->pool, &sendBuf, bufLen); + if (ret != ROK) + { + RETVALUE(ROUTRES); + } + ret = SCpyMsgFix(mBuf, 0, bufLen, sendBuf, &msgLen); + if ((ret != ROK) || (msgLen != bufLen)) + { + /* cleanup */ + SPutSBuf(info->region, info->pool, sendBuf, bufLen); + RETVALUE(RFAILED); + } + + if (dstAddr == NULLP) + { + /* VxWorks sendto has some problem + * with connected UDP socket, use send */ +#ifndef SS_VW + ret = sendto(sockFd->fd, (S8 *)sendBuf, bufLen, 0, + NULLP, sizeOfAddr); +#else + ret = send(sockFd->fd, (S8 *)sendBuf, bufLen, 0); +#endif /* end of SS_VW */ + } + else + /* cm_inet_c_001.main_54: Fix for vxworks 6.7 sending data on TCP sockets */ + { +#if (defined(SS_VW) && defined(SS_VW6_7)) + if ((sockFd->type == CM_INET_STREAM) || (sockFd->type == SOCK_RDM) ) + { + ret = send(sockFd->fd, (S8 *)sendBuf, bufLen, 0); + } + else +#endif /* end of SS_VW6_7 and SS_VW */ + { + ret = sendto(sockFd->fd, (S8 *)sendBuf, bufLen, 0, + sockAddrPtr, sizeOfAddr); + } + } + if (ret == INET_ERR) + { + /* cleanup */ + SPutSBuf(info->region, info->pool, sendBuf, bufLen); + + if(INET_ERR_CODE == ERR_AGAIN) + { + *len = 0; + RETVALUE(RWOULDBLOCK); + } + + /* Check for ERR_WOULDBLOCK */ + if(INET_ERR_CODE == ERR_WOULDBLOCK) + { + *len = 0; + RETVALUE(RWOULDBLOCK); + } + +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetSendMsg() Failed : error(%d), msgLen(%d)," + " sockFd->fd(%ld)\n", INET_ERR_CODE, bufLen, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET023, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetSendMsg() Failed : error(%d), msgLen(%d)," + " sockFd->fd(%d)\n", INET_ERR_CODE, bufLen, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET023, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + + /* cm_inet_c_001.main_37 network unreacheble error is added */ + /* check if network is reacheble*/ + if ((INET_ERR_CODE == ERR_NETUNREACH)) + { + RETVALUE(RNETFAILED); + } + + + /* Check if connection was closed */ + if ((INET_ERR_CODE == ERR_PIPE) || + (INET_ERR_CODE == ERR_CONNABORTED) || + (INET_ERR_CODE == ERR_CONNRESET)) + { + *len = 0; + RETVALUE(RCLOSED); + } + + RETVALUE(RFAILED); + } + + *len = ret; + + /* check if entire message could be sent */ + + if (ret < bufLen) + { + /* cleanup */ + SPutSBuf(info->region, info->pool, sendBuf, bufLen); + RETVALUE(RWOULDBLOCK); + } + + /* cleanup */ + SPutSBuf(info->region, info->pool, sendBuf, bufLen); + +#else /* end of Win NT/flat buffer specific part */ + ret = SFndLenMsg(mBuf, &msgLen); + if (ret != ROK) + { + RETVALUE(RFAILED); + } + + /* added */ +/* cmMemset((U8*)&msg, 0, sizeof(msg)); */ + msg.msg_flags = 0; + + if (dstAddr != NULLP) + { +#ifdef SS_LINUX + msg.msg_name = (Void*)sockAddrPtr; +#else +#ifdef SS_PS + msg.msg_name = (char *)sockAddrPtr; +#else + msg.msg_name = (caddr_t)sockAddrPtr; +#endif /* SS_PS */ +#endif /* SS_LINUX */ + msg.msg_namelen = sizeOfAddr; + } + else + { + msg.msg_name = NULLP; + msg.msg_namelen = 0; + } + /* added defined(_XPG4_2) */ +#if (defined(SS_LINUX) || defined(_XPG4_2)) + msg.msg_control = NULLP; + msg.msg_controllen = 0; +#else + msg.msg_accrights = 0; + msg.msg_accrightslen = NULLP; +#endif /* SS_LINUX */ + + /* allocate scatter vector */ + numDBufs = CM_INET_MAX_DBUF; + retVal = RNA; + ret = ROK; + unSentLen = msgLen; + strtEndDBufNum = 0; + *len = 0; + + /* if the sender wants to send Ipv6 exten. headers */ +#ifdef IPV6_OPTS_SUPPORTED + if (ipHdrParams != NULLP && (ipHdrParams->type == CM_INET_IPV6ADDR_TYPE)) + { +#ifdef SS_LINUX + if(ipHdrParams->u.ipv6HdrParm.ttl.pres == TRUE) + { + cmInetBuildSendHoplimit((U32)ipHdrParams->u.ipv6HdrParm.ttl.val, + (U8 *)(cmsgData + curMsgIdx), &curMsgIdx); + } +#endif /* SS_LINUX */ + +#ifdef LOCAL_INTF + /* have to decide how to get the src addr to add in in6_pktinfo */ + if(ipHdrParams->u.ipv6HdrParm.srcAddr6.type == 6) + { + cmInet6BuildSendPktinfo( + &ipHdrParams->u.ipv6HdrParm.srcAddr6.u.ipv6NetAddr, + (U8 *)(cmsgData + curMsgIdx), &curMsgIdx, + sockFd->protType); + } +#endif /* LOCAL_INTF */ + + /* copy each ipv6 ext header from ipHdrParams to the flat buffer + * cmsgData one by one. */ + + if (ipHdrParams->u.ipv6HdrParm.ipv6ExtHdr.hbhHdrPrsnt == TRUE) + /* build HBH ext header in cmsgData starting at indx 0 */ + cmInet6BuildSendHBHOpts( + &ipHdrParams->u.ipv6HdrParm.ipv6ExtHdr.hbhOptsArr, + (U8 *)(cmsgData + curMsgIdx), &curMsgIdx, 0); + + /* now copy the elements from the Destination Option array one by + * one to the Flat Buffer cmsgData. Start filling at indx curMsgIdx + * which is the end of HBH hdr. */ + if (ipHdrParams->u.ipv6HdrParm.ipv6ExtHdr.destOptsPrsnt == TRUE) + /* build Dest opt hdr starting at (cmsgData + curMsgIdx) */ + cmInet6BuildSendDestOpts( + &(ipHdrParams->u.ipv6HdrParm.ipv6ExtHdr.destOptsArr), + (U8 *)(cmsgData + curMsgIdx), &curMsgIdx, 1); + + /* copy Route header to to the Flat Buffer cmsgData */ + if (ipHdrParams->u.ipv6HdrParm.ipv6ExtHdr.rtOptsPrsnt == TRUE) + /* curMsgIdx will be the indx where Dest opt ends in cmsgData */ + cmInet6BuildSendRouteOpts( + &ipHdrParams->u.ipv6HdrParm.ipv6ExtHdr.rtOptsArr, + (U8 *)(cmsgData + curMsgIdx), &curMsgIdx); + + /* msghrd struc's msg_control will point cmsgData and msg_controllen + * will be the curMsgIdx */ + msg.msg_control = cmsgData; /* pointer to Ancillary Data */ + msg.msg_controllen = curMsgIdx; /* total length of ancillary Data */ + + } +#endif /* IPV6_OPTS_SUPPORTED */ + + /* Loop till all the data is sent or till the sendmsg call cannot send + * any more data. */ + do + { + /* build the send vector */ + /* cm_inet_c_001.main_50 - Partial send handling. Added variable to hold + total length of the packed dbufs */ + retVal = buildSendIovec(mBuf, unSentLen, txArr, numDBufs, &i, + &strtEndDBufNum, &ioLen); + if (retVal != ROK) + { + if (retVal == RNA) + { + /* Incase of UDP/RAW messages call SCompressMsg. */ + if (sockFd->type != CM_INET_STREAM) + { + /* Compress the message into a single dBuf */ + ret = SCompressMsg(mBuf); + if (ret != ROK) + RETVALUE(RFAILED); + + strtEndDBufNum = 0; + /* Rebuild the send vector */ + /* cm_inet_c_001.main_50 - Partial send handling. Added variable to hold + total length of the packed dbuf */ + ret = buildSendIovec(mBuf, unSentLen, txArr, numDBufs, &i, + &strtEndDBufNum, &ioLen); + if (ret != ROK) + RETVALUE(RFAILED); + + retVal = ROK; + } + } + else + RETVALUE(RFAILED); + } + msg.msg_iov = txArr; + msg.msg_iovlen = i; + + +#ifdef NTL_LIB + { + extern int ntl_hLib; + if ( sockFd->fd >= 0xD001) + ret = ntl_sendmsg(ntl_hLib, sockFd->fd, &msg, 0); + else + ret = sendmsg(sockFd->fd, &msg, 0); + } +#else + ret = sendmsg(sockFd->fd, &msg, 0); +#endif + /* cm_inet_c_001.main_50 - Update the length only in successful cases */ + if (ret == INET_ERR) + { + if((INET_ERR_CODE == ERR_AGAIN) || + (INET_ERR_CODE == ERR_WOULDBLOCK)) + { + /* cm_inet_c_001.main_50 - Return without making length 0, if in case the partial + message was sent earlier */ + RETVALUE(RWOULDBLOCK); + } +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetSendMsg() Failed : error(%d)," + " sockFd->fd(%ld)\n", INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET024, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetSendMsg() Failed : error(%d)," + " sockFd->fd(%d)\n", INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET024, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + + /* cm_inet_c_001.main_37 network unreacheble error is added */ + /* check if network is reacheble or not */ + if ((INET_ERR_CODE == ERR_NETUNREACH)) + { + RETVALUE(RNETFAILED); + } + + /* Check if connection was closed by the peer */ + if ((INET_ERR_CODE == ERR_PIPE) || + (INET_ERR_CODE == ERR_CONNREFUSED) || + (INET_ERR_CODE == ERR_CONNABORTED)) + { + *len = 0; + RETVALUE(RCLOSED); + } + RETVALUE(RFAILED); + } + + /* cm_inet_c_001.main_50 - Update the length only in successful cases */ + *len += ret; + + /* cm_inet_c_001.main_50 - if what is actually sent is less than what is attemped + * to be sent, then return WOULDBLOCK + */ + if (ret < ioLen) + RETVALUE(RWOULDBLOCK); + + unSentLen -= ret; + + } while (*len < msgLen); +#endif /* WIN32 | CMINETFLATBUF */ + + RETVALUE(ROK); + +} /* end of cmInetSendMsg */ + + +/* added new functions for IPv6 extension headers */ +#ifdef IPV6_OPTS_SUPPORTED +#ifdef LOCAL_INTF +/* +* +* Fun: cmInet6BuildSendPktinfo +* +* Desc: This function inserts src address (into ancillary data) which +* will be used as the src addr in outgoing IP packet when sending +* that packet using sendmsg()function. +* +* Ret: ROK +* +* Notes: +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PRIVATE S16 cmInet6BuildSendPktinfo +( +CmInetIpAddr6 *srcAddr, /* src ip addr to set on outgoing packet */ +U8 *cmsgBuf, /* flat buffer where to build ext hdrs */ +U32 *curMsgIdx, /* idx in cmsgBuf where HBH/Dest ext hdr ends */ +U8 protType /* whether IPv4/IPv6 socket */ +) +#else +PRIVATE S16 cmInet6BuildSendPktinfo(srcAddr, cmsgBuf, curMsgIdx, protType) +CmInetIpAddr6 *srcAddr; /* src ip addr to set on outgoing packet */ +U8 *cmsgBuf; /* flat buffer where to build ext hdrs */ +U32 *curMsgIdx; /* idx in cmsgBuf where HBH/Dest ext hdr ends */ +U8 protType; /* whether IPv4/IPv6 socket */ +#endif /* ANSI */ +{ + struct cmsghdr *tempHdr; + struct in6_pktinfo *ipv6Pktinfo; + struct in6_addr lpBkAddr; + U8 len; + + TRC2(cmInet6BuildSendPktinfo) + + len = 0; + + lpBkAddr = in6addr_loopback; + + /* cmsghdr struc will appear before data in the ancillary data object. + * So put cmsghdr struc in flat buffer first. */ + + /* cmsghdr struc points to flat buffer's starting address */ + tempHdr = (struct cmsghdr *)cmsgBuf; + + /* fill up level & type of cmsghdr structure */ + if (protType == AF_INET6) + { + tempHdr->cmsg_level = IPPROTO_IPV6; + tempHdr->cmsg_type = IPV6_PKTINFO; + } +#ifdef CMINETDBG + else if(protType == AF_INET) + { + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "Invalid socket type in cmInet6BuildPktinfo()," + "protType(%d)\n", protType); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET025, 0, prntBuf); + + } +#endif + /* skip length of cmsghdr structure - 12 bytes */ + len += sizeof(struct cmsghdr); + + if(protType == AF_INET6) + ipv6Pktinfo = (struct in6_pktinfo *)(cmsgBuf + len); +#ifdef CMINETDBG + else + { + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "Invalid socket type in cmInet6BuildPktinfo()," + "protType(%d)\n", protType); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET026, 0, prntBuf); + } +#endif + + /* insert the hoplimit. This will override the kernel's + * default hoplimit value */ + if(protType == AF_INET6) + { + /* store ipv6 src addr */ + cmMemcpy((U8 *)&(ipv6Pktinfo->ipi6_addr), (U8 *)srcAddr, 16); + len += 16; + + /* store interface index */ + /* 0 is invalid intf indx it tells kernel to chose any intf it likes to + * send this pkt. if we use nozero intf indx then kernel will send this + * pkt only through that intf */ + ipv6Pktinfo->ipi6_ifindex = 0; + len += sizeof(int); + } +#ifdef CMINETDBG + else if(protType == AF_INET) + { + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "Invalid socket type in cmInet6BuildPktinfo()," + "protType(%d)\n", protType); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET027, 0, prntBuf); + } +#endif + + /* fill up the length of cmsghdr structure */ + tempHdr->cmsg_len = len; + *curMsgIdx += len; + + RETVALUE(ROK); + +}/* end of cmInet6BuildSendPktinfo */ +#endif /* LOCAL_INTF */ + + +#ifdef SS_LINUX +/* +* +* Fun: cmInetBuildSendHoplimit +* +* Desc: This function inserts hoplimit value to be sent out by ancillary +* data by calling sendmsg()function. +* +* Ret: ROK +* +* Notes: +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PRIVATE S16 cmInetBuildSendHoplimit +( +U32 hoplimit, /* the hoplimit value to be set on outgoing packet */ +U8 *cmsgBuf, /* flat buffer where to build ext hdrs */ +U32 *curMsgIdx /* idx in cmsgBuf where HBH/Dest ext hdr ends */ +) +#else +PRIVATE S16 cmInetBuildSendHoplimit(hoplimit, cmsgBuf, curMsgIdx) +U32 hoplimit; /* the hoplimit value to be sent on outgoing packet */ +U8 *cmsgBuf; /* flat buffer where to build ext hdrs */ +U32 *curMsgIdx; /* idx in cmsgBuf where HBH/Dest ext hdr ends */ +#endif /* ANSI */ +{ + struct cmsghdr *tempHdr; + U8 len; + + TRC2(cmInetBuildSendHoplimit) + + len = 0; + + /* cmsghdr struc will appear before data in the ancillary data object. + * So put cmsghdr struc in flat buffer first. */ + + /* cmsghdr struc points to flat buffer's starting address */ + tempHdr = (struct cmsghdr *)cmsgBuf; + + /* fill up level & type of cmsghdr structure */ + tempHdr->cmsg_level = IPPROTO_IPV6; + tempHdr->cmsg_type = IPV6_HOPLIMIT; + + /* skip cmsghdr struc (length of cmsghdr structure) */ + len += sizeof(struct cmsghdr); + + /* insert the hoplimit. This will override the kernel's + * default hoplimit value */ + *(cmsgBuf + len) = hoplimit; + len += sizeof(hoplimit); + + /* fill up the length of cmsghdr structure */ + tempHdr->cmsg_len = len; + *curMsgIdx += len; + + RETVALUE(ROK); +} /* end of cmInetBuildSendHoplimit */ +#endif /* SS_LINUX */ + + +/* +* +* Fun: cmInet6BuildSendHBHOpts +* +* Desc: This function builds the HopByHop option which will be put +* in the data portion of the ancillary data object. To build +* the HopByHop option this function takes an array of +* individual HopByHop option and fill them in a flat buffer. +* cmsghdr struc always appear before HopBYHop Options, Dest +* Options and Route header option. +* +* The address of the flat Buffer *cmsgBuf is passed to this +* function from cmInetSendMsg. This buffer will have all extension +* headers. This buffer is passed as ancillary data by sendmsg() +* +* Ret: +* +* Notes: This function will also be used for Destination options +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PRIVATE S16 cmInet6BuildSendHBHOpts +( +CmInetIpv6HBHHdrArr *hbhOptsArr,/* IPv6 extensions headers HBH/Dest opts */ +U8 *cmsgBuf, /* flat buffer where to build ext hdrs */ +U32 *curMsgIdx, /* idx in cmsgBuf where HBH/Dest ext hdr ends */ +U8 hdrId /* 0: HBH hdr, 1:Dest Hdr */ +) +#else +PRIVATE S16 cmInet6BuildSendHBHOpts(hbhOptsArr, cmsgBuf, curMsgIdx, hdrId) +CmInetIpv6HBHHdrArr *hbhOptsArr;/* IPv6 extensions headers HBH/Dest opts */ +U8 *cmsgBuf; /* flat buffer where to build ext hdrs */ +U32 *curMsgIdx; /* idx in cmsgBuf where HBH/Dest ext hdr ends */ +U8 hdrId; /* 0: HBH hdr, 1:Dest Hdr */ +#endif +{ + struct cmsghdr *tempHdr; + U8 len; + U8 optsIdx; + + TRC2(cmInet6BuildSendHBHOpts) + + len = 0; + optsIdx = 0; + + /* cmsghdr struc will appear before data in the ancillary data object. + * So put cmsghdr struc in flat buffer first. */ + + /* cmsghdr struc points to flat buffer's starting address */ + tempHdr = (struct cmsghdr *)cmsgBuf; + + /* fill up level & type of cmsghdr structure */ + if (hdrId == 0) + { + tempHdr->cmsg_level = IPPROTO_IPV6; + tempHdr->cmsg_type = IPV6_HOPOPTS; + } + else if (hdrId == 1) + { + tempHdr->cmsg_level = IPPROTO_IPV6; + tempHdr->cmsg_type = IPV6_DSTOPTS; + } + + /* skip cmsghdr struc (length of cmsghdr structure) */ + len += (sizeof(tempHdr->cmsg_level) + sizeof(tempHdr->cmsg_len) + + sizeof(tempHdr->cmsg_type)); + + /* Next Hdr: will be fill up accordingly by Kernel */ + *(cmsgBuf + len) = 0x00; + len += 1; + + /* Header Ext Length: will be fill up by us. In units of 8-byte excluding + * first 8 bytes starting from Next Header field. */ + *(cmsgBuf + len) = 0x00; + len += 1; + + /* fillup all HBH/dest options' TLV. Here, we assume that all the HBH/dest + * options are packed inside 1 HBH option header. */ + for (optsIdx = 0; optsIdx < hbhOptsArr->numHBHOpts; + optsIdx ++) + { + /* Copy the TLV into cmsgBuf data portion */ + /* copy type field of every HBH/dest option */ + *(cmsgBuf + len) = hbhOptsArr->hbhOpts[optsIdx].type; + len += sizeof(hbhOptsArr->hbhOpts[optsIdx].type); + + /* copy length field of every HBH/dest option */ + *(cmsgBuf + len) = hbhOptsArr->hbhOpts[optsIdx].length; + len += sizeof(hbhOptsArr->hbhOpts[optsIdx].length); + + /* copy all value bytes of current HBH/dest option to the flat buffer */ + cmMemcpy((U8 *)(cmsgBuf + len), + (U8 *)(hbhOptsArr->hbhOpts[optsIdx].value), + hbhOptsArr->hbhOpts[optsIdx].length); + len += hbhOptsArr->hbhOpts[optsIdx].length; + } + + /* cuMsgIdx will have the total length of HBH options array */ + /* add this length to the length of cmsgHdr struc */ + + /* Padding: Different header has different padding requirement(xn+y). For + * HBH Router Alert we need 2 bytes of padding. As this same function is + * used for Destination option also and there is no option for it is yet + * proposed, we are passing padN options - 6 bytes to make the Dest Option + * hdr a multiple of 8 bytes. */ + + /* HBH: padN of 2 bytes needed for Router Alert */ + /* This logic is present currently to support router alert which is the + * only supported HBH option today. For other, generic method needed */ + if (hdrId == 0) + { + *(cmsgBuf + len) = 0x01; + len += 1; + *(cmsgBuf + len) = 0x00; + len += 1; + } + + /* fill up the length of cmsghdr structure */ + tempHdr->cmsg_len = len; + *curMsgIdx += len; + + RETVALUE(ROK); +} /* end of cmInet6BuildSendHBHOpts */ + + +/* +* +* Fun: cmInet6BuildSendRouteOpts +* +* Desc: This function transfers bytes from the Route hdr array to the +* flat buffer. First the top cmsghdr structure will be filled in +* the flat buffer, then route hdr type 0 will be added after +* cmsghdr struc in the flat buffer. Then all IPV6 addresses will +* be filled up. +* +* Ret: +* +* Notes: None +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PRIVATE S16 cmInet6BuildSendRouteOpts +( +CmInetIpv6RtHdr *rtOptsArr, /* IPv6 destination options array */ +U8 *cmsgBuf, /* flat buffer where to build ext hdrs */ +U32 *curMsgIdx /* idx in cmsgBuf where to start building RT hdr */ +) +#else +PRIVATE S16 cmInet6BuildSendRouteOpts(rtOptsArr, cmsgBuf, curMsgIdx) +CmInetIpv6RtHdr *rtOptsArr; /* IPv6 destination options array */ +U8 *cmsgBuf; /* flat buffer where to build ext hdrs */ +U32 *curMsgIdx; /* idx in cmsgBuf where to start building RT hd */ +#endif /* ANSI */ +{ + struct cmsghdr *tempHdr; + CmInetIpv6RtHdr0 *tempRtHdr; + U8 len; + U8 addrIdx; + + TRC2(cmInet6BuildSendRouteOpts); + + len = 0; + addrIdx = 0; + + /* cmsghdr struc will appear before data in the ancillary data object. + * So put cmsghdr struc in flat buffer first */ + + /* cmsghdr struc points to flat buffer */ + tempHdr = (struct cmsghdr *)(cmsgBuf); + + tempHdr->cmsg_level = IPPROTO_IPV6; + tempHdr->cmsg_type = IPV6_RTHDR; + + /* skip cmsghdr structure */ + len += sizeof(struct cmsghdr); + + /* we know the total size of Route hdr if we know the num of ipv6 addrs */ + tempHdr->cmsg_len = len + sizeof(CmInetIpv6RtHdr0) + + rtOptsArr->numAddrs * sizeof(CmInetIpAddr6); + + /* attach route hdr type 0 after cmsghdr structure */ + tempRtHdr = (CmInetIpv6RtHdr0 *)(cmsgBuf + len); + + /* fill up fields of route hdr type 0 */ + + /* will be filled up by Kernel */ + tempRtHdr->ip6r0_nextHdr = 0x00; + + tempRtHdr->ip6r0_hdrExtLen = (2 * rtOptsArr->numAddrs); + + /* only type supported today */ + tempRtHdr->ip6r0_type = 0x00; + + tempRtHdr->ip6r0_segLeft = rtOptsArr->numAddrs; + + /* Note: rfc 2292(1998) mentions 1 reserve byte & 3 strict/loose bytes + * restricting total 23 ipv6 addresses can be added to the route header. + * But rfc 2292(2002) mentions all 4 bytes are reserved which allows + * as many ipv6 addresses as wishes to be added to the route header */ + + tempRtHdr->ip6r0_resrvAndSLmap = rtOptsArr->slMap; + + /* move pointer in the flat buffer to the end of this structure */ + len += sizeof(CmInetIpv6RtHdr0); + + /* fill up all IPV6 addresses from rtOptsArr in the flat buffer */ + for (addrIdx = 0; addrIdx < rtOptsArr->numAddrs; addrIdx++) + { + cmMemcpy((U8 *)(cmsgBuf + len), + (U8 *)(rtOptsArr->ipv6Addrs[addrIdx]), 16); + len += 16; + } + + *curMsgIdx += len; + RETVALUE(ROK); +} /* end of cmInet6BuildSendRouteOpts */ + + +/* +* +* Fun: cmInet6BuildRecvHopOptsArr +* +* Desc: This function fills up the HopByHop Array of ipHdrParam from +* the ancillary data received through recvmsg() call. The memory +* to hold the extension headers is allocated here. All received +* ext hdr info will be passed to upper user as ipHdrParam. +* +* Ret: ROK - successful +* RFAILED - failed +* +* Notes: None +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PRIVATE S16 cmInet6BuildRecvHopOptsArr +( +U8 *cmsgData, /* flat buffer where to build ext hdrs */ +U32 hbhDataLen, /* byte len of cmsghdr + hbh ancil data */ +CmInetIpv6HBHHdrArr *hbhOptsArr, /* IPv6 extensions headers */ +U8 hdrId, /* 0: HBH, 1: DEST */ +CmInetMemInfo *info /* Memory information */ +) +#else +PRIVATE S16 cmInet6BuildRecvHopOptsArr(cmsgData, hbhDataLen, hbhOptsArr, hdrId, + info) +U8 *cmsgData; /* flat buffer where to build ext hdrs */ +U32 hbhDataLen; /* byte len of cmsghdr + hbh ancil data */ +CmInetIpv6HBHHdrArr *hbhOptsArr; /* IPv6 extensions headers */ +U8 hdrId; /* 0: HBH, 1: DEST */ +CmInetMemInfo *info; /* Memory information */ +#endif /* ANSI */ +{ + U32 curDataIdx; /* to keep track where we are in the hbh Data */ + U8 optsIdx; /* how many hbh opts present in data */ + U8 numOpts; /* number of hbh opts present in data */ + U8 tempLen; + U8 tempType; + S16 ret; + + TRC2(cmInet6BuildRecvHopOptsArr) + + /* get length of actual hbh ancillary data */ + hbhDataLen -= sizeof(struct cmsghdr); + + curDataIdx = 0; + optsIdx = 0; + numOpts = 0; + + /* skip Next Hdr byte & Hdr Ext Length byte */ + curDataIdx += 2; + + /* First find out how many hop-by-hop headers we need to allocate */ + for (;;) + { + /* break when all HBH data is copied to hbhOptsArr */ + if (curDataIdx >= hbhDataLen) + break; + + numOpts += 1; + + /* get type */ + tempType = *(U8 *)(cmsgData + curDataIdx); + curDataIdx += 1; + + /* take care of pad1 option */ + if (tempType == 0) + { + /* not considering the pad1 as valid option */ + numOpts -= 1; + continue; + } + + /* get length */ + tempLen = *(U8 *)(cmsgData + curDataIdx); + + /* 1 is to skip length. tempLen to skip the value field */ + curDataIdx += (1 + tempLen); + + /* considering the padN as valid option for Dest Opt Hdr!!! As this is + * the "only" valid option today. Ignore for HBH hdr */ + if (hdrId != 1) + if (tempType == 1) + numOpts -= 1; + } + + /* allocate mem needed to hold all HBH/Dest options */ + ret = SGetSBuf(info->region, info->pool, + (Data **)&hbhOptsArr->hbhOpts, + (Size)((sizeof(CmInetIpv6HBHHdr)) * numOpts)); + if (ret != ROK) + { +#ifdef CMINETDBG + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "SGetSBuf failure 1 in cmInet6BuildRecvHopOptsArr\n"); + CMINETLOGERROR(ERRCLS_ADD_RES, ECMINET028, 0, prntBuf); +#endif /* CMINETDBG */ + RETVALUE(ROUTRES); + } + + curDataIdx = 0; + optsIdx = 0; + + /* skip Next Hdr byte & Hdr Ext Length byte */ + curDataIdx += 2; + + hbhOptsArr->numHBHOpts = numOpts; + + /* fill up HBH/dest opt array from recvd ancillary data */ + for (;;) + { + /* break when all HBH data is copied to hbhOptsArr */ + if (curDataIdx >= hbhDataLen) + break; + + /* only copy Router Alert HBH option part which has type 5. Otherwise, + * skip it when it is a PAD1, PADN or Jumbogram option for HBH. But + * consider padN as valid option for dest opt hdr. */ + + /* get the type of current HBH/dest option */ + tempType = *(cmsgData + curDataIdx); + curDataIdx += 1; + + /* ignore PAD1 for both HBH/dest by skipping to next option */ + if (tempType == 0) + continue; + + /* calculate how much to skip for padN in case of HBH */ + if (hdrId != 1) + { + if (tempType == 1) + { + /* get the length field of padN option */ + tempLen = *(cmsgData + curDataIdx); + curDataIdx += 1; + + /* move pointer forward to skip value field */ + curDataIdx += tempLen; + continue; + } + } + hbhOptsArr->hbhOpts[optsIdx].type = tempType; + + /* copy the length */ + hbhOptsArr->hbhOpts[optsIdx].length = *(cmsgData + curDataIdx); + curDataIdx += 1; + + /* take care of PADN = 2 when value field empty. We also don't need + * to allocate memory for empty value field */ + if (hbhOptsArr->hbhOpts[optsIdx].length == 0) + hbhOptsArr->hbhOpts[optsIdx].value = NULLP; + else + { + /* take care of all other options having valid value field + * such as Router Alert, PADN >= 3 bytes and Jumbo */ + ret = SGetSBuf(info->region, info->pool, + (Data **)&hbhOptsArr->hbhOpts[optsIdx].value, + (Size)hbhOptsArr->hbhOpts[optsIdx].length); + if (ret != ROK) + { +#ifdef CMINETDBG + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "SGetSBuf failure 2 cmInet6BuildRecvHopOptsArr\n"); + CMINETLOGERROR(ERRCLS_ADD_RES, ECMINET029, 0, prntBuf); +#endif /* CMINETDBG */ + /* now go inside every separate HBH option and free the memory + * allocated for its value field */ + for (; optsIdx > 0; optsIdx --) + { + if (hbhOptsArr->hbhOpts[optsIdx - 1].value != NULLP) + { +#ifdef CMINETDBG + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "SPutSBuf call 1 in BuildRecvHopOptsArr\n"); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET030, 0, prntBuf); +#endif /* CMINETDBG */ + SPutSBuf(info->region, info->pool, + (Data *)hbhOptsArr->hbhOpts[optsIdx - 1].value, + (Size)hbhOptsArr->hbhOpts[optsIdx - 1].length); + } + } + /* clean up all CmInetIpv6HBHHdr structures allocated for all + * arrived HBH options OR numOpts CmInetIpv6HBHHdr structures + * allocated after counting numOpts */ +#ifdef CMINETDBG + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "SPutSBuf call 2 in BuildRecvHopOptsArr\n"); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET031, 0, prntBuf); +#endif /* CMINETDBG */ + SPutSBuf(info->region, info->pool, + (Data *)hbhOptsArr->hbhOpts, numOpts * sizeof(CmInetIpv6HBHHdr)); + hbhOptsArr->numHBHOpts = 0; + hbhOptsArr->hbhOpts = NULLP; + RETVALUE(ROUTRES); + } + /* copy the value bytes */ + cmMemcpy((U8 *)hbhOptsArr->hbhOpts[optsIdx].value, + (U8 *)(cmsgData + curDataIdx), + hbhOptsArr->hbhOpts[optsIdx].length); + curDataIdx += hbhOptsArr->hbhOpts[optsIdx].length; + } + + /* get next option */ + optsIdx++; + } + RETVALUE(ROK); +} /* end of cmInet6BuildRecvHopOptsArr() */ + + +/* +* +* Fun: cmInet6BuildRecvRtHdr +* +* Desc: This function fills up the Route Header in the cmInetIpv6HdrParm +* from the recvd ancillary data from recvmsg system call. +* +* Ret: ROK - successful +* RFAILED - failed +* +* Notes: None +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PRIVATE S16 cmInet6BuildRecvRtHdr +( +U8 *cmsgData, /* flat buffer where to build Route hdr */ +U32 rtDataLen, /* byte len of cmsghdr struc+rtHdr ancil data */ +CmInetIpv6RtHdr0 *rtHdr0, /* rtHeader0 struct that precedes IPV6 addrss */ +CmInetIpv6RtHdr *rtOptsArr,/* IPv6 extensions headers */ +CmInetMemInfo *info /* Memory information */ +) +#else +PRIVATE S16 cmInet6BuildRecvRtHdr(cmsgData, rtDataLen, rtHdr0, rtOptsArr, info) +U8 *cmsgData; /* flat buffer where to build Route hdr */ +U32 rtDataLen; /* byte len of cmsghdr struc+rtHdr ancil data */ +CmInetIpv6RtHdr0 *rtHdr0; /* rtHeader0 struct that precedes IPV6 addrss */ +CmInetIpv6RtHdr *rtOptsArr;/* IPv6 extensions headers */ +CmInetMemInfo *info; /* Memory information */ +#endif /* ANSI */ +{ + U32 curDataIdx; /* to keep track where we are in hbh Data */ + U8 i; /* loop counter */ + S16 ret; /* temporary return value */ + + TRC2(cmInet6BuildRecvRtHdr) + + /* byte len of actual rtHdr ancil data */ + rtDataLen -= sizeof(struct cmsghdr); + + /* start from beginning */ + curDataIdx = 0; + + /* copy next header byte */ + rtHdr0->ip6r0_nextHdr = *(cmsgData + curDataIdx); + curDataIdx += 1; + + /* copy header extension length byte */ + rtHdr0->ip6r0_hdrExtLen = *(cmsgData + curDataIdx); + curDataIdx += 1; + + /* copy type byte (always 0) */ + rtHdr0->ip6r0_type = 0x00; + curDataIdx += 1; + + /* copy segment left byte */ + rtHdr0->ip6r0_segLeft = *(cmsgData + curDataIdx); + curDataIdx += 1; + + /* copy 1 reserve byte + 3 strict/loose bytes */ + cmMemcpy((U8 *)(&rtOptsArr->slMap), + (U8 *)(cmsgData + curDataIdx), 4); + curDataIdx += 4; + + /* also save reserv byte + 3 sl bytes to rtHdro struc */ + rtHdr0->ip6r0_resrvAndSLmap = rtOptsArr->slMap; + + /* subtract 8 bytes for Next Hdr, Hdr Ext Len, .... + SL bit map */ + rtOptsArr->numAddrs = (rtDataLen - 8)/16; + + ret = SGetSBuf(info->region, info->pool, + (Data **)&rtOptsArr->ipv6Addrs, + (Size)rtOptsArr->numAddrs * 16); + if (ret != ROK) + { +#ifdef CMINETDBG + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "SGetSBuf failure 1 in cmInet6BuildRecvRtHdr\n"); + CMINETLOGERROR(ERRCLS_ADD_RES, ECMINET032, 0, prntBuf); +#endif /* CMINETDBG */ + RETVALUE(ROUTRES); + } + + /* copy all the ipv6 addresses */ + for(i=0; i < rtOptsArr->numAddrs; i++) + { + cmMemcpy((U8 *)(rtOptsArr->ipv6Addrs[i]), + (U8 *)(cmsgData + curDataIdx), 16); + curDataIdx += 16; + } + + RETVALUE(ROK); +} /* end of cmInet6BuildRecvRtHdr() */ + + +/* +* +* Fun: cmInet6GetHopLimitValue +* +* Desc: This function extracts the hop limit value(ttl) of from the +* ancillary data received through recvmsg() call. Then this +* hoplimit value will be passed to upper user as ipHdrParam. +* +* Ret: ROK - successful +* +* Notes: None +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PRIVATE S16 cmInet6GetHopLimitValue +( +U8 *cmsgData, /* flat buffer where to build ext hdrs */ +U32 hopLimitDataLen, /* byte len of cmsghdr + hbh ancil data */ +CmInetIpv6HdrParm *ipv6HdrParam /* ipv6 header parameters */ +) +#else +PRIVATE S16 cmInet6GetHopLimitValue(cmsgData, hopLimitDataLen, ipv6HdrParam) +U8 *cmsgData; /* flat buffer where to build ext hdrs */ +U32 hopLimitDataLen; /* byte len of cmsghdr + hbh ancil data */ +CmInetIpv6HdrParm *ipv6HdrParam; /* ipv6 header parameters */ +#endif /* ANSI */ +{ + U16 curDataIdx; /* to keep track where we are in the ancillary Data */ + U32 *hopLimitValue; /* ttl/hoplimit value */ + + hopLimitValue = NULL; + curDataIdx = 0; + + /* get length of actual hbh ancillary data */ + hopLimitDataLen -= sizeof(struct cmsghdr); + + /* go to the first byte of hop limit which present after cmsghdr struc */ + curDataIdx += sizeof(struct cmsghdr); + + /* mark that hoplimit(ttl) is present */ + ipv6HdrParam->ttl.pres = TRUE; + + /* the first byte will be the HopLimit value */ + hopLimitValue = (U32 *)(cmsgData); + ipv6HdrParam->ttl.val = (U8)(*hopLimitValue); + + RETVALUE(ROK); +} +#endif /* IPV6_OPTS_SUPPORTED */ + + +/* +* +* Fun: cmInetRecvMsg +* +* Desc: Reads data from a socket into a message. +* The buffers for the message are allocated within the +* cmInetRead() function from the pool and region Id set in the +* info struct. +* If the number of octets given by the paramter len is not +* available the function immediately returns with RKDNA. +* If the len parameter is set to CM_INET_READ_ANY, the currently +* available data is read. +* Values for flag parameter: +* +* CM_INET_NO_FLAG - no additional control flag +* CM_INET_MSG_PEEK - do not destroy data on receive buffer +* +* Ret: ROK - successful +* ROKDNA - ok, data not available +* RCLOSED - connection closed by peer +* ROUTRES - failed, out of resources +* RFAILED - failed +* +* Notes: None. +* +* File: cm_inet.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmInetRecvMsg +( +CmInetFd *sockFd, /* socket file descriptor */ +CmInetAddr *fromAddr, /* sender Internet address/port */ +CmInetMemInfo *info, /* buffer allocation info */ +Buffer **mPtr, /* received buffer structure */ +MsgLen *len, /* number of octets to read */ +/* added for IPv6 */ +#ifdef IPV6_OPTS_SUPPORTED +CmInetIpHdrParm *ipHdrParams, /* IPv6 extensions headers */ +#endif /* IPV6_OPTS_SUPPORTED */ +#ifdef LOCAL_INTF +CmInetLocalInf *localIf, /* local interface on which pkt was recvd */ +#endif /* LOCAL_INTF */ +S32 flags /* additional control flags */ +) +#else +/* added for IPv6 */ +#ifdef IPV6_OPTS_SUPPORTED +#ifdef LOCAL_INTF +PUBLIC S16 cmInetRecvMsg(sockFd, fromAddr, info, mPtr, len, + ipHdrParams, localIf, flags) +CmInetFd *sockFd; /* socket file descriptor */ +CmInetAddr *fromAddr; /* sender Internet address/port */ +CmInetMemInfo *info; /* buffer allocation info */ +Buffer **mPtr; /* received buffer structure */ +MsgLen *len; /* number of octets to read */ +CmInetIpHdrParm *ipHdrParams; /* IPv6 extensions headers */ +CmInetLocalInf *localIf; /* local interface on which pkt was recvd */ +S32 flags; /* additional control flags */ +#else +PUBLIC S16 cmInetRecvMsg(sockFd, fromAddr, info, mPtr, len, ipHdrParams, flags) +CmInetFd *sockFd; /* socket file descriptor */ +CmInetAddr *fromAddr; /* sender Internet address/port */ +CmInetMemInfo *info; /* buffer allocation info */ +Buffer **mPtr; /* received buffer structure */ +MsgLen *len; /* number of octets to read */ +CmInetIpHdrParm *ipHdrParams; /* IPv6 extensions headers */ +S32 flags; /* additional control flags */ +#endif /* LOCAL_INTF */ +#else +#ifdef LOCAL_INTF +PUBLIC S16 cmInetRecvMsg(sockFd, fromAddr, info, mPtr, len, localIf, flags) +CmInetFd *sockFd; /* socket file descriptor */ +CmInetAddr *fromAddr; /* sender Internet address/port */ +CmInetMemInfo *info; /* buffer allocation info */ +Buffer **mPtr; /* received buffer structure */ +MsgLen *len; /* number of octets to read */ +CmInetLocalInf *localIf; /* local interface on which pkt was recvd */ +S32 flags; /* additional control flags */ +#else +PUBLIC S16 cmInetRecvMsg(sockFd, fromAddr, info, mPtr, len, flags) +CmInetFd *sockFd; /* socket file descriptor */ +CmInetAddr *fromAddr; /* sender Internet address/port */ +CmInetMemInfo *info; /* buffer allocation info */ +Buffer **mPtr; /* received buffer structure */ +MsgLen *len; /* number of octets to read */ +S32 flags; /* additional control flags */ +#endif /* LOCAL_INTF */ +#endif /* IPV6_OPTS_SUPPORTED */ +#endif /* ANSI */ +{ +#if (defined(WIN32) || defined(CMINETFLATBUF)) + S32 ret; /* temporary return value */ + U32 pendLen; /* pending data length */ + S32 recvLen; /* number of received octets by recvmsg() */ + MsgLen bufLen; /* entire number of received octets */ + MsgLen curLen; /* current number of octets in buffer */ + Data *recvBuf; /* receive buffer */ + Data *bufPtr; /* current buffer position */ + Buffer *mBuf; /* received message */ + U32 remAddrLen; /* length of remote address */ + struct sockaddr_in *remAddr; /* remote Internet address */ +#ifdef IPV6_SUPPORTED + struct sockaddr_in6 *remAddr6; /* remote Internet address */ + struct sockaddr_in6 remSockAddr; /* to get packet's source IP address */ +#else + CmInetSockAddr remSockAddr; /* to get packet's source IP address */ +#endif /* IPV6_SUPPORTED */ +#else + S32 ret; /* temporary return value */ + /* cm_inet_c_001.main_58: Fix for g++ compilation warning */ + U16 i; /* index */ + U32 pendLen; /* pending data length */ + S32 numBuf; /* number of allocated dBufs */ + S32 recvLen; /* number of received octets by recvmsg() */ + MsgLen bufLen; /* entire number of received octets */ + struct msghdr msg; /* message header */ + /* cm_inet_c_001.main_54: Fix for Klockworks issue */ + Buffer *tempMsg = NULLP; /* temporary message */ + CmInetIovec rxArr[CM_INET_MAX_DBUF]; /* dynamic gather array */ + Buffer **dBufs = NULLP; /* dynamic array with allocated dBufs */ + S16 numDBufs; /* number of allocated dBufs */ + + /* cm_inet_c_001.main_55: As remAddrLen is only being used when + * WIN32 or CMINETFLATBUF is defined, then Removed variable + * in else part*/ + struct sockaddr_in *remAddr; /* remote Internet address */ +#ifdef IPV6_SUPPORTED + struct sockaddr_in6 *remAddr6; /* remote Internet address */ + struct sockaddr_in6 remSockAddr;/* to get packet's source IP address */ + /* added for IPv6 ext headers support */ +#ifdef IPV6_OPTS_SUPPORTED + CmInetIpv6RtHdr0 rtHdr0; /* type 0 route header */ +#endif /* IPV6_OPTS_SUPPORTED */ + +#ifdef LOCAL_INTF + struct in6_pktinfo *pkt6Info; /* IPv6 IP_PKTINFO */ +#endif /* LOCAL_INTF */ + +#if (defined(SS_LINUX) || defined(_XPG4_2)) + U8 ancillData[CM_INET_IPV6_ANCIL_DATA]; + /* from stack for IPv6 ancill data */ +#endif +#else + CmInetSockAddr remSockAddr; /* to get packet's src IP address */ +#if (defined(SS_LINUX) || defined(_XPG4_2)) + U8 ancillData[CM_INET_IPV4_ANCIL_DATA]; + /* from stack for IPv4 ancill data */ +#endif +#endif /* IPV6_SUPPORTED */ + /* added new definitions */ + Bool allocFlatBuf; /* allocate a flat buffer */ + /* cm_inet_c_001.main_54: Fix for Klockworks issue */ + Data *recvBuf = NULLP; /* receive buffer */ +#ifdef SS_LINUX +#ifdef LOCAL_INTF + struct in_pktinfo *pkt4Info; /* IPv4 IP_PKTINFO */ +#endif +#endif /* SS_LINUX */ +#if (defined(IPV6_OPTS_SUPPORTED) || defined(LOCAL_INTF)) + struct cmsghdr *cmsgptr;/* pointer to struct cmsghdr */ +#endif +#endif /* WIN32 | CMINETFLATBUF */ + /* used by getsockopt */ + + /* cm_inet_c_001.main_55:Removed unused variables errValue and optLen */ + + TRC2(cmInetRecvMsg) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if ((sockFd == NULLP) || CM_INET_INV_SOCK_FD(sockFd) || + (info == NULLP) || (mPtr == NULLP) || (len == NULLP)) + { + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + *mPtr = NULLP; + + /*cm_inet_c_001.main_48 variables declaration */ +#if !((defined(WIN32) || defined(CMINETFLATBUF))) + numBuf = 0; + numDBufs = 0; +#endif + +#if (defined(WIN32) || defined(CMINETFLATBUF)) + remAddr = NULLP; +#ifdef IPV6_SUPPORTED + remAddr6 = NULLP; +#endif /* IPV6_SUPPORTED */ +#else +#ifdef IPV6_SUPPORTED + remAddr = NULLP; + remAddr6 = NULLP; +#endif /* IPV6_SUPPORTED */ + +#if (defined(SS_LINUX) || defined(_XPG4_2)) + cmMemset((U8*)ancillData, 0, sizeof(ancillData)); +#endif /* SS_LINUX || _XPG4_2 */ + +#endif /* (WIN32 | CMINETFLATBUF) */ + + /* clear the structure */ + cmMemset((U8*)&remSockAddr, 0, sizeof(remSockAddr)); + + /* get number of pending data */ + /* removed 3rd arg memInfo. MemInfo is no longer + needed as we call ioctl for all sockets */ + + /* cm_inet_c_001.main_48 : call ioctl only for STREAM + * sockets now. For Non-Stream sockets(Raw & UDP), fix + * pending length to CM_INET_MAX_UDPRAW_MSGSIZE + */ + if(sockFd->type == CM_INET_STREAM) + { + ret = cmInetGetNumRead(sockFd, &pendLen); + if (ret != ROK) + { + /* ret may be RFAILED or ROUTRES */ + RETVALUE(ret); + } + } + else + { + /* cm_inet_c_001.main_48 : pendLen is set 1 greater + * than the #defined value. If recvFrom/recvMsg + * returns the len == pendLen, we would drop the + * message as the msg len is larger than the largest + * msg we are willing to accept. + */ + pendLen = CM_INET_MAX_UDPRAW_MSGSIZE+1; + } + + + /* check if connection got closed */ + if (pendLen == 0) + { + if (sockFd->type == CM_INET_STREAM) + { + /* cm_inet_c_001.main_50: + * cm_inet_c_001.main_56: Removed comment for cm_inet_c_001.main_50 as + * the current patch changes its functionality */ + U8 readBuf[1]; /* declaration of variable for Peek */ + + /* + * cm_inet_c_001.main_56: + * We are peeking the socket buffer again with peek as on some machines + * like solaris, there is a latency observed in ioctl. In such cases, + * ioctl may return 0, even though there are bytes available to read. + * We reconfirm through peek whether 0 means EOF or its ioctl latency + * issue. + */ + ret = cmInetPeekNew(sockFd, NULLP, info, 0, 1, readBuf); + if (ret == RCLOSED) + { + RETVALUE(ret); + } + /* cm_inet_c_001.main_56: + * Returning ROKDNA even cmInetPeekNew returns ROK. Because currently + * we are not sure about pending length. Anyway socket FD already set, + * we do another iteration to get exact pendLen value. We cannot call + * cmInetGetNumRead at this point because of latency between the ioctl + * call and recvfrom call issues on some machines ioctl call may + * return ZERO even their a data to read. */ + RETVALUE(ROKDNA); + } + } + /* cm_inet_c_001.main_52: Support for partial reception */ + /* cm_inet_c_001.main_59: Fix for compilation warning */ + if ((sockFd->type == CM_INET_STREAM) && (*len > (MsgLen)pendLen)) + { + /* cm_inet_c_001.main_54: Fix for Klockworks issue */ + *len = (MsgLen)pendLen; + } + + /* check if there are enough pending data to read */ + if ((*len == CM_INET_READ_ANY) || ((U32)*len <= pendLen)) + { + if (*len == CM_INET_READ_ANY) + { + /* added check for TCP socket. Pending data length in + the socket recv buffer is determined by ioctl call in + cmInetGetNumRead. + For TCP it can't be > CM_INET_MAX_MSG_LEN. */ + if (sockFd->type == CM_INET_STREAM) + { + /* max message length is limited to control the memory usage */ + if (pendLen > CM_INET_MAX_MSG_LEN) + pendLen = CM_INET_MAX_MSG_LEN; + } + /* cm_inet_c_001.main_48 : removed the check for + * Non Stream sockets (pendLen < MAX_UDPRAW_MSGSIZE) + * as we are hardcoding pendLen for Non-Stream sockets. + */ + + /* read all pending data */ + /* cm_inet_c_001.main_54: Fix for Klockworks issue */ + bufLen = (MsgLen)pendLen; + *len = (MsgLen)pendLen; + } + else + { + /* cm_inet_c_001.main_45- Returning CM_INET_MAX_MSG_LEN when input is larger than + * this */ +#ifdef LONG_MSG + /* max message length is limited to control the memory usage */ + if ((*len) > CM_INET_MAX_MSG_LEN) + { + (*len) = CM_INET_MAX_MSG_LEN; + } +#endif + /* read data length given by user */ + bufLen = *len; + } + +#if (defined(WIN32) || defined(CMINETFLATBUF)) + + /* set destination Internet address structure */ + if (fromAddr != NULLP) + { + remAddrLen = sizeof(remSockAddr); + } + else + { + remAddrLen = 0; + } + + /* allocate flat receive buffer */ + ret = SGetSBuf(info->region, info->pool, &recvBuf, bufLen); + if (ret != ROK) + { + RETVALUE(ROUTRES); + } + curLen = bufLen; + bufPtr = recvBuf; + + /* + * maybe needs more than one recvfrom() call to read an entire + * message from a stream socket (TCP) + */ + while (curLen > 0) + { + /* added separate recvfrom calls different OS */ + + /*cm_inet_c_001.main_42 1. In Vx-Works the 5th and 6th parameter of recvfrom + system call are either NULL or should be valid pointer.*/ +#if( defined(SS_VW) || defined(HPOS) || defined(SS_PS)) + if (remAddrLen) + recvLen = recvfrom(sockFd->fd, (S8 *)bufPtr, curLen, 0, + (struct sockaddr *)&remSockAddr, (int *)&remAddrLen); + else + recvLen = recvfrom(sockFd->fd, (S8 *)bufPtr, curLen, 0, + NULLP, (int *)&remAddrLen); +#else +#if ( defined(SUNOS) || defined(SS_LINUX)) + if (remAddrLen) + recvLen = recvfrom(sockFd->fd, (S8 *)bufPtr, curLen, 0, + (struct sockaddr *)&remSockAddr, (socklen_t *)&remAddrLen); + else + recvLen = recvfrom(sockFd->fd, (S8 *)bufPtr, curLen, 0, + NULLP, (socklen_t *)&remAddrLen); +#else + if (remAddrLen) + recvLen = recvfrom(sockFd->fd, (S8 *)bufPtr, curLen, 0, + &remSockAddr, (S32 *)&remAddrLen); + else + recvLen = recvfrom(sockFd->fd, (S8 *)bufPtr, curLen, 0, + NULLP, (S32 *)&remAddrLen); + +#endif /* defined(SUNOS) || defined(SS_LINUX) */ +#endif /* defined(SS_VW) || defined(HPOS) || defined(SS_PS) */ + + if (recvLen == INET_ERR) + { + /* cleanup */ + /* moved cleanup here */ + SPutSBuf(info->region, info->pool, recvBuf, bufLen); + + /* added check ERR_WOULDBLOCK */ + if ((INET_ERR_CODE == ERR_AGAIN) || + (INET_ERR_CODE == ERR_WOULDBLOCK)) + { + *len = 0; + RETVALUE(ROKDNA); + } + + + /* In Windows the recvfrom function fails + * with error code which maps to either WSAECONNABORTED. If + * this happens then cmInetRecvMsg must return RCLOSED */ + if ((INET_ERR_CODE == ERR_CONNABORTED) || + (INET_ERR_CODE == ERR_CONNRESET)) + { + *len = 0; + RETVALUE(RCLOSED); + } + +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE,"cmInetRecvMsg() Failed : error(%d)," + " sockFd->fd(%ld)\n", INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET034, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE,"cmInetRecvMsg() Failed : error(%d)," + " sockFd->fd(%d)\n", INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET034, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + + RETVALUE(RFAILED); + } + curLen -= recvLen; + bufPtr += recvLen; + + /* + * a message is always read atomically on a datagram socket, + * therefore it's ok to read less than pending data! + */ +#ifdef CM_INET2 + if ((sockFd->type == CM_INET_RAW) || + (sockFd->type == CM_INET_DGRAM)) + { + *len = recvLen; + break; + } +#else /* CM_INET2 */ + if (sockFd->type == CM_INET_DGRAM) + { + *len = recvLen; + break; + } +#endif /* CM_INET2 */ + } /* while (curLen > 0) (only for stream sockets) */ + + /* For UDP, it is possible to receive + * a 0 byte datagram, in this case just return ROKDNA. + */ +#ifdef CM_INET2 + if ((sockFd->type == CM_INET_DGRAM || sockFd->type == CM_INET_RAW) + && (*len == 0)) +#else + if ((sockFd->type == CM_INET_DGRAM) && (*len == 0)) +#endif + { + SPutSBuf(info->region, info->pool, recvBuf, bufLen); + RETVALUE(ROKDNA); + } + + /* cm_inet_c_001.main_48 : If Received + * len == CM_INET_MAX_UDPRAW_MSGSIZE+1 + * Drop this message + */ +#ifdef CM_INET2 + if ((sockFd->type == CM_INET_DGRAM || sockFd->type == CM_INET_RAW) + && (*len == (CM_INET_MAX_UDPRAW_MSGSIZE+1))) +#else + if ((sockFd->type == CM_INET_DGRAM) + && (*len == (CM_INET_MAX_UDPRAW_MSGSIZE+1))) +#endif + { +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE,"cmInetRecvMsg(),recevied a message" + " > than allowed(%lu), sockFd->fd(%ld) \n", + CM_INET_MAX_UDPRAW_MSGSIZE, sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET068, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE,"cmInetRecvMsg(),recevied a message" + " > than allowed(%lu), sockFd->fd(%d) \n", + CM_INET_MAX_UDPRAW_MSGSIZE, sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET068, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif + SPutSBuf(info->region, info->pool, recvBuf, bufLen); + RETVALUE(ROKDNA); + } + + /* cm_inet_c_001.main_48 : copy data to a message structure */ + ret = SGetMsg(info->region, info->pool, &mBuf); + if (ret != ROK) + { + /* cleanup */ + SPutSBuf(info->region, info->pool, recvBuf, bufLen); + RETVALUE(ret); + } + +#ifdef CM_INET2 + if ((sockFd->type == CM_INET_DGRAM) || + (sockFd->type == CM_INET_RAW)) + { + ret = SAddPstMsgMult(recvBuf, *len, mBuf); + } + else + { + ret = SAddPstMsgMult(recvBuf, bufLen, mBuf); + } + +#else /* CM_INET2 */ + if (sockFd->type == CM_INET_DGRAM) + { + ret = SAddPstMsgMult(recvBuf, *len, mBuf); + } + else + { + ret = SAddPstMsgMult(recvBuf, bufLen, mBuf); + } +#endif /* CM_INET2 */ + + if (ret != ROK) + { + SPutSBuf(info->region, info->pool, recvBuf, bufLen); + SPutMsg(mBuf); + RETVALUE(ret); + } + *mPtr = mBuf; + + /* setup return destination Internet address */ + /* added the check of (remAddrLen > 0) */ + if ((fromAddr != NULLP) && (remAddrLen > 0)) + { +#ifdef IPV6_SUPPORTED + if (remAddrLen == sizeof(struct sockaddr_in6)) + { + remAddr6 = (struct sockaddr_in6 *)&remSockAddr; + fromAddr->type = CM_INET_IPV6ADDR_TYPE; + fromAddr->u.ipv6Addr.port = CM_INET_NTOH_U16(remAddr6->sin6_port); + CM_INET_COPY_IPV6ADDR(&fromAddr->u.ipv6Addr.ipv6NetAddr, + &remAddr6->sin6_addr); + } + else + { + remAddr = (struct sockaddr_in *)&remSockAddr; + fromAddr->type = CM_INET_IPV4ADDR_TYPE; + fromAddr->u.ipv4Addr.port = CM_INET_NTOH_U16(remAddr->sin_port); + fromAddr->u.ipv4Addr.address = CM_INET_NTOH_U32(remAddr->sin_addr.s_addr); + } +#else + remAddr = (struct sockaddr_in *)&remSockAddr; + fromAddr->port = CM_INET_NTOH_U16(remAddr->sin_port); + fromAddr->address = CM_INET_NTOH_U32(remAddr->sin_addr.s_addr); +#endif /* IPV6_SUPPORTED */ + } + + /* cleanup */ + SPutSBuf(info->region, info->pool, recvBuf, bufLen); + +#else /* end of Win NT/flat buffer specific part */ + + /* Initialise variable */ + allocFlatBuf = FALSE; + + /* + * maybe needs more than one recvmsg() call to read entire message + * on a stream socket + */ + while (bufLen > 0) + { + /* allocate gather vector, it's a dynamic array */ + numDBufs = CM_INET_MAX_DBUF; + + ret = SGetSBuf(info->region, info->pool, (Data**)&dBufs, + numDBufs*sizeof(Buffer*)); + if (ret != ROK) + { + RETVALUE(ROUTRES); + } + + /* Allocate dBufs for gather read */ + /* allocate dBufs for gathering read */ + if (sockFd->type == CM_INET_STREAM) + ret = buildRecvBuf(info, bufLen, rxArr, dBufs, numDBufs, &msg, + TRUE); + else + ret = buildRecvBuf(info, bufLen, rxArr, dBufs, numDBufs, &msg, + FALSE); + if (ret != ROK) + { + /* check if the function returned RNA */ + if (ret == RNA) + { + /* Incase of UDP/RAW messages allocate a flat buffer. Incase + * of TCP ignore this error condition. The user will call + * cmInetRecvMsg again */ + /* cm_inet_c_001.main_62:Warning fix */ + if (sockFd->type != (U8)CM_INET_STREAM)/* G++ */ + { + +#ifdef T2K_MEM_LEAK_DBG + char * file = __FILE__; + U32 line = __LINE__; +#endif + + /* cleanup the dBuf array */ + for (i = 0; i < msg.msg_iovlen; i++) + SPutDBuf(info->region, info->pool, dBufs[i]); + + SPutSBuf(info->region, info->pool, (Data*)dBufs, + numDBufs * sizeof(Buffer*)); + + /* allocate flat receive buffer */ + ret = SGetSBuf(info->region, info->pool, &recvBuf, bufLen); + if (ret != ROK) + RETVALUE(ROUTRES); + + allocFlatBuf = TRUE; + + /* update the message structure */ +#ifdef SS_LINUX + rxArr[0].iov_base = (Void*)recvBuf; + rxArr[0].iov_len = (U32)bufLen; +#else + rxArr[0].iov_base = (S8*)recvBuf; + rxArr[0].iov_len = bufLen; +#endif /* SS_LINUX */ + msg.msg_iov = rxArr; + msg.msg_iovlen = 1; + } + } + else + { + SPutSBuf(info->region, info->pool, (Data*)dBufs, + numDBufs*sizeof(Buffer*)); + RETVALUE(ret); + } + } + + numBuf = msg.msg_iovlen; + + /* setup destination Internet address structure */ + if (fromAddr != NULLP) + { +#ifdef SS_LINUX + msg.msg_name = (Void*)&remSockAddr; +#else +#ifdef SS_PS + msg.msg_name = (char *)&remSockAddr; +#else + msg.msg_name = (caddr_t)&remSockAddr; +#endif /* SS_PS */ +#endif /* SS_LINUX */ + msg.msg_namelen = sizeof(remSockAddr); + } + else + { + msg.msg_name = NULLP; + msg.msg_namelen = 0; + } + + /* added defined(_XPG4_2). Also changed the + * assignments */ +#if (defined(SS_LINUX) || defined(_XPG4_2)) + msg.msg_control = ancillData; + msg.msg_controllen = sizeof(ancillData); +#else + msg.msg_accrights = NULLP; + msg.msg_accrightslen = 0; +#endif /* SS_LINUX */ + + recvLen = recvmsg(sockFd->fd, &msg, flags); + if ((recvLen == INET_ERR) || (recvLen > CM_INET_MAX_MSG_LEN)) + { + /* Moved up the cleanup precedures here before returning */ + /* Cleanup flat buffer if allocated */ + if (allocFlatBuf) + SPutSBuf(info->region, info->pool, recvBuf, bufLen); + else + { + /* cleanup */ + for (i = 0; i < numBuf; i++) + { + #ifdef T2K_MEM_LEAK_DBG + char * file = __FILE__; + U32 line = __LINE__; + #endif + + SPutDBuf(info->region, info->pool, dBufs[i]); + } + SPutSBuf(info->region, info->pool, (Data*)dBufs, + numDBufs*sizeof(Buffer*)); + } + + /* cm_inet_c_001.main_50 - Free the buffer only when valid, it might be that + * it has partially received data + */ + /* added check ERR_AGAIN when CMINETFLATBUF is not defined. + added check ERR_WOULDBLOCK */ + if ((INET_ERR_CODE == ERR_AGAIN) || + (INET_ERR_CODE == ERR_WOULDBLOCK)) + { + /* cm_inet_c_001.main_50 : If message is read partially then just return + * OK without freeing the mPtr. This will gaurd us + * against unexpected WOULDBLOCKS observed in solaris + */ + if (*mPtr != NULLP) + RETVALUE(ROK); + + RETVALUE(ROKDNA); + } + + /* cm_inet_c_001.main_50 - Free the buffer only when valid, it might be that + * it has partially received data + */ + if (*mPtr != NULLP) + { + SPutMsg(*mPtr); + } +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE,"cmInetRecvMsg() Failed : error(%d)," + " sockFd->fd(%ld)\n", INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET035, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE,"cmInetRecvMsg() Failed : error(%d)," + " sockFd->fd(%d)\n", INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET035, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + + /* If this happens then cmInetRecvMsg must return RCLOSED. + * Needed for getting icmp msgs */ + if (INET_ERR_CODE == ERR_CONNABORTED) + { + *len = 0; + RETVALUE(RCLOSED); + } + RETVALUE(RFAILED); + } + + bufLen -= recvLen; + + /* added for IPv6 extn headers */ +#if (defined(IPV6_OPTS_SUPPORTED) || defined(LOCAL_INTF)) + + /* check if ancillary data has been received. + * Return the allocated memory when no ancillary data received */ +#if (defined(SS_LINUX) || defined(_XPG4_2)) + if (msg.msg_controllen) + { + cmsgptr = CMSG_FIRSTHDR(&msg); + } + else + cmsgptr = NULLP; +#else + cmsgptr = NULLP; +#endif /* SS_LINUX || _XPG4_2 */ + + if (cmsgptr != NULLP) + { +#ifdef IPV6_OPTS_SUPPORTED + if(ipHdrParams != NULLP) + { + ipHdrParams->u.ipv6HdrParm.ttl.pres = FALSE; + ipHdrParams->u.ipv6HdrParm.ipv6ExtHdr.hbhHdrPrsnt = FALSE; + ipHdrParams->u.ipv6HdrParm.ipv6ExtHdr.destOptsPrsnt = FALSE; + ipHdrParams->u.ipv6HdrParm.ipv6ExtHdr.rtOptsPrsnt = FALSE; + + /* get all ancillary data objects recvd one by one */ + for (cmsgptr = CMSG_FIRSTHDR(&msg); cmsgptr != NULLP; + cmsgptr = CMSG_NXTHDR(&msg, cmsgptr)) + { + if (cmsgptr->cmsg_level == IPPROTO_IPV6) + { + /* Initialise ipHdrParams properly */ + ipHdrParams->type = CM_INET_IPV6ADDR_TYPE; + + if (cmsgptr->cmsg_type == IPV6_HOPOPTS) + { + /* build up HBH opt array from recvd ancillary data */ + ret = cmInet6BuildRecvHopOptsArr( + (U8 *)CMSG_DATA(cmsgptr), cmsgptr->cmsg_len, + &ipHdrParams->u.ipv6HdrParm.ipv6ExtHdr.hbhOptsArr, + 0, info); + if (ret != ROK) + RETVALUE(ret); + ipHdrParams->u.ipv6HdrParm.ipv6ExtHdr.hbhHdrPrsnt = + TRUE; + } +#ifdef SS_LINUX + else if(cmsgptr->cmsg_type == IPV6_DSTOPTS) +#else + else if ((cmsgptr->cmsg_type == IPV6_DSTOPTS) || + (cmsgptr->cmsg_type == IPV6_RTHDRDSTOPTS)) +#endif /* SS_LINUX */ + { + /* build up Dest opt array from recvd ancillary data */ + ret = cmInet6BuildRecvDstOptsArr( + (U8 *)CMSG_DATA(cmsgptr), cmsgptr->cmsg_len, + &ipHdrParams->u.ipv6HdrParm.ipv6ExtHdr.destOptsArr, + 1, info); + if (ret != ROK) + RETVALUE(ret); + ipHdrParams->u.ipv6HdrParm.ipv6ExtHdr.destOptsPrsnt = + TRUE; + } + else if (cmsgptr->cmsg_type == IPV6_RTHDR) + { + /* build up Route Hdr from recvd ancillary data */ + ret = cmInet6BuildRecvRtHdr( + (U8 *)CMSG_DATA(cmsgptr), cmsgptr->cmsg_len, &rtHdr0, + &ipHdrParams->u.ipv6HdrParm.ipv6ExtHdr.rtOptsArr, + info); + if (ret != ROK) + RETVALUE(ret); + ipHdrParams->u.ipv6HdrParm.ipv6ExtHdr.rtOptsPrsnt = + TRUE; + } + else if(cmsgptr->cmsg_type == IPV6_HOPLIMIT) + { + /* get the received hoplimit */ + ret = cmInet6GetHopLimitValue((U8 *)CMSG_DATA(cmsgptr), + cmsgptr->cmsg_len, &ipHdrParams->u.ipv6HdrParm); + if (ret != ROK) + RETVALUE(ret); + } + } + } /* for */ + } /* ipHdrParams */ +#endif /* IPV6_OPTS_SUPPORTED */ + +#ifdef IPV6_SUPPORTED +#ifdef LOCAL_INTF + for (cmsgptr = CMSG_FIRSTHDR(&msg); cmsgptr != NULLP; + cmsgptr = CMSG_NXTHDR(&msg, cmsgptr)) + { + if(cmsgptr->cmsg_type == IPV6_PKTINFO) + { + pkt6Info = (struct in6_pktinfo *)CMSG_DATA(cmsgptr); + localIf->intfPrsnt = TRUE; + localIf->localIf = pkt6Info->ipi6_ifindex; + localIf->localIfAddr.type = CM_INET_IPV6ADDR_TYPE; + cmMemcpy((U8 *)&localIf->localIfAddr.u.ipv6NetAddr, + (U8 *)(int *)&pkt6Info->ipi6_addr, 16); + } + } +#endif /* LOCAL_INTF */ +#endif + +#if (defined(SS_LINUX) && defined(LOCAL_INTF)) +#ifdef IPV6_SUPPORTED + if(sockFd->protType == AF_INET) + { +#endif + for (cmsgptr = CMSG_FIRSTHDR(&msg); cmsgptr != NULL; + cmsgptr = CMSG_NXTHDR(&msg, cmsgptr)) + { + if (cmsgptr->cmsg_level == IPPROTO_IP && + cmsgptr->cmsg_type == IP_PKTINFO) + { + pkt4Info = (struct in_pktinfo *)CMSG_DATA(cmsgptr); + localIf->intfPrsnt = TRUE; + localIf->localIf = pkt4Info->ipi_ifindex; + localIf->localIfAddr.type = CM_INET_IPV4ADDR_TYPE; + localIf->localIfAddr.u.ipv4NetAddr = + ntohl(*(int *)&pkt4Info->ipi_addr); + } + } +#ifdef IPV6_SUPPORTED + } +#endif +#endif /* SS_LINUX */ + } +#endif /* IPV6_OPTS_SUPPORTED || LOCAL_INTF */ + + /* setup return destination Internet address */ + if (fromAddr != NULLP) + { +#ifdef IPV6_SUPPORTED + if (msg.msg_namelen == sizeof(struct sockaddr_in6)) + { + remAddr6 = (struct sockaddr_in6 *)&remSockAddr; + fromAddr->type = CM_INET_IPV6ADDR_TYPE; + fromAddr->u.ipv6Addr.port = + CM_INET_NTOH_U16(remAddr6->sin6_port); + CM_INET_COPY_IPV6ADDR(&fromAddr->u.ipv6Addr.ipv6NetAddr, + &remAddr6->sin6_addr); + } + else + { + remAddr = (struct sockaddr_in *)&remSockAddr; + fromAddr->type = CM_INET_IPV4ADDR_TYPE; + fromAddr->u.ipv4Addr.port = CM_INET_NTOH_U16(remAddr->sin_port); + fromAddr->u.ipv4Addr.address = + CM_INET_NTOH_U32(remAddr->sin_addr.s_addr); + } +#else + remAddr = (struct sockaddr_in *)&remSockAddr; + fromAddr->port = CM_INET_NTOH_U16(remAddr->sin_port); + fromAddr->address = CM_INET_NTOH_U32(remAddr->sin_addr.s_addr); +#endif /* IPV6_SUPPORTED */ + } + + /* Incase a flat buffer was allocated get + * a message to pass up */ + if (allocFlatBuf) + { + bufLen += recvLen; + + /* Get a message */ + ret = SGetMsg(info->region, info->pool, &tempMsg); + if (ret != ROK) + { + /* cleanup */ + SPutSBuf(info->region, info->pool, recvBuf, bufLen); + RETVALUE(ret); + } + + /* cm_inet_c_001.main_48 : A 0 len UDP packet could be received */ + if ( recvLen > 0) + { + ret = SAddPstMsgMult(recvBuf, recvLen, tempMsg); + if (ret != ROK) + { + SPutSBuf(info->region, info->pool, recvBuf, bufLen); + SPutMsg(tempMsg); + RETVALUE(ret); + } + } + + *mPtr = tempMsg; + + SPutSBuf(info->region, info->pool, recvBuf, bufLen); + /* cm_inet_c_001.main_48 :flat buffers are allocated + * for non -TCP sockets. On these sockets we can receive + * only one message at a time + */ + /* cm_inet_c_001.main_54: Fix for Klockworks issue */ + *len = (MsgLen)recvLen; + break; + } + else + { + /* build message out of dBufs */ + ret = buildRecvMsg(info, rxArr, numBuf, recvLen, dBufs, &tempMsg); + if (ret != ROK) + { + /* Deallocate previously allocated + * mBuf */ + if (*mPtr != NULLP) + SPutMsg(*mPtr); + SPutSBuf(info->region, info->pool, (Data*)dBufs, + numDBufs*sizeof(Buffer*)); + RETVALUE(ret); + } + } + + if (*mPtr == NULLP) + { + /* it's first recvmsg() call */ + *mPtr = tempMsg; + } + else + { + /* concatenate messages */ + ret = SCatMsg(*mPtr, tempMsg, M1M2); + if (ret != ROK) + { + /* cleanup */ + SPutMsg(*mPtr); + SPutMsg(tempMsg); + SPutSBuf(info->region, info->pool, (Data*)dBufs, + numDBufs*sizeof(Buffer*)); + RETVALUE(RFAILED); + } + SPutMsg(tempMsg); + } + + SPutSBuf(info->region, info->pool, (Data*)dBufs, + numDBufs*sizeof(Buffer*)); + + /* + * a message is always read atomically on a datagram socket, + * therefore it's ok to read less than pending data! + */ +#ifdef CM_INET2 + if ((sockFd->type == CM_INET_DGRAM) || + (sockFd->type == CM_INET_RAW)) + { + /* cm_inet_c_001.main_54: Fix for Klockworks issue */ + *len = (MsgLen)recvLen; + break; + } +#else /* CM_INET2 */ + if (sockFd->type == CM_INET_DGRAM) + { + /* cm_inet_c_001.main_54: Fix for Klockworks issue */ + *len = (MsgLen)recvLen; + break; + } +#endif /* CM_INET2 */ + } /* while(bufLen > 0) (only for stream sockets) */ + + /* cm_inet_c_001.main_48 : For UDP, it is possible to receive + * a 0 byte datagram, in this case just return ROKDNA + */ + +#ifdef CM_INET2 + if ((sockFd->type == CM_INET_DGRAM || sockFd->type == CM_INET_RAW) + && (*len == 0)) +#else + if ((sockFd->type == CM_INET_DGRAM) && (*len == 0)) +#endif + { + *len = 0; + if (*mPtr != NULLP) + { + SPutMsg(*mPtr); + } + RETVALUE(ROKDNA); + + } + + /* Received len == CM_INET_MAX_UDPRAW_MSGSIZE+1 + * Drop this message + */ + +#ifdef CM_INET2 + if ((sockFd->type == CM_INET_DGRAM || sockFd->type == CM_INET_RAW) + && (*len == (CM_INET_MAX_UDPRAW_MSGSIZE+1))) +#else + if ((sockFd->type == CM_INET_DGRAM) + && (*len == (CM_INET_MAX_UDPRAW_MSGSIZE+1))) +#endif + { + *len = 0; + if (*mPtr != NULLP) + { + SPutMsg(*mPtr); + } + +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE,"cmInetRecvMsg() recevied a message > than" + " allowed(%d),sockFd->fd(%ld)\n", + CM_INET_MAX_UDPRAW_MSGSIZE, sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET069, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE,"cmInetRecvMsg() recevied a message > than" + " allowed(%d),sockFd->fd(%d)\n", + CM_INET_MAX_UDPRAW_MSGSIZE, sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET069, 0, prntBuf); +#endif +#endif + RETVALUE(ROKDNA); + + } + +#endif /* WIN32 | CMINETFLATBUF */ + } + else + { + /* not enough data pending yet */ + RETVALUE(ROKDNA); + } + + RETVALUE(ROK); +} /* end of cmInetRecvMsg */ + + +/* cm_inet_c_001.main_56: Added new function cmInetPeekNew() */ + +/* + * + * Fun: cmInetPeekNew + * + * Desc: Reads some data from the socket without destroying the socket + * receive buffer. + * The data is specified by the byte positon (first byte is at + * position 0) and the length. + * + * Ret: ROK - successful + * ROKDNA - ok, data not available + * RCLOSED - connection closed by peer + * RFAILED - failed + * + * Notes: Following are the differences from the cmInetPeek to cmInetPeekNew. + * This primitive does not call the select function as this is already + * taken care by the called primitive. This primitive will not use any + * ioctl calls, because on some machines due to latency in ioctl call + * length may return as ZERO, even there is some data to be read from + * the socket and this primitive only peek buffer using recvfrom. + * + * Caller of this function need to allocate the sufficient memory to hold + * the data peeked from the socket i.e. dataPos + dataLen. Socket data + * will be copied in the "data" starting from dataPos offset. + * + * For example, caller passed the following values to this function. + * dataPos = 2 and dataLen = 10,then size of data buffer received should + * be minimum of (dataPos + dataLen)12 bytes and socket data will be + * copied in the data buffer from offset 2 (dataPos) onwards. + * + * + * File: cm_inet.c + */ + +#ifdef ANSI +PUBLIC S16 cmInetPeekNew +( + CmInetFd *sockFd, /* socket file descriptor */ + CmInetAddr *fromAddr, /* sender Internet address/port */ + CmInetMemInfo *info, /* buffer allocation info */ + MsgLen dataPos, /* position of data */ + MsgLen dataLen, /* length of read data */ + Data *data /* read data */ + ) +#else +PUBLIC S16 cmInetPeekNew(sockFd, fromAddr, info, dataPos, dataLen, data) + CmInetFd *sockFd; /* socket file descriptor */ + CmInetAddr *fromAddr; /* sender Internet address/port */ + CmInetMemInfo *info; /* buffer allocation info */ + MsgLen dataPos; /* position of data */ + MsgLen dataLen; /* length of read data */ + Data *data; /* read data */ +#endif +{ + /* cm_inet_c_001.main_57 - Fix for validation and compilation warning */ + S32 recvLen; /* number of received octets */ + S32 remAddrLen; /* length of remote address length */ + struct sockaddr_in *remAddr; /* remote Internet address */ +#ifdef IPV6_SUPPORTED + struct sockaddr_in6 *remAddr6; /* remote Internet IPV6 address */ + struct sockaddr_in6 remSockAddr; /* to get packet's source IP address */ +#else + CmInetSockAddr remSockAddr; /* to get packet's source IP address */ +#endif /* IPV6_SUPPORTED */ + + TRC2(cmInetPeeknew); + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if ((sockFd == NULLP) || CM_INET_INV_SOCK_FD(sockFd) || + (info == NULLP) || (data == NULLP) || + (dataPos < 0) || (dataLen < 0)) + { + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + /* check if fromAddr is present or not */ + if (fromAddr != NULLP) + { + remAddrLen = sizeof(remSockAddr); + } + else + { + remAddrLen = 0; + } + + /* added different recvfrom calls with different 6th arg for + * different OS If remAddrLen is 0, pass NULLP */ +#if( defined(SS_VW) || defined(HPOS) || defined(SS_PS)) + if(remAddrLen) + recvLen = recvfrom(sockFd->fd,(S8*)(data + dataPos), (dataLen), + CM_INET_MSG_PEEK, &remSockAddr, (int*)&remAddrLen); + else + recvLen = recvfrom(sockFd->fd,(S8*)(data + dataPos), (dataLen), + CM_INET_MSG_PEEK, NULLP, (int*)&remAddrLen); +#else +#if ( defined(SUNOS) || defined(SS_LINUX)) + if(remAddrLen) + recvLen = recvfrom(sockFd->fd, (S8*)(data + dataPos),(dataLen), + CM_INET_MSG_PEEK, (struct sockaddr *)&remSockAddr, + (socklen_t *)&remAddrLen); + else + recvLen = recvfrom(sockFd->fd, (S8*)(data + dataPos),(dataLen), + CM_INET_MSG_PEEK, NULLP, (socklen_t *)&remAddrLen); +#else + if(remAddrLen) + recvLen = recvfrom(sockFd->fd,(S8*)(data + dataPos), (dataLen), + CM_INET_MSG_PEEK, &remSockAddr, (S32*)&remAddrLen); + else + recvLen = recvfrom(sockFd->fd,(S8*)(data + dataPos), (dataLen), + CM_INET_MSG_PEEK, NULLP, (S32*)&remAddrLen); +#endif /* defined(SUNOS) || defined(SS_LINUX) */ +#endif /* defined(SS_VW) || defined(HPOS) || defined(SS_PS) */ + + /* removed the check of returned remAddrLen */ + if (recvLen == INET_ERR) + { + /* added check ERR_WOULDBLOCK */ + if ((INET_ERR_CODE == ERR_AGAIN) || + (INET_ERR_CODE == ERR_WOULDBLOCK)) + { + recvLen = 0; + RETVALUE(ROKDNA); + } + /* cm_inet_c_001.main_61: added host unreachable check */ + if ((INET_ERR_CODE == ERR_CONNABORTED) || + (INET_ERR_CODE == ERR_CONNRESET) || + (INET_ERR_CODE == ERR_HOSTUNREACH) || + (INET_ERR_CODE == ERR_CONNREFUSED)) + { + recvLen = 0; + RETVALUE(RCLOSED); + } +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE,"cmInetPeekNew() Failed : error(%d), sockFd->fd(%ld)\n", + INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET070, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE,"cmInetPeekNew() Failed : error(%d), sockFd->fd(%d)\n", + INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET070, 0, prntBuf); +#endif +#endif /* CMINETDBG */ + + RETVALUE(RFAILED); + } + else if (recvLen == 0) + { + RETVALUE(RCLOSED); + } + + /* cm_inet_c_001.main_57 - Fix for validation */ + if (recvLen < (S32)dataLen) /* maybe happen */ + { + RETVALUE(ROKDNA); + } + + /* setup return destination Internet address */ + /* added the check of (remAddLen > 0) */ + if ((fromAddr != NULLP) && (remAddrLen > 0)) + { +#ifdef IPV6_SUPPORTED + cmMemset((U8*)fromAddr, 0, sizeof(fromAddr)); + if (remAddrLen == sizeof(struct sockaddr_in6)) + { + remAddr6 = (struct sockaddr_in6 *)&remSockAddr; + fromAddr->type = CM_INET_IPV6ADDR_TYPE; + fromAddr->u.ipv6Addr.port = + CM_INET_NTOH_U16(remAddr6->sin6_port); + CM_INET_COPY_IPV6ADDR(&fromAddr->u.ipv6Addr.ipv6NetAddr, + &remAddr6->sin6_addr); + } + else + { + remAddr = (struct sockaddr_in *)&remSockAddr; + fromAddr->type = CM_INET_IPV4ADDR_TYPE; + fromAddr->u.ipv4Addr.port = CM_INET_NTOH_U16(remAddr->sin_port); + fromAddr->u.ipv4Addr.address = + CM_INET_NTOH_U32(remAddr->sin_addr.s_addr); + } +#else + remAddr = (struct sockaddr_in *)&remSockAddr; + fromAddr->port = CM_INET_NTOH_U16(remAddr->sin_port); + fromAddr->address = CM_INET_NTOH_U32(remAddr->sin_addr.s_addr); +#endif /* IPV6_SUPPORTED */ + } + + RETVALUE(ROK); +} /* end of cmInetPeeknew */ + + +/* +* +* Fun: cmInetPeek +* +* Desc: Reads some data from the socket without destroying the socket +* receive buffer. +* The data is specified by the byte positon (first byte is at +* position 0) and the length. +* +* Ret: ROK - successful +* ROKDNA - ok, data not available +* RCLOSED - connection closed by peer +* RFAILED - failed +* +* Notes: None. +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmInetPeek +( +CmInetFd *sockFd, /* socket file descriptor */ +CmInetAddr *fromAddr, /* sender Internet address/port */ +CmInetMemInfo *info, /* buffer allocation info */ +MsgLen dataPos, /* position of data */ +MsgLen dataLen, /* length of read data */ +Data *data /* read data */ +) +#else +PUBLIC S16 cmInetPeek(sockFd, fromAddr, info, dataPos, dataLen, data) +CmInetFd *sockFd; /* socket file descriptor */ +CmInetAddr *fromAddr; /* sender Internet address/port */ +CmInetMemInfo *info; /* buffer allocation info */ +MsgLen dataPos; /* position of data */ +MsgLen dataLen; /* length of read data */ +Data *data; /* read data */ +#endif +{ + /* cm_inet_c_001.main_54: Fix for Klockworks issue */ + Data *recvBuf = NULLP; /* plain receive buffer */ + /* cm_inet_c_001.main_47: 102069 Changed from S32 to MsgLen for bufLen*/ + MsgLen bufLen; /* buffer length */ + MsgLen i; /* index */ + MsgLen j; /* index */ + S32 ret; /* temporary return value */ + U32 timeout; /* timeout for cmInetSelect() */ + U32 *timeoutPtr; /* pointer to timeout */ + S16 numFdS; /* number of ready descriptors */ + /* cm_inet_c_001.main_45 - fixing the UMR issue in 64bit linux */ + U32 pendLen = 0; /* pending data length */ + S32 recvLen; /* number of received octets */ + S32 remAddrLen; /* length of remote address length */ + CmInetFdSet readFdS; /* socket file descriptor set */ + struct sockaddr_in *remAddr; /* remote Internet address */ +#ifdef IPV6_SUPPORTED + struct sockaddr_in6 *remAddr6; /* remote Internet IPV6 address */ + struct sockaddr_in6 remSockAddr; /* to get packet's source IP address */ +#else + CmInetSockAddr remSockAddr; /* to get packet's source IP address */ +#endif /* IPV6_SUPPORTED */ + + TRC2(cmInetPeek); + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if ((sockFd == NULLP) || CM_INET_INV_SOCK_FD(sockFd) || + (info == NULLP) || (data == NULLP) || + (dataPos < 0) || (dataLen < 0)) + { + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + /* check if there are some datas */ + if (sockFd->blocking) + { + /* blocking */ + timeoutPtr = NULLP; + } + else + { + /* poll (non-blocking) */ + timeout = 0; + timeoutPtr = &timeout; + } + CM_INET_FD_ZERO(&readFdS); + CM_INET_FD_SET(sockFd, &readFdS); + + ret = cmInetSelect(&readFdS, NULLP, timeoutPtr, &numFdS); + if (CM_INET_FD_ISSET(sockFd, &readFdS)) + { + /* get number of pending data */ + /* removed 3rd arg memInfo. MemInfo is no longer needed as we + call ioctl for all sockets */ + ret = cmInetGetNumRead(sockFd, &pendLen); + if (ret != ROK) + { + /* cm_inet_c_001.main_50 + * Return RCLOSED if cmInetGetNumRead returns RCLOSED. For other + * errors just return RFAILED. + */ + if (ret == RCLOSED) + RETVALUE(RCLOSED); + + RETVALUE(RFAILED); + } + + /* check if connection got closed */ + if (pendLen == 0) + { + + /* cm_inet_c_001.main_50 + * Due to latency (mostly in solaris) sometimes ioctl(FIONREAD) + * (inside cmInetGetNumRead) returns pend length as 0 on a TCP + * socket that select says is ready to read. This should not be + * considered as connection closed. So return ROKDNA instead of + * RCLOSED even for TCP sockets + */ + RETVALUE(ROKDNA); + } + /* added check for TCP/UDP socket. Pending data len in the socket + recv buffer is determined by ioctl call in cmInetGetNumRead. + For TCP it can't be > CM_INET_MAX_MSG_LEN. + For UDP it can't be > CM_INET_MAX_UDPRAW_MSGSIZE. */ + if (sockFd->type == CM_INET_STREAM) + { + /* max message length is limited to control the memory usage */ + if (pendLen > CM_INET_MAX_MSG_LEN) + pendLen = CM_INET_MAX_MSG_LEN; + /* In STREAM remote address is not required */ + remAddrLen = 0; + } + else + { + if (pendLen > CM_INET_MAX_UDPRAW_MSGSIZE) + pendLen = CM_INET_MAX_UDPRAW_MSGSIZE; + + remAddrLen = sizeof(CmInetSockAddr); + } + + /* check if there are enough pending data to read */ + bufLen = dataPos + dataLen; + + /* check if fromAddr is present or not */ + if (fromAddr != NULLP) + { + remAddrLen = sizeof(remSockAddr); + } + else + { + remAddrLen = 0; + } + + /* cm_inet_c_001.main_58: Fix for g++ compilation warning */ + if ((MsgLen)pendLen >= bufLen) + { + /* allocate receive buffer (flat structure) */ + ret = SGetSBuf(info->region, info->pool, &recvBuf, bufLen); + if (ret != ROK) + { + RETVALUE(ROUTRES); + } + + /* added different recvfrom calls with + * different 6th arg for different OS */ + + /* If remAddrLen is 0, pass NULLP */ +#if( defined(SS_VW) || defined(HPOS) || defined(SS_PS)) + if(remAddrLen) + recvLen = recvfrom(sockFd->fd,(S8*)recvBuf, bufLen, + CM_INET_MSG_PEEK, &remSockAddr, (int*)&remAddrLen); + else + recvLen = recvfrom(sockFd->fd,(S8*)recvBuf, bufLen, + CM_INET_MSG_PEEK, NULLP, (int*)&remAddrLen); +#else +#if ( defined(SUNOS) || defined(SS_LINUX)) + if(remAddrLen) + recvLen = recvfrom(sockFd->fd, (S8*)recvBuf,bufLen, + CM_INET_MSG_PEEK, (struct sockaddr *)&remSockAddr, + (socklen_t *)&remAddrLen); + else + recvLen = recvfrom(sockFd->fd, (S8*)recvBuf,bufLen, + CM_INET_MSG_PEEK, NULLP, (socklen_t *)&remAddrLen); +#else + if(remAddrLen) + recvLen = recvfrom(sockFd->fd,(S8*)recvBuf, bufLen, + CM_INET_MSG_PEEK, &remSockAddr, (S32*)&remAddrLen); + else + recvLen = recvfrom(sockFd->fd,(S8*)recvBuf, bufLen, + CM_INET_MSG_PEEK, NULLP, (S32*)&remAddrLen); +#endif /* defined(SUNOS) || defined(SS_LINUX) */ +#endif /* defined(SS_VW) || defined(HPOS) || defined(SS_PS) */ + + /* removed the check of returned remAddrLen */ + if (recvLen == INET_ERR) + { + /* cleanup */ + /* moved cleanup here */ + SPutSBuf(info->region, info->pool, recvBuf, bufLen); + + /* added check ERR_WOULDBLOCK */ + if ((INET_ERR_CODE == ERR_AGAIN) || + (INET_ERR_CODE == ERR_WOULDBLOCK)) + { + recvLen = 0; + RETVALUE(ROKDNA); + } + + /* moved up the cleanup */ + +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE,"cmInetPeek() Failed : error(%d), sockFd->fd(%ld)\n", + INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET036, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE,"cmInetPeek() Failed : error(%d), sockFd->fd(%d)\n", + INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET036, 0, prntBuf); +#endif +#endif /* CMINETDBG */ + + if ((INET_ERR_CODE == ERR_CONNABORTED) || + (INET_ERR_CODE == ERR_CONNRESET)) + { + recvLen = 0; + RETVALUE(RCLOSED); + } + RETVALUE(RFAILED); + } + + if (recvLen < (S32)bufLen) /* maybe happen */ + { + /* cleanup */ + SPutSBuf(info->region, info->pool, recvBuf, bufLen); + RETVALUE(ROKDNA); + } + + /* copy data */ + for (j = 0, i = dataPos; i < bufLen; j++, i++) + data[j] = recvBuf[i]; + + /* setup return destination Internet address */ + /* added the check of (remAddLen > 0) */ + if ((fromAddr != NULLP) && (remAddrLen > 0)) + { +#ifdef IPV6_SUPPORTED + cmMemset((U8*)fromAddr, 0, sizeof(fromAddr)); + if (remAddrLen == sizeof(struct sockaddr_in6)) + { + remAddr6 = (struct sockaddr_in6 *)&remSockAddr; + fromAddr->type = CM_INET_IPV6ADDR_TYPE; + fromAddr->u.ipv6Addr.port = + CM_INET_NTOH_U16(remAddr6->sin6_port); + CM_INET_COPY_IPV6ADDR(&fromAddr->u.ipv6Addr.ipv6NetAddr, + &remAddr6->sin6_addr); + } + else + { + remAddr = (struct sockaddr_in *)&remSockAddr; + fromAddr->type = CM_INET_IPV4ADDR_TYPE; + fromAddr->u.ipv4Addr.port = CM_INET_NTOH_U16(remAddr->sin_port); + fromAddr->u.ipv4Addr.address = + CM_INET_NTOH_U32(remAddr->sin_addr.s_addr); + } +#else + remAddr = (struct sockaddr_in *)&remSockAddr; + fromAddr->port = CM_INET_NTOH_U16(remAddr->sin_port); + fromAddr->address = CM_INET_NTOH_U32(remAddr->sin_addr.s_addr); +#endif /* IPV6_SUPPORTED */ + } + + /* cleanup */ + SPutSBuf(info->region, info->pool, recvBuf, bufLen); + } + else + { + /* not enough data pending yet */ + RETVALUE(ROKDNA); + } + } + else + { + /* no data pending */ + RETVALUE(ROKDNA); + } + + RETVALUE(ROK); +} /* end of cmInetPeek */ + + +/* +* +* Fun: cmInetClose +* +* Desc: Close a socket gracefully. +* +* Ret: ROK - successful +* RFAILED - failed +* +* Notes: None. +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmInetClose +( +CmInetFd *sockFd /* socket file descriptor */ +) +#else +PUBLIC S16 cmInetClose(sockFd) +CmInetFd *sockFd; /* socket file descriptor */ +#endif +{ + S32 ret; /* temporary return value */ + + TRC2(cmInetClose); + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if ((sockFd == NULLP) || CM_INET_INV_SOCK_FD(sockFd)) + { + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + +#ifdef WIN32 + ret = closesocket(sockFd->fd); +#else + ret = close(sockFd->fd); +#endif /* WIN32 */ + if (ret == INET_ERR) + { +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetClose() Failed : error(%d), sockFd->fd(%ld)\n", + INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET037, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetClose() Failed : error(%d), sockFd->fd(%d)\n", + INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET037, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + + RETVALUE(ROK); +} /* end of cmInetClose */ + + +/* +* +* Fun: cmInetShutdown +* +* Desc: Close an Internet connection with more control over the data of +* the full-duplex connection. +* Values for the howTo parameter: +* +* CM_INET_SHTDWN_RECV - discard data in receive buffer +* CM_INET_SHTDWN_SEND - discard data in transmit buffer +* CM_INET_SHTDWN_BOTH - discard data in receive and transmit buffer +* +* Ret: ROK - successful +* RFAILED - failed +* +* Notes: This function does not free the socket descriptor but only closes the +* connection (cmInetClose() has to be called afterwards). +* No error is returned if the socket is not connected while calling +* this function. +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmInetShutdown +( +CmInetFd *sockFd, /* socket file descriptor */ +S32 howTo /* operation flag */ +) +#else +PUBLIC S16 cmInetShutdown(sockFd, howTo) +CmInetFd *sockFd; /* socket file descriptor */ +S32 howTo; /* operation flag */ +#endif +{ + S32 ret; /* temporary return value */ + + TRC2(cmInetShutdown); + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if ((sockFd == NULLP) || CM_INET_INV_SOCK_FD(sockFd)) + { + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + ret = shutdown(sockFd->fd, howTo); + if (ret == INET_ERR) + { + if (INET_ERR_CODE == ERR_NOTCONN) + { + /* socket is not connected */ + RETVALUE(ROK); + } + else + { + /* real problem */ +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetShutdown() Failed : error(%d)," + " sockFd->fd(%ld)\n", INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET038, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetShutdown() Failed : error(%d)," + " sockFd->fd(%d)\n", INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET038, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + } + + RETVALUE(ROK); +} /* end of cmInetShutdown */ + + +/* +* +* Fun: cmInetSelect +* +* Desc: Allows multiplex i/o requests among multiple sockets. +* If the parameter mSecTimeout points to a value of zero the +* call immediatley returns (poll), if it is a null pointer, the +* timeout is set to infinit. +* numFdS returns the number of ready file descriptors contained +* in the file descriptor sets +* +* Ret: ROK - successful +* RTIMEOUT - timout expired +* RFAILED - failed +* +* Notes: None. +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmInetSelect +( +CmInetFdSet *readFdS, /* read socket descriptor file set */ +CmInetFdSet *writeFdS, /* write socket descriptor file set */ +U32 *mSecTimeout, /* timeout in msecs */ +S16 *numFdS /* number of ready descriptors */ +) +#else +PUBLIC S16 cmInetSelect(readFdS, writeFdS, mSecTimeout, numFdS) +CmInetFdSet *readFdS; /* read socket descriptor file set */ +CmInetFdSet *writeFdS; /* write socket descriptor file set */ +U32 *mSecTimeout; /* timeout in msecs */ +S16 *numFdS; /* number of ready descriptors */ +#endif +{ + S32 ret; /* temporary return value */ + struct timeval timeout; /* timeout structure */ + struct timeval *timeoutPtr; + S32 errCode; + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if (numFdS == NULLP) + { + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + *numFdS = 0; + + if (mSecTimeout != NULLP) + { + timeout.tv_sec = *mSecTimeout / 1000; + timeout.tv_usec = (*mSecTimeout % 1000) * 1000; + timeoutPtr = &timeout; + } + else + { + /* infinite timeout */ + timeoutPtr = NULLP; + } + +#ifdef TUCL_TTI_RCV + timeout.tv_sec = 0; + timeout.tv_usec = 1; +#endif + + /* cm_inet_c_001.main_53 - Removed do-while loop */ + ret = select(FD_SETSIZE, readFdS, writeFdS, (fd_set*)0, timeoutPtr); + + /* cm_inet_c_001.main_53 - Return ROKDNA in case select was interrupted */ + if ((ret == INET_ERR) && (INET_ERR_CODE == ERR_EINTR)) + { + RETVALUE(ROKDNA); + } + + /* timeout occured */ + if (ret == 0) + { + RETVALUE(RTIMEOUT); + } + + if (ret == INET_ERR) + { + /* asa: Added a check for ERR_INVAL to return ROK + * readFdS and writeFdS may be passed as NULL to + * cmInetSelect() call + */ + switch(errCode = INET_ERR_CODE) + { + case ERR_INVAL: + RETVALUE(ROK); + + default: +#ifdef CMINETDBG + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetSelect() Failed : error(%d)\n", + INET_ERR_CODE); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET039, 0, prntBuf); +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + + } /* end of switch */ + } + + /* return number of ready file descriptors */ + /* cm_inet_c_001.main_54: Fix for Klockworks issue */ + *numFdS = (S16)ret; + + RETVALUE(ROK); +} /* end of cmInetSelect */ + + +/* +* +* Fun: cmInetSetOpt +* +* Desc: Sets a socket option. +* The function supports following options: +* +* CM_INET_OPT_BLOCK: +* value: CM_INET_OPT_DISABLE non-blocking +* value: CM_INET_OPT_ENABLE blocking +* +* CM_INET_OPT_REUSEADDR: +* value: CM_INET_OPT_ENABLE reuse address +* +* CM_INET_OPT_BROADCAST: +* value: CM_INET_OPT_DISABLE +* value: CM_INET_OPT_ENABLE +* +* CM_INET_OPT_KEEPALIVE: +* value: CM_INET_OPT_DISABLE +* value: CM_INET_OPT_ENABLE +* +* CM_INET_OPT_RX_BUF_SIZE: +* value: receive buffer size in bytes +* +* CM_INET_OPT_TX_BUF_SIZE: +* value: transmitter buffer size in bytes +* +* CM_INET_OPT_ADD_MCAST_MBR: +* value: address of CmInetMCastInf structure +* +* CM_INET_OPT_DRP_MCAST_MBR: +* value: address of CmInetMCastInf structure +* +* CM_INET_OPT_TCP_NODELAY: +* value: CM_INET_OPT_DISABLE +* value: CM_INET_OPT_ENABLE +* +* CM_INET_OPT_BSD_COMPAT: For Linux only +* value: CM_INET_OPT_ENABLE +* value: CM_INET_OPT_DISABLE +* +* CM_INET_OPT_HDR_INCLD: +* value: CM_INET_ENABLE +* value: CM_INET_DISABLE +* +* CM_INET_OPT_DONT_FRAGMENT: +* value: CM_INET_OPT_ENABLE +* value: CM_INET_DISABLE +* +* CM_INET_OPT_TOS: +* value: Type of Service. +* +* CM_INET_OPT_TTL: +* value: Time To Live. +* +* CM_INET_OPT_IP_OPTIONS: +* value: IPv4 header option value +* ENABLE/DISABLE. +* +* CM_INET_OPT_IP_ROUTER_ALERT: +* value: CM_INET_OPT_DISABLE +* value: CM_INET_OPT_ENABLE +* +* CM_INET_OPT_IPV4_PKTINFO +* value: CM_INET_OPT_ENABLE +* value: CM_INET_OPT_DISABLE +* +* CM_INET_OPT_MCAST_LOOP: +* value: CM_INET_OPT_DISABLE +* value: CM_INET_OPT_ENABLE +* +* CM_INET_OPT_MCAST_IF: +* value: Address of interface. +* +* CM_INET_OPT_MCAST_TTL: +* value: TTL of the outgoing multicast packet. +* +* The next options are defined only if IPV6 is +* supported. +* +* CM_INET_OPT_ADD_MCAST6_MBR: +* value: address of CmInetMCastInf6 structure +* +* CM_INET_OPT_DRP_MCAST6_MBR: +* value: address of CmInetMCastInf6 structure +* +* CM_INET_OPT_MCAST6_LOOP: +* value: CM_INET_OPT_DISABLE +* value: CM_INET_OPT_ENABLE +* +* CM_INET_OPT_MCAST6_IF: +* value: Interface index +* +* CM_INET_OPT_MCAST6_HOPS: +* value: multicast hop limit +* +* CM_INET_OPT_RECVIPV6_HOPLIM: +* value: CM_INET_OPT_ENABLE hop limit will be returned +* on the socket. +* value: CM_INET_OPT_DISABLE hop limit wont be returned +* on the socket. +* +* CM_INET_OPT_RECVIPV6_HBHOPTS: +* value: CM_INET_OPT_ENABLE HBH Options will be returned +* on the socket. +* value: CM_INET_OPT_DISABLE HBH Options wont be returned +* on the socket. +* +* CM_INET_OPT_RECVIPV6_DSTOPTS: +* value: CM_INET_OPT_ENABLE Dest Options will be returned +* on the socket. +* value: CM_INET_OPT_DISABLE Dest Options wont be returned +* on the socket. +* +* CM_INET_OPT_RECVIPV6_RTHDR: +* value: CM_INET_OPT_ENABLE Route Hdr Opt will be turned +* ON on the socket. +* value: CM_INET_OPT_DISABLE Route Hdr Opt will be turned +* OFF on the socket. +* +* CM_INET_OPT_IP_ROUTER_ALERT6 +* value: CM_INET_OPT_ENABLE +* value: CM_INET_OPT_DISABLE +* +* CM_INET_OPT_IPV6_PKTINFO +* value: CM_INET_OPT_ENABLE Enable sending and receiving +* of packet info +* value: CM_INET_OPT_DISABLE Disable sending and receiving +* of packet info +* +* CM_INET_OPT_LINGER +* value: address of CmInetSockLinger structure +* +* CM_INET_OPT_SCTP_EVENTS +* value: address of CmInetSctpSockEvent structure +* +* CM_INET_OPT_SCTP_PRIM_ADDR +* value: address of CmInetSctpPrimAddr structure +* +* CM_INET_OPT_SCTP_PEERADDR_PARAMS +* value: address of CmInetSctpPeerAddrParams structure +* +* +* Ret: ROK - successful +* RFAILED - failed +* RNA - failed, option not available +* (Only when CM_INET2 is defined) +* +* Notes: The send and receive buffer size may be system +* specific. The cmInetSetOpt() call may return +* successfuly although not the entire buffer size +* could be set! +* +* File: cm_inet.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmInetSetOpt +( +CmInetFd *sockFd, /* socket file descriptor */ +U32 level, /* option level */ +U32 type, /* option type */ +Ptr value /* option value */ +) +#else +PUBLIC S16 cmInetSetOpt(sockFd, level, type, value) +CmInetFd *sockFd; /* socket file descriptor */ +U32 level; /* option level */ +U32 type; /* option type */ +Ptr value; /* option value */ +#endif +{ + S32 ret = ROK; /* temporary return value */ + U32 disable = 0; /* disable option */ + U32 enable = 1; /* enable option */ + + /* added for IPv4 options */ +#ifdef IPV4_OPTS_SUPPORTED +#if((!defined (SS_VW)) && (!defined(SS_LINUX))) + TknStr64 *tempTknStr64; /* points TknStr64 structure */ + /* which has value for IPv4 hdr options.*/ +#endif /* SS_VW && SS_LINUX */ +#ifdef WIN32 + int disableOpt = 0; +#endif /* WIN32 */ +#endif /* IPV4_OPTS_SUPPORTED */ + +#if (defined(SUNOS)|| defined(WIN32) || defined(SS_PS) || defined(SS_VW_MCAST)\ + || defined(HPOS)) + U8 lpEnable = 1; /* multicast loop enable */ + U8 lpDisable = 0; /* multicast loop disable */ +#endif /* SUNOS || WIN32 || SS_PS || SS_VW_MCAST || HPOS */ + +#ifdef WIN32 + BOOL boolEnable = TRUE; /* enable option */ + BOOL boolDisable = FALSE; /* disable option */ +#endif /* WIN32 */ + +#if (defined(SUNOS) || defined(WIN32) || defined(SS_PS) || \ + defined(SS_VW_MCAST) || defined(HPOS)) + struct ip_mreq stMreq; + CmInetMCastInf *mCast; +#endif /* SUNOS || WIN32 || SS_PS || SS_VW_MCAST || HPOS */ + +#ifdef IPV6_SUPPORTED + U32 loopEna = 1; /* IPv6 multicast loop enable */ + U32 loopDis = 0; /* IPv6 multicast loop disable */ + struct ipv6_mreq *stMreq6Ptr; + /* cm_inet_c_001.main_44 : some operating system doesnt have icmp6_filter. so + this flag is gaurded under ICMPV6_FILTER_SUPPORTED. so if user want this + support he has to enable the above flag.*/ + /* cm_inet_c_001.main_58 : Protaected under flag CM_ICMP_FILTER_SUPPORT + * to support filteration of ICMP messages */ +#if (defined(ICMPV6_FILTER_SUPPORTED) || defined(CM_ICMP_FILTER_SUPPORT)) + struct icmp6_filter *icmp6Filter; +#endif /* ICMPV6_FILTER_SUPPORTED */ +#endif /* IPV6_SUPPORTED */ + + /* cm_inet_c_001.main_58 : Added new local variables to support filteration + * of ICMP messages */ +#ifdef SS_LINUX +#ifdef CM_ICMP_FILTER_SUPPORT + struct icmp_filter icmpFilter; +#endif +#endif + + /*cm_inet_c_001.main_38 Updated for TUCL 2.1 Release (Kernel SCTP Support) */ +#ifdef CM_LKSCTP + struct linger lngr; + struct sctp_event_subscribe event; + struct sctp_paddrparams addrParams; + struct sctp_setprim setPrim; + struct sockaddr_in *pAddr; + struct sctp_assocparams assocParams; + struct sctp_initmsg initmsg; + struct sctp_rtoinfo rtoinfo; +#ifdef IPV6_SUPPORTED + struct sockaddr_in6 *pAddr6; +#endif /* IPV6_SUPPORTED */ + + CmInetSockLinger *pSockLinger; + CmInetSctpSockEvent *pSctpEvent; + CmInetSctpPrimAddr *pSctpPrimAddr; + CmInetSctpPeerAddrParams *pSctpPAddrParams; + CmInetSctpRtoInfo *pSctpRtoInfo; + CmInetSctpInitMsg *pSctpInitMsg; + CmInetSctpAssocParams *pSctpAssocParams; +#endif + + U32 *optVal; + + TRC2(cmInetSetOpt); + + /* cm_inet_c_001.main_58 : Added NULL check for value field */ + if(value == NULLP) + { + RETVALUE(RFAILED); + } + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if ((sockFd == NULLP) || CM_INET_INV_SOCK_FD(sockFd)) + { + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + switch (type) + { + case CM_INET_OPT_BLOCK: + optVal = (U32*)value; + switch(*optVal) + { + case CM_INET_OPT_ENABLE: + +#ifdef WIN32 + /* cm_inet_c_001.main_59: Fix for compilation warning */ + ret = ioctlsocket(sockFd->fd, FIONBIO, (U32 *)&disable); +#else +#ifdef SS_PS + ret = ioctl(sockFd->fd, FIONBIO, (char*)&disable); +#else +#ifdef SS_VW + ret = ioctl(sockFd->fd, (S32)FIONBIO, (S32)&disable); +#else + ret = ioctl(sockFd->fd, (S32)FIONBIO, &disable); + +#endif /* SS_VW */ +#endif /* SS_PS */ +#endif /* WIN32 */ + sockFd->blocking = 1; + break; + + case CM_INET_OPT_DISABLE: +#ifdef WIN32 + /* cm_inet_c_001.main_59: Fix for compilation warning */ + ret = ioctlsocket(sockFd->fd, FIONBIO, (U32 *)&enable); +#else +#ifdef SS_PS + ret = ioctl(sockFd->fd, FIONBIO, (char*)&enable); +#else +#ifdef SS_VW + ret = ioctl(sockFd->fd, (S32)FIONBIO, (S32)&enable); +#else + ret = ioctl(sockFd->fd, (S32)FIONBIO, &enable); +#endif /* SS_VW */ +#endif /* SS_PS */ +#endif /* WIN32 */ + sockFd->blocking = 0; + break; + + default: + /* wrong value */ + RETVALUE(RFAILED); + break; + } + break; + + case CM_INET_OPT_REUSEADDR: + optVal = (U32*)value; + if (*optVal == CM_INET_OPT_ENABLE) + { +#ifdef WIN32 + ret = setsockopt(sockFd->fd, level, SO_REUSEADDR, + (char*)&boolEnable, sizeof(boolEnable)); +#else + ret = setsockopt(sockFd->fd, level, SO_REUSEADDR, + (char*)&enable, sizeof(enable)); +#ifdef SS_VW + setsockopt(sockFd->fd, level, SO_REUSEPORT, + (char*)&enable, sizeof(enable)); +#endif /* SS_VW */ +#endif /* WIN32 */ + } + else if (*optVal == CM_INET_OPT_DISABLE) + { +#ifdef WIN32 + ret = setsockopt(sockFd->fd, level, SO_REUSEADDR, + (char*)&boolDisable, sizeof(boolDisable)); +#else + ret = setsockopt(sockFd->fd, level, SO_REUSEADDR, + (char*)&disable, sizeof(disable)); +#ifdef SS_VW + ret = setsockopt(sockFd->fd, level, SO_REUSEPORT, + (char*)&disable, sizeof(disable)); +#endif /* SS_VW */ +#endif /* WIN32 */ + } + break; + + case CM_INET_OPT_BROADCAST: + optVal = (U32*)value; + if (*optVal == CM_INET_OPT_ENABLE) + { +#ifdef WIN32 + ret = setsockopt(sockFd->fd, level, SO_BROADCAST, + (char*)&boolEnable, sizeof(boolEnable)); +#else + ret = setsockopt(sockFd->fd, level, SO_BROADCAST, + (char*)&enable, sizeof(enable)); +#endif /* WIN32 */ + } + else if (*optVal == CM_INET_OPT_DISABLE) + { +#ifdef WIN32 + ret = setsockopt(sockFd->fd, level, SO_BROADCAST, + (char*)&boolDisable, sizeof(boolDisable)); +#else + ret = setsockopt(sockFd->fd, level, SO_BROADCAST, + (char*)&disable, sizeof(disable)); +#endif /* WIN32 */ + } + break; + + case CM_INET_OPT_KEEPALIVE: + optVal = (U32*)value; + if (*optVal == CM_INET_OPT_ENABLE) + { +#ifdef WIN32 + ret = setsockopt(sockFd->fd, level, SO_KEEPALIVE, + (char*)&boolEnable, sizeof(boolEnable)); +#else + ret = setsockopt(sockFd->fd, level, SO_KEEPALIVE, + (char*)&enable, sizeof(enable)); +#endif /* WIN32 */ + } + else if (*optVal == CM_INET_OPT_DISABLE) + { +#ifdef WIN32 + ret = setsockopt(sockFd->fd, level, SO_KEEPALIVE, + (char*)&boolDisable, sizeof(boolDisable)); +#else + ret = setsockopt(sockFd->fd, level, SO_KEEPALIVE, + (char*)&disable, sizeof(disable)); +#endif /* WIN32 */ + } + break; + + case CM_INET_OPT_RX_BUF_SIZE: + optVal = (U32*)value; + ret = setsockopt(sockFd->fd, level, SO_RCVBUF, + (char*)optVal, sizeof(*optVal)); + break; + + case CM_INET_OPT_TX_BUF_SIZE: + optVal = (U32*)value; + ret = setsockopt(sockFd->fd, level, SO_SNDBUF, + (char*)optVal, sizeof(*optVal)); + break; + + case CM_INET_OPT_TCP_NODELAY: + optVal = (U32*)value; + if (*optVal == CM_INET_OPT_ENABLE) + { +#ifdef WIN32 +#ifndef SS_WINCE + ret = setsockopt(sockFd->fd, level, TCP_NODELAY, + (char*)&boolEnable, sizeof(boolEnable)); +#endif /* SS_WINCE */ +#else + ret = setsockopt(sockFd->fd, level, TCP_NODELAY, + (char*)&enable, sizeof(enable)); +#endif /* WIN32 */ + } + else if (*optVal == CM_INET_OPT_DISABLE) + { +#ifdef WIN32 +#ifndef SS_WINCE + ret = setsockopt(sockFd->fd, level, TCP_NODELAY, + (char*)&boolDisable, sizeof(boolDisable)); +#endif /* SS_WINCE */ +#else + ret = setsockopt(sockFd->fd, level, TCP_NODELAY, + (char*)&disable, sizeof(disable)); +#endif /* WIN32 */ + } + break; + +#if (defined(SUNOS)|| defined(WIN32) || defined(SS_PS) || \ + defined(SS_VW_MCAST) || defined(HPOS)) + + case CM_INET_OPT_ADD_MCAST_MBR: + mCast = (CmInetMCastInf*)value; + + /* Copy the addresses to stMreq structure */ +#ifdef SS_PS + stMreq.imr_mcastaddr.s_addr = CM_INET_HTON_U32(mCast->mCastAddr); +#else + stMreq.imr_multiaddr.s_addr = CM_INET_HTON_U32(mCast->mCastAddr); +#endif + stMreq.imr_interface.s_addr = CM_INET_HTON_U32(mCast->localAddr); + + ret = setsockopt(sockFd->fd, level, IP_ADD_MEMBERSHIP, + (char*)&stMreq, sizeof(stMreq)); + break; + + case CM_INET_OPT_DRP_MCAST_MBR: + mCast = (CmInetMCastInf*)value; + + /* Copy the addresses to stMreq structure */ +#ifdef SS_PS + stMreq.imr_mcastaddr.s_addr = CM_INET_HTON_U32(mCast->mCastAddr); +#else + stMreq.imr_multiaddr.s_addr = CM_INET_HTON_U32(mCast->mCastAddr); +#endif + stMreq.imr_interface.s_addr = CM_INET_HTON_U32(mCast->localAddr); + + ret = setsockopt(sockFd->fd, level, IP_DROP_MEMBERSHIP, + (char*)&stMreq, sizeof(stMreq)); + break; + +#endif /* SUNOS || WIN32 || SS_PS || SS_VW_MCAST || HPOS */ + +#ifdef SS_LINUX + /* cm_inet_c_001.main_37 - Enable CMINET_BSDCOMPAT flag if system doesnt + support CM_INET_OPT_BSD_COMPAT */ +#ifndef CMINET_BSDCOMPAT + case CM_INET_OPT_BSD_COMPAT: + optVal = (U32*)value; + if (*optVal == CM_INET_OPT_ENABLE) + { + ret = setsockopt(sockFd->fd, level, SO_BSDCOMPAT, + &enable, sizeof(enable)); + } + else if (*optVal == CM_INET_OPT_DISABLE) + { + ret = setsockopt(sockFd->fd, level, SO_BSDCOMPAT, + &disable, sizeof(disable)); + } + break; +#endif /* CMINET_BSDCOMPAT */ +#endif /* SS_LINUX */ + +#ifdef CM_INET2 + /* Added for support of Raw socket modify according to the + * option available on different platform */ +#if (defined(SUNOS)|| defined(WIN32) || defined(SS_PS) || defined(SS_VW) \ + || defined(HPOS)) + case CM_INET_OPT_HDR_INCLD: + optVal = (U32*)value; + if (*optVal == CM_INET_OPT_ENABLE) + { +#ifdef WIN32 + RETVALUE(RNA); +#else + ret = setsockopt(sockFd->fd, level, IP_HDRINCL, + (char*)&enable, sizeof(enable)); +#endif /* WIN32 */ + } + else if (*optVal == CM_INET_OPT_DISABLE) + { +#ifdef WIN32 + RETVALUE(RNA); +#else + ret = setsockopt(sockFd->fd, level, IP_HDRINCL, + (char*)&disable, sizeof(disable)); +#endif /* WIN32 */ + } + break; + + /* added new options */ +#ifdef IPV4_OPTS_SUPPORTED +#ifdef SS_LINUX + /* Linux: set Router Alert socket option to Intercept RAW RSVP + packets at the Intermediate node(Router) with Router Alert SET. + This socket option is MUST be set (when this server is opened) + if the RSVP server wants to intercept raw RSVP packets. */ + case CM_INET_OPT_IP_ROUTER_ALERT: + optVal = (U32*)value; + if (*optVal == CM_INET_OPT_ENABLE) + { + ret = setsockopt(sockFd->fd, level, IP_ROUTER_ALERT, + (char*)&enable, sizeof(enable)); + if (ret != ROK) + RETVALUE(RFAILED); + } + else if (*optVal == CM_INET_OPT_DISABLE) + { + ret = setsockopt(sockFd->fd, level, IP_ROUTER_ALERT, + (char*)&disable, sizeof(disable)); + if (ret != ROK) + RETVALUE(RFAILED); + } + break; +#endif /* SS_LINUX */ + + /* set Router Alert socket option */ + case CM_INET_OPT_IP_OPTIONS: +#if (defined (SS_VW) || defined(SS_LINUX)) + RETVALUE(RNA); +#else + tempTknStr64=(TknStr64 *)value; + if (tempTknStr64->pres == TRUE) + { + if (tempTknStr64->len == 0) + { + /* disable the IP_OPTIONS for Router Alert. */ +#ifdef WIN32 + ret = setsockopt(sockFd->fd, level, IP_OPTIONS, + (CONSTANT char *)&disableOpt, sizeof(int)); +#else + ret = setsockopt(sockFd->fd, level, IP_OPTIONS, NULL, 0); +#endif /* WIN32 */ + } + else + /* enable the IP_OPTIONS for Router Alert */ + ret = setsockopt(sockFd->fd, level, IP_OPTIONS, + (char *)tempTknStr64->val, tempTknStr64->len); + } + else + RETVALUE(RFAILED); /* Trying to set IPv4 Hdr option + * without giving option values*/ +#endif /* SS_VW || SS_LINUX */ + break; +#endif /* IPV4_OPTS_SUPPORTED */ + + /* added new options */ +#if (defined(SS_LINUX) && (!defined(SS_VW) && !defined(WIN32))) +#ifdef LOCAL_INTF + case CM_INET_OPT_IPV4_PKTINFO: + optVal = (U32*)value; + if (*optVal == CM_INET_OPT_ENABLE) + { + /* set IP_PKTINFO option when IP_ROUTER_ALERT is set in linux */ + ret = setsockopt(sockFd->fd, level, IP_PKTINFO, + (char*)&enable, sizeof(enable)); + + if (ret != ROK) + RETVALUE(RFAILED); + } + else if (*optVal == CM_INET_OPT_DISABLE) + { + /* disable IP_PKTINFO when IP_ROUTER_ALERT is set in linux */ + ret = setsockopt(sockFd->fd, level, IP_PKTINFO, + (char*)&disable, sizeof(disable)); + + if (ret != ROK) + RETVALUE(RFAILED); + } + break; +#endif /* LOCAL_INTF */ +#endif /* SS_LINUX */ + +#endif /* SUNOS || WIN32 || SS_PS || SS_VW || HPOS */ + + case CM_INET_OPT_DONTFRAGMENT: + optVal = (U32*)value; + if (*optVal == CM_INET_OPT_ENABLE) + { +#ifdef WIN32 + ret = setsockopt(sockFd->fd, level, IP_DONTFRAGMENT, + (char*)&boolEnable, sizeof(boolEnable)); +#endif /* WIN32 */ + } + else if (*optVal == CM_INET_OPT_DISABLE) + { +#ifdef WIN32 + ret = setsockopt(sockFd->fd, level, IP_DONTFRAGMENT, + (char*)&boolDisable, sizeof(boolDisable)); +#endif /* WIN32 */ + } + break; + + /* also add these 2 options for VxWorks */ +#if (defined(SUNOS)|| defined(WIN32) || defined(HPOS) || defined(SS_VW)) + case CM_INET_OPT_TOS: + optVal = (U32*)value; + ret = setsockopt(sockFd->fd, level, IP_TOS, + (char*)optVal, sizeof(*optVal)); + break; + + case CM_INET_OPT_TTL: + optVal = (U32*)value; + ret = setsockopt(sockFd->fd, level, IP_TTL, + (char*)optVal, sizeof(*optVal)); + break; +#endif /* SUNOS || WIN32 || HPOS || SS_VW */ +#endif /* CM_INET2 */ + +#if (defined(SUNOS)|| defined(WIN32) || defined(SS_PS) || defined(SS_VW_MCAST) \ + || defined(HPOS)) + case CM_INET_OPT_MCAST_LOOP: + optVal = (U32*)value; + if (*optVal == CM_INET_OPT_ENABLE) + { +#ifdef SS_VW + ret = setsockopt(sockFd->fd, level, IP_MULTICAST_LOOP, + (char *)&lpEnable, sizeof(lpEnable)); +#else + ret = setsockopt(sockFd->fd, level, IP_MULTICAST_LOOP, + (CONSTANT char *)&lpEnable, sizeof(lpEnable)); +#endif /* SS_VW */ + } + else + { +#ifdef SS_VW + ret = setsockopt(sockFd->fd, level, IP_MULTICAST_LOOP, + (char *)&lpDisable, sizeof(lpDisable)); +#else + ret = setsockopt(sockFd->fd, level, IP_MULTICAST_LOOP, + (CONSTANT char *)&lpDisable, sizeof(lpDisable)); +#endif /* SS_VW */ + } + break; + + case CM_INET_OPT_MCAST_IF: + optVal = (U32*)value; + *optVal = CM_INET_HTON_U32((U32)*optVal); + ret = setsockopt(sockFd->fd, level, IP_MULTICAST_IF, + (char *)optVal, sizeof(struct in_addr)); + break; + + case CM_INET_OPT_MCAST_TTL: + optVal = (U32*)value; + /* remove CONSTANT in setsockopt for VW */ +#ifdef SS_VW + ret = setsockopt(sockFd->fd, level, IP_MULTICAST_TTL, + (char *)optVal, sizeof(U8)); +#else + ret = setsockopt(sockFd->fd, level, IP_MULTICAST_TTL, + (CONSTANT char *)optVal, sizeof(U8)); +#endif /* SS_VW */ + break; +#endif /* SUNOS || WIN32 || SS_PS || SS_VW_MCAST || HPOS */ + +#ifdef IPV6_SUPPORTED + case CM_INET_OPT_IPV6_TTL: + optVal = (U32*)value; + ret = setsockopt(sockFd->fd, level, IPV6_UNICAST_HOPS, + (char*)optVal, sizeof(*optVal)); + break; + + case CM_INET_OPT_ADD_MCAST6_MBR: + stMreq6Ptr = (struct ipv6_mreq *)value; + ret = setsockopt(sockFd->fd, level, IPV6_JOIN_GROUP, + (char*)stMreq6Ptr, sizeof(struct ipv6_mreq)); + break; + + case CM_INET_OPT_DRP_MCAST6_MBR: + stMreq6Ptr = (struct ipv6_mreq *)value; + ret = setsockopt(sockFd->fd, level, IPV6_LEAVE_GROUP, + (char*)stMreq6Ptr, sizeof(struct ipv6_mreq)); + break; + + case CM_INET_OPT_MCAST6_LOOP: + optVal = (U32*)value; + if (*optVal == CM_INET_OPT_ENABLE) + { + ret = setsockopt(sockFd->fd, level, IPV6_MULTICAST_LOOP, + &loopEna, sizeof(loopEna)); + } + else + { + ret = setsockopt(sockFd->fd, level, IPV6_MULTICAST_LOOP, + &loopDis, sizeof(loopDis)); + } + break; + + case CM_INET_OPT_MCAST6_IF: + ret = setsockopt(sockFd->fd, level, IPV6_MULTICAST_IF, + (U32 *)value, sizeof(U32)); + break; + + case CM_INET_OPT_MCAST6_HOPS: + optVal = (U32*)value; + ret = setsockopt(sockFd->fd, level, IPV6_MULTICAST_HOPS, + (char *)optVal, sizeof(U32)); + break; + + /* cm_inet_c_001.main_44 : some operating system doesnt have icmp6_filter. so + this flag is gaurded under ICMPV6_SUPPORTED. so if user want this + support he has to enable the above flag.*/ + /* cm_inet_c_001.main_58 : Protaected under flag CM_ICMP_FILTER_SUPPORT + * to support filteration of ICMP messages */ +#if (defined(ICMPV6_FILTER_SUPPORTED) || defined(CM_ICMP_FILTER_SUPPORT)) + case CM_INET_OPT_ICMP6_FILTER: + icmp6Filter = (struct icmp6_filter *)value; + ret = setsockopt(sockFd->fd, level, ICMP6_FILTER, + (char *)icmp6Filter, sizeof(struct icmp6_filter)); + break; +#endif /* ICMPV6_FILTER_SUPPORTED */ + + /* added new options */ +#ifdef IPV6_OPTS_SUPPORTED + case CM_INET_OPT_RECVIPV6_HOPLIM: + optVal = (U32*)value; +#ifdef SS_LINUX + ret = setsockopt(sockFd->fd, level, IPV6_HOPLIMIT, + (char *)optVal, sizeof(U32)); +#else + ret = setsockopt(sockFd->fd, level, IPV6_HOPLIMIT, + (char *)optVal, sizeof(U32)); + /* enable the reception of IPv6 HopLimit value as ancillary data */ + ret = setsockopt(sockFd->fd, level, IPV6_RECVHOPLIMIT, + (char*)&enable, sizeof(enable)); +#endif /* SS_LINUX */ + + break; + + case CM_INET_OPT_RECVIPV6_HBHOPTS: + optVal = (U32*)value; +#ifdef SS_LINUX + ret = setsockopt(sockFd->fd, level, IPV6_HOPOPTS, + (char *)optVal, sizeof(U32)); +#else + ret = setsockopt(sockFd->fd, level, IPV6_RECVHOPOPTS, + (char *)optVal, sizeof(U32)); +#endif /* SS_LINUX */ + break; + + case CM_INET_OPT_RECVIPV6_DSTOPTS: + optVal = (U32*)value; +#ifdef SS_LINUX + ret = setsockopt(sockFd->fd, level, IPV6_DSTOPTS, + (char *)optVal, sizeof(U32)); +#else + ret = setsockopt(sockFd->fd, level, IPV6_RECVDSTOPTS, + (char *)optVal, sizeof(U32)); +#endif /* SS_LINUX */ + break; + + case CM_INET_OPT_RECVIPV6_RTHDR: + optVal = (U32*)value; +#ifdef SS_LINUX + ret = setsockopt(sockFd->fd, level, IPV6_RTHDR, + (char *)optVal, sizeof(U32)); +#else + ret = setsockopt(sockFd->fd, level, IPV6_RECVRTHDR, + (char *)optVal, sizeof(U32)); +#endif /* SS_LINUX */ + break; + + /* works ONLY for IPPROTO_RAW type socket. so if it this socket + * option is tried to set for IPPROTO_RSVP, then it is supposed + * to fail with EINVAL according to net/ipv6/ipv6_sockglue.c + * + * if HI_SRVC_RAW_RAW is not used during ServOpenReq as the server + * type, then it will fail here due to above reason */ +#ifdef SS_LINUX + case CM_INET_OPT_IP_ROUTER_ALERT6: + optVal = (U32*)value; + if(*optVal == CM_INET_OPT_ENABLE) + ret = setsockopt(sockFd->fd, IPPROTO_IPV6, IPV6_ROUTER_ALERT, + (char *)&enable, sizeof(enable)); + else + ret = setsockopt(sockFd->fd, level, IPV6_ROUTER_ALERT, + (char *)&disable, sizeof(disable)); + + break; +#endif /* SS_LINUX */ +#endif /* IPV6_OPTS_SUPPORTED */ + +#ifdef LOCAL_INTF + case CM_INET_OPT_IPV6_PKTINFO: + optVal = (U32*)value; +#ifdef SS_LINUX + ret = setsockopt(sockFd->fd, level, IPV6_PKTINFO, + (char *)optVal, sizeof(U32)); +#else + ret = setsockopt(sockFd->fd, level, IPV6_RECVPKTINFO, + (char *)&enable, sizeof(enable)); +#endif /* SS_LINUX */ + break; +#endif /* LOCAL_INTF */ + +#endif /* IPV6_SUPPORTED */ + + /*cm_inet_c_001.main_38 Updated for TUCL 2.1 Release (Kernel SCTP Support) */ +#ifdef CM_LKSCTP + case CM_INET_OPT_LINGER: + pSockLinger = (CmInetSockLinger *)value; + + cmMemset((U8*)&lngr, 0, sizeof(struct linger)); + + if (pSockLinger->enable == TRUE) + lngr.l_onoff = 1; + else + lngr.l_onoff = 0; + + lngr.l_linger = pSockLinger->lingerTime; + ret = setsockopt(sockFd->fd, level, SO_LINGER, &lngr, sizeof(lngr)); + break; + + case CM_INET_OPT_SCTP_EVENTS: + pSctpEvent = (CmInetSctpSockEvent *)value; + + cmMemset((U8*)&event, 0, sizeof(struct sctp_event_subscribe)); + + if (pSctpEvent->dataIoEvent == TRUE) + event.sctp_data_io_event = 1; + + if (pSctpEvent->associationEvent == TRUE) + event.sctp_association_event = 1; + + if (pSctpEvent->addressEvent == TRUE) + event.sctp_address_event = 1; + + if (pSctpEvent->sendFailureEvent == TRUE) + event.sctp_send_failure_event = 1; + + if (pSctpEvent->peerErrorEvent == TRUE) + event.sctp_peer_error_event = 1; + + if (pSctpEvent->shutdownEvent == TRUE) + event.sctp_shutdown_event = 1; + + if (pSctpEvent->partialDeliveryEvent == TRUE) + event.sctp_partial_delivery_event = 1; + + if (pSctpEvent->adaptationLayerEvent == TRUE) +#ifdef SUN_KSCTP + event.sctp_adaption_layer_event = 1; +#else + event.sctp_adaptation_layer_event = 1; +#endif + + ret = setsockopt(sockFd->fd, level, SCTP_EVENTS, &event, sizeof(event)); + break; + + case CM_INET_OPT_SCTP_PRIM_ADDR: + pSctpPrimAddr = (CmInetSctpPrimAddr *)value; + + cmMemset((U8*)&setPrim, 0, sizeof(struct sctp_setprim)); + +#ifdef IPV6_SUPPORTED + if (pSctpPrimAddr->addr.type == CM_INET_IPV6ADDR_TYPE) + { + if (sockFd->protType == AF_INET) + { +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "Invalid address: sockFd->protType(%d)," + " sockFd->fd(%ld)\n", sockFd->protType, sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET040, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "Invalid address: sockFd->protType(%d)," + " sockFd->fd(%d)\n", sockFd->protType, sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET040, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + + pAddr6 = (struct sockaddr_in6*)&(setPrim.ssp_addr); + pAddr6->sin6_family = AF_INET6; + pAddr6->sin6_port = CM_INET_HTON_U16(pSctpPrimAddr->port); + CM_INET_COPY_IPV6ADDR(&pAddr6->sin6_addr.s6_addr, &pSctpPrimAddr->addr.u.ipv6NetAddr); + } + else + { + pAddr = (struct sockaddr_in*)&(setPrim.ssp_addr); + pAddr->sin_family = AF_INET; + pAddr->sin_port = CM_INET_HTON_U16(pSctpPrimAddr->port); + pAddr->sin_addr.s_addr = CM_INET_HTON_U32(pSctpPrimAddr->addr.u.ipv4NetAddr); + } +#else + pAddr = (struct sockaddr_in*)&(setPrim.ssp_addr); + pAddr->sin_family = AF_INET; + pAddr->sin_port = CM_INET_HTON_U16(pSctpPrimAddr->port); + pAddr->sin_addr.s_addr = CM_INET_HTON_U32(pSctpPrimAddr->addr.u.ipv4NetAddr); +#endif /* IPV6_SUPPORTED */ + + setPrim.ssp_assoc_id = pSctpPrimAddr->assocId; + + ret = setsockopt(sockFd->fd, level, SCTP_PRIMARY_ADDR, &setPrim, sizeof(setPrim)); + break; + + case CM_INET_OPT_SCTP_PEERADDR_PARAMS: + pSctpPAddrParams = (CmInetSctpPeerAddrParams *)value; + + cmMemset((U8*)&addrParams, 0, sizeof(struct sctp_paddrparams)); + + + if (pSctpPAddrParams->s.addrPres == TRUE) + { +#ifdef IPV6_SUPPORTED + if (pSctpPAddrParams->s.addr.type == CM_INET_IPV6ADDR_TYPE) + { + if (sockFd->protType == AF_INET) + { +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "Invalid address: sockFd->protType(%d)," + " sockFd->fd(%ld)\n", sockFd->protType, sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET041, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "Invalid address: sockFd->protType(%d)," + " sockFd->fd(%d)\n", sockFd->protType, sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET041, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + + RETVALUE(RFAILED); + } + + pAddr6 = (struct sockaddr_in6*)&(addrParams.spp_address); + pAddr6->sin6_family = AF_INET6; + pAddr6->sin6_port = CM_INET_HTON_U16(pSctpPAddrParams->s.port); + CM_INET_COPY_IPV6ADDR(&pAddr6->sin6_addr.s6_addr, &pSctpPAddrParams->s.addr.u.ipv6NetAddr); + } + else + { + pAddr = (struct sockaddr_in*)&(addrParams.spp_address); + pAddr->sin_family = AF_INET; + pAddr->sin_port = CM_INET_HTON_U16(pSctpPAddrParams->s.port); + pAddr->sin_addr.s_addr = CM_INET_HTON_U32(pSctpPAddrParams->s.addr.u.ipv4NetAddr); + } +#else + pAddr = (struct sockaddr_in*)&(addrParams.spp_address); + pAddr->sin_family = AF_INET; + pAddr->sin_port = CM_INET_HTON_U16(pSctpPAddrParams->s.port); + pAddr->sin_addr.s_addr = CM_INET_HTON_U32(pSctpPAddrParams->s.addr.u.ipv4NetAddr); +#endif /* IPV6_SUPPORTED */ + } + else + { +#ifdef IPV6_SUPPORTED + if (sockFd->protType == AF_INET6) + addrParams.spp_address.ss_family = AF_INET6; + else + addrParams.spp_address.ss_family = AF_INET; +#else + addrParams.spp_address.ss_family = AF_INET; +#endif + } + + /* Not validating the address, whether addr is a valid address or not */ + + addrParams.spp_assoc_id = pSctpPAddrParams->assocId; + /*cm_inet_c_001.main_58 : fix for klockwork issue */ + addrParams.spp_pathmaxrxt = (U16)pSctpPAddrParams->pathMaxRxt; +#ifdef SUN_KSCTP + if (pSctpPAddrParams->hbEnblFlag == CM_INET_OPT_ENABLE) + addrParams.spp_hbinterval = pSctpPAddrParams->hbInterval; + else + addrParams.spp_hbinterval = 0; +#else + /* linux */ + addrParams.spp_flags = 0; + + if (pSctpPAddrParams->pmtudFlag == CM_INET_OPT_ENABLE) + { + addrParams.spp_flags |= SPP_PMTUD_ENABLE; + addrParams.spp_pathmtu = pSctpPAddrParams->pathMtu; + } + else if(pSctpPAddrParams->pmtudFlag == CM_INET_OPT_DISABLE) + addrParams.spp_flags |= SPP_PMTUD_DISABLE; + + if (pSctpPAddrParams->sackDelayFlag == CM_INET_OPT_ENABLE) + { + addrParams.spp_flags |= SPP_SACKDELAY_ENABLE; + addrParams.spp_sackdelay = pSctpPAddrParams->sackDelay; + } + else if(pSctpPAddrParams->sackDelayFlag == CM_INET_OPT_DISABLE) + addrParams.spp_flags |= SPP_SACKDELAY_DISABLE; + + if (pSctpPAddrParams->hbEnblFlag == CM_INET_OPT_ENABLE) + { + addrParams.spp_flags |= SPP_HB_ENABLE; + addrParams.spp_hbinterval = pSctpPAddrParams->hbInterval; + } + else if(pSctpPAddrParams->hbEnblFlag == CM_INET_OPT_DISABLE) + addrParams.spp_flags |= SPP_HB_DISABLE; +#endif + ret = setsockopt(sockFd->fd, level, SCTP_PEER_ADDR_PARAMS, &addrParams, sizeof(addrParams)); + break; + + case CM_INET_OPT_SCTP_ASSOC_PARAMS: + pSctpAssocParams = (CmInetSctpAssocParams *)value; + + cmMemset((U8*)&assocParams, 0, sizeof(struct sctp_assocparams)); + + assocParams.sasoc_cookie_life = pSctpAssocParams->cookieLife; + assocParams.sasoc_asocmaxrxt = pSctpAssocParams->assocMaxReTx; + assocParams.sasoc_assoc_id = pSctpAssocParams->assocId; + assocParams.sasoc_number_peer_destinations = pSctpAssocParams->numberOfPeerDest; + assocParams.sasoc_peer_rwnd = pSctpAssocParams->peerRwnd; + assocParams.sasoc_local_rwnd = pSctpAssocParams->localRwnd; + + ret = setsockopt(sockFd->fd, level, SCTP_ASSOCINFO, &assocParams, sizeof(assocParams)); + break; + + case CM_INET_OPT_SCTP_RTO_INFO: + pSctpRtoInfo = (CmInetSctpRtoInfo *)value; + + cmMemset((U8*)&rtoinfo, 0, sizeof(struct sctp_rtoinfo)); + + rtoinfo.srto_assoc_id = pSctpRtoInfo->assocId; + rtoinfo.srto_initial = pSctpRtoInfo->rtoInitial; + rtoinfo.srto_max = pSctpRtoInfo->rtoMax; + rtoinfo.srto_min = pSctpRtoInfo->rtoMin; + + ret = setsockopt(sockFd->fd, level, SCTP_RTOINFO, &rtoinfo, sizeof(rtoinfo)); + break; + + case CM_INET_OPT_SCTP_INIT_MSG: + pSctpInitMsg = (CmInetSctpInitMsg *)value; + + cmMemset((U8*)&initmsg, 0, sizeof(struct sctp_initmsg)); + + initmsg.sinit_max_attempts = pSctpInitMsg->maxInitReTx; + initmsg.sinit_max_init_timeo = pSctpInitMsg->maxInitTimeout; + initmsg.sinit_num_ostreams = pSctpInitMsg->numOstreams; + initmsg.sinit_max_instreams = pSctpInitMsg->maxInstreams; + + ret = setsockopt(sockFd->fd, level, SCTP_INITMSG, &initmsg, sizeof(initmsg)); + break; + +#endif /*CM_LKSCTP*/ + + /* cm_inet_c_001.main_58 : Added to support filteration of ICMP + * messages and protected under CM_ICMP_FILTER_SUPPORT flag. Its a + * partial implementaion for icmp filter done for TUCL */ +#ifdef SS_LINUX +#ifdef CM_ICMP_FILTER_SUPPORT + case CM_INET_OPT_ICMP_FILTER: + optVal = (U32*)value; + ret = setsockopt(sockFd->fd, level, ICMP_FILTER, + optVal, sizeof(icmpFilter)); + break; +#endif +#endif + + default: + /* wrong socket option type */ + RETVALUE(RFAILED); + break; + } + + if (ret == INET_ERR) + { +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetSetOpt() Failed : error(%d), sockFd->fd(%ld)\n", + INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET042, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetSetOpt() Failed : error(%d), sockFd->fd(%d)\n", + INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET042, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} /* end of cmInetSetOpt */ + + + +/* +* +* Fun: cmInetGetNumRead +* +* Desc: Gives the number of pending octets in the socket receive buffer. +* +* Ret: ROK - successful +* RFAILED - failed +* +* Notes: None. +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmInetGetNumRead +( +CmInetFd *sockFd, /* socket file descriptor */ +U32 *dataLen /* number of pending octets */ +/* removed 3rd argument memInfo */ +) +#else +PUBLIC S16 cmInetGetNumRead(sockFd, dataLen) +CmInetFd *sockFd; /* socket file descriptor */ +U32 *dataLen; /* number of pending octets */ +/* removed 3rd argument memInfo */ +#endif +{ + S32 ret; /* temporary return value */ + + /* removed local variables added for recvfrom call */ + + TRC2(cmInetGetNumRead); + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if ((sockFd == NULLP) || CM_INET_INV_SOCK_FD(sockFd) || + (dataLen == NULLP)) + { + RETVALUE(RFAILED); + } +#endif + + /* use ioctl call for all types of socket to get length of + pending data in the socket recv buffer */ +#ifdef WIN32 + /* cm_inet_c_001.main_59: Fix for compilation warning */ + ret = ioctlsocket(sockFd->fd, FIONREAD, (U32 *)dataLen); +#else +#ifdef SS_PS + ret = ioctl(sockFd->fd, FIOREAD, (char*)dataLen); +#else +#ifdef SS_VW + ret = ioctl(sockFd->fd, FIONREAD, (S32)dataLen); +#else + ret = ioctl(sockFd->fd, FIONREAD, dataLen); +#endif /* SS_VW */ +#endif /* SS_PS */ +#endif /* WIN32 */ + + /* For UDP socket assign the length of pending data in the + socket recv buffer to largest datagram size. + Removed recvfrom call & necessary processing for it. */ + + if (ret == INET_ERR) + { + /* removed error check CONABORTED added for recvfrom call. + Also return value changed from RCLOSED to ROK */ + /* Check for reset connection */ + /* cm_inet_c_001.main_45: Close the TCP connection only when err is one of these*/ + if ((INET_ERR_CODE == ERR_CONNREFUSED) || + (INET_ERR_CODE == ERR_CONNABORTED) || + (INET_ERR_CODE == ERR_TIMEDOUT)) + { + *dataLen = 0; + + /* cm_inet_c_001.main_50 + * Return RCLOSED instead of ROK to initiate connection closure. + * ROK will be returned only if the ioctl call above returns ROK. + * The routines calling this function have been modified to not + * return RCLOSED when this function returns ROK with pending data + * length value of 0. This modification is needed because: + * Due to latency (mostly in solaris) sometimes ioctl(FIONREAD) + * returns successfully with pend length as 0 on a TCP socket that + * select says is ready to read. This should not be considered as + * connection closed. + */ + RETVALUE(RCLOSED); + } + + /* removed error check ERR_WOULDBLOCK */ + /* cm_inet_c_001.main_45: Dont close the connection in case of ERR_CONNRESET */ + if ((INET_ERR_CODE == ERR_AGAIN) || + (INET_ERR_CODE == ERR_CONNRESET)) + { + *dataLen = 0; + RETVALUE(ROKDNA); + } + +#ifdef SS_LINUX + /* cm_inet_c_001.main_45: Change 2048 to CM_INET_MAX_UDPRAW_MSGSIZE */ + *dataLen = CM_INET_MAX_UDPRAW_MSGSIZE; + RETVALUE(ROK); +#endif /* SS_LINUX */ + + /* removed error debug printing added for recvfrom call. */ + +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE,"cmInetGetNumRead() Failed : error(%d)," + " sockFd->fd(%ld)\n", INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET043, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE,"cmInetGetNumRead() Failed : error(%d)," + " sockFd->fd(%d)\n", INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET043, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + + RETVALUE(ROK); +} /* end of cmInetGetNumRead */ + + +#ifndef SS_PS +/* +* +* Fun: cmInetGetHostByName +* +* Desc: Resolves a host name into the appropriate 4 byte Internet +* address. +* +* Ret: ROK - successful +* RFAILED - failed +* +* Notes: None. +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmInetGetHostByName +( +S8 *hostName, /* host name */ +CmInetIpAddrTbl *addrTbl /* Address Table of IPV4 Addresses */ +) +#else +PUBLIC S16 cmInetGetHostByName (hostName, addrTbl) +S8 *hostName; /* host name */ +CmInetIpAddrTbl *addrTbl; /* Address Table of IPV4 Addresses */ +#endif +{ +#ifndef SS_VW + U8 numAddrs; /* Number of Addresses */ +#endif /* SS_VW */ + +#if (defined(WIN32) || defined(SS_LINUX) || defined(HPOS)) + struct hostent *hostid; /* pointer to host information */ +#else +#ifndef SS_VW + struct hostent hostid; /* host information */ + S8 infoBuf[CM_INET_MAX_INFO]; /* info buffer */ + S32 err; /* error code */ +#endif /* SS_VW */ +#endif /* WIN32 || SS_LINUX || HPOS */ + + TRC2(cmInetGetHostByName) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if ((hostName == NULLP) || (addrTbl == NULLP)) + { + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + /* Initialise */ +#ifndef SS_VW + numAddrs = 0; +#endif /* SS_VW */ + + addrTbl->count = 0; + +#if (defined(WIN32) || defined(SS_LINUX) || defined(HPOS)) + hostid = gethostbyname(hostName); + if (hostid == 0) + { +#ifdef CMINETDBG + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE,"cmInetGetHostByName() Failed : error(%d)," + " hostName(%p)\n", INET_ERR_CODE, hostName); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET044, 0, prntBuf); +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + if (hostid->h_addrtype != AF_INET) + { +#ifdef CMINETDBG + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetGetHostByName() Failed : error(%d)," + " hostName(%p), hostid->h_addrtype(%d)\n", + INET_ERR_CODE, hostName, hostid->h_addrtype); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET045, 0, prntBuf); +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + else + { + while ((numAddrs < CM_INET_IPV4_NUM_ADDR) && + (hostid->h_addr_list[numAddrs] != NULLP)) + { + addrTbl->netAddr[addrTbl->count++] = + CM_INET_NTOH_U32 (*((U32 *) hostid->h_addr_list[numAddrs])); + numAddrs += 1; + } + } +#else + +#ifdef SS_VW + { + S32 vwIpAddr; + + vwIpAddr = hostGetByName(hostName); + if (vwIpAddr == INET_ERR) + { +#ifdef CMINETDBG + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE,"cmInetGetHostByName() Failed : error(%d)," + " hostName(%p)\n", INET_ERR_CODE, hostName); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET046, 0, prntBuf); +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + CM_COPY_VWIPADDR(vwIpAddr, &(addrTbl->netAddr[addrTbl->count])); + addrTbl->count++; + } +#else + + err = 0; /* err is not reset by gethostnyname_r()! */ + + gethostbyname_r(hostName, &hostid, infoBuf, CM_INET_MAX_INFO, (int*)&err); + if ((hostid.h_addrtype != AF_INET) || (err < 0)) + { +#ifdef CMINETDBG + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE,"cmInetGetHostByName() Failed : error(%d), hostName(%p)," + " hostid.h_addrtype(%d)\n", + INET_ERR_CODE, hostName, hostid.h_addrtype); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET047, 0, prntBuf); +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + else + { + while ((numAddrs < CM_INET_IPV4_NUM_ADDR) && + (hostid.h_addr_list[numAddrs] != NULLP)) + { + addrTbl->netAddr[addrTbl->count++] = + CM_INET_NTOH_U32 (*((U32 *) hostid.h_addr_list[numAddrs])); + numAddrs += 1; + } + } +#endif /* SS_VW */ + +#endif /* WIN32 || SS_LINUX || HPOS */ + + RETVALUE(ROK); + +} /* end of cmInetGetHostByName */ + + +/* The getipnodebyname is not supported on all the Solaris Operating system + * versions. This has to be supported on operating systems that support IPV6 + * as per the RFC on the IPV6 socket interface. Hence this function is moved + * under the IPV6_SUPPORTED flag */ + +/* This function now can be called for both IPv4 and IPv6. However, we will + * call cmInetGetHostByName inside for IPv4. Move all flag dependencies + * inside this function. */ +/* +* +* Fun: cmInetGetIpNodeByName +* +* Desc: Resolves a host name into the appropriate 4 byte Internet +* address or into the appropriate 16 byte IPV6 address. +* This function is expected to be thread safe and should be used +* instead of the cmInetGetHostByName function. +* +* Ret: ROK - successful +* RFAILED - failed +* +* Notes: None. +* +* File: cm_inet.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmInetGetIpNodeByName +( +S8 *hostName, /* host name */ +CmInetIpAddrArr *addrArr /* Array of addressed filled in */ +) +#else +PUBLIC S16 cmInetGetIpNodeByName(hostName, addrArr) +S8 *hostName; /* host name */ +CmInetIpAddrArr *addrArr; /* Array of addressed filled in */ +#endif +{ + /* for return value from cmInetGetHostByName */ +#ifndef IPV6_SUPPORTED + S16 ret; +#else +#ifdef SUNOS +#ifndef SS_LINUX + U8 numAddrs=0; /* Number of addresses */ + int err=0; /* error code */ + struct hostent *hostid; /* host information */ +#endif /* SS_LINUX */ +#endif /* SUNOS */ +#endif /* IPV6_SUPPORTED */ + + TRC2(cmInetGetIpNodeByName) + + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if ((hostName == NULLP) || (addrArr == NULLP)) + { + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + +#ifdef IPV6_SUPPORTED +#ifdef SUNOS +#ifndef SS_LINUX + +#ifdef IPV6_SUPPORTED + if (addrArr->type == CM_INET_IPV6ADDR_TYPE) + hostid = getipnodebyname(hostName, AF_INET6, 0, &err); + else +#endif /* IPV6_SUPPORTED */ + hostid = getipnodebyname(hostName, AF_INET, 0, &err); + if (!hostid) + { +#ifdef CMINETDBG + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE,"cmInetGetIpNodeByName() Failed : error(%d)," + " hostName(%p), addrArr->type(%d)n", + err, hostName, addrArr->type); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET048, 0, prntBuf); +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + +#ifdef IPV6_SUPPORTED + if (addrArr->type == CM_INET_IPV6ADDR_TYPE) + { + if (hostid->h_addrtype == AF_INET6) + { + while ((numAddrs < CM_INET_IPV6_NUM_ADDR) && + (hostid->h_addr_list[numAddrs] != NULLP)) + { + /* Use the cminet fill macro here */ + CM_INET_COPY_IPV6ADDR(&addrArr->u.ipv6AddrArr.netAddr[numAddrs], + hostid->h_addr_list[numAddrs]); + addrArr->u.ipv6AddrArr.count++; + numAddrs += 1; + } + } + else + { +#ifdef CMINETDBG + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetGetIpNodeByName() Failed : error(%d)," + " hostName(%p), addrArr->type(%d),hostid->h_addrtype(%d) \n", + err, hostName, addrArr->type, hostid->h_addrtype); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET049, 0, prntBuf); +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + } + else +#endif /* IPV6_SUPPORTED */ + { + if (hostid->h_addrtype == AF_INET) + { + while ((numAddrs < CM_INET_IPV4_NUM_ADDR) && + (hostid->h_addr_list[numAddrs] != NULLP)) + { + addrArr->u.ipv4AddrArr.count ++; + addrArr->u.ipv4AddrArr.netAddr[numAddrs] = + CM_INET_NTOH_U32 (*((U32 *) hostid->h_addr_list[numAddrs])); + numAddrs += 1; + } + } + else + { +#ifdef CMINETDBG + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetGetIpNodeByName() Failed : error(%d)," + " hostName(%p), hostid->h_addrtype(%d), addrArr->type(%d)\n", + err, hostName, hostid->h_addrtype, addrArr->type); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET050, 0, prntBuf); +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + } +#endif /* SS_LINUX */ +#endif /* SUNOS */ + + RETVALUE(ROK); +#else + ret = cmInetGetHostByName(hostName, &addrArr->u.ipv4AddrArr); + RETVALUE(ret); +#endif /* IPV6_SUPPORTED */ + +} /* end of cmInetGetIpNodeByName */ + + +/* +* +* Fun: cmInetAddr +* +* Desc: Converts an ASCII string containig an internet address +* ("xxx.xxx.xxx.xxx") into a CmInetIpAddr (U32) format. +* This function is a wrapper for the inet_addr() call. +* +* Ret: ROK - successful +* RFAILED - failed +* +* Notes: None. +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmInetAddr( +S8 *asciiAddr, /* ascii address representation */ +CmInetIpAddr *address /* 4 byte interent address */ +) +#else +PUBLIC S16 cmInetAddr(asciiAddr, address) +S8 *asciiAddr; /* ascii address representation */ +CmInetIpAddr *address; /* 4 byte interent address */ +#endif +{ + TRC2(cmInetAddr); + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if (asciiAddr == NULLP) + { + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + *address = inet_addr(asciiAddr); + if (*address == (U32)ERR_INADDRNONE) + { + /* asciiAddr does not contain a valid internet address */ + RETVALUE(RFAILED); + } + + RETVALUE(ROK); +} + + +/* +* +* Fun: cmInetNtoa +* +* Desc: Converts an CmInetIPAddr based IP address into a string +* of the format "xxx.xxx.xxx.xxx". +* This function is a wrapper for the inet_ntoa() call. +* +* Ret: ROK - successful +* RFAILED - failed +* +* Notes: This function delivers a pointer to a static buffer +* within the system. Therefore the string has to be copied +* by the caller before another call is made! +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmInetNtoa( +CmInetIpAddr address, /* 4 byte interent address */ +S8 **asciiAddr /* ascii address representation */ +) +#else +PUBLIC S16 cmInetNtoa(address, asciiAddr) +CmInetIpAddr address; /* 4 byte interent address */ +S8 **asciiAddr; /* ascii address representation */ +#endif +{ + struct in_addr inetAddr; /* internet address structure */ + + TRC2(cmInetNtoa); + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if (asciiAddr == NULLP) + { + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + inetAddr.s_addr = address; + + *asciiAddr = inet_ntoa(inetAddr); + if (*asciiAddr == NULL) + { + RETVALUE(RFAILED); + } + + RETVALUE(ROK); +} +/* +* +* Fun: cmInetNtop +* +* Desc: Converts an network address into a string. +* This function is a wrapper for the inet_ntop() call. +* +* Ret: ROK - successful +* RFAILED - failed +* +* Notes: This function copies the resulting string to the buffer pointed to +* by asciiaddr,which must be a non NULL pointer.The caller specifies +* the number of bytes available in this buffer in the argument len. +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmInetNtop( +U8 type, /* ip address type */ +Void *address, /* 4/16 byte interent address */ +S8 *asciiAddr, /* ascii adress representation */ +U32 len +) +#else +PUBLIC S16 cmInetNtop(type,address, asciiAddr,len) +U8 type; /* ip address type */ +Void *address; /* 4/16 byte interent address */ +S8 *asciiAddr; /* ascii adress representation */ +U32 len; +#endif +{ + + S32 domain = 0; + TRC2(cmInetNtop); + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if (asciiAddr == NULLP || address == NULLP || len == 0 ) + { + RETVALUE(RFAILED); + } + +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + switch(type) + { + case CM_INET_IPV4ADDR_TYPE : + domain = AF_INET; + break; + case CM_INET_IPV6ADDR_TYPE : + domain = AF_INET6; + break; + } + if(inet_ntop(domain,address,asciiAddr,len) == NULL) + { + RETVALUE(RFAILED); + } + + RETVALUE(ROK); +} + + +/* The inet_pton is not supported on all the Solaris Operating system + * versions. This has to be supported on operating systems that support + * IPV6 as per the RFC on the IPV6 socket interface. Hence this function + *is moved under the IPV6_SUPPORTED flag */ +#ifdef IPV6_SUPPORTED +#ifdef SUNOS + +/* +* +* Fun: cmInetPton +* +* Desc: Converts a IP address string to address. +* +* Ret: ROK - successful +* RFAILED - failed +* +* Notes: +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmInetPton( +CmInetIpAddr *address, /* 4 byte interent address */ +S8 *asciiAddr /* ascii address representation */ +) +#else +PUBLIC S16 cmInetPton(address, asciiAddr) +CmInetIpAddr *address; /* 4 byte interent address */ +S8 *asciiAddr; /* ascii address representation */ +#endif +{ + S16 ret; + + TRC2(cmInetPton); + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if ((asciiAddr == NULLP) || (address == NULLP)) + { + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + ret = inet_pton(AF_INET, asciiAddr, (void *)address); + if (ret != 1) + { + RETVALUE(RFAILED); + } + + RETVALUE(ROK); +} /* end of cmInetPton */ +#endif /* SUNOS */ +#endif /* IPV6_SUPPORTED */ + +#ifdef IPV6_SUPPORTED + +/* +* +* Fun: cmInetPton6 +* +* Desc: Converts a IP address string to IPV6 address suitable +* to be used in bind. +* +* Ret: ROK - successful +* RFAILED - failed +* +* Notes: +* +* File: cm_inet.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmInetPton6( +CmInetIpAddr6 *address6, /* 16 byte interent address */ +S8 *asciiAddr /* ascii address representation */ +) +#else +PUBLIC S16 cmInetPton6(address6, asciiAddr) +CmInetIpAddr6 *address6; /* 16 byte interent address */ +S8 *asciiAddr; /* ascii address representation */ +#endif +{ + S16 ret; + +#ifdef WIN32 + struct sockaddr_storage ss; + U32 sslen = sizeof(ss); +#endif /* WIN32 */ + TRC2(cmInetPton); + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if ((asciiAddr == NULLP) || (address6 == NULLP)) + { + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + +#ifndef WIN32 + ret = inet_pton(AF_INET6, asciiAddr, (void *)address6); + if (ret != 1) + { + RETVALUE(RFAILED); + } +#else + /* cm_inet_c_001.main_44 : In windows inet_pton is not implemented. so we are using the below function + * to convert the ipv6 address string to appropriate form */ + WSAStringToAddressA((LPTSTR)asciiAddr, AF_INET6, NULL, (struct sockaddr*)&ss, &sslen); + cmMemcpy((U8*)address6, (U8*)&(((struct sockaddr_in6 *)&ss)->sin6_addr), sizeof(CmInetIpAddr6)); +#endif /* WIN32 */ + + RETVALUE(ROK); +} /* end of cmInetPton6 */ +#endif /* IPV6_SUPPORTED */ +#endif /* SS_PS */ + + +/* +* +* Fun: cmInetGetMemSize +* +* Desc: This function gives the max number of static buffer space that +* the internet library will allocate. +* +* Ret: ROK - successful +* +* Notes: None. +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmInetGetMemSize( +S32 *size /* max used memory size */ +) +#else +PUBLIC S16 cmInetGetMemSize(size) +S32 *size; /* max used memory size */ +#endif +{ +#ifdef WIN32 + /* max static memory size depends on max flat buffer size */ + *size = CM_INET_MAX_MSG_LEN; +#else + /* max static memory size depends on max flat buffer or iovect size */ + *size = CM_INET_MAX_MSG_LEN; +#endif + + RETVALUE(ROK); +} + + + +/* +* +* Fun: cmInetInit +* +* Desc: This function initializes the socket library. +* +* Ret: ROK - successful +* +* Notes: Required only for Winsock and not for 4.3BSD +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmInetInit( +Void +) +#else +PUBLIC S16 cmInetInit(Void) +#endif +{ +#ifdef WIN32 + U16 version; + S32 err; + WSADATA data; + + version = MAKEWORD(CM_INET_HIGH_VER, CM_INET_LOW_VER); + err = WSAStartup(version, &data); + if (err != 0) + { + RETVALUE(RFAILED); + } +#endif + + RETVALUE(ROK); +} + + +/* +* +* Fun: cmInetDeInit +* +* Desc: This function de initializes the socket library. The +* WINSOCK implementation de registers the application and +* releases any resources allocated on behalf of the +* application. +* +* Ret: ROK - successful +* +* Notes: Required only for Winsock and not for 4.3BSD +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmInetDeInit( +Void +) +#else +PUBLIC S16 cmInetDeInit(Void) +#endif +{ +#ifdef WIN32 + S32 err; + + err = WSACleanup(); + if (err != 0) + { + RETVALUE(RFAILED); + } +#endif + + RETVALUE(ROK); +}/* end of cmInetDeInit() */ + + +/* +* +* Fun: cmInetGetSockName +* +* Desc: This function is used to retireve the current name +* for the specified socket descriptor. It returns the +* local association(address and port) for the socket. +* +* Ret: ROK - successful +* RFAILED - failed +* +* Notes: Please note if the socket was bound to CM_INET_INADDR_ANY +* cmInetGetSockName() will not necessarily return the local +* address information unless the socket has been connected. +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmInetGetSockName +( +CmInetFd *sockFd, /* socket file descriptor */ +CmInetAddr *locAddr +) +#else +PUBLIC S16 cmInetGetSockName(sockFd, locAddr) +CmInetFd *sockFd; /* socket file descriptor */ +CmInetAddr *locAddr; +#endif +{ + struct sockaddr_in *sockAddr; +#ifdef IPV6_SUPPORTED + struct sockaddr_in6 *sockAddr6; + struct sockaddr_in6 lclSockAddr; +#else + CmInetSockAddr lclSockAddr; +#endif /* IPV6_SUPPORTED */ +#ifdef UNIX + socklen_t size; +#else + U32 size; +#endif /* SS_LINUX */ + S32 errCode; + /*cm_inet_c_001.main_58 : fix for klockwork issue */ + S32 ret; + + TRC2(cmInetGetSockName); + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if ((sockFd == NULLP) || CM_INET_INV_SOCK_FD(sockFd) || + (locAddr == NULLP)) + { + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + cmMemset((U8*)&lclSockAddr, 0, sizeof(lclSockAddr)); + size = sizeof(lclSockAddr); + +#ifdef UNIX + ret = getsockname(sockFd->fd, (CmInetSockAddr*)&lclSockAddr, + (socklen_t *)&size); +#else + ret = getsockname(sockFd->fd, (CmInetSockAddr*)&lclSockAddr, (int*)&size); +#endif /* SS_LINUX */ + + if(ret == INET_ERR) + { + switch(errCode = INET_ERR_CODE) + { + case ERR_INVAL: + sockAddr = (struct sockaddr_in *)&lclSockAddr; +#ifdef IPV6_SUPPORTED + locAddr->type = CM_INET_IPV4ADDR_TYPE; + locAddr->u.ipv4Addr.port = CM_INET_NTOH_U16(sockAddr->sin_port); +#else + locAddr->port = CM_INET_NTOH_U16(sockAddr->sin_port); +#endif /* IPV6_SUPPORTED */ + RETVALUE(ROK); + + default: +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE,"cmInetGetHostByName() Failed : error(%d)," + " sockFd->fd(%ld)\n", INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET051, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE,"cmInetGetHostByName() Failed : error(%d)," + " sockFd->fd(%d)\n", INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_INT_PAR, ECMINET051, 0, prntBuf); +#endif /* ALIGN_64BIT */ +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + }/* end of switch */ + + }/* end if */ + + /* Fill the returned address in to locAddr */ +#ifdef IPV6_SUPPORTED + cmMemset((U8*)locAddr, 0, sizeof(CmInetAddr)); + if (size == sizeof(struct sockaddr_in6)) + { + sockAddr6 = (struct sockaddr_in6 *)&lclSockAddr; + locAddr->type = CM_INET_IPV6ADDR_TYPE; + locAddr->u.ipv6Addr.port = CM_INET_NTOH_U16(sockAddr6->sin6_port); + CM_INET_COPY_IPV6ADDR(&locAddr->u.ipv6Addr.ipv6NetAddr, + &sockAddr6->sin6_addr); + } + else + { + sockAddr = (struct sockaddr_in *)&lclSockAddr; + locAddr->type = CM_INET_IPV4ADDR_TYPE; + locAddr->u.ipv4Addr.port = CM_INET_NTOH_U16(sockAddr->sin_port); + locAddr->u.ipv4Addr.address = + CM_INET_NTOH_U32(sockAddr->sin_addr.s_addr); + } +#else + sockAddr = (struct sockaddr_in *)&lclSockAddr; + locAddr->port = CM_INET_NTOH_U16(sockAddr->sin_port); + locAddr->address = CM_INET_NTOH_U32(sockAddr->sin_addr.s_addr); +#endif /* IPV6_SUPPORTED */ + RETVALUE(ROK); +}/* end of cmInetGetSockName() */ + +/* New functions to peek into the file descriptor + * set */ +#if (defined(SUNOS) || defined(WIN32) || defined(SS_LINUX) || defined(SS_VW) \ + || defined(HPOS)) + +/* +* +* Fun: cmInetFdSetInfoInit +* +* Desc: This function is used to initialise operating system specific +* data that will be used to peek into the file descriptor lists +* to get the sockets that are set +* +* Ret: ROK - successful +* RFAILED - failed +* +* Notes: +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmInetFdSetInfoInit +( +CmInetFdSetInfo *fdSetInfo +) +#else +PUBLIC S16 cmInetFdSetInfoInit(fdSetInfo) +CmInetFdSetInfo *fdSetInfo; +#endif +{ +#if (defined(SUNOS) || defined(SS_LINUX) || defined(SS_VW) || defined(HPOS)) + U16 arIdx; + U8 curByte; + U8 bitPos; + CmInetFdSet *fdSet; +#endif /* SUNOS || SS_LINUX || SS_VW */ + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (fdSetInfo == NULLP) + RETVALUE(RFAILED); +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + if (fdSetInfo->initDone == TRUE) + RETVALUE(ROK); + +#ifdef WIN32 + fdSetInfo->numFds = 0; +#endif /* WIN32 */ + +#if (defined(SUNOS) || defined(SS_LINUX) || defined(SS_VW)|| defined(HPOS)) + /* Check if we are on a big endian machine */ + arIdx = 0x01; + if (*(U8 *)&arIdx) + fdSetInfo->bigEndian = FALSE; + else + fdSetInfo->bigEndian = TRUE; + + fdSetInfo->arIdx = 0; + fdSetInfo->ar[0] = 0xff; + + /* Initialise the array */ + /* The array contains bit positions for the first bit + * for each integer from 1 to 2^8. + */ + for (arIdx = 1; arIdx < 256; arIdx++) + { + /* cm_inet_c_001.main_54: Fix for Klockworks issue */ + curByte = (U8)arIdx; + bitPos = 0; + + while(bitPos < 8) + { + if (curByte & 0x01) + { + fdSetInfo->ar[arIdx] = bitPos; + break; + } + bitPos += 1; + curByte = curByte >> 1; + } + } + /* Calculate the number of array elements in this fd_set */ +#if (defined(SS_LINUX) && !defined(_GNU_SOURCE)) + fdSetInfo->numArElems = sizeof(CmInetFdSet)/sizeof(fdSet->__fds_bits[0]); +#else + fdSetInfo->numArElems = sizeof(CmInetFdSet)/sizeof(fdSet->fds_bits[0]); +#endif /* SS_LINUX */ +#endif /* SUNOS || SS_LINUX || SS_VW || HPOS */ + + fdSetInfo->initDone = TRUE; + RETVALUE(ROK); +}/* end of cmInetFdSetInfoInit() */ + + +/* +* +* Fun: cmInetGetFd +* +* Desc: This function is used to get the file descriptor from the +* file descriptor set. +* +* Ret: ROK - successful +* ROKDNA - socket not found +* RFAILED - failed +* RNA - failed, initialisation not done +* +* Notes: If the application modifies fdSet between calls to this +* function then the results are undefined. This function should +* be called in a loop till either it returns - not ROK, or if +* all sockets in the file descriptor set are processed. +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmInetGetFd +( +CmInetFdSetInfo *fdSetInfo, +CmInetFdSet *fdSet, +CmInetFdType *sockFd +) +#else +PUBLIC S16 cmInetGetFd(fdSetInfo, fdSet, sockFd) +CmInetFdSetInfo *fdSetInfo; +CmInetFdSet *fdSet; +CmInetFdType *sockFd; +#endif +{ + /*cm_inet_c_001.main_58 : Fix for klockwork issue */ +#if (!defined (WIN32)) + U32 sizOfFdSetArElem; + U8 bytesScanned; + Bool found; + U32 curIdx; + U8 *tempByte; + U8 bitPos; +#endif /* !defined (WIN32) */ + +#if (ERRCLASS & ERRCLS_INT_PAR) + if ((fdSetInfo == NULLP) || (fdSet == NULLP) || (sockFd == NULLP)) + RETVALUE(RFAILED); + + if (fdSetInfo->initDone != TRUE) + RETVALUE(RNA); +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + +#ifdef WIN32 +#if (ERRCLASS & ERRCLS_DEBUG) + if (fdSetInfo->numFds > FD_SETSIZE) + RETVALUE(RFAILED); +#endif /* ERRCLASS & ERRCLS_DEBUG */ + /* cm_inet_c_001.main_32 : Corrected check for number of fd set in + a fdset for WIN32*/ + if (fdSetInfo->numFds >= fdSet->fd_count) + RETVALUE(ROKDNA); + + *sockFd = fdSet->fd_array[fdSetInfo->numFds]; + fdSetInfo->numFds += 1; + RETVALUE(ROK); +#endif /* WIN32 */ + + /* cm_inet_c_001.main_59: Protected under if not defined WIN32 */ +#if (!defined (WIN32)) + /* Start with arIdx and continue upto number of array elements. */ + curIdx = fdSetInfo->arIdx; + found = FALSE; + +#if (defined(SS_LINUX) && !defined(_GNU_SOURCE)) + sizOfFdSetArElem = sizeof(fdSet->__fds_bits[0]); +#else + sizOfFdSetArElem = sizeof(fdSet->fds_bits[0]); +#endif /* SS_LINUX */ + + for (curIdx = fdSetInfo->arIdx; curIdx < fdSetInfo->numArElems; + curIdx ++) + { +#if (defined(SS_LINUX) && !defined(_GNU_SOURCE)) + if (fdSet->__fds_bits[curIdx]) +#else + if (fdSet->fds_bits[curIdx]) +#endif /* SS_LINUX */ + { + /* Walk through the bytes in this element */ +#if (defined(SS_LINUX) && !defined(_GNU_SOURCE)) + tempByte = (U8 *)&fdSet->__fds_bits[curIdx]; +#else + tempByte = (U8 *)&fdSet->fds_bits[curIdx]; +#endif /* SS_LINUX */ + + /* Set the starting byte offset */ + if (fdSetInfo->bigEndian) + tempByte += sizOfFdSetArElem - 1; + + for (bytesScanned = 0; bytesScanned < sizOfFdSetArElem; + bytesScanned ++) + { + if (*tempByte) + { + bitPos = fdSetInfo->ar[*tempByte]; + /* cm_inet_c_001.main_54: Fix for Klockworks issue */ + fdSetInfo->arIdx = (U16)curIdx; + /* Calculate fd depending on where we are */ + *sockFd = ((bytesScanned << 3) + bitPos); + *sockFd += (curIdx * (sizOfFdSetArElem << 3)); + /* Clear the file descriptor */ + *tempByte &= ~(1 << bitPos); + RETVALUE(ROK); + } + if (fdSetInfo->bigEndian) + tempByte -= 1; + else + tempByte += 1; + } + break; + } + } + + if (!found) + RETVALUE(ROKDNA); + + RETVALUE(ROK); +#endif /* SUNOS || SS_LINUX || SS_VW || HPOS */ +} /* end of cmInetGetFd */ + +#endif /* SUNOS || WIN32 || SS_LINUX || SS_VW || HPOS */ + + +/* add cmInetConvertStrToIpAddr and + * cmInetAsciiToIpv4 functions */ +/* +* +* Fun: cmInetConvertStrToIpAddr +* +* Desc: This function parses the input string for an IPV4/IPV6 address. +* formats: +* 1) IPV4 in dot number format: +* 206.216.108.253 +* 2) IPV6, in uncompressed, compressed, and IPV4 embedded format +* 10:20:30:40:502:610:70C:80ad +* A5::34:45 +* 45::AB:34:123.34.5.667 +* +* Ret: ROK - SUCCESS +* RFAILED - FAILURE +* +* Notes: +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmInetConvertStrToIpAddr +( +U16 len, /* Length of IP address */ +U8 *val, /* Domain Name String */ +CmInetNetAddr *address /* IP Address */ +) +#else +PUBLIC S16 cmInetConvertStrToIpAddr(len, val, address) +U16 len; /* Length of IP address */ +U8 *val; /* Domain Name String */ +CmInetNetAddr *address; /* IP Address */ +#endif +{ + U8 idx; /* Index for string*/ + U8 ipv4[CM_INET_IPV4ADDR_SIZE]; /* IPV4 Address bytes */ +#ifdef IPV6_SUPPORTED + U16 *ipv6; /* IPV6 Address bytes */ + U16 ipv6Reg[8]; /* regular IPV6 Address bytes */ + U16 ipv6Cmp[8]; /* compressed IPV6 Address bytes */ + U8 numBlk; /* number of blocks in IPV6 addr */ + Bool compressed; /* IPV6 in compressed format */ + U8 ipv6Idx; /* counter for IPV6 */ + U8 blkBeginIdx; /* IPV6, char index for the + beginning of the block */ + U8 i; /* counter for IPV6 */ + S16 retVal; /* return value */ + Bool embedIPV4 = FALSE; /* IPV4 embedded in IPV6 ? */ +#endif /* IPV6_SUPPORTED*/ + + TRC2(cmInetConvertStrToIpAddr) + + idx = 0; +#ifdef IPV6_SUPPORTED + numBlk = 0; + ipv6Idx = 0; + compressed = FALSE; + embedIPV4 = FALSE; + ipv6 = ipv6Reg; /* assign pointer to IPV6 regular, uncompressed */ + cmMemset((U8 *)ipv6Reg, 0, CM_INET_IPV6ADDR_SIZE); + cmMemset((U8 *)ipv6Cmp, 0, CM_INET_IPV6ADDR_SIZE); +#endif /* IPV6_SUPPORTED*/ + + cmMemset((U8 *)ipv4, 0, CM_INET_IPV4ADDR_SIZE); + + /* Check for IP Address */ + while ((val[idx] != '.') && (val[idx] != ':') && + (idx < len)) + { +#if (ERRCLASS & ERRCLS_DEBUG) + if (((val[idx] < '0') || (val[idx] > '9')) && + ((val[idx] < 'a') || (val[idx] > 'f')) && + ((val[idx] < 'A') || (val[idx] > 'F'))) + { + /* Not a digit */ + RETVALUE(RFAILED); + } +#endif /* (ERRCLASS & ERRCLS_DEBUG) */ + + /* Convert Ascii to integer */ + CM_INET_ATOI(ipv4[0], val[idx]); + +#ifdef IPV6_SUPPORTED + /* convert Ascii to hex */ + CM_INET_ATOH(ipv6[0], val[idx]); +#endif /* IPV6_SUPPORTED */ + + idx++; /* move to the next character */ + } /* while, try to determine IPV4 or IPV6 */ + +#if (ERRCLASS & ERRCLS_DEBUG) + if ((val[idx] != '.') && (val[idx] != ':')) + { + /* Not a digit */ + RETVALUE(RFAILED); + } /* if, couldn't determine IPV4 or IPV6 */ +#endif /* (ERRCLASS & ERRCLS_DEBUG) */ + + + if (val[idx] == '.') + { + idx++; + cmInetAsciiToIpv4(3, &(ipv4[1]), (U16)(len - idx), &(val[idx])); + + address->type = CM_INET_IPV4ADDR_TYPE; + CM_INET_GET_IPV4_ADDR_FRM_STRING(address->u.ipv4NetAddr, ipv4); + } /* if, IPV4 */ +#ifdef IPV6_SUPPORTED + else + { + numBlk = 1; /* already converted the 1st block */ + ipv6Idx = 0; + while ((val[idx] != '\0') && (idx < len) && (numBlk <= 8)) + { + idx++; /* go to the next char, either a number or the 2nd : */ + if (val[idx] == ':') + { +#if (ERRCLASS & ERRCLS_DEBUG) + if (compressed == TRUE) + { + /* can't have 2 :: */ + RETVALUE(RFAILED); + } /* if, 2 :: */ +#endif /* (ERRCLASS & ERRCLS_DEBUG) */ + + compressed = TRUE; + idx++; /* skip the : */ + ipv6 = ipv6Cmp; + ipv6Idx = 0; + } /* if, IPV6 in compressed format :: */ + else + { + ipv6Idx++; + } /* else, uncompressed, convert next block */ + + numBlk++; /* increase number of blocks */ + + /* assign the index the beginning of the block */ + blkBeginIdx = idx; + + while(val[idx] != ':' && val[idx] != '\0' && idx < len) + { + if (val[idx] == '.') + { + /* convert number to IPV4 */ + ipv6[ipv6Idx] = 0; /* clear out whatever we did */ + cmMemset((U8 *)ipv4, 0, CM_INET_IPV4ADDR_SIZE); + retVal = cmInetAsciiToIpv4(4, ipv4, len - blkBeginIdx, + &(val[blkBeginIdx])); + /* stop the loop, embedded IPV4 is the last part of + an IPV6 address */ + if (retVal != ROK) + { + RETVALUE(retVal); + } + embedIPV4 = TRUE; + break; + } /* if, '.' means IPV4 address embedded in IPV6 */ + +#if (ERRCLASS & ERRCLS_DEBUG) + if (((val[idx] < '0') || (val[idx] > '9')) && + ((val[idx] < 'a') || (val[idx] > 'f')) && + ((val[idx] < 'A') || (val[idx] > 'F'))) + { + /* Not a digit */ + RETVALUE(RFAILED); + } +#endif /* (ERRCLASS & ERRCLS_DEBUG) */ + + /* Convert Ascii to integer */ + CM_INET_ATOH(ipv6[ipv6Idx], val[idx]); + + /* move to the next index */ + idx++; + } /* while, convert a block of 16 bits Hex number */ + if (embedIPV4 == TRUE) + { + ipv6Idx--; /* deccrease in case of compressed IPV6 */ + break; /* stop the while look */ + } /* if, IPV4 embedded in IPV6 */ + } /* while, IPV6 parsing */ + if (compressed == TRUE) + { + if (embedIPV4 == TRUE) + { + numBlk = 5; /* the last 2 blocks are IPV4 */ + } /* if, IPV4 embedded */ + else + { + numBlk = 7; /* copy from the last block */ + } /* else, no embedded IPV4 */ + + /* type cast U8 over -1 becasue we want to copy the last block, + ipv6Cmp[0] + */ + for (i = ipv6Idx; i != (U8) (-1); i --) + { + ipv6Reg[numBlk] = ipv6Cmp[i]; + numBlk--; + } /* for, copying compress IPV6 to regular IPV6 */ + } /* if, compressed format */ + + if (embedIPV4 == TRUE) + { + ipv6Reg[6] = PutHiByte(ipv6Reg[6], ipv4[0]); + ipv6Reg[6] = PutLoByte(ipv6Reg[6], ipv4[1]); + ipv6Reg[7] = PutHiByte(ipv6Reg[7], ipv4[2]); + ipv6Reg[7] = PutLoByte(ipv6Reg[7], ipv4[3]); + } /* if, IPV4 embedded */ + + /* convert IPV6 to cmInetIpv6 */ + address->type = CM_INET_IPV6ADDR_TYPE; + cmMemcpy((U8 *)address->u.ipv6NetAddr, + (CONSTANT U8 *) ipv6Reg, CM_INET_IPV6ADDR_SIZE); + } /* else, IPV6 */ +#endif /* IPV6_SUPPORTED */ + + RETVALUE(ROK); +} /* cmInetConvertStrToIpAddr */ + + +/* +* +* Fun: cmInetAsciiToIpv4 +* +* Desc: This function parses the input string to an IPV4 address. +* The input string can be +* - the whole IPV4 address, '123.43.45.56', or +* - a part of it. '34.56.454' +* numBytes: number of bytes needs to be converted, IPV4 has +* 4 bytes. If we are only converting the end of an +* address, this number needs to be adjusted. For +* example, when converting '34.56.454]', the number +* is 3. +* +* Ret: ROK - SUCCESS +* RFAILED - FAILURE +* +* Notes: +* +* File: cm_inet.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmInetAsciiToIpv4 +( +U8 numBytes, /* number of Byte to convert */ +U8 *ipv4Addr, /* IPV4 Address */ +U16 len, /* Length of IP address */ +U8 *val /* Domain Name String */ +) +#else +PUBLIC S16 cmInetAsciiToIpv4(numBytes, ipv4Addr, len, val) +U8 numBytes; /* number of Byte to convert */ +U8 *ipv4Addr; /* IPV4 Address */ +U16 len; /* Length of IP address */ +U8 *val; /* Domain Name String */ +#endif +{ + U8 byteCount; /* Byte Count */ + U8 idx; /* Index for string*/ + + TRC2(cmInetAsciiToIpv4) + + idx = 0; + for (byteCount = 0; byteCount < numBytes; byteCount++) + { + while((val[idx] != '.') && (idx < len)) + { +#if (ERRCLASS & ERRCLS_DEBUG) + if (val[idx] < '0' || val[idx] > '9') + { + /* Not a digit */ + RETVALUE(RFAILED); + } +#endif /* (ERRCLASS & ERRCLS_DEBUG) */ + + /* Convert Ascii to integer */ + CM_INET_ATOI(ipv4Addr[byteCount], val[idx]); + + /* move to the next index */ + idx++; + } + idx++; + } + + RETVALUE(ROK); +} /* cmInetAsciiToIpv4 */ + +/* cm_inet_c_001.main_34:Added wrapper function for getaddrinfo and freeaddrinfo */ +#if (!defined(SS_VW) && !defined(SS_PS) && !defined(WIN32)) + +/* +* +* Fun: cmInetGetAddrInfo +* +* Desc: a socket file descriptor to a local Internet +* address/port. +* +* Ret: Value returned by getaddrinfo +* +* Notes: None. +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PUBLIC S32 cmInetGetAddrInfo +( +CONSTANT S8 *node, /* Network addr which has to be resolved */ +CONSTANT S8 *service, /* Sets the port number in network addr */ +CONSTANT CmInetAddrInfo *hints, /* Specifies preferred socket type or protocol */ +CmInetAddrInfo **res /* Link list of addrInfo structure */ +) +#else +PUBLIC S32 cmInetGetAddrInfo(node,service,hints,res) +CONSTANT S8 *node; /* Network addr which has to be resolved */ +CONSTANT S8 *service; /* Sets the port number in network addr */ +CONSTANT CmInetAddrInfo *hints; /* Specifies preferred socket type or protocol */ +CmInetAddrInfo **res; /* Link list of addrInfo structure */ +#endif +{ + S32 ret; + TRC2(cmInetGetAddrInfo); + ret = ROK; + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if ((node == NULLP) || (hints == NULLP)) + { + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + ret = getaddrinfo(node,service,hints,res); + if (ret != ROK) + { +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetGetAddrInfo() Failed : error(%ld), node(%p)," + " service(%p)\n", ret, node, service); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET052, 0, prntBuf); +#else + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE, "cmInetGetAddrInfo() Failed : error(%d), node(%p)," + " service(%p)\n ", ret, node, service); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET053, 0, prntBuf); +#endif /* ALIGN_64BIT */ +#endif /* CMINETDBG */ + } + RETVALUE(ret); +} /* end of cmInetGetAddrInfo */ + + +/* +* +* Fun: cmInetFreeAddrInfo +* +* Desc: Free the dynamically allocated addrinfo structure +* +* Ret: None +* +* Notes: None. +* +* File: cm_inet.c +* +*/ + +#ifdef ANSI +PUBLIC Void cmInetFreeAddrInfo +( +CmInetAddrInfo *res /* Link list of addrInfo structure */ +) +#else +PUBLIC Void cmInetFreeAddrInfo(res) +CmInetAddrInfo *res; /* Link list of addrInfo structure */ +#endif +{ + TRC2(cmInetFreeAddrInfo); + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if (res == NULLP) + RETVOID; +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + freeaddrinfo(res); +} /* end of cmInetFreeAddrInfo */ + +#endif /* SS_VW | SS_PS | WIN32*/ + +/* cm_inet_c_001.main_36 : 1. Added new interface - cmInetFlushRecvBuf() + to flush the data from socket receive buffer. */ +#ifdef CM_INET_FLUSH_RECV_BUF + +/* +* +* Fun: cmInetFlushRcvBuf +* +* Desc: Reads all the data from a socket and throw it!! +* The buffers for the receive buffer for recvfrom() are allocated from the stack. +* +* Ret: ROK - successful +* ROKDNA - ok, data not available +* RCLOSED - connection closed by peer +* ROUTRES - failed, out of resources +* RFAILED - failed +* +* Notes: None. +* +* File: cm_inet.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmInetFlushRecvBuf +( +CmInetFd *sockFd, /* socket file descriptor */ +MsgLen *len, /* number of octects to be flushed */ +S32 flags /* additional control flags */ +) +#else +PUBLIC S16 cmInetFlushRecvBuf(sockFd, len, flags) +CmInetFd *sockFd; /* socket file descriptor */ +MsgLen *len; /* number of octects to be flushed */ +S32 flags; /* additional control flags */ +#endif /* ANSI */ +{ + + Data recvTempBuf[CM_INET_MAX_BYTES_READ]; + +#if (defined(WIN32) || defined(CMINETFLATBUF)) + S32 ret; /* temporary return value */ + U32 pendLen; /* pending data length */ + S32 recvLen; /* number of received octets by recvmsg() */ + MsgLen curLen; /* current number of octets in buffer */ + U32 remAddrLen; /* length of remote address */ + struct sockaddr_in *remAddr; /* remote Internet address */ +#ifdef IPV6_SUPPORTED + struct sockaddr_in6 remSockAddr; /* to get packet's source IP address */ +#else + CmInetSockAddr remSockAddr; /* to get packet's source IP address */ +#endif /* IPV6_SUPPORTED */ +#else + S32 ret; /* temporary return value */ + MsgLen curLen; /* current number of octets in buffer */ + U32 pendLen; /* pending data length */ + S32 recvLen; /* number of received octets by recvmsg() */ + struct msghdr msg; /* message header */ + CmInetIovec rxArr[CM_INET_MAX_DBUF]; /* dynamic gather array */ + U32 remAddrLen; /* length of remote address */ +#ifdef IPV6_SUPPORTED + struct sockaddr_in6 remSockAddr;/* to get packet's source IP address */ + +#if (defined(SS_LINUX) || defined(_XPG4_2)) + U8 ancillData[CM_INET_IPV6_ANCIL_DATA]; + /* from stack for IPv6 ancill data */ +#endif +#else + CmInetSockAddr remSockAddr; /* to get packet's src IP address */ +#if (defined(SS_LINUX) || defined(_XPG4_2)) + U8 ancillData[CM_INET_IPV4_ANCIL_DATA]; + /* from stack for IPv4 ancill data */ +#endif +#endif /* IPV6_SUPPORTED */ +#endif /* WIN32 | CMINETFLATBUF */ + + /* used by getsockopt */ + U32 errValue; /* error value */ + U32 optLen; /* option length */ + + TRC2(cmInetFlushRcvBuf) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if ((sockFd == NULLP) || CM_INET_INV_SOCK_FD(sockFd)) + { + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + +#if (defined(WIN32) || defined(CMINETFLATBUF)) + remAddr = NULLP; +#endif /* (WIN32 | CMINETFLATBUF) */ + + /* clear the structure */ + cmMemset((U8*)&remSockAddr, 0, sizeof(remSockAddr)); + + /* get number of pending data */ + ret = cmInetGetNumRead(sockFd, &pendLen); + if (ret != ROK) + { + /* ret may be RFAILED or ROUTRES */ + RETVALUE(ret); + } + + /* check if connection got closed */ + if (pendLen == 0) + { + if (sockFd->type == CM_INET_STREAM) + { + + /* cm_inet_c_001.main_50 + * Due to latency (mostly in solaris) sometimes ioctl(FIONREAD) + * (inside cmInetGetNumRead) returns pend length as 0 on a TCP + * socket that select says is ready to read. This should not be + * considered as connection closed. So return ROKDNA instead of + * RCLOSED + */ + RETVALUE(ROKDNA); + } + else + /* clear error if there is any, because if there is internal error + * here it will cause infinite loop in TUCL */ + { + errValue = 0; + optLen = sizeof(int); +#ifdef UNIX + ret = getsockopt(sockFd->fd, SOL_SOCKET, SO_ERROR, + (char*)&errValue, (socklen_t *)&optLen); +#else +#if (defined(SS_VW) || defined(SS_PS)) + ret = getsockopt(sockFd->fd, SOL_SOCKET, SO_ERROR, + (char*)&errValue, (int *)&optLen); +#else +#ifndef SS_WINCE + ret = getsockopt(sockFd->fd, SOL_SOCKET, SO_ERROR, + (char*)&errValue, (int *)&optLen); +#endif /* SS_WINCE */ +#endif /* SS_VW */ +#endif /* SS_LINUX */ + if (ret == INET_ERR) + { +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE,"cmInetFlushRecvBuf() Failed : error(%d)," + " sockFd->fd(%ld)\n", INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET054, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE,"cmInetFlushRecvBuf() Failed : error(%d)," + " sockFd->fd(%d)\n", INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET054, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + RETVALUE(RFAILED); + } + else + { + U8 tempBuf; + /* added separate recvfrom calls different OS */ +#if( defined(SS_VW) || defined(HPOS) || defined(SS_PS)) + recvLen = recvfrom(sockFd->fd, (S8 *)&tempBuf, pendLen, 0, + (struct sockaddr *)&remSockAddr, (int *)&remAddrLen); +#else +#if ( defined(SUNOS) || defined(SS_LINUX)) + recvLen = recvfrom(sockFd->fd, (S8 *)&tempBuf, pendLen, 0, + NULLP, (socklen_t *)&remAddrLen); +#else + recvLen = recvfrom(sockFd->fd, (S8 *)&tempBuf, pendLen, 0, + NULLP, (S32 *)&remAddrLen); + +#endif /* defined(SUNOS) || defined(SS_LINUX) */ +#endif /* defined(SS_VW) || defined(HPOS) || defined(SS_PS) */ + + RETVALUE(ROKDNA); + } + } + }/* if (pendLen == 0)*/ + + + if((*len == CM_INET_READ_THROW) || (*len >= CM_INET_MAX_BYTES_READ)) + { + curLen = CM_INET_MAX_BYTES_READ; + } + else + { + curLen = *len; /*set to given number of messasges to be flushed */ + } + + if((*len != CM_INET_READ_THROW) && (*len < pendLen)) + { + pendLen = *len; + } + +#if (defined(WIN32) || defined(CMINETFLATBUF)) + + remAddrLen = 0; + /* + * maybe needs more than one recvfrom() call to read an entire + * message + */ + while (curLen > 0) + { + cmMemset((U8*)recvTempBuf, 0, CM_INET_MAX_BYTES_READ); + /* added separate recvfrom calls different OS */ + +#if( defined(SS_VW) || defined(HPOS) || defined(SS_PS)) + recvLen = recvfrom(sockFd->fd, (S8 *)recvTempBuf, curLen, 0, + (struct sockaddr *)&remSockAddr, (int *)&remAddrLen); +#else +#if ( defined(SUNOS) || defined(SS_LINUX)) + recvLen = recvfrom(sockFd->fd, (S8 *)recvTempBuf, curLen, 0, + (struct sockaddr *)&remSockAddr, (socklen_t *)&remAddrLen); +#else + recvLen = recvfrom(sockFd->fd, (S8 *)recvTempbuf, curLen, 0, + &remSockAddr, (S32 *)&remAddrLen); + +#endif /* defined(SUNOS) || defined(SS_LINUX) */ +#endif /* defined(SS_VW) || defined(HPOS) || defined(SS_PS) */ + + if (recvLen == INET_ERR) + { + + /* added check ERR_WOULDBLOCK */ + if ((INET_ERR_CODE == ERR_AGAIN) || + (INET_ERR_CODE == ERR_WOULDBLOCK)) + { + *len = 0; + RETVALUE(ROKDNA); + } + + + /* In Windows the recvfrom function fails + * with error code which maps to either WSAECONNABORTED. If + * this happens then cmInetFlushRecvBuf must return RCLOSED */ + if ((INET_ERR_CODE == ERR_CONNABORTED) || + (INET_ERR_CODE == ERR_CONNRESET)) + { + *len = 0; + RETVALUE(RCLOSED); + } + +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54 : CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE,"cmInetFlushRecvBuf() Failed : error(%d)," + " sockFd->fd(%ld)\n", INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET055, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE,"cmInetFlushRecvBuf() Failed : error(%d)," + " sockFd->fd(%d)\n", INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET055, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + + RETVALUE(RFAILED); + } + + if(recvLen < curLen) + break; + + pendLen -= recvLen; + + if(pendLen < curLen) + curLen = pendLen; + + } /* while (curLen > 0) */ + +#else /* end of Win NT/flat buffer specific part */ + + /* + * maybe needs more than one recvmsg() call to read entire message + * on a stream socket + */ + while (curLen > 0) + { + cmMemset((U8*)recvTempBuf, 0, CM_INET_MAX_BYTES_READ); + /* update the message structure */ +#ifdef SS_LINUX + rxArr[0].iov_base = (Void*)recvTempBuf; + rxArr[0].iov_len = (U32)curLen; +#else + rxArr[0].iov_base = (S8*)recvTempBuf; + rxArr[0].iov_len = curLen; +#endif /* SS_LINUX */ + msg.msg_iov = rxArr; + msg.msg_iovlen = 1; + + msg.msg_name = NULLP; + msg.msg_namelen = 0; + + /* added defined(_XPG4_2). Also changed the + * assignments */ +#if (defined(SS_LINUX) || defined(_XPG4_2)) + msg.msg_control = ancillData; + msg.msg_controllen = sizeof(ancillData); + msg.msg_flags = 0; +#else + msg.msg_accrights = NULLP; + msg.msg_accrightslen = 0; +#endif /* SS_LINUX */ + + recvLen = recvmsg(sockFd->fd, &msg, flags); + if ((recvLen == INET_ERR) || (recvLen > CM_INET_MAX_MSG_LEN)) + { + /* added check ERR_AGAIN when CMINETFLATBUF is not defined. + added check ERR_WOULDBLOCK */ + if ((INET_ERR_CODE == ERR_AGAIN) || + (INET_ERR_CODE == ERR_WOULDBLOCK)) + { + *len = 0; + RETVALUE(ROKDNA); + } + +#ifdef CMINETDBG +#ifndef ALIGN_64BIT + /* cm_inet_c_001.main_54: CMINETLOGERROR added insted of SDisp */ + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE,"cmInetFlushRecvBuf() Failed : error(%d)," + " sockFd->fd(%ld)\n", INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET056, 0, prntBuf); +#else + /* cm_inet_c_001.main_62:Warning fix */ + snprintf(prntBuf, CMINET_PRNT_BUF_SIZE,"cmInetFlushRecvBuf() Failed : error(%d)," + " sockFd->fd(%d)\n", INET_ERR_CODE, sockFd->fd); + CMINETLOGERROR(ERRCLS_DEBUG, ECMINET056, 0, prntBuf); +#endif /*ALIGN_64BIT*/ +#endif /* CMINETDBG */ + + /* If this happens then cmInetFlushRecvBuf must return RCLOSED. + * Needed for getting icmp msgs */ + if (INET_ERR_CODE == ERR_CONNABORTED) + { + *len = 0; + RETVALUE(RCLOSED); + } + RETVALUE(RFAILED); + }/* if ((recvLen == INET_ERR) || (recvLen > CM_INET_MAX_MSG_LEN))*/ + + if(recvLen < curLen) + break; + + pendLen -= recvLen; + + if(pendLen < curLen) + curLen = pendLen; + + } /* while(curLen > 0) */ + +#endif /* WIN32 | CMINETFLATBUF */ + + + RETVALUE(ROK); +} /* end of cmInetFlushRecvBuf */ + +#endif /* CM_INET_FLUSH_RECV_BUF*/ + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/cm/cm_inet.h b/src/cm/cm_inet.h new file mode 100644 index 000000000..babd7a9ce --- /dev/null +++ b/src/cm/cm_inet.h @@ -0,0 +1,635 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ +/********************************************************************20** + + Name: common Internet socket library + + Type: header file + + Desc: common library for Internet sockets + + File: cm_inet.h + +*********************************************************************21*/ + + +/* + * This software may be combined with the following TRILLIUM + * software: + * + * part no. description + * -------- ---------------------------------------------- + * 1000151 TCAP over TCP/IP + */ + +#ifndef __CMINETH__ +#define __CMINETH__ + +#define CM_INET_IPV4ADDR_SIZE 4 +#define CM_INET_IPV6ADDR_SIZE 16 + +#define CM_INET_IPV4PORT_SIZE 2 +#define CM_INET_IPV6PORT_SIZE 2 + +/* reusing the definition */ +#define CM_INET_IPV4ADDR_TYPE CM_IPV4ADDR_TYPE +#define CM_INET_IPV6ADDR_TYPE CM_IPV6ADDR_TYPE + +#ifdef WIN32 +#define CM_INET_HIGH_VER 2 +#define CM_INET_LOW_VER 2 +#endif /* WIN32 */ + +/* Invalid socket flag */ +#ifdef WIN32 +#define CM_INET_INV_SOCKFD INVALID_SOCKET +#else +#define CM_INET_INV_SOCKFD -1 +#endif + +/* cm_inet_h_001.main_30 Poll Specific changes */ +#define CM_INET_POLL_MAXFDSUPP 1024 + +#define CM_INET_IPV4_NUM_ADDR 16 +#define CM_INET_IPV6_NUM_ADDR 4 + +/*cm_inet_h_001.main_21 Updated for TUCL 2.1 Release (Kernel SCTP Support) */ +#ifdef CM_LKSCTP +#define CM_INET_NUM_NET_ADDR 5 + +#define CM_INET_SCTP_MSG_NOTIFICATION 0x8000 +#define CM_INET_SCTP_MSG_EOR 0x80 + +/* sctp notification type */ +#define CM_INET_SCTP_ASSOC_CHANGE 1 +#define CM_INET_SCTP_PEER_ADDR_CHANGE 2 +#define CM_INET_SCTP_SEND_FAILED 3 +#define CM_INET_SCTP_REMOTE_ERROR 4 +#define CM_INET_SCTP_SHUTDOWN_EVENT 5 +#define CM_INET_SCTP_PARTIAL_DELIVERY_EVENT 6 +#define CM_INET_SCTP_ADAPTATION_INDICATION 7 + +/* sctp association change state */ +#define CM_INET_SCTP_COMM_UP 1 +#define CM_INET_SCTP_COMM_LOST 2 +#define CM_INET_SCTP_RESTART 3 +#define CM_INET_SCTP_SHUTDOWN_COMP 4 +#define CM_INET_SCTP_CANT_STR_ASSOC 5 + +/* sctp peer addr state */ +#define CM_INET_SCTP_ADDR_AVAILABLE 1 +#define CM_INET_SCTP_ADDR_UNREACHABLE 2 +#define CM_INET_SCTP_ADDR_REMOVED 3 +#define CM_INET_SCTP_ADDR_ADDED 4 +#define CM_INET_SCTP_ADDR_MADE_PRIM 5 +#define CM_INET_SCTP_ADDR_CONFIRMED 6 + +/* sctp assoc state */ +#define CM_INET_SCTP_STA_EMPTY 0 +#define CM_INET_SCTP_STA_CLOSED 1 +#define CM_INET_SCTP_STA_COOKIE_WAIT 2 +#define CM_INET_SCTP_STA_COOKIE_ECHOED 3 +#define CM_INET_SCTP_STA_ESTABLISHED 4 +#define CM_INET_SCTP_STA_SHUTDOWN_PENDING 5 +#define CM_INET_SCTP_STA_SHUTDOWN_SENT 6 +#define CM_INET_SCTP_STA_SHUTDOWN_RECEIVED 7 +#define CM_INET_SCTP_STA_SHUTDOWN_ACK_SENT 8 +#endif + +#ifdef IPV6_SUPPORTED +#define CM_INET_IPV4_DOMAIN AF_INET +#define CM_INET_IPV6_DOMAIN AF_INET6 +#endif /* IPV6_SUPPORTED */ + +/* domain */ + +/* cm_inet_h_001.main_31 : added macro for Debug print buffer size */ +#ifdef CMINETDBG +#define CMINET_PRNT_BUF_SIZE 512 +#endif +/* socket types */ +#define CM_INET_STREAM SOCK_STREAM +#define CM_INET_DGRAM SOCK_DGRAM +/*cm_inet_h_001.main_21 Updated for TUCL 2.1 Release (Kernel SCTP Support) */ +#ifdef CM_LKSCTP +#define CM_INET_SEQPACKET SOCK_SEQPACKET +#endif + +/* cm_inet_h_001.main_18:Added CM_INET_AI_PASSIVE for getaddrinfo*/ +#define CM_INET_AI_PASSIVE AI_PASSIVE + +#ifdef CM_INET2 +#define CM_INET_RAW SOCK_RAW +#endif /* CM_INET2 */ + +/* socket options type */ +#define CM_INET_OPT_BLOCK 0 /* blocking socket */ +#define CM_INET_OPT_REUSEADDR 1 /* reuse socket address */ +#define CM_INET_OPT_RX_BUF_SIZE 2 /* socket receive buffer size */ +#define CM_INET_OPT_TX_BUF_SIZE 3 /* socket transmitt buffer size */ +#define CM_INET_OPT_ADD_MCAST_MBR 4 /* add IP multicast group membership */ +#define CM_INET_OPT_DRP_MCAST_MBR 5 /* drop IP multicast group membership */ +#define CM_INET_OPT_TCP_NODELAY 6 /* disable TCP Nagle algorithm */ + +#ifdef SS_LINUX +#define CM_INET_OPT_BSD_COMPAT 7 /* BSD compatible option for Linux */ +#endif /* SS_LINUX */ + +#define CM_INET_OPT_MCAST_LOOP 8 /* Multicast loop enable/disable */ +#define CM_INET_OPT_MCAST_IF 9 /* specify local outgoing interface */ +#define CM_INET_OPT_MCAST_TTL 14 /* Specify TTL value for multicast + * applications */ +#ifdef CM_INET2 +#define CM_INET_OPT_HDR_INCLD 10 /* Header Include */ +#define CM_INET_OPT_DONTFRAGMENT 11 /* Don't Fragment */ +#define CM_INET_OPT_TOS 12 /* Type of service */ +#define CM_INET_OPT_TTL 13 /* Time to Live */ + +#ifdef IPV6_SUPPORTED +#define CM_INET_OPT_ADD_MCAST6_MBR 15 /* Add IPV6 multicast member */ +#define CM_INET_OPT_DRP_MCAST6_MBR 16 /* Drop IPV6 multicast member */ +#define CM_INET_OPT_MCAST6_LOOP 17 /* Enable or disable multicast loop + * packets */ +#define CM_INET_OPT_MCAST6_IF 18 /* Specify multicast interface */ +#define CM_INET_OPT_MCAST6_HOPS 19 /* Specify multicast hop limit */ + +#define CM_INET_OPT_ICMP6_FILTER 20 /* Specify icmp V6 filter */ +#define CM_INET_OPT_IPV6_TTL 21 /* Specify unicast hop limit */ + +/* IPv6 socket options */ +#ifdef IPV6_OPTS_SUPPORTED +#define CM_INET_OPT_RECVIPV6_HOPLIM 22 /* Receive hop limit */ +#define CM_INET_OPT_RECVIPV6_HBHOPTS 25 /* Receive HopByHop options */ +#define CM_INET_OPT_RECVIPV6_DSTOPTS 26 /* Receive Destination options */ +#define CM_INET_OPT_RECVIPV6_RTHDR 27 /* Receive Route header options */ +#define CM_INET_ALL_IPV6_EXTHDRS_LEN 512 /* total length of 3 IPV6 ext hdrs */ +#define CM_INET_OPT_IP_ROUTER_ALERT6 30 +#endif /* IPV6_OPTS_SUPPORTED */ +#define CM_INET_OPT_IPV6_PKTINFO 31 +#endif /* IPV6_SUPPORTED */ + +/* IPv4 socket options */ +#ifdef IPV4_OPTS_SUPPORTED +#define CM_INET_OPT_IP_OPTIONS 28 /* Router Alert in IPv4 */ +#define CM_INET_OPT_IPV4_PKTINFO 32 /* IPv4 PKTINFO */ +#define CM_INET_OPT_IP_ROUTER_ALERT 29 /* Router Alert to Intercept Linux */ +#endif /* IPV4_OPTS_SUPPORTED */ +#endif /* CM_INET2 */ + +#define CM_INET_OPT_BROADCAST 23 /* Broadcasting enable/disable */ +#define CM_INET_OPT_KEEPALIVE 24 /* KEEPALIVE enable/disable */ + +/*cm_inet_h_001.main_21 Updated for TUCL 2.1 Release (Kernel SCTP Support) */ +#ifdef CM_LKSCTP +#define CM_INET_OPT_LINGER 33 /* socket linger */ +#define CM_INET_OPT_SCTP_EVENTS 34 /* sctp events */ +#define CM_INET_OPT_SCTP_PRIM_ADDR 35 /* sctp primary address */ +#define CM_INET_OPT_SCTP_PEERADDR_PARAMS 36 /* sctp peer address parameters */ +#define CM_INET_OPT_SCTP_GET_ASSOC_STA 37 +#define CM_INET_OPT_SCTP_GET_PADDR_INFO 38 +/*cm_inet_h_001.main_22 Updated for the support of configurable RTO parameters, + HBeat value Max retransmissions (Init, Path, Association)*/ +#define CM_INET_OPT_SCTP_ASSOC_PARAMS 39 +#define CM_INET_OPT_SCTP_RTO_INFO 40 +#define CM_INET_OPT_SCTP_INIT_MSG 41 +#endif + + +/* cm_inet_h_001.main_29: Added new macro to support filter for ICMP messages */ +#ifdef CM_ICMP_FILTER_SUPPORT +#ifdef SS_LINUX +#define CM_INET_OPT_ICMP_FILTER 42 +#endif +#ifdef IPV6_SUPPORTED +#define CM_MAX_IPV6_FILTER 8 +#endif +#endif + +/* socket option value */ +#define CM_INET_OPT_DISABLE 0 /* enable option */ +#define CM_INET_OPT_ENABLE 1 /* disable option */ +#ifdef CM_LKSCTP +/* cm_inet_h_001.main_23: changed the value from 0xffffffff to ~0 to fix TUCL + warnings */ +#define CM_INET_OPT_DEFAULT (~0) /* default option */ +#endif + +/* level for cmInetSetOpt */ +#define CM_INET_LEVEL_SOCKET SOL_SOCKET /* socket level option */ +#define CM_INET_LEVEL_IP IPPROTO_IP /* IP level option */ +#define CM_INET_LEVEL_TCP IPPROTO_TCP /* TCP level option */ +#define CM_INET_LEVEL_SCTP IPPROTO_SCTP /* SCTP level option */ +/* cm_inet_h_001.main_29: Added new macro to support filter for ICMP messages */ +#ifdef CM_ICMP_FILTER_SUPPORT +#ifdef SS_LINUX +#define CM_INET_LEVEL_RAW SOL_RAW /* socket level option */ +#endif +#endif + +/* shutdown options */ +#ifdef WIN32 +#define CM_INET_SHTDWN_RECV SD_RECEIVE +#define CM_INET_SHTDWN_SEND SD_SEND +#define CM_INET_SHTDWN_BOTH SD_BOTH +#else +#define CM_INET_SHTDWN_RECV 0 +#define CM_INET_SHTDWN_SEND 1 +#define CM_INET_SHTDWN_BOTH 2 +#endif /* WIN32 */ + +/* send/recv control flags */ +#define CM_INET_NO_FLAG 0 +#define CM_INET_MSG_PEEK MSG_PEEK + +#if !(defined(WIN32) || defined(SS_LINUX)) +#define CM_INET_MAX_INFO 512 +#endif /* WIN32 || SS_LINUX */ + +#define CM_INET_MAX_DBUF 15 /* max. number of dBufs for a message */ + +/* cm_inet_h_001.main_24 : Inet message length is extended to 7fffffff when LONG_MSG is defined */ + +/* cm_inet_h_001.main_26 rss 1. Provided the user the flexibility to set CM_INET_MAX_MSG_LEN + * value during compilation time */ +#ifndef CM_INET_MAX_MSG_LEN +#define CM_INET_MAX_MSG_LEN 0x7fff /* max length of a message */ +#endif + +/* cm_inet_h_001.main_25 : ifndef flag added as this can be defined by the customer now*/ +#ifndef CM_INET_MAX_UDPRAW_MSGSIZE +#define CM_INET_MAX_UDPRAW_MSGSIZE 2048 +#endif + +#define CM_INET_IPV6_ANCIL_DATA 512 +#define CM_INET_IPV4_ANCIL_DATA 128 + +#define CM_INET_READ_ANY -1 /* read any pending data */ + +/* cm_inet_h_001.main_19 1. Added new defines for the new interface - + cmInetFlushRecvBuf() to flush the data + from socket receive buffer. */ +#ifdef CM_INET_FLUSH_RECV_BUF +#define CM_INET_READ_THROW -2 /* read and throw data from receive buffer */ +#define CM_INET_MAX_BYTES_READ 1024 +#endif /*CM_INET_FLUSH_RECV_BUF*/ + +/* cm_inet_h_001.main_20 Added new defines for returning unreachable failure */ +#define RNETFAILED 27 + +#define CM_INET_INADDR_ANY INADDR_ANY /* accepts any address */ + +#ifdef CM_INET2 + +/* protocol values */ +#define CM_INET_PROTO_IP IPPROTO_IP /* IP protocol */ +#define CM_INET_PROTO_ICMP IPPROTO_ICMP /* ICMP protocol */ +#define CM_INET_PROTO_TCP IPPROTO_TCP /* TCP protocol */ +#define CM_INET_PROTO_UDP IPPROTO_UDP /* UDP protocol */ +#define CM_INET_PROTO_RAW IPPROTO_RAW /* Raw protocol */ +#define CM_INET_PROTO_SCTP 132 /* SCTP protocol */ +/*cm_inet_h_001.main_21 Updated for TUCL 2.1 Release (Kernel SCTP Support) */ +#ifdef CM_LKSCTP +#define CM_INET_PROTO_LKSCTP IPPROTO_SCTP /* SCTP protocol */ +#endif +#define CM_INET_PROTO_RSVP 46 /* RSVP protocol */ + +#ifdef IPV6_SUPPORTED +#define CM_INET_LEVEL_IPV6 IPPROTO_IPV6 /* IP V6 protocol */ +#define CM_INET_PROTO_IPV6 IPPROTO_IPV6 /* IP V6 protocol */ +#define CM_INET_PROTO_ICMPV6 IPPROTO_ICMPV6 /* ICMP V6 protocol */ +#endif /* IPV6_SUPPORTED */ + +#endif /* CM_INET2 */ + +/* macros */ + +/* macros to manipulate and checking a socket file descriptor set */ +#define CM_INET_FD_SET(_sockFd, _fdSet) FD_SET((_sockFd)->fd, _fdSet) +#define CM_INET_FD_CLR(_sockFd, _fdSet) FD_CLR((_sockFd)->fd, _fdSet) +#define CM_INET_FD_ISSET(_sockFd, _fdSet) FD_ISSET((_sockFd)->fd, _fdSet) +#define CM_INET_FD_ZERO(_fdSet) FD_ZERO(_fdSet) + +/* macros to convert from network to host byteorder and vice versa */ +#define CM_INET_NTOH_U32(_long) ntohl(_long) +#define CM_INET_HTON_U32(_long) htonl(_long) +#define CM_INET_NTOH_U16(_word) ntohs(_word) +#define CM_INET_HTON_U16(_word) htons(_word) + +/* peeks a U8 from the given position */ +#define CM_INET_PEEK_U8(_sockFd, _fromAddr, _info, _pos, _octet, _ret) \ + _ret = cmInetPeek(_sockFd, _fromAddr, _info, _pos, sizeof(U8), &_octet) + +/* + * peeks a U16 from the given position (it is supposed that the U16 is + * represented in big endian representation within the data stream) + */ +#define CM_INET_PEEK_U16(_sockFd, _fromAddr, _info, _pos, _word, _ret) \ + { \ + U8 _tempWord[2]; \ + \ + _ret = cmInetPeek(_sockFd, _fromAddr, _info, _pos, sizeof(U16), _tempWord); \ + if (_ret == ROK) \ + { \ + _word = ((_tempWord[0] << 8) + (_tempWord[1])); \ + } \ + } + +/* + * peeks a U32 from the given position (it is supposed that the U32 is + * represented in big endian representation within the data stream) + */ +#define CM_INET_PEEK_U32(_sockFd, _fromAddr, _info, _pos, _long, _ret) \ + { \ + U8 _tempLong[4]; \ + \ + _ret = cmInetPeek(_sockFd, _fromAddr, _info, _pos, sizeof(U32), _tempLong); \ + if (_ret == ROK) \ + { \ + _long = ((_tempLong[0] << 24) + (_tempLong[1] << 16) \ + + (_tempLong[2] << 8) + _tempLong[3]); \ + } \ + } + +/* tests if socket descriptor is invalide */ +#ifdef WIN32 +#define CM_INET_INV_SOCK_FD(_sockFd) ((_sockFd)->fd == INVALID_SOCKET) +#else +#define CM_INET_INV_SOCK_FD(_sockFd) ((_sockFd)->fd < 0) +#endif /* WIN32 */ + +/* tests if two socket descriptor are equal */ +#define CM_INET_SOCK_SAME(_s1, _s2, _ret) \ + { \ + _ret = FALSE; \ + if ((_s1->fd == _s2->fd) && \ + (_s1->blocking == _s2->blocking) && \ + (_s1->type == _s2->type)) \ + { \ + _ret = TRUE; \ + } \ + } + +/* set socket descriptor to an invalid (uninitialized) value */ +#ifdef WIN32 +#define CM_INET_SET_INV_SOCK_FD(_sockFd) ((_sockFd)->fd = INVALID_SOCKET) +#else +#define CM_INET_SET_INV_SOCK_FD(_sockFd) ((_sockFd)->fd = -1) +#endif /* WIN32 */ + +/* This macro frees ipHdrParm structure memory allocated to hold ipv6 + * extension headers */ + +#ifdef IPV6_OPTS_SUPPORTED +#define CM_INET_FREE_IPV6_HDRPARM(_region, _pool, _hdrParmIpv6) \ +{ \ + U8 numOpts; \ + if( _hdrParmIpv6->ipv6ExtHdr.hbhHdrPrsnt) \ + { \ + for(numOpts = _hdrParmIpv6->ipv6ExtHdr.hbhOptsArr.numHBHOpts; \ + numOpts > 0; numOpts--) \ + { \ + if (_hdrParmIpv6->ipv6ExtHdr.hbhOptsArr.hbhOpts[numOpts - 1].length) \ + SPutSBuf(_region, _pool, (Data *)_hdrParmIpv6->ipv6ExtHdr. \ + hbhOptsArr.hbhOpts[numOpts - 1].value, (Size)(_hdrParmIpv6-> \ + ipv6ExtHdr.hbhOptsArr.hbhOpts[numOpts - 1].length)); \ + SPutSBuf(_region, _pool, (Data *)&_hdrParmIpv6->ipv6ExtHdr. \ + hbhOptsArr.hbhOpts[numOpts - 1], \ + (Size)sizeof(CmInetIpv6HBHHdr)); \ + } \ + } \ + if(_hdrParmIpv6->ipv6ExtHdr.destOptsPrsnt) \ + { \ + for(numOpts = _hdrParmIpv6->ipv6ExtHdr.destOptsArr.numDestOpts; \ + numOpts > 0; numOpts--) \ + { \ + SPutSBuf(_region, _pool, (Data *)_hdrParmIpv6->ipv6ExtHdr. \ + destOptsArr.destOpts[numOpts - 1].value, (Size)(_hdrParmIpv6-> \ + ipv6ExtHdr.destOptsArr.destOpts[numOpts - 1].length)); \ + SPutSBuf(_region, _pool, (Data *)&_hdrParmIpv6->ipv6ExtHdr. \ + destOptsArr.destOpts[numOpts - 1], \ + (Size)sizeof(CmInetIpv6DestOptsHdr)); \ + } \ + } \ + if( _hdrParmIpv6->ipv6ExtHdr.rtOptsPrsnt) \ + { \ + SPutSBuf(_region, _pool, \ + (Data *)_hdrParmIpv6->ipv6ExtHdr.rtOptsArr.ipv6Addrs, \ + (Size)(_hdrParmIpv6->ipv6ExtHdr.rtOptsArr.numAddrs * 16)); \ + } \ +} +/* Use the function for HBH options for destinations options as both ext + * header has similar format */ + +#define cmInet6BuildRecvDstOptsArr(cmsgPtr, cmsg_len, destOptsArr, hdrId, info) \ + cmInet6BuildRecvHopOptsArr(cmsgPtr, cmsg_len, \ + (CmInetIpv6HBHHdrArr *)destOptsArr, hdrId, info) + +#define cmInet6BuildSendDestOpts(destOptsArr, cmsgData, curMsgIdx, hdrId) \ + cmInet6BuildSendHBHOpts((CmInetIpv6HBHHdrArr *)destOptsArr, \ + cmsgData, curMsgIdx, hdrId) + +#endif /* IPV6_OPTS_SUPPORTED */ + +#ifdef IPV6_SUPPORTED +#define CM_INET_COPY_IPV6ADDR(_addrToFill, _fromAddr) \ +{ \ + (Void)cmMemcpy((U8 *)_addrToFill, (U8 *)_fromAddr, sizeof(CmInetIpAddr6)); \ +} + +#if (defined(SUNOS) || defined(HPOS) || defined(SS_VW)) + +#define CM_INET_ICMP6_FILTER_SETPASSALL(_icmp6Filter) \ +{ \ + ICMP6_FILTER_SETPASSALL(&_icmp6Filter); \ +} + +#define CM_INET_ICMP6_FILTER_SETBLOCKALL(_icmp6Filter) \ +{ \ + ICMP6_FILTER_SETBLOCKALL(&_icmp6Filter); \ +} + +#define CM_INET_ICMP6_FILTER_SETPASS(msgType, _icmp6Filter) \ +{ \ + ICMP6_FILTER_SETPASS(msgType, &_icmp6Filter); \ +} + +#define CM_INET_ICMP6_FILTER_SETBLOCK(msgType, _icmp6Filter) \ +{ \ + ICMP6_FILTER_SETBLOCK(msgType, &_icmp6Filter); \ +} + +#define CM_INET_ICMP6_FILTER_WILLPASS(msgType, _icmp6Filter) \ +{ \ + ICMP6_FILTER_WILLPASS(msgType, &_icmp6Filter); \ +} + +#define CM_INET_ICMP6_FILTER_WILLBLOCK(msgType, _icmp6Filter) \ +{ \ + ICMP6_FILTER_WILLBLOCK(msgType, &_icmp6Filter); \ +} +#endif /* SUNOS || HPOS */ +#endif /* IPV6_SUPPORTED */ + +#define cmPkCmInetIpAddr(x, mBuf) SPkU32(x, mBuf) /* pack IP Address */ +#define cmUnpkCmInetIpAddr(x, mBuf) SUnpkU32(x, mBuf) /* unpacks IP Address */ + +#ifdef SS_VW +#define CM_COPY_VWIPADDR(vwIpAddr, addr) \ + { \ + (Void)cmMemcpy((U8 *)addr, (U8 *)&vwIpAddr, sizeof(S32)); \ + } +#endif + +/* Changes for peeking into the file descriptor set */ +#ifdef WIN32 +#define CM_INET_FDSETINFO_RESET(_fdSetInfo) \ +{ \ + _fdSetInfo->numFds = 0; \ +} +#else +#define CM_INET_FDSETINFO_RESET(_fdSetInfo) \ +{ \ + _fdSetInfo->arIdx = 0; \ +} +#endif /* WIN32 */ + +/* convert a hex character in ASCII to int format */ +#define CM_INET_ATOH(_intVal, _asciiVal) \ +{ \ + if ((_asciiVal >='a') && (_asciiVal <='f')) \ + { \ + _intVal = (16 * _intVal) + (_asciiVal - 'a' +10 ); \ + } \ + else if ((_asciiVal >='A') && (_asciiVal <= 'F')) \ + { \ + _intVal = (16 * _intVal) + (_asciiVal - 'A' +10 ); \ + } \ + else \ + { \ + _intVal = (16 * _intVal) + (_asciiVal - '0'); \ + } \ +} + +/* convert a decimal digit in ASCII to int format */ +#define CM_INET_ATOI(_intVal, _asciiVal) \ +{ \ + _intVal = (10 * _intVal) + (_asciiVal - '0'); \ +} + + +#define CM_INET_GET_IPV4_ADDR_FRM_STRING(_value, _str) \ +{ \ + U16 _hiWord; \ + U16 _loWord; \ + \ + _hiWord = 0; \ + _loWord = 0; \ + _hiWord = PutHiByte(_hiWord, (_str[0])); \ + _hiWord = PutLoByte(_hiWord, (_str[1])); \ + _loWord = PutHiByte(_loWord, (_str[2])); \ + _loWord = PutLoByte(_loWord, (_str[3])); \ + _value = PutLoWord(_value, _loWord); \ + _value = PutHiWord(_value, _hiWord); \ +} + +/* cm_inet_h_001.main_27: Added error codes*/ +#define CMINETLOGERROR(errCls, errCode, errVal, errDesc) \ + SLogError(ENTNC, INSTNC, 0, __FILE__, __LINE__, \ + errCls, errCode, errVal, errDesc ) + +#define ECMINET 0 +#define ECMINET001 (ECMINET + 1) /*cm_inet.c : 819*/ +#define ECMINET002 (ECMINET + 2) /*cm_inet.c : 871*/ +#define ECMINET003 (ECMINET + 3) /*cm_inet.c : 993*/ +#define ECMINET004 (ECMINET + 4) /*cm_inet.c : 997*/ +#define ECMINET005 (ECMINET + 5) /*cm_inet.c : 1081*/ +#define ECMINET006 (ECMINET + 6) /*cm_inet.c : 1188*/ +#define ECMINET007 (ECMINET + 7) /*cm_inet.c : 1226*/ +#define ECMINET008 (ECMINET + 8) /*cm_inet.c : 1335*/ +#define ECMINET009 (ECMINET + 9) /*cm_inet.c : 1423*/ +#define ECMINET010 (ECMINET + 10) /*cm_inet.c : 1566*/ +#define ECMINET011 (ECMINET + 11) /*cm_inet.c : 1659*/ +#define ECMINET012 (ECMINET + 12) /*cm_inet.c : 1783*/ +#define ECMINET013 (ECMINET + 13) /*cm_inet.c : 1867*/ +#define ECMINET014 (ECMINET + 14) /*cm_inet.c : 1987*/ +#define ECMINET015 (ECMINET + 15) /*cm_inet.c : 2292*/ +#define ECMINET016 (ECMINET + 16) /*cm_inet.c : 2310*/ +#define ECMINET017 (ECMINET + 17) /*cm_inet.c : 2571*/ +#define ECMINET018 (ECMINET + 18) /*cm_inet.c : 2811*/ +#define ECMINET019 (ECMINET + 19) /*cm_inet.c : 2955*/ +#define ECMINET020 (ECMINET + 20) /*cm_inet.c : 2960*/ +#define ECMINET021 (ECMINET + 21) /*cm_inet.c : 3020*/ +#define ECMINET022 (ECMINET + 22) /*cm_inet.c : 3119*/ +#define ECMINET023 (ECMINET + 23) /*cm_inet.c : 3412*/ +#define ECMINET024 (ECMINET + 24) /*cm_inet.c : 3606*/ +#define ECMINET025 (ECMINET + 25) /*cm_inet.c : 3709*/ +#define ECMINET026 (ECMINET + 26) /*cm_inet.c : 3723*/ +#define ECMINET027 (ECMINET + 27) /*cm_inet.c : 3747*/ +#define ECMINET028 (ECMINET + 28) /*cm_inet.c : 4148*/ +#define ECMINET029 (ECMINET + 29) /*cm_inet.c : 4216*/ +#define ECMINET030 (ECMINET + 30) /*cm_inet.c : 4227*/ +#define ECMINET031 (ECMINET + 31) /*cm_inet.c : 4240*/ +#define ECMINET032 (ECMINET + 32) /*cm_inet.c : 4343*/ +#define ECMINET033 (ECMINET + 33) /*cm_inet.c : 3932*/ +#define ECMINET034 (ECMINET + 34) /*cm_inet.c : 4788*/ +#define ECMINET035 (ECMINET + 35) /*cm_inet.c : 5071*/ +#define ECMINET036 (ECMINET + 36) /*cm_inet.c : 5616*/ +#define ECMINET037 (ECMINET + 37) /*cm_inet.c : 5735*/ +#define ECMINET038 (ECMINET + 38) /*cm_inet.c : 5806*/ +#define ECMINET039 (ECMINET + 39) /*cm_inet.c : 5910*/ +#define ECMINET040 (ECMINET + 40) /*cm_inet.c : 6797*/ +#define ECMINET041 (ECMINET + 41) /*cm_inet.c : 6842*/ +#define ECMINET042 (ECMINET + 42) /*cm_inet.c : 6971*/ +#define ECMINET043 (ECMINET + 43) /*cm_inet.c : 7090*/ +#define ECMINET044 (ECMINET + 44) /*cm_inet.c : 7166*/ +#define ECMINET045 (ECMINET + 45) /*cm_inet.c : 7175*/ +#define ECMINET046 (ECMINET + 46) /*cm_inet.c : 7201*/ +#define ECMINET047 (ECMINET + 47) /*cm_inet.c : 7218*/ +#define ECMINET048 (ECMINET + 48) /*cm_inet.c : 7322*/ +#define ECMINET049 (ECMINET + 49) /*cm_inet.c : 7347*/ +#define ECMINET050 (ECMINET + 50) /*cm_inet.c : 7371*/ +#define ECMINET051 (ECMINET + 51) /*cm_inet.c : 7810*/ +#define ECMINET052 (ECMINET + 52) /*cm_inet.c : 8416*/ +#define ECMINET053 (ECMINET + 53) /*cm_inet.c : 8422*/ +#define ECMINET054 (ECMINET + 54) /*cm_inet.c : 8610*/ +#define ECMINET055 (ECMINET + 55) /*cm_inet.c : 8703*/ +#define ECMINET056 (ECMINET + 56) /*cm_inet.c : 8768*/ +#define ECMINET057 (ECMINET + 57) /*cm_inet.c : 1104*/ +#define ECMINET058 (ECMINET + 58) /*cm_inet.c : 1125*/ +#define ECMINET059 (ECMINET + 59) /*cm_inet.c : 1209*/ +#define ECMINET060 (ECMINET + 60) /*cm_inet.c : 1313*/ +#define ECMINET061 (ECMINET + 61) /*cm_inet.c : 1355*/ +#define ECMINET062 (ECMINET + 62) /*cm_inet.c : 1444*/ +#define ECMINET063 (ECMINET + 63) /*cm_inet.c : 1534*/ +#define ECMINET064 (ECMINET + 64) /*cm_inet.c : 1803*/ +#define ECMINET065 (ECMINET + 65) /*cm_inet.c : 1967*/ +#define ECMINET066 (ECMINET + 66) /*cm_inet.c : 2627*/ +#define ECMINET067 (ECMINET + 67) /*cm_inet.c : 2757*/ +#define ECMINET068 (ECMINET + 68) /*cm_inet.c : 4845*/ +#define ECMINET069 (ECMINET + 69) /*cm_inet.c : 5385*/ +/* cm_inet_h_001.main_28: Added new error code ECMINET070 */ +#define ECMINET070 (ECMINET + 70) /*cm_inet.c : 5385*/ +/* cm_inet_h_001.main_29: Added new error code ECMINET070 */ +#define ECMINET071 (ECMINET + 71) /*cm_inet.c : xxxx*/ +#define ECMINETXXX ECMINET /*cm_inet.c : xxxx*/ + + +#endif /* __CMINETH__ */ +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/cm/cm_inet.x b/src/cm/cm_inet.x new file mode 100644 index 000000000..f6eeeebfd --- /dev/null +++ b/src/cm/cm_inet.x @@ -0,0 +1,768 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/********************************************************************20** + + Name: common Internet socket library + + Type: header file + + Desc: common library for Internet sockets + + File: cm_inet.x + +*********************************************************************21*/ + + +/* + * This software may be combined with the following TRILLIUM + * software: + * + * part no. description + * -------- ---------------------------------------------- + * 1000151 TCAP over TCP/IP + */ + +/* cm_inet_x_001.main_29: SS_4GMX_LCORE changes */ +#ifdef SS_4GMX_LCORE +#define __CMINETX__ 1 +#endif +#ifndef __CMINETX__ +#define __CMINETX__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#ifdef WIN32 +#ifdef SS_WINCE +#ifndef IN +#define IN +#include +#undef IN +#else /*IN*/ +#include +#endif /*IN*/ +#else /*SS_WINCE*/ + /* cm_inet_x_001.main_28: Added #define IN */ +#ifndef IN +#define IN +#include +#undef IN +#else /*IN*/ +#include +#endif /*IN*/ +#endif /* SS_WINCE */ +#else +#include +#ifdef SS_LINUX +#include +#include +#endif /* SS_LINUX */ +#include +#ifdef SS_PS +#include +#else +#include +#include +#endif /* SS_PS */ +#endif /* WIN32 */ + +#ifdef IPV6_SUPPORTED +#if (defined(SUNOS) || defined(HPOS)) +#include +#endif /* SUNOS || HPOS */ +#endif /* IPV6_SUPPORTED */ + + /* cm_inet_x_001.main_27 : Added header file inclusion */ +#if (defined(SS_VW) && defined(SS_VW6_7)) +#include +#include +#include +#endif + +/* cm_inet_x_001.main_21:Added wrapper function for getaddrinfo and freeaddrinfo */ +#if (!defined(SS_VW) && !defined(SS_PS) && !defined(WIN32)) +#include +#endif + +/* Redifining the CmInetIpAddr & CmInetIpAddr6 */ +typedef CmIpAddr CmInetIpAddr; /* 4 byte IP address */ +#ifdef IPV6_SUPPORTED +typedef CmIpAddr6 CmInetIpAddr6; /* 16 byte IPV6 address */ +#endif /* IPV6_SUPPORTED */ + +typedef struct cmInetIpAddrTbl +{ + U16 count; /* Number of addresses in table */ + CmInetIpAddr netAddr[CM_INET_IPV4_NUM_ADDR]; /* Address table */ +}CmInetIpAddrTbl; + +typedef CmInetIpAddrTbl CmInetIpv4AddrArr; + +#ifdef IPV6_SUPPORTED +typedef struct cmInetIpv6AddrArr +{ + U16 count; /* Number of addresses in array */ + CmInetIpAddr6 netAddr[CM_INET_IPV6_NUM_ADDR]; /* Address array */ +}CmInetIpv6AddrArr; +#endif /* IPV6_SUPPORTED */ + +typedef struct cmInetIpAddrArr +{ + U8 type; + union + { + CmInetIpv4AddrArr ipv4AddrArr; +#ifdef IPV6_SUPPORTED + CmInetIpv6AddrArr ipv6AddrArr; +#endif /* IPV6_SUPPORTED */ + } u; + +} CmInetIpAddrArr; + + +/* Adding a type for socket Address */ +typedef struct cmInetCmnSockAddr +{ + U32 type; + U32 len; + union + { + struct sockaddr_in addr; +#ifdef IPV6_SUPPORTED + struct sockaddr_in6 addr6; +#endif + }u; +}CmInetCmnSockAddr; + + + +/* Adding a type for socket descriptors */ +#ifdef WIN32 +typedef SOCKET CmInetFdType; +#else +#if (defined(SUNOS) || defined(HPOS)) +typedef S32 CmInetFdType; +#else +#ifdef SS_LINUX +typedef S32 CmInetFdType; +#else +typedef S16 CmInetFdType; +#endif /* SS_LINUX */ +#endif /* SUNOS || HPOS */ +#endif /* WIN32 */ +/* cm_inet_x_001.main_29 Poll Implementation Changes */ +typedef struct pollfd CmInetPollFd; + +typedef struct cmInetFd /* trillium socket file descriptor */ +{ + CmInetFdType fd; /* socket descriptor */ + U8 blocking; /* true if socket is blocking */ + U8 type; /* socket type (stream|datagram) */ + +#ifdef IPV6_SUPPORTED + U8 protType; /* indicates whether IPv4 or IPv6 socket */ +#endif /* IPV6_SUPPORTED */ +}CmInetFd; + +typedef fd_set CmInetFdSet; /* socket file descriptor set */ + +#ifdef IPV6_SUPPORTED +/* IPV4 Address */ +typedef struct cmInetIpv4Addr +{ + U16 port; + CmInetIpAddr address; +} CmInetIpv4Addr; + +/* IPV6 Address */ +typedef struct cmInetIpv6Addr +{ + U16 port; + CmInetIpAddr6 ipv6NetAddr; +} CmInetIpv6Addr; + +typedef struct CmInetAddr /* Internet address */ +{ + U8 type; /* type of address present in the union */ + union + { + CmInetIpv4Addr ipv4Addr; /* IPV4 Address */ + CmInetIpv6Addr ipv6Addr; /* IPV6 Address */ + }u; +}CmInetAddr; + +typedef struct cmInetMCastInf6 /* multicast interface information */ +{ + CmInetIpAddr6 mCastAddr; /* multicast address */ + U32 localInf; /* local interface */ +} CmInetMCastInf6; +#else +/* IPV4 Address */ +typedef struct cmInetAddr1 +{ + U16 port; + CmInetIpAddr address; +} CmInetAddr; +typedef CmInetAddr CmInetIpv4Addr; +#endif /* IPV6_SUPPORTED */ + +typedef struct cmInetMemInfo /* memory information */ +{ + Region region; /* memory region */ + Pool pool; /* memory pool */ +} CmInetMemInfo; + +typedef struct cmInetMCastInf /* multicast information */ +{ + CmInetIpAddr mCastAddr; /* multicast class D address */ + CmInetIpAddr localAddr; /* local interface address */ +}CmInetMCastInf; + +/* this is the same structure as cmNetAddr in cm_tpt.x + used here for cmInetConvertStrToIpAddr */ +typedef struct cmInetNetAddr +{ + U8 type; /* type of network address */ + union + { + CmInetIpAddr ipv4NetAddr; /* IP network address */ +#ifdef IPV6_SUPPORTED + CmInetIpAddr6 ipv6NetAddr; /* IPv6 network address */ +#endif /* IPV6_SUPPORTED */ + }u; +} CmInetNetAddr; + +/*cm_inet_x_001.main_23 Updated for TUCL 2.1 Release (Kernel SCTP Support) */ +#ifdef CM_LKSCTP +typedef struct cmInetNetAddrLst +{ + U8 count; + CmInetNetAddr addrs[CM_INET_NUM_NET_ADDR]; +} CmInetNetAddrLst; +#endif + +#ifdef LOCAL_INTF +/* used to pass local interface (on which packet was received) to upper user */ +typedef struct cmInetLocalInf +{ + Bool intfPrsnt; /* bool to indicate if this is a valid loc intf */ + U32 localIf; /* interface index IPv4(32 bit) or IPv6(32 bit) */ + CmInetNetAddr localIfAddr; /* interface address */ +}CmInetLocalInf; +#endif /* LOCAL_INTF */ + +#ifdef IPV6_SUPPORTED +#if (defined(SUNOS) || defined(HPOS) || defined(SS_VW)) +typedef struct icmp6_filter CmInetIcmp6Filter; +#endif /* SUNOS || HPOS */ +#endif /* IPV6_SUPPORTED */ + +/* New data structures needed to support 3 types of IPV6 extension + * headers - HBH, Destination Option & Route Header */ +#ifdef IPV6_SUPPORTED +#ifdef IPV6_OPTS_SUPPORTED + +/* structure to hold TLV of each HBH option */ +typedef struct cmInetIpv6HBHHdr +{ + U8 type; + U8 length; + U8 *value; +} CmInetIpv6HBHHdr; + +/* structure to hold TLV of each Destination option */ +typedef struct cmInetIpv6DestOptsHdr +{ + U8 type; + U8 length; + U8 *value; +} CmInetIpv6DestOptsHdr; + +/* structure to hold IPV6 addresses of the Route header */ +typedef struct cmInetIpv6RtHdr +{ + U8 numAddrs; + U32 slMap; + CmInetIpAddr6 *ipv6Addrs; +} CmInetIpv6RtHdr; + +/* array of all HBH options */ +typedef struct cmInetIpv6HBHHdrArr +{ + U8 numHBHOpts; + CmInetIpv6HBHHdr *hbhOpts; +} CmInetIpv6HBHHdrArr; + +/* array of all Destination options */ +typedef struct cmInetIpv6DestOptsArr +{ + U8 numDestOpts; + CmInetIpv6DestOptsHdr *destOpts; +} CmInetIpv6DestOptsArr; + +/* structure having 3 substructures for 3 types of ext headers */ +typedef struct cmInetIpv6ExtHdr +{ + Bool hbhHdrPrsnt; + CmInetIpv6HBHHdrArr hbhOptsArr; + Bool destOptsPrsnt; + CmInetIpv6DestOptsArr destOptsArr; + Bool rtOptsPrsnt; + CmInetIpv6RtHdr rtOptsArr; +} CmInetIpv6ExtHdr; + +/* structure for type 0 Route Header */ +typedef struct cmInetIpv6RtHdr0 +{ + U8 ip6r0_nextHdr; + U8 ip6r0_hdrExtLen; + U8 ip6r0_type; + U8 ip6r0_segLeft; + U32 ip6r0_resrvAndSLmap; /* first byte reserved, last 3 srtict/loose map */ +} CmInetIpv6RtHdr0; +#endif /* IPV6_OPTS_SUPPORTED */ + +typedef struct cmInetIpv6HdrParm +{ + TknU8 ttl; + CmInetNetAddr srcAddr6;/* used to set src addr on sending pkt(IPv6) */ +#ifdef IPV6_OPTS_SUPPORTED + CmInetIpv6ExtHdr ipv6ExtHdr; +#endif /* IPV6_OPTS_SUPPORTED */ +} CmInetIpv6HdrParm; +#endif /* IPV6_SUPPORTED */ + +typedef struct cmInetIpv4HdrParm +{ + TknU8 proto; /* Protocol value */ + TknU8 dfBit; /* Don't fragment flag */ + TknU8 tos; /* Type of Service */ + TknU8 ttl; /* Time to Live */ + /* added new field */ +#ifdef IPV4_OPTS_SUPPORTED + TknStr64 ipv4HdrOpt; /* IPV4 hdr opt */ +#endif /* IPV4_OPTS_SUPPORTED */ +} CmInetIpv4HdrParm; +typedef struct cmInetIpHdrParm +{ + U8 type; + union + { + CmInetIpv4HdrParm hdrParmIpv4; /* IPv4 header parameters */ +#ifdef IPV6_SUPPORTED + CmInetIpv6HdrParm ipv6HdrParm; +#endif /* IPV6_SUPPORTED */ + } u; +} CmInetIpHdrParm; + +/* New data structures to peek into the file descriptor set. */ +/* fdSetInfo structure */ +#ifdef WIN32 +typedef struct cmInetFdSetInfo +{ + Bool initDone; /* Initialisation done */ + U32 numFds; /* Number of file descriptors scanned */ +} CmInetFdSetInfo; +#else +#if (defined(SUNOS) || defined(SS_LINUX) || defined(SS_VW) || defined(HPOS)) +typedef struct cmInetFdSetInfo +{ + Bool initDone; /* Initialisation done */ + Bool bigEndian; /* Big endian architecture */ + U16 arIdx; /* Current index in fd_set array */ + U32 numArElems; /* Number of array elements */ + U8 ar[256]; /* Array of bit positions */ +} CmInetFdSetInfo; +#endif /* SUNOS || SS_LINUX || SS_VW */ +#endif /* WIN32 */ + +/*cm_inet_x_001.main_23 Updated for TUCL 2.1 Release (Kernel SCTP Support) */ +#ifdef CM_LKSCTP +typedef struct cmInetSctpSndRcvInfo +{ + U16 stream; + U16 ssn; + U16 flags; + U32 ppid; + U32 context; + U32 timetolive; + U32 tsn; + U32 cumtsn; + U32 assocId; +} CmInetSctpSndRcvInfo; + +typedef struct cmInetSctpNotification +{ + struct + { + U16 nType; + U16 nFlags; + U32 nLen; + } header; + + union + { + struct + { + U16 state; + U16 error; + U16 outStreams; + U16 inStreams; + U32 assocId; + U8 *info; + }assocChange; + struct + { + CmInetNetAddr addr; + S32 state; + S32 error; + U32 assocId; + }paddrChange; + struct + { + U16 error; + U32 assocId; + U8 *data; + }remoteErr; + struct + { + U32 error; + CmInetSctpSndRcvInfo info; + U32 assocId; + U8 *data; + }sndFailed; + struct + { + U32 assocId; + }shutdownEvt; + struct + { + U32 adaptationInd; + U32 assocId; + }adaptationEvt; + struct + { + U32 indication; + U32 assocId; + }pdapiEvt; + }u; +}CmInetSctpNotification; + +typedef struct cmInetSockLinger +{ + Bool enable; + U32 lingerTime; +} CmInetSockLinger; + +typedef struct cmInetSctpSockEvent +{ + Bool dataIoEvent; + Bool associationEvent; + Bool addressEvent; + Bool sendFailureEvent; + Bool peerErrorEvent; + Bool shutdownEvent; + Bool partialDeliveryEvent; + Bool adaptationLayerEvent; +} CmInetSctpSockEvent; + +typedef struct cmInetSctpPeerAddrParams +{ + U32 assocId; + struct + { + Bool addrPres; + CmInetNetAddr addr; + U16 port; + }s; + U32 pathMaxRxt; + U32 pathMtu; + U32 sackDelay; + U8 pmtudFlag; + U8 sackDelayFlag; + U8 hbEnblFlag; + U32 hbInterval; +} CmInetSctpPeerAddrParams; + +typedef struct cmInetSctpPrimAddr +{ + U32 assocId; + CmInetNetAddr addr; + U16 port; +}CmInetSctpPrimAddr; + +typedef struct cmInetSctpPeerAddrInfo +{ + U32 assocId; + CmInetNetAddr addr; + U16 port; + Bool isActive; + U32 cwnd; + U32 srtt; + U32 rto; + U32 mtu; +}CmInetSctpPeerAddrInfo; + +typedef struct cmInetSctpStatus +{ + U32 assocId; + S32 state; + U32 rwnd; + U16 unackdata; + U16 penddata; + U16 instrms; + U16 outstrms; + U32 fragPoint; + CmInetSctpPeerAddrInfo primary; +}CmInetSctpStatus; + +/*cm_inet_x_001.main_24 Updated for the support of configurable RTO parameters, + HBeat value Max retransmissions (Init, Path, Association)*/ +typedef struct cmInetSctpRtoInfo +{ + U32 assocId; + U32 rtoInitial; + U32 rtoMax; + U32 rtoMin; +}CmInetSctpRtoInfo; + +typedef struct cmInetSctpInitMsg +{ + U16 maxInitReTx; + U16 maxInitTimeout; + U16 maxInstreams; + U16 numOstreams; +}CmInetSctpInitMsg; + +typedef struct cmInetSctpAssocParams +{ + U32 assocId; + U16 assocMaxReTx; + U16 numberOfPeerDest; + U32 peerRwnd; + U32 localRwnd; + U32 cookieLife; +}CmInetSctpAssocParams; + +#endif + +/* added a new type CmInetSockAddr */ +#ifdef SUNOS +#ifdef SS_LINUX +typedef struct iovec CmInetIovec; +#else +typedef iovec_t CmInetIovec; +#endif /* SS_LINUX */ +typedef struct sockaddr CmInetSockAddr; +#else +#ifdef HPOS +typedef struct iovec CmInetIovec; +typedef struct sockaddr CmInetSockAddr; +#else +#ifdef SS_VW +typedef struct iovec CmInetIovec; +typedef struct sockaddr CmInetSockAddr; +#else +#ifdef WIN32 +typedef struct sockaddr CmInetSockAddr; +#else +#ifdef SS_PS +typedef struct iovec CmInetIovec; +typedef struct sockaddr_in CmInetSockAddr; +#endif /* SS_PS */ +#endif /* WIN32 */ +#endif /* SS_VW */ +#endif /* HPOS */ +#endif /* SUNOS */ + +#ifdef SUNOS +typedef struct sockaddr_in6 CmInet6SockAddr; +typedef struct sockaddr_in CmInet4SockAddr; +#endif /* SUNOS */ + +/* addrInfo structure */ +#if (!defined(SS_VW) && !defined(SS_PS) && !defined(WIN32)) +typedef struct addrinfo CmInetAddrInfo; +#endif /* SS_VW | SS_PS | WIN32*/ + +/* socket function prototypes */ + +#ifdef CM_INET2 +#ifdef IPV6_SUPPORTED +EXTERN S16 cmInetSocket ARGS((U8 type, CmInetFd *sockFd, U8 protocol, + U8 family)); +#else +EXTERN S16 cmInetSocket ARGS((U8 type, CmInetFd *sockFd, U8 protocol)); +#endif /* IPV6_SUPPORTED */ +#else /* CM_INET2 */ +EXTERN S16 cmInetSocket ARGS((U8 type, CmInetFd *sockFd)); +#endif /* CM_INET2 */ + +/* cm_inet_x_001.main_22 1. Added new interface - cmInetFlushRecvBuf() + to flush the data from socket receive buffer. */ +#ifdef CM_INET_FLUSH_RECV_BUF +EXTERN S16 cmInetFlushRecvBuf ARGS((CmInetFd *sockFd, + MsgLen *len, + S32 flags)); +#endif /* CM_INET_FLUSH_RECV_BUF*/ + +EXTERN S16 cmInetBind ARGS((CmInetFd *sockFd, CmInetAddr *myAddr)); +EXTERN S16 cmInetConnect ARGS((CmInetFd *sockFd, CmInetAddr *servAddr)); +EXTERN S16 cmInetListen ARGS((CmInetFd *sockFd, S16 backLog)); +EXTERN S16 cmInetAccept ARGS((CmInetFd *sockFd, CmInetAddr *fromAddr, + CmInetFd *newSockFd)); +#ifdef IPV6_OPTS_SUPPORTED +#ifdef LOCAL_INTF +EXTERN S16 cmInetRecvMsg ARGS((CmInetFd *sockFd, CmInetAddr *dstAddr, + CmInetMemInfo *info, Buffer **mPtr, + MsgLen *len, CmInetIpHdrParm *ipHdrParams, + CmInetLocalInf *localIf, S32 flags)); +#else +EXTERN S16 cmInetRecvMsg ARGS((CmInetFd *sockFd, CmInetAddr *dstAddr, + CmInetMemInfo *info, Buffer **mPtr, + MsgLen *len, CmInetIpHdrParm *ipHdrParams, + S32 flags)); +#endif /* LOCAL_INTF */ +#else +#ifdef LOCAL_INTF +EXTERN S16 cmInetRecvMsg ARGS((CmInetFd *sockFd, CmInetAddr *dstAddr, + CmInetMemInfo *info, Buffer **mPtr, + MsgLen *len, CmInetLocalInf *localIf, + S32 flags)); +#else +EXTERN S16 cmInetRecvMsg ARGS((CmInetFd *sockFd, CmInetAddr *dstAddr, + CmInetMemInfo *info, Buffer **mPtr, + MsgLen *len, S32 flags)); +#endif /* LOCAL_INTF */ +#endif /* IPV6_OPTS_SUPPORTED */ +EXTERN S16 cmInetSendDscpMsg ARGS((CmInetFd *sockFd, CmInetAddr *dstAddr, + CmInetMemInfo *info, Buffer *mBuf, MsgLen *len, + CmInetIpHdrParm *ipHdrParams, S16 flags)); + +#ifdef IPV6_OPTS_SUPPORTED +EXTERN S16 cmInetSendMsg ARGS((CmInetFd *sockFd, CmInetAddr *dstAddr, + CmInetMemInfo *info, Buffer *mBuf, MsgLen *len, + CmInetIpHdrParm *ipHdrParams, S16 flags)); +#else +EXTERN S16 cmInetSendMsg ARGS((CmInetFd *sockFd, CmInetAddr *dstAddr, + CmInetMemInfo *info, Buffer *mBuf, MsgLen *len, + S16 flags)); +#endif /* IPV6_OPTS_SUPPORTED */ +EXTERN S16 cmInetPeek ARGS((CmInetFd *sockFd, CmInetAddr *fromAddr, + CmInetMemInfo *info, MsgLen dataPos, + MsgLen dataLen, U8 *data)); +/* cm_inet_x_001.main_26: Added new function declaration cmInetPeekNew() */ +EXTERN S16 cmInetPeekNew ARGS((CmInetFd *sockFd, CmInetAddr *fromAddr, + CmInetMemInfo *info, MsgLen dataPos, + MsgLen dataLen, U8 *data)); +EXTERN S16 cmInetClose ARGS((CmInetFd *sockFd)); +EXTERN S16 cmInetShutdown ARGS((CmInetFd *sockFd, S32 howTo)); +EXTERN S16 cmInetSelect ARGS((CmInetFdSet *readFdS, CmInetFdSet *writeFdS, + U32 *mSecTimeout, S16 *numFdS)); +EXTERN S16 cmInetSetOpt ARGS((CmInetFd *sockFd, U32 level, U32 type, + Ptr value)); +EXTERN S16 cmInetGetNumRead ARGS((CmInetFd *sockFd, U32 *dataLen)); +#ifndef SS_PS +EXTERN S16 cmInetGetHostByName ARGS((S8 *hostName, CmInetIpAddrTbl *addrTbl)); +EXTERN S16 cmInetGetIpNodeByName ARGS((S8 *hostName, CmInetIpAddrArr *addrArr)); +EXTERN S16 cmInetAddr ARGS((S8 *asciiAddr, CmInetIpAddr *address)); +EXTERN S16 cmInetNtoa ARGS((CmInetIpAddr address, S8 **asciiAddr)); +EXTERN S16 cmInetPton ARGS((CmInetIpAddr *address, S8 *asciiAddr)); +#ifdef IPV6_SUPPORTED +EXTERN S16 cmInetPton6 ARGS((CmInetIpAddr6 *address6, S8 *asciiAddr)); +#endif /* IPV6_SUPPORTED */ +#endif /* SS_PS */ +/* Function prototypes to peek into file descriptor set. */ +#if (defined(WIN32) || defined(SUNOS) || defined(SS_LINUX) || defined(SS_VW) \ + || defined(HPOS)) +EXTERN S16 cmInetFdSetInfoInit ARGS((CmInetFdSetInfo *fdSetInfo)); +EXTERN S16 cmInetGetFd ARGS((CmInetFdSetInfo *fdSetInfo, CmInetFdSet *fdSet, + CmInetFdType *sockFd)); +#endif /* WIN32 | SUNOS | SS_LINUX | SS_VW | HPOS */ + +EXTERN S16 cmInetGetMemSize ARGS((S32 *size)); +EXTERN S16 cmInetInit ARGS((Void)); +EXTERN S16 cmInetDeInit ARGS((Void)); +EXTERN S16 cmInetGetSockName ARGS((CmInetFd *sockFd, CmInetAddr *locAddr)); + +EXTERN S16 cmInetConvertStrToIpAddr ARGS((U16 len, U8 *val, + CmInetNetAddr *address)); +EXTERN S16 cmInetAsciiToIpv4 ARGS((U8 numBytes, U8 *ipv4Addr, + U16 len, U8 *val)); + + +/* cm_inet_x_001.main_29 Poll Implementation Changes */ +EXTERN S16 cmInetPoll ARGS((CmInetPollFd *pollFdArr,U32 idx,S16 *numFdS,U32 timeout)); +EXTERN S16 cmInetPollSetFd ARGS((CmInetFd *sockFd,CmInetPollFd *pollFdArr,S16 idx, U16 eventMask)); +EXTERN S16 cmInetPollFdIsSet ARGS((CmInetPollFd *pollFdArr, S16 idx, U16 eventMask)); +EXTERN S16 cmInetPollClearFdREvent ARGS((CmInetPollFd *pollFdArr, S16 idx, U16 eventMask)); +EXTERN S16 cmInetPollClearFdEvent ARGS((CmInetPollFd *pollFdArr,S16 idx, U16 eventMask)); +EXTERN S16 cmInetPollDelFd ARGS((CmInetPollFd *pollFdArr, S16 delIdx, S16 crntIdx)); +EXTERN S16 cmInetPollInitFdArr ARGS((CmInetPollFd *pollFdArr)); +EXTERN S16 cmInetNtop ARGS((U8 type,Void *address,S8 *asciiAddr,U32 len)); + + + +/* cm_inet_x_001.main_21:Added wrapper function for getaddrinfo and freeaddrinfo */ +#if (!defined(SS_VW) && !defined(SS_PS) && !defined(WIN32)) +EXTERN S32 cmInetGetAddrInfo ARGS((CONSTANT S8* node, CONSTANT S8* service, + CONSTANT CmInetAddrInfo *hints, CmInetAddrInfo **res)); +EXTERN Void cmInetFreeAddrInfo ARGS((CmInetAddrInfo *res)); +#endif /* SS_VW | SS_PS | WIN32 */ + +/*cm_inet_x_001.main_23 Updated for TUCL 2.1 Release (Kernel SCTP Support) */ +#ifdef CM_LKSCTP +EXTERN S16 cmInetSctpBindx ARGS((CmInetFd *sockFd, + CmInetNetAddrLst *addrLst, + U16 port)); +EXTERN S16 cmInetSctpConnectx ARGS((CmInetFd *sockFd, CmInetNetAddr *primAddr, + CmInetNetAddrLst *addrLst, + U16 port)); +EXTERN S16 cmInetSctpPeelOff ARGS((CmInetFd *sockFd, U32 assocId, + CmInetFdType *assocFd)); +EXTERN S16 cmInetSctpSendMsg ARGS((CmInetFd *sockFd, CmInetNetAddr *dstAddr, + U16 port, CmInetMemInfo *info, + Buffer *mBuf, MsgLen *len, U16 strmId, + Bool unorderFlg, U16 ttl, U32 ppId, + U32 context)); +EXTERN S16 cmInetSctpRecvMsg ARGS((CmInetFd *sockFd, CmInetNetAddr *srcAddr, + U16 *port, CmInetMemInfo *info, + Buffer **mBuf, MsgLen *len, + CmInetSctpSndRcvInfo *sinfo, U32 *flag, + CmInetSctpNotification *ntfy)); +EXTERN S16 cmInetSctpGetPAddrs ARGS((CmInetFd *sockFd, U32 assocId, + CmInetNetAddrLst *addrlst)); +EXTERN S16 cmInetGetOpt ARGS((CmInetFd *sockFd, U32 level, U32 type, + Ptr value)); + +/*cm_inet_x_001.main_25: Added new funcion */ +EXTERN S16 cmInetShutDownSctp ARGS((CmInetFd *sockFd)); +/*cm_inet_x_001.main_30: Added new function */ +EXTERN S16 cmInetAbortSctpAssoc ARGS((CmInetFd *sockFd, UConnId assocId)); +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* __CMINETX__ */ + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/cm/cm_lib.c b/src/cm/cm_lib.c new file mode 100644 index 000000000..f846c60ba --- /dev/null +++ b/src/cm/cm_lib.c @@ -0,0 +1,541 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/********************************************************************20** + + Name: common library functions + + Type: C source file + + Desc: Common functions that are implemented in + both a portable and a performance-efficient manner. These + functions are selected based on the operating system. + + File: cm_lib.c + +*********************************************************************21*/ + +/*********************************************************************** + * This file provides memory and string library functions implemented in + * one of two ways: + * + * 1. portable: does not assume library support for any of the functions + * needed. + * + * 2. using environment specific: this uses existing library + * functions and is therefore, for an environment where such + * functionality is available and , a more desirable choice! + * + * The following functions are available in this file: + * + * 1. cmMemcpy: copies specified number of octets from one memory + * location to another. + * 2. cmMemcmp: compares specified number of octets at one memory + * locaton with the same number from another. + * 3. cmMemset: sets specified number of octets starting at given + * memory location with the given value. + * 4. cmStrCmp: compares two strings, until the '\0' character is + * encountered. + * 5. cmStrncmp: compares two strings, until \0 is encountered or + * until the specified length is exceeded. + * 6. cmStrlen: finds length of a string until the \0 character. + * + * The following flags are used in this file: + * + * 1. DONT_USE_SYS_LIB: If defined, this will compile in the portable + * versions of each function in this file. This overrides all other + * flags defined in this file. + * + * For the SOLARIS environment: + * + * The functionality defined in this file is generally available as library + * functions in the native operating systems' libraries. We have provided + * the functionality using the SOLARIS libraries, in this file. + * + * If you want to take advantage of these library functions, all you need + * to do is the following: + * + * 1. Do not turn on the DONT_USE_SYS_LIB flag. + * 2. Turn on the SUNOS51 flag. + * + * This, in turn, turns on the following flags + * + * 1. MEMCPY_AVAIL : maps cmMemcpy to C library function memcpy + * 2. MEMCMP_AVAIL : maps cmMemcmp to C library function memcmp + * 3. MEMSET_AVAIL : maps cmMemset to C library function memset + * 4. STRCMP_AVAIL : maps cmStrcmp to Strings library function strcmp + * 5. STRNCMP_AVAIL : maps cmStrncmp to Strings library function strncmp + * 5. STRLEN_AVAIL : maps cmStrlen to Strings library function strlen + * + * For an environment different from SOLARIS: + * + * You will need to modify this file to do more or less the same stuff + * as has been done for Solaris. i.e. + * + * 1. create a section inside the #ifndef DONT_USE_SYS_LIB section + * similar to the #ifdef SUNOS51 section that: + * 1. includes system header files. + * 2. defines MEMCPY_AVAIL etc. as needed. + * 2. modify code inside functions to make use of the system library + * primitive. + * 3. communicate your changes to Trillium so they can be incorporated + * in the next release of this file + * + * To add a new library primitive to this file: + * 1. it should be implemented in both a portable and environment specific + * manner. + * 2. the portable implementation will not be the default + * 3. the portable version and the environment specif versions must be + * enclosed in #ifdef XXXXXX_AVAIL + * + * #else + * + * #endif + * 4. It must be communicated to Trillium so it will be included in the + * next release of the file. + * 5. Trillium engineering must have all changes approved by engineering + * management. + * 6. Trillium reserves the right to not incorporate any changes submitted + * by customers, if not approved by Trillium engineering management. + * 7. Trillium reserves the right to modify code submitted by customers to + * enhance this file. + ************************************************************************/ + +/*cm_lib_c_001.main_13 - Moved env files inclusion to the top*/ +#include "envopt.h" /* environment options */ +#include "envind.h" /* environment options */ +#include "envdep.h" /* environment options */ + +#ifndef DONT_USE_SYS_LIB + +#include +#include +#include +#include +#define MEMCPY_AVAIL 1 +#define MEMCMP_AVAIL 1 +#define MEMSET_AVAIL 1 +#define STRCMP_AVAIL 1 +#define STRNCMP_AVAIL 1 +#define STRLEN_AVAIL 1 + +#else /* DONT_USE_SYS_LIB */ +#define MEMCPY_AVAIL 0 +#define MEMCMP_AVAIL 0 +#define MEMSET_AVAIL 0 +#define STRCMP_AVAIL 0 +#define STRNCMP_AVAIL 0 +#define STRLEN_AVAIL 0 +#endif /* not DONT_USE_SYS_LIB */ + + + +#include "gen.h" /* general layer */ +#include "ssi.h" /* system services */ + +/* header/extern include files (.x) */ + +#include "gen.x" /* general layer */ +#include "ssi.x" /* system services */ +#include "cm_lib.x" /* prototypes of primitives in this file */ + +#if (ERRCLASS & ERRCLS_DEBUG) + +#define ECMLIBBASE 0 +#define ECMLIB001 ECMLIBBASE + 1 +#define ECMLIB002 ECMLIBBASE + 2 +#define ECMLIB003 ECMLIBBASE + 3 +#define ECMLIB004 ECMLIBBASE + 4 +#define ECMLIB005 ECMLIBBASE + 5 +#define ECMLIB006 ECMLIBBASE + 6 +#define ECMLIB007 ECMLIBBASE + 7 + +#define CMLIBERR(_eCode, _eVal, _eDesc) \ + SLogError ((Ent) 0, (Inst)0, (ProcId)0, __FILE__, __LINE__, \ + (ErrCls)ERRCLS_DEBUG, (ErrCode)_eCode, (ErrVal) _eVal, \ + (Txt *) _eDesc) +#else +#define CMLIBERR(_eCode, _eVal, _eDesc) +#endif + +#ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */ +EXTERN Data *startPtr128; +EXTERN Size regMemSize; +#endif + +/* +* +* Fun: cmMemcpy +* +* Desc: common primitive to copy a contiguous string of bytes +* optimized for when memcpy is available. It uses memcpy +* when available. Otherwise, copies in a 'for' loop. +* +* sets "len" memory locations starting from "tgt" to the values +* of corresponding memory locations starting from "src". +* +* Ret: pointer to target string +* +* Notes: None +* +* File: cm_lib.c +* +*/ +#ifdef ANSI +PUBLIC U8 *cmMemcpy +( +U8 *tgt, +CONSTANT U8 *src, +PTR len +) +#else +PUBLIC U8 *cmMemcpy(tgt, src, len) +U8 *tgt; +CONSTANT U8 *src; +PTR len; +#endif +{ + /*cm_lib_c_001.main_14 : Fix for TRACE5 feature crash due to missing TRC MACRO*/ + TRC2(cmMemcpy) + +#ifdef MS_MBUF_CORRUPTION /* checking for valid memory address */ +if ((tgt > startPtr128) && (tgt < (startPtr128+regMemSize))) +{ + if ((*((U32 *)(tgt + 4)) == 0xDEADDEAD) || (*((U32 *)(tgt + 24)) == 0xDEADDEAD) || + (*((U32 *)(tgt + 44)) == 0xDEADDEAD) || (*((U32 *)(tgt + 80)) == 0xDEADDEAD)) + { + Data *crashPtr=NULLP; + *crashPtr = 9; + } +} +if ((src > startPtr128) && (src < (startPtr128+regMemSize))) +{ + if ((*((U32 *)(src + 4)) == 0xDEADDEAD) || (*((U32 *)(src + 24)) == 0xDEADDEAD) || + (*((U32 *)(src + 44)) == 0xDEADDEAD) || (*((U32 *)(src + 80)) == 0xDEADDEAD)) + { + Data *crashPtr=NULLP; + *crashPtr = 9; + } +} +#endif +#if (MEMCPY_AVAIL) /* memcpy is available */ + RETVALUE((U8 *) memcpy((Void *)tgt, (CONSTANT Void *)src, (size_t)len)); +#else + while (len--) + *tgt++ = *src++; + + RETVALUE(tgt); +#endif /* MEMCPY_AVAIL */ + +} /* end of cmMemcpy */ + + +/* +* +* Fun: cmMemcmp +* +* Desc: common primitive to compare a contiguous string of bytes +* optimized for when memcmp is available. It uses memcmp +* when available. Otherwise, compares in a 'for' loop. +* +* Ret: < 0 => s1 < s2 +* > 0 => s1 > s2 +* = 0 => s1 = s2 +* +* Notes: None +* +* File: cm_lib.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmMemcmp +( +CONSTANT U8 *s1, +CONSTANT U8 *s2, +PTR len +) +#else +PUBLIC S16 cmMemcmp (s1, s2, len) +CONSTANT U8 *s1; +CONSTANT U8 *s2; +PTR len; +#endif +{ + /*cm_lib_c_001.main_14 : Fix for TRACE5 feature crash due to missing TRC MACRO*/ + TRC2(cmMemcmp) +#if MEMCMP_AVAIL /* memcmp is available */ + RETVALUE((S16) memcmp((CONSTANT Void *)s1, (CONSTANT Void *)s2, (size_t)len)); +#else /* MEMCMP_AVAIL: memcmp is not available */ + while (len--) + { + if (*s1 ^ *s2) + RETVALUE((S16) (*s1 - *s2)); + s1++; + s2++; + } + RETVALUE(0); +#endif /* MEMCMP_AVAIL */ +} /* end of cmMemcmp */ + + +/* +* +* Fun: cmMemset +* +* Desc: common primitive to set a contiguous string of bytes +* with a specified value optimized for when memset is available. +* It uses memset when available. Otherwise, uses a 'for' loop. +* +* sets "len" memory locations starting from "str" to the value +* "val". +* +* Ret: pointer to string +* +* Notes: None +* +* File: cm_lib.c +* +*/ +#ifdef ANSI +PUBLIC U8 *cmMemset +( +U8 *str, +U8 val, +PTR len +) +#else +PUBLIC U8 *cmMemset(str, val, len) +U8 *str; +U8 val; +PTR len; +#endif +{ + /*cm_lib_c_001.main_14 : Fix for TRACE5 feature crash due to missing TRC MACRO*/ + TRC2(cmMemset) +#if MS_MBUF_CORRUPTION /* checking for valid memory address */ +if ((str > startPtr128) && (str < (startPtr128+regMemSize))) +{ + if ((*((U32 *)(str + 4)) == 0xDEADDEAD) || (*((U32 *)(str + 24)) == 0xDEADDEAD) || + (*((U32 *)(str + 44)) == 0xDEADDEAD) || (*((U32 *)(str + 80)) == 0xDEADDEAD)) + { + Data *crashPtr=NULLP; + *crashPtr = 9; + } +} +#endif +#if (MEMSET_AVAIL) /* memset is available */ + if (val==0) + { + bzero((void *)str,(size_t)len); + } + else + { + memset((void *)str,val,(size_t) len); + } +#else /* MEMSET_AVAIL: memset is not available */ + while (len --) + *str++ = val; + +#endif /* MEMSET_AVAIL */ + RETVALUE(str); +} /* end of cmMemset */ + + +/* +* +* Fun: cmStrcmp +* +* Desc: common primitive to compare a contiguous string of characters +* terminated by the '\0' character. +* +* when strcmp is available, it uses that. otherwise, it +* compares the strings using a for loop. +* +* The following is the "strcmp" description from the SunOS 5.4 +* man-page. cmStrcmp follows this. +* +* strcmp() compares two strings byte-by-byte, according to the +* ordering of your machine's character set. The function +* returns an integer greater than, equal to, or less than 0, +* if the string pointed to by s1 is greater than, equal to, or +* less than the string pointed to by s2 respectively. The sign +* of a non-zero return value is determined by the sign of the +* difference between the values of the first pair of bytes +* that differ in the strings being compared. +* +* Bytes following a null byte are not compared. +* +* +* Ret: < 0 => s1 < s2 +* > 0 => s1 > s2 +* = 0 => s1 = s2 +* +* Notes: None +* +* File: cm_lib.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmStrcmp +( +CONSTANT U8 *s1, +CONSTANT U8 *s2 +) +#else +PUBLIC S16 cmStrcmp (s1, s2) +CONSTANT U8 *s1; +CONSTANT U8 *s2; +#endif +{ + /*cm_lib_c_001.main_14 : Fix for TRACE5 feature crash due to missing TRC MACRO*/ + TRC2(cmStrcmp) +#if (STRCMP_AVAIL) + RETVALUE(strcmp((CONSTANT S8 *)s1, (CONSTANT S8 *)s2)); +#else /* STRCMP_AVAIL */ + + while (*s1 && *s2) + { + if (*s1 ^ *s2) + RETVALUE(*s1 - *s2); + s1++; + s2++; + } + RETVALUE(0); +#endif /* strcmp is not available */ + +} /* end of cmStrcmp */ + + + +/* +* +* Fun: cmStrncmp +* +* Desc: common primitive to compare a contiguous string of characters +* terminated by the '\0' character. +* +* when strncmp is available, it uses that. otherwise, it +* compares the strings using a for loop. +* +* The following is the "strncmp" description from the SunOS 5.4 +* man-page. cmStrncmp follows this. +* +* strcmp() compares two strings byte-by-byte, according to the +* ordering of your machine's character set. The function +* returns an integer greater than, equal to, or less than 0, +* if the string pointed to by s1 is greater than, equal to, or +* less than the string pointed to by s2 respectively. The sign +* of a non-zero return value is determined by the sign of the +* difference between the values of the first pair of bytes +* that differ in the strings being compared. strncmp() makes +* the same comparison but looks at a maximum of n bytes. +* Bytes following a null byte are not compared. +* +* Ret: < 0 => s1 < s2 +* > 0 => s1 > s2 +* = 0 => s1 = s2 +* +* Notes: None +* +* File: cm_lib.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmStrncmp +( +CONSTANT U8 *s1, +CONSTANT U8 *s2, +MsgLen len /* cm_lib_c_001.main_12: Changing from S16 to MsgLen.*/ +) +#else +PUBLIC S16 cmStrncmp (s1, s2, len) +CONSTANT U8 *s1; +CONSTANT U8 *s2; +MsgLen len; +#endif +{ + /*cm_lib_c_001.main_14 : Fix for TRACE5 feature crash due to missing TRC MACRO*/ + TRC2(cmStrncmp) +#if (STRNCMP_AVAIL) + RETVALUE(strncmp((CONSTANT S8 *)s1, (CONSTANT S8 *)s2, (size_t) len)); +#else /* STRNCMP_AVAIL */ + + while (*s1 && *s2 && len--) + { + if (*s1 ^ *s2) + RETVALUE(*s1 - *s2); + s1++; + s2++; + } + RETVALUE(0); +#endif /* strncmp is not available */ +} /* end of cmStrncmp */ + + +/* +* +* Fun: cmStrlen +* +* Desc: common primitive to compute the length of a NULL terminated +* string. +* +* when strlen is available, it uses that. otherwise, it +* inspects the string using a for loop. +* +* The following is the "strlen" description from the SunOS 5.4 +* man-page. cmStrlen follows this. +* +* strlen() returns the number of bytes in s, not including the +* terminating null character. +* +* Ret: length of string +* +* Notes: None +* +* File: cm_lib.c +* +*/ +#ifdef ANSI +PUBLIC MsgLen cmStrlen +( +CONSTANT U8 *s +) +#else +/* cm_lib_c_001.main_12: Changing from S16 to MsgLen.*/ +PUBLIC MsgLen cmStrlen (s) +CONSTANT U8 *s; +#endif +{ +#if (STRLEN_AVAIL) + /*cm_lib_c_001.main_15 : Fix for warning due to mixed declation*/ + TRC2(cmStrlen) + RETVALUE((MsgLen)strlen((CONSTANT S8 *)s)); +#else /* STRLEN_AVAIL */ + MsgLen i; + + /*cm_lib_c_001.main_15 : Fix for warning due to mixed declation*/ + TRC2(cmStrlen) + + for (i = 0; *s; i++, s++); + RETVALUE(i); +#endif /* strlen is not available */ +} /* end of cmStrlen */ + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/cm/cm_llist.c b/src/cm/cm_llist.c new file mode 100644 index 000000000..e9ae20ff2 --- /dev/null +++ b/src/cm/cm_llist.c @@ -0,0 +1,423 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/********************************************************************20** + + Name: common functions - linked list management + + Type: C source file + + Desc: common functions for linked lists + + File: cm_llist.c + +*********************************************************************21*/ + +/* header include files (.h) */ + +#include "envopt.h" /* environment options */ +#include "envdep.h" /* environment dependent */ +#include "envind.h" /* environment independent */ + +#include "gen.h" /* general layer */ +#include "ssi.h" /* system services */ + +/* header/extern include files (.x) */ + +#include "gen.x" /* general layer */ +#include "ssi.x" /* system services */ +#include "cm_llist.x" /* common functions */ + + +/* Linked List functions */ + + +/* +* +* Fun: cmLListInit +* +* Desc: initializes a linked list control pointer. +* +* Ret: ROK - ok +* +* Notes: None +* +* File: cm_llist.c +* +*/ +#ifdef ANSI +PUBLIC Void cmLListInit +( +CmLListCp *lCp /* list control point */ +) +#else +PUBLIC Void cmLListInit(lCp) +CmLListCp *lCp; /* list control point */ +#endif +{ + TRC3(cmLListInit); + + lCp->first = (CmLList *)NULLP; + lCp->last = (CmLList *)NULLP; + lCp->crnt = (CmLList *)NULLP; + lCp->count = 0; + + RETVOID; +} /* end of cmLListInit */ + + + +/*insert before head*/ +/* +* +* Fun: cmLListAdd2Head +* +* Desc: adds node to linked list before head. +* +* Ret: ROK - ok +* +* Notes: None +* +* File: cm_llist.c +* +*/ +#ifdef ANSI +PUBLIC Void cmLListAdd2Head +( +CmLListCp *lCp, /* list control point */ +CmLList *node /* node to be added */ +) +#else +PUBLIC Void cmLListAdd2Head(lCp, node) +CmLListCp *lCp; /* list control point */ +CmLList *node; /* node to be added */ +#endif +{ + TRC3(cmLListAdd2Head); + +#ifdef ERRCHK + if (lCp == (CmLListCp *)NULLP) + RETVOID; +#endif + + lCp->count++; + + node->next = lCp->first; + node->prev = NULLP; + lCp->first = lCp->crnt = node; + + if (!node->next) + { + lCp->last = node; + RETVOID; + } + + node->next->prev = node; + RETVOID; +} /* end of cmLListAdd2Head */ + + +/* +* +* Fun: cmLListAdd2Tail +* +* Desc: adds node to linked list after last. +* +* Ret: ROK - ok +* +* Notes: None +* +* File: cm_llist.c +* +*/ +#ifdef ANSI +PUBLIC Void cmLListAdd2Tail +( +CmLListCp *lCp, /* list control point */ +CmLList *node /* node to be added */ +) +#else +PUBLIC Void cmLListAdd2Tail(lCp, node) +CmLListCp *lCp; /* list control point */ +CmLList *node; /* node to be added */ +#endif +{ + TRC3(cmLListAdd2Tail); + +#ifdef ERRCHK + if (lCp == (CmLListCp *)NULLP) + RETVOID; +#endif + + lCp->count++; + + node->prev = lCp->last; + node->next = NULLP; + lCp->last = lCp->crnt = node; + + if (!node->prev) + { + lCp->first = node; + RETVOID; + } + + node->prev->next = node; + RETVOID; +} /* end of cmLListAdd2Tail */ + + +/* +* +* Fun: cmLListInsCrnt +* +* Desc: adds node to linked list before crnt. +* +* Ret: ROK - ok +* +* Notes: None +* +* File: cm_llist.c +* +*/ +#ifdef ANSI +PUBLIC Void cmLListInsCrnt +( +CmLListCp *lCp, /* list control point */ +CmLList *node /* node to be added */ +) +#else +PUBLIC Void cmLListInsCrnt(lCp, node) +CmLListCp *lCp; /* list control point */ +CmLList *node; /* node to be added */ +#endif +{ + TRC3(cmLListInsCrnt); + +#ifdef ERRCHK + if (!lCp) + RETVOID; +#endif + + lCp->count++; + + if (lCp->count == 1) + { + lCp->crnt = lCp->first = lCp->last = node; + node->next = NULLP; + RETVOID; + } + + node->next = lCp->crnt; + node->prev = lCp->crnt->prev; + if (node->prev) + node->prev->next = node; + node->next->prev = node; + + if (lCp->first == lCp->crnt) + lCp->first = node; + lCp->crnt = node; + + RETVOID; +} /* end of cmLListInsCrnt */ + +/* cm_llist_c_001.main_7 - Add function */ +/* +* +* Fun: cmLListInsAfterCrnt +* +* Desc: adds node to linked list after crnt. +* +* Ret: ROK - ok +* +* Notes: None +* +* File: cm_llist.c +* +*/ +#ifdef ANSI +PUBLIC Void cmLListInsAfterCrnt +( +CmLListCp *lCp, /* list control point */ +CmLList *node /* node to be added */ +) +#else +PUBLIC Void cmLListInsAfterCrnt(lCp, node) +CmLListCp *lCp; /* list control point */ +CmLList *node; /* node to be added */ +#endif +{ + TRC3(cmLListInsAfterCrnt); + +#ifdef ERRCHK + if (!lCp) + RETVOID; +#endif + + lCp->count++; + + if (lCp->count == 1) + { + lCp->crnt = lCp->first = lCp->last = node; + RETVOID; + } + + node->prev = lCp->crnt; + node->next = lCp->crnt->next; + if (node->next) + node->next->prev = node; + node->prev->next = node; + + if (lCp->last == lCp->crnt) + lCp->last = node; + lCp->crnt = node; + + RETVOID; +} /* end of cmLListInsAfterCrnt */ + + + +/* +* +* Fun: cmLListDelFrm +* +* Desc: remove node pointed to by nodePtr from list and return node. +* nodePtr could be anywhere in the list. +* - resets crnt to NULLP. +* +* Ret: pointer +* +* Notes: None +* +* File: cm_llist.c +* +*/ +#ifdef ANSI +PUBLIC CmLList *cmLListDelFrm +( +CmLListCp *lCp, /* list control pointer */ +CmLList *node /* node to be removed */ +) +#else +PUBLIC CmLList *cmLListDelFrm(lCp, node) +CmLListCp *lCp; /* list control pointer */ +CmLList *node; /* node to be removed */ +#endif +{ + TRC3(cmLListDelFrm); + +#ifdef ERRCHK + /* cm_llist_c_001.main_8 : added null check for node */ + if (lCp == (CmLListCp *)NULLP || lCp->count == 0 || !node) + { + RETVALUE(NULLP); + } +#endif + + if (lCp->count == 1) + { + lCp->first = lCp->crnt = lCp->last = (CmLList *)NULLP; + lCp->count = 0; + RETVALUE(node); + } + + lCp->count--; + lCp->crnt = (CmLList *)NULLP; + if (lCp->first == node) + { + if (node->next) + node->next->prev = (CmLList *)NULLP; + lCp->first = node->next; + node->next = node->prev = (CmLList *)NULLP; + RETVALUE(node); + } + + if (lCp->last == node) + { + if (node->prev) + node->prev->next = (CmLList *)NULLP; + lCp->last = node->prev; + node->next = node->prev = (CmLList *)NULLP; + RETVALUE(node); + } + + node->prev->next = node->next; + node->next->prev = node->prev; + node->next = node->prev = (CmLList *)NULLP; + RETVALUE(node); +} /* end of cmLListDelFrm */ + + +/*-- + * + * Fun: cmLListCatLList + * + * Desc: adds a linked list to the end of the first list. list2 is + * added at the end of list1 + * + * Ret: ROK - ok + * + * Notes: None + * + * File: cm_llist.c + * + --*/ +#ifdef ANSI +PUBLIC Void cmLListCatLList +( + CmLListCp *list1, /*-- list control point --*/ + CmLListCp *list2 /*-- node to be added --*/ + ) +#else +PUBLIC Void cmLListCatLList(list1, list2) + CmLListCp *list1; /*-- list control point --*/ + CmLListCp *list2; /*-- node to be added --*/ +#endif +{ + TRC3(cmLListCatLList); + + /*-- if the second list is empty nothing to do --*/ + if(list2->count == 0) + { + RETVOID; + } + + /*-- if the first list is empty make first the same as second*/ + if(list1->count == 0) + { + list1->first = list2->first; + list1->last = list2->last; + list1->count = list2->count; + list1->crnt = list1->first; + } + else + { + list2->first->prev = list1->last; + list1->last->next = list2->first; + /* Set the last to the end of the 2nd list */ + list1->last = list2->last; + list1->count += list2->count; + } + + cmLListInit(list2); + + RETVOID; +} /*-- end of cmLListCatLList --*/ + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/cm/cm_lte.c b/src/cm/cm_lte.c new file mode 100755 index 000000000..ebb4dcc7d --- /dev/null +++ b/src/cm/cm_lte.c @@ -0,0 +1,507 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/************************************************************************ + + Name: Common LTE + + Type: C source file + + Desc: C code for packing/unpacking of cm_lte data structures. + + File: cm_lte.c + +**********************************************************************/ + +/* header include files (.h) */ + +#include "envopt.h" /* environment options */ +#include "envdep.h" /* environment dependent */ +#include "envind.h" /* environment independent */ + +/* header/extern include files (.x) */ + +#include "gen.h" /* general layer */ +#include "ssi.h" /* system services */ +#include "cm_lte.h" /* common lte header file */ +#include "cm5.h" /* common timers */ +#include "mt_ss.h" /* MTSS specific */ +#include "mt_err.h" /* MTSS error defines */ +#include "ss_queue.h" /* queues */ +#include "ss_task.h" /* tasking */ +#include "ss_msg.h" /* messaging */ +#include "ss_mem.h" /* memory management interface */ +#include "ss_gen.h" /* general */ +/* mt003.301 Additions - Task deregistration */ +#include "ss_err.h" /* error */ + + +/* header/extern include files (.x) */ + +#include "gen.x" /* general layer */ +#include "ssi.x" /* system services */ +#include "cm_lte.x" /* common lte header file */ +#include "cm5.x" /* common timers */ +#include "mt_ss.x" /* MTSS specific */ +#include "ss_queue.x" /* queues */ +#include "ss_task.x" /* tasking */ +#include "ss_timer.x" /* timers */ +#include "ss_strm.h" +#include "ss_strm.x" /* STREAMS */ +#include "ss_msg.x" /* messaging */ +#include "ss_mem.x" /* memory management interface */ +#include "ss_drvr.x" /* driver tasks */ +#include "ss_gen.x" /* general */ + + +/* public variable declarations */ +PUBLIC U32 cmLteTime; + + +/*********************************************************** +* +* Func : cmPkLteRlcId +* +* +* Desc : RLC Identifier +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkLteRlcId +( +CmLteRlcId *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkLteRlcId(param, mBuf) +CmLteRlcId *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkLteRlcId); + + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + CMCHKPK(cmPkLteRnti, param->ueId, mBuf); + CMCHKPK(SPkU8, param->rbType, mBuf); + CMCHKPK(cmPkLteRbId, param->rbId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkLteRlcId +* +* +* Desc : RLC Identifier +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkLteRlcId +( +CmLteRlcId *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkLteRlcId(param, mBuf) +CmLteRlcId *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkLteRlcId); + + CMCHKUNPK(cmUnpkLteRbId, ¶m->rbId, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->rbType, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->ueId, mBuf); + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkLteTimingInfo +* +* +* Desc : LTE Timing Info +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkLteTimingInfo +( +CmLteTimingInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkLteTimingInfo(param, mBuf) +CmLteTimingInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkLteTimingInfo); + + CMCHKPK(SPkU8, param->subframe, mBuf); + CMCHKPK(SPkU16, param->sfn, mBuf); + CMCHKPK(SPkU16, param->hSfn, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkLteTimingInfo +* +* +* Desc : LTE Timing Info +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkLteTimingInfo +( +CmLteTimingInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkLteTimingInfo(param, mBuf) +CmLteTimingInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkLteTimingInfo); + + CMCHKUNPK(SUnpkU16, ¶m->hSfn, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->sfn, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->subframe, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkLtePdcpId +* +* +* Desc : PDCP Id +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkLtePdcpId +( +CmLtePdcpId *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkLtePdcpId(param, mBuf) +CmLtePdcpId *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkLtePdcpId); + + CMCHKPK(SPkU8, param->rbType, mBuf); + CMCHKPK(cmPkLteRbId, param->rbId, mBuf); + CMCHKPK(cmPkLteRnti, param->ueId, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkLtePdcpId +* +* +* Desc : PDCP Id +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkLtePdcpId +( +CmLtePdcpId *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkLtePdcpId(param, mBuf) +CmLtePdcpId *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkLtePdcpId); + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->ueId, mBuf); + CMCHKUNPK(cmUnpkLteRbId, ¶m->rbId, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->rbType, mBuf); + RETVALUE(ROK); +} +#ifdef LTE_L2_MEAS +#ifdef ANSI +PUBLIC S16 cmUpdateSsiMemInfo +( +CmLteMemInfo *mInfo +) +#else +PUBLIC S16 cmUpdateSsiMemInfo(mInfo) +CmLteMemInfo *mInfo; +#endif +{ + U8 numReg = 0; + U8 numPool = 0; + U8 idxReg; + U8 idxPool; + SsMemDbgInfo dbgInfo; + + SGetRegPoolInfo(&numReg,&numPool); + mInfo->numRegions = numReg; + + for(idxReg=0; idxReg< numReg; idxReg++) + { + SGetRegInfo(idxReg, &dbgInfo); + + if(mInfo->regInfo[idxReg].isGenMemInfoUpdated == TRUE) + { + for(idxPool=0; idxPoolregInfo[idxReg].poolInfo[idxPool].crntUsed = dbgInfo.bktDbgTbl[idxPool].numAlloc; + if(mInfo->regInfo[idxReg].poolInfo[idxPool].crntUsed > mInfo->regInfo[idxReg].poolInfo[idxPool].maxUsed) + mInfo->regInfo[idxReg].poolInfo[idxPool].maxUsed = mInfo->regInfo[idxReg].poolInfo[idxPool].crntUsed; + } + } + else + { + mInfo->regInfo[idxReg].numPools = numPool; + mInfo->regInfo[idxReg].regionId = idxReg; + mInfo->regInfo[idxReg].regionType = 0; + + for(idxPool=0; idxPoolregInfo[idxReg].poolInfo[idxPool].totAvailable = dbgInfo.bktDbgTbl[idxPool].numBlks; + mInfo->regInfo[idxReg].poolInfo[idxPool].poolSize = dbgInfo.bktDbgTbl[idxPool].size; + mInfo->regInfo[idxReg].poolInfo[idxPool].crntUsed = dbgInfo.bktDbgTbl[idxPool].numAlloc; + if(mInfo->regInfo[idxReg].poolInfo[idxPool].crntUsed > mInfo->regInfo[idxReg].poolInfo[idxPool].maxUsed) + mInfo->regInfo[idxReg].poolInfo[idxPool].maxUsed = mInfo->regInfo[idxReg].poolInfo[idxPool].crntUsed; + } + mInfo->regInfo[idxReg].isGenMemInfoUpdated = TRUE; + } + } + RETVALUE(ROK); +} + +#ifdef ANSI +PUBLIC S16 cmFillMemUtilizationMeas +( + CmLteMemInfo *memoryInfo, +CmLteMemInfo *memInfo +) +#else +PUBLIC S16 cmFillMemUtilizationMeas(memoryInfo,memInfo) +CmLteMemInfo *memoryInfo; +CmLteMemInfo *memInfo; +#endif +{ + U8 idxReg = 0; + U8 idxPool = 0; + U8 numPool = 0; + + memoryInfo->numRegions = memInfo->numRegions; + for(idxReg=0; idxReg < memInfo->numRegions; idxReg++) + { + memoryInfo->regInfo[idxReg].regionId = memInfo->regInfo[idxReg].regionId; + memoryInfo->regInfo[idxReg].numPools = memInfo->regInfo[idxReg].numPools; + memoryInfo->regInfo[idxReg].regionType = memInfo->regInfo[idxReg].regionType; + numPool = memoryInfo->regInfo[idxReg].numPools; + + for(idxPool=0; idxPool < numPool; idxPool++) + { + memoryInfo->regInfo[idxReg].poolInfo[idxPool].totAvailable = memInfo->regInfo[idxReg].poolInfo[idxPool].totAvailable; + memoryInfo->regInfo[idxReg].poolInfo[idxPool].poolSize = memInfo->regInfo[idxReg].poolInfo[idxPool].poolSize; + memoryInfo->regInfo[idxReg].poolInfo[idxPool].crntUsed = memInfo->regInfo[idxReg].poolInfo[idxPool].crntUsed; + memoryInfo->regInfo[idxReg].poolInfo[idxPool].maxUsed = memInfo->regInfo[idxReg].poolInfo[idxPool].maxUsed; + } + } + RETVALUE(ROK); +} + +#ifdef ANSI +PUBLIC S16 cmClearMemUtilizationCounter +( +CmLteMemInfo *memInfo +) +#else +PUBLIC S16 cmClearMemUtilizationCounter(memInfo) +CmLteMemInfo *memInfo; +#endif +{ + U8 idxReg = 0; + U8 idxPool = 0; + U8 numPool = 0; + for(idxReg=0; idxReg < memInfo->numRegions; idxReg++) + { + memInfo->regInfo[idxReg].regionId = 0; + memInfo->regInfo[idxReg].numPools = 0; + memInfo->regInfo[idxReg].regionType = 0; + memInfo->regInfo[idxReg].isGenMemInfoUpdated = FALSE; + numPool = memInfo->regInfo[idxReg].numPools; + + for(idxPool=0; idxPoolregInfo[idxReg].poolInfo[idxPool].totAvailable = 0; + memInfo->regInfo[idxReg].poolInfo[idxPool].poolSize = 0; + memInfo->regInfo[idxReg].poolInfo[idxPool].crntUsed = 0; + memInfo->regInfo[idxReg].poolInfo[idxPool].maxUsed = 0; + } + } + RETVALUE(ROK); +} + +#ifdef ANSI +PUBLIC S16 cmClearCpuUtilizationCounter +( +CmCpuStatsInfo *cpuInfo +) +#else +PUBLIC S16 cmClearCpuUtilizationCounter(cpuInfo) +CmCpuStatsInfo *cpuInfo +#endif +{ + U8 idx= 0; + for(idx=0; idx < cpuInfo->numCores; idx++) + { + cpuInfo->cpuUtil[idx].maxCpuUtil = 0; + cpuInfo->cpuUtil[idx].totCpuUtil = 0; + cpuInfo->cpuUtil[idx].numSamples = 0; + } + cpuInfo->numCores = 0; + RETVALUE(ROK); +} + +#ifdef ANSI +PUBLIC S16 cmFillCpuUtilizationMeas +( +CmLteCpuInfo *cpuMeasInfo, +CmCpuStatsInfo *cpuInfo +) +#else +PUBLIC S16 cmFillCpuUtilizationMeas(cpuMeasInfo,cpuInfo) +CmLteCpuInfo *cpuMeasInfo; +CmCpuStatsInfo *cpuInfo; +#endif +{ + U8 idx= 0; + cpuMeasInfo->numCores = cpuInfo->numCores; + for(idx=0; idx < cpuInfo->numCores; idx++) + { + cpuMeasInfo->cpuUtil[idx].avgCpuUtil = cpuInfo->cpuUtil[idx].totCpuUtil/cpuInfo->cpuUtil[idx].numSamples; + cpuMeasInfo->cpuUtil[idx].maxCpuUtil = cpuInfo->cpuUtil[idx].maxCpuUtil; + } + RETVALUE(ROK); + +} +#endif + +#ifdef TENB_TTI_PERF +CmTtiProc ttiProc; +#define TTI_1MS 950 + +PUBLIC Void cmUpdateTtiCounters(U32 ttiProcessingTime) +{ + ttiProc.numOfTti++; + ttiProc.totTtiProcessingTime += ttiProcessingTime; + if(ttiProcessingTime > ttiProc.maxTtiProcessingTime) + { + ttiProc.maxTtiProcessingTime = ttiProcessingTime; + } + if(ttiProcessingTime > TTI_THRESHOLD_VALUE) + { + ttiProc.ttiThresholdExceedCount++; + } + if(ttiProcessingTime > TTI_1MS) + { + ttiProc.ttiStretchCount++; + } + RETVOID; +} + +PUBLIC Void cmResetTtiCounters(Void) +{ + ttiProc.totTtiProcessingTime = 0; + ttiProc.numOfTti = 0; + ttiProc.maxTtiProcessingTime = 0; + ttiProc.ttiStretchCount = 0; + ttiProc.ttiThresholdExceedCount = 0; + ttiProc.phyReptTtiStretchCount = 0; + RETVOID; +} +#endif + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/cm/cm_math.c b/src/cm/cm_math.c new file mode 100755 index 000000000..0b1044cb0 --- /dev/null +++ b/src/cm/cm_math.c @@ -0,0 +1,208 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + + +/********************************************************************20** + + Name: common MATH library functions + + Type: C source file + + Desc: Common functions that are implemented in + a portable manner. These functions are selected + based on the operating system. + + File: cm_math.c + +*********************************************************************21*/ + + +/* header include files (.h) */ +#include "envopt.h" /* environment options */ +#include "envdep.h" /* environment dependent */ +#include "envind.h" /* environment independent */ +#include "gen.h" /* general */ +#include "ssi.h" /* system services interface */ + +#include "cm_math.h" +#include "cm_math.x" + +#include + +#include + + +#ifdef SS_FLOAT +/* +* +* Fun: cmAbs +* +* Desc: common primitive for an absolute value of an integer +* +* Ret: absolute value of the operand +* +* Notes: None +* +* File: cm_math.c +* +*/ +#ifdef ANSI +PUBLIC U32 cmAbs +( +F64 val +) +#else +PUBLIC U32 cmAbs(val) +F64 val; +#endif +{ +#if (defined(SUNOS)|| defined(WIN32)|| defined(WIN2K)|| defined (SS_LINUX)) + RETVALUE((U32) abs((int) val));/* G++ */ +#endif +} /* end of cmAbs */ +#endif /* SS_FLOAT */ + + +#ifdef SS_FLOAT +/* +* +* Fun: cmPow +* +* Desc: common primitive for computing the power of x raised to y. +* +* Ret: value of x raised to the power of y. +* +* Notes: None +* +* File: cm_math.c +* +*/ +#ifdef ANSI +PUBLIC F64 cmPow +( +F64 x, +F64 y +) +#else +PUBLIC F64 cmPow(x, y) +F64 x; +F64 y; +#endif +{ +#if (defined(SUNOS)|| defined(WIN32)|| defined(WIN2K)|| defined (SS_LINUX)) + RETVALUE((F64) pow((F64)x, (F64)y)); +#endif +} /* end of cmPow */ +#endif /* SS_FLOAT */ + +#ifdef SS_FLOAT +/* +* +* Fun: cmFloor +* +* Desc: common primitive for computing the largest integral value +* not greater than x. +* +* Ret: floor value of x +* +* Notes: None +* +* File: cm_math.c +* +*/ +#ifdef ANSI +PUBLIC F64 cmFloor +( +F64 x +) +#else +PUBLIC F64 cmFloor(x) +F64 x; +#endif +{ +#if (defined(SUNOS)|| defined(WIN32)|| defined(WIN2K)|| defined (SS_LINUX)) + RETVALUE((F64) floor((F64)x)); +#endif + +} /* end of cmFloor */ +#endif /* SS_FLOAT */ + +#ifdef SS_FLOAT +/* +* +* Fun: cmLog +* +* Desc: common primitive for computing the natural logrithm of x. +* +* Ret: loge(x) +* +* Notes: None +* +* File: cm_math.c +* +*/ +#ifdef ANSI +PUBLIC F64 cmLog +( +F64 x +) +#else +PUBLIC F64 cmLog(x) +F64 x; +#endif +{ +#if (defined(SUNOS)|| defined(WIN32)|| defined(WIN2K)|| defined (SS_LINUX)) + RETVALUE((F64) log((F64)x)); +#endif + +} /* end of cmLog */ +#endif /* SS_FLOAT */ + +#ifdef SS_FLOAT +/* +* +* Fun: cmLog10 +* +* Desc: common primitive for computing the base 10 logrithm of x. +* +* Ret: log10(x) +* +* Notes: None +* +* File: cm_math.c +* +*/ +#ifdef ANSI +PUBLIC F64 cmLog10 +( +F64 x +) +#else +PUBLIC F64 cmLog10(x) +F64 x; +#endif +{ +#if (defined(SUNOS)|| defined(WIN32)|| defined(WIN2K)|| defined (SS_LINUX)) + RETVALUE((F64) log10((F64)x)); +#endif +} /* end of cmLog10 */ +#endif /* SS_FLOAT */ + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/cm/cm_mblk.c b/src/cm/cm_mblk.c new file mode 100644 index 000000000..3413ca8f7 --- /dev/null +++ b/src/cm/cm_mblk.c @@ -0,0 +1,739 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/********************************************************************20** + + Name: common memory allocation library + + Type: C include file + + Desc: memory library routines + + File: cm_mblk.c + +*********************************************************************21*/ + + +/* header include files (.h) */ +#include "envopt.h" /* environment options */ +#include "envdep.h" /* environment dependent */ +#include "envind.h" /* environment independent */ +#include "gen.h" /* general layer */ +#include "ssi.h" /* system services */ +#include "cm_mblk.h" /* Header file */ + +/* header/extern include files (.x) */ +#include "gen.x" /* general layer */ +#include "ssi.x" /* system services */ +#include "cm_lib.x" /* Common library */ +#include "cm_mblk.x" /* Typedef file */ + +#ifdef SS_LOCKLESS_MEMORY +EXTERN pthread_t tmpRegTidMap[20]; +#define CM_MEM_GET_REGION(_region) \ +{ \ + U8 _regCnt; \ + _region = 0xFF; \ + \ + for(_regCnt = 0; _regCnt < 12; _regCnt++) \ + { \ + if(tmpRegTidMap[_regCnt] == pthread_self()) \ + { \ + _region = _regCnt; \ + break; \ + } \ + } \ +} +#endif + + + +PRIVATE Void cmAddMemNode ARGS((CmMemListCp *lCp,CmMemList *node)); + + +/* +* +* Fun: cmAllocEvnt +* +* Desc: This function allocates the first memory chunk, +* which contains CmMemListCp structure at the top, +* parcels the requested event structure out of this +* chunk and return to the user. +* +* Ret: ROK +* +* Notes: None +* +* File: cm_mblk.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmAllocEvnt +( +Size evntSize, /* Size of the Event structure */ +Size maxBlkSize, /* Chunk Memory size */ +Mem *sMem, /* Static memory region and pool */ +Ptr *ptr /* Location to place allocated event ptr */ +) +#else +PUBLIC S16 cmAllocEvnt (evntSize,maxBlkSize,sMem,ptr) +Size evntSize; /* Size of the Event structure */ +Size maxBlkSize; /* Memory size requested */ +Mem *sMem; /* Static Memory region and pool */ +Ptr *ptr; /* Location to place allocated event ptr */ +#endif +{ + + Data *allocPtr; /* Allocated Memory Pointer */ + CmMemList *node; /* Memory Link List Node */ + CmMemListCp *memCp; /* memory Link list control point */ + CmMemCb *cb; /* Allocated Memory Control Block */ + + TRC2(cmAllocEvnt) + + /* Validation check */ +#ifndef LTE_ENB_PAL + if( evntSize > maxBlkSize) + { + printf("\nNot Allocating memory for Event\n"); +#ifdef ALIGN_64BIT + printf("eventSize [%d] greater than maxBlkSize [%d]\n", + evntSize, maxBlkSize); +#else + printf("eventSize [%ld] greater than maxBlkSize [%ld]\n", + evntSize, maxBlkSize); +#endif + RETVALUE(RFAILED); + } +#endif + + /* Allocate memory for the first Memory Chunk */ + /* Allocated memory should be maxBlkSize + sizeof(CmMemList) */ +#ifdef SS_LOCKLESS_MEMORY + if(SGetStaticBuffer(sMem->region, sMem->pool, (Data **)&allocPtr, + (Size)(maxBlkSize + sizeof(CmMemList)), 0) != ROK) +#else + if (SGetSBuf(sMem->region, sMem->pool, + (Data **)&allocPtr, + (Size)(maxBlkSize + sizeof(CmMemList))) != ROK) +#endif /* SS_LOCKLESS_MEMORY */ + + RETVALUE(RFAILED); + + /* Reset the contents */ + cmMemset((U8 *)allocPtr, (U8 )0, + (PTR)(maxBlkSize + sizeof(CmMemList)) ); + + /* The above allocated memory chunk is structured as follows + + +-------------------+ + | CmMemList | + +-------------------+ <---- Event Structure begins here + | CmMemListCp | ^ + +-------------------+ | + | Event data part | | evntSize + +-------------------+ | + .... | + .... \/ + +-------------------+ + + */ + + /* Overlay CmMemList structure on top of this allocated chunk */ + node = (CmMemList *)allocPtr; + /* cm_mblk_c_001.101: update size value */ + node->size = maxBlkSize; + + /* Get to CmMemListCp start */ + memCp = (CmMemListCp *) ((PTR)allocPtr + sizeof(CmMemList)); + + /* Initialise memListCp */ + CM_INIT_MEMCP( memCp,maxBlkSize,sMem); + + /* Add link list node to link list */ + cmAddMemNode(memCp, node); + + /* Get pointer to memCb inside MemListCp */ + cb = (CmMemCb *)&(memCp->memCb); + + /* Align evntSize, if necessary */ + CM_ALIGN_SIZE(evntSize); + + cb->memAllocated = (evntSize + sizeof(CmMemList) ); + cb->initPtr = (PTR)allocPtr; + *ptr = (Ptr) ((PTR)allocPtr + sizeof(CmMemList)); + cb->runPtr = ((PTR)(*ptr) + evntSize); + + RETVALUE(ROK); + +} /* End of cmAllocEvnt */ + + +/* +* +* Fun: cmInitMemCp +* +* Desc: This function intialises Memory Link List +* Control point +* +* Ret: ROK +* +* Notes: None +* +* File: cm_mblk.c +* +*/ + +#ifdef ANSI +PUBLIC Void cmInitMemCp +( +CmMemListCp *memCp, /* Memory control pointer */ +Size maxBlkSize, /* Chunk Memory size */ +Mem *sMem /* Static memory region and pool */ +) +#else +PUBLIC Void cmInitMemCp (memCp,maxBlkSize,sMem) +CmMemListCp *memCp; /* Memory control pointer */ +Size maxBlkSize; /* Memory size requested */ +Mem *sMem; /* Static Memory region and pool */ +#endif +{ + + TRC2(cmInitMemCp) + + /* Intialise Memory Control Point */ + CM_INIT_MEMCP(memCp,maxBlkSize,sMem); + + RETVOID; + +} /* End of cmInitMemCp */ + + +/* +* +* Fun: cmGetMem +* +* Desc: This function parcels memory from memory chunks +* It allocated big chunk as and when required +* +* Ret: ROK +* +* Notes: None +* +* File: cm_mblk.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmGetMem +( +Ptr memPtr, /* Pointer to memCp */ +Size size, /* Memory size requested */ +Ptr *allocPtr /* location to place pointer */ +) +#else +PUBLIC S16 cmGetMem (memPtr,size,allocPtr) +Ptr memPtr; /* Pointer to memCp */ +Size size; /* Memory size requested */ +Ptr *allocPtr; /* location to place pointer */ +#endif +{ + + CmMemCb *cb; /* Pointer to Memory Control Block */ + CmMemList *node; /* Memory List node */ + CmMemListCp *memCp; /* Memory Control Point */ + /* cm_mblk_c_001.101: added local variable */ + Size blkSize; /* required block size */ + + TRC2(cmGetMem) + + memCp = (CmMemListCp *)memPtr; + cb = &memCp->memCb; + + /* Make requested size aligned, if necessary */ + CM_ALIGN_SIZE(size); + + /* cm_mblk_c_001.101 : If the requested size is greater than the configured + * max size, then allocate a new block with the requested size. This will + * enable us to handle large allocation requests in H.323 stack for certain + * information elements. This will not impact any normal allocation request + * as we fall back to the configured size */ + if( size > cb->maxSize) + blkSize = size; + else + blkSize = cb->maxSize; + + if( cb->initPtr) + { + /* if a chunk is already there */ + if( (cb->memAllocated + size) <= + (U32)(cb->maxSize + sizeof(CmMemList)) ) + { + /* Requested memory is available in present chunk */ + *allocPtr = (Ptr) cb->runPtr; + cb->memAllocated += size; + cb->runPtr += size; + RETVALUE(ROK); + } + } + + /* For all other cases, We need to allocate a new memory chunk */ + /* Allocate buffer */ + /* cm_mblk_c_001.101: use blkSize instead of cb->maxSize */ +#ifdef SS_LOCKLESS_MEMORY + if(SGetStaticBuffer(cb->sMem.region, cb->sMem.pool, + (Data **)&(cb->initPtr), + (Size)(blkSize + sizeof(CmMemList)), 0) != ROK) +#else + if (SGetSBuf(cb->sMem.region, cb->sMem.pool, + (Data **)&(cb->initPtr), + (Size)(blkSize + sizeof(CmMemList)) ) != ROK) +#endif /* SS_LOCKLESS_MEMORY */ + RETVALUE(RFAILED); + + /* Reset the contents */ + /* Initialise above allocated structure */ + /* cm_mblk_c_001.101: use blkSize instead of cb->maxSize */ + cmMemset((U8 *)cb->initPtr, (U8 )0, + (PTR)(blkSize + sizeof(CmMemList) )); + + /* The above allocated memory chunk is structured as follows + + +-------------------+ + | CmMemList | + +-------------------+ + Data Portion + .... + .... + +-------------------+ */ + + /* Overlay CmMemList structure on top of this allocated chunk */ + node = (CmMemList *)cb->initPtr; + /* cm_mblk_c_001.101: update size */ + node->size = blkSize; + + /* Add link list node to link list */ + cmAddMemNode(memCp, node); + + cb->memAllocated = (size + sizeof(CmMemList) ); + *allocPtr = (Ptr) ((PTR)cb->initPtr + sizeof(CmMemList)); + cb->runPtr = ((PTR)(*allocPtr) + size); + + RETVALUE(ROK); + +} /* End of cmGetMem */ + + +#ifdef TFU_ALLOC_EVENT_NO_INIT + +/* +* +* Fun: cmAllocEvntNoInit +* +* Desc: This function allocates the first memory chunk, +* which contains CmMemListCp structure at the top, +* parcels the requested event structure out of this +* chunk and return to the user. +* +* Ret: ROK +* +* Notes: None +* +* File: cm_mblk.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmAllocEvntNoInit +( +Size evntSize, /* Size of the Event structure */ +Size maxBlkSize, /* Chunk Memory size */ +Mem *sMem, /* Static memory region and pool */ +Ptr *ptr /* Location to place allocated event ptr */ +) +#else +PUBLIC S16 cmAllocEvntNoInit (evntSize,maxBlkSize,sMem,ptr) +Size evntSize; /* Size of the Event structure */ +Size maxBlkSize; /* Memory size requested */ +Mem *sMem; /* Static Memory region and pool */ +Ptr *ptr; /* Location to place allocated event ptr */ +#endif +{ + + Data *allocPtr; /* Allocated Memory Pointer */ + CmMemList *node; /* Memory Link List Node */ + CmMemListCp *memCp; /* memory Link list control point */ + CmMemCb *cb; /* Allocated Memory Control Block */ + + TRC2(cmAllocEvntNoInit) + + /* Validation check */ + if( evntSize > maxBlkSize) + RETVALUE(RFAILED); + + /* Allocate memory for the first Memory Chunk */ + /* Allocated memory should be maxBlkSize + sizeof(CmMemList) */ +#ifdef SS_LOCKLESS_MEMORY + if(SGetStaticBuffer(sMem->region, sMem->pool, (Data **)&allocPtr, + (Size)(maxBlkSize + sizeof(CmMemList)), 0) != ROK) +#else + if (SGetSBuf(sMem->region, sMem->pool, + (Data **)&allocPtr, + (Size)(maxBlkSize + sizeof(CmMemList))) != ROK) +#endif /* SS_LOCKLESS_MEMORY */ + + RETVALUE(RFAILED); + + /* Reset the contents */ + cmMemset((U8 *)allocPtr, (U8 )0, + (PTR)(sizeof(CmMemList)) ); + + /* The above allocated memory chunk is structured as follows + + +-------------------+ + | CmMemList | + +-------------------+ <---- Event Structure begins here + | CmMemListCp | ^ + +-------------------+ | + | Event data part | | evntSize + +-------------------+ | + .... | + .... \/ + +-------------------+ + + */ + + /* Overlay CmMemList structure on top of this allocated chunk */ + node = (CmMemList *)allocPtr; + /* cm_mblk_c_001.101: update size value */ + node->size = maxBlkSize; + + /* Get to CmMemListCp start */ + memCp = (CmMemListCp *) ((PTR)allocPtr + sizeof(CmMemList)); + + /* Initialise memListCp */ + CM_INIT_MEMCP( memCp,maxBlkSize,sMem); + + /* Add link list node to link list */ + cmAddMemNode(memCp, node); + + /* Get pointer to memCb inside MemListCp */ + cb = (CmMemCb *)&(memCp->memCb); + + /* Align evntSize, if necessary */ + CM_ALIGN_SIZE(evntSize); + + cb->memAllocated = (evntSize + sizeof(CmMemList) ); + cb->initPtr = (PTR)allocPtr; + *ptr = (Ptr) ((PTR)allocPtr + sizeof(CmMemList)); + cb->runPtr = ((PTR)(*ptr) + evntSize); + + RETVALUE(ROK); + +} /* End of cmAllocEvntNoInit */ + +/* +* +* Fun: cmGetMemNoInit +* +* Desc: This function parcels memory from memory chunks +* It allocated big chunk as and when required +* +* Ret: ROK +* +* Notes: None +* +* File: cm_mblk.c +* +*/ + +#ifdef ANSI +PUBLIC S16 cmGetMemNoInit +( +Ptr memPtr, /* Pointer to memCp */ +Size size, /* Memory size requested */ +Ptr *allocPtr /* location to place pointer */ +) +#else +PUBLIC S16 cmGetMemNoInit (memPtr,size,allocPtr) +Ptr memPtr; /* Pointer to memCp */ +Size size; /* Memory size requested */ +Ptr *allocPtr; /* location to place pointer */ +#endif +{ + + CmMemCb *cb; /* Pointer to Memory Control Block */ + CmMemList *node; /* Memory List node */ + CmMemListCp *memCp; /* Memory Control Point */ + /* cm_mblk_c_001.101: added local variable */ + Size blkSize; /* required block size */ + + TRC2(cmGetMemNoInit) + + memCp = (CmMemListCp *)memPtr; + cb = &memCp->memCb; + + /* Make requested size aligned, if necessary */ + CM_ALIGN_SIZE(size); + + /* cm_mblk_c_001.101 : If the requested size is greater than the configured + * max size, then allocate a new block with the requested size. This will + * enable us to handle large allocation requests in H.323 stack for certain + * information elements. This will not impact any normal allocation request + * as we fall back to the configured size */ + if( size > cb->maxSize) + blkSize = size; + else + blkSize = cb->maxSize; + + if( cb->initPtr) + { + /* if a chunk is already there */ + if( (cb->memAllocated + size) <= + (U32)(cb->maxSize + sizeof(CmMemList)) ) + { + /* Requested memory is available in present chunk */ + *allocPtr = (Ptr) cb->runPtr; + //cmMemset((U8 *)*allocPtr, (U8 )0, + // (PTR)(size) ); + cb->memAllocated += size; + cb->runPtr += size; + RETVALUE(ROK); + } + } + + /* For all other cases, We need to allocate a new memory chunk */ + /* Allocate buffer */ + /* cm_mblk_c_001.101: use blkSize instead of cb->maxSize */ +#ifdef SS_LOCKLESS_MEMORY + if(SGetStaticBuffer(cb->sMem.region, cb->sMem.pool, + (Data **)&(cb->initPtr), + (Size)(blkSize + sizeof(CmMemList)), 0) != ROK) +#else + if (SGetSBuf(cb->sMem.region, cb->sMem.pool, + (Data **)&(cb->initPtr), + (Size)(blkSize + sizeof(CmMemList)) ) != ROK) +#endif /* SS_LOCKLESS_MEMORY */ + RETVALUE(RFAILED); + + /* Reset the contents */ + /* Initialise above allocated structure */ + /* cm_mblk_c_001.101: use blkSize instead of cb->maxSize */ + cmMemset((U8 *)cb->initPtr, (U8 )0, + (PTR)(sizeof(CmMemList))); + /* The above allocated memory chunk is structured as follows + + +-------------------+ + | CmMemList | + +-------------------+ + Data Portion + .... + .... + +-------------------+ */ + + /* Overlay CmMemList structure on top of this allocated chunk */ + node = (CmMemList *)cb->initPtr; + /* cm_mblk_c_001.101: update size */ + node->size = blkSize; + + /* Add link list node to link list */ + cmAddMemNode(memCp, node); + + cb->memAllocated = (size + sizeof(CmMemList) ); + *allocPtr = (Ptr) ((PTR)cb->initPtr + sizeof(CmMemList)); + cb->runPtr = ((PTR)(*allocPtr) + size); + + RETVALUE(ROK); + +} /* End of cmGetMemNoInit */ + + + + +#endif + +/* +* +* Fun: cmFreeMem +* +* Desc: This function frees memory chunks after +* traversing link list +* +* Ret: ROK +* +* Notes: None +* +* File: cm_mblk.c +* +*/ + +#ifdef ANSI +PUBLIC Void cmFreeMem +( +Ptr memPtr /* Link List CP */ +) +#else +PUBLIC Void cmFreeMem (memPtr) +Ptr memPtr; /* Link List CP */ +#endif +{ + Mem sMem; /* Static Memory region and pool */ + S32 count; /* Count of linked blocks */ + /* cm_mblk_c_001.101: removed local variable maxSize */ + CmMemList *node; /* Pointer to link list node */ + CmMemList *prevNode; /* Pointer to previous node */ + CmMemListCp *lcp; /* Memory Link List */ + + TRC2(cmFreeMem) + + lcp = (CmMemListCp *)memPtr; + + sMem.region = lcp->memCb.sMem.region; + sMem.pool = lcp->memCb.sMem.pool; + count = lcp->count; + /* cm_mblk_c_001.101: removed getting maxSize value */ + + /* Free Memory by traversing Back to Front */ + node = lcp->last; + + /* Initialise memCp running variables */ + /* User may want to reuse same memCp for further */ + /* allocations, if memCp was not a part of */ + /* event structure */ + CM_INIT_MEMCPVAR(lcp); + + while(count && node) + { + prevNode = node->prev; + + /* Release complete memory for present chunk */ + /* cm_mblk_c_001.101: use node->size instead of maxSize */ + if( node ) + { +#ifdef SS_LOCKLESS_MEMORY + SPutStaticBuffer(sMem.region, sMem.pool, + (Data *)node, (node->size + sizeof(CmMemList)), 0); +#else + SPutSBuf(sMem.region,sMem.pool, + (Data *)node, (node->size + sizeof(CmMemList))); +#endif /* SS_LOCKLESS_MEMORY */ + } + node = prevNode; + count--; + } + + RETVOID; + +} /* End of cmFreeMem */ + + +/* +* +* Fun: cmAddMemNode +* +* Desc: adds node to Memory linked list after last. +* +* Ret: ROK - ok +* +* Notes: None +* +* File: cm_mblk.c +* +*/ +#ifdef ANSI +PRIVATE Void cmAddMemNode +( +CmMemListCp *lCp, /* list control point */ +CmMemList *node /* node to be added */ +) +#else +PRIVATE Void cmAddMemNode (lCp, node) +CmMemListCp *lCp; /* list control point */ +CmMemList *node; /* node to be added */ +#endif +{ + TRC3(cmAddMemNode); + + lCp->count++; + + node->prev = lCp->last; + node->next = NULLP; + lCp->last = node; + + if (!node->prev) + { + lCp->first = node; + RETVOID; + } + + node->prev->next = node; + RETVOID; + +} /* end of cmAddMemNode */ + + + +/* +* +* Fun: cmGetMemStatus +* +* Desc: This function returns the static memory status with +* parameters such as memory region and pool etc +* +* Ret: ROK +* +* Notes: None +* +* File: cm_mblk.c +* +*/ + +#ifdef ANSI +PUBLIC Void cmGetMemStatus +( +Ptr memPtr, /* Memory control pointer */ +CmMemStatus *status /* memory region,pool and status */ +) +#else +PUBLIC Void cmGetMemStatus (memPtr,status) +Ptr memPtr; /* Memory control pointer */ +CmMemStatus *status; /* memory region,pool and status */ +#endif +{ + + CmMemListCp *memCp; /* Memory Link List */ + + TRC3(cmGetMemStatus) + + memCp = (CmMemListCp *)memPtr; + + /* Copy relevant parameters */ + status->sMem.region = memCp->memCb.sMem.region; + status->sMem.pool = memCp->memCb.sMem.pool; + status->memBlkCnt = memCp->count; + status->maxBlkSize = memCp->memCb.maxSize; + status->memAllocated = memCp->memCb.memAllocated; + + RETVOID; + +} /* End of cmGetMemStatus */ + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/cm/cm_mem.c b/src/cm/cm_mem.c new file mode 100755 index 000000000..41a6843f5 --- /dev/null +++ b/src/cm/cm_mem.c @@ -0,0 +1,6895 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/********************************************************************20** + + Name: Common Memory Manager + + Type: C source file + + Desc: C source code for the Commom Memory Manager module. + + File: cm_mem.c + + Sid: cm_mem.c@@/main/28 - Fri Aug 26 13:52:41 2011 + + Prg: rm + +*********************************************************************21*/ + + +/************************************************************************ + +The following functions are provided in this file. + + cmMmRegInit Memory Region Initialization. + cmMmRegDeInit Memory Region Deinitialization. + +************************************************************************/ + + +/* header include files (.h) */ +#include "envopt.h" /* environment options */ +#include "envdep.h" /* environment dependent */ +#include "envind.h" /* environment independent */ + +#include "gen.h" /* general */ +#include "ssi.h" /* system services */ +#include "cm_mem.h" /* Common memory manager cm_mem_c_001.main_15 */ +#ifdef SS_MEM_LEAK_STS +#include +#include +#include +#ifdef SS_MEM_LEAK_SOL +#include +#include +#include +#else /* SS_MEM_LEAK_SOL */ +#include +#endif /* SS_MEM_LEAK_SOL */ +#include +#include "cm_hash.h" +#endif /* SS_MEM_LEAK_STS */ + +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 +#include "cm_hash.h" /* common hash functions */ +#endif +#ifdef SS_MULTICORE_SUPPORT /* cm_mem_c_001.main_14 */ +#include "ss_dep.h" /* implementation-specific */ +#include "ss_queue.h" /* queues */ +#include "ss_task.h" /* tasking */ +#endif +#ifdef SS_MULTICORE_SUPPORT +#include "ss_dep.h" /* implementation-specific */ +#include "ss_queue.h" /* queues */ +#include "ss_task.h" /* tasking */ +#endif + +/* header/extern include files (.x) */ +#include "gen.x" /* general */ +#include "ssi.x" /* system services */ +#ifdef SS_MULTICORE_SUPPORT +#include "ss_dep.x" /* implementation-specific */ +#include "ss_queue.x" /* queues */ +#include "ss_task.x" /* system services */ +#endif +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 +#include "cm_hash.x" /* common hash functions */ +#endif +#include "cm_mem.x" /* Common memory manager */ +/* cm_mem_c_001.main_28 : Fix for compilation warning */ +#include "cm_lib.x" /* common library functions */ +/* cm_mem_c_001.main_15: Addition */ +#ifdef SS_MEM_LEAK_STS +#include "cm_hash.x" /* common hash functions */ +#endif /* SS_MEM_LEAK_STS */ + +#ifdef USE_PURE +#include +#endif /* USE_PURE */ +#ifdef SS_MULTICORE_SUPPORT +#include "ss_dep.x" /* implementation-specific */ +#include "ss_queue.x" /* queues */ +#include "ss_task.x" /* system services */ +#endif + +#ifdef USE_PURE +#include +#endif /* USE_PURE */ + +#ifdef SS_LIGHT_MEM_LEAK_STS + MemLeakCb gmemLkCb; + U32 queueIndxAllocCnt =0; + U32 queueIndxFreeCnt =0; + U32 allocQueueFullCnt =0; + U32 allocQueueEmptyCnt =0; +#endif + +/* local defines */ + +/* local typedefs */ + +/* local externs */ + +/* forward references */ +/* cm_mem_c_001.main_12 - prototype is changed to accept memType(static/dynamic) */ +/* cm_mem_c_001.main_15: Addition */ +/* cm_mem_c_001.main_22: Fixing warnings on GCC compiler*/ +#ifdef __cplusplus + extern "C" { +#endif + +#ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */ +PUBLIC U32 memFreeCount=0; +PUBLIC U32 cmFreeCaller[4]={0}; +PUBLIC U32 cmAllocCaller[4]={0}; +PUBLIC Data *startPtr256=NULLP; +PUBLIC Data *startPtr128=NULLP; +PUBLIC U32 cmMemInfo128[100000][2]={0, 0}; +PUBLIC U32 cmMemInfo256[100000][2]={0, 0}; +PUBLIC Data *startPtr512=NULLP; +PUBLIC Data *startPtr768=NULLP; +PUBLIC Data *startPtr1664=NULLP; +PUBLIC Data *startPtr4800=NULLP; +PUBLIC Data *startPtr9920=NULLP; +PUBLIC Size regMemSize=0; +#endif +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL2 +//extern CmMmRegCb *mtCMMRegCb[SS_MAX_REGS]; +#endif +#ifdef SS_HISTOGRAM_SUPPORT +#ifdef SSI_DEBUG_LEVEL1 +PRIVATE S16 cmAlloc ARGS((Void *regionCb, Size *size, U32 flags, Data **ptr, + U32 memType, U32 line, U8 *fileName, U8 entId, Bool hstReg)); +PRIVATE S16 cmHeapAlloc ARGS((CmMmHeapCb *heapCb, Data **ptr, Size *size, U32 memType, U32 line, U8 *fileName, U8 entId, Bool hstReg)); +/*cm_mem_c_001.main_20-added new functionto allocate memory from new region*/ +#else +PRIVATE S16 cmHeapAlloc ARGS((CmMmHeapCb *heapCb, Data **ptr, Size *size, + U32 line, U8 *fileName, U8 entId, Bool hstReg)); +PRIVATE S16 cmAlloc ARGS((Void *regionCb, Size *size, U32 flags, Data **ptr, + U32 line, U8 *fileName, U8 entId, Bool hstReg)); +#endif /* SSI_DEBUG_LEVEL1 */ + +PRIVATE S16 cmFree ARGS((Void *regionCb, Data *ptr, Size size, U32 line, + U8 *fileName, U8 entId, Bool hstReg)); + +PRIVATE S16 cmHeapFree ARGS((CmMmHeapCb *heapCb, Data *ptr, Size size, + U32 line, U8 *fileName, U8 entId, Bool hstReg)); +#else /* no histogram support */ +/* cm_mem_c_001.main_12 - prototype is changed to accept memType(static/dynamic) */ +#ifdef SSI_DEBUG_LEVEL1 +PRIVATE S16 cmHeapAlloc ARGS((CmMmHeapCb *heapCb, Data **ptr, Size *size, U32 memType)); +#else +#ifndef USE_PURE +PRIVATE S16 cmHeapAlloc ARGS((CmMmHeapCb *heapCb, Data **ptr, Size *size)); +#endif/*USE_PURE*/ +#endif /* SSI_DEBUG_LEVEL1 */ +#ifndef USE_PURE +PRIVATE S16 cmHeapFree ARGS((CmMmHeapCb *heapCb, Data *ptr, Size size)); +#endif/*USE_PURE*/ +/* cm_mem_c_001.main_15 :Additions */ +#ifdef SS_LIGHT_MEM_LEAK_STS +PRIVATE S16 cmAlloc ARGS((Void *regionCb, Size *size, U32 flags, Data **ptr, U32 memType, U32 lineNo,U8 *funcName )); +PRIVATE S16 cmFree ARGS((Void *regionCb, Data *ptr, Size size, U32 lineNo, U8* funcName)); +#else /*SS_LIGHT_MEM_LEAK_STS */ +#if (defined(SSI_DEBUG_LEVEL1) || defined(BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1)) +PRIVATE S16 cmAlloc ARGS((Void *regionCb, Size *size, U32 flags, Data **ptr, U32 memType)); +#else +#ifdef T2K_MEM_LEAK_DBG +PRIVATE S16 cmAlloc ARGS((Void *regionCb, Size *size, U32 flags, Data **ptr, char* file, U32 line)); +#else +PRIVATE S16 cmAlloc ARGS((Void *regionCb, Size *size, U32 flags, Data **ptr)); +#endif +#endif /* SSI_DEBUG_LEVEL1 */ +#ifdef T2K_MEM_LEAK_DBG +PRIVATE S16 cmFree ARGS((Void *regionCb, Data *ptr, Size size, char* file, U32 line)); +#else +PRIVATE S16 cmFree ARGS((Void *regionCb, Data *ptr, Size size)); +#endif +#endif /* SS_HISTOGRAM_SUPPORT */ +#endif /*SS_LIGHT_MEM_LEAK_STS*/ +/*cm_mem_c_001.main_23 Removed support of SSI_DEBUG_LEVEL1 and SS_HISTOGRAM_SUPPORT for SS_FAP*/ +#ifdef SS_FAP +PRIVATE S16 cmAllocWL ARGS((Void *regionCb, Size *size, U32 flags, Data **ptr)); +PRIVATE S16 cmFreeWL ARGS((Void *regionCb, Data *ptr, Size size)); +#endif + +PRIVATE S16 cmCtl ARGS((Void *regionCb, Event event, SMemCtl *memCtl)); + +PRIVATE Void cmMmHeapInit ARGS((Data *memAddr, CmMmHeapCb *heapCb, Size size)); +PRIVATE Void cmMmBktInit ARGS((Data **memAddr, CmMmRegCb *regCb, + CmMmRegCfg *cfg, U16 bktIdx, U16 *lstMapIdx)); + +/* cm_mem_c_001.main_12 - addition of protoypes for sanity check and hash list functions */ +#ifdef SSI_DEBUG_LEVEL1 +PRIVATE S16 cmMmBktSanityChk ARGS((CmMmBkt *bkt)); +PRIVATE S16 cmMmHeapSanityChk ARGS((CmMmHeapCb *heapCb)); +PRIVATE S16 cmMmHashFunc ARGS((CmMmHashListCp *hashListCp, U32 key, U16 *idx )); +PRIVATE S16 cmMmHashListInit ARGS((CmMmHashListCp *hashListCp, U16 nmbBins, + Region region, Pool pool)); +PRIVATE S16 cmMmHashListDeinit ARGS((CmMmHashListCp *hashListCp, Region region, Pool pool)); +PRIVATE S16 cmMmHashListInsert ARGS((CmMmHashListCp *hashListCp, U32 key)); +#endif /* SSI_DEBUG_LEVEL1 */ +/* cm_mem_c_001.main_15 : Addtions */ +#ifdef SS_HISTOGRAM_SUPPORT +PRIVATE S16 cmHstGrmAllocInsert ARGS((CmHstGrmHashListCp *hashListCp, U32 blkSz, U32 *reqSz, U32 line, U8 *fileName, U8 entId)); +PRIVATE S16 cmHstGrmFreeInsert ARGS((CmHstGrmHashListCp* hashListCp, U32 blkSz, U32 line, U8 *fileName, U8 entId)); +PRIVATE S16 cmHstGrmHashListInit ARGS((CmHstGrmHashListCp *hashListCp)); +PRIVATE S16 cmHstGrmHashListDeInit ARGS((CmHstGrmHashListCp *hashListCp)); +PRIVATE S16 cmHstGrmGetHashIdxAndKey ARGS((U8 *fileName, U32 line, U32 *binIdx, U32 *key)); +PRIVATE S16 cmHstGrmFindEntry ARGS((CmHstGrmHashListCp *hashListCp, U32 key, U32 *binIdx, CmMemEntries **entry)); +PRIVATE S16 cmHstGrmFillEntry ARGS((CmMemEntries *entry, U32 key, U32 line, U8 *fileName, U8 entId)); +#endif /* SS_HISTOGRAM_SUPPORT */ + +/* cm_mem_c_001.main_22: Fixing warnings on GCC compiler */ +#ifdef __cplusplus +} +#endif + +/* public variable declarations */ +#ifdef USE_PURE +Size avail_size; +#endif /* USE_PURE */ +/* cm_mem_c_001.main_15:Additions */ +#ifdef SS_MEM_LEAK_STS +MemUsrMdlStr memUsrMdlStr[]= +{ + MEMRAW2STR(DEFAULT, STACK), + MEMRAW2STR(tc, PDCP_LAYER), + MEMRAW2STR(Tc, PDCP_LAYER), + MEMRAW2STR(mg, GCP_LAYER), + MEMRAW2STR(Mg, GCP_LAYER), + {NULLP, NULLP} +}; + +MemLkCb memLkCb; +#endif /* SS_MEM_LEAK_STS */ +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL2 +MemLkInfo memLk; +#endif + + + +#ifdef T2K_MEM_LEAK_DBG +typedef struct { +U8 minBktSzBitMask; /* minimum allocation size in Log(x)base 2, where X is minimum bucket size in region */ +U16 minBktSzMins1; /* X-1 */ +}RegMinBktSzInfo; +static RegMinBktSzInfo regMinBktSzInfo[SS_MAX_REGS] = {{8,0xFF},{7,0x7F},{7,0x7F},{7,0x7F}}; +RegionMemLeakInfo regMemLeakInfo; + +U32 getT2kMemLeakIndex(U64 address, Region region) +{ + return ((address - regMemLeakInfo.regStartAddr[region]) >> regMinBktSzInfo[region].minBktSzBitMask); +} + +static U32 t2kMemAllocTick; +static U32 smallTick; + +void InsertToT2kMemLeakInfo(U64 address, U32 size, U32 lineNo, char* fileName, Region region) +{ + + T2kMeamLeakInfo *leakInfo; + /* if(!startMemLeak) + { + RETVOID; + }*/ + + U32 index1 = getT2kMemLeakIndex(address,region); + + if(((U64)(address - regMemLeakInfo.regStartAddr[region]) & regMinBktSzInfo[region].minBktSzMins1) !=0) + { + printf("address in InsertToT2kMemLeakInfo is %ld size = %d file is %s line is %d \n", address, size, fileName, lineNo); + } + + leakInfo = (((T2kMeamLeakInfo*)(regMemLeakInfo.gMemLeakInfo[region])) + index1); + if(leakInfo->address == 0) + { + leakInfo->address = address; + leakInfo->size = size; + leakInfo->lineNo = lineNo; + leakInfo->fileName = fileName; + leakInfo->age = t2kMemAllocTick; + leakInfo->prevRemLineNo = 0; + leakInfo->prevRemFileName = '\0'; + + //printf("InsertToT2kMemLeakInfo the adress from List Address = %x, index1 = %d from File=%s, line=%d \n",address,index1,fileName,lineNo); + if(smallTick++ == 4096) + { + smallTick = 0; + leakInfo->age = (++t2kMemAllocTick); + } + } + else + { + printf("Something is wrong, trying to insert %ld index1 = %d file is %s line is %d \n",address, index1, fileName, lineNo); + printf("Address present :%ld, from File:%s, Line:%d, Size:%d, Age:%d", + leakInfo->address, leakInfo->fileName, + leakInfo->lineNo, leakInfo->size, + leakInfo->age); + } +} + + +void RemoveFromT2kMemLeakInfo(U64 address, char *file, U32 line,Region region) +{ + T2kMeamLeakInfo *leakInfo; + + /* if(!startMemLeak) + { + RETVALUE(ROK); + }*/ + + U32 index1 = getT2kMemLeakIndex(address, region); + + if(index1 >= T2K_MEM_LEAK_INFO_TABLE_SIZE) + { + printf("index1 out of range = %d address is %ld file = %s line = %d. We are going to crash!!!\n", + index1, + address, + file, + line); + } + leakInfo = (((T2kMeamLeakInfo*)(regMemLeakInfo.gMemLeakInfo[region])) + index1); + if(leakInfo->address == address) + { + + leakInfo->address = 0; + leakInfo->age = 0; + leakInfo->prevRemLineNo = leakInfo->lineNo; + leakInfo->prevRemFileName = leakInfo->fileName; + leakInfo->lastDelLineNum = line; + leakInfo->lastDelFileName = file; + } + else + { + printf("Something is wrong, trying to remove %ld index1 = %d from File=%s, line=%d address present is %ld region%d \n",address, index1, file,line,leakInfo->address,region); + + printf("\n Last Del file %s line %d\n",leakInfo->lastDelFileName, + leakInfo->lastDelLineNum); + + if(leakInfo->prevRemFileName != NULLP) + { + printf("Previous File:%s, Previous Line:%d\n", + leakInfo->prevRemFileName, leakInfo->prevRemLineNo); + } + } +} + +void DumpT2kMemLeakInfoToFile() +{ + int i,reg; + T2kMeamLeakInfo *leakInfo; + + FILE *fp = fopen("memLeakInfo_reg.txt","wb"); + + if(fp == NULL) + { + printf("Could not open file for dumping mem leak info\n"); + return; + } + for(reg=0; reg address != 0) + { + char* onlyFileName = rindex(leakInfo->fileName,'/'); + if(onlyFileName == NULL) + { + onlyFileName = leakInfo->fileName; + } + + fprintf(fp, "%ld s=%d a=%d l=%d f=%s\n",leakInfo->address, + leakInfo->size, + leakInfo->age, + leakInfo->lineNo, + onlyFileName); + } + } + fprintf(fp, "REGION %d LEAKS END\n",reg); + } + fprintf(fp,"Current t2kMemAllocTick = %d\n",t2kMemAllocTick); + + fclose(fp); +} +#endif /* T2K_MEM_LEAK_DBG */ + +/* cm_mem_c_008.104 - Addition for memory calculator tool */ +#ifdef MEMCAL_DEBUG +PRIVATE Txt prntBuf[200]; /* print buffer */ +PRIVATE U8 tryHeap=0; +#endif + +/* cm_mem_c_001.main_12 - addition for ssi enhancements prints */ +/* cm_mem_c_001.main_20 Additions */ +#if (defined(SSI_DEBUG_LEVEL1) || defined(SS_HISTOGRAM_SUPPORT) || \ + defined(BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1)) +#ifdef DEBUGP +PRIVATE Txt dbgPrntBuf[200]; /* print buffer */ +#endif /* DEBUGP */ +#endif /*SSI_DEBUG_LEVEL1 || SS_HISTOGRAM_SUPPORT */ + +U32 num_times = 0; +#ifdef SSI_MEM_CORR_PREVENTION +U32 cmDblFreeAttempts = 0; +#endif +/* private variable declarations */ + + +/* +* +* Fun: cmMmRegInit +* +* Desc: Configure the memory region for allocation. The function +* registers the memory region with System Service by calling +* SRegRegion. +* +* +* Ret: ROK - successful, +* RFAILED - unsuccessful. +* +* Notes: The memory owner calls this function to initialize the memory +* manager with the information of the memory region. Before +* calling this function, the memory owner should allocate memory +* for the memory region. The memory owner should also provide the +* memory for the control block needed by the memory manager. The +* memory owner should allocate the memory for the region control +* block as cachable memory. This may increase the average +* throughput in allocation and deallocation as the region control +* block is mostly accessed by the CMM. +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmMmRegInit +( +Region region, +CmMmRegCb *regCb, +CmMmRegCfg *cfg +) +#else +PUBLIC S16 cmMmRegInit(region, regCb, cfg) +Region region; +CmMmRegCb *regCb; +CmMmRegCfg *cfg; +#endif +{ + Data *memAddr; + U16 bktIdx; + U16 lstMapIdx; + +#if (ERRCLASS & ERRCLS_INT_PAR) + Size lstQnSize; + Size bktBlkSize; + Txt errMsg[256] = {'\0'}; +#endif +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + U16 offset; + CmMmBlkHdr ptrHdr; +#endif + + TRC2(cmMmRegInit); + +#if (ERRCLASS & ERRCLS_INT_PAR) + + /* error check on parameters */ + if ((regCb == NULLP) || (cfg == NULLP)) + { + RETVALUE(RFAILED); + } + + /* Error check on the configuration fields */ + if ((!cfg->size) || (cfg->vAddr == NULLP) || + (cfg->numBkts > CMM_MAX_BKT_ENT)) + { + RETVALUE(RFAILED); + } + /* Check if the quantum size is power of 2 */ + if ((cfg->numBkts) && + ((cfg->bktQnSize - 1) & (cfg->bktQnSize))) + { + /* cm_mem_c_001.main_20 Addition */ + sprintf(errMsg,"\n cmMmRegInit() failed, check if BktQuantum size might not be power of 2 \n"); + SPrint(errMsg); + RETVALUE(RFAILED); + } + + /* + * Check if the size of the memory region is enough, whether bucket sizes + * are multiples of quantumn size, and also whether two consecutive buckets + * falls within same quanta. + */ + lstQnSize = cfg->bktQnSize; + regCb->bktSize = 0; + + for ( bktIdx =0; bktIdx < cfg->numBkts; bktIdx++) + { + /* check if bucket size is mutiple of quantum size */ + if (cfg->bktCfg[bktIdx].size % cfg->bktQnSize) + { + /* cm_mem_c_001.main_20 Addition */ +/*cm_mem_c_001.main_23 Fix for specifier mismatch warnings in 64BIT compilation*/ +#ifdef ALIGN_64BIT + sprintf(errMsg,"\n cmMmRegInit() failed, Bkt:%d size:%u not multiple of quantum size:%u\ + \n",bktIdx,cfg->bktCfg[bktIdx].size,cfg->bktQnSize); +#else + sprintf(errMsg,"\n cmMmRegInit() failed, Bkt:%d size:%lu not multiple of quantum size:%lu\ + \n",bktIdx,cfg->bktCfg[bktIdx].size,cfg->bktQnSize); +#endif + SPrint(errMsg); + RETVALUE(RFAILED); + } + + if ((bktBlkSize = cfg->bktCfg[bktIdx].size) < lstQnSize) + { + /* + * Two consecutive buckets are not separated by quantum size. + */ + /* cm_mem_c_001.main_20 Addition */ + sprintf(errMsg,"\n cmMmRegInit() failed, Two consecutive buckets are not separated by quantum size \n"); + SPrint(errMsg); + RETVALUE(RFAILED); + } + /* cm_mem_c_001.main_20 Addition */ + if (((cfg->bktCfg[bktIdx].size) /\ + cfg->bktQnSize) > CMM_MAX_MAP_ENT) + { + /* Error check whether the size of the mapping table is sufficient */ +/*cm_mem_c_001.main_23 Fix for specifier mismatch warnings in 64BIT compilation*/ +#ifdef ALIGN_64BIT + sprintf(errMsg,"\n cmMmRegInit() failed, check maxBucketSize/BktQuantumSize(%u)\ + \n should be less than CMM_MAX_MAP_ENT:%d \n",cfg->bktQnSize,CMM_MAX_MAP_ENT); +#else + sprintf(errMsg,"\n cmMmRegInit() failed, check maxBucketSize/BktQuantumSize(%lu)\ + \n should be less than CMM_MAX_MAP_ENT:%d \n",cfg->bktQnSize,CMM_MAX_MAP_ENT); +#endif + SPrint(errMsg); + RETVALUE(RFAILED); + } + + + regCb->bktSize += (cfg->bktCfg[bktIdx].size * + cfg->bktCfg[bktIdx].numBlks); + + if (regCb->bktSize > cfg->size) + { + /* Size of the memory region is less than the required size */ + + sprintf(errMsg,"\n cmMmRegInit() failed, Size of the memory region is less than the required size \n"); + SPrint(errMsg); + RETVALUE(RFAILED); + } + + lstQnSize = ((bktBlkSize / cfg->bktQnSize) + 1) * cfg->bktQnSize; + } + +#endif + + /* Initialize the region control block */ + regCb->region = region; + regCb->regInfo.regCb = regCb; + regCb->regInfo.start = cfg->vAddr; + regCb->regInfo.size = cfg->size; + +#ifdef USE_PURE + avail_size = cfg->size; +#endif /* USE_PURE */ + + if ( cfg->chFlag & CMM_REG_OUTBOARD) + { + /* Out_of_board memory */ + regCb->regInfo.flags = CMM_REG_OUTBOARD; + } + else + { + regCb->regInfo.flags = 0; + } + + +/* Initialize the memory manager function handlers */ + /*cm_mem_c_001.main_21-registering new alloc function for new region*/ +#ifdef SS_FAP + if(region == SS_WL_REGION) + { + regCb->regInfo.alloc = cmAllocWL; + regCb->regInfo.free = cmFreeWL; + } + else +#endif + { + /* Initialize the memory manager function handlers */ + regCb->regInfo.alloc = cmAlloc; + regCb->regInfo.free = cmFree; + } + regCb->regInfo.ctl = cmCtl; + + /* Initialize the physical address */ + if ((regCb->chFlag = cfg->chFlag) & CMM_REG_PHY_VALID) + { + regCb->pAddr = cfg->pAddr; + } + + /* Initial address of the memory region block */ + memAddr = cfg->vAddr; + + /* Initialize the fields related to the bucket pool */ + regCb->bktMaxBlkSize = 0; + regCb->bktSize = 0; + + if (cfg->numBkts > 0 && cfg->numBkts < CMM_MAX_BKT_ENT) + { + /* Last bucket has the maximum size */ + regCb->bktMaxBlkSize = cfg->bktCfg[cfg->numBkts - 1].size; + + /* Get the power of the bktQnSize */ + regCb->bktQnPwr = 0; + while( !((cfg->bktQnSize >> regCb->bktQnPwr) & 0x01)) + { + regCb->bktQnPwr++; + } + + /* Initilaize the bktIndex of the map entries to FF */ + for ( lstMapIdx = 0; lstMapIdx < CMM_MAX_MAP_ENT; lstMapIdx++) + { + regCb->mapTbl[lstMapIdx].bktIdx = 0xFF; + } + + lstMapIdx = 0; + for ( bktIdx = 0; bktIdx < cfg->numBkts; bktIdx++) + { + /* Allocate the lock for the bucket pool */ + /* cm_mem_c_001.main_13 : Replaced SInitLock with WTInitLock for NT */ +#ifdef SS_WIN + if (WTInitLock (&(regCb->bktTbl[bktIdx].bktLock), cfg->lType) != ROK) +#else + if (SInitLock (&(regCb->bktTbl[bktIdx].bktLock), cfg->lType) != ROK) +#endif + { + /* Free the initialzed lock for the earlier buckets. */ + for ( ;bktIdx > 0;) + { + /* cm_mem_c_001.main_13: Replaced SDestroyLock with + WTDestroyLock for NT */ + /* cm_mem_c_001.main_24 fix for memory corruption*/ + --bktIdx; +#ifdef SS_WIN + WTDestroyLock(&(regCb->bktTbl[bktIdx].bktLock)); +#else + SDestroyLock(&(regCb->bktTbl[bktIdx].bktLock)); +#endif + } + + RETVALUE(RFAILED); + } + + cmMmBktInit( &memAddr, regCb, cfg, bktIdx, &lstMapIdx); + } + + /* Used while freeing the bktLock in cmMmRegDeInit */ + regCb->numBkts = cfg->numBkts; + } + + /* + * Initialize the heap pool if size the memory region region is more + * than the size of the bucket pool + */ + regCb->heapSize = 0; + regCb->heapFlag = FALSE; + + /* Align the memory address */ + memAddr = (Data *)(PTRALIGN(memAddr)); + + regCb->heapSize = cfg->vAddr + cfg->size - memAddr; + + /* + * Round the heap size so that the heap size is multiple + * of CMM_MINBUFSIZE + */ + regCb->heapSize -= (regCb->heapSize % CMM_MINBUFSIZE); + + if (regCb->heapSize) + { + /* Allocate the lock for the heap pool */ + /* cm_mem_c_001.main_13 : Replaced SInitLock with WTInitLock for NT */ +#ifdef SS_WIN + if (WTInitLock (®Cb->heapCb.heapLock, cfg->lType) != ROK) +#else + if (SInitLock (®Cb->heapCb.heapLock, cfg->lType) != ROK) +#endif + { + bktIdx = cfg->numBkts;/* ccpu00125353: warning fix */ + if (bktIdx != 0) + { + /* Free the initialzed locks of the buckets */ + for (; bktIdx > 0;) + { + /* cm_mem_c_001.main_13: Replaced SDestroyLock with + WTDestroyLock for NT */ + /* cm_mem_c_001.main_24 fix for memory corruption*/ + --bktIdx; +#ifdef SS_WIN + WTDestroyLock(&(regCb->bktTbl[bktIdx].bktLock)); +#else + SDestroyLock(&(regCb->bktTbl[bktIdx].bktLock)); +#endif + } + } + + RETVALUE(RFAILED); + } + + regCb->heapFlag = TRUE; + cmMmHeapInit(memAddr, &(regCb->heapCb), regCb->heapSize); + } + + /* Call SRegRegion to register the memory region with SSI */ + if (SRegRegion(region, ®Cb->regInfo) != ROK) + { + RETVALUE(RFAILED); + } + +/* cm_mem_c_001.main_12 - addition for initializing the hash table */ +#ifdef SSI_DEBUG_LEVEL1 + /* Initialize the region level hash table for debug info storage */ + if (cmMmHashListInit(®Cb->hashListCp, CMM_STAT_HASH_TBL_LEN, region, 0) != ROK) + { + RETVALUE(RFAILED); + } +#endif /* SSI_DEBUG_LEVEL1 */ +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL2 + /* Initialize the hast list to maintain the SSI memory information for Broadcom */ + offset = (U16)((PTR)(&ptrHdr.ent) - (PTR) &ptrHdr); + printf("###########offset is %d region %d\n", offset, region); + if(cmHashListInit(®Cb->brdcmSsiLstCp, 1000, offset, FALSE, + CM_HASH_KEYTYPE_U32MOD, region, 0) != ROK) + { + RETVALUE(RFAILED); + } +#endif /* SSI_DEBUG_LEVEL1 */ + + RETVALUE(ROK); +} /* end of cmMmRegInit*/ + + + +/* +* +* Fun: cmMmRegDeInit +* +* Desc: Deinitialize the memory region. The function call SDeregRegion +* to deregister the memory region with System Service. +* +* +* Ret: ROK - successful +* RFAILED - unsuccessful. +* +* Notes: The memory owner calls this function to deinitialize the region. +* The memory manager does not return the memory to the system. +* Before calling this function, the memory owner must be sure that +* no layer is using any memory block from this region. On +* successful return from the function, any request to the memory +* manager to allocate/deallocate memory will fail. The memory owner +* can reuse the memory for other region or return the memory to the +* system memory pool. +* +* +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmMmRegDeInit +( +CmMmRegCb *regCb +) +#else +PUBLIC S16 cmMmRegDeInit(regCb) +CmMmRegCb *regCb; +#endif +{ + U16 bktIdx; + + TRC2(cmMmRegDeInit); + +#if (ERRCLASS & ERRCLS_INT_PAR) + + /* error check on parameters */ + if (regCb == NULLP) + { + RETVALUE(RFAILED); + } + +#endif + +/* cm_mem_c_001.main_12 - addition for deinitializing the hash table */ +#ifdef SSI_DEBUG_LEVEL1 + /* Deinitialize the hash table used for debug info storage at region level */ + if (cmMmHashListDeinit(®Cb->hashListCp, regCb->region, 0) != ROK) + { + RETVALUE(RFAILED); + } +#endif /* SSI_DEBUG_LEVEL1 */ +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL2 + /* Deinitialize the hash table used for broadcom ssi instrumentation */ + if (cmHashListDeinit(®Cb->brdcmSsiLstCp) != ROK) + { + RETVALUE(RFAILED); + } +#endif + + /* Call SDeregRegion first to deregister the memory region with SSI */ + (Void) SDeregRegion (regCb->region); + + if (regCb->bktSize) + { + /* Bucket pool is configured */ + + /* Free the initialzed locks of the buckets */ + for ( bktIdx = regCb->numBkts; bktIdx > 0;) + { + /* cm_mem_c_001.main_13: Replaced SDestroyLock with + WTDestroyLock for NT */ + /* cm_mem_c_001.main_24 fix for memory corruption*/ + --bktIdx; +#ifdef SS_WIN + WTDestroyLock(&(regCb->bktTbl[bktIdx].bktLock)); +#else + SDestroyLock(&(regCb->bktTbl[bktIdx].bktLock)); +#endif +/* cm_mem_c_001.main_15:Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + /* De-initialise the memory histogram hash list */ + cmHstGrmHashListDeInit(&(regCb->bktTbl[bktIdx].hstGrmHashListCp)); +#endif /* SS_HISTOGRAM_SUPPORT */ + } + } + + if (regCb->heapFlag) + { + /* Heap pool is configured */ + + /* cm_mem_c_001.main_13: Replaced SDestroyLock with + WTDestroyLock for NT */ +#ifdef SS_WIN + WTDestroyLock(®Cb->heapCb.heapLock); +#else + SDestroyLock(®Cb->heapCb.heapLock); +#endif + } + + RETVALUE(ROK); + +} /* end of cmMmRegDeInit */ + +#ifdef CM_MEM_OVERUSED +#define OVERUSED(_bkt) (((_bkt)->numAlloc * 100) / (_bkt)->numBlks > 80) + +int g_overused[5] = {0}; +#endif + +#ifdef CM_MEM_PRINT_DEFINED +volatile int gSubIndex = 0; +int regAllocBktSts[10][2][6]={{0}}; +int regFreeBktSts[10][2][6]={{0}}; +#endif + +/* +* +* Fun: cmAlloc +* +* Desc: Allocate a memory block for the memory region. +* +* +* Ret: ROK - successful +* RFAILED - unsuccessful. +* +* Notes: +* The function allocates a memory block of size atleast equal to +* the requested size. The size parameter will be updated with the +* actual size of the memory block allocated for the request. The +* CMM tries to allocate the memory block form the bucket pool. If +* there is no memory in the bucket the CMM allocates the memory +* block form the heap pool. This function is always called by the +* System Service module. +* +* The caller of the function should try to use the out value of +* the size while returning the memory block to the region. However +* the current design of the memory manager does not enforce to pass +* the actual size of the memory block. (Due to the SGetSBuf +* semantics the layer will not able to pass the correct size of the +* memory block while calling SPutSBuf). +* +* +* File: cm_mem.c +* +*/ +/* cm_mem_c_001.main_12 - addition to accept new parameter memType(static/dynamic) */ + +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT +#ifdef SSI_DEBUG_LEVEL1 +#ifdef ANSI +PRIVATE S16 cmAlloc +( +Void *regionCb, +Size *size, +U32 flags, +Data **ptr, +U32 memType, +U32 line, +U8 *fileName, +U8 entId, +Bool hstReg +) +#else +PRIVATE S16 cmAlloc(regionCb, size, flags, ptr, memType, line, fileName, entId, hstReg) +Void *regionCb; +Size *size; +U32 flags; +Data **ptr; +U32 memType; +U32 line; +U8 *fileName; +U8 entId; +Bool hstReg; +#endif +#else +#ifdef ANSI +PRIVATE S16 cmAlloc +( +Void *regionCb, +Size *size, +U32 flags, +Data **ptr, +U32 line, +U8 *fileName, +U8 entId, +Bool hstReg +) +#else +PRIVATE S16 cmAlloc(regionCb, size, flags, ptr, line, fileName, entId, hstReg) +Void *regionCb; +Size *size; +U32 flags; +Data **ptr; +U32 line; +U8 *fileName; +U8 entId; +Bool hstReg; +#endif +#endif /* SSI_DEBUG_LEVEL1 */ +#else +#ifdef SS_LIGHT_MEM_LEAK_STS +#ifdef ANSI +PRIVATE S16 cmAlloc +( +Void *regionCb, +Size *size, +U32 flags, +Data **ptr, +U32 memType, +U32 lineNo, +U8 *funcName +) +#else +PRIVATE S16 cmAlloc(regionCb, size, flags, ptr ,memType, lineNo, funcName) +Void *regionCb; +Size *size; +U32 flags; +Data **ptr; +U32 memType; +U32 lineNo; +U8 *funcName; +#endif +#else /*SS_LIGHT_MEM_LEAK_STS */ +#ifdef SSI_DEBUG_LEVEL1 +#ifdef ANSI +PRIVATE S16 cmAlloc +( +Void *regionCb, +Size *size, +U32 flags, +Data **ptr, +U32 memType +) +#else +PRIVATE S16 cmAlloc(regionCb, size, flags, ptr, memType) +Void *regionCb; +Size *size; +U32 flags; +Data **ptr; +U32 memType; +#endif +#else +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 +#ifdef ANSI +PRIVATE S16 cmAlloc +( +Void *regionCb, +Size *size, +U32 flags, +Data **ptr, +U32 memType +) +#else +PRIVATE S16 cmAlloc(regionCb, size, flags, ptr, memType) +Void *regionCb; +Size *size; +U32 flags; +Data **ptr; +U32 memType; +#endif +#else +#ifdef T2K_MEM_LEAK_DBG +PRIVATE S16 cmAlloc +( + Void *regionCb, + Size *size, + U32 flags, + Data **ptr , + char* file, + U32 line + ) +#else +#ifdef ANSI +PRIVATE S16 cmAlloc +( +Void *regionCb, +Size *size, +U32 flags, +Data **ptr +) +#else +PRIVATE S16 cmAlloc(regionCb, size, flags, ptr) +Void *regionCb; +Size *size; +U32 flags; +Data **ptr; +#endif +#endif +#endif /* BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 */ +#endif /* SSI_DEBUG_LEVEL1 */ +#endif /*SS_LIGHT_MEM_LEAK_STS */ +/* cm_mem_c_001.main_15: Additions */ +#endif /* SS_HISTOGRAM_SUPPORT */ + +{ +/* cm_mem_c_001.main_26 : Fixes for Compilation Warnings */ +#ifndef USE_PURE + U16 idx; + CmMmBkt *bkt; +#endif + CmMmRegCb *regCb; +/* cm_mem_c_001.main_26 : Fixes for Compilation Warnings */ +#ifndef USE_PURE + U16 cnt; +#endif +/* cm_mem_c_001.main_15 : Additions */ +#if (defined(SS_MEM_LEAK_STS) || defined( BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1)) + Size reqSz; +#endif /* SS_MEM_LEAK_STS */ +/* cm_mem_c_001.main_12 - addition to hold the allocated block */ +#if (defined(SSI_DEBUG_LEVEL1) || defined(BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1) || defined (SS_LIGHT_MEM_LEAK_STS)) + CmMmBlkHdr *alocBlk; +#endif /* SSI_DEBUG_LEVEL1 */ +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL2 + CmMmBlkHdr *ptrHdr; +#endif +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + S8 hstGrmBuf[256]; +#endif /* SS_HISTOGRAM_SUPPORT */ +#ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */ + U16 memIndex=0; +Data *nextptr1; +Data *prevptr1; +Data **nextptr; +Data **prevptr; + nextptr=&nextptr1; + prevptr=&prevptr1; +#endif + + TRC2(cmAlloc); + +#ifndef USE_MEMCAL + UNUSED(flags); +#endif +/* cm_mem_c_001.main_15 : Additions */ +#if (defined(SS_MEM_LEAK_STS) || defined( BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1)) + reqSz = *size; +#endif /* SS_MEM_LEAK_STS */ + + regCb = (CmMmRegCb *)regionCb; + +#if (ERRCLASS & ERRCLS_INT_PAR) + + /* error check on parameters */ + if ((regCb == NULLP) || (size == NULLP) || !(*size) || (ptr == NULLP)) + { + RETVALUE(RFAILED); + } +#endif + +/* cm_mem_c_001.main_12 - addition for checking memType parameter */ +#ifdef SSI_DEBUG_LEVEL1 +#if (ERRCLASS & ERRCLS_INT_PAR) + if ((memType != CMM_STATIC_MEM_FLAG) && (memType != CMM_DYNAMIC_MEM_FLAG)) + { + RETVALUE(RFAILED); + } +#endif /* (ERRCLASS & ERRCLS_INT_PAR) */ +#endif /* SSI_DEBUG_LEVEL1 */ + +#ifndef USE_PURE + + if (flags) + num_times++; + +/* cm_mem_c_001.main_12 - addition to insert the size into hash list */ +#ifdef SSI_DEBUG_LEVEL1 + /* Update the hash list */ + if (cmMmHashListInsert(&(regCb->hashListCp), *size) != ROK) + { + /* display that, this entry could not be made in the hash list */ +#ifdef DEBUGP + /* display an error message here */ +/*cm_mem_c_001.main_23 Fix for specifier mismatch warnings in 64BIT compilation*/ +#ifdef ALIGN_64BIT + sprintf(dbgPrntBuf, "\n Could not make an entry for size %u in hash table of region %d \n", + *size, regCb->region); +#else + sprintf(dbgPrntBuf, "\n Could not make an entry for size %lu in hash table of region %d \n", + *size, regCb->region); +#endif + SDisplay(0, dbgPrntBuf); +#endif /* DEBUGP */ + } +#endif /* SSI_DEBUG_LEVEL1 */ + + /* + * Check if the requested size is less than or equal to the maximum block + * size in the bucket. + */ + if ( *size <= regCb->bktMaxBlkSize) + { + /* Get the map to the mapping table */ + idx = ((*size - 1) >> regCb->bktQnPwr); + +#if (ERRCLASS & ERRCLS_DEBUG) + if (regCb->mapTbl[idx].bktIdx == 0xFF) + { + /* Some fatal error in the map table initialization. */ + RETVALUE(RFAILED); + } +#endif + + /* Dequeue the memory block and return it to the user */ + bkt = &(regCb->bktTbl[regCb->mapTbl[idx].bktIdx]); + + cnt = 0; + /* While loop is introduced to use the "break statement inside */ + while (cnt < 1) + { + /* + * Check if the size request is not greater than the size available + * in the bucket + */ + if (*size > bkt->size) + { + /* Try to go to the next bucket if available */ + if((idx < (CMM_MAX_MAP_ENT - 1)) && + (regCb->mapTbl[++idx].bktIdx != 0xFF)) + { + bkt = &(regCb->bktTbl[regCb->mapTbl[idx].bktIdx]); + } + else + { + /* This is the last bucket, try to allocate from heap */ + break; + } + } + + /* Acquire the bucket lock */ + /* cm_mem_c_001.main_13 : Replaced SLock with WTLock for NT */ +#ifdef SS_WIN + (Void) WTLock(&(bkt->bktLock)); +#else + (Void) SLock(&(bkt->bktLock)); +#endif +#ifdef XEON_SPECIFIC_CHANGES + CM_MEM_ALLOC_STS(regCb->region, idx); +#endif + +#if (ERRCLASS & ERRCLS_DEBUG) + regCb->mapTbl[idx].numReq++; +#endif /* (ERRCLASS & ERRCLS_DEBUG) */ + +/* cm_mem_c_001.main_12 - addition for sanity check before allocation */ +#if (defined(SSI_DEBUG_LEVEL1) || defined(BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1)) + /* increment the allocation attempt counter at bucket level */ + bkt->numAllocAttempts++; + + /* detect trampling if any and call sanity check. This is done for (bkt->nextBlk) as + the allocation is always from (bkt->nextBlk) */ + if (bkt->nextBlk) + { +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + if(cmMmRegIsBlkSane(bkt->nextBlk, bkt->size) != ROK) +#else + if (cmMmRegIsBlkSane(bkt->nextBlk) != ROK) +#endif + { + /* detected a trampled memory block in this bucket */ +#ifdef DEBUGP + /* display an error message here */ +/*cm_mem_c_001.main_23 Fix for specifier mismatch warnings in 64BIT compilation*/ +#ifdef ALIGN_64BIT + sprintf(dbgPrntBuf, "Memory Trampling at: %8p, Bucket Id:%03d, size %u bytes \n", + (void *)bkt->nextBlk, regCb->mapTbl[idx].bktIdx, *size); +#else + sprintf(dbgPrntBuf, "Memory Trampling at: %8p, Bucket Id:%03d, size %lu bytes \n", + (void *)bkt->nextBlk, regCb->mapTbl[idx].bktIdx, *size); +#endif + SDisplay(0, dbgPrntBuf); +#endif /* DEBUGP */ + abort(); +#ifndef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + if (cmMmBktSanityChk(bkt) == RTRAMPLINGNOK) + { + /* Release the lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock(&(bkt->bktLock)); +#else + (Void) SUnlock(&(bkt->bktLock)); +#endif + /* handle RTRAMPLINGNOK in SAlloc/SGetSBuf */ + RETVALUE(RTRAMPLINGNOK); + } + else +#endif + { + /* Release the lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock(&(bkt->bktLock)); +#else + (Void) SUnlock(&(bkt->bktLock)); +#endif + /* return RFAILED */ + RETVALUE(RFAILED); + } + } + } + *ptr = (Data *)(bkt->nextBlk) + (sizeof(CmMmBlkHdr)); /* ccpu00125353: warning fix */ +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL2 + ptrHdr = (CmMmBlkHdr *)bkt->nextBlk; +#endif +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + /* Initialize the elements with 0xAB */ + cmMemset((U8 *)*ptr, 0xAB, *size); +#endif +// printf("Pointer allocated %8p size %d\n", *ptr, *size); + /* Store this pointer in hash list */ + if ((bkt->nextBlk) && *ptr) +#elif SS_LIGHT_MEM_LEAK_STS + *ptr = (Data *)(bkt->nextBlk) + (sizeof(CmMmBlkHdr)); /* ccpu00125353: warning fix */ + if ((bkt->nextBlk) && *ptr) +#else + *ptr = bkt->next;/* ccpu00125353: warning fix */ + if (*ptr != NULLP) +#endif /* SSI_DEBUG_LEVEL1 */ + { +/* cm_mem_c_001.main_12 - addition for header */ +#if (defined(SSI_DEBUG_LEVEL1) || defined(BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1) || defined (SS_LIGHT_MEM_LEAK_STS)) + /* point to next block header */ + alocBlk = bkt->nextBlk; + bkt->nextBlk = (CmMmBlkHdr *)(bkt->nextBlk->nextBlk); +#else +#ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */ + if(bkt->size == 128) + { + memIndex = (*ptr - startPtr128) / 128; + } + if(bkt->size == 256) + { + memIndex = (*ptr - startPtr256) / 256; + } +#if 1 + if (*((U32 *)(*ptr + 4)) != 0xDEADDEAD && *((U32 *)(*ptr + 80)) != 0xDEADDEAD && *((U32 *)(*ptr + 24)) != 0xDEADDEAD) + { + } + if(bkt->size == 256) + { + } + } +#endif +#endif /* MS_MBUF_CORRUPTION */ +#ifdef SSI_MEM_CORR_PREVENTION + *(((U32 *)(*ptr)) + 2) = 0; +#endif + +#ifdef T2K_MEM_LEAK_DBG + + { + /* Lock before the transaction-start */ + pthread_mutex_lock(&(regMemLeakInfo.memLock[regCb->region])); + InsertToT2kMemLeakInfo( (U64)*ptr,*size,line,file,regCb->region); + /* UnLock after the transaction */ + pthread_mutex_unlock(&(regMemLeakInfo.memLock[regCb->region])); + } +#endif /* T2K_MEM_LEAK_DBG */ + + bkt->next = *((CmMmEntry **)(bkt->next)); +#ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */ + *nextptr = bkt->next; + if (*((U32 *)(*nextptr + 4)) != 0xDEADDEAD && *((U32 *)(*nextptr + 80)) != 0xDEADDEAD && *((U32 *)(*nextptr + 24)) != 0xDEADDEAD) + { + if(bkt->size == 128) + *prevptr = startPtr128 + ((memIndex-1)*128); + if(bkt->size == 256) + *prevptr = startPtr256 + ((memIndex-1)*256); + if(bkt->size == 128) + memIndex = (*nextptr - startPtr128) / 128; + if(bkt->size == 256) + memIndex = (*nextptr - startPtr256) / 256; + nextptr1=NULLP; + *nextptr1=9; + } + if(bkt->size == 128) + { + memIndex = (*ptr - startPtr128) / 128; + cmMemInfo128[memIndex][0] = cmAllocCaller[MxGetCpuID()]; + } + if(bkt->size == 256) + { + memIndex = (*ptr - startPtr256) / 256; + cmMemInfo256[memIndex][0] = cmAllocCaller[MxGetCpuID()]; + } + cmAllocCaller[MxGetCpuID()] = NULLP; + *((U32 *)(*ptr + 4)) = 0x00000000; + *((U32 *)(*ptr + 124)) = 0; + *((U32 *)(*ptr + 24)) = 0x00000000; + *((U32 *)(*ptr + 44)) = 0x00000000; + *((U32 *)(*ptr + 80)) = 0x00000000; + *((U32 *)(*ptr + 116)) = 0x00000000; +#endif +#endif /* SSI_DEBUG_LEVEL1 */ + +/* cache_coherency_changes */ +#ifdef LOWERARM + MxDMB(); +#endif + /* + * Increment the statistics variable of number of memory block + * allocated + */ + bkt->numAlloc++; + if (bkt->numAlloc > bkt->maxAlloc) + { + bkt->maxAlloc = bkt->numAlloc; + } +#ifdef CM_MEM_OVERUSED + { + if (g_overused[bktIdx] == 0 && OVERUSED(bkt)) + { + g_overused[bktIdx] = 1; + /*printf("cmAlloc: bktIdx %u overused %u numAlloc %u\n", bktIdx, g_overused[bktIdx], bkt->numAlloc); */ + } + } +#endif +/* cm_mem_c_001.main_12 - addition for header manipulation */ +#if (defined(SSI_DEBUG_LEVEL1) || defined(BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1)) + /* update the size for which this memory block has been allocated */ + alocBlk->requestedSize = *size; + /* update the memory block header */ + CMM_RESET_FREE_FLAG(alocBlk->memFlags); + if (memType == CMM_STATIC_MEM_FLAG) + { + CMM_SET_STATIC_FLAG(alocBlk->memFlags); + /* add it to the static memory allocated */ + bkt->staticMemUsed += bkt->size; + } + else + { + CMM_SET_DYNAMIC_FLAG(alocBlk->memFlags); + /* add it to the dynamic memory allocated */ + bkt->dynamicMemUsed += bkt->size; + } +#elif SS_LIGHT_MEM_LEAK_STS + alocBlk->requestedSize = *size; + alocBlk->lineNo = lineNo; + alocBlk->currFuncName = funcName; + if(gmemLkCb.isStarted == TRUE) + { + alocBlk->allocQueueIndx = cmStorAllocBlk(alocBlk); + } +#endif /* SSI_DEBUG_LEVEL1 */ + + if (((bkt->size - (*size)) >> regCb->bktQnPwr) && flags) + { + bkt->bktNoFitCnt++; +#ifdef MEMCAL_DEBUG +/*cm_mem_c_001.main_23 Fix for specifier mismatch warnings in 64BIT compilation*/ +#ifdef ALIGN_64BIT + sprintf(prntBuf, + "[MEM_CAL_CNTA] %u bytes request not fitted in bkt %d [size %u bytes] %u times\n", *size, regCb->mapTbl[idx].bktIdx, bkt->size, bkt->bktNoFitCnt++); +#else + sprintf(prntBuf, + "[MEM_CAL_CNTA] %lu bytes request not fitted in bkt %d [size %lu bytes] %lu times\n", *size, regCb->mapTbl[idx].bktIdx, bkt->size, bkt->bktNoFitCnt++); +#endif + SDisplay(0, prntBuf); +#endif + } + +#ifdef MEMCAL_DEBUG + if (flags) + { + sprintf(prntBuf, + "SGetSBuf:%08lu:Size Bucket Id:%03d Times:%05lu Pointer: %8p\n", + *size, regCb->mapTbl[idx].bktIdx, num_times, *ptr); + SDisplay(0, prntBuf); + } +#endif /* MEMCAL_DEBUG */ + /* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + /* If If Tapa task (entId)is registerd for histogram then insert Memrory allocated + * information into the hash list */ + if(hstReg) + { + if (cmHstGrmAllocInsert(&(bkt->hstGrmHashListCp), bkt->size, size, line, fileName, entId) != ROK) + { + sprintf(hstGrmBuf, "Unable to Insert into the histgram hash list\n"); + SPrint(hstGrmBuf); + } + }/* End of if */ + +#endif /* SS_HISTOGRAM_SUPPORT */ + + /* Update the size parameter */ + *size = bkt->size; +#ifdef SS_MEM_LEAK_STS + /* cm_mem_c_001.main_25 - Fixed compilation warnings 32/64 bit */ + cmStorAllocBlk((PTR)*ptr, (Size) reqSz, (Size) *size, + regCb->mapTbl[idx].bktIdx); +#elif BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL2 + cmStorAllocBlk(ptrHdr, (Size)reqSz, (Size) *size, + regCb->mapTbl[idx].bktIdx, regCb); +#endif /* SS_MEM_LEAK_STS */ + + /* cm_mem_c_008.104 - Addition for memory calculator tool */ + + /* Release the lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock(&(bkt->bktLock)); +#else + (Void) SUnlock(&(bkt->bktLock)); +#endif + + RETVALUE(ROK); + } + else if (flags) + { + bkt->bktFailCnt++; +#ifdef MEMCAL_DEBUG +/*cm_mem_c_001.main_23 Fix for specifier mismatch warnings in 64BIT compilation*/ +#ifdef ALIGN_64BIT + sprintf(prntBuf, + "[MEM_CAL_CNTB] Allocation failed in bucket %d [ size %u bytes], %u times\n", regCb->mapTbl[idx].bktIdx, bkt->size, bkt->bktFailCnt); +#else + sprintf(prntBuf, + "[MEM_CAL_CNTB] Allocation failed in bucket %d [ size %lu bytes], %lu times\n", regCb->mapTbl[idx].bktIdx, bkt->size, bkt->bktFailCnt); +#endif + SDisplay(0, prntBuf); +#endif + } + +#if (ERRCLASS & ERRCLS_DEBUG) + regCb->mapTbl[idx].numFailure++; +#endif /* (ERRCLASS & ERRCLS_DEBUG) */ + + /* Release the lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock(&(bkt->bktLock)); +#else + (Void) SUnlock(&(bkt->bktLock)); +#endif + cnt = cnt + 1; + } + } + else + { + if (flags) + { + regCb->heapCb.heapAllocCnt++; +#ifdef MEMCAL_DEBUG +/*cm_mem_c_001.main_23 Fix for specifier mismatch warnings in 64BIT compilation*/ +#ifdef ALIGN_64BIT + sprintf(prntBuf, + "[MEM_CAL_CNTC] No bucket block configured for %u bytes \n Number of blocks allocated from heap = %u\n",*size, + regCb->heapCb.heapAllocCnt); +#else + sprintf(prntBuf, + "[MEM_CAL_CNTC] No bucket block configured for %lu bytes \n Number of blocks allocated from heap = %lu\n",*size, + regCb->heapCb.heapAllocCnt); +#endif + SDisplay(0, prntBuf); +#endif + } + } + + /* Memory not available in the bucket pool */ + if (regCb->heapFlag && (*size < regCb->heapSize)) + { +#ifdef MEMCAL_DEBUG + if (flags) tryHeap = 1; +#endif + /* + * The heap memory block is available. Allocate the memory block from + * heap pool. + */ +/* cm_mem_c_001.main_15: Additions */ +#ifdef SS_HISTOGRAM_SUPPORT +/* cm_mem_c_001.main_12 - addition for passing an extra parameter */ +#ifdef SSI_DEBUG_LEVEL1 + RETVALUE(cmHeapAlloc(&(regCb->heapCb), ptr, size, memType, line, fileName, entId, hstReg)); +#else + RETVALUE(cmHeapAlloc(&(regCb->heapCb), ptr, size, line, fileName, entId, hstReg)); +#endif /* SSI_DEBUG_LEVEL1 */ +#else +/* cm_mem_c_001.main_12 - addition for passing an extra parameter */ +#ifdef SSI_DEBUG_LEVEL1 + RETVALUE(cmHeapAlloc(&(regCb->heapCb), ptr, size, memType)); +#else + RETVALUE(cmHeapAlloc(&(regCb->heapCb), ptr, size)); +#endif /* SSI_DEBUG_LEVEL1 */ +#endif /* SS_HISTOGRAM_SUPPORT */ + } + + /* No memory available */ + RETVALUE(RFAILED); +#else /* use pure is on */ +/*cm_mem_c_001.main_27 SSI-4GMX specfic changes*/ +#ifdef SS_4GMX_LCORE + *ptr = (Data*) MxHeapAlloc(SsiHeap, *size); + cmMemset((U8*)ptr, 0, *size); +#else + *ptr = (Data*) malloc(*size); +#endif + if ( (*ptr) == NULLP) + RETVALUE(RFAILED); + avail_size -= *size; + RETVALUE(ROK); +#endif /* USE_PURE */ + +} /* end of cmAlloc */ + + +/* +* +* Fun: cmFree +* +* Desc: Return the memory block for the memory region. +* +* +* Ret: ROK - successful +* RFAILED - unsuccessful. +* +* Notes: The user calls this function to return the previously allocated +* memory block to the memory region. The memory manager does not +* check the validity of the state of the memory block(like whether +* it was allocated earlier). The caller must be sure that, the +* address specified in the parameter 'ptr' is valid and was +* allocated previously from same region. +* +* +* File: cm_mem.c +* +*/ + +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_LIGHT_MEM_LEAK_STS +#ifdef ANSI +PRIVATE S16 cmFree +( +Void *regionCb, +Data *ptr, +Size size, +U32 lineNo, +U8 *funcName +) +#else +PRIVATE S16 cmFree(regionCb, ptr, size, lineNo, funcName) +Void *regionCb; +Data *ptr; +Size size; +U32 lineNo; +U8 *funcName; +#endif +#else /*SS_LIGHT_MEM_LEAK_STS */ +#ifdef SS_HISTOGRAM_SUPPORT +#ifdef ANSI +PRIVATE S16 cmFree +( +Void *regionCb, +Data *ptr, +Size size, +U32 line, +U8 *fileName, +U8 entId, +Bool hstReg +) +#else +PRIVATE S16 cmFree(regionCb, ptr, size, line, fileName, entId, hstReg) +Void *regionCb; +Data *ptr; +Size size; +U32 line; +U8 *fileName; +U8 entId; +Bool hstReg; +#endif + +#else +#ifdef T2K_MEM_LEAK_DBG +PRIVATE S16 cmFree +( + Void *regionCb, + Data *ptr, + Size size, + char* file, + U32 line + ) +#else /* T2K_MEM_LEAK_DBG */ +#ifdef ANSI +PRIVATE S16 cmFree +( +Void *regionCb, +Data *ptr, +Size size +) +#else +PRIVATE S16 cmFree(regionCb, ptr, size) +Void *regionCb; +Data *ptr; +Size size; +#endif +#endif +/* cm_mem_c_001.main_15 : Additions */ +#endif /* SS_HISTOGRAM_SUPPORT */ +#endif /*SS_LIGHT_MEM_LEAK_STS */ + +{ +/* cm_mem_c_001.main_26 : Fixes for Compilation Warnings */ +#ifndef USE_PURE + U16 idx; + CmMmBkt *bkt; +#endif + CmMmRegCb *regCb; +/* cm_mem_c_001.main_12 - addition for holding the free pointer */ +#if (defined(SSI_DEBUG_LEVEL1) || defined(BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1) || defined (SS_LIGHT_MEM_LEAK_STS)) + CmMmBlkHdr *ptrHdr; +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + CmMmBlkHdr *lastHdr; +#endif +#endif /* SSI_DEBUG_LEVEL1 */ +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + S8 hstGrmBuf[256]; +#endif /* SS_HISTOGRAM_SUPPORT */ +#ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption*/ + U16 memIndex=0; +#endif + + TRC2(cmFree); + + regCb = (CmMmRegCb *)regionCb; + +#ifndef USE_PURE +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + /* Check if the memory block is from the memory region */ + if (ptr >= ((CmMmRegCb *)regCb)->regInfo.start + + ((CmMmRegCb *)regCb)->regInfo.size) + { + RETVALUE(RFAILED); + } +#endif +#if (ERRCLASS & ERRCLS_INT_PAR) + + /* error check on parameters */ + if ((regCb == NULLP) || (!size) || (ptr == NULLP)) + { + RETVALUE(RFAILED); + } + +#ifndef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + /* Check if the memory block is from the memory region */ + if (ptr >= ((CmMmRegCb *)regCb)->regInfo.start + + ((CmMmRegCb *)regCb)->regInfo.size) + { + RETVALUE(RFAILED); + } +#endif + /* cm_mem_c_001.main_20 Addition */ + if (ptr < regCb->regInfo.start) + { + RETVALUE(RFAILED); + } + +#endif + + /* + * Check if the memory block was allocated from the bucket pool. + */ + + if (ptr < (regCb->regInfo.start + regCb->bktSize)) + { +#ifdef T2K_MEM_LEAK_DBG + { + pthread_mutex_lock(&(regMemLeakInfo.memLock[regCb->region])); + RemoveFromT2kMemLeakInfo((U64)ptr , file,line,regCb->region); + pthread_mutex_unlock(&(regMemLeakInfo.memLock[regCb->region])); + } +#endif + /* The memory block was allocated from the bucket pool */ + + /* Get the map to the mapping table */ + idx = ((size - 1) >> regCb->bktQnPwr); + +#if (ERRCLASS & ERRCLS_DEBUG) + if (regCb->mapTbl[idx].bktIdx == 0xFF) + { + /* Some fatal error in the map table initialization. */ + RETVALUE(RFAILED); + } +#endif + + /* Enqueue the memory block and return it to the user */ + bkt = &(regCb->bktTbl[regCb->mapTbl[idx].bktIdx]); + + /* + * Check if the size is not greater than the size available + * in the bucket. If so, then the buffer must have been allocated + * from next bucket. We don't need to check the validity of the + * next bucket, otherwise buffer must have been allocated from heap + * pool. + */ + if (size > bkt->size) + { + bkt = &(regCb->bktTbl[regCb->mapTbl[++idx].bktIdx]); + } + + /* Acquire the bucket lock */ + /* cm_mem_c_001.main_13 : Replaced SLock with WTLock for NT */ +#ifdef SS_WIN + (Void) WTLock(&(bkt->bktLock)); +#else + (Void) SLock(&(bkt->bktLock)); +#endif +#ifdef XEON_SPECIFIC_CHANGES + CM_MEM_FREE_STS(regCb->region, idx); +#endif +/* cache_coherency_changes */ +#ifdef LOWERARM + MxDMB(); +#endif + +/* cm_mem_c_001.main_12 - addition for sanity check and free */ +#if (defined(SSI_DEBUG_LEVEL1) || defined(BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1)) + /* increment the dealloc attempt counter at bucket level */ + bkt->numDeallocAttempts++; + + /* Check the memFlags to see whether this block was allocated */ + ptrHdr = (CmMmBlkHdr *) (ptr - sizeof(CmMmBlkHdr)); +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL2 + cmRlsAllocBlk(ptrHdr, regCb); +#endif +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + /* Check for ptr size */ + if(((ptrHdr->requestedSize - size) % size) != 0) + { +#ifdef DEBUGP + sprintf(dbgPrntBuf, "Passed size (%d) does not match with allocated \ + size(%d) %8p, Bucket Id:%03d\n", + size, ptrHdr->requestedSize, ptr, regCb->mapTbl[idx].bktIdx); +#endif + printf("Passed size (%d) does not match with allocated \ + size(%d) %8p, Bucket Id:%03d\n", + size, ptrHdr->requestedSize, ptr, regCb->mapTbl[idx].bktIdx); + abort(); + } + /* Validate the tail part to see if there is any over run */ +// printf("Pointer free request %8p, size %d\n", ptr, size); +#endif + + /* validate the block to be freed for trampling */ +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + if(cmMmRegIsBlkSane(ptrHdr, bkt->size) != ROK) +#else + if (cmMmRegIsBlkSane(ptrHdr) != ROK) +#endif + { + /* Handle error case of Memory trampling */ +#ifdef DEBUGP + /* display an error message here */ +/*cm_mem_c_001.main_23 Fix for specifier mismatch warnings in 64BIT compilation*/ +#ifdef ALIGN_64BIT + sprintf(dbgPrntBuf, "Memory Trampling at: %8p, Bucket Id:%03d, size %u bytes \n", + ptr, regCb->mapTbl[idx].bktIdx, bkt->size); +#else + sprintf(dbgPrntBuf, "Memory Trampling at: %8p, Bucket Id:%03d, size %lu bytes \n", + ptr, regCb->mapTbl[idx].bktIdx, bkt->size); +#endif + SDisplay(0, dbgPrntBuf); +#endif /* DEBUGP */ + abort(); + /* + * if sanity check returns RTRAMPLINGOK then there is nothing to do + * as the memory blk is already invalidated in cmMmBktSanityChk + */ +#ifndef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + if (cmMmBktSanityChk(bkt) == RTRAMPLINGOK) + { + bkt->numAlloc--; + + /* Release the lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock(&(bkt->bktLock)); +#else + (Void) SUnlock(&(bkt->bktLock)); +#endif + + RETVALUE(ROK); + } + else +#endif + { + /* + * this is the case where in the entire bucket has been made unusable + * Release the lock + */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock(&(bkt->bktLock)); +#else + (Void) SUnlock(&(bkt->bktLock)); +#endif + + /* handle RTRAMPLINGNOK in SFree/SPutSBuf */ + RETVALUE(RTRAMPLINGNOK); + } +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + printf("Memory signature is invalid\n"); + abort(); +#endif + } + + /* reset the size */ + ptrHdr->requestedSize = 0; +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + /* Initialize the elements with 0xAB */ + cmMemset((U8 *)ptr, 0xAB, size); +#endif + /* check if the block to be freed is already having the state as FREE */ + if (CMM_IS_FREE(ptrHdr->memFlags)) + { + /* Handle double deallocation error case */ +#ifdef DEBUGP + /* display an error message here */ +/*cm_mem_c_001.main_23 Fix for specifier mismatch warnings in 64BIT compilation*/ +#ifdef ALIGN_64BIT + sprintf(dbgPrntBuf, "Attempt to double deallocate memory at: %8p, Bucket Id:%03d, size %u bytes \n", + ptr, regCb->mapTbl[idx].bktIdx, bkt->size); +#else + sprintf(dbgPrntBuf, "Attempt to double deallocate memory at: %8p, Bucket Id:%03d, size %lu bytes \n", + ptr, regCb->mapTbl[idx].bktIdx, bkt->size); +#endif + SDisplay(0, dbgPrntBuf); +#endif /* DEBUGP */ + + /* Release the lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock(&(bkt->bktLock)); +#else + (Void) SUnlock(&(bkt->bktLock)); +#endif +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + printf("Attempt to double deallocate memory at: %8p, Bucket Id:%03d,\ + size %u bytes \n", ptr, regCb->mapTbl[idx].bktIdx, bkt->size); + abort(); +#endif + /* handle RDBLFREE in SFree/SPutSBuf */ + RETVALUE(RDBLFREE); + } + if (CMM_IS_STATIC(ptrHdr->memFlags)) + { + CMM_SET_FREE_FLAG(ptrHdr->memFlags); + CMM_RESET_STATIC_FLAG(ptrHdr->memFlags); + /* deduct it from the static memory count */ + bkt->staticMemUsed -= bkt->size; + } + else if (CMM_IS_DYNAMIC(ptrHdr->memFlags)) + { + CMM_SET_FREE_FLAG(ptrHdr->memFlags); + CMM_RESET_DYNAMIC_FLAG(ptrHdr->memFlags); + /* deduct it from the dynamic memory count */ + bkt->dynamicMemUsed -= bkt->size; + } + else + { + /* This is a case similar to trampled memory */ +#ifdef DEBUGP +/*cm_mem_c_001.main_23 Fix for specifier mismatch warnings in 64BIT compilation*/ +#ifdef ALIGN_64BIT + sprintf(dbgPrntBuf, "Invalid memory flag: %u !!!\n", ptrHdr->memFlags); +#else + sprintf(dbgPrntBuf, "Invalid memory flag: %lu !!!\n", ptrHdr->memFlags); +#endif + SDisplay(0, dbgPrntBuf); +#endif /* DEBUGP */ +#ifndef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + if (cmMmBktSanityChk(bkt) == RTRAMPLINGOK) + { + /* do not add to the free list */ + bkt->numAlloc--; + + /* Release the lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock(&(bkt->bktLock)); +#else + (Void) SUnlock(&(bkt->bktLock)); +#endif + RETVALUE(ROK); + } + else +#endif + { + /* + * this is the case where in the entire bucket has been made unusable + * Release the lock + */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock(&(bkt->bktLock)); +#else + (Void) SUnlock(&(bkt->bktLock)); +#endif + + /* handle RTRAMPLINGNOK in SFree/SPutSBuf */ + RETVALUE(RTRAMPLINGNOK); + } + } +#ifndef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + /* Return the block to memory */ + ptrHdr->nextBlk = bkt->nextBlk; + bkt->nextBlk = ptrHdr; +#endif +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + /* Move the ptr to end of the bucket */ + lastHdr = (CmMmBlkHdr *)bkt->lastBlk; + lastHdr->nextBlk = ptrHdr; + bkt->lastBlk = ptrHdr; + ptrHdr->nextBlk = NULLP; +#endif +#elif SS_LIGHT_MEM_LEAK_STS + ptrHdr = (CmMmBlkHdr *) (ptr - sizeof(CmMmBlkHdr)); + ptrHdr->lineNo = lineNo; + ptrHdr->currFuncName = funcName; + if(gmemLkCb.isStarted == TRUE) + { + cmRlsAllocBlk(ptrHdr->allocQueueIndx); + } + ptrHdr->nextBlk = bkt->nextBlk; + bkt->nextBlk = ptrHdr; +#else + +#ifndef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */ +#ifdef SSI_MEM_CORR_PREVENTION + if (*(((U32 *)(ptr)) + 2) == 0xdeaddead) + { + /* Do not free an already freed block to avoid corruption */ + cmDblFreeAttempts++; + bkt->numAlloc++; + } + else + { + *((CmMmEntry **)bkt->last) = ptr; + bkt->last = (CmMmEntry *)ptr; + *((CmMmEntry **)ptr) = NULLP; + *(((U32 *)(ptr)) + 2) = 0xdeaddead; + } +#else + *((CmMmEntry **)ptr) = bkt->next; + bkt->next = (CmMmEntry *)ptr; +#endif +#else + if(memFreeCount >= 125000) + memFreeCount = 0; + if(bkt->size == 128) + { + Data *crashPtr=NULLP; + if(((ptr - startPtr128) % 128) != 0) + { + *crashPtr = 9; + } + memIndex = (ptr - startPtr128) / 128; + } + if(bkt->size == 256) + { + Data *crashPtr=NULLP; + if(((ptr - startPtr256) % 256) != 0) + { + *crashPtr = 9; + } + memIndex = (ptr - startPtr256) / 256; + } + if(bkt->size == 512) + { + Data *crashPtr=NULLP; + if(((ptr - startPtr512) % 512) != 0) + { + *crashPtr = 9; + } + } + if(bkt->size == 768) + { + Data *crashPtr=NULLP; + if(((ptr - startPtr768) % 768) != 0) + { + *crashPtr = 9; + } + } + if(bkt->size == 1664) + { + Data *crashPtr=NULLP; + if(((ptr - startPtr1664) % 1664) != 0) + { + *crashPtr = 9; + } + } + if(bkt->size == 4800) + { + Data *crashPtr=NULLP; + if(((ptr - startPtr4800) % 4800) != 0) + { + *crashPtr = 9; + } + } + if(bkt->size == 9920) + { + Data *crashPtr=NULLP; + if(((ptr - startPtr9920) % 9920) != 0) + { + *crashPtr = 9; + } + } + if (*((U32 *)(ptr + 4)) != 0xDEADDEAD) + { + *(U32 *)(ptr + 4) = 0xDEADDEAD; + } + else + { + Data *crashPtr=NULLP; + *crashPtr = 9; + } + if (*((U32 *)(ptr + 24)) != 0xDEADDEAD) + { + *(U32 *)(ptr + 24) = 0xDEADDEAD; + } + else + { + Data *crashPtr=NULLP; + *crashPtr = 9; + } + if (*((U32 *)(ptr + 44)) != 0xDEADDEAD) + { + *(U32 *)(ptr + 44) = 0xDEADDEAD; + } + else + { + Data *crashPtr=NULLP; + *crashPtr = 9; + } + if (*((U32 *)(ptr + 80)) != 0xDEADDEAD) + { + *(U32 *)(ptr + 80) = 0xDEADDEAD; + } + else + { + Data *crashPtr=NULLP; + *crashPtr = 9; + /* Cause a crash to identify the caller */ + } + *(U32 *)(ptr + 124) = memFreeCount++; + (*(U32 *)(ptr + 116)) = cmFreeCaller[MxGetCpuID()]; + if(bkt->size == 128) + { + memIndex = (ptr - startPtr128) / 128; + cmMemInfo128[memIndex][1] = cmFreeCaller[MxGetCpuID()]; + } + if(bkt->size == 256) + { + memIndex = (ptr - startPtr256) / 256; + cmMemInfo256[memIndex][1] = cmFreeCaller[MxGetCpuID()]; + } + cmFreeCaller[MxGetCpuID()] = NULLP; + + /* + Reverted: Removed functionality to move freed buffer to end of free List in bucket. + This is impacting throughput. + */ +#if 1 + *((CmMmEntry **)bkt->last) = ptr; + bkt->last = (CmMmEntry *)ptr; + *((CmMmEntry **)ptr) = NULLP; +#else + *((CmMmEntry **)ptr) = bkt->next; + bkt->next = (CmMmEntry *)ptr; +#endif +#endif +#endif /* SSI_DEBUG_LEVEL1 */ + +/* cache_coherency_changes */ +#ifdef LOWERARM + MxDMB(); +#endif + /* + * Decrement the statistics variable of number of memory block + * allocated + */ + bkt->numAlloc--; +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + /* If If Tapa task (entId)is registerd for histogram then insert Memrory Freed + * information into the hash list */ + if(hstReg) + { + if (cmHstGrmFreeInsert(&bkt->hstGrmHashListCp, bkt->size, line, fileName, entId) != ROK) + { + sprintf(hstGrmBuf, "Unable to Insert into the histgram hash list\n"); + SPrint(hstGrmBuf); + } + }/* End of if */ +#endif /* SS_HISTOGRAM_SUPPORT */ + +#ifdef SS_MEM_LEAK_STS + /* cm_mem_c_001.main_25 - Fixed compilation warnings 32/64 bit */ + cmRlsAllocBlk((PTR)ptr); +#endif /* SS_MEM_LEAK_STS */ + /* Release the lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock(&(bkt->bktLock)); +#else + (Void) SUnlock(&(bkt->bktLock)); +#endif + + RETVALUE(ROK); + } + + /* The memory block was allocated from the heap pool */ +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + RETVALUE(cmHeapFree (&(regCb->heapCb), ptr, size, line, fileName, entId, hstReg)); +#else + RETVALUE(cmHeapFree (&(regCb->heapCb), ptr, size)); +#endif /* SS_HISTOGRAM_SUPPORT */ +#else /* use pure is on */ + TRC2(cmFree); +/*cm_mem_c_001.main_27 SSI-4GMX specfic changes*/ +#ifdef SS_4GMX_LCORE + (Void)MxHeapFree(SsiHeap, ptr); +#else + (Void)free(ptr); +#endif + avail_size += size; + RETVALUE(ROK); +#endif /* USE_PURE */ + + +} /* end of cmFree */ + +/* + * + * Fun: cmAllocNL + * + * Desc: Allocate a memory block for the memory region(No Lock). + * + * + * Ret: ROK - successful + * RFAILED - unsuccessful. + * + * Notes: + * The function allocates a memory block of size atleast equal to + * the requested size. The size parameter will be updated with the + * actual size of the memory block allocated for the request. The + * CMM tries to allocate the memory block form the bucket pool. If + * there is no memory in the bucket the CMM allocates the memory + * block form the heap pool. This function is always called by the + * System Service module. + * + * The caller of the function should try to use the out value of + * the size while returning the memory block to the region. However + * the current design of the memory manager does not enforce to pass + * the actual size of the memory block. (Due to the SGetSBuf + * semantics the layer will not able to pass the correct size of the + * memory block while calling SPutSBuf). + * + * + * File: cm_mem.c + * + */ +/* cm_mem_c_001.main_12 - addition to accept new parameter memType(static/dynamic) */ + +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT +#ifdef SSI_DEBUG_LEVEL1 +#ifdef ANSI +PUBLIC S16 cmAllocNL +( +Void *regionCb, +Size *size, +U32 flags, +Data **ptr, +U32 memType, +U32 line, +U8 *fileName, +U8 entId, +Bool hstReg +) +#else +PUBLIC S16 cmAllocNL(regionCb, size, flags, ptr, memType, + line, fileName, entId, hstReg) +Void *regionCb; +Size *size; +U32 flags; +Data **ptr; +U32 memType; +U32 line; +U8 *fileName; +U8 entId; +Bool hstReg; +#endif +#else +#ifdef ANSI +PUBLIC S16 cmAllocNL +( +Void *regionCb, +Size *size, +U32 flags, +Data **ptr, +U32 line, +U8 *fileName, +U8 entId, +Bool hstReg +) +#else +PUBLIC S16 cmAllocNL(regionCb, size, flags, ptr, line, + fileName, entId, hstReg) +Void *regionCb; +Size *size; +U32 flags; +Data **ptr; +U32 line; +U8 *fileName; +U8 entId; +Bool hstReg; +#endif +#endif /* SSI_DEBUG_LEVEL1 */ + +#else +#ifdef SS_LIGHT_MEM_LEAK_STS +#ifdef ANSI +PUBLIC S16 cmAllocNL +( +Void *regionCb, +Size *size, +U32 flags, +Data **ptr, +U32 memType, +U32 lineNo, +U8 *funcName +) +#else +PUBLIC S16 cmAllocNL(regionCb, size, flags, ptr ,memType, lineNo, funcName) +Void *regionCb; +Size *size; +U32 flags; +Data **ptr; +U32 memType; +U32 lineNo; +U8 *funcName; +#endif +#else /*SS_LIGHT_MEM_LEAK_STS */ +#ifdef SSI_DEBUG_LEVEL1 +#ifdef ANSI +PUBLIC S16 cmAllocNL +( +Void *regionCb, +Size *size, +U32 flags, +Data **ptr, +U32 memType +) +#else +PUBLIC S16 cmAllocNL(regionCb, size, flags, ptr, memType) +Void *regionCb; +Size *size; +U32 flags; +Data **ptr; +U32 memType; +#endif +#else +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 +#ifdef ANSI +PUBLIC S16 cmAllocNL +( +Void *regionCb, +Size *size, +U32 flags, +Data **ptr, +U32 memType +) +#else +PUBLIC S16 cmAllocNL(regionCb, size, flags, ptr, memType) +Void *regionCb; +Size *size; +U32 flags; +Data **ptr; +U32 memType; +#endif +#else +#ifdef ANSI +PUBLIC S16 cmAllocNL +( +Void *regionCb, +Size *size, +U32 flags, +Data **ptr +) +#else +PUBLIC S16 cmAllocNL(regionCb, size, flags, ptr) +Void *regionCb; +Size *size; +U32 flags; +Data **ptr; +#endif +#endif /* BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 */ +#endif /* SSI_DEBUG_LEVEL1 */ + /* cm_mem_c_001.main_15: Additions */ +#endif /*SS_LIGHT_MEM_LEAK_STS */ +#endif /* SS_HISTOGRAM_SUPPORT */ + +{ + /* cm_mem_c_001.main_26 : Fixes for Compilation Warnings */ +#ifndef USE_PURE + U16 idx; + CmMmBkt *bkt; +#endif + CmMmRegCb *regCb; + /* cm_mem_c_001.main_26 : Fixes for Compilation Warnings */ +#ifndef USE_PURE + U16 cnt; +#endif + /* cm_mem_c_001.main_15 : Additions */ +#if (defined(SS_MEM_LEAK_STS) || defined( BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1)) + Size reqSz = 0; +#endif /* SS_MEM_LEAK_STS */ + /* cm_mem_c_001.main_12 - addition to hold the allocated block */ +#if (defined(SSI_DEBUG_LEVEL1) || defined(BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1) || defined (SS_LIGHT_MEM_LEAK_STS)) + CmMmBlkHdr *alocBlk; +#endif /* SSI_DEBUG_LEVEL1 */ +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL2 + CmMmBlkHdr *ptrHdr; +#endif + /* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + S8 hstGrmBuf[256]; +#endif /* SS_HISTOGRAM_SUPPORT */ + + TRC2(cmAllocNL); + +#ifndef USE_MEMCAL + UNUSED(flags); +#endif + /* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_MEM_LEAK_STS + reqSz = *size; +#endif /* SS_MEM_LEAK_STS */ + + regCb = (CmMmRegCb *)regionCb; + +#if (ERRCLASS & ERRCLS_INT_PAR) + + /* error check on parameters */ + if ((regCb == NULLP) || (size == NULLP) || !(*size) || (ptr == NULLP)) + { + RETVALUE(RFAILED); + } +#endif + + /* cm_mem_c_001.main_12 - addition for checking memType parameter */ +#ifdef SSI_DEBUG_LEVEL1 +#if (ERRCLASS & ERRCLS_INT_PAR) + if ((memType != CMM_STATIC_MEM_FLAG) && (memType != CMM_DYNAMIC_MEM_FLAG)) + { + RETVALUE(RFAILED); + } +#endif /* (ERRCLASS & ERRCLS_INT_PAR) */ +#endif /* SSI_DEBUG_LEVEL1 */ + +#ifndef USE_PURE + + if (flags) + num_times++; + + /* cm_mem_c_001.main_12 - addition to insert the size into hash list */ +#ifdef SSI_DEBUG_LEVEL1 + /* Update the hash list */ + if (cmMmHashListInsert(&(regCb->hashListCp), *size) != ROK) + { + /* display that, this entry could not be made in the hash list */ +#ifdef DEBUGP + /* display an error message here */ +#ifdef ALIGN_64BIT + sprintf(dbgPrntBuf, "\n Could not make an entry for size %u \ + in hash table of region %d \n", + *size, regCb->region); +#else + sprintf(dbgPrntBuf, "\n Could not make an entry for size %lu \ + in hash table of region %d \n", + *size, regCb->region); +#endif + SDisplay(0, dbgPrntBuf); +#endif /* DEBUGP */ + } +#endif /* SSI_DEBUG_LEVEL1 */ + + /* + * Check if the requested size is less than or equal to the maximum block + * size in the bucket. + */ + if ( *size <= regCb->bktMaxBlkSize) + { + /* Get the map to the mapping table */ + idx = ((*size - 1) >> regCb->bktQnPwr); + +#if (ERRCLASS & ERRCLS_DEBUG) + if (regCb->mapTbl[idx].bktIdx == 0xFF) + { + /* Some fatal error in the map table initialization. */ + RETVALUE(RFAILED); + } +#endif + + /* Dequeue the memory block and return it to the user */ + bkt = &(regCb->bktTbl[regCb->mapTbl[idx].bktIdx]); + + cnt = 0; + /* While loop is introduced to use the "break statement inside */ + while (cnt < 1) + { + /* + * Check if the size request is not greater than the size available + * in the bucket + */ + if (*size > bkt->size) + { + /* Try to go to the next bucket if available */ + if((idx < (CMM_MAX_MAP_ENT - 1)) && + (regCb->mapTbl[++idx].bktIdx != 0xFF)) + { + bkt = &(regCb->bktTbl[regCb->mapTbl[idx].bktIdx]); + } + else + { + /* This is the last bucket, try to allocate from heap */ + break; + } + } + +#if (ERRCLASS & ERRCLS_DEBUG) + regCb->mapTbl[idx].numReq++; +#endif /* (ERRCLASS & ERRCLS_DEBUG) */ + + /* cm_mem_c_001.main_12 - addition for sanity check before allocation */ +#if (defined(SSI_DEBUG_LEVEL1) || defined(BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1)) + /* increment the allocation attempt counter at bucket level */ + bkt->numAllocAttempts++; + + /* detect trampling if any and call sanity check. This is done for (bkt->nextBlk) as + the allocation is always from (bkt->nextBlk) */ + if (bkt->nextBlk) + { +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + if(cmMmRegIsBlkSane(bkt->nextBlk, bkt->size) != ROK) +#else + if (cmMmRegIsBlkSane(bkt->nextBlk) != ROK) +#endif + { + /* detected a trampled memory block in this bucket */ +#ifdef DEBUGP + /* display an error message here */ + /*cm_mem_c_001.main_23 Fix for specifier mismatch warnings in 64BIT compilation*/ +#ifdef ALIGN_64BIT + sprintf(dbgPrntBuf, "Memory Trampling at: %8p, Bucket Id:%03d, \ + size %u bytes \n", + (void *)bkt->nextBlk, regCb->mapTbl[idx].bktIdx, *size); +#else + sprintf(dbgPrntBuf, "Memory Trampling at: %8p, Bucket Id:%03d, \ + size %lu bytes \n", + (void *)bkt->nextBlk, regCb->mapTbl[idx].bktIdx, *size); +#endif + SDisplay(0, dbgPrntBuf); +#endif /* DEBUGP */ + abort(); + +#ifndef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + if (cmMmBktSanityChk(bkt) == RTRAMPLINGNOK) + { + /* handle RTRAMPLINGNOK in SAlloc/SGetSBuf */ + RETVALUE(RTRAMPLINGNOK); + } + else + { + /* return RFAILED */ + RETVALUE(RFAILED); + } +#endif + } + } + *ptr = (Data *)(bkt->nextBlk) + (sizeof(CmMmBlkHdr)); +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL2 + ptrHdr = (CmMmBlkHdr *)bkt->nextBlk; +#endif +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + /* Initialize the elements with 0xAB */ + cmMemset((U8 *)*ptr, 0xAB, *size); +#endif + if ((bkt->nextBlk) && *ptr) +#elif SS_LIGHT_MEM_LEAK_STS + *ptr = (Data *)(bkt->nextBlk) + (sizeof(CmMmBlkHdr)); /* ccpu00125353: warning fix */ + if ((bkt->nextBlk) && *ptr) +#else + *ptr = bkt->next;/* ccpu00125353: warning fix */ + if (*ptr != NULLP) +#endif /* SSI_DEBUG_LEVEL1 */ + { + /* cm_mem_c_001.main_12 - addition for header */ +#if (defined(SSI_DEBUG_LEVEL1) || defined(BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1) || defined (SS_LIGHT_MEM_LEAK_STS)) + /* point to next block header */ + alocBlk = bkt->nextBlk; + bkt->nextBlk = (CmMmBlkHdr *)(bkt->nextBlk->nextBlk); +#else +#ifdef SSI_MEM_CORR_PREVENTION + *(((U32 *)(*ptr)) + 2) = 0; +#endif + bkt->next = *((CmMmEntry **)(bkt->next)); +#endif /* SSI_DEBUG_LEVEL1 */ + + /* cache_coherency_changes */ +#ifdef LOWERARM + MxDMB(); +#endif + /* + * Increment the statistics variable of number of memory block + * allocated + */ + bkt->numAlloc++; + if (bkt->numAlloc > bkt->maxAlloc) + { + bkt->maxAlloc = bkt->numAlloc; + } +#ifdef CM_MEM_OVERUSED + { + if (g_overused[bktIdx] == 0 && OVERUSED(bkt)) + { + g_overused[bktIdx] = 1; + } + } +#endif + /* cm_mem_c_001.main_12 - addition for header manipulation */ +#if (defined(SSI_DEBUG_LEVEL1) || defined(BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1)) + /* update the size for which this memory block has been allocated */ + alocBlk->requestedSize = *size; + /* update the memory block header */ + CMM_RESET_FREE_FLAG(alocBlk->memFlags); + if (memType == CMM_STATIC_MEM_FLAG) + { + CMM_SET_STATIC_FLAG(alocBlk->memFlags); + /* add it to the static memory allocated */ + bkt->staticMemUsed += bkt->size; + } + else + { + CMM_SET_DYNAMIC_FLAG(alocBlk->memFlags); + /* add it to the dynamic memory allocated */ + bkt->dynamicMemUsed += bkt->size; + } +#elif SS_LIGHT_MEM_LEAK_STS + alocBlk->requestedSize = *size; + alocBlk->lineNo = lineNo; + alocBlk->currFuncName = funcName; + if(gmemLkCb.isStarted == TRUE) + { + alocBlk->allocQueueIndx = cmStorAllocBlk(alocBlk); + } +#endif /* SSI_DEBUG_LEVEL1 */ + + if (((bkt->size - (*size)) >> regCb->bktQnPwr) && flags) + { + bkt->bktNoFitCnt++; +#ifdef MEMCAL_DEBUG +#ifdef ALIGN_64BIT + sprintf(prntBuf, + "[MEM_CAL_CNTA] %u bytes request not fitted in bkt %d \ + [size %u bytes] %u times\n", + *size, regCb->mapTbl[idx].bktIdx, bkt->size, bkt->bktNoFitCnt++); +#else + sprintf(prntBuf, + "[MEM_CAL_CNTA] %lu bytes request not fitted in bkt %d \ + [size %lu bytes] %lu times\n", + *size, regCb->mapTbl[idx].bktIdx, bkt->size, bkt->bktNoFitCnt++); +#endif + SDisplay(0, prntBuf); +#endif + } + +#ifdef MEMCAL_DEBUG + if (flags) + { + sprintf(prntBuf, + "SGetSBuf:%08lu:Size Bucket Id:%03d Times:%05lu Pointer: %8p\n", + *size, regCb->mapTbl[idx].bktIdx, num_times, *ptr); + SDisplay(0, prntBuf); + } +#endif /* MEMCAL_DEBUG */ + /* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + if(hstReg) + { + if (cmHstGrmAllocInsert(&(bkt->hstGrmHashListCp), + bkt->size, size, line, fileName, entId) != ROK) + { + sprintf(hstGrmBuf, "Unable to Insert into the histgram hash list\n"); + SPrint(hstGrmBuf); + } + }/* End of if */ + +#endif /* SS_HISTOGRAM_SUPPORT */ + + /* Update the size parameter */ + *size = bkt->size; +#ifdef SS_MEM_LEAK_STS + /* cm_mem_c_001.main_25 - Fixed compilation warnings 32/64 bit */ + cmStorAllocBlk((PTR)*ptr, (Size) reqSz, (Size) *size, + regCb->mapTbl[idx].bktIdx); +#elif BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL2 + cmStorAllocBlk(ptrHdr, (Size) reqSz, (Size) *size, + regCb->mapTbl[idx].bktIdx, regCb); +#endif /* SS_MEM_LEAK_STS */ + + /* cm_mem_c_008.104 - Addition for memory calculator tool */ + + RETVALUE(ROK); + } + else if (flags) + { + bkt->bktFailCnt++; +#ifdef MEMCAL_DEBUG +#ifdef ALIGN_64BIT + sprintf(prntBuf, + "[MEM_CAL_CNTB] Allocation failed in bucket %d [ size %u bytes], \ + %u times\n", regCb->mapTbl[idx].bktIdx, bkt->size, bkt->bktFailCnt); +#else + sprintf(prntBuf, + "[MEM_CAL_CNTB] Allocation failed in bucket %d [ size %lu bytes], \ + %lu times\n", regCb->mapTbl[idx].bktIdx, bkt->size, bkt->bktFailCnt); +#endif + SDisplay(0, prntBuf); +#endif + } + +#if (ERRCLASS & ERRCLS_DEBUG) + regCb->mapTbl[idx].numFailure++; +#endif /* (ERRCLASS & ERRCLS_DEBUG) */ + + cnt = cnt + 1; + } + } + else + { + if (flags) + { + regCb->heapCb.heapAllocCnt++; +#ifdef MEMCAL_DEBUG +#ifdef ALIGN_64BIT + sprintf(prntBuf, + "[MEM_CAL_CNTC] No bucket block configured for %u bytes \n \ + Number of blocks allocated from heap = %u\n",*size, + regCb->heapCb.heapAllocCnt); +#else + sprintf(prntBuf, + "[MEM_CAL_CNTC] No bucket block configured for %lu bytes \n \ + Number of blocks allocated from heap = %lu\n",*size, + regCb->heapCb.heapAllocCnt); +#endif + SDisplay(0, prntBuf); +#endif + } + } + + /* Memory not available in the bucket pool */ + if (regCb->heapFlag && (*size < regCb->heapSize)) + { +#ifdef MEMCAL_DEBUG + if (flags) tryHeap = 1; +#endif + /* + * The heap memory block is available. Allocate the memory block from + * heap pool. + */ + /* cm_mem_c_001.main_15: Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + /* cm_mem_c_001.main_12 - addition for passing an extra parameter */ +#ifdef SSI_DEBUG_LEVEL1 + RETVALUE(cmHeapAlloc(&(regCb->heapCb), ptr, size, + memType, line, fileName, entId, hstReg)); +#else + RETVALUE(cmHeapAlloc(&(regCb->heapCb), ptr, size, + line, fileName, entId, hstReg)); +#endif /* SSI_DEBUG_LEVEL1 */ +#else + /* cm_mem_c_001.main_12 - addition for passing an extra parameter */ +#ifdef SSI_DEBUG_LEVEL1 + RETVALUE(cmHeapAlloc(&(regCb->heapCb), ptr, size, memType)); +#else + RETVALUE(cmHeapAlloc(&(regCb->heapCb), ptr, size)); +#endif /* SSI_DEBUG_LEVEL1 */ +#endif /* SS_HISTOGRAM_SUPPORT */ + } + + /* No memory available */ + RETVALUE(RFAILED); +#else /* use pure is on */ + /*cm_mem_c_001.main_27 SSI-4GMX specfic changes*/ +#ifdef SS_4GMX_LCORE + *ptr = (Data*) MxHeapAlloc(SsiHeap, *size); + cmMemset((U8*)ptr, 0, *size); +#else + *ptr = (Data*) malloc(*size); +#endif + if ( (*ptr) == NULLP) + RETVALUE(RFAILED); + avail_size -= *size; + RETVALUE(ROK); +#endif /* USE_PURE */ + +} /* end of cmAllocNL */ + + +/* +* +* Fun: cmFreeNL +* +* Desc: Return the memory block for the memory region(No Lock). +* +* +* Ret: ROK - successful +* RFAILED - unsuccessful. +* +* Notes: The user calls this function to return the previously allocated +* memory block to the memory region. The memory manager does not +* check the validity of the state of the memory block(like whether +* it was allocated earlier). The caller must be sure that, the +* address specified in the parameter 'ptr' is valid and was +* allocated previously from same region. +* +* +* File: cm_mem.c +* +*/ + +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_LIGHT_MEM_LEAK_STS +#ifdef ANSI +PUBLIC S16 cmFreeNL +( +Void *regionCb, +Data *ptr, +Size size, +U32 lineNo, +U8 *funcName +) +#else +PUBLIC S16 cmFreeNL(regionCb, ptr, size, lineNo, funcName) +Void *regionCb; +Data *ptr; +Size size; +U32 lineNo; +U8 *funcName; +#endif +#else /*SS_LIGHT_MEM_LEAK_STS */ + +#ifdef SS_HISTOGRAM_SUPPORT +#ifdef ANSI +PUBLIC S16 cmFreeNL +( +Void *regionCb, +Data *ptr, +Size size, +U32 line, +U8 *fileName, +U8 entId, +Bool hstReg +) +#else +PUBLIC S16 cmFreeNL(regionCb, ptr, size, line, fileName, entId, hstReg) +Void *regionCb; +Data *ptr; +Size size; +U32 line; +U8 *fileName; +U8 entId; +Bool hstReg; +#endif + +#else + +#ifdef ANSI +PUBLIC S16 cmFreeNL +( +Void *regionCb, +Data *ptr, +Size size +) +#else +PUBLIC S16 cmFreeNL(regionCb, ptr, size) +Void *regionCb; +Data *ptr; +Size size; +#endif + /* cm_mem_c_001.main_15 : Additions */ +#endif /* SS_HISTOGRAM_SUPPORT */ +#endif /*SS_LIGHT_MEM_LEAK_STS */ + +{ +#ifndef USE_PURE + U16 idx; + CmMmBkt *bkt; +#endif + CmMmRegCb *regCb; + /* cm_mem_c_001.main_12 - addition for holding the free pointer */ +#if (defined(SSI_DEBUG_LEVEL1) || defined(BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1) || defined (SS_LIGHT_MEM_LEAK_STS)) + CmMmBlkHdr *ptrHdr; +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + CmMmBlkHdr *lastHdr; +#endif /* BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 */ +#endif /* SSI_DEBUG_LEVEL1 */ + /* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + S8 hstGrmBuf[256]; +#endif /* SS_HISTOGRAM_SUPPORT */ + + TRC2(cmFreeNL); + + regCb = (CmMmRegCb *)regionCb; + +#ifndef USE_PURE +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + /* Check if the memory block is from the memory region */ + if (ptr >= ((CmMmRegCb *)regCb)->regInfo.start + + ((CmMmRegCb *)regCb)->regInfo.size) + { + RETVALUE(RFAILED); + } +#endif +#if (ERRCLASS & ERRCLS_INT_PAR) + + /* error check on parameters */ + if ((regCb == NULLP) || (!size) || (ptr == NULLP)) + { + RETVALUE(RFAILED); + } +#ifndef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + /* Check if the memory block is from the memory region */ + if (ptr >= ((CmMmRegCb *)regCb)->regInfo.start + + ((CmMmRegCb *)regCb)->regInfo.size) + { + RETVALUE(RFAILED); + } +#endif + /* cm_mem_c_001.main_20 Addition */ + if (ptr < regCb->regInfo.start) + { + RETVALUE(RFAILED); + } + +#endif + + /* + * Check if the memory block was allocated from the bucket pool. + */ + + if (ptr < (regCb->regInfo.start + regCb->bktSize)) + { + /* The memory block was allocated from the bucket pool */ + + /* Get the map to the mapping table */ + idx = ((size - 1) >> regCb->bktQnPwr); + +#if (ERRCLASS & ERRCLS_DEBUG) + if (regCb->mapTbl[idx].bktIdx == 0xFF) + { + /* Some fatal error in the map table initialization. */ + RETVALUE(RFAILED); + } +#endif + + /* Enqueue the memory block and return it to the user */ + bkt = &(regCb->bktTbl[regCb->mapTbl[idx].bktIdx]); + + /* + * Check if the size is not greater than the size available + * in the bucket. If so, then the buffer must have been allocated + * from next bucket. We don't need to check the validity of the + * next bucket, otherwise buffer must have been allocated from heap + * pool. + */ + if (size > bkt->size) + { + bkt = &(regCb->bktTbl[regCb->mapTbl[++idx].bktIdx]); + } + + /* cache_coherency_changes */ +#ifdef LOWERARM + MxDMB(); +#endif + + /* cm_mem_c_001.main_12 - addition for sanity check and free */ +#if (defined(SSI_DEBUG_LEVEL1) || defined(BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1)) + /* increment the dealloc attempt counter at bucket level */ + bkt->numDeallocAttempts++; + + /* Check the memFlags to see whether this block was allocated */ + ptrHdr = (CmMmBlkHdr *) (ptr - sizeof(CmMmBlkHdr)); +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL2 + cmRlsAllocBlk(ptrHdr, regCb); +#endif +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + /* Check for ptr size */ + if(((ptrHdr->requestedSize - size) % size) != 0) + { +#ifdef DEBUGP + sprintf(dbgPrntBuf, "Passed size (%d) does not match with allocated size(%d):%8p, Bucket Id:%03d\n", + size, ptrHdr->requestedSize, ptr, regCb->mapTbl[idx].bktIdx); +#endif + printf("Passed size (%d) does not match with allocated size(%d):%8p, Bucket Id:%03d\n", + size, ptrHdr->requestedSize, ptr, regCb->mapTbl[idx].bktIdx); + abort(); + } +#endif + + /* validate the block to be freed for trampling */ +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + if(cmMmRegIsBlkSane(ptrHdr, bkt->size) != ROK) +#else + if (cmMmRegIsBlkSane(ptrHdr) != ROK) +#endif + { + /* Handle error case of Memory trampling */ +#ifdef DEBUGP + /* display an error message here */ +#ifdef ALIGN_64BIT + sprintf(dbgPrntBuf, "Memory Trampling at: %8p, Bucket Id:%03d, size %u bytes \n", + ptr, regCb->mapTbl[idx].bktIdx, bkt->size); +#else + sprintf(dbgPrntBuf, "Memory Trampling at: %8p, Bucket Id:%03d, size %lu bytes \n", + ptr, regCb->mapTbl[idx].bktIdx, bkt->size); +#endif + SDisplay(0, dbgPrntBuf); +#endif /* DEBUGP */ + abort(); + /* + * if sanity check returns RTRAMPLINGOK then there is nothing to do + * as the memory blk is already invalidated in cmMmBktSanityChk + */ +#ifndef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + if (cmMmBktSanityChk(bkt) == RTRAMPLINGOK) + { + bkt->numAlloc--; + + RETVALUE(ROK); + } + else + { + /* handle RTRAMPLINGNOK in SFree/SPutSBuf */ + RETVALUE(RTRAMPLINGNOK); + } +#endif +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + printf("Memory signature is invalid\n"); + abort(); +#endif + } + /* reset the size */ + ptrHdr->requestedSize = 0; +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + /* Initialize the elements with 0XAB */ + cmMemset((U8 *)ptr, 0xAB, size); +#endif + /* check if the block to be freed is already having the state as FREE */ + if (CMM_IS_FREE(ptrHdr->memFlags)) + { + /* Handle double deallocation error case */ +#ifdef DEBUGP + /* display an error message here */ + /*cm_mem_c_001.main_23 Fix for specifier mismatch + * warnings in 64BIT compilation*/ +#ifdef ALIGN_64BIT + sprintf(dbgPrntBuf, "Attempt to double deallocate memory at: %8p," + "Bucket Id:%03d, size %u bytes \n", + ptr, regCb->mapTbl[idx].bktIdx, bkt->size); +#else + sprintf(dbgPrntBuf, "Attempt to double deallocate memory at: %8p," + "Bucket Id:%03d, size %lu bytes \n", + ptr, regCb->mapTbl[idx].bktIdx, bkt->size); +#endif + SDisplay(0, dbgPrntBuf); +#endif /* DEBUGP */ +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + printf("Attempt to double deallocate memory at: %8p, Bucket Id:%03d,\ + size %u bytes \n", ptr, regCb->mapTbl[idx].bktIdx, bkt->size); + abort(); +#endif + + /* handle RDBLFREE in SFree/SPutSBuf */ + RETVALUE(RDBLFREE); + } + if (CMM_IS_STATIC(ptrHdr->memFlags)) + { + CMM_SET_FREE_FLAG(ptrHdr->memFlags); + CMM_RESET_STATIC_FLAG(ptrHdr->memFlags); + /* deduct it from the static memory count */ + bkt->staticMemUsed -= bkt->size; + } + else if (CMM_IS_DYNAMIC(ptrHdr->memFlags)) + { + CMM_SET_FREE_FLAG(ptrHdr->memFlags); + CMM_RESET_DYNAMIC_FLAG(ptrHdr->memFlags); + /* deduct it from the dynamic memory count */ + bkt->dynamicMemUsed -= bkt->size; + } + else + { + /* This is a case similar to trampled memory */ +#ifdef DEBUGP + /*cm_mem_c_001.main_23 Fix for specifier + * mismatch warnings in 64BIT compilation*/ +#ifdef ALIGN_64BIT + sprintf(dbgPrntBuf, "Invalid memory flag: %u !!!\n", ptrHdr->memFlags); +#else + sprintf(dbgPrntBuf, "Invalid memory flag: %lu !!!\n", ptrHdr->memFlags); +#endif + SDisplay(0, dbgPrntBuf); +#endif /* DEBUGP */ +#ifndef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + if (cmMmBktSanityChk(bkt) == RTRAMPLINGOK) + { + /* do not add to the free list */ + bkt->numAlloc--; + RETVALUE(ROK); + } + else + { + /* handle RTRAMPLINGNOK in SFree/SPutSBuf */ + RETVALUE(RTRAMPLINGNOK); + } +#endif + } +#ifndef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + /* Return the block to memory */ + ptrHdr->nextBlk = bkt->nextBlk; + bkt->nextBlk = ptrHdr; +#endif +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + /* Move the ptr to end of the bucket */ + lastHdr = (CmMmBlkHdr *)bkt->lastBlk; + lastHdr->nextBlk = ptrHdr; + bkt->lastBlk = ptrHdr; + ptrHdr->nextBlk = NULLP; +#endif +#elif SS_LIGHT_MEM_LEAK_STS + ptrHdr = (CmMmBlkHdr *) (ptr - sizeof(CmMmBlkHdr)); + ptrHdr->lineNo = lineNo; + ptrHdr->currFuncName = funcName; + if(gmemLkCb.isStarted == TRUE) + { + cmRlsAllocBlk(ptrHdr->allocQueueIndx); + } + ptrHdr->nextBlk = bkt->nextBlk; + bkt->nextBlk = ptrHdr; + +#else +#ifdef SSI_MEM_CORR_PREVENTION + if (*(((U32 *)(ptr)) + 2) == 0xdeaddead) + { + /* Do not free an already freed block to avoid corruption */ + cmDblFreeAttempts++; + bkt->numAlloc++; + } + else + { + *((CmMmEntry **)bkt->last) = ptr; + bkt->last = (CmMmEntry *)ptr; + *((CmMmEntry **)ptr) = NULLP; + *(((U32 *)(ptr)) + 2) = 0xdeaddead; + } +#else + *((CmMmEntry **)ptr) = bkt->next; + bkt->next = (CmMmEntry *)ptr; +#endif +#endif /* SSI_DEBUG_LEVEL1 */ + + /* cache_coherency_changes */ +#ifdef LOWERARM + MxDMB(); +#endif + /* + * Decrement the statistics variable of number of memory block + * allocated + */ + bkt->numAlloc--; + /* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + /* If Tapa task (entId)is registerd for histogram then insert Memrory Freed + * information into the hash list */ + if(hstReg) + { + if (cmHstGrmFreeInsert(&bkt->hstGrmHashListCp, bkt->size, + line, fileName, entId) != ROK) + { + sprintf(hstGrmBuf, "Unable to Insert into the histgram hash list\n"); + SPrint(hstGrmBuf); + } + }/* End of if */ +#endif /* SS_HISTOGRAM_SUPPORT */ + +#ifdef SS_MEM_LEAK_STS + /* cm_mem_c_001.main_25 - Fixed compilation warnings 32/64 bit */ + cmRlsAllocBlk((PTR)ptr); +#endif /* SS_MEM_LEAK_STS */ + + RETVALUE(ROK); + } + + /* The memory block was allocated from the heap pool */ + /* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + RETVALUE(cmHeapFree (&(regCb->heapCb), ptr, size, line, fileName, entId, hstReg)); +#else + RETVALUE(cmHeapFree (&(regCb->heapCb), ptr, size)); +#endif /* SS_HISTOGRAM_SUPPORT */ +#else /* use pure is on */ + TRC2(cmFreeNL); + /*cm_mem_c_001.main_27 SSI-4GMX specfic changes*/ +#ifdef SS_4GMX_LCORE + (Void)MxHeapFree(SsiHeap, ptr); +#else + (Void)free(ptr); +#endif + avail_size += size; + RETVALUE(ROK); +#endif /* USE_PURE */ +} /* end of cmFreeNL */ + + +/* +* +* Fun: cmAllocWL +* +* Desc: alloc without lock +* +* +* Ret: ROK - successful +* RFAILED - unsuccessful. +* +* +* File: cm_mem.c +* +*/ +/*cm_mem_c_001.main_21-added new function*/ +/*cm_mem_c_001.main_23 Removed support of SSI_DEBUG_LEVEL1 and SS_HISTOGRAM_SUPPORT for SS_FAP*/ +#ifdef SS_FAP +#ifdef ANSI +PRIVATE S16 cmAllocWL +( +Void *regionCb, +Size *size, +U32 flags, +Data **ptr +) +#else +PRIVATE S16 cmAllocWL(regionCb, size, flags, ptr) +Void *regionCb; +Size *size; +U32 flags; +Data **ptr; +#endif +{ + U16 idx; + CmMmBkt *bkt; + CmMmRegCb *regCb; + /*cm_mem_c_001.main_23 Removed support of SSI_DEBUG_LEVEL1 and SS_HISTOGRAM_SUPPORT for SS_FAP*/ + + TRC2(cmAllocWL); + + /*cm_mem_c_001.main_23 Removed support of USE_MEMCAL and MEMCAL_DEBUG support for SS_FAP*/ + + regCb = (CmMmRegCb *)regionCb; + +#if (ERRCLASS & ERRCLS_INT_PAR) + + /* error check on parameters */ + if ((regCb == NULLP) || (size == NULLP) || !(*size) || (ptr == NULLP)) + { + RETVALUE(RFAILED); + } +#endif + + /*cm_mem_c_001.main_23 Removed support of SSI_DEBUG_LEVEL1 and SS_HISTOGRAM_SUPPORT for SS_FAP*/ + +#ifndef USE_PURE + + /* + * Check if the requested size is less than or equal to the maximum block + * size in the bucket. + */ + /* cm_mem_c_001.main_23 Adding check to compair size with Maximum block size*/ + if ( *size <= regCb->bktMaxBlkSize) + { + /* Get the map to the mapping table */ + idx = ((*size - 1) >> regCb->bktQnPwr); + + /* Dequeue the memory block and return it to the user */ + bkt = &(regCb->bktTbl[regCb->mapTbl[idx].bktIdx]); + + { + /* + * Check if the size request is not greater than the size available + * in the bucket + */ + /* cm_mem_c_001.main_23 combined If(*size <= bkt->size) and if(*ptr = bkt->next)*/ + if ((*size <= bkt->size)&&(*ptr = bkt->next)) + { + /* Try to go to the next bucket if available */ + bkt->next = *((CmMmEntry **)(bkt->next)); + + /* + * Increment the statistics variable of number of memory block + * allocated + */ + bkt->numAlloc++; + + /* Update the size parameter */ + *size = bkt->size; + + RETVALUE(ROK); + } + } + } + + /* Memory not available in the bucket pool */ + if (regCb->heapFlag && (*size < regCb->heapSize)) + { + /*cm_mem_c_001.main_23 Removed support of and MEMCAL_DEBUG support for SS_FAP*/ + /* + * The heap memory block is available. Allocate the memory block from + * heap pool. + */ + /*cm_mem_c_001.main_23 Removed support of SSI_DEBUG_LEVEL1 and SS_HISTOGRAM_SUPPORT for SS_FAP*/ + RETVALUE(cmHeapAlloc(&(regCb->heapCb), ptr, size)); + } + + /* No memory available */ + RETVALUE(RFAILED); +#else /* use pure is on */ +/*cm_mem_c_001.main_27 SSI-4GMX specfic changes*/ +#ifdef SS_4GMX_LCORE + *ptr = (Data*) MxHeapAlloc(SsiHeap, *size); + cmMemset((U8*)ptr, 0, *size); +#else + *ptr = (Data*) malloc(*size); +#endif + if ( (*ptr) == NULLP) + RETVALUE(RFAILED); + avail_size -= *size; + RETVALUE(ROK); +#endif /* USE_PURE */ + +} /* end of cmAllocWL */ + + +/* +* +* Fun: cmfree +* +* Desc: free without lock +* +* +* Ret: ROK - successful +* RFAILED - unsuccessful. +* +* +* File: cm_mem.c +* +*/ + +#ifdef ANSI +PRIVATE S16 cmFreeWL +( +Void *regionCb, +Data *ptr, +Size size +) +#else +PRIVATE S16 cmFreeWL(regionCb, ptr, size) +Void *regionCb; +Data *ptr; +Size size; +#endif +{ + U16 idx; + CmMmBkt *bkt; + CmMmRegCb *regCb; + /*cm_mem_c_001.main_23 Removed support of SSI_DEBUG_LEVEL1 and SS_HISTOGRAM_SUPPORT for SS_FAP*/ + + TRC2(cmFreeWL); + + regCb = (CmMmRegCb *)regionCb; + +#ifndef USE_PURE +#if (ERRCLASS & ERRCLS_INT_PAR) + + /* error check on parameters */ + if ((regCb == NULLP) || (!size) || (ptr == NULLP)) + { + RETVALUE(RFAILED); + } + + /* Check if the memory block is from the memory region */ + if (ptr >= ((CmMmRegCb *)regCb)->regInfo.start + + ((CmMmRegCb *)regCb)->regInfo.size) + { + RETVALUE(RFAILED); + } + +#endif + + /* + * Check if the memory block was allocated from the bucket pool. + */ + + if (ptr < (regCb->regInfo.start + regCb->bktSize)) + { + /* The memory block was allocated from the bucket pool */ + + /* Get the map to the mapping table */ + idx = ((size - 1) >> regCb->bktQnPwr); + +#if (ERRCLASS & ERRCLS_DEBUG) + if (regCb->mapTbl[idx].bktIdx == 0xFF) + { + /* Some fatal error in the map table initialization. */ + RETVALUE(RFAILED); + } +#endif + + /* Enqueue the memory block and return it to the user */ + bkt = &(regCb->bktTbl[regCb->mapTbl[idx].bktIdx]); + + /* + * Check if the size is not greater than the size available + * in the bucket. If so, then the buffer must have been allocated + * from next bucket. We don't need to check the validity of the + * next bucket, otherwise buffer must have been allocated from heap + * pool. + */ + if (size > bkt->size) + { + bkt = &(regCb->bktTbl[regCb->mapTbl[++idx].bktIdx]); + } + + /*cm_mem_c_001.main_23 Removed support of SSI_DEBUG_LEVEL1 and SS_HISTOGRAM_SUPPORT for SS_FAP*/ + *((CmMmEntry **)ptr) = bkt->next; + bkt->next = (CmMmEntry *)ptr; + + /* + * Decrement the statistics variable of number of memory block + * allocated + */ + bkt->numAlloc--; + + RETVALUE(ROK); + } + + /* The memory block was allocated from the heap pool */ + RETVALUE(cmHeapFree (&(regCb->heapCb), ptr, size)); +#else /* use pure is on */ + TRC2(cmFree); +/*cm_mem_c_001.main_27 SSI-4GMX specfic changes*/ +#ifdef SS_4GMX_LCORE + (Void)MxHeapFree(SsiHeap, ptr); +#else + (Void)free(ptr); +#endif + avail_size += size; + RETVALUE(ROK); +#endif /* USE_PURE */ + + +} /* end of cmFreeWL */ +#endif + + +/* +* +* Fun: cmCtl +* +* Desc: Control request function. +* +* +* Ret: ROK - successful +* RFAILED - unsuccessful. +* +* Notes: The current semantics of the control function is defined for two +* types of events: virtual address to physical address translation +* and memory resource check. +* +* The physical address translation is valid only for the memory +* region physically contiguous and non pagable. +* +* +* +* File: cm_mem.c +* +*/ + +#ifdef ANSI +PRIVATE S16 cmCtl +( +Void *regionCb, +Event event, +SMemCtl *memCtl +) +#else +PRIVATE S16 cmCtl(regionCb, event, memCtl) +Void *regionCb; +Event event; +SMemCtl *memCtl; +#endif +{ + CmMmRegCb *regCb; + + TRC2(cmCtl); + + regCb = (CmMmRegCb *)regionCb; + +#if (ERRCLASS & ERRCLS_INT_PAR) + + /* error check on parameters */ + if ((regCb == NULLP) || (memCtl == NULLP)) + { + RETVALUE(RFAILED); + } + +#endif + + switch (event) + { + case SS_MEM_V_TO_P: + { + Size offset; + +#if (ERRCLASS & ERRCLS_INT_PAR) + if ((memCtl->u.vtop.vaddr == NULLP) || + (memCtl->u.vtop.paddr == NULLP)) + { + RETVALUE(RFAILED); + } +#endif + + /* Check if the virtual to physical address translation is valid */ + if (regCb->chFlag & CMM_REG_PHY_VALID) + { + offset = memCtl->u.vtop.vaddr - regCb->regInfo.start; + *(memCtl->u.vtop.paddr) = regCb->pAddr + offset; + + RETVALUE(ROK); + } + break; + } + + case SS_MEM_CHK_RES: + { + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (!(memCtl->u.chkres.size) || + (memCtl->u.chkres.status == NULLP)) + { + RETVALUE(RFAILED); + } +#endif +#ifndef USE_PURE + /* Check if the Bucket pool is configured */ + if (regCb->bktSize) + { + U16 idx; + CmMmBkt *bkt; + U32 avlSize, totSize; + /* + * The bucket pool is configured. The status value returned + * does reflect on the memory availabilty in the bucket pool. + * The value does not consider the available memory in the + * heap pool. + */ + idx = ((memCtl->u.chkres.size - 1) >> regCb->bktQnPwr); + bkt = &(regCb->bktTbl[regCb->mapTbl[idx].bktIdx]); + avlSize = (bkt->numBlks - bkt->numAlloc) * bkt->size; + avlSize += regCb->heapCb.avlSize; + totSize = (bkt->numBlks * bkt->size) + regCb->heapSize; + *(memCtl->u.chkres.status) = (avlSize/(totSize/10)); + } + else + { + /* Bucket pool not configured */ + + /* + * Find the percentage memory available in the heap pool. The value + * does not consider the fragmentation of the heap pool. + */ + *(memCtl->u.chkres.status) = ((regCb->heapCb.avlSize) / + (regCb->heapSize/10)); + } + + RETVALUE(ROK); +#else /* use pure is on */ + *(memCtl->u.chkres.status) = ((avail_size) / + (regCb->regInfo.size/10)); + RETVALUE(ROK); +#endif /* USE_PURE */ + + } + + default: + { + /* No other event is supported currently */ + RETVALUE(RFAILED); + } + } + + /* shouldn't reach here */ + RETVALUE(RFAILED); +} /* end of cmCtl */ + + +/* +* +* Fun: cmMmBktInit +* +* Desc: Initialize the bucket and the map table. +* +* +* Ret: ROK - successful, +* RFAILED - unsuccessful. +* +* Notes: This function is called by the cmMmRegInit. +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PRIVATE Void cmMmBktInit +( +Data **memAddr, +CmMmRegCb *regCb, +CmMmRegCfg *cfg, +U16 bktIdx, +U16 *lstMapIdx +) +#else +PRIVATE Void cmMmBktInit (memAddr, regCb, cfg, bktIdx, lstMapIdx) +Data **memAddr; +CmMmRegCb *regCb; +CmMmRegCfg *cfg; +U16 bktIdx; +U16 *lstMapIdx; +#endif +{ + U32 cnt; + U16 idx; + U32 numBlks; + Size size; +/* cm_mem_c_001.main_12 - addition for temporary variables */ +#if (defined(SSI_DEBUG_LEVEL1) || defined(BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1) || defined (SS_LIGHT_MEM_LEAK_STS)) + CmMmBlkHdr **nextBlk; +#ifdef SS_LIGHT_MEM_LEAK_STS + CmMmBlkHdr *lastBlk; +#endif /*SS_LIGHT_MEM_LEAK_STS */ + U32 sigCnt; +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + Data *tmpMemAddr; + CmMmBlkTail *blkTail; +#endif +#else + Data **next; +#ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */ + Data **last; +#endif +#endif /* SSI_DEBUG_LEVEL1 */ + + TRC2(cmMmBktInit); + + + size = cfg->bktCfg[bktIdx].size; + numBlks = cfg->bktCfg[bktIdx].numBlks; + +/* cm_mem_c_001.main_12 - addition for header initialization */ +#if (defined(SSI_DEBUG_LEVEL1) || defined(BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1) || defined (SS_LIGHT_MEM_LEAK_STS)) + /* Reset the next block pointer */ + regCb->bktTbl[bktIdx].nextBlk = NULLP; +#if (defined(BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1) || defined (SS_LIGHT_MEM_LEAK_STS)) + regCb->bktTbl[bktIdx].lastBlk = NULLP; +#endif + /* Initialize the link list of the memory block */ + nextBlk = &(regCb->bktTbl[bktIdx].nextBlk); + + for (cnt = 0; cnt < numBlks; cnt++) + { + *nextBlk = (CmMmBlkHdr *)*memAddr; +#ifdef SS_LIGHT_MEM_LEAK_STS + lastBlk = (CmMmBlkHdr *)*memAddr; +#endif /*SS_LIGHT_MEM_LEAK_STS */ + + /* initialize the memory block header */ + for (sigCnt=0; sigCnt < CMM_TRAMPLING_SIGNATURE_LEN; sigCnt++) + { + (*nextBlk)->trSignature[sigCnt] = 0xAB; + } +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + /* Initialize memory block tail */ + blkTail = (CmMmBlkTail *)(*memAddr + sizeof(CmMmBlkHdr) + size); + for (sigCnt=0; sigCnt < CMM_TRAMPLING_SIGNATURE_LEN; sigCnt++) + { + blkTail->trSignature[sigCnt] = 0xFE; + } +#endif + CMM_SET_FREE_FLAG((*nextBlk)->memFlags); + (*nextBlk)->requestedSize = 0; +#ifdef SS_LIGHT_MEM_LEAK_STS + (*nextBlk)->timeStamp = 0X7777; + (*nextBlk)->lineNo = 0; + (*nextBlk)->allocQueueIndx = 1; + (*nextBlk)->currFuncName = NULL; +#endif /*SS_LIGHT_MEM_LEAK_STS */ + +#if defined(SSI_DEBUG_LEVEL1) || defined(SS_LIGHT_MEM_LEAK_STS) + *memAddr = (Data *)((*memAddr) + ((sizeof(CmMmBlkHdr)) + size)); +#elif BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + *memAddr = (Data *)((*memAddr) + ((sizeof(CmMmBlkHdr)) + sizeof(CmMmBlkTail) + size)); +#endif + nextBlk = &((*nextBlk)->nextBlk); + } + + *nextBlk = NULLP; +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + tmpMemAddr = (Data *)((*memAddr) - ((sizeof(CmMmBlkHdr)) + sizeof(U32) + size)); + regCb->bktTbl[bktIdx].lastBlk = (CmMmBlkHdr *)tmpMemAddr; +#endif + +#else + /* Reset the next pointer */ + regCb->bktTbl[bktIdx].next = NULLP; +#ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */ + regCb->bktTbl[bktIdx].last = NULLP; +#endif + + /* Initialize the link list of the memory block */ + next = &(regCb->bktTbl[bktIdx].next); +#ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */ + last = &(regCb->bktTbl[bktIdx].last); + if(regCb->region == 0) + { + if(size == 128) + { + startPtr128 = *memAddr; + regMemSize = regCb->regInfo.size; + uart_printf("size of all pool=%u\n", regMemSize); + uart_printf("startPtr128=%x\n", startPtr128); + } + if(size == 256) + { + startPtr256 = *memAddr; + uart_printf("startPtr256=%x\n", startPtr256); + } + if(size == 512) + { + startPtr512 = *memAddr; + uart_printf("startPtr512=%x\n", startPtr512); + } + if(size == 768) + { + startPtr768 = *memAddr; + uart_printf("startPtr768=%x\n", startPtr768); + } + if(size == 1664) + { + startPtr1664 = *memAddr; + uart_printf("startPtr1664=%x\n", startPtr1664); + } + if(size == 4800) + { + startPtr4800 = *memAddr; + uart_printf("startPtr4800=%x\n", startPtr4800); + } + if(size == 9920) + { + startPtr9920 = *memAddr; + uart_printf("startPtr9920=%x\n", startPtr9920); + } + } +#endif + for (cnt = 0; cnt < numBlks; cnt++) + { + *next = *memAddr; +#ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */ + (*(U32 *)(*next + 4)) = 0xdeaddead; + (*(U32 *)(*next + 124)) = 0; + (*(U32 *)(*next + 116)) = 0xdeaddead; + (*(U32 *)(*next + 24)) = 0xdeaddead; + (*(U32 *)(*next + 44)) = 0xdeaddead; + (*(U32 *)(*next + 80)) = 0xdeaddead; +#endif +#ifdef SSI_MEM_CORR_PREVENTION + *(((U32 *)(*next)) + 2) = 0xdeaddead; +#endif + next = (CmMmEntry **)(*memAddr); + *memAddr = (*memAddr) + size; + } + *next = NULLP; +#ifdef MS_MBUF_CORRUPTION /* Should be enabled when debugging mbuf corruption */ + *last = (CmMmEntry *)next; +#endif +#ifdef SSI_MEM_CORR_PREVENTION + regCb->bktTbl[bktIdx].last = (CmMmEntry *)next; +#endif + +#endif /* SSI_DEBUG_LEVEL1 */ + + /* Initialize the Map entry */ + idx = size / cfg->bktQnSize; + + /* + * Check if the size is multiple of quantum size. If not we need to initialize + * one more map table entry. + */ + if(size % cfg->bktQnSize) + { + idx++; + } + + while ( *lstMapIdx < idx) + { + regCb->mapTbl[*lstMapIdx].bktIdx = bktIdx; + +#if (ERRCLASS & ERRCLS_DEBUG) + regCb->mapTbl[*lstMapIdx].numReq = 0; + regCb->mapTbl[*lstMapIdx].numFailure = 0; +#endif + + (*lstMapIdx)++; + } + + /* Initialize the bucket structure */ + regCb->bktTbl[bktIdx].size = size; + regCb->bktTbl[bktIdx].numBlks = numBlks; + regCb->bktTbl[bktIdx].numAlloc = 0; + + /* Update the total bucket size */ +/* cm_mem_c_001.main_12 - addition for considering the header size */ +#if (defined(SSI_DEBUG_LEVEL1) || defined (SS_LIGHT_MEM_LEAK_STS)) + regCb->bktSize += ((size + sizeof(CmMmBlkHdr)) * numBlks); +/* Addition for considering the header size and tail */ +#elif BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + regCb->bktSize += ((size + sizeof(CmMmBlkHdr) + sizeof(U32)) * numBlks); +#else + regCb->bktSize += (size * numBlks); +#endif /* SSI_DEBUG_LEVEL1 */ + + regCb->bktTbl[bktIdx].bktFailCnt = 0; + regCb->bktTbl[bktIdx].bktNoFitCnt = 0; + +/* cm_mem_c_001.main_12 - addition for statistics related variable initialization */ +#if (defined(SSI_DEBUG_LEVEL1) || defined(BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1)) + /* Initialize other required pointers */ + regCb->bktTbl[bktIdx].bktStartPtr = (Data *)(regCb->bktTbl[bktIdx].nextBlk); + regCb->bktTbl[bktIdx].numAllocAttempts = 0; + regCb->bktTbl[bktIdx].numDeallocAttempts = 0; + regCb->bktTbl[bktIdx].staticMemUsed = 0; + regCb->bktTbl[bktIdx].dynamicMemUsed = 0; + regCb->bktTbl[bktIdx].trampleCount = 0; +#endif /*SSI_DEBUG_LEVEL1*/ +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + /* Initialise the memory histogram hash list */ + cmHstGrmHashListInit(&(regCb->bktTbl[bktIdx].hstGrmHashListCp)); +#endif /* SS_HISTOGRAM_SUPPORT */ + + RETVOID; +} /* end of cmMmBktInit */ + + +/* +* +* Fun: cmMmHeapInit +* +* Desc: Initialize the heap pool. +* +* +* Ret: ROK - successful +* RFAILED - unsuccessful. +* +* Notes: This function is called by the cmMmRegInit. +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PRIVATE Void cmMmHeapInit +( +Data *memAddr, +CmMmHeapCb *heapCb, +Size size +) +#else +PRIVATE Void cmMmHeapInit (memAddr, heapCb, size) +Data *memAddr; +CmMmHeapCb *heapCb; +Size size; +#endif +{ +/* cm_mem_c_001.main_12 - addition for ssi enhancements */ +#ifdef SSI_DEBUG_LEVEL1 + U16 idx; +#endif /* SSI_DEBUG_LEVEL1 */ + TRC2(cmMmHeapInit); + + /* Initialize the heap control block */ + heapCb->vStart = memAddr; + heapCb->vEnd = memAddr + size; + heapCb->avlSize = size; + heapCb->minSize = CMM_MINBUFSIZE; + + heapCb->next = (CmHEntry *)memAddr; + heapCb->next->next = NULLP; +/* cm_mem_c_001.main_12 - addition for header initialization */ +#ifdef SSI_DEBUG_LEVEL1 + heapCb->next->size = size - sizeof(CmHEntry); + heapCb->next->requestedSize = 0; + for (idx=0; idx < CMM_TRAMPLING_SIGNATURE_LEN; idx++) + { + heapCb->next->trSignature[idx] = 0xAB; + } + CMM_SET_FREE_FLAG(heapCb->next->memFlags); + heapCb->staticHeapMemUsed = 0; + heapCb->dynamicHeapMemUsed = 0; + heapCb->nextOffset = sizeof(heapCb->next->trSignature) + + sizeof(heapCb->next->memFlags) + + sizeof(heapCb->next->requestedSize); + heapCb->numAllocAttempts = 0; + heapCb->numDeallocAttempts = 0; + heapCb->trampleCount = 0; +#else + heapCb->next->size = size; +#endif /* SSI_DEBUG_LEVEL1 */ + +#if (ERRCLASS & ERRCLS_DEBUG) + heapCb->numFragBlk = 0; + heapCb->numReq = 0; + heapCb->numFailure = 0; +#endif + + heapCb->heapAllocCnt = 0; +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + /* Initialise the memory histogram hash list */ + cmHstGrmHashListInit(&(heapCb->heapHstGrmHashListCp)); +#endif /* SS_HISTOGRAM_SUPPORT */ + RETVOID; + +} /* end of cmMmHeapInit */ + +#ifndef USE_PURE +/* +* +* Fun: cmHeapAlloc +* +* Desc: Allocates the memory block from the heap pool. +* +* +* Ret: ROK - successful +* RFAILED - unsuccessful. +* +* Notes: This function is called by the cmAlloc. cmAlloc calls this +* function when there is no memory block available in the bucket +* and the heap pool is configured. +* +* +* +* File: cm_mem.c +* +*/ +/* cm_mem_c_001.main_12 - addition for taking another parameter memType(static/dynamic) */ +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_4GMX_LCORE +EXTERN U8 ysCellConfigDone; +#endif +#ifdef SS_HISTOGRAM_SUPPORT +#ifdef SSI_DEBUG_LEVEL1 +#ifdef ANSI +PRIVATE S16 cmHeapAlloc +( +CmMmHeapCb *heapCb, +Data **ptr, +Size *size, +U32 memType, +U32 line, +U8 *fileName, +U8 entId, +Bool hstReg +) +#else +PRIVATE S16 cmHeapAlloc (heapCb, ptr, size, memType, line, fileName, entId, hstReg) +CmMmHeapCb *heapCb; +Data **ptr; +Size *size; +U32 memType; +U32 line; +U8 *fileName; +U8 entId; +Bool hstReg; +#endif +#else +#ifdef ANSI +PRIVATE S16 cmHeapAlloc +( +CmMmHeapCb *heapCb, +Data **ptr, +Size *size, +U32 line, +U8 *fileName, +U8 entId, +Bool hstReg +) +#else +PRIVATE S16 cmHeapAlloc (heapCb, ptr, size, line, fileName, entId, hstReg) +CmMmHeapCb *heapCb; +Data **ptr; +Size *size; +U32 line; +U8 *fileName; +U8 entId; +Bool hstReg; +#endif +#endif /* SSI_DEBUG_LEVEL1 */ +#else +#ifdef SSI_DEBUG_LEVEL1 +#ifdef ANSI +PRIVATE S16 cmHeapAlloc +( +CmMmHeapCb *heapCb, +Data **ptr, +Size *size, +U32 memType +) +#else +PRIVATE S16 cmHeapAlloc (heapCb, ptr, size, memType) +CmMmHeapCb *heapCb; +Data **ptr; +Size *size; +U32 memType; +#endif +#else +#ifdef ANSI +PRIVATE S16 cmHeapAlloc +( +CmMmHeapCb *heapCb, +Data **ptr, +Size *size +) +#else +PRIVATE S16 cmHeapAlloc (heapCb, ptr, size) +CmMmHeapCb *heapCb; +Data **ptr; +Size *size; +#endif +#endif /* SSI_DEBUG_LEVEL1 */ +/* cm_mem_c_001.main_15 : Additions */ +#endif /* SS_HISTOGRAM_SUPPORT */ +{ + CmHEntry *prvHBlk; /* Previous heap block */ + CmHEntry *curHBlk; /* Current heap block */ + Size tmpSize; +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_MEM_LEAK_STS + Size reqSz; +#endif /* SS_MEM_LEAK_STS */ +/* cm_mem_c_001.main_12 - addition for ssi enhancements */ +#ifdef SSI_DEBUG_LEVEL1 + CmHEntry *alocHeapBlk; + Size requestedSize; + Size hdr; + U16 idx; +#endif /* SSI_DEBUG_LEVEL1 */ +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + S8 hstGrmBuf[256]; +#endif /* SS_HISTOGRAM_SUPPORT */ + + TRC2(cmHeapAlloc); +/* cm_mem_c_001.main_15 : Additions */ + /* Acquire the heap lock */ + /* cm_mem_c_001.main_13 : Replaced SLock with WTLock for NT */ +#ifdef SS_4GMX_LCORE + if(1 == ysCellConfigDone) + { +#ifdef SSI_DEBUG_LEVEL1 + /* display a message here */ + sprintf(dbgPrntBuf,"Allocating from heap size=%u\n", *size); + SDisplay(0, dbgPrntBuf); +#endif /* SSI_DEBUG_LEVEL1 */ + } +#endif +#ifdef SS_WIN + (Void) WTLock (&(heapCb->heapLock)); +#else + (Void) SLock (&(heapCb->heapLock)); +#endif + +#ifdef SS_MEM_LEAK_STS + reqSz = *size; +#endif /* SS_MEM_LEAK_STS */ +/* cm_mem_c_001.main_12 - addition for manipulation of statistics related data */ +#ifdef SSI_DEBUG_LEVEL1 + heapCb->numAllocAttempts++; + requestedSize = *size; +#endif /* SSI_DEBUG_LEVEL1 */ + + /* Roundup the requested size */ + *size = CMM_DATALIGN(*size, (heapCb->minSize)); + + /* Check if the available total size is adequate. */ + if ((*size) >= heapCb->avlSize) + { +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_WIN + (Void) WTUnlock (&(heapCb->heapLock)); +#else + (Void) SUnlock (&(heapCb->heapLock)); +#endif + RETVALUE(ROUTRES); + } + + +/* cm_mem_c_001.main_12 - addition for aligning the header size */ +#ifdef SSI_DEBUG_LEVEL1 + hdr = PTRALIGN(sizeof(CmHEntry)); +#endif /* SSI_DEBUG_LEVEL1 */ + + /* + * Search through the heap block list in the heap pool of size + * greater than or equal to the requested size. + * + */ +/* cm_mem_c_001.main_12 - addition for accessing the heapCb->next */ +#ifdef SSI_DEBUG_LEVEL1 + prvHBlk = (CmHEntry *)((Data *)&(heapCb->next) - heapCb->nextOffset); +#else + prvHBlk = (CmHEntry *)&(heapCb->next); +#endif /* SSI_DEBUG_LEVEL1 */ + for (curHBlk = prvHBlk->next; curHBlk; curHBlk = curHBlk->next, + prvHBlk = prvHBlk->next) + { + /* + * Since the size of the block is always multiple of CMM_MINBUFSIZE + * and the requested size is rounded to the size multiple of + * CMM_MINBUFSIZE, the difference between the size of the heap block + * and the size to allocate will be either zero or multiple of + * CMM_MINBUFSIZE. + */ + if ((*size) <= curHBlk->size) + { +/* cm_mem_c_001.main_12 - addition for block size calculation */ +#ifdef SSI_DEBUG_LEVEL1 + tmpSize = curHBlk->size - (*size); + if (tmpSize != 0) + tmpSize = tmpSize - hdr; + if (tmpSize) +#else + /* cm_mem_c_001.main_28 : compilation warning fix */ + tmpSize = (curHBlk->size - (*size)); + if (tmpSize != 0) +#endif /* SSI_DEBUG_LEVEL1 */ + { + /* Heap block of bigger size */ +/* cm_mem_c_001.main_12 - addition for allocating memory */ +#ifdef SSI_DEBUG_LEVEL1 + *ptr = (Data *)curHBlk + hdr + tmpSize + hdr; + alocHeapBlk = (CmHEntry *) ((Data *)curHBlk + hdr + tmpSize); + /* + * No need to look for memory trampling as this is a new block altogether + * Update the header only for this case as it is new block formed + */ + for (idx=0; idx < CMM_TRAMPLING_SIGNATURE_LEN; idx++) + { + alocHeapBlk->trSignature[idx] = 0xAB; + } + alocHeapBlk->size = *size; +#else + *ptr = (Data *)curHBlk + tmpSize; +#endif /* SSI_DEBUG_LEVEL1 */ + curHBlk->size = tmpSize; + } + else + { + /* Heap block is same size of the requested size */ +/* cm_mem_c_001.main_12 - addition for sanity check and allocation. This is a fresh block */ +#ifdef SSI_DEBUG_LEVEL1 + /* look for memory trampling as this is a pure block*/ + if (curHBlk) + { + if (cmMmRegIsBlkSane((CmMmBlkHdr *)curHBlk) != ROK) + { + /* detected a trampled memory block in this bucket */ + #ifdef DEBUGP + /* display an error message here */ +/*cm_mem_c_001.main_23 Fix for specifier mismatch warnings in 64BIT compilation*/ +#ifdef ALIGN_64BIT + sprintf(dbgPrntBuf, "Memory Trampling in heap at: %8p, size %u bytes \n", (void *)curHBlk, requestedSize); +#else + sprintf(dbgPrntBuf, "Memory Trampling in heap at: %8p, size %lu bytes \n", (void *)curHBlk, requestedSize); +#endif + SDisplay(0, dbgPrntBuf); + #endif /* DEBUGP */ + + if (cmMmHeapSanityChk(heapCb) == RTRAMPLINGNOK) + { + /* Release the lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with + WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock (&(heapCb->heapLock)); +#else + (Void) SUnlock (&(heapCb->heapLock)); +#endif + /* handle RTRAMPLINGNOK in SAlloc/SGetSBuf */ + RETVALUE(RTRAMPLINGNOK); + } + else + { + /* Release the lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with + WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock (&(heapCb->heapLock)); +#else + (Void) SUnlock (&(heapCb->heapLock)); +#endif + RETVALUE(RFAILED); + } + } + } + + *ptr = (Data *)curHBlk + hdr; + alocHeapBlk = curHBlk; + *size = curHBlk->size; +#else + *ptr = (Data *)curHBlk; +#endif /* SSI_DEBUG_LEVEL1 */ + prvHBlk->next = curHBlk->next; + } + +/* cm_mem_c_001.main_12 - addition for header updation */ +#ifdef SSI_DEBUG_LEVEL1 + /* update the header fields */ + alocHeapBlk->requestedSize = requestedSize; + alocHeapBlk->memFlags = 0; + if (memType == CMM_STATIC_MEM_FLAG) + { + CMM_SET_STATIC_FLAG(alocHeapBlk->memFlags); + heapCb->staticHeapMemUsed += (*size + hdr); + } + else + { + CMM_SET_DYNAMIC_FLAG(alocHeapBlk->memFlags); + heapCb->dynamicHeapMemUsed += (*size + hdr); + } + heapCb->avlSize -= ((*size) + hdr); +#else + heapCb->avlSize -= (*size); +#endif /* SSI_DEBUG_LEVEL1 */ + +#ifdef MEMCAL_DEBUG + if (tryHeap) + { + sprintf(prntBuf, + "SGetSBuf:%08lu:Size Heap Alloc Times:%05lu Pointer: %8p\n", + *size, num_times, *ptr); + SDisplay(0, prntBuf); + tryHeap = 0; + } +#endif +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_MEM_LEAK_STS + /* cm_mem_c_001.main_25 - Fixed compilation warnings 32/64 bit */ + cmStorAllocBlk((PTR)*ptr, (Size) reqSz, (Size) *size, MT_MAX_BKTS); +#endif /* SS_MEM_LEAK_STS */ + /* Release the lock */ +/* cm_mem_c_001.main_16 : cm_mem_c_001.main_18 Additions */ +#ifdef SS_WIN + (Void) WTUnlock (&(heapCb->heapLock)); +#else + (Void) SUnlock (&(heapCb->heapLock)); +#endif + +#ifdef SS_HISTOGRAM_SUPPORT + /* If If Tapa task (entId)is registerd for histogram then insert Memrory allocated + * information into the hash list */ + if(hstReg) + { + if (cmHstGrmAllocInsert(&(heapCb->heapHstGrmHashListCp), *size, size, line, fileName, entId) != ROK) + { + sprintf(hstGrmBuf, "Unable to Insert into the histgram hash list\n"); + SPrint(hstGrmBuf); + } + }/* End of if */ + +#endif /* SS_HISTOGRAM_SUPPORT */ + + RETVALUE(ROK); + } + } + +/* cm_mem_c_008.104 - Addition for memory calculator tool */ +#ifdef MEMCAL_DEBUG + tryHeap = 0; +#endif + + + /* Release the lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock (&(heapCb->heapLock)); +#else + (Void) SUnlock (&(heapCb->heapLock)); +#endif + + RETVALUE(ROUTRES); + +} /* end of cmHeapAlloc */ + + +/* +* +* Fun: cmHeapFree +* +* Desc: Return the memory block from the heap pool. +* +* +* Ret: ROK - successful +* RFAILED - unsuccessful. +* +* Notes: This function returns the memory block to the heap pool. This +* function is called by cmFree. The function does not check the +* validity of the memory block. The caller must be sure that the +* block was previously allocated and belongs to the heap pool. The +* function maintain the sorting order of the memory block on the +* starting address of the block. This function also do compaction +* if the neighbouring blocks are already in the heap. +* +* +* +* File: cm_mem.c +* +*/ +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT +#ifdef ANSI +PRIVATE S16 cmHeapFree +( +CmMmHeapCb *heapCb, +Data *ptr, +Size size, +U32 line, +U8 *fileName, +U8 entId, +Bool hstReg +) +#else +PRIVATE S16 cmHeapFree (heapCb, ptr, size, line, fileName, entId, hstReg) +CmMmHeapCb *heapCb; +Data *ptr; +Size size; +U32 line; +U8 *fileName; +U8 entId; +Bool hstReg; +#endif +#else +#ifdef ANSI +PRIVATE S16 cmHeapFree +( +CmMmHeapCb *heapCb, +Data *ptr, +Size size +) +#else +PRIVATE S16 cmHeapFree (heapCb, ptr, size) +CmMmHeapCb *heapCb; +Data *ptr; +Size size; +#endif +/* cm_mem_c_001.main_15 : Additions */ +#endif /* SS_HISTOGRAM_SUPPORT */ +{ + CmHEntry *p; + CmHEntry *curHBlk; /* Current heap block */ +/* cm_mem_c_001.main_12 - addition for ssi enhancements */ +#ifdef SSI_DEBUG_LEVEL1 + Size hdr; +#endif /* SSI_DEBUG_LEVEL1 */ +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + Size allocSize = size; + S8 hstGrmBuf[256]; +#endif /* SS_HISTOGRAM_SUPPORT */ + + TRC2(cmHeapFree); + + /* Roundup the requested size */ + size = CMM_DATALIGN(size, (heapCb->minSize)); +/* cm_mem_c_001.main_15: Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + allocSize = size; +#endif /* SS_HISTOGRAM_SUPPORT */ + + /* Acquire the heap lock */ + /* cm_mem_c_001.main_13 : Replaced SLock with WTLock for NT */ +#ifdef SS_WIN + (Void) WTLock (&(heapCb->heapLock)); +#else + (Void) SLock (&(heapCb->heapLock)); +#endif + + /* increase the avlSize */ +/* cm_mem_c_001.main_12 - addition for manipulation of statistics related data */ +#ifdef SSI_DEBUG_LEVEL1 + hdr = PTRALIGN(sizeof(CmHEntry)); + heapCb->avlSize += (size + hdr); + heapCb->numDeallocAttempts++; +#else + heapCb->avlSize += size; +#endif /* SSI_DEBUG_LEVEL1 */ + +/* cm_mem_c_001.main_12 - addition for pointing to the block */ +#ifdef SSI_DEBUG_LEVEL1 + p = (CmHEntry *)(ptr - hdr); +#else + p = (CmHEntry *)ptr; +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_MEM_LEAK_STS + /* cm_mem_c_001.main_25 - Fixed compilation warnings 32/64 bit */ + cmRlsAllocBlk((PTR)ptr); +#endif /* SS_MEM_LEAK_STS */ +#endif /* SSI_DEBUG_LEVEL1 */ + + +/* cm_mem_c_001.main_12 - addition for sanity and double-free checks */ +#ifdef SSI_DEBUG_LEVEL1 + /* look for memory trampling */ + if (cmMmRegIsBlkSane((CmMmBlkHdr *)p) != ROK) + { + /* detected a trampled memory block in heap */ + #ifdef DEBUGP + /* display an error message here */ +/*cm_mem_c_001.main_23 Fix for specifier mismatch warnings in 64BIT compilation*/ +#ifdef ALIGN_64BIT + sprintf(dbgPrntBuf, "Memory Trampling in heap at: %8p, size %u bytes \n", (void *)p, size); +#else + sprintf(dbgPrntBuf, "Memory Trampling in heap at: %8p, size %lu bytes \n", (void *)p, size); +#endif + SDisplay(0, dbgPrntBuf); + #endif /* DEBUGP */ + + if (cmMmHeapSanityChk(heapCb) == RTRAMPLINGNOK) + { + /* Release the lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock (&(heapCb->heapLock)); +#else + (Void) SUnlock (&(heapCb->heapLock)); +#endif + /* handle RTRAMPLINGNOK in SAlloc/SGetSBuf */ + RETVALUE(RTRAMPLINGNOK); + } + else + { + /* do not add to the free heap */ + heapCb->avlSize -= (size + hdr); + /* Release the heap lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock (&(heapCb->heapLock)); +#else + (Void) SUnlock (&(heapCb->heapLock)); +#endif + + RETVALUE(ROK); + } + } + + /* look for any double free */ + if (CMM_IS_FREE(p->memFlags)) + { + #ifdef DEBUGP +/*cm_mem_c_001.main_23 Fix for specifier mismatch warnings in 64BIT compilation*/ +#ifdef ALIGN_64BIT + sprintf(dbgPrntBuf, "DOUBLE FREE at %8p for size %u in HEAP \n", (void *)p, size); +#else + sprintf(dbgPrntBuf, "DOUBLE FREE at %8p for size %lu in HEAP \n", (void *)p, size); +#endif + SDisplay(0, dbgPrntBuf); + #endif /* DEBUGP */ + + heapCb->avlSize -= (size + hdr); +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_WIN + (Void) WTUnlock (&(heapCb->heapLock)); +#else + (Void) SUnlock (&(heapCb->heapLock)); +#endif + + RETVALUE(RDBLFREE); + } +#endif /* SSI_DEBUG_LEVEL1 */ + + for ( curHBlk = heapCb->next; curHBlk; curHBlk = curHBlk->next) + { + /* + * The block will be inserted to maintain the sorted order on the + * starting address of the block. + */ + if (p > curHBlk) + { + if (!(curHBlk->next) || + (p < (curHBlk->next))) + { + /* Heap block should be inserted here */ + + /* + * Check if the block to be returned can be merged with the + * current block. + */ +/* cm_mem_c_001.main_12 - addition for header consideration */ +#ifdef SSI_DEBUG_LEVEL1 + if (((Data *)curHBlk + hdr + curHBlk->size) == (Data *)p) +#else + if (((Data *)curHBlk + curHBlk->size) == (Data *)p) +#endif /* SSI_DEBUG_LEVEL1 */ + { + /* Merge the block */ +/* cm_mem_c_001.main_12 - addition for updating statistics related data */ +#ifdef SSI_DEBUG_LEVEL1 + /* update the flags */ + if (CMM_IS_STATIC(p->memFlags)) + heapCb->staticHeapMemUsed -= (size + hdr); + else if (CMM_IS_DYNAMIC(p->memFlags)) + heapCb->dynamicHeapMemUsed -= (size + hdr); + size = (curHBlk->size += (size + hdr)); +#else + size = (curHBlk->size += size); +#endif /*SSI_DEBUG_LEVEL1*/ + p = curHBlk; + } + else + { +/* cm_mem_c_001.main_12 - addition for double-free check */ +#ifdef SSI_DEBUG_LEVEL1 + /* Check for double deallocation in heap */ + if ((Data *)p < ((Data *)curHBlk + curHBlk->size)) + { + /* Release the lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock (&(heapCb->heapLock)); +#else + (Void) SUnlock (&(heapCb->heapLock)); +#endif + + /* This block is already freed in the heap */ + RETVALUE(RDBLFREE); + } + /* update the flags as it is a new node */ + if (CMM_IS_STATIC(p->memFlags)) + { + heapCb->staticHeapMemUsed -= (size + hdr); + CMM_RESET_STATIC_FLAG(p->memFlags); + } + else if (CMM_IS_DYNAMIC(p->memFlags)) + { + heapCb->dynamicHeapMemUsed -= (size + hdr); + CMM_RESET_DYNAMIC_FLAG(p->memFlags); + } + CMM_SET_FREE_FLAG(p->memFlags); + p->requestedSize = 0; +#endif /*SSI_DEBUG_LEVEL1*/ + /* insert the block */ + p->next = curHBlk->next; + p->size = size; + curHBlk->next = p; + } + + /* Try to merge with the next block in the chain */ +/* cm_mem_c_001.main_12 - addition for ssi enhancements */ +#ifdef SSI_DEBUG_LEVEL1 + if (((Data *)p + hdr + size) == (Data *)(p->next) && (p->next)) +#else + if (((Data *)p + size) == (Data *)(p->next) && (p->next)) +#endif /*SSI_DEBUG_LEVEL1*/ + { + /* p->next can not be NULL */ +/* cm_mem_c_001.main_12 - addition for header consideration */ +#ifdef SSI_DEBUG_LEVEL1 + p->size += (p->next->size + hdr); +#else + p->size += p->next->size; +#endif /*SSI_DEBUG_LEVEL1*/ + p->next = p->next->next; + } + + /* Release the lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock (&(heapCb->heapLock)); +#else + (Void) SUnlock (&(heapCb->heapLock)); +#endif +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + /* If If Tapa task (entId)is registerd for histogram then insert + Memrory Freed information into the hash list */ + if(hstReg) + { + if (cmHstGrmFreeInsert(&heapCb->heapHstGrmHashListCp, allocSize, line, + fileName, entId) != ROK) + { + sprintf(hstGrmBuf, "Unable to Insert into the histgram hash list\n"); + SPrint(hstGrmBuf); + } + }/* End of if */ +#endif /* SS_HISTOGRAM_SUPPORT */ + RETVALUE(ROK); + } + } + else if (p < curHBlk) + { + /* + * Check if the block to be returned can be merged with the + * current block. + */ +/* cm_mem_c_001.main_12 - addition for header consideration */ +#ifdef SSI_DEBUG_LEVEL1 + if (((Data *)p + hdr + size) == (Data *)curHBlk) +#else + if (((Data *)p + size) == (Data *)curHBlk) +#endif /* SSI_DEBUG_LEVEL1 */ + { + /* Merge the block */ +/* cm_mem_c_001.main_12 - addition for header consideration */ +#ifdef SSI_DEBUG_LEVEL1 + p->size = size + (curHBlk->size + hdr); +#else + p->size = size + curHBlk->size; +#endif /* SSI_DEBUG_LEVEL1 */ + p->next = curHBlk->next; + } + else + { + /* insert the block */ + p->next = curHBlk; + p->size = size; + } +/* cm_mem_c_001.main_12 - addition for header updation */ +#ifdef SSI_DEBUG_LEVEL1 + /* update the flags in both cases as they are new start nodes*/ + if (CMM_IS_STATIC(p->memFlags)) + { + heapCb->staticHeapMemUsed -= (size + hdr); + CMM_RESET_STATIC_FLAG(p->memFlags); + } + else if (CMM_IS_DYNAMIC(p->memFlags)) + { + heapCb->dynamicHeapMemUsed -= (size + hdr); + CMM_RESET_DYNAMIC_FLAG(p->memFlags); + } + CMM_SET_FREE_FLAG(p->memFlags); + p->requestedSize = 0; +#endif /* SSI_DEBUG_LEVEL1 */ + + heapCb->next = p; + + /* Release the lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock (&(heapCb->heapLock)); +#else + (Void) SUnlock (&(heapCb->heapLock)); +#endif +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + /* If If Tapa task (entId)is registerd for histogram then insert + Memrory Freed information into the hash list */ + if(hstReg) + { + if (cmHstGrmFreeInsert(&heapCb->heapHstGrmHashListCp, allocSize, line, + fileName, entId) != ROK) + { + sprintf(hstGrmBuf, "Unable to Insert into the histgram hash list\n"); + SPrint(hstGrmBuf); + } + }/* End of if */ +#endif /* SS_HISTOGRAM_SUPPORT */ + RETVALUE(ROK); + } + + } + + if (heapCb->next == NULLP) + { + /* Heap block is empty. Insert the block in the head. */ + heapCb->next = p; + p->next = NULLP; + p->size = size; + +/* cm_mem_c_001.main_12 - addition for header updation */ +#ifdef SSI_DEBUG_LEVEL1 + if (CMM_IS_STATIC(p->memFlags)) + { + heapCb->staticHeapMemUsed -= (size + hdr); + CMM_RESET_STATIC_FLAG(p->memFlags); + } + else if (CMM_IS_DYNAMIC(p->memFlags)) + { + heapCb->dynamicHeapMemUsed -= (size + hdr); + CMM_RESET_DYNAMIC_FLAG(p->memFlags); + } + CMM_SET_FREE_FLAG(p->memFlags); + p->requestedSize = 0; +#endif /* SSI_DEBUG_LEVEL1 */ + + /* Release the heap lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock (&(heapCb->heapLock)); +#else + (Void) SUnlock (&(heapCb->heapLock)); +#endif +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + /* If If Tapa task (entId)is registerd for histogram then insert + Memrory Freed information into the hash list */ + if(hstReg) + { + if (cmHstGrmFreeInsert(&heapCb->heapHstGrmHashListCp, allocSize, line, + fileName, entId) != ROK) + { + sprintf(hstGrmBuf, "Unable to Insert into the histgram hash list\n"); + SPrint(hstGrmBuf); + } + }/* End of if */ +#endif /* SS_HISTOGRAM_SUPPORT */ + RETVALUE(ROK); + } + + /* Release the lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock (&(heapCb->heapLock)); +#else + (Void) SUnlock (&(heapCb->heapLock)); +#endif + + RETVALUE(RFAILED); +} /* end of cmHeapFree */ +#endif/*USE_PURE*/ +#ifdef SS_LIGHT_MEM_LEAK_STS +#ifdef ANSI +PUBLIC U32 cmGetFreeIndx +( +Void +) +#else +PUBLIC U32 cmGetFreeIndx(Void) +#endif +{ + + if(gmemLkCb.head == gmemLkCb.tail) + { + allocQueueEmptyCnt++; + RETVALUE(CM_MAX_ALLOC_ENTERIES); + } + else + { + U32 allocQIndx = gmemLkCb.queue[gmemLkCb.head]; + gmemLkCb.head = (gmemLkCb.head +1) % CM_MAX_ALLOC_ENTERIES; + RETVALUE(allocQIndx); + } + +} +#ifdef ANSI +PUBLIC U32 cmPutFreeIndx +( +U32 allocQIndx +) +#else +PUBLIC U32 cmPutFreeIndx(allocQIndx) +U32 allocQIndx; +#endif + +{ + U32 tmpTail = (gmemLkCb.tail+1)% CM_MAX_ALLOC_ENTERIES; + if(tmpTail == gmemLkCb.head) + { + allocQueueFullCnt++; + RETVALUE(RFAILED); + } + else + { + gmemLkCb.queue[gmemLkCb.tail] = allocQIndx; + gmemLkCb.tail = tmpTail; + RETVALUE(ROK); + } +} +/* +* +* Fun: cmInitMemLeakMdl +* +* Desc: Initializes the memory leak detection module +* +* +* Ret: RETVOID +* +* Notes: This function initializes the memory leak detection module. +* +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PUBLIC Void cmInitMemLeak +( +Void +) +#else +PUBLIC Void cmInitMemLeak (Void) +#endif +{ + U32 indx; + + TRC3(cmInitMemLeak); + + gmemLkCb.isStarted = FALSE; + gmemLkCb.head = 0; + gmemLkCb.tail = 0; + SInitLock(&gmemLkCb.memLock, 1); + for(indx = 0; indx < CM_MAX_ALLOC_ENTERIES; indx++) + { + gmemLkCb.allocInfo[indx].used = FALSE; + cmPutFreeIndx(indx); + } + + RETVOID; +} /* cmInitMemLeak */ +/* + * + * Fun: cmDeinitMemLeak + * + * Desc: De-initializes the memory leak detection + * + * + * Ret: RETVOID + * + * Notes: This function de-initializes the memory leak detection module. + * + * + * File: cm_mem.c + * + **/ +#ifdef ANSI +PUBLIC Void cmDeinitMemLeak +( +Void +) +#else +PUBLIC Void cmDeinitMemLeak (Void) +#endif +{ + U32 indx; + + TRC3(cmDeinitMemLeak); + + for(indx = 0; indx < CM_MAX_ALLOC_ENTERIES; indx++) + { + gmemLkCb.allocInfo[indx].used = FALSE; + } + SDestroyLock(&gmemLkCb.memLock); + gmemLkCb.isStarted = FALSE; + gmemLkCb.head = 0; + gmemLkCb.tail = 0; + RETVOID; +} +/* +* +* Fun: cmStorAllocBlk +* +* Desc: Initializes the memory leak detection module +* +* +* Ret: RETVOID +* +* Notes: This function initializes the memory leak detection module. +* +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PUBLIC U32 cmStorAllocBlk +( +Void *addr +) +#else +PUBLIC U32 cmStorAllocBlk (addr) +Void *addr; +#endif /* ANSI */ + +{ + U32 allocQIndx; + + (Void) SLock(&gmemLkCb.memLock); + allocQIndx = cmGetFreeIndx(); + if(allocQIndx < CM_MAX_ALLOC_ENTERIES) + { + queueIndxAllocCnt++; + gmemLkCb.allocInfo[allocQIndx].memAddr = addr; + gmemLkCb.allocInfo[allocQIndx].used = TRUE; + } + (Void) SUnlock(&(gmemLkCb.memLock)); + + RETVALUE(allocQIndx); +} /* cmStorAllocBlk */ + + +/* +* +* Fun: cmRlsAllocBlk +* +* Desc: Initializes the memory leak detection module +* +* +* Ret: RETVOID +* +* Notes: This function initializes the memory leak detection module. +* +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PUBLIC Void cmRlsAllocBlk +( +U32 allocQIndx +) +#else +PUBLIC Void cmRlsAllocBlk(allocQIndx) +U32 allocQIndx; +#endif +{ + TRC3(cmRlsAllocBlk); + + if(allocQIndx < CM_MAX_ALLOC_ENTERIES) + { + if(gmemLkCb.allocInfo[allocQIndx].used == TRUE) + { + (Void) SLock(&gmemLkCb.memLock); + gmemLkCb.allocInfo[allocQIndx].used = FALSE; + cmPutFreeIndx(allocQIndx); + queueIndxFreeCnt++; + (Void) SUnlock(&(gmemLkCb.memLock)); + } + } + RETVOID; +} /* cmRlsAllocBlk */ + +/* +* +* Fun: cmStartStopLeakLog +* +* +* Ret: Void +* +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PUBLIC Void cmStartStopLeakLog +( +Void +) +#else +PUBLIC Void cmStartStopLeakLog(Void) +#endif +{ + if (FALSE == gmemLkCb.isStarted) + { + printf("!!leak capturing started\n"); + gmemLkCb.isStarted = TRUE; + } + else + { + gmemLkCb.isStarted = FALSE; + printf("!!leak capturing stopped\n"); + cmPrintLeakLog(); + } + RETVOID; +} + +/* +* +* Fun: cmPrintLeakLog +* +* Desc: Prints leak log +* +* Ret: Void +* +* Notes: None +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PUBLIC Void cmPrintLeakLog +( +Void +) +#else +PUBLIC Void cmPrintLeakLog(Void) +#endif +{ + + U32 indx; + CmMmBlkHdr *aBkt; + static U32 leakCount =0; + + TRC3(cmPrintLeakLog); + + printf("---- START OF LEAK LOG ----"); + SLock(&gmemLkCb.memLock); + printf("---- Lock Acquired ----"); + for(indx = 0; indx < CM_MAX_ALLOC_ENTERIES; indx++) + { + if(gmemLkCb.allocInfo[indx].used == TRUE) + { + leakCount++; + aBkt =(CmMmBlkHdr *)gmemLkCb.allocInfo[indx].memAddr; + printf("LeakCnt(%ld)Addr(0x%p)RqSz(%ld)", + leakCount,gmemLkCb.allocInfo[indx].memAddr, aBkt->requestedSize); + printf("LineNo(%ld)funcName(%s)\n", + aBkt->lineNo, aBkt->currFuncName); + gmemLkCb.allocInfo[indx].used = FALSE; + cmPutFreeIndx(indx); + } + //if(leakCount % 10 == 0) + // sleep(1); + } + printf("---- END OF LEAK LOG ----"); + SUnlock(&gmemLkCb.memLock); + printf("---- Lock Released ----"); + leakCount =0; + RETVOID; +} +#endif + + +#if (defined(SS_MEM_LEAK_STS) || defined(BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL2)) +/* +* +* Fun: cmRlsAllocBlk +* +* Desc: Initializes the memory leak detection module +* +* +* Ret: RETVOID +* +* Notes: This function initializes the memory leak detection module. +* +* +* File: cm_mem.c +* +*/ +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL2 +#ifdef ANSI +PUBLIC Void cmRlsAllocBlk +( +CmMmBlkHdr *ptrHdr, +CmMmRegCb *regCb +) +#else +PUBLIC Void cmRlsAllocBlk(ptrHdr, regCb) +CmMmBlkHdr *ptrHdr; +CmMmRegCb *regCb; +#endif +#else +#ifdef ANSI +PUBLIC Void cmRlsAllocBlk +( +#ifdef BIT_64 +U64 addr +#else +U32 addr +#endif +) +#else +PUBLIC Void cmRlsAllocBlk(addr) +#ifdef BIT_64 +U64 addr; +#else +U32 addr; +#endif +#endif +#endif +{ + Ptr trace[CM_MAX_STACK_TRACE]; + S8 **funcNm; + U8 idx; + U8 i; + S16 retVal; + S32 traceSize; +#ifndef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL2 + MemAllocInfo *memAllocInfo; +#endif + + TRC3(cmRlsAllocBlk); + +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL2 +#ifdef BIT_64 + retVal = cmHashListFind(®Cb->brdcmSsiLstCp,(U8 *)&ptrHdr, + (U16)sizeof(U64), 0, (PTR *)&ptrHdr); +#else + retVal = cmHashListFind(®Cb->brdcmSsiLstCp,(U8 *)&ptrHdr, + (U16)sizeof(U32), 0, (PTR *)&ptrHdr); +#endif + if(retVal == ROK) + { + cmHashListDelete(®Cb->brdcmSsiLstCp, (PTR)ptrHdr); + } +#else + if( memLkCb.memLkMdlInit == FALSE) + { + RETVOID; + } + for(idx = 0; idx < CM_MEM_USR_MDL; idx++) + { + SLock(&memLkCb.memUsrMdl[idx][addr & 0x3].memLck); +#ifdef BIT_64 + retVal = cmHashListFind(&memLkCb.memUsrMdl[idx][addr & 0x3].memHashCp, + (U8 *)&addr, sizeof(U64), 0, + (PTR *)&memAllocInfo); +#else + retVal = cmHashListFind(&memLkCb.memUsrMdl[idx][addr & 0x3].memHashCp, + (U8 *)&addr, sizeof(U32), 0, + (PTR *)&memAllocInfo); +#endif + if(retVal == ROK) + { + cmHashListDelete(&memLkCb.memUsrMdl[idx][addr & 0x3].memHashCp, + (PTR)memAllocInfo); + SUnlock(&memLkCb.memUsrMdl[idx][addr & 0x3].memLck); + funcNm = (S8 **) memAllocInfo->backTrace; +#ifdef SS_MEM_LEAK_SOL + for(i = 0; i < memAllocInfo->bTrcSz; i++) + { +/*cm_mem_c_001.main_27 SSI-4GMX specfic changes*/ +#ifdef SS_4GMX_LCORE + MxHeapFree(SsiHeap, funcNm[i]); +#else + free(funcNm[i]); +#endif + } +#endif /* SS_MEM_LEAK_SOL */ +#ifdef SS_MEM_LEAK_FREE_TRACE + { + + Txt prntBuf[255]; + sprintf( prntBuf, "\n==============================\n"); + SPrint(prntBuf); + /* cm_mem_c_001.main_25 - Fixed compilation warnings 32/64 bit */ +#ifdef ALIGN_64BIT + sprintf( prntBuf, "Address: [%x]\n", addr); +#else + sprintf( prntBuf, "Address: [%lx]\n", addr); +#endif + SPrint(prntBuf); + traceSize = backtrace(trace, CM_MAX_STACK_TRACE); + funcNm = backtrace_symbols(trace, traceSize); + sprintf( prntBuf, "[bt] Execution path:\n"); + SPrint(prntBuf); + for (i=0; i < traceSize; ++i) + { + sprintf( prntBuf, "[bt] %s\n", funcNm[i]); + SPrint(prntBuf); + } + sprintf( prntBuf, "\n==============================\n"); + SPrint(prntBuf); + } +#endif /* SS_MEM_LEAK_FREE_TRACE */ +/*cm_mem_c_001.main_27 SSI-4GMX specfic changes*/ +#ifdef SS_4GMX_LCORE + MxHeapFree(SsiHeap, funcNm); + MxHeapFree(SsiHeap, memAllocInfo); +#else + free(funcNm); + free(memAllocInfo); +#endif + break; + } + SUnlock(&memLkCb.memUsrMdl[idx][addr & 0x3].memLck); + } + +#ifndef SS_MEM_LEAK_SOL + if(idx == CM_MEM_USR_MDL) + { + Txt prntBuf[255]; + sprintf( prntBuf,"\nPossible Double-Deallocation.\n"); + SPrint(prntBuf); +/*cm_mem_c_001.main_23 Fix for specifier mismatch warnings in 64BIT compilation*/ +#ifdef ALIGN_64BIT + sprintf( prntBuf, "Address: [%u]\n", addr); +#else + sprintf( prntBuf, "Address: [%lu]\n", addr); +#endif + SPrint(prntBuf); + traceSize = backtrace(trace, CM_MAX_STACK_TRACE); + funcNm = backtrace_symbols(trace, traceSize); + sprintf( prntBuf,"[bt] Execution path:\n"); + SPrint(prntBuf); + for (i=0; i < traceSize; ++i) + { + sprintf( prntBuf,"[bt] %s\n", funcNm[i]); + SPrint(prntBuf); + } + printf("\n==============================\n"); +/*cm_mem_c_001.main_27 SSI-4GMX specfic changes*/ +#ifdef SS_4GMX_LCORE + MxHeapFree(SsiHeap, funcNm); +#else + free(funcNm); +#endif + } +#endif /* SS_MEM_LEAK_SOL */ +#endif/* BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 */ + /*cm_mem_c_001.main_25 : */ + RETVOID; +} /* cmRlsAllocBlk */ + + +/* +* +* Fun: cmStorAllocBlk +* +* Desc: Initializes the memory leak detection module +* +* +* Ret: RETVOID +* +* Notes: This function initializes the memory leak detection module. +* +* +* File: cm_mem.c +* +*/ +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL2 +#ifdef ANSI +PUBLIC Void cmStorAllocBlk +( +CmMmBlkHdr *ptrHdr, +Size reqSz, +Size allocSz, +U16 bktIdx, +CmMmRegCb *regCb +) +#else +PUBLIC Void cmStorAllocBlk (ptrHdr, reqSz, allocSz, bktIdx, regCb) +CmMmBlkHdr *ptrHdr; +Size reqSz; +Size allocSz; +U16 bktIdx; +CmMmRegCb *regCb; +#endif +#else +#ifdef ANSI +PUBLIC Void cmStorAllocBlk +( +#ifdef BIT_64 +U64 addr, +#else +U32 addr, +#endif +Size reqSz, +Size allocSz, +U16 bktIdx +) +#else +PUBLIC Void cmStorAllocBlk (addr, reqSz, allocSz, bktIdx) +#ifdef BIT_64 +U64 addr; +#else +U32 addr; +#endif +Size reqSz; +Size allocSz; +U16 bktIdx; +#endif /* ANSI */ +#endif /* BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 */ +{ +#ifndef SS_MEM_LEAK_SOL + void *trace[CM_MAX_STACK_TRACE]; +#endif /* SS_MEM_LEAK_SOL */ +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL2 + U8 btrIdx; +#else + MemAllocInfo *allocInfo; + U8 moduleId; + S8 **funcNm; + S32 traceSize; +#endif + + TRC3(cmStorAllocBlk); +#ifndef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL2 + if( memLkCb.memLkMdlInit == FALSE) + { + RETVOID; + } +#endif +#ifdef SS_MEM_LEAK_SOL + /* I need to do this for solaris, because it does not implement + * backtrace. Here backtrace is my function. See below for the + * implementation. */ +/*cm_mem_c_001.main_27 SSI-4GMX specfic changes*/ +#ifdef SS_4GMX_LCORE + funcNm = (S8 **)MxHeapAlloc(SsiHeap, (sizeof(U32) * CM_MAX_STACK_TRACE)); + cmMemset((U8*)funcNm, 0, (sizeof(U32) * CM_MAX_STACK_TRACE)); +#else + funcNm = (S8 **)calloc(1, (sizeof(U32) * CM_MAX_STACK_TRACE)); +#endif + /* SGetSBuf(DFLT_REGION, DFLT_POOL, &funcNm, sizeof(U32) * CM_MAX_STACK_TRACE); */ + traceSize = backtrace((Void **)funcNm, CM_MAX_STACK_TRACE); +#else /* SS_MEM_LEAK_SOL */ +#ifndef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL2 + traceSize = backtrace(trace, CM_MAX_STACK_TRACE); + funcNm = backtrace_symbols(trace, traceSize); +#endif +#endif /* SS_MEM_LEAK_SOL */ + +#ifndef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL2 + moduleId = cmMemGetModuleId(funcNm, traceSize); + (Void)SLock(&(memLkCb.memUsrMdl[moduleId][addr & 0x3].memLck)); +#endif + +/*cm_mem_c_001.main_27 SSI-4GMX specfic changes*/ +#ifndef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL2 +#ifdef SS_4GMX_LCORE + allocInfo = (MemAllocInfo *)MxHeapAlloc(SsiHeap, sizeof(MemAllocInfo)); + cmMemset((U8*)allocInfo, 0, sizeof(MemAllocInfo)); +#else + allocInfo = (MemAllocInfo *)calloc(1, sizeof(MemAllocInfo)); +#endif +#endif + /* SGetSBuf(DFLT_REGION, DFLT_POOL, &allocInfo, sizeof(MemAllocInfo)); */ +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL2 + /* check if hashListCp is initialised yet */ + if ( regCb->brdcmSsiLstCp.nmbBins == 0) + { + RETVALUE(ROK); + } + ptrHdr->reqSz = reqSz; + ptrHdr->allocSz = allocSz; + ptrHdr->bktIdx = bktIdx; +#if 0 + for(btrIdx = 0; btrIdx < BRDCM_MEM_LEAK_BTRACE; btrIdx++) + { + // ptrHdr->backTrace[btrIdx] = __builtin_return_address(btrIdx); + } +#endif + cmHashListInsert(®Cb->brdcmSsiLstCp, (PTR)ptrHdr, + (U8 *)&(ptrHdr), sizeof(PTR)); +#else + allocInfo->memAddr = addr; + allocInfo->reqSz = reqSz; + allocInfo->allocSz = allocSz; + allocInfo->bktIdx = bktIdx; + allocInfo->backTrace = (PTR) funcNm; + allocInfo->moduleId = moduleId; + allocInfo->bTrcSz = traceSize; + cmHashListInsert(&memLkCb.memUsrMdl[moduleId][addr & 0x3].memHashCp, + (PTR)allocInfo, (U8 *)&(allocInfo->memAddr), + sizeof(allocInfo->memAddr)); + memLkCb.memUsrMdl[moduleId][addr & 0x3].used = TRUE; + + (Void) SUnlock(&(memLkCb.memUsrMdl[moduleId][addr & 0x3].memLck)); +#endif + RETVOID; +} /* cmStorAllocBlk */ + +/* +* + RETVOID; +} /* cmStorAllocBlk */ + +/* +* +* Fun: SLogLkInfo +* +* Desc: Initializes the memory leak detection module +* +* +* Ret: RETVOID +* +* Notes: This function initializes the memory leak detection module. +* +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PUBLIC Void SLogLkInfo +( +Void +) +#else +PUBLIC Void SLogLkInfo (Void) +#endif +{ +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL2 + U8 idx; + U8 regionIdx; + Txt prntBuf[255]; + S8 **funcNm; + CmMmBlkHdr *newBlkHdr; + CmMmBlkHdr *oldBlkHdr; + CmMmRegCb *tmpRegCb; + FILE *fp; + + TRC3(SLogLkInfo); + fp = fopen("meLeakLog.txt", "w"); + if(fp == NULL) + { + memLk.fileLkLog = (FILE *)stdout; + } + else + { + memLk.fileLkLog = fp; + } + sprintf(prntBuf, "\n------- START OF LEAK LOG -------\n"); + fwrite(prntBuf, strlen(prntBuf), 1, memLk.fileLkLog); + for(regionIdx = 0; regionIdx < SS_MAX_REGS; regionIdx++) + { +// tmpRegCb = mtCMMRegCb[regionIdx]; + while(cmHashListGetNext(&tmpRegCb->brdcmSsiLstCp, + (PTR)oldBlkHdr, (PTR *)&newBlkHdr) == ROK) + { + sprintf(prntBuf, "[LBIS]\n"); + fwrite(prntBuf, strlen(prntBuf), 1, memLk.fileLkLog); +#ifdef ALIGN_64BIT + sprintf(prntBuf, "Address: 0x%u\n", newBlkHdr); +#else + sprintf(prntBuf, "Address: 0x%lu\n", newBlkHdr); +#endif + fwrite(prntBuf, strlen(prntBuf), 1, memLk.fileLkLog); + sprintf(prntBuf, "Requested Size: %d\n", (S16)newBlkHdr->reqSz); + fwrite(prntBuf, strlen(prntBuf), 1, memLk.fileLkLog); + sprintf(prntBuf, "Allocated Size: %d\n", (S16)newBlkHdr->allocSz); + fwrite(prntBuf, strlen(prntBuf), 1, memLk.fileLkLog); + sprintf(prntBuf, "Bucket Idx: %d\n", newBlkHdr->bktIdx); + fwrite(prntBuf, strlen(prntBuf), 1, memLk.fileLkLog); + sprintf(prntBuf,"Memory Allocation Path:\n"); + fwrite(prntBuf, strlen(prntBuf), 1, memLk.fileLkLog); + //funcNm = (S8 **)newBlkHdr->backTrace; + for(idx = 0; idx < BRDCM_MEM_LEAK_BTRACE; idx ++) + { + // sprintf(prntBuf,"==> %p\n", newBlkHdr->backTrace[idx]); + fwrite(prntBuf, strlen(prntBuf), 1, memLk.fileLkLog); + } + sprintf(prntBuf, "[LBIE]\n\n"); + fwrite(prntBuf, strlen(prntBuf), 1, memLk.fileLkLog); + fflush(memLk.fileLkLog); + oldBlkHdr = newBlkHdr; + newBlkHdr = NULLP; + } + } + sprintf(prntBuf, "\n------- END OF LEAK LOG -------\n"); + fwrite(prntBuf, strlen(prntBuf), 1, memLk.fileLkLog); + fclose(fp); +#else + MemAllocInfo *oldMemInfo; + MemAllocInfo *newMemInfo; + U8 memMdl; + U8 hashIdx; + U8 idx; + Txt prntBuf[255]; + S8 **funcNm; + TRC3(SLogLkInfo); + if( memLkCb.memLkMdlInit == FALSE) + { + RETVOID; + } + sprintf(prntBuf, "\n------- START OF LEAK LOG -------\n"); + fwrite(prntBuf, strlen(prntBuf), 1, memLkCb.fileLkLog); + + for(memMdl = 0; memMdl < CM_MEM_USR_MDL; memMdl++) + { + for (hashIdx = 0; hashIdx < CM_MAX_HASH_PER_TSK; hashIdx++) + { + if(memLkCb.memUsrMdl[memMdl][hashIdx].used == FALSE) + { + continue; + } + oldMemInfo = NULLP; + newMemInfo = NULLP; + SLock(&memLkCb.memUsrMdl[memMdl][hashIdx].memLck); + while(cmHashListGetNext(&memLkCb.memUsrMdl[memMdl][hashIdx].memHashCp, + (PTR)oldMemInfo, (PTR *)&newMemInfo) == ROK) + { + sprintf(prntBuf, "[LBIS]\n"); + fwrite(prntBuf, strlen(prntBuf), 1, memLkCb.fileLkLog); + /* cm_mem_c_001.main_25 - Fixed compilation warnings 32/64 bit */ +#ifdef ALIGN_64BIT + sprintf(prntBuf, "Address: 0x%u\n", newMemInfo->memAddr); +#else + sprintf(prntBuf, "Address: 0x%lu\n", newMemInfo->memAddr); +#endif + fwrite(prntBuf, strlen(prntBuf), 1, memLkCb.fileLkLog); + sprintf(prntBuf, "Module Name: %s\n", + memUsrMdlStr[newMemInfo->moduleId].mdlStr); + fwrite(prntBuf, strlen(prntBuf), 1, memLkCb.fileLkLog); + sprintf(prntBuf, "Requested Size: %d\n", (S16)newMemInfo->reqSz); + fwrite(prntBuf, strlen(prntBuf), 1, memLkCb.fileLkLog); + sprintf(prntBuf, "Allocated Size: %d\n", (S16)newMemInfo->allocSz); + fwrite(prntBuf, strlen(prntBuf), 1, memLkCb.fileLkLog); + sprintf(prntBuf, "Bucket Idx: %d\n", newMemInfo->bktIdx); + fwrite(prntBuf, strlen(prntBuf), 1, memLkCb.fileLkLog); + sprintf(prntBuf,"Memory Allocation Path:\n"); + fwrite(prntBuf, strlen(prntBuf), 1, memLkCb.fileLkLog); + funcNm = (S8 **)newMemInfo->backTrace; + for(idx = 0; idx < newMemInfo->bTrcSz; idx ++) + { + sprintf(prntBuf,"==> %s\n", funcNm[idx]); + fwrite(prntBuf, strlen(prntBuf), 1, memLkCb.fileLkLog); + } + sprintf(prntBuf, "[LBIE]\n\n"); + fwrite(prntBuf, strlen(prntBuf), 1, memLkCb.fileLkLog); + fflush(memLkCb.fileLkLog); + oldMemInfo = newMemInfo; + newMemInfo = NULLP; + } + SUnlock(&memLkCb.memUsrMdl[memMdl][hashIdx].memLck); + } + } + sprintf(prntBuf, "\n------- END OF LEAK LOG -------\n"); + fwrite(prntBuf, strlen(prntBuf), 1, memLkCb.fileLkLog); +#endif + RETVOID; +} + +#endif + +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_MEM_LEAK_STS +/* +* +* Fun: cmInitMemLeakMdl +* +* Desc: Initializes the memory leak detection module +* +* +* Ret: RETVOID +* +* Notes: This function initializes the memory leak detection module. +* +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PUBLIC Void cmInitMemLeakMdl +( +Void +) +#else +PUBLIC Void cmInitMemLeakMdl (Void) +#endif +{ + U8 memMdl; + U8 hashIdx; + + TRC3(cmInitMemLeakMdl); + + memLkCb.memLkMdlInit = FALSE; + for(memMdl = 0; memMdl < CM_MEM_USR_MDL; memMdl++) + { + for (hashIdx = 0; hashIdx < CM_MAX_HASH_PER_TSK; hashIdx++) + { + SInitLock(&memLkCb.memUsrMdl[memMdl][hashIdx].memLck, 1); + cmHashListInit(&memLkCb.memUsrMdl[memMdl][hashIdx].memHashCp, + 500, 0, FALSE, CM_HASH_KEYTYPE_U32MOD, 0, 0); + memLkCb.memUsrMdl[memMdl][hashIdx].used = FALSE; + } + } + if(memLkCb.fileLkLog == NULLP) + { + memLkCb.fileLkLog = (FILE *) stdout; + } + memLkCb.memLkMdlInit = TRUE; + + RETVOID; +} /* cmInitMemLeakMdl */ +/* cm_mem_c_002.main_21 Added for shutdown procedure */ +/* + * + * Fun: cmDeinitMemLeakMdl + * + * Desc: De-initializes the memory leak detection module + * + * + * Ret: RETVOID + * + * Notes: This function de-initializes the memory leak detection module. + * + * + * File: cm_mem.c + * + **/ +#ifdef ANSI +PUBLIC Void cmDeinitMemLeakMdl +( +Void +) +#else +PUBLIC Void cmDeinitMemLeakMdl (Void) +#endif +{ + U8 memMdl; + U8 hashIdx; + + TRC3(cmDeinitMemLeakMdl); + + memLkCb.memLkMdlInit = FALSE; + for(memMdl = 0; memMdl < CM_MEM_USR_MDL; memMdl++) + { + for (hashIdx = 0; hashIdx < CM_MAX_HASH_PER_TSK; hashIdx++) + { + SDestroyLock(&memLkCb.memUsrMdl[memMdl][hashIdx].memLck); + cmHashListDeinit(&memLkCb.memUsrMdl[memMdl][hashIdx].memHashCp); + memLkCb.memUsrMdl[memMdl][hashIdx].used = FALSE; + } + } + RETVOID; +} +/* +* +* Fun: cmMemOpenMemLkFile +* +* Desc: Initializes the memory leak detection module +* +* +* Ret: RETVOID +* +* Notes: This function initializes the memory leak detection module. +* +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PUBLIC Void cmMemOpenMemLkFile +( +S8 *arg +) +#else +PUBLIC Void cmMemOpenMemLkFile (arg) +S8 *msOptArg; +#endif +{ + TRC3(cmMemOpenMemLkFile); + memLkCb.fileLkLog = NULLP; + memLkCb.fileLkLog = fopen(arg, "w"); + RETVOID; +} +/* +* +* Fun: SFlushLkInfo +* +* Desc: Initializes the memory leak detection module +* +* +* Ret: RETVOID +* +* Notes: This function initializes the memory leak detection module. +* +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PUBLIC Void SFlushLkInfo +( +Void +) +#else +PUBLIC Void SFlushLkInfo (Void) +#endif +{ + MemAllocInfo *newMemInfo; + U8 memMdl; + U8 hashIdx; + S8 **funcNm; +#ifdef SS_MEM_LEAK_SOL + U8 i; +#endif /* SS_MEM_LEAK_SOL */ + + TRC3(SFlushLkInfo); + if( memLkCb.memLkMdlInit == FALSE) + { + RETVOID; + } + + for(memMdl = 0; memMdl < CM_MEM_USR_MDL; memMdl++) + { + for(hashIdx = 0; hashIdx < CM_MAX_HASH_PER_TSK; hashIdx++) + { + if(memLkCb.memUsrMdl[memMdl][hashIdx].used == FALSE) + { + continue; + } + newMemInfo = NULLP; + SLock(&memLkCb.memUsrMdl[memMdl][hashIdx].memLck); + while(cmHashListGetNext(&memLkCb.memUsrMdl[memMdl][hashIdx].memHashCp, + (PTR)NULLP, (PTR *)&newMemInfo) == ROK) + { + funcNm = (S8 **)newMemInfo->backTrace; +#ifdef SS_MEM_LEAK_SOL + for(i = 0; i < newMemInfo->bTrcSz; i++) + { +/*cm_mem_c_001.main_27 SSI-4GMX specfic changes*/ +#ifdef SS_4GMX_LCORE + MxHeapFree(SsiHeap, funcNm[i]); +#else + free(funcNm[i]); +#endif + /* SPutSBuf(DFLT_REGION, DFLT_POOL, funcNm[i], sizeof(U32) * CM_MAX_STACK_TRACE); */ + } +#endif /* SS_MEM_LEAK_SOl */ +/*cm_mem_c_001.main_27 SSI-4GMX specfic changes*/ +#ifdef SS_4GMX_LCORE + MxHeapFree(SsiHeap, funcNm); + MxHeapFree(SsiHeap, newMemInfo); +#else + free(funcNm); + free(newMemInfo); +#endif + } + SUnlock(&memLkCb.memUsrMdl[memMdl][hashIdx].memLck); + } + } + RETVOID; +} +/* +* +* Fun: cmMemGetModuleId +* +* Desc: Initializes the memory leak detection module +* +* +* Ret: RETVOID +* +* Notes: This function initializes the memory leak detection module. +* +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PUBLIC U8 cmMemGetModuleId +( +S8 **funNm, +S32 traceSize +) +#else +PUBLIC U8 cmMemGetModuleId (funNm, traceSize) +S8 **funNm; +S32 traceSize; +#endif /* ANSI */ +{ + U8 idx; + U8 memStrIdx; + U32 len; + S32 retVal; + S16 memReqIdx; + S16 mdlFunStrIdx; + + Txt *memFn[]={"SGetMsg", "SGetSBuf", "SGetDBuf", NULLP}; + + /*cm_mem_c_001.main_25 : Fix for TRACE5 feature crash due to missing TRC MACRO*/ + TRC3(cmMemGetModuleId) + for(idx = 0; idx < traceSize; idx++) + { + memReqIdx = -1; + memStrIdx = 0; + while((memReqIdx < 0) && (memFn[memStrIdx] != NULLP)) + { + memReqIdx = cmMemGetStrMtchIdx(0, traceSize, memFn[memStrIdx], + funNm); + memStrIdx++; + } + mdlFunStrIdx = 0; + while(memUsrMdlStr[mdlFunStrIdx].fPStr != NULLP) + { + len = strlen((const S8 *)memUsrMdlStr[mdlFunStrIdx].fPStr); + memReqIdx = cmMemGetStrMtchIdx((memReqIdx + 1), traceSize, + memUsrMdlStr[mdlFunStrIdx].fPStr, + funNm); + if(memReqIdx >= 0) + { + RETVALUE(mdlFunStrIdx); + } + mdlFunStrIdx++; + } + mdlFunStrIdx = 0; + while(memUsrMdlStr[mdlFunStrIdx].fPStr != NULLP) + { + retVal = strcmp((const S8 *)"DEFAULT", + (const S8 *)memUsrMdlStr[mdlFunStrIdx].fPStr); + if(retVal == NULLD) + { + RETVALUE(mdlFunStrIdx); + } + mdlFunStrIdx++; + } + } + + RETVALUE(0); +} /* cmMemGetModuleId */ + +/* +* +* Fun: cmMemGetStrMtchIdx +* +* Desc: Initializes the memory leak detection module +* +* +* Ret: RETVOID +* +* Notes: This function initializes the memory leak detection module. +* +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmMemGetStrMtchIdx +( +U8 strtIdx, +U8 endIdx, +S8 *str, +S8 **strLst +) +#else +PUBLIC S16 cmMemGetStrMtchIdx(strtIdx, endIdx, str, strLst) +U8 strtIdx; +U8 endIdx; +S8 *str; +S8 **strLst; +#endif +{ + + S8 cmpStr[255]; + U32 len; + Bool found; + U32 tempLen; + U8 idx; + S32 retVal; + TRC3(cmMemGetStrMtchIdx); + + len = strlen((const S8 *)str); + cmpStr[0] = '('; + strncpy((S8 *)&cmpStr[1], (const S8 *)str, len); + cmpStr[len + 1] = '\0'; + len++; + found = FALSE; + for(;strtIdx < endIdx && !found; strtIdx++) + { + idx = 0; + tempLen = strlen((const S8 *)strLst[strtIdx]); + if(tempLen < len) + continue; + + while(*(strLst[strtIdx] + idx + len) != '\0') + { + retVal = strncmp((const S8 *)cmpStr, + ((const S8 *)strLst[strtIdx] + idx), len); + if(0 == retVal) + { + found = TRUE; + break; + } + idx++; + } + } + + if(!found) + { + RETVALUE(-1); + } + RETVALUE(strtIdx); + +} /* cmMemGetStrMtchIdx */ +#ifdef SS_MEM_LEAK_SOL +/* +* +* Fun: cmAddrToSymStr +* +* Desc: Initializes the memory leak detection module +* +* +* Ret: RETVOID +* +* Notes: This function initializes the memory leak detection module. +* +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PUBLIC S32 cmAddrToSymStr +( +Void *pc, +S8 *buffer, +S32 size +) +#else +PUBLIC S32 cmAddrToSymStr(pc, buffer, size) +Void *pc; +S8 *buffer; +S32 size; +#endif +{ + + Dl_info info; + Sym *sym; + + TRC3(cmAddrToSymStr); + + if (dladdr1(pc, &info, (Void **)&sym, RTLD_DL_SYMENT) == 0) + { + RETVALUE(snprintf(buffer, size, "[0x%p]", pc)); + } + + if ((info.dli_fname != NULLP && info.dli_sname != NULLP) && + ((uintptr_t)pc - (uintptr_t)info.dli_saddr < sym->st_size)) + { + RETVALUE(snprintf(buffer, size, "%s(%s+0x%x) [0x%p]", + info.dli_fname, + info.dli_sname, + (unsigned long)pc - (unsigned long)info.dli_saddr, pc)); + } + else + { + RETVALUE(snprintf(buffer, size, "%s(0x%p [0x%p]", + info.dli_fname, + (unsigned long)pc - (unsigned long)info.dli_fbase, pc)); + } + +} /* cmAddrToSymStr */ + +/* +* +* Fun: cmLeakCallBack +* +* Desc: Initializes the memory leak detection module +* +* +* Ret: RETVOID +* +* Notes: This function initializes the memory leak detection module. +* +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PUBLIC S32 cmLeakCallBack +( +uintptr_t pc, +S32 sigNo, +Void *arg +) +#else +PUBLIC S32 cmLeakCallBack(pc, sigNo, arg) +uintptr_t pc; +S32 sigNo; +Void *arg; +#endif +{ + S8 *buffer; + TRC3(cmLeakCallBack); + + Backtrace_t *bt = (Backtrace_t *)arg; + if (bt->bt_actcount >= bt->bt_maxcount) + RETVALUE(-1); +/*cm_mem_c_001.main_27 SSI-4GMX specfic changes*/ +#ifdef SS_4GMX_LCORE + buffer = (S8 *)MxHeapAlloc(SsiHeap, 510); + cmMemset((U8*)buffer, 0, 510); +#else + buffer = (S8 *)calloc(1, 510); +#endif + /* SGetSBuf(DFLT_REGION, DFLT_POOL, &buffer, 510); */ + (void) cmAddrToSymStr((void *)pc, buffer, 505); + bt->bt_buffer[bt->bt_actcount++] = (S8 *)buffer; + + RETVALUE(0); +} /* cmLeakCallBack */ +#if 0 +/* +* +* Fun: backtrace +* +* Desc: Initializes the memory leak detection module +* +* +* Ret: RETVOID +* +* Notes: This function initializes the memory leak detection module. +* +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PUBLIC S32 backtrace +( +Void **buffer, +S32 count +) +#else +PUBLIC S32 backtrace(buffer, count) +Void **buffer; +S32 count; +#endif +{ + TRC3(backtrace); + + Backtrace_t bt; + ucontext_t u; + + bt.bt_buffer = buffer; + bt.bt_maxcount = count; + bt.bt_actcount = 0; + + if (getcontext(&u) < 0) + RETVALUE(0); + (Void) walkcontext(&u, cmLeakCallBack, &bt); + RETVALUE(bt.bt_actcount); + +} /* backtrace */ +#endif +#endif /* SS_MEM_LEAK_SOL */ + +#endif /* SS_MEM_LEAK_STS */ +/* cm_mem_c_001.main_12 - addition related to SSI enhancemens +* These include sanity check functions for bucket and heap, +* for printing several memory related statistics +*/ +#if (defined(BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1) || defined(SSI_DEBUG_LEVEL1)) +/* +* +* Fun: cmMmRegIsBlkSane +* +* Desc: Performs the sanity check for the memory block by checking its header. +* +* Ret: ROK - If no trampling is detected in the block +* RFAILED - If trampling is detected in the block +* +* Notes: This function performs the memory block sanity in a block. +* +* File: cm_mem.c +* +*/ +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 +#ifdef ANSI +PUBLIC S16 cmMmRegIsBlkSane +( +CmMmBlkHdr *blkPtr, +Size size +) +#else +PUBLIC S16 cmMmRegIsBlkSane(blkPtr, size) +CmMmBlkHdr *blkPtr; +Size size; +#endif +#else +#ifdef ANSI +PUBLIC S16 cmMmRegIsBlkSane +( +CmMmBlkHdr *blkPtr +) +#else +PUBLIC S16 cmMmRegIsBlkSane(blkPtr) +CmMmBlkHdr *blkPtr; +#endif +#endif +{ + U32 sigCnt; +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + CmMmBlkTail *tailPtr; +#endif + TRC2(cmMmRegIsBlkSane); + + for ( sigCnt=0; sigCnt < CMM_TRAMPLING_SIGNATURE_LEN; sigCnt++) + { + if (blkPtr->trSignature[sigCnt] != 0xAB) + { + RETVALUE(RFAILED); + } + } +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 + tailPtr = (CmMmBlkTail *)((Data *)blkPtr + (sizeof(CmMmBlkHdr) + size)); + for ( sigCnt=0; sigCnt < CMM_TRAMPLING_SIGNATURE_LEN; sigCnt++) + { + if (tailPtr->trSignature[sigCnt] != 0xFE) + { + RETVALUE(RFAILED); + } + } +#endif + RETVALUE(ROK); +} +#endif +#ifdef SSI_DEBUG_LEVEL1 +/* +* +* Fun: cmMmBktSanityChk +* +* Desc: Performs the sanity check for the memory blocks in a memory bucket. +* This API gets called when trampling is detected in a memory block. +* +* Ret: RTRAMPLINGNOK - Trampling, serious error +* RTRAMPLINGOK - Trampling, but OK to proceed +* +* Notes: This function performs the memory block sanity in a bucket. This +* function is called by cmAlloc and cmFree as part of error handling mechanism. +* Performs sanity check for the whole bucket by traversing each +* of the memory blocks using the pointer bktStartPtr. +* Keeps track of number of tramplings happened. If the count +* exceeds the threshold decided, then invalidates this bucket. +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PRIVATE S16 cmMmBktSanityChk +( +CmMmBkt *bkt +) +#else +PRIVATE S16 cmMmBktSanityChk(bkt) +CmMmBkt *bkt; +#endif +{ + CmMmBlkHdr *ptrBlk; + U32 blkCnt; + + TRC2(cmMmBktSanityChk); + + bkt->trampleCount = 0; + + /* scan the entire memory list of the bucket */ + for (blkCnt = 0, ptrBlk = (CmMmBlkHdr *)bkt->bktStartPtr; + blkCnt < (bkt->numBlks); blkCnt++) + { + if (cmMmRegIsBlkSane(ptrBlk) != ROK) + { + bkt->trampleCount++; + if (bkt->trampleCount > CMM_TRAMPLING_THRESHOLD) + { + /* Take action to invalidate the entire bucket */ + RETVALUE(RTRAMPLINGNOK); + } + } + /* reach next memory block in this bucket manually */ + ptrBlk = (CmMmBlkHdr *)((Data *)ptrBlk + ((bkt->size) + (sizeof(CmMmBlkHdr)))); + } + + #ifdef DEBUGP + /* display an error message here */ + sprintf(dbgPrntBuf, " %d Memory tramplings detected in the bucket!\n", bkt->trampleCount); + SDisplay(0, dbgPrntBuf); + #endif /* DEBUGP */ + + RETVALUE(RTRAMPLINGOK); +} + +/* +* +* Fun: cmMmHeapSanityChk +* +* Desc: Performs the sanity check for the memory blocks in the memory heap. +* This API gets called when trampling is detected in heap(Alloc/Free). +* +* Ret: RTRAMPLINGNOK - Trampling, serious error +* RTRAMPLINGOK - Trampling, but OK to proceed +* +* Notes: This function performs the memory block sanity in the heap. This +* function is called by cmHeapAlloc and cmHeapFree as part of error +* handling mechanism. Keeps track of number of tramplings happened. +* If the count exceeds the threshold then return RTRAMPLINGNOK. If the +* count is less than threshold, then return RTRAMPLINGOK. +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PRIVATE S16 cmMmHeapSanityChk +( +CmMmHeapCb *heapCb +) +#else +PRIVATE S16 cmMmHeapSanityChk(heapCb) +CmMmHeapCb *heapCb; +#endif +{ + + TRC2(cmMmHeapSanityChk); + + /* increment the trample count */ + heapCb->trampleCount++; + + if (heapCb->trampleCount > CMM_TRAMPLING_THRESHOLD) + { + RETVALUE(RTRAMPLINGNOK); + } + + RETVALUE(RTRAMPLINGOK); +} +/* +* +* Fun: cmMmHashFunc +* +* Desc: Computes the hash list index (bin number) for a specified +* key of type (x % 101). +* +* return (idx % hash_table_size); +* +* Ret: ROK - successful, *idx contains computed index +* +* Notes: None. +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PRIVATE S16 cmMmHashFunc +( +CmMmHashListCp *hashListCp, +U32 key, +U16 *idx +) +#else +PRIVATE S16 cmMmHashFunc (hashListCp, key, idx) +CmMmHashListCp *hashListCp; /* hash list control point */ +U32 key; /* key string */ +U16 *idx; /* idx to return */ +#endif +{ + TRC2(cmMmHashFunc); + + *idx = (U16)(key % hashListCp->numOfbins); + + RETVALUE(ROK); + +} /* end of cmMmHashFunc () */ + +/* +* +* Fun: cmMmHashListInit +* +* Desc: Initializes a hash list. Parameters are: +* +* hashListCp control point for hash list +* nmbBins number of bins in the hash list. Storage will +* be allocated for them from the indicated memory +* region and pool. +* region +* pool for allocating storage for bins. +* +* Ret: ROK - initialization successful +* RFAILED - initialization failed, lack of memory +* +* Notes: None +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PRIVATE S16 cmMmHashListInit +( +CmMmHashListCp *hashListCp, /* hash list to initialize */ +U16 nmbBins, /* number of hash list bins */ +Region region, /* memory region to allocate bins */ +Pool pool /* memory pool to allocate bins */ +) +#else +PRIVATE S16 cmMmHashListInit(hashListCp, nmbBins, region, pool) +CmMmHashListCp *hashListCp; /* hash list to initialize */ +U16 nmbBins; /* number of hash list bins */ +Region region; /* memory region to allocate bins */ +Pool pool; /* memory pool to allocate bins */ +#endif +{ + U16 i; + CmMmHashListEnt *hl; + + TRC2(cmMmHashListInit); + + /* initialize control point fields */ + hashListCp->hashList = NULLP; + hashListCp->numOfbins = 0; + hashListCp->numOfEntries = 0; + + /* allocate memory for bins */ + if (nmbBins) + { + if (SGetSBuf(region, pool, (Data **) &hashListCp->hashList, + (Size)(nmbBins * sizeof(CmMmHashListEnt))) != ROK) + RETVALUE(RFAILED); + + /* initialize bin pointers */ + hl = hashListCp->hashList; + for(i = 0; i < nmbBins; i++) + { + hl[i].size = hl[i].numAttempts = 0; + } + + /* initialize bin size */ + hashListCp->numOfbins = nmbBins; + } + + RETVALUE(ROK); +} + +/* +* +* Fun: cmMmHashListDeinit +* +* Desc: Deinitializes a hash list. Deallocates memory for bins +* and resets header fields. Parameters are: +* +* hashListCp control point for hash list +* region +* pool for allocating storage for bins. +* +* Ret: ROK - successful +* RFAILED - failure, invalid parameters +* +* Notes: None +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PRIVATE S16 cmMmHashListDeinit +( +CmMmHashListCp *hashListCp, /* hash list to deinitialize */ +Region region, /* memory region to allocate bins */ +Pool pool /* memory pool to allocate bins */ +) +#else +PRIVATE S16 cmMmHashListDeinit(hashListCp, region, pool) +CmMmHashListCp *hashListCp; /* hash list to deinitialize */ +Region region; /* memory region to allocate bins */ +Pool pool; /* memory pool to allocate bins */ +#endif +{ + TRC2(cmMmHashListDeinit); + + /* deallocate memory for bins */ + if (hashListCp->numOfbins) + (Void) SPutSBuf(region, pool, + (Data *) hashListCp->hashList, + (Size) (hashListCp->numOfbins * sizeof(CmMmHashListEnt))); + + /* deinitialize control point fields */ + hashListCp->hashList = NULLP; + hashListCp->numOfbins = 0; + hashListCp->numOfEntries = 0; + + RETVALUE(ROK); +} /* end of cmMmHashListDeinit */ + +/* +* +* Fun: cmMmHashListInsert +* +* Desc: Inserts a new entry in the hash list. Parameters are: +* +* hashListCp control point for hash list +* key pointer to key string in the new entry +* +* Ret: ROK - insertion successful +* RFAILED - insertion failed (incorrect parameter values) +* +* Notes: None +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PRIVATE S16 cmMmHashListInsert +( +CmMmHashListCp *hashListCp, /* hash list to add to */ +U32 key /* pointer to key */ +) +#else +PRIVATE S16 cmMmHashListInsert(hashListCp, key) +CmMmHashListCp *hashListCp; /* hash list to add to */ +U32 key; /* pointer to key */ +#endif +{ + CmMmHashListEnt *hashListEnt; /* pointer to hash list entry header */ + U16 idx; /* index for insertion into hash list */ + U16 i; + + TRC2(cmMmHashListInsert); + + /* check if hashListCp is initialised yet */ + if ( hashListCp->numOfbins == 0) + RETVALUE(ROK); + + /* compute index for insertion */ + if (cmMmHashFunc(hashListCp, key, &idx) != ROK) + RETVALUE(RFAILED); + + hashListEnt = hashListCp->hashList; + + if (hashListEnt[idx].numAttempts == 0) + { + /* new entry, insert here */ + hashListEnt[idx].size = key; + hashListEnt[idx].numAttempts++; + /* increment count of entries in hash list */ + hashListCp->numOfEntries++; + } + else + { + /* this hash is occupied, re-hash it using linear probing */ + for (i=idx; i < CMM_STAT_HASH_TBL_LEN; i++) + { + if (hashListEnt[i].size == key) + { + hashListEnt[i].numAttempts++; + break; + } + + if (hashListEnt[i].numAttempts == 0) + { + hashListEnt[i].size = key; + hashListEnt[i].numAttempts++; + /* increment count of entries in hash list */ + hashListCp->numOfEntries++; + break; + } + } + + if (i == CMM_STAT_HASH_TBL_LEN) + { + /* there is no free slot for this key */ + RETVALUE(RFAILED); + } + } + + RETVALUE(ROK); +} /* end of cmMmHashListInsert */ + +#endif /* SSI_DEBUG_LEVEL1 */ +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT +/* +* +* Fun: cmHstGrmHashListInit +* +* Desc: Initializes a hash list. Parameters are: +* +* hashListCp control point for hash list +* Ret: ROK - initialization successful +* RFAILED - initialization failed, lack of memory +* +* Notes: None +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PRIVATE S16 cmHstGrmHashListInit +( +CmHstGrmHashListCp *hashListCp /* hash list to initialize */ +) +#else +PRIVATE S16 cmHstGrmHashListInit(hashListCp) +CmHstGrmHashListCp *hashListCp; /* hash list to initialize */ +#endif +{ + /*cm_mem_c_001.main_25 : Fix for TRACE5 feature crash due to missing TRC MACRO*/ + TRC2(cmHstGrmHashListInit) +#ifdef DEBUGP + /* display an error message here */ + /*cm_mem_c_001.main_25: Fixed Warnings for 32/64 bit compilation*/ +#ifdef ALIGN_64BIT + sprintf(dbgPrntBuf, " %lu size of memory histogram hash List\n", sizeof(CmHstGrmHashListCp)); +#else + sprintf(dbgPrntBuf, " %d size of memory histogram hash List\n", sizeof(CmHstGrmHashListCp)); +#endif + SDisplay(0, dbgPrntBuf); +#endif /* DEBUGP */ + memset(hashListCp, 0, sizeof(CmHstGrmHashListCp)); + RETVALUE(ROK); +} + +/* +* +* Fun: cmHstGrmHashListDeInit +* +* Desc: De-initializes a hash list. Parameters are: +* +* hashListCp control point for hash list +* Ret: ROK - initialization successful +* RFAILED - initialization failed, lack of memory +* +* Notes: None +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PRIVATE S16 cmHstGrmHashListDeInit +( +CmHstGrmHashListCp *hashListCp /* hash list to initialize */ +) +#else +PRIVATE S16 cmHstGrmHashListDeInit(hashListCp) +CmHstGrmHashListCp *hashListCp; /* hash list to initialize */ +#endif +{ + /*cm_mem_c_001.main_25 : Fix for TRACE5 feature crash due to missing TRC MACRO*/ + TRC2(cmHstGrmHashListDeInit) +#ifdef DEBUGP + /* display an error message here */ + /*cm_mem_c_001.main_25: Fixed Warnings for 32/64 bit compilation*/ +#ifdef ALIGN_64BIT + sprintf(dbgPrntBuf, " %lu size of memory histogram hash List\n", sizeof(CmHstGrmHashListCp)); +#else + sprintf(dbgPrntBuf, " %d size of memory histogram hash List\n", sizeof(CmHstGrmHashListCp)); +#endif + SDisplay(0, dbgPrntBuf); +#endif /* DEBUGP */ + memset(hashListCp, 0, sizeof(CmHstGrmHashListCp)); + RETVALUE(ROK); +} + +/* +* +* Fun: cmHstGrmFreeInsert +* +* Desc: Inserts a Freed information in into the hash list. Parameters are: +* +* bkt : pointer to bucket for which memory is freed. +* line : Line where memory is freed. +* file : file where memory is freed. +* entId : Tapa task which releases the memory. +* +* Ret: ROK - insertion successful +* RFAILED - insertion failed (incorrect parameter values) +* +* Notes: None +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PRIVATE S16 cmHstGrmFreeInsert +( +CmHstGrmHashListCp* hashListCp, /* hash list cp */ +U32 blkSz, /* size of the block freed */ +U32 line, /* Line number */ +U8 *fileName, /* file name */ +U8 entId /* Tapa task which free the memory */ +) +#else +PRIVATE S16 cmHstGrmFreeInsert(hashListCp, blkSz, line, fileName, entId) +CmHstGrmHashListCp* hashListCp; /* hash list cp */ +U32 blkSz; /* size of the block freed */ +U32 line; /* line number */ +U8 *fileName; /* file Name */ +U8 entId; /* Tapa task which frees the memory */ +#endif +{ + U32 binIdx = 0; /* Bin index to insert the entry into the hash list */ + U32 key = 0; /* Key to fine the bin index */ + U32 ret = 0; /* Return value */ + CmMemEntries *entry = NULLP; /* Entry which contains the information */ + + + TRC2(cmHstGrmFreeInsert); + + /* check for the total number of entries in the hash list. * + * If there is no place for new entry return failure */ + cmHstGrmGetHashIdxAndKey(fileName, line, &binIdx, &key); + + /* After comuting the hash bind and key, check the entity already * + existing or not. if we found the entry then update the information */ + ret = cmHstGrmFindEntry(hashListCp, key, &binIdx, &entry); + if(ret == ROK) + { + entry->freedBytes += blkSz; + entry->bucketFreeReq++; + RETVALUE(ROK); + } /* End of if */ + + /* If hash list is full then print the error tna continue */ + if(hashListCp->totalNumEntries == (CMM_HIST_MAX_MEM_BIN * CMM_HIST_MAX_MEM_ENTRY_PER_BIN)) + { + printf("No place in the hash list. Increase the value of macro CMM_HIST_MAX_MEM_BIN and CMM_HIST_MAX_MEM_ENTRY_PER_BIN \n"); + RETVALUE(RFAILED); + } /* End of if */ + + /* Take the address of next free entry in the hash bin */ + entry = &(hashListCp->hashList[binIdx].entries[hashListCp->hashList[binIdx].numOfEntries]); + + /* Increase the number of time frees called */ + entry->bucketFreeReq++; + entry->freedBytes += blkSz; + + /* Fill the information into the entry structure */ + cmHstGrmFillEntry(entry, key, line, fileName, entId); + /* Increase the total numbet of entries in the bin */ + hashListCp->hashList[binIdx].numOfEntries++; + + /* Increase the total number of entries in the hash list */ + hashListCp->totalNumEntries++; + + RETVALUE(ROK); +} /* end of cmHstGrmFreeInsert */ + + +/* +* +* Fun: ret = cmHstGrmAllocInsert +* +* Desc: Inserts a memory allocated information in the hash list. Parameters are: +* +* hashListCp control point for hash list +* key pointer to key string in the new entry +* +* Ret: ROK - insertion successful +* RFAILED - insertion failed (incorrect parameter values) +* +* Notes: None +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PRIVATE S16 cmHstGrmAllocInsert +( +CmHstGrmHashListCp *hashListCp, +U32 blkSz, +U32 *reqSz, +U32 line, +U8 *fileName, +U8 entId +) +#else +PRIVATE S16 cmHstGrmAllocInsert(hashListCp, blkSz, reqSz, line, fileName, entId) +CmHstGrmHashListCp *hashListCp; +U32 blkSz; +U32 *reqSz; +U32 line; +U8 *fileName; +U8 entId; +#endif +{ + U32 binIdx = 0; + U32 key = 0; + U32 ret = 0; + CmMemEntries *entry = NULLP; + + TRC2(cmHstGrmAllocInsert); + + /* check for the total number of entries in the hash list. * + * If there is no place for new entry return failure */ + cmHstGrmGetHashIdxAndKey(fileName, line, &binIdx, &key); + + /* After comuting the hash bind and key, check the entity already * + existing or not. if we found the entry then update the information */ + ret = cmHstGrmFindEntry(hashListCp, key, &binIdx, &entry); + + if(ret == ROK) + { + entry->allocBytes += blkSz; + entry->bucketAllocReq++; + entry->wastedBytes += (blkSz - *reqSz); + RETVALUE(ROK); + } /* End of if */ + + if(hashListCp->totalNumEntries == (CMM_HIST_MAX_MEM_BIN * CMM_HIST_MAX_MEM_ENTRY_PER_BIN)) + { + printf("No place in the hash list. Increase the value of macro CMM_HIST_MAX_MEM_BIN and CMM_HIST_MAX_MEM_ENTRY_PER_BIN\n"); + RETVALUE(RFAILED); + } /* End of if */ + + /* Take the address of next free entry in the hash bin */ + entry = &(hashListCp->hashList[binIdx].entries[hashListCp->hashList[binIdx].numOfEntries]); + + /* Clauculae the wasted bytes */ + /* Here wasted byte is differnce between the byte user + * has requested and the byte the ssi allocated */ + entry->wastedBytes += (blkSz - *reqSz); + entry->bucketAllocReq++; + entry->allocBytes += blkSz; + + /* Fill the information into the entry structure */ + cmHstGrmFillEntry(entry, key, line, fileName, entId); + /* Increase the total numbet of entries in the bin */ + hashListCp->hashList[binIdx].numOfEntries++; + + /* Increase the total number of entries in the hash list */ + hashListCp->totalNumEntries++; + + RETVALUE(ROK); +} /* end of cmHstGrmAllocInsert */ + + +/* +* +* Fun: cmHstGrmGetHashIdxAndKey +* +* Desc: Finds an entry in the hash list. Parameters are: +* +* hashListCp control point for hash list +* key pointer to key string in the new entry +* +* Ret: ROK - insertion successful +* RFAILED - insertion failed (incorrect parameter values) +* +* Notes: None +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PRIVATE S16 cmHstGrmGetHashIdxAndKey +( +U8 *fileName, +U32 line, +U32 *binIdx, +U32 *key +) +#else +PRIVATE S16 cmHstGrmGetHashIdxAndKey(fileName, line, binIdx, key) +U8 *fileName; +U32 line; +U32 *binIdx; +U32 *key; +#endif +{ + + U32 i = 0; + TRC2(cmHstGrmGetHashIdxAndKey); + + /* Calculate the key using file name and line number */ + for(i = 0 ; fileName[i] != '\0'; i++) + { + *key += fileName[i]; + }/* End of for */ + *key += line; + *binIdx = ( *key % CMM_HIST_MAX_MEM_BIN); + RETVALUE(ROK); +} /* end of cmHstGrmFillEntry */ + +/* +* +* Fun: cmHstGrmFillEntry +* +* Desc: Insert the entry into the hash list. +* +* entry : Infornation which will be inserted into the hash list +* key : Which will be used ti find the entry. +* line : Line number +* fileName : File name +* entId : Tapa task Id +* +* Ret: ROK - insertion successful +* RFAILED - insertion failed (incorrect parameter values) +* +* Notes: None +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PRIVATE S16 cmHstGrmFillEntry +( +CmMemEntries *entry, +U32 key, +U32 line, +U8 *fileName, +U8 entId +) +#else +PRIVATE S16 cmHstGrmFillEntry(entry, key, line, fileName, entId) +CmMemEntries *entry; +U32 key; +U32 line; +U8 *fileName; +U8 entId; +#endif +{ + + U32 idx = 0; + TRC2(cmHstGrmFillEntry); + entry->key = key; + entry->line = line; + entry->entId = entId; + for(idx = 0; fileName[idx] != '\0'; idx++) + { + entry->fileName[idx] = fileName[idx]; + } + entry->fileName[idx] = '\0'; + RETVALUE(ROK); +} /* end of cmHstGrmFillEntry */ + +/* +* +* Fun: cmHstGrmFindEntry +* +* Desc: Finds an entry in the hash list. Parameters are: +* +* hashListCp control point for hash list +* key pointer to key string in the new entry +* +* Ret: ROK - insertion successful +* RFAILED - insertion failed (incorrect parameter values) +* +* Notes: None +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PRIVATE S16 cmHstGrmFindEntry +( +CmHstGrmHashListCp *hashListCp, +U32 key, +U32 *binIdx, +CmMemEntries **entry +) +#else +PRIVATE S16 cmHstGrmFindEntry(hashListCp, key, binIdx, entry) +CmHstGrmHashListCp *hashListCp; +U32 key; +U32 *binIdx; +CmMemEntries **entry; +#endif +{ + + U32 numEnt = 0; + U32 numBin = 0; + CmHstGrmHashListEnt *tmpBin = NULLP; + + TRC2(cmHstGrmFindEntry); + + + for(numBin = 0; numBin < CMM_HIST_MAX_MEM_BIN; numBin++) + { + /* find for the entry in the bin */ + tmpBin = &(hashListCp->hashList[*binIdx]); + for(numEnt = 0; numEnt < tmpBin->numOfEntries; numEnt++) + { + /* If key supplied is matched with the stored key then + * return that entity */ + if(tmpBin->entries[numEnt].key == key) + { + *entry = &(tmpBin->entries[numEnt]); + RETVALUE(ROK); + }/* End of if (tmpBin->entries[numEnt].key) */ + }/* end of for (numEnt = 0) */ + + /* Here we are checking for any room left in the bin. If the room * + exists its mean that there is no entry with the Key. so return * + failure. + If there is no room in the bin, then check the other bins to find * + the entry */ + if(numEnt == CMM_HIST_MAX_MEM_ENTRY_PER_BIN) + { + if(*binIdx == CMM_HIST_MAX_MEM_BIN) + { + *binIdx = 0; + }/* End of if (binIdx) */ + else + { + *binIdx++; + }/* End of else (binIdx) */ + } /* End of if (numEnt) */ + else + { + printf ("Unable to find the entry in hash list\n"); + RETVALUE(RFAILED); + }/* End of else (numEnt) */ + }/* end of for (numBin = 0) */ + + printf("Unable to find the entry in the hash list\n"); + RETVALUE(RFAILED); +} /* end of cmHstGrmFindEntry */ + +#endif /* SS_HISTOGRAM_SUPPORT */ + +/********************************************************************** + End of file + **********************************************************************/ diff --git a/src/cm/cm_mem.h b/src/cm/cm_mem.h new file mode 100644 index 000000000..6e83be42f --- /dev/null +++ b/src/cm/cm_mem.h @@ -0,0 +1,150 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + + +/********************************************************************20** + + Name: Common Memory Manager + + Type: C include file + + Desc: Defines that are required by the Common Memory Manager. + + File: cm_mem.h + +*********************************************************************21*/ + +#ifndef __CMMEMH_ +#define __CMMEMH_ + +/* cm_mem_h_001.103 - Addition */ +#ifdef __cplusplus +extern "C" { +#endif + + +#ifdef XEON_MULTIPLE_CELL_CHANGES +#define MAX_WLS_DEVICE_NAME_LEN 16 +#define DEFAULT_WLS_DEVICE_NAME "/dev/wls" +#endif + +#define CMM_MINBUFSIZE (PTRALIGN(sizeof(CmHEntry))) +#define CMM_DATALIGN(s, msz) (((Size)(s) % msz) ? ((Size)(s) + ((msz - (Size)(s) % msz))): (Size)(s)) + +#define CMM_BUFSIZE(s, msz) ((Size)(s) < (Size) msz ? \ + (Size) msz : \ + (Size) CMM_DATALIGN(s, msz)) + +/* defines */ +/* cm_mem_h_001.103 - Addition for MEMCAL */ +#ifndef CMM_MAX_BKT_ENT +#define CMM_MAX_BKT_ENT 30 +#endif +#ifndef CMM_MAX_MAP_ENT +/* cm_mem_h_001.main_10: Modifications*/ +#define CMM_MAX_MAP_ENT 512 +#endif + +/* cm_mem_h_001.main_6 - addition for SSI enhancements */ +#if (defined(SSI_DEBUG_LEVEL1) || defined(BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1) || defined (SS_LIGHT_MEM_LEAK_STS)) +/* +* Memory block header signature length +* Customer might choose to modify this to set his desired trampling signature length +* Customer should choose a value between 1 byte to 4 bytes +*/ +#define CMM_TRAMPLING_SIGNATURE_LEN 4 + +/* +* Maximum number of trampling allowed +* Customer might choose to modify this, however too big a value is not suggestible +*/ +#define CMM_TRAMPLING_THRESHOLD 3 + +/* +* Hash list size to mantain the statistics of size requested & the number of attempts for allocation +* Customer might choose to modify this to accomodate statistics for more sizes +* preferably choose a prime number for better performance +*/ +#define CMM_STAT_HASH_TBL_LEN 211 /* prime number */ + +/* values for memFlags in CmMmBlkHdr */ +#define CMM_FREE_FLAG 0x01 +#define CMM_DYNAMIC_MEM_FLAG 0x04 +#define CMM_STATIC_MEM_FLAG 0x08 + +/* +* MACROs for setting/resetting above flags +* FREE state related flags +*/ +#define CMM_SET_FREE_FLAG(x) ((x) |= CMM_FREE_FLAG) +#define CMM_RESET_FREE_FLAG(x) ((x) &= (~(CMM_FREE_FLAG))) +#define CMM_IS_FREE(x) ((x) & CMM_FREE_FLAG) + +/* DYNAMIC state related flags */ +#define CMM_SET_DYNAMIC_FLAG(x) ((x) |= CMM_DYNAMIC_MEM_FLAG) +#define CMM_RESET_DYNAMIC_FLAG(x) ((x) &= (~(CMM_DYNAMIC_MEM_FLAG))) +#define CMM_IS_DYNAMIC(x) ((x) & CMM_DYNAMIC_MEM_FLAG) + +/* STATIC state related flags */ +#define CMM_SET_STATIC_FLAG(x) ((x) |= CMM_STATIC_MEM_FLAG) +#define CMM_RESET_STATIC_FLAG(x) ((x) &= (~(CMM_STATIC_MEM_FLAG))) +#define CMM_IS_STATIC(x) ((x) & CMM_STATIC_MEM_FLAG) +#endif /* SSI_DEBUG_LEVEL1 */ + +/* Valid Physical Bit */ +#define CMM_REG_PHY_VALID 0x01 +#define CMM_REG_OUTBOARD 0x02 +/* cm_mem_h_001.main_7 : Additions */ +#if (defined(SS_MEM_LEAK_STS) || defined(BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1)) +#ifndef CM_MEM_USR_MDL +#define CM_MEM_USR_MDL 10 +#ifndef CM_MAX_STACK_TRACE +#define CM_MAX_STACK_TRACE 20 +#endif /* if CM_MAX_STACK_TRACE is not defined in Makefile */ +#endif +#define MEMRAW2STR(x,y) {#x, #y} +#define CM_MAX_HASH_PER_TSK 4 +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL2 +#define BRDCM_MEM_LEAK_BTRACE 6 /* Back trace */ +#endif +#endif /* SS_MEM_LEAK_STS */ + +#ifdef SS_HISTOGRAM_SUPPORT +#define CMM_HIST_MAX_FILENAME 100 +#define CMM_HIST_MAX_MEM_ENTRY_PER_BIN 25 +#define CMM_HIST_MAX_MEM_BIN 25 +#endif /* SS_HISTOGRAM_SUPPORT */ + +#ifdef SS_LOCKLESS_MEMORY +#define CMM_MAX_NUMBER_BKT_NODE 2 +#endif + +#ifdef SS_LIGHT_MEM_LEAK_STS +#define CM_MAX_ALLOC_ENTERIES 100000 +#endif +/* cm_mem_h_001.103 */ +#ifdef __cplusplus +} +#endif + +#endif /* __CMMEMH_ */ + +/********************************************************************** + End of file + **********************************************************************/ + diff --git a/src/cm/cm_mem.x b/src/cm/cm_mem.x new file mode 100644 index 000000000..a3f9d339a --- /dev/null +++ b/src/cm/cm_mem.x @@ -0,0 +1,514 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + + +/********************************************************************20** + + Name: Common Memory Manager + + Type: C include file + + Desc: Data structure definitions that are used by + the Common Memory Manager. + + File: cm_mem.x + + Sid: cm_mem.x@@/main/13 - Fri Feb 26 13:16:42 2010 + + Prg: rm + +*********************************************************************21*/ + +#ifndef __CMMEMX_ +#define __CMMEMX_ + +#ifdef __cplusplus +extern "C" { +#endif +/*cm_mem_x_001.main_12: As these required for the following only */ +#if (defined(SS_HISTOGRAM_SUPPORT) || defined(SS_MEM_LEAK_STS)) +#include "cm_hash.h" /* cm_mem_x_001.main_11: Additions */ +#include "cm_hash.x" +#endif /* SS_HISTOGRAM_SUPPORT */ + + + +/* typedefs */ +typedef struct cmMmRegCfg CmMmRegCfg; +typedef struct cmMmBktCfg CmMmBktCfg; + + +typedef struct cmMmRegCb CmMmRegCb; +typedef struct cmMmMapBkt CmMmMapBkt; +typedef struct cmMmHeapCb CmMmHeapCb; +typedef struct cmMmBkt CmMmBkt; +typedef struct cmHEntry CmHEntry; +/* cm_mem_x_001.main_9 - addition of new data types for providing +* header for memory blocks in buckets and a hash list to maintain +* size vs. numAttempts statistics +*/ +#if (defined(SSI_DEBUG_LEVEL1) || defined(BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1) || defined (SS_LIGHT_MEM_LEAK_STS)) +typedef struct cmMmBlkHdr CmMmBlkHdr; +typedef struct cmMmHashListEnt CmMmHashListEnt; +typedef struct cmMmHashListCp CmMmHashListCp; +#endif /* SSI_DEBUG_LEVEL1 */ +typedef Data CmMmEntry; + /* cm_mem_x_001.main_11: Additions */ +#ifdef SS_HISTOGRAM_SUPPORT +typedef struct cmHstGrmHashListCp CmHstGrmHashListCp; +typedef struct cmHstGrmHashListEnt CmHstGrmHashListEnt; +typedef struct cmMemEntries CmMemEntries; +#endif /* SS_HISTOGRAM_SUPPORT */ + +/* forward definitions */ + + +/************************************************************************ + Common Memory Manager Configuration Data Structures +************************************************************************/ + +/* Bucket configuration structure. */ +struct cmMmBktCfg +{ + Size size; /* Size of the memory block */ + U32 numBlks; /* Number of the block in the bucket */ +}; + +/* Memory Region configuration structure. */ +struct cmMmRegCfg +{ + Size size; /* Size of the memory */ + Data *vAddr; /* Start address of the memory */ + U8 lType; /* Lock Type to be used */ + + U8 chFlag; /* Flag defines the memory region characteristics */ + Data *pAddr; /* Physical address of the memory block: Valid + if CMM_REG_PHY_VALID bit of chFlag is set */ + Size bktQnSize; /* Quatum size of the memory block */ + U16 numBkts; /* Number of buckets in the Bucket Pool */ + + CmMmBktCfg bktCfg[CMM_MAX_BKT_ENT]; /* Bucket configuration structure */ +}; + +/************************************************************************ + Common Memory Manager Implementation Data Structures +************************************************************************/ +/* cm_mem_x_001.main_11: Additions */ +#ifdef SS_HISTOGRAM_SUPPORT +struct cmMemEntries /* Entry information */ +{ + U32 line; /* Line Number where memory allocation primitive used */ + U32 allocBytes; /* Granted Byte */ + U32 allocOverFlow; /* If the value of allocBytes overflows then we use this variable */ + U32 freedBytes; /* Freed Bytes */ + U32 freeOverFlow; /* If the value of freeByte overflows then we use this value */ + U32 wastedBytes; /* Difference between Granted and Requested bytes */ + U32 bucketAllocReq; /* No of times this Bucket used */ + U32 bucketFreeReq; /* No of times this Bucket freed */ + U32 entId; /* Tapa task used this bucket */ + U32 key; /* combination of file name and line */ + U8 fileName[CMM_HIST_MAX_FILENAME]; /* File Name where memory allocation primitive used */ +}; + +struct cmHstGrmHashListEnt /* hash list entry */ +{ + CmMemEntries entries[CMM_HIST_MAX_MEM_ENTRY_PER_BIN]; /* Number of entires in each bin */ + U32 numOfEntries; /*Number of entries in hash list */ +}; + +struct cmHstGrmHashListCp /* Hash List control pointer */ +{ + CmHstGrmHashListEnt hashList[CMM_HIST_MAX_MEM_BIN]; /* Number of bins in hash list */ + U16 totalNumEntries; /* Total number of bins */ +}; + +#endif /* SS_HISTOGRAM_SUPPORT */ + +/* cm_mem_x_001.main_9 - addition of memory header for blocks in buckets */ +#if (defined(SSI_DEBUG_LEVEL1) || defined(BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1) || defined (SS_LIGHT_MEM_LEAK_STS)) +/* Memory Block Header */ +struct cmMmBlkHdr +{ + /* trSignature shall always be maintained as the first element in this structure */ + U8 trSignature[CMM_TRAMPLING_SIGNATURE_LEN]; /* signature to detect trampling */ + CmMmBlkHdr *nextBlk; /* pointer to the next memory block header */ + U32 memFlags; /* Free/Static/Dynamic */ + Size requestedSize; /* requested size for which this mem blk has been allocated */ +#ifdef SS_LIGHT_MEM_LEAK_STS + U32 timeStamp; /* Time stamp */ + U32 lineNo; + U32 allocQueueIndx; + U8 *currFuncName; +#endif +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL2 + CmHashListEnt ent; /* hash list entry */ + Size reqSz; /* Requested size */ + Size allocSz;/* Allocated size */ + U8 bktIdx; /* Bucket ID */ + Void *backTrace[BRDCM_MEM_LEAK_BTRACE]; /* Back trace */ +#endif +}; +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 +typedef struct cmMmBlkTail +{ + U8 trSignature[CMM_TRAMPLING_SIGNATURE_LEN]; /* signature to detect trampling */ +}CmMmBlkTail; +typedef struct memLkInfo +{ + Bool memLkMdlInit; + FILE *fileLkLog; +}MemLkInfo; +#endif +#endif /* SSI_DEBUG_LEVEL1 */ + +/* Memory bucket structure */ +struct cmMmBkt /* Bucket Structure */ +{ +/* cm_mem_x_001.main_9 - addition of next block pointer */ +#if (defined(SSI_DEBUG_LEVEL1) || defined(BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1) || defined (SS_LIGHT_MEM_LEAK_STS)) + CmMmBlkHdr *nextBlk; /* pointer to the next memory block header */ +#if (defined(BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1) || defined (SS_LIGHT_MEM_LEAK_STS)) + CmMmBlkHdr *lastBlk; /* Pointer to the last memory block header */ +#endif +#else + CmMmEntry *next; /* Pointer to the next memory block */ +#ifdef SSI_MEM_CORR_PREVENTION + CmMmEntry *last; /* Pointer to the last memory block */ +#endif +#ifdef MS_MBUF_CORRUPTION /*PST Should not take code Under this flag*/ + CmMmEntry *last; /* Pointer to the last memory block */ +#endif +#endif /* SSI_DEBUG_LEVEL1 */ + Size size; /* Size of the block */ + U32 numBlks; /* Total number of blocks in the bucket */ + U32 maxAlloc; /* Maximum number of blocks allocated till now */ + U32 numAlloc; /* Number of blocks allocated */ + SLockId bktLock; /* Lock to protect the bucket pool */ + U32 bktFailCnt; /* bucket alloc failure count */ + U32 bktNoFitCnt; /* number of blocks not fit */ +/* cm_mem_x_001.main_9 - addition of statistics related data */ +#if (defined(SSI_DEBUG_LEVEL1) || defined(BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1)) + Data *bktStartPtr; /* maintains the start address of the memory block in the bucket */ + StsCntr numAllocAttempts; /* total number of allocation attempts */ + StsCntr numDeallocAttempts; /* total number of de-allocation attempts */ + Size staticMemUsed; /* amount of memory used for static allocations */ + Size dynamicMemUsed; /* amount of memory used for dynamic allocations */ + U8 trampleCount; /* incremented everytime a trampling is detected in any block of the bucket */ +#endif /*SSI_DEBUG_LEVEL1*/ +/* cm_mem_x_001.main_11: Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + CmHstGrmHashListCp hstGrmHashListCp; +#endif /* SS_HISTOGRAM_SUPPORT */ +}; + + +/* Size-To-Bucket map table structure */ +struct cmMmMapBkt +{ + U16 bktIdx; /* The index to the memory bucket */ + +#if (ERRCLASS & ERRCLS_DEBUG) + U16 numReq; /* Number of the allocation request */ + U16 numFailure; /* Number of allocation failure form the bucket */ +#endif + +}; + +/* Heap entry structure linked in the heap control block */ +struct cmHEntry +{ +/* cm_mem_x_001.main_9 - addition to provide trampling and double-free detections support */ +#ifdef SSI_DEBUG_LEVEL1 + /* trSignature shall always be maintianed as the first element in this structure */ + U8 trSignature[CMM_TRAMPLING_SIGNATURE_LEN]; /* signature to detect trampling */ + U32 memFlags; /* flag to maintain the memory status */ + Size requestedSize; /* size of the heap entry block */ +#endif /* SSI_DEBUG_LEVEL1 */ + CmHEntry *next; /* Pointer to the next entry block */ + Size size; /* size of the heap entry block */ +}; + +/* Heap control block */ +struct cmMmHeapCb +{ + Data *vStart; /* Memory start address */ + Data *vEnd; /* Memory end address */ + CmHEntry *next; /* Next heap block entry */ + Size avlSize; /* Total available memory */ + Size minSize; /* Minimum size that can be allocated */ + SLockId heapLock; /* Lock to protect the heap pool */ +#if (ERRCLASS & ERRCLS_DEBUG) + U16 numFragBlk; /* Number of fragmented block */ + U16 numReq; /* Number of allocation request */ + U16 numFailure; /* Number of allocation failure */ +#endif + U32 heapAllocCnt; /* Number of blocks from heap */ +/* cm_mem_x_001.main_9 - addition of statistics related data */ +#ifdef SSI_DEBUG_LEVEL1 + Size staticHeapMemUsed; /* amount of heap memory used for static allocations */ + Size dynamicHeapMemUsed; /* amount of heap memory used for dynamic allocations */ + Size nextOffset; /* Offset to the next pointer in structure CmHEntry */ + /* Update this in cmMmHeapInit if cmHEntry is changed */ + StsCntr numAllocAttempts; /* total number of allocation attempts in heap */ + StsCntr numDeallocAttempts; /* total number of de-allocation attempts in heap */ + U8 trampleCount; /* incremented everytime a trampling is detected in any block of the heap */ +#endif /* SSI_DEBUG_LEVEL1 */ + /* cm_mem_x_001.main_11: Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + /* Hash list to support Heap Block histogram */ + CmHstGrmHashListCp heapHstGrmHashListCp; +#endif /* SS_HISTOGRAM_SUPPORT */ + +}; + +/* cm_mem_x_001.main_9 - addition of hash list for maintaining size vs. numAttempts statistics */ +#ifdef SSI_DEBUG_LEVEL1 +struct cmMmHashListEnt /* hash list entry */ +{ + U32 size; /* pointer to key */ + U32 numAttempts; /* number of attempts */ +}; + +struct cmMmHashListCp +{ + CmMmHashListEnt *hashList; + U16 numOfbins; + U16 numOfEntries; +}; +#endif /* SSI_DEBUG_LEVEL1 */ + +/* Memory region control block */ +struct cmMmRegCb +{ + Region region; /* Region Id of the memory */ + SRegInfo regInfo; /* Region information block */ + + U8 chFlag; /* Flag defines the region characteristics */ + Data *pAddr; /* Physical address of the memory block. + Valid if CMM_REG_PHY_VALID bit is set */ + + Size bktSize; /* Size of the memory used for the bucket pool */ + U16 bktQnPwr; /* Quantum size of the bucket pool */ + Size bktMaxBlkSize; /* Maximum size of block in the bucket pool */ + U16 numBkts; /* Number of buckets in the Bucket Pool */ + + CmMmMapBkt mapTbl[CMM_MAX_MAP_ENT]; /* size-to-bucket map table */ + CmMmBkt bktTbl[CMM_MAX_BKT_ENT]; /* Pointer to the memory bkt tbl */ + + Bool heapFlag; /* Set to true if the heap pool is configured */ + Size heapSize; /* Size of the heap pool */ + CmMmHeapCb heapCb; /* Heap pool control block */ +/* cm_mem_x_001.main_9 - addition of hash list control point in region control block */ +#ifdef SSI_DEBUG_LEVEL1 + CmMmHashListCp hashListCp; /* hast list to maintain the size statistics */ +#endif /* SSI_DEBUG_LEVEL1 */ +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL2 + CmHashListCp brdcmSsiLstCp; /* hast list to maintain the SSI memory information for Broadcom */ +#endif +#ifdef SS_MULTICORE_SUPPORT /*cm_mem_x_001.main_10*/ + SsSTskEntry *sTsk; +#endif /* SS_MULTICORE_SUPPORT */ + +}; + +#ifdef SS_LIGHT_MEM_LEAK_STS +typedef struct allocInfo +{ + Void *memAddr; + U8 used; +}AllocInfo; + +typedef struct memLeakCb +{ + SLockId memLock; + U8 isStarted; + AllocInfo allocInfo[CM_MAX_ALLOC_ENTERIES]; + U32 queue[CM_MAX_ALLOC_ENTERIES]; + U32 head; + U32 tail; +}MemLeakCb; + +EXTERN Void cmInitMemLeak ARGS((Void)); +EXTERN Void cmDeinitMemLeak ARGS((Void)); +EXTERN Void cmStartStopLeakLog ARGS((Void)); +EXTERN U32 cmStorAllocBlk ARGS((Void *addr)); +EXTERN Void cmRlsAllocBlk ARGS((U32 indx)); +EXTERN Void cmPrintLeakLog ARGS((Void)); +#endif /* SS_LIGHT_MEM_LEAK_STS */ + + /* cm_mem_x_001.main_11: Additions */ +#ifdef SS_MEM_LEAK_STS +typedef struct _memHash +{ + SLockId memLck; + Bool used; + CmHashListCp memHashCp; +}MemHash; + +typedef struct _memAllocInfo +{ + CmHashListEnt ent; +#ifdef BIT_64 + U64 memAddr; +#else + U32 memAddr; +#endif + Size reqSz; + Size allocSz; + U16 bktIdx; + U8 moduleId; + U8 bTrcSz; + PTR backTrace; +}MemAllocInfo; + +typedef struct _memLkCb +{ + Bool memLkMdlInit; + FILE *fileLkLog; + MemHash memUsrMdl[CM_MEM_USR_MDL][CM_MAX_HASH_PER_TSK]; +}MemLkCb; + +typedef struct _memUsrMdlStr +{ + Txt *fPStr; + Txt *mdlStr; +}MemUsrMdlStr; + +#ifdef SS_MEM_LEAK_SOL +typedef struct backtrace +{ + Void **bt_buffer; + S32 bt_maxcount; + S32 bt_actcount; +} Backtrace_t; +#endif /* SS_MEM_LEAK_SOL */ + +#endif /* SS_MEM_LEAK_STS */ + +#ifdef T2K_MEM_LEAK_DBG +#define T2K_MEM_LEAK_INFO_TABLE_SIZE 8388606 + /* osCp.wls.allocAddr is the starting address allocated by WLS, + * whenever that changes pleasse change here */ +U64 t2k_MEM_LEAK_START_ADDR; + + +typedef struct _t2kMemLeakInfo +{ + U64 address; /* 0 means it is free */ + U32 size; /* size of the block */ + U32 age; /* in ticks, when it was allocated */ + U32 lineNo; /* lineNo in the file from where allocation was done */ + char* fileName; /* from where allocation was done */ + U32 prevRemLineNo; /* lineNo in the file from where allocation was done */ + char* prevRemFileName; /* from where allocation was done */ + U32 lastDelLineNum; /* lineNo in the file from where allocation was done */ + char* lastDelFileName; /* from where allocation was done */ +}T2kMeamLeakInfo; + +typedef struct _regMemLeakInfo +{ + U32 numActvRegions; + T2kMeamLeakInfo *gMemLeakInfo[SS_MAX_REGS]; /* Allocate using calloc(system Call ) size T2K_MEM_LEAK_INFO_TABLE_SIZE*/ + U64 regStartAddr[SS_MAX_REGS]; /* start Address of Region */ + pthread_mutex_t memLock[SS_MAX_REGS]; /* Region Lock */ +}RegionMemLeakInfo; + +#endif /*T2K_MEM_LEAK_DBG */ + + +/* functions prototypes */ + +EXTERN S16 cmMmRegInit ARGS(( + Region region, + CmMmRegCb *regCb, + CmMmRegCfg *cfg)); +EXTERN S16 cmMmRegDeInit ARGS(( CmMmRegCb *regCb)); + /* cm_mem_x_001.main_11: Additions */ +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL2 +EXTERN Void cmRlsAllocBlk ARGS((CmMmBlkHdr *ptrHdr, CmMmRegCb *regCb)); +EXTERN Void cmStorAllocBlk ARGS((CmMmBlkHdr *ptrHdr, Size reqSz, Size allocSz, + U16 bktIdx, CmMmRegCb *regCb)); +#endif +#ifdef SS_MEM_LEAK_STS +EXTERN Void cmInitMemLeakMdl ARGS((Void)); +/* cm_mem_x_001.main_12 : Additions */ +EXTERN Void cmDeinitMemLeakMdl ARGS((Void)); +#ifdef BIT_64 +EXTERN Void cmStorAllocBlk ARGS((U64 addr, Size reqSz, Size allocSz, + U16 bktIdx)); +EXTERN Void cmRlsAllocBlk ARGS((U64 addr)); +#else +EXTERN Void cmStorAllocBlk ARGS((U32 addr, Size reqSz, Size allocSz, + U16 bktIdx)); +EXTERN Void cmRlsAllocBlk ARGS((U32 addr)); +#endif +EXTERN U8 cmMemGetModuleId ARGS((S8 **funNm, S32 traceSize)); +EXTERN S16 cmMemGetStrMtchIdx ARGS((U8 strtIdx, U8 endIdx, + S8 *str, S8 **strLst)); +EXTERN Void cmMemOpenMemLkFile ARGS((S8 *arg)); +EXTERN Void SLogLkInfo ARGS((Void)); +EXTERN Void SFlushLkInfo ARGS((Void)); + +#ifdef SS_MEM_LEAK_SOL +EXTERN S32 cmAddrToSymStr ARGS((Void *pc, S8 *buffer, S32 size)); +EXTERN S32 cmLeakCallBack ARGS((uintptr_t pc, S32 signo, Void *arg)); +EXTERN S32 backtrace ARGS((Void **buffer, S32 count)); +#endif /* SS_MEM_LEAK_SOL */ + +#endif /* SS_MEM_LEAK_STS */ +/* cm_mem_x_001.main_9 - addition of an API prototype for sanity check */ +#ifdef SSI_DEBUG_LEVEL1 +EXTERN S16 cmMmRegIsBlkSane ARGS((CmMmBlkHdr *blkPtr)); +#endif /* SSI_DEBUG_LEVEL1 */ + +#ifdef BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1 +EXTERN S16 cmMmRegIsBlkSane ARGS((CmMmBlkHdr *blkPtr, Size size)); +#endif +#ifdef SS_HISTOGRAM_SUPPORT +#ifdef SSI_DEBUG_LEVEL1 +EXTERN S16 cmAllocNL ARGS((Void *regionCb, Size *size, U32 flags, Data **ptr, U32 memType, U32 line, U8 *fileName, U8 entId, Bool hstReg)); +#else +EXTERN S16 cmAllocNL ARGS((Void *regionCb, Size *size, U32 flags, Data **ptr, U32 line, U8 *fileName, U8 entId, Bool hstReg)); +#endif +#elif defined(SS_LIGHT_MEM_LEAK_STS) +EXTERN S16 cmAllocNL ARGS((Void *regionCb,Size *size,U32 flags,Data **ptr,U32 memType,U32 lineNo,U8 *funcName)); +#else +#if (defined(SSI_DEBUG_LEVEL1) || defined(BRDCM_SSI_MEM_LEAK_DEBUG_LEVEL1)) +EXTERN S16 cmAllocNL ARGS((Void *regionCb, Size *size, U32 flags, Data **ptr, U32 memType)); +#else +EXTERN S16 cmAllocNL ARGS((Void *regionCb, Size *size, U32 flags, Data **ptr)); +#endif +#endif + +#ifdef SS_HISTOGRAM_SUPPORT +EXTERN S16 cmFreeNL ARGS((Void *regionCb, Data *ptr, Size size, U32 line, U8 *fileName, U8 entId, Bool hstReg)); +#elif defined(SS_LIGHT_MEM_LEAK_STS) +EXTERN S16 cmFreeNL ARGS((Void *regionCb,Data *ptr, Size size,U32 lineNo,U8 *funcName)); +#else +EXTERN S16 cmFreeNL ARGS((Void *regionCb, Data *ptr, Size size)); +#endif + +#ifdef __cplusplus +} +#endif + +#endif + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/cm/cm_mem_wl.c b/src/cm/cm_mem_wl.c new file mode 100755 index 000000000..302cce375 --- /dev/null +++ b/src/cm/cm_mem_wl.c @@ -0,0 +1,7613 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + + +/********************************************************************20** + + Name: Common Memory Manager + + Type: C source file + + Desc: C source code for the Commom Memory Manager module. + + File: cm_mem_wl.c + +*********************************************************************21*/ + + +/************************************************************************ + +The following functions are provided in this file. + + cmMmRegInit Memory Region Initialization. + cmMmRegDeInit Memory Region Deinitialization. + +************************************************************************/ + +#ifndef SS_RBUF + +/* header include files (.h) */ +#include "envopt.h" /* environment options */ +#include "envdep.h" /* environment dependent */ +#include "envind.h" /* environment independent */ + +#include "gen.h" /* general */ +#include "ssi.h" /* system services */ +#include "cm_mem.h" /* Common memory manager cm_mem_c_001.main_15 */ +#include +#ifdef SS_MEM_LEAK_STS +#include +#include +#ifdef SS_MEM_LEAK_SOL +#include +#include +#include +#else /* SS_MEM_LEAK_SOL */ +#include +#endif /* SS_MEM_LEAK_SOL */ +#include +#endif /* SS_MEM_LEAK_STS */ +#include "cm_hash.h" + +#ifdef SS_MULTICORE_SUPPORT /* cm_mem_c_001.main_14 */ +#include "ss_dep.h" /* implementation-specific */ +#include "ss_queue.h" /* queues */ +#include "ss_task.h" /* tasking */ +#endif +#ifdef SS_MULTICORE_SUPPORT +#include "ss_dep.h" /* implementation-specific */ +#include "ss_queue.h" /* queues */ +#include "ss_task.h" /* tasking */ +#endif +#include "cm_llist.h" + +/* header/extern include files (.x) */ +#include "gen.x" /* general */ +#include "ssi.x" /* system services */ +#ifdef SS_MULTICORE_SUPPORT +#include "ss_dep.x" /* implementation-specific */ +#include "ss_queue.x" /* queues */ +#include "ss_task.x" /* system services */ +#endif +#include "cm_hash.x" /* common hash functions */ +#include "cm_llist.x" +#include "cm_mem_wl.x" /* Common memory manager */ +/* cm_mem_c_001.main_15: Addition */ +#include "cm_lib.x" /* common library functions */ + + +#ifdef USE_PURE +#include +#endif /* USE_PURE */ +#ifdef SS_MULTICORE_SUPPORT +#include "ss_dep.x" /* implementation-specific */ +#include "ss_queue.x" /* queues */ +#include "ss_task.x" /* system services */ +#endif + +#ifdef USE_PURE +#include +#endif /* USE_PURE */ + +#include +#include +#include +#include + +#ifdef SS_USE_ICC_MEMORY +#include "icc_lib.h" +#endif /* SS_USE_ICC_MEMORY */ + +#ifdef L2_L3_SPLIT +#include "mt_plat_t33.h" +extern S32 clusterMode; +#endif + +#include "cm_lte.x" + + +/* local defines */ +/*ccpu00142274 - UL mem based flow control changes */ +#ifdef TENB_T2K3K_SPECIFIC_CHANGES +/* selva */ +U32 gMemoryAlarm; +PRIVATE U32 memoryCheckCounter; + +#define NUM_CALLS_TO_CHECK_MEM_AGAIN 80 /* Number of calls after which need to check mem */ +#ifndef L2_L3_SPLIT +#ifdef T2200_2GB_DDR_CHANGES +#define ICC_MEM_UPPER_THRESHOLD 20 /* Only 20% of the available memory blocks are free */ +#define ICC_MEM_LOWER_THRESHOLD 10 /* Only 10% of the available memory blocks are free */ +#else +#define ICC_MEM_UPPER_THRESHOLD 10 /* Only 20% of the available memory blocks are free */ +#define ICC_MEM_LOWER_THRESHOLD 8 /* Only 10% of the available memory blocks are free */ +#endif +#else +#define ICC_MEM_UPPER_THRESHOLD 9 /* Only 20% of the available memory blocks are free */ +#define ICC_MEM_LOWER_THRESHOLD 12 /* Only 30% of the available memory blocks are free */ +#endif +#define ICC_POOL_ZERO_SIZE 384 +#define ICC_POOL_ONE_SIZE 1920 +#define ICC_POOL_TWO_SIZE 3968 +#ifdef T2200_2GB_DDR_CHANGES +#define ICC_POOL_THREE_SIZE 16256 +#else +#define ICC_POOL_THREE_SIZE 8064 +#endif +#ifndef L2_L3_SPLIT +#ifdef T2200_2GB_DDR_CHANGES +#define ICC_POOL_ZERO_TOTAL_BLKS 139809 /* this and the next should be dynamic*/ +#define ICC_POOL_ONE_TOTAL_BLKS 209714 +#define ICC_POOL_TWO_TOTAL_BLKS 27961 +#define ICC_POOL_THREE_TOTAL_BLKS 27961 +#else +#define ICC_POOL_ZERO_TOTAL_BLKS 55106 /* this and the next should be dynamic*/ +#define ICC_POOL_ONE_TOTAL_BLKS 68567 +#define ICC_POOL_TWO_TOTAL_BLKS 13819 +#define ICC_POOL_THREE_TOTAL_BLKS 10902 +#endif +#else +/* The below configuration used for icc_part_size=573M in boot args, if icc part + * size changes then need to change the below configuration values*/ +#ifndef LTE_ADV +#define ICC_POOL_ZERO_TOTAL_BLKS 78232 +#define ICC_POOL_ONE_TOTAL_BLKS 117349 +#define ICC_POOL_TWO_TOTAL_BLKS 15645 +#define ICC_POOL_THREE_TOTAL_BLKS 15645 +#else +#define ICC_POOL_ZERO_TOTAL_BLKS 79437 +#define ICC_POOL_ONE_TOTAL_BLKS 80009 +#define ICC_POOL_TWO_TOTAL_BLKS 16864 +#define ICC_POOL_THREE_TOTAL_BLKS 11970 +#endif +#endif +#endif + +/* local typedefs */ + +/* local externs */ + +/* forward references */ +/* cm_mem_c_001.main_12 - prototype is changed to accept memType(static/dynamic) */ +/* cm_mem_c_001.main_15: Addition */ +/* cm_mem_c_001.main_22: Fixing warnings on GCC compiler*/ +#ifdef __cplusplus + extern "C" { +#endif + +CmHashListCp memDoubleFree; /* Added to find the double free */ +SLockId memDoubleFreeLock; +#define NUM_BT_TRACES 12 +typedef struct cmMemFreeInfo +{ + PTR ptr; + size_t btSize; + void *btArr[NUM_BT_TRACES]; + struct timeval timeStamp; + +} CmMemFreeInfo; + +#define NUM_FREE_BUFFERS 128 +typedef struct cmBtInfo +{ + U32 btInfoIdx; + CmMemFreeInfo btInfo[NUM_FREE_BUFFERS]; +} CmBtInfo; + +CmBtInfo *regBtInfo; +CmBtInfo *allocBtInfo; + +typedef struct cmMemDoubleFree +{ + CmHashListEnt tmpListEnt; + CmMemFreeInfo traceInfo; + PTR memBlkPtr; +}CmMemDoubleFree; + +PTR prvAllocPtr[8]; +PUBLIC U8 stopBtInfo = FALSE; +PUBLIC Buffer *palBuffer; +EXTERN Buffer *mtTskBuffer1; +EXTERN Buffer *mtTskBuffer2; + +#ifdef SS_USE_ICC_MEMORY +PRIVATE pthread_mutex_t iccAllocFreeLock; +#else +PRIVATE pthread_mutex_t dynAllocFreeLock; +#endif /* SS_USE_ICC_MEMORY */ + +#ifdef SS_MEM_WL_DEBUG +PRIVATE S16 cmInitBtInfo ARGS((void)); +#endif + +#ifdef SS_USE_ICC_MEMORY +#ifdef T2K_MEM_LEAK_DBG +PRIVATE S16 cmIccAlloc ARGS((Void *regionCb, Size *size, U32 flags, Data **ptr, char*, U32)); +PRIVATE S16 cmIccFree ARGS((Void *regionCb, Data *ptr, Size size,char*, U32)); +PRIVATE S16 cmIccAllocWithLock ARGS((Void *regionCb, Size *size, U32 flags, Data **ptr, char*, U32)); +PRIVATE S16 cmIccFreeWithLock ARGS((Void *regionCb, Data *ptr, Size size,char*, U32)); +PUBLIC void InsertToT2kMemLeakInfo ARGS((U32 address, U32 size, U32 lineNo, char* fileName)); +void RemoveFromT2kMemLeakInfo ARGS((U32 address, char *file, U32 line)); +PRIVATE U32 getT2kMemLeakIndex ARGS((U32 address)); +#else +PRIVATE S16 cmIccAlloc ARGS((Void *regionCb, Size *size, U32 flags, Data **ptr)); +PRIVATE S16 cmIccFree ARGS((Void *regionCb, Data *ptr, Size size)); +PRIVATE S16 cmIccAllocWithLock ARGS((Void *regionCb, Size *size, U32 flags, Data **ptr)); +PRIVATE S16 cmIccFreeWithLock ARGS((Void *regionCb, Data *ptr, Size size)); +#endif +#else /* SS_USE_ICC_MEMORY */ +PRIVATE S16 cmDynAllocWithLock ARGS((Void *regionCb,Size *size,U32 flags,Data **ptr)); +PRIVATE S16 cmDynFreeWithLock ARGS((Void *regionCb,Data *ptr, Size size)); +PRIVATE S16 cmDynAlloc ARGS((Void *regionCb,Size *size,U32 flags,Data **ptr)); +PRIVATE S16 cmDynFree ARGS((Void *regionCb,Data *ptr, Size size)); +#endif /* SS_USE_ICC_MEMORY */ + + +#ifdef T2K_MEM_LEAK_DBG +PRIVATE S16 cmAllocWL ARGS((Void *regionCb, Size *size, U32 flags, Data **ptr,char*,U32)); +PRIVATE S16 cmFreeWL ARGS((Void *regionCb, Data *ptr, Size size,char*, U32)); + +PRIVATE S16 cmAlloc ARGS((Void *regionCb, Size *size, U32 flags, Data **ptr,char*,U32)); +PRIVATE S16 cmFree ARGS((Void *regionCb, Data *ptr, Size size,char*, U32)); +#else +PRIVATE S16 cmAllocWL ARGS((Void *regionCb, Size *size, U32 flags, Data **ptr)); +PRIVATE S16 cmFreeWL ARGS((Void *regionCb, Data *ptr, Size size)); + +PRIVATE S16 cmAlloc ARGS((Void *regionCb, Size *size, U32 flags, Data **ptr)); +PRIVATE S16 cmFree ARGS((Void *regionCb, Data *ptr, Size size)); +#endif +#ifdef T2K_MEM_LEAK_DBG +PRIVATE S16 cmAllocWL ARGS((Void *regionCb, Size *size, U32 flags, Data **ptr,char*,U32)); +PRIVATE S16 cmFreeWL ARGS((Void *regionCb, Data *ptr, Size size,char*, U32)); +#else +PRIVATE S16 cmAllocWL ARGS((Void *regionCb, Size *size, U32 flags, Data **ptr)); +PRIVATE S16 cmFreeWL ARGS((Void *regionCb, Data *ptr, Size size)); +#endif +#ifndef USE_PURE +PRIVATE S16 cmHeapAlloc ARGS((CmMmHeapCb *heapCb, Data **ptr, Size *size)); +PRIVATE S16 cmHeapFree ARGS((CmMmHeapCb *heapCb, Data *ptr, Size size)); +#endif +PRIVATE S16 cmCtl ARGS((Void *regionCb, Event event, SMemCtl *memCtl)); +PRIVATE Void cmMmHeapInit ARGS((Data *memAddr, CmMmHeapCb *heapCb, Size size)); +#if 0 +#ifdef SS_HISTOGRAM_SUPPORT +#ifdef SSI_DEBUG_LEVEL1 +PRIVATE S16 cmAlloc ARGS((Void *regionCb, Size *size, U32 flags, Data **ptr, + U32 memType, U32 line, U8 *fileName, U8 entId, Bool hstReg)); +PRIVATE S16 cmHeapAlloc ARGS((CmMmHeapCb *heapCb, Data **ptr, Size *size, U32 memType, U32 line, U8 *fileName, U8 entId, Bool hstReg)); +/*cm_mem_c_001.main_20-added new functionto allocate memory from new region*/ +#else +PRIVATE S16 cmHeapAlloc ARGS((CmMmHeapCb *heapCb, Data **ptr, Size *size, + U32 line, U8 *fileName, U8 entId, Bool hstReg)); +PRIVATE S16 cmAlloc ARGS((Void *regionCb, Size *size, U32 flags, Data **ptr, + U32 line, U8 *fileName, U8 entId, Bool hstReg)); +#endif /* SSI_DEBUG_LEVEL1 */ + +PRIVATE S16 cmFree ARGS((Void *regionCb, Data *ptr, Size size, U32 line, + U8 *fileName, U8 entId, Bool hstReg)); + +PRIVATE S16 cmHeapFree ARGS((CmMmHeapCb *heapCb, Data *ptr, Size size, + U32 line, U8 *fileName, U8 entId, Bool hstReg)); +#else /* no histogram support */ +/* cm_mem_c_001.main_12 - prototype is changed to accept memType(static/dynamic) */ +#ifdef SSI_DEBUG_LEVEL1 +PRIVATE S16 cmHeapAlloc ARGS((CmMmHeapCb *heapCb, Data **ptr, Size *size, U32 memType)); +#else +PRIVATE S16 cmHeapAlloc ARGS((CmMmHeapCb *heapCb, Data **ptr, Size *size)); +#endif /* SSI_DEBUG_LEVEL1 */ +PRIVATE S16 cmHeapFree ARGS((CmMmHeapCb *heapCb, Data *ptr, Size size)); +/* cm_mem_c_001.main_15 :Additions */ +#ifdef SSI_DEBUG_LEVEL1 +PRIVATE S16 cmAlloc ARGS((Void *regionCb, Size *size, U32 flags, Data **ptr, U32 memType)); +#else +PRIVATE S16 cmAlloc ARGS((Void *regionCb, Size *size, U32 flags, Data **ptr)); +#endif /* SSI_DEBUG_LEVEL1 */ +PRIVATE S16 cmFree ARGS((Void *regionCb, Data *ptr, Size size)); +#endif /* SS_HISTOGRAM_SUPPORT */ + +/*cm_mem_c_001.main_23 Removed support of SSI_DEBUG_LEVEL1 and SS_HISTOGRAM_SUPPORT for SS_FAP*/ +#ifdef SS_FAP +PRIVATE S16 cmAllocWL ARGS((Void *regionCb, Size *size, U32 flags, Data **ptr)); +PRIVATE S16 cmFreeWL ARGS((Void *regionCb, Data *ptr, Size size)); +#endif + + +PRIVATE Void cmMmBktInit ARGS((Data **memAddr, CmMmRegCb *regCb, + CmMmRegCfg *cfg, U16 bktIdx, U16 *lstMapIdx)); + +/* cm_mem_c_001.main_12 - addition of protoypes for sanity check and hash list functions */ +#ifdef SSI_DEBUG_LEVEL1 +PRIVATE S16 cmMmBktSanityChk ARGS((CmMmBkt *bkt)); +PRIVATE S16 cmMmHeapSanityChk ARGS((CmMmHeapCb *heapCb)); +PRIVATE S16 cmMmHashFunc ARGS((CmMmHashListCp *hashListCp, U32 key, U16 *idx )); +PRIVATE S16 cmMmHashListInit ARGS((CmMmHashListCp *hashListCp, U16 nmbBins, + Region region, Pool pool)); +PRIVATE S16 cmMmHashListDeinit ARGS((CmMmHashListCp *hashListCp, Region region, Pool pool)); +PRIVATE S16 cmMmHashListInsert ARGS((CmMmHashListCp *hashListCp, U32 key)); +#endif /* SSI_DEBUG_LEVEL1 */ +/* cm_mem_c_001.main_15 : Addtions */ +#ifdef SS_HISTOGRAM_SUPPORT +PRIVATE S16 cmHstGrmAllocInsert ARGS((CmHstGrmHashListCp *hashListCp, U32 blkSz, U32 *reqSz, U32 line, U8 *fileName, U8 entId)); +PRIVATE S16 cmHstGrmFreeInsert ARGS((CmHstGrmHashListCp* hashListCp, U32 blkSz, U32 line, U8 *fileName, U8 entId)); +PRIVATE S16 cmHstGrmHashListInit ARGS((CmHstGrmHashListCp *hashListCp)); +PRIVATE S16 cmHstGrmHashListDeInit ARGS((CmHstGrmHashListCp *hashListCp)); +PRIVATE S16 cmHstGrmGetHashIdxAndKey ARGS((U8 *fileName, U32 line, U32 *binIdx, U32 *key)); +PRIVATE S16 cmHstGrmFindEntry ARGS((CmHstGrmHashListCp *hashListCp, U32 key, U32 *binIdx, CmMemEntries **entry)); +PRIVATE S16 cmHstGrmFillEntry ARGS((CmMemEntries *entry, U32 key, U32 line, U8 *fileName, U8 entId)); +#endif /* SS_HISTOGRAM_SUPPORT */ +#endif + +/* cm_mem_c_001.main_22: Fixing warnings on GCC compiler */ +#ifdef __cplusplus +} +#endif + +/* public variable declarations */ +#ifdef USE_PURE +Size avail_size; +#endif /* USE_PURE */ +/* cm_mem_c_001.main_15:Additions */ +#ifdef SS_MEM_LEAK_STS +MemUsrMdlStr memUsrMdlStr[]= +{ + MEMRAW2STR(DEFAULT, STACK), + MEMRAW2STR(tc, PDCP_LAYER), + MEMRAW2STR(Tc, PDCP_LAYER), + MEMRAW2STR(mg, GCP_LAYER), + MEMRAW2STR(Mg, GCP_LAYER), + {NULLP, NULLP} +}; + +MemLkCb memLkCb; +#endif /* SS_MEM_LEAK_STS */ + +/* cm_mem_c_008.104 - Addition for memory calculator tool */ +#ifdef MEMCAL_DEBUG +PRIVATE Txt prntBuf[200]; /* print buffer */ +PRIVATE U8 tryHeap=0; +#endif + +/* cm_mem_c_001.main_12 - addition for ssi enhancements prints */ +/* cm_mem_c_001.main_20 Additions */ +#if (defined(SSI_DEBUG_LEVEL1) || defined(SS_HISTOGRAM_SUPPORT)) +#ifdef DEBUGP +PRIVATE Txt dbgPrntBuf[200]; /* print buffer */ +#endif /* DEBUGP */ +#endif /*SSI_DEBUG_LEVEL1 || SS_HISTOGRAM_SUPPORT */ + +#ifdef T2K_MEM_LEAK_DBG + /* convert to decimal (0x(end_addr - start_addr)>>8)*2 */ +#define T2K_MEM_LEAK_INFO_TABLE_SIZE 3670014 /* New Sercomm Board*/ +//#define T2K_MEM_LEAK_INFO_TABLE_SIZE 3145726 /*Old Sercomm Board*/ + /* 0x94200000 is the starting address allocated by ICC, + * whenever that changes pleasse change here */ +//#define T2K_MEM_LEAK_START_ADDR 0x9d400000 /*Old Sercomm Board*/ +#define T2K_MEM_LEAK_START_ADDR 0x9d200000 /*New Sercomm Board*/ +#endif + +U32 num_times = 0; +EXTERN pthread_t tmpRegTidMap[20]; +#if 0 +EXTERN pthread_t tmpMainTid; +#endif +extern Bool g_usettitmr; +PUBLIC void DumpLayersDebugInformation() +{ + DumpSSIDemandQDebugInformation(); + /* dump layers information only after we start receiving the TTIs */ + if(g_usettitmr) + { +#ifdef L2_L3_SPLIT + if (clusterMode == RADIO_CLUSTER_MODE) + { + DumpRLCDlDebugInformation(); + +#ifndef UL_RLC_NET_CLUSTER + DumpRLCUlDebugInformation(); +#endif + printSchCellInfo(); + } + else + { +#ifdef UL_RLC_NET_CLUSTER + DumpRLCUlDebugInformation(); +#endif + DumpPDCPDlDebugInformation(); + DumpPDCPUlDebugInformation(); + } +#else + //DumpPDCPDlDebugInformation(); + //DumpPDCPUlDebugInformation(); + DumpRLCDlDebugInformation(); + DumpRLCUlDebugInformation(); + //printSchCellInfo(); +#endif + } +} + +/* private variable declarations */ +/* +* +* Fun: cmMmStatBktInit +* +* Desc: Initialize the bucket and the map table. +* +* +* Ret: ROK - successful, +* RFAILED - unsuccessful. +* +* Notes: This function is called by the cmMmRegInit. +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PRIVATE Void cmMmStatBktInit +( +Data **memAddr, +CmMmRegCb *regCb, +CmMmRegCfg *cfg, +U16 bktIdx, +U16 *lstMapIdx +) +#else +PRIVATE Void cmMmStatBktInit (memAddr, regCb, cfg, bktIdx, lstMapIdx) +Data **memAddr; +CmMmRegCb *regCb; +CmMmRegCfg *cfg; +U16 bktIdx; +U16 *lstMapIdx; +#endif +{ + U32 cnt; + U16 idx; + U32 numBlks; + Size size; +/* cm_mem_c_001.main_12 - addition for temporary variables */ +#ifdef SSI_DEBUG_LEVEL1 + CmMmBlkHdr **nextBlk; + U32 sigCnt; +#else + Data **next; +#endif /* SSI_DEBUG_LEVEL1 */ + + TRC2(cmMmStatBktInit); + + + size = cfg->bktCfg[bktIdx].size; + numBlks = cfg->bktCfg[bktIdx].numBlks; + +/* cm_mem_c_001.main_12 - addition for header initialization */ +#ifdef SSI_DEBUG_LEVEL1 + /* Reset the next block pointer */ + regCb->bktTbl[bktIdx].nextBlk = NULLP; + + /* Initialize the link list of the memory block */ + nextBlk = &(regCb->bktTbl[bktIdx].nextBlk); + + for (cnt = 0; cnt < numBlks; cnt++) + { + *nextBlk = (CmMmBlkHdr *)*memAddr; + + /* initialize the memory block header */ + for (sigCnt=0; sigCnt < CMM_TRAMPLING_SIGNATURE_LEN; sigCnt++) + { + (*nextBlk)->trSignature[sigCnt] = 0xAB; + } + + CMM_SET_FREE_FLAG((*nextBlk)->memFlags); + (*nextBlk)->requestedSize = 0; + *memAddr = (Data *)((*memAddr) + ((sizeof(CmMmBlkHdr)) + size)); + nextBlk = &((*nextBlk)->nextBlk); + } + + *nextBlk = NULLP; + +#else + /* Initialize the bucket linked list */ + + /* Reset the next pointer */ + regCb->bktTbl[bktIdx].next = NULLP; + + /* Initialize the link list of the memory block */ + next = &(regCb->bktTbl[bktIdx].next); + for (cnt = 0; cnt < numBlks; cnt++) + { + *next = *memAddr; + next = (CmMmEntry **)(*memAddr); + *memAddr = (*memAddr) + size; + + } + *next = NULLP; + +#endif /* SSI_DEBUG_LEVEL1 */ + + /* Initialize the Map entry */ + idx = size / cfg->bktQnSize; + + /* + * Check if the size is multiple of quantum size. If not we need to initialize + * one more map table entry. + */ + if(size % cfg->bktQnSize) + { + idx++; + } + + while ( *lstMapIdx < idx) + { + regCb->mapTbl[*lstMapIdx].bktIdx = bktIdx; + +#if (ERRCLASS & ERRCLS_DEBUG) + regCb->mapTbl[*lstMapIdx].numReq = 0; + regCb->mapTbl[*lstMapIdx].numFailure = 0; +#endif + + (*lstMapIdx)++; + } + + /* Initialize the bucket structure */ + regCb->bktTbl[bktIdx].size = size; + regCb->bktTbl[bktIdx].numBlks = numBlks; + regCb->bktTbl[bktIdx].numAlloc = 0; + regCb->bktTbl[bktIdx].maxAlloc = 0; + + /* Update the total bucket size */ +/* cm_mem_c_001.main_12 - addition for considering the header size */ +#ifdef SSI_DEBUG_LEVEL1 + regCb->bktSize += ((size + sizeof(CmMmBlkHdr)) * numBlks); +#else + regCb->bktSize += (size * numBlks); +#endif /* SSI_DEBUG_LEVEL1 */ + + regCb->bktTbl[bktIdx].bktFailCnt = 0; + regCb->bktTbl[bktIdx].bktNoFitCnt = 0; + +/* cm_mem_c_001.main_12 - addition for statistics related variable initialization */ +#ifdef SSI_DEBUG_LEVEL1 + /* Initialize other required pointers */ + regCb->bktTbl[bktIdx].bktStartPtr = (Data *)(regCb->bktTbl[bktIdx].nextBlk); + regCb->bktTbl[bktIdx].numAllocAttempts = 0; + regCb->bktTbl[bktIdx].numDeallocAttempts = 0; + regCb->bktTbl[bktIdx].staticMemUsed = 0; + regCb->bktTbl[bktIdx].dynamicMemUsed = 0; + regCb->bktTbl[bktIdx].trampleCount = 0; +#endif /*SSI_DEBUG_LEVEL1*/ +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + /* Initialise the memory histogram hash list */ + cmHstGrmHashListInit(&(regCb->bktTbl[bktIdx].hstGrmHashListCp)); +#endif /* SS_HISTOGRAM_SUPPORT */ + + RETVOID; +} /* end of cmMmStatBktInit */ + +/* +* +* Fun: cmMmStatRegInit +* +* Desc: Configure the memory region for allocation. The function +* registers the memory region with System Service by calling +* SRegRegion. +* +* +* Ret: ROK - successful, +* RFAILED - unsuccessful. +* +* Notes: The memory owner calls this function to initialize the memory +* manager with the information of the memory region. Before +* calling this function, the memory owner should allocate memory +* for the memory region. The memory owner should also provide the +* memory for the control block needed by the memory manager. The +* memory owner should allocate the memory for the region control +* block as cachable memory. This may increase the average +* throughput in allocation and deallocation as the region control +* block is mostly accessed by the CMM. +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmMmStatRegInit +( +Region region, +CmMmRegCb *regCb, +CmMmRegCfg *cfg +) +#else +PUBLIC S16 cmMmStatRegInit(region, regCb, cfg) +Region region; +CmMmRegCb *regCb; +CmMmRegCfg *cfg; +#endif +{ + Data *memAddr; + U16 bktIdx; + U16 lstMapIdx; + +#if (ERRCLASS & ERRCLS_INT_PAR) + Size lstQnSize; + Size bktBlkSize; + Txt errMsg[256] = {'\0'}; +#endif + + TRC2(cmMmRegInit); + +#if (ERRCLASS & ERRCLS_INT_PAR) + + /* error check on parameters */ + if ((regCb == NULLP) || (cfg == NULLP)) + { + RETVALUE(RFAILED); + } + + /* Error check on the configuration fields */ + if ((!cfg->size) || (cfg->vAddr == NULLP) || + (cfg->numBkts > CMM_MAX_BKT_ENT)) + { + RETVALUE(RFAILED); + } + /* Check if the quantum size is power of 2 */ + if ((cfg->numBkts) && + ((cfg->bktQnSize - 1) & (cfg->bktQnSize))) + { + /* cm_mem_c_001.main_20 Addition */ + sprintf(errMsg,"\n cmMmRegInit() failed, check if BktQuantum size might not be power of 2 \n"); + SPrint(errMsg); + RETVALUE(RFAILED); + } + + /* + * Check if the size of the memory region is enough, whether bucket sizes + * are multiples of quantumn size, and also whether two consecutive buckets + * falls within same quanta. + */ + lstQnSize = cfg->bktQnSize; + regCb->bktSize = 0; + + for ( bktIdx =0; bktIdx < cfg->numBkts; bktIdx++) + { + /* check if bucket size is mutiple of quantum size */ + if (cfg->bktCfg[bktIdx].size % cfg->bktQnSize) + { + /* cm_mem_c_001.main_20 Addition */ +/*cm_mem_c_001.main_23 Fix for specifier mismatch warnings in 64BIT compilation*/ +#ifdef ALIGN_64BIT + sprintf(errMsg,"\n cmMmRegInit() failed, Bkt:%d size:%u not multiple of quantum size:%u\ + \n",bktIdx,cfg->bktCfg[bktIdx].size,cfg->bktQnSize); +#else + sprintf(errMsg,"\n cmMmRegInit() failed, Bkt:%d size:%lu not multiple of quantum size:%lu\ + \n",bktIdx,cfg->bktCfg[bktIdx].size,cfg->bktQnSize); +#endif + SPrint(errMsg); + RETVALUE(RFAILED); + } + + if ((bktBlkSize = cfg->bktCfg[bktIdx].size) < lstQnSize) + { + /* + * Two consecutive buckets are not separated by quantum size. + */ + /* cm_mem_c_001.main_20 Addition */ + sprintf(errMsg,"\n cmMmRegInit() failed, Two consecutive buckets are not separated by quantum size \n"); + SPrint(errMsg); + RETVALUE(RFAILED); + } + /* cm_mem_c_001.main_20 Addition */ + if (((cfg->bktCfg[bktIdx].size) /\ + cfg->bktQnSize) > CMM_MAX_MAP_ENT) + { + /* Error check whether the size of the mapping table is sufficient */ +/*cm_mem_c_001.main_23 Fix for specifier mismatch warnings in 64BIT compilation*/ +#ifdef ALIGN_64BIT + sprintf(errMsg,"\n cmMmRegInit() failed, check maxBucketSize/BktQuantumSize(%u)\ + \n should be less than CMM_MAX_MAP_ENT:%d \n",cfg->bktQnSize,CMM_MAX_MAP_ENT); +#else + sprintf(errMsg,"\n cmMmRegInit() failed, check maxBucketSize/BktQuantumSize(%lu)\ + \n should be less than CMM_MAX_MAP_ENT:%d \n",cfg->bktQnSize,CMM_MAX_MAP_ENT); +#endif + SPrint(errMsg); + RETVALUE(RFAILED); + } + + + regCb->bktSize += (cfg->bktCfg[bktIdx].size * + cfg->bktCfg[bktIdx].numBlks); + + if (regCb->bktSize > cfg->size) + { + /* Size of the memory region is less than the required size */ + + sprintf(errMsg,"\n cmMmRegInit() failed, Size of the memory region is less than the required size \n"); + SPrint(errMsg); + RETVALUE(RFAILED); + } + + lstQnSize = ((bktBlkSize / cfg->bktQnSize) + 1) * cfg->bktQnSize; + } + +#endif + + /* Initialize the region control block */ + regCb->region = region; + regCb->regInfo.regCb = regCb; + regCb->regInfo.start = cfg->vAddr; + regCb->regInfo.size = cfg->size; + +#ifdef USE_PURE + avail_size = cfg->size; +#endif /* USE_PURE */ + + if ( cfg->chFlag & CMM_REG_OUTBOARD) + { + /* Out_of_board memory */ + regCb->regInfo.flags = CMM_REG_OUTBOARD; + } + else + { + regCb->regInfo.flags = 0; + } + + +#if 1 + if(region == SS_MAX_REGS - 1) + { + regCb->regInfo.alloc = cmAlloc; + regCb->regInfo.free = cmFree; + regCb->regInfo.ctl = cmCtl; + } + else + { + regCb->regInfo.alloc = cmAllocWL; + regCb->regInfo.free = cmFreeWL; + regCb->regInfo.ctl = cmCtl; + } +#else + regCb->regInfo.alloc = cmAlloc; + regCb->regInfo.free = cmFree; + regCb->regInfo.ctl = cmCtl; +#endif + + /* Initialize the physical address */ + if ((regCb->chFlag = cfg->chFlag) & CMM_REG_PHY_VALID) + { + regCb->pAddr = cfg->pAddr; + } + + /* Initial address of the memory region block */ + memAddr = cfg->vAddr; + + /* Initialize the fields related to the bucket pool */ + regCb->bktMaxBlkSize = 0; + regCb->bktSize = 0; + + if (cfg->numBkts) + { + /* Last bucket has the maximum size */ + regCb->bktMaxBlkSize = cfg->bktCfg[cfg->numBkts - 1].size; + + /* Get the power of the bktQnSize */ + regCb->bktQnPwr = 0; + while( !((cfg->bktQnSize >> regCb->bktQnPwr) & 0x01)) + { + regCb->bktQnPwr++; + } + + /* Initilaize the bktIndex of the map entries to FF */ + for ( lstMapIdx = 0; lstMapIdx < CMM_MAX_MAP_ENT; lstMapIdx++) + { + regCb->mapTbl[lstMapIdx].bktIdx = 0xFF; + } + + lstMapIdx = 0; + for ( bktIdx = 0; bktIdx < cfg->numBkts; bktIdx++) + { + /* Allocate the lock for the bucket pool */ + cmMmStatBktInit( &memAddr, regCb, cfg, bktIdx, &lstMapIdx); + } + + /* Used while freeing the bktLock in cmMmRegDeInit */ + regCb->numBkts = cfg->numBkts; + } + + /* + * Initialize the heap pool if size the memory region region is more + * than the size of the bucket pool + */ + regCb->heapSize = 0; + regCb->heapFlag = FALSE; + + /* Align the memory address */ + memAddr = (Data *)(PTRALIGN(memAddr)); + + regCb->heapSize = cfg->vAddr + cfg->size - memAddr; + + /* + * Round the heap size so that the heap size is multiple + * of CMM_MINBUFSIZE + */ + regCb->heapSize -= (regCb->heapSize % CMM_MINBUFSIZE); + + if (regCb->heapSize) + { + /* Allocate the lock for the heap pool */ + regCb->heapFlag = TRUE; + cmMmHeapInit(memAddr, &(regCb->heapCb), regCb->heapSize); + } + + /* Call SRegRegion to register the memory region with SSI */ + if (SRegRegion(region, ®Cb->regInfo) != ROK) + { + RETVALUE(RFAILED); + } + + RETVALUE(ROK); +} /* end of cmMmRegInit*/ + +#if 0 +/* +* +* Fun: ssPutDynBufSet +* +* Desc: Puts the set of dynamic buffers into the global region +* +* +* Ret: ROK - successful, +* RFAILED - unsuccessful. +* +* Notes: +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PUBLIC S16 ssPutDynBufSet +( +U8 bktIdx, +CmMmBktLstCb *bktLstCb +) +#else +PUBLIC S16 ssPutDynBufSet(bktIdx, bktLstCb) +U8 bktIdx; +CmMmBktLstCb *bktLstCb; +#endif +{ + CmMmGlobRegCb *globReg; + CmMmDynBktCb *bktCb; + + TRC1(ssPutDynBufSet); + + globReg = &osCp.globRegCb; + + if(bktIdx > CMM_MAX_BKT_ENT) + { + RETVALUE(RFAILED); + } + + bktCb = &(globReg->bktTbl[bktIdx]); + + /* Lock the global region first */ + SLock(&(globReg->regLock)); + + cmLListAdd2Tail(&(bktCb->listBktSet), bktLstCb); + + SUnlock(&(globReg->regLock)); + + RETVALUE(ROK); +} + +/* +* +* Fun: ssGetDynBufSet +* +* Desc: Gets the set of dynamic buffers into the global region +* +* +* Ret: ROK - successful, +* RFAILED - unsuccessful. +* +* Notes: +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PUBLIC S16 ssGetDynBufSet +( +U8 bktIdx, +CmMmBktLstCb **bktLstCb +) +#else +PUBLIC S16 ssGetDynBufSet(bktIdx, bktLstCb) +U8 bktIdx; +CmMmBktLstCb **bktLstCb; +#endif +{ + CmMmGlobRegCb *globReg; + CmMmDynBktCb *bktCb; + CmLList *lstNode; + + TRC1(ssGetDynBufSet); + + globReg = &osCp.globRegCb; + + if(bktIdx > CMM_MAX_BKT_ENT) + { + RETVALUE(RFAILED); + } + + *bktLstCb = NULLP; + bktCb = &(globReg->bktTbl[bktIdx]); + + /* Lock the global region first */ + SLock(&(globReg->regLock)); + + lstNode = cmLListFirst(&(bktCb->listBktSet)); + + if(lstNode == NULLP) + { + SUnlock(&(globReg->regLock)); + RETVALUE(RFAILED); + } + + cmLListDelFrm(&(bktCb->listBktSet), lstNode); + SUnlock(&(globReg->regLock)); + + *bktLstCb = (CmMmBktLstCb *)lstNode->node; + + RETVALUE(ROK); +} +#endif + + +/* +* +* Fun: cmMmGlobRegInit +* +* Desc: Configure the memory region for allocation. The function +* registers the memory region with System Service by calling +* SRegRegion. +* +* +* Ret: ROK - successful, +* RFAILED - unsuccessful. +* +* Notes: +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmMmGlobRegInit +( +CmMmGlobRegCb *regCb +) +#else +PUBLIC S16 cmMmGlobRegInit(regCb) +CmMmGlobRegCb *regCb; +#endif +{ + Data **memAddr; + Data **next; + U16 bktIdx; + U16 bucketSetSize; + U16 cnt; + Size size; + CmMmBlkSetElement *blkLstElem; + U16 numBlks; + +#if (ERRCLASS & ERRCLS_INT_PAR) + Size lstQnSize; + Size bktBlkSize; + Txt errMsg[256] = {'\0'}; +#endif + + TRC2(cmMmGlobRegInit); + +#ifdef SS_MEM_WL_DEBUG + if (cmInitBtInfo() == RFAILED) + { + RETVALUE(RFAILED); + } +#endif + for ( bktIdx = 0; bktIdx < regCb->numBkts; bktIdx++) + { + /* Initial address of the memory region block */ + memAddr = ®Cb->bktTbl[bktIdx].startAddr; + bucketSetSize = regCb->bktTbl[bktIdx].bucketSetSize; + size = regCb->bktTbl[bktIdx].size; + + /* Initialize the bucket linked list */ + cmLListInit(®Cb->bktTbl[bktIdx].listValidBktSet); + cmLListInit(®Cb->bktTbl[bktIdx].listFreeBktSet); + SInitLock(&(regCb->bktTbl[bktIdx].bucketLock), SS_LOCK_MUTEX); + + /* Initialize the link list of the memory block */ + next = &(regCb->bktTbl[bktIdx].next); + + numBlks = regCb->bktTbl[bktIdx].numBlks; + for (cnt = 1; cnt <= numBlks; cnt++) + { + *next = *memAddr; + next = (CmMmEntry **)(*memAddr); + *memAddr = (*memAddr) + size; + + /* Maintain the list Cb */ + if(!(cnt % bucketSetSize)) + { + blkLstElem = calloc(1, sizeof(CmMmBlkSetElement)); + blkLstElem->nextBktPtr = (CmMmEntry *)regCb->bktTbl[bktIdx].next; + blkLstElem->numFreeBlks = bucketSetSize; + blkLstElem->memSetNode.node = (PTR)blkLstElem; + cmLListAdd2Tail((®Cb->bktTbl[bktIdx].listValidBktSet), (&blkLstElem->memSetNode)); + next = &(regCb->bktTbl[bktIdx].next); + } + } + *next = NULLP; + } + + RETVALUE(ROK); +} /* end of cmMmGlobRegInit*/ + +#ifdef SS_USE_ICC_MEMORY +/* +* +* Fun: cmIccAllocWithLock +* +* Desc: Allocate a memory block for use by dynamic buffers. +* This handler uses the lock to avoid the two thread +* trying to allocate the memory at same time. This +* handler must be used only for non-data plane thread +* it causes delay due to lock. +* +* +* Ret: ROK - successful +* RFAILED - unsuccessful. +* +* Notes: +* +* File: cm_mem_wl.c +* +*/ +#ifdef T2K_MEM_LEAK_DBG +#ifdef ANSI +PRIVATE S16 cmIccAllocWithLock +( +Void *regionCb, /* Pointer to a region */ +Size *size, /* size needs to be allocated */ +U32 flags, /* Flags used */ +Data **ptr, /* Reference to pointer for which need to be allocate */ +char *file, +U32 line +) +#endif +#else +#ifdef ANSI +PRIVATE S16 cmIccAllocWithLock +( +Void *regionCb, /* Pointer to a region */ +Size *size, /* size needs to be allocated */ +U32 flags, /* Flags used */ +Data **ptr /* Reference to pointer for which need to be allocate */ +) +#else +PRIVATE S16 cmIccAllocWithLock(regionCb, size, flags, ptr) +Void *regionCb; /* Pointer to a region */ +Size *size; /* size needs to be allocated */ +U32 flags; /* Flags used */ +Data **ptr; /* Reference to pointer for which need to be allocate */ +#endif +#endif +{ + CmMmDynRegCb *regCb; + Data *memPtr; + + TRC2(cmIccAllocWithLock); + + regCb = (CmMmDynRegCb *)regionCb; + + if((SLock(&iccAllocFreeLock)) != ROK) + { + printf("cmIccAllocWithLock: Failed to get the ICC lock\n"); + RETVALUE(RFAILED); + } + + memPtr = (Data *)TL_Alloc(regCb->iccHdl, *size); + + if((SUnlock(&iccAllocFreeLock)) != ROK) + { + printf("cmIccAllocWithLock: Failed to unlock the ICC lock\n"); + RETVALUE(RFAILED); + } + + if ((memPtr) == NULLP) + { + int *p = 0; + printf("\n*****************Region(%d) is out of memory size = %ld******************\n",regCb->region, *size); + printf("Exiting...\n"); + /* crash here */ + *p = 10; + } + +#ifdef T2K_MEM_LEAK_DBG + if(((U32)(memPtr - T2K_MEM_LEAK_START_ADDR) & 0xff) != 0) + { + printf("Address returned is %p size = %ld\n",memPtr,*size); + } + + InsertToT2kMemLeakInfo((U32)memPtr,*size,line,file); +#endif + *ptr = memPtr; + + RETVALUE(ROK); + +} /* end of cmIccAllocWithLock */ + +/* +* +* Fun: cmIccFreeWithLock +* +* Desc: Return the Dynamic memory block for the memory region. +* This handler uses the lock to avoid the two thread +* trying to free the memory at same time. This +* handler must be used only for non-data plane thread +* it causes delay due to lock. +* +* Ret: ROK - successful +* RFAILED - unsuccessful. +* +* Notes: +* +* +* File: cm_mem_wl.c +* +*/ +#ifdef T2K_MEM_LEAK_DBG +#ifdef ANSI +PRIVATE S16 cmIccFreeWithLock +( +Void *regionCb, /* Pointer to region cb */ +Data *ptr, /* Memory block needs to be freed */ +Size size, /* Size of the block */ +char *file, +U32 line +) +#endif +#else +#ifdef ANSI +PRIVATE S16 cmIccFreeWithLock +( +Void *regionCb, /* Pointer to region cb */ +Data *ptr, /* Memory block needs to be freed */ +Size size /* Size of the block */ +) +#else +PRIVATE S16 cmIccFreeWithLock(regionCb, ptr, size) +Void *regionCb; /* Pointer to region cb */ +Data *ptr; /* Memory block needs to be freed */ +Size size; /* Size of the block */ +#endif +#endif +{ + CmMmDynRegCb *regCb; + + TRC2(cmIccFreeWithLock); + + regCb = (CmMmDynRegCb *)regionCb; + + if((SLock(&iccAllocFreeLock)) != ROK) + { + printf("cmIccFreeWithLock: Failed to get the ICC lock\n"); + RETVALUE(RFAILED); + } + +#ifdef T2K_MEM_LEAK_DBG + RemoveFromT2kMemLeakInfo((U32)ptr - ((U32)ptr % 512),file,line); + +#endif + TL_Free(regCb->iccHdl, ptr); + + if((SUnlock(&iccAllocFreeLock)) != ROK) + { + printf("cmIccFreeWithLock: Failed to unlock the ICC lock\n"); + RETVALUE(RFAILED); + } + + RETVALUE(ROK); +} /* end of cmIccFree */ + +/* +* +* Fun: cmIccAlloc +* +* Desc: Allocate a memory block for use by dynamic buffers +* +* +* Ret: ROK - successful +* RFAILED - unsuccessful. +* +* Notes: +* +* File: cm_mem_wl.c +* +*/ +#ifdef T2K_MEM_LEAK_DBG +#ifdef ANSI +PRIVATE S16 cmIccAlloc +( +Void *regionCb, /* Pointer to a region */ +Size *size, /* size needs to be allocated */ +U32 flags, /* Flags used */ +Data **ptr, /* Reference to pointer for which need to be allocate */ +char *file, +U32 line +) +#else +#endif +#else +#ifdef ANSI +PRIVATE S16 cmIccAlloc +( +Void *regionCb, /* Pointer to a region */ +Size *size, /* size needs to be allocated */ +U32 flags, /* Flags used */ +Data **ptr /* Reference to pointer for which need to be allocate */ +) +#else +PRIVATE S16 cmIccAlloc(regionCb, size, flags, ptr) +Void *regionCb; /* Pointer to a region */ +Size *size; /* size needs to be allocated */ +U32 flags; /* Flags used */ +Data **ptr; /* Reference to pointer for which need to be allocate */ +#endif + +#endif +{ + CmMmDynRegCb *regCb; + Data *memPtr; + + TRC2(cmIccAlloc); + + regCb = (CmMmDynRegCb *)regionCb; + + memPtr = (Data *)TL_Alloc(regCb->iccHdl, *size); + + if ((memPtr) == NULLP) + { + int *p = 0; + printf("\n*****************Region(%d) is out of memory size = %ld******************\n",regCb->region, *size); + printf("Exiting...\n"); + /* crash here */ + *p = 10; + } +#ifdef T2K_MEM_LEAK_DBG + if(((U32)(memPtr - T2K_MEM_LEAK_START_ADDR) & 0xff) != 0) + { + printf("Address returned is %p size = %ld\n",memPtr,*size); + } + + InsertToT2kMemLeakInfo((U32)memPtr,*size,line,file); +#endif +#ifdef YS_PHY_3_8_2 + *ptr = memPtr;/*TL_VA2TRUEVA(regCb->iccHdl, memPtr); */ +#else + *ptr = memPtr; /*TL_VA2TRUEVA(regCb->iccHdl, memPtr); */ +#endif + + RETVALUE(ROK); + +} /* end of cmIccAlloc */ + +/* +* +* Fun: cmIccFree +* +* Desc: Return the Dynamic memory block for the memory region. +* +* +* Ret: ROK - successful +* RFAILED - unsuccessful. +* +* Notes: +* +* +* File: cm_mem_wl.c +* +*/ +#ifdef T2K_MEM_LEAK_DBG +PRIVATE S16 cmIccFree +( +Void *regionCb, /* Pointer to region cb */ +Data *ptr, /* Memory block needs to be freed */ +Size size, /* Size of the block */ +char* file, +U32 line +) +#else +#ifdef ANSI +PRIVATE S16 cmIccFree +( +Void *regionCb, /* Pointer to region cb */ +Data *ptr, /* Memory block needs to be freed */ +Size size /* Size of the block */ +) +#else +PRIVATE S16 cmIccFree(regionCb, ptr, size) +Void *regionCb; /* Pointer to region cb */ +Data *ptr; /* Memory block needs to be freed */ +Size size; /* Size of the block */ +#endif +#endif +{ + CmMmDynRegCb *regCb; + TRC2(cmIccFree); + + regCb = (CmMmDynRegCb *)regionCb; + +#ifdef YS_PHY_3_8_2 + // memPtr = TL_TRUEVA2VA(regCb->iccHdl, ptr); + { +#ifdef T2K_MEM_LEAK_DBG + RemoveFromT2kMemLeakInfo((U32)ptr - ((U32)ptr % 512),file,line); +#endif + } + + TL_Free(regCb->iccHdl, ptr); +#else +/* memPtr = TL_TRUEVA2VA(regCb->iccHdl, ptr); */ + memPtr = ptr; + TL_Free(regCb->iccHdl, memPtr); +#endif + /*TL_Free(regCb->iccHdl, ptr);*/ + +#if 0 + if(a < 10) + printf("FREE -ICC Addr Before PA2VA %x After PA2VA %x\n", memPtr, ptr); + a++; +#endif + + RETVALUE(ROK); +} /* end of cmIccFree */ + +/* +* +* Fun: cmMmDynRegInit +* +* Desc: Configure the memory region for allocation. The function +* registers the memory region with System Service by calling +* SRegRegion. +* +* +* Ret: ROK - successful, +* RFAILED - unsuccessful. +* +* Notes: The memory owner calls this function to initialize the memory +* manager with the information of the memory region. Before +* calling this function, the memory owner should allocate memory +* for the memory region. The memory owner should also provide the +* memory for the control block needed by the memory manager. The +* memory owner should allocate the memory for the region control +* block as cachable memory. This may increase the average +* throughput in allocation and deallocation as the region control +* block is mostly accessed by the CMM. +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmMmDynRegInit +( +CmMmDynRegCb *regCb +) +#else +PUBLIC S16 cmMmDynRegInit(regCb) +CmMmDynRegCb *regCb; +#endif +{ + SRegInfo regInfo; +#ifdef T2200_2GB_DDR_CHANGES + Txt regIccStr[10] = {'\0'}; +#else + Txt regIccStr[64] = {'\0'}; +#endif + + TRC2(cmMmDynRegInit); + + /* Register the region/memory with ICC and get the handler for same. The id is starting + * from region+1 as the zero is used by PHY code */ +#ifdef T2200_2GB_DDR_CHANGES + sprintf(regIccStr, "RxID=%d", (regCb->region + 1)); +#else +#if 0 + sprintf(regIccStr, "RxID=%d", (regCb->region + 1)); +#else + //snprintf(regIccStr, sizeof(regIccStr), "QueueSize=%u RxID=%u", 1024, (regCb->region + 1)); + + // snprintf(regIccStr, sizeof(regIccStr), "QueueSize=%u RxID=%u", 2048, (regCb->region + 1)); +#ifdef L2_L3_SPLIT + if(clusterMode == RADIO_CLUSTER_MODE) + { + if(regCb->region == 3) + {/* ICC packet receiver */ + snprintf(regIccStr, sizeof(regIccStr), "QueueSize=%u RxID=%u", 4096, (regCb->region + 1)); + }else + { + snprintf(regIccStr, sizeof(regIccStr), "QueueSize=%u RxID=%u", 2048, (regCb->region + 1)); + //sprintf(regIccStr, "RxID=%d", (regCb->region + 1)); + } + }else + {/* NET CLUSTER */ + snprintf(regIccStr, sizeof(regIccStr), "QueueSize=%u RxID=%u", 2048, (regCb->region + 1)); + //snprintf(regIccStr, sizeof(regIccStr), "QueueSize=%u RxID=%u", 1024, (regCb->region + 1)); + //snprintf(regIccStr, sizeof(regIccStr), "RXID=%u", (regCb->region + 1)); + } +#else +#ifdef T2200_2GB_DDR_CHANGES + sprintf(regIccStr, "RxID=%d", (regCb->region + 1)); +#else + sprintf (regIccStr, "queuesize=%d rxid=%d", 512, (regCb->region) + 1); +#endif +#endif +#endif +#endif + printf(" %s \n",regIccStr); + regCb->iccHdl = TL_Open(regIccStr, 0); + + printf("\nICC Region is %d\n",regCb->region); + + /* Call SRegRegion to register the memory region with SSI */ + cmMemset((U8*)®Info, 0, sizeof(regInfo)); + + /* Register the lock region for SS_MAX_REGS - 1 region */ + if((SS_MAX_REGS - 1) == regCb->region) + { + regInfo.alloc = cmIccAllocWithLock; + regInfo.free = cmIccFreeWithLock; + regInfo.regCb = regCb; + if((SInitLock((&iccAllocFreeLock), SS_LOCK_MUTEX)) != ROK) + { + printf("Failed to initialize the lock region lock\n"); + } + } + else + { + regInfo.alloc = cmIccAlloc; + regInfo.free = cmIccFree; + regInfo.regCb = regCb; + } + + if (SRegDynRegion(regCb->region, ®Info) != ROK) + { + RETVALUE(RFAILED); + } + + RETVALUE(ROK); +} /* end of cmMmDynRegInit*/ + +#else /* SS_USE_ICC_MEMORY */ + +/* +* +* Fun: cmMmDynRegInit +* +* Desc: Configure the memory region for allocation. The function +* registers the memory region with System Service by calling +* SRegRegion. +* +* +* Ret: ROK - successful, +* RFAILED - unsuccessful. +* +* Notes: The memory owner calls this function to initialize the memory +* manager with the information of the memory region. Before +* calling this function, the memory owner should allocate memory +* for the memory region. The memory owner should also provide the +* memory for the control block needed by the memory manager. The +* memory owner should allocate the memory for the region control +* block as cachable memory. This may increase the average +* throughput in allocation and deallocation as the region control +* block is mostly accessed by the CMM. +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmMmDynRegInit +( +CmMmDynRegCb *regCb +) +#else +PUBLIC S16 cmMmDynRegInit(regCb) +CmMmDynRegCb *regCb; +#endif +{ + Region region; + U16 lstMapIdx; + U16 cnt; + Size size; + CmMmBlkSetElement *blkLstElem; + SRegInfo regInfo; + Size bktQnSize = MT_BKTQNSIZE; + U16 idx; + U16 idx1; + U16 numBkts; + + TRC2(cmMmDynRegInit); + + /* Initialize the region control block */ + region = regCb->region; + numBkts = regCb->numBkts; + + /* Initilaize the bktIndex of the map entries to FF */ + for ( lstMapIdx = 0; lstMapIdx < CMM_MAX_MAP_ENT; lstMapIdx++) + { + regCb->mapTbl[lstMapIdx].bktIdx = 0xFF; + } + + lstMapIdx = 0; + + for(cnt = 0; cnt < numBkts; cnt++) + { + /* Initialize the Map entry */ + size = regCb->bktTbl[cnt].size; + idx = size / bktQnSize; + + /* + * Check if the size is multiple of quantum size. If not we need to initialize + * one more map table entry. + */ + if(size % bktQnSize) + { + idx++; + } + + while ( lstMapIdx < idx) + { + regCb->mapTbl[lstMapIdx].bktIdx = cnt; + lstMapIdx++; + } + } + + regCb->bktQnPwr = 0; + + while( !((bktQnSize >> regCb->bktQnPwr) & 0x01)) + { + regCb->bktQnPwr++; + } + + /* Initialize the bucket structure */ +#if 0 + regCb->bktTbl[bktIdx].numAlloc = 0; + regCb->bktTbl[bktIdx].maxAlloc = 0; + + /* Update the total bucket size */ + regCb->bktSize += (regCb->bktTbl[bktIdx].size * regCb->bktTbl[bktIdx].numBkt); + + regCb->bktTbl[bktIdx].bktFailCnt = 0; + regCb->bktTbl[bktIdx].bktNoFitCnt = 0; + + if(regCb->bktMaxBlkSize < regCb->bktTbl[bktIdx].size) + { + regCb->bktMaxBlkSize = regCb->bktTbl[bktIdx].size; + } +#endif + + for(idx = 0; idx < numBkts; idx++) + { + regCb->bktTbl[idx].crntMemBlkSetElem = NULLP; + + for(idx1 = 0; idx1 < CMM_MAX_NUMBER_BKT_NODE; idx1++) + { + blkLstElem = calloc(1, sizeof(CmMmBlkSetElement)); + blkLstElem->memSetNode.node = (PTR)blkLstElem; + cmLListAdd2Tail((®Cb->bktTbl[idx].memBlkSetElem), (&blkLstElem->memSetNode)); + } + } + + /* Call SRegRegion to register the memory region with SSI */ + cmMemset((U8*)®Info, 0, sizeof(regInfo)); +#if 1 + if((SS_MAX_REGS - 1) == regCb->region) + { + regInfo.alloc = cmDynAllocWithLock; + regInfo.free = cmDynFreeWithLock; + if((SInitLock((&dynAllocFreeLock), SS_LOCK_MUTEX)) != ROK) + { + printf("Failed to initialize the lock region lock\n"); + } + } + else +#endif + { +#if 0 + static dynLockCreated; + regInfo.alloc = cmDynAllocWithLock; + regInfo.free = cmDynFreeWithLock; + if ( dynLockCreated == 0) + { + if((SInitLock((&dynAllocFreeLock), SS_LOCK_MUTEX)) != ROK) + { + printf("Failed to initialize the lock region lock\n"); + } + dynLockCreated = 1; + } +#endif + +#if 1 + regInfo.alloc = cmDynAlloc; + regInfo.free = cmDynFree; +#endif + } + + regInfo.regCb = regCb; + + if (SRegDynRegion(region, ®Info) != ROK) + { + RETVALUE(RFAILED); + } + + RETVALUE(ROK); +} /* end of cmMmDynRegInit*/ + +#endif /* SS_USE_ICC_MEMORY */ + + +/* +* +* Fun: cmMmRegDeInit +* +* Desc: Deinitialize the memory region. The function call SDeregRegion +* to deregister the memory region with System Service. +* +* +* Ret: ROK - successful +* RFAILED - unsuccessful. +* +* Notes: The memory owner calls this function to deinitialize the region. +* The memory manager does not return the memory to the system. +* Before calling this function, the memory owner must be sure that +* no layer is using any memory block from this region. On +* successful return from the function, any request to the memory +* manager to allocate/deallocate memory will fail. The memory owner +* can reuse the memory for other region or return the memory to the +* system memory pool. +* +* +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmMmRegDeInit +( +CmMmRegCb *regCb +) +#else +PUBLIC S16 cmMmRegDeInit(regCb) +CmMmRegCb *regCb; +#endif +{ + U16 bktIdx; + + TRC2(cmMmRegDeInit); + +#if (ERRCLASS & ERRCLS_INT_PAR) + + /* error check on parameters */ + if (regCb == NULLP) + { + RETVALUE(RFAILED); + } + +#endif + +/* cm_mem_c_001.main_12 - addition for deinitializing the hash table */ +#ifdef SSI_DEBUG_LEVEL1 + /* Deinitialize the hash table used for debug info storage at region level */ + if (cmMmHashListDeinit(®Cb->hashListCp, regCb->region, 0) != ROK) + { + RETVALUE(RFAILED); + } +#endif /* SSI_DEBUG_LEVEL1 */ + + /* Call SDeregRegion first to deregister the memory region with SSI */ + (Void) SDeregRegion (regCb->region); + + if (regCb->bktSize) + { + /* Bucket pool is configured */ + + /* Free the initialzed locks of the buckets */ + for ( bktIdx = regCb->numBkts; bktIdx > 0;) + { + /* cm_mem_c_001.main_13: Replaced SDestroyLock with + WTDestroyLock for NT */ + /* cm_mem_c_001.main_24 fix for memory corruption*/ + --bktIdx; +#ifdef SS_WIN + WTDestroyLock(&(regCb->bktTbl[bktIdx].bktLock)); +#else + SDestroyLock(&(regCb->bktTbl[bktIdx].bktLock)); +#endif +/* cm_mem_c_001.main_15:Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + /* De-initialise the memory histogram hash list */ + cmHstGrmHashListDeInit(&(regCb->bktTbl[bktIdx].hstGrmHashListCp)); +#endif /* SS_HISTOGRAM_SUPPORT */ + } + } + + if (regCb->heapFlag) + { + /* Heap pool is configured */ + + /* cm_mem_c_001.main_13: Replaced SDestroyLock with + WTDestroyLock for NT */ +#ifdef SS_WIN + WTDestroyLock(®Cb->heapCb.heapLock); +#else + SDestroyLock(®Cb->heapCb.heapLock); +#endif + } + + RETVALUE(ROK); + +} /* end of cmMmRegDeInit */ + +#ifndef USE_PURE +#ifndef SS_USE_ICC_MEMORY +/* +* +* Fun: cmGetMemBlkSetForAlloc +* +* Desc: Retruns the pointer to the element which is used for +* allocating the buffer. Also, it does the threshold check +* and get the additional memory block set from the global +* region +* +* +* Ret: Pointer to memory block set - successful +* NULL - unsuccessful. +* +* Notes: +* Current implementation of the is function is made assuming that +* there will maximum two set of nodes only. +* +* File: cm_mem_wl.c +* +*/ + +#ifdef ANSI +PRIVATE CmMmBlkSetElement* cmGetMemBlkSetForAlloc +( +U8 bucketIndex, /* Index to the bucket list */ +CmMmDynBktCb *bkt /* Bucket list control block */ +) +#else +PRIVATE CmMmBlkSetElement* cmGetMemBlkSetForAlloc(bucketIndex, bkt) +U8 bucketIndex; /* Index to the bucket list */ +CmMmDynBktCb *bkt; /* Bucket list control block */ +#endif +{ + CmMmBlkSetElement *memBlkSetElem; + CmMmBlkSetElement *nextMemBlkSetElem; + CmLList *memSetNode; + CmLList *nextMemSetNode; + + /* Check if we are coming here for the first time, if yes get a new + * block set from global region */ + if(bkt->crntMemBlkSetElem == NULLP) + { + /* set the current index to initial one and get the bucket set from + * global region */ + memSetNode = cmLListFirst(&bkt->memBlkSetElem); + + /* Check if the element exits or not */ + if((memSetNode == NULLP) || (memSetNode->node == NULLP)) + { + RETVALUE(NULLP); + } + + bkt->crntMemBlkSetElem = (CmMmBlkSetElement *)memSetNode->node; + /* Get the new block set from the gloabl region and return the same */ + ssGetDynMemBlkSet(bucketIndex, bkt->crntMemBlkSetElem, 0); + RETVALUE(bkt->crntMemBlkSetElem); + } + /* If this is not the first time, take the bucket list CB from the + * current index */ + memBlkSetElem = bkt->crntMemBlkSetElem; + /* If the current index doesnot have any free buckets, it check in + * the next bucket node */ + if(memBlkSetElem->numFreeBlks == 0) + { + /* Get the next element in the list and if it is not present, then + * get the first node */ + memSetNode = cmLListNext(&bkt->memBlkSetElem); + + if(memSetNode == NULLP) + { + memSetNode = cmLListFirst(&bkt->memBlkSetElem); + } + memBlkSetElem = (CmMmBlkSetElement *)memSetNode->node; + + /* if next node also empty, return failure */ + if(memBlkSetElem->numFreeBlks == 0) + { + RETVALUE(NULLP); + } + /* store the new index in the current node which will be + * used in the next time. */ + bkt->crntMemBlkSetElem = memBlkSetElem; + } + +#if 0 + if(memBlkSetElem->nextBktPtr == NULLP) + { + ssGetDynMemBlkSet(bucketIndex, memBlkSetElem); + } +#endif + /* If we have reached the threshold value, get the next set of buckets from + * the global region and place it */ + if(memBlkSetElem->numFreeBlks < bkt->blkSetAcquireThreshold) + { + /* Get the next element for the threshold check. If next is not present, + * get the first one. Here, we are not using the cmLList macros to get + * to the next node or first node as those macros are working on the crnt + * node and will change the crnt. As we dont want to change the crnt node + * at this point, we are directly using the listCp prameter to get next + * first nodes */ + nextMemSetNode = memBlkSetElem->memSetNode.next; + + if(nextMemSetNode == NULLP) + { + nextMemSetNode = bkt->memBlkSetElem.first; + } + + nextMemBlkSetElem = (CmMmBlkSetElement *)nextMemSetNode->node; + + if(nextMemBlkSetElem->numFreeBlks == 0) + { + /* The last parameter is used wheather to block for the block set aquiring + or not. Here, the logic is such that, when the current node number of + free blocks becomes one and the next node has zero free blocks, + we must get the block set from global region. + For example, if acquire threashold is 20 and current node has only one + free block and next node has zero free blocks we block to aquire lock + and get the set from global region else, we try for lock, if we get + the lock, the get the block set else it is get in next go + */ + ssGetDynMemBlkSet(bucketIndex, nextMemBlkSetElem, + (memBlkSetElem->numFreeBlks - 1)); + } + } + + /* On successful, return the bucket node to calling function */ + RETVALUE(memBlkSetElem); +} /* cmGetMemBlkSetForAlloc */ + + +/* +* +* Fun: cmGetMemBlkSetForFree +* +* Desc: Retruns the pointer to the element which is used for +* freeing the buffer. Also, it does the threshold check +* and release the additional memory block set to the global +* region +* +* +* Ret: Pointer to memory block set - successful +* NULL - unsuccessful. +* +* Notes: +* Current implementation of the is function is made assuming that +* there will maximum two set of nodes only. +* +* File: cm_mem_wl.c +* +*/ + +#ifdef ANSI +PRIVATE CmMmBlkSetElement* cmGetMemBlkSetForFree +( +U8 bucketIndex, /* Index to the bucket list */ +CmMmDynBktCb *bkt /* Bucket list control block */ +) +#else +PRIVATE CmMmBlkSetElement* cmGetMemBlkSetForFree(bucketIndex, bkt) +U8 bucketIndex; /* Index to the bucket list */ +CmMmDynBktCb *bkt; /* Bucket list control block */ +#endif +{ + CmMmBlkSetElement *memBlkSetElem; + CmMmBlkSetElement *nextMemBlkSetElem; + CmLList *memSetNode; + CmLList *nextMemSetNode; + + /* Check if we are coming here for the first time, if yes get a new + * block set from global region */ + if(bkt->crntMemBlkSetElem == NULLP) + { + /* set the current index to initial one */ + memSetNode = cmLListFirst(&bkt->memBlkSetElem); + + /* Check if the element exits or not */ + if((memSetNode == NULLP) || (memSetNode->node == NULLP)) + { + RETVALUE(NULLP); + } + bkt->crntMemBlkSetElem = (CmMmBlkSetElement *)memSetNode->node; + RETVALUE(bkt->crntMemBlkSetElem); + } + /* If this is not the first time, take the bucket list CB from the + * current index */ + memBlkSetElem = bkt->crntMemBlkSetElem; + /* If the current index doesnot have any free buckets, it check in + * the next bucket node */ + if(memBlkSetElem->numFreeBlks >= bkt->bucketSetSize) + { + /* Get the next element in the list and if it is not present, then + * get the first node */ + nextMemSetNode = cmLListNext(&bkt->memBlkSetElem); + + if(nextMemSetNode == NULLP) + { + nextMemSetNode = cmLListFirst(&bkt->memBlkSetElem); + } + memBlkSetElem = (CmMmBlkSetElement *)nextMemSetNode->node; + + /* if next node also empty, return failure */ + if(memBlkSetElem->numFreeBlks >= bkt->bucketSetSize) + { + RETVALUE(NULLP); + } + /* store the new index in the current node which will be + * used in the next time. */ + bkt->crntMemBlkSetElem = memBlkSetElem; + } + + /* If we have reached the threshold value and have additional block set, + * release the additional block set back to global region */ + if(memBlkSetElem->numFreeBlks > bkt->blkSetRelThreshold) + { + /* Get the next element for the threshold check. If next is not present, + * get the first one. Here, we are not using the cmLList macros to get + * to the next node or first node as those macros are working on the crnt + * node and will change the crnt. As we dont want to change the crnt node + * at this point, we are directly using the listCp prameter to get next + * first nodes */ + nextMemSetNode = memBlkSetElem->memSetNode.next; + if(nextMemSetNode == NULLP) + { + nextMemSetNode = bkt->memBlkSetElem.first; + } + + nextMemBlkSetElem = (CmMmBlkSetElement *)nextMemSetNode->node; + if(nextMemBlkSetElem->numFreeBlks == bkt->bucketSetSize) + { + /* The last parameter is used wheather to block for the block set aquiring + or not. Here, the logic is such that, when the current node number of + free blocks becomes one less than the bucket set size and the next node + is has full free blocks, we must free the block set back to global region + For example, if bucket set size if 100 and release threashold is 80 and + current node has number of free blocks 99 and next node has 100 free blocks + we block to aquire lock and free it back to global region else, we try for + lock, if we get the lock, the block set is freed else its freed in next go + */ + ssPutDynMemBlkSet(bucketIndex, nextMemBlkSetElem, + (bkt->bucketSetSize - memBlkSetElem->numFreeBlks - 1)); +#if 0 + nextMemBlkSetElem->numFreeBlks = 0; + nextMemBlkSetElem->nextBktPtr = NULLP; +#endif + } + } + + /* On successful, return the bucket node to calling function */ + RETVALUE(memBlkSetElem); +} +#endif /* SS_USE_ICC_MEMORY */ +#endif /* USE_PURE */ + +#ifdef SS_MEM_WL_DEBUG +/* +* +* Fun: cmRemoveAllocPtrFromList +* +* Desc: Remove a node with Free PTR from hashlist. The memory +* of the node is Freed to the same region +* +* +* Ret: ROK - successful +* RFAILED - unsuccessful. +* +* Notes: +* +* File: cm_mem_wl.c +* +*/ + +#ifdef ANSI +PRIVATE S16 cmRemoveAllocPtrFromList +( +CmMmDynRegCb *regionCb, /* Pointer to a region */ +PTR ptr +) +#else +PRIVATE S16 cmRemoveAllocPtrFromList(regionCb, ptr) +CmMmDynRegCb *regionCb; /* Pointer to a region */ +PTR ptr; +#endif +{ + + CmMemDoubleFree *memNode = NULLP; + + SLock(&memDoubleFreeLock); + if((cmHashListFind(&(memDoubleFree), (U8*)&ptr, + sizeof(U32), 0, (PTR *)&memNode)) != ROK) + { + Void *tmpBtArr[10]; + U16 tmpBtSize; + S8 **strings; + U16 idx; + + tmpBtSize = backtrace(tmpBtArr, 10); + strings = backtrace_symbols(tmpBtArr, tmpBtSize); + printf("**** Trying to free non allocated block BT is: \n"); + for(idx = 0; idx < tmpBtSize; idx++) + { + printf("%s\n", strings[idx]); + } + printf("*****************************************\n"); + printf("Analysis from Array storing BT for freeing and allocation\n"); + cmAnalyseBtInfo(ptr, regionCb->region); + SUnlock(&memDoubleFreeLock); + RETVALUE(RFAILED); + } + + if((cmHashListDelete(&(memDoubleFree), (PTR)memNode)) != ROK) + { + SUnlock(&memDoubleFreeLock); + RETVALUE(RFAILED); + } + SUnlock(&memDoubleFreeLock); + SPutSBuf(regionCb->region, 0, (Data *)memNode, sizeof(CmMemDoubleFree)); + + RETVALUE(ROK); +} + +/* +* +* Fun: cmInsertAllocPtrToList +* +* Desc: Insert a node with allocated PTR into hashlist. The memory +* for the node is allocated from the same region +* +* +* Ret: ROK - successful +* RFAILED - unsuccessful. +* +* Notes: +* +* File: cm_mem_wl.c +* +*/ + +#ifdef ANSI +PRIVATE S16 cmInsertAllocPtrToList +( +CmMmDynRegCb *regionCb, /* Pointer to a region */ +PTR ptr +) +#else +PRIVATE S16 cmInsertAllocPtrToList(regionCb, ptr) +CmMmDynRegCb *regionCb; /* Pointer to a region */ +PTR ptr; +#endif +{ + + CmMemDoubleFree *memNode; + + SGetSBuf(regionCb->region, 0, (Data **)&memNode, sizeof(CmMemDoubleFree)); + if(memNode == NULLP) + { + RETVALUE(RFAILED); + } + + memNode->memBlkPtr = ptr; + SLock(&memDoubleFreeLock); + if((cmHashListInsert(&(memDoubleFree), (PTR)memNode, (U8*)&memNode->memBlkPtr, + sizeof(PTR))) != ROK) + { + SUnlock(&memDoubleFreeLock); + RETVALUE(RFAILED); + } + SUnlock(&memDoubleFreeLock); + + RETVALUE(ROK); +} +#endif + + +#ifndef SS_USE_ICC_MEMORY +/* +* +* Fun: cmDynAllocWithLock +* +* Desc: Allocate a memory block for use by dynamic buffers +* +* +* Ret: ROK - successful +* RFAILED - unsuccessful. +* +* Notes: +* +* File: cm_mem_wl.c +* +*/ +/* cm_mem_c_001.main_15 : Additions */ + +#ifdef ANSI +PRIVATE S16 cmDynAllocWithLock +( +Void *regionCb, /* Pointer to a region */ +Size *size, /* size needs to be allocated */ +U32 flags, /* Flags used */ +Data **ptr /* Reference to pointer for which need to be allocate */ +) +#else +PRIVATE S16 cmDynAllocWithLock(regionCb, size, flags, ptr) +Void *regionCb; /* Pointer to a region */ +Size *size; /* size needs to be allocated */ +U32 flags; /* Flags used */ +Data **ptr; /* Reference to pointer for which need to be allocate */ +#endif +{ + S16 ret; + + TRC2(cmDynAlloc); + + if((SLock(&dynAllocFreeLock)) != ROK) + { + printf("cmDynAllocWithLock: Failed to get the dyn lock\n"); + RETVALUE(RFAILED); + } + + ret = cmDynAlloc (regionCb, size,flags,ptr); + + if((SUnlock(&dynAllocFreeLock)) != ROK) + { + printf("cmDynAllocWithLock: Failed to unlock the Dyn lock\n"); + RETVALUE(RFAILED); + } + + RETVALUE(ret); +} /* end of cmDynAlloc */ + +/* +* +* Fun: cmDynAlloc +* +* Desc: Allocate a memory block for use by dynamic buffers +* +* +* Ret: ROK - successful +* RFAILED - unsuccessful. +* +* Notes: +* +* File: cm_mem_wl.c +* +*/ +/* cm_mem_c_001.main_15 : Additions */ + +#ifdef ANSI +PRIVATE S16 cmDynAlloc +( +Void *regionCb, /* Pointer to a region */ +Size *size, /* size needs to be allocated */ +U32 flags, /* Flags used */ +Data **ptr /* Reference to pointer for which need to be allocate */ +) +#else +PRIVATE S16 cmDynAlloc(regionCb, size, flags, ptr) +Void *regionCb; /* Pointer to a region */ +Size *size; /* size needs to be allocated */ +U32 flags; /* Flags used */ +Data **ptr; /* Reference to pointer for which need to be allocate */ +#endif +{ + CmMmDynRegCb *regCb; + + TRC2(cmDynAlloc); + + regCb = (CmMmDynRegCb *)regionCb; + +#ifdef SS_MEM_WL_DEBUG + if((tmpRegTidMap[regCb->region] != (pthread_self())) ) + { + **ptr = 10; + } +#endif + +#if (ERRCLASS & ERRCLS_INT_PAR) + + /* error check on parameters */ + if ((regCb == NULLP) || (size == NULLP) || !(*size) || (ptr == NULLP)) + { + RETVALUE(RFAILED); + } +#endif + +#ifndef USE_PURE + + /* + * Check if the requested size is less than or equal to the maximum block + * size in the bucket. + */ + +#ifdef SS_MEM_WL_DEBUG + if ( (*size + 4) <= regCb->bktMaxBlkSize) +#else + if ( (*size) <= regCb->bktMaxBlkSize) +#endif + { + U32 idx; + CmMmBlkSetElement *dynMemElem; + U32 bktIdx; + CmMmDynBktCb *bkt; + + /* Get the map to the mapping table */ +#ifdef SS_MEM_WL_DEBUG + idx = (((*size + 4) - 1) >> regCb->bktQnPwr); +#else + idx = (((*size) - 1) >> regCb->bktQnPwr); +#endif + +#if (ERRCLASS & ERRCLS_DEBUG) + if (regCb->mapTbl[idx].bktIdx == 0xFF) + { + printf("Failed to get the buffer of size %d\n", *size); + /* Some fatal error in the map table initialization. */ + RETVALUE(RFAILED); + } +#endif + if (idx > 512) + { + RETVALUE(RFAILED); + } + /* Dequeue the memory block and return it to the user */ + bktIdx = regCb->mapTbl[idx].bktIdx; + bkt = &(regCb->bktTbl[bktIdx]); +#ifdef SS_MEM_WL_DEBUG + if(bkt->size < (*size+4)) +#else + if(bkt->size < (*size)) +#endif + { + idx++; + bkt = &(regCb->bktTbl[bktIdx = regCb->mapTbl[idx].bktIdx]); + } + + dynMemElem = cmGetMemBlkSetForAlloc(bktIdx, bkt); + + /* Check if the bucket index, if its not valid, return failure */ + if(dynMemElem == NULLP) + { +#ifndef ALIGN_64BIT + printf("Failed to get the buffer of size %ld\n", *size); +#else + printf("Failed to get the buffer of size %d\n", *size); +#endif + RETVALUE(RFAILED); + } + +#ifdef SS_MEM_WL_DEBUG + if(dynMemElem->nextBktPtr == prvAllocPtr[regCb->region]) + { + U32 *tmpDump; + *tmpDump = 100; + } +#endif + /* Get the bucket node from the index returned and allocate the memory */ + *ptr = dynMemElem->nextBktPtr; + if (*ptr == NULLP) + { + RETVALUE(RFAILED); + } + dynMemElem->nextBktPtr = *((CmMmEntry **)(*ptr)); + dynMemElem->numFreeBlks--; + +#ifdef SS_MEM_WL_DEBUG + prvAllocPtr[regCb->region] = *ptr; +#if 0 + if(regCb->region == 6) + printf("cmDynAlloc: PTR = %x\n", *ptr); + **ptr = (U32) ((bktIdx << 4) | 0x0f); +#endif + + **ptr = (U8) bktIdx; + *(*ptr+1) = 0xde; + *(*ptr+2) = 0xad; + *(*ptr+3) = 0xbe; + *ptr += sizeof (U32); + + if ((bktIdx == 0) && (!stopBtInfo)) + { + CmBtInfo *btInfo; + U32 btIdx; + btInfo = &allocBtInfo[regCb->region]; + btIdx = btInfo->btInfoIdx; + btInfo->btInfo[btIdx].ptr = (PTR) *ptr; + { + btInfo->btInfo[btIdx].btSize = backtrace(btInfo->btInfo[btIdx].btArr, NUM_BT_TRACES); + } + gettimeofday(&(btInfo->btInfo[btIdx].timeStamp), NULLP); +#if 0 + cmInsertAllocPtrToList(regCb, (PTR)*ptr); +#endif + + btIdx++; + btIdx &= (NUM_FREE_BUFFERS - 1); + + btInfo->btInfo[btIdx].ptr = (PTR)0; + btInfo->btInfo[btIdx].btSize = 0; + cmMemset(btInfo->btInfo[bktIdx].btArr, 0, sizeof (btInfo->btInfo[bktIdx].btArr)); + btInfo->btInfoIdx = btIdx; + } +#endif + + RETVALUE(ROK); + } + + /* If the size is not matching, return failure to caller */ +#ifndef ALIGN_64BIT + printf("Failed to get the buffer of size %ld\n", *size); +#else + printf("Failed to get the buffer of size %d\n", *size); +#endif + RETVALUE(RFAILED); + +#else /* use pure is on */ + +#ifdef SS_4GMX_LCORE + *ptr = (Data*) MxHeapAlloc(SsiHeap, *size); + cmMemset((U8*)ptr, 0, *size); +#else +/* *ptr = (Data*) malloc(*size); */ +#endif + *ptr = (Data *)malloc(*size); + + if ( (*ptr) == NULLP) + RETVALUE(RFAILED); + /* avail_size -= *size; */ + RETVALUE(ROK); +#endif /* USE_PURE */ + +} /* end of cmDynAlloc */ +#endif /* SS_USE_ICC_MEMORY */ + + +#define OVERUSED(_bkt) (((_bkt)->numAlloc * 100) / (_bkt)->numBlks > 80) + +int g_overused[5] = {0}; + + +/* +* +* Fun: cmAlloc +* +* Desc: Allocate a memory block for the memory region. +* +* +* Ret: ROK - successful +* RFAILED - unsuccessful. +* +* Notes: +* The function allocates a memory block of size atleast equal to +* the requested size. The size parameter will be updated with the +* actual size of the memory block allocated for the request. The +* CMM tries to allocate the memory block form the bucket pool. If +* there is no memory in the bucket the CMM allocates the memory +* block form the heap pool. This function is always called by the +* System Service module. +* +* The caller of the function should try to use the out value of +* the size while returning the memory block to the region. However +* the current design of the memory manager does not enforce to pass +* the actual size of the memory block. (Due to the SGetSBuf +* semantics the layer will not able to pass the correct size of the +* memory block while calling SPutSBuf). +* +* +* File: cm_mem_wl.c +* +*/ +/* cm_mem_c_001.main_12 - addition to accept new parameter memType(static/dynamic) */ + +/* cm_mem_c_001.main_15 : Additions */ +#ifdef T2K_MEM_LEAK_DBG +PRIVATE S16 cmAlloc +( + Void *regionCb, + Size *size, + U32 flags, + Data **ptr , + char* file, + U32 line + ) +#else +#ifdef SS_HISTOGRAM_SUPPORT +#ifdef SSI_DEBUG_LEVEL1 +#ifdef ANSI +PRIVATE S16 cmAlloc +( +Void *regionCb, +Size *size, +U32 flags, +Data **ptr, +U32 memType, +U32 line, +U8 *fileName, +U8 entId, +Bool hstReg +) +#else +PRIVATE S16 cmAlloc(regionCb, size, flags, ptr, memType, line, fileName, entId, hstReg) +Void *regionCb; +Size *size; +U32 flags; +Data **ptr; +U32 memType; +U32 line; +U8 *fileName; +U8 entId; +Bool hstReg; +#endif +#else +#ifdef ANSI +PRIVATE S16 cmAlloc +( +Void *regionCb, +Size *size, +U32 flags, +Data **ptr, +U32 line, +U8 *fileName, +U8 entId, +Bool hstReg +) +#else +PRIVATE S16 cmAlloc(regionCb, size, flags, ptr, line, fileName, entId, hstReg) +Void *regionCb; +Size *size; +U32 flags; +Data **ptr; +U32 line; +U8 *fileName; +U8 entId; +Bool hstReg; +#endif +#endif /* SSI_DEBUG_LEVEL1 */ + +#else + +#ifdef SSI_DEBUG_LEVEL1 +#ifdef ANSI +PRIVATE S16 cmAlloc +( +Void *regionCb, +Size *size, +U32 flags, +Data **ptr, +U32 memType +) +#else +PRIVATE S16 cmAlloc(regionCb, size, flags, ptr, memType) +Void *regionCb; +Size *size; +U32 flags; +Data **ptr; +U32 memType; +#endif +#else +#ifdef ANSI +PRIVATE S16 cmAlloc +( +Void *regionCb, +Size *size, +U32 flags, +Data **ptr +) +#else +PRIVATE S16 cmAlloc(regionCb, size, flags, ptr) +Void *regionCb; +Size *size; +U32 flags; +Data **ptr; +#endif + +#endif +#endif /* SSI_DEBUG_LEVEL1 */ +/* cm_mem_c_001.main_15: Additions */ +#endif /* SS_HISTOGRAM_SUPPORT */ + +{ +/* cm_mem_c_001.main_26 : Fixes for Compilation Warnings */ +#ifndef USE_PURE + U16 idx; + CmMmBkt *bkt; + U16 bktIdx; +#endif + CmMmRegCb *regCb; +/* cm_mem_c_001.main_26 : Fixes for Compilation Warnings */ +#ifndef USE_PURE + U16 cnt; +#endif +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_MEM_LEAK_STS + Size reqSz; +#endif /* SS_MEM_LEAK_STS */ +/* cm_mem_c_001.main_12 - addition to hold the allocated block */ +#ifdef SSI_DEBUG_LEVEL1 + CmMmBlkHdr *alocBlk; +#endif /* SSI_DEBUG_LEVEL1 */ +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + S8 hstGrmBuf[256]; +#endif /* SS_HISTOGRAM_SUPPORT */ + + TRC2(cmAlloc); + +#ifndef USE_MEMCAL + UNUSED(flags); +#endif +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_MEM_LEAK_STS + reqSz = *size; +#endif /* SS_MEM_LEAK_STS */ + + regCb = (CmMmRegCb *)regionCb; + +#if (ERRCLASS & ERRCLS_INT_PAR) + + /* error check on parameters */ + if ((regCb == NULLP) || (size == NULLP) || !(*size) || (ptr == NULLP)) + { + RETVALUE(RFAILED); + } +#endif + +/* cm_mem_c_001.main_12 - addition for checking memType parameter */ +#ifdef SSI_DEBUG_LEVEL1 +#if (ERRCLASS & ERRCLS_INT_PAR) + if ((memType != CMM_STATIC_MEM_FLAG) && (memType != CMM_DYNAMIC_MEM_FLAG)) + { + RETVALUE(RFAILED); + } +#endif /* (ERRCLASS & ERRCLS_INT_PAR) */ +#endif /* SSI_DEBUG_LEVEL1 */ + +#ifndef USE_PURE + + if (flags) + num_times++; + +/* cm_mem_c_001.main_12 - addition to insert the size into hash list */ +#ifdef SSI_DEBUG_LEVEL1 + /* Update the hash list */ + if (cmMmHashListInsert(&(regCb->hashListCp), *size) != ROK) + { + /* display that, this entry could not be made in the hash list */ +#ifdef DEBUGP + /* display an error message here */ +/*cm_mem_c_001.main_23 Fix for specifier mismatch warnings in 64BIT compilation*/ +#ifdef ALIGN_64BIT + sprintf(dbgPrntBuf, "\n Could not make an entry for size %u in hash table of region %d \n", + *size, regCb->region); +#else + sprintf(dbgPrntBuf, "\n Could not make an entry for size %lu in hash table of region %d \n", + *size, regCb->region); +#endif + SDisplay(0, dbgPrntBuf); +#endif /* DEBUGP */ + } +#endif /* SSI_DEBUG_LEVEL1 */ + + /* + * Check if the requested size is less than or equal to the maximum block + * size in the bucket. + */ + if ( *size <= regCb->bktMaxBlkSize) + { + /* Get the map to the mapping table */ + idx = ((*size - 1) >> regCb->bktQnPwr); + +#if (ERRCLASS & ERRCLS_DEBUG) + if (regCb->mapTbl[idx].bktIdx == 0xFF) + { + /* Some fatal error in the map table initialization. */ + RETVALUE(RFAILED); + } +#endif + + /* Dequeue the memory block and return it to the user */ + bkt = &(regCb->bktTbl[bktIdx = regCb->mapTbl[idx].bktIdx]); + + cnt = 0; + /* While loop is introduced to use the "break statement inside */ + while (cnt < 1) + { + /* + * Check if the size request is not greater than the size available + * in the bucket + */ + if (*size > bkt->size) + { + /* Try to go to the next bucket if available */ + if((idx < (CMM_MAX_MAP_ENT - 1)) && + (regCb->mapTbl[++idx].bktIdx != 0xFF)) + { + bkt = &(regCb->bktTbl[bktIdx = regCb->mapTbl[idx].bktIdx]); + } + else + { + /* This is the last bucket, try to allocate from heap */ + break; + } + } + + /* Acquire the bucket lock */ + /* cm_mem_c_001.main_13 : Replaced SLock with WTLock for NT */ +#ifdef SS_WIN + (Void) WTLock(&(bkt->bktLock)); +#else + (Void) SLock(&(bkt->bktLock)); +#endif + +#if (ERRCLASS & ERRCLS_DEBUG) + regCb->mapTbl[idx].numReq++; +#endif /* (ERRCLASS & ERRCLS_DEBUG) */ + +/* cm_mem_c_001.main_12 - addition for sanity check before allocation */ +#ifdef SSI_DEBUG_LEVEL1 + /* increment the allocation attempt counter at bucket level */ + bkt->numAllocAttempts++; + + /* detect trampling if any and call sanity check. This is done for (bkt->nextBlk) as + the allocation is always from (bkt->nextBlk) */ + if (bkt->nextBlk) + { + if (cmMmRegIsBlkSane(bkt->nextBlk) != ROK) + { + /* detected a trampled memory block in this bucket */ + #ifdef DEBUGP + /* display an error message here */ +/*cm_mem_c_001.main_23 Fix for specifier mismatch warnings in 64BIT compilation*/ +#ifdef ALIGN_64BIT + sprintf(dbgPrntBuf, "Memory Trampling at: %8p, Bucket Id:%03d, size %u bytes \n", + (void *)bkt->nextBlk, regCb->mapTbl[idx].bktIdx, *size); +#else + sprintf(dbgPrntBuf, "Memory Trampling at: %8p, Bucket Id:%03d, size %lu bytes \n", + (void *)bkt->nextBlk, regCb->mapTbl[idx].bktIdx, *size); +#endif + SDisplay(0, dbgPrntBuf); + #endif /* DEBUGP */ + + if (cmMmBktSanityChk(bkt) == RTRAMPLINGNOK) + { + /* Release the lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock(&(bkt->bktLock)); +#else + (Void) SUnlock(&(bkt->bktLock)); +#endif + /* handle RTRAMPLINGNOK in SAlloc/SGetSBuf */ + RETVALUE(RTRAMPLINGNOK); + } + else + { + /* Release the lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock(&(bkt->bktLock)); +#else + (Void) SUnlock(&(bkt->bktLock)); +#endif + /* return RFAILED */ + RETVALUE(RFAILED); + } + } + } + + if ((bkt->nextBlk) && (*ptr = (Data *)(bkt->nextBlk) + (sizeof(CmMmBlkHdr)))) +#else + if ((*ptr = bkt->next)) +#endif /* SSI_DEBUG_LEVEL1 */ + { +/* cm_mem_c_001.main_12 - addition for header */ +#ifdef SSI_DEBUG_LEVEL1 + /* point to next block header */ + alocBlk = bkt->nextBlk; + bkt->nextBlk = (CmMmBlkHdr *)(bkt->nextBlk->nextBlk); +#else + bkt->next = *((CmMmEntry **)(bkt->next)); +#endif /* SSI_DEBUG_LEVEL1 */ + + /* + * Increment the statistics variable of number of memory block + * allocated + */ + bkt->numAlloc++; + if (bkt->numAlloc > bkt->maxAlloc) + { + bkt->maxAlloc = bkt->numAlloc; + } + { + if (g_overused[bktIdx] == 0 && OVERUSED(bkt)) + { + g_overused[bktIdx] = 1; + /*printf("cmAlloc: bktIdx %u overused %u numAlloc %u\n", bktIdx, g_overused[bktIdx], bkt->numAlloc); */ + } + } +#if 0 + if(bkt->numAlloc < 100) + printf("cmAlloc: Allocated PTR = %x size = %d\n", *ptr, *size); +#endif + +/* cm_mem_c_001.main_12 - addition for header manipulation */ +#ifdef SSI_DEBUG_LEVEL1 + /* update the size for which this memory block has been allocated */ + alocBlk->requestedSize = *size; + /* update the memory block header */ + CMM_RESET_FREE_FLAG(alocBlk->memFlags); + if (memType == CMM_STATIC_MEM_FLAG) + { + CMM_SET_STATIC_FLAG(alocBlk->memFlags); + /* add it to the static memory allocated */ + bkt->staticMemUsed += bkt->size; + } + else + { + CMM_SET_DYNAMIC_FLAG(alocBlk->memFlags); + /* add it to the dynamic memory allocated */ + bkt->dynamicMemUsed += bkt->size; + } +#endif /* SSI_DEBUG_LEVEL1 */ + + if (((bkt->size - (*size)) >> regCb->bktQnPwr) && flags) + { + bkt->bktNoFitCnt++; +#ifdef MEMCAL_DEBUG +/*cm_mem_c_001.main_23 Fix for specifier mismatch warnings in 64BIT compilation*/ +#ifdef ALIGN_64BIT + sprintf(prntBuf, + "[MEM_CAL_CNTA] %u bytes request not fitted in bkt %d [size %u bytes] %u times\n", *size, regCb->mapTbl[idx].bktIdx, bkt->size, bkt->bktNoFitCnt++); +#else + sprintf(prntBuf, + "[MEM_CAL_CNTA] %lu bytes request not fitted in bkt %d [size %lu bytes] %lu times\n", *size, regCb->mapTbl[idx].bktIdx, bkt->size, bkt->bktNoFitCnt++); +#endif + SDisplay(0, prntBuf); +#endif + } + +#ifdef MEMCAL_DEBUG + if (flags) + { + sprintf(prntBuf, + "SGetSBuf:%08lu:Size Bucket Id:%03d Times:%05lu Pointer: %8p\n", + *size, regCb->mapTbl[idx].bktIdx, num_times, *ptr); + SDisplay(0, prntBuf); + } +#endif /* MEMCAL_DEBUG */ + /* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + /* If If Tapa task (entId)is registerd for histogram then insert Memrory allocated + * information into the hash list */ + if(hstReg) + { + if (cmHstGrmAllocInsert(&(bkt->hstGrmHashListCp), bkt->size, size, line, fileName, entId) != ROK) + { + sprintf(hstGrmBuf, "Unable to Insert into the histgram hash list\n"); + SPrint(hstGrmBuf); + } + }/* End of if */ + +#endif /* SS_HISTOGRAM_SUPPORT */ + + /* Update the size parameter */ + *size = bkt->size; +#ifdef SS_MEM_LEAK_STS + /* cm_mem_c_001.main_25 - Fixed compilation warnings 32/64 bit */ + cmStorAllocBlk((PTR)*ptr, (Size) reqSz, (Size) *size, + regCb->mapTbl[idx].bktIdx); +#endif /* SS_MEM_LEAK_STS */ + + /* cm_mem_c_008.104 - Addition for memory calculator tool */ + + /* Release the lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock(&(bkt->bktLock)); +#else + (Void) SUnlock(&(bkt->bktLock)); +#endif + + RETVALUE(ROK); + } + else if (flags) + { + bkt->bktFailCnt++; +#ifdef MEMCAL_DEBUG +/*cm_mem_c_001.main_23 Fix for specifier mismatch warnings in 64BIT compilation*/ +#ifdef ALIGN_64BIT + sprintf(prntBuf, + "[MEM_CAL_CNTB] Allocation failed in bucket %d [ size %u bytes], %u times\n", regCb->mapTbl[idx].bktIdx, bkt->size, bkt->bktFailCnt); +#else + sprintf(prntBuf, + "[MEM_CAL_CNTB] Allocation failed in bucket %d [ size %lu bytes], %lu times\n", regCb->mapTbl[idx].bktIdx, bkt->size, bkt->bktFailCnt); +#endif + SDisplay(0, prntBuf); +#endif + } + +#if (ERRCLASS & ERRCLS_DEBUG) + regCb->mapTbl[idx].numFailure++; +#endif /* (ERRCLASS & ERRCLS_DEBUG) */ + + /* Release the lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock(&(bkt->bktLock)); +#else + (Void) SUnlock(&(bkt->bktLock)); +#endif + cnt = cnt + 1; + } + } + else + { + if (flags) + { + regCb->heapCb.heapAllocCnt++; +#ifdef MEMCAL_DEBUG +/*cm_mem_c_001.main_23 Fix for specifier mismatch warnings in 64BIT compilation*/ +#ifdef ALIGN_64BIT + sprintf(prntBuf, + "[MEM_CAL_CNTC] No bucket block configured for %u bytes \n Number of blocks allocated from heap = %u\n",*size, + regCb->heapCb.heapAllocCnt); +#else + sprintf(prntBuf, + "[MEM_CAL_CNTC] No bucket block configured for %lu bytes \n Number of blocks allocated from heap = %lu\n",*size, + regCb->heapCb.heapAllocCnt); +#endif + SDisplay(0, prntBuf); +#endif + } + } + + /* Memory not available in the bucket pool */ + if (regCb->heapFlag && (*size < regCb->heapSize)) + { +#ifdef MEMCAL_DEBUG + if (flags) tryHeap = 1; +#endif + /* + * The heap memory block is available. Allocate the memory block from + * heap pool. + */ +/* cm_mem_c_001.main_15: Additions */ +#ifdef SS_HISTOGRAM_SUPPORT +/* cm_mem_c_001.main_12 - addition for passing an extra parameter */ +#ifdef SSI_DEBUG_LEVEL1 + RETVALUE(cmHeapAlloc(&(regCb->heapCb), ptr, size, memType, line, fileName, entId, hstReg)); +#else + RETVALUE(cmHeapAlloc(&(regCb->heapCb), ptr, size, line, fileName, entId, hstReg)); +#endif /* SSI_DEBUG_LEVEL1 */ +#else +/* cm_mem_c_001.main_12 - addition for passing an extra parameter */ +#ifdef SSI_DEBUG_LEVEL1 + RETVALUE(cmHeapAlloc(&(regCb->heapCb), ptr, size, memType)); +#else + RETVALUE(cmHeapAlloc(&(regCb->heapCb), ptr, size)); +#endif /* SSI_DEBUG_LEVEL1 */ +#endif /* SS_HISTOGRAM_SUPPORT */ + } + + /* No memory available */ + RETVALUE(RFAILED); +#else /* use pure is on */ +/*cm_mem_c_001.main_27 SSI-4GMX specfic changes*/ +#ifdef SS_4GMX_LCORE + *ptr = (Data*) MxHeapAlloc(SsiHeap, *size); + cmMemset((U8*)ptr, 0, *size); +#else + *ptr = (Data*) malloc(*size); +#endif + if ( (*ptr) == NULLP) + RETVALUE(RFAILED); + avail_size -= *size; + RETVALUE(ROK); +#endif /* USE_PURE */ + +} /* end of cmAlloc */ + +#ifdef SS_MEM_WL_DEBUG +/* +* +* Fun: cmInitDoubleFreeList +* +* Desc: Initialize the hashlist used for detecting double free +* +* Ret: ROK - successful +* RFAILED - unsuccessful. +* +* Notes: +* +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmInitDoubleFreeList +( +Void +) +#else +PUBLIC S16 cmInitDoubleFreeList() +#endif +{ + U16 offset; + CmMemDoubleFree memNode; + + TRC2(cmInitDoubleFreeList); + + offset = (U16)((PTR)(&memNode.tmpListEnt) - (PTR)&memNode); + + if((cmHashListInit(&(memDoubleFree), 1000, offset, 0, + CM_HASH_KEYTYPE_U32MOD, 0, 0)) != ROK); + { + RETVALUE(RFAILED); + } + SInitLock(&memDoubleFreeLock, SS_LOCK_MUTEX); + + RETVALUE(ROK); +} + +#ifdef SS_MEM_WL_DEBUG +/* +* +* Fun: cmInitBtInfo +* +* Desc: Return the Dynamic memory block for the memory region. +* +* +* Ret: ROK - successful +* RFAILED - unsuccessful. +* +* Notes: +* +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PRIVATE S16 cmInitBtInfo +( +) +#else +PRIVATE S16 cmInitBtInfo (Void) +#endif +{ + regBtInfo = (CmBtInfo *)calloc(1, 8 * sizeof (CmBtInfo)); + if (regBtInfo == NULLP) + { + RETVALUE(RFAILED); + } + allocBtInfo = (CmBtInfo *)calloc(1, 8 * sizeof (CmBtInfo)); + if(allocBtInfo == NULLP) + { + RETVALUE(RFAILED); + } + + RETVALUE(ROK); +} +#endif /* SS_MEM_WL_DEBUG */ +/* +* +* Fun: cmAnalyseBtInfo +* +* Desc: Return the Dynamic memory block for the memory region. +* +* +* Ret: ROK - successful +* RFAILED - unsuccessful. +* +* Notes: +* +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PUBLIC Void cmAnalyseBtInfo +( +PTR ptr, /* Memory block needs to be freed */ +U32 idx +) +#else +PUBLIC Void cmAnalyseBtInfo (ptr,idx) +PTR ptr; /* Memory block needs to be freed */ +U32 idx; +#endif +{ + U32 tmpCnt; + U32 btIdx; + CmBtInfo *btInfo; + U8 regIdx; + +#if 0 + for(regIdx = 0; regIdx < 8; regIdx++) + { + btInfo = & regBtInfo[regIdx]; + btIdx = btInfo->btInfoIdx; + + for (tmpCnt = 0; tmpCnt < NUM_FREE_BUFFERS; tmpCnt++) + { +#if 0 + if ((btInfo->btInfo[btIdx].ptr >= ptr) && + (btInfo->btInfo[btIdx].ptr + 128 ) >= ptr) + +#endif + if(btInfo->btInfo[btIdx].btSize != 0) + { + U32 i; + char **strings; + strings = backtrace_symbols( btInfo->btInfo[btIdx].btArr,btInfo->btInfo[btIdx].btSize); + printf("*** Last Free Region = %d PTR %x Timestamp sec = (%ld) usec = (%ld) ***\n", idx, ptr, btInfo->btInfo[btIdx].timeStamp.tv_sec, btInfo->btInfo[btIdx].timeStamp.tv_usec); + for (i=0; i < btInfo->btInfo[btIdx].btSize; i++) + { + printf("%s\n", strings[i]); + } + printf("*******************************************************\n"); + + free(strings); + } + + btIdx--; + if (btIdx == 0) + { + btIdx = NUM_FREE_BUFFERS - 1; + } + } + } +#endif + + +/* for(regIdx = 0; regIdx < 8; regIdx++) + { */ + idx = 2; + btInfo = &allocBtInfo[idx]; + btIdx = btInfo->btInfoIdx; + + for (tmpCnt = 0; tmpCnt < NUM_FREE_BUFFERS; tmpCnt++) + { +/* if ((btInfo->btInfo[btIdx].ptr >= ptr) && + (btInfo->btInfo[btIdx].ptr + 128 ) >= ptr) */ + if(btInfo->btInfo[btIdx].btSize != 0) + { + U32 i; + char **strings; + strings = backtrace_symbols( btInfo->btInfo[btIdx].btArr,btInfo->btInfo[btIdx].btSize); + printf("*** Last Allocation Region = %d PTR %x Timestamp sec = (%ld) usec = (%ld) ***\n", idx, ptr, btInfo->btInfo[btIdx].timeStamp.tv_sec, btInfo->btInfo[btIdx].timeStamp.tv_usec); + for (i=0; i < btInfo->btInfo[btIdx].btSize; i++) + { + printf("%s\n", strings[i]); + } + printf("*******************************************************\n"); + + free(strings); + } + + btIdx--; + if (btIdx == 0) + { + btIdx = NUM_FREE_BUFFERS - 1; + } + } +/* } */ + + RETVOID; +} +#endif + +#ifndef SS_USE_ICC_MEMORY +/* +* +* Fun: cmDynFreeWithLock +* +* Desc: Return the Dynamic memory block for the memory region. +* +* +* Ret: ROK - successful +* RFAILED - unsuccessful. +* +* Notes: +* +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PRIVATE S16 cmDynFreeWithLock +( +Void *regionCb, /* Pointer to region cb */ +Data *ptr, /* Memory block needs to be freed */ +Size size /* Size of the block */ +) +#else +PRIVATE S16 cmDynFreeWithLock(regionCb, ptr, size) +Void *regionCb; /* Pointer to region cb */ +Data *ptr; /* Memory block needs to be freed */ +Size size; /* Size of the block */ +#endif +{ + S16 ret; + + if((SLock(&dynAllocFreeLock)) != ROK) + { + printf("dynAllocWithLock: Failed to get the DYN lock\n"); + RETVALUE(RFAILED); + } + + ret = cmDynFree(regionCb, ptr,size); + + if((SUnlock(&dynAllocFreeLock)) != ROK) + { + printf("dynAllocWithLock: Failed to unlock the dyn lock\n"); + RETVALUE(RFAILED); + } + + RETVALUE(ret); + +} /* end of cmDynFree */ + +/* +* +* Fun: cmDynFree +* +* Desc: Return the Dynamic memory block for the memory region. +* +* +* Ret: ROK - successful +* RFAILED - unsuccessful. +* +* Notes: +* +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PRIVATE S16 cmDynFree +( +Void *regionCb, /* Pointer to region cb */ +Data *ptr, /* Memory block needs to be freed */ +Size size /* Size of the block */ +) +#else +PRIVATE S16 cmDynFree(regionCb, ptr, size) +Void *regionCb; /* Pointer to region cb */ +Data *ptr; /* Memory block needs to be freed */ +Size size; /* Size of the block */ +#endif +{ + CmMmDynRegCb *regCb; +#ifndef USE_PURE + U32 idx; + U32 bktIdx; + CmMmDynBktCb *bkt = NULLP; + CmMmBlkSetElement *dynMemElem; +#endif +#ifdef SS_MEM_WL_DEBUG + U8 tmpBktIdx; + U8 tmpVal; +#endif + + TRC2(cmDynFree); + + regCb = (CmMmDynRegCb *)regionCb; +#ifdef SS_MEM_WL_DEBUG + if((tmpRegTidMap[regCb->region] != (pthread_self()))) + { + bkt->size = 10; + } +#endif + +#ifndef USE_PURE +#if (ERRCLASS & ERRCLS_INT_PAR) + /* error check on parameters */ + if ((regCb == NULLP) || (!size) || (ptr == NULLP)) + { + RETVALUE(RFAILED); + } + + /* Check if the memory block is from the memory region */ + if (ptr >= ((CmMmRegCb *)regCb)->regInfo.start + + ((CmMmRegCb *)regCb)->regInfo.size) + { + RETVALUE(RFAILED); + } + /* cm_mem_c_001.main_20 Addition */ + if (ptr < regCb->regInfo.start) + { + RETVALUE(RFAILED); + } + +#endif + +#ifdef SS_MEM_WL_DEBUG + ptr -= sizeof (U32); + size += 4; +#endif + /* The memory block was allocated from the bucket pool */ + + /* Get the map to the mapping table */ + idx = ((size - 1) >> regCb->bktQnPwr); + +#if (ERRCLASS & ERRCLS_DEBUG) + if (regCb->mapTbl[idx].bktIdx == 0xFF) + { + /* Some fatal error in the map table initialization. */ + RETVALUE(RFAILED); + } +#endif + + /* Enqueue the memory block and return it to the user */ + bkt = &(regCb->bktTbl[bktIdx = regCb->mapTbl[idx].bktIdx]); + + /* + * Check if the size is not greater than the size available + * in the bucket. If so, then the buffer must have been allocated + * from next bucket. We don't need to check the validity of the + * next bucket, otherwise buffer must have been allocated from heap + * pool. + */ +#ifdef SS_MEM_WL_DEBUG + if (size > bkt->size) + { + printf("Size = %d bucket size = %d\n", size, bkt->size); + exit(-1); + bkt = &(regCb->bktTbl[bktIdx = regCb->mapTbl[++idx].bktIdx]); + } + if(size > bkt->size) + { + printf("2nd time Size = %d bucket size = %d\n", size, bkt->size); + exit(-1); + U8 *tmpptr = NULLP; + printf("Bucket Size wrong \n"); + *tmpptr = 10; + } +#endif + + dynMemElem = cmGetMemBlkSetForFree(bktIdx, bkt); + + /* Check if the bucket index, if its not valid, return failure */ + if(dynMemElem == NULLP) + { + RETVALUE(RFAILED); + } + +#ifdef SS_MEM_WL_DEBUG + tmpBktIdx = (U8)*ptr; + tmpVal = (U8)*(ptr+1); + + if ((tmpBktIdx != bktIdx) || (tmpVal != 0xde)) + { + U8 *tmpptr = NULLP; + printf("bktIdx wrong \n"); + *tmpptr = 10; + } + + if ((bktIdx == 0) && (!stopBtInfo)) + { + CmBtInfo *btInfo; + U32 btIdx; + btInfo = ®BtInfo[regCb->region]; + btIdx = btInfo->btInfoIdx; + btInfo->btInfo[btIdx].ptr = (PTR) ptr; + { + btInfo->btInfo[btIdx].btSize = backtrace(btInfo->btInfo[btIdx].btArr, NUM_BT_TRACES); + } +#if 0 + cmRemoveAllocPtrFromList(regCb, (ptr + sizeof(U32))); +#endif + gettimeofday(&(btInfo->btInfo[btIdx].timeStamp), NULLP); + + btIdx++; + btIdx &= (NUM_FREE_BUFFERS - 1); + + btInfo->btInfo[btIdx].ptr = (PTR)0; + btInfo->btInfo[btIdx].btSize = 0; + cmMemset(btInfo->btInfo[bktIdx].btArr, 0, sizeof (btInfo->btInfo[bktIdx].btArr)); + btInfo->btInfoIdx = btIdx; + } + + if(prvAllocPtr[regCb->region] == ptr) + { + prvAllocPtr[regCb->region] = NULLP; + } + + cmMemset(ptr, (regCb->region+1), bkt->size); +#endif + + /* Get the bucket node from the index returned and allocate the memory */ + *((CmMmEntry **)ptr) = dynMemElem->nextBktPtr; + dynMemElem->nextBktPtr = ptr; + dynMemElem->numFreeBlks++; + + RETVALUE(ROK); + +#else /* use pure is on */ + TRC2(cmDynFree); +/*cm_mem_c_001.main_27 SSI-4GMX specfic changes*/ +#ifdef SS_4GMX_LCORE + (Void)MxHeapFree(SsiHeap, ptr); +#else + /* (Void)free(ptr); */ +#endif +/* avail_size += size; */ + free(ptr); + + RETVALUE(ROK); +#endif /* USE_PURE */ + + +} /* end of cmDynFree */ +#endif /* SS_USE_ICC_MEMORY */ + + + +/* +* +* Fun: cmFree +* +* Desc: Return the memory block for the memory region. +* +* +* Ret: ROK - successful +* RFAILED - unsuccessful. +* +* Notes: The user calls this function to return the previously allocated +* memory block to the memory region. The memory manager does not +* check the validity of the state of the memory block(like whether +* it was allocated earlier). The caller must be sure that, the +* address specified in the parameter 'ptr' is valid and was +* allocated previously from same region. +* +* +* File: cm_mem_wl.c +* +*/ + +/* cm_mem_c_001.main_15 : Additions */ +#ifdef T2K_MEM_LEAK_DBG +PRIVATE S16 cmFree +( + Void *regionCb, + Data *ptr, + Size size, + char* file, + U32 line +) +#else +#ifdef SS_HISTOGRAM_SUPPORT +#ifdef ANSI +PRIVATE S16 cmFree +( +Void *regionCb, +Data *ptr, +Size size, +U32 line, +U8 *fileName, +U8 entId, +Bool hstReg +) +#else +PRIVATE S16 cmFree(regionCb, ptr, size, line, fileName, entId, hstReg) +Void *regionCb; +Data *ptr; +Size size; +U32 line; +U8 *fileName; +U8 entId; +Bool hstReg; +#endif + +#else + +#ifdef ANSI +PRIVATE S16 cmFree +( +Void *regionCb, +Data *ptr, +Size size +) +#else +PRIVATE S16 cmFree(regionCb, ptr, size) +Void *regionCb; +Data *ptr; +Size size; +#endif +#endif +/* cm_mem_c_001.main_15 : Additions */ +#endif /* SS_HISTOGRAM_SUPPORT */ + +{ +/* cm_mem_c_001.main_26 : Fixes for Compilation Warnings */ +#ifndef USE_PURE + U16 idx; + CmMmBkt *bkt; + U16 bktIdx; +#endif + CmMmRegCb *regCb; +/* cm_mem_c_001.main_12 - addition for holding the free pointer */ +#ifdef SSI_DEBUG_LEVEL1 + CmMmBlkHdr *ptrHdr; +#endif /* SSI_DEBUG_LEVEL1 */ +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + S8 hstGrmBuf[256]; +#endif /* SS_HISTOGRAM_SUPPORT */ + + TRC2(cmFree); + + regCb = (CmMmRegCb *)regionCb; + +#ifndef USE_PURE +#if (ERRCLASS & ERRCLS_INT_PAR) + + /* error check on parameters */ + if ((regCb == NULLP) || (!size) || (ptr == NULLP)) + { + RETVALUE(RFAILED); + } + + /* Check if the memory block is from the memory region */ + if (ptr >= ((CmMmRegCb *)regCb)->regInfo.start + + ((CmMmRegCb *)regCb)->regInfo.size) + { + RETVALUE(RFAILED); + } + /* cm_mem_c_001.main_20 Addition */ + if (ptr < regCb->regInfo.start) + { + RETVALUE(RFAILED); + } + +#endif + + /* + * Check if the memory block was allocated from the bucket pool. + */ + if(ptr < regCb->regInfo.start) + { + Buffer *tmpBuffer = NULLP; + tmpBuffer->b_cont = NULLP; + } + + if (ptr < (regCb->regInfo.start + regCb->bktSize)) + { + /* The memory block was allocated from the bucket pool */ + + /* Get the map to the mapping table */ + idx = ((size - 1) >> regCb->bktQnPwr); + +#if (ERRCLASS & ERRCLS_DEBUG) + if (regCb->mapTbl[idx].bktIdx == 0xFF) + { + /* Some fatal error in the map table initialization. */ + RETVALUE(RFAILED); + } +#endif + + /* Enqueue the memory block and return it to the user */ + bkt = &(regCb->bktTbl[bktIdx = regCb->mapTbl[idx].bktIdx]); + + /* + * Check if the size is not greater than the size available + * in the bucket. If so, then the buffer must have been allocated + * from next bucket. We don't need to check the validity of the + * next bucket, otherwise buffer must have been allocated from heap + * pool. + */ + if (size > bkt->size) + { + bkt = &(regCb->bktTbl[bktIdx = regCb->mapTbl[++idx].bktIdx]); + } + + /* Acquire the bucket lock */ + /* cm_mem_c_001.main_13 : Replaced SLock with WTLock for NT */ +#ifdef SS_WIN + (Void) WTLock(&(bkt->bktLock)); +#else + (Void) SLock(&(bkt->bktLock)); +#endif + +/* cm_mem_c_001.main_12 - addition for sanity check and free */ +#ifdef SSI_DEBUG_LEVEL1 + /* increment the dealloc attempt counter at bucket level */ + bkt->numDeallocAttempts++; + + /* Check the memFlags to see whether this block was allocated */ + ptrHdr = (CmMmBlkHdr *) (ptr - sizeof(CmMmBlkHdr)); + + /* validate the block to be freed for trampling */ + if (cmMmRegIsBlkSane(ptrHdr) != ROK) + { + /* Handle error case of Memory trampling */ + #ifdef DEBUGP + /* display an error message here */ +/*cm_mem_c_001.main_23 Fix for specifier mismatch warnings in 64BIT compilation*/ +#ifdef ALIGN_64BIT + sprintf(dbgPrntBuf, "Memory Trampling at: %8p, Bucket Id:%03d, size %u bytes \n", + ptr, regCb->mapTbl[idx].bktIdx, bkt->size); +#else + sprintf(dbgPrntBuf, "Memory Trampling at: %8p, Bucket Id:%03d, size %lu bytes \n", + ptr, regCb->mapTbl[idx].bktIdx, bkt->size); +#endif + SDisplay(0, dbgPrntBuf); + #endif /* DEBUGP */ + /* + * if sanity check returns RTRAMPLINGOK then there is nothing to do + * as the memory blk is already invalidated in cmMmBktSanityChk + */ + if (cmMmBktSanityChk(bkt) == RTRAMPLINGOK) + { + bkt->numAlloc--; + + /* Release the lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock(&(bkt->bktLock)); +#else + (Void) SUnlock(&(bkt->bktLock)); +#endif + + RETVALUE(ROK); + } + else + { + /* + * this is the case where in the entire bucket has been made unusable + * Release the lock + */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock(&(bkt->bktLock)); +#else + (Void) SUnlock(&(bkt->bktLock)); +#endif + + /* handle RTRAMPLINGNOK in SFree/SPutSBuf */ + RETVALUE(RTRAMPLINGNOK); + } + } + + /* reset the size */ + ptrHdr->requestedSize = 0; + /* check if the block to be freed is already having the state as FREE */ + if (CMM_IS_FREE(ptrHdr->memFlags)) + { + /* Handle double deallocation error case */ + #ifdef DEBUGP + /* display an error message here */ +/*cm_mem_c_001.main_23 Fix for specifier mismatch warnings in 64BIT compilation*/ +#ifdef ALIGN_64BIT + sprintf(dbgPrntBuf, "Attempt to double deallocate memory at: %8p, Bucket Id:%03d, size %u bytes \n", + ptr, regCb->mapTbl[idx].bktIdx, bkt->size); +#else + sprintf(dbgPrntBuf, "Attempt to double deallocate memory at: %8p, Bucket Id:%03d, size %lu bytes \n", + ptr, regCb->mapTbl[idx].bktIdx, bkt->size); +#endif + SDisplay(0, dbgPrntBuf); + #endif /* DEBUGP */ + + /* Release the lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock(&(bkt->bktLock)); +#else + (Void) SUnlock(&(bkt->bktLock)); +#endif + + /* handle RDBLFREE in SFree/SPutSBuf */ + RETVALUE(RDBLFREE); + } + if (CMM_IS_STATIC(ptrHdr->memFlags)) + { + CMM_SET_FREE_FLAG(ptrHdr->memFlags); + CMM_RESET_STATIC_FLAG(ptrHdr->memFlags); + /* deduct it from the static memory count */ + bkt->staticMemUsed -= bkt->size; + } + else if (CMM_IS_DYNAMIC(ptrHdr->memFlags)) + { + CMM_SET_FREE_FLAG(ptrHdr->memFlags); + CMM_RESET_DYNAMIC_FLAG(ptrHdr->memFlags); + /* deduct it from the dynamic memory count */ + bkt->dynamicMemUsed -= bkt->size; + } + else + { + /* This is a case similar to trampled memory */ + #ifdef DEBUGP +/*cm_mem_c_001.main_23 Fix for specifier mismatch warnings in 64BIT compilation*/ +#ifdef ALIGN_64BIT + sprintf(dbgPrntBuf, "Invalid memory flag: %u !!!\n", ptrHdr->memFlags); +#else + sprintf(dbgPrntBuf, "Invalid memory flag: %lu !!!\n", ptrHdr->memFlags); +#endif + SDisplay(0, dbgPrntBuf); + #endif /* DEBUGP */ + if (cmMmBktSanityChk(bkt) == RTRAMPLINGOK) + { + /* do not add to the free list */ + bkt->numAlloc--; + + /* Release the lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock(&(bkt->bktLock)); +#else + (Void) SUnlock(&(bkt->bktLock)); +#endif + RETVALUE(ROK); + } + else + { + /* + * this is the case where in the entire bucket has been made unusable + * Release the lock + */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock(&(bkt->bktLock)); +#else + (Void) SUnlock(&(bkt->bktLock)); +#endif + + /* handle RTRAMPLINGNOK in SFree/SPutSBuf */ + RETVALUE(RTRAMPLINGNOK); + } + } + + /* Return the block to memory */ + ptrHdr->nextBlk = bkt->nextBlk; + bkt->nextBlk = ptrHdr; +#else + /* MS_REMOVE */ +#if 0 + /* sriky: For debugging double deallocation */ + cmMemset(ptr, 0, 50); +#endif + *((CmMmEntry **)ptr) = bkt->next; + bkt->next = (CmMmEntry *)ptr; +#endif /* SSI_DEBUG_LEVEL1 */ + +#if 0 + if(bkt->numAlloc <= 0 || bkt->numAlloc > 12000) + { + void *array[10]; + size_t tmpsize, i; + char **strings; + + printf("\n cmFree: Freed pointer = %x and backtrace:\n", ptr); + printf("****************************************\n"); + tmpsize = backtrace(array, 10); + strings = backtrace_symbols(array, tmpsize); + for(i = 0; i < tmpsize; i++) + printf("%s\n", strings[i]); + printf("****************************************\n"); + free(strings); + } +#endif + /* + * Decrement the statistics variable of number of memory block + * allocated + */ + if(bkt->numAlloc) + { + bkt->numAlloc--; + } + { + if (g_overused[bktIdx] == 1 && !OVERUSED(bkt)) + { + g_overused[bktIdx] = 0; + /*printf("cmFree: bktIdx %u overused %u numAlloc %u\n", bktIdx, g_overused[bktIdx], bkt->numAlloc); */ + } + } +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + /* If If Tapa task (entId)is registerd for histogram then insert Memrory Freed + * information into the hash list */ + if(hstReg) + { + if (cmHstGrmFreeInsert(&bkt->hstGrmHashListCp, bkt->size, line, fileName, entId) != ROK) + { + sprintf(hstGrmBuf, "Unable to Insert into the histgram hash list\n"); + SPrint(hstGrmBuf); + } + }/* End of if */ +#endif /* SS_HISTOGRAM_SUPPORT */ + +#ifdef SS_MEM_LEAK_STS + /* cm_mem_c_001.main_25 - Fixed compilation warnings 32/64 bit */ + cmRlsAllocBlk((PTR)ptr); +#endif /* SS_MEM_LEAK_STS */ + + /* Release the lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock(&(bkt->bktLock)); +#else + (Void) SUnlock(&(bkt->bktLock)); +#endif + + RETVALUE(ROK); + } + + /* The memory block was allocated from the heap pool */ +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + RETVALUE(cmHeapFree (&(regCb->heapCb), ptr, size, line, fileName, entId, hstReg)); +#else + RETVALUE(cmHeapFree (&(regCb->heapCb), ptr, size)); +#endif /* SS_HISTOGRAM_SUPPORT */ +#else /* use pure is on */ + TRC2(cmFree); +/*cm_mem_c_001.main_27 SSI-4GMX specfic changes*/ +#ifdef SS_4GMX_LCORE + (Void)MxHeapFree(SsiHeap, ptr); +#else + (Void)free(ptr); +#endif + avail_size += size; + RETVALUE(ROK); +#endif /* USE_PURE */ + + +} /* end of cmFree */ + + +/* +* +* Fun: cmAllocWL +* +* Desc: alloc without lock +* +* +* Ret: ROK - successful +* RFAILED - unsuccessful. +* +* +* File: cm_mem_wl.c +* +*/ +/*cm_mem_c_001.main_21-added new function*/ +/*cm_mem_c_001.main_23 Removed support of SSI_DEBUG_LEVEL1 and SS_HISTOGRAM_SUPPORT for SS_FAP*/ +#ifdef T2K_MEM_LEAK_DBG +PRIVATE S16 cmAllocWL +( +Void *regionCb, +Size *size, +U32 flags, +Data **ptr , +char* file, +U32 line +) +#else +#ifdef ANSI +PRIVATE S16 cmAllocWL +( +Void *regionCb, +Size *size, +U32 flags, +Data **ptr +) +#else +PRIVATE S16 cmAllocWL(regionCb, size, flags, ptr) +Void *regionCb; +Size *size; +U32 flags; +Data **ptr; +#endif +#endif +{ +#ifndef USE_PURE + U16 idx; + CmMmBkt *bkt = NULLP; +#endif + CmMmRegCb *regCb; + /*cm_mem_c_001.main_23 Removed support of SSI_DEBUG_LEVEL1 and SS_HISTOGRAM_SUPPORT for SS_FAP*/ + + TRC2(cmAllocWL); + + /*cm_mem_c_001.main_23 Removed support of USE_MEMCAL and MEMCAL_DEBUG support for SS_FAP*/ + + regCb = (CmMmRegCb *)regionCb; + +#ifdef SS_MEM_WL_DEBUG + if((tmpRegTidMap[regCb->region] != (pthread_self()))) + { + bkt->size = 10; + } +#endif + +#if (ERRCLASS & ERRCLS_INT_PAR) + + /* error check on parameters */ + if ((regCb == NULLP) || (size == NULLP) || !(*size) || (ptr == NULLP)) + { + RETVALUE(RFAILED); + } +#endif + + /*cm_mem_c_001.main_23 Removed support of SSI_DEBUG_LEVEL1 and SS_HISTOGRAM_SUPPORT for SS_FAP*/ + +#ifndef USE_PURE + + /* + * Check if the requested size is less than or equal to the maximum block + * size in the bucket. + */ +#ifdef MSPD_T2K_TRACK_BUG + *size += 4; +#endif + /* cm_mem_c_001.main_23 Adding check to compair size with Maximum block size*/ + if ( *size <= regCb->bktMaxBlkSize) + { + /* Get the map to the mapping table */ + idx = ((*size - 1) >> regCb->bktQnPwr); + + /* Dequeue the memory block and return it to the user */ + bkt = &(regCb->bktTbl[regCb->mapTbl[idx].bktIdx]); + + { + /* + * Check if the size request is not greater than the size available + * in the bucket + */ + /* cm_mem_c_001.main_23 combined If(*size <= bkt->size) and if(*ptr = bkt->next)*/ + if ((*size <= bkt->size)&&(*ptr = bkt->next)) + { + /* Try to go to the next bucket if available */ + bkt->next = *((CmMmEntry **)(bkt->next)); + + /* + * Increment the statistics variable of number of memory block + * allocated + */ + bkt->numAlloc++; + if (bkt->numAlloc > bkt->maxAlloc) + { + bkt->maxAlloc = bkt->numAlloc; + } + +#ifdef MSPD_T2K_TRACK_BUG + *(*ptr + 0) = 0xDE; + *(*ptr + 1) = 0xAD; + *(*ptr + 2) = 0xBE; + *(*ptr + 3) = 0xEF; + + (*ptr) += 4; +#endif + + /* Update the size parameter */ + *size = bkt->size; + + RETVALUE(ROK); + } + } + } + + /* Memory not available in the bucket pool */ + if (regCb->heapFlag && (*size < regCb->heapSize)) + { + /*cm_mem_c_001.main_23 Removed support of and MEMCAL_DEBUG support for SS_FAP*/ + /* + * The heap memory block is available. Allocate the memory block from + * heap pool. + */ + /*cm_mem_c_001.main_23 Removed support of SSI_DEBUG_LEVEL1 and SS_HISTOGRAM_SUPPORT for SS_FAP*/ + RETVALUE(cmHeapAlloc(&(regCb->heapCb), ptr, size)); + } + + /* No memory available */ + RETVALUE(RFAILED); +#else /* use pure is on */ +/*cm_mem_c_001.main_27 SSI-4GMX specfic changes*/ +#ifdef SS_4GMX_LCORE + *ptr = (Data*) MxHeapAlloc(SsiHeap, *size); + cmMemset((U8*)ptr, 0, *size); +#else +/* *ptr = (Data*) malloc(*size); */ +#endif + *ptr = (Data *)malloc(*size); + + if ( (*ptr) == NULLP) + RETVALUE(RFAILED); +/* avail_size -= *size; */ + RETVALUE(ROK); +#endif /* USE_PURE */ + +} /* end of cmAllocWL */ + + +/* +* +* Fun: cmfree +* +* Desc: free without lock +* +* +* Ret: ROK - successful +* RFAILED - unsuccessful. +* +* +* File: cm_mem_wl.c +* +*/ + +#ifdef T2K_MEM_LEAK_DBG +PRIVATE S16 cmFreeWL +( +Void *regionCb, +Data *ptr, +Size size, +char* file, +U32 line +) +#else +#ifdef ANSI +PRIVATE S16 cmFreeWL +( +Void *regionCb, +Data *ptr, +Size size +) +#else +PRIVATE S16 cmFreeWL(regionCb, ptr, size) +Void *regionCb; +Data *ptr; +Size size; +#endif +#endif +{ +#ifndef USE_PURE + U16 idx; + CmMmBkt *bkt = NULLP; +#endif + CmMmRegCb *regCb; + /*cm_mem_c_001.main_23 Removed support of SSI_DEBUG_LEVEL1 and SS_HISTOGRAM_SUPPORT for SS_FAP*/ + + TRC2(cmFreeWL); + + regCb = (CmMmRegCb *)regionCb; + +#ifdef SS_MEM_WL_DEBUG + if(tmpRegTidMap[regCb->region] != (pthread_self())) + { + bkt->size = 10; + } +#endif + +#ifndef USE_PURE +#if (ERRCLASS & ERRCLS_INT_PAR) + + /* error check on parameters */ + if ((regCb == NULLP) || (!size) || (ptr == NULLP)) + { + RETVALUE(RFAILED); + } + + /* Check if the memory block is from the memory region */ + if (ptr >= ((CmMmRegCb *)regCb)->regInfo.start + + ((CmMmRegCb *)regCb)->regInfo.size) + { + RETVALUE(RFAILED); + } + +#endif + + /* + * Check if the memory block was allocated from the bucket pool. + */ +#if 0 + if(ptr < regCb->regInfo.start) + { + Buffer *tmpbuf = NULLP; + tmpbuf->b_cont = NULLP; + } +#endif + +#ifdef MSPD_T2K_TRACK_BUG + size += 4; +#endif + + if (ptr < (regCb->regInfo.start + regCb->bktSize)) + { + /* The memory block was allocated from the bucket pool */ + + /* Get the map to the mapping table */ + idx = ((size - 1) >> regCb->bktQnPwr); + +#if (ERRCLASS & ERRCLS_DEBUG) + if (regCb->mapTbl[idx].bktIdx == 0xFF) + { + /* Some fatal error in the map table initialization. */ + RETVALUE(RFAILED); + } +#endif + + /* Enqueue the memory block and return it to the user */ + bkt = &(regCb->bktTbl[regCb->mapTbl[idx].bktIdx]); + +#ifdef MSPD_T2K_TRACK_BUG + ptr -= 4; + if((ptr[0] != 0xDE) || (ptr[1] != 0xAD) || (ptr[2] != 0xBE) || (ptr[3] != 0xEF)) + { + char *abc = NULLP; + *abc = 100; + } +#endif + /* + * Check if the size is not greater than the size available + * in the bucket. If so, then the buffer must have been allocated + * from next bucket. We don't need to check the validity of the + * next bucket, otherwise buffer must have been allocated from heap + * pool. + */ + if (size > bkt->size) + { + bkt = &(regCb->bktTbl[regCb->mapTbl[++idx].bktIdx]); + } + + /*cm_mem_c_001.main_23 Removed support of SSI_DEBUG_LEVEL1 and SS_HISTOGRAM_SUPPORT for SS_FAP*/ + *((CmMmEntry **)ptr) = bkt->next; + bkt->next = (CmMmEntry *)ptr; + + /* + * Decrement the statistics variable of number of memory block + * allocated + */ + bkt->numAlloc--; + +#if 0 + if ((regCb->region == 2) && (bkt->numAlloc < 50)) + { + CmBtInfo *btInfo; + U32 btIdx; + btInfo = &allocBtInfo[regCb->region]; + btIdx = btInfo->btInfoIdx; + btInfo->btInfo[btIdx].ptr = (PTR) *ptr; + { + btInfo->btInfo[btIdx].btSize = backtrace(btInfo->btInfo[btIdx].btArr, NUM_BT_TRACES); + } +#if 0 + gettimeofday(&(btInfo->btInfo[btIdx].timeStamp), NULLP); + cmInsertAllocPtrToList(regCb, (PTR)*ptr); +#endif + + btIdx++; + btIdx &= (NUM_FREE_BUFFERS - 1); + + btInfo->btInfo[btIdx].ptr = (PTR)0; + btInfo->btInfo[btIdx].btSize = 0; + cmMemset(btInfo->btInfo[regCb->mapTbl[idx].bktIdx].btArr, 0, sizeof (btInfo->btInfo[regCb->mapTbl[idx].bktIdx].btArr)); + btInfo->btInfoIdx = btIdx; + } +#endif + + RETVALUE(ROK); + } + + /* The memory block was allocated from the heap pool */ + RETVALUE(cmHeapFree (&(regCb->heapCb), ptr, size)); +#else /* use pure is on */ + TRC2(cmFree); +/*cm_mem_c_001.main_27 SSI-4GMX specfic changes*/ +#ifdef SS_4GMX_LCORE + (Void)MxHeapFree(SsiHeap, ptr); +#else +/* (Void)free(ptr); */ +#endif +/* avail_size += size; */ + free(ptr); + + RETVALUE(ROK); +#endif /* USE_PURE */ + + +} /* end of cmFreeWL */ + + +/* +* +* Fun: cmCtl +* +* Desc: Control request function. +* +* +* Ret: ROK - successful +* RFAILED - unsuccessful. +* +* Notes: The current semantics of the control function is defined for two +* types of events: virtual address to physical address translation +* and memory resource check. +* +* The physical address translation is valid only for the memory +* region physically contiguous and non pagable. +* +* +* +* File: cm_mem_wl.c +* +*/ + +#ifdef ANSI +PRIVATE S16 cmCtl +( +Void *regionCb, +Event event, +SMemCtl *memCtl +) +#else +PRIVATE S16 cmCtl(regionCb, event, memCtl) +Void *regionCb; +Event event; +SMemCtl *memCtl; +#endif +{ + CmMmRegCb *regCb; + + TRC2(cmCtl); + + regCb = (CmMmRegCb *)regionCb; + +#if (ERRCLASS & ERRCLS_INT_PAR) + + /* error check on parameters */ + if ((regCb == NULLP) || (memCtl == NULLP)) + { + RETVALUE(RFAILED); + } + +#endif + + switch (event) + { + case SS_MEM_V_TO_P: + { + Size offset; + +#if (ERRCLASS & ERRCLS_INT_PAR) + if ((memCtl->u.vtop.vaddr == NULLP) || + (memCtl->u.vtop.paddr == NULLP)) + { + RETVALUE(RFAILED); + } +#endif + + /* Check if the virtual to physical address translation is valid */ + if (regCb->chFlag & CMM_REG_PHY_VALID) + { + offset = memCtl->u.vtop.vaddr - regCb->regInfo.start; + *(memCtl->u.vtop.paddr) = regCb->pAddr + offset; + + RETVALUE(ROK); + } + break; + } + + case SS_MEM_CHK_RES: + { + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (!(memCtl->u.chkres.size) || + (memCtl->u.chkres.status == NULLP)) + { + RETVALUE(RFAILED); + } +#endif +#ifndef USE_PURE + /* Check if the Bucket pool is configured */ + if (regCb->bktSize) + { + U16 idx; + CmMmBkt *bkt; + U32 avlSize, totSize; + /* + * The bucket pool is configured. The status value returned + * does reflect on the memory availabilty in the bucket pool. + * The value does not consider the available memory in the + * heap pool. + */ + idx = ((memCtl->u.chkres.size - 1) >> regCb->bktQnPwr); + bkt = &(regCb->bktTbl[regCb->mapTbl[idx].bktIdx]); + avlSize = (bkt->numBlks - bkt->numAlloc) * bkt->size; + avlSize += regCb->heapCb.avlSize; + totSize = (bkt->numBlks * bkt->size) + regCb->heapSize; + *(memCtl->u.chkres.status) = (avlSize/(totSize/10)); + } + else + { + /* Bucket pool not configured */ + + /* + * Find the percentage memory available in the heap pool. The value + * does not consider the fragmentation of the heap pool. + */ + *(memCtl->u.chkres.status) = ((regCb->heapCb.avlSize) / + (regCb->heapSize/10)); + } + + RETVALUE(ROK); +#else /* use pure is on */ + *(memCtl->u.chkres.status) = ((avail_size) / + (regCb->regInfo.size/10)); + RETVALUE(ROK); +#endif /* USE_PURE */ + + } + + default: + { + /* No other event is supported currently */ + RETVALUE(RFAILED); + } + } + + /* shouldn't reach here */ + RETVALUE(RFAILED); +} /* end of cmCtl */ + + +#if 0 +/* +* +* Fun: cmMmBktInit +* +* Desc: Initialize the bucket and the map table. +* +* +* Ret: ROK - successful, +* RFAILED - unsuccessful. +* +* Notes: This function is called by the cmMmRegInit. +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PRIVATE Void cmMmBktInit +( +Data **memAddr, +CmMmRegCb *regCb, +CmMmRegCfg *cfg, +U16 bktIdx, +U16 *lstMapIdx +) +#else +PRIVATE Void cmMmBktInit (memAddr, regCb, cfg, bktIdx, lstMapIdx) +Data **memAddr; +CmMmRegCb *regCb; +CmMmRegCfg *cfg; +U16 bktIdx; +U16 *lstMapIdx; +#endif +{ + U32 cnt; + U16 idx; + U32 numBlks; + Size size; + Data **next; + U16 blkSetRelThreshold; + CmMmBktLstCb *bktLstCb; + + TRC2(cmMmBktInit); + + + size = cfg->bktCfg[bktIdx].size; + numBlks = cfg->bktCfg[bktIdx].numBlks; + + regCb->bktTbl[bktIdx].blkSetRelThreshold = cfg->bktCfg[bktIdx].blkSetRelThreshold; + regCb->bktTbl[bktIdx].blkSetAcquireThreshold = cfg->bktCfg[bktIdx].blkSetAcquireThreshold; + blkSetRelThreshold = cfg->bktCfg[bktIdx].blkSetRelThreshold; + + /* Initialize the bucket linked list */ + cmLListInit(®Cb->bktTbl[bktIdx].listBktSet); + + /* Reset the next pointer */ + regCb->bktTbl[bktIdx].next = NULLP; + + /* Initialize the link list of the memory block */ + next = &(regCb->bktTbl[bktIdx].next); + for (cnt = 0; cnt < numBlks; cnt++) + { + *next = *memAddr; + next = (CmMmEntry **)(*memAddr); + *memAddr = (*memAddr) + size; + + /* Maintain the list Cb */ + if((cnt != 0) && (!(cnt % blkSetRelThreshold))) + { + bktLstCb = calloc(1, sizeof(CmMmBktLstCb)); + bktLstCb->nextBktPtr = regCb->bktTbl[bktIdx].next; + bktLstCb->numBkt = blkSetRelThreshold; + cmLListAdd2Tail((®Cb->bktTbl[bktIdx].listBktSet), (&bktLstCb->memSetNode)); + next = &(regCb->bktTbl[bktIdx].next); + regCb->numBkts++; + } + } + *next = NULLP; + + bktLstCb = cmLListFirst((®Cb->bktTbl[bktIdx].listBktSet)); + regCb->bktTbl[bktIdx].next = bktLstCb->nextBktPtr; + cmLListDelFrm((®Cb->bktTbl[bktIdx].listBktSet), bktLstCb); + free(bktLstCb); + + /* Initialize the Map entry */ + idx = size / cfg->bktQnSize; + + /* + * Check if the size is multiple of quantum size. If not we need to initialize + * one more map table entry. + */ + if(size % cfg->bktQnSize) + { + idx++; + } + + while ( *lstMapIdx < idx) + { + regCb->mapTbl[*lstMapIdx].bktIdx = bktIdx; + +#if (ERRCLASS & ERRCLS_DEBUG) + regCb->mapTbl[*lstMapIdx].numReq = 0; + regCb->mapTbl[*lstMapIdx].numFailure = 0; +#endif + + (*lstMapIdx)++; + } + + /* Initialize the bucket structure */ + regCb->bktTbl[bktIdx].size = size; + regCb->bktTbl[bktIdx].numBlks = numBlks; + regCb->bktTbl[bktIdx].numAlloc = 0; + regCb->bktTbl[bktIdx].maxAlloc = 0; + + /* Update the total bucket size */ + regCb->bktSize += (size * numBlks); + + regCb->bktTbl[bktIdx].bktFailCnt = 0; + regCb->bktTbl[bktIdx].bktNoFitCnt = 0; + + RETVOID; +} /* end of cmMmBktInit */ +#endif + + +/* +* +* Fun: cmMmHeapInit +* +* Desc: Initialize the heap pool. +* +* +* Ret: ROK - successful +* RFAILED - unsuccessful. +* +* Notes: This function is called by the cmMmRegInit. +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PRIVATE Void cmMmHeapInit +( +Data *memAddr, +CmMmHeapCb *heapCb, +Size size +) +#else +PRIVATE Void cmMmHeapInit (memAddr, heapCb, size) +Data *memAddr; +CmMmHeapCb *heapCb; +Size size; +#endif +{ +/* cm_mem_c_001.main_12 - addition for ssi enhancements */ +#ifdef SSI_DEBUG_LEVEL1 + U16 idx; +#endif /* SSI_DEBUG_LEVEL1 */ + TRC2(cmMmHeapInit); + + /* Initialize the heap control block */ + heapCb->vStart = memAddr; + heapCb->vEnd = memAddr + size; + heapCb->avlSize = size; + heapCb->minSize = CMM_MINBUFSIZE; + + heapCb->next = (CmHEntry *)memAddr; + heapCb->next->next = NULLP; +/* cm_mem_c_001.main_12 - addition for header initialization */ +#ifdef SSI_DEBUG_LEVEL1 + heapCb->next->size = size - sizeof(CmHEntry); + heapCb->next->requestedSize = 0; + for (idx=0; idx < CMM_TRAMPLING_SIGNATURE_LEN; idx++) + { + heapCb->next->trSignature[idx] = 0xAB; + } + CMM_SET_FREE_FLAG(heapCb->next->memFlags); + heapCb->staticHeapMemUsed = 0; + heapCb->dynamicHeapMemUsed = 0; + heapCb->nextOffset = sizeof(heapCb->next->trSignature) + + sizeof(heapCb->next->memFlags) + + sizeof(heapCb->next->requestedSize); + heapCb->numAllocAttempts = 0; + heapCb->numDeallocAttempts = 0; + heapCb->trampleCount = 0; +#else + heapCb->next->size = size; +#endif /* SSI_DEBUG_LEVEL1 */ + +#if (ERRCLASS & ERRCLS_DEBUG) + heapCb->numFragBlk = 0; + heapCb->numReq = 0; + heapCb->numFailure = 0; +#endif + + heapCb->heapAllocCnt = 0; +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + /* Initialise the memory histogram hash list */ + cmHstGrmHashListInit(&(heapCb->heapHstGrmHashListCp)); +#endif /* SS_HISTOGRAM_SUPPORT */ + RETVOID; + +} /* end of cmMmHeapInit */ + +#ifndef USE_PURE + +/* +* +* Fun: cmHeapAlloc +* +* Desc: Allocates the memory block from the heap pool. +* +* +* Ret: ROK - successful +* RFAILED - unsuccessful. +* +* Notes: This function is called by the cmAlloc. cmAlloc calls this +* function when there is no memory block available in the bucket +* and the heap pool is configured. +* +* +* +* File: cm_mem_wl.c +* +*/ +/* cm_mem_c_001.main_12 - addition for taking another parameter memType(static/dynamic) */ +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT +#ifdef SSI_DEBUG_LEVEL1 +#ifdef ANSI +PRIVATE S16 cmHeapAlloc +( +CmMmHeapCb *heapCb, +Data **ptr, +Size *size, +U32 memType, +U32 line, +U8 *fileName, +U8 entId, +Bool hstReg +) +#else +PRIVATE S16 cmHeapAlloc (heapCb, ptr, size, memType, line, fileName, entId, hstReg) +CmMmHeapCb *heapCb; +Data **ptr; +Size *size; +U32 memType; +U32 line; +U8 *fileName; +U8 entId; +Bool hstReg; +#endif +#else +#ifdef ANSI +PRIVATE S16 cmHeapAlloc +( +CmMmHeapCb *heapCb, +Data **ptr, +Size *size, +U32 line, +U8 *fileName, +U8 entId, +Bool hstReg +) +#else +PRIVATE S16 cmHeapAlloc (heapCb, ptr, size, line, fileName, entId, hstReg) +CmMmHeapCb *heapCb; +Data **ptr; +Size *size; +U32 line; +U8 *fileName; +U8 entId; +Bool hstReg; +#endif +#endif /* SSI_DEBUG_LEVEL1 */ +#else +#ifdef SSI_DEBUG_LEVEL1 +#ifdef ANSI +PRIVATE S16 cmHeapAlloc +( +CmMmHeapCb *heapCb, +Data **ptr, +Size *size, +U32 memType +) +#else +PRIVATE S16 cmHeapAlloc (heapCb, ptr, size, memType) +CmMmHeapCb *heapCb; +Data **ptr; +Size *size; +U32 memType; +#endif +#else +#ifdef ANSI +PRIVATE S16 cmHeapAlloc +( +CmMmHeapCb *heapCb, +Data **ptr, +Size *size +) +#else +PRIVATE S16 cmHeapAlloc (heapCb, ptr, size) +CmMmHeapCb *heapCb; +Data **ptr; +Size *size; +#endif +#endif /* SSI_DEBUG_LEVEL1 */ +/* cm_mem_c_001.main_15 : Additions */ +#endif /* SS_HISTOGRAM_SUPPORT */ +{ + CmHEntry *prvHBlk; /* Previous heap block */ + CmHEntry *curHBlk; /* Current heap block */ + Size tmpSize; +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_MEM_LEAK_STS + Size reqSz; +#endif /* SS_MEM_LEAK_STS */ +/* cm_mem_c_001.main_12 - addition for ssi enhancements */ +#ifdef SSI_DEBUG_LEVEL1 + CmHEntry *alocHeapBlk; + Size requestedSize; + Size hdr; + U16 idx; +#endif /* SSI_DEBUG_LEVEL1 */ +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + S8 hstGrmBuf[256]; +#endif /* SS_HISTOGRAM_SUPPORT */ + + TRC2(cmHeapAlloc); +/* cm_mem_c_001.main_15 : Additions */ + /* Acquire the heap lock */ + /* cm_mem_c_001.main_13 : Replaced SLock with WTLock for NT */ +#ifdef SS_WIN + (Void) WTLock (&(heapCb->heapLock)); +#else + (Void) SLock (&(heapCb->heapLock)); +#endif + +#ifdef SS_MEM_LEAK_STS + reqSz = *size; +#endif /* SS_MEM_LEAK_STS */ +/* cm_mem_c_001.main_12 - addition for manipulation of statistics related data */ +#ifdef SSI_DEBUG_LEVEL1 + heapCb->numAllocAttempts++; + requestedSize = *size; +#endif /* SSI_DEBUG_LEVEL1 */ + + /* Roundup the requested size */ + *size = CMM_DATALIGN(*size, (heapCb->minSize)); + + /* Check if the available total size is adequate. */ + if ((*size) >= heapCb->avlSize) + { +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_WIN + (Void) WTUnlock (&(heapCb->heapLock)); +#else + (Void) SUnlock (&(heapCb->heapLock)); +#endif + RETVALUE(ROUTRES); + } + + +/* cm_mem_c_001.main_12 - addition for aligning the header size */ +#ifdef SSI_DEBUG_LEVEL1 + hdr = PTRALIGN(sizeof(CmHEntry)); +#endif /* SSI_DEBUG_LEVEL1 */ + + /* + * Search through the heap block list in the heap pool of size + * greater than or equal to the requested size. + * + */ +/* cm_mem_c_001.main_12 - addition for accessing the heapCb->next */ +#ifdef SSI_DEBUG_LEVEL1 + prvHBlk = (CmHEntry *)((Data *)&(heapCb->next) - heapCb->nextOffset); +#else + prvHBlk = (CmHEntry *)&(heapCb->next); +#endif /* SSI_DEBUG_LEVEL1 */ + for (curHBlk = prvHBlk->next; curHBlk; curHBlk = curHBlk->next, + prvHBlk = prvHBlk->next) + { + /* + * Since the size of the block is always multiple of CMM_MINBUFSIZE + * and the requested size is rounded to the size multiple of + * CMM_MINBUFSIZE, the difference between the size of the heap block + * and the size to allocate will be either zero or multiple of + * CMM_MINBUFSIZE. + */ + if ((*size) <= curHBlk->size) + { +/* cm_mem_c_001.main_12 - addition for block size calculation */ +#ifdef SSI_DEBUG_LEVEL1 + tmpSize = curHBlk->size - (*size); + if (tmpSize != 0) + tmpSize = tmpSize - hdr; + if (tmpSize) +#else + if ((tmpSize = (curHBlk->size - (*size)))) +#endif /* SSI_DEBUG_LEVEL1 */ + { + /* Heap block of bigger size */ +/* cm_mem_c_001.main_12 - addition for allocating memory */ +#ifdef SSI_DEBUG_LEVEL1 + *ptr = (Data *)curHBlk + hdr + tmpSize + hdr; + alocHeapBlk = (CmHEntry *) ((Data *)curHBlk + hdr + tmpSize); + /* + * No need to look for memory trampling as this is a new block altogether + * Update the header only for this case as it is new block formed + */ + for (idx=0; idx < CMM_TRAMPLING_SIGNATURE_LEN; idx++) + { + alocHeapBlk->trSignature[idx] = 0xAB; + } + alocHeapBlk->size = *size; +#else + *ptr = (Data *)curHBlk + tmpSize; +#endif /* SSI_DEBUG_LEVEL1 */ + curHBlk->size = tmpSize; + } + else + { + /* Heap block is same size of the requested size */ +/* cm_mem_c_001.main_12 - addition for sanity check and allocation. This is a fresh block */ +#ifdef SSI_DEBUG_LEVEL1 + /* look for memory trampling as this is a pure block*/ + if (curHBlk) + { + if (cmMmRegIsBlkSane((CmMmBlkHdr *)curHBlk) != ROK) + { + /* detected a trampled memory block in this bucket */ + #ifdef DEBUGP + /* display an error message here */ +/*cm_mem_c_001.main_23 Fix for specifier mismatch warnings in 64BIT compilation*/ +#ifdef ALIGN_64BIT + sprintf(dbgPrntBuf, "Memory Trampling in heap at: %8p, size %u bytes \n", (void *)curHBlk, requestedSize); +#else + sprintf(dbgPrntBuf, "Memory Trampling in heap at: %8p, size %lu bytes \n", (void *)curHBlk, requestedSize); +#endif + SDisplay(0, dbgPrntBuf); + #endif /* DEBUGP */ + + if (cmMmHeapSanityChk(heapCb) == RTRAMPLINGNOK) + { + /* Release the lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with + WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock (&(heapCb->heapLock)); +#else + (Void) SUnlock (&(heapCb->heapLock)); +#endif + /* handle RTRAMPLINGNOK in SAlloc/SGetSBuf */ + RETVALUE(RTRAMPLINGNOK); + } + else + { + /* Release the lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with + WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock (&(heapCb->heapLock)); +#else + (Void) SUnlock (&(heapCb->heapLock)); +#endif + RETVALUE(RFAILED); + } + } + } + + *ptr = (Data *)curHBlk + hdr; + alocHeapBlk = curHBlk; + *size = curHBlk->size; +#else + *ptr = (Data *)curHBlk; +#endif /* SSI_DEBUG_LEVEL1 */ + prvHBlk->next = curHBlk->next; + } + +/* cm_mem_c_001.main_12 - addition for header updation */ +#ifdef SSI_DEBUG_LEVEL1 + /* update the header fields */ + alocHeapBlk->requestedSize = requestedSize; + alocHeapBlk->memFlags = 0; + if (memType == CMM_STATIC_MEM_FLAG) + { + CMM_SET_STATIC_FLAG(alocHeapBlk->memFlags); + heapCb->staticHeapMemUsed += (*size + hdr); + } + else + { + CMM_SET_DYNAMIC_FLAG(alocHeapBlk->memFlags); + heapCb->dynamicHeapMemUsed += (*size + hdr); + } + heapCb->avlSize -= ((*size) + hdr); +#else + heapCb->avlSize -= (*size); +#endif /* SSI_DEBUG_LEVEL1 */ + +#ifdef MEMCAL_DEBUG + if (tryHeap) + { + sprintf(prntBuf, + "SGetSBuf:%08lu:Size Heap Alloc Times:%05lu Pointer: %8p\n", + *size, num_times, *ptr); + SDisplay(0, prntBuf); + tryHeap = 0; + } +#endif +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_MEM_LEAK_STS + /* cm_mem_c_001.main_25 - Fixed compilation warnings 32/64 bit */ + cmStorAllocBlk((PTR)*ptr, (Size) reqSz, (Size) *size, MT_MAX_BKTS); +#endif /* SS_MEM_LEAK_STS */ + /* Release the lock */ +/* cm_mem_c_001.main_16 : cm_mem_c_001.main_18 Additions */ +#ifdef SS_WIN + (Void) WTUnlock (&(heapCb->heapLock)); +#else + (Void) SUnlock (&(heapCb->heapLock)); +#endif + +#ifdef SS_HISTOGRAM_SUPPORT + /* If If Tapa task (entId)is registerd for histogram then insert Memrory allocated + * information into the hash list */ + if(hstReg) + { + if (cmHstGrmAllocInsert(&(heapCb->heapHstGrmHashListCp), *size, size, line, fileName, entId) != ROK) + { + sprintf(hstGrmBuf, "Unable to Insert into the histgram hash list\n"); + SPrint(hstGrmBuf); + } + }/* End of if */ + +#endif /* SS_HISTOGRAM_SUPPORT */ + + RETVALUE(ROK); + } + } + +/* cm_mem_c_008.104 - Addition for memory calculator tool */ +#ifdef MEMCAL_DEBUG + tryHeap = 0; +#endif + + + /* Release the lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock (&(heapCb->heapLock)); +#else + (Void) SUnlock (&(heapCb->heapLock)); +#endif + + RETVALUE(ROUTRES); + +} /* end of cmHeapAlloc */ + + +/* +* +* Fun: cmHeapFree +* +* Desc: Return the memory block from the heap pool. +* +* +* Ret: ROK - successful +* RFAILED - unsuccessful. +* +* Notes: This function returns the memory block to the heap pool. This +* function is called by cmFree. The function does not check the +* validity of the memory block. The caller must be sure that the +* block was previously allocated and belongs to the heap pool. The +* function maintain the sorting order of the memory block on the +* starting address of the block. This function also do compaction +* if the neighbouring blocks are already in the heap. +* +* +* +* File: cm_mem_wl.c +* +*/ +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT +#ifdef ANSI +PRIVATE S16 cmHeapFree +( +CmMmHeapCb *heapCb, +Data *ptr, +Size size, +U32 line, +U8 *fileName, +U8 entId, +Bool hstReg +) +#else +PRIVATE S16 cmHeapFree (heapCb, ptr, size, line, fileName, entId, hstReg) +CmMmHeapCb *heapCb; +Data *ptr; +Size size; +U32 line; +U8 *fileName; +U8 entId; +Bool hstReg; +#endif +#else +#ifdef ANSI +PRIVATE S16 cmHeapFree +( +CmMmHeapCb *heapCb, +Data *ptr, +Size size +) +#else +PRIVATE S16 cmHeapFree (heapCb, ptr, size) +CmMmHeapCb *heapCb; +Data *ptr; +Size size; +#endif +/* cm_mem_c_001.main_15 : Additions */ +#endif /* SS_HISTOGRAM_SUPPORT */ +{ + CmHEntry *p; + CmHEntry *curHBlk; /* Current heap block */ +/* cm_mem_c_001.main_12 - addition for ssi enhancements */ +#ifdef SSI_DEBUG_LEVEL1 + Size hdr; +#endif /* SSI_DEBUG_LEVEL1 */ +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + Size allocSize = size; + S8 hstGrmBuf[256]; +#endif /* SS_HISTOGRAM_SUPPORT */ + + TRC2(cmHeapFree); + + /* Roundup the requested size */ + size = CMM_DATALIGN(size, (heapCb->minSize)); +/* cm_mem_c_001.main_15: Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + allocSize = size; +#endif /* SS_HISTOGRAM_SUPPORT */ + + /* Acquire the heap lock */ + /* cm_mem_c_001.main_13 : Replaced SLock with WTLock for NT */ +#ifdef SS_WIN + (Void) WTLock (&(heapCb->heapLock)); +#else + (Void) SLock (&(heapCb->heapLock)); +#endif + + /* increase the avlSize */ +/* cm_mem_c_001.main_12 - addition for manipulation of statistics related data */ +#ifdef SSI_DEBUG_LEVEL1 + hdr = PTRALIGN(sizeof(CmHEntry)); + heapCb->avlSize += (size + hdr); + heapCb->numDeallocAttempts++; +#else + heapCb->avlSize += size; +#endif /* SSI_DEBUG_LEVEL1 */ + +/* cm_mem_c_001.main_12 - addition for pointing to the block */ +#ifdef SSI_DEBUG_LEVEL1 + p = (CmHEntry *)(ptr - hdr); +#else + p = (CmHEntry *)ptr; +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_MEM_LEAK_STS + /* cm_mem_c_001.main_25 - Fixed compilation warnings 32/64 bit */ + cmRlsAllocBlk((PTR)ptr); +#endif /* SS_MEM_LEAK_STS */ +#endif /* SSI_DEBUG_LEVEL1 */ + + +/* cm_mem_c_001.main_12 - addition for sanity and double-free checks */ +#ifdef SSI_DEBUG_LEVEL1 + /* look for memory trampling */ + if (cmMmRegIsBlkSane((CmMmBlkHdr *)p) != ROK) + { + /* detected a trampled memory block in heap */ + #ifdef DEBUGP + /* display an error message here */ +/*cm_mem_c_001.main_23 Fix for specifier mismatch warnings in 64BIT compilation*/ +#ifdef ALIGN_64BIT + sprintf(dbgPrntBuf, "Memory Trampling in heap at: %8p, size %u bytes \n", (void *)p, size); +#else + sprintf(dbgPrntBuf, "Memory Trampling in heap at: %8p, size %lu bytes \n", (void *)p, size); +#endif + SDisplay(0, dbgPrntBuf); + #endif /* DEBUGP */ + + if (cmMmHeapSanityChk(heapCb) == RTRAMPLINGNOK) + { + /* Release the lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock (&(heapCb->heapLock)); +#else + (Void) SUnlock (&(heapCb->heapLock)); +#endif + /* handle RTRAMPLINGNOK in SAlloc/SGetSBuf */ + RETVALUE(RTRAMPLINGNOK); + } + else + { + /* do not add to the free heap */ + heapCb->avlSize -= (size + hdr); + /* Release the heap lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock (&(heapCb->heapLock)); +#else + (Void) SUnlock (&(heapCb->heapLock)); +#endif + + RETVALUE(ROK); + } + } + + /* look for any double free */ + if (CMM_IS_FREE(p->memFlags)) + { + #ifdef DEBUGP +/*cm_mem_c_001.main_23 Fix for specifier mismatch warnings in 64BIT compilation*/ +#ifdef ALIGN_64BIT + sprintf(dbgPrntBuf, "DOUBLE FREE at %8p for size %u in HEAP \n", (void *)p, size); +#else + sprintf(dbgPrntBuf, "DOUBLE FREE at %8p for size %lu in HEAP \n", (void *)p, size); +#endif + SDisplay(0, dbgPrntBuf); + #endif /* DEBUGP */ + + heapCb->avlSize -= (size + hdr); +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_WIN + (Void) WTUnlock (&(heapCb->heapLock)); +#else + (Void) SUnlock (&(heapCb->heapLock)); +#endif + + RETVALUE(RDBLFREE); + } +#endif /* SSI_DEBUG_LEVEL1 */ + + for ( curHBlk = heapCb->next; curHBlk; curHBlk = curHBlk->next) + { + /* + * The block will be inserted to maintain the sorted order on the + * starting address of the block. + */ + if (p > curHBlk) + { + if (!(curHBlk->next) || + (p < (curHBlk->next))) + { + /* Heap block should be inserted here */ + + /* + * Check if the block to be returned can be merged with the + * current block. + */ +/* cm_mem_c_001.main_12 - addition for header consideration */ +#ifdef SSI_DEBUG_LEVEL1 + if (((Data *)curHBlk + hdr + curHBlk->size) == (Data *)p) +#else + if (((Data *)curHBlk + curHBlk->size) == (Data *)p) +#endif /* SSI_DEBUG_LEVEL1 */ + { + /* Merge the block */ +/* cm_mem_c_001.main_12 - addition for updating statistics related data */ +#ifdef SSI_DEBUG_LEVEL1 + /* update the flags */ + if (CMM_IS_STATIC(p->memFlags)) + heapCb->staticHeapMemUsed -= (size + hdr); + else if (CMM_IS_DYNAMIC(p->memFlags)) + heapCb->dynamicHeapMemUsed -= (size + hdr); + size = (curHBlk->size += (size + hdr)); +#else + size = (curHBlk->size += size); +#endif /*SSI_DEBUG_LEVEL1*/ + p = curHBlk; + } + else + { +/* cm_mem_c_001.main_12 - addition for double-free check */ +#ifdef SSI_DEBUG_LEVEL1 + /* Check for double deallocation in heap */ + if ((Data *)p < ((Data *)curHBlk + curHBlk->size)) + { + /* Release the lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock (&(heapCb->heapLock)); +#else + (Void) SUnlock (&(heapCb->heapLock)); +#endif + + /* This block is already freed in the heap */ + RETVALUE(RDBLFREE); + } + /* update the flags as it is a new node */ + if (CMM_IS_STATIC(p->memFlags)) + { + heapCb->staticHeapMemUsed -= (size + hdr); + CMM_RESET_STATIC_FLAG(p->memFlags); + } + else if (CMM_IS_DYNAMIC(p->memFlags)) + { + heapCb->dynamicHeapMemUsed -= (size + hdr); + CMM_RESET_DYNAMIC_FLAG(p->memFlags); + } + CMM_SET_FREE_FLAG(p->memFlags); + p->requestedSize = 0; +#endif /*SSI_DEBUG_LEVEL1*/ + /* insert the block */ + p->next = curHBlk->next; + p->size = size; + curHBlk->next = p; + } + + /* Try to merge with the next block in the chain */ +/* cm_mem_c_001.main_12 - addition for ssi enhancements */ +#ifdef SSI_DEBUG_LEVEL1 + if (((Data *)p + hdr + size) == (Data *)(p->next)) +#else + if (((Data *)p + size) == (Data *)(p->next)) +#endif /*SSI_DEBUG_LEVEL1*/ + { + /* p->next can not be NULL */ +/* cm_mem_c_001.main_12 - addition for header consideration */ +#ifdef SSI_DEBUG_LEVEL1 + p->size += (p->next->size + hdr); +#else + p->size += p->next->size; +#endif /*SSI_DEBUG_LEVEL1*/ + p->next = p->next->next; + } + + /* Release the lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock (&(heapCb->heapLock)); +#else + (Void) SUnlock (&(heapCb->heapLock)); +#endif +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + /* If If Tapa task (entId)is registerd for histogram then insert + Memrory Freed information into the hash list */ + if(hstReg) + { + if (cmHstGrmFreeInsert(&heapCb->heapHstGrmHashListCp, allocSize, line, + fileName, entId) != ROK) + { + sprintf(hstGrmBuf, "Unable to Insert into the histgram hash list\n"); + SPrint(hstGrmBuf); + } + }/* End of if */ +#endif /* SS_HISTOGRAM_SUPPORT */ + RETVALUE(ROK); + } + } + else if (p < curHBlk) + { + /* + * Check if the block to be returned can be merged with the + * current block. + */ +/* cm_mem_c_001.main_12 - addition for header consideration */ +#ifdef SSI_DEBUG_LEVEL1 + if (((Data *)p + hdr + size) == (Data *)curHBlk) +#else + if (((Data *)p + size) == (Data *)curHBlk) +#endif /* SSI_DEBUG_LEVEL1 */ + { + /* Merge the block */ +/* cm_mem_c_001.main_12 - addition for header consideration */ +#ifdef SSI_DEBUG_LEVEL1 + p->size = size + (curHBlk->size + hdr); +#else + p->size = size + curHBlk->size; +#endif /* SSI_DEBUG_LEVEL1 */ + p->next = curHBlk->next; + } + else + { + /* insert the block */ + p->next = curHBlk; + p->size = size; + } +/* cm_mem_c_001.main_12 - addition for header updation */ +#ifdef SSI_DEBUG_LEVEL1 + /* update the flags in both cases as they are new start nodes*/ + if (CMM_IS_STATIC(p->memFlags)) + { + heapCb->staticHeapMemUsed -= (size + hdr); + CMM_RESET_STATIC_FLAG(p->memFlags); + } + else if (CMM_IS_DYNAMIC(p->memFlags)) + { + heapCb->dynamicHeapMemUsed -= (size + hdr); + CMM_RESET_DYNAMIC_FLAG(p->memFlags); + } + CMM_SET_FREE_FLAG(p->memFlags); + p->requestedSize = 0; +#endif /* SSI_DEBUG_LEVEL1 */ + + heapCb->next = p; + + /* Release the lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock (&(heapCb->heapLock)); +#else + (Void) SUnlock (&(heapCb->heapLock)); +#endif +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + /* If If Tapa task (entId)is registerd for histogram then insert + Memrory Freed information into the hash list */ + if(hstReg) + { + if (cmHstGrmFreeInsert(&heapCb->heapHstGrmHashListCp, allocSize, line, + fileName, entId) != ROK) + { + sprintf(hstGrmBuf, "Unable to Insert into the histgram hash list\n"); + SPrint(hstGrmBuf); + } + }/* End of if */ +#endif /* SS_HISTOGRAM_SUPPORT */ + RETVALUE(ROK); + } + + } + + if (heapCb->next == NULLP) + { + /* Heap block is empty. Insert the block in the head. */ + heapCb->next = p; + p->next = NULLP; + p->size = size; + +/* cm_mem_c_001.main_12 - addition for header updation */ +#ifdef SSI_DEBUG_LEVEL1 + if (CMM_IS_STATIC(p->memFlags)) + { + heapCb->staticHeapMemUsed -= (size + hdr); + CMM_RESET_STATIC_FLAG(p->memFlags); + } + else if (CMM_IS_DYNAMIC(p->memFlags)) + { + heapCb->dynamicHeapMemUsed -= (size + hdr); + CMM_RESET_DYNAMIC_FLAG(p->memFlags); + } + CMM_SET_FREE_FLAG(p->memFlags); + p->requestedSize = 0; +#endif /* SSI_DEBUG_LEVEL1 */ + + /* Release the heap lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock (&(heapCb->heapLock)); +#else + (Void) SUnlock (&(heapCb->heapLock)); +#endif +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + /* If If Tapa task (entId)is registerd for histogram then insert + Memrory Freed information into the hash list */ + if(hstReg) + { + if (cmHstGrmFreeInsert(&heapCb->heapHstGrmHashListCp, allocSize, line, + fileName, entId) != ROK) + { + sprintf(hstGrmBuf, "Unable to Insert into the histgram hash list\n"); + SPrint(hstGrmBuf); + } + }/* End of if */ +#endif /* SS_HISTOGRAM_SUPPORT */ + RETVALUE(ROK); + } + + /* Release the lock */ + /* cm_mem_c_001.main_13: Replaced SUnlock with WTUnlock for NT */ +#ifdef SS_WIN + (Void) WTUnlock (&(heapCb->heapLock)); +#else + (Void) SUnlock (&(heapCb->heapLock)); +#endif + + RETVALUE(RFAILED); +} /* end of cmHeapFree */ +/* cm_mem_c_001.main_15 : Additions */ +#endif +#ifdef SS_MEM_LEAK_STS +/* +* +* Fun: cmInitMemLeakMdl +* +* Desc: Initializes the memory leak detection module +* +* +* Ret: RETVOID +* +* Notes: This function initializes the memory leak detection module. +* +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PUBLIC Void cmInitMemLeakMdl +( +Void +) +#else +PUBLIC Void cmInitMemLeakMdl (Void) +#endif +{ + U8 memMdl; + U8 hashIdx; + + TRC3(cmInitMemLeakMdl); + + memLkCb.memLkMdlInit = FALSE; + for(memMdl = 0; memMdl < CM_MEM_USR_MDL; memMdl++) + { + for (hashIdx = 0; hashIdx < CM_MAX_HASH_PER_TSK; hashIdx++) + { + SInitLock(&memLkCb.memUsrMdl[memMdl][hashIdx].memLck, 1); + cmHashListInit(&memLkCb.memUsrMdl[memMdl][hashIdx].memHashCp, + 500, 0, FALSE, CM_HASH_KEYTYPE_U32MOD, 0, 0); + memLkCb.memUsrMdl[memMdl][hashIdx].used = FALSE; + } + } + if(memLkCb.fileLkLog == NULLP) + { + memLkCb.fileLkLog = (FILE *) stdout; + } + memLkCb.memLkMdlInit = TRUE; + + RETVOID; +} /* cmInitMemLeakMdl */ +/* cm_mem_c_002.main_21 Added for shutdown procedure */ +/* + * + * Fun: cmDeinitMemLeakMdl + * + * Desc: De-initializes the memory leak detection module + * + * + * Ret: RETVOID + * + * Notes: This function de-initializes the memory leak detection module. + * + * + * File: cm_mem_wl.c + * + **/ +#ifdef ANSI +PUBLIC Void cmDeinitMemLeakMdl +( +Void +) +#else +PUBLIC Void cmDeinitMemLeakMdl (Void) +#endif +{ + U8 memMdl; + U8 hashIdx; + + TRC3(cmDeinitMemLeakMdl); + + memLkCb.memLkMdlInit = FALSE; + for(memMdl = 0; memMdl < CM_MEM_USR_MDL; memMdl++) + { + for (hashIdx = 0; hashIdx < CM_MAX_HASH_PER_TSK; hashIdx++) + { + SDestroyLock(&memLkCb.memUsrMdl[memMdl][hashIdx].memLck); + cmHashListDeinit(&memLkCb.memUsrMdl[memMdl][hashIdx].memHashCp); + memLkCb.memUsrMdl[memMdl][hashIdx].used = FALSE; + } + } + RETVOID; +} +/* +* +* Fun: cmMemOpenMemLkFile +* +* Desc: Initializes the memory leak detection module +* +* +* Ret: RETVOID +* +* Notes: This function initializes the memory leak detection module. +* +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PUBLIC Void cmMemOpenMemLkFile +( +S8 *arg +) +#else +PUBLIC Void cmMemOpenMemLkFile (arg) +S8 *msOptArg; +#endif +{ + TRC3(cmMemOpenMemLkFile); + memLkCb.fileLkLog = NULLP; + memLkCb.fileLkLog = fopen(arg, "w"); + RETVOID; +} + +/* +* +* Fun: SLogLkInfo +* +* Desc: Initializes the memory leak detection module +* +* +* Ret: RETVOID +* +* Notes: This function initializes the memory leak detection module. +* +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PUBLIC Void SLogLkInfo +( +Void +) +#else +PUBLIC Void SLogLkInfo (Void) +#endif +{ + + MemAllocInfo *oldMemInfo; + MemAllocInfo *newMemInfo; + U8 memMdl; + U8 hashIdx; + U8 idx; + Txt prntBuf[255]; + S8 **funcNm; + TRC3(SLogLkInfo); + if( memLkCb.memLkMdlInit == FALSE) + { + RETVOID; + } + sprintf(prntBuf, "\n------- START OF LEAK LOG -------\n"); + fwrite(prntBuf, strlen(prntBuf), 1, memLkCb.fileLkLog); + + for(memMdl = 0; memMdl < CM_MEM_USR_MDL; memMdl++) + { + for (hashIdx = 0; hashIdx < CM_MAX_HASH_PER_TSK; hashIdx++) + { + if(memLkCb.memUsrMdl[memMdl][hashIdx].used == FALSE) + { + continue; + } + oldMemInfo = NULLP; + newMemInfo = NULLP; + SLock(&memLkCb.memUsrMdl[memMdl][hashIdx].memLck); + while(cmHashListGetNext(&memLkCb.memUsrMdl[memMdl][hashIdx].memHashCp, + (PTR)oldMemInfo, (PTR *)&newMemInfo) == ROK) + { + sprintf(prntBuf, "[LBIS]\n"); + fwrite(prntBuf, strlen(prntBuf), 1, memLkCb.fileLkLog); + /* cm_mem_c_001.main_25 - Fixed compilation warnings 32/64 bit */ +#ifdef ALIGN_64BIT + sprintf(prntBuf, "Address: 0x%u\n", newMemInfo->memAddr); +#else + sprintf(prntBuf, "Address: 0x%lu\n", newMemInfo->memAddr); +#endif + fwrite(prntBuf, strlen(prntBuf), 1, memLkCb.fileLkLog); + sprintf(prntBuf, "Module Name: %s\n", + memUsrMdlStr[newMemInfo->moduleId].mdlStr); + fwrite(prntBuf, strlen(prntBuf), 1, memLkCb.fileLkLog); + sprintf(prntBuf, "Requested Size: %d\n", (S16)newMemInfo->reqSz); + fwrite(prntBuf, strlen(prntBuf), 1, memLkCb.fileLkLog); + sprintf(prntBuf, "Allocated Size: %d\n", (S16)newMemInfo->allocSz); + fwrite(prntBuf, strlen(prntBuf), 1, memLkCb.fileLkLog); + sprintf(prntBuf, "Bucket Idx: %d\n", newMemInfo->bktIdx); + fwrite(prntBuf, strlen(prntBuf), 1, memLkCb.fileLkLog); + sprintf(prntBuf,"Memory Allocation Path:\n"); + fwrite(prntBuf, strlen(prntBuf), 1, memLkCb.fileLkLog); + funcNm = (S8 **)newMemInfo->backTrace; + for(idx = 0; idx < newMemInfo->bTrcSz; idx ++) + { + sprintf(prntBuf,"==> %s\n", funcNm[idx]); + fwrite(prntBuf, strlen(prntBuf), 1, memLkCb.fileLkLog); + } + sprintf(prntBuf, "[LBIE]\n\n"); + fwrite(prntBuf, strlen(prntBuf), 1, memLkCb.fileLkLog); + fflush(memLkCb.fileLkLog); + oldMemInfo = newMemInfo; + newMemInfo = NULLP; + } + SUnlock(&memLkCb.memUsrMdl[memMdl][hashIdx].memLck); + } + } + sprintf(prntBuf, "\n------- END OF LEAK LOG -------\n"); + fwrite(prntBuf, strlen(prntBuf), 1, memLkCb.fileLkLog); + RETVOID; +} + +/* +* +* Fun: SFlushLkInfo +* +* Desc: Initializes the memory leak detection module +* +* +* Ret: RETVOID +* +* Notes: This function initializes the memory leak detection module. +* +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PUBLIC Void SFlushLkInfo +( +Void +) +#else +PUBLIC Void SFlushLkInfo (Void) +#endif +{ + MemAllocInfo *newMemInfo; + U8 memMdl; + U8 hashIdx; + S8 **funcNm; +#ifdef SS_MEM_LEAK_SOL + U8 i; +#endif /* SS_MEM_LEAK_SOL */ + + TRC3(SFlushLkInfo); + if( memLkCb.memLkMdlInit == FALSE) + { + RETVOID; + } + + for(memMdl = 0; memMdl < CM_MEM_USR_MDL; memMdl++) + { + for(hashIdx = 0; hashIdx < CM_MAX_HASH_PER_TSK; hashIdx++) + { + if(memLkCb.memUsrMdl[memMdl][hashIdx].used == FALSE) + { + continue; + } + newMemInfo = NULLP; + SLock(&memLkCb.memUsrMdl[memMdl][hashIdx].memLck); + while(cmHashListGetNext(&memLkCb.memUsrMdl[memMdl][hashIdx].memHashCp, + (PTR)NULLP, (PTR *)&newMemInfo) == ROK) + { + funcNm = (S8 **)newMemInfo->backTrace; +#ifdef SS_MEM_LEAK_SOL + for(i = 0; i < newMemInfo->bTrcSz; i++) + { +/*cm_mem_c_001.main_27 SSI-4GMX specfic changes*/ +#ifdef SS_4GMX_LCORE + MxHeapFree(SsiHeap, funcNm[i]); +#else + free(funcNm[i]); +#endif + /* SPutSBuf(DFLT_REGION, DFLT_POOL, funcNm[i], sizeof(U32) * CM_MAX_STACK_TRACE); */ + } +#endif /* SS_MEM_LEAK_SOl */ +/*cm_mem_c_001.main_27 SSI-4GMX specfic changes*/ +#ifdef SS_4GMX_LCORE + MxHeapFree(SsiHeap, funcNm); + MxHeapFree(SsiHeap, newMemInfo); +#else + free(funcNm); + free(newMemInfo); +#endif + } + SUnlock(&memLkCb.memUsrMdl[memMdl][hashIdx].memLck); + } + } + RETVOID; +} + +/* +* +* Fun: cmStorAllocBlk +* +* Desc: Initializes the memory leak detection module +* +* +* Ret: RETVOID +* +* Notes: This function initializes the memory leak detection module. +* +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PUBLIC Void cmStorAllocBlk +( +U32 addr, +Size reqSz, +Size allocSz, +U16 bktIdx +) +#else +PUBLIC Void cmStorAllocBlk (addr, reqSz, allocSz, bktIdx) +U32 addr; +Size reqSz; +Size allocSz; +U16 bktIdx; +#endif /* ANSI */ +{ +#ifndef SS_MEM_LEAK_SOL + Ptr trace[CM_MAX_STACK_TRACE]; +#endif /* SS_MEM_LEAK_SOL */ + S8 **funcNm; + S32 traceSize; + MemAllocInfo *allocInfo; + U8 moduleId; + + TRC3(cmStorAllocBlk); + if( memLkCb.memLkMdlInit == FALSE) + { + RETVOID; + } + +#ifdef SS_MEM_LEAK_SOL + /* I need to do this for solaris, because it does not implement + * backtrace. Here backtrace is my function. See below for the + * implementation. */ +/*cm_mem_c_001.main_27 SSI-4GMX specfic changes*/ +#ifdef SS_4GMX_LCORE + funcNm = (S8 **)MxHeapAlloc(SsiHeap, (sizeof(U32) * CM_MAX_STACK_TRACE)); + cmMemset((U8*)funcNm, 0, (sizeof(U32) * CM_MAX_STACK_TRACE)); +#else + funcNm = (S8 **)calloc(1, (sizeof(U32) * CM_MAX_STACK_TRACE)); +#endif + /* SGetSBuf(DFLT_REGION, DFLT_POOL, &funcNm, sizeof(U32) * CM_MAX_STACK_TRACE); */ + traceSize = backtrace((Void **)funcNm, CM_MAX_STACK_TRACE); +#else /* SS_MEM_LEAK_SOL */ + traceSize = backtrace(trace, CM_MAX_STACK_TRACE); + funcNm = backtrace_symbols(trace, traceSize); +#endif /* SS_MEM_LEAK_SOL */ + + moduleId = cmMemGetModuleId(funcNm, traceSize); + + (Void)SLock(&(memLkCb.memUsrMdl[moduleId][addr & 0x3].memLck)); +/*cm_mem_c_001.main_27 SSI-4GMX specfic changes*/ +#ifdef SS_4GMX_LCORE + allocInfo = (MemAllocInfo *)MxHeapAlloc(SsiHeap, sizeof(MemAllocInfo)); + cmMemset((U8*)allocInfo, 0, sizeof(MemAllocInfo)); +#else + allocInfo = (MemAllocInfo *)calloc(1, sizeof(MemAllocInfo)); +#endif + /* SGetSBuf(DFLT_REGION, DFLT_POOL, &allocInfo, sizeof(MemAllocInfo)); */ + allocInfo->memAddr = addr; + allocInfo->reqSz = reqSz; + allocInfo->allocSz = allocSz; + allocInfo->bktIdx = bktIdx; + allocInfo->backTrace = (PTR) funcNm; + allocInfo->moduleId = moduleId; + allocInfo->bTrcSz = traceSize; + + cmHashListInsert(&memLkCb.memUsrMdl[moduleId][addr & 0x3].memHashCp, + (PTR)allocInfo, (U8 *)&(allocInfo->memAddr), + sizeof(allocInfo->memAddr)); + memLkCb.memUsrMdl[moduleId][addr & 0x3].used = TRUE; + + (Void) SUnlock(&(memLkCb.memUsrMdl[moduleId][addr & 0x3].memLck)); + RETVOID; +} /* cmStorAllocBlk */ + +/* +* +* Fun: cmMemGetModuleId +* +* Desc: Initializes the memory leak detection module +* +* +* Ret: RETVOID +* +* Notes: This function initializes the memory leak detection module. +* +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PUBLIC U8 cmMemGetModuleId +( +S8 **funNm, +S32 traceSize +) +#else +PUBLIC U8 cmMemGetModuleId (funNm, traceSize) +S8 **funNm; +S32 traceSize; +#endif /* ANSI */ +{ + U8 idx; + U8 memStrIdx; + U32 len; + S32 retVal; + S16 memReqIdx; + S16 mdlFunStrIdx; + + Txt *memFn[]={"SGetMsg", "SGetSBuf", "SGetDBuf", NULLP}; + + /*cm_mem_c_001.main_25 : Fix for TRACE5 feature crash due to missing TRC MACRO*/ + TRC3(cmMemGetModuleId) + for(idx = 0; idx < traceSize; idx++) + { + memReqIdx = -1; + memStrIdx = 0; + while((memReqIdx < 0) && (memFn[memStrIdx] != NULLP)) + { + memReqIdx = cmMemGetStrMtchIdx(0, traceSize, memFn[memStrIdx], + funNm); + memStrIdx++; + } + mdlFunStrIdx = 0; + while(memUsrMdlStr[mdlFunStrIdx].fPStr != NULLP) + { + len = strlen((const S8 *)memUsrMdlStr[mdlFunStrIdx].fPStr); + memReqIdx = cmMemGetStrMtchIdx((memReqIdx + 1), traceSize, + memUsrMdlStr[mdlFunStrIdx].fPStr, + funNm); + if(memReqIdx >= 0) + { + RETVALUE(mdlFunStrIdx); + } + mdlFunStrIdx++; + } + mdlFunStrIdx = 0; + while(memUsrMdlStr[mdlFunStrIdx].fPStr != NULLP) + { + retVal = strcmp((const S8 *)"DEFAULT", + (const S8 *)memUsrMdlStr[mdlFunStrIdx].fPStr); + if(retVal == NULLD) + { + RETVALUE(mdlFunStrIdx); + } + mdlFunStrIdx++; + } + } + + RETVALUE(0); +} /* cmMemGetModuleId */ + +/* +* +* Fun: cmMemGetStrMtchIdx +* +* Desc: Initializes the memory leak detection module +* +* +* Ret: RETVOID +* +* Notes: This function initializes the memory leak detection module. +* +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmMemGetStrMtchIdx +( +U8 strtIdx, +U8 endIdx, +S8 *str, +S8 **strLst +) +#else +PUBLIC S16 cmMemGetStrMtchIdx(strtIdx, endIdx, str, strLst) +U8 strtIdx; +U8 endIdx; +S8 *str; +S8 **strLst; +#endif +{ + + S8 cmpStr[255]; + U32 len; + Bool found; + U32 tempLen; + U8 idx; + S32 retVal; + TRC3(cmMemGetStrMtchIdx); + + len = strlen((const S8 *)str); + cmpStr[0] = '('; + strncpy((S8 *)&cmpStr[1], (const S8 *)str, len); + cmpStr[len + 1] = '\0'; + len++; + found = FALSE; + for(;strtIdx < endIdx && !found; strtIdx++) + { + idx = 0; + tempLen = strlen((const S8 *)strLst[strtIdx]); + if(tempLen < len) + continue; + + while(*(strLst[strtIdx] + idx + len) != '\0') + { + retVal = strncmp((const S8 *)cmpStr, + ((const S8 *)strLst[strtIdx] + idx), len); + if(0 == retVal) + { + found = TRUE; + break; + } + idx++; + } + } + + if(!found) + { + RETVALUE(-1); + } + RETVALUE(strtIdx); + +} /* cmMemGetStrMtchIdx */ + +/* +* +* Fun: cmRlsAllocBlk +* +* Desc: Initializes the memory leak detection module +* +* +* Ret: RETVOID +* +* Notes: This function initializes the memory leak detection module. +* +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PUBLIC Void cmRlsAllocBlk +( +U32 addr +) +#else +PUBLIC Void cmRlsAllocBlk(addr) +U32 addr; +#endif +{ + Ptr trace[CM_MAX_STACK_TRACE]; + S8 **funcNm; + U8 idx; + U8 i; + S16 retVal; + S32 traceSize; + MemAllocInfo *memAllocInfo; + + TRC3(cmRlsAllocBlk); + if( memLkCb.memLkMdlInit == FALSE) + { + RETVOID; + } + + + for(idx = 0; idx < CM_MEM_USR_MDL; idx++) + { + SLock(&memLkCb.memUsrMdl[idx][addr & 0x3].memLck); + retVal = cmHashListFind(&memLkCb.memUsrMdl[idx][addr & 0x3].memHashCp, + (U8 *)&addr, sizeof(U32), 0, + (PTR *)&memAllocInfo); + if(retVal == ROK) + { + cmHashListDelete(&memLkCb.memUsrMdl[idx][addr & 0x3].memHashCp, + (PTR)memAllocInfo); + SUnlock(&memLkCb.memUsrMdl[idx][addr & 0x3].memLck); + funcNm = (S8 **) memAllocInfo->backTrace; +#ifdef SS_MEM_LEAK_SOL + for(i = 0; i < memAllocInfo->bTrcSz; i++) + { +/*cm_mem_c_001.main_27 SSI-4GMX specfic changes*/ +#ifdef SS_4GMX_LCORE + MxHeapFree(SsiHeap, funcNm[i]); +#else + free(funcNm[i]); +#endif + } +#endif /* SS_MEM_LEAK_SOL */ +#ifdef SS_MEM_LEAK_FREE_TRACE + { + + Txt prntBuf[255]; + sprintf( prntBuf, "\n==============================\n"); + SPrint(prntBuf); + /* cm_mem_c_001.main_25 - Fixed compilation warnings 32/64 bit */ +#ifdef ALIGN_64BIT + sprintf( prntBuf, "Address: [%x]\n", addr); +#else + sprintf( prntBuf, "Address: [%lx]\n", addr); +#endif + SPrint(prntBuf); + traceSize = backtrace(trace, CM_MAX_STACK_TRACE); + funcNm = backtrace_symbols(trace, traceSize); + sprintf( prntBuf, "[bt] Execution path:\n"); + SPrint(prntBuf); + for (i=0; i < traceSize; ++i) + { + sprintf( prntBuf, "[bt] %s\n", funcNm[i]); + SPrint(prntBuf); + } + sprintf( prntBuf, "\n==============================\n"); + SPrint(prntBuf); + } +#endif /* SS_MEM_LEAK_FREE_TRACE */ +/*cm_mem_c_001.main_27 SSI-4GMX specfic changes*/ +#ifdef SS_4GMX_LCORE + MxHeapFree(SsiHeap, funcNm); + MxHeapFree(SsiHeap, memAllocInfo); +#else + free(funcNm); + free(memAllocInfo); +#endif + break; + } + SUnlock(&memLkCb.memUsrMdl[idx][addr & 0x3].memLck); + } + +#ifndef SS_MEM_LEAK_SOL + if(idx == CM_MEM_USR_MDL) + { + Txt prntBuf[255]; + sprintf( prntBuf,"\nPossible Double-Deallocation.\n"); + SPrint(prntBuf); +/*cm_mem_c_001.main_23 Fix for specifier mismatch warnings in 64BIT compilation*/ +#ifdef ALIGN_64BIT + sprintf( prntBuf, "Address: [%u]\n", addr); +#else + sprintf( prntBuf, "Address: [%lu]\n", addr); +#endif + SPrint(prntBuf); + traceSize = backtrace(trace, CM_MAX_STACK_TRACE); + funcNm = backtrace_symbols(trace, traceSize); + sprintf( prntBuf,"[bt] Execution path:\n"); + SPrint(prntBuf); + for (i=0; i < traceSize; ++i) + { + sprintf( prntBuf,"[bt] %s\n", funcNm[i]); + SPrint(prntBuf); + } + printf("\n==============================\n"); +/*cm_mem_c_001.main_27 SSI-4GMX specfic changes*/ +#ifdef SS_4GMX_LCORE + MxHeapFree(SsiHeap, funcNm); +#else + free(funcNm); +#endif + } +#endif /* SS_MEM_LEAK_SOL */ + + /*cm_mem_c_001.main_25 : */ + RETVOID; +} /* cmRlsAllocBlk */ + + +#ifdef SS_MEM_LEAK_SOL +/* +* +* Fun: cmAddrToSymStr +* +* Desc: Initializes the memory leak detection module +* +* +* Ret: RETVOID +* +* Notes: This function initializes the memory leak detection module. +* +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PUBLIC S32 cmAddrToSymStr +( +Void *pc, +S8 *buffer, +S32 size +) +#else +PUBLIC S32 cmAddrToSymStr(pc, buffer, size) +Void *pc; +S8 *buffer; +S32 size; +#endif +{ + + Dl_info info; + Sym *sym; + + TRC3(cmAddrToSymStr); + + if (dladdr1(pc, &info, (Void **)&sym, RTLD_DL_SYMENT) == 0) + { + RETVALUE(snprintf(buffer, size, "[0x%p]", pc)); + } + + if ((info.dli_fname != NULLP && info.dli_sname != NULLP) && + ((uintptr_t)pc - (uintptr_t)info.dli_saddr < sym->st_size)) + { + RETVALUE(snprintf(buffer, size, "%s(%s+0x%x) [0x%p]", + info.dli_fname, + info.dli_sname, + (unsigned long)pc - (unsigned long)info.dli_saddr, pc)); + } + else + { + RETVALUE(snprintf(buffer, size, "%s(0x%p [0x%p]", + info.dli_fname, + (unsigned long)pc - (unsigned long)info.dli_fbase, pc)); + } + +} /* cmAddrToSymStr */ + +/* +* +* Fun: cmLeakCallBack +* +* Desc: Initializes the memory leak detection module +* +* +* Ret: RETVOID +* +* Notes: This function initializes the memory leak detection module. +* +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PUBLIC S32 cmLeakCallBack +( +uintptr_t pc, +S32 sigNo, +Void *arg +) +#else +PUBLIC S32 cmLeakCallBack(pc, sigNo, arg) +uintptr_t pc; +S32 sigNo; +Void *arg; +#endif +{ + S8 *buffer; + TRC3(cmLeakCallBack); + + Backtrace_t *bt = (Backtrace_t *)arg; + if (bt->bt_actcount >= bt->bt_maxcount) + RETVALUE(-1); +/*cm_mem_c_001.main_27 SSI-4GMX specfic changes*/ +#ifdef SS_4GMX_LCORE + buffer = (S8 *)MxHeapAlloc(SsiHeap, 510); + cmMemset((U8*)buffer, 0, 510); +#else + buffer = (S8 *)calloc(1, 510); +#endif + /* SGetSBuf(DFLT_REGION, DFLT_POOL, &buffer, 510); */ + (void) cmAddrToSymStr((void *)pc, buffer, 505); + bt->bt_buffer[bt->bt_actcount++] = (S8 *)buffer; + + RETVALUE(0); +} /* cmLeakCallBack */ + +/* +* +* Fun: backtrace +* +* Desc: Initializes the memory leak detection module +* +* +* Ret: RETVOID +* +* Notes: This function initializes the memory leak detection module. +* +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PUBLIC S32 backtrace +( +Void **buffer, +S32 count +) +#else +PUBLIC S32 backtrace(buffer, count) +Void **buffer; +S32 count; +#endif +{ + TRC3(backtrace); + + Backtrace_t bt; + ucontext_t u; + + bt.bt_buffer = buffer; + bt.bt_maxcount = count; + bt.bt_actcount = 0; + + if (getcontext(&u) < 0) + RETVALUE(0); + (Void) walkcontext(&u, cmLeakCallBack, &bt); + RETVALUE(bt.bt_actcount); + +} /* backtrace */ + +#endif /* SS_MEM_LEAK_SOL */ + +#endif /* SS_MEM_LEAK_STS */ +/* cm_mem_c_001.main_12 - addition related to SSI enhancemens +* These include sanity check functions for bucket and heap, +* for printing several memory related statistics +*/ +#ifdef SSI_DEBUG_LEVEL1 +/* +* +* Fun: cmMmBktSanityChk +* +* Desc: Performs the sanity check for the memory blocks in a memory bucket. +* This API gets called when trampling is detected in a memory block. +* +* Ret: RTRAMPLINGNOK - Trampling, serious error +* RTRAMPLINGOK - Trampling, but OK to proceed +* +* Notes: This function performs the memory block sanity in a bucket. This +* function is called by cmAlloc and cmFree as part of error handling mechanism. +* Performs sanity check for the whole bucket by traversing each +* of the memory blocks using the pointer bktStartPtr. +* Keeps track of number of tramplings happened. If the count +* exceeds the threshold decided, then invalidates this bucket. +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PRIVATE S16 cmMmBktSanityChk +( +CmMmBkt *bkt +) +#else +PRIVATE S16 cmMmBktSanityChk(bkt) +CmMmBkt *bkt; +#endif +{ + CmMmBlkHdr *ptrBlk; + U32 blkCnt; + + TRC2(cmMmBktSanityChk); + + bkt->trampleCount = 0; + + /* scan the entire memory list of the bucket */ + for (blkCnt = 0, ptrBlk = (CmMmBlkHdr *)bkt->bktStartPtr; + blkCnt < (bkt->numBlks); blkCnt++) + { + if (cmMmRegIsBlkSane(ptrBlk) != ROK) + { + bkt->trampleCount++; + if (bkt->trampleCount > CMM_TRAMPLING_THRESHOLD) + { + /* Take action to invalidate the entire bucket */ + RETVALUE(RTRAMPLINGNOK); + } + } + /* reach next memory block in this bucket manually */ + ptrBlk = (CmMmBlkHdr *)((Data *)ptrBlk + ((bkt->size) + (sizeof(CmMmBlkHdr)))); + } + + #ifdef DEBUGP + /* display an error message here */ + sprintf(dbgPrntBuf, " %d Memory tramplings detected in the bucket!\n", bkt->trampleCount); + SDisplay(0, dbgPrntBuf); + #endif /* DEBUGP */ + + RETVALUE(RTRAMPLINGOK); +} + +/* +* +* Fun: cmMmHeapSanityChk +* +* Desc: Performs the sanity check for the memory blocks in the memory heap. +* This API gets called when trampling is detected in heap(Alloc/Free). +* +* Ret: RTRAMPLINGNOK - Trampling, serious error +* RTRAMPLINGOK - Trampling, but OK to proceed +* +* Notes: This function performs the memory block sanity in the heap. This +* function is called by cmHeapAlloc and cmHeapFree as part of error +* handling mechanism. Keeps track of number of tramplings happened. +* If the count exceeds the threshold then return RTRAMPLINGNOK. If the +* count is less than threshold, then return RTRAMPLINGOK. +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PRIVATE S16 cmMmHeapSanityChk +( +CmMmHeapCb *heapCb +) +#else +PRIVATE S16 cmMmHeapSanityChk(heapCb) +CmMmHeapCb *heapCb; +#endif +{ + + TRC2(cmMmHeapSanityChk); + + /* increment the trample count */ + heapCb->trampleCount++; + + if (heapCb->trampleCount > CMM_TRAMPLING_THRESHOLD) + { + RETVALUE(RTRAMPLINGNOK); + } + + RETVALUE(RTRAMPLINGOK); +} + +/* +* +* Fun: cmMmRegIsBlkSane +* +* Desc: Performs the sanity check for the memory block by checking its header. +* +* Ret: ROK - If no trampling is detected in the block +* RFAILED - If trampling is detected in the block +* +* Notes: This function performs the memory block sanity in a block. +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PUBLIC S16 cmMmRegIsBlkSane +( +CmMmBlkHdr *blkPtr +) +#else +PUBLIC S16 cmMmRegIsBlkSane(blkPtr) +CmMmBlkHdr *blkPtr; +#endif +{ + U32 sigCnt; + + TRC2(cmMmRegIsBlkSane); + + for ( sigCnt=0; sigCnt < CMM_TRAMPLING_SIGNATURE_LEN; sigCnt++) + { + if (blkPtr->trSignature[sigCnt] != 0xAB) + { + RETVALUE(RFAILED); + } + } + + RETVALUE(ROK); +} + +/* +* +* Fun: cmMmHashFunc +* +* Desc: Computes the hash list index (bin number) for a specified +* key of type (x % 101). +* +* return (idx % hash_table_size); +* +* Ret: ROK - successful, *idx contains computed index +* +* Notes: None. +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PRIVATE S16 cmMmHashFunc +( +CmMmHashListCp *hashListCp, +U32 key, +U16 *idx +) +#else +PRIVATE S16 cmMmHashFunc (hashListCp, key, idx) +CmMmHashListCp *hashListCp; /* hash list control point */ +U32 key; /* key string */ +U16 *idx; /* idx to return */ +#endif +{ + TRC2(cmMmHashFunc); + + *idx = (U16)(key % hashListCp->numOfbins); + + RETVALUE(ROK); + +} /* end of cmMmHashFunc () */ + +/* +* +* Fun: cmMmHashListInit +* +* Desc: Initializes a hash list. Parameters are: +* +* hashListCp control point for hash list +* nmbBins number of bins in the hash list. Storage will +* be allocated for them from the indicated memory +* region and pool. +* region +* pool for allocating storage for bins. +* +* Ret: ROK - initialization successful +* RFAILED - initialization failed, lack of memory +* +* Notes: None +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PRIVATE S16 cmMmHashListInit +( +CmMmHashListCp *hashListCp, /* hash list to initialize */ +U16 nmbBins, /* number of hash list bins */ +Region region, /* memory region to allocate bins */ +Pool pool /* memory pool to allocate bins */ +) +#else +PRIVATE S16 cmMmHashListInit(hashListCp, nmbBins, region, pool) +CmMmHashListCp *hashListCp; /* hash list to initialize */ +U16 nmbBins; /* number of hash list bins */ +Region region; /* memory region to allocate bins */ +Pool pool; /* memory pool to allocate bins */ +#endif +{ + U16 i; + CmMmHashListEnt *hl; + + TRC2(cmMmHashListInit); + + /* initialize control point fields */ + hashListCp->hashList = NULLP; + hashListCp->numOfbins = 0; + hashListCp->numOfEntries = 0; + + /* allocate memory for bins */ + if (nmbBins) + { + if (SGetSBuf(region, pool, (Data **) &hashListCp->hashList, + (Size)(nmbBins * sizeof(CmMmHashListEnt))) != ROK) + RETVALUE(RFAILED); + + /* initialize bin pointers */ + hl = hashListCp->hashList; + for(i = 0; i < nmbBins; i++) + { + hl[i].size = hl[i].numAttempts = 0; + } + + /* initialize bin size */ + hashListCp->numOfbins = nmbBins; + } + + RETVALUE(ROK); +} + +/* +* +* Fun: cmMmHashListDeinit +* +* Desc: Deinitializes a hash list. Deallocates memory for bins +* and resets header fields. Parameters are: +* +* hashListCp control point for hash list +* region +* pool for allocating storage for bins. +* +* Ret: ROK - successful +* RFAILED - failure, invalid parameters +* +* Notes: None +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PRIVATE S16 cmMmHashListDeinit +( +CmMmHashListCp *hashListCp, /* hash list to deinitialize */ +Region region, /* memory region to allocate bins */ +Pool pool /* memory pool to allocate bins */ +) +#else +PRIVATE S16 cmMmHashListDeinit(hashListCp, region, pool) +CmMmHashListCp *hashListCp; /* hash list to deinitialize */ +Region region; /* memory region to allocate bins */ +Pool pool; /* memory pool to allocate bins */ +#endif +{ + TRC2(cmMmHashListDeinit); + + /* deallocate memory for bins */ + if (hashListCp->numOfbins) + (Void) SPutSBuf(region, pool, + (Data *) hashListCp->hashList, + (Size) (hashListCp->numOfbins * sizeof(CmMmHashListEnt))); + + /* deinitialize control point fields */ + hashListCp->hashList = NULLP; + hashListCp->numOfbins = 0; + hashListCp->numOfEntries = 0; + + RETVALUE(ROK); +} /* end of cmMmHashListDeinit */ + +/* +* +* Fun: cmMmHashListInsert +* +* Desc: Inserts a new entry in the hash list. Parameters are: +* +* hashListCp control point for hash list +* key pointer to key string in the new entry +* +* Ret: ROK - insertion successful +* RFAILED - insertion failed (incorrect parameter values) +* +* Notes: None +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PRIVATE S16 cmMmHashListInsert +( +CmMmHashListCp *hashListCp, /* hash list to add to */ +U32 key /* pointer to key */ +) +#else +PRIVATE S16 cmMmHashListInsert(hashListCp, key) +CmMmHashListCp *hashListCp; /* hash list to add to */ +U32 key; /* pointer to key */ +#endif +{ + CmMmHashListEnt *hashListEnt; /* pointer to hash list entry header */ + U16 idx; /* index for insertion into hash list */ + U16 i; + + TRC2(cmMmHashListInsert); + + /* check if hashListCp is initialised yet */ + if ( hashListCp->numOfbins == 0) + RETVALUE(ROK); + + /* compute index for insertion */ + if (cmMmHashFunc(hashListCp, key, &idx) != ROK) + RETVALUE(RFAILED); + + hashListEnt = hashListCp->hashList; + + if (hashListEnt[idx].numAttempts == 0) + { + /* new entry, insert here */ + hashListEnt[idx].size = key; + hashListEnt[idx].numAttempts++; + /* increment count of entries in hash list */ + hashListCp->numOfEntries++; + } + else + { + /* this hash is occupied, re-hash it using linear probing */ + for (i=idx; i < CMM_STAT_HASH_TBL_LEN; i++) + { + if (hashListEnt[i].size == key) + { + hashListEnt[i].numAttempts++; + break; + } + + if (hashListEnt[i].numAttempts == 0) + { + hashListEnt[i].size = key; + hashListEnt[i].numAttempts++; + /* increment count of entries in hash list */ + hashListCp->numOfEntries++; + break; + } + } + + if (i == CMM_STAT_HASH_TBL_LEN) + { + /* there is no free slot for this key */ + RETVALUE(RFAILED); + } + } + + RETVALUE(ROK); +} /* end of cmMmHashListInsert */ + +#endif /* SSI_DEBUG_LEVEL1 */ +/* cm_mem_c_001.main_15 : Additions */ +#ifdef SS_HISTOGRAM_SUPPORT +/* +* +* Fun: cmHstGrmHashListInit +* +* Desc: Initializes a hash list. Parameters are: +* +* hashListCp control point for hash list +* Ret: ROK - initialization successful +* RFAILED - initialization failed, lack of memory +* +* Notes: None +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PRIVATE S16 cmHstGrmHashListInit +( +CmHstGrmHashListCp *hashListCp /* hash list to initialize */ +) +#else +PRIVATE S16 cmHstGrmHashListInit(hashListCp) +CmHstGrmHashListCp *hashListCp; /* hash list to initialize */ +#endif +{ + /*cm_mem_c_001.main_25 : Fix for TRACE5 feature crash due to missing TRC MACRO*/ + TRC2(cmHstGrmHashListInit) +#ifdef DEBUGP + /* display an error message here */ + /*cm_mem_c_001.main_25: Fixed Warnings for 32/64 bit compilation*/ +#ifdef ALIGN_64BIT + sprintf(dbgPrntBuf, " %lu size of memory histogram hash List\n", sizeof(CmHstGrmHashListCp)); +#else + sprintf(dbgPrntBuf, " %d size of memory histogram hash List\n", sizeof(CmHstGrmHashListCp)); +#endif + SDisplay(0, dbgPrntBuf); +#endif /* DEBUGP */ + memset(hashListCp, 0, sizeof(CmHstGrmHashListCp)); + RETVALUE(ROK); +} + +/* +* +* Fun: cmHstGrmHashListDeInit +* +* Desc: De-initializes a hash list. Parameters are: +* +* hashListCp control point for hash list +* Ret: ROK - initialization successful +* RFAILED - initialization failed, lack of memory +* +* Notes: None +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PRIVATE S16 cmHstGrmHashListDeInit +( +CmHstGrmHashListCp *hashListCp /* hash list to initialize */ +) +#else +PRIVATE S16 cmHstGrmHashListDeInit(hashListCp) +CmHstGrmHashListCp *hashListCp; /* hash list to initialize */ +#endif +{ + /*cm_mem_c_001.main_25 : Fix for TRACE5 feature crash due to missing TRC MACRO*/ + TRC2(cmHstGrmHashListDeInit) +#ifdef DEBUGP + /* display an error message here */ + /*cm_mem_c_001.main_25: Fixed Warnings for 32/64 bit compilation*/ +#ifdef ALIGN_64BIT + sprintf(dbgPrntBuf, " %lu size of memory histogram hash List\n", sizeof(CmHstGrmHashListCp)); +#else + sprintf(dbgPrntBuf, " %d size of memory histogram hash List\n", sizeof(CmHstGrmHashListCp)); +#endif + SDisplay(0, dbgPrntBuf); +#endif /* DEBUGP */ + memset(hashListCp, 0, sizeof(CmHstGrmHashListCp)); + RETVALUE(ROK); +} + +/* +* +* Fun: cmHstGrmFreeInsert +* +* Desc: Inserts a Freed information in into the hash list. Parameters are: +* +* bkt : pointer to bucket for which memory is freed. +* line : Line where memory is freed. +* file : file where memory is freed. +* entId : Tapa task which releases the memory. +* +* Ret: ROK - insertion successful +* RFAILED - insertion failed (incorrect parameter values) +* +* Notes: None +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PRIVATE S16 cmHstGrmFreeInsert +( +CmHstGrmHashListCp* hashListCp, /* hash list cp */ +U32 blkSz, /* size of the block freed */ +U32 line, /* Line number */ +U8 *fileName, /* file name */ +U8 entId /* Tapa task which free the memory */ +) +#else +PRIVATE S16 cmHstGrmFreeInsert(hashListCp, blkSz, line, fileName, entId) +CmHstGrmHashListCp* hashListCp; /* hash list cp */ +U32 blkSz; /* size of the block freed */ +U32 line; /* line number */ +U8 *fileName; /* file Name */ +U8 entId; /* Tapa task which frees the memory */ +#endif +{ + U32 binIdx = 0; /* Bin index to insert the entry into the hash list */ + U32 key = 0; /* Key to fine the bin index */ + U32 ret = 0; /* Return value */ + CmMemEntries *entry = NULLP; /* Entry which contains the information */ + + + TRC2(cmHstGrmFreeInsert); + + /* check for the total number of entries in the hash list. * + * If there is no place for new entry return failure */ + cmHstGrmGetHashIdxAndKey(fileName, line, &binIdx, &key); + + /* After comuting the hash bind and key, check the entity already * + existing or not. if we found the entry then update the information */ + ret = cmHstGrmFindEntry(hashListCp, key, &binIdx, &entry); + if(ret == ROK) + { + entry->freedBytes += blkSz; + entry->bucketFreeReq++; + RETVALUE(ROK); + } /* End of if */ + + /* If hash list is full then print the error tna continue */ + if(hashListCp->totalNumEntries == (CMM_HIST_MAX_MEM_BIN * CMM_HIST_MAX_MEM_ENTRY_PER_BIN)) + { + printf("No place in the hash list. Increase the value of macro CMM_HIST_MAX_MEM_BIN and CMM_HIST_MAX_MEM_ENTRY_PER_BIN \n"); + RETVALUE(RFAILED); + } /* End of if */ + + /* Take the address of next free entry in the hash bin */ + entry = &(hashListCp->hashList[binIdx].entries[hashListCp->hashList[binIdx].numOfEntries]); + + /* Increase the number of time frees called */ + entry->bucketFreeReq++; + entry->freedBytes += blkSz; + + /* Fill the information into the entry structure */ + cmHstGrmFillEntry(entry, key, line, fileName, entId); + /* Increase the total numbet of entries in the bin */ + hashListCp->hashList[binIdx].numOfEntries++; + + /* Increase the total number of entries in the hash list */ + hashListCp->totalNumEntries++; + + RETVALUE(ROK); +} /* end of cmHstGrmFreeInsert */ + + +/* +* +* Fun: ret = cmHstGrmAllocInsert +* +* Desc: Inserts a memory allocated information in the hash list. Parameters are: +* +* hashListCp control point for hash list +* key pointer to key string in the new entry +* +* Ret: ROK - insertion successful +* RFAILED - insertion failed (incorrect parameter values) +* +* Notes: None +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PRIVATE S16 cmHstGrmAllocInsert +( +CmHstGrmHashListCp *hashListCp, +U32 blkSz, +U32 *reqSz, +U32 line, +U8 *fileName, +U8 entId +) +#else +PRIVATE S16 cmHstGrmAllocInsert(hashListCp, blkSz, reqSz, line, fileName, entId) +CmHstGrmHashListCp *hashListCp; +U32 blkSz; +U32 *reqSz; +U32 line; +U8 *fileName; +U8 entId; +#endif +{ + U32 binIdx = 0; + U32 key = 0; + U32 ret = 0; + CmMemEntries *entry = NULLP; + + TRC2(cmHstGrmAllocInsert); + + /* check for the total number of entries in the hash list. * + * If there is no place for new entry return failure */ + cmHstGrmGetHashIdxAndKey(fileName, line, &binIdx, &key); + + /* After comuting the hash bind and key, check the entity already * + existing or not. if we found the entry then update the information */ + ret = cmHstGrmFindEntry(hashListCp, key, &binIdx, &entry); + + if(ret == ROK) + { + entry->allocBytes += blkSz; + entry->bucketAllocReq++; + entry->wastedBytes += (blkSz - *reqSz); + RETVALUE(ROK); + } /* End of if */ + + if(hashListCp->totalNumEntries == (CMM_HIST_MAX_MEM_BIN * CMM_HIST_MAX_MEM_ENTRY_PER_BIN)) + { + printf("No place in the hash list. Increase the value of macro CMM_HIST_MAX_MEM_BIN and CMM_HIST_MAX_MEM_ENTRY_PER_BIN\n"); + RETVALUE(RFAILED); + } /* End of if */ + + /* Take the address of next free entry in the hash bin */ + entry = &(hashListCp->hashList[binIdx].entries[hashListCp->hashList[binIdx].numOfEntries]); + + /* Clauculae the wasted bytes */ + /* Here wasted byte is differnce between the byte user + * has requested and the byte the ssi allocated */ + entry->wastedBytes += (blkSz - *reqSz); + entry->bucketAllocReq++; + entry->allocBytes += blkSz; + + /* Fill the information into the entry structure */ + cmHstGrmFillEntry(entry, key, line, fileName, entId); + /* Increase the total numbet of entries in the bin */ + hashListCp->hashList[binIdx].numOfEntries++; + + /* Increase the total number of entries in the hash list */ + hashListCp->totalNumEntries++; + + RETVALUE(ROK); +} /* end of cmHstGrmAllocInsert */ + + +/* +* +* Fun: cmHstGrmGetHashIdxAndKey +* +* Desc: Finds an entry in the hash list. Parameters are: +* +* hashListCp control point for hash list +* key pointer to key string in the new entry +* +* Ret: ROK - insertion successful +* RFAILED - insertion failed (incorrect parameter values) +* +* Notes: None +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PRIVATE S16 cmHstGrmGetHashIdxAndKey +( +U8 *fileName, +U32 line, +U32 *binIdx, +U32 *key +) +#else +PRIVATE S16 cmHstGrmGetHashIdxAndKey(fileName, line, binIdx, key) +U8 *fileName; +U32 line; +U32 *binIdx; +U32 *key; +#endif +{ + + U32 i = 0; + TRC2(cmHstGrmGetHashIdxAndKey); + + /* Calculate the key using file name and line number */ + for(i = 0 ; fileName[i] != '\0'; i++) + { + *key += fileName[i]; + }/* End of for */ + *key += line; + *binIdx = ( *key % CMM_HIST_MAX_MEM_BIN); + RETVALUE(ROK); +} /* end of cmHstGrmFillEntry */ + +/* +* +* Fun: cmHstGrmFillEntry +* +* Desc: Insert the entry into the hash list. +* +* entry : Infornation which will be inserted into the hash list +* key : Which will be used ti find the entry. +* line : Line number +* fileName : File name +* entId : Tapa task Id +* +* Ret: ROK - insertion successful +* RFAILED - insertion failed (incorrect parameter values) +* +* Notes: None +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PRIVATE S16 cmHstGrmFillEntry +( +CmMemEntries *entry, +U32 key, +U32 line, +U8 *fileName, +U8 entId +) +#else +PRIVATE S16 cmHstGrmFillEntry(entry, key, line, fileName, entId) +CmMemEntries *entry; +U32 key; +U32 line; +U8 *fileName; +U8 entId; +#endif +{ + + U32 idx = 0; + TRC2(cmHstGrmFillEntry); + entry->key = key; + entry->line = line; + entry->entId = entId; + for(idx = 0; fileName[idx] != '\0'; idx++) + { + entry->fileName[idx] = fileName[idx]; + } + entry->fileName[idx] = '\0'; + RETVALUE(ROK); +} /* end of cmHstGrmFillEntry */ + +/* +* +* Fun: cmHstGrmFindEntry +* +* Desc: Finds an entry in the hash list. Parameters are: +* +* hashListCp control point for hash list +* key pointer to key string in the new entry +* +* Ret: ROK - insertion successful +* RFAILED - insertion failed (incorrect parameter values) +* +* Notes: None +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PRIVATE S16 cmHstGrmFindEntry +( +CmHstGrmHashListCp *hashListCp, +U32 key, +U32 *binIdx, +CmMemEntries **entry +) +#else +PRIVATE S16 cmHstGrmFindEntry(hashListCp, key, binIdx, entry) +CmHstGrmHashListCp *hashListCp; +U32 key; +U32 *binIdx; +CmMemEntries **entry; +#endif +{ + + U32 numEnt = 0; + U32 numBin = 0; + CmHstGrmHashListEnt *tmpBin = NULLP; + + TRC2(cmHstGrmFindEntry); + + + for(numBin = 0; numBin < CMM_HIST_MAX_MEM_BIN; numBin++) + { + /* find for the entry in the bin */ + tmpBin = &(hashListCp->hashList[*binIdx]); + for(numEnt = 0; numEnt < tmpBin->numOfEntries; numEnt++) + { + /* If key supplied is matched with the stored key then + * return that entity */ + if(tmpBin->entries[numEnt].key == key) + { + *entry = &(tmpBin->entries[numEnt]); + RETVALUE(ROK); + }/* End of if (tmpBin->entries[numEnt].key) */ + }/* end of for (numEnt = 0) */ + + /* Here we are checking for any room left in the bin. If the room * + exists its mean that there is no entry with the Key. so return * + failure. + If there is no room in the bin, then check the other bins to find * + the entry */ + if(numEnt == CMM_HIST_MAX_MEM_ENTRY_PER_BIN) + { + if(*binIdx == CMM_HIST_MAX_MEM_BIN) + { + *binIdx = 0; + }/* End of if (binIdx) */ + else + { + *binIdx++; + }/* End of else (binIdx) */ + } /* End of if (numEnt) */ + else + { + printf ("Unable to find the entry in hash list\n"); + RETVALUE(RFAILED); + }/* End of else (numEnt) */ + }/* end of for (numBin = 0) */ + + printf("Unable to find the entry in the hash list\n"); + RETVALUE(RFAILED); +} /* end of cmHstGrmFindEntry */ + +#endif /* SS_HISTOGRAM_SUPPORT */ +#ifdef T2K_MEM_LEAK_DBG +T2kMeamLeakInfo gMemLeakInfo[T2K_MEM_LEAK_INFO_TABLE_SIZE]; +U32 getT2kMemLeakIndex(U32 address) +{ +#if 0 + /* + 1 2 3 4 5 6 7 + + XOR 7 with 3 and remove 7 + XOR 1 with 5 and remove 1 + */ + + address -= T2K_MEM_LEAK_START_ADDR; + + U8 Nib7 = address & 0x0000000f; + U8 Nib1 = (address & 0x0f000000) >>24; + U8 Nib3 = (address & 0x000f0000) >> 16; + U8 Nib5 = (address & 0x00000f00) >> 8; + + /* store 8 ^ 3 in 8Nib */ + Nib7 = Nib7 ^ Nib3; + /* store 1 ^ 6 in 6Nib */ + Nib5 = Nib5 ^ Nib1; + + return(((address & 0x000fff00) | (Nib7 << 20) | (Nib5 << 4)) >> 4); + +#endif + return ((address - T2K_MEM_LEAK_START_ADDR) >> 8); +} + +static U32 t2kMemAllocTick; +static U32 smallTick; + +void InsertToT2kMemLeakInfo(U32 address, U32 size, U32 lineNo, char* fileName) +{ + U32 idx = getT2kMemLeakIndex(address); + + if(((U32)(address - T2K_MEM_LEAK_START_ADDR) & 0xff) !=0) + { + printf("address in InsertToT2kMemLeakInfo is %lx size = %ld file is %s" + "line is %ld \n", address, size, fileName, lineNo); + } + + if(gMemLeakInfo[idx].address == 0) + { + gMemLeakInfo[idx].address = address; + gMemLeakInfo[idx].size = size; + gMemLeakInfo[idx].lineNo = lineNo; + gMemLeakInfo[idx].fileName = fileName; + gMemLeakInfo[idx].age = t2kMemAllocTick; + gMemLeakInfo[idx].prevRemLineNo = 0; + gMemLeakInfo[idx].prevRemFileName = '\0'; + + if(smallTick++ == 4096) + { + smallTick = 0; + gMemLeakInfo[idx].age = (++t2kMemAllocTick); + } + } + else + { + printf("Something is wrong, trying to insert %lx idx = %ld file is %s" + "line is %ld \n",address, idx, fileName, lineNo); + printf("Address present :%lx, from File:%s, Line:%ld, Size:%ld," + "Age:%ld, differnce in Age:%ld", + gMemLeakInfo[idx].address, gMemLeakInfo[idx].fileName, + gMemLeakInfo[idx].lineNo, gMemLeakInfo[idx].size, + gMemLeakInfo[idx].age, (t2kMemAllocTick-gMemLeakInfo[idx].age)); +#if 0 + /* Try inserting into some other location */ + int i; + int lastIndex = idx + 1; + Bool inserted = FALSE; + for(i = 2; lastIndex < T2K_MEM_LEAK_INFO_TABLE_SIZE && i < 30; i++) + { + if(gMemLeakInfo[lastIndex].address == 0) + { + gMemLeakInfo[lastIndex].address = address; + gMemLeakInfo[lastIndex].size = size; + gMemLeakInfo[lastIndex].lineNo = lineNo; + gMemLeakInfo[lastIndex].fileName = fileName; + gMemLeakInfo[lastIndex].age = (++t2kMemAllocTick) >> 14; /*For every 16384 memory block allocations,Alloc Tick is incremented by 1*/ + inserted = TRUE; + break; + } + lastIndex = idx + (i * i * i); + } +#if 1 + if(!inserted) + { + printf("Something is wrong, trying to insert %x idx = %d no free i = %d\n",address, idx, i); + } +#endif +#endif + } +} + + +void RemoveFromT2kMemLeakInfo(U32 address, char *file, U32 line) +{ + U32 idx = getT2kMemLeakIndex(address); + + if(idx >= T2K_MEM_LEAK_INFO_TABLE_SIZE) + { + printf("Idx out of range = %ld address is %lx file = %s line = %ld. We are going to crash!!!\n", + idx, + address, + file, + line); + } + if(gMemLeakInfo[idx].address == address) + { + gMemLeakInfo[idx].address = 0; + gMemLeakInfo[idx].age = 0; + gMemLeakInfo[idx].prevRemLineNo = gMemLeakInfo[idx].lineNo; + gMemLeakInfo[idx].prevRemFileName = gMemLeakInfo[idx].fileName; + + gMemLeakInfo[idx].lastDelLineNum = line; + gMemLeakInfo[idx].lastDelFileName = file; + /*printf("Something is wrong, Trying to double free Address = %x, Idx = %d \n",address,idx);*/ + } + else + { + printf("Something is wrong, trying to remove %lx idx = %ld from" + "File=%s, line=%ld address present is %lx\n",address, idx, file,line, + gMemLeakInfo[idx].address); + + + printf("\n Last Del file %s line %ld\n",gMemLeakInfo[idx].lastDelFileName, + gMemLeakInfo[idx].lastDelLineNum); + + if(gMemLeakInfo[idx].prevRemFileName != NULLP) + { + printf("Previous File:%s, Previous Line:%ld\n", + gMemLeakInfo[idx].prevRemFileName, gMemLeakInfo[idx].prevRemLineNo); + } +#if 0 + /* Try removing from some other location where it might have been stored*/ + int i; + int lastIndex = idx + 1; + Bool removed = FALSE; + for(i = 2; lastIndex < T2K_MEM_LEAK_INFO_TABLE_SIZE && i < 30; i++) + { + if(gMemLeakInfo[lastIndex].address == address) + { + gMemLeakInfo[lastIndex].address = 0; + gMemLeakInfo[lastIndex].size = 0; + gMemLeakInfo[lastIndex].lineNo = 0; + gMemLeakInfo[lastIndex].fileName = 0; + gMemLeakInfo[lastIndex].age = 0; /*For every 16384 memory block allocations,Alloc Tick is incremented by 1*/ + removed = TRUE; + break; + } + lastIndex = idx + (i*i*i); + } +#if 1 + if(!removed) + { + printf("Something is wrong, trying to remove %x idx = %d lastIndex = %d FreeCalled from File=%s, line=%d\n",address, idx, lastIndex,file,line); + } +#endif +#endif + } +} + +PUBLIC void DumpT2kMemLeakInfoToFile() +{ + int i; + + FILE *fp = fopen("memLeakInfo.txt","wb"); + + if(fp == NULL) + { + printf("Could not open file for dumping mem leak info\n"); + return; + } + + for(i = 0; i< T2K_MEM_LEAK_INFO_TABLE_SIZE; i++) + { + if(gMemLeakInfo[i].address != 0) + { + char* onlyFileName = rindex(gMemLeakInfo[i].fileName,'/'); + if(onlyFileName == NULL) + { + onlyFileName = gMemLeakInfo[i].fileName; + } + + fprintf(fp, "%ld s=%ld a=%ld l=%ld f=%s\n",gMemLeakInfo[i].address, + gMemLeakInfo[i].size, + gMemLeakInfo[i].age, + gMemLeakInfo[i].lineNo, + onlyFileName); + } + } + + fprintf(fp,"Current t2kMemAllocTick = %ld\n",t2kMemAllocTick); + + fclose(fp); +} +#endif + +#ifdef TENB_T2K3K_SPECIFIC_CHANGES + +/* For Updating SOC Specific Memory Information */ +#ifdef ANSI +PUBLIC S16 UpdateSocMemInfo +( +U8 areaIndex, +CmLteMemInfo *mInfo +) +#else +PUBLIC S16 UpdateSocMemInfo(areaIndex,mInfo) +U8 areaIndex; +CmLteMemInfo *mInfo; +#endif +{ + U8 idxReg; + U8 idxPool; + U16 numPool; + void *iccHdl = NULLP; + U32 poolFreeCnt[4]; + U32 poolUsedCnt[4]; + U32 poolSize[4]; + U32 poolTotAvail[4]; + + idxReg = mInfo->numRegions; + mInfo->numRegions = mInfo->numRegions + 1; + /* Calling Soc specific API to get shared memory status */ + numPool = 4; /* For Intel it is fixed to 4. Change to API call when available */ + iccHdl = ssGetIccHdl(areaIndex); + + /* Populating global memory information */ + mInfo->regInfo[idxReg].numPools = numPool; + mInfo->regInfo[idxReg].regionId = areaIndex; + mInfo->regInfo[idxReg].regionType = 1; /* 1 - SHARED REGION */ + + /* Calling INTEL API's to Get Free MEM BLOCKS */ + poolFreeCnt[0] = TL_GetFreeBlocks(iccHdl, ICC_POOL_ZERO_SIZE); + poolFreeCnt[1] = TL_GetFreeBlocks(iccHdl, ICC_POOL_ONE_SIZE); + poolFreeCnt[2] = TL_GetFreeBlocks(iccHdl, ICC_POOL_TWO_SIZE); + poolFreeCnt[3] = TL_GetFreeBlocks(iccHdl, ICC_POOL_THREE_SIZE); + + poolUsedCnt[0] = ICC_POOL_ZERO_TOTAL_BLKS - poolFreeCnt[0]; + poolUsedCnt[1] = ICC_POOL_ONE_TOTAL_BLKS - poolFreeCnt[1]; + poolUsedCnt[2] = ICC_POOL_TWO_TOTAL_BLKS - poolFreeCnt[2]; + poolUsedCnt[3] = ICC_POOL_THREE_TOTAL_BLKS - poolFreeCnt[3]; + + poolSize[0] = ICC_POOL_ZERO_SIZE; + poolSize[1] = ICC_POOL_ONE_SIZE; + poolSize[2] = ICC_POOL_TWO_SIZE; + poolSize[3] = ICC_POOL_THREE_SIZE; + + poolTotAvail[0] = ICC_POOL_ZERO_TOTAL_BLKS; + poolTotAvail[1] = ICC_POOL_ONE_TOTAL_BLKS; + poolTotAvail[2] = ICC_POOL_TWO_TOTAL_BLKS; + poolTotAvail[3] = ICC_POOL_THREE_TOTAL_BLKS; + + for(idxPool=0; idxPoolregInfo[idxReg].poolInfo[idxPool].poolSize = poolSize[idxPool]; + mInfo->regInfo[idxReg].poolInfo[idxPool].totAvailable = + poolTotAvail[idxPool]; + mInfo->regInfo[idxReg].poolInfo[idxPool].crntUsed = poolUsedCnt[idxPool]; + if(mInfo->regInfo[idxReg].poolInfo[idxPool].crntUsed > + mInfo->regInfo[idxReg].poolInfo[idxPool].maxUsed) + { + mInfo->regInfo[idxReg].poolInfo[idxPool].maxUsed = + mInfo->regInfo[idxReg].poolInfo[idxPool].crntUsed; + } + } + + RETVALUE(ROK); +} + +/* +* +* Fun: isL2MemUsageBelowLowerThreshold +* +* Desc: Checks for the Lower threshold of ICC memory. +* +* region region for obtaining the ICC handle +* +* Ret: TRUE - Threshold has reached +* FALSE - Threshold has not reached +* +* Notes: None +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PUBLIC U32 isL2MemUsageBelowLowerThreshold( +Region region +) +#else +PUBLIC U32 isL2MemUsageBelowLowerThreshold(region) +Region region; +#endif +{ + void * iccHdl = ssGetIccHdl(region); + + U32 poolZeroFreeCnt = TL_GetFreeBlocks(iccHdl, ICC_POOL_ZERO_SIZE); + U32 poolOneFreeCnt = TL_GetFreeBlocks(iccHdl, ICC_POOL_ONE_SIZE); + + /* We are below the threshold if free count in BOTH of the pools + * is above the ICC_MEM_LOWER_THRESHOLD % */ + if(((poolZeroFreeCnt * 100) > + (ICC_MEM_LOWER_THRESHOLD * ICC_POOL_ZERO_TOTAL_BLKS)) && + ((poolOneFreeCnt * 100) > + (ICC_MEM_LOWER_THRESHOLD * ICC_POOL_ONE_TOTAL_BLKS))) + { + RETVALUE(TRUE); + } + + RETVALUE(FALSE); +} + + +/* +* +* Fun: isMemUsageBelowLowerThreshold +* +* Desc: Checks for the Lower threshold of ICC memory. +* +* region region for obtaining the ICC handle +* +* Ret: TRUE - Threshold has reached +* FALSE - Threshold has not reached +* +* Notes: None +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PUBLIC U32 isMemUsageBelowLowerThreshold( +Region region +) +#else +PUBLIC U32 isMemUsageBelowLowerThreshold(region) +Region region; +#endif +{ + void * iccHdl = ssGetIccHdl(region); + + U32 poolZeroFreeCnt = TL_GetFreeBlocks(iccHdl, ICC_POOL_ZERO_SIZE); + U32 poolOneFreeCnt = TL_GetFreeBlocks(iccHdl, ICC_POOL_ONE_SIZE); + U32 poolTwoFreeCnt = TL_GetFreeBlocks(iccHdl, ICC_POOL_TWO_SIZE); + U32 poolThreeFreeCnt = TL_GetFreeBlocks(iccHdl, ICC_POOL_THREE_SIZE); + + /* We are below the threshold if free count in BOTH of the pools + * is above the ICC_MEM_LOWER_THRESHOLD % */ + if(((poolZeroFreeCnt * 100) > + (ICC_MEM_LOWER_THRESHOLD * ICC_POOL_ZERO_TOTAL_BLKS)) && + ((poolOneFreeCnt * 100) > + (ICC_MEM_LOWER_THRESHOLD * ICC_POOL_ONE_TOTAL_BLKS)) && + ((poolTwoFreeCnt * 100) > + (ICC_MEM_LOWER_THRESHOLD * ICC_POOL_TWO_TOTAL_BLKS)) && + ((poolThreeFreeCnt * 100) > + (ICC_MEM_LOWER_THRESHOLD * ICC_POOL_THREE_TOTAL_BLKS))) + { + RETVALUE(TRUE); + } + + RETVALUE(FALSE); +} + +/* +* +* Fun: isMemUsageAboveUpperThreshold +* +* Desc: Checks for the Upper threshold of ICC memory. +* +* region region for obtaining the ICC handle +* +* Ret: TRUE - Threshold has reached +* FALSE - Threshold has not reached +* +* Notes: None +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PRIVATE U32 isMemUsageAboveUpperThreshold( +Region region +) +#else +PRIVATE U32 isMemUsageAboveUpperThreshold(region) +Region region; +#endif +{ + void * iccHdl = ssGetIccHdl(region); + + U32 poolZeroFreeCnt = TL_GetFreeBlocks(iccHdl, ICC_POOL_ZERO_SIZE); + U32 poolOneFreeCnt = TL_GetFreeBlocks(iccHdl, ICC_POOL_ONE_SIZE); + U32 poolTwoFreeCnt = TL_GetFreeBlocks(iccHdl, ICC_POOL_TWO_SIZE); + U32 poolThreeFreeCnt = TL_GetFreeBlocks(iccHdl, ICC_POOL_THREE_SIZE); + + /* We are above the threshold if free count in either of the pools + * is below the ICC_MEM_UPPER_THRESHOLD % */ + if(((poolZeroFreeCnt * 100) < + (ICC_MEM_UPPER_THRESHOLD * ICC_POOL_ZERO_TOTAL_BLKS)) || + ((poolOneFreeCnt * 100) < + (ICC_MEM_UPPER_THRESHOLD * ICC_POOL_ONE_TOTAL_BLKS)) || + ((poolTwoFreeCnt * 100) < + (ICC_MEM_UPPER_THRESHOLD * ICC_POOL_TWO_TOTAL_BLKS)) || + ((poolThreeFreeCnt * 100) < + (ICC_MEM_UPPER_THRESHOLD * ICC_POOL_THREE_TOTAL_BLKS))) + { + RETVALUE(TRUE); + } + + RETVALUE(FALSE); +} + +/* ccpu00142274- Function to check if we have reached the + * Threshold for dropping UL packets at the RLC. This function + * measures the free count of the ICC memory and based on the + * volume of packets it sets an alarm to drop packets. + * In DL, the PDCP packets are dropped at Admission Control, but + * at UL we need to check if its an AM(Data only and + * not Status PDU) or UM packet and free the PDU + * Note: With the current design, we have PDCP DL and RLC UL + * running in the same thread and the below function will be + * accessed in tandem. But if PDCP DL and RLC UL are made to run + * in different threads then there might be a race condition. + * Please revisit this function in such a case. + * */ +/* +* +* Fun: isMemThreshReached +* +* Desc: Checks whether the system has reached the +* designated threshold of ICC memory. +* +* region region for obtaining the ICC handle +* +* Ret: ROK - Threshold has not reached +* RFAILED - Threshold has reached +* +* Notes: None +* +* File: cm_mem_wl.c +* +*/ +#ifdef ANSI +PUBLIC U32 isMemThreshReached( +Region reg +) +#else +PUBLIC U32 isMemThreshReached(reg) +Region reg; +#endif +{ + TRC3(isMemThreshReached) + if(gMemoryAlarm) + { + gMemoryAlarm = !(isMemUsageBelowLowerThreshold(reg)); + RETVALUE(RFAILED); + } + else + { + if(memoryCheckCounter++ >= NUM_CALLS_TO_CHECK_MEM_AGAIN) + { + gMemoryAlarm = isMemUsageAboveUpperThreshold(reg); + memoryCheckCounter = 0; + } + } + RETVALUE(ROK); +} +#endif +#endif /* SS_LOCKLESS_MEMORY */ +#if 0 +T2kMeamLeakInfo gMemLeakInfo[T2K_MEM_LEAK_INFO_TABLE_SIZE]; +U32 getT2kMemLeakIndex(U32 address) +{ +#if 0 + /* + 1 2 3 4 5 6 7 + + XOR 7 with 3 and remove 7 + XOR 1 with 5 and remove 1 + */ + + address -= T2K_MEM_LEAK_START_ADDR; + + U8 Nib7 = address & 0x0000000f; + U8 Nib1 = (address & 0x0f000000) >>24; + U8 Nib3 = (address & 0x000f0000) >> 16; + U8 Nib5 = (address & 0x00000f00) >> 8; + + /* store 8 ^ 3 in 8Nib */ + Nib7 = Nib7 ^ Nib3; + /* store 1 ^ 6 in 6Nib */ + Nib5 = Nib5 ^ Nib1; + + return(((address & 0x000fff00) | (Nib7 << 20) | (Nib5 << 4)) >> 4); + +#endif + return ((address - T2K_MEM_LEAK_START_ADDR) >> 8); +} + +static U32 t2kMemAllocTick; +static U32 smallTick; + +void InsertToT2kMemLeakInfo(U32 address, U32 size, U32 lineNo, char* fileName) +{ + U32 index = getT2kMemLeakIndex(address); + + if(((U32)(address - T2K_MEM_LEAK_START_ADDR) & 0xff) !=0) + { + printf("address in InsertToT2kMemLeakInfo is %x size = %d file is %s line is %d \n", address, size, fileName, lineNo); + } + + if(gMemLeakInfo[index].address == 0) + { + gMemLeakInfo[index].address = address; + gMemLeakInfo[index].size = size; + gMemLeakInfo[index].lineNo = lineNo; + gMemLeakInfo[index].fileName = fileName; + gMemLeakInfo[index].age = t2kMemAllocTick; + gMemLeakInfo[index].prevRemLineNo = 0; + gMemLeakInfo[index].prevRemFileName = '\0'; + + if(smallTick++ == 4096) + { + smallTick = 0; + gMemLeakInfo[index].age = (++t2kMemAllocTick); + } + } + else + { + printf("Something is wrong, trying to insert %x index = %d file is %s line is %d \n",address, index, fileName, lineNo); + printf("Address present :%x, from File:%s, Line:%d, Size:%d, Age:%d", + gMemLeakInfo[index].address, gMemLeakInfo[index].fileName, + gMemLeakInfo[index].lineNo, gMemLeakInfo[index].size, + gMemLeakInfo[index].age); +#if 0 + /* Try inserting into some other location */ + int i; + int lastIndex = index + 1; + Bool inserted = FALSE; + for(i = 2; lastIndex < T2K_MEM_LEAK_INFO_TABLE_SIZE && i < 30; i++) + { + if(gMemLeakInfo[lastIndex].address == 0) + { + gMemLeakInfo[lastIndex].address = address; + gMemLeakInfo[lastIndex].size = size; + gMemLeakInfo[lastIndex].lineNo = lineNo; + gMemLeakInfo[lastIndex].fileName = fileName; + gMemLeakInfo[lastIndex].age = (++t2kMemAllocTick) >> 14; /*For every 16384 memory block allocations,Alloc Tick is incremented by 1*/ + inserted = TRUE; + break; + } + lastIndex = index + (i * i * i); + } +#if 1 + if(!inserted) + { + printf("Something is wrong, trying to insert %x index = %d no free i = %d\n",address, index, i); + } +#endif +#endif + } +} + + +void RemoveFromT2kMemLeakInfo(U32 address, char *file, U32 line) +{ + U32 index = getT2kMemLeakIndex(address); + + if(index >= T2K_MEM_LEAK_INFO_TABLE_SIZE) + { + printf("Index out of range = %d address is %x file = %s line = %d. We are going to crash!!!\n", + index, + address, + file, + line); + } + if(gMemLeakInfo[index].address == address) + { + gMemLeakInfo[index].address = 0; + gMemLeakInfo[index].age = 0; + gMemLeakInfo[index].prevRemLineNo = gMemLeakInfo[index].lineNo; + gMemLeakInfo[index].prevRemFileName = gMemLeakInfo[index].fileName; + + /*printf("Something is wrong, Trying to double free Address = %x, Index = %d \n",address,index);*/ + } + else + { + printf("Something is wrong, trying to remove %x index = %d from File=%s, line=%d address present is %x\n",address, index, file,line, + gMemLeakInfo[index].address); + if(gMemLeakInfo[index].prevRemFileName != NULLP) + { + printf("Previous File:%s, Previous Line:%d\n", + gMemLeakInfo[index].prevRemFileName, gMemLeakInfo[index].prevRemLineNo); + } +#if 0 + /* Try removing from some other location where it might have been stored*/ + int i; + int lastIndex = index + 1; + Bool removed = FALSE; + for(i = 2; lastIndex < T2K_MEM_LEAK_INFO_TABLE_SIZE && i < 30; i++) + { + if(gMemLeakInfo[lastIndex].address == address) + { + gMemLeakInfo[lastIndex].address = 0; + gMemLeakInfo[lastIndex].size = 0; + gMemLeakInfo[lastIndex].lineNo = 0; + gMemLeakInfo[lastIndex].fileName = 0; + gMemLeakInfo[lastIndex].age = 0; /*For every 16384 memory block allocations,Alloc Tick is incremented by 1*/ + removed = TRUE; + break; + } + lastIndex = index + (i*i*i); + } +#if 1 + if(!removed) + { + printf("Something is wrong, trying to remove %x index = %d lastIndex = %d FreeCalled from File=%s, line=%d\n",address, index, lastIndex,file,line); + } +#endif +#endif + } +} + +void DumpT2kMemLeakInfoToFile() +{ + int i; + + FILE *fp = fopen("memLeakInfo.txt","wb"); + + if(fp == NULL) + { + printf("Could not open file for dumping mem leak info\n"); + return; + } + + for(i = 0; i< T2K_MEM_LEAK_INFO_TABLE_SIZE; i++) + { + if(gMemLeakInfo[i].address != 0) + { + char* onlyFileName = rindex(gMemLeakInfo[i].fileName,'/'); + if(onlyFileName == NULL) + { + onlyFileName = gMemLeakInfo[i].fileName; + } + + fprintf(fp, "%p s=%d a=%d l=%d f=%s\n",gMemLeakInfo[i].address, + gMemLeakInfo[i].size, + gMemLeakInfo[i].age, + gMemLeakInfo[i].lineNo, + onlyFileName); + } + } + + fprintf(fp,"Current t2kMemAllocTick = %d\n",t2kMemAllocTick); + + fclose(fp); +} +#endif + +/********************************************************************** + End of file + **********************************************************************/ + diff --git a/src/cm/cm_mem_wl.x b/src/cm/cm_mem_wl.x new file mode 100755 index 000000000..6d42a4d2d --- /dev/null +++ b/src/cm/cm_mem_wl.x @@ -0,0 +1,536 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + + +/********************************************************************20** + + Name: Lockless Memory Manager + + Type: C include file + + Desc: Data structure definitions that are used by + the Lockless Memory Manager. + + File: cm_mem_wl.x + +*********************************************************************21*/ + +#ifndef __CMMEMWLX_ +#define __CMMEMWLX_ + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifdef SS_LOCKLESS_MEMORY +/* typedefs */ +typedef struct cmMmDynRegCb CmMmDynRegCb; +typedef struct cmMmDynBktCb CmMmDynBktCb; +typedef struct cmMmMapBkt CmMmMapBkt; +typedef struct cmMmGlobRegCb CmMmGlobRegCb; +typedef struct cmMmGlobalBktCb CmMmGlobalBktCb; +typedef struct cmMmBlkSetElement CmMmBlkSetElement; +typedef Data CmMmEntry; + +/* Size-To-Bucket map table structure */ +struct cmMmMapBkt +{ + U16 bktIdx; /* The index to the memory bucket */ + +#if (ERRCLASS & ERRCLS_DEBUG) + U16 numReq; /* Number of the allocation request */ + U16 numFailure; /* Number of allocation failure form the bucket */ +#endif + +}; + +/* The following structre is used as node to place the first address of the + * bucket list in the linkedlist. During initialization, all the buckets are + * divided into limited number sets. The first pointer of the bucket is placed + * in the following structure and node is placed in the linked list. Once the one set + * get over, the next address in the BktCb is changed to new address */ +struct cmMmBlkSetElement +{ + CmLList memSetNode; /* Linked list of the first pointer of the + bucket */ + U32 numFreeBlks; /* Number of Free Blocks avilable in the current + set */ + CmMmEntry *nextBktPtr; /* Address of the first bucket which will be + used for the allocation */ +}; + +#if 0 +/* This structre is used for the storing the bucket set information in the + * system task region. At present the number of array is used for two. + * The array is indexed using the crntBktNodeIdx value during allocation + * or deallocation */ +struct cmMmDynMemElem +{ + U32 numBkt; /* Number of buckets avilable in the current + set */ + CmMmEntry *nextBktPtr; /* Address of the first bucket which will be + used for the allocation */ +}; +#endif + +/* The following structure is used for the storing the buckets/pools + * this will be present for each bucket which is configured and + * will contains the all the information about the bucket. This + * will be used in global region */ +struct cmMmGlobalBktCb +{ + U8 poolId; /* Pool Id */ + Size size; /* Size of the pool */ + CmLListCp listValidBktSet; /* LList Cp used to store the nodes of memory element + node which holds valid pointers */ + CmLListCp listFreeBktSet; /* LList Cp used to store the nodes of memory element + node which holds invalid information */ + CmMmEntry *startAddr; /* Starting address */ + CmMmEntry *next; /* Next address which will be allocated */ + U32 numBlks; /* Total number of buckets configured */ + U32 bucketSetSize; + U32 bktFailCnt; /* bucket alloc failure count */ + U32 bktNoFitCnt; /* number of blocks not fit */ + SLockId bucketLock; /* Lock used for the allocation/freeing of + the set of buckets */ +}; + +/* The following structure is used for the storing the buckets/pools + * this will be present for each bucket which is configured and + * will contains the all the information about the bucket. This + * is used in the system taks local region */ +struct cmMmDynBktCb +{ + U8 poolId; /* Pool Id */ + Size size; /* Size of the pool */ + CmLListCp memBlkSetElem; /* Memory set element likend list */ + CmMmBlkSetElement *crntMemBlkSetElem; /* Pointer to the current memort block set */ + CmMmEntry *startAddr; /* Starting address */ + CmMmEntry *next; /* Next address which will be allocated */ + U32 numBktAlloc; /* Total number of buckets allocted */ + U32 numBkt; /* Total number of buckets configured */ + U16 bucketSetSize; /* Size of bucket sets */ + U16 blkSetRelThreshold; /* Upper threshold of bucket count upon + reaching will free the set to global region */ + U16 blkSetAcquireThreshold; /* Lower threshold of bucket count upon + reaching will request the set from + global region */ + U32 bktFailCnt; /* bucket alloc failure count */ + U32 bktNoFitCnt; /* number of blocks not fit */ +}; + +/* The individual Task regionCb which will be associate with every system + * task which will be created. This contains the mapping of the size to + * to bucket index and the different bucket informations.*/ +#ifdef SS_USE_ICC_MEMORY +struct cmMmDynRegCb +{ + Region region; /* Region Id of the memory */ + U16 bktSize[CMM_MAX_BKT_ENT]; /* Bucket Size */ + void *iccHdl; /* Handler used for ICC memory */ + SsAlloc alloc; /* allocation function pointer */ + SsFree free; /* deallocation function pointer */ + SsCtl ctl; /* control request function pointer */ +}; +#else +struct cmMmDynRegCb +{ + Region region; /* Region Id of the memory */ + U8 regType; /* Region Type, static or dynamic or global */ + U8 numBktBlk; /* Keeps the count of number of bucket set blocks */ + U16 numBkts; /* Number of buckets in the Bucket Pool */ + Size bktSize; /* Size of the memory used for the bucket pool */ + U16 bktQnPwr; /* Quantum size of the bucket pool */ + Size bktMaxBlkSize; /* Maximum size of block in the bucket pool */ + CmMmDynBktCb bktTbl[CMM_MAX_BKT_ENT]; /* Pointer to the memory bkt tbl */ + SsAlloc alloc; /* allocation function pointer */ + SsFree free; /* deallocation function pointer */ + SsCtl ctl; /* control request function pointer */ + CmMmMapBkt mapTbl[CMM_MAX_MAP_ENT]; /* size-to-bucket map table */ +}; +#endif /* SS_USE_ICC_MEMORY */ + +/* The global region Cb which holds the entire buckets configured */ +struct cmMmGlobRegCb +{ + Region region; /* Region Id of the memory */ + U16 numBkts; /* Number of buckets in the Bucket Pool */ + CmMmGlobalBktCb bktTbl[CMM_MAX_BKT_ENT]; /* Pointer to the memory bkt tbl */ +}; + +/* SSI_OPT: Stop */ + +/* typedefs */ +typedef struct cmMmRegCfg CmMmRegCfg; +typedef struct cmMmBktCfg CmMmBktCfg; + + +typedef struct cmMmRegCb CmMmRegCb; +typedef struct cmMmHeapCb CmMmHeapCb; +typedef struct cmMmBkt CmMmBkt; +typedef struct cmHEntry CmHEntry; +/* cm_mem_x_001.main_9 - addition of new data types for providing +* header for memory blocks in buckets and a hash list to maintain +* size vs. numAttempts statistics +*/ + /* cm_mem_x_001.main_11: Additions */ +#ifdef SS_HISTOGRAM_SUPPORT +typedef struct cmHstGrmHashListCp CmHstGrmHashListCp; +typedef struct cmHstGrmHashListEnt CmHstGrmHashListEnt; +typedef struct cmMemEntries CmMemEntries; +#endif /* SS_HISTOGRAM_SUPPORT */ + +/* forward definitions */ + + +/************************************************************************ + Common Memory Manager Configuration Data Structures +************************************************************************/ + +/* Bucket configuration structure. */ +struct cmMmBktCfg +{ + Size size; /* Size of the memory block */ + U32 numBlks; /* Number of the block in the bucket */ +}; + +/* Memory Region configuration structure. */ +struct cmMmRegCfg +{ + Size size; /* Size of the memory */ + Data *vAddr; /* Start address of the memory */ + U8 lType; /* Lock Type to be used */ + + U8 chFlag; /* Flag defines the memory region characteristics */ + Data *pAddr; /* Physical address of the memory block: Valid + if CMM_REG_PHY_VALID bit of chFlag is set */ + Size bktQnSize; /* Quatum size of the memory block */ + U16 numBkts; /* Number of buckets in the Bucket Pool */ + + CmMmBktCfg bktCfg[CMM_MAX_BKT_ENT]; /* Bucket configuration structure */ +}; + +/************************************************************************ + Common Memory Manager Implementation Data Structures +************************************************************************/ +/* cm_mem_x_001.main_11: Additions */ +#ifdef SS_HISTOGRAM_SUPPORT +struct cmMemEntries /* Entry information */ +{ + U32 line; /* Line Number where memory allocation primitive used */ + U32 allocBytes; /* Granted Byte */ + U32 allocOverFlow; /* If the value of allocBytes overflows then we use this variable */ + U32 freedBytes; /* Freed Bytes */ + U32 freeOverFlow; /* If the value of freeByte overflows then we use this value */ + U32 wastedBytes; /* Difference between Granted and Requested bytes */ + U32 bucketAllocReq; /* No of times this Bucket used */ + U32 bucketFreeReq; /* No of times this Bucket freed */ + U32 entId; /* Tapa task used this bucket */ + U32 key; /* combination of file name and line */ + U8 fileName[CMM_HIST_MAX_FILENAME]; /* File Name where memory allocation primitive used */ +}; + +struct cmHstGrmHashListEnt /* hash list entry */ +{ + CmMemEntries entries[CMM_HIST_MAX_MEM_ENTRY_PER_BIN]; /* Number of entires in each bin */ + U32 numOfEntries; /*Number of entries in hash list */ +}; + +struct cmHstGrmHashListCp /* Hash List control pointer */ +{ + CmHstGrmHashListEnt hashList[CMM_HIST_MAX_MEM_BIN]; /* Number of bins in hash list */ + U16 totalNumEntries; /* Total number of bins */ +}; + +#endif /* SS_HISTOGRAM_SUPPORT */ + +/* cm_mem_x_001.main_9 - addition of memory header for blocks in buckets */ +#ifdef SSI_DEBUG_LEVEL1 +/* Memory Block Header */ +struct cmMmBlkHdr +{ + /* trSignature shall always be maintained as the first element in this structure */ + U8 trSignature[CMM_TRAMPLING_SIGNATURE_LEN]; /* signature to detect trampling */ + CmMmBlkHdr *nextBlk; /* pointer to the next memory block header */ + U32 memFlags; /* Free/Static/Dynamic */ + Size requestedSize; /* requested size for which this mem blk has been allocated */ +}; +#endif /* SSI_DEBUG_LEVEL1 */ + +/* Memory bucket structure */ +struct cmMmBkt /* Bucket Structure */ +{ +/* cm_mem_x_001.main_9 - addition of next block pointer */ +#ifdef SSI_DEBUG_LEVEL1 + CmMmBlkHdr *nextBlk; /* pointer to the next memory block header */ +#else + CmMmEntry *next; /* Pointer to the next memory block */ +#endif /* SSI_DEBUG_LEVEL1 */ + Size size; /* Size of the block */ + U32 numBlks; /* Total number of blocks in the bucket */ + U32 maxAlloc; /* Maximum number of blocks allocated till now */ + U32 numAlloc; /* Number of blocks allocated */ + SLockId bktLock; /* Lock to protect the bucket pool */ + U32 bktFailCnt; /* bucket alloc failure count */ + U32 bktNoFitCnt; /* number of blocks not fit */ +/* cm_mem_x_001.main_9 - addition of statistics related data */ +#ifdef SSI_DEBUG_LEVEL1 + Data *bktStartPtr; /* maintains the start address of the memory block in the bucket */ + StsCntr numAllocAttempts; /* total number of allocation attempts */ + StsCntr numDeallocAttempts; /* total number of de-allocation attempts */ + Size staticMemUsed; /* amount of memory used for static allocations */ + Size dynamicMemUsed; /* amount of memory used for dynamic allocations */ + U8 trampleCount; /* incremented everytime a trampling is detected in any block of the bucket */ +#endif /*SSI_DEBUG_LEVEL1*/ +/* cm_mem_x_001.main_11: Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + CmHstGrmHashListCp hstGrmHashListCp; +#endif /* SS_HISTOGRAM_SUPPORT */ +}; + + +/* Size-To-Bucket map table structure */ + +/* Heap entry structure linked in the heap control block */ +struct cmHEntry +{ +/* cm_mem_x_001.main_9 - addition to provide trampling and double-free detections support */ +#ifdef SSI_DEBUG_LEVEL1 + /* trSignature shall always be maintianed as the first element in this structure */ + U8 trSignature[CMM_TRAMPLING_SIGNATURE_LEN]; /* signature to detect trampling */ + U32 memFlags; /* flag to maintain the memory status */ + Size requestedSize; /* size of the heap entry block */ +#endif /* SSI_DEBUG_LEVEL1 */ + CmHEntry *next; /* Pointer to the next entry block */ + Size size; /* size of the heap entry block */ +}; + +/* Heap control block */ +struct cmMmHeapCb +{ + Data *vStart; /* Memory start address */ + Data *vEnd; /* Memory end address */ + CmHEntry *next; /* Next heap block entry */ + Size avlSize; /* Total available memory */ + Size minSize; /* Minimum size that can be allocated */ + SLockId heapLock; /* Lock to protect the heap pool */ +#if (ERRCLASS & ERRCLS_DEBUG) + U16 numFragBlk; /* Number of fragmented block */ + U16 numReq; /* Number of allocation request */ + U16 numFailure; /* Number of allocation failure */ +#endif + U32 heapAllocCnt; /* Number of blocks from heap */ +/* cm_mem_x_001.main_9 - addition of statistics related data */ +#ifdef SSI_DEBUG_LEVEL1 + Size staticHeapMemUsed; /* amount of heap memory used for static allocations */ + Size dynamicHeapMemUsed; /* amount of heap memory used for dynamic allocations */ + Size nextOffset; /* Offset to the next pointer in structure CmHEntry */ + /* Update this in cmMmHeapInit if cmHEntry is changed */ + StsCntr numAllocAttempts; /* total number of allocation attempts in heap */ + StsCntr numDeallocAttempts; /* total number of de-allocation attempts in heap */ + U8 trampleCount; /* incremented everytime a trampling is detected in any block of the heap */ +#endif /* SSI_DEBUG_LEVEL1 */ + /* cm_mem_x_001.main_11: Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + /* Hash list to support Heap Block histogram */ + CmHstGrmHashListCp heapHstGrmHashListCp; +#endif /* SS_HISTOGRAM_SUPPORT */ + +}; + +/* cm_mem_x_001.main_9 - addition of hash list for maintaining size vs. numAttempts statistics */ +#ifdef SSI_DEBUG_LEVEL1 +struct cmMmHashListEnt /* hash list entry */ +{ + U32 size; /* pointer to key */ + U32 numAttempts; /* number of attempts */ +}; + +struct cmMmHashListCp +{ + CmMmHashListEnt *hashList; + U16 numOfbins; + U16 numOfEntries; +}; +#endif /* SSI_DEBUG_LEVEL1 */ + +/* Memory region control block */ +struct cmMmRegCb +{ + Region region; /* Region Id of the memory */ + SRegInfo regInfo; /* Region information block */ + + U8 chFlag; /* Flag defines the region characteristics */ + Data *pAddr; /* Physical address of the memory block. + Valid if CMM_REG_PHY_VALID bit is set */ + + Size bktSize; /* Size of the memory used for the bucket pool */ + U16 bktQnPwr; /* Quantum size of the bucket pool */ + Size bktMaxBlkSize; /* Maximum size of block in the bucket pool */ + U16 numBkts; /* Number of buckets in the Bucket Pool */ + + CmMmMapBkt mapTbl[CMM_MAX_MAP_ENT]; /* size-to-bucket map table */ + CmMmBkt bktTbl[CMM_MAX_BKT_ENT]; /* Pointer to the memory bkt tbl */ + + Bool heapFlag; /* Set to true if the heap pool is configured */ + Size heapSize; /* Size of the heap pool */ + CmMmHeapCb heapCb; /* Heap pool control block */ +/* cm_mem_x_001.main_9 - addition of hash list control point in region control block */ +#ifdef SSI_DEBUG_LEVEL1 + CmMmHashListCp hashListCp; /* hast list to maintain the size statistics */ +#endif /* SSI_DEBUG_LEVEL1 */ +#ifdef SS_MULTICORE_SUPPORT /*cm_mem_x_001.main_10*/ + SsSTskEntry *sTsk; +#endif /* SS_MULTICORE_SUPPORT */ + +}; + + /* cm_mem_x_001.main_11: Additions */ +#ifdef SS_MEM_LEAK_STS +typedef struct _memHash +{ + SLockId memLck; + Bool used; + CmHashListCp memHashCp; +}MemHash; + +typedef struct _memAllocInfo +{ + CmHashListEnt ent; + U32 memAddr; + Size reqSz; + Size allocSz; + U16 bktIdx; + U8 moduleId; + U8 bTrcSz; + PTR backTrace; +}MemAllocInfo; + +typedef struct _memLkCb +{ + Bool memLkMdlInit; + FILE *fileLkLog; + MemHash memUsrMdl[CM_MEM_USR_MDL][CM_MAX_HASH_PER_TSK]; +}MemLkCb; + +typedef struct _memUsrMdlStr +{ + Txt *fPStr; + Txt *mdlStr; +}MemUsrMdlStr; + +#ifdef SS_MEM_LEAK_SOL +typedef struct backtrace +{ + Void **bt_buffer; + S32 bt_maxcount; + S32 bt_actcount; +} Backtrace_t; +#endif /* SS_MEM_LEAK_SOL */ + +#endif /* SS_MEM_LEAK_STS */ + + +/* functions prototypes */ + +EXTERN S16 cmMmRegInit ARGS(( + Region region, + CmMmRegCb *regCb, + CmMmRegCfg *cfg)); +EXTERN S16 cmMmRegDeInit ARGS(( CmMmRegCb *regCb)); + /* cm_mem_x_001.main_11: Additions */ +#ifdef SS_MEM_LEAK_STS +EXTERN Void cmInitMemLeakMdl ARGS((Void)); +/* cm_mem_x_001.main_12 : Additions */ +EXTERN Void cmDeinitMemLeakMdl ARGS((Void)); +EXTERN Void cmStorAllocBlk ARGS((U32 addr, Size reqSz, Size allocSz, + U16 bktIdx)); +EXTERN Void cmRlsAllocBlk ARGS((U32 addr)); +EXTERN U8 cmMemGetModuleId ARGS((S8 **funNm, S32 traceSize)); +EXTERN S16 cmMemGetStrMtchIdx ARGS((U8 strtIdx, U8 endIdx, + S8 *str, S8 **strLst)); +EXTERN Void cmMemOpenMemLkFile ARGS((S8 *arg)); +EXTERN Void SLogLkInfo ARGS((Void)); +EXTERN Void SFlushLkInfo ARGS((Void)); + +#ifdef SS_MEM_LEAK_SOL +EXTERN S32 cmAddrToSymStr ARGS((Void *pc, S8 *buffer, S32 size)); +EXTERN S32 cmLeakCallBack ARGS((uintptr_t pc, S32 signo, Void *arg)); +EXTERN S32 backtrace ARGS((Void **buffer, S32 count)); +#endif /* SS_MEM_LEAK_SOL */ + +#endif /* SS_MEM_LEAK_STS */ +/* cm_mem_x_001.main_9 - addition of an API prototype for sanity check */ +#ifdef SSI_DEBUG_LEVEL1 +EXTERN S16 cmMmRegIsBlkSane ARGS((CmMmBlkHdr *blkPtr)); +#endif /* SSI_DEBUG_LEVEL1 */ + + +EXTERN Void DumpLayersDebugInformation ARGS((Void)); +EXTERN Void DumpSSIDemandQDebugInformation ARGS((Void)); +EXTERN Void DumpPDCPDlDebugInformation ARGS((Void)); +EXTERN Void DumpPDCPUlDebugInformation ARGS((Void)); +EXTERN Void DumpRLCDlDebugInformation ARGS((Void)); +EXTERN Void DumpRLCUlDebugInformation ARGS((Void)); +EXTERN Void DumpRLCUlDebugInformation ARGS((Void)); +EXTERN Void printMacCellInfo ARGS((Void)); +EXTERN Void printSchCellInfo ARGS((Void)); + +EXTERN U32 isMemThreshReached ARGS((Region region)); + +EXTERN S16 cmMmStatRegInit ARGS((Region region, CmMmRegCb *regCb, CmMmRegCfg *cfg)); +EXTERN S16 cmMmGlobRegInit ARGS((CmMmGlobRegCb *regCb)); +EXTERN S16 cmMmDynRegInit ARGS((CmMmDynRegCb *regCb)); +#ifdef USE_MALLOC +EXTERN S16 ssGetDynMemBlkSet ARGS((U8 bktIdx, CmMmBlkSetElement *dynMemSetElem)); +EXTERN S16 ssPutDynMemBlkSet ARGS((U8 bktIdx, CmMmBlkSetElement *dynMemSetElem)); +#else +EXTERN S16 ssPutDynMemBlkSet ARGS((U8 bktIdx,CmMmBlkSetElement *dynMemSetElem, + U32 doNotBlockForLock)); +EXTERN S16 ssGetDynMemBlkSet ARGS((U8 bktIdx, CmMmBlkSetElement *dynMemSetElem, + U32 doNotBlockForLock)); +#endif /* USE_MALLOC */ +#endif /* SS_LOCKLESS_MEMORY */ +#ifdef __cplusplus +} +#endif + +#ifdef T2K_MEM_LEAK_DBG +#if 0 +typedef struct _t2kMemLeakInfo +{ + U32 address; /* 0 means it is free */ + U32 size; /* size of the block */ + U32 age; /* in ticks, when it was allocated */ + U32 lineNo; /* lineNo in the file from where allocation was done */ + char* fileName; /* from where allocation was done */ + U32 prevRemLineNo; /* lineNo in the file from where allocation was done */ + char* prevRemFileName; /* from where allocation was done */ + U32 lastDelLineNum; /* lineNo in the file from where allocation was done */ + char* lastDelFileName; /* from where allocation was done */ + +}T2kMeamLeakInfo; +#endif +#endif +#endif + +/********************************************************************** + End of file +*********************************************************************/ + diff --git a/src/cm/cm_tenb_stats.c b/src/cm/cm_tenb_stats.c new file mode 100755 index 000000000..906d23339 --- /dev/null +++ b/src/cm/cm_tenb_stats.c @@ -0,0 +1,693 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/********************************************************************** + + Name: + + Type: C include file + + Desc: + + File: cm_tenb_stats.c + +**********************************************************************/ + +/** @file cm_tenb_stats.c +@brief This file contains +*/ + +/* +* The defines in this file correspond to structures and variables +* used by the following TRILLIUM software: +* +* part no. description +* -------- ---------------------------------------------- +* +*/ +/* header include files (.h) */ + +#include "envopt.h" /* Environment options */ +#include "envdep.h" /* Environment dependent */ +#include "envind.h" /* Environment independent */ +#include "gen.h" /* General */ +#include "ssi.h" /* System services interface */ +#include "cm_lte.h" /* Common LTE header file */ +#include "cm_llist.h" /* Linked list header file */ +#include "cm_tkns.h" /* Common tokens header file */ + + +/* header/extern include files (.x) */ + +#include "gen.x" /* General */ +#include "ssi.x" /* System services interface */ +#include "cm_lib.x" /* Common lib header file */ +#include "cm_llist.x" /* Linked list header file */ +#include "cm_tkns.x" /* Common tokens header file */ +#include "cm_lte.x" /* Common LTE header file */ + +#include "ss_queue.h" +#include "ss_queue.x" +#include "ss_task.x" +#include "ss_msg.x" +#include "cm_tenb_stats.x" /* Total EnodeB Stats declarations */ + +#ifdef TENB_STATS +PRIVATE Void TSInfUtlPackUeInfo ARGS(( + Buffer *mBuf, + TSInfL2UeStats *stats +)); +PRIVATE Void TSInfUtlPackCellInfo ARGS(( + Buffer *mBuf, + TSInfL2CellStats *stats +)); +PRIVATE Void TSInfUtlUnpkUeInfo ARGS(( + Buffer *mBuf, + TSInfL2UeStats *stats +)); +PRIVATE Void TSInfUtlUnpkCellInfo ARGS(( + Buffer *mBuf, + TSInfL2CellStats *stats +)); +PRIVATE Buffer* TSInfUtlAllocMsg ARGS(( + Pst *pst +)); + +/* +* +* Fun: TSInfTrigL2Stats +* +* Desc: Indicate PDCP UL to initiate Stats procedure +* +* Ret: +* +* Notes: None +* +* +*/ +#ifdef ANSI +PRIVATE Void TSInfTrigL2Stats +( + Region region, + Pool pool +) +#else +PRIVATE Void TSInfTrigL2Stats(region, pool) + Region region; + Pool pool; +#endif +{ + Buffer* pBuf; + Pst pst = {0}; + + TRC2(TSInfTrigL2Stats) + + SGetMsg(region, pool, &pBuf); +//#if defined(SCH_STATS) || defined(TENB_STATS) + pst.dstEnt = STATS_DSTENT; + pst.dstInst = STATS_DSTINST; + pst.selector = CL_DSTENT_SELECTOR; + + pst.srcProcId = STATS_SRCPROCID; + pst.dstProcId = STATS_DSTPROCID; + pst.srcEnt = STATS_SRCENT; + pst.event = TENBSTATSINIT; + SPstTsk(&pst, pBuf); + + RETVOID; +} + +/* +* +* Fun: TSInfTrigStats +* +* Desc: Trigger Sending L2 Stats +* +* Ret: +* +* Notes: None +* +* +*/ +#ifdef ANSI +PUBLIC Void TSInfTrigStats +( + Region region, + Pool pool +) +#else +PUBLIC Void TSInfTrigStats(region, pool) + Region region; + Pool pool; +#endif +{ + TRC2(TSInfTrigStats) +//TODO + TSInfTrigL2Stats(region, pool); + + RETVOID; +} + + +#ifdef ANSI +PRIVATE Buffer* TSInfUtlAllocMsg +( + Pst *pst +) +#else +PRIVATE Buffer* TSInfUtlAllocMsg(pst) + Pst *pst; +#endif +{ + Buffer *mBuf; + + TRC2(TSInfUtlAllocMsg) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { + printf("\n MBuf Allocation failed\n"); + } + RETVALUE(mBuf); +} + +#ifdef ANSI +PRIVATE Void TSInfUtlPackUeInfo +( + Buffer *mBuf, + TSInfL2UeStats *stats +) +#else +PRIVATE Void TSInfUtlPackUeInfo(mBuf, stats) + Buffer *mBuf; + TSInfL2UeStats *stats; +#endif +{ + S32 i; + U32 k; + + TRC2(TSInfUtlPackUeInfo) + + CMCHKPK(SPkU32, stats->persistent.numDeactivation, mBuf); + CMCHKPK(SPkU32, stats->persistent.numActivation, mBuf); + CMCHKPK(SPkU32, stats->persistent.activatedSCells, mBuf); + + CMCHKPK(SPkU32, stats->nonPersistent.rlc.dlMaxWindowSz, mBuf); + CMCHKPK(SPkU32, stats->nonPersistent.rlc.dlMaxPktsInSduQ, mBuf); + CMCHKPK(SPkU32, stats->nonPersistent.rlc.ulReOdrTmrExpCnt, mBuf); + + CMCHKPK(SPkU32, stats->nonPersistent.pdcp.dlFlowCtrlDropCnt, mBuf); + CMCHKPK(SPkU32, stats->nonPersistent.pdcp.dlPdcpAckWaitDropCnt, mBuf); + CMCHKPK(SPkU32, stats->nonPersistent.pdcp.dlPdcpDropCnt, mBuf); + + + for (k = 0; k < L2_STATS_MAX_CELLS; k++) + { + CMCHKPK(SPkU32, stats->nonPersistent.sch[k].ulTpt, mBuf); + CMCHKPK(SPkU32, stats->nonPersistent.sch[k].ulNumiTbs, mBuf); + CMCHKPK(SPkU32, stats->nonPersistent.sch[k].ulSumiTbs, mBuf); + CMCHKPK(SPkU32, stats->nonPersistent.sch[k].ulNumCqi, mBuf); + CMCHKPK(SPkU32, stats->nonPersistent.sch[k].ulSumCqi, mBuf); + CMCHKPK(SPkU32, stats->nonPersistent.sch[k].ulDtxCnt, mBuf); + CMCHKPK(SPkU32, stats->nonPersistent.sch[k].ulNackCnt, mBuf); + CMCHKPK(SPkU32, stats->nonPersistent.sch[k].ulAckNackCnt, mBuf); + CMCHKPK(SPkU32, stats->nonPersistent.sch[k].ulPrbUsg, mBuf); + CMCHKPK(SPkU32, stats->nonPersistent.sch[k].ulRetxOccns, mBuf); + CMCHKPK(SPkU32, stats->nonPersistent.sch[k].ulTxOccns, mBuf); + CMCHKPK(SPkU32, stats->nonPersistent.sch[k].dlTpt, mBuf); + CMCHKPK(SPkU32, stats->nonPersistent.sch[k].dlBo, mBuf); + for (i=0; i<4; i++) + { + CMCHKPK(SPkU32, stats->nonPersistent.sch[k].riCnt[i], mBuf); + } + for (i=0; i<5; i++) + { + CMCHKPK(SPkU32, stats->nonPersistent.sch[k].dlPdbLvl[i], mBuf); + } + CMCHKPK(SPkU32, stats->nonPersistent.sch[k].cqiDropCnt, mBuf); + CMCHKPK(SPkU32, stats->nonPersistent.sch[k].dlNumCw1iTbs, mBuf); + CMCHKPK(SPkU32, stats->nonPersistent.sch[k].dlSumCw1iTbs, mBuf); + CMCHKPK(SPkU32, stats->nonPersistent.sch[k].dlNumCw0iTbs, mBuf); + CMCHKPK(SPkU32, stats->nonPersistent.sch[k].dlSumCw0iTbs, mBuf); + CMCHKPK(SPkU32, stats->nonPersistent.sch[k].dlNumCw1Cqi, mBuf); + CMCHKPK(SPkU32, stats->nonPersistent.sch[k].dlSumCw1Cqi, mBuf); + CMCHKPK(SPkU32, stats->nonPersistent.sch[k].dlNumCw0Cqi, mBuf); + CMCHKPK(SPkU32, stats->nonPersistent.sch[k].dlSumCw0Cqi, mBuf); + for (i=0; i<2; i++) + { + CMCHKPK(SPkU32, stats->nonPersistent.sch[k].dlDtxCnt[i], mBuf); + } + for (i=0; i<2; i++) + { + CMCHKPK(SPkU32, stats->nonPersistent.sch[k].dlAckNackCnt[i], mBuf); + } + for (i=0; i<2; i++) + { + CMCHKPK(SPkU32, stats->nonPersistent.sch[k].dlNackCnt[i], mBuf); + } + CMCHKPK(SPkU32, stats->nonPersistent.sch[k].dlPrbUsg, mBuf); + CMCHKPK(SPkU32, stats->nonPersistent.sch[k].dlRetxOccns, mBuf); + CMCHKPK(SPkU32, stats->nonPersistent.sch[k].dlTxOccns, mBuf); + } + CMCHKPK(SPkU32, stats->rnti, mBuf); + RETVOID; +} + +#ifdef ANSI +PRIVATE Void TSInfUtlPackCellInfo +( + Buffer *mBuf, + TSInfL2CellStats *stats +) +#else +PRIVATE Void TSInfUtlPackCellInfo(mBuf, stats) + Buffer *mBuf; + TSInfL2CellStats *stats; +#endif +{ + S32 i,j; + + TRC2(TSInfUtlPackCellInfo) + + CMCHKPK(SPkU32, stats->rlc.reOdrTmrExp, mBuf); + CMCHKPK(SPkU32, stats->rlc.maxRlcDrbRetxFail, mBuf); + CMCHKPK(SPkU32, stats->rlc.maxRlcSrbRetxFail, mBuf); + + CMCHKPK(SPkU32, stats->sch.ulNumiTbs, mBuf); + CMCHKPK(SPkU32, stats->sch.ulSumiTbs, mBuf); + CMCHKPK(SPkU32, stats->sch.ulNumCqi, mBuf); + CMCHKPK(SPkU32, stats->sch.ulSumCqi, mBuf); +#ifdef RG_5GTF + CMCHKPK(SPkU32, stats->sch.ul5gtfRbAllocFail, mBuf); + CMCHKPK(SPkU32, stats->sch.ul5gtfPdcchSend, mBuf); + CMCHKPK(SPkU32, stats->sch.ul5gtfUeFnlzReAdd, mBuf); + CMCHKPK(SPkU32, stats->sch.ul5gtfUeRmvFnlzZeroBo, mBuf); + CMCHKPK(SPkU32, stats->sch.ul5gtfUeRbAllocDone, mBuf); + CMCHKPK(SPkU32, stats->sch.ul5gtfAllocAllocated, mBuf); + CMCHKPK(SPkU32, stats->sch.ul5gtfPdcchSchd, mBuf); + CMCHKPK(SPkU32, stats->sch.ul5gtfUeSchPick, mBuf); + CMCHKPK(SPkU32, stats->sch.ul5gtfBsrRecv, mBuf); + CMCHKPK(SPkU32, stats->sch.ul5gtfSrRecv, mBuf); + + CMCHKPK(SPkU32, stats->sch.dl5gtfPdschCons, mBuf); + CMCHKPK(SPkU32, stats->sch.dl5gtfPdcchSend, mBuf); + CMCHKPK(SPkU32, stats->sch.dl5gtfBoUpd, mBuf); + CMCHKPK(SPkU32, stats->sch.dl5gtfFnlzFail, mBuf); + CMCHKPK(SPkU32, stats->sch.dl5gtfFnlzPass, mBuf); + CMCHKPK(SPkU32, stats->sch.dl5gtfRbAllocFail, mBuf); + CMCHKPK(SPkU32, stats->sch.dl5gtfRbAllocPass, mBuf); + CMCHKPK(SPkU32, stats->sch.dl5gtfUePick, mBuf); +#endif + CMCHKPK(SPkU32, stats->sch.cntTtiProcTime500, mBuf); + CMCHKPK(SPkU32, stats->sch.cntTtiProcTime600, mBuf); + CMCHKPK(SPkU32, stats->sch.cntTtiProcTime700, mBuf); + CMCHKPK(SPkU32, stats->sch.cntTtiProcTime800, mBuf); + CMCHKPK(SPkU32, stats->sch.cntTtiProcTime900, mBuf); + CMCHKPK(SPkU32, stats->sch.cntTtiProcTime1000, mBuf); + CMCHKPK(SPkU32, stats->sch.avgTtiProcTime, mBuf); + for (i=9; i>=0; i--) + { + CMCHKPK(SPkU32, stats->sch.dlPdbRatio[i], mBuf); + } + for (i=9; i>=0; i--) + { + CMCHKPK(SPkU32, stats->sch.ulPrbUsage[i], mBuf); + } + for (i=9; i>=0; i--) + { + CMCHKPK(SPkU32, stats->sch.dlPrbUsage[i], mBuf); + } + for (i=3; i>=0; i--) + { + CMCHKPK(SPkU32, stats->sch.ulDtx[i], mBuf); + } + for (i=3; i>=0; i--) + { + CMCHKPK(SPkU32, stats->sch.ulAckNack[i], mBuf); + } + for (i=3; i>=0; i--) + { + CMCHKPK(SPkU32, stats->sch.ulNack[i], mBuf); + } + for (i=1; i>=0; i--) + { + for (j=3; j>=0; j--) + { + CMCHKPK(SPkU32, stats->sch.dlDtx[i][j], mBuf); + } + } + for (i=1; i>=0; i--) + { + for (j=3; j>=0; j--) + { + CMCHKPK(SPkU32, stats->sch.dlAckNack[i][j], mBuf); + } + } + for (i=1; i>=0; i--) + { + for (j=3; j>=0; j--) + { + CMCHKPK(SPkU32, stats->sch.dlNack[i][j], mBuf); + } + } + for (i=3; i>=0; i--) + { + CMCHKPK(SPkU32, stats->sch.riCnt[i], mBuf); + } + CMCHKPK(SPkU32, stats->sch.dlNumCw1iTbs, mBuf); + CMCHKPK(SPkU32, stats->sch.dlSumCw1iTbs, mBuf); + CMCHKPK(SPkU32, stats->sch.dlNumCw0iTbs, mBuf); + CMCHKPK(SPkU32, stats->sch.dlSumCw0iTbs, mBuf); + CMCHKPK(SPkU32, stats->sch.dlNumCw1Cqi, mBuf); + CMCHKPK(SPkU32, stats->sch.dlSumCw1Cqi, mBuf); + CMCHKPK(SPkU32, stats->sch.dlNumCw0Cqi, mBuf); + CMCHKPK(SPkU32, stats->sch.dlSumCw0Cqi, mBuf); + CMCHKPK(SPkU32, stats->sch.msg3Fail, mBuf); + CMCHKPK(SPkU32, stats->sch.msg4Fail, mBuf); + + CMCHKPK(SPkU32, stats->cellId, mBuf); + + RETVOID; +} + +#ifdef ANSI +PRIVATE Void TSInfUtlUnpkUeInfo +( + Buffer *mBuf, + TSInfL2UeStats *stats +) +#else +PRIVATE Void TSInfUtlUnpkUeInfo(mBuf, stats) + Buffer *mBuf; + TSInfL2UeStats *stats; +#endif +{ + S32 i; + U32 k; + + TRC2(TSInfUtlUnpkUeInfo) + + CMCHKUNPK(SUnpkU32, &stats->rnti, mBuf); + + for (k = L2_STATS_MAX_CELLS; k > 0; k--) + { + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.sch[k-1].dlTxOccns, mBuf); + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.sch[k-1].dlRetxOccns, mBuf); + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.sch[k-1].dlPrbUsg, mBuf); + for (i=1; i>=0; i--) + { + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.sch[k-1].dlNackCnt[i], mBuf); + } + for (i=1; i>=0; i--) + { + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.sch[k-1].dlAckNackCnt[i], mBuf); + } + for (i=1; i>=0; i--) + { + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.sch[k-1].dlDtxCnt[i], mBuf); + } + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.sch[k-1].dlSumCw0Cqi, mBuf); + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.sch[k-1].dlNumCw0Cqi, mBuf); + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.sch[k-1].dlSumCw1Cqi, mBuf); + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.sch[k-1].dlNumCw1Cqi, mBuf); + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.sch[k-1].dlSumCw0iTbs, mBuf); + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.sch[k-1].dlNumCw0iTbs, mBuf); + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.sch[k-1].dlSumCw1iTbs, mBuf); + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.sch[k-1].dlNumCw1iTbs, mBuf); + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.sch[k-1].cqiDropCnt, mBuf); + for (i=4; i>=0; i--) + { + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.sch[k-1].dlPdbLvl[i], mBuf); + } + for (i=3; i>=0; i--) + { + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.sch[k-1].riCnt[i], mBuf); + } + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.sch[k-1].dlBo, mBuf); + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.sch[k-1].dlTpt, mBuf); + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.sch[k-1].ulTxOccns, mBuf); + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.sch[k-1].ulRetxOccns, mBuf); + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.sch[k-1].ulPrbUsg, mBuf); + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.sch[k-1].ulAckNackCnt, mBuf); + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.sch[k-1].ulNackCnt, mBuf); + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.sch[k-1].ulDtxCnt, mBuf); + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.sch[k-1].ulSumCqi, mBuf); + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.sch[k-1].ulNumCqi, mBuf); + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.sch[k-1].ulSumiTbs, mBuf); + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.sch[k-1].ulNumiTbs, mBuf); + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.sch[k-1].ulTpt, mBuf); + } + + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.pdcp.dlPdcpDropCnt, mBuf); + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.pdcp.dlPdcpAckWaitDropCnt, mBuf); + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.pdcp.dlFlowCtrlDropCnt, mBuf); + + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.rlc.ulReOdrTmrExpCnt, mBuf); + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.rlc.dlMaxPktsInSduQ, mBuf); + CMCHKUNPK(SUnpkU32, &stats->nonPersistent.rlc.dlMaxWindowSz, mBuf); + + CMCHKUNPK(SUnpkU32, &stats->persistent.activatedSCells, mBuf); + CMCHKUNPK(SUnpkU32, &stats->persistent.numActivation, mBuf); + CMCHKUNPK(SUnpkU32, &stats->persistent.numDeactivation, mBuf); + + RETVOID; +} + +#ifdef ANSI +PRIVATE Void TSInfUtlUnpkCellInfo +( + Buffer *mBuf, + TSInfL2CellStats *stats +) +#else +PRIVATE Void TSInfUtlUnpkCellInfo(mBuf, stats) + Buffer *mBuf; + TSInfL2CellStats *stats; +#endif +{ + S32 i,j; + + TRC2(TSInfUtlUnpkCellInfo) + + CMCHKUNPK(SUnpkU32, &stats->cellId, mBuf); + + CMCHKUNPK(SUnpkU32, &stats->sch.msg4Fail, mBuf); + CMCHKUNPK(SUnpkU32, &stats->sch.msg3Fail, mBuf); + CMCHKUNPK(SUnpkU32, &stats->sch.dlSumCw0Cqi, mBuf); + CMCHKUNPK(SUnpkU32, &stats->sch.dlNumCw0Cqi, mBuf); + CMCHKUNPK(SUnpkU32, &stats->sch.dlSumCw1Cqi, mBuf); + CMCHKUNPK(SUnpkU32, &stats->sch.dlNumCw1Cqi, mBuf); + CMCHKUNPK(SUnpkU32, &stats->sch.dlSumCw0iTbs, mBuf); + CMCHKUNPK(SUnpkU32, &stats->sch.dlNumCw0iTbs, mBuf); + CMCHKUNPK(SUnpkU32, &stats->sch.dlSumCw1iTbs, mBuf); + CMCHKUNPK(SUnpkU32, &stats->sch.dlNumCw1iTbs, mBuf); + for (i=0; i<4; i++) + { + CMCHKUNPK(SUnpkU32, &stats->sch.riCnt[i], mBuf); + } + for (i=0; i<2; i++) + { + for (j=0; j<4; j++) + { + CMCHKUNPK(SUnpkU32, &stats->sch.dlNack[i][j], mBuf); + } + } + for (i=0; i<2; i++) + { + for (j=0; j<4; j++) + { + CMCHKUNPK(SUnpkU32, &stats->sch.dlAckNack[i][j], mBuf); + } + } + for (i=0; i<2; i++) + { + for (j=0; j<4; j++) + { + CMCHKUNPK(SUnpkU32, &stats->sch.dlDtx[i][j], mBuf); + } + } + for (i=0; i<4; i++) + { + CMCHKUNPK(SUnpkU32, &stats->sch.ulNack[i], mBuf); + } + for (i=0; i<4; i++) + { + CMCHKUNPK(SUnpkU32, &stats->sch.ulAckNack[i], mBuf); + } + for (i=0; i<4; i++) + { + CMCHKUNPK(SUnpkU32, &stats->sch.ulDtx[i], mBuf); + } + for (i=0; i<10; i++) + { + CMCHKUNPK(SUnpkU32, &stats->sch.dlPrbUsage[i], mBuf); + } + for (i=0; i<10; i++) + { + CMCHKUNPK(SUnpkU32, &stats->sch.ulPrbUsage[i], mBuf); + } + for (i=0; i<10; i++) + { + CMCHKUNPK(SUnpkU32, &stats->sch.dlPdbRatio[i], mBuf); + } + CMCHKUNPK(SUnpkU32, &stats->sch.avgTtiProcTime, mBuf); + CMCHKUNPK(SUnpkU32, &stats->sch.cntTtiProcTime1000, mBuf); + CMCHKUNPK(SUnpkU32, &stats->sch.cntTtiProcTime900, mBuf); + CMCHKUNPK(SUnpkU32, &stats->sch.cntTtiProcTime800, mBuf); + CMCHKUNPK(SUnpkU32, &stats->sch.cntTtiProcTime700, mBuf); + CMCHKUNPK(SUnpkU32, &stats->sch.cntTtiProcTime600, mBuf); + CMCHKUNPK(SUnpkU32, &stats->sch.cntTtiProcTime500, mBuf); +#ifdef RG_5GTF + CMCHKUNPK(SUnpkU32, &stats->sch.dl5gtfUePick, mBuf); + CMCHKUNPK(SUnpkU32, &stats->sch.dl5gtfRbAllocPass, mBuf); + CMCHKUNPK(SUnpkU32, &stats->sch.dl5gtfRbAllocFail, mBuf); + CMCHKUNPK(SUnpkU32, &stats->sch.dl5gtfFnlzPass, mBuf); + CMCHKUNPK(SUnpkU32, &stats->sch.dl5gtfFnlzFail, mBuf); + CMCHKUNPK(SUnpkU32, &stats->sch.dl5gtfBoUpd, mBuf); + CMCHKUNPK(SUnpkU32, &stats->sch.dl5gtfPdcchSend, mBuf); + CMCHKUNPK(SUnpkU32, &stats->sch.dl5gtfPdschCons, mBuf); + + CMCHKUNPK(SUnpkU32, &stats->sch.ul5gtfSrRecv, mBuf); + CMCHKUNPK(SUnpkU32, &stats->sch.ul5gtfBsrRecv, mBuf); + CMCHKUNPK(SUnpkU32, &stats->sch.ul5gtfUeSchPick, mBuf); + CMCHKUNPK(SUnpkU32, &stats->sch.ul5gtfPdcchSchd, mBuf); + CMCHKUNPK(SUnpkU32, &stats->sch.ul5gtfAllocAllocated, mBuf); + CMCHKUNPK(SUnpkU32, &stats->sch.ul5gtfUeRbAllocDone, mBuf); + CMCHKUNPK(SUnpkU32, &stats->sch.ul5gtfUeRmvFnlzZeroBo, mBuf); + CMCHKUNPK(SUnpkU32, &stats->sch.ul5gtfUeFnlzReAdd, mBuf); + CMCHKUNPK(SUnpkU32, &stats->sch.ul5gtfPdcchSend, mBuf); + CMCHKUNPK(SUnpkU32, &stats->sch.ul5gtfRbAllocFail, mBuf); +#endif + CMCHKUNPK(SUnpkU32, &stats->sch.ulSumCqi, mBuf); + CMCHKUNPK(SUnpkU32, &stats->sch.ulNumCqi, mBuf); + CMCHKUNPK(SUnpkU32, &stats->sch.ulSumiTbs, mBuf); + CMCHKUNPK(SUnpkU32, &stats->sch.ulNumiTbs, mBuf); + + CMCHKUNPK(SUnpkU32, &stats->rlc.maxRlcSrbRetxFail, mBuf); + CMCHKUNPK(SUnpkU32, &stats->rlc.maxRlcDrbRetxFail, mBuf); + CMCHKUNPK(SUnpkU32, &stats->rlc.reOdrTmrExp, mBuf); + + RETVOID; +} + +#ifdef ANSI +PUBLIC Void TSInfPkSndL2UeStats +( + Pst *pst, + SuId suId, + TSInfL2UeStats *stats +) +#else +PUBLIC Void TSInfPkSndL2UeStats(pst, suId, stats) + Pst *pst; + SuId suId; + TSInfL2UeStats *stats; +#endif +{ + Buffer *mBuf; + + TRC2(TSInfPkSndL2UeStats) + + mBuf = TSInfUtlAllocMsg(pst); + TSInfUtlPackUeInfo(mBuf, stats); + SPkS16(suId, mBuf); + pst->event = (Event) EVTTENBL2UESTATS; + SPstTsk(pst, mBuf); + RETVOID; +} + +#ifdef ANSI +PUBLIC Void TSInfUnpkL2UeStats +( + TSInfL2UeStatsInd func, + Pst *pst, + Buffer *mBuf +) +#else +PUBLIC Void TSInfUnpkL2UeStats(func, pst, mBuf) + TSInfL2UeStatsInd func; + Pst *pst; + Buffer *mBuf; +#endif +{ + SuId suId; + TSInfL2UeStats stats; + + TRC2(TSInfUnpkL2UeStats) + + SUnpkS16(&suId, mBuf); + TSInfUtlUnpkUeInfo(mBuf, &stats); + SPutMsg(mBuf); + (*func)(pst, suId, &stats); + RETVOID; +} + +#ifdef ANSI +PUBLIC Void TSInfPkSndL2CellStats +( + Pst *pst, + SuId suId, + TSInfL2CellStats *stats +) +#else +PUBLIC Void TSInfPkSndL2CellStats(pst, suId, stats) + Pst *pst; + SuId suId; + TSInfL2Cellstats *stats; +#endif +{ + Buffer *mBuf; + + TRC2(TSInfPkSndL2CellStats) + + mBuf = TSInfUtlAllocMsg(pst); + TSInfUtlPackCellInfo(mBuf, stats); + SPkS16(suId, mBuf); + pst->event = (Event) EVTTENBL2CELLSTATS; + SPstTsk(pst, mBuf); + RETVOID; +} + +#ifdef ANSI +PUBLIC Void TSInfUnpkL2CellStats +( + TSInfL2CellStatsInd func, + Pst *pst, + Buffer *mBuf +) +#else +PUBLIC Void TSInfUnpkL2CellStats(func, pst, mBuf) + TSInfL2CellStatsInd func; + Pst *pst; + Buffer *mBuf; +#endif +{ + SuId suId; + TSInfL2CellStats stats; + + TRC2(TSInfUnpkL2CellStats) + + SUnpkS16(&suId, mBuf); + TSInfUtlUnpkCellInfo(mBuf, &stats); + SPutMsg(mBuf); + (*func)(pst, suId, &stats); + RETVOID; +} +#endif /* TENB_STATS */ + +/********************************************************************** + End of file + **********************************************************************/ diff --git a/src/cm/cm_tkns.c b/src/cm/cm_tkns.c new file mode 100644 index 000000000..da3b002e0 --- /dev/null +++ b/src/cm/cm_tkns.c @@ -0,0 +1,972 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/********************************************************************20** + + Name: general layer + + Type: C file + + Desc: Packing/Unpacking for structures, defined in cm_tkns.x + + File: cm_tkns.c + +*********************************************************************21*/ + +/* header include files (.h) */ + +#include "envopt.h" /* environment options */ +#include "envdep.h" /* environment dependent */ +#include "envind.h" /* environment independent */ + +#include "gen.h" /* general layer */ +#include "ssi.h" /* system services */ +#include "cm_mblk.h" +#include "cm_tkns.h" /* common tokens */ + +/* header/extern include files (.x) */ + +#include "gen.x" /* general layer */ +#include "ssi.x" /* system services */ +#include "cm_mblk.x" +#include "cm_tkns.x" /* common tokens */ + + + +/* + * PACKING FUNCTIONS + */ + + +/* + * + * Fun: cmPkTknS16 + * + * Desc: This function unpacks a token S16 + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_tkns.c + * + */ +#ifdef ANSI +PUBLIC S16 cmPkTknS16 +( +TknS16 *tknS16, /* token S16 */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkTknS16(tknS16, mBuf) +TknS16 *tknS16; /* token S16 */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmPkTknS16) + + if (tknS16->pres) + { + /* Value */ + CMCHKPK(SPkS16, tknS16->val, mBuf); + } + + /* Token Header */ + CMCHKPK(SPkU8, tknS16->pres, mBuf); + + RETVALUE(ROK); +} /* end of cmPkTknS16 */ + + +/* + * + * Fun: cmPkTknBStr32 + * + * Desc: This function packs a token bit string of size 32 + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_tkns.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmPkTknBStr32 +( +TknBStr32 *tknStr, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkTknBStr32(tknStr, mBuf) +TknBStr32 *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmPkTknBStr32) + + CMPKTKNBSTR(tknStr, mBuf); + + RETVALUE(ROK); + +} /* end of cmPkTknBStr32 */ + +/* + * + * Fun: cmPkTknStr8 + * + * Desc: This function packs a token string of size 8 + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_tkns.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmPkTknStr8 +( +TknStr8 *tknStr, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkTknStr8(tknStr, mBuf) +TknStr8 *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmPkTknStr8) + + CMPKTKNSTR(tknStr, mBuf); + + RETVALUE(ROK); + +} /* end of cmPkTknStr8 */ + + +/* + * + * Fun: cmPkTknStr16 + * + * Desc: This function packs a token string of size 16 + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_tkns.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmPkTknStr16 +( +TknStr16 *tknStr, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkTknStr16(tknStr, mBuf) +TknStr16 *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmPkTknStr16) + + CMPKTKNSTR(tknStr, mBuf); + + RETVALUE(ROK); + +} /* end of cmPkTknStr16 */ + + +/* + * + * Fun: cmPkTknStrOSXL + * + * Desc: This function packs a Long Octet string + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_tkns.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmPkTknStrOSXL +( +TknStrOSXL *tknStr, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkTknStrOSXL(tknStr, mBuf) +TknStrOSXL *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + U16 ndx; + + TRC2(cmPkTknStrOSXL) + + if(tknStr->pres) + { + /* Value */ + for (ndx = 0; ndx < tknStr->len; ndx++) + { + CMCHKPK(SPkU8, tknStr->val[ndx], mBuf); + } + /* Length */ + CMCHKPK(SPkU16, tknStr->len, mBuf); + } + /* Token Header */ + CMCHKPK(SPkU8, tknStr->pres, mBuf); + + RETVALUE(ROK); + +} /* end of cmPkTknStrOSXL */ + + + +/* + * + * Fun: cmPkTknStrBSXL + * + * Desc: This function packs a Long bit string + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_tkns.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmPkTknStrBSXL +( +TknStrBSXL *tknStr, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkTknStrBSXL(tknStr, mBuf) +TknStrBSXL *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + U16 ndx; + U16 len; + + TRC2(cmPkTknStrBSXL) + + if(tknStr->pres) + { + if (tknStr->len % 8) + len = (tknStr->len/8) + 1; + else + len = (tknStr->len/8); + + /* Value */ + for (ndx = 0; ndx < len; ndx++) + { + CMCHKPK(SPkU8, tknStr->val[ndx], mBuf); + } + /* Length */ + CMCHKPK(SPkU16, tknStr->len, mBuf); + } + /* Token Header */ + CMCHKPK(SPkU8, tknStr->pres, mBuf); + + RETVALUE(ROK); + +} /* end of cmPkTknStrBSXL */ + + +/* + * + * Fun: cmPkTknStrBMP4 + * + * Desc: This function packs a BMP token string of size 4 + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_tkns.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmPkTknStrBMP4 +( +TknStrBMP4 *tknStr, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkTknStrBMP4(tknStr, mBuf) +TknStrBMP4 *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + U8 ndx; + + TRC2(cmPkTknStrBMP4) + + if(tknStr->pres) + { + /* Value */ + for (ndx = 0; ndx < tknStr->len; ndx++) + { + CMCHKPK(SPkU16, tknStr->val[ndx], mBuf); + } + + /* Length */ + CMCHKPK(SPkU8, tknStr->len, mBuf); + } + + /* Token Header */ + CMCHKPK(SPkU8, tknStr->pres, mBuf); + + RETVALUE(ROK); +} /* end of cmPkTknStrBMP4 */ + + +/* + * + * Fun: cmPkTknStrBMPXL + * + * Desc: This function packs a Long BMP Octet string + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_tkns.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmPkTknStrBMPXL +( +TknStrBMPXL *tknStr, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkTknStrBMPXL(tknStr, mBuf) +TknStrBMPXL *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + U16 ndx; + + TRC2(cmPkTknStrBMPXL) + + if(tknStr->pres) + { + /* Value */ + for (ndx = 0; ndx < tknStr->len; ndx++) + { + CMCHKPK(SPkU16, tknStr->val[ndx], mBuf); + } + /* Length */ + CMCHKPK(SPkU16, tknStr->len, mBuf); + } + /* Token Header */ + CMCHKPK(SPkU8, tknStr->pres, mBuf); + + RETVALUE(ROK); +} /* end of cmPkTknStrBMPXL */ + + +/* + * + * Fun: cmPkTknStrUNI4 + * + * Desc: This function packs a UNI token string of size 4 + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_tkns.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmPkTknStrUNI4 +( +TknStrUNI4 *tknStr, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkTknStrUNI4(tknStr, mBuf) +TknStrUNI4 *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + U8 ndx; + + TRC2(cmPkTknStrUNI4) + + if(tknStr->pres) + { + /* Value */ + for (ndx = 0; ndx < tknStr->len; ndx++) + { + CMCHKPK(SPkU32, tknStr->val[ndx], mBuf); + } + + /* Length */ + CMCHKPK(SPkU8, tknStr->len, mBuf); + } + + /* Token Header */ + CMCHKPK(SPkU8, tknStr->pres, mBuf); + + RETVALUE(ROK); +} /* end of cmPkTknStrUNI4 */ + + +/* + * + * Fun: cmPkTknStrUNIXL + * + * Desc: This function packs a Long UNI Octet string + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_tkns.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmPkTknStrUNIXL +( +TknStrUNIXL *tknStr, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmPkTknStrUNIXL(tknStr, mBuf) +TknStrUNIXL *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + U16 ndx; + + TRC2(cmPkTknStrUNIXL) + + if(tknStr->pres) + { + /* Value */ + for (ndx = 0; ndx < tknStr->len; ndx++) + { + CMCHKPK(SPkU32, tknStr->val[ndx], mBuf); + } + /* Length */ + CMCHKPK(SPkU16, tknStr->len, mBuf); + } + /* Token Header */ + CMCHKPK(SPkU8, tknStr->pres, mBuf); + + RETVALUE(ROK); +} /* end of cmPkTknStrUNIXL */ + +/* + * UNPACKING FUNCTIONS + */ + + +/* + * + * Fun: cmUnpkTknS16 + * + * Desc: This function unpacks a token S16 + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_tkns.c + * + */ +#ifdef ANSI +PUBLIC S16 cmUnpkTknS16 +( +TknS16 *tknS16, /* token S16 */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkTknS16(tknS16, mBuf) +TknS16 *tknS16; /* token S16 */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmUnpkTknS16) + + /* Token Header */ + CMCHKUNPK(SUnpkU8, &tknS16->pres, mBuf); + + if (tknS16->pres) + { + /* Value */ + CMCHKUNPK(SUnpkS16, &tknS16->val, mBuf); + } + + RETVALUE(ROK); +} /* end of cmUnpkTknS16 */ + + +/* + * + * Fun: cmUnpkTknBStr32 + * + * Desc: This function packs a token bit string of size 32 + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_tkns.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmUnpkTknBStr32 +( +TknBStr32 *tknStr, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkTknBStr32(tknStr, mBuf) +TknBStr32 *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmUnpkTknBStr32) + + CMUNPKTKNBSTR(tknStr, mBuf); + + RETVALUE(ROK); + +} /* end of cmUnpkTknBStr32 */ + + +/* + * + * Fun: cmUnpkTknStr8 + * + * Desc: This function packs a token string of size 8 + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_tkns.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmUnpkTknStr8 +( +TknStr8 *tknStr, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkTknStr8(tknStr, mBuf) +TknStr8 *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmUnpkTknStr8) + + CMUNPKTKNSTR(tknStr, mBuf); + + RETVALUE(ROK); + +} /* end of cmUnpkTknStr8 */ + + +/* + * + * Fun: cmUnpkTknStr16 + * + * Desc: This function packs a token string of size 16 + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_tkns.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmUnpkTknStr16 +( +TknStr16 *tknStr, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkTknStr16(tknStr, mBuf) +TknStr16 *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + TRC2(cmUnpkTknStr16) + + CMUNPKTKNSTR(tknStr, mBuf); + + RETVALUE(ROK); + +} /* end of cmUnpkTknStr16 */ + + +/* + * + * Fun: cmUnpkTknStrOSXL + * + * Desc: This function packs a long octet token string + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_tkns.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmUnpkTknStrOSXL +( +TknStrOSXL *tknStr, /* token string */ +Buffer *mBuf, /* message buffer */ +Ptr ptr /* pointer to memory control block */ +) +#else +PUBLIC S16 cmUnpkTknStrOSXL(tknStr, mBuf, ptr) +TknStrOSXL *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +Ptr ptr; /* pointer to control memory block */ +#endif +{ + U16 ndx; + + TRC2(cmUnpkTknStrOSXL) + + CMCHKUNPK(SUnpkU8, &tknStr->pres, mBuf); + + if(tknStr->pres) + { + /* Length */ + CMCHKUNPK(SUnpkU16, &tknStr->len, mBuf); + + if( cmGetMem(ptr, tknStr->len, (Ptr *)&tknStr->val) != ROK) + { + RETVALUE(RFAILED); + } + /* Value */ + for (ndx = 1; ndx <= tknStr->len; ndx++) + { + CMCHKUNPK(SUnpkU8, &tknStr->val[tknStr->len - ndx], mBuf); + } + } + + RETVALUE(ROK); + +} /* end of cmUnpkTknStrOSXL */ + + + +/* + * + * Fun: cmUnpkTknStrBSXL + * + * Desc: This function packs a long bit token string + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_tkns.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmUnpkTknStrBSXL +( +TknStrBSXL *tknStr, /* token string */ +Ptr ptr, /* pointer to memory control block */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkTknStrBSXL(tknStr, ptr, mBuf) +TknStrBSXL *tknStr; /* token string */ +Ptr ptr; /* pointer to control memory block */ +Buffer *mBuf; /* message buffer */ +#endif +{ + U16 ndx; + U16 len; + + TRC2(cmUnpkTknStrBSXL) + + CMCHKUNPK(SUnpkU8, &tknStr->pres, mBuf); + + if(tknStr->pres) + { + /* Length */ + CMCHKUNPK(SUnpkU16, &tknStr->len, mBuf); + + if (tknStr->len % 8) + len = (tknStr->len/8) + 1; + else + len = (tknStr->len/8); + + if( cmGetMem(ptr, len, (Ptr *)&tknStr->val) != ROK) + { + RETVALUE(RFAILED); + } + /* Value */ + for (ndx = 1; ndx <= len; ndx++) + { + CMCHKUNPK(SUnpkU8, &tknStr->val[len - ndx], mBuf); + } + } + + RETVALUE(ROK); + +} /* end of cmUnpkTknStrBSXL */ + + +/* + * + * Fun: cmUnpkTknStrBMP4 + * + * Desc: This function unpacks a BMP token string of size 4 + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_tkns.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmUnpkTknStrBMP4 +( +TknStrBMP4 *tknStr, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkTknStrBMP4(tknStr, mBuf) +TknStrBMP4 *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + U8 ndx; + + TRC2(cmUnpkTknStrBMP4) + + /* Token Header */ + CMCHKUNPK(SUnpkU8, &tknStr->pres, mBuf); + + if(tknStr->pres) + { + /* Length */ + CMCHKUNPK(SUnpkU8, &tknStr->len, mBuf); + + /* Value */ + for (ndx = 1; ndx <= tknStr->len; ndx++) + { + CMCHKUNPK(SUnpkU16, &tknStr->val[tknStr->len - ndx], mBuf); + } + } + + RETVALUE(ROK); +} /* end of cmUnpkTknStrBMP4 */ + + +/* + * + * Fun: cmUnpkTknStrBMPXL + * + * Desc: This function packs a long octet token string + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_tkns.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmUnpkTknStrBMPXL +( +TknStrBMPXL *tknStr, /* token string */ +Buffer *mBuf, /* message buffer */ +Ptr ptr /* pointer to memory control block */ +) +#else +PUBLIC S16 cmUnpkTknStrBMPXL(tknStr, mBuf, ptr) +TknStrBMPXL *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +Ptr ptr; /* pointer to control memory block */ +#endif +{ + U16 ndx; + + TRC2(cmUnpkTknStrBMPXL) + + CMCHKUNPK(SUnpkU8, &tknStr->pres, mBuf); + + if(tknStr->pres) + { + /* Length */ + CMCHKUNPK(SUnpkU16, &tknStr->len, mBuf); + + /* Each BMP Character is 2 octet long */ + if( cmGetMem(ptr, 2*(tknStr->len), (Ptr *)&tknStr->val) != ROK) + { + RETVALUE(RFAILED); + } + /* Value */ + for (ndx = 1; ndx <= tknStr->len; ndx++) + { + CMCHKUNPK(SUnpkU16, &tknStr->val[tknStr->len - ndx], mBuf); + } + } + + RETVALUE(ROK); + +} /* end of cmUnpkTknStrBMPXL */ + + +/* + * + * Fun: cmUnpkTknStrUNI4 + * + * Desc: This function unpacks a UNI token string of size 4 + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_tkns.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmUnpkTknStrUNI4 +( +TknStrUNI4 *tknStr, /* token string */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkTknStrUNI4(tknStr, mBuf) +TknStrUNI4 *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +#endif +{ + U8 ndx; + + TRC2(cmUnpkTknStrUNI4) + + /* Token Header */ + CMCHKUNPK(SUnpkU8, &tknStr->pres, mBuf); + + if(tknStr->pres) + { + /* Length */ + CMCHKUNPK(SUnpkU8, &tknStr->len, mBuf); + + /* Value */ + for (ndx = 1; ndx <= tknStr->len; ndx++) + { + CMCHKUNPK(SUnpkU32, &tknStr->val[tknStr->len - ndx], mBuf); + } + } + + RETVALUE(ROK); +} /* end of cmUnpkTknStrUNI4 */ + + +/* + * + * Fun: cmUnpkTknStrUNIXL + * + * Desc: This function packs a long octet token string + * + * Ret: ROK - ok + * + * Notes: None + * + File: cm_tkns.c + * + */ + +#ifdef ANSI +PUBLIC S16 cmUnpkTknStrUNIXL +( +TknStrUNIXL *tknStr, /* token string */ +Buffer *mBuf, /* message buffer */ +Ptr ptr /* pointer to memory control block */ +) +#else +PUBLIC S16 cmUnpkTknStrUNIXL(tknStr, mBuf, ptr) +TknStrUNIXL *tknStr; /* token string */ +Buffer *mBuf; /* message buffer */ +Ptr ptr; /* pointer to control memory block */ +#endif +{ + U16 ndx; + + TRC2(cmUnpkTknStrUNIXL) + + CMCHKUNPK(SUnpkU8, &tknStr->pres, mBuf); + + if(tknStr->pres) + { + /* Length */ + CMCHKUNPK(SUnpkU16, &tknStr->len, mBuf); + + /* Each UNI Character is 4 octets long */ + if( cmGetMem(ptr, 4*tknStr->len, (Ptr *)&tknStr->val) != ROK) + { + RETVALUE(RFAILED); + } + /* Value */ + for (ndx = 1; ndx <= tknStr->len; ndx++) + { + CMCHKUNPK(SUnpkU32, &tknStr->val[tknStr->len - ndx], mBuf); + } + } + + RETVALUE(ROK); + +} /* end of cmUnpkTknStrUNIXL */ + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/cm/cpj.h b/src/cm/cpj.h deleted file mode 100755 index 0d078f826..000000000 --- a/src/cm/cpj.h +++ /dev/null @@ -1,307 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: LTE PDCP Interface - - Type: C include file - - Desc: This file contains the defines required by PDCP user - - File: cpj.h - -*********************************************************************21*/ -#ifndef __CPJ_H__ -#define __CPJ_H__ - -#ifdef __cplusplus -EXTERN "C" { -#endif /*for extern "C"*/ - -/** - * @file - * @brief Macro for CPJ Interface - */ - -#define CPJ_SEL_LC 0 /* CPJ loose couple selector */ - -#define CPJ_7BIT_SN_SIZE 7 /*!< Sequence length is 7-bit */ -#define CPJ_12BIT_SN_SIZE 12 /*!< Sequence length is 12-bit */ -#define CPJ_MAX_CFG 10 /*!< Maximum PDCP entity to be configured */ -#define CPJ_MAX_DRB 12 /*!< Maximum DRBs per UE */ - -/* CPJ Configuration Failure Reasons */ -#define CPJ_CFG_REAS_NONE 0 /*!< No Failure */ -#define CPJ_CFG_REAS_ENT_CREAT_FAIL 1 /*!< PDCP Entity Creation Failure*/ -#define CPJ_CFG_REAS_UE_CREAT_FAIL 2 /*!< UE CB Creation Failure */ -#define CPJ_CFG_REAS_INVALID_PDCPID 3 /*!< Invalid PDCP ID */ -#define CPJ_CFG_REAS_PDCPID_PRSNT 4 /*!< PDCP ID already present */ -#define CPJ_CFG_REAS_INVALID_RLCMODE 5 /*!< Invalid RLC Mode */ -#define CPJ_CFG_REAS_PDCPID_UNKWN 6 /*!< PDCP ID Unknown */ -#define CPJ_CFG_REAS_UE_UNKWN 7 /*!< UE Cb Unknown */ -#define CPJ_CFG_REAS_CIPHER_ALGO_INVALID 8 /*!< Invalid Cipher Algo */ -#define CPJ_CFG_REAS_ENT_DEL_FAIL 9 /*!< PDCP Entity Deletion Failure */ -#define CPJ_CFG_REAS_UE_DEL_FAIL 10 /*!< UE Cb Deletion Failure */ -#define CPJ_CFG_REAS_REEST_FAIL 11 /*!< PDCP Reestablish Failure */ -#define CPJ_CFG_REAS_COMP_ALGO_INVALID 12 /*!< Compression Algo not - supported */ -#define CPJ_CFG_REAS_RECFG_FAIL 13 /*!< PDCP Reconfiguration Failed */ -#define CPJ_CFG_REAS_INVALID_CFG 14 /*!< Invalid Configuration Type */ -#define CPJ_CFG_REAS_SAME_UEID 15 /*!< UE IDs match in ChngUeId - Request*/ -#define CPJ_CFG_REAS_SAME_RBID 16 /*!< UE IDs match in ChngUeId - Request */ -#define CPJ_CFG_REAS_INVALID_RBID 17 /*!< Invalid RB ID */ - -#define CPJ_CFG_REAS_INTINIT_FAILED 18 /*!< Integrity Init Failed */ -#define CPJ_CFG_REAS_CCIPHR_FAILED 19 /*!< Control Plane Cihper Init Failed */ -#define CPJ_CFG_REAS_UCIPHR_FAILED 20 /*!< User Plane Cipher Init Failed */ - -#define CPJ_CFG_REAS_NO_DRBS 21 /*!< No DRBs Present */ -#define CPJ_CFG_REAS_OBD_TIMEOUT 22 /*!< No DRBs Present */ -#define CPJ_CFG_REAS_INVALID_STATE 23 /*!< Invalid state to perform re-establishment */ - -#define CPJ_CFG_TRANSID_SIZE 9 /*!< Macro for Transaction ID size */ - -/* CPJ Configuration confirmations */ -#define CPJ_CFG_CFM_OK 1 /*!< Confirm status OK */ -#define CPJ_CFG_CFM_NOK 2 /*!< Confirm status NOK */ - -/*Event Code*/ -#define CPJ_EVC_RESET_FAILED 1 /*!< Reset Failed */ - -#define EVTCPJBNDREQ 0x20 /*!< Bind Request */ -#define EVTCPJBNDCFM 0x21 /*!< Bind Confirmation */ -#define EVTCPJUBNDREQ 0x22 /*!< Unbind Request */ -#define EVTCPJCFGREQ 0x23 /*!< Config Request */ -#define EVTCPJCFGCFM 0x24 /*!< Config Confirmation */ -#define EVTCPJUEIDCHGREQ 0x25 /*!< UE ID Change Request */ -#define EVTCPJUEIDCHGCFM 0x26 /*!< UE ID Change Confirmation */ -#define EVTCPJSECCFGREQ 0x27 /*!< Security Config Request */ -#define EVTCPJSECCFGCFM 0x28 /*!< Security Config Confirm */ -#define EVTCPJREESTREQ 0x29 /*!< Count C Request */ -#define EVTCPJREESTCFM 0x2A /*!< Count C Confirm */ -#define EVTCPJCOUNTREQ 0x2B /*!< Count C Request */ -#define EVTCPJCOUNTCFM 0x2C /*!< Count C Confirm */ -#define EVTCPJSDUSTAREQ 0x2D /*!< SDU Status Request */ -#define EVTCPJSDUSTACFM 0x2E /*!< SDU Status Confirm */ -#define EVTCPJKDFREQ 0x2F /*!< Key derivation primitive - request event*/ -#define EVTCPJKDFCFM 0x30 /*!< Configuration Confirm - event*/ -#define EVTCPJSTARTDATAFWDREQ 0x31 /*!< Data Forward Request */ -#define EVTCPJDATRESUMEREQ 0x32 /*!< Data Resume Request */ -#define EVTCPJDATRESUMECFM 0x33 /*!< Data Resume Confirm */ - -#define CPJ_CIPHER_KEY_LEN 16 /*!< Ciphering key length */ -#define CPJ_INTG_KEY_LEN 16 /*!< Integrity key length */ -#define CPJ_MAX_ROHC_PROF_LIST 9 /*!< ROHC profile list */ -#define CPJ_MAX_CFM 10 /*!< Maximum number of confirm */ - -#define CPJ_CFG_ADD 0x01 /*!< Configure new PDCP entity - in the requested UE */ -#define CPJ_CFG_MODIFY 0x02 /*!< Reconfigure PDCP entity - in the requested UE */ -#define CPJ_CFG_DELETE 0x03 /*!< Delete PDCP entity - in the requested UE */ -#define CPJ_CFG_REESTABLISH 0x04 /*!< Reestablish PDCP entity - in the requested UE */ -#define CPJ_CFG_DELETE_UE 0x05 /*!< Delete UE in PDCP */ - - -#define CPJ_SEC_INTG_INFO 0x01 /*!< Integrity information */ -#define CPJ_SEC_CIPHER_INFO 0x02 /*!< Ciphering information */ - -#ifdef CPJ_V2 -#define CPJ_SEC_ALG_NULL 0x00 /*!< NULL algorithm */ -#define CPJ_SEC_ALG_SNOW3G 0x01 /*!< Snow 3G algorithm */ -#define CPJ_SEC_ALG_AES 0x02 /*!< AES algorithm */ -#define CPJ_SEC_ALG_ZUC 0x03 /*!< ZUC algorithm */ -#else -#define CPJ_SEC_ALG_NULL 0x01 /*!< NULL algorithm */ -#define CPJ_SEC_ALG_SNOW3G 0x02 /*!< Snow 3G algorithm */ -#define CPJ_SEC_ALG_AES 0x03 /*!< AES algorithm */ -#define CPJ_SEC_ALG_ZUC 0x04 /*!< ZUC algorithm */ -#endif - - -/* Defines which is used in ModCfg to set the bitflag */ -#define CPJ_RECFG_DISRQD 0x01 /*!< Discard Required is present*/ -#define CPJ_RECFG_CFMREQ 0x02 /*!< Confirm Required is present */ -#define CPJ_RECFG_REORDTMR 0x04 /*!< t-Reorder reconfiguration is present */ - -/* Flags will be used to fill the Hand off information */ -#define CPJ_HO_NOT_PRSNT 0 /*!< Hand of Info is not present */ -#define CPJ_HO_UL 1 /*!< Uplink count present */ -#define CPJ_HO_DL 2 /*!< Downlink count present */ - - -#define CPJ_KDF_TYPE1 0 /*!< eNodeB key type for for deriving eNodeB* - Key(Horizontal key derivation - ref: ts 33.401)*/ -#define CPJ_KDF_TYPE2 1 /*!< eNodeB key type for for deriving AS - security keys */ -#define CPJ_KDF_TYPE3 2 /*!< NH key type for for deriving eNodeB* Key - (Verticall key derivation - ref: ts 33.401) */ - -#define CPJ_SEC_KEY_LEN 32 /*!< size of the security keys*/ - -/* cpj_h_001.main_2 added support for L2 Measurement */ -#ifdef LTE_L2_MEAS -#define CPJ_MAX_QCI 10 -#endif - -/* Error Codes */ -#define ECPJXXX 0 -#define ERRCPJ 0 - -#define ECPJ001 (ERRCPJ + 1) -#define ECPJ002 (ERRCPJ + 2) -#define ECPJ003 (ERRCPJ + 3) -#define ECPJ004 (ERRCPJ + 4) -#define ECPJ005 (ERRCPJ + 5) -#define ECPJ006 (ERRCPJ + 6) -#define ECPJ007 (ERRCPJ + 7) -#define ECPJ008 (ERRCPJ + 8) -#define ECPJ009 (ERRCPJ + 9) -#define ECPJ010 (ERRCPJ + 10) -#define ECPJ011 (ERRCPJ + 11) -#define ECPJ012 (ERRCPJ + 12) -#define ECPJ013 (ERRCPJ + 13) -#define ECPJ014 (ERRCPJ + 14) -#define ECPJ015 (ERRCPJ + 15) -#define ECPJ016 (ERRCPJ + 16) -#define ECPJ017 (ERRCPJ + 17) -#define ECPJ018 (ERRCPJ + 18) -#define ECPJ019 (ERRCPJ + 19) -#define ECPJ020 (ERRCPJ + 20) -#define ECPJ021 (ERRCPJ + 21) -#define ECPJ022 (ERRCPJ + 22) -#define ECPJ023 (ERRCPJ + 23) -#define ECPJ024 (ERRCPJ + 24) -#define ECPJ025 (ERRCPJ + 25) -#define ECPJ026 (ERRCPJ + 26) -#define ECPJ027 (ERRCPJ + 27) -#define ECPJ028 (ERRCPJ + 28) -#define ECPJ029 (ERRCPJ + 29) -#define ECPJ030 (ERRCPJ + 30) -#define ECPJ031 (ERRCPJ + 31) -#define ECPJ032 (ERRCPJ + 32) -#define ECPJ033 (ERRCPJ + 33) -#define ECPJ034 (ERRCPJ + 34) -#define ECPJ035 (ERRCPJ + 35) -#define ECPJ036 (ERRCPJ + 36) -#define ECPJ037 (ERRCPJ + 37) -#define ECPJ038 (ERRCPJ + 38) -#define ECPJ039 (ERRCPJ + 39) -#define ECPJ040 (ERRCPJ + 40) -#define ECPJ041 (ERRCPJ + 41) -#define ECPJ042 (ERRCPJ + 42) -#define ECPJ043 (ERRCPJ + 43) -#define ECPJ044 (ERRCPJ + 44) -#define ECPJ045 (ERRCPJ + 45) -#define ECPJ046 (ERRCPJ + 46) -#define ECPJ047 (ERRCPJ + 47) -#define ECPJ048 (ERRCPJ + 48) -#define ECPJ049 (ERRCPJ + 49) -#define ECPJ050 (ERRCPJ + 50) -#define ECPJ051 (ERRCPJ + 51) -#define ECPJ052 (ERRCPJ + 52) -#define ECPJ053 (ERRCPJ + 53) -#define ECPJ054 (ERRCPJ + 54) -#define ECPJ055 (ERRCPJ + 55) -#define ECPJ056 (ERRCPJ + 56) -#define ECPJ057 (ERRCPJ + 57) -#define ECPJ058 (ERRCPJ + 58) -#define ECPJ059 (ERRCPJ + 59) -#define ECPJ060 (ERRCPJ + 60) -#define ECPJ061 (ERRCPJ + 61) -#define ECPJ062 (ERRCPJ + 62) -#define ECPJ063 (ERRCPJ + 63) -#define ECPJ064 (ERRCPJ + 64) -#define ECPJ065 (ERRCPJ + 65) -#define ECPJ066 (ERRCPJ + 66) -#define ECPJ067 (ERRCPJ + 67) -#define ECPJ068 (ERRCPJ + 68) -#define ECPJ069 (ERRCPJ + 69) -#define ECPJ070 (ERRCPJ + 70) -#define ECPJ071 (ERRCPJ + 71) -#define ECPJ072 (ERRCPJ + 72) -#define ECPJ073 (ERRCPJ + 73) -#define ECPJ074 (ERRCPJ + 74) -#define ECPJ075 (ERRCPJ + 75) -#define ECPJ076 (ERRCPJ + 76) -#define ECPJ077 (ERRCPJ + 77) -#define ECPJ078 (ERRCPJ + 78) -#define ECPJ079 (ERRCPJ + 79) -#define ECPJ080 (ERRCPJ + 80) -#define ECPJ081 (ERRCPJ + 81) -#define ECPJ082 (ERRCPJ + 82) -#define ECPJ083 (ERRCPJ + 83) -#define ECPJ084 (ERRCPJ + 84) -#define ECPJ085 (ERRCPJ + 85) -#define ECPJ086 (ERRCPJ + 86) -#define ECPJ087 (ERRCPJ + 87) -#define ECPJ088 (ERRCPJ + 88) -#define ECPJ089 (ERRCPJ + 89) -#define ECPJ090 (ERRCPJ + 90) -#define ECPJ091 (ERRCPJ + 91) -#define ECPJ092 (ERRCPJ + 92) -#define ECPJ093 (ERRCPJ + 93) -#define ECPJ094 (ERRCPJ + 94) -#define ECPJ095 (ERRCPJ + 95) -#define ECPJ096 (ERRCPJ + 96) -#define ECPJ097 (ERRCPJ + 97) -#define ECPJ098 (ERRCPJ + 98) -#define ECPJ099 (ERRCPJ + 99) -#define ECPJ100 (ERRCPJ + 100) -#define ECPJ101 (ERRCPJ + 101) -#define ECPJ102 (ERRCPJ + 102) -#define ECPJ103 (ERRCPJ + 103) -#define ECPJ104 (ERRCPJ + 104) -#define ECPJ105 (ERRCPJ + 105) -#define ECPJ106 (ERRCPJ + 106) -#define ECPJ107 (ERRCPJ + 107) -#define ECPJ108 (ERRCPJ + 108) -#define ECPJ109 (ERRCPJ + 109) -#define ECPJ110 (ERRCPJ + 110) -#define ECPJ111 (ERRCPJ + 111) -#define ECPJ112 (ERRCPJ + 112) -#define ECPJ113 (ERRCPJ + 113) -#define ECPJ114 (ERRCPJ + 114) -#define ECPJ115 (ERRCPJ + 115) -#define ECPJ116 (ERRCPJ + 116) -#define ECPJ117 (ERRCPJ + 117) -#define ECPJ118 (ERRCPJ + 118) -#define ECPJ119 (ERRCPJ + 119) -#define ECPJ120 (ERRCPJ + 120) -#define ECPJ121 (ERRCPJ + 121) -#define ECPJ122 (ERRCPJ + 122) - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ -#endif /* __CPJ_H__ */ - -/********************************************************************30** - - End of file -**********************************************************************/ diff --git a/src/cm/cpj.x b/src/cm/cpj.x deleted file mode 100755 index d28df1ab8..000000000 --- a/src/cm/cpj.x +++ /dev/null @@ -1,1655 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: LTE PDCP Interface - - Type: C include file - - Desc: This file contains the Data structures for LTE PDCP Interface - - File: cpj.x - -*********************************************************************21*/ -#ifndef __CPJ_X__ -#define __CPJ_X__ - -#ifdef __cplusplus -EXTERN "C" { -#endif /*for extern "C"*/ - -/** - * @file - * @brief CPJ Interface file - */ - -/************************************************************************* - * START OF STRUCTURES - ************************************************************************/ -/** - * @brief - * Cipher Key type information. - */ -typedef U8 CpjCipherKey; - -/** - * @brief - * Integrity Key type information. - */ -typedef U8 CpjIntegrityKey; - -/** - * @brief - * RLC Parameter Information in AM mode. - */ -typedef struct cpjRlcAm -{ - Bool statusRepReqd; /*!< Status report required */ - U8 pdcpSNSize; /*!< Length of PDCP sequence number */ -}CpjRlcAm; - -/** - * @brief - * RLC Parameter Information in UM mode. - */ -typedef struct cpjRlcUm -{ - U8 pdcpSNSize; /*!< Length of PDCP sequence number */ -}CpjRlcUm; - -/** - * @brief - * Mapped RLC Entity Information in RLC for the PDCP Entity - */ -typedef struct cpjRlcInfo -{ - U8 dir; /*!< UPLINK/DOWNLINK/BOTH */ - U8 mode; /*!< RLC Mode */ - union - { - CpjRlcAm rlcAm; /*!< RLC in AM mode */ - CpjRlcUm rlcUm; /*!< RLC in UM mode */ - }m; -}CpjRlcInfo; - - -/** - * @brief - * Ciphering Information to be configured per UE in PDCP. - */ -typedef struct cpjCipherInfo -{ - CpjCipherKey ctrlplnKey[CPJ_CIPHER_KEY_LEN]; /*!< Control plane - ciphering key */ - CpjCipherKey usrplnKey[CPJ_CIPHER_KEY_LEN]; /*!< User plane - ciphering key */ - U8 algoType; /*!< Algorithm type. - Allowed values are: - -# CPJ_SEC_ALG_NULL - -# CPJ_SEC_ALG_SNOW3G - -# CPJ_SEC_ALG_AES - */ -}CpjCipherInfo; - -/** - * @brief - * Integrity protection paramater information. -*/ -typedef struct cpjIntegInfo -{ - U8 algoType; /*!< Algorithm type. - Allowed values are: - -# CPJ_SEC_ALG_AES - -# CPJ_SEC_ALG_SNOW3G - */ - CpjIntegrityKey intKey[CPJ_INTG_KEY_LEN]; /*!< Integrity key */ -} CpjIntegInfo; - -/** - * @brief - * PDCP Security configuration parameter. - */ -typedef struct cpjSecCfg -{ - Bool selSecAct; /*!< Selective security activation flag. - - PDCP applies only Integrity algorithm for the first UL and first DL - messages (security activation procedure), applies both Integrity and - ciphering for all the other messages (including handover which involves - reconfiguration messages). selSecAct enables to identify whether - PDCP needs to selectively apply only Integrity for first UL/DL message. - */ - U8 isHo; - CpjIntegInfo integInfo; /*!< Integrity configuration */ - CpjCipherInfo cipherInfo; /*!< Ciphering configuration */ -} CpjSecCfg; - -/** - * @brief - * ROHC Compression protocol information structure. - */ -typedef struct cpjRohcInfo -{ - U16 maxCid; /*!< Maximum CID */ - Bool profLst[CPJ_MAX_ROHC_PROF_LIST]; /*!< ROHC profile - information */ -}CpjRohcInfo; - -/** - * @brief - * ROHC Configuration information for PDCP entity. - */ -typedef struct cpjHdrCompCfg -{ - Bool hdrCompUsed; /*!< Header Compression Used/Not */ - CpjRohcInfo rohcInfo; /*!< ROHC configuration information */ -}CpjHdrCompCfg; - -/** - * @brief - * Handover Information for RB. - */ -typedef struct cpjHoInfo -{ - U8 isHoPres; /*!< Last 2bits (from LSB)is used to convey handover information is present or - not. @n Allowed values are: - -# CPJ_HO_NOT_PRSNT 00 - -# CPJ_HO_UL 01 - -# CPJ_HO_DL 10 - */ - U8 snLen; /*!< PDCP SN len 12/15 bit */ - U32 dlCount; /*!< DL COUNT to assign for new SDUs */ - U32 ulCount; /*!< UL First Missing SN */ - U16 numBits; /*!< Number of bits in UL bitmap */ - U8 *ulBitMap; /*!< UL SN bitmap excluding FMS to be used - as status report */ -} CpjHoInfo; - -/** - * @brief - * Configuraiton Structure to add an RB. - */ -typedef struct cpjAddCfgEnt -{ - Bool discReqd; /*!< Discard required/not for PDUs - with Integrity Verification failure */ - Bool cfmReqd; /*!< Confirm required/not for SDUs - received by the peer PDCP entity. */ - /* cpj_x_001.main_3 added support for L2 Measurement */ -#ifdef LTE_L2_MEAS - U8 qci; /*!< qCI value Associated with that RB */ -#endif /* LTE_L2_MEAS */ - - CpjRlcInfo rlcInfo; /*!< Corresponding RLC entity information. */ - S16 discardTmr; /*!< Discard timer. @n The value for this parameter - is expected in milli seconds. @n Value of infinity - is also allowed and -1 must be passed for - the same. */ - U16 reOrdrTmrVal; /*!< t-Reorder Timer value in milli sec */ - CpjHdrCompCfg hdrCompCfg; /*!< PDCP compression information */ -}CpjAddCfgEnt; - -/** - * @brief - * Configuraiton Structure to modify an RB. - */ -typedef struct cpjModCfgEnt -{ - - U8 bitFlag; /*!< List of Modified Elements - Each bit respresents one element */ - - Bool discReqd; /*!< Discard required/not for PDUs - with Integrity Verification failure. - bitFlag=0x01 */ - Bool cfmReqd; /*!< Confirm required/not for SDUs - received by the peer PDCP entity. - bitFlag=0x02 */ - CpjHdrCompCfg hdrCompCfg; /*!< PDCP compression information */ - CpjHoInfo hoInfo; /*!< Handover Information */ - U16 reOrdrTmrVal; /*!< t-Reorder Timer value */ -}CpjModCfgEnt; - - -/** - * @brief - * Configuration structure for PDCP entity. - */ -typedef struct cpjCfgEnt -{ - U8 rbId; /*!< PDCP ID. */ - U8 cfgType; /*!< Configuration request type - - -# CPJ_CFG_ADD, - -# CPJ_CFG_MODIFY, - -# CPJ_CFG_DELETE, - -# CPJ_REESTABLISH, - -# CPJ_CFG_DELETE_UE */ - U8 rbType; /*!< RB type. - -# CM_LTE_SRB - -# CM_LTE_DRB */ - - union{ - CpjAddCfgEnt addCfg; /*!< Configuration parameters for - cfgType CPJ_CFG_ADD */ - CpjModCfgEnt modCfg; /*!< Configuration parameters for - cfgType CPJ_CFG_MODIFY */ - }m; -}CpjCfgEnt; - - - -/** - * @brief - * PDCP Configuration structure. Parameters are filled by RRC - layer while configuring the PDCP layer. - */ -typedef struct cpjCfgReqInfo -{ - CmLteRnti ueId; /*!< UE ID */ - CmLteCellId cellId; /*!< Cell ID */ - U32 transId; /*!< Transaction ID */ - U8 numEnt; /*!< Number of entities to be - configured in the Config request.*/ - U8 isHo; -#ifdef TENB_MULT_CELL_SUPPRT - SpId rlcUlSapId; - SpId rlcDlSapId; -#endif - CpjCfgEnt cfgEnt[CPJ_MAX_CFG]; /*!< Config paramater for - PDCP entity. */ -}CpjCfgReqInfo; - -/** - * @brief - * PDCP Confirm parameter structure for PDCP entity. - */ -typedef struct cpjCfmEnt -{ - U8 rbId; /*!< RB ID */ - U8 rbType; /*!< RB Type */ - Status status; /*!< ROK or RFAILED */ - Reason reason; /*!< Reason for failure */ -}CpjCfmEnt; - -/** - * @brief - * PDCP Configuration Confirm structure. - */ -typedef struct cpjCfgCfmInfo -{ - CmLteRnti ueId; /*!< UE ID */ - CmLteCellId cellId; /*!< Cell ID */ - U32 transId; /*!< Transcation ID */ - U8 numEnt; /*!< Number of entities */ - CpjCfmEnt cfmEnt[CPJ_MAX_CFM]; /*!< Confirm parameter for - PDCP entity */ -}CpjCfgCfmInfo; - -/** - * @brief - * Re-estabishment Request structure for SRB1 of an UE. - */ -typedef struct cpjReEstReqInfo -{ - CmLtePdcpId pdcpId; /*!< PDCP ID */ - U32 transId; /*!< Transcation ID */ - U8 intKey[CPJ_INTG_KEY_LEN]; /*!< Integrity key */ - CpjCipherKey ctrlplnKey[CPJ_CIPHER_KEY_LEN]; /*!< Control plane - ciphering key */ - CpjCipherKey usrplnKey[CPJ_CIPHER_KEY_LEN]; /*!< User plane - ciphering key */ -}CpjReEstReqInfo; - -/** - * @brief - * Data Forwarding Request structure - */ -typedef struct cpjDataFwdReqInfo -{ - CmLteRnti ueId; /*!< UE ID */ - CmLteCellId cellId; /*!< Cell ID */ - U32 transId; /*!< Transcation ID */ - Bool isUlDatFwdReq; /*!< UL Data Fwd reqd or not */ -}CpjDataFwdReqInfo; - - -/** - * @brief - * Data Resume Request structure - */ -typedef struct cpjDatResumeReqInfo -{ - CmLteRnti ueId; /*!< UE ID */ - CmLteCellId cellId; /*!< Cell ID */ - U32 transId; /*!< Transcation ID */ -}CpjDatResumeReqInfo; -/** - * @brief - * Re-establishment Confirmation structure for an UE. - */ -typedef struct cpjReEstCfmInfo -{ - CmLteRnti ueId; /*!< UE ID */ - CmLteCellId cellId; /*!< Cell ID */ - U32 transId; /*!< Transcation ID */ - Status status; /*!< Status of reestablishment. - Allowed values are: - -# LCM_PRIM_OK - -# LCM_PRIM_NOK - */ -}CpjReEstCfmInfo; - -/** - * @brief - * PDCP Security Configuration structure. Parameters are filled by RRC - * while configuring the security parameters. - */ -typedef struct cpjSecCfgReqInfo -{ - CmLteRnti ueId; /*!< UE ID */ - CmLteCellId cellId; /*!< Cell ID */ - U32 transId; /*!< Transcation ID */ - CpjSecCfg secCfg; /*!< Configuration paramater for PDCP entity */ -}CpjSecCfgReqInfo; - -/** - * @brief - * PDCP Security Configuration confirm structure. - */ -typedef struct cpjSecCfgCfmInfo -{ - CmLteRnti ueId; /*!< UE ID */ - CmLteCellId cellId; /*!< Cell ID */ - U32 transId; /*!< Transcation ID */ - Status status; /*!< ROK or RFAILED */ - Reason reason; /*!< Reason for failure */ -}CpjSecCfgCfmInfo; - -/** - * @brief - * UE ID Information - */ -typedef struct cpjUeInfo -{ - CmLteCellId cellId; /*!< Cell ID */ - CmLteRnti ueId; /*!< UE ID */ -}CpjUeInfo; - -/** - * @brief - * PDCP Count Request Information from RRC. - */ -typedef struct cpjCountReqInfo -{ - CmLteRnti ueId; /*!< UE ID */ - CmLteCellId cellId; /*!< Cell ID */ - U32 transId; /*!< Transaction ID */ -} CpjCountReqInfo; - -/** - * @brief - * PDCP Count Information for a DRB. - */ -typedef struct cpjCountInfo -{ - U8 rbId; /*!< RB ID */ - U8 dir; /*!< Direction of the RB */ - U32 ulCount; /*!< UL Count value */ - U32 dlCount; /*!< DL Count value */ -} CpjCountInfo; -/** - * @brief - * PDCP Count Request Confirmation to RRC. - */ -typedef struct cpjCountCfmInfo -{ - CmLteRnti ueId; /*!< UE ID */ - CmLteCellId cellId; /*!< Cell ID */ - U32 transId; /*!< Transaction ID */ - U8 numRb; /*!< Number of DRBs */ - CpjCountInfo countInfo[CPJ_MAX_DRB]; /*!< CountInfo of DRBs */ - Status status; /*!< ROK or RFAILED */ - Reason reason; /*!< Reason for failure */ -} CpjCountCfmInfo; - -/** - * @brief - * PDCP SDU Status Request Information from RRC - Used for reestablishment - * during handover. - */ -typedef struct cpjSduStaReqInfo -{ - CmLteRnti ueId; /*!< UE ID */ - CmLteCellId cellId; /*!< Cell ID */ - U32 transId; /*!< Transaction ID */ -} CpjSduStaReqInfo; - -/** - * @brief - * PDCP UL SDU Status Information for a DRB mapped to RLC AM. - */ -typedef struct cpjUlSduStaInfo -{ - U16 numBits; /*!< Number of bits in UL bitmap */ - U8 *ulBitMap; /*!< Status Report of PDUs recieved during - re-establishment. @n - The MSB of the first octet of the type "Bitmap" - indicates whether or not the PDCP SDU with the - SN (FMS + 1) modulo 4096 is received. @n - The LSB of the first octet of the type "Bitmap" - indicates whether or not the PDCP SDU with the - SN (FMS + 8) modulo 4096 has been received - correctly. - */ - U32 count; /*!< UL Count value with First Missing - Sequence Number */ -} CpjUlSduStaInfo; - -/** - * @brief - * PDCP DL SDU Status Information for a DRB mapped to RLC AM. - */ -typedef struct cpjDlSduStaInfo -{ - U32 count; /*!< Count with the next SN to be assigned - for a SDU */ -} CpjDlSduStaInfo; - -/** - * @brief - * PDCP SDU Status Information for a DRB mapped to RLC AM. - */ -typedef struct cpjSduStaInfo -{ - U8 rbId; /*!< RB ID */ - U8 dir; /*!< Direction of the RB */ - U8 snLen; /*!< PDCP-SN length 12/15 bits */ - CpjUlSduStaInfo ulSduStaInfo; /*!< SDU Status Info for UL */ - CpjDlSduStaInfo dlSduStaInfo; /*!< SDU Status Info for DL */ -} CpjSduStaInfo; - -/** - * @brief - * PDCP SDU Status Request Confirmation for an UE. - */ -typedef struct cpjSduStaCfmInfo -{ - CmLteRnti ueId; /*!< UE ID */ - CmLteCellId cellId; /*!< Cell ID */ - U32 transId; /*!< Transaction ID */ - U8 numRb; /*!< Number of RBs */ - CpjSduStaInfo sduStaInfo[CPJ_MAX_DRB]; /*!< SDU Status Info of DRBs mapped - to RLC AM */ - Status status; /*!< ROK or RFAILED */ - Reason reason; /*!< Reason for Failure */ -} CpjSduStaCfmInfo; - -/** - * @brief - * PDCP Data Resume Request Confirmation for an UE. - */ -typedef struct cpjDatResumeCfmInfo -{ - CmLteRnti ueId; /*!< UE ID */ - CmLteCellId cellId; /*!< Cell ID */ - U32 transId; /*!< Transaction ID */ - Status status; /*!< ROK or RFAILED */ - Reason reason; /*!< Reason for Failure */ -} CpjDatResumeCfmInfo; -/********************************************************************************************************************************/ - /*START OF KEY DERIVATION FUNTION (KDF) REQUEST STRUCTURES*/ -/********************************************************************************************************************************/ - -/*AS key generation input information structure*/ -typedef struct cpjAsKeyInfo{ - U8 intgAlgoType; /*!SNOW3g or AES, used in key - derivation as well */ - U8 ciphAlgoType; /*!SNOW3g or AES, used in key - derivation as well */ - U8 secKey[CPJ_SEC_KEY_LEN]; /*!< eNodeB key received in initial - context setup */ -}CpjAsKeyInfo; - -/*Horizontal keNB derivation input information structure*/ -typedef struct cpjKenbStarInfo{ - U16 dlCarrFreq; /*!< DL UARFCN*/ - U16 physCellId; /*!< Physical cell ID*/ - U8 secKey[CPJ_SEC_KEY_LEN]; /*!< Current eNodeB key at App used to - derive keNB*. Horizontal KD */ -}CpjKenbStarInfo; - -/*Vertical keNB derivation input information structure*/ -typedef struct cpjNhKeyInfo{ - U16 dlCarrFreq; /*!< DL UARFCN*/ - U16 physCellId; /*!< Physical cell ID*/ - U8 secKey[CPJ_SEC_KEY_LEN]; /*!< NH key provided by MME used to - derive keNB*. Vertical KD */ -}CpjNhKeyInfo; - -typedef struct cpjKdfReqInfo { - U8 keyDerType; /*!< Keyderivation type: for AS security - keys/keNB* from keNB/keNB* - from NH key */ - union - { - CpjAsKeyInfo kEnbInf; /*!< eNodeB key for for deriving AS - security keys */ - CpjKenbStarInfo kEnbStarInf; /*!< eNodeB key for for deriving eNodeB* - Key (Horizontal key derivation ref: - ts 33.401) */ - CpjNhKeyInfo nhKeyInf; /*!< NH key for for deriving eNodeB* Key - (Verticall key derivation ref: - ts 33.401) */ - } u; -} CpjKdfReqInfo; - -/** - @brief Transaction ID between CPJ and User. */ -typedef struct cpjCfgTransId { - U8 trans[CPJ_CFG_TRANSID_SIZE]; /*!< User transaction ID */ -} CpjCfgTransId; - - -/********************************************************************************************************************************/ - /*END OF REQUEST STRUCTURES*/ -/********************************************************************************************************************************/ - - -/********************************************************************************************************************************/ - /*START OF KEY DERIVATION FUNTION (KDF) CONFIRM STRUCTURES*/ -/********************************************************************************************************************************/ - -/*AS key generation output information structure*/ -typedef struct cpjAskeyCfmInfo{ - U8 intKey[CPJ_SEC_KEY_LEN]; /*!< eNodeB key received in initial - context setup */ - U8 upCiphKey[CPJ_SEC_KEY_LEN]; /*!< eNodeB key received in initial - context setup */ - U8 cpCiphKey[CPJ_SEC_KEY_LEN]; /*!< eNodeB key received in initial - context setup */ -}CpjAskeyCfmInfo; - -/*Horizontal keNB derivation output information structure*/ -typedef struct cpjKenbStarCfmInfo{ - U8 secKey[CPJ_SEC_KEY_LEN]; /*!< Current eNodeB key at App used - to derive keNB*. Horizontal KD */ -}CpjKenbStarCfmInfo; - -/*Vertical keNB derivation output information structure*/ -typedef struct cpjNhKeyCfmInfo{ - U8 secKey[CPJ_SEC_KEY_LEN]; /*!< NH key provided by MME used to - derive keNB*. Vertical KD */ -}CpjNhKeyCfmInfo; - -typedef struct cpjKdfCfmInfo { - U8 keyDerType; /*!< Keyderivation type: for AS - security keys/keNB* from - keNB/keNB* from NH key */ - union - { - CpjAskeyCfmInfo kEnbInf; /*!< AS security keys */ - CpjKenbStarCfmInfo kEnbStarInf; /*!< eNodeB* Key (Horizontal key - derivation ref: ts 33.401) */ - CpjNhKeyCfmInfo nhKeyInf; /*!< eNodeB* Key (Verticall key - derivation ref: ts 33.401) */ - } u; -} CpjKdfCfmInfo; - -/************************************************************************* - * END OF STRUCTURES - ************************************************************************/ - -/************************************************************************* - * Start of Pointer Interface primitives - ************************************************************************/ -typedef S16 (*CpjBndReq) ARGS((Pst *pst, SuId suId, SpId spId)); -typedef S16 (*CpjBndCfm) ARGS((Pst *pst, SuId suId, U8 status)); -typedef S16 (*CpjUbndReq) ARGS((Pst *pst, SpId spId, Reason reason)); -typedef S16 (*CpjCfgReq) ARGS((Pst *pst, SpId spId, CpjCfgReqInfo *cfgReq)); -typedef S16 (*CpjCfgCfm) ARGS((Pst *pst, SuId suId, CpjCfgCfmInfo *cfgCfm)); -typedef S16 (*CpjReEstReq) ARGS((Pst *pst, SpId spId, CpjReEstReqInfo *reEstReq)); -typedef S16 (*CpjReEstCfm) ARGS((Pst *pst, SuId suId, CpjReEstCfmInfo *reEstCfm)); -typedef S16 (*CpjSecCfgReq) ARGS((Pst *pst, SpId spId, CpjSecCfgReqInfo *secCfgReq)); -typedef S16 (*CpjSecCfgCfm) ARGS((Pst *pst, SuId suId, CpjSecCfgCfmInfo *secCfgCfm)); -typedef S16 (*CpjUeIdChgReq) ARGS((Pst *pst, SpId spId, U32 transId, - CpjUeInfo *oldUeInfo, - CpjUeInfo *newUeInfo)); -typedef S16 (*CpjUeIdChgCfm) ARGS((Pst *pst, SuId suId, U32 transId, - CpjUeInfo *ueInfo, CmStatus status)); -typedef S16 (*CpjCountReq) ARGS((Pst *pst, SpId spId, CpjCountReqInfo *countReq)); -typedef S16 (*CpjCountCfm) ARGS((Pst *pst, SuId suId, CpjCountCfmInfo *countCfm)); -typedef S16 (*CpjSduStaReq) ARGS((Pst *pst, SpId spId, CpjSduStaReqInfo *staReq)); -typedef S16 (*CpjSduStaCfm) ARGS((Pst *pst, SuId suId, CpjSduStaCfmInfo *staCfm)); -typedef S16 (*CpjDataFwdReq) ARGS((Pst *pst, SpId spId, CpjDataFwdReqInfo *dataFwdReq)); -typedef S16 (*CpjDatResumeReq) ARGS((Pst *pst, SpId spId, CpjDatResumeReqInfo - *DatResumeReq)); -typedef S16 (*CpjDatResumeCfm) ARGS((Pst *pst, SuId suId, CpjDatResumeCfmInfo *dataResCfm)); -typedef S16 (*CpjKdfReq) ARGS(( - Pst* pst, - SpId spId, - CpjCfgTransId transId, - CpjKdfReqInfo* cfgReqInfo)); - -/* Configuration Confirm from PHY to User. */ -typedef S16 (*CpjKdfCfm) ARGS(( - Pst* pst, - SuId suId, - CpjCfgTransId transId, - CpjKdfCfmInfo* kdfCfmInfo, - U8 status)); - - -/************************************************************************* - * End of Pointer Interface primitives - ************************************************************************/ -/* cpj_x_001.main_2 */ -/************************************************************************* - * Start of Extern Interface Declarations - ************************************************************************/ -/** - * @brief Bind request primitive - * @details - * The function binds the PDCP service user entity (RRC) to the PDCP product. - * PDCP acknowledges the receipt of the bind request by sending a PjUiCpjBndCfm - * primitive. - * - * @param[in] pst - Pointer to the post structure. - * @param[in] suId - Service user ID. This is the reference number used by - * PDCP service user to identify its SAP. This reference number is - * provided by PDCP in any further primitives sent by PDCP to the service user. - * @param[in] spId - Service provider ID. This is the reference number used - * by PDCP service user to identify its SAP. This reference number is - * provided by PDCP in any further primitives sent by PDCP to the service user. - * - * @return ROK - */ -EXTERN S16 PjUiCpjBndReq ARGS((Pst *pst, SuId suId, SpId spId)); - -/** - * @brief Bind confirmation primitive - * @details - * PDCP invokes the bind confirm primitive to acknowledge the receipt of - * the PjUiCpjBndReq primitive from the RRC layer. The status field indicates - * whether the bind request succeeded or failed. The bind request may fail due - * to invalid parameters in the bind request from the service user - * (for example, an invalid spId). - * - * @param[in] pst - Pointer to the pst structure. - * @param[in] suId - Service user ID. This is the reference number used - * by PDCP service user (RRC layer) to identify its SAP. - * @param[in] status - Status field indicates whether the bind request - * succeeded or failed. - * -# TRUE, for successful bind. - * -# FALSE, otherwise. - * - * @return ROK. - */ -EXTERN S16 PjUiCpjBndCfm ARGS((Pst *pst, SuId suId, U8 status)); - -/** - * @brief Unbind request primitive - * @details - * The PDCP service user (RRC) initiates this primitive for performing - * an unbind operation. This function brings the link between RRC and PDCP - * down if it is already up, and releases all the resources associated for - * this SAP at PDCP. - * - * @param[in] pst - Pointer to the post structure. - * @param[in] spId - Service provider ID. This is the reference number used - * by PDCP to identify its SAP. - * @param[in] reason - Unbind reason. Not used in the current implementation. - * - * @return ROK - */ -EXTERN S16 PjUiCpjUbndReq ARGS((Pst *pst, SpId spId, Reason reason)); - -/** - * @brief Configuration request primitive - * @details - * RRC uses this primitive to configure PDCP system parameters. The - * various parameters are configured by RRC. In one configuration request, - * multiple PDCP entities can be configured based on the rbId. - * For PDCP on target eNB, RRC can configure the handover information. - * - * @param[in] pst - Pointer to post structure. - * @param[in] spId - Service provider ID. This is the reference number used - * by PDCP to identify its SAP. - * @param[in] pdcpCfg - PDCP configuration structure. - * - * @return ROK - */ -EXTERN S16 PjUiCpjCfgReq ARGS((Pst *pst, SpId spId, CpjCfgReqInfo *cfgReq)); - -/** - * @brief Configuration confirmation primitive - * @details - * This primitive is invoked by PDCP to inform to PDCP User (RRC) about - * the PDCP configuration request primitive execution status. - * - * @param[in] pst - Pointer to the post structure. - * @param[in] suId - Service user ID. This is the reference number used - * by PDCP to identify its SAP. - * @param[in] pdcpCfgCfm - PDCP configuration confirm structure. - * - * @return ROK - */ -EXTERN S16 PjUiCpjCfgCfm ARGS((Pst *pst, SuId suId, CpjCfgCfmInfo *cfgCfm)); - -/** - * @brief Reestablishment request primtive - * @details - * RRC uses this primitive to reestablish the PDCP entity. - * This primitive is initiation of reestablishment procedure. - * This prmitive and corresponding confirmation are followed by - * PjUiCpjCfgReq procedure for entire reestablishment procedure to complete. - * - * @param[in] pst - Pointer to post structure. - * @param[in] spId - Service provider ID. This is the reference number used by - * PDCP to identify its SAP. - * @param[in] reEstReq - PDCP reestablishment request structure. - * - */ -EXTERN S16 PjUiCpjReEstReq ARGS((Pst *pst, SpId spId, CpjReEstReqInfo *reEstReq)); - -/** - * @brief Reestablishment confirmation primitive - * @details - * This primitive is invoked by PDCP to inform PDCP User (RRC) about the PDCP - * (SRB1) reestablishment request primitive execution status. - * - * @param[in] pst - Pointer to the post structure. - * @param[in] suId - Service user ID. This is the reference number used - * by PDCP to identify its SAP. - * @param[in] reEstCfm - PDCP reestablishment confirm structure. - * - */ -EXTERN S16 PjUiCpjReEstCfm ARGS((Pst *pst, SuId suId, CpjReEstCfmInfo *reEstCfm)); - -/** - * @brief Security Configuration request primitive - * @details - * RRC uses this primitive to configure PDCP security parameters. - * Integrity protection and/or Ciphering are configured by RRC based on the - * selSecAct flag. Integrity Protection/Ciphering are configured per UE and applicable - * to all PDCP entities in that UE. Both Integrity protection and ciphering are - * configured during reestablishment. - * - * @param[in] pst - Pointer to post structure. - * @param[in] spId - Service provider ID. This is the reference number used by - * PDCP to identify its SAP. - * @param[in] pdcpSecCfg - PDCP security configuration structure. - * - * @return ROK - */ -EXTERN S16 PjUiCpjSecCfgReq ARGS((Pst *pst, SpId spId, - CpjSecCfgReqInfo *secCfgReq)); - -/** - * @brief Security Configuration confirmation primitive. - * @details - * This primitive is invoked by PDCP to inform to PDCP User (RRC) about - * the PDCP secutiry configuration request primitive execution status. - * - * @param[in] pst - Pointer to the post structure. - * @param[in] suId - Service user ID. This is the reference number used - * by PDCP to identify its SAP. - * @param[in] pdcpSecCfgCfm - PDCP configuration confirm structure. - * - * @return ROK - */ -EXTERN S16 PjUiCpjSecCfgCfm ARGS( (Pst *pst, SuId suId, - CpjSecCfgCfmInfo *secCfgCfm)); - -/** - * @brief UE ID change request primitive - * @details - * This primitive is used by RRC to change the UeId for the existing UE context. - * - * @param[in] pst - Point to the post structure - * @param[in] spId - The ID of the service provider SAP in the PDCP layer. - * @param[in] transId - Transaction ID. This field uniquely identifies - * transaction between RRC and PDCP. - * @param[in] oldUeInfo - Old UE ID info for which the change request has come. - * @param[in] newUeInfo - New UE ID info for existing UE context. - * - * @return ROK - */ -EXTERN S16 PjUiCpjUeIdChgReq ARGS((Pst *pst, SpId spId, U32 transId, - CpjUeInfo *oldUeInfo, CpjUeInfo *newUeInfo)); - -/** - * @brief UE ID change confirmation primitive - * @details - * This primitive is used by PDCP to confirm the UeId change requested by RRC. - * The different values for status are:\n - * ROK - Success\n - * RFAILED - Failure\n - * - * The different reasons for the failure are: - * CPJ_CFG_REAS_UE_CREAT_FAIL - UE Cb update failure \n - * CPJ_CFG_REAS_UE_UNKWN - Request received for an unknown UE ID. - * - * @param [in] pst - Point to the post structure. - * @param [in] suId - The ID of the service user SAP associated with PDCP - * @param [in] transId - Transaction ID. This field uniquely identifies - * transaction between RRC and PDCP. - * @param [in] ueInfo - UE Identity which is changed with the new ID - * for the same context. - * @param [in] CmStatus - Confirmation status with appropriate reason - * information. - * @return ROK - */ -EXTERN S16 PjUiCpjUeIdChgCfm ARGS((Pst *pst, SuId suId, U32 transId, - CpjUeInfo *ueInfo, CmStatus status)); - -/** - * @brief Count request primitive - * @details - * RRC uses this primitive to request count value for all DRBs in a UE. - * PDCP sends the UL and DL count values in the confirmation of this request. - * - * @param[in] pst - Pointer to post structure. - * @param[in] spId - Service provider ID. This is the reference number used - * by PDCP to identify its SAP. - * @param[in] countReq - PDCP Count Request Information. - * - * @return ROK - */ -EXTERN S16 PjUiCpjCountReq ARGS((Pst *pst, SpId spId, CpjCountReqInfo *countReq)); - -/** - * @brief Count confirmation primitive - * @details - * PDCP uses this primitive to send the count values for all - * DRBs in a UE to RRC. PDCP sends the RB ID, direction - * and count value(s) ( UL, DL or both based on direction of the RB) - * for each DRB. - * - * @param[in] pst - Pointer to post structure. - * @param[in] suId - The ID of the service user SAP associated with PDCP. - * @param[in] countCfm - PDCP Count Confirmation Info. - * - * @return ROK -*/ -EXTERN S16 PjUiCpjCountCfm ARGS((Pst *pst, SuId suId, CpjCountCfmInfo *countCfm)); - -/** - * @brief SDU Status Request primitive - * @details - * RRC uses this primitive to request the status of the SDUs for DRBs in an UE. - * Its used as a reestablishment request during handover. - * This primitive is used to forward the handover control Information to the target - * eNodeB. - * - * @param[in] pst - Pointer to post structure. - * @param[in] spId - Service provider ID. This is the reference number used - * by PDCP to identify its SAP. - * @param[in] sduStaReq - PDCP SDU Status Request Information. - * - * @return ROK - */ -EXTERN S16 PjUiCpjSduStaReq ARGS((Pst *pst, SpId spId, CpjSduStaReqInfo *staReq)); - -/** - * @brief SDU Status confirmation primitive - * @details - * PDCP uses this primitive to send the SDU status for the DRBs in - * the requested UE. PDCP sends the RB ID, direction of the RB,status report - * and count(to indicate the first missing SN) in UL and count(to indicate - * the next SN to be assigned) in DL for each requested DRB mapped on to RLC AM. - * - * @param[in] pst - Pointer to post structure. - * @param[in] suId - The ID of the service user SAP associated with PDCP. - * @param[in] sduStaCfm - PDCP SDU Status Confirmation Info. - * - * @return ROK -*/ -EXTERN S16 PjUiCpjSduStaCfm ARGS((Pst *pst, SuId suId, CpjSduStaCfmInfo *staCfm)); - -#ifdef FLAT_BUFFER_OPT -EXTERN S16 PjUiCpjDatResumeReqFB ARGS((Pst *pst, SpId spId, CpjDatResumeReqInfo - *dataResReq)); - -EXTERN S16 PjUiCpjDatForwardReqFB ARGS(( Pst *pst, SpId spId, - CpjDataFwdReqInfo *dataFwdReq)); -#endif - - -EXTERN S16 PjUiCpjDatResumeReq ARGS((Pst *pst, SpId spId, CpjDatResumeReqInfo - *dataResReq)); - -EXTERN S16 PjUiCpjDatForwardReq ARGS(( Pst *pst, SpId spId, - CpjDataFwdReqInfo *dataFwdReq)); - -EXTERN S16 PjUiCpjDatResumeCfm ARGS(( Pst *pst, SuId suId, CpjDatResumeCfmInfo - *datResCfm)); -/** -* @brief This API is used to receive a Bind confirm from PDCP to Application. -* -* @details -* -* @param[in] pst - Post structure -* @param[in] suId - Service User Id -* @param[in] transId - Transaction Id -* @param[in] kdfCfmInf - Generated keys -* @param[in] status - status of KDF request -* @return S16 -* -# ROK -**/ -EXTERN S16 PjUiCpjKdfCfm ARGS (( -Pst* pst, -SuId suId, -CpjCfgTransId transId, -CpjKdfCfmInfo *kdfCfmInf, -U8 status -)); - -EXTERN S16 PjUiCpjKdfReq ARGS(( -Pst* pst, -SpId spId, -CpjCfgTransId transId, -CpjKdfReqInfo *kdfReqInfo -)); - -EXTERN S16 cmPkCpjKdfReq ARGS(( - Pst* pst, - SpId spId, - CpjCfgTransId transId, - CpjKdfReqInfo *kdfReqInfo -)); -/* Configuration Request from User to PHY for - * cell or dedicated configuration. -*/ -EXTERN S16 cmUnpkCpjKdfReq ARGS(( - CpjKdfReq func, - Pst* pst, - Buffer *mBuf -)); -/* Configuration Confirm from PHY to User. */ -EXTERN S16 cmPkCpjKdfCfm ARGS(( - Pst* pst, - SuId suId, - CpjCfgTransId transId, - CpjKdfCfmInfo *kdfCfmInfo, - U8 status -)); -/* Configuration Confirm from PHY to User. */ -EXTERN S16 cmUnpkCpjKdfCfm ARGS(( - CpjKdfCfm func, - Pst* pst, - Buffer *mBuf -)); - - -/************ Dummy Extern interface primitives ***********************/ -#ifdef DM -EXTERN S16 DmUiCpjBndReq ARGS((Pst *, SuId, SpId)); - -EXTERN S16 DmUiCpjUbndReq ARGS((Pst *, SpId, Reason)); - -EXTERN S16 DmUiCpjBndCfm ARGS((Pst *, SuId, U8)); - -EXTERN S16 DmUiCpjCfgReq ARGS( (Pst *, SpId , CpjCfgReqInfo *)); - -EXTERN S16 DmUiCpjCfgCfm ARGS( (Pst *, SuId , CpjCfgCfmInfo *)); - -EXTERN S16 DmUiCpjSecCfgReq ARGS((Pst *, SpId ,CpjSecCfgReqInfo *)); - -EXTERN S16 DmUiCpjSecCfgCfm ARGS((Pst *, SuId ,CpjSecCfgCfmInfo *)); - -EXTERN S16 DmUiCpjUeIdChgReq ARGS( (Pst *, SpId , U32, CpjUeInfo *, CpjUeInfo *)); - -EXTERN S16 DmUiCpjUeIdChgCfm ARGS( (Pst *, SuId , U32, CpjUeInfo *, CmStatus)); - -EXTERN S16 DmUiCpjReEstReq ARGS((Pst *, SpId , CpjReEstReqInfo *)); - -EXTERN S16 DmUiCpjReEstCfm ARGS (( Pst *, SuId , CpjReEstCfmInfo *)); - -EXTERN S16 DmUiCpjCountReq ARGS((Pst *, SpId ,CpjCountReqInfo *)); - -EXTERN S16 DmUiCpjCountCfm ARGS((Pst *, SuId ,CpjCountCfmInfo *)); - -EXTERN S16 DmUiCpjSduStaReq ARGS((Pst *, SpId ,CpjSduStaReqInfo *)); - -EXTERN S16 DmUiCpjStartDataFwdReq ARGS((Pst *, SpId ,CpjDataFwdReqInfo *)); - -EXTERN S16 DmUiCpjDatResumeReq ARGS((Pst *, SpId ,CpjDatResumeReqInfo *)); - -EXTERN S16 DmUiCpjSduStaCfm ARGS((Pst *, SuId ,CpjSduStaCfmInfo *)); - -EXTERN S16 DmUiCpjDatForwardReq ARGS((Pst *,SpId ,CpjDataFwdReqInfo *)); - - -#endif - -/************ LTE RRC Extern interface primitives ***********************/ -#ifdef NH /* LTE-RRC */ -EXTERN S16 NhLiCpjBndReq ARGS((Pst *, SuId, SpId)); - -EXTERN S16 NhLiCpjUbndReq ARGS((Pst *, SpId, Reason)); - -EXTERN S16 NhLiCpjBndCfm ARGS((Pst *, SuId, U8)); - -EXTERN S16 NhLiCpjCfgReq ARGS( (Pst *, SpId , CpjCfgReqInfo *)); - -EXTERN S16 NhLiCpjCfgCfm ARGS( (Pst *, SuId , CpjCfgCfmInfo *)); - -EXTERN S16 NhLiCpjSecCfgReq ARGS((Pst *, SpId , CpjSecCfgReqInfo *)); - -EXTERN S16 NhLiCpjSecCfgCfm ARGS((Pst *, SuId , CpjSecCfgCfmInfo *)); - -EXTERN S16 NhLiCpjUeIdChgReq ARGS( (Pst *, SpId , U32 , CpjUeInfo *, CpjUeInfo *)); - -EXTERN S16 NhLiCpjUeIdChgCfm ARGS( (Pst *, SuId , U32, CpjUeInfo *, CmStatus)); - -EXTERN S16 NhLiCpjReEstReq ARGS((Pst *pst, SpId spId, CpjReEstReqInfo *reEstReq)); - -EXTERN S16 NhLiCpjReEstCfm ARGS (( Pst *pst, SuId suId, CpjReEstCfmInfo *cfmInfo)); - -EXTERN S16 NhLiCpjCountReq ARGS((Pst *, SpId , CpjCountReqInfo *)); - -EXTERN S16 NhLiCpjCountCfm ARGS((Pst *, SuId , CpjCountCfmInfo *)); - -EXTERN S16 NhLiCpjSduStaReq ARGS((Pst *, SpId , CpjSduStaReqInfo *)); - -EXTERN S16 NhLiCpjSduStaCfm ARGS((Pst *, SuId , CpjSduStaCfmInfo *)); - -EXTERN S16 NhLiCpjDatResumeCfm ARGS((Pst *, SuId , CpjDatResumeCfmInfo *)); - -EXTERN S16 NhLiCpjStartDataFwdReq ARGS((Pst *post, SpId spId, CpjDataFwdReqInfo - *pdcpDataFwdReq )); -EXTERN S16 NhLiCpjDatResumeReq ARGS((Pst *post, SpId spId, CpjDatResumeReqInfo - *pdcpDatResumeReq )); -#endif -/************************************************************************* - * End of Extern Interface Declarations * - ************************************************************************/ - -/*********************************************************************** - * Start of pack/unpack functions * - * *********************************************************************/ -#ifdef LCCPJ - -PUBLIC S16 cmPkCpjBndReq ARGS(( -Pst * pst, -SuId suId, -SpId spId -)); -PUBLIC S16 cmUnpkCpjBndReq ARGS(( -CpjBndReq func, -Pst *pst, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjBndCfm ARGS(( -Pst * pst, -SuId suId, -U8 status -)); -PUBLIC S16 cmUnpkCpjBndCfm ARGS(( -CpjBndCfm func, -Pst *pst, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjUbndReq ARGS(( -Pst * pst, -SpId spId, -Reason reason -)); -PUBLIC S16 cmUnpkCpjUbndReq ARGS(( -CpjUbndReq func, -Pst *pst, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjCfgReq ARGS(( -Pst * pst, -SpId spId, -CpjCfgReqInfo * cfgReq -)); -PUBLIC S16 cmUnpkCpjCfgReq ARGS(( -CpjCfgReq func, -Pst *pst, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjCfgCfm ARGS(( -Pst * pst, -SuId suId, -CpjCfgCfmInfo * cfgCfm -)); -PUBLIC S16 cmUnpkCpjCfgCfm ARGS(( -CpjCfgCfm func, -Pst *pst, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjReEstReq ARGS(( -Pst * pst, -SpId spId, -CpjReEstReqInfo * reEstReq -)); -PUBLIC S16 cmUnpkCpjReEstReq ARGS(( -CpjReEstReq func, -Pst *pst, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjReEstCfm ARGS(( -Pst * pst, -SuId suId, -CpjReEstCfmInfo * reEstCfm -)); -PUBLIC S16 cmUnpkCpjReEstCfm ARGS(( -CpjReEstCfm func, -Pst *pst, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjSecCfgReq ARGS(( -Pst * pst, -SpId spId, -CpjSecCfgReqInfo * secCfgReq -)); -PUBLIC S16 cmUnpkCpjSecCfgReq ARGS(( -CpjSecCfgReq func, -Pst *pst, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjSecCfgCfm ARGS(( -Pst * pst, -SuId suId, -CpjSecCfgCfmInfo * secCfgCfm -)); -PUBLIC S16 cmUnpkCpjSecCfgCfm ARGS(( -CpjSecCfgCfm func, -Pst *pst, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjUeIdChgReq ARGS(( -Pst * pst, -SpId spId, -U32 transId, -CpjUeInfo * oldUeInfo, -CpjUeInfo * newUeInfo -)); -PUBLIC S16 cmUnpkCpjUeIdChgReq ARGS(( -CpjUeIdChgReq func, -Pst *pst, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjUeIdChgCfm ARGS(( -Pst * pst, -SuId suId, -U32 transId, -CpjUeInfo * ueInfo, -CmStatus status -)); -PUBLIC S16 cmUnpkCpjUeIdChgCfm ARGS(( -CpjUeIdChgCfm func, -Pst *pst, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjCountReq ARGS(( -Pst * pst, -SpId spId, -CpjCountReqInfo * countReq -)); -PUBLIC S16 cmUnpkCpjCountReq ARGS(( -CpjCountReq func, -Pst *pst, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjCountCfm ARGS(( -Pst * pst, -SuId suId, -CpjCountCfmInfo * countCfm -)); -PUBLIC S16 cmUnpkCpjCountCfm ARGS(( -CpjCountCfm func, -Pst *pst, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjSduStaReq ARGS(( -Pst * pst, -SpId spId, -CpjSduStaReqInfo * staReq -)); -PUBLIC S16 cmUnpkCpjSduStaReq ARGS(( -CpjSduStaReq func, -Pst *pst, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjStartDataFwdReq ARGS(( -Pst * pst, -SpId spId, -CpjDataFwdReqInfo * dataFwdReq -)); -PUBLIC S16 cmUnpkCpjStartDataFwdReq ARGS(( -CpjDataFwdReq func, -Pst *pst, -Buffer *mBuf -)); - -PUBLIC S16 cmPkCpjDatResumeReq ARGS(( -Pst * pst, -SpId spId, -CpjDatResumeReqInfo * dataFwdReq -)); - -PUBLIC S16 cmUnpkCpjDatResumeReq ARGS(( -CpjDatResumeReq func, -Pst *pst, -Buffer *mBuf -)); - -PUBLIC S16 cmPkCpjSduStaCfm ARGS(( -Pst * pst, -SuId suId, -CpjSduStaCfmInfo * staCfm -)); -PUBLIC S16 cmUnpkCpjSduStaCfm ARGS(( -CpjSduStaCfm func, -Pst *pst, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjRlcAm ARGS(( -CpjRlcAm *param, -Buffer *mBuf -)); -PUBLIC S16 cmUnpkCpjRlcAm ARGS(( -CpjRlcAm *param, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjRlcUm ARGS(( -CpjRlcUm *param, -Buffer *mBuf -)); -PUBLIC S16 cmUnpkCpjRlcUm ARGS(( -CpjRlcUm *param, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjRlcInfo ARGS(( -CpjRlcInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmUnpkCpjRlcInfo ARGS(( -CpjRlcInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjCipherInfo ARGS(( -CpjCipherInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmUnpkCpjCipherInfo ARGS(( -CpjCipherInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjIntegInfo ARGS(( -CpjIntegInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmUnpkCpjIntegInfo ARGS(( -CpjIntegInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjSecCfg ARGS(( -CpjSecCfg *param, -Buffer *mBuf -)); -PUBLIC S16 cmUnpkCpjSecCfg ARGS(( -CpjSecCfg *param, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjRohcInfo ARGS(( -CpjRohcInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmUnpkCpjRohcInfo ARGS(( -CpjRohcInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjHdrCompCfg ARGS(( -CpjHdrCompCfg *param, -Buffer *mBuf -)); -PUBLIC S16 cmUnpkCpjHdrCompCfg ARGS(( -CpjHdrCompCfg *param, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjHoInfo ARGS(( -Pst *pst, -CpjHoInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmUnpkCpjHoInfo ARGS(( -Pst *pst, -CpjHoInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjCfgEnt ARGS(( -Pst *pst, -CpjCfgEnt *param, -Buffer *mBuf -)); -PUBLIC S16 cmUnpkCpjCfgEnt ARGS(( -Pst *pst, -CpjCfgEnt *param, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjAddCfgEnt ARGS(( -CpjAddCfgEnt *param, -Buffer *mBuf -)); -PUBLIC S16 cmUnpkCpjAddCfgEnt ARGS(( -CpjAddCfgEnt *param, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjModCfgEnt ARGS(( -Pst *pst, -CpjModCfgEnt *param, -Buffer *mBuf -)); -PUBLIC S16 cmUnpkCpjModCfgEnt ARGS(( -Pst *pst, -CpjModCfgEnt *param, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjCfgReqInfo ARGS(( -Pst *pst, -CpjCfgReqInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmUnpkCpjCfgReqInfo ARGS(( -Pst *pst, -CpjCfgReqInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjCfmEnt ARGS(( -CpjCfmEnt *param, -Buffer *mBuf -)); -PUBLIC S16 cmUnpkCpjCfmEnt ARGS(( -CpjCfmEnt *param, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjCfgCfmInfo ARGS(( -CpjCfgCfmInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmUnpkCpjCfgCfmInfo ARGS(( -CpjCfgCfmInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjReEstReqInfo ARGS(( -CpjReEstReqInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmUnpkCpjReEstReqInfo ARGS(( -CpjReEstReqInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjReEstCfmInfo ARGS(( -CpjReEstCfmInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmUnpkCpjReEstCfmInfo ARGS(( -CpjReEstCfmInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjSecCfgReqInfo ARGS(( -CpjSecCfgReqInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmUnpkCpjSecCfgReqInfo ARGS(( -CpjSecCfgReqInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjSecCfgCfmInfo ARGS(( -CpjSecCfgCfmInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmUnpkCpjSecCfgCfmInfo ARGS(( -CpjSecCfgCfmInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjUeInfo ARGS(( -CpjUeInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmUnpkCpjUeInfo ARGS(( -CpjUeInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjCountReqInfo ARGS(( -CpjCountReqInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmUnpkCpjCountReqInfo ARGS(( -CpjCountReqInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjCountInfo ARGS(( -CpjCountInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmUnpkCpjCountInfo ARGS(( -CpjCountInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjCountCfmInfo ARGS(( -CpjCountCfmInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmUnpkCpjCountCfmInfo ARGS(( -CpjCountCfmInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjSduStaReqInfo ARGS(( -CpjSduStaReqInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmUnpkCpjSduStaReqInfo ARGS(( -CpjSduStaReqInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjStartDataFwdReqInfo ARGS(( -CpjDataFwdReqInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmUnpkCpjStartDataFwdReqInfo ARGS(( -CpjDataFwdReqInfo *param, -Buffer *mBuf -)); - -PUBLIC S16 cmPkCpjDatResumeReqInfo ARGS(( -CpjDatResumeReqInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmUnpkCpjDatResumeReqInfo ARGS(( -CpjDatResumeReqInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjUlSduStaInfo ARGS(( -Pst *pst, -CpjUlSduStaInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmUnpkCpjUlSduStaInfo ARGS(( -Pst *pst, -CpjUlSduStaInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjDlSduStaInfo ARGS(( -CpjDlSduStaInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmUnpkCpjDlSduStaInfo ARGS(( -CpjDlSduStaInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjSduStaInfo ARGS(( -Pst *pst, -CpjSduStaInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmUnpkCpjSduStaInfo ARGS(( -Pst *pst, -CpjSduStaInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmPkCpjSduStaCfmInfo ARGS(( -Pst *pst, -CpjSduStaCfmInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmUnpkCpjSduStaCfmInfo ARGS(( -Pst *pst, -CpjSduStaCfmInfo *param, -Buffer *mBuf -)); -PUBLIC S16 cmUnpkCpjDatResumeCfmInfo ARGS(( -Pst *pst, -CpjDatResumeCfmInfo *param, -Buffer *mBuf -)); - -PUBLIC S16 cmPkCpjDataResCfmInfo ARGS(( -Pst *pst, -CpjDatResumeCfmInfo *param, -Buffer *mBuf -)); - -PUBLIC S16 cmUnpkCpjDatResumeCfm ARGS(( -CpjDatResumeCfm func, -Pst *pst, -Buffer *mBuf -)); - -PUBLIC S16 cmPkCpjDatResumeCfm ARGS(( -Pst * pst, -SuId suId, -CpjDatResumeCfmInfo * dataResCfm -)); - -PUBLIC S16 cmUnpkCpjDatResumeCfm ARGS(( -CpjDatResumeCfm func, -Pst *pst, -Buffer *mBuf -)); - -PUBLIC S16 cmUnpkCpjNhKeyCfmInfo ARGS(( -CpjNhKeyCfmInfo *param, -Buffer *mBuf -)); - -PUBLIC S16 cmUnpkCpjKenbStarCfmInfo ARGS(( -CpjKenbStarCfmInfo *param, -Buffer *mBuf -)); - -PUBLIC S16 cmUnpkCpjAskeyCfmInfo ARGS(( -CpjAskeyCfmInfo *param, -Buffer *mBuf -)); - -PUBLIC S16 cmUnpkCpjKdfCfmInfo ARGS(( -CpjKdfCfmInfo *param, -Buffer *mBuf -)); - -PUBLIC S16 cmUnpkCpjCfgTransId ARGS(( -CpjCfgTransId *param, -Buffer *mBuf -)); - -PUBLIC S16 cmPkCpjNhKeyInfo ARGS(( -CpjNhKeyInfo *param, -Buffer *mBuf -)); - -PUBLIC S16 cmPkCpjKenbStarInfo ARGS(( -CpjKenbStarInfo *param, -Buffer *mBuf -)); - -PUBLIC S16 cmPkCpjAskeyInfo ARGS(( -CpjAsKeyInfo *param, -Buffer *mBuf -)); - -PUBLIC S16 cmPkCpjKdfReqInfo ARGS(( -CpjKdfReqInfo *param, -Buffer *mBuf -)); - -PUBLIC S16 cmPkCpjCfgTransId ARGS(( -CpjCfgTransId *param, -Buffer *mBuf -)); - -PUBLIC S16 cmUnpkCpjNhKeyInfo ARGS(( -CpjNhKeyInfo *param, -Buffer *mBuf -)); - -PUBLIC S16 cmUnpkCpjKenbStarInfo ARGS(( -CpjKenbStarInfo *param, -Buffer *mBuf -)); - -PUBLIC S16 cmUnpkCpjAskeyInfo ARGS(( -CpjAsKeyInfo *param, -Buffer *mBuf -)); - -PUBLIC S16 cmUnpkCpjKdfReqInfo ARGS(( -CpjKdfReqInfo *param, -Buffer *mBuf -)); - -PUBLIC S16 cmPkCpjNhKeyCfmInfo ARGS(( -CpjNhKeyCfmInfo *param, -Buffer *mBuf -)); - -PUBLIC S16 cmPkCpjKenbStarCfmInfo ARGS(( -CpjKenbStarCfmInfo *param, -Buffer *mBuf -)); - -PUBLIC S16 cmPkCpjAskeyCfmInfo ARGS(( -CpjAskeyCfmInfo *param, -Buffer *mBuf -)); - -PUBLIC S16 cmPkCpjKdfCfmInfo ARGS(( -CpjKdfCfmInfo *param, -Buffer *mBuf -)); - -#endif - -/*********************************************************************** - * End of pack/unpack functions * - * *********************************************************************/ - -#ifdef __cplusplus -} -#endif /* __cplusplus */ -#endif /* __CPJ_X__ */ - -/********************************************************************30** - - End of file -**********************************************************************/ diff --git a/src/cm/crg.c b/src/cm/crg.c new file mode 100755 index 000000000..9d2dc3a19 --- /dev/null +++ b/src/cm/crg.c @@ -0,0 +1,2307 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + + +/************************************************************************ + + Name: LTE-MAC layer + + Type: C source file + + Desc: C source code for pack/unpack of CRG interface primitives. + + File: crg.c + +**********************************************************************/ + +/** @file crg.c +@brief This file contains the packing/unpacking code for the CRG interface + primitives. +*/ +/* header include files (.h) */ +#include "envopt.h" /* environment options */ +#include "envdep.h" /* environment dependent */ +#include "envind.h" /* environment independent */ +#include "gen.h" /* general */ +#include "ssi.h" /* system services */ +#include "cm_tkns.h" /* Common Token Defines */ +#include "cm_llist.h" /* Common Link List Defines */ +#include "cm_hash.h" /* Common Hash List Defines */ +#include "cm_lte.h" /* Common LTE Defines */ +#include "crg.h" /* CRG Interface defines */ + +/* header/extern include files (.x) */ +#include "gen.x" /* general */ +#include "ssi.x" /* system services */ +#include "cm_tkns.x" /* Common Token Definitions */ +#include "cm_llist.x" /* Common Link List Definitions */ +#include "cm_lib.x" /* Common Library Definitions */ +#include "cm_hash.x" /* Common Hash List Definitions */ +#include "cm_lte.x" /* Common LTE Defines */ +#include "crg.x" /* CRG Interface includes */ + + +#ifdef LCCRG + +/** +* @brief Request from RRC to MAC to bind the interface saps +* +* @details +* +* Function : cmPkCrgBndReq +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] SpId spId +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkCrgBndReq +( +Pst* pst, +SuId suId, +SpId spId +) +#else +PUBLIC S16 cmPkCrgBndReq(pst, suId, spId) +Pst* pst; +SuId suId; +SpId spId; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkCrgBndReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECRG001, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECRG002, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECRG003, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + pst->event = (Event) EVTCRGBNDREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief Request from RRC to MAC to bind the interface saps +* +* @details +* +* Function : cmUnpkCrgBndReq +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] SpId spId +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkCrgBndReq +( +CrgBndReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCrgBndReq(func, pst, mBuf) +CrgBndReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + SpId spId; + + TRC3(cmUnpkCrgBndReq) + + if (SUnpkS16(&suId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECRG004, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SUnpkS16(&spId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECRG005, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, suId, spId)); +} + + +/** +* @brief Confirmation from MAC to RRC for the bind/Unbind + * request for the interface saps +* +* @details +* +* Function : cmPkCrgBndCfm +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] U8 status +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkCrgBndCfm +( +Pst* pst, +SuId suId, +U8 status +) +#else +PUBLIC S16 cmPkCrgBndCfm(pst, suId, status) +Pst* pst; +SuId suId; +U8 status; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkCrgBndCfm) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECRG006, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SPkU8(status, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECRG007, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECRG008, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + pst->event = (Event) EVTCRGBNDCFM; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief Confirmation from MAC to RRC for the bind/Unbind + * request for the interface saps +* +* @details +* +* Function : cmUnpkCrgBndCfm +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] U8 status +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkCrgBndCfm +( +CrgBndCfm func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCrgBndCfm(func, pst, mBuf) +CrgBndCfm func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + U8 status; + + TRC3(cmUnpkCrgBndCfm) + + if (SUnpkS16(&suId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECRG009, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SUnpkU8(&status, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECRG010, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, suId, status)); +} + + +/** +* @brief Request from RRC to MAC to Unbind the interface saps +* +* @details +* +* Function : cmPkCrgUbndReq +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] Reason reason +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkCrgUbndReq +( +Pst* pst, +SpId spId, +Reason reason +) +#else +PUBLIC S16 cmPkCrgUbndReq(pst, spId, reason) +Pst* pst; +SpId spId; +Reason reason; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkCrgUbndReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECRG011, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SPkS16(reason, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECRG012, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECRG013, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + pst->event = (Event) EVTCRGUBNDREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief Request from RRC to MAC to Unbind the interface saps +* +* @details +* +* Function : cmUnpkCrgUbndReq +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] Reason reason +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkCrgUbndReq +( +CrgUbndReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCrgUbndReq(func, pst, mBuf) +CrgUbndReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SpId spId; + Reason reason; + + TRC3(cmUnpkCrgUbndReq) + + if (SUnpkS16(&spId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECRG014, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SUnpkS16(&reason, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECRG015, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, spId, reason)); +} + + +/** +* @brief Configuration Request from RRC to MAC for + * configuring Cell/Ue/Lc +* +* @details +* +* Function : cmPkCrgCfgReq +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] CrgCfgTransId transId +* @param[in] CrgCfgReqInfo * cfgReqInfo +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkCrgCfgReq +( +Pst* pst, +SpId spId, +CrgCfgTransId transId, +CrgCfgReqInfo * cfgReqInfo +) +#else +PUBLIC S16 cmPkCrgCfgReq(pst, spId, transId, cfgReqInfo) +Pst* pst; +SpId spId; +CrgCfgTransId transId; +CrgCfgReqInfo * cfgReqInfo; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkCrgCfgReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECRG016, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo, sizeof(CrgCfgReqInfo)); + RETVALUE(RFAILED); + } + if (cmPkCrgCfgReqInfo(cfgReqInfo, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECRG017, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo, sizeof(CrgCfgReqInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } +/* crg_c_001.main_5: MOD - Updating ERR code */ + if (cmPkCrgCfgTransId(&transId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECRG018, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo, sizeof(CrgCfgReqInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECRG019, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo, sizeof(CrgCfgReqInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo, sizeof(CrgCfgReqInfo)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECRG020, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + pst->event = (Event) EVTCRGCFGREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief Configuration Request from RRC to MAC for + * configuring Cell/Ue/Lc +* +* @details +* +* Function : cmUnpkCrgCfgReq +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] CrgCfgTransId transId +* @param[in] CrgCfgReqInfo * cfgReqInfo +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkCrgCfgReq +( +CrgCfgReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCrgCfgReq(func, pst, mBuf) +CrgCfgReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SpId spId; + CrgCfgTransId transId; + CrgCfgReqInfo *cfgReqInfo; + + TRC3(cmUnpkCrgCfgReq) + + if (SUnpkS16(&spId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECRG021, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (cmUnpkCrgCfgTransId(&transId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECRG022, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if ((SGetSBuf(pst->region, pst->pool, (Data **)&cfgReqInfo, sizeof(CrgCfgReqInfo))) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECRG023, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (cmUnpkCrgCfgReqInfo(cfgReqInfo, mBuf) != ROK) { + SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo, sizeof(CrgCfgReqInfo)); + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECRG024, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, spId, transId, cfgReqInfo)); +} + + +/** +* @brief Configuration Confirm from MAC to RRC +* +* @details +* +* Function : cmPkCrgCfgCfm +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] CrgCfgTransId transId +* @param[in] U8 status +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkCrgCfgCfm +( +Pst* pst, +SuId suId, +CrgCfgTransId transId, +U8 status +) +#else +PUBLIC S16 cmPkCrgCfgCfm(pst, suId, transId, status) +Pst* pst; +SuId suId; +CrgCfgTransId transId; +U8 status; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkCrgCfgCfm) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECRG025, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } +/* crg_c_001.main_5 - ADD - Added the packing for status. */ + if (SPkU8(status, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECRG026, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (cmPkCrgCfgTransId(&transId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECRG027, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECRG028, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + pst->event = (Event) EVTCRGCFGCFM; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief Configuration Confirm from MAC to RRC +* +* @details +* +* Function : cmUnpkCrgCfgCfm +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] CrgCfgTransId transId +* @param[in] U8 status +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkCrgCfgCfm +( +CrgCfgCfm func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCrgCfgCfm(func, pst, mBuf) +CrgCfgCfm func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + CrgCfgTransId transId; + U8 status; + + TRC3(cmUnpkCrgCfgCfm) + + if (SUnpkS16(&suId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECRG029, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (cmUnpkCrgCfgTransId(&transId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECRG030, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SUnpkU8(&status, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECRG031, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, suId, transId, status)); +} + + +/*********************************************************** +* +* Func : cmPkCrgCfgTransId +* +* +* Desc : Transaction ID between MAC and RRC +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCrgCfgTransId +( +CrgCfgTransId *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCrgCfgTransId(param, mBuf) +CrgCfgTransId *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkCrgCfgTransId) + + for (i=CRG_CFG_TRANSID_SIZE-1; i >= 0; i--) { + CMCHKPK(SPkU8, param->trans[i], mBuf); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkCrgCfgTransId +* +* +* Desc : Transaction ID between MAC and RRC +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCrgCfgTransId +( +CrgCfgTransId *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCrgCfgTransId(param, mBuf) +CrgCfgTransId *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmUnpkCrgCfgTransId) + + for (i=0; itrans[i], mBuf); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkCrgBwCfg +* +* +* Desc : Bandwidth configuration per cell +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCrgBwCfg +( +CrgBwCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCrgBwCfg(param, mBuf) +CrgBwCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCrgBwCfg) + + CMCHKPK(SPkU8, param->ulTotalBw, mBuf); + CMCHKPK(SPkU8, param->dlTotalBw, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkCrgBwCfg +* +* +* Desc : Bandwidth configuration per cell +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCrgBwCfg +( +CrgBwCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCrgBwCfg(param, mBuf) +CrgBwCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCrgBwCfg) + + CMCHKUNPK(SUnpkU8, ¶m->dlTotalBw, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->ulTotalBw, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkCrgRachCfg +* +* +* Desc : RACH configuration per cell +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCrgRachCfg +( +CrgRachCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCrgRachCfg(param, mBuf) +CrgRachCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCrgRachCfg) + + CMCHKPK(SPkU8, param->maxMsg3Tx, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkCrgRachCfg +* +* +* Desc : RACH configuration per cell +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCrgRachCfg +( +CrgRachCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCrgRachCfg(param, mBuf) +CrgRachCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCrgRachCfg) + + CMCHKUNPK(SUnpkU8, ¶m->maxMsg3Tx, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkCrgCellCfg +* +* +* Desc : Cell configuration +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCrgCellCfg +( +CrgCellCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCrgCellCfg(param, mBuf) +CrgCellCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCrgCellCfg) + +#ifdef EMTC_ENABLE + CMCHKPK(SPkU8, param->emtcEnable, mBuf); +#endif +#ifdef TENB_MULT_CELL_SUPPRT + CMCHKPK(SPkS16, param->rguDlSapId, mBuf); + CMCHKPK(SPkS16, param->rguUlSapId, mBuf); +#endif + CMCHKPK(cmPkCrgBwCfg, ¶m->bwCfg, mBuf); + CMCHKPK(cmPkCrgRachCfg, ¶m->rachCfg, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkCrgCellCfg +* +* +* Desc : Cell configuration +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCrgCellCfg +( +CrgCellCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCrgCellCfg(param, mBuf) +CrgCellCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCrgCellCfg) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkCrgRachCfg, ¶m->rachCfg, mBuf); + CMCHKUNPK(cmUnpkCrgBwCfg, ¶m->bwCfg, mBuf); +#ifdef TENB_MULT_CELL_SUPPRT + CMCHKUNPK(SUnpkS16, ¶m->rguUlSapId, mBuf); + CMCHKUNPK(SUnpkS16, ¶m->rguDlSapId, mBuf); +#endif +#ifdef EMTC_ENABLE + CMCHKUNPK(SUnpkU8, ¶m->emtcEnable, mBuf); +#endif + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkCrgUeUlHqCfg +* +* +* Desc : Uplink HARQ configuration per UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCrgUeUlHqCfg +( +CrgUeUlHqCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCrgUeUlHqCfg(param, mBuf) +CrgUeUlHqCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCrgUeUlHqCfg) + + CMCHKPK(SPkU8, param->maxUlHqTx, mBuf); + RETVALUE(ROK); +} + +#ifdef LTE_ADV +/*********************************************************** +* +* Func : cmPkCrgUeSCellCfg +* +* +* Desc : Secondary Cell information of the UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PRIVATE S16 cmPkCrgUeSCellCfg +( +CrgUeSCellInfo *param, +Buffer *mBuf +) +#else +PRIVATE S16 cmPkCrgUeSCellCfg(param, mBuf) +CrgUeSCellInfo *param; +Buffer *mBuf; +#endif +{ + CMCHKPK(SPkS16, param->rguDlSapId, mBuf); + CMCHKPK(SPkS16, param->rguUlSapId, mBuf); + CMCHKPK(SPkU8, param->macInst, mBuf); + CMCHKPK(SPkU16, param->sCellId, mBuf); + + RETVALUE(ROK); +} +/*********************************************************** +* +* Func : cmUnpkCrgUeSCellCfg +* +* +* Desc : Secondary Cell information of the UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PRIVATE S16 cmUnpkCrgUeSCellCfg +( +CrgUeSCellInfo *param, +Buffer *mBuf +) +#else +PRIVATE S16 cmUnpkCrgUeSCellCfg(param, mBuf) +CrgUeSCellInfo *param; +Buffer *mBuf; +#endif +{ + CMCHKUNPK(SUnpkU16, ¶m->sCellId, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->macInst, mBuf); + CMCHKUNPK(SUnpkS16, ¶m->rguUlSapId, mBuf); + CMCHKUNPK(SUnpkS16, ¶m->rguDlSapId, mBuf); + RETVALUE(ROK); +} +/*********************************************************** +* +* Func : cmPkCrgUeSecCellInfo +* +* +* Desc : Secondary Cell information of the UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCrgUeSecCellInfo +( +CrgUeSecCellInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCrgUeSecCellInfo(param, mBuf) +CrgUeSecCellInfo *param; +Buffer *mBuf; +#endif +{ + S8 idx; + for(idx = param->numSCells - 1; idx >= 0; idx--) + { + CMCHKPK(cmPkCrgUeSCellCfg, ¶m->ueSCellCfg[(U8)idx], mBuf); + } + + CMCHKPK(SPkU8, param->numSCells, mBuf); + CMCHKPK(SPkU8, param->isSCellCfgPres, mBuf); + + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func : cmUnpkCrgUeSecCellInfo +* +* +* Desc : Secondary Cell information of the UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCrgUeSecCellInfo +( +CrgUeSecCellInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCrgUeSecCellInfo(param, mBuf) +CrgUeSecCellInfo *param; +Buffer *mBuf; +#endif +{ + U8 idx; + + CMCHKUNPK(SUnpkU8, ¶m->isSCellCfgPres, mBuf); + if(TRUE == param->isSCellCfgPres) + { + CMCHKUNPK(SUnpkU8, ¶m->numSCells, mBuf); + + for(idx = 0; idx < param->numSCells; idx++) + { + CMCHKUNPK(cmUnpkCrgUeSCellCfg, ¶m->ueSCellCfg[idx],mBuf); + } + } + + RETVALUE(ROK); +} + +#endif /* LTE_ADV */ + + +/*********************************************************** +* +* Func : cmUnpkCrgUeUlHqCfg +* +* +* Desc : Uplink HARQ configuration per UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCrgUeUlHqCfg +( +CrgUeUlHqCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCrgUeUlHqCfg(param, mBuf) +CrgUeUlHqCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCrgUeUlHqCfg) + + CMCHKUNPK(SUnpkU8, ¶m->maxUlHqTx, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkCrgUeCfg +* +* +* Desc : UE configuration +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCrgUeCfg +( +CrgUeCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCrgUeCfg(param, mBuf) +CrgUeCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCrgUeCfg) +#ifdef TENB_MULT_CELL_SUPPRT + CMCHKPK(SPkS16, param->rguDlSapId, mBuf); + CMCHKPK(SPkS16, param->rguUlSapId, mBuf); +#endif + CMCHKPK(SPkU32, param->txMode.tm, mBuf); + CMCHKPK(SPkU8, param->txMode.pres, mBuf); + CMCHKPK(cmPkCrgUeUlHqCfg, ¶m->ueUlHqCfg, mBuf); + CMCHKPK(cmPkLteRnti, param->crnti, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkCrgUeCfg +* +* +* Desc : UE configuration +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCrgUeCfg +( +CrgUeCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCrgUeCfg(param, mBuf) +CrgUeCfg *param; +Buffer *mBuf; +#endif +{ + U32 tmpEnum; + + TRC3(cmUnpkCrgUeCfg) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->crnti, mBuf); + CMCHKUNPK(cmUnpkCrgUeUlHqCfg, ¶m->ueUlHqCfg, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->txMode.pres, mBuf); + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->txMode.tm = (CrgTxMode) tmpEnum; +#ifdef TENB_MULT_CELL_SUPPRT + CMCHKUNPK(SUnpkS16, ¶m->rguUlSapId, mBuf); + CMCHKUNPK(SUnpkS16, ¶m->rguDlSapId, mBuf); +#endif + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkCrgDlLchCfg +* +* +* Desc : Logical channel configuration info for downlink logical channels +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCrgDlLchCfg +( +CrgDlLchCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCrgDlLchCfg(param, mBuf) +CrgDlLchCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCrgDlLchCfg) + + CMCHKPK(SPkU8, param->dlTrchType, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkCrgDlLchCfg +* +* +* Desc : Logical channel configuration info for downlink logical channels +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCrgDlLchCfg +( +CrgDlLchCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCrgDlLchCfg(param, mBuf) +CrgDlLchCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCrgDlLchCfg) + + CMCHKUNPK(SUnpkU8, ¶m->dlTrchType, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkCrgUlLchCfg +* +* +* Desc : Logical channel configuration info for uplink logical channels +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCrgUlLchCfg +( +CrgUlLchCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCrgUlLchCfg(param, mBuf) +CrgUlLchCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCrgUlLchCfg) + + CMCHKPK(SPkU8, param->lcgId, mBuf); + CMCHKPK(SPkU8, param->ulTrchType, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkCrgUlLchCfg +* +* +* Desc : Logical channel configuration info for uplink logical channels +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCrgUlLchCfg +( +CrgUlLchCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCrgUlLchCfg(param, mBuf) +CrgUlLchCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCrgUlLchCfg) + + CMCHKUNPK(SUnpkU8, ¶m->ulTrchType, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->lcgId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkCrgLchCfg +* +* +* Desc : Logical channel configuration info for common and dedicated channels +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCrgLchCfg +( +CrgLchCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCrgLchCfg(param, mBuf) +CrgLchCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCrgLchCfg) +/* crg_c_001.main_5 - ADD - Added the packing for LTE_L2_MEAS. */ +#ifdef LTE_L2_MEAS + CMCHKPK(SPkU8, param->qci, mBuf); +#endif + CMCHKPK(cmPkCrgUlLchCfg, ¶m->ulInfo, mBuf); + CMCHKPK(cmPkCrgDlLchCfg, ¶m->dlInfo, mBuf); + CMCHKPK(SPkU8, param->dir, mBuf); + CMCHKPK(cmPkLteLcType, param->lcType, mBuf); + CMCHKPK(cmPkLteLcId, param->lcId, mBuf); + CMCHKPK(cmPkLteRnti, param->crnti, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkCrgLchCfg +* +* +* Desc : Logical channel configuration info for common and dedicated channels +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCrgLchCfg +( +CrgLchCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCrgLchCfg(param, mBuf) +CrgLchCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCrgLchCfg) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->crnti, mBuf); + CMCHKUNPK(cmUnpkLteLcId, ¶m->lcId, mBuf); + CMCHKUNPK(cmUnpkLteLcType, ¶m->lcType, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->dir, mBuf); + CMCHKUNPK(cmUnpkCrgDlLchCfg, ¶m->dlInfo, mBuf); + CMCHKUNPK(cmUnpkCrgUlLchCfg, ¶m->ulInfo, mBuf); +/* crg_c_001.main_5 - ADD - Added the unpacking for LTE_L2_MEAS. */ +#ifdef LTE_L2_MEAS + CMCHKUNPK(SUnpkU8, ¶m->qci, mBuf); +#endif + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkCrgCfg +* +* +* Desc : Basic configuration info for MAC +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCrgCfg +( +CrgCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCrgCfg(param, mBuf) +CrgCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCrgCfg) + + switch(param->cfgType) { + case CRG_LCH_CFG: + CMCHKPK(cmPkCrgLchCfg, ¶m->u.lchCfg, mBuf); + break; + case CRG_UE_CFG: + CMCHKPK(cmPkCrgUeCfg, ¶m->u.ueCfg, mBuf); + break; + case CRG_CELL_CFG: + CMCHKPK(cmPkCrgCellCfg, ¶m->u.cellCfg, mBuf); + break; + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkU8, param->cfgType, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkCrgCfg +* +* +* Desc : Basic configuration info for MAC +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCrgCfg +( +CrgCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCrgCfg(param, mBuf) +CrgCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCrgCfg) + + CMCHKUNPK(SUnpkU8, ¶m->cfgType, mBuf); + switch(param->cfgType) { + case CRG_CELL_CFG: + CMCHKUNPK(cmUnpkCrgCellCfg, ¶m->u.cellCfg, mBuf); + break; + case CRG_UE_CFG: + CMCHKUNPK(cmUnpkCrgUeCfg, ¶m->u.ueCfg, mBuf); + break; + case CRG_LCH_CFG: + CMCHKUNPK(cmUnpkCrgLchCfg, ¶m->u.lchCfg, mBuf); + break; + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkCrgCellRecfg +* +* +* Desc : Cell reconfiguration info +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCrgCellRecfg +( +CrgCellRecfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCrgCellRecfg(param, mBuf) +CrgCellRecfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCrgCellRecfg) + + CMCHKPK(cmPkCrgRachCfg, ¶m->rachRecfg, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkCrgCellRecfg +* +* +* Desc : Cell reconfiguration info +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCrgCellRecfg +( +CrgCellRecfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCrgCellRecfg(param, mBuf) +CrgCellRecfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCrgCellRecfg) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkCrgRachCfg, ¶m->rachRecfg, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkCrgUeRecfg +* +* +* Desc : UE reconfiguration info +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCrgUeRecfg +( +CrgUeRecfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCrgUeRecfg(param, mBuf) +CrgUeRecfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCrgUeRecfg) +#ifdef LTE_ADV + if(TRUE == param->crgSCellCfg.isSCellCfgPres) + { + CMCHKPK(cmPkCrgUeSecCellInfo, ¶m->crgSCellCfg, mBuf); + } + else + { + CMCHKPK(SPkU8, param->crgSCellCfg.isSCellCfgPres, mBuf); + } +#endif /* LTE_ADV */ + CMCHKPK(SPkU32, param->txMode.tm, mBuf); + CMCHKPK(SPkU8, param->txMode.pres, mBuf); + CMCHKPK(cmPkCrgUeUlHqCfg, ¶m->ueUlHqRecfg, mBuf); + CMCHKPK(cmPkLteRnti, param->newCrnti, mBuf); + CMCHKPK(cmPkLteRnti, param->oldCrnti, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkCrgUeRecfg +* +* +* Desc : UE reconfiguration info +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCrgUeRecfg +( +CrgUeRecfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCrgUeRecfg(param, mBuf) +CrgUeRecfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCrgUeRecfg) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->oldCrnti, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->newCrnti, mBuf); + CMCHKUNPK(cmUnpkCrgUeUlHqCfg, ¶m->ueUlHqRecfg, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->txMode.pres, mBuf); + CMCHKUNPK(SUnpkU32, (U32 *)¶m->txMode.tm, mBuf); +#ifdef LTE_ADV + CMCHKUNPK(cmUnpkCrgUeSecCellInfo, ¶m->crgSCellCfg, mBuf); +#endif /* LTE_ADV */ + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkCrgLchRecfg +* +* +* Desc : Logical channel reconfiguration info for dedicated channels only +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCrgLchRecfg +( +CrgLchRecfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCrgLchRecfg(param, mBuf) +CrgLchRecfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCrgLchRecfg) + + CMCHKPK(SPkU8, param->ulRecfg.lcgId, mBuf); + CMCHKPK(cmPkLteLcId, param->lcId, mBuf); + CMCHKPK(cmPkLteRnti, param->crnti, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkCrgLchRecfg +* +* +* Desc : Logical channel reconfiguration info for dedicated channels only +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCrgLchRecfg +( +CrgLchRecfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCrgLchRecfg(param, mBuf) +CrgLchRecfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCrgLchRecfg) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->crnti, mBuf); + CMCHKUNPK(cmUnpkLteLcId, ¶m->lcId, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->ulRecfg.lcgId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkCrgRecfg +* +* +* Desc : Basic reconfiguration info for MAC +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCrgRecfg +( +CrgRecfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCrgRecfg(param, mBuf) +CrgRecfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCrgRecfg) + + switch(param->recfgType) { + case CRG_LCH_CFG: + CMCHKPK(cmPkCrgLchRecfg, ¶m->u.lchRecfg, mBuf); + break; + case CRG_UE_CFG: + CMCHKPK(cmPkCrgUeRecfg, ¶m->u.ueRecfg, mBuf); + break; + case CRG_CELL_CFG: + CMCHKPK(cmPkCrgCellRecfg, ¶m->u.cellRecfg, mBuf); + break; + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkU8, param->recfgType, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkCrgRecfg +* +* +* Desc : Basic reconfiguration info for MAC +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCrgRecfg +( +CrgRecfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCrgRecfg(param, mBuf) +CrgRecfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCrgRecfg) + + CMCHKUNPK(SUnpkU8, ¶m->recfgType, mBuf); + switch(param->recfgType) { + case CRG_CELL_CFG: + CMCHKUNPK(cmUnpkCrgCellRecfg, ¶m->u.cellRecfg, mBuf); + break; + case CRG_UE_CFG: + CMCHKUNPK(cmUnpkCrgUeRecfg, ¶m->u.ueRecfg, mBuf); + break; + case CRG_LCH_CFG: + CMCHKUNPK(cmUnpkCrgLchRecfg, ¶m->u.lchRecfg, mBuf); + break; + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkCrgDel +* +* +* Desc : Basic Delete info for MAC +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCrgDel +( +CrgDel *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCrgDel(param, mBuf) +CrgDel *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCrgDel) + + switch(param->delType) { + case CRG_LCH_CFG: + CMCHKPK(SPkU8, param->u.lchDel.dir, mBuf); + CMCHKPK(cmPkLteLcId, param->u.lchDel.lcId, mBuf); + CMCHKPK(cmPkLteRnti, param->u.lchDel.crnti, mBuf); + CMCHKPK(cmPkLteCellId, param->u.lchDel.cellId, mBuf); + break; + case CRG_UE_CFG: + CMCHKPK(cmPkLteRnti, param->u.ueDel.crnti, mBuf); + CMCHKPK(cmPkLteCellId, param->u.ueDel.cellId, mBuf); + break; + case CRG_CELL_CFG: + CMCHKPK(cmPkLteCellId, param->u.cellDel.cellId, mBuf); + break; + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkU8, param->delType, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkCrgDel +* +* +* Desc : Basic Delete info for MAC +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCrgDel +( +CrgDel *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCrgDel(param, mBuf) +CrgDel *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCrgDel) + + CMCHKUNPK(SUnpkU8, ¶m->delType, mBuf); + switch(param->delType) { + case CRG_CELL_CFG: + CMCHKUNPK(cmUnpkLteCellId, ¶m->u.cellDel.cellId, mBuf); + break; + case CRG_UE_CFG: + CMCHKUNPK(cmUnpkLteCellId, ¶m->u.ueDel.cellId, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->u.ueDel.crnti, mBuf); + break; + case CRG_LCH_CFG: + CMCHKUNPK(cmUnpkLteCellId, ¶m->u.lchDel.cellId, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->u.lchDel.crnti, mBuf); + CMCHKUNPK(cmUnpkLteLcId, ¶m->u.lchDel.lcId, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->u.lchDel.dir, mBuf); + break; + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkCrgRst +* +* +* Desc : UE RESET info for MAC +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCrgRst +( +CrgRst *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCrgRst(param, mBuf) +CrgRst *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCrgRst) + + CMCHKPK(cmPkLteRnti, param->crnti, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkCrgRst +* +* +* Desc : UE RESET info for MAC +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCrgRst +( +CrgRst *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCrgRst(param, mBuf) +CrgRst *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCrgRst) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->crnti, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkCrgCfgReqInfo +* +* +* Desc : Config/Reconfig/Delete info for MAC +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCrgCfgReqInfo +( +CrgCfgReqInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCrgCfgReqInfo(param, mBuf) +CrgCfgReqInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCrgCfgReqInfo) + + switch(param->action) { + case CRG_RESET: + CMCHKPK(cmPkCrgRst, ¶m->u.rstInfo, mBuf); + break; + case CRG_DELETE: + CMCHKPK(cmPkCrgDel, ¶m->u.delInfo, mBuf); + break; + case CRG_RECONFIG: + CMCHKPK(cmPkCrgRecfg, ¶m->u.recfgInfo, mBuf); + break; + case CRG_CONFIG: + CMCHKPK(cmPkCrgCfg, ¶m->u.cfgInfo, mBuf); + break; + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkU8, param->action, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkCrgCfgReqInfo +* +* +* Desc : Config/Reconfig/Delete info for MAC +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCrgCfgReqInfo +( +CrgCfgReqInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCrgCfgReqInfo(param, mBuf) +CrgCfgReqInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCrgCfgReqInfo) + + CMCHKUNPK(SUnpkU8, ¶m->action, mBuf); + switch(param->action) { + case CRG_CONFIG: + CMCHKUNPK(cmUnpkCrgCfg, ¶m->u.cfgInfo, mBuf); + break; + case CRG_RECONFIG: + CMCHKUNPK(cmUnpkCrgRecfg, ¶m->u.recfgInfo, mBuf); + break; + case CRG_DELETE: + CMCHKUNPK(cmUnpkCrgDel, ¶m->u.delInfo, mBuf); + break; + case CRG_RESET: + CMCHKUNPK(cmUnpkCrgRst, ¶m->u.rstInfo, mBuf); + break; + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} +#endif + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/cm/ctf.c b/src/cm/ctf.c new file mode 100755 index 000000000..78f1946a9 --- /dev/null +++ b/src/cm/ctf.c @@ -0,0 +1,8335 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/********************************************************************20** + + Name: CTF Interface + + Type: C file + + Desc: This file contains the packing/unpacking functions + for control plane primitives on CTF interface. + + File: ctf.c + +*********************************************************************21*/ + +/* header include files (.h) */ +#include "envopt.h" /* Environment options */ +#include "envdep.h" /* Environment dependent options */ +#include "envind.h" /* Environment independent options */ +#include "gen.h" /* General layer */ +#include "ssi.h" /* System service interface */ +#include "cm5.h" /* Common timer library */ +#include "cm_llist.h" /* Common linked list library */ +#include "cm_hash.h" /* Common hash library */ +#include "cm_tkns.h" /* Common tokens */ +#include "cm_lte.h" /* Common LTE Defines */ +#include "ctf.h" /* CTF interface defines */ + +/* header/extern include files (.x) */ +#include "gen.x" /* General layer */ +#include "ssi.x" /* System services interface */ +#include "cm_lib.x" /* Common linrary function */ +#include "cm_llist.x" /* Common link list library */ +#include "cm_hash.x" /* Common hash list library */ +#include "cm_tkns.x" /* Common tokens */ +#include "cm_lte.x" /* Common LTE library */ +#ifdef TENB_AS_SECURITY +#include "cm_mblk.x" +#endif +#include "ctf.x" + +#ifdef TENB_AS_SECURITY +#define cmPkCtfCrnti SPkU16 +#define cmPkCtfCellId SPkU16 +#define cmUnpkCtfCellId SUnpkU16 +#define cmUnpkCtfCrnti SUnpkU16 +#endif + + +#if (defined(LCCTF) || defined(LWLCCTF)) + + +/** +* @brief Request from RRC to PHY to bind the CTF interface SAP. +* +* @details +* +* Function: cmPkCtfBndReq +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] SpId spId +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkCtfBndReq +( +Pst* pst, +SuId suId, +SpId spId +) +#else +PUBLIC S16 cmPkCtfBndReq(pst, suId, spId) +Pst* pst; +SuId suId; +SpId spId; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkCtfBndReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF001, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF002, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF003, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + pst->event = (Event) EVTCTFBNDREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief Request from RRC to PHY to bind the CTF interface SAP. +* +* @details +* +* Function: cmUnpkCtfBndReq +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] SpId spId +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfBndReq +( +CtfBndReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfBndReq(func, pst, mBuf) +CtfBndReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId = 0; + SpId spId = 0; + + TRC3(cmUnpkCtfBndReq) + + if (SUnpkS16(&suId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF004, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SUnpkS16(&spId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF005, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, suId, spId)); +} + + +/** +* @brief Confirmation from PHY to RRC for the bind + * request for the CTF interface SAP. +* +* @details +* +* Function: cmPkCtfBndCfm +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] U8 status +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkCtfBndCfm +( +Pst* pst, +SuId suId, +U8 status +) +#else +PUBLIC S16 cmPkCtfBndCfm(pst, suId, status) +Pst* pst; +SuId suId; +U8 status; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkCtfBndCfm) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF006, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SPkU8(status, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF007, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF008, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + pst->event = (Event) EVTCTFBNDCFM; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief Confirmation from PHY to RRC for the bind + * request for the CTF interface SAP. +* +* @details +* +* Function: cmUnpkCtfBndCfm +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] U8 status +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfBndCfm +( +CtfBndCfm func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfBndCfm(func, pst, mBuf) +CtfBndCfm func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId = 0; + U8 status; + + TRC3(cmUnpkCtfBndCfm) + + if (SUnpkS16(&suId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF009, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SUnpkU8(&status, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF010, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, suId, status)); +} + + +/** +* @brief Request from RRC to PHY to Unbind the CTF interface SAP. +* +* @details +* +* Function: cmPkCtfUbndReq +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] Reason reason +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkCtfUbndReq +( +Pst* pst, +SpId spId, +Reason reason +) +#else +PUBLIC S16 cmPkCtfUbndReq(pst, spId, reason) +Pst* pst; +SpId spId; +Reason reason; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkCtfUbndReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF011, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SPkS16(reason, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF012, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF013, (ErrVal)0,(Txt*)&"Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + pst->event = (Event) EVTCTFUBNDREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief Request from RRC to PHY to Unbind the CTF interface SAP. +* +* @details +* +* Function: cmUnpkCtfUbndReq +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] Reason reason +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfUbndReq +( +CtfUbndReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfUbndReq(func, pst, mBuf) +CtfUbndReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SpId spId = 0; + Reason reason = 0; + + TRC3(cmUnpkCtfUbndReq) + + if (SUnpkS16(&spId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF014, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SUnpkS16(&reason, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF015, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, spId, reason)); +} + + +/*********************************************************** +* +* Func: cmRelCtfCfgReq +* +* +* Desc: This fucntion will release the memory used for ctf cfg req +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PRIVATE S16 cmRelCtfCfgReq +( +Pst *pst, +CtfCfgReqInfo *cfgReqInfo +) +#else +PRIVATE S16 cmRelCtfCfgReq(pst,cfgReqInfo) +Pst *pst; +CtfCfgReqInfo *param; +#endif +{ + /* ctf_c_001.main_4: Added support for vendor specific parameters */ +#ifdef CTF_VER3 + if(cfgReqInfo->vendorParams.paramBuffer != NULLP) { + SPutSBuf(pst->region, pst->pool, + (Data *)cfgReqInfo->vendorParams.paramBuffer, + cfgReqInfo->vendorParams.buffLen); + } +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo, sizeof(CtfCfgReqInfo)); + RETVALUE(ROK); +} + +#ifdef TENB_AS_SECURITY +/*********************************************************** +* +* Func: cmPkCtfNhKeyInfo +* +* +* Desc: Pack keNB* input parameter information + * @details This is one of the main structure in the KDF request primitive. + * -# This structure contains the configuration information as given by + * the Application to trigger key derivation at PHY layer for generation of kENB*. + * -# It take Next Hop key, DL Frequency and Physical cell Id as input. + * -# The result of configuration is indicated in KdfCfgCfm. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfNhKeyInfo +( +CtfNhKeyInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfNhKeyInfo(param, mBuf) +CtfNhKeyInfo *param; +Buffer *mBuf; +#endif +{ + + S16 idx; + + TRC3(cmPkCtfNhKeyInfo) + + for(idx=31;idx>=0;idx--) + { + CMCHKPK(SPkU8,param->secKey[idx],mBuf); + } + CMCHKPK(SPkU16, param->physCellId, mBuf); + CMCHKPK(SPkU16, param->dlCarrFreq, mBuf); + + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func: cmPkCtfKenbStarInfo +* +* +* Desc: Pack keNB* input parameter information + * @details This is one of the main structure in the KDF request primitive. + * -# This structure contains the configuration information as given by + * the Application to trigger key derivation at PHY layer for generation of kENB*. + * -# It take existing kENB, DL Frequency and Physical cell Id as input. + * -# The result of configuration is indicated in KdfCfgCfm. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfKenbStarInfo +( +CtfKenbStarInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfKenbStarInfo(param, mBuf) +CtfKenbStarInfo *param; +Buffer *mBuf; +#endif +{ + + S16 idx; + + TRC3(cmPkCtfKenbStarInfo) + + for(idx=31;idx>=0;idx--) + { + CMCHKPK(SPkU8,param->secKey[idx],mBuf); + } + CMCHKPK(SPkU16, param->physCellId, mBuf); + CMCHKPK(SPkU16, param->dlCarrFreq, mBuf); + + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func: cmPkCtfAskeyInfo +* +* +* Desc: Pack AS key generation input parameter information. + * @details This is one of the main structure in the KDF request primitive. + * -# This structure contains the configuration information as given by + * the Application to trigger key derivation at PHY layer for generation of AS Security keys. + * -# It take existing kENB, and integrity/cipherig Algorithm as input. + * -# The result of configuration is indicated in KdfCfgCfm. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfAskeyInfo +( +CtfAsKeyInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfAskeyInfo(param, mBuf) +CtfAsKeyInfo *param; +Buffer *mBuf; +#endif +{ + + S16 idx; + + TRC3(cmPkCtfAskeyInfo) + + + for(idx=31;idx>=0;idx--) + { + CMCHKPK(SPkU8,param->secKey[idx],mBuf); + } + CMCHKPK(SPkU8, param->ciphAlgoType, mBuf); + CMCHKPK(SPkU8, param->intgAlgoType, mBuf); + + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func: cmPkCtfKdfReqInfo +* +* +* Desc: Pack one of the 3 Key Derivation types. + * @details This is the encompassing structure in the KDF request primitive. + * -# This structure contains the configuration information as given by + * the Application to trigger key derivation at PHY layer for generation of keys. + * -# It takes key derivation type as input. + * -# The result of configuration is indicated in KdfCfgCfm. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfKdfReqInfo +( +CtfKdfReqInfo *param, +Buffer *mBuf + ) +#else +PUBLIC S16 cmPkCtfKdfReqInfo(param, mBuf) +CtfKdfReqInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfKdfReqInfo) + + switch (param->keyDerType) + { + case CTF_KDF_TYPE1: + CMCHKPK(cmPkCtfAskeyInfo, ¶m->u.kEnbInf, mBuf); + break; + case CTF_KDF_TYPE2: + CMCHKPK(cmPkCtfKenbStarInfo, ¶m->u.kEnbStarInf, mBuf); + break; + case CTF_KDF_TYPE3: + CMCHKPK(cmPkCtfNhKeyInfo , ¶m->u.nhKeyInf, mBuf); + break; + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkU8, param->keyDerType, mBuf); + + RETVALUE(ROK); +} + +/** +* @brief Primitive Request from Application to PHY for + * security key derivation. +* +* @details +* +* Function: cmPkCtfKdfReq +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] CtfCfgTransId transId +* @param[in] CtfCfgReqInfo* cfgReqInfo +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkCtfKdfReq +( +Pst* pst, +SpId spId, +CtfCfgTransId transId, +CtfKdfReqInfo* kdfReqInfo +) +#else +PUBLIC S16 cmPkCtfKdfReq(pst, spId, transId, kdfReqInfo) +Pst* pst; +SpId spId; +CtfCfgTransId transId; +CtfKdfReqInfo* kdfReqInfo; +#endif +{ + Buffer *mBuf = NULLP; + + + TRC3(cmPkCtfKdfReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF016, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)kdfReqInfo, sizeof(CtfKdfReqInfo)); + RETVALUE(RFAILED); + } + if (pst->selector == CTF_SEL_LC) { + if (cmPkCtfKdfReqInfo(kdfReqInfo, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF017, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)kdfReqInfo, sizeof(CtfKdfReqInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + else if (pst->selector == CTF_SEL_LWLC) { + #if 0 + if (cmPkPtr((PTR)cfgReqInfo, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF018, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo, sizeof(CtfCfgReqInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + #endif + } + if (cmPkCtfCfgTransId(&transId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF019, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)kdfReqInfo, sizeof(CtfKdfReqInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF020, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)kdfReqInfo, sizeof(CtfKdfReqInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (pst->selector != CTF_SEL_LWLC) { + if (SPutSBuf(pst->region, pst->pool, (Data *)kdfReqInfo, sizeof(CtfKdfReqInfo)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF021, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + pst->event = (Event) EVTCTFKDFREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} +#endif + +/********************************************************************************************************************************/ + /*START OF CNM PACK & UNPACK FUNCTIONS*/ +/********************************************************************************************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfCnmVendorSpecificInfo +( +CtfCnmVendorSpecificInfo *param, +Buffer *mBuf +) +#else +CtfCnmVendorSpecificInfo *param; +Buffer *mBuf; +#endif +{ + S32 i; + TRC3(cmPkCtfCnmVendorSpecificInfo); + if(param->numOfVendorSpecifcParam <= CTF_CNM_MAX_VENDOR_PARAMS) + { + for(i= param->numOfVendorSpecifcParam-1; i >= 0; i--) + { + CMCHKPK(SPkU32,(U32)param->vendorSpecifcParam[i], mBuf); + } + } + CMCHKPK(SPkU16, param->numOfVendorSpecifcParam, mBuf); + RETVALUE(ROK); +} + +#ifdef ANSI +PUBLIC S16 cmPkCtfCtfCnmCellSyncReq +( +CtfCnmCellSyncReq *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfCtfCnmCellSyncReq(param, mBuf) +CtfCnmCellSyncReq *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfCtfCnmCellSyncReq); + CMCHKPK(SPkU16, param->nbrEarfcn, mBuf); + CMCHKPK(SPkU16, param->nbrPCellId, mBuf); + CMCHKPK(SPkU8, param->nbrTxAntCount, mBuf); + CMCHKPK(SPkU8, param->nbrCellCp, mBuf); + CMCHKPK(SPkU8, param->nbrCellNRb, mBuf); + CMCHKPK(SPkU8, param->nbrSpecSfCfg, mBuf); + CMCHKPK(cmPkCtfCnmVendorSpecificInfo, ¶m->ctfCnmVendorSpecificInfo, mBuf); + RETVALUE(ROK); + +} + +#ifdef ANSI +PUBLIC S16 cmPkCtfcfgReqInfo +( +CtfCnmInitSyncReq *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfcfgReqInfo(param, mBuf) +CtfCnmInitSyncReq *param; +Buffer *mBuf; +#endif +{ + S32 i; + TRC3(cmPkCtfcfgReqInfo); + + CMCHKPK(SPkU8, param->searchType, mBuf); + CMCHKPK(SPkU8, param->mibRequest, mBuf); + CMCHKPK(SPkU16, param->earfcn, mBuf); + CMCHKPK(SPkU8, param->measBandWidth, mBuf); + if(param->numOfPciList <= CTF_CNM_MAX_CELL_SEARCH) + { + for(i= param->numOfPciList-1; i >= 0; i--) + { + CMCHKPK(cmPkCtfCtfCnmCellSyncReq, ¶m->pciList[i], mBuf); + } + } + CMCHKPK(SPkU16, param->numOfPciList, mBuf); + RETVALUE(ROK); + +} +#ifdef ANSI +PUBLIC S16 cmUnpkCtfCnmVendorSpecificInfo +( +CtfCnmVendorSpecificInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfCnmVendorSpecificInfo(param, mBuf) +CtfCnmVendorSpecificInfo *param; +Buffer *mBuf; +#endif +{ + S32 i; + TRC3(cmUnpkCtfCnmVendorSpecificInfo); + + CMCHKUNPK(SUnpkU16, ¶m->numOfVendorSpecifcParam, mBuf); + for(i=0; (inumOfVendorSpecifcParam)&&(i < CTF_CNM_MAX_VENDOR_PARAMS); i++) + { + CMCHKUNPK(SUnpkU32, ¶m->vendorSpecifcParam[i], mBuf); + } + RETVALUE(ROK); +} + +#ifdef ANSI +PUBLIC S16 cmUnpkCtfCtfCnmCellSyncReq +( +CtfCnmCellSyncReq *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfCtfCnmCellSyncReq(param, mBuf) +CtfCnmCellSyncReq *param; +Buffer *mBuf; +#endif +{ + TRC3(cmUnpkCtfCtfCnmCellSyncReq); + + + CMCHKUNPK(cmUnpkCtfCnmVendorSpecificInfo, ¶m->ctfCnmVendorSpecificInfo, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->nbrSpecSfCfg, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->nbrCellNRb, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->nbrCellCp, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->nbrTxAntCount, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->nbrPCellId, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->nbrEarfcn, mBuf); + RETVALUE(ROK); + +} + +#ifdef ANSI +PUBLIC S16 cmUnpkCtfsyncReqInfo +( +CtfCnmInitSyncReq *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfsyncReqInfo(param, mBuf) +CtfCnmInitSyncReq *param; +Buffer *mBuf; +#endif +{ + S32 i; + TRC3(cmUnpkCtfsyncReqInfo); + + CMCHKUNPK(SUnpkU16, ¶m->numOfPciList, mBuf); + for(i=0; (i < param->numOfPciList)&&(i < CTF_CNM_MAX_CELL_SEARCH); i++) + { + CMCHKUNPK(cmUnpkCtfCtfCnmCellSyncReq, ¶m->pciList[i], mBuf); + } + + CMCHKUNPK(SUnpkU8, ¶m->measBandWidth, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->earfcn, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->mibRequest, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->searchType, mBuf); + RETVALUE(ROK); +} +/** +* @brief Configuration Request from App to CL for + * cnm Cell Sync request. +* +* @details +* +* Function: cmPkCtfCnmCellSyncReq +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] CtfCfgTransId * transId +* @param[in] CtfCnmCellSyncReq* ctfcnmCellSyncReq +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkCtfCnmCellSyncReq +( +Pst* pst, +SpId spId, +CtfCfgTransId *transId, +CtfCnmCellSyncReq * cfgReqInfo +) +#else +PUBLIC S16 cmPkCtfCnmCellSyncReq(pst, spId, transId, cfgReqInfo) +Pst* pst; +SpId spId; +CtfCfgTransId *transId; +CtfCnmCellSyncReq * cfgReqInfo; +#endif +{ + + Buffer *mBuf = NULLP; + + TRC3(cmPkCtfCnmCellSyncReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF016, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo, sizeof(CtfCnmCellSyncReq)); + RETVALUE(RFAILED); + } + if (pst->selector == CTF_SEL_LC) { + if (cmPkCtfCtfCnmCellSyncReq(cfgReqInfo, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF017, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo, sizeof(CtfCnmCellSyncReq)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + else if (pst->selector == CTF_SEL_LWLC) { + + if (cmPkPtr((PTR)cfgReqInfo, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF018, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo, sizeof(CtfCnmCellSyncReq)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + } + if(cmPkCtfCfgTransId(transId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF019, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo, sizeof(CtfCnmCellSyncReq)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF020, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo, sizeof(CtfCnmCellSyncReq)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (pst->selector != CTF_SEL_LWLC) { + SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo, sizeof(CtfCnmCellSyncReq)); + } + pst->event = (Event)EVTCTFCNMSYNCREQ; + RETVALUE(SPstTsk(pst,mBuf)); + +} +/** +* @brief Configuration Request from RRC to PHY for + * cell or dedicated configuration. +* +* @details +* +* Function: cmUnpkCtfCnmCellSyncReq +* +* @param[in] CtfCnmCellSyncReqMsg func +* @param[in] Pst* pst +* @param[in] Buffer *mBuf +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfCnmCellSyncReq +( +CtfCnmCellSyncReqMsg func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfCnmCellSyncReq(func, pst, mBuf) +CtfCnmCellSyncReqMsg func; +Pst *pst; +Buffer *mBuf; +#endif +{ + + SpId spId = 0; + CtfCfgTransId transId; + CtfCnmCellSyncReq *SyncReqMsg = NULLP; + TRC3(cmUnpkCtfCnmCellSyncReq) + + if (SUnpkS16(&spId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF022, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (cmUnpkCtfCfgTransId(&transId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF023, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector != CTF_SEL_LWLC) { + if ((SGetSBuf(pst->region, pst->pool, (Data **)&SyncReqMsg, sizeof(CtfCnmCellSyncReq))) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF024, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + if (pst->selector == CTF_SEL_LWLC) { + if (cmUnpkPtr((PTR *)&SyncReqMsg, mBuf) != ROK) { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + else if (pst->selector == CTF_SEL_LC) + if (cmUnpkCtfCtfCnmCellSyncReq(SyncReqMsg, mBuf) != ROK) { + SPutSBuf(pst->region, pst->pool, (Data *)SyncReqMsg, sizeof(CtfCnmCellSyncReq)); + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF025, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, spId, &transId, SyncReqMsg)); + +} +/*-----------------------------------------------------*/ + + +/** +* @brief Configuration Request from App to CL for + * cnm Init Sync request. +* +* @details +* +* Function: cmPkCtfCnmInitSyncReq +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] CtfCfgTransId * transId +* @param[in] CtfCnmInitSyncReq* ctfcnmInitSyncReq +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkCtfCnmInitSyncReq +( +Pst* pst, +SpId spId, +CtfCfgTransId *transId, +CtfCnmInitSyncReq * cfgReqInfo +) +#else +PUBLIC S16 cmPkCtfCnmInitSyncReq(pst, spId, transId, cfgReqInfo) +Pst* pst; +SpId spId; +CtfCfgTransId *transId; +CtfCnmInitSyncReq * cfgReqInfo; +#endif +{ + Buffer *mBuf = NULLP; + + TRC3(cmPkCtfCnmInitSyncReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF016, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo, sizeof(CtfCnmInitSyncReq)); + RETVALUE(RFAILED); + } + if (pst->selector == CTF_SEL_LC) { + if (cmPkCtfcfgReqInfo(cfgReqInfo, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF017, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo, sizeof(CtfCnmInitSyncReq)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + else if (pst->selector == CTF_SEL_LWLC) { + + if (cmPkPtr((PTR)cfgReqInfo, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF018, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo, sizeof(CtfCnmInitSyncReq)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + } + if(cmPkCtfCfgTransId(transId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF019, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo, sizeof(CtfCnmInitSyncReq)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF020, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo, sizeof(CtfCnmInitSyncReq)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (pst->selector != CTF_SEL_LWLC) { + SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo, sizeof(CtfCnmInitSyncReq)); + } + pst->event = (Event)EVTCTFCNMINITSYNCREQ; + RETVALUE(SPstTsk(pst,mBuf)); + +} +/*-----------------------------------------------------------------*/ + +/** +* @brief Configuration Request from RRC to PHY for + * cell or dedicated configuration. +* +* @details +* +* Function: cmUnpkCtfCnmInitSyncReq +* +* @param[in] CtfCnmInitSyncReqMsg func +* @param[in] Pst* pst +* @param[in] Buffer *mBuf +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfCnmInitSyncReq +( +CtfCnmInitSyncReqMsg func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfCnmInitSyncReq(func, pst, mBuf) +CtfCnmInitSyncReqMsg func; +Pst *pst; +Buffer *mBuf; +#endif +{ + + SpId spId = 0; + CtfCfgTransId transId; + CtfCnmInitSyncReq *syncReqInfo = NULLP; + TRC3(cmUnpkCtfCnmInitSyncReq) + + if (SUnpkS16(&spId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF022, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (cmUnpkCtfCfgTransId(&transId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF023, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector != CTF_SEL_LWLC) { + if ((SGetSBuf(pst->region, pst->pool, (Data **)&syncReqInfo, sizeof(CtfCnmInitSyncReq))) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF024, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + if (pst->selector == CTF_SEL_LWLC) { + if (cmUnpkPtr((PTR *)&syncReqInfo, mBuf) != ROK) { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + else if (pst->selector == CTF_SEL_LC) + if (cmUnpkCtfsyncReqInfo(syncReqInfo, mBuf) != ROK) { + SPutSBuf(pst->region, pst->pool, (Data *)syncReqInfo, sizeof(CtfCnmInitSyncReq)); + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF025, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, spId, &transId, syncReqInfo)); +} +/*-----------------------------------------------------------------------------*/ + +#ifdef ANSI +PUBLIC S16 cmPkCtfctfCnmMibInfo +( +CtfCnmMibInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfctfCnmMibInfo(param, mBuf) +CtfCnmMibInfo *param; +Buffer *mBuf; +#endif +{ + TRC3(cmPkCtfctfCnmMibInfo) + + CMCHKPK(SPkU16, param->sfn, mBuf); + CMCHKPK(SPkU8, param->numTxAntennas, mBuf); + CMCHKPK(SPkU8, param->phichDuration, mBuf); + CMCHKPK(SPkU8, param->phichResource, mBuf); + CMCHKPK(SPkU8, param->dlSystemBandWidht, mBuf); + RETVALUE(ROK); + +} + +#ifdef ANSI +PUBLIC S16 cmPkCtfctfCnmInitSyncInfo +( +CtfCnmInitSyncInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfctfCnmInitSyncInfo(param, mBuf) +CtfCnmInitSyncInfo *param; +Buffer *mBuf; +#endif +{ + TRC3(cmPkCtfctfCnmInitSyncInfo) + + CMCHKPK(SPkU16, param->pci, mBuf); + CMCHKPK(SPkU8, param->rsrp, mBuf); + CMCHKPK(SPkU8, param->mibValidFlag, mBuf); + CMCHKPK(SPkU16, param->localSfn, mBuf); + CMCHKPK(cmPkCtfctfCnmMibInfo, ¶m->ctfCnmMibInfo, mBuf); + CMCHKPK(cmPkCtfCnmVendorSpecificInfo, ¶m->ctfCnmVendorSpecificInfo, mBuf); + RETVALUE(ROK); + +} + +#ifdef ANSI +PUBLIC S16 cmPkCtfcfgRspInfo +( +CtfCnmInitSyncRsp *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfcfgRspInfo(param, mBuf) +CtfCnmInitSyncRsp *param; +Buffer *mBuf; +#endif +{ + S32 i; + TRC3(cmPkCtfcfgRspInfo) + + + CMCHKPK(SPkU8, param->status, mBuf); + CMCHKPK(SPkU16, param->earfcn, mBuf); + if(param->numOfNeighbourInfo <= CTF_CNM_MAX_CELL_SEARCH) + { + for(i= param->numOfNeighbourInfo-1; i >= 0; i--) + { + CMCHKPK(cmPkCtfctfCnmInitSyncInfo, ¶m->ctfCnmInitSyncInfo[i], mBuf); + } + } + CMCHKPK(SPkU8, param->numOfNeighbourInfo, mBuf); + RETVALUE(ROK); + +} + +/** +* @brief Configuration Request from App to CL for + * cnm Init Sync responce +* +* @details +* +* Function: cmPkCtfCnmInitSyncRsp +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] CtfCfgTransId * transId +* @param[in] CtfCnmInitSyncRsp* ctfcnmInitSyncRsp +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkCtfCnmInitSyncRsp +( +Pst* pst, +SpId spId, +CtfCfgTransId *transId, +CtfCnmInitSyncRsp * cfgRspInfo +) +#else +PUBLIC S16 cmPkCtfCnmInitSyncRsp(pst, spId, transId, cfgRspInfo) +Pst* pst; +SpId spId; +CtfCfgTransId *transId; +CtfCnmInitSyncRsp * cfgRspInfo; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkCtfCnmInitSyncRsp) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF016, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgRspInfo, sizeof(CtfCnmInitSyncRsp)); + RETVALUE(RFAILED); + } + if (pst->selector == CTF_SEL_LC) { + if (cmPkCtfcfgRspInfo(cfgRspInfo, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF017, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgRspInfo, sizeof(CtfCnmInitSyncRsp)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + else if (pst->selector == CTF_SEL_LWLC) { + + if (cmPkPtr((PTR)cfgRspInfo, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF018, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgRspInfo, sizeof(CtfCnmInitSyncRsp)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + } + if(cmPkCtfCfgTransId(transId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF019, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgRspInfo, sizeof(CtfCnmInitSyncRsp)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF020, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgRspInfo, sizeof(CtfCnmInitSyncRsp)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (pst->selector != CTF_SEL_LWLC) { + SPutSBuf(pst->region, pst->pool, (Data *)cfgRspInfo, sizeof(CtfCnmInitSyncRsp)); + } + pst->event = (Event)EVTCTFCNMINITSYNCRSP; + RETVALUE(SPstTsk(pst,mBuf)); + +} +/*-----------------------------------------------------------------------------*/ + +#ifdef ANSI +PUBLIC S16 cmUnpkCtfctfCnmMibInfo +( +CtfCnmMibInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfctfCnmMibInfo(param, mBuf) +CtfCnmMibInfo *param; +Buffer *mBuf; +#endif +{ + TRC3(cmUnpkCtfctfCnmMibInfo); + + + CMCHKUNPK(SUnpkU8, ¶m->dlSystemBandWidht, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->phichResource, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->phichDuration, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numTxAntennas, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->sfn, mBuf); + RETVALUE(ROK); + +} + +#ifdef ANSI +PUBLIC S16 cmUnpkctfCnmInitSyncInfo +( +CtfCnmInitSyncInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkctfCnmInitSyncInfo(param, mBuf) +CtfCnmInitSyncInfo *param; +Buffer *mBuf; +#endif +{ + TRC3(cmUnpkctfCnmInitSyncInfo); + + CMCHKUNPK(cmUnpkCtfCnmVendorSpecificInfo, ¶m->ctfCnmVendorSpecificInfo, mBuf); + CMCHKUNPK(cmUnpkCtfctfCnmMibInfo, ¶m->ctfCnmMibInfo, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->localSfn, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->mibValidFlag, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->rsrp, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->pci, mBuf); + RETVALUE(ROK); + +} + +#ifdef ANSI +PUBLIC S16 cmUnpkCtfCnmInitSyncRspMsg +( +CtfCnmInitSyncRsp *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfCnmInitSyncRspMsg(param, mBuf) +CtfCnmInitSyncRsp *param; +Buffer *mBuf; +#endif +{ + S32 i; + TRC3(cmUnpkCtfCnmInitSyncRspMsg); + + + CMCHKUNPK(SUnpkU8, ¶m->numOfNeighbourInfo, mBuf); + for(i=0; (i < param->numOfNeighbourInfo)&&(i < CTF_CNM_MAX_CELL_SEARCH); i++) + { + CMCHKUNPK(cmUnpkctfCnmInitSyncInfo, ¶m->ctfCnmInitSyncInfo[i], mBuf); + } + CMCHKUNPK(SUnpkU16, ¶m->earfcn, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->status, mBuf); + RETVALUE(ROK); + +} +/** +* @brief Configuration Request from RRC to PHY for + * cell or dedicated configuration. +* +* @details +* +* Function: cmUnpkCtfCnmInitSyncRsp +* +* @param[in] CtfCnmInitSyncRspMsg func +* @param[in] Pst* pst +* @param[in] Buffer *mBuf +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfCnmInitSyncRsp +( +CtfCnmInitSyncRspMsg func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfCnmInitSyncRsp(func, pst, mBuf) +CtfCnmInitSyncRspMsg func; +Pst *pst; +Buffer *mBuf; +#endif +{ + + SpId spId = 0; + CtfCfgTransId transId; + CtfCnmInitSyncRsp *syncRspInfo = NULLP; + TRC3(cmUnpkCtfCnmInitSyncRsp) + + if (SUnpkS16(&spId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF022, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (cmUnpkCtfCfgTransId(&transId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF023, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector != CTF_SEL_LWLC) { + if((SGetSBuf(pst->region, pst->pool, (Data **)&syncRspInfo, sizeof(CtfCnmInitSyncRsp))) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF024, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + if (pst->selector == CTF_SEL_LWLC) { + if(cmUnpkPtr((PTR *)&syncRspInfo, mBuf) != ROK) { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + else if (pst->selector == CTF_SEL_LC) + if(cmUnpkCtfCnmInitSyncRspMsg(syncRspInfo, mBuf) != ROK) { + SPutSBuf(pst->region, pst->pool, (Data *)syncRspInfo, sizeof(CtfCnmInitSyncRsp)); + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF025, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, spId, &transId, syncRspInfo)); + +} +/*-----------------------------------------------------------------------*/ + +#ifdef ANSI +PUBLIC S16 cmPkCtfCellSyncRsp +( +CtfCnmCellSyncRsp *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfCellSyncRsp(param, mBuf) +CtfCnmCellSyncRsp *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfCellSyncRsp) + + CMCHKPK(SPkU8, param->status, mBuf); + RETVALUE(ROK); + +} +/** +* @brief Configuration Request from App to CL for +* cnm Init Sync responce. +* +* @details +* +* Function: cmPkCtfCnmCellSyncRsp +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] CtfCfgTransId * transId +* @param[in] CtfCnmCellSyncRsp* ctfcnmCellSyncRsp +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkCtfCnmCellSyncRsp +( +Pst* pst, +SpId spId, +CtfCfgTransId *transId, +CtfCnmCellSyncRsp * cfgRspInfo +) +#else +PUBLIC S16 cmPkCtfCnmCellSyncRsp(pst, spId, transId, cfgRspInfo) +Pst* pst; +SpId spId; +CtfCfgTransId *transId; +CtfCnmCellSyncRsp * cfgRspInfo; +#endif +{ + + Buffer *mBuf = NULLP; + TRC3(cmPkCtfCnmCellSyncRsp) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF016, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgRspInfo, sizeof(CtfCnmCellSyncRsp)); + RETVALUE(RFAILED); + } + if (pst->selector == CTF_SEL_LC) { + if (cmPkCtfCellSyncRsp(cfgRspInfo, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF017, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgRspInfo, sizeof(CtfCnmCellSyncRsp)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + else if (pst->selector == CTF_SEL_LWLC) { + + if (cmPkPtr((PTR)cfgRspInfo, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF018, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgRspInfo, sizeof(CtfCnmCellSyncRsp)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + } + if(cmPkCtfCfgTransId(transId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF019, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgRspInfo, sizeof(CtfCnmCellSyncRsp)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF020, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgRspInfo, sizeof(CtfCnmCellSyncRsp)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (pst->selector != CTF_SEL_LWLC) { + SPutSBuf(pst->region, pst->pool, (Data *)cfgRspInfo, sizeof(CtfCnmCellSyncRsp)); + } + pst->event = (Event)EVTCTFCNMSYNCRSP; + RETVALUE(SPstTsk(pst,mBuf)); + + +} +/*------------------------------------------------------------*/ + +#ifdef ANSI +PUBLIC S16 cmUnpkCtfCnmSyncRspMsg +( +CtfCnmCellSyncRsp *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfCnmSyncRspMsg(param, mBuf) +CtfCnmCellSyncRsp *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCtfCnmSyncRspMsg); + + CMCHKUNPK(SUnpkU8, ¶m->status, mBuf); + RETVALUE(ROK); + +} +/** +* @brief Configuration Request from RRC to PHY for + * cell or dedicated configuration. +* +* @details +* +* Function: cmUnpkCtfCnmCellSyncRsp +* +* @param[in] CtfCnmCellSyncRspMsg func +* @param[in] Pst* pst +* @param[in] Buffer *mBuf +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfCnmCellSyncRsp +( +CtfCnmCellSyncRspMsg func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfCnmCellSyncRsp(func, pst, mBuf) +CtfCnmCellSyncRspMsg func; +Pst *pst; +Buffer *mBuf; +#endif +{ + + SpId spId = 0; + CtfCfgTransId transId; + CtfCnmCellSyncRsp *syncRspMsg = NULLP; + TRC3(cmUnpkCtfCnmCellSyncRsp) + + if (SUnpkS16(&spId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF022, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (cmUnpkCtfCfgTransId(&transId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF023, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector != CTF_SEL_LWLC) { + if ((SGetSBuf(pst->region, pst->pool, (Data **)&syncRspMsg, sizeof(CtfCnmCellSyncRsp))) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF024, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + if (pst->selector == CTF_SEL_LWLC) { + if (cmUnpkPtr((PTR *)&syncRspMsg, mBuf) != ROK) { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + else if (pst->selector == CTF_SEL_LC) + if (cmUnpkCtfCnmSyncRspMsg(syncRspMsg, mBuf) != ROK) { + SPutSBuf(pst->region, pst->pool, (Data *)syncRspMsg, sizeof(CtfCnmCellSyncRsp)); + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF025, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, spId, &transId, syncRspMsg)); + +} +/*---------------------------------------------------------------*/ + +#ifdef ANSI +PUBLIC S16 cmPkCtfcfgIndInfo +( +CtfCnmCellSyncInd *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfcfgIndInfo(param, mBuf) +CtfCnmCellSyncInd *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfcfgIndInfo); + + CMCHKPK(SPkU8, param->status, mBuf); + CMCHKPK(cmPkCtfCnmVendorSpecificInfo, ¶m->ctfCnmVendorSpecificInfo, mBuf); + RETVALUE(ROK); + +} +/** +* @brief Configuration Request from App to CL for +* cnm Init Sync responce. +* +* @details +* +* Function: cmPkCtfCnmCellSyncInd +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] CtfCfgTransId * transId +* @param[in] CtfCnmCellSyncInd* ctfcnmCellSyncInd +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkCtfCnmCellSyncInd +( +Pst* pst, +SpId spId, +CtfCfgTransId *transId, +CtfCnmCellSyncInd * cfgIndInfo +) +#else +PUBLIC S16 cmPkCtfCnmCellSyncInd(pst, spId, transId, cfgIndInfo) +Pst* pst; +SpId spId; +CtfCfgTransId *transId; +CtfCnmCellSyncInd * cfgIndInfo; +#endif +{ + + Buffer *mBuf = NULLP; + TRC3(cmPkCtfCnmCellSyncInd) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF016, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgIndInfo, sizeof(CtfCnmCellSyncInd)); + RETVALUE(RFAILED); + } + if (pst->selector == CTF_SEL_LC) { + if (cmPkCtfcfgIndInfo(cfgIndInfo, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF017, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgIndInfo, sizeof(CtfCnmCellSyncInd)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + else if (pst->selector == CTF_SEL_LWLC) { + + if (cmPkPtr((PTR)cfgIndInfo, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF018, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgIndInfo, sizeof(CtfCnmCellSyncInd)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + } + if(cmPkCtfCfgTransId(transId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF019, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgIndInfo, sizeof(CtfCnmCellSyncInd)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF020, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgIndInfo, sizeof(CtfCnmCellSyncInd)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (pst->selector != CTF_SEL_LWLC) { + SPutSBuf(pst->region, pst->pool, (Data *)cfgIndInfo, sizeof(CtfCnmCellSyncInd)); + } + pst->event = (Event)EVTCTFCNMSYNCIND; + RETVALUE(SPstTsk(pst,mBuf)); + +} + +/*---------------------------------------------------------------*/ + +#ifdef ANSI +PUBLIC S16 cmUnpkCtfCnmSyncIndMsg +( +CtfCnmCellSyncInd *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfCnmSyncIndMsg(param, mBuf) +CtfCnmCellSyncInd *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCtfCnmSyncIndMsg); + + CMCHKUNPK(cmUnpkCtfCnmVendorSpecificInfo, ¶m->ctfCnmVendorSpecificInfo, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->status, mBuf); + RETVALUE(ROK); + +} +/** +* @brief Configuration Request from RRC to PHY for + * cell or dedicated configuration. +* +* @details +* +* Function: cmUnpkCtfCnmCellSyncInd +* +* @param[in] CtfCnmCellSyncIndMsg func +* @param[in] Pst* pst +* @param[in] Buffer *mBuf +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfCnmCellSyncInd +( +CtfCnmCellSyncIndMsg func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfCnmCellSyncInd(func, pst, mBuf) +CtfCnmCellSyncIndMsg func; +Pst *pst; +Buffer *mBuf; +#endif +{ + + SpId spId = 0; + CtfCfgTransId transId; + CtfCnmCellSyncInd *syncIndMsg = NULLP; + TRC3(cmUnpkCtfCnmInitSyncRsp) + + if (SUnpkS16(&spId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF022, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (cmUnpkCtfCfgTransId(&transId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF023, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector != CTF_SEL_LWLC) { + if ((SGetSBuf(pst->region, pst->pool, (Data **)&syncIndMsg, sizeof(CtfCnmCellSyncInd))) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF024, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + if (pst->selector == CTF_SEL_LWLC) { + if (cmUnpkPtr((PTR *)&syncIndMsg, mBuf) != ROK) { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + else if (pst->selector == CTF_SEL_LC) + if (cmUnpkCtfCnmSyncIndMsg(syncIndMsg, mBuf) != ROK) { + SPutSBuf(pst->region, pst->pool, (Data *)syncIndMsg, sizeof(CtfCnmCellSyncInd)); + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF025, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, spId, &transId, syncIndMsg)); + +} + +/********************************************************************************************************************************/ + /*END OF CNM PACK & UNPACK FUNCTIONS*/ +/********************************************************************************************************************************/ + + + + +/** +* @brief Configuration Request from RRC to PHY for + * cell or dedicated configuration. +* +* @details +* +* Function: cmPkCtfCfgReq +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] CtfCfgTransId transId +* @param[in] CtfCfgReqInfo* cfgReqInfo +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkCtfCfgReq +( +Pst* pst, +SpId spId, +CtfCfgTransId transId, +CtfCfgReqInfo* cfgReqInfo +) +#else +PUBLIC S16 cmPkCtfCfgReq(pst, spId, transId, cfgReqInfo) +Pst* pst; +SpId spId; +CtfCfgTransId transId; +CtfCfgReqInfo* cfgReqInfo; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkCtfCfgReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF016, (ErrVal)0, "Packing failed"); +#endif + cmRelCtfCfgReq(pst, cfgReqInfo); + RETVALUE(RFAILED); + } + if (pst->selector == CTF_SEL_LC) { + if (cmPkCtfCfgReqInfo(cfgReqInfo, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF017, (ErrVal)0, "Packing failed"); +#endif + cmRelCtfCfgReq(pst, cfgReqInfo); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + else if (pst->selector == CTF_SEL_LWLC) { + if (cmPkPtr((PTR)cfgReqInfo, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF018, (ErrVal)0, "Packing failed"); +#endif + cmRelCtfCfgReq(pst, cfgReqInfo); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + if (cmPkCtfCfgTransId(&transId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF019, (ErrVal)0, "Packing failed"); +#endif + cmRelCtfCfgReq(pst, cfgReqInfo); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF020, (ErrVal)0, "Packing failed"); +#endif + cmRelCtfCfgReq(pst, cfgReqInfo); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (pst->selector != CTF_SEL_LWLC) { + cmRelCtfCfgReq(pst, cfgReqInfo); + } + pst->event = (Event) EVTCTFCFGREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + +#ifdef TENB_AS_SECURITY +/*********************************************************** +* +* Func: cmPkCtfKenbCfgInfo +* +* +* Desc: Key derivation funtion Input Information + * @details This funtion packs the the CtfKenbCfgInfo structure + * which contains the eNodeB key and Algorithm Type for + * deriving AS security keys. + * + * + * Ret : S16 + * + * Notes: + * + * File: + * + **********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfNhKeyInfo +( +CtfNhKeyInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfNhKeyInfo(param, mBuf) +CtfNhKeyInfo *param; +Buffer *mBuf; +#endif +{ + + U8 idx; + + TRC3(cmUnpkCtfNhKeyInfo) + + CMCHKUNPK(SUnpkU16, ¶m->dlCarrFreq, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->physCellId, mBuf); + for(idx=0;idx<32;idx++) + { + CMCHKUNPK(SUnpkU8,¶m->secKey[idx],mBuf); + } + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func: cmPkCtfKenbCfgInfo +* +* +* Desc: Key derivation funtion Input Information + * @details This funtion packs the the CtfKenbCfgInfo structure + * which contains the eNodeB key and Algorithm Type for + * deriving AS security keys. + * + * + * Ret : S16 + * + * Notes: + * + * File: + * + **********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfKenbStarInfo +( +CtfKenbStarInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfKenbStarInfo(param, mBuf) +CtfKenbStarInfo *param; +Buffer *mBuf; +#endif +{ + + U8 idx; + + TRC3(cmUnpkCtfKenbStarInfo) + + CMCHKUNPK(SUnpkU16, ¶m->dlCarrFreq, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->physCellId, mBuf); + for(idx=0;idx<32;idx++) + { + CMCHKUNPK(SUnpkU8,¶m->secKey[idx],mBuf); + } + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func: cmPkCtfKenbCfgInfo +* +* +* Desc: Key derivation funtion Input Information + * @details This funtion packs the the CtfKenbCfgInfo structure + * which contains the eNodeB key and Algorithm Type for + * deriving AS security keys. + * + * + * Ret : S16 + * + * Notes: + * + * File: + * + **********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfAskeyInfo +( +CtfAsKeyInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfAskeyInfo(param, mBuf) +CtfAskeyInfo *param; +Buffer *mBuf; +#endif +{ + + U8 idx; + + TRC3(cmUnpkCtfAskeyInfo) + + CMCHKUNPK(SUnpkU8, ¶m->intgAlgoType, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->ciphAlgoType, mBuf); + for(idx=0;idx<32;idx++) + { + CMCHKUNPK(SUnpkU8,¶m->secKey[idx],mBuf); + } + RETVALUE(ROK); +} + +/*********************************************************** + * + * Func: cmPkCtfKenbCfgInfo + * + * + * Desc: Key derivation funtion Input Information + * @details This funtion packs the the CtfKenbCfgInfo structure + * which contains the eNodeB key and Algorithm Type for + * deriving AS security keys. + * + * + * Ret : S16 + * + * Notes: + * + * File: + * + * **********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfKdfReqInfo +( +CtfKdfReqInfo *param, +Buffer *mBuf + ) +#else +PUBLIC S16 cmUnpkCtfKdfReqInfo(param, mBuf) +CtfKdfReqInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCtfKdfReqInfo) + + CMCHKUNPK(SUnpkU8, ¶m->keyDerType, mBuf); + switch (param->keyDerType) + { + case CTF_KDF_TYPE1: + CMCHKUNPK(cmUnpkCtfAskeyInfo, ¶m->u.kEnbInf, mBuf); + break; + case CTF_KDF_TYPE2: + CMCHKUNPK(cmUnpkCtfKenbStarInfo, ¶m->u.kEnbStarInf, mBuf); + break; + case CTF_KDF_TYPE3: + CMCHKUNPK(cmUnpkCtfNhKeyInfo, ¶m->u.nhKeyInf, mBuf); + break; + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + +/** +* @brief Configuration Request from RRC to PHY for + * cell or dedicated configuration. +* +* @details +* +* Function: cmUnpkCtfCfgReq +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] CtfCfgTransId transId +* @param[in] CtfCfgReqInfo* cfgReqInfo +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfKdfReq +( +CtfKdfReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfKdfReq(func, pst, mBuf) +CtfKdfReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SpId spId = 0; + CtfCfgTransId transId; + CtfKdfReqInfo *kdfReqInfo = NULLP; + + TRC3(cmUnpkCtfKdfReq) + + if (SUnpkS16(&spId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF022, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + + if (cmUnpkCtfCfgTransId(&transId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF023, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + + if (pst->selector != CTF_SEL_LWLC) { + if ((SGetSBuf(pst->region, pst->pool, (Data **)&kdfReqInfo, sizeof(CtfKdfReqInfo))) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF024, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + } + + if (pst->selector == CTF_SEL_LWLC) { + /*if (cmUnpkPtr((PTR *)&cfgReqInfo, mBuf) != ROK) { + SPutMsg(mBuf); + RETVALUE(RFAILED); + }*/ + } + else if (pst->selector == CTF_SEL_LC) + if (cmUnpkCtfKdfReqInfo(kdfReqInfo, mBuf) != ROK) { + SPutSBuf(pst->region, pst->pool, (Data *)kdfReqInfo, sizeof(CtfKdfReqInfo)); + SPutMsg(mBuf); + #if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF025, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, spId, transId, kdfReqInfo)); +} +#endif + + + +/** +* @brief Configuration Request from RRC to PHY for + * cell or dedicated configuration. +* +* @details +* +* Function: cmUnpkCtfCfgReq +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] CtfCfgTransId transId +* @param[in] CtfCfgReqInfo* cfgReqInfo +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfCfgReq +( +CtfCfgReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfCfgReq(func, pst, mBuf) +CtfCfgReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SpId spId = 0; + CtfCfgTransId transId; + CtfCfgReqInfo *cfgReqInfo = NULLP; + + TRC3(cmUnpkCtfCfgReq) + + if (SUnpkS16(&spId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF022, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (cmUnpkCtfCfgTransId(&transId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF023, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector != CTF_SEL_LWLC) { + if ((SGetSBuf(pst->region, pst->pool, (Data **)&cfgReqInfo, sizeof(CtfCfgReqInfo))) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF024, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + if (pst->selector == CTF_SEL_LWLC) { + if (cmUnpkPtr((PTR *)&cfgReqInfo, mBuf) != ROK) { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + else if (pst->selector == CTF_SEL_LC) + if (cmUnpkCtfCfgReqInfo(pst,cfgReqInfo, mBuf) != ROK) { + cmRelCtfCfgReq(pst, cfgReqInfo); + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF025, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, spId, transId, cfgReqInfo)); +} + +#ifdef TENB_AS_SECURITY +/*********************************************************** +* +* Func: cmPkCtfKenbCfgInfo +* +* +* Desc: Key derivation funtion Input Information + * @details This funtion packs the the CtfKenbCfgInfo structure + * which contains the eNodeB key and Algorithm Type for + * deriving AS security keys. + * + * + * Ret : S16 + * + * Notes: + * + * File: + * + **********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfNhKeyCfmInfo +( +CtfNhKeyCfmInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfNhKeyCfmInfo(param, mBuf) +CtfNhKeyCfmInfo *param; +Buffer *mBuf; +#endif +{ + + S16 idx; + + TRC3(cmPkCtfNhKeyCfmInfo) + + for(idx=31;idx>=0;idx--) + { + CMCHKPK(SPkU8,param->secKey[idx],mBuf); + } + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func: cmPkCtfKenbCfgInfo +* +* +* Desc: Key derivation funtion Input Information + * @details This funtion packs the the CtfKenbCfgInfo structure + * which contains the eNodeB key and Algorithm Type for + * deriving AS security keys. + * + * + * Ret : S16 + * + * Notes: + * + * File: + * + **********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfKenbStarCfmInfo +( +CtfKenbStarCfmInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfKenbStarCfmInfo(param, mBuf) +CtfKenbStarCfmInfo *param; +Buffer *mBuf; +#endif +{ + + S16 idx; + + TRC3(cmPkCtfKenbStarCfmInfo) + + for(idx=31;idx>=0;idx--) + { + CMCHKPK(SPkU8,param->secKey[idx],mBuf); + } + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func: cmPkCtfKenbCfgInfo +* +* +* Desc: Key derivation funtion Input Information + * @details This funtion packs the the CtfKenbCfgInfo structure + * which contains the eNodeB key and Algorithm Type for + * deriving AS security keys. + * + * + * Ret : S16 + * + * Notes: + * + * File: + * + **********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfAskeyCfmInfo +( +CtfAskeyCfmInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfAskeyCfmInfo(param, mBuf) +CtfAskeyCfmInfo *param; +Buffer *mBuf; +#endif +{ + + S16 idx; + + TRC3(cmPkCtfCtfAskeyCfmInfo) + + for(idx=15;idx>=0;idx--) + { + CMCHKPK(SPkU8,param->cpCiphKey[idx],mBuf); + } + for(idx=15;idx>=0;idx--) + { + CMCHKPK(SPkU8,param->upCiphKey[idx],mBuf); + } + for(idx=15;idx>=0;idx--) + { + CMCHKPK(SPkU8,param->intKey[idx],mBuf); + } + RETVALUE(ROK); +} + +/*********************************************************** + * + * Func: cmPkCtfKenbCfgInfo + * + * + * Desc: Key derivation funtion Input Information + * @details This funtion packs the the CtfKenbCfgInfo structure + * which contains the eNodeB key and Algorithm Type for + * deriving AS security keys. + * + * + * Ret : S16 + * + * Notes: + * + * File: + * + * **********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfKdfCfmInfo +( +CtfKdfCfmInfo *param, +Buffer *mBuf + ) +#else +PUBLIC S16 cmPkCtfKdfCfmInfo(param, mBuf) +CtfKdfCfmInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfKdfCfmInfo) + + switch (param->keyDerType) + { + case CTF_KDF_TYPE1: + CMCHKPK(cmPkCtfAskeyCfmInfo, ¶m->u.kEnbInf, mBuf); + break; + case CTF_KDF_TYPE2: + CMCHKPK(cmPkCtfKenbStarCfmInfo, ¶m->u.kEnbStarInf, mBuf); + break; + case CTF_KDF_TYPE3: + CMCHKPK(cmPkCtfNhKeyCfmInfo, ¶m->u.nhKeyInf, mBuf); + break; + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkU8, param->keyDerType, mBuf); + RETVALUE(ROK); +} + +/** +* @brief Configuration Confirm from PHY to RRC. +* +* @details +* +* Function: cmPkCtfCfgCfm +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] CtfCfgTransId transId +* @param[in] U8 status +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkCtfKdfCfm +( +Pst* pst, +SuId suId, +CtfCfgTransId transId, +CtfKdfCfmInfo *kdfCfmInfo, +U8 status +) +#else +PUBLIC S16 cmPkCtfKdfCfm(pst, suId, transId, status) +Pst* pst; +SuId suId; +CtfCfgTransId transId; +U8 status; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkCtfKdfCfm) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF026, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)kdfCfmInfo, sizeof(CtfKdfCfmInfo)); + RETVALUE(RFAILED); + } + + if (SPkU8(status, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF027, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)kdfCfmInfo, sizeof(CtfKdfCfmInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (cmPkCtfKdfCfmInfo(kdfCfmInfo, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF028, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)kdfCfmInfo, sizeof(CtfKdfCfmInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (cmPkCtfCfgTransId(&transId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF028, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)kdfCfmInfo, sizeof(CtfKdfCfmInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF029, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)kdfCfmInfo, sizeof(CtfKdfCfmInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (SPutSBuf(pst->region, pst->pool, (Data *)kdfCfmInfo, sizeof(CtfKdfCfmInfo)) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF021, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + pst->event = (Event) EVTCTFKDFCFM; + RETVALUE(SPstTsk(pst,mBuf)); +} +#endif + +/** +* @brief Configuration Confirm from PHY to RRC. +* +* @details +* +* Function: cmPkCtfCfgCfm +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] CtfCfgTransId transId +* @param[in] U8 status +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkCtfCfgCfm +( +Pst* pst, +SuId suId, +CtfCfgTransId transId, +U8 status +) +#else +PUBLIC S16 cmPkCtfCfgCfm(pst, suId, transId, status) +Pst* pst; +SuId suId; +CtfCfgTransId transId; +U8 status; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkCtfCfgCfm) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF026, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SPkU8(status, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF027, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (cmPkCtfCfgTransId(&transId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF028, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF029, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + pst->event = (Event) EVTCTFCFGCFM; + RETVALUE(SPstTsk(pst,mBuf)); +} + +/** +* @brief ENB STOP Indication from PHY to ENB-APP. +* +* @details +* +* Function: cmPkCtfEnbStopInd +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] CtfCfgTransId transId +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkCtfEnbStopInd +( +Pst* pst, +SuId suId, +CtfCfgTransId transId +) +#else +PUBLIC S16 cmPkCtfEnbStopInd(pst, suId, transId) +Pst* pst; +SuId suId; +CtfCfgTransId transId; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkCtfEnbStopInd) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF026, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (cmPkCtfCfgTransId(&transId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF028, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF029, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + pst->event = (Event) EVTCTFENBSTOPIND; + RETVALUE(SPstTsk(pst,mBuf)); +} + +#ifdef TENB_AS_SECURITY +/*********************************************************** +* +* Func: cmPkCtfKenbCfgInfo +* +* +* Desc: Key derivation funtion Input Information + * @details This funtion packs the the CtfKenbCfgInfo structure + * which contains the eNodeB key and Algorithm Type for + * deriving AS security keys. + * + * + * Ret : S16 + * + * Notes: + * + * File: + * + **********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfNhKeyCfmInfo +( +CtfNhKeyCfmInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfNhKeyCfmInfo(param, mBuf) +CtfNhKeyCfmInfo *param; +Buffer *mBuf; +#endif +{ + + U8 idx; + + TRC3(cmUnpkCtfNhKeyCfmInfo) + + for(idx=0;idx<32;idx++) + { + CMCHKUNPK(SUnpkU8,¶m->secKey[idx],mBuf); + } + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func: cmPkCtfKenbCfgInfo +* +* +* Desc: Key derivation funtion Input Information + * @details This funtion packs the the CtfKenbCfgInfo structure + * which contains the eNodeB key and Algorithm Type for + * deriving AS security keys. + * + * + * Ret : S16 + * + * Notes: + * + * File: + * + **********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfKenbStarCfmInfo +( +CtfKenbStarCfmInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfKenbStarCfmInfo(param, mBuf) +CtfKenbStarCfmInfo *param; +Buffer *mBuf; +#endif +{ + + U8 idx; + + TRC3(cmUnpkCtfKenbStarCfmInfo) + + for(idx=0;idx<32;idx++) + { + CMCHKUNPK(SUnpkU8,¶m->secKey[idx],mBuf); + } + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func: cmPkCtfKenbCfgInfo +* +* +* Desc: Key derivation funtion Input Information + * @details This funtion packs the the CtfKenbCfgInfo structure + * which contains the eNodeB key and Algorithm Type for + * deriving AS security keys. + * + * + * Ret : S16 + * + * Notes: + * + * File: + * + **********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfAskeyCfmInfo +( +CtfAskeyCfmInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfAskeyCfmInfo(param, mBuf) +CtfAskeyCfmInfo *param; +Buffer *mBuf; +#endif +{ + + U8 idx; + + TRC3(cmUnpkCtfCtfAskeyCfmInfo) + + for(idx=0;idx<16;idx++) + { + CMCHKUNPK(SUnpkU8,¶m->intKey[idx],mBuf); + } + for(idx=0;idx<16;idx++) + { + CMCHKUNPK(SUnpkU8,¶m->upCiphKey[idx],mBuf); + } + for(idx=0;idx<16;idx++) + { + CMCHKUNPK(SUnpkU8,¶m->cpCiphKey[idx],mBuf); + } + RETVALUE(ROK); +} + +/*********************************************************** + * + * Func: cmPkCtfKenbCfgInfo + * + * + * Desc: Key derivation funtion Input Information + * @details This funtion packs the the CtfKenbCfgInfo structure + * which contains the eNodeB key and Algorithm Type for + * deriving AS security keys. + * + * + * Ret : S16 + * + * Notes: + * + * File: + * + * **********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfKdfCfmInfo +( +CtfKdfCfmInfo *param, +Buffer *mBuf + ) +#else +PUBLIC S16 cmUnpkCtfKdfCfmInfo(param, mBuf) +CtfKdfCfmInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCtfKdfCfmInfo) + + CMCHKUNPK(SUnpkU8, ¶m->keyDerType, mBuf); + switch (param->keyDerType) + { + case CTF_KDF_TYPE1: + CMCHKUNPK(cmUnpkCtfAskeyCfmInfo, ¶m->u.kEnbInf, mBuf); + break; + case CTF_KDF_TYPE2: + CMCHKUNPK(cmUnpkCtfKenbStarCfmInfo, ¶m->u.kEnbStarInf, mBuf); + break; + case CTF_KDF_TYPE3: + CMCHKUNPK(cmUnpkCtfNhKeyCfmInfo, ¶m->u.nhKeyInf, mBuf); + break; + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + +/** +* @brief Configuration Confirm from PHY to RRC. +* +* @details +* +* Function: cmUnpkCtfCfgCfm +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] CtfCfgTransId transId +* @param[in] U8 status +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfKdfCfm +( +CtfKdfCfm func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfCfgCfm(func, pst, mBuf) +CtfKdfCfm func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId = 0; + CtfCfgTransId transId; + U8 status; + CtfKdfCfmInfo kdfCfmInfo; + + TRC3(cmUnpkCtfKdfCfm) + + if (SUnpkS16(&suId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF030, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (cmUnpkCtfCfgTransId(&transId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF031, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (cmUnpkCtfKdfCfmInfo(&kdfCfmInfo, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF031, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + + if (SUnpkU8(&status, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF032, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, suId, transId,&kdfCfmInfo, status)); +} +#endif + + +/** +* @brief Configuration Confirm from PHY to RRC. +* +* @details +* +* Function: cmUnpkCtfCfgCfm +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] CtfCfgTransId transId +* @param[in] U8 status +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfCfgCfm +( +CtfCfgCfm func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfCfgCfm(func, pst, mBuf) +CtfCfgCfm func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId = 0; + CtfCfgTransId transId; + U8 status; + + TRC3(cmUnpkCtfCfgCfm) + + if (SUnpkS16(&suId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF030, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (cmUnpkCtfCfgTransId(&transId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF031, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SUnpkU8(&status, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF032, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, suId, transId, status)); +} + +/** +* @brief ENB STOP Indication from PHY to ENB-APP +* +* @details +* +* Function: cmUnpkCtfEnbStopInd +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] CtfCfgTransId transId +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfEnbStopInd +( +CtfEnbStopInd func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfEnbStopInd(func, pst, mBuf) +CtfEnbStopInd func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId = 0; + CtfCfgTransId transId; + + TRC3(cmUnpkCtfCfgCfm) + + if (SUnpkS16(&suId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF030, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (cmUnpkCtfCfgTransId(&transId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF031, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, suId, transId)); +} + + +/** +* @brief UE ID Change Request from RRC to PHY. +* +* @details +* +* Function: cmPkCtfUeIdChgReq +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] CtfCfgTransId transId +* @param[in] CtfUeInfo * ueInfo +* @param[in] CtfUeInfo * newUeInfo +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkCtfUeIdChgReq +( +Pst* pst, +SpId spId, +CtfCfgTransId transId, +CtfUeInfo * ueInfo, +CtfUeInfo * newUeInfo +) +#else +PUBLIC S16 cmPkCtfUeIdChgReq(pst, spId, transId, ueInfo, newUeInfo) +Pst* pst; +SpId spId; +CtfCfgTransId transId; +CtfUeInfo * ueInfo; +CtfUeInfo * newUeInfo; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkCtfUeIdChgReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF033, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)ueInfo, sizeof(CtfUeInfo)); + SPutSBuf(pst->region, pst->pool, (Data *)newUeInfo, sizeof(CtfUeInfo)); + RETVALUE(RFAILED); + } + if (pst->selector == CTF_SEL_LC) { + if (cmPkCtfUeInfo(newUeInfo, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF034, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)ueInfo, sizeof(CtfUeInfo)); + SPutSBuf(pst->region, pst->pool, (Data *)newUeInfo, sizeof(CtfUeInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + else if (pst->selector == CTF_SEL_LWLC) { + if (cmPkPtr((PTR)newUeInfo, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF035, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)ueInfo, sizeof(CtfUeInfo)); + SPutSBuf(pst->region, pst->pool, (Data *)newUeInfo, sizeof(CtfUeInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + if (pst->selector == CTF_SEL_LC) { + if (cmPkCtfUeInfo(ueInfo, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF036, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)ueInfo, sizeof(CtfUeInfo)); + SPutSBuf(pst->region, pst->pool, (Data *)newUeInfo, sizeof(CtfUeInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + else if (pst->selector == CTF_SEL_LWLC) { + if (cmPkPtr((PTR)ueInfo, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF037, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)ueInfo, sizeof(CtfUeInfo)); + SPutSBuf(pst->region, pst->pool, (Data *)newUeInfo, sizeof(CtfUeInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + if (cmPkCtfCfgTransId(&transId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF038, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)ueInfo, sizeof(CtfUeInfo)); + SPutSBuf(pst->region, pst->pool, (Data *)newUeInfo, sizeof(CtfUeInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF039, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)ueInfo, sizeof(CtfUeInfo)); + SPutSBuf(pst->region, pst->pool, (Data *)newUeInfo, sizeof(CtfUeInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (pst->selector != CTF_SEL_LWLC) { + if (SPutSBuf(pst->region, pst->pool, (Data *)ueInfo, sizeof(CtfUeInfo)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF040, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPutSBuf(pst->region, pst->pool, (Data *)newUeInfo, sizeof(CtfUeInfo)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF041, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + pst->event = (Event) EVTCTFUEIDCHGREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief UE ID Change Request from RRC to PHY. +* +* @details +* +* Function: cmUnpkCtfUeIdChgReq +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] CtfCfgTransId transId +* @param[in] CtfUeInfo * ueInfo +* @param[in] CtfUeInfo * newUeInfo +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfUeIdChgReq +( +CtfUeIdChgReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfUeIdChgReq(func, pst, mBuf) +CtfUeIdChgReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SpId spId = 0; + CtfCfgTransId transId; + CtfUeInfo *ueInfo = NULLP; + CtfUeInfo *newUeInfo = NULLP; + + TRC3(cmUnpkCtfUeIdChgReq) + + if (SUnpkS16(&spId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)& __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF042, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (cmUnpkCtfCfgTransId(&transId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF043, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector != CTF_SEL_LWLC) { + if ((SGetSBuf(pst->region, pst->pool, (Data **)&ueInfo, sizeof(CtfUeInfo))) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF044, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + if (pst->selector == CTF_SEL_LWLC) { + if (cmUnpkPtr((PTR *)&ueInfo, mBuf) != ROK) { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + else if (pst->selector == CTF_SEL_LC) + if (cmUnpkCtfUeInfo(ueInfo, mBuf) != ROK) { + SPutSBuf(pst->region, pst->pool, (Data *)ueInfo, sizeof(CtfUeInfo)); + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF045, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector != CTF_SEL_LWLC) { + if ((SGetSBuf(pst->region, pst->pool, (Data **)&newUeInfo, sizeof(CtfUeInfo))) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF046, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutMsg(mBuf); + SPutSBuf(pst->region, pst->pool, (Data *)ueInfo, sizeof(CtfUeInfo)); + RETVALUE(RFAILED); + } + } + if (pst->selector == CTF_SEL_LWLC) { + if (cmUnpkPtr((PTR *)&newUeInfo, mBuf) != ROK) { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + else if (pst->selector == CTF_SEL_LC) + if (cmUnpkCtfUeInfo(newUeInfo, mBuf) != ROK) { + SPutSBuf(pst->region, pst->pool, (Data *)ueInfo, sizeof(CtfUeInfo)); + SPutSBuf(pst->region, pst->pool, (Data *)newUeInfo, sizeof(CtfUeInfo)); + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF047, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, spId, transId, ueInfo, newUeInfo)); +} + + +/** +* @brief UE ID Change Confirm from PHY to RRC. +* +* @details +* +* Function: cmPkCtfUeIdChgCfm +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] CtfCfgTransId transId +* @param[in] CtfUeInfo * ueInfo +* @param[in] U8 status +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkCtfUeIdChgCfm +( +Pst* pst, +SuId suId, +CtfCfgTransId transId, +CtfUeInfo * ueInfo, +CmStatus status +) +#else +PUBLIC S16 cmPkCtfUeIdChgCfm(pst, suId, transId, ueInfo, status) +Pst* pst; +SuId suId; +CtfCfgTransId transId; +CtfUeInfo * ueInfo; +CmStatus status; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkCtfUeIdChgCfm) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF048, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)ueInfo, sizeof(CtfUeInfo)); + RETVALUE(RFAILED); + } + if (cmPkCmStatus(&status, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF049, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)ueInfo, sizeof(CtfUeInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (pst->selector == CTF_SEL_LC) { + if (cmPkCtfUeInfo(ueInfo, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF050, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)ueInfo, sizeof(CtfUeInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + else if (pst->selector == CTF_SEL_LWLC) { + if (cmPkPtr((PTR)ueInfo, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF051, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)ueInfo, sizeof(CtfUeInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + if (cmPkCtfCfgTransId(&transId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF052, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)ueInfo, sizeof(CtfUeInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF053, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)ueInfo, sizeof(CtfUeInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (pst->selector != CTF_SEL_LWLC) { + if (SPutSBuf(pst->region, pst->pool, (Data *)ueInfo, sizeof(CtfUeInfo)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF054, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + pst->event = (Event) EVTCTFUEIDCHGCFM; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief UE ID Change Confirm from PHY to RRC. +* +* @details +* +* Function: cmUnpkCtfUeIdChgCfm +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] CtfCfgTransId transId +* @param[in] CtfUeInfo * ueInfo +* @param[in] U8 status +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfUeIdChgCfm +( +CtfUeIdChgCfm func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfUeIdChgCfm(func, pst, mBuf) +CtfUeIdChgCfm func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId = 0; + CtfCfgTransId transId; + CtfUeInfo *ueInfo = NULLP; + CmStatus status; + + TRC3(cmUnpkCtfUeIdChgCfm) + + if (SUnpkS16(&suId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF055, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (cmUnpkCtfCfgTransId(&transId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF056, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector != CTF_SEL_LWLC) { + if ((SGetSBuf(pst->region, pst->pool, (Data **)&ueInfo, sizeof(CtfUeInfo))) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF057, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + if (pst->selector == CTF_SEL_LWLC) { + if (cmUnpkPtr((PTR *)&ueInfo, mBuf) != ROK) { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + else if (pst->selector == CTF_SEL_LC) + if (cmUnpkCtfUeInfo(ueInfo, mBuf) != ROK) { + SPutSBuf(pst->region, pst->pool, (Data *)ueInfo, sizeof(CtfUeInfo)); + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF058, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (cmUnpkCmStatus(&status, mBuf) != ROK) { + SPutSBuf(pst->region, pst->pool, (Data *)ueInfo, sizeof(CtfUeInfo)); + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF059, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, suId, transId, ueInfo, status)); +} + + +/*********************************************************** +* +* Func: cmPkCtfCfgTransId +* +* +* Desc: Transaction ID between CTF and RRC. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfCfgTransId +( +CtfCfgTransId *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfCfgTransId(param, mBuf) +CtfCfgTransId *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkCtfCfgTransId) + + for (i=CTF_CFG_TRANSID_SIZE-1; i >= 0; i--) { + CMCHKPK(SPkU8, param->trans[i], mBuf); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmUnpkCtfCfgTransId +* +* +* Desc: Transaction ID between CTF and RRC. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfCfgTransId +( +CtfCfgTransId *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfCfgTransId(param, mBuf) +CtfCfgTransId *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmUnpkCtfCfgTransId) + + for (i=0; itrans[i], mBuf); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmPkCtfUeInfo +* +* +* Desc: * UE ID information +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfUeInfo +( +CtfUeInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfUeInfo(param, mBuf) +CtfUeInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfUeInfo) + + CMCHKPK(cmPkLteRnti, param->ueId, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmUnpkCtfUeInfo +* +* +* Desc: * UE ID information +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfUeInfo +( +CtfUeInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfUeInfo(param, mBuf) +CtfUeInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCtfUeInfo) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->ueId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmPkCtfBwCfgInfo +* +* +* Desc: Bandwidth Configuration + * @details This structure contains the uplink and downlink bandwidth + * information for configuration at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfBwCfgInfo +( +CtfBwCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfBwCfgInfo(param, mBuf) +CtfBwCfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfBwCfgInfo) + + CMCHKPK(SPkU8, param->eUtraBand, mBuf); + CMCHKPK(SPkU32, param->ulBw, mBuf); + CMCHKPK(SPkU32, param->dlBw, mBuf); + /* ctf_c_001.main_4: Removed packing of param->pres */ + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmUnpkCtfBwCfgInfo +* +* +* Desc: Bandwidth Configuration + * @details This structure contains the uplink and downlink bandwidth + * information for configuration at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfBwCfgInfo +( +CtfBwCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfBwCfgInfo(param, mBuf) +CtfBwCfgInfo *param; +Buffer *mBuf; +#endif +{ + + U32 tmpEnum; + TRC3(cmUnpkCtfBwCfgInfo) + + /* ctf_c_001.main_4: Removed UnPacking of param->pres */ + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->dlBw = (CtfBandwidth)tmpEnum; + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->ulBw = (CtfBandwidth)tmpEnum; + CMCHKUNPK(SUnpkU8, ¶m->eUtraBand, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmPkCtfTxSchemeCfg +* +* +* Desc: Transmission Scheme Configuration + * @details This structure contains the transmission scheme related information. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfTxSchemeCfg +( +CtfTxSchemeCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfTxSchemeCfg(param, mBuf) +CtfTxSchemeCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfTxSchemeCfg) + + CMCHKPK(SPkU32, param->cycPfx, mBuf); + CMCHKPK(SPkU32, param->scSpacing, mBuf); + CMCHKPK(SPkU32, param->duplexMode, mBuf); + /* ctf_c_001.main_4: Removed packing of param->pres */ + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmUnpkCtfTxSchemeCfg +* +* +* Desc: Transmission Scheme Configuration + * @details This structure contains the transmission scheme related information. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfTxSchemeCfg +( +CtfTxSchemeCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfTxSchemeCfg(param, mBuf) +CtfTxSchemeCfg *param; +Buffer *mBuf; +#endif +{ + U32 tmpEnum; + + TRC3(cmUnpkCtfTxSchemeCfg) + + /* ctf_c_001.main_4: Removed UnPacking of param->pres */ + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->duplexMode = (CtfDuplexMode)tmpEnum; + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->scSpacing = (CtfSCSpacing)tmpEnum; + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->cycPfx = (CtfCPCfg)tmpEnum; + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmPkCtfAntennaCfgInfo +* +* +* Desc: Antenna Ports configuration + * @details This structure contains the antenna configuration information for + * configuration at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfAntennaCfgInfo +( +CtfAntennaCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfAntennaCfgInfo(param, mBuf) +CtfAntennaCfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfAntennaCfgInfo) + + CMCHKPK(SPkU32, param->antPortsCnt, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmUnpkCtfAntennaCfgInfo +* +* +* Desc: Antenna Ports configuration + * @details This structure contains the antenna configuration information for + * configuration at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfAntennaCfgInfo +( +CtfAntennaCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfAntennaCfgInfo(param, mBuf) +CtfAntennaCfgInfo *param; +Buffer *mBuf; +#endif +{ + U32 tmpEnum; + + TRC3(cmUnpkCtfAntennaCfgInfo) + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->antPortsCnt = (CtfAntennaPortsCount)tmpEnum; + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmPkCtfPrachCfgInfo +* +* +* Desc: PRACH configuration + * @details This structure contains the configuration information for PRACH at PHY. + * -# PRACH preamble sequences are generated by PHY using Zadoff-Chu + * sequences.[Ref: 36.211, 5.7.2] + * -# PRACH preamble format is derived from PRACH Configuration Index. + * [Ref: 36.211, Table 5.7.1-2] + * -# PrachFreqOffset is the first physical resource block allocated to + * the PRACH opportunity considered for preamble format 0, 1, 2, and 3. + * [Ref: 36.211, 5.7.1] +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfPrachCfgInfo +( +CtfPrachCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfPrachCfgInfo(param, mBuf) +CtfPrachCfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfPrachCfgInfo) + + /*ctf_c_001.main_1*/ + if(param->pres != FALSE) + { + CMCHKPK(SPkU8, param->prachFreqOffset, mBuf); + CMCHKPK(SPkU8, param->highSpeedFlag, mBuf); + CMCHKPK(SPkU8, param->zeroCorrelationZoneCfg, mBuf); + CMCHKPK(SPkU8, param->prachCfgIndex, mBuf); + CMCHKPK(SPkU16, param->rootSequenceIndex, mBuf); + } + CMCHKPK(SPkU8, param->pres, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmUnpkCtfPrachCfgInfo +* +* +* Desc: PRACH configuration + * @details This structure contains the configuration information for PRACH at PHY. + * -# PRACH preamble sequences are generated by PHY using Zadoff-Chu + * sequences.[Ref: 36.211, 5.7.2] + * -# PRACH preamble format is derived from PRACH Configuration Index. + * [Ref: 36.211, Table 5.7.1-2] + * -# PrachFreqOffset is the first physical resource block allocated to + * the PRACH opportunity considered for preamble format 0, 1, 2, and 3. + * [Ref: 36.211, 5.7.1] +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfPrachCfgInfo +( +CtfPrachCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfPrachCfgInfo(param, mBuf) +CtfPrachCfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCtfPrachCfgInfo) + + CMCHKUNPK(SUnpkU8, ¶m->pres, mBuf); +/*ctf_c_001.main_1*/ + if(param->pres != FALSE) + { + CMCHKUNPK(SUnpkU16, ¶m->rootSequenceIndex, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->prachCfgIndex, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->zeroCorrelationZoneCfg, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->highSpeedFlag, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->prachFreqOffset, mBuf); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmPkCtfPdschCfgInfo +* +* +* Desc: PDSCH configuration + * @details This structure contains the PDSCH configuration information for + * configuration at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfPdschCfgInfo +( +CtfPdschCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfPdschCfgInfo(param, mBuf) +CtfPdschCfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfPdschCfgInfo) +/*ctf_c_001.main_1*/ + if(param->pres != FALSE) + { + CMCHKPK(SPkU8, param->p_b, mBuf); + CMCHKPK(SPkS16, param->refSigPwr, mBuf); + } + CMCHKPK(SPkU8, param->pres, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmUnpkCtfPdschCfgInfo +* +* +* Desc: PDSCH configuration + * @details This structure contains the PDSCH configuration information for + * configuration at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfPdschCfgInfo +( +CtfPdschCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfPdschCfgInfo(param, mBuf) +CtfPdschCfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCtfPdschCfgInfo) + + CMCHKUNPK(SUnpkU8, ¶m->pres, mBuf); +/*ctf_c_001.main_1*/ + if(param->pres != FALSE) + { + CMCHKUNPK(SUnpkS16, ¶m->refSigPwr, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->p_b, mBuf); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmPkCtfPuschCfgBasic +* +* +* Desc: Basic PUSCH configuration + * @details This structure contains the basic PUSCH configuration information for + * configuration at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfPuschCfgBasic +( +CtfPuschCfgBasic *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfPuschCfgBasic(param, mBuf) +CtfPuschCfgBasic *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfPuschCfgBasic) + + CMCHKPK(SPkU8, param->enable64QAM, mBuf); + CMCHKPK(SPkU8, param->hoppingOffset, mBuf); + CMCHKPK(SPkU32, param->hoppingMode, mBuf); + CMCHKPK(SPkU8, param->noOfsubBands, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmUnpkCtfPuschCfgBasic +* +* +* Desc: Basic PUSCH configuration + * @details This structure contains the basic PUSCH configuration information for + * configuration at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfPuschCfgBasic +( +CtfPuschCfgBasic *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfPuschCfgBasic(param, mBuf) +CtfPuschCfgBasic *param; +Buffer *mBuf; +#endif +{ + U32 tmpEnum; + + TRC3(cmUnpkCtfPuschCfgBasic) + + CMCHKUNPK(SUnpkU8, ¶m->noOfsubBands, mBuf); + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->hoppingMode = (CtfPuschHoppingMode)tmpEnum; + CMCHKUNPK(SUnpkU8, ¶m->hoppingOffset, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->enable64QAM, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmPkCtfPuschUlRS +* +* +* Desc: PUSCH Uplink Reference Signals configuration + * @details This structure contains the PUSCH configuration information for + * uplink reference signals configuration at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfPuschUlRS +( +CtfPuschUlRS *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfPuschUlRS(param, mBuf) +CtfPuschUlRS *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfPuschUlRS) + + CMCHKPK(SPkU8, param->cycShift, mBuf); + CMCHKPK(SPkU8, param->grpNum, mBuf); + CMCHKPK(SPkU8, param->seqHopEnabled, mBuf); + CMCHKPK(SPkU8, param->grpHopEnabled, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmUnpkCtfPuschUlRS +* +* +* Desc: PUSCH Uplink Reference Signals configuration + * @details This structure contains the PUSCH configuration information for + * uplink reference signals configuration at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfPuschUlRS +( +CtfPuschUlRS *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfPuschUlRS(param, mBuf) +CtfPuschUlRS *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCtfPuschUlRS) + + CMCHKUNPK(SUnpkU8, ¶m->grpHopEnabled, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->seqHopEnabled, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->grpNum, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->cycShift, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmPkCtfPuschCfgInfo +* +* +* Desc: PUSCH configuration + * @details This structure contains the information for PUSCH + * configuration at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfPuschCfgInfo +( +CtfPuschCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfPuschCfgInfo(param, mBuf) +CtfPuschCfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfPuschCfgInfo) + +/*ctf_c_001.main_1*/ + if(param->pres != FALSE) + { + CMCHKPK(cmPkCtfPuschUlRS, ¶m->puschUlRS, mBuf); + CMCHKPK(cmPkCtfPuschCfgBasic, ¶m->puschBasicCfg, mBuf); + } + CMCHKPK(SPkU8, param->pres, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmUnpkCtfPuschCfgInfo +* +* +* Desc: PUSCH configuration + * @details This structure contains the information for PUSCH + * configuration at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfPuschCfgInfo +( +CtfPuschCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfPuschCfgInfo(param, mBuf) +CtfPuschCfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCtfPuschCfgInfo) + + CMCHKUNPK(SUnpkU8, ¶m->pres, mBuf); +/*ctf_c_001.main_1*/ + if(param->pres != FALSE) + { + CMCHKUNPK(cmUnpkCtfPuschCfgBasic, ¶m->puschBasicCfg, mBuf); + CMCHKUNPK(cmUnpkCtfPuschUlRS, ¶m->puschUlRS, mBuf); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmPkCtfPhichCfgInfo +* +* +* Desc: PHICH configuration + * @details This structure contains the duration and resource information for + * PHICH configuration at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfPhichCfgInfo +( +CtfPhichCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfPhichCfgInfo(param, mBuf) +CtfPhichCfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfPhichCfgInfo) + +/*ctf_c_001.main_1*/ + if(param->pres != FALSE) + { + CMCHKPK(SPkU32, param->resource, mBuf); + CMCHKPK(SPkU32, param->duration, mBuf); + } + CMCHKPK(SPkU8, param->pres, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmUnpkCtfPhichCfgInfo +* +* +* Desc: PHICH configuration + * @details This structure contains the duration and resource information for + * PHICH configuration at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfPhichCfgInfo +( +CtfPhichCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfPhichCfgInfo(param, mBuf) +CtfPhichCfgInfo *param; +Buffer *mBuf; +#endif +{ + U32 tmpEnum; + + TRC3(cmUnpkCtfPhichCfgInfo) + + CMCHKUNPK(SUnpkU8, ¶m->pres, mBuf); +/*ctf_c_001.main_1*/ + if(param->pres != FALSE) + { + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->duration = (CtfPhichDuration)tmpEnum; + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->resource = (CtfPhichResource)tmpEnum; + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmPkCtfPucchCfgInfo +* +* +* Desc: PUCCH configuration + * @details This structure contains the information for PUCCH + * configuration at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfPucchCfgInfo +( +CtfPucchCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfPucchCfgInfo(param, mBuf) +CtfPucchCfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfPucchCfgInfo) + +/*ctf_c_001.main_1*/ + if(param->pres != FALSE) + { + CMCHKPK(SPkU32, param->deltaShift, mBuf); + CMCHKPK(SPkU16, param->n1PUCCH, mBuf); + CMCHKPK(SPkU8, param->nCS, mBuf); + CMCHKPK(SPkU8, param->nRB, mBuf); + } + CMCHKPK(SPkU8, param->pres, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmUnpkCtfPucchCfgInfo +* +* +* Desc: PUCCH configuration + * @details This structure contains the information for PUCCH + * configuration at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfPucchCfgInfo +( +CtfPucchCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfPucchCfgInfo(param, mBuf) +CtfPucchCfgInfo *param; +Buffer *mBuf; +#endif +{ + U32 tmpEnum; + + TRC3(cmUnpkCtfPucchCfgInfo) + + CMCHKUNPK(SUnpkU8, ¶m->pres, mBuf); +/*ctf_c_001.main_1*/ + if(param->pres != FALSE) + { + CMCHKUNPK(SUnpkU8, ¶m->nRB, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->nCS, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->n1PUCCH, mBuf); + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->deltaShift = (CtfPucchDeltaShift)tmpEnum; + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmPkCtfSrsUlCfgInfo +* +* +* Desc: SRS uplink configuration + * @details This structure contains the information for setting-up/release + * of uplink SRS configuration at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfSrsUlCfgInfo +( +CtfSrsUlCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfSrsUlCfgInfo(param, mBuf) +CtfSrsUlCfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfSrsUlCfgInfo) + +/*ctf_c_001.main_1*/ + if(param->pres != FALSE) + { + CMCHKPK(SPkU8, param->srsSetup.srsMaxUpPts, mBuf); + CMCHKPK(SPkU8, param->srsSetup.srsANSimultTx, mBuf); + CMCHKPK(SPkU8, param->srsSetup.sfCfg, mBuf); + CMCHKPK(SPkU8, param->srsSetup.srsBw, mBuf); + CMCHKPK(SPkU8, param->srsCfgType, mBuf); + } + CMCHKPK(SPkU8, param->pres, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmUnpkCtfSrsUlCfgInfo +* +* +* Desc: SRS uplink configuration + * @details This structure contains the information for setting-up/release + * of uplink SRS configuration at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfSrsUlCfgInfo +( +CtfSrsUlCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfSrsUlCfgInfo(param, mBuf) +CtfSrsUlCfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCtfSrsUlCfgInfo) + + CMCHKUNPK(SUnpkU8, ¶m->pres, mBuf); +/*ctf_c_001.main_1*/ + if(param->pres != FALSE) + { + CMCHKUNPK(SUnpkU8, ¶m->srsCfgType, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->srsSetup.srsBw, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->srsSetup.sfCfg, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->srsSetup.srsANSimultTx, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->srsSetup.srsMaxUpPts, mBuf); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmPkCtfTddSfCfgInfo +* +* +* Desc: Subframe Configuration for TDD mode. + * @details This structure contains the information for setting-up + * the subframe for TDD mode at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfTddSfCfgInfo +( +CtfTddSfCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfTddSfCfgInfo(param, mBuf) +CtfTddSfCfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfTddSfCfgInfo) + +/*ctf_c_001.main_1*/ + if(param->pres != FALSE) + { + CMCHKPK(SPkU8, param->spclSfPatterns, mBuf); + CMCHKPK(SPkU8, param->sfAssignment, mBuf); + } + CMCHKPK(SPkU8, param->pres, mBuf); + RETVALUE(ROK); +} + +/* ctf_c_001.main_4: Added support for vendor specific parameters */ +#ifdef CTF_VER3 +/*********************************************************** +* +* Func: cmPkCtfVendorSpecParams +* +* +* Desc: Vendor Specific Parameter configuration +* @details This structure contains the Parameters which is spaciftc to +* Vendor. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfVendorSpecParams +( +CtfVendorSpecific *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfVendorSpecParams(param, mBuf) +CtfVendorSpecific *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfVendorSpecParams) + if( param->buffLen != 0) { + SAddPreMsgMultInOrder(param->paramBuffer,param->buffLen,mBuf); + } + CMCHKPK(SPkU16,param->buffLen,mBuf); + + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func: cmUnpkCtfVendorSpecParams +* +* +* Desc: Vendor Specific Parameter configuration +* @details This structure contains the Parameters which is spaciftc to +* Vendor. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfVendorSpecParams +( +Pst *pst, +CtfVendorSpecific *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfVendorSpecParams(pst, param, mBuf) +Pst *pst; +CtfVendorSpecific *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCtfVendorSpecParams) + + CMCHKUNPK(SUnpkU16, ¶m->buffLen, mBuf); + + if(param->buffLen != 0) { + if ((SGetSBuf(pst->region, pst->pool, (Data **)¶m->paramBuffer, param->buffLen)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF060, (ErrVal)0, (Txt*)&"Unpacking failed"); +#endif + RETVALUE(RFAILED) ; + } + SRemPreMsgMult(param->paramBuffer, param->buffLen,mBuf) ; + } + else { + param->paramBuffer = NULLP ; + } + + RETVALUE(ROK); +} +#endif + +/*********************************************************** +* +* Func: cmUnpkCtfTddSfCfgInfo +* +* +* Desc: Subframe Configuration for TDD mode. + * @details This structure contains the information for setting-up + * the subframe for TDD mode at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfTddSfCfgInfo +( +CtfTddSfCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfTddSfCfgInfo(param, mBuf) +CtfTddSfCfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCtfTddSfCfgInfo) + + CMCHKUNPK(SUnpkU8, ¶m->pres, mBuf); +/*ctf_c_001.main_1*/ + if(param->pres != FALSE) + { + CMCHKUNPK(SUnpkU8, ¶m->sfAssignment, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->spclSfPatterns, mBuf); + } + RETVALUE(ROK); +} +/*********************************************************** +* +* Func: cmPkCtfUnLicnsdCellParam +* +* +* Desc: Packing unlicensed SDL cell specific parameter +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PRIVATE S16 cmPkCtfUnLicnsdCellParam +( +CtfUnLicnsdCfgInfo *param, +Buffer *mBuf +) +#else +PRIVATE S16 cmPkCtfUnLicnsdCellParam(param, mBuf) +CtfUnLicnsdCfgInfo *param; +Buffer *mBuf; +#endif +{ + U8 idx; + + TRC3(cmPkCtfUnLicnsdCellParam) + + CMCHKPK(SPkS32, param->txPowerLimit, mBuf); + CMCHKPK(SPkU8, param->coExistMethod, mBuf); + CMCHKPK(SPkU8, param->lteOnPeriod, mBuf); + CMCHKPK(SPkU8, param->ccaMethod, mBuf); + CMCHKPK(SPkU8, param->adaptiveTx, mBuf); + CMCHKPK(SPkU16, param->transPeriod, mBuf); + CMCHKPK(SPkU16, param->listenPrd, mBuf); + CMCHKPK(SPkS16, param->energyTh, mBuf); + CMCHKPK(SPkU16, param->scanTimePrd, mBuf); + CMCHKPK(SPkU16, param->activityTh, mBuf); + + for(idx = 0; idx < param->numFreq; idx++) + { + CMCHKPK(SPkU32, param->earfcn[idx], mBuf); + } + + CMCHKPK(SPkU8, param->numFreq, mBuf); + + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func: cmPkCtfCellCfgInfo +* +* +* Desc: Cell Configuration Information + * @details This structure contains the information for setting-up + * of a cell and its associated resources at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfCellCfgInfo +( +CtfCellCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfCellCfgInfo(param, mBuf) +CtfCellCfgInfo *param; +Buffer *mBuf; +#endif +{ +#ifdef EMTC_ENABLE + S32 i; +#endif + TRC3(cmPkCtfCellCfgInfo) + +#ifdef EMTC_ENABLE + for (i = CTF_MAX_CE_LEVEL-1; i >= 0; i--) { + CMCHKPK(SPkU8, param->ceLevelInfo[i].emtcNumRepPerPreambleAtt, mBuf); + CMCHKPK(SPkU8, param->ceLevelInfo[i].lastPreamble, mBuf); + CMCHKPK(SPkU8, param->ceLevelInfo[i].firstPreamble, mBuf); + } + CMCHKPK(SPkU8, param->mPdcchStart, mBuf); + CMCHKPK(SPkU8, param->catMenabled, mBuf); +#endif + if(param->unLicnsdCfgPres) + { + printf("pverma param->unLicnsdCfgPres cm/ctf -->%d\n",param->unLicnsdCfgPres); + CMCHKPK(cmPkCtfUnLicnsdCellParam, ¶m->lteUCfg, mBuf); + } + CMCHKPK(SPkU8, param->unLicnsdCfgPres, mBuf); + /*Added for rgu dynamic delta*/ + CMCHKPK(SPkU8, param->numDlUePerTti, mBuf); + CMCHKPK(SPkS16, param->pilotSigPwr, mBuf); + CMCHKPK(SPkU16, param->ulEarfcn, mBuf); + CMCHKPK(SPkU16, param->dlEarfcn, mBuf); + CMCHKPK(SPkS16, param->priSigPwr, mBuf); + CMCHKPK(SPkS16, param->secSigPwr, mBuf); + /* Packing PHY configuration parameters */ + CMCHKPK(SPkU32, param->period, mBuf); + CMCHKPK(SPkU32, param->counter, mBuf); + CMCHKPK(SPkU16, param->opMode, mBuf); + + /* ctf_c_001.main_3: Added the pack for newly added fileds inside the CFG structure*/ + CMCHKPK(SPkU8, param->rachSrRepModePres, mBuf); + CMCHKPK(SPkU16, param->rachSrRepMode, mBuf); + + CMCHKPK(SPkU8, param->dataRepModePres, mBuf); + CMCHKPK(SPkU16, param->dataRepMode, mBuf); + + CMCHKPK(SPkU8, param->phySyncModePres, mBuf); + CMCHKPK(SPkU16, param->phySyncMode, mBuf); + + CMCHKPK(SPkU8, param->rxAntennaPortsPres, mBuf); + CMCHKPK(SPkU16, param->rxAntennaPorts, mBuf); + + CMCHKPK(SPkU8, param->txAntennaPortsPres, mBuf); + CMCHKPK(SPkU16, param->txAntennaPorts, mBuf); + + CMCHKPK(SPkU8, param->pucchProbDtxAckPres, mBuf); + CMCHKPK(SPkU16, param->pucchProbDtxAck, mBuf); + + CMCHKPK(SPkU8, param->puschProbDtxAckPres, mBuf); + CMCHKPK(SPkU16, param->puschProbDtxAck, mBuf); + + CMCHKPK(SPkU8, param->srsDopEstFactorPres, mBuf); + CMCHKPK(SPkU16, param->srsDopEstFactor, mBuf); + + CMCHKPK(SPkU8, param->prachPkRatio0Pres, mBuf); + CMCHKPK(SPkU16, param->prachPkRatio0, mBuf); + + CMCHKPK(SPkU8, param->prachPkRatio4Pres, mBuf); + CMCHKPK(SPkU16, param->prachPkRatio4, mBuf); + + CMCHKPK(SPkU8, param->pucchNoiseGammaPres, mBuf); + CMCHKPK(SPkU16, param->pucchNoiseGamma, mBuf); + + CMCHKPK(SPkU8, param->extWinMarginPres, mBuf); + CMCHKPK(SPkU16, param->extWinMargin, mBuf); + + CMCHKPK(SPkU8, param->dciPowOsPres, mBuf); + CMCHKPK(SPkU16, param->dciPowOs, mBuf); + + CMCHKPK(SPkU8, param->cfiPowOsPres, mBuf); + CMCHKPK(SPkU16, param->cfiPowOs, mBuf); + + CMCHKPK(SPkU8, param->syncSigPowOsPres, mBuf); + CMCHKPK(SPkU16, param->syncSigPowOs, mBuf); + + CMCHKPK(cmPkCtfTddSfCfgInfo, ¶m->tddSfCfg, mBuf); + CMCHKPK(cmPkCtfSrsUlCfgInfo, ¶m->srsUlCfg, mBuf); + CMCHKPK(cmPkCtfPucchCfgInfo, ¶m->pucchCfg, mBuf); + CMCHKPK(cmPkCtfPhichCfgInfo, ¶m->phichCfg, mBuf); + CMCHKPK(cmPkCtfPuschCfgInfo, ¶m->puschCfg, mBuf); + CMCHKPK(cmPkCtfPdschCfgInfo, ¶m->pdschCfg, mBuf); + CMCHKPK(cmPkCtfPrachCfgInfo, ¶m->prachCfg, mBuf); + CMCHKPK(cmPkCtfAntennaCfgInfo, ¶m->antennaCfg, mBuf); + CMCHKPK(cmPkCtfTxSchemeCfg, ¶m->txCfg, mBuf); + CMCHKPK(cmPkCtfBwCfgInfo, ¶m->bwCfg, mBuf); + CMCHKPK(SPkU8, param->physCellId, mBuf); + CMCHKPK(SPkU8, param->physCellIdPres, mBuf); + + CMCHKPK(SPkS16, param->macSapId, mBuf); + CMCHKPK(SPkS16, param->schSapId, mBuf); + + CMCHKPK(SPkU8, param->cellIdGrpId, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} +/*********************************************************** +* +* Func: cmUnpkCtfUnLicnsdCellParam +* +* +* Desc: Unpacking unLicensed SDL cell specific parameter +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PRIVATE S16 cmUnpkCtfUnLicnsdCellParam +( +CtfUnLicnsdCfgInfo *param, +Buffer *mBuf +) +#else +PRIVATE S16 cmUnpkCtfUnLicnsdCellParam(param, mBuf) +CtfUnLicnsdCfgInfo *param; +Buffer *mBuf; +#endif +{ + U8 idx; + + TRC3(cmPkCtfUnLicnsdCellParam) + + CMCHKUNPK(SUnpkU8, ¶m->numFreq, mBuf); + + for(idx = 0; idx < param->numFreq; idx++) + { + CMCHKUNPK(SUnpkU32, ¶m->earfcn[idx], mBuf); + } + + CMCHKUNPK(SUnpkU16, ¶m->activityTh, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->scanTimePrd, mBuf); + CMCHKUNPK(SUnpkS16, ¶m->energyTh, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->listenPrd, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->transPeriod, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->adaptiveTx, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->ccaMethod, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->lteOnPeriod, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->coExistMethod, mBuf); + CMCHKUNPK(SUnpkS32, ¶m->txPowerLimit, mBuf); + + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func: cmUnpkCtfCellCfgInfo +* +* +* Desc: Cell Configuration Information + * @details This structure contains the information for setting-up + * of a cell and its associated resources at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfCellCfgInfo +( +CtfCellCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfCellCfgInfo(param, mBuf) +CtfCellCfgInfo *param; +Buffer *mBuf; +#endif +{ +#ifdef EMTC_ENABLE + S32 i; +#endif + TRC3(cmUnpkCtfCellCfgInfo) + + /* ctf_c_001.main_3: Added the unpack for newly added fileds inside the CFG structure*/ + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->cellIdGrpId, mBuf); + + CMCHKUNPK(SUnpkS16, ¶m->schSapId, mBuf); + CMCHKUNPK(SUnpkS16, ¶m->macSapId, mBuf); + + CMCHKUNPK(SUnpkU8, ¶m->physCellIdPres, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->physCellId, mBuf); + CMCHKUNPK(cmUnpkCtfBwCfgInfo, ¶m->bwCfg, mBuf); + CMCHKUNPK(cmUnpkCtfTxSchemeCfg, ¶m->txCfg, mBuf); + CMCHKUNPK(cmUnpkCtfAntennaCfgInfo, ¶m->antennaCfg, mBuf); + CMCHKUNPK(cmUnpkCtfPrachCfgInfo, ¶m->prachCfg, mBuf); + CMCHKUNPK(cmUnpkCtfPdschCfgInfo, ¶m->pdschCfg, mBuf); + CMCHKUNPK(cmUnpkCtfPuschCfgInfo, ¶m->puschCfg, mBuf); + CMCHKUNPK(cmUnpkCtfPhichCfgInfo, ¶m->phichCfg, mBuf); + CMCHKUNPK(cmUnpkCtfPucchCfgInfo, ¶m->pucchCfg, mBuf); + CMCHKUNPK(cmUnpkCtfSrsUlCfgInfo, ¶m->srsUlCfg, mBuf); + CMCHKUNPK(cmUnpkCtfTddSfCfgInfo, ¶m->tddSfCfg, mBuf); + + CMCHKUNPK(SUnpkU16, ¶m->syncSigPowOs, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->syncSigPowOsPres, mBuf); + + CMCHKUNPK(SUnpkU16, ¶m->cfiPowOs, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->cfiPowOsPres, mBuf); + + CMCHKUNPK(SUnpkU16, ¶m->dciPowOs, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->dciPowOsPres, mBuf); + + CMCHKUNPK(SUnpkU16, ¶m->extWinMargin, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->extWinMarginPres, mBuf); + + CMCHKUNPK(SUnpkU16, ¶m->pucchNoiseGamma, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->pucchNoiseGammaPres, mBuf); + + CMCHKUNPK(SUnpkU16, ¶m->prachPkRatio4, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->prachPkRatio4Pres, mBuf); + + CMCHKUNPK(SUnpkU16, ¶m->prachPkRatio0, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->prachPkRatio0Pres, mBuf); + + CMCHKUNPK(SUnpkU16, ¶m->srsDopEstFactor, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->srsDopEstFactorPres, mBuf); + + CMCHKUNPK(SUnpkU16, ¶m->puschProbDtxAck, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->puschProbDtxAckPres, mBuf); + + CMCHKUNPK(SUnpkU16, ¶m->pucchProbDtxAck, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->pucchProbDtxAckPres, mBuf); + + CMCHKUNPK(SUnpkU16, ¶m->txAntennaPorts, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->txAntennaPortsPres, mBuf); + + CMCHKUNPK(SUnpkU16, ¶m->rxAntennaPorts, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->rxAntennaPortsPres, mBuf); + + CMCHKUNPK(SUnpkU16, ¶m->phySyncMode, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->phySyncModePres, mBuf); + + CMCHKUNPK(SUnpkU16, ¶m->dataRepMode, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->dataRepModePres, mBuf); + + CMCHKUNPK(SUnpkU16, ¶m->rachSrRepMode, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->rachSrRepModePres, mBuf); + + /* UnPacking PHY configuration parameters */ + CMCHKUNPK(SUnpkU16, ¶m->opMode, mBuf); + CMCHKUNPK(SUnpkU32, ¶m->counter, mBuf); + CMCHKUNPK(SUnpkU32, ¶m->period, mBuf); + CMCHKUNPK(SUnpkS16, ¶m->priSigPwr, mBuf); + CMCHKUNPK(SUnpkS16, ¶m->secSigPwr, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->dlEarfcn, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->ulEarfcn, mBuf); + CMCHKUNPK(SUnpkS16, ¶m->pilotSigPwr, mBuf); + /* Added for rgu dynamic delta change*/ + CMCHKUNPK(SUnpkU8, ¶m->numDlUePerTti, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->unLicnsdCfgPres, mBuf); + + if(param->unLicnsdCfgPres) + { + printf("pverma param->unLicnsdCfgPres 2 -->%d \n",param->unLicnsdCfgPres); + CMCHKUNPK(cmUnpkCtfUnLicnsdCellParam, ¶m->lteUCfg, mBuf); + } +#ifdef EMTC_ENABLE + CMCHKUNPK(SUnpkU8, ¶m->catMenabled, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->mPdcchStart, mBuf); + + for (i = 0; i < CTF_MAX_CE_LEVEL; i++) { + CMCHKUNPK(SUnpkU8, ¶m->ceLevelInfo[i].firstPreamble, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->ceLevelInfo[i].lastPreamble, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->ceLevelInfo[i].emtcNumRepPerPreambleAtt, mBuf); + } +#endif + RETVALUE(ROK); +} + + + +/* ctf_c_001.main_4: Modified cmPkCtfCellRecfgInfo() to Add support for + * vendor specific parameters */ +/*********************************************************** +* +* Func: cmPkCtfCellRecfgInfo +* +* +* Desc: Cell Re-configuration Information + * @details This structure contains the information for reconfiguration + * of a cell and its associated resources at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfCellRecfgInfo +( +CtfCellRecfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfCellRecfgInfo(param, mBuf) +CtfCellRecfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfCellRecfgInfo) + +#ifdef ENABLE_API_LOG + CMCHKPK(SPkU8, param->enableAPILog, mBuf); +#endif /* ENABLE_API_LOG */ + /* ctf_c_001.main_3: Added the pack for newly added fileds inside the CFG structure*/ + CMCHKPK(SPkS16, param->secSigPwr, mBuf); + CMCHKPK(SPkS16, param->priSigPwr, mBuf); + CMCHKPK(SPkS16, param->pilotSigPwr, mBuf); + CMCHKPK(SPkU8, param->rachSrRepModePres, mBuf); + CMCHKPK(SPkU16, param->rachSrRepMode, mBuf); + + CMCHKPK(SPkU8, param->dataRepModePres, mBuf); + CMCHKPK(SPkU16, param->dataRepMode, mBuf); + + CMCHKPK(SPkU8, param->phySyncModePres, mBuf); + CMCHKPK(SPkU16, param->phySyncMode, mBuf); + + CMCHKPK(SPkU8, param->rxAntennaPortsPres, mBuf); + CMCHKPK(SPkU16, param->rxAntennaPorts, mBuf); + + CMCHKPK(SPkU8, param->txAntennaPortsPres, mBuf); + CMCHKPK(SPkU16, param->txAntennaPorts, mBuf); + + CMCHKPK(SPkU8, param->pucchProbDtxAckPres, mBuf); + CMCHKPK(SPkU16, param->pucchProbDtxAck, mBuf); + + + CMCHKPK(SPkU8, param->puschProbDtxAckPres, mBuf); + CMCHKPK(SPkU16, param->puschProbDtxAck, mBuf); + + CMCHKPK(SPkU8, param->srsDopEstFactorPres, mBuf); + CMCHKPK(SPkU16, param->srsDopEstFactor, mBuf); + + CMCHKPK(SPkU8, param->prachPkRatio0Pres, mBuf); + CMCHKPK(SPkU16, param->prachPkRatio0, mBuf); + + CMCHKPK(SPkU8, param->prachPkRatio4Pres, mBuf); + CMCHKPK(SPkU16, param->prachPkRatio4, mBuf); + + CMCHKPK(SPkU8, param->pucchNoiseGammaPres, mBuf); + CMCHKPK(SPkU16, param->pucchNoiseGamma, mBuf); + + CMCHKPK(SPkU8, param->extWinMarginPres, mBuf); + CMCHKPK(SPkU16, param->extWinMargin, mBuf); + + CMCHKPK(SPkU8, param->dciPowOsPres, mBuf); + CMCHKPK(SPkU16, param->dciPowOs, mBuf); + + CMCHKPK(SPkU8, param->cfiPowOsPres, mBuf); + CMCHKPK(SPkU16, param->cfiPowOs, mBuf); + + CMCHKPK(SPkU8, param->syncSigPowOsPres, mBuf); + CMCHKPK(SPkU16, param->syncSigPowOs, mBuf); + + CMCHKPK(cmPkCtfTddSfCfgInfo, ¶m->tddSfCfg, mBuf); + CMCHKPK(cmPkCtfSrsUlCfgInfo, ¶m->srsUlCfg, mBuf); + CMCHKPK(cmPkCtfPucchCfgInfo, ¶m->pucchCfg, mBuf); + CMCHKPK(cmPkCtfPhichCfgInfo, ¶m->phichCfg, mBuf); + CMCHKPK(cmPkCtfPuschCfgInfo, ¶m->puschCfg, mBuf); + CMCHKPK(cmPkCtfPdschCfgInfo, ¶m->pdschCfg, mBuf); + CMCHKPK(cmPkCtfPrachCfgInfo, ¶m->prachCfg, mBuf); + CMCHKPK(cmPkLteTimingInfo, ¶m->actvnTime, mBuf); + + CMCHKPK(cmPkCtfAntennaCfgInfo, ¶m->antennaCfg, mBuf); + CMCHKPK(cmPkCtfTxSchemeCfg, ¶m->txCfg, mBuf); + CMCHKPK(cmPkCtfBwCfgInfo, ¶m->bwCfg, mBuf); + CMCHKPK(SPkU8, param->physCellId, mBuf); + CMCHKPK(SPkU8, param->physCellIdPres, mBuf); + CMCHKPK(SPkU8, param->cellIdGrpId, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + CMCHKPK(SPkU32, param->ctfReCfgType, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmUnpkCtfCellRecfgInfo +* +* +* Desc: Cell Re-configuration Information + * @details This structure contains the information for reconfiguration + * of a cell and its associated resources at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfCellRecfgInfo +( +CtfCellRecfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfCellRecfgInfo(param, mBuf) +CtfCellRecfgInfo *param; +Buffer *mBuf; +#endif +{ + + U32 tmpEnum; + TRC3(cmUnpkCtfCellRecfgInfo) + + /* ctf_c_001.main_3: Added the unpack for newly added fileds inside the CFG structure*/ + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->ctfReCfgType = (CtfReCfgType)tmpEnum; + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->cellIdGrpId, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->physCellIdPres, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->physCellId, mBuf); + CMCHKUNPK(cmUnpkCtfBwCfgInfo, ¶m->bwCfg, mBuf); + CMCHKUNPK(cmUnpkCtfTxSchemeCfg, ¶m->txCfg, mBuf); + CMCHKUNPK(cmUnpkCtfAntennaCfgInfo, ¶m->antennaCfg, mBuf); + + CMCHKUNPK(cmUnpkLteTimingInfo, ¶m->actvnTime, mBuf); + CMCHKUNPK(cmUnpkCtfPrachCfgInfo, ¶m->prachCfg, mBuf); + CMCHKUNPK(cmUnpkCtfPdschCfgInfo, ¶m->pdschCfg, mBuf); + CMCHKUNPK(cmUnpkCtfPuschCfgInfo, ¶m->puschCfg, mBuf); + CMCHKUNPK(cmUnpkCtfPhichCfgInfo, ¶m->phichCfg, mBuf); + CMCHKUNPK(cmUnpkCtfPucchCfgInfo, ¶m->pucchCfg, mBuf); + CMCHKUNPK(cmUnpkCtfSrsUlCfgInfo, ¶m->srsUlCfg, mBuf); + CMCHKUNPK(cmUnpkCtfTddSfCfgInfo, ¶m->tddSfCfg, mBuf); + + CMCHKUNPK(SUnpkU16, ¶m->syncSigPowOs, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->syncSigPowOsPres, mBuf); + + CMCHKUNPK(SUnpkU16, ¶m->cfiPowOs, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->cfiPowOsPres, mBuf); + + CMCHKUNPK(SUnpkU16, ¶m->dciPowOs, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->dciPowOsPres, mBuf); + + CMCHKUNPK(SUnpkU16, ¶m->extWinMargin, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->extWinMarginPres, mBuf); + + CMCHKUNPK(SUnpkU16, ¶m->pucchNoiseGamma, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->pucchNoiseGammaPres, mBuf); + + CMCHKUNPK(SUnpkU16, ¶m->prachPkRatio4, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->prachPkRatio4Pres, mBuf); + + CMCHKUNPK(SUnpkU16, ¶m->prachPkRatio0, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->prachPkRatio0Pres, mBuf); + + CMCHKUNPK(SUnpkU16, ¶m->srsDopEstFactor, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->srsDopEstFactorPres, mBuf); + + CMCHKUNPK(SUnpkU16, ¶m->puschProbDtxAck, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->puschProbDtxAckPres, mBuf); + + CMCHKUNPK(SUnpkU16, ¶m->pucchProbDtxAck, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->pucchProbDtxAckPres, mBuf); + + CMCHKUNPK(SUnpkU16, ¶m->txAntennaPorts, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->txAntennaPortsPres, mBuf); + + CMCHKUNPK(SUnpkU16, ¶m->rxAntennaPorts, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->rxAntennaPortsPres, mBuf); + + CMCHKUNPK(SUnpkU16, ¶m->phySyncMode, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->phySyncModePres, mBuf); + + CMCHKUNPK(SUnpkU16, ¶m->dataRepMode, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->dataRepModePres, mBuf); + + CMCHKUNPK(SUnpkU16, ¶m->rachSrRepMode, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->rachSrRepModePres, mBuf); + + CMCHKUNPK(SUnpkS16, ¶m->pilotSigPwr, mBuf); + CMCHKUNPK(SUnpkS16, ¶m->priSigPwr, mBuf); + CMCHKUNPK(SUnpkS16, ¶m->secSigPwr, mBuf); + printf("param->pilotSigPwr = %d\nparam->priSigPwr = %d\n param->secSigPwr = %d\n",param->pilotSigPwr,param->priSigPwr,param->secSigPwr); +#ifdef ENABLE_API_LOG + CMCHKUNPK(SUnpkU8, ¶m->enableAPILog, mBuf); +#endif /* ENABLE_API_LOG */ + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmPkCtfDedPdschCfgInfo +* +* +* Desc: Dedicated PDSCH Configuration + * @details This structure contains the information for PDSCH configuration + * specific to an UE. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfDedPdschCfgInfo +( +CtfDedPdschCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfDedPdschCfgInfo(param, mBuf) +CtfDedPdschCfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfDedPdschCfgInfo) + +/*ctf_c_001.main_1*/ + if(param->pres != FALSE) + CMCHKPK(SPkU32, param->pA, mBuf); + CMCHKPK(SPkU8, param->pres, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmUnpkCtfDedPdschCfgInfo +* +* +* Desc: Dedicated PDSCH Configuration + * @details This structure contains the information for PDSCH configuration + * specific to an UE. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfDedPdschCfgInfo +( +CtfDedPdschCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfDedPdschCfgInfo(param, mBuf) +CtfDedPdschCfgInfo *param; +Buffer *mBuf; +#endif +{ + U32 tmpEnum; + TRC3(cmUnpkCtfDedPdschCfgInfo) + + CMCHKUNPK(SUnpkU8, ¶m->pres, mBuf); +/*ctf_c_001.main_1*/ + if(param->pres != FALSE) + { + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->pA = (CtfPdschPaParam)tmpEnum; + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmPkCtfDedPucchCfgInfo +* +* +* Desc: Dedicated PUCCH Configuration + * @details This structure contains the information for setting-up/release + * PUCCH configuration specific to an UE. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfDedPucchCfgInfo +( +CtfDedPucchCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfDedPucchCfgInfo(param, mBuf) +CtfDedPucchCfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfDedPucchCfgInfo) + +/*ctf_c_001.main_1*/ + if(param->pres != FALSE) + { +#ifdef CTF_VER3 + /*ctf_c_001.main_4:115549: packing tddAckNackFBMode and tddAckNackCfgPres */ + if (param->tddAckNackCfgPres != FALSE) + { + CMCHKPK(SPkU32, param->tddAckNackFBMode, mBuf); + } + + CMCHKPK(SPkU8, param->tddAckNackCfgPres, mBuf); +#endif /* CTF_VER3 */ + CMCHKPK(SPkU16, param->pucchSetup.n1PUCCHRep, mBuf); +#ifdef CTF_VER3 + /*ctf_c_001.main_4:115549: packing pucchSetup.repFactPres */ + if (param->pucchSetup.repFactPres) + { + CMCHKPK(SPkU32, param->pucchSetup.repFact, mBuf); + } + + CMCHKPK(SPkU8, param->pucchSetup.repFactPres, mBuf); +#else + CMCHKPK(SPkU32, param->pucchSetup.repFact, mBuf); +#endif /* CTF_VER3 */ + CMCHKPK(SPkU8, param->dedPucchCfgType, mBuf); + } + CMCHKPK(SPkU8, param->pres, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmUnpkCtfDedPucchCfgInfo +* +* +* Desc: Dedicated PUCCH Configuration + * @details This structure contains the information for setting-up/release + * PUCCH configuration specific to an UE. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfDedPucchCfgInfo +( +CtfDedPucchCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfDedPucchCfgInfo(param, mBuf) +CtfDedPucchCfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCtfDedPucchCfgInfo) + + CMCHKUNPK(SUnpkU8, ¶m->pres, mBuf); +/*ctf_c_001.main_1*/ + if(param->pres != FALSE) + { + CMCHKUNPK(SUnpkU8, ¶m->dedPucchCfgType, mBuf); +#ifdef CTF_VER3 + /* ctf_c_001.main_4:115549: unpacking pucchSetup.repFactPres */ + CMCHKUNPK(SUnpkU8, ¶m->pucchSetup.repFactPres, mBuf); + + if (param->pucchSetup.repFactPres) + { + CMCHKUNPK(SUnpkU32, (U32 *)¶m->pucchSetup.repFact, mBuf); + } +#else + CMCHKUNPK(SUnpkU32, (U32 *)¶m->pucchSetup.repFact, mBuf); +#endif /*CTF_VER3 */ + CMCHKUNPK(SUnpkU16, ¶m->pucchSetup.n1PUCCHRep, mBuf); +#ifdef CTF_VER3 + /*ctf_c_001.main_4:115549: unpacking tddAckNackCfgPres and tddAckNackFBMode */ + CMCHKUNPK(SUnpkU8, ¶m->tddAckNackCfgPres, mBuf); + + if (param->tddAckNackCfgPres != FALSE) + { + CMCHKUNPK(SUnpkU32, (U32 *)¶m->tddAckNackFBMode, mBuf); + } +#endif /* CTF_VER3 */ + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmPkCtfDedPuschCfgInfo +* +* +* Desc: Dedicated PUSCH Configuration + * @details This structure contains the information for PUCCH + * configuration specific to an UE. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfDedPuschCfgInfo +( +CtfDedPuschCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfDedPuschCfgInfo(param, mBuf) +CtfDedPuschCfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfDedPuschCfgInfo) + +/*ctf_c_001.main_1*/ + if(param->pres != FALSE) + { + CMCHKPK(SPkU8, param->betaOffsetCqiIdx, mBuf); + CMCHKPK(SPkU8, param->betaOffsetRiIdx, mBuf); + CMCHKPK(SPkU8, param->betaOffsetAckIdx, mBuf); + } + CMCHKPK(SPkU8, param->pres, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmUnpkCtfDedPuschCfgInfo +* +* +* Desc: Dedicated PUSCH Configuration + * @details This structure contains the information for PUCCH + * configuration specific to an UE. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfDedPuschCfgInfo +( +CtfDedPuschCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfDedPuschCfgInfo(param, mBuf) +CtfDedPuschCfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCtfDedPuschCfgInfo) + + CMCHKUNPK(SUnpkU8, ¶m->pres, mBuf); +/*ctf_c_001.main_1*/ + if(param->pres != FALSE) + { + CMCHKUNPK(SUnpkU8, ¶m->betaOffsetAckIdx, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->betaOffsetRiIdx, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->betaOffsetCqiIdx, mBuf); + } + RETVALUE(ROK); +} + + +#ifndef TFU_UPGRADE + +/*********************************************************** +* +* Func: cmPkCtfCqiRptModePeriodic +* +* +* Desc: Periodic CQI Report Configuration + * @details This structure contains the information for periodic CQI report + * related configuration specific to an UE. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfCqiRptModePeriodic +( +CtfCqiRptModePeriodic *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfCqiRptModePeriodic(param, mBuf) +CtfCqiRptModePeriodic *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfCqiRptModePeriodic) +/* ctf_c_001.main_2: added packning for cqiMask*/ +#ifdef CTF_VER1 + CMCHKPK(SPkU32, (U32 )param->cqiSetup.cqiMask.cqiMaskSetup, mBuf); + CMCHKPK(SPkU8, param->cqiSetup.cqiMask.pres, mBuf); +#endif /* CTF_VER1 */ + CMCHKPK(SPkU8, param->cqiSetup.simultaneousAckNack, mBuf); + CMCHKPK(SPkU16, param->cqiSetup.riCfgIndx, mBuf); + CMCHKPK(SPkU8, param->cqiSetup.riCfgPres, mBuf); + CMCHKPK(SPkU8, param->cqiSetup.subbandCqi.k, mBuf); + CMCHKPK(SPkU8, param->cqiSetup.formatIndicator, mBuf); + CMCHKPK(SPkU16, param->cqiSetup.cqiPmiCfgIndx, mBuf); + CMCHKPK(SPkU16, param->cqiSetup.cqiPUCCHRsrcIndx, mBuf); + CMCHKPK(SPkU8, param->cqiPeriodicCfgType, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmUnpkCtfCqiRptModePeriodic +* +* +* Desc: Periodic CQI Report Configuration + * @details This structure contains the information for periodic CQI report + * related configuration specific to an UE. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfCqiRptModePeriodic +( +CtfCqiRptModePeriodic *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfCqiRptModePeriodic(param, mBuf) +CtfCqiRptModePeriodic *param; +Buffer *mBuf; +#endif +{ +#ifdef CTF_VER1 + U32 tmpEnum; +#endif + TRC3(cmUnpkCtfCqiRptModePeriodic) + + CMCHKUNPK(SUnpkU8, ¶m->cqiPeriodicCfgType, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->cqiSetup.cqiPUCCHRsrcIndx, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->cqiSetup.cqiPmiCfgIndx, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->cqiSetup.formatIndicator, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->cqiSetup.subbandCqi.k, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->cqiSetup.riCfgPres, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->cqiSetup.riCfgIndx, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->cqiSetup.simultaneousAckNack, mBuf); +/* ctf_c_001.main_2: added Unpackning for cqiMask*/ +#ifdef CTF_VER1 + CMCHKUNPK(SUnpkU8, ¶m->cqiSetup.cqiMask.pres, mBuf); + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->cqiSetup.cqiMask.cqiMaskSetup = tmpEnum; +#endif /* CTF_VER1 */ + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmPkCtfCqiReportCfgInfo +* +* +* Desc: CQI Report Configuration + * @details This structure contains the information for CQI report + * related configuration specific to an UE. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfCqiReportCfgInfo +( +CtfCqiReportCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfCqiReportCfgInfo(param, mBuf) +CtfCqiReportCfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfCqiReportCfgInfo) + +/*ctf_c_001.main_1*/ + if(param->pres != FALSE) + { +#ifdef CTF_VER2 + /* + * ctf_c_001.main_2: Added provision to send Periodic and aPeriodic CQI + *report configuration in the same message + */ + if(param->reportMode.aPeriodicRpt.pres != FALSE) + { + CMCHKPK(SPkU32, param->reportMode.aPeriodicRpt.aPeriodicRptMode, mBuf); + } + CMCHKPK(SPkU8, param->reportMode.aPeriodicRpt.pres, mBuf); + + if(param->reportMode.periodicRpt.pres != FALSE) + { + CMCHKPK(cmPkCtfCqiRptModePeriodic, ¶m->reportMode.periodicRpt, mBuf); + } + CMCHKPK(SPkU8, param->reportMode.periodicRpt.pres, mBuf); + +#else /* CTF_VER2 */ + + switch(param->reportingMode) { + case CTF_CQI_RPTMODE_PRDIOC: + CMCHKPK(cmPkCtfCqiRptModePeriodic, ¶m->reportMode.periodicRpt, mBuf); + break; + case CTF_CQI_RPTMODE_APRDIOC: + CMCHKPK(SPkU32, param->reportMode.aPeriodicRpt, mBuf); + break; + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkU8, param->reportingMode, mBuf); +#endif /* CTF_VER2 */ + +/* ctf_c_001.main_2: added packning for pmiRiRpt*/ +#ifdef CTF_VER1 + CMCHKPK(SPkU32, param->pmiRiRpt.pmiRiRptSetup, mBuf); + CMCHKPK(SPkU8, param->pmiRiRpt.pres, mBuf); +#endif /* CTF_VER1 */ + } + + CMCHKPK(SPkU8, param->pres, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmUnpkCtfCqiReportCfgInfo +* +* +* Desc: CQI Report Configuration + * @details This structure contains the information for CQI report + * related configuration specific to an UE. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfCqiReportCfgInfo +( +CtfCqiReportCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfCqiReportCfgInfo(param, mBuf) +CtfCqiReportCfgInfo *param; +Buffer *mBuf; +#endif +{ +#if defined (CTF_VER1) || defined (CTF_VER2) + U32 tmpEnum; +#endif + TRC3(cmUnpkCtfCqiReportCfgInfo) + + CMCHKUNPK(SUnpkU8, ¶m->pres, mBuf); +/*ctf_c_001.main_1*/ + if(param->pres != FALSE) + { +/* ctf_c_001.main_2: added Unpackning for cqiMask*/ +#ifdef CTF_VER1 + CMCHKUNPK(SUnpkU8, ¶m->pmiRiRpt.pres, mBuf); + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->pmiRiRpt.pmiRiRptSetup = tmpEnum; +#endif /* CTF_VER1 */ + +#ifdef CTF_VER2 + /* + *ctf_c_001.main_2: Added provision to send Periodic and aPeriodic CQI + *report configuration in the same message + */ + CMCHKUNPK(SUnpkU8, ¶m->reportMode.periodicRpt.pres, mBuf) + if(param->reportMode.periodicRpt.pres != FALSE) + { + CMCHKUNPK(cmUnpkCtfCqiRptModePeriodic, ¶m->reportMode.periodicRpt, mBuf); + } + + CMCHKUNPK(SUnpkU8, ¶m->reportMode.aPeriodicRpt.pres, mBuf) + if(param->reportMode.aPeriodicRpt.pres != FALSE) + { + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->reportMode.aPeriodicRpt.aPeriodicRptMode = + (CtfCqiRptModeAperiodic)tmpEnum; + } + +#else /* CTF_VER2 */ + + CMCHKUNPK(SUnpkU8, ¶m->reportingMode, mBuf); + switch(param->reportingMode) { + case CTF_CQI_RPTMODE_APRDIOC: + CMCHKUNPK(SUnpkU32, (U32 *)¶m->reportMode.aPeriodicRpt, mBuf); + break; + case CTF_CQI_RPTMODE_PRDIOC: + CMCHKUNPK(cmUnpkCtfCqiRptModePeriodic, ¶m->reportMode.periodicRpt, mBuf); + break; + default : + RETVALUE(RFAILED); + } +#endif /* CTF_VER2 */ + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmPkCtfDedSrsUlCfgInfo +* +* +* Desc: Dedicated Uplink SRS Configuration + * @details This structure contains the information for setting-up/release + * UL SRS configuration specific to an UE. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfDedSrsUlCfgInfo +( +CtfDedSrsUlCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfDedSrsUlCfgInfo(param, mBuf) +CtfDedSrsUlCfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfDedSrsUlCfgInfo) + +/*ctf_c_001.main_1*/ + if(param->pres != FALSE) + { + CMCHKPK(SPkU8, param->dedSrsSetup.cyclicShift, mBuf); + CMCHKPK(SPkU8, param->dedSrsSetup.txComb, mBuf); + CMCHKPK(SPkU16, param->dedSrsSetup.srsCfgIdx, mBuf); + CMCHKPK(SPkU8, param->dedSrsSetup.duration, mBuf); + CMCHKPK(SPkU8, param->dedSrsSetup.freqDmnPos, mBuf); + CMCHKPK(SPkU8, param->dedSrsSetup.srsHopngBw, mBuf); + CMCHKPK(SPkU8, param->dedSrsSetup.srsBw, mBuf); + CMCHKPK(SPkU8, param->dedSrsUlCfgType, mBuf); + } + CMCHKPK(SPkU8, param->pres, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmUnpkCtfDedSrsUlCfgInfo +* +* +* Desc: Dedicated Uplink SRS Configuration + * @details This structure contains the information for setting-up/release + * UL SRS configuration specific to an UE. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfDedSrsUlCfgInfo +( +CtfDedSrsUlCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfDedSrsUlCfgInfo(param, mBuf) +CtfDedSrsUlCfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCtfDedSrsUlCfgInfo) + + CMCHKUNPK(SUnpkU8, ¶m->pres, mBuf); +/*ctf_c_001.main_1*/ + if(param->pres != FALSE) + { + CMCHKUNPK(SUnpkU8, ¶m->dedSrsUlCfgType, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->dedSrsSetup.srsBw, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->dedSrsSetup.srsHopngBw, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->dedSrsSetup.freqDmnPos, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->dedSrsSetup.duration, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->dedSrsSetup.srsCfgIdx, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->dedSrsSetup.txComb, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->dedSrsSetup.cyclicShift, mBuf); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmPkCtfDedSRCfgInfo +* +* +* Desc: Dedicated SR Configuration + * @details This structure contains the information for setting-up/release + * SR configuration specific to an UE at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfDedSRCfgInfo +( +CtfDedSRCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfDedSRCfgInfo(param, mBuf) +CtfDedSRCfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfDedSRCfgInfo) + +/*ctf_c_001.main_1*/ + if(param->pres != FALSE) + { + CMCHKPK(SPkU8, param->dedSrSetup.srCfgIdx, mBuf); + CMCHKPK(SPkU16, param->dedSrSetup.srPUCCHRi, mBuf); + CMCHKPK(SPkU8, param->dedSRCfgType, mBuf); + } + CMCHKPK(SPkU8, param->pres, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmUnpkCtfDedSRCfgInfo +* +* +* Desc: Dedicated SR Configuration + * @details This structure contains the information for setting-up/release + * SR configuration specific to an UE at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfDedSRCfgInfo +( +CtfDedSRCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfDedSRCfgInfo(param, mBuf) +CtfDedSRCfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCtfDedSRCfgInfo) + + CMCHKUNPK(SUnpkU8, ¶m->pres, mBuf); +/*ctf_c_001.main_1*/ + if(param->pres != FALSE) + { + CMCHKUNPK(SUnpkU8, ¶m->dedSRCfgType, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->dedSrSetup.srPUCCHRi, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->dedSrSetup.srCfgIdx, mBuf); + } + RETVALUE(ROK); +} + +#endif /* TFU_UPGRADE */ + + +/*********************************************************** +* +* Func: cmPkCtfDedAntCfgInfo +* +* +* Desc: Dedicated Antenna Configuration + * @details This structure contains the information for antenna related + * configuration specific to an UE at PHY. +* +* +* Ret : S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfDedAntCfgInfo +( +CtfDedAntCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfDedAntCfgInfo(param, mBuf) +CtfDedAntCfgInfo *param; +Buffer *mBuf; +#endif +{ + +#ifdef CTF_VER2 + U8 idx; +#endif /* CTF_VER2 */ + + TRC3(cmPkCtfDedAntCfgInfo) + +/*ctf_c_001.main_1*/ + if(param->pres != FALSE) + { + CMCHKPK(SPkU32, param->ueTxAntSelection.txAntSelect, mBuf); + CMCHKPK(SPkU8, param->ueTxAntSelection.cfgType, mBuf); + /* ctf_c_001.main_3 txMode is of type enum and is 32bit length */ + CMCHKPK(SPkU32, (U32)param->txMode, mBuf); +#ifdef CTF_VER2 + /* + *ctf_c_001.main_2: Added Packing of CodeBookSubsetRestriction parameter + */ + switch(param->codeBookSubsetRes.ctfCdBkRestType) + { + case N2TX_ANT_TM3: + CMCHKPK(SPkU8, param->codeBookSubsetRes.codeBookSubsetRestn. + n2TxAntTm3, mBuf); + break; + + case N4TX_ANT_TM3: + CMCHKPK(SPkU8, param->codeBookSubsetRes.codeBookSubsetRestn. + n4TxAntTm3, mBuf); + break; + + case N2TX_ANT_TM4: + CMCHKPK(SPkU8, param->codeBookSubsetRes.codeBookSubsetRestn. + n2TxAntTm4, mBuf); + break; + + case N4TX_ANT_TM4: + for(idx = 0; idx < 8; idx++) + CMCHKPK(SPkU8, param->codeBookSubsetRes.codeBookSubsetRestn. + n4TxAntTm4[idx], mBuf); + break; + + case N2TX_ANT_TM5: + CMCHKPK(SPkU8, param->codeBookSubsetRes.codeBookSubsetRestn. + n2TxAntTm5, mBuf); + break; + + case N4TX_ANT_TM5: + CMCHKPK(SPkU16, param->codeBookSubsetRes.codeBookSubsetRestn. + n4TxAntTm5, mBuf); + break; + + case N2TX_ANT_TM6: + CMCHKPK(SPkU8, param->codeBookSubsetRes.codeBookSubsetRestn. + n2TxAntTm6, mBuf); + break; + + case N4TX_ANT_TM6: + CMCHKPK(SPkU16, param->codeBookSubsetRes.codeBookSubsetRestn. + n4TxAntTm6, mBuf); + break; + default : + break; + + } + CMCHKPK(SPkU32, param->codeBookSubsetRes.ctfCdBkRestType, mBuf); +#endif /* CTF_VER2 */ + } + CMCHKPK(SPkU8, param->pres, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmUnpkCtfDedAntCfgInfo +* +* +* Desc: Dedicated Antenna Configuration + * @details This structure contains the information for antenna related + * configuration specific to an UE at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfDedAntCfgInfo +( +CtfDedAntCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfDedAntCfgInfo(param, mBuf) +CtfDedAntCfgInfo *param; +Buffer *mBuf; +#endif +{ +#ifdef CTF_VER2 + S16 idx; +#endif /* CTF_VER2 */ + + U32 tmpEnum; + + TRC3(cmUnpkCtfDedAntCfgInfo) + + CMCHKUNPK(SUnpkU8, ¶m->pres, mBuf); +/*ctf_c_001.main_1*/ + if(param->pres != FALSE) + { +#ifdef CTF_VER2 + /* + * Added Unpacking for CodeBookSubsetRestriction parameter + */ + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->codeBookSubsetRes.ctfCdBkRestType = (CtfCdBkSubsetRestnType)tmpEnum; + switch(param->codeBookSubsetRes.ctfCdBkRestType) + { + case N2TX_ANT_TM3: + CMCHKUNPK(SUnpkU8, ¶m->codeBookSubsetRes.codeBookSubsetRestn. + n2TxAntTm3, mBuf); + break; + + case N4TX_ANT_TM3: + CMCHKUNPK(SUnpkU8, ¶m->codeBookSubsetRes.codeBookSubsetRestn. + n4TxAntTm3, mBuf); + break; + + case N2TX_ANT_TM4: + CMCHKUNPK(SUnpkU8, ¶m->codeBookSubsetRes.codeBookSubsetRestn. + n2TxAntTm4, mBuf); + break; + + case N4TX_ANT_TM4: + for(idx = 7; idx >= 0; idx--) + { + CMCHKUNPK(SUnpkU8, &(param->codeBookSubsetRes.codeBookSubsetRestn. + n4TxAntTm4[idx]), mBuf); + } + break; + + case N2TX_ANT_TM5: + CMCHKUNPK(SUnpkU8, ¶m->codeBookSubsetRes.codeBookSubsetRestn. + n2TxAntTm5, mBuf); + break; + + case N4TX_ANT_TM5: + CMCHKUNPK(SUnpkU16, ¶m->codeBookSubsetRes.codeBookSubsetRestn. + n4TxAntTm5, mBuf); + break; + + case N2TX_ANT_TM6: + CMCHKUNPK(SUnpkU8, ¶m->codeBookSubsetRes.codeBookSubsetRestn. + n2TxAntTm6, mBuf); + break; + + case N4TX_ANT_TM6: + CMCHKUNPK(SUnpkU16, ¶m->codeBookSubsetRes.codeBookSubsetRestn. + n4TxAntTm6, mBuf); + break; + default : + break; + } +#endif /* CTF_VER2 */ + /* ctf_c_001.main_3 Enum is 32bit length */ + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->txMode = (CtfUeTxAntMode)tmpEnum; + CMCHKUNPK(SUnpkU8, ¶m->ueTxAntSelection.cfgType, mBuf); + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->ueTxAntSelection.txAntSelect = (CtfUeTxAntSelectType)tmpEnum; + } + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func: cmPkCtfUeSecCellCfgInfo +* +* +* Desc: Secondary Cell Configuration for a UE + * @details This structure contains the information for +* secondary cells for the UE +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfUeSecCellCfgInfo +( +CtfUeSecCellCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfUeSecCellCfgInfo(*param, mBuf) +CtfUeSecCellCfgInfo *param; +Buffer *mBuf; +#endif +{ + CMCHKPK(SPkU16, param->sCellId, mBuf); + CMCHKPK(SPkU8, param->sCellIdx, mBuf); + + RETVALUE(ROK); +} +/*********************************************************** +* +* Func: cmPkCtfSecCellCfgInfo +* +* +* Desc: Secondary Cell Configuration for a UE + * @details This structure contains the information for +* secondary cells for the UE +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfSecCellCfgInfo +( +CtfSecCellCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfSecCellCfgInfo(*param, mBuf) +CtfSecCellCfgInfo *param; +Buffer *mBuf; +#endif +{ + S8 idx; + + for(idx = param->numSCells - 1; idx >= 0; idx--) + { + CMCHKPK(cmPkCtfUeSecCellCfgInfo, ¶m->ueSCellDedCfg[(U8)idx], mBuf); + } + CMCHKPK(SPkU32, param->sCellAction, mBuf); + CMCHKPK(SPkU8, param->numSCells, mBuf); + + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func: cmUnpkCtfUeSecCellCfgInfo +* +* +* Desc: Secondary Cell Configuration for a UE + * @details This structure contains the information for +* secondary cells for the UE +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfUeSecCellCfgInfo +( +CtfUeSecCellCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfUeSecCellCfgInfo(*param, mBuf) +CtfUeSecCellCfgInfo *param; +Buffer *mBuf; +#endif +{ + CMCHKUNPK(SUnpkU8, ¶m->sCellIdx, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->sCellId, mBuf); + + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func: cmUnpkCtfSecCellCfgInfo +* +* +* Desc: Secondary Cell Configuration for a UE + * @details This structure contains the information for +* secondary cells for the UE +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ + +#ifdef ANSI +PUBLIC S16 cmUnpkCtfSecCellCfgInfo +( +CtfSecCellCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfSecCellCfgInfo(*param, mBuf) +CtfSecCellCfgInfo *param; +Buffer *mBuf; +#endif +{ + U8 idx; + + CMCHKUNPK(SUnpkU8, ¶m->numSCells, mBuf); + CMCHKUNPK(SUnpkU32, (U32*)¶m->sCellAction, mBuf); + for(idx = 0 ; idx < param->numSCells; idx++) + { + CMCHKUNPK(cmUnpkCtfUeSecCellCfgInfo, ¶m->ueSCellDedCfg[idx], mBuf); + } + + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func: cmPkCtfUeCatCfgInfo +* +* +* Desc: UE Category Configuration + * @details This structure contains the information for configuring + * the UE category at PHY. +* +* +* Ret : S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfUeCatCfgInfo +( +CtfUeCatCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfUeCatCfgInfo(param, mBuf) +CtfUeCatCfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfUeCatCfgInfo) + +/*ctf_c_001.main_1*/ + if(param->pres != FALSE) + CMCHKPK(SPkU32, param->ueCategory, mBuf); + CMCHKPK(SPkU8, param->pres, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmUnpkCtfUeCatCfgInfo +* +* +* Desc: UE Category Configuration + * @details This structure contains the information for configuring + * the UE category at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfUeCatCfgInfo +( +CtfUeCatCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfUeCatCfgInfo(param, mBuf) +CtfUeCatCfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCtfUeCatCfgInfo) + + CMCHKUNPK(SUnpkU8, ¶m->pres, mBuf); +/*ctf_c_001.main_1*/ + if(param->pres != FALSE) + CMCHKUNPK(SUnpkU32, (U32 *)¶m->ueCategory, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmPkCtfDedCfgInfo +* +* +* Desc: Dedicated Configuration Information + * @details This structure contains the information for configuration + * of UE-specific physical channel resources at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfDedCfgInfo +( +CtfDedCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfDedCfgInfo(param, mBuf) +CtfDedCfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfDedCfgInfo) +#ifdef EMTC_ENABLE + CMCHKPK(SPkU8, param->isEmtcUe, mBuf); +#endif + CMCHKPK(cmPkCtfDedAntCfgInfo, ¶m->antInfo, mBuf); +#ifndef TFU_UPGRADE + CMCHKPK(cmPkCtfDedSRCfgInfo, ¶m->dedSRCfg, mBuf); + CMCHKPK(cmPkCtfDedSrsUlCfgInfo, ¶m->srsUlCfg, mBuf); + CMCHKPK(cmPkCtfCqiReportCfgInfo, ¶m->cqiRptCfg, mBuf); +#endif /* TFU_UPGRADE */ + CMCHKPK(cmPkCtfDedPuschCfgInfo, ¶m->puschCfg, mBuf); + CMCHKPK(cmPkCtfDedPucchCfgInfo, ¶m->pucchCfg, mBuf); + CMCHKPK(cmPkCtfDedPdschCfgInfo, ¶m->pdschCfg, mBuf); + CMCHKPK(cmPkCtfUeCatCfgInfo, ¶m->ueCatCfg, mBuf); + CMCHKPK(cmPkLteRnti, param->ueId, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmUnpkCtfDedCfgInfo +* +* +* Desc: Dedicated Configuration Information + * @details This structure contains the information for configuration + * of UE-specific physical channel resources at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfDedCfgInfo +( +CtfDedCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfDedCfgInfo(param, mBuf) +CtfDedCfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCtfDedCfgInfo) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->ueId, mBuf); + CMCHKUNPK(cmUnpkCtfUeCatCfgInfo, ¶m->ueCatCfg, mBuf); + CMCHKUNPK(cmUnpkCtfDedPdschCfgInfo, ¶m->pdschCfg, mBuf); + CMCHKUNPK(cmUnpkCtfDedPucchCfgInfo, ¶m->pucchCfg, mBuf); + CMCHKUNPK(cmUnpkCtfDedPuschCfgInfo, ¶m->puschCfg, mBuf); +#ifndef TFU_UPGRADE + CMCHKUNPK(cmUnpkCtfCqiReportCfgInfo, ¶m->cqiRptCfg, mBuf); + CMCHKUNPK(cmUnpkCtfDedSrsUlCfgInfo, ¶m->srsUlCfg, mBuf); + CMCHKUNPK(cmUnpkCtfDedSRCfgInfo, ¶m->dedSRCfg, mBuf); +#endif /* TFU_UPGRADE */ + CMCHKUNPK(cmUnpkCtfDedAntCfgInfo, ¶m->antInfo, mBuf); +#ifdef EMTC_ENABLE + CMCHKUNPK(SUnpkU8, ¶m->isEmtcUe, mBuf); +#endif + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmPkCtfDedRecfgInfo +* +* +* Desc: Dedicated Re-configuration Information + * @details This structure contains the information for re-configuration + * of UE-specific physical channel resources at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfDedRecfgInfo +( +CtfDedRecfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfDedRecfgInfo(param, mBuf) +CtfDedRecfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfDedRecfgInfo) + + CMCHKPK(cmPkCtfSecCellCfgInfo, ¶m->sCellInfo,mBuf); + /*ctf_c_001.main_1*/ + CMCHKPK(cmPkCtfDedAntCfgInfo, ¶m->antInfo, mBuf); +#ifndef TFU_UPGRADE + CMCHKPK(cmPkCtfCqiReportCfgInfo, ¶m->cqiRptCfg, mBuf); + CMCHKPK(cmPkCtfDedSRCfgInfo, ¶m->dedSRCfg, mBuf); + CMCHKPK(cmPkCtfDedSrsUlCfgInfo, ¶m->srsUlCfg, mBuf); +#endif /* TFU_UPGRADE */ + CMCHKPK(cmPkCtfDedPuschCfgInfo, ¶m->puschCfg, mBuf); + CMCHKPK(cmPkCtfDedPucchCfgInfo, ¶m->pucchCfg, mBuf); + CMCHKPK(cmPkCtfDedPdschCfgInfo, ¶m->pdschCfg, mBuf); + CMCHKPK(cmPkCtfUeCatCfgInfo, ¶m->ueCatCfg, mBuf); + /* ctf_c_001.main_4: ReEst Fix */ +#ifdef CTF_VER3 + CMCHKPK(cmPkLteRnti, param->newUeId, mBuf); +#else + CMCHKPK(cmPkLteRnti, param->newUeId, mBuf); +#endif + CMCHKPK(cmPkLteRnti, param->ueId, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmUnpkCtfDedRecfgInfo +* +* +* Desc: Dedicated Re-configuration Information + * @details This structure contains the information for re-configuration + * of UE-specific physical channel resources at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfDedRecfgInfo +( +CtfDedRecfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfDedRecfgInfo(param, mBuf) +CtfDedRecfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCtfDedRecfgInfo) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->ueId, mBuf); + /* ctf_c_001.main_4: ReEst Fix */ +#ifdef CTF_VER3 + CMCHKUNPK(cmUnpkLteRnti, ¶m->newUeId, mBuf); +#else + CMCHKUNPK(cmUnpkLteRnti, ¶m->newUeId, mBuf); +#endif + CMCHKUNPK(cmUnpkCtfUeCatCfgInfo, ¶m->ueCatCfg, mBuf); + CMCHKUNPK(cmUnpkCtfDedPdschCfgInfo, ¶m->pdschCfg, mBuf); + CMCHKUNPK(cmUnpkCtfDedPucchCfgInfo, ¶m->pucchCfg, mBuf); + CMCHKUNPK(cmUnpkCtfDedPuschCfgInfo, ¶m->puschCfg, mBuf); +#ifndef TFU_UPGRADE + CMCHKUNPK(cmUnpkCtfDedSrsUlCfgInfo, ¶m->srsUlCfg, mBuf); + CMCHKUNPK(cmUnpkCtfDedSRCfgInfo, ¶m->dedSRCfg, mBuf); + /*ctf_c_001.main_1*/ + CMCHKUNPK(cmUnpkCtfCqiReportCfgInfo, ¶m->cqiRptCfg, mBuf); +#endif /* TFU_UPGRADE */ + CMCHKUNPK(cmUnpkCtfDedAntCfgInfo, ¶m->antInfo, mBuf); + + CMCHKUNPK(cmUnpkCtfSecCellCfgInfo, ¶m->sCellInfo,mBuf); + + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmPkCtfCellReleaseInfo +* +* +* Desc: Cell Release Information + * @details This structure contains the information for release/removal + * of a cell and its assocated resources at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfCellReleaseInfo +( +CtfCellReleaseInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfCellReleaseInfo(param, mBuf) +CtfCellReleaseInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfCellReleaseInfo) + + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmUnpkCtfCellReleaseInfo +* +* +* Desc: Cell Release Information + * @details This structure contains the information for release/removal + * of a cell and its assocated resources at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfCellReleaseInfo +( +CtfCellReleaseInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfCellReleaseInfo(param, mBuf) +CtfCellReleaseInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCtfCellReleaseInfo) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmPkCtfDedReleaseInfo +* +* +* Desc: Dedicated Release Information + * @details This structure contains the information for release/removal + * of dedicated/UE-specific configuration at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfDedReleaseInfo +( +CtfDedReleaseInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfDedReleaseInfo(param, mBuf) +CtfDedReleaseInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfDedReleaseInfo) + CMCHKPK(cmPkCtfSecCellCfgInfo, ¶m->sCellInfo,mBuf); + CMCHKPK(cmPkLteRnti, param->ueId, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmUnpkCtfDedReleaseInfo +* +* +* Desc: Dedicated Release Information + * @details This structure contains the information for release/removal + * of dedicated/UE-specific configuration at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfDedReleaseInfo +( +CtfDedReleaseInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfDedReleaseInfo(param, mBuf) +CtfDedReleaseInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCtfDedReleaseInfo) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->ueId, mBuf); + CMCHKUNPK(cmUnpkCtfSecCellCfgInfo, ¶m->sCellInfo,mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmPkCtfCfgInfo +* +* +* Desc: Configuration Information + * @details This structure contains the information for setting-up + * cell or UE-specific configuration at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfCfgInfo +( +CtfCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfCfgInfo(param, mBuf) +CtfCfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfCfgInfo) + + switch(param->cfgElem) { + case CTF_UE_CFG: + CMCHKPK(cmPkCtfDedCfgInfo, ¶m->u.dedCfg, mBuf); + break; + case CTF_CELL_CFG: + CMCHKPK(cmPkCtfCellCfgInfo, ¶m->u.cellCfg, mBuf); + break; + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkU8, param->cfgElem, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmUnpkCtfCfgInfo +* +* +* Desc: Configuration Information + * @details This structure contains the information for setting-up + * cell or UE-specific configuration at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfCfgInfo +( +CtfCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfCfgInfo(param, mBuf) +CtfCfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCtfCfgInfo) + + CMCHKUNPK(SUnpkU8, ¶m->cfgElem, mBuf); + switch(param->cfgElem) { + case CTF_CELL_CFG: + CMCHKUNPK(cmUnpkCtfCellCfgInfo, ¶m->u.cellCfg, mBuf); + break; + case CTF_UE_CFG: + CMCHKUNPK(cmUnpkCtfDedCfgInfo, ¶m->u.dedCfg, mBuf); + break; + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmPkCtfReCfgInfo +* +* +* Desc: Re-configuration Information + * @details This structure contains the information for re-configuring + * cell or UE-specific configuration at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfReCfgInfo +( +CtfReCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfReCfgInfo(param, mBuf) +CtfReCfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfReCfgInfo) + + switch(param->cfgElem) { + case CTF_UE_CFG: + CMCHKPK(cmPkCtfDedRecfgInfo, ¶m->u.dedRecfg, mBuf); + break; + case CTF_CELL_CFG: + CMCHKPK(cmPkCtfCellRecfgInfo, ¶m->u.cellRecfg, mBuf); + break; + /* Starts - Fix for CR ccpu00123185 */ + case CTF_TX_PWR_CFG: + CMCHKPK(cmPkCtfCellPwrcfgInfo, ¶m->u.cellRecfg, mBuf); + break; + /* ends - Fix for CR ccpu00123185 */ + case CTF_CELL_STOP: + CMCHKPK(cmPkCtfCellStop, ¶m->u.cellRecfg, mBuf); + break; + + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkU8, param->cfgElem, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmUnpkCtfReCfgInfo +* +* +* Desc: Re-configuration Information + * @details This structure contains the information for re-configuring + * cell or UE-specific configuration at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfReCfgInfo +( +CtfReCfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfReCfgInfo(param, mBuf) +CtfReCfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCtfReCfgInfo) + + CMCHKUNPK(SUnpkU8, ¶m->cfgElem, mBuf); + switch(param->cfgElem) { + case CTF_CELL_CFG: + CMCHKUNPK(cmUnpkCtfCellRecfgInfo, ¶m->u.cellRecfg, mBuf); + break; + case CTF_UE_CFG: + CMCHKUNPK(cmUnpkCtfDedRecfgInfo, ¶m->u.dedRecfg, mBuf); + break; + /* Starts - Fix for CR ccpu00123185 */ + case CTF_TX_PWR_CFG: + CMCHKUNPK(cmUnpkCtfCellPwrcfgInfo, ¶m->u.cellRecfg, mBuf); + break; + /* ends - Fix for CR ccpu00123185 */ + case CTF_CELL_STOP: + CMCHKUNPK(cmUnpkCtfCellStop, ¶m->u.cellRecfg, mBuf); + break; + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmPkCtfReleaseInfo +* +* +* Desc: Release configuration Information + * @details This structure contains the information for releasing + * cell or UE-specific configuration at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfReleaseInfo +( +CtfReleaseInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfReleaseInfo(param, mBuf) +CtfReleaseInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfReleaseInfo) + + switch(param->cfgElem) { + case CTF_UE_CFG: + CMCHKPK(cmPkCtfDedReleaseInfo, ¶m->u.dedRel, mBuf); + break; + case CTF_CELL_CFG: + CMCHKPK(cmPkCtfCellReleaseInfo, ¶m->u.cellRel, mBuf); + break; + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkU8, param->cfgElem, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmUnpkCtfReleaseInfo +* +* +* Desc: Release configuration Information + * @details This structure contains the information for releasing + * cell or UE-specific configuration at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfReleaseInfo +( +CtfReleaseInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfReleaseInfo(param, mBuf) +CtfReleaseInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCtfReleaseInfo) + + CMCHKUNPK(SUnpkU8, ¶m->cfgElem, mBuf); + switch(param->cfgElem) { + case CTF_CELL_CFG: + CMCHKUNPK(cmUnpkCtfCellReleaseInfo, ¶m->u.cellRel, mBuf); + break; + case CTF_UE_CFG: + CMCHKUNPK(cmUnpkCtfDedReleaseInfo, ¶m->u.dedRel, mBuf); + break; + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmPkCtfCfgReqInfo +* +* +* Desc: Configuration Request information + * @details This is the main structure in the Configuration request primitive. + * -# This structure contains the configuration information as given by + * the RRC to configure PHY layer for common/dedicated resources. + * -# It can contain Config/Reconfig/Release. + * -# The result of configuration is indicated in TfUiCtfCfgCfm. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfCfgReqInfo +( +CtfCfgReqInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfCfgReqInfo(param, mBuf) +CtfCfgReqInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfCfgReqInfo) + + /* ctf_c_001.main_4: Added support for vendor specific parameters */ +#ifdef CTF_VER3 + CMCHKPK(cmPkCtfVendorSpecParams, ¶m->vendorParams, mBuf); +#endif + switch(param->cfgType) { + case CTF_DELETE: + CMCHKPK(cmPkCtfReleaseInfo, ¶m->u.release, mBuf); + break; + case CTF_RECONFIG: + CMCHKPK(cmPkCtfReCfgInfo, ¶m->u.reCfg, mBuf); + break; + case CTF_CONFIG: + CMCHKPK(cmPkCtfCfgInfo, ¶m->u.cfg, mBuf); + break; + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkU8, param->cfgType, mBuf); + RETVALUE(ROK); +} + + + + /* ctf_c_001.main_4: Modified cmUnpkCtfCfgReqInfo() to add support + * for vendor specific parameters */ +/*********************************************************** +* +* Func: cmUnpkCtfCfgReqInfo +* +* +* Desc: Configuration Request information + * @details This is the main structure in the Configuration request primitive. + * -# This structure contains the configuration information as given by + * the RRC to configure PHY layer for common/dedicated resources. + * -# It can contain Config/Reconfig/Release. + * -# The result of configuration is indicated in TfUiCtfCfgCfm. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfCfgReqInfo +( +Pst *pst, +CtfCfgReqInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfCfgReqInfo(param, mBuf) +Pst *pst; +CtfCfgReqInfo *param; +Buffer *mBuf; +#endif +{ + +#ifdef CTF_VER3 + S16 retVal; +#endif + + TRC3(cmUnpkCtfCfgReqInfo) + + CMCHKUNPK(SUnpkU8, ¶m->cfgType, mBuf); + switch(param->cfgType) { + case CTF_CONFIG: + CMCHKUNPK(cmUnpkCtfCfgInfo, ¶m->u.cfg, mBuf); + break; + case CTF_RECONFIG: + CMCHKUNPK(cmUnpkCtfReCfgInfo, ¶m->u.reCfg, mBuf); + break; + case CTF_DELETE: + CMCHKUNPK(cmUnpkCtfReleaseInfo, ¶m->u.release, mBuf); + break; + default : + RETVALUE(RFAILED); + } +#ifdef CTF_VER3 + if((retVal = cmUnpkCtfVendorSpecParams(pst, ¶m->vendorParams, mBuf)) != ROK) + RETVALUE(retVal); +#endif + RETVALUE(ROK); +} + + /* Starts - Fix for CR ccpu00123185 */ +/*********************************************************** +* +* Func: cmPkCtfCellPwrcfgInfo +* +* +* Desc: Cell Re-configuration Information + * @details This structure contains the information for reconfiguration of Reference Signal Power + * of a cell and its associated resources at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfCellPwrcfgInfo +( +CtfCellRecfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfCellPwrcfgInfo(param, mBuf) +CtfCellRecfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfCellPwrcfgInfo) + + /* Added the pack for newly added reference signal Power*/ + CMCHKPK(SPkU32, (U32)param->ctfCellStatus, mBuf); + CMCHKPK(SPkS16, param->pilotSigPwr, mBuf); + CMCHKPK(SPkS16, param->priSigPwr, mBuf); + CMCHKPK(SPkS16, param->secSigPwr, mBuf); + + CMCHKPK(SPkS16, param->pdschCfg.refSigPwr, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func: cmUnpkCtfCellPwrcfgInfo +* +* +* Desc: Cell Re-configuration Information + * @details This structure contains the information for reconfiguration + * of a cell and its associated resources at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfCellPwrcfgInfo +( +CtfCellRecfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfCellPwrcfgInfo(param, mBuf) +CtfCellRecfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCtfCellPwrcfgInfo) + + /* ctf_c_001.main_3: Added the unpack for newly added fileds inside the CFG structure*/ + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + + CMCHKUNPK(SUnpkS16, ¶m->pdschCfg.refSigPwr, mBuf); + CMCHKUNPK(SUnpkS16, ¶m->secSigPwr, mBuf); + CMCHKUNPK(SUnpkS16, ¶m->priSigPwr, mBuf); + CMCHKUNPK(SUnpkS16, ¶m->pilotSigPwr, mBuf); + CMCHKUNPK(SUnpkU32, (U32 *)¶m->ctfCellStatus, mBuf); + + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func: cmPkCtfCellStop +* +* +* Desc: Cell Re-configuration Information + * @details This structure contains the information for reconfiguration of Reference Signal Power + * of a cell and its associated resources at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfCellStop +( +CtfCellRecfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfCellStop(param, mBuf) +CtfCellRecfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkCtfCellStop) + + /* Added the pack for newly added reference signal Power*/ + CMCHKPK(SPkU32, (U32)param->ctfCellStatus, mBuf); + CMCHKPK(SPkS16, param->pilotSigPwr, mBuf); + CMCHKPK(SPkS16, param->priSigPwr, mBuf); + CMCHKPK(SPkS16, param->secSigPwr, mBuf); + + CMCHKPK(SPkS16, param->pdschCfg.refSigPwr, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func: cmUnpkCtfCellStop +* +* +* Desc: Cell Re-configuration Information + * @details This structure contains the information for reconfiguration + * of a cell and its associated resources at PHY. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkCtfCellStop +( +CtfCellRecfgInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfCellStop(param, mBuf) +CtfCellRecfgInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCtfCellStop) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + + CMCHKUNPK(SUnpkS16, ¶m->pdschCfg.refSigPwr, mBuf); + CMCHKUNPK(SUnpkS16, ¶m->secSigPwr, mBuf); + CMCHKUNPK(SUnpkS16, ¶m->priSigPwr, mBuf); + CMCHKUNPK(SUnpkS16, ¶m->pilotSigPwr, mBuf); + CMCHKUNPK(SUnpkU32, (U32 *)¶m->ctfCellStatus, mBuf); + + RETVALUE(ROK); +} + +/* Periodic REM Scan for TPM */ +/*********************************************************** +* +* Func: cmPkPerRemScanCellInfo +* +* +* Desc: Periodic REM cell search response +* @details This Message contains cell search results. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkPerRemScanCellInfo +( +CtfPeriodicRemCellInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkPerRemScanCellInfo(param, mBuf) +CtfPeriodicRemCellInfo *param; +Buffer *mBuf; +#endif +{ + TRC3(cmPkPerRemScanCellInfo) + + CMCHKPK(SPkU16,param->pci, mBuf); + CMCHKPK(SPkU8, param->rsrp, mBuf); + CMCHKPK(SPkU8, param->dlBw, mBuf); + CMCHKPK(SPkU8, param->numTx, mBuf); + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func: cmPkCtfPeriodicCellSearchRsp +* +* +* Desc: Periodic REM cell search response +* @details This Message contains Periodic REM scan results. +* +* +* Ret: S16 +* +* Notes: +* +* File: +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkCtfPeriodicCellSearchRsp +( +CtfPeriodicRemCellSearchRsp *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCtfPeriodicCellSearchRsp(param, mBuf) +CtfPeriodicRemCellSearchRsp *param; +Buffer *mBuf; +#endif +{ + S16 idx; + TRC3(cmPkCtfPeriodicCellSearchRsp) + + for(idx = param->numCells - 1; idx >=0; idx--) + { + CMCHKPK(cmPkPerRemScanCellInfo, ¶m->cellInfo[idx], mBuf); + } + CMCHKPK(SPkU8, param->numCells, mBuf); + + RETVALUE(ROK); +} + +/** +* @brief Configuration Request from App to CL for + * cnm Init Sync responce +* +* @details +* +* Function: cmPkCtfPeriodicRemCellSearchRsp +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] CtfCfgTransId * transId +* @param[in] CtfCnmInitSyncRsp* ctfcnmInitSyncRsp +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkCtfPeriodicRemCellSearchRsp +( +Pst* pst, +SpId spId, +CtfCfgTransId *transId, +CtfPeriodicRemCellSearchRsp *CellCfgRsp +) +#else +PUBLIC S16 cmPkCtfPeriodicRemCellSearchRsp(pst, spId, transId, CellCfgRsp) +Pst* pst; +SpId spId; +CtfCfgTransId *transId; +CtfPeriodicRemCellSearchRsp *CellCfgRsp; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkCtfPeriodicRemCellSearchRsp) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF016, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)CellCfgRsp, + sizeof(CtfPeriodicRemCellSearchRsp)); + RETVALUE(RFAILED); + } + if (pst->selector == CTF_SEL_LC) { + if (cmPkCtfPeriodicCellSearchRsp(CellCfgRsp, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF017, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)CellCfgRsp, + sizeof(CtfPeriodicRemCellSearchRsp)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + else if (pst->selector == CTF_SEL_LWLC) { + + if (cmPkPtr((PTR)CellCfgRsp, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF018, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)CellCfgRsp, + sizeof(CtfPeriodicRemCellSearchRsp)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + } + if(cmPkCtfCfgTransId(transId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF019, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)CellCfgRsp, + sizeof(CtfPeriodicRemCellSearchRsp)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF020, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)CellCfgRsp, + sizeof(CtfPeriodicRemCellSearchRsp)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (pst->selector != CTF_SEL_LWLC) { + SPutSBuf(pst->region, pst->pool, (Data *)CellCfgRsp, + sizeof(CtfPeriodicRemCellSearchRsp)); + } + pst->event = (Event)EVTCTFPREMCELLSRCHRSP; + RETVALUE(SPstTsk(pst,mBuf)); +} + +#ifdef ANSI +PUBLIC S16 cmUnpkCtfPerRemScanCellInfo +( +CtfPeriodicRemCellInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfPerRemScanCellInfo(param, mBuf) +CtfPeriodicRemCellInfo *param; +Buffer *mBuf; +#endif +{ + TRC3(cmUnpkCtfPerRemScanCellInfo); + + CMCHKUNPK(SUnpkU8, ¶m->numTx, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->dlBw, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->rsrp, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->pci, mBuf); + RETVALUE(ROK); +} + +#ifdef ANSI +PUBLIC S16 cmUnpkCtfPerRemCellSrch +( +CtfPeriodicRemCellSearchRsp *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkCtfPerRemCellSrch(param, mBuf) +CtfPeriodicRemCellSearchRsp *param; +Buffer *mBuf; +#endif +{ + S16 idx; + TRC3(cmUnpkCtfPerRemCellSrch); + + CMCHKUNPK(SUnpkU8, ¶m->numCells, mBuf); + for(idx = 0; idx < (param->numCells); idx++) + { + CMCHKUNPK(cmUnpkCtfPerRemScanCellInfo, ¶m->cellInfo[idx], mBuf); + } + + RETVALUE(ROK); +} + +/** +* @brief ENB STOP Indication from PHY to ENB-APP +* +* @details +* +* Function: cmUnpkPerRemCellSrchRsp +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] CtfCfgTransId transId +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkPerRemCellSrchRsp +( +CtfPerRemCellSrchRsp func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkPerRemCellSrchRsp(func, pst, mBuf) +CtfPerRemCellSrchRsp func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId = 0; + CtfCfgTransId transId; + CtfPeriodicRemCellSearchRsp *CellSrchRsp = NULLP; + TRC3(cmUnpkPerRemCellSrchRsp) + + if (SUnpkS16(&suId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF030, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (cmUnpkCtfCfgTransId(&transId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF031, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector != CTF_SEL_LWLC) { + if ((SGetSBuf(pst->region, pst->pool, (Data **)&CellSrchRsp, + sizeof(CtfPeriodicRemCellSearchRsp))) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF024, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + if (pst->selector == CTF_SEL_LWLC) { + if (cmUnpkPtr((PTR *)&CellSrchRsp, mBuf) != ROK) { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + else if (pst->selector == CTF_SEL_LC) + if (cmUnpkCtfPerRemCellSrch(CellSrchRsp, mBuf) != ROK) { + SPutSBuf(pst->region, pst->pool, (Data *)CellSrchRsp, + sizeof(CtfPeriodicRemCellSearchRsp)); + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + /* ctf_c_001.main_3 Compilation warning fix with g++ */ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + (Txt*)&__FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ECTF025, (ErrVal)0, (Txt*)&"Packing failed"); +#endif + RETVALUE(RFAILED); + } + + SPutMsg(mBuf); + RETVALUE((*func)(pst, suId, &transId, CellSrchRsp)); +} +/* Periodic REM Scan for TPM End */ + +/* ends - Fix for CR ccpu00123185 */ +#endif + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/cm/ctf.x b/src/cm/ctf.x new file mode 100755 index 000000000..6372346dc --- /dev/null +++ b/src/cm/ctf.x @@ -0,0 +1,2687 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/********************************************************************** + + Name: LTE PHY layer + + Type: C Include File + + Desc: Structures, variables, and typedefs required by the LTE PHY + and PHY-User Control (CTF) interface. + + File: ctf.x + +**********************************************************************/ + +#ifndef __CTF_X__ +#define __CTF_X__ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file + * @brief CTF Interface File. + */ + +/** + * @brief + * Configuration transaction identifier. + */ +/* Data Structures for CTF */ + +/** + @brief Transaction ID between CTF and User. */ +typedef struct ctfCfgTransId { + U8 trans[CTF_CFG_TRANSID_SIZE]; /*!< User transaction ID */ +} CtfCfgTransId; + + +/* Enumerations for CTF */ +/** + * @enum ctfBandwidth + * This element enumerates the Bandwidth values for PHY in terms of RBs. */ +typedef enum { + CTF_BW_RB_6, + CTF_BW_RB_15, + CTF_BW_RB_25, + CTF_BW_RB_50, + CTF_BW_RB_75, + CTF_BW_RB_100 +} CtfBandwidth; + +/** + * @enum ctfDuplexMode + * This element enumerates the duplex mode for the entire system at PHY. +*/ +typedef enum { + CTF_DUPMODE_FDD=1, + CTF_DUPMODE_TDD +} CtfDuplexMode; + +/** + * @enum ctfSCSpacing + * This element enumerates the sub-carrier spacing for configuration at PHY. +*/ +typedef enum { + CTF_SC_SPACING_15KHZ, + CTF_SC_SPACING_7DOT5KHZ +} CtfSCSpacing; + +/** + * @enum ctfCPCfg + * This element enumerates the cyclic prefix for use at PHY. +*/ +typedef enum { + CTF_CP_NORMAL, + CTF_CP_EXTENDED +} CtfCPCfg; + +/** + * @brief + * This element enumerates the number of antenna ports for configuration at PHY. +*/ +typedef enum { + CTF_AP_CNT_1 = 1, + CTF_AP_CNT_2 = 2, + CTF_AP_CNT_4 = 4 +} CtfAntennaPortsCount; + +/** + * @enum ctfPhichDuration + * This element enumerates the duration for PHICH configuration at PHY. +*/ +typedef enum { + CTF_PHICH_DUR_NORMAL, + CTF_PHICH_DUR_EXTENDED +} CtfPhichDuration; + +/** + * @enum ctfPhichResource + * This element enumerates the resources for PHICH configuration at PHY. +*/ +typedef enum { + CTF_PHICH_RSRC_ONESIXTH, + CTF_PHICH_RSRC_HALF, + CTF_PHICH_RSRC_ONE, + CTF_PHICH_RSRC_TWO +} CtfPhichResource; + +/** + * @enum ctfPuschHoppingMode + * This element enumerates the hopping mode for PUSCH configuration at PHY. +*/ +typedef enum { + CTF_PUSCH_HOPMODE_INTER_SUBFRM, + CTF_PUSCH_HOPMODE_INTRAANDINTERSUBFRM +} CtfPuschHoppingMode; + +/** + * @enum ctfPucchDeltaShift + * This element enumerates the delta shift for PUCCH configuration at PHY. +*/ +typedef enum { + CTF_PUCCH_DELTASHIFT1, + CTF_PUCCH_DELTASHIFT2, + CTF_PUCCH_DELTASHIFT3 +} CtfPucchDeltaShift; + +/** + * @enum ctfPdschPaParam + * This element enumerates the parameter PA for PDSCH configuration at PHY. + * Each enum value maps to a PA value in dBs. +*/ +typedef enum { + CTF_PDSCH_PA_MINUS_6, + CTF_PDSCH_PA_MINUS_4DOT77, + CTF_PDSCH_PA_MINUS_3, + CTF_PDSCH_PA_MINUS_1DOT77, + CTF_PDSCH_PA_ZERO, + CTF_PDSCH_PA_ONE, + CTF_PDSCH_PA_TWO, + CTF_PDSCH_PA_THREE +} CtfPdschPaParam; + +/** + * @enum CtfCqiRptModeAperiodic + * This element enumerates the Aperiodic CQI reporting configuration at PHY. +*/ +typedef enum { + CTF_CQI_RPT_MODE_APERIODIC_RM12, /*!< Corresponds to Mode 1-2 */ + CTF_CQI_RPT_MODE_APERIODIC_RM20, /*!< Corresponds to Mode 2-0 */ + CTF_CQI_RPT_MODE_APERIODIC_RM22, /*!< Corresponds to Mode 2-2 */ + CTF_CQI_RPT_MODE_APERIODIC_RM30, /*!< Corresponds to Mode 3-0 */ + CTF_CQI_RPT_MODE_APERIODIC_RM31 /*!< Corresponds to Mode 3-1 */ +} CtfCqiRptModeAperiodic; + +/** + * @enum CtfUeTxAntSelectType + * This element enumerates the UE TX Antenna selection configuration at PHY. +*/ +typedef enum { + CTF_UE_TX_ANT_SELECT_CLOSEDLOOP, /*!< Closed loop selection */ + CTF_UE_TX_ANT_SELECT_OPENLOOP /*!< Open loop selection */ +} CtfUeTxAntSelectType; + +/** + * @enum CtfPucchRepFactor + * This element enumerates the repetition factors for PUCCH configuration. +*/ +typedef enum { + CTF_PUCCH_REP_FACTOR_N2, /*!< Pucch repetition factor of 2 */ + CTF_PUCCH_REP_FACTOR_N4, /*!< Pucch repetition factor of 4 */ + CTF_PUCCH_REP_FACTOR_N6 /*!< Pucch repetition factor of 6 */ +} CtfPucchRepFactor; + +#ifdef CTF_VER3 +/* ctf_x_001.main_4:115549: */ + /** + * @enum CtfTddAckNackFBMode + * This element enumerates the ACK/NACK feedback mode for TDD mode of + * PUCCH configuration. + */ + typedef enum { + CTF_PUCCH_TDD_ACKNACK_FB_MODE_BUNDLING, /*!< Bundling option */ + CTF_PUCCH_TDD_ACKNACK_FB_MODE_MUXING /*!< Multiplexing option */ + } CtfTddAckNackFBMode; +#endif /* CTF_VER3 */ + +/** + * @enum CtfUeTxAntMode + * This element enumerates the UE Transmission mode. +*/ +typedef enum { + CTF_UE_TX_ANT_MODE_TM1, /*!< Transmission Mode 1 */ + CTF_UE_TX_ANT_MODE_TM2, /*!< Transmission Mode 2 */ + CTF_UE_TX_ANT_MODE_TM3, /*!< Transmission Mode 3 */ + CTF_UE_TX_ANT_MODE_TM4, /*!< Transmission Mode 4 */ + CTF_UE_TX_ANT_MODE_TM5, /*!< Transmission Mode 5 */ + CTF_UE_TX_ANT_MODE_TM6, /*!< Transmission Mode 6 */ + CTF_UE_TX_ANT_MODE_TM7 /*!< Transmission Mode 7 */ +/* ctf_x_001.main_2: Added transmission mode 8*/ +#ifdef CTF_VER1 + ,CTF_UE_TX_ANT_MODE_TM8 /*!< Transmission Mode 8 */ +#endif +} CtfUeTxAntMode; +/* ctf_x_001.main_3:Added enum for CTF reconfiguration */ +/** + * @enum CtfReCfgType + * This element enumerates the CTF reconfiguration type +*/ +typedef enum { + CTF_MAJOR_RECFG, /*!< CTF Major reconfiguration */ + CTF_MINOR_RECFG /*!< CTF Minor reconfiguration */ +} CtfReCfgType; + +/** + * @brief + * UE ID information + */ +typedef struct ctfUeInfo { + CmLteCellId cellId; /*!< Cell ID */ + CmLteRnti ueId; /*!< UE ID */ +}CtfUeInfo; + +/* Data Structures for CTF */ +/** + * @brief Bandwidth Configuration. + * @details This structure contains the uplink and downlink bandwidth + * information for configuration at PHY. +*/ +typedef struct ctfBwCfgInfo { + Bool pres; /*!< Present field */ + CtfBandwidth dlBw; /*!< Downlink Bandwidth in RBs */ + CtfBandwidth ulBw; /*!< Uplink Bandwidth in RBs */ + U8 eUtraBand; /*!< EUTRA Operating Band - 36.104 (5.5) + FDD:(1..14), TDD:(33..40) */ +} CtfBwCfgInfo; + +/** + * @brief Transmission Scheme Configuration. + * @details This structure contains the transmission scheme related information. +*/ +typedef struct ctfTxSchemeCfg { + Bool pres; /*!< Present field */ + CtfDuplexMode duplexMode; /*!< Duplexing Mode: TDD/FDD */ + CtfSCSpacing scSpacing; /*!< Sub-carrier spacing */ + CtfCPCfg cycPfx; /*!< Cyclic prefix */ +} CtfTxSchemeCfg; + +/** + * @brief Antenna Ports configuration. + * @details This structure contains the antenna configuration information for + * configuration at PHY. +*/ +typedef struct ctfAntennaCfgInfo { + CtfAntennaPortsCount antPortsCnt; /*!< Count of antenna ports */ +} CtfAntennaCfgInfo; + +/** + * @brief PRACH configuration. + * @details This structure contains the configuration information for PRACH at PHY. + * -# PRACH preamble sequences are generated by PHY using Zadoff-Chu + * sequences.[Ref: 36.211, 5.7.2] + * -# PRACH preamble format is derived from PRACH Configuration Index. + * [Ref: 36.211, Table 5.7.1-2] + * -# PrachFreqOffset is the first physical resource block allocated to + * the PRACH opportunity considered for preamble format 0, 1, 2 and 3. + * [Ref: 36.211, 5.7.1] +*/ +typedef struct ctfPrachCfgInfo { + Bool pres; /*!< Indicates the presence of this info */ + U16 rootSequenceIndex; /*!< Range (0..837) */ + U8 prachCfgIndex; /*!< Prach Config Index (0..63) */ + U8 zeroCorrelationZoneCfg; /*!< Used for preamble sequence generation + (36.211, 5.7.2); FDD:0..15, TDD:0..6 */ + Bool highSpeedFlag; /*!< TRUE: Restricted set, + FALSE: Unrestricted Set */ + U8 prachFreqOffset; /*!< Range(0..94) */ +} CtfPrachCfgInfo; + +/** + * @brief PDSCH configuration. + * @details This structure contains the PDSCH configuration information for + * configuration at PHY. +*/ +typedef struct ctfPdschCfgInfo { + Bool pres; /*!< Indicates the presence of this info */ + S16 refSigPwr; /*!< Provides downlink reference signal EPRE, + in (-60..50)dBm */ + U8 p_b; /*!< Range(0..3) [36.213, 5.2] */ +} CtfPdschCfgInfo; + +/** + * @brief Basic PUSCH configuration. + * @details This structure contains the basic PUSCH configuration information for + * configuration at PHY. +*/ +typedef struct ctfPuschCfgBasic { + U8 noOfsubBands; /*!< Number of sub-bands, (1..4) */ + CtfPuschHoppingMode hoppingMode; /*!< Hopping Mode */ + U8 hoppingOffset; /*!< Hopping Offset(0..98) */ + Bool enable64QAM; /*!< 64 QAM,TRUE: enabled, + FALSE: disabled */ +} CtfPuschCfgBasic; + +/** + * @brief PUSCH Uplink Reference Signals configuration. + * @details This structure contains the PUSCH configuration information for + * uplink reference signals configuration at PHY. +*/ +typedef struct ctfPuschUlRS { + Bool grpHopEnabled; /*!< Group hopping, TRUE: enabled, FALSE: disabled */ + Bool seqHopEnabled; /*!< Sequence hopping, TRUE: enabled, FALSE: disabled */ + U8 grpNum; /*!< Group number (0..29) */ + U8 cycShift; /*!< Cyclic shift(0..7) */ +} CtfPuschUlRS; + +/** + * @brief PUSCH configuration. + * @details This structure contains the information for PUSCH + * configuration at PHY. +*/ +typedef struct ctfPuschCfgInfo { + Bool pres; /*!< Indicates the presence of PUSCH configuration info */ + CtfPuschCfgBasic puschBasicCfg; /*!< PUSCH basic configuration */ + CtfPuschUlRS puschUlRS; /*!< PUSCH uplink RS */ +} CtfPuschCfgInfo; + +/** + * @brief PHICH configuration. + * @details This structure contains the duration and resource information for + * PHICH configuration at PHY. +*/ +typedef struct ctfPhichCfgInfo { + Bool pres; /*!< Indicates the presence of PHICH + configuration info */ + CtfPhichDuration duration; /*!< PHICH duration, normal/extended, + [36.211, 6.9.3-1] */ + CtfPhichResource resource; /*!< PHICH Resource, Ng [36.211, 6.9] */ +} CtfPhichCfgInfo; + +/** + * @brief PUCCH configuration. + * @details This structure contains the information for PUCCH + * configuration at PHY. +*/ +typedef struct ctfPucchCfgInfo { + Bool pres; /*!< Indicates the presence of PUCCH configuration info */ + U8 nRB; /*!< Number of RBs that are available for use by + PUCCH formats (0..98) */ + U8 nCS; /*!< Number of cyclic shifts used for PUCCH formats (0..7) */ + U16 n1PUCCH; /*!< PUCCH resource for transmission of ACK/NACK (0..2047) */ + CtfPucchDeltaShift deltaShift; /*!< PUCCH delta shift */ +} CtfPucchCfgInfo; + +/** + * @brief SRS uplink configuration. + * @details This structure contains the information for setting-up/release + * of uplink SRS configuration at PHY. +*/ +typedef struct ctfSrsUlCfgInfo { + Bool pres; /*!< Indicates the presence of UL SRS info */ + U8 srsCfgType; /*!< Setup/Release: The setup structure + is valid ,only if srcCfgType is setup. */ + struct srsSetupS + { + U8 srsBw; /*!< SRS bandwidth config (0..7) */ + U8 sfCfg; /*!< SRS sub-frame config (0..15) */ + Bool srsANSimultTx; /*!< Simultaneous transmisson + of SRS and ACK/NACK */ + Bool srsMaxUpPts; /*!< SRS MaxUpPTS: TRUE/FALSE, + This field is valid only for TDD */ + } srsSetup; +} CtfSrsUlCfgInfo; + +/** + * @brief Subframe Configuration for TDD mode. + * @details This structure contains the information for setting-up + * the subframe for TDD mode at PHY. +*/ +typedef struct ctfTddSfCfgInfo { + Bool pres; /*!< Indicates if this info is valid */ + U8 sfAssignment; /*!< UL-DL subframe assignment : (0..6) + 36.211 Table 4.2-2 */ + U8 spclSfPatterns; /*!< Special subframe configuration : (0..8) + 36.211 Table 4.2-1 */ +} CtfTddSfCfgInfo; + +/* ctf_x_001.main_4: Added support for vendor specific parameters */ +#ifdef CTF_VER3 +/** + * @brief Vendor Specific Parameter + * @details This structure contains the Parameters which is spaciftc to + * Vendor. + */ + +typedef struct ctfVendorSpecific{ + U16 buffLen ; /*!< Length of parameters in bytes */ + U8 *paramBuffer ; /*!< parameter Buffer */ +} CtfVendorSpecific; +#endif +/* Cell specific configuration parameters */ + +/** + * @brief Unlicensed Cell Configuration Information. + * @details This structure contains the information for setting-up + * of an unlicensed SDL cell and its associated resources at PHY. +*/ +typedef struct ctfUnLicnsdCellCfg { + U8 coExistMethod; /*!< Continuous/LTE-U/LAA */ + U8 lteOnPeriod; /*!< Percentage of time SDL + is active */ + U8 ccaMethod; /*!< Clear channel assesment method */ + Bool adaptiveTx; /*!< Indicates if the duty cycle is + adaptive or fixed */ + U16 transPeriod; /*!< Defines the duty cycle */ + U16 listenPrd; /*!< Time duration in us for clear channel + assessment */ + S16 energyTh; /*!< Energy threshold in dBFS */ + U16 scanTimePrd; /*!< Time period for RF channel scan */ + U16 activityTh; /*!< Percentage of time for activity detection + to select different EARFCN */ + S32 txPowerLimit; /*! Reference Signal power for Unlicensed Cell */ + U8 numFreq; /*!< Number of unlicensed channels */ + U32 earfcn[CTF_LTEU_MAX_EARFCN]; /*!< Unlicensed channels */ +} CtfUnLicnsdCfgInfo; + +typedef struct ctfLaaScanInd { + S32 status; + U32 nEarfcn; + U32 earfcn[CTF_LTEU_MAX_EARFCN]; +} CtfLaaScanInd; + +#ifdef EMTC_ENABLE +typedef struct ctfEmtcCElevelInfoLst { + U8 firstPreamble; /*!< for each CE mode, starting preamble */ + U8 lastPreamble; /*!< for each CE mode, starting preamble */ + U8 emtcNumRepPerPreambleAtt;/*!< num of repetition per preamble attempt*/ +}CtfEmtcCElevelInfoLst; +#endif + +/** + * @brief Cell Configuration Information. + * @details This structure contains the information for setting-up + * of a cell and its associated resources at PHY. +*/ +typedef struct ctfCellCfgInfo { + CmLteCellId cellId; /*!< Cell ID */ + U8 cellIdGrpId;/*!< Cell Identity Group ID (0..167) */ + SpId macSapId; /*!< MAC SAP Id for Tfu Interface*/ + SpId schSapId; /*!< Scheduler SAP Id for Tfu Interface */ + /*ctf_x_001.main_3: Adding the remaining parameters */ + Bool physCellIdPres ; + U8 physCellId; /*!< Cell ID (0..2) */ + CtfBwCfgInfo bwCfg; /*!< Bandwidth configuration */ + CtfTxSchemeCfg txCfg; /*!< Basic transmission scheme + configuration [36.300, 5.1.1] */ + CtfAntennaCfgInfo antennaCfg; /*!< Antenna configuration */ + CtfPrachCfgInfo prachCfg; /*!< PRACH configuration */ + CtfPdschCfgInfo pdschCfg; /*!< PDSCH configuration */ + CtfPuschCfgInfo puschCfg; /*!< PUSCH configuration */ + CtfPhichCfgInfo phichCfg; /*!< PHICH configuration */ + CtfPucchCfgInfo pucchCfg; /*!< PUCCH configuration */ + CtfSrsUlCfgInfo srsUlCfg; /*!< SRS UL configuration, setup case */ + CtfTddSfCfgInfo tddSfCfg; /*!< SubFrame configuration for TDD only */ + + /*ctf_x_001.main_3: Adding the remaining parameters */ + U16 syncSigPowOs; /*!< Synchronization signal power offset */ + Bool syncSigPowOsPres; + U16 cfiPowOs; /*!< Cfi Power Offset */ + Bool cfiPowOsPres; + U16 dciPowOs; /*!< Dci Power Offser */ + Bool dciPowOsPres; + U16 extWinMargin; /*!< Extraction Window Marin */ + Bool extWinMarginPres; + U16 pucchNoiseGamma; /*!< PUCCH Noise Estimation Gamma*/ + Bool pucchNoiseGammaPres; + U16 prachPkRatio4; /*!< PRACH Format4 Peak Ratio */ + Bool prachPkRatio4Pres; + U16 prachPkRatio0; /*!< PRACH Format0 Peak Ratio */ + Bool prachPkRatio0Pres; + U16 srsDopEstFactor; /*!< Doppler Estimation Compensation Power */ + Bool srsDopEstFactorPres; + U16 puschProbDtxAck; /*!< Portability Dtx Ack PUSCH */ + Bool puschProbDtxAckPres; + U16 pucchProbDtxAck; /*!< Portability Dtx Ack PUCCH Format1 */ + Bool pucchProbDtxAckPres; + + U16 txAntennaPorts ; /*!< The number of cell specific transmit antenna ports */ + Bool txAntennaPortsPres; + U16 rxAntennaPorts ; /*!< The number of cell specific receive antenna ports */ + Bool rxAntennaPortsPres ; + + U16 phySyncMode; /*!< The method used by the PHY to signal the 1ms subframe */ + Bool phySyncModePres; + U16 dataRepMode; /*!< The data report mode for the uplink data */ + Bool dataRepModePres ; + U16 rachSrRepMode; /*!< The reporting mode for RACH.indication and SR.indcation */ + Bool rachSrRepModePres; + /* PHY configuration parameters */ + U16 opMode; + U32 counter; + U32 period; + S16 priSigPwr; + S16 secSigPwr; + U16 dlEarfcn; + U16 ulEarfcn; +/*Start Fix for CR ccpu00123185 */ + S16 pilotSigPwr; +/*End Fix for CR ccpu00123185 */ + /* Added parameter for rgu dynamic delta*/ + U8 numDlUePerTti; + Bool unLicnsdCfgPres; /*!< Flag to indicate unlicensed cell config */ + CtfUnLicnsdCfgInfo lteUCfg; /*!< Unlicensed carrier config */ +#ifdef EMTC_ENABLE + U8 catMenabled; + U8 mPdcchStart; + CtfEmtcCElevelInfoLst ceLevelInfo[CTF_MAX_CE_LEVEL]; +#endif +} CtfCellCfgInfo; + +/** + * @enum CtfCellStatus + * This element enumerates the Cell Status for configuration at PHY. +*/ +typedef enum { + CTF_CELL_DOWN, /*!< Cell DOWN selection */ + CTF_CELL_UP /*!< Cell UP selection */ +} CtfCellStatus; + +/** + * @brief Cell Re-configuration Information. + * @details This structure contains the information for reconfiguration + * of a cell and its associated resources at PHY. +*/ +typedef struct ctfCellRecfgInfo { + CtfReCfgType ctfReCfgType ; + CmLteCellId cellId; /*!< Cell ID */ + /*ctf_x_001.main_3: Adding the remaining parameters */ + U8 cellIdGrpId;/*!< Cell Identity Group ID (0..167) */ + Bool physCellIdPres ; + U8 physCellId; /*!< Cell ID (0..2) */ + CtfBwCfgInfo bwCfg; /*!< Bandwidth configuration */ + CtfTxSchemeCfg txCfg; /*!< Basic transmission scheme + configuration [36.300, 5.1.1] */ + CtfAntennaCfgInfo antennaCfg; /*!< Antenna configuration */ + CmLteTimingInfo actvnTime; /*!< Activation time, only SFN is valid */ + CtfPrachCfgInfo prachCfg; /*!< PRACH configuration */ + CtfPdschCfgInfo pdschCfg; /*!< PDSCH configuration */ + CtfPuschCfgInfo puschCfg; /*!< PUSCH configuration */ + CtfPhichCfgInfo phichCfg; /*!< PHICH configuration */ + CtfPucchCfgInfo pucchCfg; /*!< PUCCH configuration */ + CtfSrsUlCfgInfo srsUlCfg; /*!< SRS UL configuration, setup case */ + CtfTddSfCfgInfo tddSfCfg; /*!< SubFrame configuration for TDD only */ + /*ctf_x_001.main_3: Adding the remaining parameters */ + U16 syncSigPowOs; /*!< Synchronization signal power offset */ + Bool syncSigPowOsPres; + U16 cfiPowOs; /*!< Cfi Power Offset */ + Bool cfiPowOsPres; + U16 dciPowOs; /*!< Dci Power Offser */ + Bool dciPowOsPres; + U16 extWinMargin; /*!< Extraction Window Marin */ + Bool extWinMarginPres; + U16 pucchNoiseGamma; /*!< PUCCH Noise Estimation Gamma*/ + Bool pucchNoiseGammaPres; + U16 prachPkRatio4; /*!< PRACH Format4 Peak Ratio */ + Bool prachPkRatio4Pres; + U16 prachPkRatio0; /*!< PRACH Format0 Peak Ratio */ + Bool prachPkRatio0Pres; + U16 srsDopEstFactor; /*!< Doppler Estimation Compensation Power */ + Bool srsDopEstFactorPres; + U16 puschProbDtxAck; /*!< Portability Dtx Ack PUSCH */ + Bool puschProbDtxAckPres; + U16 pucchProbDtxAck; /*!< Portability Dtx Ack PUCCH Format1 */ + Bool pucchProbDtxAckPres; + + U16 txAntennaPorts ; /*!< The number of cell specific transmit antenna ports */ + Bool txAntennaPortsPres; + U16 rxAntennaPorts ; /*!< The number of cell specific receive antenna ports */ + Bool rxAntennaPortsPres ; + + U16 phySyncMode; /*!< The method used by the PHY to signal the 1ms subframe */ + Bool phySyncModePres; + U16 dataRepMode; /*!< The data report mode for the uplink data */ + Bool dataRepModePres ; + U16 rachSrRepMode; /*!< The reporting mode for RACH.indication and SR.indcation */ + Bool rachSrRepModePres; +/*Start Fix for CR ccpu00123185 */ + S16 pilotSigPwr; + S16 priSigPwr; + S16 secSigPwr; +/*End Fix for CR ccpu00123185 */ + CtfCellStatus ctfCellStatus; +#ifdef ENABLE_API_LOG + U8 enableAPILog; +#endif /* ENABLE_API_LOG */ +} CtfCellRecfgInfo; + +/* UE-specific/Dedicated config parameters */ + +/** + * @brief Dedicated PDSCH Configuration. + * @details This structure contains the information for PDSCH configuration + * specific to an UE. +*/ +typedef struct ctfDedPdschCfgInfo { + Bool pres; /*!< Indicates the presence of PDSCH configuration info */ + CtfPdschPaParam pA; /*!< Pa (in dB) */ +} CtfDedPdschCfgInfo; + +/** + * @brief Dedicated PUCCH Configuration. + * @details This structure contains the information for setting-up/release + * PUCCH configuration specific to an UE. +*/ +typedef struct ctfDedPucchCfgInfo { + Bool pres; /*!< Indicates the presence of PUCCH info */ + U8 dedPucchCfgType; /*!< Setup/Release */ + struct pucchSetupS + { +#ifdef CTF_VER3 + /* ctf_x_001.main_4:115549: */ + Bool repFactPres; /*!< Indicates if repetition factor + is configured or not */ +#endif /* CTF_VER3 */ + CtfPucchRepFactor repFact; /*!< ACK/NACK repetition factor */ + U16 n1PUCCHRep; /*!< PUCCH resource to repeat the + transmission of the corresponding + ACK/NACK responce [36.213, 10.1] */ + } pucchSetup; +#ifdef CTF_VER3 + /* ctf_x_001.main_4:115549: */ + Bool tddAckNackCfgPres; /*! Present flag for TDD + ACK/NACK config */ + CtfTddAckNackFBMode tddAckNackFBMode; /*!< TDD ACK/NACK Feedback Mode + (bundling, multiplexing) */ +#endif /* CTF_VER3 */ +} CtfDedPucchCfgInfo; + +/** + * @brief Dedicated PUSCH Configuration. + * @details This structure contains the information for PUCCH + * configuration specific to an UE. +*/ +typedef struct ctfDedPuschCfgInfo { + Bool pres; /*!< Indicates the presence of PUSCH info */ + U8 betaOffsetAckIdx; /*!< Beta offset ACK index, (0..15) + [36.213, Table 8.6.3.-1] */ + U8 betaOffsetRiIdx; /*!< Beta offset RI index, (0..15) + [36.213, Table 8.6.3.-2] */ + U8 betaOffsetCqiIdx; /*!< Beta offset CQI index, (0..15) + [36.213, Table 8.6.3.-3] */ +} CtfDedPuschCfgInfo; + + +/* ctf_x_001.main_2: Added pmiRiRpt and cqiMask*/ +#ifdef CTF_VER1 +/** + * @enum ctfPmiRiRptSetup + * This element enumerates the CQI PMI Report setup configuration at PHY. +*/ +typedef enum ctfPmiRiRptSetup +{ + CTF_CQI_PMI_RPT_SETUP /*!< PMI Report setup */ +} CtfPmiRiRptSetup; + +/** + * @struct ctfPmiRiRpt + * This struct contains the CQI PMI Report setup configuration at PHY. +*/ +typedef struct ctfPmiRiRpt +{ + Bool pres; /*!< Indicates presence of Pmi Ri Rpt */ + CtfPmiRiRptSetup pmiRiRptSetup; /*!< PMI Report setup */ +} CtfPmiRiRpt; + +/** + * @enum ctfCqiMaskSetup + * This element enumerates the CQI reporting setup configuration at PHY. +*/ +typedef enum ctfCqiMaskSetup +{ + CTF_CQI_RPT_SETUP /*!< Cqi report setup */ +} CtfCqiMaskSetup; + +/** + * @struct ctfCqiMask + * This struct contains the CQI reporting setup configuration at PHY. +*/ +typedef struct ctfCqiMask +{ + Bool pres; /*!< Presence field */ + CtfCqiMaskSetup cqiMaskSetup; /*!< Cqi Report Setup */ +} CtfCqiMask; +#endif /* CTF_VER1 */ + +#ifndef TFU_UPGRADE +/* ctf_x_001.main_2: Moved aPeriodic enum to seperate structure*/ +#ifdef CTF_VER2 +/* Moved aPeriodic enum to seperate structure */ +/** + * @brief APeriodic CQI Report Configuration. + * @details This structure contains the information for Aperiodic CQI report + * related configuration specific to an UE. +*/ +typedef struct ctfCqiReportModeAPeriodic { + Bool pres; + CtfCqiRptModeAperiodic aPeriodicRptMode; /*!region, pst->pool, &mBuf)) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)EKWU001, (ErrVal)0, "SGetMsg() failed"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(ret1); + } + CMCHKPKLOG(SPkS16, spId, mBuf, EKWU002, pst); + CMCHKPKLOG(SPkS16, suId, mBuf, EKWU003, pst); + pst->event = (Event) KWU_EVT_BND_REQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +#ifdef ANSI +PUBLIC S16 cmPkKwuBndCfm +( +Pst * pst, +SuId suId, +U8 status +) +#else +PUBLIC S16 cmPkKwuBndCfm(pst, suId, status) +Pst * pst; +SuId suId; +U8 status; +#endif +{ + S16 ret1; + Buffer *mBuf; + + TRC3(cmPkKwuBndCfm) + + mBuf = NULLP; + + if((ret1 = SGetMsg(pst->region, pst->pool, &mBuf)) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)EKWU004, (ErrVal)0, "SGetMsg() failed"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(ret1); + } + + CMCHKPKLOG(SPkU8, status, mBuf, EKWU005, pst); + CMCHKPKLOG(SPkS16, suId, mBuf, EKWU006, pst); + pst->event = (Event) KWU_EVT_BND_CFM; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +#ifdef ANSI +PUBLIC S16 cmPkKwuUbndReq +( +Pst * pst, +SuId suId, +Reason reason +) +#else +PUBLIC S16 cmPkKwuUbndReq(pst, suId, reason) +Pst * pst; +SuId suId; +Reason reason; +#endif +{ + S16 ret1; + Buffer *mBuf; + + TRC3(cmPkKwuUbndReq) + + mBuf = NULLP; + + if((ret1 = SGetMsg(pst->region, pst->pool, &mBuf)) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)EKWU007, (ErrVal)0, "SGetMsg() failed"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(ret1); + } + CMCHKPKLOG(SPkS16, reason, mBuf, EKWU008, pst); + CMCHKPKLOG(SPkS16, suId, mBuf, EKWU009, pst); + + pst->event = (Event) KWU_EVT_UBND_REQ; + RETVALUE(SPstTsk(pst,mBuf)); +} /* cmPkKwuUbndReq */ + +#ifdef ANSI +PUBLIC S16 cmPkKwuDatReqInfo +( +KwuDatReqInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkKwuDatReqInfo(param, mBuf) +KwuDatReqInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkKwuDatReqInfo); + +#ifdef CCPU_OPT + switch(param->lcType) { + case CM_LTE_LCH_CCCH: + CMCHKPK(cmPkLteRnti, param->tm.rnti, mBuf); + break; + case CM_LTE_LCH_BCCH: + case CM_LTE_LCH_PCCH: + CMCHKPK(cmPkLteTimingInfo, ¶m->tm.tmg, mBuf); +#ifdef EMTC_ENABLE + CMCHKPK(SPkU8, param->emtcDiReason,mBuf); + CMCHKPK(SPkU8, param->pnb,mBuf); +#endif + break; + case CM_LTE_LCH_DTCH: + case CM_LTE_LCH_DCCH: + break; + default : + RETVALUE(RFAILED); + } + CMCHKPK(cmPkLteLcType, param->lcType, mBuf); + +#endif + CMCHKPK(SPkU32, param->sduId, mBuf); + CMCHKPK(cmPkLteRlcId, ¶m->rlcId, mBuf); + RETVALUE(ROK); +} /* cmPkKwuDatReqInfo */ + + +#ifdef ANSI +PUBLIC S16 cmPkKwuDatReq +( +Pst * pst, +SpId spId, +KwuDatReqInfo* datReq, +Buffer * mBuf +) +#else +PUBLIC S16 cmPkKwuDatReq(pst, spId, datReq, mBuf) +Pst * pst; +SpId spId; +KwuDatReqInfo* datReq; +Buffer * mBuf; +#endif +{ +#ifdef LCKWU +#if (ERRCLASS & ERRCLS_ADD_RES) +#endif +#endif /* LCKWU */ + S16 ret1 = ROK; +#ifndef SS_RBUF + KwuDatReqInfo* datReqInfo; +#endif + TRC3(cmPkKwuDatReq) +#ifndef SS_RBUF + switch(pst->selector) + { + case KWU_SEL_LWLC: + { + if(pst->srcEnt == ENTPJ) + { + /* When the Selector is LWLC, we need to allocate memory, copy + * the contents and pass the pointer of the allocated memory. The + * subsequent free would be done during the Unpack function of the + * primitive. */ + if((ret1 = SGetStaticBuffer(pst->region, pst->pool, (Data **)&datReqInfo, + sizeof(KwuDatReqInfo),SS_SHARABLE_MEMORY)) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)EKWU028, (ErrVal)0, "SGetMsg() failed"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(ret1); + } + cmMemcpy((U8*)datReqInfo,(U8*)datReq,sizeof(KwuDatReqInfo)); + CMCHKPK(cmPkPtr,(PTR)datReqInfo, mBuf); + } + else + { + CMCHKPK(cmPkPtr,(PTR)datReq, mBuf); + } + } + break; + case KWU_SEL_LC: + { +#if (ERRCLASS & ERRCLS_ADD_RES) + ret1 = cmPkKwuDatReqInfo( (datReq), mBuf); + if(ret1 != ROK) + { + SPutMsg(mBuf); + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)EKWU010, (ErrVal)ret1, "Packing failure"); + RETVALUE( ret1 ); + } +#else + cmPkKwuDatReqInfo( (datReq), mBuf); +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + if(pst->srcEnt == ENTNH) + { + if (SPutStaticBuffer(pst->region, pst->pool, (Data *)datReq, + sizeof(KwuDatReqInfo),SS_SHARABLE_MEMORY) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + } + break; + default: + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRKWU, (ErrVal)ret1, "pst->selector is invalid\n"); +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(RFAILED); + } + + CMCHKPKLOG(SPkS16, spId, mBuf, EKWU011, pst); +#ifdef L2_L3_SPLIT + if(datReq->rlcId.rbType == CM_LTE_SRB) + { + pst->event = (Event) KWU_EVT_CPLANE_DAT_REQ; + } + else + { + pst->event = (Event) KWU_EVT_UPLANE_DAT_REQ; + } +#else + pst->event = (Event) KWU_EVT_DAT_REQ; +#endif + RETVALUE(SPstTsk(pst,mBuf)); +#else + if (pst->srcEnt == ENTPJ) + { + Void *elem = NULLP; + KwuDatReqDetl *kwuDatReqDetl = NULLP; + elem = SRngGetWIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC); + if (NULLP != elem) + { + kwuDatReqDetl = (KwuDatReqDetl *) elem; + kwuDatReqDetl->spId = spId; + kwuDatReqDetl->lcType = datReq->lcType; + kwuDatReqDetl->sduId = datReq->sduId; + kwuDatReqDetl->rlcId = datReq->rlcId; + kwuDatReqDetl->mBuf = mBuf; + SRngIncrWIndx(SS_RNG_BUF_DLPDCP_TO_DLRLC); + SsRngInfoTbl[SS_RNG_BUF_DLPDCP_TO_DLRLC].pktRate++; + ret1 = ROK; + } + else + { + SsRngInfoTbl[SS_RNG_BUF_DLPDCP_TO_DLRLC].pktDrop++; + SPutMsg(mBuf); + ret1 = RFAILED; + } + } + else + { + switch(pst->selector) + { +#ifdef LCKWU + case KWU_SEL_LC: + { + ret1 = cmPkKwuDatReqInfo( (datReq), mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + SPutMsg(mBuf); + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)EKWU010, (ErrVal)ret1, "Packing failure"); + RETVALUE( ret1 ); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + } + break; + case KWU_SEL_LWLC: + { + CMCHKPK(cmPkPtr,(PTR)datReq, mBuf); + } + break; +#endif /* LCKWU */ + } + + CMCHKPKLOG(SPkS16, spId, mBuf, EKWU011, pst); + pst->event = (Event) KWU_EVT_DAT_REQ; + ret1 = SPstTsk(pst,mBuf); + if(pst->selector == KWU_SEL_LC) + { + if (SPutStaticBuffer(pst->region, pst->pool, (Data *)datReq, + sizeof(KwuDatReqInfo),SS_SHARABLE_MEMORY) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + } + RETVALUE(ret1); +#endif +} /* cmPkKwuDatReq */ + + +#ifdef ANSI +PUBLIC S16 cmPkKwuDatIndInfo +( +KwuDatIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkKwuDatIndInfo(param, mBuf) +KwuDatIndInfo *param; +Buffer *mBuf; +#endif +{ + TRC3(cmPkKwuDatIndInfo); + + CMCHKPK(SPkU8, param->isOutOfSeq, mBuf); +#ifdef CCPU_OPT + CMCHKPK(cmPkLteRnti, param->tCrnti, mBuf); +#endif + CMCHKPK(cmPkLteRlcId, ¶m->rlcId, mBuf); + RETVALUE(ROK); +} + + +#ifdef ANSI +PUBLIC S16 cmPkKwuDatInd +( +Pst * pst, +SuId suId, +KwuDatIndInfo* datInd, +Buffer * mBuf +) +#else +PUBLIC S16 cmPkKwuDatInd(pst, suId, datInd, mBuf) +Pst * pst; +SuId suId; +KwuDatIndInfo* datInd; +Buffer * mBuf; +#endif +{ +#ifdef LCKWU + S16 ret1 = ROK; +#endif /* LCKWU */ +#ifdef TENB_SPLIT_ARCH +#ifdef SS_LOCKLESS_MEMORY + SsMsgInfo *mInfo; +#endif +#endif + KwuDatIndInfo *datIndInfo = NULLP; + + TRC3(cmPkKwuDatInd) + +#ifdef TENB_SPLIT_ARCH + /* SSI_CHANGES: */ +#ifdef SS_LOCKLESS_MEMORY + mInfo = (SsMsgInfo *)mBuf->b_rptr; + mInfo->region = pst->region; +#endif /* SS_LOCKLESS_MEMORY */ +#endif + + switch(pst->selector) + { + case KWU_SEL_LWLC: + { + /* When the Selector is LWLC, we need to allocate memory, copy + * the contents and pass the pointer of the allocated memory. The + * subsequent free would be done during the Unpack function of the + * primitive. */ + if((ret1 = SGetStaticBuffer(pst->region, pst->pool, (Data **)&datIndInfo, + sizeof(KwuDatIndInfo),SS_SHARABLE_MEMORY)) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)EKWU028, (ErrVal)0, "SGetMsg() failed"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(ret1); + } + + cmMemcpy((U8*)datIndInfo,(U8*)datInd,sizeof(KwuDatIndInfo)); + CMCHKPK(cmPkPtr,(PTR)datIndInfo, mBuf); + } + break; + case KWU_SEL_LC: + { +#if (ERRCLASS & ERRCLS_ADD_RES) + ret1 = cmPkKwuDatIndInfo( (datInd), mBuf); + if(ret1 != ROK) + { + SPutMsg(mBuf); + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)EKWU012, (ErrVal)ret1, "Packing failure"); + RETVALUE( ret1 ); + } +#else + cmPkKwuDatIndInfo( (datInd), mBuf); +#endif /* ERRCLASS & ERRCLS_ADD_RES */ +#if 0 + /*Commenting out the below block as no Memory Allocation happens + * in Protocol. This code will be removed once testing is done */ + if (SPutStaticBuffer(pst->region, pst->pool, (Data *)datInd, + sizeof(KwuDatIndInfo),SS_SHARABLE_MEMORY) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } +#endif + } + break; + default: + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRKWU, (ErrVal)ret1, "pst->selector is invalid\n"); +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(RFAILED); + } + + CMCHKPKLOG(SPkS16, suId, mBuf, EKWU013, pst); + pst->event = (Event) KWU_EVT_DAT_IND; + + RETVALUE(SPstTsk(pst,mBuf)); +} /* cmPkKwuDatInd */ + + +#ifdef ANSI +PUBLIC S16 cmPkKwuDatCfmInfo +( +KwuDatCfmInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkKwuDatCfmInfo(param, mBuf) +KwuDatCfmInfo *param; +Buffer *mBuf; +#endif +{ + register U32 iter; + + TRC3(cmPkKwuDatCfmInfo); + for(iter = 0; iter < param->numSduIds; iter++) + { + CMCHKPK(SPkU32, param->sduIds[iter], mBuf); + } + CMCHKPK(SPkU32, param->numSduIds, mBuf); + CMCHKPK(cmPkLteRlcId, ¶m->rlcId, mBuf); + RETVALUE(ROK); +} /* cmPkKwuDatCfmInfo */ + + +#ifdef ANSI +PUBLIC S16 cmPkKwuDatCfm +( +Pst * pst, +SuId suId, +KwuDatCfmInfo* datCfm +) +#else +PUBLIC S16 cmPkKwuDatCfm(pst, suId, datCfm) +Pst * pst; +SuId suId; +KwuDatCfmInfo* datCfm; +#endif +{ +#if (ERRCLASS & ERRCLS_ADD_RES) + S16 ret1= ROK; +#endif + Buffer *mBuf; + + TRC3(cmPkKwuDatCfm) + + mBuf = NULLP; + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { + RETVALUE(RFAILED); + } + + switch(pst->selector) + { + case KWU_SEL_LWLC: + { + CMCHKPK(cmPkPtr,(PTR)datCfm, mBuf); + } + break; + case KWU_SEL_LC: + { +#if (ERRCLASS & ERRCLS_ADD_RES) + ret1 = cmPkKwuDatCfmInfo( (datCfm), mBuf); + if(ret1 != ROK) + { + SPutMsg(mBuf); + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)EKWU014, (ErrVal)ret1, "Packing failure"); + RETVALUE( ret1 ); + } +#else + cmPkKwuDatCfmInfo( (datCfm), mBuf); +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + if (SPutStaticBuffer(pst->region, pst->pool, (Data *)datCfm, + sizeof(KwuDatCfmInfo),SS_SHARABLE_MEMORY) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + break; + default: + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRKWU, (ErrVal)ret1, "pst->selector is invalid\n"); +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(RFAILED); + } + + CMCHKPKLOG(SPkS16, suId, mBuf, EKWU015, pst); + pst->event = (Event) KWU_EVT_DAT_CFM; + + RETVALUE(SPstTsk(pst,mBuf)); +} /* cmPkKwuDatCfm */ + + +#ifdef ANSI +PUBLIC S16 cmPkKwuDiscSduReq +( +Pst * pst, +SpId spId, +KwuDiscSduInfo* discSdu +) +#else +PUBLIC S16 cmPkKwuDiscSduReq(pst, spId, discSdu) +Pst * pst; +SpId spId; +KwuDiscSduInfo* discSdu; +#endif +{ +#ifdef LCKWU + S16 ret1; +#endif /* LCKWU */ + Buffer *mBuf; + KwuDiscSduInfo* discSduInfo = NULLP; + + TRC3(cmPkKwuDiscSduReq) + mBuf = NULLP; + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { + RETVALUE(RFAILED); + } + + switch(pst->selector) + { + case KWU_SEL_LWLC: + { + /* When the Selector is LWLC, we need to allocate memory, copy + * the contents and pass the pointer of the allocated memory. The + * subsequent free would be done during the Unpack function of the + * primitive. */ + if((ret1 = SGetStaticBuffer(pst->region, pst->pool, (Data **)&discSduInfo, + sizeof(KwuDiscSduInfo),SS_SHARABLE_MEMORY)) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)EKWU028, (ErrVal)0, "SGetMsg() failed"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(ret1); + } + + cmMemcpy((U8*)discSduInfo,(U8*)discSdu,sizeof(KwuDiscSduInfo)); + CMCHKPK(cmPkPtr,(PTR)discSduInfo, mBuf); + } + break; + case KWU_SEL_LC: + { +#if (ERRCLASS & ERRCLS_ADD_RES) + ret1 = cmPkKwuDiscSduInfo( (discSdu), mBuf); + if(ret1 != ROK) + { + SPutMsg(mBuf); + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)EKWU016, (ErrVal)ret1, "Packing failure"); + RETVALUE( ret1 ); + } +#else + cmPkKwuDiscSduInfo( (discSdu), mBuf); +#endif /* ERRCLASS & ERRCLS_ADD_RES */ +#if 0 + if (SPutSBuf(pst->region, pst->pool, (Data *)discSdu, + sizeof(KwuDiscSduInfo)) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } +#endif + break; + } + } + + CMCHKPKLOG(SPkS16, spId, mBuf, EKWU017, pst); + pst->event = (Event) KWU_EVT_DISC_SDU_REQ; + + RETVALUE(SPstTsk(pst,mBuf)); +} /* cmPkKwuDiscSduReq */ + + +#ifdef ANSI +PUBLIC S16 cmPkKwuStaIndInfo +( +KwuStaIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkKwuStaIndInfo(param, mBuf) +KwuStaIndInfo *param; +Buffer *mBuf; +#endif +{ + S16 i; + + TRC3(cmPkKwuStaIndInfo); + + for (i = (param->numSdu - 1); i >= 0; i--) + { + CMCHKPK(SPkU32, param->sduId[(U16)i], mBuf); + } + CMCHKPK(SPkU32, param->numSdu, mBuf); + CMCHKPK(cmPkLteRlcId, ¶m->rlcId, mBuf); + RETVALUE(ROK); +} + +#ifdef ANSI +PUBLIC S16 cmPkKwuFlowCntrlIndInfo +( +KwuFlowCntrlIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkKwuFlowCntrlIndInfo(param, mBuf) +KwuFlowCntrlIndInfo *param; +Buffer *mBuf; +#endif +{ + TRC3(cmPkKwuFlowCntrlIndInfo); + + CMCHKPK(SPkU32, param->pktAdmitCnt, mBuf); + CMCHKPK(cmPkLteRlcId, ¶m->rlcId, mBuf); + + RETVALUE(ROK); +} /* cmPkKwuFlowCntrlIndInfo */ + +#ifdef ANSI +PUBLIC S16 cmUnpkKwuFlowCntrlIndInfo +( +KwuFlowCntrlIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkKwuFlowCntrlIndInfo(param, mBuf) +KwuFlowCntrlIndInfo *param; +Buffer *mBuf; +#endif +{ + TRC3(cmUnpkKwuFlowCntrlIndInfo); + + CMCHKUNPK(cmUnpkLteRlcId, ¶m->rlcId, mBuf); + CMCHKUNPK(SUnpkU32, ¶m->pktAdmitCnt, mBuf); + + RETVALUE(ROK); +} /* cmUnpkKwuFlowCntrlIndInfo */ + + +#ifdef ANSI +PUBLIC S16 cmPkKwuStaInd +( +Pst * pst, +SuId suId, +KwuStaIndInfo* staInd +) +#else +PUBLIC S16 cmPkKwuStaInd(pst, suId, staInd) +Pst * pst; +SuId suId; +KwuStaIndInfo* staInd; +#endif +{ +#ifdef LCKWU +#if (ERRCLASS & ERRCLS_ADD_RES) + S16 ret1 = ROK; +#endif +#endif /* LCKWU */ + Buffer *mBuf; + + TRC3(cmPkKwuStaInd) + + mBuf = NULLP; + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { + RETVALUE(RFAILED); + } + + switch(pst->selector) + { + case KWU_SEL_LWLC: + { + CMCHKPK(cmPkPtr,(PTR) staInd, mBuf); + } + break; + case KWU_SEL_LC: + { +#if (ERRCLASS & ERRCLS_ADD_RES) + ret1 = cmPkKwuStaIndInfo( (staInd), mBuf); + if(ret1 != ROK) + { + SPutMsg(mBuf); + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)EKWU018, (ErrVal)ret1, "Packing failure"); + RETVALUE( ret1 ); + } +#else + cmPkKwuStaIndInfo( (staInd), mBuf); +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + if (SPutStaticBuffer(pst->region, pst->pool, (Data *)staInd, + sizeof(KwuStaIndInfo),SS_SHARABLE_MEMORY) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + break; + default: + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRKWU, (ErrVal)ret1, "pst->selector is invalid\n"); +#endif + RETVALUE(RFAILED); + } + + CMCHKPKLOG(SPkS16, suId, mBuf, EKWU019, pst); + pst->event = (Event) KWU_EVT_STA_IND; + + RETVALUE(SPstTsk(pst,mBuf)); +} /* cmPkKwuStaInd */ + + +#ifdef ANSI +PUBLIC S16 cmPkKwuReEstCmpInd +( +Pst * pst, +SuId suId, +CmLteRlcId rlcId +) +#else +PUBLIC S16 cmPkKwuReEstCmpInd(pst, suId, rlcId) +Pst * pst; +SuId suId; +CmLteRlcId rlcId; +#endif +{ +#ifdef LCKWU +#if (ERRCLASS & ERRCLS_ADD_RES) + S16 ret1; +#endif +#endif /* LCKWU */ + Buffer *mBuf; + + TRC3(cmPkKwuReEstCmpInd) + + mBuf = NULLP; + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { + RETVALUE(RFAILED); + } + + switch(pst->selector) + { +#ifdef LCKWU + case KWU_SEL_LC: + { +#if (ERRCLASS & ERRCLS_ADD_RES) + ret1 = cmPkLteRlcId( &rlcId, mBuf); + if(ret1 != ROK) + { + SPutMsg(mBuf); + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)EKWU018, (ErrVal)ret1, "Packing failure"); + RETVALUE( ret1 ); + } +#else + cmPkLteRlcId( &rlcId, mBuf); +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + break; + } +#endif /* LCKWU */ + } + + CMCHKPKLOG(SPkS16, suId, mBuf, EKWU019, pst); + pst->event = (Event) KWU_EVT_REEST_CMP_IND; + + RETVALUE(SPstTsk(pst,mBuf)); +} /* cmPkKwuReEstCmpInd */ + +/* kwu_c_001.main_3 added support for L2 Measurement */ +#ifdef ANSI +PUBLIC S16 cmPkKwuDiscSduCfm +( +Pst *pst, +SpId spId, +KwuDiscSduInfo *discCfmSdu +) +#else +PUBLIC S16 cmPkKwuDiscSduCfm(pst, spId, discCfmSdu) +Pst *pst; +SpId spId; +KwuDiscSduInfo *discCfmSdu; +#endif +{ +#if (ERRCLASS & ERRCLS_ADD_RES) + S16 ret1 = ROK; +#endif + Buffer *mBuf; + + TRC3(cmPkKwuDiscSduCfm) + + mBuf = NULLP; + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { + RETVALUE(RFAILED); + } + + switch(pst->selector) + { + case KWU_SEL_LWLC: + { + CMCHKPK(cmPkPtr,(PTR)discCfmSdu, mBuf); + } + break; + case KWU_SEL_LC: + { +#if (ERRCLASS & ERRCLS_ADD_RES) + ret1 = cmPkKwuDiscSduInfo((discCfmSdu), mBuf); + if(ret1 != ROK) + { + SPutMsg(mBuf); + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRKWU, (ErrVal)ret1, "Packing failure"); + RETVALUE( ret1 ); + } +#else + cmPkKwuDiscSduInfo((discCfmSdu), mBuf); +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + if (SPutStaticBuffer(pst->region, pst->pool, (Data *)discCfmSdu, + sizeof(KwuDiscSduInfo),SS_SHARABLE_MEMORY) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + break; + default: + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRKWU, (ErrVal)ret1, "pst->selector is invalid\n"); +#endif + RETVALUE(RFAILED); + } + + CMCHKPKLOG(SPkS16, spId, mBuf, ERRKWU, pst); + pst->event = (Event) KWU_EVT_DISC_SDU_CFM; + + RETVALUE(SPstTsk(pst,mBuf)); +} /* cmPkKwuDiscSduCfm */ + +#ifdef ANSI +PUBLIC S16 cmPkKwuFlowCntrlInd +( +Pst *pst, +SuId suId, +KwuFlowCntrlIndInfo *flowCntrlIndInfo +) +#else +PUBLIC S16 cmPkKwuFlowCntrlInd(pst, suId, flowCntrlIndInfo) +Pst *pst; +SuId suId; +KwuFlowCntrlIndInfo *flowCntrlIndInfo; +#endif +{ + Buffer *mBuf; + + TRC3(cmPkKwuFlowCntrlInd) + + mBuf = NULLP; + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) + { + SPutStaticBuffer(pst->region, + pst->pool, + (Data *)flowCntrlIndInfo, + sizeof(KwuFlowCntrlIndInfo),0); + RETVALUE(RFAILED); + } +#ifdef LCKWU + switch(pst->selector) + { + case KWU_SEL_LC: + { + cmPkKwuFlowCntrlIndInfo((flowCntrlIndInfo), mBuf); + + if (SPutStaticBuffer(pst->region, + pst->pool, + (Data *)flowCntrlIndInfo, + sizeof(KwuFlowCntrlIndInfo),0) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + break; + + case KWU_SEL_LWLC: + { + CMCHKPK(cmPkPtr,(PTR) flowCntrlIndInfo, mBuf); + } + break; + } +#endif + + CMCHKPKLOG(SPkS16, suId, mBuf, ERRKWU, pst); + pst->event = (Event) KWU_EVT_FLOW_CNTRL_IND; + + RETVALUE(SPstTsk(pst,mBuf)); +} /* cmPkKwuFlowCntrlInd */ + +#ifdef LTE_L2_MEAS +#ifdef ANSI +PUBLIC S16 cmPkKwuDatAckInfo +( +KwuDatAckInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkKwuDatAckInfo(param, mBuf) +KwuDatAckInfo *param; +Buffer *mBuf; +#endif +{ + TRC3(cmPkKwuDatAckIndInfo); + + CMCHKPK(cmPkLteRlcId, ¶m->rlcId, mBuf); + CMCHKPK(SPkU32, param->sduId, mBuf); + RETVALUE(ROK); +} + +#ifdef ANSI +PUBLIC S16 cmPkKwuDatAckInd +( +Pst * pst, +SuId suId, +KwuDatAckInfo* datInd +) +#else +PUBLIC S16 cmPkKwuDatAckInd(pst, suId, datInd) +Pst * pst; +SuId suId; +KwuDatAckInfo* datInd; +#endif +{ + S16 ret1; + + Buffer *mBuf; + + TRC3(cmPkKwuDatAckInd); + + mBuf = NULLP; + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { + RETVALUE(RFAILED); + } + + ret1 = cmPkKwuDatAckInfo( (datInd), mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + SPutMsg(mBuf); + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRKWU, (ErrVal)ret1, "Packing failure"); + RETVALUE( ret1 ); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + if (SPutStaticBuffer(pst->region, pst->pool, (Data *)datInd, + sizeof(KwuDatAckInfo),SS_SHARABLE_MEMORY) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + CMCHKPKLOG(SPkS16, suId, mBuf, ERRKWU, pst); + pst->event = (Event) KWU_EVT_DAT_ACK_IND; + + RETVALUE(SPstTsk(pst,mBuf)); +} /* cmPkKwuDatAckInd */ +#endif /* LTE_L2_MEAS */ + + +#ifdef ANSI +PUBLIC S16 cmUnpkKwuBndReq +( +KwuBndReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkKwuBndReq(func, pst, mBuf) +KwuBndReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId = 0; + SpId spId = 0; + + TRC3(cmUnpkKwuBndReq) + + CMCHKUNPKLOG(SUnpkS16, &suId, mBuf, EKWU020, pst); + CMCHKUNPKLOG(SUnpkS16, &spId, mBuf, EKWU021, pst); + SPutMsg(mBuf); + + RETVALUE((*func)(pst, suId, spId)); +} + + +#ifdef ANSI +PUBLIC S16 cmUnpkKwuBndCfm +( +KwuBndCfm func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkKwuBndCfm(func, pst, mBuf) +KwuBndCfm func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId = 0; + U8 status = 0; + + TRC3(cmUnpkKwuBndCfm) + + CMCHKUNPKLOG(SUnpkS16, &suId, mBuf, EKWU022, pst); + CMCHKUNPKLOG(SUnpkU8, &status, mBuf, EKWU023, pst); + SPutMsg(mBuf); + + RETVALUE((*func)(pst, suId, status)); +} + + +#ifdef ANSI +PUBLIC S16 cmUnpkKwuUbndReq +( +KwuUbndReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkKwuUbndReq(func, pst, mBuf) +KwuUbndReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SpId spId = 0; + Reason reason = 0; + + TRC3(cmUnpkKwuUbndReq) + + CMCHKUNPKLOG(SUnpkS16, &spId, mBuf, EKWU024, pst); + CMCHKUNPKLOG(SUnpkS16, &reason, mBuf, EKWU025, pst); + SPutMsg(mBuf); + + RETVALUE((*func)(pst, spId, reason)); +} /* cmUnpkKwuUbndReq */ + + +#ifdef ANSI +PUBLIC S16 cmUnpkKwuDatReqInfo +( +KwuDatReqInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkKwuDatReqInfo(param, mBuf) +KwuDatReqInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkKwuDatReqInfo); + + CMCHKUNPK(cmUnpkLteRlcId, ¶m->rlcId, mBuf); + CMCHKUNPK(SUnpkU32, ¶m->sduId, mBuf); + +#ifdef CCPU_OPT + CMCHKUNPK(cmUnpkLteLcType, ¶m->lcType, mBuf); + switch(param->lcType) { + case CM_LTE_LCH_BCCH: + case CM_LTE_LCH_PCCH: +#ifdef EMTC_ENABLE + CMCHKUNPK(SUnpkU8,¶m->pnb , mBuf); + CMCHKUNPK(SUnpkU8,¶m->emtcDiReason , mBuf); +#endif + CMCHKUNPK(cmUnpkLteTimingInfo, ¶m->tm.tmg, mBuf); + + break; + case CM_LTE_LCH_CCCH: + CMCHKUNPK(cmUnpkLteRnti, ¶m->tm.rnti, mBuf); + break; + case CM_LTE_LCH_DTCH: + case CM_LTE_LCH_DCCH: + break; + default : + RETVALUE(RFAILED); + } +#endif + RETVALUE(ROK); +} + + +#ifdef ANSI +PUBLIC S16 cmUnpkKwuDatReq +( +KwuDatReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkKwuDatReq(func, pst, mBuf) +KwuDatReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ +#if(ERRCLASS & ERRCLS_DEBUG) + S16 ret1 = ROK; +#endif + S16 retVal; + SpId spId = 0; + KwuDatReqInfo *datReq = NULLP; + KwuDatReqInfo datReqTmp; + + TRC3(cmUnpkKwuDatReq) + + + CMCHKUNPK(SUnpkS16, &(spId), mBuf); + + switch(pst->selector) + { + case KWU_SEL_LWLC: + { + CMCHKUNPK(cmUnpkPtr,(PTR *) &datReq, mBuf); + } + break; + case KWU_SEL_LC: + { +#if 0 + /*This will be removed once the testing is done on all platforms */ + if((ret1 = SGetStaticBuffer(pst->region, pst->pool, (Data **)&datReq,\ + sizeof(KwuDatReqInfo),SS_SHARABLE_MEMORY)) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + /*MBUF_FIXX*/ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)EKWU026, (ErrVal)0, "SGetMsg() failed"); + +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(ret1); + } + +#endif + /* Allocate the memory statically as there is no free + * in RLC */ + datReq = &datReqTmp; + cmMemset((U8 *)datReq, 0, sizeof(KwuDatReqInfo)); +#if(ERRCLASS & ERRCLS_DEBUG) + ret1 = cmUnpkKwuDatReqInfo( (datReq), mBuf); + if(ret1 != ROK) + { + SPutMsg(mBuf); + SLogError(pst->dstEnt, pst->dstInst, pst->dstProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG, + (ErrVal)EKWU027, (ErrVal)ret1, "Unpacking failure"); + RETVALUE( ret1 ); + } +#else + cmUnpkKwuDatReqInfo( (datReq), mBuf); +#endif /* ERRCLASS & ERRCLS_DEBUG */ + } + break; + default: + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRKWU, (ErrVal)ret1, "pst->selector is invalid\n"); +#endif + RETVALUE(RFAILED); + } + + retVal = (*func)(pst, spId, datReq, mBuf); + /* If LWLC is configured, we need to + * free the memory here. */ + if(pst->selector == KWU_SEL_LWLC) + { + retVal = SPutStaticBuffer(pst->region, pst->pool, (Data *)datReq, + sizeof(KwuDatReqInfo),SS_SHARABLE_MEMORY); + } + RETVALUE(retVal); +} /* cmUnpkKwuDatReq */ + + +#ifdef ANSI +PUBLIC S16 cmUnpkKwuDatIndInfo +( +KwuDatIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkKwuDatIndInfo(param, mBuf) +KwuDatIndInfo *param; +Buffer *mBuf; +#endif +{ + TRC3(cmUnpkKwuDatIndInfo); + + CMCHKUNPK(cmUnpkLteRlcId, ¶m->rlcId, mBuf); + +#ifdef CCPU_OPT + CMCHKUNPK(cmUnpkLteRnti, ¶m->tCrnti, mBuf); +#endif + CMCHKUNPK(SUnpkU8, ¶m->isOutOfSeq, mBuf); + RETVALUE(ROK); +} + + +#ifdef ANSI +PUBLIC S16 cmUnpkKwuDatInd +( +KwuDatInd func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkKwuDatInd(func, pst, mBuf) +KwuDatInd func; +Pst *pst; +Buffer *mBuf; +#endif +{ + S16 ret1 = ROK, retVal; + SuId suId = 0; + KwuDatIndInfo *datInd = NULLP; + KwuDatIndInfo datIndTmp; + + TRC3(cmUnpkKwuDatInd) + + CMCHKUNPK(SUnpkS16, &(suId), mBuf); + + switch(pst->selector) + { + case KWU_SEL_LWLC: + { + CMCHKUNPK(cmUnpkPtr,(PTR *) &datInd, mBuf); + } + break; + case KWU_SEL_LC: + { + /*SGetStaticBuffer used as RRC has an equivalent free but PDCP + * doesn't free any memory */ + if(pst->dstEnt != ENTPJ) + { + if((ret1 = SGetStaticBuffer(pst->region, pst->pool, (Data **)&datInd, + sizeof(KwuDatIndInfo),SS_SHARABLE_MEMORY)) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)EKWU028, (ErrVal)0, "SGetMsg() failed"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(ret1); + } + } + else + { + datInd = &datIndTmp; + } + + ret1 = cmUnpkKwuDatIndInfo( (datInd), mBuf); +#if(ERRCLASS & ERRCLS_DEBUG) + if(ret1 != ROK) + { + SPutMsg(mBuf); + SLogError(pst->dstEnt, pst->dstInst, pst->dstProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG, + (ErrVal)EKWU029, (ErrVal)ret1, "Unpacking failure"); + RETVALUE( ret1 ); + } +#endif /* ERRCLASS & ERRCLS_DEBUG */ + } + break; + default: + SPutMsg(mBuf); + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRKWU, (ErrVal)ret1, "pst->selector is invalid\n"); + RETVALUE(RFAILED); + } + retVal = (*func)(pst, suId, datInd, mBuf); + /* If LWLC is configured and the destination entity is PDCP, we need to + * free the memory here. */ + if((pst->selector == KWU_SEL_LWLC) && (pst->dstEnt == ENTPJ)) + { + retVal = SPutStaticBuffer(pst->region, pst->pool, (Data *)datInd, + sizeof(KwuDatIndInfo),SS_SHARABLE_MEMORY); + } + RETVALUE(retVal); +} /* cmUnpkKwuDatInd */ + + +#ifdef ANSI +PUBLIC S16 cmUnpkKwuDatCfmInfo +( +KwuDatCfmInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkKwuDatCfmInfo(param, mBuf) +KwuDatCfmInfo *param; +Buffer *mBuf; +#endif +{ + register S32 iter; + TRC3(cmUnpkKwuDatCfmInfo); + + CMCHKUNPK(cmUnpkLteRlcId, ¶m->rlcId, mBuf); + CMCHKUNPK(SUnpkU32, ¶m->numSduIds, mBuf); + +#ifdef L2_L3_SPLIT /*Work Around */ + if (param->numSduIds >= KWU_MAX_DAT_CFM) + param->numSduIds = KWU_MAX_DAT_CFM; +#endif + for(iter = param->numSduIds -1; iter >= 0 ; iter--) + { + CMCHKUNPK(SUnpkU32, ¶m->sduIds[iter], mBuf); + } + RETVALUE(ROK); +} + +#ifdef ANSI +PUBLIC S16 cmUnpkKwuDatCfm +( +KwuDatCfm func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkKwuDatCfm(func, pst, mBuf) +KwuDatCfm func; +Pst *pst; +Buffer *mBuf; +#endif +{ + S16 ret1 = ROK; + SuId suId = 0; + KwuDatCfmInfo *datCfm = NULLP; + + TRC3(cmUnpkKwuDatCfm) + + CMCHKUNPK(SUnpkS16, &(suId), mBuf); + + switch(pst->selector) + { + case KWU_SEL_LWLC: + { + CMCHKUNPK(cmUnpkPtr,(PTR *) &datCfm, mBuf); + } + break; + case KWU_SEL_LC: + { + if((ret1 = SGetStaticBuffer(pst->region, pst->pool, (Data **)&datCfm,\ + sizeof(KwuDatCfmInfo),SS_SHARABLE_MEMORY)) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)EKWU030, (ErrVal)0, "SGetMsg() failed"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(ret1); + } + + cmMemset((U8 *)datCfm, 0, sizeof(KwuDatCfmInfo)); + ret1 = cmUnpkKwuDatCfmInfo( (datCfm), mBuf); +#if(ERRCLASS & ERRCLS_DEBUG) + if(ret1 != ROK) + { + SPutMsg(mBuf); + SLogError(pst->dstEnt, pst->dstInst, pst->dstProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG, + (ErrVal)EKWU031, (ErrVal)ret1, "Unpacking failure"); + RETVALUE( ret1 ); + } +#endif /* ERRCLASS & ERRCLS_DEBUG */ + } + break; + default: +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRKWU, (ErrVal)ret1, "pst->selector is invalid\n"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + SPutMsg(mBuf); + + RETVALUE((*func)(pst, suId, datCfm)); +} /* cmUnpkKwuDatCfm */ + + +#ifdef ANSI +PUBLIC S16 cmUnpkKwuDiscSduReq +( +KwuDiscSduReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkKwuDiscSduReq(func, pst, mBuf) +KwuDiscSduReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + S16 ret1 = ROK; + SpId spId = 0; + KwuDiscSduInfo *discSdu = NULLP; + + + CMCHKUNPK(SUnpkS16, &(spId), mBuf); + switch(pst->selector) + { + case KWU_SEL_LWLC: + { + CMCHKUNPK(cmUnpkPtr,(PTR *) &discSdu, mBuf); + } + break; + case KWU_SEL_LC: + { + if((ret1 = SGetStaticBuffer(pst->region, pst->pool, (Data **)&discSdu,\ + sizeof(KwuDiscSduInfo),SS_SHARABLE_MEMORY)) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + /*MBUF_FIXX*/ + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)EKWU032, (ErrVal)0, "SGetMsg() failed"); + +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(ret1); + } + + cmMemset((U8 *)discSdu, 0, sizeof(KwuDiscSduInfo)); + ret1 = cmUnpkKwuDiscSduInfo( (discSdu), mBuf); +#if(ERRCLASS & ERRCLS_DEBUG) + if(ret1 != ROK) + { + SPutMsg(mBuf); + SLogError(pst->dstEnt, pst->dstInst, pst->dstProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG, + (ErrVal)EKWU033, (ErrVal)ret1, "Unpacking failure"); + RETVALUE( ret1 ); + } +#endif /* ERRCLASS & ERRCLS_DEBUG */ + break; + } + default: +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRKWU, (ErrVal)ret1, "pst->selector is invalid\n"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + + RETVALUE((*func)(pst, spId, discSdu)); +} /* cmUnpkKwuDiscSduReq */ + + +#ifdef ANSI +PUBLIC S16 cmUnpkKwuStaIndInfo +( +KwuStaIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkKwuStaIndInfo(param, mBuf) +KwuStaIndInfo *param; +Buffer *mBuf; +#endif +{ + U32 i; + + TRC3(cmUnpkKwuStaIndInfo); + + CMCHKUNPK(cmUnpkLteRlcId, ¶m->rlcId, mBuf); + CMCHKUNPK(SUnpkU32, ¶m->numSdu, mBuf); + for (i = 0; i < param->numSdu; i++) + { + CMCHKUNPK(SUnpkU32, ¶m->sduId[i], mBuf); + } + + RETVALUE(ROK); +} /* cmUnpkKwuStaIndInfo */ + + +#ifdef ANSI +PUBLIC S16 cmUnpkKwuStaInd +( +KwuStaInd func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkKwuStaInd(func, pst, mBuf) +KwuStaInd func; +Pst *pst; +Buffer *mBuf; +#endif +{ + S16 ret1 = ROK; + SuId suId = 0; + KwuStaIndInfo *staInd = NULLP; + + TRC3(cmUnpkKwuStaInd) + + CMCHKUNPK(SUnpkS16, &(suId), mBuf); + + switch(pst->selector) + { + case KWU_SEL_LWLC: + { + CMCHKUNPK(cmUnpkPtr,(PTR *)&staInd, mBuf); + } + break; + case KWU_SEL_LC: + { + if((ret1 = SGetStaticBuffer(pst->region, pst->pool, (Data **)&staInd,\ + sizeof(KwuStaIndInfo),SS_SHARABLE_MEMORY)) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)EKWU034, (ErrVal)0, "SGetMsg() failed"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(ret1); + } + + cmMemset((U8 *)staInd, 0, sizeof(KwuStaIndInfo)); + + ret1 = cmUnpkKwuStaIndInfo( (staInd), mBuf); +#if(ERRCLASS & ERRCLS_DEBUG) + if(ret1 != ROK) + { + SPutMsg(mBuf); + SLogError(pst->dstEnt, pst->dstInst, pst->dstProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG, + (ErrVal)EKWU035, (ErrVal)ret1, "Unpacking failure"); + RETVALUE( ret1 ); + } +#endif /* ERRCLASS & ERRCLS_DEBUG */ + } + break; + default: + SPutMsg(mBuf); +#if(ERRCLASS & ERRCLS_DEBUG) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRKWU, (ErrVal)ret1, "pst->selector is invalid\n"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + + RETVALUE((*func)(pst, suId, staInd)); +} /* cmUnpkKwuStaInd */ + + +#ifdef ANSI +PUBLIC S16 cmUnpkKwuReEstCmpInd +( +KwuReEstCmpInd func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkKwuReEstCmpInd(func, pst, mBuf) +KwuReEstCmpInd func; +Pst *pst; +Buffer *mBuf; +#endif +{ +#if(ERRCLASS & ERRCLS_DEBUG) + S16 ret1; +#endif + SuId suId = 0; + CmLteRlcId rlcId; + + TRC3(cmUnpkKwuReEstCmpInd) + + cmMemset((U8 *)&rlcId, 0, sizeof(CmLteRlcId)); + + CMCHKUNPK(SUnpkS16, &(suId), mBuf); + switch(pst->selector) + { +#ifdef LCKWU + case KWU_SEL_LC: + { +#if(ERRCLASS & ERRCLS_DEBUG) + ret1 = cmUnpkLteRlcId( &rlcId, mBuf); + if(ret1 != ROK) + { + SPutMsg(mBuf); + SLogError(pst->dstEnt, pst->dstInst, pst->dstProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG, + (ErrVal)EKWU035, (ErrVal)ret1, "Unpacking failure"); + RETVALUE( ret1 ); + } +#else + cmUnpkLteRlcId( &rlcId, mBuf); +#endif /* ERRCLASS & ERRCLS_DEBUG */ + break; + } +#endif /* LCKWU */ + } + SPutMsg(mBuf); + + RETVALUE((*func)(pst, suId, rlcId)); +} /* cmUnpkKwuReEstCmpInd */ + +/* kwu_c_001.main_3 added support for L2 Measurement */ +#ifdef ANSI +PUBLIC S16 cmUnpkKwuDiscSduCfm +( +KwuDiscSduCfm func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkKwuDiscSduCfm(func, pst, mBuf) +KwuDiscSduCfm func; +Pst *pst; +Buffer *mBuf; +#endif +{ + S16 ret1 = ROK; + SpId spId = 0; + KwuDiscSduInfo *discSdu = NULLP; + + TRC3(cmUnpkKwuDiscSduCfm); + + CMCHKUNPK(SUnpkS16, &(spId), mBuf); + + switch(pst->selector) + { + case KWU_SEL_LWLC: + { + CMCHKUNPK(cmUnpkPtr,(PTR *) &discSdu, mBuf); + } + break; + case KWU_SEL_LC: + { + if((ret1 = SGetStaticBuffer(pst->region, pst->pool, (Data **)&discSdu,\ + sizeof(KwuDiscSduInfo),SS_SHARABLE_MEMORY)) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRKWU, (ErrVal)0, "SGetMsg() failed"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(ret1); + } + cmMemset((U8 *)discSdu, 0, sizeof(KwuDiscSduInfo)); + + ret1 = cmUnpkKwuDiscSduInfo( (discSdu), mBuf); +#if(ERRCLASS & ERRCLS_DEBUG) + if(ret1 != ROK) + { + SPutMsg(mBuf); + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRKWU, (ErrVal)0, "SGetMsg() failed"); + } +#endif /* ERRCLASS & ERRCLS_DEBUG */ + } + break; + default: + SPutMsg(mBuf); +#if(ERRCLASS & ERRCLS_DEBUG) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRKWU, (ErrVal)ret1, "pst->selector is invalid\n"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + + RETVALUE((*func)(pst, spId, discSdu)); +} /* cmUnpkKwuDiscSduCfm */ +#ifdef ANSI +PUBLIC S16 cmUnpkKwuFlowCntrlInd +( +KwuFlowCntrlInd func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkKwuFlowCntrlInd(func, pst, mBuf) +KwuFlowCntrlInd func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + KwuFlowCntrlIndInfo *flowCntrlInfo = NULLP; + + TRC3(cmUnpkKwuFlowCntrlInd); + + CMCHKUNPK(SUnpkS16, &(suId), mBuf); + switch(pst->selector) + { +#ifdef LCKWU + case KWU_SEL_LC: + { + if(SGetStaticBuffer(pst->region, + pst->pool, + (Data **)&flowCntrlInfo, + sizeof(KwuFlowCntrlIndInfo),0) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + cmUnpkKwuFlowCntrlIndInfo(flowCntrlInfo, mBuf); + } + break; + + case KWU_SEL_LWLC: + { + CMCHKUNPK(cmUnpkPtr,(PTR *) &flowCntrlInfo, mBuf); + } + break; +#endif + } + + SPutMsg(mBuf); + + RETVALUE((*func)(pst, suId, flowCntrlInfo)); +} /* cmUnpkKwuFlowCntrlInd */ +#ifdef LTE_L2_MEAS + +#ifdef ANSI +PUBLIC S16 cmUnpkKwuDatAckInfo +( +KwuDatAckInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkKwuDatAckInfo(param, mBuf) +KwuDatAckInfo *param; +Buffer *mBuf; +#endif +{ + TRC3(cmUnpkKwuDatAckInfo); + + CMCHKUNPK(SUnpkU32, ¶m->sduId, mBuf); + CMCHKUNPK(cmUnpkLteRlcId, ¶m->rlcId, mBuf); + + RETVALUE(ROK); +} + + +#ifdef ANSI +PUBLIC S16 cmUnpkKwuDatAckInd +( +KwuDatAckInd func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkKwuDatAckInd(func, pst, mBuf) +KwuDatAckInd func; +Pst *pst; +Buffer *mBuf; +#endif +{ + S16 ret1; + SuId suId = 0; + KwuDatAckInfo *datInd = NULLP; + + TRC3(cmUnpkKwuDatAckInd); + + if((ret1 = SGetStaticBuffer(pst->region, pst->pool, (Data **)&datInd,\ + sizeof(KwuDatAckInfo),SS_SHARABLE_MEMORY)) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRKWU, (ErrVal)0, "SGetMsg() failed"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(ret1); + } + + cmMemset((U8 *)datInd, 0, sizeof(KwuDatAckInfo)); + + CMCHKUNPK(SUnpkS16, &(suId), mBuf); + ret1 = cmUnpkKwuDatAckInfo( (datInd), mBuf); +#if(ERRCLASS & ERRCLS_DEBUG) + if(ret1 != ROK) + { + SPutMsg(mBuf); + SLogError(pst->dstEnt, pst->dstInst, pst->dstProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_DEBUG, + (ErrVal)ERRKWU, (ErrVal)ret1, "Unpacking failure"); + RETVALUE( ret1 ); + } +#endif /* ERRCLASS & ERRCLS_DEBUG */ + + RETVALUE((*func)(pst, suId, datInd)); +} /* cmUnpkKwuDatAckInd */ +#endif /* LTE_L2_MEAS */ +#endif /* LCKWU */ + +/********************************************************************** + End of file + **********************************************************************/ diff --git a/src/cm/lcl.h b/src/cm/lcl.h new file mode 100644 index 000000000..f9223c52f --- /dev/null +++ b/src/cm/lcl.h @@ -0,0 +1,169 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/* Defines APIs exchanged between du_app and cl module of MAC */ +#ifndef __LCL_H__ +#define __LCL_H__ + +#define NUM_NUMEROLOGY 5 /* Number of numerology */ +#define MAX_TDD_PERIODICITY 5 +#define MAX_SYMB_PER_SLOT 14 + +typedef enum +{ + DUP_MODE_FDD, + DUP_MODE_TDD +}DuplexMode; + +typedef enum +{ + MAC_GEN_FULL_PBCH_PAYLD, /* MAC generated the full PBCH Payload */ + PHY_GEN_TIMING_PBCH_BIT, /* PHY generates the timing PBCH bits */ + PHY_GEN_FULL_PBCH_PAYLD /* PHY generates full PBCH payload */ +}BchPduOpt; + +typedef enum +{ + LONG_SEQUENCE, + SHORT_SEQUENCE +}PrachSeqLen; + +typedef enum +{ + UNRESTRICTED, + RESTRICTED_SET_TYPE_A, + RESTRICTED_SET_TYPE_B +}RstSetCfg; + +typedef enum +{ + DONT_REPORT_RSSI, + RSSI_UNIT_DBM, + RSSI_UNIT_DBFS +}RSSIMeasUnit; + +typedef enum +{ + DL_SLOT, + UL_SLOT, + GUARD_SLOT +}SlotConfig; + +typedef enum +{ + TX_PRDCTY_MS_0P5, + TX_PRDCTY_MS_0P625, + TX_PRDCTY_MS_1, + TX_PRDCTY_MS_1P25, + TX_PRDCTY_MS_2, + TX_PRDCTY_MS_2P5, + TX_PRDCTY_MS_5, + TX_PRDCTY_MS_10 +}DlUlTxPeriodicity; + +typedef enum +{ + BETA_PSS_0DB, + BETA_PSS_1DB +}BetaPss; + +typedef enum +{ + SSB_PRDCTY_MS_5, + SSB_PRDCTY_MS_10, + SSB_PRDCTY_MS_20, + SSB_PRDCTY_MS_40, + SSB_PRDCTY_MS_80, + SSB_PRDCTY_MS_160 +}SSBPeriod; + +typedef struct carrierCfg +{ + Bool pres; + U16 bw; /* DL/UL bandwidth */ + U32 freq; /* Absolute frequency of DL/UL point A in KHz */ + U16 k0[NUM_NUMEROLOGY]; /* K0 for DL/UL */ + U16 gridSize[NUM_NUMEROLOGY]; /* DL/UL Grid size for each numerologies */ + U16 numAnt; /* Number of Tx/Rx antennas */ +}CarrierCfg; + +typedef struct ssbCfg +{ + U32 ssbPbchPwr; /* SSB block power */ + BchPduOpt bchPayload; /* Options for generation of payload */ + U8 scsCmn; /* subcarrier spacing for common */ + U16 ssbPrbOffset; /* SSB PRB offset from point A */ + BetaPss betaPss; + SSBPeriod ssbPeriod; /* SSB Periodicity in msec */ + U8 ssbSubcOffset; /* Subcarrier Offset */ + U32 mibPdu; /* MIB payload */ + U32 nSSBMask[2]; /* Bitmap for actually transmitted SSB. */ + Bool multCarrBand; /* Multiple carriers in a band */ + Bool multCellCarr; /* Multiple cells in single carrier */ +}SsbCfg; + +typedef struct fdmInfo +{ + U16 rootSeqIdx; /* Root sequence index */ + U8 numRootSeq; /* Number of root sequences required for FD */ + U16 k1; /* Frequency Offset for each FD */ + U8 zeroCorrZoneCfg; /* Zero correlation zone cofig */ + U8 numUnusedRootSeq; /* Number of unused root sequence */ + U8 *unsuedRootSeq; /* Unused root sequence per FD */ +}FdmInfo; + +typedef struct prachCfg +{ + Bool pres; + PrachSeqLen prachSeqLen; /* RACH Sequence length: Long/short */ + U8 prachSubcSpacing; /* Subcarrier spacing of RACH */ + RstSetCfg prachRstSetCfg; /* PRACH restricted set config */ + U8 prachFdm; /* PRACH FDM (1,2,4,8) */ + FdmInfo fdm[8]; + U8 ssbPerRach; /* SSB per RACH occassion */ + Bool prachMultCarrBand; /* Multiple carriers in Band */ +}PrachCfg; + +typedef struct tddCfg +{ + Bool pres; + DlUlTxPeriodicity tddPeriod; /* DL UL Transmission periodicity */ + SlotConfig slotCfg[MAX_TDD_PERIODICITY][MAX_SYMB_PER_SLOT]; +}TDDCfg; + +typedef struct clCellCfg +{ + U8 numTlv; /* Number of configuration TLVs */ + U8 carrierId; /* Carrired Index */ + U16 cellId; /* Cell Id */ + U16 phyCellId; /* Physical cell id */ + DuplexMode dupType; /* Duplex type: TDD/FDD */ + CarrierCfg dlCarrCfg; /* DL Carrier configuration */ + CarrierCfg ulCarrCfg; /* UL Carrier configuration */ + Bool freqShft; /* Indicates presence of 7.5kHz frequency shift */ + SsbCfg ssbCfg; /* SSB configuration */ + PrachCfg prachCfg; /* PRACH Configuration */ + TDDCfg tddCfg; /* TDD periodicity and slot configuration */ + RSSIMeasUnit rssiUnit; /* RSSI measurement unit */ +}ClCellCfg; + +#endif + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/cm/lkw.c b/src/cm/lkw.c new file mode 100755 index 000000000..931e0b491 --- /dev/null +++ b/src/cm/lkw.c @@ -0,0 +1,3276 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/********************************************************************20** + + Name: LTE-RLC Layer + + Type: C source file + + Desc: C Source code for common packing and unpacking functions + for RLC Layer Manager Interfaces. It contains the + following function definitions + + -- cmPkLkwCfgReq + -- cmPkLkwCntrlReq + -- cmPkLkwCntrlCfm + -- cmPkLkwCfgCfm + -- cmPkLkwStaInd + + -- cmUnpkLkwCfgReq + -- cmUnpkLkwCntrlReq + -- cmUnpkLkwCntrlCfm + -- cmUnpkLkwCfgCfm + -- cmUnpkLkwStaInd + + File: lkw.c + +*********************************************************************21*/ + + +/* header include files (.h) */ + +#include "envopt.h" /* environment options */ +#include "envdep.h" /* environment dependent */ +#include "envind.h" /* environment independent */ + +#include "gen.h" /* general */ +#include "ssi.h" /* system services interface */ +#include "cm_lte.h" /* layer manager */ +#include "lkw.h" /* Layer manager */ + +/* header/extern include files (.x) */ + +#include "gen.x" /* general */ +#include "ssi.x" /* system services interface */ +#include "cm_lib.x" /* common library header file */ +#include "cm_lte.x" /* layer manager */ +#include "lkw.x" /* layer manager */ + +#ifdef LCLKW + +Txt ptNmb[LKW_PART_NUM_STR_LEN]; /* Part number */ + + +/* forward references */ + +PRIVATE S16 cmPkKwMngmt ARGS ((KwMngmt *param ,Event eventType, + Buffer *mBuf)); +PRIVATE S16 cmPkKwCfg ARGS ((KwMngmt *param ,Elmnt elmnt, Buffer *mBuf)); +PRIVATE S16 cmPkKwCntrl ARGS ((KwMngmt *cntrl, Elmnt elmnt, Buffer *mBuf)); +PRIVATE S16 cmPkKwUsta ARGS ((KwMngmt *usta, Elmnt elmnt, Buffer *mBuf)); +PRIVATE S16 cmPkKwSsta ARGS ((KwMngmt *ssta, Elmnt etmnt, Event eventType, + Buffer *mBuf)); +PRIVATE S16 cmPkKwSts ARGS ((KwMngmt *sts, Elmnt elmnt, Buffer *mBuf)); +PRIVATE S16 cmPkGenSts ARGS ((KwGenSts *gen, Buffer *mBuf)); +PRIVATE S16 cmPkCkwSapSts ARGS ((KwCkwCntSts *rcSap, Buffer *mBuf)); +PRIVATE S16 cmPkKwuSapSts ARGS ((KwKwuSapSts *ruSap, Buffer *mBuf)); +/* lkw_c_001.main_2 removed support of RGU sap statistics as it is reflecting + * in general statstics. + * */ +PRIVATE S16 cmPkKwTrc ARGS ((KwMngmt *trc, Buffer *mBuf)); + +PRIVATE S16 cmUnpkKwMngmt ARGS ((KwMngmt *param, Event eventType, + Buffer * mBuf)); +PRIVATE S16 cmUnpkKwCfg ARGS ((KwMngmt *cfg, Elmnt elmnt, Buffer *mBuf)); +PRIVATE S16 cmUnpkKwCntrl ARGS ((KwMngmt *param, Elmnt elmnt, Buffer *mBuf)); +PRIVATE S16 cmUnpkKwUsta ARGS ((KwMngmt *usta, Elmnt elmnt, Buffer *mBuf)); +PRIVATE S16 cmUnpkKwSsta ARGS ((KwMngmt *ssta, Elmnt elmnt, Event eventType, + Buffer *mBuf)); +PRIVATE S16 cmUnpkKwSts ARGS ((KwMngmt *sts, Elmnt elmnt, Buffer *mBuf)); +PRIVATE S16 cmUnpkGenSts ARGS ((KwGenSts *gen, Buffer *mBuf)); +PRIVATE S16 cmUnpkCkwSapSts ARGS ((KwCkwCntSts *rcSap, Buffer *mBuf)); +PRIVATE S16 cmUnpkKwuSapSts ARGS ((KwKwuSapSts *ruSap, Buffer *mBuf)); +/* lkw_c_001.main_2 removed support of RGU sap statistics as it is reflecting + * in general statstics. + * */ +PRIVATE S16 cmUnpkKwTrc ARGS ((KwMngmt *trc, Buffer *mBuf)); + + +PRIVATE S16 cmPkCkwSapSta ARGS ((KwCkwCntSapSta *rcSap, Buffer *mBuf)); +PRIVATE S16 cmUnpkCkwSapSta ARGS ((KwCkwCntSapSta *rcSap, Buffer *mBuf)); + +PRIVATE S16 cmPkKwuSapSta ARGS ((KwKwuSapSta *rlSap, Buffer *mBuf)); +PRIVATE S16 cmUnpkKwuSapSta ARGS ((KwKwuSapSta *rlSap, Buffer *mBuf)); + +PRIVATE S16 cmPkRguSapSta ARGS ((KwRguSapSta *mkSap, Buffer *mBuf)); +PRIVATE S16 cmUnpkRguSapSta ARGS ((KwRguSapSta *mkSap, Buffer *mBuf)); + +/** + * @brief + Pack Config Request + * + * @param[in] pst : post structure + * @param[in] cfg : RLC LM structure + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ + +#ifdef ANSI +PUBLIC S16 cmPkLkwCfgReq +( +Pst *pst, /* post structure */ +KwMngmt *cfg /* RLC LM structure */ +) +#else +PUBLIC S16 cmPkLkwCfgReq(pst, cfg) +Pst *pst; /* post structure */ +KwMngmt *cfg; /* RLC LM structure */ +#endif +{ + Buffer *mBuf; /* message buffer */ + S16 ret1; /* return value */ + + TRC3(cmPkLkwCfgReq) + + ret1 = SGetMsg(pst->region, pst->pool, &mBuf); + if (ret1 != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + LKWLOGERROR(pst, ERRCLS_ADD_RES, ELKW001, (ErrVal) ret1, + "SGetMsg failed ...!\n"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(ret1); + } + + ret1 = cmPkKwMngmt(cfg, LKW_EVT_CFG_REQ, mBuf); + + if(ret1 != ROK) + { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + LKWLOGERROR(pst, ERRCLS_ADD_RES, ELKW002, (ErrVal) ret1, + "cmPkKwMngmt failure ......!"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(RFAILED); + } + + pst->event = (Event) LKW_EVT_CFG_REQ; /* event */ + SPstTsk(pst, mBuf); + + RETVALUE(ROK); + +} /* end of cmPkLkwCfgReq */ + +/** + * @brief + Unpack Config Request + * + * @param[in] func : primitive to call + * @param[in] pst : post structure + * @param[in] mBuf : message buffer + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ + +#ifdef ANSI +PUBLIC S16 cmUnpkLkwCfgReq +( +LkwCfgReq func, /* primitive to call */ +Pst *pst, /* post structure */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkLkwCfgReq(func, pst, mBuf) +LkwCfgReq func; /* primitive to call */ +Pst *pst; /* post structure */ +Buffer *mBuf; /* message buffer */ +#endif +{ + S16 ret1; /* Return value */ + KwMngmt cfg; /* RLC LM structure */ + + TRC3(cmUnpkLkwCfgReq) + + cmMemset((U8 *) &cfg, (U8) 0, (S16) sizeof(KwMngmt)); + ret1 = cmUnpkKwMngmt(&cfg, LKW_EVT_CFG_REQ, mBuf); + + if(ret1 != ROK) + { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_DEBUG) + /*MBUF_FIXX*/ + LKWLOGERROR(pst, ERRCLS_INT_PAR, ELKW003, (ErrVal) ret1, + "cmUnpkKwMngmt failure ......!"); + +#endif /* ERRCLASS & ERRCLS_DEBUG */ + RETVALUE(RFAILED); + } + + SPutMsg(mBuf); + (Void) (*func)(pst, &cfg); + + RETVALUE(ROK); + +} /* end of cmUnpkLkwCfgReq */ + + + +/** + * @brief + Pack Control Request + * + * @param[in] pst : post structure + * @param[in] cntrl : RLC LM structure + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ + +#ifdef ANSI +PUBLIC S16 cmPkLkwCntrlReq +( +Pst *pst, /* post structure */ +KwMngmt *cntrl /* RLC LM structure */ +) +#else +PUBLIC S16 cmPkLkwCntrlReq(pst,cntrl) +Pst *pst; /* post structure */ +KwMngmt *cntrl; /* RLC LM structure */ +#endif +{ + Buffer *mBuf; /* message buffer */ + S16 ret1; /* return value */ + + TRC3(cmPkLkwCntrlReq) + + ret1 = SGetMsg(pst->region, pst->pool, &mBuf); + if (ret1 != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + LKWLOGERROR(pst, ERRCLS_INT_PAR, ELKW004, (ErrVal) ret1, + "SGetMsg failure ......!"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(ret1); + } + + ret1 = cmPkKwMngmt(cntrl, LKW_EVT_CNTRL_REQ, mBuf); + + if(ret1 != ROK) + { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + LKWLOGERROR(pst, ERRCLS_INT_PAR, ELKW005, (ErrVal) ret1, + "cmPkKwMngmt failure ......!"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(ret1); + } + + pst->event = (Event) LKW_EVT_CNTRL_REQ; /* event */ + SPstTsk(pst, mBuf); + + RETVALUE(ROK); + +} /* end of cmPkLkwCntrlReq */ + +/** + * @brief + Unpack Control Request + * + * @param[in] func : primitive to call + * @param[in] pst : post structure + * @param[in] mBuf : message buffer + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ + +#ifdef ANSI +PUBLIC S16 cmUnpkLkwCntrlReq +( +LkwCntrlReq func, /* primitive to call */ +Pst *pst, /* post structure */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkLkwCntrlReq(func, pst, mBuf) +LkwCntrlReq func; /* primitive to call */ +Pst *pst; /* post structure */ +Buffer *mBuf; /* message buffer */ +#endif +{ + S16 ret1; /* return value */ + KwMngmt cfm; /* Confirmation */ + + TRC3(cmUnpkLkwCntrlReq) + + ret1 = cmUnpkKwMngmt(&cfm, LKW_EVT_CNTRL_REQ, mBuf); + + if(ret1 != ROK) + { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_DEBUG) + /*MBUF_FIXX*/ + LKWLOGERROR(pst, ERRCLS_INT_PAR, ELKW006, (ErrVal) ret1, + "cmUnpkKwMngmt failure ......!"); + +#endif /* ERRCLASS & ERRCLS_DEBUG */ + RETVALUE(RFAILED); + } + + SPutMsg(mBuf); + RETVALUE((*func)(pst, &cfm)); + +} /* end of cmUnpkLkwCntrlReq */ + +/** + * @brief + Pack Control Confirm + * + * @param[in] pst : post structure + * @param[in] cfg : RLC LM structure + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ + +#ifdef ANSI +PUBLIC S16 cmPkLkwCntrlCfm +( +Pst *pst, /* post structure */ +KwMngmt *cfm /* RLC LM structure */ +) +#else +PUBLIC S16 cmPkLkwCntrlCfm(pst, cfm) +Pst *pst; /* post structure */ +KwMngmt *cfm; /* RLC LM structure */ +#endif +{ + Buffer *mBuf; /* message buffer */ + S16 ret1; /* return value */ + + TRC3(cmPkLkwCntrlCfm) + + ret1 = SGetMsg(pst->region, pst->pool, &mBuf); + if (ret1 != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + LKWLOGERROR(pst, ERRCLS_INT_PAR, ELKW007, (ErrVal) ret1, + "SGetMsg failure ......!"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(ret1); + } + + ret1 = cmPkKwMngmt(cfm, LKW_EVT_CNTRL_CFM, mBuf); + + if(ret1 != ROK) + { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + LKWLOGERROR(pst, ERRCLS_INT_PAR, ELKW008, (ErrVal) ret1, + "Packing failure ......!"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(RFAILED); + } + + pst->event = (Event) LKW_EVT_CNTRL_CFM; /* event */ + SPstTsk(pst, mBuf); + + RETVALUE(ROK); + +} /* end of cmPkLkwCntrlCfm */ + + +/** + * @brief + Unpack Control confirm + * + * @param[in] func : primitive to call + * @param[in] pst : post structure + * @param[in] mBuf : message buffer + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ + +#ifdef ANSI +PUBLIC S16 cmUnpkLkwCntrlCfm +( +LkwCntrlCfm func, /* primitive to call */ +Pst *pst, /* post structure */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkLkwCntrlCfm(func, pst, mBuf) +LkwCntrlCfm func; /* primitive to call */ +Pst *pst; /* post structure */ +Buffer *mBuf; /* message buffer */ +#endif +{ + KwMngmt cfm; /* RLC LM structure */ + S16 ret1; /* return value */ + + TRC3(cmUnpkLkwCntrlCfm) + + ret1 = cmUnpkKwMngmt(&cfm, LKW_EVT_CNTRL_CFM, mBuf); + + if(ret1 != ROK) + { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_DEBUG) + if(ret1 != ROK) + { + LKWLOGERROR(pst, ERRCLS_INT_PAR, ELKW009, (ErrVal) ret1, + "cmUnpkKwMngmt failure ......!"); + } +#endif /* ERRCLASS & ERRCLS_DEBUG */ + RETVALUE(RFAILED); + } + + SPutMsg(mBuf); + + RETVALUE((*func)(pst, &cfm)); + +} /* end of cmUnpkLkwCntrlCfm */ + +/** + * @brief + Unpack statistics Confirm + * + * @param[in] func : primitive to call + * @param[in] pst : post structure + * @param[in] mBuf : message buffer + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ +#ifdef ANSI +PUBLIC S16 cmUnpkLkwStsCfm +( +LkwStsCfm func, /* primitive to call */ +Pst *pst, /* post structure */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkLkwStsCfm(func, pst, mBuf) +LkwStsCfm func; /* primitive to call */ +Pst *pst; /* post structure */ +Buffer *mBuf; /* message buffer */ +#endif +{ + KwMngmt cfm; /* RLC LM structure */ + S16 ret1; /* return value */ + + TRC3(cmUnpkLkwStsCfm) + + ret1 = cmUnpkKwMngmt(&cfm, LKW_EVT_STS_CFM, mBuf); + + if(ret1 != ROK) + { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_DEBUG) + if(ret1 != ROK) + { + LKWLOGERROR(pst, ERRCLS_INT_PAR, ELKW010, (ErrVal) ret1, + "SPutMsg failure ......!"); + } +#endif /* ERRCLASS & ERRCLS_DEBUG */ + RETVALUE(RFAILED); + } + + SPutMsg(mBuf); + + RETVALUE((*func)(pst, 0, &cfm)); + +} /* end of cmUnpkLkwStsCfm */ + +/** + * @brief + Pack Config Confirm + * + * @param[in] pst : post structure + * @param[in] cfg : RLC LM structure + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ + + +#ifdef ANSI +PUBLIC S16 cmPkLkwCfgCfm +( +Pst *pst, /* post structure */ +KwMngmt *cfm /* RLC LM structure */ +) +#else +PUBLIC S16 cmPkLkwCfgCfm(pst,cfm) +Pst *pst; /* post structure */ +KwMngmt *cfm; /* RLC LM structure */ +#endif +{ + Buffer *mBuf; /* message buffer */ + S16 ret1; /* return value */ + + TRC3(cmPkLkwCfgCfm) + + ret1 = SGetMsg(pst->region, pst->pool, &mBuf); + if (ret1 != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + LKWLOGERROR(pst, ERRCLS_INT_PAR, ELKW011, (ErrVal) ret1, + "SGetMsg failure ......!"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(ret1); + } + + ret1 = cmPkKwMngmt(cfm, LKW_EVT_CFG_CFM, mBuf); + + if(ret1 != ROK) + { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + LKWLOGERROR(pst, ERRCLS_INT_PAR, ELKW012, (ErrVal) ret1, + "SPutMsg failure ......!"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(RFAILED); + } + + pst->event = (Event) LKW_EVT_CFG_CFM; /* event */ + SPstTsk(pst, mBuf); + + RETVALUE(ROK); + +} /* end of cmPkLkwCfgCfm */ + + +/** + * @brief + Unpack Config Confirm + * + * @param[in] func : primitive to call + * @param[in] pst : post structure + * @param[in] mBuf : message buffer + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ +#ifdef ANSI +PUBLIC S16 cmUnpkLkwCfgCfm +( +LkwCfgCfm func, /* primitive to call */ +Pst *pst, /* post structure */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkLkwCfgCfm(func, pst, mBuf) +LkwCfgCfm func; /* primitive to call */ +Pst *pst; /* post structure */ +Buffer *mBuf; /* message buffer */ +#endif +{ + S16 ret1; /* return value */ + KwMngmt cfm; /* RLC LM structure */ + + TRC3(cmUnpkLkwCfgCfm) + + ret1 = cmUnpkKwMngmt(&cfm, LKW_EVT_CFG_CFM, mBuf); + + if(ret1 != ROK) + { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_DEBUG) + if(ret1 != ROK) + { + LKWLOGERROR(pst, ERRCLS_INT_PAR, ELKW013, (ErrVal) ret1, + "SPutMsg failure ......!"); + } +#endif /* ERRCLASS & ERRCLS_DEBUG */ + RETVALUE(RFAILED); + } + + SPutMsg(mBuf); + RETVALUE((*func)(pst, &cfm)); + +} /* end of cmUnpkLkwCfgCfm */ + + + +/** + * @brief + Pack Status Indication + * + * @param[in] pst : post structure + * @param[in] usta : RLC LM structure + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ + +#ifdef ANSI +PUBLIC S16 cmPkLkwStaInd +( +Pst *pst, /* post structure */ +KwMngmt *usta /* RLC LM structure */ +) +#else +PUBLIC S16 cmPkLkwStaInd(pst,usta) +Pst *pst; /* post structure */ +KwMngmt *usta; /* RLC LM structure */ +#endif +{ + Buffer *mBuf; /* message buffer */ + S16 ret1; /* return value */ + + TRC3(cmPkLkwStaInd) + + ret1 = SGetMsg(pst->region, pst->pool, &mBuf); + if (ret1 != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + LKWLOGERROR(pst, ERRCLS_INT_PAR, ELKW014, (ErrVal) ret1, + "SGetMsg() failed"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(ret1); + } + + ret1 = cmPkKwMngmt(usta, LKW_EVT_STA_IND, mBuf); + + if(ret1 != ROK) + { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + LKWLOGERROR(pst, ERRCLS_INT_PAR, ELKW015, (ErrVal) ret1, + "cmPkKwMngmt failure ......!"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(ret1); + } + + pst->event = (Event) LKW_EVT_STA_IND; /* event */ + SPstTsk(pst, mBuf); + + RETVALUE(ROK); + +} /* end of cmPkLkwStaInd */ + + +/** + * @brief + Unpack Unsolicited Status indication + * + * @param[in] func : primitive to call + * @param[in] pst : post structure + * @param[in] mBuf : message buffer + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ + +#ifdef ANSI +PUBLIC S16 cmUnpkLkwStaInd +( +LkwStaInd func, /* primitive pointer */ +Pst *pst, /* post structure */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkLkwStaInd(func, pst, mBuf) +LkwStaInd func; /* primitive pointer */ +Pst *pst; /* post structure */ +Buffer *mBuf; /* message buffer */ +#endif +{ + KwMngmt usta; /* RLC LM structure */ + S16 ret1; /* return value */ + + TRC3(cmUnpkLkwStaInd) + + ret1 = cmUnpkKwMngmt(&usta, LKW_EVT_STA_IND, mBuf); + + if(ret1 != ROK) + { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_DEBUG) + if(ret1 != ROK) + { + LKWLOGERROR(pst, ERRCLS_INT_PAR, ELKW016, (ErrVal) ret1, + "cmUnpkKwMngmt failure ......!"); + } +#endif /* ERRCLASS & ERRCLS_DEBUG */ + RETVALUE(RFAILED); + } + + SPutMsg(mBuf); + + RETVALUE((*func)(pst, &usta)); +} /* end of cmUnpkLsnStaInd */ + +/** + * @brief + Pack Status Request + * + * @param[in] pst : post structure + * @param[in] sta : RLC LM structure + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ + +#ifdef ANSI +PUBLIC S16 cmPkLkwStaReq +( +Pst *pst, /* post structure */ +KwMngmt *sta /* status */ +) +#else +PUBLIC S16 cmPkLkwStaReq(pst,sta) +Pst *pst; /* post structure */ +KwMngmt *sta; /* status */ +#endif +{ + Buffer *mBuf; /* message buffer */ + S16 ret1; /* return value */ + + TRC3(cmPkLkwStaReq) + + ret1 = SGetMsg(pst->region, pst->pool, &mBuf); + if (ret1 != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + LKWLOGERROR(pst, ERRCLS_INT_PAR, ELKW017, (ErrVal) ret1, + "SGetMsg failure ......!"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(RFAILED); + } + + ret1 = cmPkKwMngmt(sta, LKW_EVT_STA_REQ, mBuf); + + if(ret1 != ROK) + { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + LKWLOGERROR(pst, ERRCLS_INT_PAR, ELKW018, (ErrVal) ret1, + "SGetMsg() failure ......!"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(RFAILED); + } + + pst->event = (Event) LKW_EVT_STA_REQ; /* event */ + SPstTsk(pst, mBuf); + + RETVALUE(ROK); + +} /* end of cmPkLkwStaReq */ + +/** + * @brief + Unpack status confirmation + * + * @param[in] func : primitive to call + * @param[in] pst : post structure + * @param[in] mBuf : message buffer + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ +#ifdef ANSI +PUBLIC S16 cmUnpkLkwStaCfm +( +LkwStaReq func, /* primitive pointer */ +Pst *pst, /* post structure */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkLkwStaCfm(func, pst, mBuf) +LkwStaReq func; /* primitive pointer */ +Pst *pst; /* post structure */ +Buffer *mBuf; /* message buffer */ +#endif +{ + KwMngmt cfm; /* RLC LM structure */ + S16 ret1; /* return value */ + + TRC3(cmUnpkLkwStaReq) + + ret1 = cmUnpkKwMngmt(&cfm, LKW_EVT_STA_CFM, mBuf); + + if(ret1 != ROK) + { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_DEBUG) + if(ret1 != ROK) + { + LKWLOGERROR(pst, ERRCLS_INT_PAR, ELKW019, (ErrVal) ret1, + "Unpacking failure ......!"); + } +#endif /* ERRCLASS & ERRCLS_DEBUG */ + RETVALUE(RFAILED); + } + + SPutMsg(mBuf); + + RETVALUE((*func)(pst, &cfm)); + +} /* end of function cmUnpkLkwStaCfm */ + +/** + * @brief + Unpack Status request + * + * @param[in] func : primitive to call + * @param[in] pst : post structure + * @param[in] mBuf : message buffer + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ +#ifdef ANSI +PUBLIC S16 cmUnpkLkwStsReq +( +LkwStsReq func, /* primitive pointer */ +Pst *pst, /* post structure */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkLkwStsReq(func, pst, mBuf) +LkwStsReq func; /* primitive pointer */ +Pst *pst; /* post structure */ +Buffer *mBuf; /* message buffer */ +#endif +{ + KwMngmt sts; /* RLC LM structure */ + S16 ret1; /* return value */ + Action action; /* Action */ + + TRC3(cmUnpkLkwStsReq) + + CMCHKUNPK(SUnpkS16, &action, mBuf); + + ret1 = cmUnpkKwMngmt(&sts, LKW_EVT_STS_REQ, mBuf); + + if(ret1 != ROK) + { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_DEBUG) + /*MBUF_FIXX*/ + LKWLOGERROR(pst, ERRCLS_INT_PAR, ELKW020, (ErrVal) ret1, + "Unpacking failure ......!"); + +#endif /* ERRCLASS & ERRCLS_DEBUG */ + RETVALUE(RFAILED); + } + + SPutMsg(mBuf); + + RETVALUE((*func)(pst, action, &sts)); + +} /* end of function cmUnpkLkwStsReq */ + + +/** + * @brief + Unpack ssta + * + * @param[in] func : primitive to call + * @param[in] pst : post structure + * @param[in] mBuf : message buffer + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ +#ifdef ANSI +PUBLIC S16 cmUnpkLkwStaReq +( +LkwStaReq func, /* primitive pointer */ +Pst *pst, /* post structure */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkLkwStaReq(func, pst, mBuf) +LkwStaReq func; /* primitive pointer */ +Pst *pst; /* post structure */ +Buffer *mBuf; /* message buffer */ +#endif +{ + KwMngmt sta; /* RLC LM structure */ + S16 ret1; /* return value */ + + TRC3(cmUnpkLkwStaReq) + + ret1 = cmUnpkKwMngmt(&sta, LKW_EVT_STA_REQ, mBuf); + + if(ret1 != ROK) + { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_DEBUG) + /*MBUF_FIXX*/ + LKWLOGERROR(pst, ERRCLS_INT_PAR, ELKW021, (ErrVal) ret1, + "Unpacking failure ......!"); + +#endif /* ERRCLASS & ERRCLS_DEBUG */ + RETVALUE(RFAILED); + } + + SPutMsg(mBuf); + + RETVALUE((*func)(pst, &sta)); + +} /* end of function cmUnpkLkwStaReq */ + + +/** + * @brief + Unpack Trace Indication + * + * @param[in] func : primitive to call + * @param[in] pst : post structure + * @param[in] mBuf : message buffer + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ + +#ifdef ANSI +PUBLIC S16 cmUnpkLkwTrcInd +( +LkwTrcInd func, /* primitive to call */ +Pst *pst, /* post structure */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 cmUnpkLkwTrcInd(func, pst, mBuf) +LkwTrcInd func; /* primitive to call */ +Pst *pst; /* post structure */ +Buffer *mBuf; /* message buffer */ +#endif +{ + S16 ret1; /* return value */ + KwMngmt trc; /* RLC LM structure */ + + TRC3(cmUnpkLkwTrcInd) + + ret1 = cmUnpkKwMngmt(&trc, LKW_EVT_TRC_IND, mBuf); + + if(ret1 != ROK) + { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_DEBUG) + if(ret1 != ROK) + { + LKWLOGERROR(pst, ERRCLS_INT_PAR, ELKW022, (ErrVal) ret1, + "Unpacking failure ......!"); + } +#endif /* ERRCLASS & ERRCLS_DEBUG */ + RETVALUE(RFAILED); + } + + (Void) (*func)(pst, &trc, mBuf); + + RETVALUE(ROK); + +} /* end of cmUnpkLkwTrcInd */ + + +/** + * @brief + Pack Config Request + * + * @param[in] pst : post structure + * @param[in] cfg : RLC LM structure + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ + +#ifdef ANSI +PRIVATE S16 cmPkCkwSapSta +( +KwCkwCntSapSta *rcSap, /* SAP statistics */ +Buffer *mBuf /* Message buffer */ +) +#else +PRIVATE S16 cmPkCkwSapSta(rcSap, mBuf) +KwCkwCntSapSta *rcSap; /* SAP statistics */ +Buffer *mBuf; /* Message buffer */ +#endif +{ + TRC3(cmPkCkwSapSta) + + CMCHKPK(cmPkState, rcSap->state, mBuf); + CMCHKPK(SPkS16, rcSap->spId, mBuf); + + RETVALUE(ROK); + +} /* end of cmPkCkwSapSta */ + +/** + * @brief + Unpack CKW sap Sta + * + * @param[out] rcSap: RLC LM structure + * @param[in] buffer: Buffer + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ +#ifdef ANSI +PRIVATE S16 cmUnpkCkwSapSta +( +KwCkwCntSapSta *rcSap, /* SAP statistics */ +Buffer *mBuf /* Message buffer */ +) +#else +PRIVATE S16 cmUnpkCkwSapSta(rcSap, mBuf) +KwCkwCntSapSta *rcSap; /* SAP statistics */ +Buffer *mBuf; /* Message buffer */ +#endif +{ + TRC3(cmUnpkCkwSapSta) + + CMCHKUNPK(SUnpkS16, &rcSap->spId, mBuf); + CMCHKUNPK(cmUnpkState, &rcSap->state, mBuf); + + RETVALUE(ROK); +} /* end of function cmUnpkCkwSapSta */ + +/** + * @brief + Pack Config Request + * + * @param[in] pst : post structure + * @param[in] cfg : RLC LM structure + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ +#ifdef ANSI +PRIVATE S16 cmPkKwuSapSta +( +KwKwuSapSta *rlSap, /* SAP statistics */ +Buffer *mBuf /* Message buffer */ +) +#else +PRIVATE S16 cmPkKwuSapSta(rlSap, mBuf) +KwKwuSapSta *rlSap; /* SAP statistics */ +Buffer *mBuf; /* Message buffer */ +#endif +{ + TRC3(cmPkKwuSapSta) + + CMCHKPK(cmPkState, rlSap->state, mBuf); + CMCHKPK(SPkS16, rlSap->spId, mBuf); + + RETVALUE(ROK); + +} /* end of cmPkKwuSapSta */ + +/** + * @brief + Unpack Kwu Sap Sta + * + * @param[out] rlSap : KwRLSapSta structure + * @param[in] mBuf : message buffer + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ +#ifdef ANSI +PRIVATE S16 cmUnpkKwuSapSta +( +KwKwuSapSta *rlSap, /* SAP statistics */ +Buffer *mBuf /* Message buffer */ +) +#else +PRIVATE S16 cmUnpkKwuSapSta(rlSap, mBuf) +KwKwuSapSta *rlSap; /* SAP statistics */ +Buffer *mBuf; /* Message buffer */ +#endif +{ + TRC3(cmUnpkKwuSapSta) + + CMCHKUNPK(SUnpkS16, &rlSap->spId, mBuf); + CMCHKUNPK(cmUnpkState, &rlSap->state, mBuf); + + RETVALUE(ROK); + +} /* end of function cmUnpkKwuSapSta */ + +/** + * @brief + Pack + * + * @param[in] pst : post structure + * @param[in] cfg : RLC LM structure + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ +#ifdef ANSI +PRIVATE S16 cmPkRguSapSta +( +KwRguSapSta *mkSap, /* SAP statistics */ +Buffer *mBuf /* Message buffer */ +) +#else +PRIVATE S16 cmPkRguSapSta(mkSap, mBuf) +KwRguSapSta *mkSap; /* SAP statistics */ +Buffer *mBuf; /* Message buffer */ +#endif +{ + TRC3(cmPkRguSapSta) + + CMCHKPK(cmPkState, mkSap->state, mBuf); + CMCHKPK(cmPkSuId, mkSap->suId, mBuf); + + RETVALUE(ROK); + +} /* end of cmPkRguSapSta */ + +/** + * @brief + Unpack Rgu Sap Sta + * + * @param[out] mkSap: KwRguSapSta structure + * @param[in] mBuf : message buffer + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ +#ifdef ANSI +PRIVATE S16 cmUnpkRguSapSta +( +KwRguSapSta *mkSap, /* SAP statistics */ +Buffer *mBuf /* Message buffer */ +) +#else +PRIVATE S16 cmUnpkRguSapSta(mkSap, mBuf) +KwRguSapSta *mkSap; /* SAP statistics */ +Buffer *mBuf; /* Message buffer */ +#endif +{ + TRC3(cmUnpkRguSapSta) + + CMCHKUNPK(cmUnpkSuId, &mkSap->suId, mBuf); + CMCHKUNPK(cmUnpkState, &mkSap->state, mBuf); + + RETVALUE(ROK); + +} /* end of function cmUnpkRguSapSta */ + +/** + * @brief + Pack + * + * @param[in] pst : post structure + * @param[in] cfg : RLC LM structure + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ +#ifdef ANSI +PUBLIC S16 cmPkLkwStaCfm +( +Pst *pst, /* post structure */ +KwMngmt *cfm /* solicited status confirm */ +) +#else +PUBLIC S16 cmPkLkwStaCfm(pst, cfm) +Pst *pst; /* post structure */ +KwMngmt *cfm; /* solicited status confirm */ +#endif +{ + Buffer *mBuf; /* message buffer */ + S16 ret1; /* return value */ + + TRC3(cmPkLkwStaCfm); + + ret1 = SGetMsg(pst->region, pst->pool, &mBuf); + if (ret1 != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + LKWLOGERROR(pst, ERRCLS_INT_PAR, ELKW023, (ErrVal) ret1, + "SGetMsg() failure ......!"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(RFAILED); + } + + ret1 = cmPkKwMngmt(cfm, LKW_EVT_STA_CFM, mBuf); + + if(ret1 != ROK) + { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + LKWLOGERROR(pst, ERRCLS_INT_PAR, ELKW024, (ErrVal) ret1, + "packing failure ......!"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(RFAILED); + } + + pst->event = (Event) LKW_EVT_STA_CFM; /* event */ + SPstTsk(pst, mBuf); + + RETVALUE(ROK); +} /* end of cmPkLkwStaCfm */ + + +/** + * @brief + Pack + * + * @param[in] pst : post structure + * @param[in] cfg : RLC LM structure + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ +#ifdef ANSI +PUBLIC S16 cmPkLkwTrcInd +( +Pst *pst, /* post structure */ +KwMngmt *trc, /* trace */ +Buffer *trcBuf /* trace buffer */ +) +#else +PUBLIC S16 cmPkLkwTrcInd(pst, trc, trcBuf) +Pst *pst; /* post structure */ +KwMngmt *trc; /* trace */ +Buffer *trcBuf; /* trace buffer */ +#endif +{ + S16 ret1 = ROK; /* return value */ + Buffer *mBuf = NULLP; /* Buffer to trace */ + + TRC3(cmPkLkwTrcInd); + + ret1 = SGetMsg(pst->region, pst->pool, &mBuf); + if (ret1 != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + LKWLOGERROR(pst, ERRCLS_INT_PAR, ELKW025, (ErrVal) ret1, + "SGetMsg() failure ......!"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(RFAILED); + } + + if (trcBuf) + { + ret1 = SCatMsg(mBuf, trcBuf, M1M2); + if (ret1 != ROK) + { + SPutMsg(mBuf); + SPutMsg(trcBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + LKWLOGERROR(pst, ERRCLS_INT_PAR, ELKW026, (ErrVal) ret1, + "SGetMsg() failure ......!"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(RFAILED); + } + + SPutMsg(trcBuf); + } + + ret1 = cmPkKwMngmt(trc, LKW_EVT_TRC_IND, mBuf); + + if(ret1 != ROK) + { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + LKWLOGERROR(pst, ERRCLS_INT_PAR, ELKW027, (ErrVal) ret1, + "packing failure ......!"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + /* log error */ + RETVALUE(RFAILED); + } + + pst->event = (Event) LKW_EVT_TRC_IND; /* event */ + SPstTsk(pst, mBuf); + + RETVALUE(ROK); + +} /* end of cmPkLkwTrcInd */ + + +/** + * @brief + Pack + * + * @param[in] pst : post structure + * @param[in] cfg : RLC LM structure + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ +#ifdef ANSI +PUBLIC S16 cmPkLkwStsReq +( +Pst *pst, /* post structure */ +Action action, /* action */ +KwMngmt *sts /* statistics request */ +) +#else +PUBLIC S16 cmPkLkwStsReq(pst, action, sts) +Pst *pst; /* post structure */ +Action action; /* action */ +KwMngmt *sts; /* statistics request */ +#endif +{ + + Buffer *mBuf; /* message buffer */ + S16 ret1; /* return value */ + + TRC3(cmPkLkwStsReq) + + ret1 = SGetMsg(pst->region, pst->pool, &mBuf); + if (ret1 != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + LKWLOGERROR(pst, ERRCLS_INT_PAR, ELKW028, (ErrVal) ret1, + "SGetMsg() failure ......!"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(RFAILED); + } + + ret1 = cmPkKwMngmt(sts, LKW_EVT_STS_REQ, mBuf); + + if(ret1 != ROK) + { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + LKWLOGERROR(pst, ERRCLS_INT_PAR, ELKW029, (ErrVal) ret1, + "Packing failure ......!"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(RFAILED); + } + + CMCHKPK(SPkS16, action, mBuf); + pst->event = (Event) LKW_EVT_STS_REQ; /* event */ + SPstTsk(pst, mBuf); + + RETVALUE(ROK); + +} /* end of cmPkLkwStsReq */ + + +/** + * @brief + Pack + * + * @param[in] pst : post structure + * @param[in] cfg : RLC LM structure + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ +#ifdef ANSI +PUBLIC S16 cmPkLkwStsCfm +( +Pst *pst, /* post structure */ +Action action, /* action */ +KwMngmt *cfm /* statistics confirmation */ +) +#else +PUBLIC S16 cmPkLkwStsCfm(pst, action, cfm) +Pst *pst; /* post structure */ +Action action; /* action */ +KwMngmt *cfm; /* statistics confirmation */ +#endif +{ + Buffer *mBuf; /* message buffer */ + S16 ret1; /* return value */ + + TRC3(cmPkLkwStsCfm); + /* lkw_c_001.main_2 removed warning */ + UNUSED(action); + ret1 = SGetMsg(pst->region, pst->pool, &mBuf); + if (ret1 != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + LKWLOGERROR(pst, ERRCLS_INT_PAR, ELKW030, (ErrVal) ret1, + "SGetMsg() failure ......!"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(RFAILED); + } + + ret1 = cmPkKwMngmt(cfm, LKW_EVT_STS_CFM, mBuf); + + if(ret1 != ROK) + { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + if(ret1 != ROK) + { + LKWLOGERROR(pst, ERRCLS_INT_PAR, ELKW031, (ErrVal) ret1, + "Packing failure ......!"); + } +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(RFAILED); + } + + pst->event = (Event) LKW_EVT_STS_CFM; /* event */ + SPstTsk(pst, mBuf); + + RETVALUE(ROK); +} /* end of cmPkLkwStsCfm */ + + +/** + * @brief + Pack + * + * @param[in] pst : post structure + * @param[in] cfg : RLC LM structure + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ + +#ifdef ANSI +PRIVATE S16 cmPkKwMngmt +( +KwMngmt *param, /* Managment */ +Event eventType, /* Event type */ +Buffer *mBuf /* Message Buffer */ +) +#else +PRIVATE S16 cmPkKwMngmt(param ,eventType, mBuf) +KwMngmt *param; /* Managment */ +Event eventType; /* Event type */ +Buffer *mBuf; /* Message Buffer */ +#endif +{ + S16 ret1; /* return value */ + + TRC3(cmPkKwMngmt) + + switch( eventType ) + { + case LKW_EVT_CFG_REQ: + ret1 = cmPkKwCfg(param, param->hdr.elmId.elmnt ,mBuf); + if (ret1 != ROK) + { + RETVALUE(RFAILED); + } + break; + + case LKW_EVT_CNTRL_REQ: + ret1 = cmPkKwCntrl(param, param->hdr.elmId.elmnt ,mBuf); + if (ret1 != ROK) + { + RETVALUE(RFAILED); + } + break; + + case LKW_EVT_STA_IND: + ret1 = cmPkKwUsta(param, param->hdr.elmId.elmnt ,mBuf); + if (ret1 != ROK) + { + RETVALUE(RFAILED); + } + break; + + case LKW_EVT_STA_REQ: + case LKW_EVT_STA_CFM: + ret1 = cmPkKwSsta(param, param->hdr.elmId.elmnt , eventType, mBuf); + if (ret1 != ROK) + { + RETVALUE(RFAILED); + } + break; + + case LKW_EVT_STS_REQ: + case LKW_EVT_STS_CFM: + ret1 = cmPkKwSts(param, param->hdr.elmId.elmnt ,mBuf); + if (ret1 != ROK) + { + RETVALUE(RFAILED); + } + break; + case LKW_EVT_TRC_IND: + ret1 = cmPkKwTrc(param, mBuf); + if (ret1 != ROK) + { + RETVALUE(RFAILED); + } + break; + case LKW_EVT_CNTRL_CFM: + case LKW_EVT_CFG_CFM: + break; + } + + CMCHKPK(cmPkCmStatus, ¶m->cfm, mBuf); + CMCHKPK(cmPkHeader, ¶m->hdr, mBuf); + + RETVALUE(ROK); +} /* end of function cmPkKwMngmt */ + + +/** + * @brief + Pack + * + * @param[in] pst : post structure + * @param[in] cfg : RLC LM structure + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ +#ifdef ANSI +PRIVATE S16 cmPkKwCfg +( +KwMngmt *cfg, +Elmnt elmnt, +Buffer *mBuf +) +#else +PRIVATE S16 cmPkKwCfg(cfg, elmnt, mBuf) +KwMngmt *cfg; +Elmnt elmnt; +Buffer *mBuf; +#endif +{ + TRC3(cmPkKwCfg) + + switch( elmnt ) + { + case STGEN: + { + CMCHKPK(SPkU16, cfg->t.cfg.s.gen.maxRguSaps, mBuf); + CMCHKPK(SPkU8, cfg->t.cfg.s.gen.rlcMode, mBuf); + CMCHKPK(SPkU32, cfg->t.cfg.s.gen.timeRes, mBuf); + CMCHKPK(SPkU16, cfg->t.cfg.s.gen.maxUdxSaps, mBuf); + CMCHKPK(SPkU16, cfg->t.cfg.s.gen.maxKwuSaps, mBuf); + CMCHKPK(SPkU32, cfg->t.cfg.s.gen.maxUe, mBuf); + CMCHKPK(cmPkPst, &cfg->t.cfg.s.gen.lmPst,mBuf); + + break; + } + case STCKWSAP: + case STKWUSAP: + case STUDXSAP: + case STRGUSAP: + { + CMCHKPK(SPkU8, cfg->t.cfg.s.sap.route,mBuf); + CMCHKPK(SPkU8, cfg->t.cfg.s.sap.priority,mBuf); + CMCHKPK(SPkU16, cfg->t.cfg.s.sap.bndTmrIntvl, mBuf); + CMCHKPK(SPkS16, cfg->t.cfg.s.sap.sapId, mBuf); + CMCHKPK(SPkU8, cfg->t.cfg.s.sap.inst, mBuf); + CMCHKPK(SPkU8, cfg->t.cfg.s.sap.ent, mBuf); + CMCHKPK(SPkU16, cfg->t.cfg.s.sap.procId, mBuf); + CMCHKPK(SPkU8, cfg->t.cfg.s.sap.mem.pool, mBuf); + CMCHKPK(SPkU8, cfg->t.cfg.s.sap.mem.region, mBuf); + CMCHKPK(SPkU8, cfg->t.cfg.s.sap.selector, mBuf); + break; + } + default: + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} /*end of function cmPkKwCfg*/ + + +/** + * @brief + Pack kw control request + * + * @param[in] cntrl : LM management structure + * @param[in] elmnt : element + * @param[in] mBuf : Buffer + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ +#ifdef ANSI +PRIVATE S16 cmPkKwCntrl +( +KwMngmt *cntrl, +Elmnt elmnt, +Buffer *mBuf +) +#else +PRIVATE S16 cmPkKwCntrl(cntrl, elmnt, mBuf) +KwMngmt *cntrl; +Elmnt elmnt; +Buffer *mBuf; +#endif +{ + U8 subAction; /* sub action */ + + TRC3(cmPkKwCntrl) + + switch( elmnt ) + { + case STGEN: + { + subAction = cntrl->t.cntrl.subAction; + switch(subAction) + { + case SAUSTA: + break; + case SADBG: + { + CMCHKPK(SPkU32, cntrl->t.cntrl.s.dbgCntrl.dbgMask, + mBuf); + } + break; + case SATRC: + { + CMCHKPK(SPkS16, cntrl->t.cntrl.s.trcCntrl.trcLen, + mBuf); + CMCHKPK(SPkU8, cntrl->t.cntrl.s.trcCntrl.trcMask, + mBuf); + } + break; +#ifdef SS_DIAG + case SALOG: + { + CMCHKPK(SPkU32, cntrl->t.cntrl.s.logMask, mBuf); + } + break; +#endif + default: + break; + } + break; + } + case STRGUSAP: + case STUDXSAP: + CMCHKPK(SPkS16, cntrl->t.cntrl.s.sapCntrl.spId, mBuf); + CMCHKPK(SPkS16, cntrl->t.cntrl.s.sapCntrl.suId, mBuf); + break; + default: + break; + } + + CMCHKPK(SPkU8, cntrl->t.cntrl.action, mBuf); + CMCHKPK(SPkU8, cntrl->t.cntrl.subAction, mBuf); + CMCHKPK(cmPkDateTime, &cntrl->t.cntrl.dt, mBuf); + + RETVALUE(ROK); +} /*end of function cmPkKwCntrl */ + +/** + * @brief + Pack unsolicit status + * + * @param[in] usta : RLC LM structure + * @param[in] elmnt : element + * @param[in] mBuf : Buffer + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ +#ifdef ANSI +PRIVATE S16 cmPkKwUsta +( +KwMngmt *usta, +Elmnt elmnt, +Buffer *mBuf +) +#else +PRIVATE S16 cmPkKwUsta(usta, elmnt, mBuf) +KwMngmt *usta; +Elmnt elmnt; +Buffer *mBuf; +#endif +{ + TRC3(cmPkKwUsta) + + /* lkw_c_001.main_2 removed warning */ + UNUSED(elmnt); + /* lkw_c_001.main_2 added support for L2 Measurement */ +#ifdef LTE_L2_MEAS + CMCHKPK(SPkU8, usta->t.usta.qci, mBuf); +#endif + CMCHKPK(SPkU32, usta->t.usta.ueId, mBuf); + CMCHKPK(SPkS16, usta->t.usta.suId, mBuf); + CMCHKPK(cmPkCmAlarm, &usta->t.usta.alarm,mBuf); + CMCHKPK(cmPkDateTime, &usta->t.usta.dt, mBuf); + + RETVALUE(ROK); + +} /* end of cmPkKwUsta */ + + +/** + * @brief + Pack + * + * @param[in] pst : post structure + * @param[in] cfg : RLC LM structure + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ +#ifdef ANSI +PRIVATE S16 cmPkKwSsta +( +KwMngmt *ssta, +Elmnt elmnt, +Event eventType, +Buffer *mBuf +) +#else +PRIVATE S16 cmPkKwSsta(ssta, elmnt, eventType, mBuf) +KwMngmt *ssta; +Elmnt elmnt; +Event eventType; +Buffer *mBuf; +#endif +{ + S16 ret1; + TRC3(cmPkKwSsta) + + ret1 = RFAILED; + switch(elmnt) + { + case STSID: + ret1 = ROK; + if(eventType == LKW_EVT_STA_CFM) + { + CMCHKPK(cmPkSystemId, &ssta->t.ssta.s.sysId,mBuf); + } + break; + case STCKWSAP: + ret1 = cmPkCkwSapSta(&ssta->t.ssta.s.ckwSap, mBuf); + break; + case STKWUSAP: + ret1 = cmPkKwuSapSta(&ssta->t.ssta.s.kwuSap, mBuf); + break; + case STRGUSAP: + case STUDXSAP: + ret1 = cmPkRguSapSta(&ssta->t.ssta.s.rguSap, mBuf); + break; + default: + ret1 = RFAILED; + break; + } + + if(ret1 != ROK) + { + RETVALUE(RFAILED); + } + + CMCHKPK(cmPkDateTime, &ssta->t.ssta.dt, mBuf); + + RETVALUE(ROK); + +} /* end of cmPkKwSsta */ + +/** + * @brief + Pack Trace Indication + * + * @param[in] trc : RLC LM structure + * @param[in] mBuf : Buffer + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ +#ifdef ANSI +PRIVATE S16 cmPkKwTrc +( +KwMngmt *trc, /* trace */ +Buffer *mBuf /* data buffer */ +) +#else +PRIVATE S16 cmPkKwTrc(trc, mBuf) +KwMngmt *trc; /* trace */ +Buffer *mBuf; /* data buffer */ +#endif +{ + TRC3(cmPkKwTrc) + + CMCHKPK(SPkU16, trc->t.trc.event, mBuf); + CMCHKPK(cmPkDateTime, &trc->t.trc.dt, mBuf); + + RETVALUE(ROK); +} /* end of cmPkKwTrc */ + + +/** + * @brief + Pack Statistics request + * + * @param[in] pst : post structure + * @param[in] cfg : RLC LM structure + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ + +#ifdef ANSI +PRIVATE S16 cmPkKwSts +( +KwMngmt *sts, +Elmnt elmnt, +Buffer *mBuf +) +#else +PRIVATE S16 cmPkKwSts(sts, elmnt, mBuf) +KwMngmt *sts; +Elmnt elmnt; +Buffer *mBuf; +#endif +{ + S16 ret1; + TRC3(cmPkKwSts) + + ret1 = RFAILED; + switch(elmnt) + { + case STGEN: + ret1 = cmPkGenSts(&sts->t.sts.s.gen, mBuf); + break; + case STCKWSAP: + ret1 = cmPkCkwSapSts(&sts->t.sts.s.ckwSap, mBuf); + break; + case STKWUSAP: + ret1 = cmPkKwuSapSts(&sts->t.sts.s.kwuSap, mBuf); + break; +/* lkw_c_001.main_2 removed support of RGU sap statistics as it is reflecting + * in general statstics. + * */ + default: + ret1 = RFAILED; + break; + } /* end of switch */ + + if(ret1 != ROK) + { + RETVALUE(RFAILED); + } + + CMCHKPK(cmPkDateTime, &sts->t.sts.dt, mBuf); + + RETVALUE(ROK); +} /* end of cmPkKwSts */ + + + +/** + * @brief + Pack general statistics + * + * @param[in] gen : KwGenSts structure + * @param[in] mBuf : Buffer + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ +#ifdef ANSI +PRIVATE S16 cmPkGenSts +( +KwGenSts *gen, +Buffer *mBuf +) +#else +PRIVATE S16 cmPkGenSts(gen, mBuf) +KwGenSts *gen; +Buffer *mBuf; +#endif +{ + TRC3(cmPkGenSts) + + CMCHKPK(SPkU32, gen->numSduDisc, mBuf); + CMCHKPK(SPkU32, gen->numOfRb, mBuf); + CMCHKPK(SPkU32, gen->protTimeOut, mBuf); + CMCHKPK(SPkU32, gen->errorPdusRecv, mBuf); + CMCHKPK(SPkU32, gen->unexpPdusRecv, mBuf); + CMCHKPK(SPkU32, gen->bytesSent, mBuf); + CMCHKPK(SPkU32, gen->bytesRecv, mBuf); + CMCHKPK(SPkU32, gen->pdusRetx, mBuf); + CMCHKPK(SPkU32, gen->pdusSent, mBuf); + CMCHKPK(SPkU32, gen->pdusRecv, mBuf); + CMCHKPK(SPkU32, gen->numUe, mBuf); + + RETVALUE(ROK); + +} /* end of cmPkGenSts */ + +/** + * @brief + Pack CKW statistics + * + * @param[in] pst : post structure + * @param[in] cfg : RLC LM structure + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ +#ifdef ANSI +PRIVATE S16 cmPkCkwSapSts +( +KwCkwCntSts *rcSap, +Buffer *mBuf +) +#else +PRIVATE S16 cmPkCkwSapSts(rcSap, mBuf) +KwCkwCntSts *rcSap; +Buffer *mBuf; +#endif +{ + TRC3(cmPkCkwSapSts) + + CMCHKPK(SPkU32, rcSap->statMsgs, mBuf); + + RETVALUE(ROK); +} /* end of cmPkCkwSapSts */ + +/** + * @brief + Pack Config Request + * + * @param[in] pst : post structure + * @param[in] cfg : RLC LM structure + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ +#ifdef ANSI +PRIVATE S16 cmPkKwuSapSts +( +KwKwuSapSts *ruSap, +Buffer *mBuf +) +#else +PRIVATE S16 cmPkKwuSapSts(ruSap, mBuf) +KwKwuSapSts *ruSap; +Buffer *mBuf; +#endif +{ + TRC3(cmPkCkwSapSts) + + CMCHKPK(SPkU32, ruSap->sduTx, mBuf); + CMCHKPK(SPkU32, ruSap->sduRx, mBuf); + /* lkw_c_001.main_2 changed from suId to spId */ + CMCHKPK(cmPkSuId, ruSap->spId, mBuf); + + RETVALUE(ROK); +} /* end of cmPkCkwSapSts */ + +/* lkw_c_001.main_2 removed support of RGU sap statistics as it is reflecting + * in general statstics. + * */ + +/** + * @brief + Unpack RLC Layer Management structure + * + * @param[in] param : RLC LM structure + * @param[in] eventType : event type + * @param[in] mBuf : message buffer + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ +#ifdef ANSI +PRIVATE S16 cmUnpkKwMngmt +( +KwMngmt *param, +Event eventType, +Buffer *mBuf +) +#else +PRIVATE S16 cmUnpkKwMngmt(param ,eventType, mBuf) +KwMngmt *param; +Event eventType; +Buffer *mBuf; +#endif +{ + S16 ret1; + TRC3(cmUnpkKwMngmt) + + cmMemset((U8 *) param, (U8) 0, (S16) sizeof(KwMngmt)); + + CMCHKUNPK(cmUnpkHeader, ¶m->hdr, mBuf); + CMCHKUNPK(cmUnpkCmStatus, ¶m->cfm, mBuf); + + switch( eventType ) + { + case LKW_EVT_CFG_REQ: + ret1 = cmUnpkKwCfg(param, param->hdr.elmId.elmnt ,mBuf); + if (ret1 != ROK) + { + RETVALUE(RFAILED); + } + break; + case LKW_EVT_CNTRL_REQ: + ret1 = cmUnpkKwCntrl(param, param->hdr.elmId.elmnt ,mBuf); + if (ret1 != ROK) + { + RETVALUE(RFAILED); + } + break; + + case LKW_EVT_STA_IND: + ret1 = cmUnpkKwUsta(param, param->hdr.elmId.elmnt ,mBuf); + if (ret1 != ROK) + { + RETVALUE(RFAILED); + } + break; + + case LKW_EVT_STA_REQ: + case LKW_EVT_STA_CFM: + ret1 = cmUnpkKwSsta(param, param->hdr.elmId.elmnt, eventType,mBuf); + if (ret1 != ROK) + { + RETVALUE(RFAILED); + } + break; + + case LKW_EVT_STS_REQ: + case LKW_EVT_STS_CFM: + + ret1 = cmUnpkKwSts(param, param->hdr.elmId.elmnt ,mBuf); + if (ret1 != ROK) + { + RETVALUE(RFAILED); + } + break; + case LKW_EVT_TRC_IND: + ret1 = cmUnpkKwTrc(param, mBuf); + if (ret1 != ROK) + { + RETVALUE(RFAILED); + } + break; + + case LKW_EVT_CNTRL_CFM: + case LKW_EVT_CFG_CFM: + break; + + default: + break; + } + RETVALUE(ROK); +} /*end of function cmUnpkKwMngmt*/ + +/** + * @brief + Unpack Kw configuration structure + * + * @param[out] cfg : RLC LM structure + * @param[in] elmnt : element + * @param[in] mBuf : message buffer + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ +#ifdef ANSI +PRIVATE S16 cmUnpkKwCfg +( +KwMngmt *cfg, +Elmnt elmnt, +Buffer *mBuf +) +#else +PRIVATE S16 cmUnpkKwCfg(cfg ,elmnt, mBuf) +KwMngmt *cfg; +Elmnt elmnt; +Buffer *mBuf; +#endif +{ + TRC3(cmUnpkKwCfg) + + switch(elmnt) + { + case STGEN: + { + CMCHKUNPK(cmUnpkPst, &cfg->t.cfg.s.gen.lmPst,mBuf); + CMCHKUNPK(SUnpkU32, &cfg->t.cfg.s.gen.maxUe, mBuf); + CMCHKUNPK(SUnpkU16, &cfg->t.cfg.s.gen.maxKwuSaps, mBuf); + CMCHKUNPK(SUnpkU16, &cfg->t.cfg.s.gen.maxUdxSaps, mBuf); + CMCHKUNPK(SUnpkU32, &cfg->t.cfg.s.gen.timeRes, mBuf); + CMCHKUNPK(SUnpkU8, &cfg->t.cfg.s.gen.rlcMode, mBuf); + CMCHKUNPK(SUnpkU16, &cfg->t.cfg.s.gen.maxRguSaps, mBuf); + } + break; + + case STCKWSAP: + case STKWUSAP: + case STRGUSAP: + case STUDXSAP: + { + CMCHKUNPK(SUnpkU8, &cfg->t.cfg.s.sap.selector, mBuf); + CMCHKUNPK(SUnpkU8, &cfg->t.cfg.s.sap.mem.region, mBuf); + CMCHKUNPK(SUnpkU8, &cfg->t.cfg.s.sap.mem.pool, mBuf); + CMCHKUNPK(SUnpkU16, &cfg->t.cfg.s.sap.procId, mBuf); + CMCHKUNPK(SUnpkU8, &cfg->t.cfg.s.sap.ent, mBuf); + CMCHKUNPK(SUnpkU8, &cfg->t.cfg.s.sap.inst, mBuf); + CMCHKUNPK(SUnpkS16, &cfg->t.cfg.s.sap.sapId, mBuf); + CMCHKUNPK(SUnpkU16, &cfg->t.cfg.s.sap.bndTmrIntvl, mBuf); + CMCHKUNPK(SUnpkU8, &cfg->t.cfg.s.sap.priority,mBuf); + CMCHKUNPK(SUnpkU8, &cfg->t.cfg.s.sap.route,mBuf); + } + break; + default: + RETVALUE(RFAILED); + } /* end of switch */ + + RETVALUE(ROK); +} /* end of cmUnpkKwCfg */ + +/** + * @brief + Unpack Control Structure + * + * @param[in] cfm : RLC LM structure + * @param[in] elmnt : element + * @param[in] mBuf : message buffer + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ +#ifdef ANSI +PRIVATE S16 cmUnpkKwCntrl +( +KwMngmt *cfm, +Elmnt elmnt, +Buffer *mBuf +) +#else +PRIVATE S16 cmUnpkKwCntrl(cfm, elmnt, mBuf) +KwMngmt *cfm; +Elmnt elmnt; +Buffer *mBuf; +#endif +{ + U8 subAction; + KwDbgCntrl *dbgCntrl; + KwTrcCntrl *trcCntrl; + + TRC3(cmUnpkKwCntrl); + + /* lkw_c_001.main_2 removed warning */ + UNUSED(elmnt); + + CMCHKUNPK(cmUnpkDateTime, &cfm->t.cntrl.dt, mBuf); + CMCHKUNPK(SUnpkU8, &cfm->t.cntrl.subAction, mBuf); + CMCHKUNPK(SUnpkU8, &cfm->t.cntrl.action, mBuf); + + subAction = cfm->t.cntrl.subAction; + + switch(cfm->hdr.elmId.elmnt) + { + case STGEN: + { + switch(subAction) + { + case SAUSTA: + break; + case SADBG: + { + dbgCntrl = &cfm->t.cntrl.s.dbgCntrl; + CMCHKUNPK(SUnpkU32, &dbgCntrl->dbgMask, mBuf); + } + break; + case SATRC: + { + trcCntrl = &cfm->t.cntrl.s.trcCntrl; + CMCHKUNPK(SUnpkU8, &trcCntrl->trcMask, mBuf); + CMCHKUNPK(SUnpkS16,&trcCntrl->trcLen, mBuf); + } + break; +#ifdef SS_DIAG + case SALOG: + { + CMCHKUNPK(SUnpkU32, &cfm->t.cntrl.s.logMask, mBuf); + } + break; +#endif + default: + break; + } + break; + } + case STRGUSAP: + case STUDXSAP: + CMCHKUNPK(SUnpkS16, &cfm->t.cntrl.s.sapCntrl.suId, mBuf); + CMCHKUNPK(SUnpkS16, &cfm->t.cntrl.s.sapCntrl.spId, mBuf); + break; + default: + break; + } + + RETVALUE(ROK); + +} /* end of cmUnpkKwCntrl */ + + +/** + * @brief + Unpack USta + * + * @param[in] usta : RLC LM Structure + * @param[in] elmnt : element + * @param[out] mBuf : message buffer + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ +#ifdef ANSI +PRIVATE S16 cmUnpkKwUsta +( +KwMngmt *usta, +Elmnt elmnt, +Buffer *mBuf +) +#else +PRIVATE S16 cmUnpkKwUsta(usta ,elmnt, mBuf) +KwMngmt *usta; +Elmnt elmnt; +Buffer *mBuf; +#endif +{ + TRC3(cmUnpkKwUsta); + + /* lkw_c_001.main_2 removed warning */ + UNUSED(elmnt); + + CMCHKUNPK(cmUnpkDateTime, &usta->t.usta.dt, mBuf); + CMCHKUNPK(cmUnpkCmAlarm, &usta->t.usta.alarm,mBuf); + CMCHKUNPK(SUnpkS16, &usta->t.usta.suId, mBuf); + CMCHKUNPK(SUnpkU32, &usta->t.usta.ueId, mBuf); + /* lkw_c_001.main_2 added support for L2 Measurement */ +#ifdef LTE_L2_MEAS + CMCHKUNPK(SUnpkU8, &usta->t.usta.qci, mBuf); +#endif + RETVALUE(ROK); +} + +/** + * @brief + Unpack SSta + * + * @param[out] ssta: RLC LM structure + * @param[in] elmnt : element + * @param[in] mBuf : message buffer + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ +#ifdef ANSI +PRIVATE S16 cmUnpkKwSsta +( +KwMngmt *ssta, +Elmnt elmnt, +Event eventType, +Buffer *mBuf +) +#else +PRIVATE S16 cmUnpkKwSsta(ssta ,elmnt, eventType, mBuf) +KwMngmt *ssta; +Elmnt elmnt; +Event eventType; +Buffer *mBuf; +#endif +{ + S16 ret1; /* return value */ + TRC3(cmUnpkKwSsta); + + CMCHKUNPK(cmUnpkDateTime, &ssta->t.ssta.dt, mBuf); + switch(elmnt) + { + case STSID: + ret1 = ROK; + if(eventType == LKW_EVT_STA_CFM) + { + cmMemset((U8 *) ptNmb, (U8) 0, LKW_PART_NUM_STR_LEN); + ssta->t.ssta.s.sysId.ptNmb = ptNmb; + CMCHKUNPK(cmUnpkSystemId, &ssta->t.ssta.s.sysId,mBuf); + } + break; + case STCKWSAP: + ret1 = cmUnpkCkwSapSta(&ssta->t.ssta.s.ckwSap, mBuf); + break; + case STKWUSAP: + ret1 = cmUnpkKwuSapSta(&ssta->t.ssta.s.kwuSap, mBuf); + break; + case STRGUSAP: + case STUDXSAP: + ret1 = cmUnpkRguSapSta(&ssta->t.ssta.s.rguSap, mBuf); + break; + default: + ret1 = RFAILED; + break; + } + + if(ret1 != ROK) + { + RETVALUE(RFAILED); + } + + RETVALUE(ROK); +} + + +/** + * @brief + Unpack trace Indication + * + * @param[out] trc : RLC LM Structure + * @param[in] mBuf : message buffer + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ +#ifdef ANSI +PRIVATE S16 cmUnpkKwTrc +( +KwMngmt *trc, +Buffer *mBuf +) +#else +PRIVATE S16 cmUnpkKwTrc(trc, mBuf) +KwMngmt *trc; +Buffer *mBuf; +#endif +{ + TRC3(cmUnpkKwTrc); + + CMCHKUNPK(cmUnpkDateTime, &trc->t.trc.dt, mBuf); + CMCHKUNPK(SUnpkU16, &trc->t.trc.event, mBuf); + + RETVALUE(ROK); +} /* end of cmUnpkKwTrc */ + + +/** + * @brief + Unpack Statistics + * + * @param[out] sts : RLC LM structure + * @param[in] elmnt : element + * @param[in] mBuf : message buffer + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ +#ifdef ANSI +PRIVATE S16 cmUnpkKwSts +( +KwMngmt *sts, +Elmnt elmnt, +Buffer *mBuf +) +#else +PRIVATE S16 cmUnpkKwSts(sts ,elmnt, mBuf) +KwMngmt *sts; +Elmnt elmnt; +Buffer *mBuf; +#endif +{ + S16 ret1; /* return value */ + TRC3(cmUnpkKwSts); + + CMCHKUNPK(cmUnpkDateTime, &sts->t.sts.dt, mBuf); + + switch(elmnt) + { + case STGEN: + ret1 = cmUnpkGenSts(&sts->t.sts.s.gen, mBuf); + break; + case STCKWSAP: + ret1 = cmUnpkCkwSapSts(&sts->t.sts.s.ckwSap, mBuf); + break; + case STKWUSAP: + ret1 = cmUnpkKwuSapSts(&sts->t.sts.s.kwuSap, mBuf); + break; +/* lkw_c_001.main_2 removed support of RGU sap statistics as it is reflecting + * in general statstics. + * */ + default: + ret1 = RFAILED; + break; + } /* end of switch */ + + if(ret1 != ROK) + { + RETVALUE(RFAILED); + } + + RETVALUE(ROK); +} /* end of cmUnpkKwSts */ + + +/** + * @brief + Unpack General statistics + * + * @param[out] gen : KwGenSts structure + * @param[in] mBuf : message buffer + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ +#ifdef ANSI +PRIVATE S16 cmUnpkGenSts +( +KwGenSts *gen, +Buffer *mBuf +) +#else +PRIVATE S16 cmUnpkGenSts(gen, mBuf) +KwGenSts *gen; +Buffer *mBuf; +#endif +{ + TRC3(cmUnpkGenSts); + + CMCHKUNPK(SUnpkU32, &gen->numUe, mBuf); + CMCHKUNPK(SUnpkU32, &gen->pdusRecv, mBuf); + CMCHKUNPK(SUnpkU32, &gen->pdusSent, mBuf); + CMCHKUNPK(SUnpkU32, &gen->pdusRetx, mBuf); + CMCHKUNPK(SUnpkU32, &gen->bytesRecv, mBuf); + CMCHKUNPK(SUnpkU32, &gen->bytesSent, mBuf); + CMCHKUNPK(SUnpkU32, &gen->unexpPdusRecv, mBuf); + CMCHKUNPK(SUnpkU32, &gen->errorPdusRecv, mBuf); + CMCHKUNPK(SUnpkU32, &gen->protTimeOut, mBuf); + CMCHKUNPK(SUnpkU32, &gen->numOfRb, mBuf); + CMCHKUNPK(SUnpkU32, &gen->numSduDisc, mBuf); + + RETVALUE(ROK); +} /* end of cmUnpkGenSts */ + +/** + * @brief + Unpack Ckw Sap Statistics + * + * @param[out] rcSap : KwCkwCntSts structure + * @param[in] mBuf : message buffer + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ +#ifdef ANSI +PRIVATE S16 cmUnpkCkwSapSts +( +KwCkwCntSts *rcSap, +Buffer *mBuf +) +#else +PRIVATE S16 cmUnpkCkwSapSts(rcSap ,mBuf) +KwCkwCntSts *rcSap; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkCkwSapSts); + + CMCHKUNPK(SUnpkU32, &rcSap->statMsgs, mBuf); + + RETVALUE(ROK); + +} /* end of cmUnpkCkwSapSts */ + +/** + * @brief + Unpack Kwu Sap statistics + * + * @param[out] : KwKwuSapSts structure + * @param[in] mBuf : message buffer + * @return S16 + * -# Success : ROK + * -# Failure : RFAILED + */ +#ifdef ANSI +PRIVATE S16 cmUnpkKwuSapSts +( +KwKwuSapSts *ruSap, +Buffer *mBuf +) +#else +PRIVATE S16 cmUnpkKwuSapSts(ruSap, mBuf) +KwKwuSapSts *ruSap; +Buffer *mBuf; +#endif +{ + TRC3(cmUnpkKwuSapSts) + + /* lkw_c_001.main_2 changed from suId to spId */ + CMCHKUNPK(cmUnpkSuId, &ruSap->spId, mBuf); + CMCHKUNPK(SUnpkU32, &ruSap->sduRx, mBuf); + CMCHKUNPK(SUnpkU32, &ruSap->sduTx, mBuf); + + RETVALUE(ROK); + +} /* end of cmUnpkKwuSapSts */ + +/* lkw_c_001.main_2 added support for L2 Measurement */ +#ifdef LTE_L2_MEAS +#ifdef ANSI +PUBLIC S16 cmPkLkwL2MeasReq +( +Pst * pst, +KwL2MeasReqEvt *measReqEvt +) +#else +PUBLIC S16 cmPkLkwL2MeasReq(pst, measReqEvt) +Pst * pst; +KwL2MeasReqEvt *measReqEvt; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkLkwL2MeasReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRLKW, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)measReqEvt, sizeof(KwL2MeasReqEvt)); + RETVALUE(RFAILED); + } + if (cmPkKwL2MeasReqInfo(&measReqEvt->measReq, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRLKW, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)measReqEvt, sizeof(KwL2MeasReqEvt)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkU16(measReqEvt->measPeriod, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRLKW, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)measReqEvt, sizeof(KwL2MeasReqEvt)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkU32(measReqEvt->transId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRLKW, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)measReqEvt, sizeof(KwL2MeasReqEvt)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + pst->event = (Event) LKW_EVT_L2MEAS_REQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + +#ifdef ANSI +PUBLIC S16 cmPkKwL2MeasReqInfo +( +KwL2MeasReqInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkKwL2MeasReqInfo(param, mBuf) +KwL2MeasReqInfo *param; +Buffer *mBuf; +#endif +{ + U8 idx; + U16 idx1; + + TRC3(cmPkKwL2MeasReqInfo) + + if((param->measType & LKW_L2MEAS_DL_IP) || + (param->measType & LKW_L2MEAS_UL_IP)) + { + for(idx1 = 0;idx1 < param->val.ipThMeas.numUes;idx1++) + { + + CMCHKPK(cmPkLteCellId, param->val.ipThMeas.ueInfoLst[idx1].cellId, mBuf); + CMCHKPK(cmPkLteRnti, param->val.ipThMeas.ueInfoLst[idx1].ueId, mBuf); + for(idx = 0; idx < param->val.ipThMeas.ueInfoLst[idx1].numQci; idx++) + { + CMCHKPK(SPkU8, param->val.ipThMeas.ueInfoLst[idx1].qci[idx], mBuf); + } + CMCHKPK(SPkU8, param->val.ipThMeas.ueInfoLst[idx1].numQci, mBuf); + } + CMCHKPK(SPkU16, param->val.ipThMeas.numUes, mBuf); + CMCHKPK(SPkU8, param->measType, mBuf); + RETVALUE(ROK); + } + else + { + for(idx = 0; idx < param->val.nonIpThMeas.numQci; idx++) + { + CMCHKPK(SPkU8, param->val.nonIpThMeas.qci[idx], mBuf); + } + CMCHKPK(SPkU8, param->val.nonIpThMeas.numQci, mBuf); + CMCHKPK(SPkU16, param->val.nonIpThMeas.numSamples, mBuf); + } + CMCHKPK(SPkU8, param->measType, mBuf); + RETVALUE(ROK); +} + +#ifdef ANSI +PUBLIC S16 cmPkLkwL2MeasStopReq +( +Pst *pst, +U8 measType +) +#else +PUBLIC S16 cmPkLkwL2MeasStopReq(pst, measType) +Pst *pst; +U8 measType; +#endif +{ + Buffer *mBuf = NULLP; + + TRC3(cmPkLkwL2MeasStopReq) + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRLKW, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + CMCHKPK(SPkU8, measType, mBuf); + pst->event = (Event) LKW_EVT_L2MEAS_STOP_REQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + +#ifdef ANSI +PUBLIC S16 cmPkLkwL2MeasSendReq +( +Pst *pst, +U8 measType +) +#else +PUBLIC S16 cmPkLkwL2MeasSendReq(pst, measType) +Pst *pst; +U8 measType; +#endif +{ + Buffer *mBuf = NULLP; + + TRC3(cmPkLkwL2MeasSendReq) + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRLKW, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + CMCHKPK(SPkU8, measType, mBuf); + pst->event = (Event) LKW_EVT_L2MEAS_SEND_REQ; + RETVALUE(SPstTsk(pst,mBuf)); +} +#ifdef TENB_SPLIT_ARCH +#ifdef ANSI +PUBLIC S16 cmUnpkLkwL2MeasReq +( +LkwL2MeasReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkLkwL2MeasReq(func, pst, mBuf) +LkwL2MeasReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + KwL2MeasReqEvt measReqEvt; + + TRC3(cmUnpkLkwL2MeasReq) + + if (SUnpkU32(&measReqEvt.transId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRLKW, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SUnpkU16(&measReqEvt.measPeriod, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRLKW, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (cmUnpkKwL2MeasReqInfo(&measReqEvt.measReq, mBuf) != ROK) + { + /*SPutSBuf(pst->region, pst->pool, (Data *)measReqEvt, sizeof(KwL2MeasReqEvt));*/ + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRLKW, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, &measReqEvt)); +} +#else +#ifdef ANSI +PUBLIC S16 cmUnpkLkwL2MeasReq +( +LkwL2MeasReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkLkwL2MeasReq(func, pst, mBuf) +LkwL2MeasReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + S16 ret; + KwL2MeasReqEvt *measReqEvt; + + TRC3(cmUnpkLkwL2MeasReq) + + + if((ret = SGetSBuf(pst->region, pst->pool, (Data **)&measReqEvt,\ + sizeof(KwL2MeasReqEvt))) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRLKW, (ErrVal)0, "SGetMsg() failed"); +#endif /* ERRCLASS & ERRCLS_ADD_RES */ + RETVALUE(ret); + } + + if (SUnpkU32(&measReqEvt->transId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRLKW, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SUnpkU16(&measReqEvt->measPeriod, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRLKW, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (cmUnpkKwL2MeasReqInfo(&measReqEvt->measReq, mBuf) != ROK) + { + SPutSBuf(pst->region, pst->pool, (Data *)measReqEvt, sizeof(KwL2MeasReqEvt)); + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRLKW, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, measReqEvt)); +} +#endif + +#ifdef ANSI +PUBLIC S16 cmUnpkKwL2MeasReqInfo +( +KwL2MeasReqInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkKwL2MeasReqInfo(param, mBuf) +KwL2MeasReqInfo *param; +Buffer *mBuf; +#endif +{ + U8 idx; + U16 idx1; + + TRC3(cmUnpkKwL2MeasReqInfo) + + CMCHKUNPK(SUnpkU8, ¶m->measType, mBuf); + + if((param->measType & LKW_L2MEAS_DL_IP) || + (param->measType & LKW_L2MEAS_UL_IP)) + { + CMCHKUNPK(SUnpkU16, ¶m->val.ipThMeas.numUes, mBuf); + for(idx1 = 0;idx1 < param->val.ipThMeas.numUes;idx1++) + { + CMCHKUNPK(SUnpkU8, ¶m->val.ipThMeas.ueInfoLst[idx1].numQci, mBuf); + for(idx = param->val.ipThMeas.ueInfoLst[idx1].numQci; idx > 0; idx--) + { + CMCHKUNPK(SUnpkU8, ¶m->val.ipThMeas.ueInfoLst[idx1].\ + qci[idx - 1], mBuf); + } + CMCHKUNPK(cmUnpkLteRnti, ¶m->val.ipThMeas.ueInfoLst[idx1].\ + ueId, mBuf); + CMCHKUNPK(cmUnpkLteCellId, ¶m->val.ipThMeas.\ + ueInfoLst[idx1].cellId, mBuf); + } + RETVALUE(ROK); + } + else + { + CMCHKUNPK(SUnpkU16, ¶m->val.nonIpThMeas.numSamples, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->val.nonIpThMeas.numQci, mBuf); + for(idx = param->val.nonIpThMeas.numQci; idx > 0; idx--) + { + CMCHKUNPK(SUnpkU8, ¶m->val.nonIpThMeas.qci[idx - 1], mBuf); + } + } + RETVALUE(ROK); +} + +#ifdef ANSI +PUBLIC S16 cmUnpkLkwL2MeasStopReq +( +LkwL2MeasStopReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkLkwL2MeasStopReq(func, pst, mBuf) +LkwL2MeasStopReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + U8 measType; + TRC3(cmUnpkLkwL2MeasReq) + + CMCHKUNPK(SUnpkU8, &measType, mBuf); + SPutMsg(mBuf); + RETVALUE((*func)(pst, measType)); +} + +#ifdef ANSI +PUBLIC S16 cmUnpkLkwL2MeasSendReq +( +LkwL2MeasSendReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkLkwL2MeasSendReq(func, pst, mBuf) +LkwL2MeasSendReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + U8 measType; + + TRC3(cmUnpkLkwL2MeasSendReq) + + CMCHKUNPK(SUnpkU8, &measType, mBuf); + SPutMsg(mBuf); + RETVALUE((*func)(pst, measType)); +} + +#ifdef ANSI +PUBLIC S16 cmPkLkwL2MeasCfm +( +Pst * pst, +KwL2MeasCfmEvt *measCfmEvt +) +#else +PUBLIC S16 cmPkLkwL2MeasCfm(pst, measCfmEvt) +Pst * pst; +KwL2MeasCfmEvt *measCfmEvt; +#endif +{ + Buffer *mBuf = NULLP; + U8 idx; + U8 idx1; + + TRC3(cmPkLkwL2MeasCfm) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRLKW, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)measCfmEvt, sizeof(KwL2MeasCfmEvt)); + RETVALUE(RFAILED); + } + + if((measCfmEvt->measType & LKW_L2MEAS_ACT_UE) || \ + (measCfmEvt->measType & LKW_L2MEAS_UU_LOSS) || \ + (measCfmEvt->measType & LKW_L2MEAS_DL_DISC) || \ + (measCfmEvt->measType & LKW_L2MEAS_DL_DELAY)) + { + for(idx = 0; idx < measCfmEvt->val.nonIpThMeas.numCfm; idx++) + { + if (cmPkKwL2MeasCfmInfo(&measCfmEvt->val.nonIpThMeas.measCfm[idx], \ + mBuf, measCfmEvt->measType) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRLKW, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + + if (SPkU16(measCfmEvt->val.nonIpThMeas.numCfm, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRLKW, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + else + { + for(idx1 =0 ;idx1< measCfmEvt->val.ipThMeas.numUes;idx1++) + { + + for(idx = 0; idx < measCfmEvt->val.ipThMeas.ueInfoLst[idx1].numCfm; idx++) + { + if (cmPkKwL2MeasCfmInfo(&measCfmEvt->val.ipThMeas.ueInfoLst[idx1].\ + measCfm[idx], mBuf, measCfmEvt->measType) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRLKW, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + + if (SPkU16(measCfmEvt->val.ipThMeas.ueInfoLst[idx1].numCfm, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRLKW, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + CMCHKPK(cmPkLteCellId, measCfmEvt->val.ipThMeas.ueInfoLst[idx1].cellId, mBuf); + CMCHKPK(cmPkLteRnti, measCfmEvt->val.ipThMeas.ueInfoLst[idx1].ueId, mBuf); + } + SPkU16(measCfmEvt->val.ipThMeas.numUes, mBuf); + } + + CMCHKPK(SPkU8, measCfmEvt->measType, mBuf); + CMCHKPK(cmPkCmStatus, &measCfmEvt->status, mBuf); + if (SPkU32(measCfmEvt->transId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRLKW, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + pst->event = (Event) LKW_EVT_L2MEAS_CFM; + RETVALUE(SPstTsk(pst,mBuf)); +} + +#ifdef ANSI +PUBLIC S16 cmPkKwL2MeasCfmInfo +( +KwL2MeasCfmInfo *param, +Buffer *mBuf, +U8 measType +) +#else +PUBLIC S16 cmPkKwL2MeasCfmInfo(param, mBuf, measType) +KwL2MeasCfmInfo *param; +Buffer *mBuf; +U8 measType; +#endif +{ + TRC3(cmPkKwL2MeasCfmInfo) + + if((measType & LKW_L2MEAS_DL_IP) || + (measType & LKW_L2MEAS_UL_IP)) + { + CMCHKPK(SPkF32, param->val.ipThrput.ulIpThPut, mBuf); + CMCHKPK(SPkF32, param->val.ipThrput.dlIpThPut, mBuf); + CMCHKPK(SPkU8, param->qci, mBuf); + RETVALUE(ROK); + } + else + { + CMCHKPK(SPkU32, param->val.nonIpThrput.dlDiscRate, mBuf); + CMCHKPK(SPkU32, param->val.nonIpThrput.uuLoss, mBuf); + CMCHKPK(SPkU32, param->val.nonIpThrput.numActUe, mBuf); + CMCHKPK(SPkU32, param->val.nonIpThrput.dlSduDelay, mBuf); + CMCHKPK(SPkU8, param->qci, mBuf); + } + RETVALUE(ROK); +} + +#ifdef ANSI +PUBLIC S16 cmUnpkLkwL2MeasCfm +( +LkwL2MeasCfm func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkLkwL2MeasCfm(func, pst, mBuf) +LkwL2MeasCfm func; +Pst *pst; +Buffer *mBuf; +#endif +{ + U8 idx; + U16 idx1; + KwL2MeasCfmEvt measCfmEvt; + + TRC3(cmUnpkLkwL2MeasCfm) + + cmMemset((U8 *)&measCfmEvt, 0 , sizeof(KwL2MeasCfmEvt)); + + if (SUnpkU32(&measCfmEvt.transId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRLKW, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + CMCHKUNPK(cmUnpkCmStatus, &measCfmEvt.status, mBuf); + CMCHKUNPK(SUnpkU8, &measCfmEvt.measType, mBuf); + + if(measCfmEvt.measType & LKW_L2MEAS_DL_IP || measCfmEvt.measType & LKW_L2MEAS_UL_IP) + { + CMCHKUNPK(SUnpkU16, &measCfmEvt.val.ipThMeas.numUes, mBuf); + for(idx1 = 0;idx1srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRLKW, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + for(idx = measCfmEvt.val.ipThMeas.ueInfoLst[idx1].numCfm; idx > 0; idx--) + { + if (cmUnpkKwL2MeasCfmInfo(&measCfmEvt.val.ipThMeas.ueInfoLst[idx1].\ + measCfm[idx - 1], mBuf, measCfmEvt.measType) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRLKW, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + } + } + } + else + { + if (SUnpkU16(&measCfmEvt.val.nonIpThMeas.numCfm, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRLKW, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + for(idx = measCfmEvt.val.nonIpThMeas.numCfm; idx > 0; idx--) + { + if (cmUnpkKwL2MeasCfmInfo(&measCfmEvt.val.nonIpThMeas.measCfm[idx - 1], \ + mBuf, measCfmEvt.measType) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRLKW, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + } + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, &measCfmEvt)); +} + +#ifdef ANSI +PUBLIC S16 cmUnpkKwL2MeasCfmInfo +( +KwL2MeasCfmInfo *param, +Buffer *mBuf, +U8 measType +) +#else +PUBLIC S16 cmUnpkKwL2MeasCfmInfo(param, mBuf, measType) +KwL2MeasCfmInfo *param; +Buffer *mBuf; +U8 measType; +#endif +{ + TRC3(cmUnpkKwL2MeasCfmInfo) + + if((measType & LKW_L2MEAS_DL_IP) || + (measType & LKW_L2MEAS_UL_IP)) + { + CMCHKUNPK(SUnpkU8, ¶m->qci, mBuf); + CMCHKUNPK(SUnpkF32, ¶m->val.ipThrput.dlIpThPut, mBuf); + CMCHKUNPK(SUnpkF32, ¶m->val.ipThrput.ulIpThPut, mBuf); + } + else + + { + CMCHKUNPK(SUnpkU8, ¶m->qci, mBuf); + CMCHKUNPK(SUnpkU32, ¶m->val.nonIpThrput.dlSduDelay, mBuf); + CMCHKUNPK(SUnpkU32, ¶m->val.nonIpThrput.numActUe, mBuf); + CMCHKUNPK(SUnpkU32, ¶m->val.nonIpThrput.uuLoss, mBuf); + CMCHKUNPK(SUnpkU32, ¶m->val.nonIpThrput.dlDiscRate, mBuf); + } + RETVALUE(ROK); +} + + +#ifdef ANSI +PUBLIC S16 cmPkLkwL2MeasStopCfm +( +Pst * pst, +U8 measType, +U8 status +) +#else +PUBLIC S16 cmPkLkwL2MeasStopCfm(pst, measType,status) +Pst * pst; +U8 measType; +U8 status +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkLkwL2MeasStopCfm) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERRLKW, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + CMCHKPK(SPkU8, status, mBuf); + CMCHKPK(SPkU8, measType, mBuf); + pst->event = (Event) LKW_EVT_L2MEAS_STOP_CFM; + RETVALUE(SPstTsk(pst,mBuf)); +} + +#ifdef ANSI +PUBLIC S16 cmUnpkLkwL2MeasStopCfm +( +LkwL2MeasStopCfm func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkLkwL2MeasStopCfm(func, pst, mBuf) +LkwL2MeasStopCfm func; +Pst *pst; +Buffer *mBuf; +#endif +{ + U8 measType; + U8 status; + TRC3(cmUnpkLkwL2MeasCfm) + CMCHKUNPK(SUnpkU8, &measType, mBuf); + CMCHKUNPK(SUnpkU8, &status, mBuf); + SPutMsg(mBuf); + RETVALUE((*func)(pst, measType,status)); +} +#endif /* LTE_L2_MEAS */ +#endif /* LCLKW */ + + +/********************************************************************** + End of file + **********************************************************************/ diff --git a/src/cm/lpj.h b/src/cm/lpj.h deleted file mode 100755 index aa92975b4..000000000 --- a/src/cm/lpj.h +++ /dev/null @@ -1,237 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: LPJ PDCP Layer Manager Interface - - Type: C include file - - Desc: This file Contains the Hash defines for LPJ Interface - - File: lpj.h - -*********************************************************************21*/ - -#ifndef __LPJ_H__ -#define __LPJ_H__ - -#ifdef __cplusplus -EXTERN "C" { -#endif /*for extern "C"*/ - -#define STUDXSAP 189 - -#define LPJ_SEL_LC 0 -#ifdef TENB_SPLIT_ARCH -#define LPJ_MODE_PDCP_UL 0x1 -#define LPJ_MODE_PDCP_DL 0x2 -#endif - -/* KWU Interface Hash Defines */ -#define LPJ_MAX_NUM_RB 24 /*!< Maximum number of RBs. */ - -/* Event codes at the PDCP management interface */ -#define LPJ_EVT_CFG_REQ 0x50 /*!< General configuration request. */ -#define LPJ_EVT_CFG_CFM 0x51 /*!< General configuration confirm. */ -#define LPJ_EVT_CNTRL_REQ 0x52 /*!< Control request. */ -#define LPJ_EVT_CNTRL_CFM 0x53 /*!< Control confirm. */ -#define LPJ_EVT_STA_IND 0x54 /*!< Unsolicited status indication. */ -#define LPJ_EVT_STA_REQ 0x55 /*!< Solicited status request. */ -#define LPJ_EVT_STA_CFM 0x56 /*!< Solicited status confirm. */ -#define LPJ_EVT_STS_REQ 0x57 /*!< Statistics request. */ -#define LPJ_EVT_STS_CFM 0x58 /*!< Statistics confirm. */ -#define LPJ_EVT_TRC_IND 0x59 /*!< Trace indication. */ -/* lpj_h_001.main_2 added support for L2 Measurement */ -#define LPJ_EVT_L2MEAS_REQ 0x60 /*!< L2 Measurement Request. */ -#define LPJ_EVT_L2MEAS_CFM 0x61 /*!< L2 Measurement Confirm. */ -#ifdef LTE_L2_MEAS -#define LPJ_EVT_MEAS_HALT 0x62 /*!< Measurement is halted due to RB deletion */ -#define LPJ_EVT_L2MEAS_SEND_REQ 0x63 /*!< L2 Measurement Send Request*/ -#define LPJ_EVT_L2MEAS_STOP_REQ 0x64 /*!< L2 Measurement Stop Request*/ -#define LPJ_EVT_L2MEAS_STOP_CFM 0x65 /*!< L2 Measurement Stop Confirm*/ -#endif -#define LPJ_EVT_L2MEAS_SEND_REQ 0x63 /*!< L2 Measurement send request*/ -#define LPJ_EVT_L2MEAS_STOP_REQ 0x64 /*!< L2 Measurement stop request.*/ -#define LPJ_EVT_L2MEAS_STOP_CFM 0x65 /*!< L2 Measurement stop confirm*/ - -#define LPJ_ZEROSTS 0 /*!< Reset the statistics counters. */ -#define LPJ_NOZEROSTS 1 /*!< No reset of statistics counters. */ - -/********************************************************************KW** - Specific event values -*********************************************************************KW*/ -#define LPJ_EVENT_RGU_BND_CFM (LCM_EVENT_LYR_SPECIFIC + 1) -#define LPJ_EVENT_KWU_BND_REQ (LCM_EVENT_LYR_SPECIFIC + 2) -#define LPJ_EVENT_CKW_BND_REQ (LCM_EVENT_LYR_SPECIFIC + 3) -#define LPJ_EVENT_CPJ_BND_REQ (LCM_EVENT_LYR_SPECIFIC + 4) -#define LPJ_EVENT_PJU_BND_REQ (LCM_EVENT_LYR_SPECIFIC + 5) - -/********************************************************************KW** - Specific cause values -*********************************************************************KW*/ -#define LPJ_CAUSE_UNKNOWN (LCM_CAUSE_LYR_SPECIFIC + 1) -#define LPJ_CAUSE_SAP_BNDENB (LCM_CAUSE_LYR_SPECIFIC + 2) -#define LPJ_CAUSE_SAP_BNDDIS (LCM_CAUSE_LYR_SPECIFIC + 3) -#define LMG_CAUSE_RSRC_UNAVAIL (LCM_CAUSE_LYR_SPECIFIC + 4) -/* lpj_h_001.main_2 added support for L2 Measurement */ -#ifdef LTE_L2_MEAS -#define LPJ_CAUSE_MEM_FAILED (LCM_CAUSE_LYR_SPECIFIC + 5) -#define LPJ_CAUSE_INVALID_MEASTYPE (LCM_CAUSE_LYR_SPECIFIC + 6) -#define LPJ_CAUSE_EXCEED_MEASREQ (LCM_CAUSE_LYR_SPECIFIC + 7) -#define LPJ_CAUSE_EXCEED_NUMQCI (LCM_CAUSE_LYR_SPECIFIC + 8) -#define LPJ_CAUSE_MEAS_ALREADY_ENA (LCM_CAUSE_LYR_SPECIFIC + 9) -#define LPJ_CAUSE_INVALID_QCI (LCM_CAUSE_LYR_SPECIFIC + 10) -#define LPJ_CAUSE_ZERO_MEASPERIOD (LCM_CAUSE_LYR_SPECIFIC + 11) -#define LPJ_CAUSE_RB_DELETION (LCM_CAUSE_LYR_SPECIFIC + 12) -#endif -/************************************************************************ - * Events - ***********************************************************************/ -#define LPJ_EVT_BND_REQ 0 /*!< Bind Request Event. */ -#define LPJ_EVT_BND_CFM 1 /*!< Bind Confirm Event. */ -#define LPJ_EVT_UBND_REQ 2 /*!< Unbind Request Event. */ -#define LPJ_EVT_WAIT_BNDCFM 3 /*!< Wait Bind Confirm Event. */ - -/************************************************************************* - * KWU SAPs - ************************************************************************/ -#define LPJ_RRC_SAP 0x00 /*!< RLU SAP ID for RRC */ -#define LPJ_PDCP_SAP 0x01 /*!< RLU SAP ID for PDCP */ - -/********************************************************************KW** - Usta defines -*********************************************************************KW*/ -#define LPJ_USTA_DGNVAL_NONE 1 -#define LPJ_USTA_DGNVAL_MEM 2 -#define LPJ_USTA_DGNVAL_SAPID 3 -#define LPJ_USTA_DGNVAL_UEID 4 -#define LPJ_USTA_MAX_DGNVAL 256 -/********************************************************************KW** - Specific event values -*********************************************************************KW*/ -#define LPJ_EVENT_LI_BND_CFM (LCM_EVENT_LYR_SPECIFIC + 1) - -#define LPJ_PART_NUM_STR_LEN 10 /*!< Part Number String Length. */ - -/* lpj_h_001.main_2 added support for L2 Measurement */ -/********************************************************************KW** - L2 MEASUREMENT VALUES -*********************************************************************KW*/ -#ifdef LTE_L2_MEAS -#define LPJ_L2MEAS_NONE 0x0000 -#define LPJ_L2MEAS_DL_DELAY 0x0001 -#define LPJ_L2MEAS_DL_DISC 0x0002 -#define LPJ_L2MEAS_UL_LOSS 0x0004 -#define LPJ_L2MEAS_DLDP_BIT_RATE 0x0008 /*Added for L2 Meas*/ -#define LPJ_L2MEAS_ULDP_BIT_RATE 0x0010 -#define LPJ_L2MEAS_DLCP_BIT_RATE 0x0020 -#define LPJ_L2MEAS_ULCP_BIT_RATE 0x0040 -#define LPJ_L2CPU_PERCORE_STATS 0x0080 -#define LPJ_L2MEM_PERPOOL_STATS 0x0100 - -#define LPJ_MAX_L2MEAS 5 -#define LPJ_MAX_QCI 10 -#endif -/* lpj_h_001.main_1 */ -#define LPJ_FULL_TRACE -1 /*!< Trace macro to get full trace */ -/* Added Log Error for LPJ Interface */ -#define LPJLOGERROR(_pst, _errCls, _errCode, _errVal, _errDesc) \ - SLogError(_pst->srcEnt, _pst->srcInst, _pst->srcProcId, \ - __FILE__, __LINE__, _errCls, _errCode, _errVal, _errDesc) - -/* Error Codes */ -#define ERRLPJ 0 - -#define ELPJ001 (ERRLPJ + 1) -#define ELPJ002 (ERRLPJ + 2) -#define ELPJ003 (ERRLPJ + 3) -#define ELPJ004 (ERRLPJ + 4) -#define ELPJ005 (ERRLPJ + 5) -#define ELPJ006 (ERRLPJ + 6) -#define ELPJ007 (ERRLPJ + 7) -#define ELPJ008 (ERRLPJ + 8) -#define ELPJ009 (ERRLPJ + 9) -#define ELPJ010 (ERRLPJ + 10) -#define ELPJ011 (ERRLPJ + 11) -#define ELPJ012 (ERRLPJ + 12) -#define ELPJ013 (ERRLPJ + 13) -#define ELPJ014 (ERRLPJ + 14) -#define ELPJ015 (ERRLPJ + 15) -#define ELPJ016 (ERRLPJ + 16) -#define ELPJ017 (ERRLPJ + 17) -#define ELPJ018 (ERRLPJ + 18) -#define ELPJ019 (ERRLPJ + 19) -#define ELPJ020 (ERRLPJ + 20) -#define ELPJ021 (ERRLPJ + 21) -#define ELPJ022 (ERRLPJ + 22) -#define ELPJ023 (ERRLPJ + 23) -#define ELPJ024 (ERRLPJ + 24) -#define ELPJ025 (ERRLPJ + 25) -#define ELPJ026 (ERRLPJ + 26) -#define ELPJ027 (ERRLPJ + 27) -#define ELPJ028 (ERRLPJ + 28) -#define ELPJ029 (ERRLPJ + 29) -#define ELPJ030 (ERRLPJ + 30) -#define ELPJ031 (ERRLPJ + 31) -#define ELPJ032 (ERRLPJ + 32) -#define ELPJ033 (ERRLPJ + 33) -#define ELPJ034 (ERRLPJ + 34) -#define ELPJ035 (ERRLPJ + 35) -#define ELPJ036 (ERRLPJ + 36) -#define ELPJ037 (ERRLPJ + 37) -#define ELPJ038 (ERRLPJ + 38) -#define ELPJ039 (ERRLPJ + 39) -#define ELPJ040 (ERRLPJ + 40) -#define ELPJ041 (ERRLPJ + 41) -#define ELPJ042 (ERRLPJ + 42) -#define ELPJ043 (ERRLPJ + 43) -#define ELPJ044 (ERRLPJ + 44) -#define ELPJ045 (ERRLPJ + 45) -#define ELPJ046 (ERRLPJ + 46) -#define ELPJ047 (ERRLPJ + 47) -#define ELPJ048 (ERRLPJ + 48) -#define ELPJ049 (ERRLPJ + 49) -#define ELPJ050 (ERRLPJ + 50) -#define ELPJ051 (ERRLPJ + 51) -#define ELPJ052 (ERRLPJ + 52) -#define ELPJ053 (ERRLPJ + 53) -#define ELPJ054 (ERRLPJ + 54) -#define ELPJ055 (ERRLPJ + 55) -#define ELPJ056 (ERRLPJ + 56) -#define ELPJ057 (ERRLPJ + 57) -#define ELPJ058 (ERRLPJ + 58) -#define ELPJ059 (ERRLPJ + 59) -#define ELPJ060 (ERRLPJ + 60) -#define ELPJ061 (ERRLPJ + 61) -#define ELPJ062 (ERRLPJ + 62) -#define ELPJ063 (ERRLPJ + 63) -#define ELPJ064 (ERRLPJ + 64) -#define ELPJ065 (ERRLPJ + 65) -#define ELPJ066 (ERRLPJ + 66) -#define ELPJ067 (ERRLPJ + 67) - -#ifdef __cplusplus -} -#endif /* __cplusplus */ -#endif /* __LPJ_H__ */ - - -/********************************************************************30** - End of file -**********************************************************************/ diff --git a/src/cm/lpj.x b/src/cm/lpj.x deleted file mode 100755 index c1d05c824..000000000 --- a/src/cm/lpj.x +++ /dev/null @@ -1,951 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: PDCP Layer Manager Interface: LPJ - - Type: C include file - - Desc: This file Contains the Data structures and prototypes - for LPJ Interface - - File: lpj.x - -*********************************************************************21*/ - -#ifndef __LPJ_X__ -#define __LPJ_X__ - -#ifdef __cplusplus -EXTERN "C" { -#endif /* __cplusplus */ - -#if (defined(KW_PDCP) || defined(TENB_SPLIT_ARCH)) -/*typedef U32 CntrSts;*/ -#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) - -/** @struct PjOBPst - * Post Info for Off-board Entities */ -typedef struct pjObdPst -{ - Pst cmpPst; /*!< Service user post structure - for compression */ - Pst secPst; /*!< Service user post structure - for security algorithm */ -}PjObdPst; -#endif /* PJ_SEC_ASYNC || PJ_CMP_ASYNC */ - -/** @brief - General Configuration Structure. */ -typedef struct pjGenCfg -{ - Pst lmPst; /*!< Post structure for communicating - with LM. */ - Ticks timeRes; /*!< Time resolution. */ - U8 mode; /*!< Pdcp mode DL / UL */ - U8 maxPjuSaps; /*!< Number of PDCP Data SAPs */ - U8 maxKwuSaps; /*!< Number of PDCP Data SAPs */ - U8 maxUdxSaps; /*!< Number of Udx SAPs */ - U8 nmbUlBins; /*!< Number of bins which is used for - RxBuff to store */ - U8 nmbDlBins; /*!< Number of bins which is used for - RxBuff to store */ - U32 maxUe; -#if (defined(PJ_SEC_ASYNC) || defined (PJ_CMP_ASYNC)) - S32 obdTmrInt; /*!< Timer Interval used while - waiting for an output data from - Off-board entities */ - S32 obdWtTmrInt; /*!< OBD wait timer used while opening - and closing the context with - Off-board entities */ - PjObdPst obdPst; /*!< Post Information for off-board Interface */ -#endif /* PJ_SEC_ASYNC || PJ_CMP_ASYNC */ -}PjGenCfg; - -/** @brief - SAP Configuration Structure */ -typedef struct pjSapCfg -{ - Selector selector; /*!< Selector for LC/TC. */ - MemoryId mem; /*!< Region and pool. */ - ProcId procId; /*!< Processor ID. */ - Ent ent; /*!< Entity ID. */ - Inst inst; /*!< Instance ID. */ - - SpId sapId; /*!< SAP ID. */ - U16 bndTmrIntvl; /*!< Bind timer interval. */ - Priority priority; /*!< Priority. */ - Route route; /*!< Route. */ -}PjSapCfg; - -/** @brief -* Configuration Structure -*/ -typedef struct pjCfg -{ - union - { - PjGenCfg gen; /*!< General configuraton. */ - PjSapCfg sap; /*!< SAP configuration. */ - }s; -}PjCfg; - -/** @brief - General Statistics Structure */ -typedef struct pjGenSts -{ - CntrSts numUe; - CntrSts numOfRb; /*!< Total number of RBs in PDCP */ - CntrSts rxPdus; /*!< Number of PDUs received Layer from RLC. */ - CntrSts txPdus; /*!< Number of PDUs sent to RLC. */ - CntrSts errorPdusRecv; /*!< Format error PDUs received from RLC. */ - CntrSts numSdusDisc; /*!< Number of SDUs discarded due to PDCP - discard timer expiry. */ - CntrSts numCmpFails; /*!< Number of Compression fails */ - CntrSts numDecmpFails; /*!< Number of Decompression fails */ - CntrSts numIntgPrtFails; /*!< Number of Integration Protection fails */ - CntrSts numIntgVrfFails; /*!< Number of Integration Verification fails */ - CntrSts numCiphFails; /*!< Number of Ciphering fails */ - CntrSts numDeciphFails; /*!< Number of Deciphering fails */ - CntrSts numPdusDiscObdTmrExp; /*!< Number of PDUs discarded in UL - due to Off-board timer expiry. */ - CntrSts numSdusDiscObdTmrExp; /*!< Number of SDUs discarded in DL - due to Off-board timer expiry. */ - CntrSts numPktsFrwd; /*!< Number of Packets forwarded to X2 - interface */ - CntrSts numPktsRcvd; /*!< Number of Packets recieved to X2 - interface */ -}PjGenSts; - -/** @brief - General Statistics Structure */ -typedef struct pjPjuSts -{ - /* lpj_x_001.main_1 modified from suId to spId */ - SpId spId; /*!< Service provider ID. */ - CntrSts rxSdus; /*!< Number of SDUs received Layer from UL. */ - CntrSts txSdus; /*!< Number of SDUs sent to UL. */ -}PjPjuSts; -/** @brief - Statistics Structure */ -typedef struct pjSts -{ - DateTime dt; /*!< Date and Time structure. */ - union - { - PjGenSts gen; /*!< General Statistics. */ - PjPjuSts pjuSap; /*!< PJU SAP Statistics. */ - }s; -}PjSts; - -/** @brief - PDCP Data Plane Upper SAP Status Structure */ -typedef struct pjPjuSapSta -{ - SpId spId; /*!< Service provider ID. */ - State state; /*!< State of the SAP. */ -}PjPjuSapSta; - -/** @brief - PDCP Uplink Downlink SAP Status Structure */ -typedef struct pjUdxSapSta -{ - SpId spId; /*!< Service provider ID. */ - State state; /*!< State of the SAP. */ -}PjUdxSapSta; - - -/** @brief - PDCP Data Plane Upper SAP Status Structure */ -typedef struct pjKwuSapSta -{ - SpId spId; /*!< Service provider ID. */ - State state; /*!< State of the SAP. */ -}PjKwuSapSta; - -/** @brief - PDCP Control Plane SAP Status Structure */ -typedef struct pjCpjSapSta -{ - SpId spId; /*!< Service provider ID. */ - State state; /*!< State of the SAP. */ -}PjCpjSapSta; - -/** @brief - Status Structure */ -typedef struct pjSSta -{ - DateTime dt; /*!< Date and Time structure. */ - union - { - SystemId sysId; /*!< System ID. */ - PjCpjSapSta cpjSap; /*!< PDCP Control plane Upper SAP Status. */ - PjPjuSapSta pjuSap; /*!< PDCP Data plane Upper SAP status. */ - PjKwuSapSta kwuSap; /*!< PDCP Data plane Upper SAP status. */ - PjUdxSapSta udxSap; /*!< PDCP Data plane Upper SAP status. */ - }s; -}PjSSta; - -/** @brief - Trace Control Structure */ -typedef struct pjTrcCntrl -{ - U8 trcMask; /*!< Trace mask. */ - S16 trcLen; /*!< Trace length. */ -}PjTrcCntrl; - -/** @brief - Debug Control Structure */ -typedef struct pjDbgCntrl -{ - U32 dbgMask; /*!< Debug mask. Assign non zero value to enable - and zero to disable debug */ -}PjDbgCntrl; - -/** @brief - SAP Control Structure */ -typedef struct pjSapCntrl -{ - SuId suId; /*!< Service user ID. */ - SpId spId; /*!< Service provider ID. */ -}PjSapCntrl; - -/** @brief - Control Structure */ -typedef struct pjCntrl -{ - DateTime dt; /*!< Date and Time structure. */ - U8 action; /*!< Action. */ - U8 subAction; /*!< Sub action. */ - union - { - PjTrcCntrl trcCntrl; /*!< Trace Control Structure. */ - PjDbgCntrl dbgCntrl; /*!< Debug Control Structure. */ -#ifdef SS_DIAG - U32 logMask; /*!< Logging Control Structure. */ -#endif - PjSapCntrl sapCntrl; /*!< Debug Control Structure. */ - }s; -}PjCntrl; - -/** @brief - Unsolicited Status Structure */ -typedef struct pjUSta -{ - DateTime dt; /*!< Date and Time structure. */ - CmAlarm alarm; /*!< Alarm. */ - SuId suId; /*!< Service user ID. */ - U32 ueId; /*!< Urnti UE ID. */ - /* lpj_x_001.main_1 added support for L2 Measurement */ -#ifdef LTE_L2_MEAS - U8 qci; /*!< QCI */ -#endif -}PjUSta; - -/** @brief - Trace Structure */ -typedef struct pjTrc -{ - DateTime dt; /*!< Date and Time structure. */ - U16 event; /*!< Event. Events defined in the different PDCP - interfaces are possible values here.*/ -}PjTrc; - -/** @brief - Layer Management Structure */ -typedef struct _pjMngmt -{ - Header hdr; /*!< common header. */ - CmStatus cfm; /*!< Status of confirmation. */ - union - { - PjCfg cfg; /*!< General Configuration. */ - PjCntrl cntrl; /*!< Control Structure. */ - PjSts sts; /*!< Statistics. */ - PjSSta ssta; /*!< Status. */ - PjUSta usta; /*!< Unsolicited Status. */ - PjTrc trc; /*!< Trace Structre. */ - }t; -}PjMngmt; - -/* lpj_x_001.main_1 added support for L2 Measurement */ -#ifdef LTE_L2_MEAS -/** @brief Measurement Request Params Structure. */ -typedef struct pjL2MeasReqInfo -{ - U16 measType; /*!< Type of measurement */ - U8 numQci; /*!< Number of qCI to take measurement for */ - U8 qci[LPJ_MAX_QCI]; /*!< QCI for the measurement */ -}PjL2MeasReqInfo; - -/** @brief Measurement Request Structure. */ -typedef struct pjL2MeasReqEvt -{ - U32 transId; /*!< Transaction identifier */ - U16 measPeriod; /*!< Time period of measurement */ - PjL2MeasReqInfo measReq; /*!< Measurement request */ -}PjL2MeasReqEvt; - -/** @brief Measurement Confirm Params Structure. */ -typedef struct pjL2MeasCfmInfo -{ - U8 qci; /*!< Qci */ - U32 dlDelay; /*!< DL Delay */ - U32 dlDisc; /*!< DL Discard */ - U32 ulLoss; /*!< UL Loss */ - U32 ulBitRate; /*!< UL Data Plane Bit Rate*/ - U32 dlBitRate; /*!< DL Data Plane Bit Rate*/ - U32 dlCpBitRate;/*!
region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG001, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector == LRG_SEL_LC) { + if (cmPkRgMngmt(pst, cfg, EVTLRGCFGREQ, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG002, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + pst->event = (Event) EVTLRGCFGREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief This API is used to send a +Configuration Request from LM to MAC. +* +* @details +* +* Function: cmUnpkLrgCfgReq +* +* @param[in] Pst * pst +* @param[in] RgMngmt * cfg +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkLrgCfgReq +( +LrgCfgReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkLrgCfgReq(func, pst, mBuf) +LrgCfgReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + /* lrg_c_001.main_2: Changed Pointer across Interface */ + RgMngmt cfg; + + TRC3(cmUnpkLrgCfgReq) + + if (cmUnpkRgMngmt(pst, &cfg, EVTLRGCFGREQ, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG003, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, &cfg)); +} + + +/** +* @brief This API is used to send a +Configuration Request from LM to SCH. +* +* @details +* +* Function: cmPkLrgSchCfgReq +* +* @param[in] Pst * pst +* @param[in] RgMngmt * cfg +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkLrgSchCfgReq +( +Pst * pst, +RgMngmt * cfg +) +#else +PUBLIC S16 cmPkLrgSchCfgReq(pst, cfg) +Pst * pst; +RgMngmt * cfg; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkLrgSchCfgReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG004, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector == LRG_SEL_LC) { + if (cmPkRgMngmt(pst, cfg, EVTLRGSCHCFGREQ, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG005, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + + pst->event = (Event) EVTLRGSCHCFGREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief This API is used to send a +Configuration Request from LM to SCH. +* +* @details +* +* Function: cmUnpkLrgSchCfgReq +* +* @param[in] Pst * pst +* @param[in] RgMngmt * cfg +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkLrgSchCfgReq +( +LrgSchCfgReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkLrgSchCfgReq(func, pst, mBuf) +LrgSchCfgReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + /* lrg_c_001.main_2: Changed Pointer across Interface */ + RgMngmt cfg; + + TRC3(cmUnpkLrgSchCfgReq) + + if (cmUnpkRgMngmt(pst, &cfg, EVTLRGSCHCFGREQ, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG006, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, &cfg)); +} + + +/** +* @brief This API is used to send a +Configuration Confirm from MAC to LM. +* +* @details +* +* Function: cmPkLrgCfgCfm +* +* @param[in] Pst * pst +* @param[in] RgMngmt * cfm +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkLrgCfgCfm +( +Pst * pst, +RgMngmt * cfm +) +#else +PUBLIC S16 cmPkLrgCfgCfm(pst, cfm) +Pst * pst; +RgMngmt * cfm; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkLrgCfgCfm) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG007, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector == LRG_SEL_LC) { + if (cmPkRgMngmt(pst, cfm, EVTLRGCFGCFM, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG008, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + + pst->event = (Event) EVTLRGCFGCFM; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief This API is used to send a +Configuration Confirm from MAC to LM. +* +* @details +* +* Function: cmUnpkLrgCfgCfm +* +* @param[in] Pst * pst +* @param[in] RgMngmt * cfm +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkLrgCfgCfm +( +LrgCfgCfm func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkLrgCfgCfm(func, pst, mBuf) +LrgCfgCfm func; +Pst *pst; +Buffer *mBuf; +#endif +{ + RgMngmt cfm; + + TRC3(cmUnpkLrgCfgCfm) + + if (cmUnpkRgMngmt(pst, &cfm, EVTLRGCFGCFM, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG009, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, &cfm)); +} + + +/** +* @brief This API is used to send a +Configuration Confirm from SCH to LM. +* +* @details +* +* Function: cmPkLrgSchCfgCfm +* +* @param[in] Pst * pst +* @param[in] RgMngmt * cfg +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkLrgSchCfgCfm +( +Pst * pst, +RgMngmt * cfg +) +#else +PUBLIC S16 cmPkLrgSchCfgCfm(pst, cfg) +Pst * pst; +RgMngmt * cfg; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkLrgSchCfgCfm) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG010, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector == LRG_SEL_LC) { + if (cmPkRgMngmt(pst, cfg, EVTLRGSCHCFGCFM, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG011, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + + pst->event = (Event) EVTLRGSCHCFGCFM; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief This API is used to send a +Configuration Confirm from SCH to LM. +* +* @details +* +* Function: cmUnpkLrgSchCfgCfm +* +* @param[in] Pst * pst +* @param[in] RgMngmt * cfg +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkLrgSchCfgCfm +( +LrgSchCfgCfm func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkLrgSchCfgCfm(func, pst, mBuf) +LrgSchCfgCfm func; +Pst *pst; +Buffer *mBuf; +#endif +{ + RgMngmt cfg; + + TRC3(cmUnpkLrgSchCfgCfm) + + if (cmUnpkRgMngmt(pst, &cfg, EVTLRGSCHCFGCFM, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG012, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, &cfg)); +} + + +/** +* @brief This API is used to send a +Statistics Request from LM to MAC. +* +* @details +* +* Function: cmPkLrgStsReq +* +* @param[in] Pst * pst +* @param[in] RgMngmt * sts +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkLrgStsReq +( +Pst * pst, +RgMngmt * sts +) +#else +PUBLIC S16 cmPkLrgStsReq(pst, sts) +Pst * pst; +RgMngmt * sts; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkLrgStsReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG013, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector == LRG_SEL_LC) { + if (cmPkRgMngmt(pst, sts, EVTLRGSTSREQ, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG014, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + + pst->event = (Event) EVTLRGSTSREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief This API is used to send a +Statistics Request from LM to MAC. +* +* @details +* +* Function: cmUnpkLrgStsReq +* +* @param[in] Pst * pst +* @param[in] RgMngmt * sts +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkLrgStsReq +( +LrgStsReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkLrgStsReq(func, pst, mBuf) +LrgStsReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + RgMngmt sts; + + TRC3(cmUnpkLrgStsReq) + + if (cmUnpkRgMngmt(pst, &sts, EVTLRGSTSREQ, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG015, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, &sts)); +} + + +/** +* @brief This API is used to send a +Statistics Confirm from MAC to LM. +* +* @details +* +* Function: cmPkLrgStsCfm +* +* @param[in] Pst * pst +* @param[in] RgMngmt * cfm +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkLrgStsCfm +( +Pst * pst, +RgMngmt * cfm +) +#else +PUBLIC S16 cmPkLrgStsCfm(pst, cfm) +Pst * pst; +RgMngmt * cfm; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkLrgStsCfm) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG016, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector == LRG_SEL_LC) { + if (cmPkRgMngmt(pst, cfm, EVTLRGSTSCFM, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG017, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + + pst->event = (Event) EVTLRGSTSCFM; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief This API is used to send a +Statistics Confirm from MAC to LM. +* +* @details +* +* Function: cmUnpkLrgStsCfm +* +* @param[in] Pst * pst +* @param[in] RgMngmt * cfm +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkLrgStsCfm +( +LrgStsCfm func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkLrgStsCfm(func, pst, mBuf) +LrgStsCfm func; +Pst *pst; +Buffer *mBuf; +#endif +{ + RgMngmt cfm; + + TRC3(cmUnpkLrgStsCfm) + + if (cmUnpkRgMngmt(pst, &cfm, EVTLRGSTSCFM, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG018, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, &cfm)); +} + + +/** +* @brief This API is used to send a +Status Request from LM to MAC. +* +* @details +* +* Function: cmPkLrgStaReq +* +* @param[in] Pst * pst +* @param[in] RgMngmt * sta +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkLrgStaReq +( +Pst * pst, +RgMngmt * sta +) +#else +PUBLIC S16 cmPkLrgStaReq(pst, sta) +Pst * pst; +RgMngmt * sta; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkLrgStaReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG019, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (cmPkRgMngmt(pst, sta, EVTLRGSSTAREQ, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG020, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + pst->event = (Event) EVTLRGSSTAREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief This API is used to send a +Status Request from LM to MAC. +* +* @details +* +* Function: cmUnpkLrgStaReq +* +* @param[in] Pst * pst +* @param[in] RgMngmt * sta +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkLrgStaReq +( +LrgStaReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkLrgStaReq(func, pst, mBuf) +LrgStaReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + RgMngmt sta; + + TRC3(cmUnpkLrgStaReq) + + cmMemset((U8 *)&sta, 0, sizeof(RgMngmt)); + if (cmUnpkRgMngmt(pst, &sta, EVTLRGSSTAREQ, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG021, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, &sta)); +} + + +/** +* @brief This API is used to send a +Status Confirm from MAC to LM. +* +* @details +* +* Function: cmPkLrgStaCfm +* +* @param[in] Pst * pst +* @param[in] RgMngmt * cfm +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkLrgStaCfm +( +Pst * pst, +RgMngmt * cfm +) +#else +PUBLIC S16 cmPkLrgStaCfm(pst, cfm) +Pst * pst; +RgMngmt * cfm; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkLrgStaCfm) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG022, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (cmPkRgMngmt(pst, cfm, EVTLRGSSTACFM, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG023, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + pst->event = (Event) EVTLRGSSTACFM; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief This API is used to send a +Status Confirm from MAC to LM. +* +* @details +* +* Function: cmUnpkLrgStaCfm +* +* @param[in] Pst * pst +* @param[in] RgMngmt * cfm +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkLrgStaCfm +( +LrgStaCfm func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkLrgStaCfm(func, pst, mBuf) +LrgStaCfm func; +Pst *pst; +Buffer *mBuf; +#endif +{ + RgMngmt cfm; + + TRC3(cmUnpkLrgStaCfm) + + cmMemset((U8 *)&cfm, 0, sizeof(RgMngmt)); + if (cmUnpkRgMngmt(pst, &cfm, EVTLRGSSTACFM, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG024, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, &cfm)); +} + + +/** +* @brief This API is used to send a +Status Indication from MAC to LM. +* +* @details +* +* Function: cmPkLrgStaInd +* +* @param[in] Pst * pst +* @param[in] RgMngmt * usta +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkLrgStaInd +( +Pst * pst, +RgMngmt * usta +) +#else +PUBLIC S16 cmPkLrgStaInd(pst, usta) +Pst * pst; +RgMngmt * usta; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkLrgStaInd) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG025, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector == LRG_SEL_LC) { + if (cmPkRgMngmt(pst, usta, EVTLRGUSTAIND, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG026, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + + pst->event = (Event) EVTLRGUSTAIND; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief This API is used to send a +Status Indication from MAC to LM. +* +* @details +* +* Function: cmUnpkLrgStaInd +* +* @param[in] Pst * pst +* @param[in] RgMngmt * usta +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkLrgStaInd +( +LrgStaInd func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkLrgStaInd(func, pst, mBuf) +LrgStaInd func; +Pst *pst; +Buffer *mBuf; +#endif +{ + RgMngmt usta; + + TRC3(cmUnpkLrgStaInd) + + if (cmUnpkRgMngmt(pst, &usta, EVTLRGUSTAIND, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG027, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, &usta)); +} + + +/** +* @brief This API is used to send a +Status Indication from SCH to LM. +* +* @details +* +* Function: cmPkLrgSchStaInd +* +* @param[in] Pst * pst +* @param[in] RgMngmt * sta +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkLrgSchStaInd +( +Pst * pst, +RgMngmt * sta +) +#else +PUBLIC S16 cmPkLrgSchStaInd(pst, sta) +Pst * pst; +RgMngmt * sta; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkLrgSchStaInd) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG028, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector == LRG_SEL_LC) { + if (cmPkRgMngmt(pst, sta, EVTLRGSCHSTAIND, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG029, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + + pst->event = (Event) EVTLRGSCHSTAIND; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief This API is used to send a +Status Indication from SCH to LM. +* +* @details +* +* Function: cmUnpkLrgSchStaInd +* +* @param[in] Pst * pst +* @param[in] RgMngmt * sta +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkLrgSchStaInd +( +LrgSchStaInd func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkLrgSchStaInd(func, pst, mBuf) +LrgSchStaInd func; +Pst *pst; +Buffer *mBuf; +#endif +{ + RgMngmt sta; + + TRC3(cmUnpkLrgSchStaInd) + + if (cmUnpkRgMngmt(pst, &sta, EVTLRGSCHSTAIND, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG030, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, &sta)); +} + + +/** +* @brief This API is used to send a +Control Request from LM to MAC. +* +* @details +* +* Function: cmPkLrgCntrlReq +* +* @param[in] Pst * pst +* @param[in] RgMngmt * cntrl +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkLrgCntrlReq +( +Pst * pst, +RgMngmt * cntrl +) +#else +PUBLIC S16 cmPkLrgCntrlReq(pst, cntrl) +Pst * pst; +RgMngmt * cntrl; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkLrgCntrlReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG031, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector == LRG_SEL_LC) { + if (cmPkRgMngmt(pst, cntrl, EVTLRGCNTRLREQ, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG032, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + + pst->event = (Event) EVTLRGCNTRLREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief This API is used to send a +Control Request from LM to MAC. +* +* @details +* +* Function: cmUnpkLrgCntrlReq +* +* @param[in] Pst * pst +* @param[in] RgMngmt * cntrl +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkLrgCntrlReq +( +LrgCntrlReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkLrgCntrlReq(func, pst, mBuf) +LrgCntrlReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + RgMngmt cntrl; + + TRC3(cmUnpkLrgCntrlReq) + + if (cmUnpkRgMngmt(pst, &cntrl, EVTLRGCNTRLREQ, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG033, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, &cntrl)); +} + + +/** +* @brief This API is used to send a +Control Request from LM to SCH. +* +* @details +* +* Function: cmPkLrgSchCntrlReq +* +* @param[in] Pst * pst +* @param[in] RgMngmt * cntrl +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkLrgSchCntrlReq +( +Pst * pst, +RgMngmt * cntrl +) +#else +PUBLIC S16 cmPkLrgSchCntrlReq(pst, cntrl) +Pst * pst; +RgMngmt * cntrl; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkLrgSchCntrlReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG034, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector == LRG_SEL_LC) { + if (cmPkRgMngmt(pst, cntrl, EVTLRGSCHCNTRLREQ, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG035, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + + pst->event = (Event) EVTLRGSCHCNTRLREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief This API is used to send a +Control Request from LM to SCH. +* +* @details +* +* Function: cmUnpkLrgSchCntrlReq +* +* @param[in] Pst * pst +* @param[in] RgMngmt * cntrl +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkLrgSchCntrlReq +( +LrgSchCntrlReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkLrgSchCntrlReq(func, pst, mBuf) +LrgSchCntrlReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + RgMngmt cntrl; + + TRC3(cmUnpkLrgSchCntrlReq) + + if (cmUnpkRgMngmt(pst, &cntrl, EVTLRGSCHCNTRLREQ, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG036, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, &cntrl)); +} + + +/** +* @brief This API is used to send a +Control Confirm from MAC to LM. +* +* @details +* +* Function: cmPkLrgCntrlCfm +* +* @param[in] Pst * pst +* @param[in] RgMngmt * cfm +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkLrgCntrlCfm +( +Pst * pst, +RgMngmt * cfm +) +#else +PUBLIC S16 cmPkLrgCntrlCfm(pst, cfm) +Pst * pst; +RgMngmt * cfm; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkLrgCntrlCfm) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG037, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector == LRG_SEL_LC) { + if (cmPkRgMngmt(pst, cfm, EVTLRGCNTRLCFM, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG038, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + + pst->event = (Event) EVTLRGCNTRLCFM; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief This API is used to send a +Control Confirm from MAC to LM. +* +* @details +* +* Function: cmUnpkLrgCntrlCfm +* +* @param[in] Pst * pst +* @param[in] RgMngmt * cfm +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkLrgCntrlCfm +( +LrgCntrlCfm func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkLrgCntrlCfm(func, pst, mBuf) +LrgCntrlCfm func; +Pst *pst; +Buffer *mBuf; +#endif +{ + RgMngmt cfm; + + TRC3(cmUnpkLrgCntrlCfm) + + if (cmUnpkRgMngmt(pst, &cfm, EVTLRGCNTRLCFM, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG039, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, &cfm)); +} + + +/** +* @brief This API is used to send a +Control Confirm from SCH to LM. +* +* @details +* +* Function: cmPkLrgSchCntrlCfm +* +* @param[in] Pst * pst +* @param[in] RgMngmt * cntrl +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkLrgSchCntrlCfm +( +Pst * pst, +RgMngmt * cntrl +) +#else +PUBLIC S16 cmPkLrgSchCntrlCfm(pst, cntrl) +Pst * pst; +RgMngmt * cntrl; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkLrgSchCntrlCfm) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG040, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector == LRG_SEL_LC) { + if (cmPkRgMngmt(pst, cntrl, EVTLRGSCHCNTRLCFM, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG041, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + + pst->event = (Event) EVTLRGSCHCNTRLCFM; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief This API is used to send a +Control Confirm from SCH to LM. +* +* @details +* +* Function: cmUnpkLrgSchCntrlCfm +* +* @param[in] Pst * pst +* @param[in] RgMngmt * cntrl +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkLrgSchCntrlCfm +( +LrgSchCntrlCfm func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkLrgSchCntrlCfm(func, pst, mBuf) +LrgSchCntrlCfm func; +Pst *pst; +Buffer *mBuf; +#endif +{ + RgMngmt cntrl; + + TRC3(cmUnpkLrgSchCntrlCfm) + + if (cmUnpkRgMngmt(pst, &cntrl, EVTLRGSCHCNTRLCFM, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG042, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, &cntrl)); +} + + +/** +* @brief This API is used to send a +Trace Indication from MAC to LM. +* +* @details +* +* Function: cmPkLrgTrcInd +* +* @param[in] Pst * pst +* @param[in] RgMngmt * trc +* @param[in] Buffer * trcBuf +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkLrgTrcInd +( +Pst * pst, +RgMngmt * trc, +Buffer * trcBuf +) +#else +PUBLIC S16 cmPkLrgTrcInd(pst, trc, trcBuf) +Pst * pst; +RgMngmt * trc; +Buffer * trcBuf; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkLrgTrcInd) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG043, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(trcBuf); + RETVALUE(RFAILED); + } + if (pst->selector == LRG_SEL_LC) { + MsgLen msgLen; + if (SFndLenMsg(trcBuf, &msgLen) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG044, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(trcBuf); + RETVALUE(RFAILED); + } + if (SCatMsg(mBuf, trcBuf, M1M2) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG045, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(trcBuf); + RETVALUE(RFAILED); + } + SPutMsg(trcBuf); + CMCHKPK(cmPkMsgLen, msgLen, mBuf); + } + if (cmPkRgMngmt(pst, trc, EVTLRGTRCIND, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG046, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(trcBuf); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + pst->event = (Event) EVTLRGTRCIND; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief This API is used to send a +Trace Indication from MAC to LM. +* +* @details +* +* Function: cmUnpkLrgTrcInd +* +* @param[in] Pst * pst +* @param[in] RgMngmt * trc +* @param[in] Buffer * trcBuf +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkLrgTrcInd +( +LrgTrcInd func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkLrgTrcInd(func, pst, mBuf) +LrgTrcInd func; +Pst *pst; +Buffer *mBuf; +#endif +{ + RgMngmt trc; + /* lrg_c_001.main_3 - MODIFY - Modified trcBuf to have it initialized to NULLP */ + Buffer *trcBuf = NULLP; + + TRC3(cmUnpkLrgTrcInd) + + if (cmUnpkRgMngmt(pst, &trc, EVTLRGTRCIND, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG047, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector == LRG_SEL_LC) { + MsgLen msgLen, totalMsgLen; + CMCHKUNPK(cmUnpkMsgLen, &msgLen, mBuf); + if (SFndLenMsg(mBuf, &totalMsgLen) != ROK) + RETVALUE(RFAILED); + if (SSegMsg(mBuf, totalMsgLen-msgLen, &trcBuf) != ROK) + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, &trc, trcBuf)); +} + + +/*********************************************************** +* +* Func : cmPkRgGenCfg +* +* +* Desc : This structure holds configuration parameters for MAC General Configuration. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgGenCfg +( +RgGenCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgGenCfg(param, mBuf) +RgGenCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgGenCfg) + +#ifdef LTE_ADV + CMCHKPK(SPkU8, param->isSCellActDeactAlgoEnable, mBuf); + CMCHKPK(SPkU8, param->forceCntrlSrbBoOnPCel, mBuf); +#endif + CMCHKPK(SPkU8, param->startCellId, mBuf); + CMCHKPK(SPkU8, param->numRguSaps, mBuf); + CMCHKPK(SPkU8, param->tmrRes, mBuf); + CMCHKPK(cmPkMemoryId, ¶m->mem, mBuf); + CMCHKPK(cmPkPst, ¶m->lmPst, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgGenCfg +* +* +* Desc : This structure holds configuration parameters for MAC General Configuration. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgGenCfg +( +RgGenCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgGenCfg(param, mBuf) +RgGenCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgGenCfg) + + CMCHKUNPK(cmUnpkPst, ¶m->lmPst, mBuf); + CMCHKUNPK(cmUnpkMemoryId, ¶m->mem, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->tmrRes, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numRguSaps, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->startCellId, mBuf); +#ifdef LTE_ADV + CMCHKUNPK(SUnpkU8, ¶m->forceCntrlSrbBoOnPCel, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->isSCellActDeactAlgoEnable, mBuf); +#endif + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgUpSapCfg +* +* +* Desc : This structure holds configuration parameters for MAC Upper SAP Configuration. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgUpSapCfg +( +RgUpSapCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgUpSapCfg(param, mBuf) +RgUpSapCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgUpSapCfg) + + CMCHKPK(SPkS16, param->suId, mBuf); + CMCHKPK(SPkS16, param->spId, mBuf); + CMCHKPK(SPkU8, param->route, mBuf); + CMCHKPK(SPkU8, param->inst, mBuf); + CMCHKPK(SPkU8, param->ent, mBuf); + CMCHKPK(SPkU16, param->procId, mBuf); + CMCHKPK(SPkU8, param->prior, mBuf); + CMCHKPK(cmPkMemoryId, ¶m->mem, mBuf); + CMCHKPK(SPkU8, param->selector, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgUpSapCfg +* +* +* Desc : This structure holds configuration parameters for MAC Upper SAP Configuration. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgUpSapCfg +( +RgUpSapCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgUpSapCfg(param, mBuf) +RgUpSapCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgUpSapCfg) + + CMCHKUNPK(SUnpkU8, ¶m->selector, mBuf); + CMCHKUNPK(cmUnpkMemoryId, ¶m->mem, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->prior, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->procId, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->ent, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->inst, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->route, mBuf); + CMCHKUNPK(SUnpkS16, ¶m->spId, mBuf); + CMCHKUNPK(SUnpkS16, ¶m->suId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgLowSapCfg +* +* +* Desc : This structure holds configuration parameters for MAC Lower SAP Configuration. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgLowSapCfg +( +RgLowSapCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgLowSapCfg(param, mBuf) +RgLowSapCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgLowSapCfg) + + CMCHKPK(cmPkTmrCfg, ¶m->bndTmr, mBuf); + CMCHKPK(SPkS16, param->suId, mBuf); + CMCHKPK(SPkS16, param->spId, mBuf); + CMCHKPK(SPkU8, param->route, mBuf); + CMCHKPK(SPkU8, param->inst, mBuf); + CMCHKPK(SPkU8, param->ent, mBuf); + CMCHKPK(SPkU16, param->procId, mBuf); + CMCHKPK(SPkU8, param->prior, mBuf); + CMCHKPK(cmPkMemoryId, ¶m->mem, mBuf); + CMCHKPK(SPkU8, param->selector, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgLowSapCfg +* +* +* Desc : This structure holds configuration parameters for MAC Lower SAP Configuration. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgLowSapCfg +( +RgLowSapCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgLowSapCfg(param, mBuf) +RgLowSapCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgLowSapCfg) + + CMCHKUNPK(SUnpkU8, ¶m->selector, mBuf); + CMCHKUNPK(cmUnpkMemoryId, ¶m->mem, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->prior, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->procId, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->ent, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->inst, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->route, mBuf); + CMCHKUNPK(SUnpkS16, ¶m->spId, mBuf); + CMCHKUNPK(SUnpkS16, ¶m->suId, mBuf); + CMCHKUNPK(cmUnpkTmrCfg, ¶m->bndTmr, mBuf); + RETVALUE(ROK); +} + +#ifdef MAC_SCH_STATS + + +/*********************************************************** +* +* Func : cmPkRgAckNack +* +* +* Desc : Ack and Nack statistics +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgAckNack +( +RgAckNack *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgAckNack (param, mBuf) +RgAckNack *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgAckNack) + + CMCHKPK(SPkU16, param->numOfAcks, mBuf); + CMCHKPK(SPkU16, param->numOfNacks, mBuf); + CMCHKPK(SPkU8, param->mcs, mBuf); + + RETVALUE(ROK); +} /* cmPkRgAckNack */ + + +/*********************************************************** +* +* Func : cmPkRgSchNackAckStats +* +* +* Desc : +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgSchNackAckStats +( +RgSchNackAckStats *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgSchNackAckStats (param, mBuf) +RgSchNackAckStats *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkRgSchNackAckStats) + + for (i=14; i >= 0; i--) { + CMCHKPK(cmPkRgAckNack, ¶m->ulCqiStat[i], mBuf); + } + + for (i=14; i >= 0; i--) { + CMCHKPK(cmPkRgAckNack, ¶m->dlCqiStat[i], mBuf); + } + + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func : cmPkRgHqNumRetx +* +* +* Desc : Harq Retransmission statistics +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgHqNumRetx +( +RgSchHqNumRetx *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgHqNumRetx (param, mBuf) +RgSchHqNumRetx *param; +Buffer *mBuf; +#endif +{ + TRC3(cmPkRgHqNumRetx) + + CMCHKPK(SPkU32, param->totalTx, mBuf); + CMCHKPK(SPkU16, param->numOfHQ_4, mBuf); + CMCHKPK(SPkU16, param->numOfHQ_3, mBuf); + CMCHKPK(SPkU16, param->numOfHQ_2, mBuf); + CMCHKPK(SPkU16, param->numOfHQ_1, mBuf); + CMCHKPK(SPkU8, param->mcs, mBuf); + + RETVALUE(ROK); +} /* cmPkRgHqNumRetx */ + + +/*********************************************************** +* +* Func : cmPkRgSchHqRetxStats +* +* +* Desc : +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgSchHqRetxStats +( +RgSchHqRetxStats *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgSchHqRetxStats (param, mBuf) +RgSchHqRetxStats *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkRgSchHqRetxStats) + + for (i=14; i >= 0; i--) { + CMCHKPK(cmPkRgHqNumRetx, ¶m->ulCqiStat[i], mBuf); + } + + for (i=14; i >= 0; i--) { + CMCHKPK(cmPkRgHqNumRetx, ¶m->dlCqiStat[i], mBuf); + } + + RETVALUE(ROK); +} /* cmPkRgSchHqRetxStats */ + +/* unpcaking functions */ + +/*********************************************************** +* +* Func : cmUnpkRgAckNack +* +* +* Desc : Ack and Nack statistics +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgAckNack +( +RgAckNack *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgAckNack (param, mBuf) +RgAckNack *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgAckNack) + + CMCHKUNPK(SUnpkU8, ¶m->mcs, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->numOfNacks, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->numOfAcks, mBuf); + + RETVALUE(ROK); +} /* cmUnkRgAckNack */ + + +/*********************************************************** +* +* Func : cmUnpkRgSchNackAckStats +* +* +* Desc : +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgSchNackAckStats +( +RgSchNackAckStats *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgSchNackAckStats (param, mBuf) +RgSchNackAckStats *param; +Buffer *mBuf; +#endif +{ + S32 i; + TRC3(cmUnpkRgSchNackAckStats) + + for (i=0; i <= 14; i++) { + CMCHKUNPK(cmUnpkRgAckNack, ¶m->dlCqiStat[i], mBuf); + } + + for (i=0; i <= 14; i++) { + CMCHKUNPK(cmUnpkRgAckNack, ¶m->ulCqiStat[i], mBuf); + } + + RETVALUE(ROK); +} /* cmUnpkRgSchNackAckStats */ + + +/*********************************************************** +* +* Func : cmUnpkRgHqNumRetx +* +* +* Desc : Harq Retransmission statistics +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgHqNumRetx +( +RgSchHqNumRetx *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgHqNumRetx (param, mBuf) +RgSchHqNumRetx *param; +Buffer *mBuf; +#endif +{ + TRC3(cmUnpkRgHqNumRetx) + + CMCHKUNPK(SUnpkU8, ¶m->mcs, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->numOfHQ_1, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->numOfHQ_2, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->numOfHQ_3, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->numOfHQ_4, mBuf); + CMCHKUNPK(SUnpkU32, ¶m->totalTx, mBuf); + + RETVALUE(ROK); +} /* cmUnpkRgHqNumRetx */ + + +/*********************************************************** +* +* Func : cmUnpkRgSchHqRetxStats +* +* +* Desc : +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgSchHqRetxStats +( +RgSchHqRetxStats *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgSchHqRetxStats (param, mBuf) +RgSchHqRetxStats *param; +Buffer *mBuf; +#endif +{ + S32 i; + TRC3(cmUnpkRgSchHqRetxStats) + + for (i=0; i <= 14; i++) { + CMCHKUNPK(cmUnpkRgHqNumRetx, ¶m->dlCqiStat[i], mBuf); + } + + for (i=0; i <= 14; i++) { + CMCHKUNPK(cmUnpkRgHqNumRetx, ¶m->ulCqiStat[i], mBuf); + } + + RETVALUE(ROK); +} /* cmUnpkRgSchHqRetxStats */ + +#endif /* MAC_SCH_STATS */ + + +/*********************************************************** +* +* Func : cmPkRgGenSts +* +* +* Desc : This structure holds General Statistical information of MAC. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgGenSts +( +RgGenSts *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgGenSts(param, mBuf) +RgGenSts *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgGenSts) + +#ifdef MAC_SCH_STATS + CMCHKPK(cmPkRgSchHqRetxStats, ¶m->hqRetxStats, mBuf); + CMCHKPK(cmPkRgSchNackAckStats, ¶m->nackAckStats, mBuf); +#endif /* MAC_SCH_STATS */ + CMCHKPK(SPkU16, param->numCellCfg, mBuf); + CMCHKPK(SPkU32, param->numUeCfg, mBuf); + CMCHKPK(SPkU32, param->numHarqFail, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgGenSts +* +* +* Desc : This structure holds General Statistical information of MAC. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgGenSts +( +RgGenSts *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgGenSts(param, mBuf) +RgGenSts *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgGenSts) + + CMCHKUNPK(SUnpkU32, ¶m->numHarqFail, mBuf); + CMCHKUNPK(SUnpkU32, ¶m->numUeCfg, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->numCellCfg, mBuf); +#ifdef MAC_SCH_STATS + CMCHKUNPK(cmUnpkRgSchNackAckStats, ¶m->nackAckStats, mBuf); + CMCHKUNPK(cmUnpkRgSchHqRetxStats, ¶m->hqRetxStats, mBuf); +#endif /* MAC_SCH_STATS */ + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgSapSts +* +* +* Desc : This structure holds Statistical information of a SAP in MAC. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgSapSts +( +RgSapSts *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgSapSts(param, mBuf) +RgSapSts *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgSapSts) + + CMCHKPK(SPkU32, param->numPduDrop, mBuf); + CMCHKPK(SPkU32, param->numPduTxmit, mBuf); + CMCHKPK(SPkU32, param->numPduRcvd, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgSapSts +* +* +* Desc : This structure holds Statistical information of a SAP in MAC. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgSapSts +( +RgSapSts *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgSapSts(param, mBuf) +RgSapSts *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgSapSts) + + CMCHKUNPK(SUnpkU32, ¶m->numPduRcvd, mBuf); + CMCHKUNPK(SUnpkU32, ¶m->numPduTxmit, mBuf); + CMCHKUNPK(SUnpkU32, ¶m->numPduDrop, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgSchInstCfg +* +* +* Desc : Scheduler Configuration +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgSchInstCfg +( +RgSchInstCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgSchInstCfg(param, mBuf) +RgSchInstCfg *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkRgSchInstCfg) + + for (i=param->numSaps-1; i >= 0; i--) { + CMCHKPK(cmPkRgLowSapCfg, ¶m->tfuSap[i], mBuf); + } + for (i=param->numSaps-1; i >= 0; i--) { + CMCHKPK(cmPkRgUpSapCfg, ¶m->rgrSap[i], mBuf); + } + for (i=param->numSaps-1; i >= 0; i--) { + CMCHKPK(cmPkRgUpSapCfg, ¶m->rgmSap[i], mBuf); + } + CMCHKPK(SPkU8, param->numSaps, mBuf); + CMCHKPK(cmPkRgGenCfg, ¶m->genCfg, mBuf); + CMCHKPK(SPkU8, param->instId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgSchInstCfg +* +* +* Desc : Scheduler Configuration +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgSchInstCfg +( +RgSchInstCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgSchInstCfg(param, mBuf) +RgSchInstCfg *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmUnpkRgSchInstCfg) + + CMCHKUNPK(SUnpkU8, ¶m->instId, mBuf); + CMCHKUNPK(cmUnpkRgGenCfg, ¶m->genCfg, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numSaps, mBuf); + for (i=0; inumSaps; i++) { + CMCHKUNPK(cmUnpkRgUpSapCfg, ¶m->rgmSap[i], mBuf); + } + for (i=0; inumSaps; i++) { + CMCHKUNPK(cmUnpkRgUpSapCfg, ¶m->rgrSap[i], mBuf); + } + for (i=0; inumSaps; i++) { + CMCHKUNPK(cmUnpkRgLowSapCfg, ¶m->tfuSap[i], mBuf); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgCfg +* +* +* Desc : This structure holds Configuration parameters for MAC. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgCfg +( +RgCfg *param, +S16 elmnt, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgCfg(param, elmnt, mBuf) +RgCfg *param; +S16 elmnt; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgCfg) + + switch(elmnt) { + case STSCHINST: + CMCHKPK(cmPkRgSchInstCfg, ¶m->s.schInstCfg, mBuf); + break; + case STTFUSAP: + CMCHKPK(cmPkRgLowSapCfg, ¶m->s.tfuSap, mBuf); + break; + case STCRGSAP: + CMCHKPK(cmPkRgUpSapCfg, ¶m->s.crgSap, mBuf); + break; + case STRGUSAP: + CMCHKPK(cmPkRgUpSapCfg, ¶m->s.rguSap, mBuf); + break; + case STGEN: + CMCHKPK(cmPkRgGenCfg, ¶m->s.genCfg, mBuf); + break; + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgCfg +* +* +* Desc : This structure holds Configuration parameters for MAC. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgCfg +( +RgCfg *param, +S16 elmnt, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgCfg(param, elmnt, mBuf) +RgCfg *param; +S16 elmnt; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgCfg) + + switch(elmnt) { + case STGEN: + CMCHKUNPK(cmUnpkRgGenCfg, ¶m->s.genCfg, mBuf); + break; + case STRGUSAP: + CMCHKUNPK(cmUnpkRgUpSapCfg, ¶m->s.rguSap, mBuf); + break; + case STCRGSAP: + CMCHKUNPK(cmUnpkRgUpSapCfg, ¶m->s.crgSap, mBuf); + break; + case STTFUSAP: + CMCHKUNPK(cmUnpkRgLowSapCfg, ¶m->s.tfuSap, mBuf); + break; + case STSCHINST: + CMCHKUNPK(cmUnpkRgSchInstCfg, ¶m->s.schInstCfg, mBuf); + break; + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgSapSta +* +* +* Desc : This structure holds a SAP's status information. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgSapSta +( +RgSapSta *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgSapSta(param, mBuf) +RgSapSta *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgSapSta) + + CMCHKPK(SPkU8, param->sapState, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgSapSta +* +* +* Desc : This structure holds a SAP's status information. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgSapSta +( +RgSapSta *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgSapSta(param, mBuf) +RgSapSta *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgSapSta) + + CMCHKUNPK(SUnpkU8, ¶m->sapState, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgSts +* +* +* Desc : This structure holds MAC's Statistical information. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgSts +( +RgSts *param, +S16 elmnt, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgSts(param, elmnt, mBuf) +RgSts *param; +S16 elmnt; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgSts) + + switch(elmnt) { + case STTFUSAP: + CMCHKPK(cmPkRgSapSts, ¶m->s.tfuSts, mBuf); + break; + case STRGRSAP: + CMCHKPK(cmPkRgSapSts, ¶m->s.rgrSts, mBuf); + break; + case STCRGSAP: + CMCHKPK(cmPkRgSapSts, ¶m->s.crgSts, mBuf); + break; + case STRGUSAP: + CMCHKPK(cmPkRgSapSts, ¶m->s.rguSts, mBuf); + break; + case STGEN: + CMCHKPK(cmPkRgGenSts, ¶m->s.genSts, mBuf); + break; + default : + break; + } + CMCHKPK(cmPkAction, param->action, mBuf); + CMCHKPK(SPkU8, param->sapInst, mBuf); + CMCHKPK(cmPkDateTime, ¶m->dt, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgSts +* +* +* Desc : This structure holds MAC's Statistical information. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgSts +( +RgSts *param, +S16 elmnt, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgSts(param, elmnt, mBuf) +RgSts *param; +S16 elmnt; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgSts) + + CMCHKUNPK(cmUnpkDateTime, ¶m->dt, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->sapInst, mBuf); + CMCHKUNPK(cmUnpkAction, ¶m->action, mBuf); + switch(elmnt) { + case STGEN: + CMCHKUNPK(cmUnpkRgGenSts, ¶m->s.genSts, mBuf); + break; + case STRGUSAP: + CMCHKUNPK(cmUnpkRgSapSts, ¶m->s.rguSts, mBuf); + break; + case STCRGSAP: + CMCHKUNPK(cmUnpkRgSapSts, ¶m->s.crgSts, mBuf); + break; + case STRGRSAP: + CMCHKUNPK(cmUnpkRgSapSts, ¶m->s.rgrSts, mBuf); + break; + case STTFUSAP: + CMCHKUNPK(cmUnpkRgSapSts, ¶m->s.tfuSts, mBuf); + break; + default : + break; + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgSsta +* +* +* Desc : This structure holds MAC's Solicited Status information. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgSsta +( +Pst *pst, +RgSsta *param, +S16 elmnt, +#ifdef LRG_V1 +U8 eventType, +#endif +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgSsta(pst, param, elmnt, eventType, mBuf) +Pst *pst; +RgSsta *param; +S16 elmnt; +/* lrg_c_001.main_3 - ADD - Added the extra parameter eventType to the function */ +#ifdef LRG_V1 +U8 eventType; +#endif +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgSsta) + + switch(elmnt) { + case STTFUSAP: + CMCHKPK(cmPkRgSapSta, ¶m->s.tfuSapSta, mBuf); + break; + case STRGRSAP: + CMCHKPK(cmPkRgSapSta, ¶m->s.rgrSapSta, mBuf); + break; + case STCRGSAP: + CMCHKPK(cmPkRgSapSta, ¶m->s.crgSapSta, mBuf); + break; + case STRGUSAP: + CMCHKPK(cmPkRgSapSta, ¶m->s.rguSapSta, mBuf); + break; + /*ccpu00118255 - ADD - Check for eventType before Pack */ + case STGEN: +#ifdef LRG_V1 + if (eventType == EVTLRGSSTACFM) + { + CMCHKPK(cmPkSystemId, ¶m->s.sysId, mBuf); + if (param->s.sysId.ptNmb != NULLP) + { + SPutSBuf(pst->region, pst->pool, + (Data *)param->s.sysId.ptNmb, LRG_MAX_PT_NUM_SIZE); + } + } +#else /*LRG_V1 not defined */ + if (param->s.sysId.ptNmb != NULLP) + { + CMCHKPK(cmPkSystemId, ¶m->s.sysId, mBuf); + SPutSBuf(pst->region, pst->pool, (Data *)param->s.sysId.ptNmb, LRG_MAX_PT_NUM_SIZE); + } + +#endif /*end of LRG_V1 */ + break; + default : + break; + } + CMCHKPK(SPkU8, param->sapInst, mBuf); + CMCHKPK(cmPkDateTime, ¶m->dt, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgSsta +* +* +* Desc : This structure holds MAC's Solicited Status information. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgSsta +( +Pst *pst, +RgSsta *param, +S16 elmnt, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgSsta(pst, param, elmnt, mBuf) +Pst *pst; +RgSsta *param; +S16 elmnt; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgSsta) + + CMCHKUNPK(cmUnpkDateTime, ¶m->dt, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->sapInst, mBuf); + switch(elmnt) { + case STGEN: + /*ccpu00118255 - ADD - Check for eventType before Unpack */ + if (pst->event == EVTLRGSSTACFM) + { + /* After Merging */ + if((SGetSBuf(pst->region, pst->pool, (Data **)¶m->s.sysId.ptNmb, + LRG_MAX_PT_NUM_SIZE)) != ROK){ +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG048, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + /* KWORK_FIX: Moved the memset under the NULL check */ + if (param->s.sysId.ptNmb != NULLP) + { + cmMemset((U8 *)param->s.sysId.ptNmb, 0, LRG_MAX_PT_NUM_SIZE); + CMCHKUNPK(cmUnpkSystemId, ¶m->s.sysId, mBuf); + } + } + break; + case STRGUSAP: + CMCHKUNPK(cmUnpkRgSapSta, ¶m->s.rguSapSta, mBuf); + break; + case STCRGSAP: + CMCHKUNPK(cmUnpkRgSapSta, ¶m->s.crgSapSta, mBuf); + break; + case STRGRSAP: + CMCHKUNPK(cmUnpkRgSapSta, ¶m->s.rgrSapSta, mBuf); + break; + case STTFUSAP: + CMCHKUNPK(cmUnpkRgSapSta, ¶m->s.tfuSapSta, mBuf); + break; + default : + break; + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgUstaDgn +* +* +* Desc : Alarm diagnostics structure. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgUstaDgn +( +RgUstaDgn *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgUstaDgn(param, mBuf) +RgUstaDgn *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgUstaDgn) + + switch(param->type) { + case LRG_USTA_DGNVAL_MEM: + CMCHKPK(cmPkMemoryId, ¶m->u.mem, mBuf); + break; + default : + break; + } + CMCHKPK(SPkU8, param->type, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgUstaDgn +* +* +* Desc : Alarm diagnostics structure. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgUstaDgn +( +RgUstaDgn *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgUstaDgn(param, mBuf) +RgUstaDgn *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgUstaDgn) + + CMCHKUNPK(SUnpkU8, ¶m->type, mBuf); + switch(param->type) { + case LRG_USTA_DGNVAL_MEM: + CMCHKUNPK(cmUnpkMemoryId, ¶m->u.mem, mBuf); + break; + default : + break; + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgUsta +* +* +* Desc : This structure holds MAC's Unsolicited Status information. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgUsta +( +RgUsta *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgUsta(param, mBuf) +RgUsta *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgUsta) + + CMCHKPK(cmPkRgUstaDgn, ¶m->dgn, mBuf); + CMCHKPK(cmPkCmAlarm, ¶m->cmAlarm, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgUsta +* +* +* Desc : This structure holds MAC's Unsolicited Status information. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgUsta +( +RgUsta *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgUsta(param, mBuf) +RgUsta *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgUsta) + + CMCHKUNPK(cmUnpkCmAlarm, ¶m->cmAlarm, mBuf); + CMCHKUNPK(cmUnpkRgUstaDgn, ¶m->dgn, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgTrc +* +* +* Desc : This structure holds MAC's Trace Indication information. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgTrc +( +RgTrc *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgTrc(param, mBuf) +RgTrc *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgTrc) + + CMCHKPK(SPkU8, param->evnt, mBuf); + CMCHKPK(cmPkDateTime, ¶m->dt, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgTrc +* +* +* Desc : This structure holds MAC's Trace Indication information. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgTrc +( +RgTrc *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgTrc(param, mBuf) +RgTrc *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgTrc) + + CMCHKUNPK(cmUnpkDateTime, ¶m->dt, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->evnt, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgDbgCntrl +* +* +* Desc : This structure holds MAC's Debug Control information. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgDbgCntrl +( +RgDbgCntrl *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgDbgCntrl(param, mBuf) +RgDbgCntrl *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgDbgCntrl) + + CMCHKPK(SPkU32, param->dbgMask, mBuf); + RETVALUE(ROK); +} + +#ifdef PHY_ERROR_LOGING +/*********************************************************** +* +* Func : cmPkRgSchUlAllocCntrl +* +* +* Desc : This structure holds MAC's Debug Control information. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgSchUlAllocCntrl +( +RgSchUlAllocCntrl *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgSchUlAllocCntrl(param, mBuf) +RgSchUlAllocCntrl *param; +Buffer *mBuf; +#endif +{ + TRC3(cmPkRgSchUlAllocCntrl) + + CMCHKPK(SPkU8, param->mcs, mBuf); + CMCHKPK(SPkU16, param->numOfRb, mBuf); + CMCHKPK(SPkU16, param->rbStart, mBuf); + CMCHKPK(SPkU8, param->testStart, mBuf); + CMCHKPK(SPkU8, param->enaLog, mBuf); + CMCHKPK(SPkU16, param->logTime, mBuf); + + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func : cmUnpkRgSchUlAllocCntrl +* +* +* Desc : This structure holds MAC's Scheduler Configuration for Ul Allocation. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgSchUlAllocCntrl +( +RgSchUlAllocCntrl *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgSchUlAllocCntrl(param, mBuf) +RgSchUlAllocCntrl *param; +Buffer *mBuf; +#endif +{ + TRC3(cmUnpkRgSchUlAllocCntrl) + + CMCHKUNPK(SUnpkU16, ¶m->logTime, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->enaLog, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->testStart, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->rbStart, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->numOfRb, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->mcs, mBuf); + + RETVALUE(ROK); +} + + +#endif + +/*********************************************************** +* +* Func : cmUnpkRgDbgCntrl +* +* +* Desc : This structure holds MAC's Debug Control information. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgDbgCntrl +( +RgDbgCntrl *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgDbgCntrl(param, mBuf) +RgDbgCntrl *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgDbgCntrl) + + CMCHKUNPK(SUnpkU32, ¶m->dbgMask, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgSapCntrl +* +* +* Desc : This structure holds MAC's SAP Control information. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgSapCntrl +( +RgSapCntrl *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgSapCntrl(param, mBuf) +RgSapCntrl *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgSapCntrl) + + CMCHKPK(SPkS16, param->spId, mBuf); + CMCHKPK(SPkS16, param->suId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgSapCntrl +* +* +* Desc : This structure holds MAC's SAP Control information. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgSapCntrl +( +RgSapCntrl *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgSapCntrl(param, mBuf) +RgSapCntrl *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgSapCntrl) + + CMCHKUNPK(SUnpkS16, ¶m->suId, mBuf); + CMCHKUNPK(SUnpkS16, ¶m->spId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgCntrl +* +* +* Desc : This structure holds MAC's Control information. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgCntrl +( +RgCntrl *param, +S16 elmnt, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgCntrl(param, elmnt, mBuf) +RgCntrl *param; +S16 elmnt; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgCntrl) + + switch(elmnt) { + case STTFUSAP: + case STRGUSAP: + case STRGRSAP: + case STCRGSAP: + switch(param->subAction) { + default : + CMCHKPK(cmPkRgSapCntrl, ¶m->s.rgSapCntrl, mBuf); + break; + } + break; + case STGEN: + switch(param->subAction) { + case SATRC: + CMCHKPK(SPkS16, param->s.trcLen, mBuf); + break; + case SADBG: + CMCHKPK(cmPkRgDbgCntrl, ¶m->s.rgDbgCntrl, mBuf); + break; + case SAUSTA: + break; +#ifdef SS_DIAG + case SALOG: + CMCHKPK(SPkU32, param->s.logMask, mBuf); + break; +#endif +#ifdef PHY_ERROR_LOGING + case SAELMNT: + CMCHKPK(cmPkRgSchUlAllocCntrl, ¶m->s.rgSchUlAllocCntrl, mBuf); + break; +#endif + default : + break; + } + break; + default : + break; + } + CMCHKPK(SPkU8, param->subAction, mBuf); + CMCHKPK(SPkU8, param->action, mBuf); + CMCHKPK(cmPkDateTime, ¶m->dt, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgCntrl +* +* +* Desc : This structure holds MAC's Control information. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgCntrl +( +RgCntrl *param, +S16 elmnt, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgCntrl(param, elmnt, mBuf) +RgCntrl *param; +S16 elmnt; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgCntrl) + + CMCHKUNPK(cmUnpkDateTime, ¶m->dt, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->action, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->subAction, mBuf); + switch(elmnt) { + case STGEN: + switch(param->subAction) { + case SADBG: + CMCHKUNPK(cmUnpkRgDbgCntrl, ¶m->s.rgDbgCntrl, mBuf); + break; + case SATRC: + CMCHKUNPK(SUnpkS16, ¶m->s.trcLen, mBuf); + break; + case SAUSTA: + break; +#ifdef SS_DIAG + case SALOG: + CMCHKUNPK(SUnpkU32, ¶m->s.logMask, mBuf); + break; +#endif +#ifdef PHY_ERROR_LOGING + case SAELMNT: + CMCHKUNPK(cmUnpkRgSchUlAllocCntrl, ¶m->s.rgSchUlAllocCntrl, mBuf); + break; +#endif + default : + break; + } + break; + case STTFUSAP: + case STRGUSAP: + case STRGRSAP: + case STCRGSAP: + switch(param->subAction) { + default : + CMCHKUNPK(cmUnpkRgSapCntrl, ¶m->s.rgSapCntrl, mBuf); + break; + } + break; + default : + break; + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgMngmt +* +* +* Desc : This structure holds MAC's Configuration and Control Management Information. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgMngmt +( +Pst *pst, +RgMngmt *param, +U8 eventType, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgMngmt(pst, param, eventType, mBuf) +Pst *pst; +RgMngmt *param; +U8 eventType; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgMngmt) + + switch(eventType) { + case EVTLRGCNTRLREQ: + case EVTLRGCNTRLCFM: + case EVTLRGSCHCNTRLREQ: + case EVTLRGSCHCNTRLCFM: + if(cmPkRgCntrl(¶m->t.cntrl, param->hdr.elmId.elmnt, mBuf) != ROK) + RETVALUE(RFAILED); + break; + case EVTLRGTRCIND: + CMCHKPK(cmPkRgTrc, ¶m->t.trc, mBuf); + break; + case EVTLRGUSTAIND: + case EVTLRGSCHSTAIND: + CMCHKPK(cmPkRgUsta, ¶m->t.usta, mBuf); + break; + case EVTLRGSSTAREQ: + case EVTLRGSSTACFM: + /*ccpu00118255 - ADD - eventType param */ +#ifdef LRG_V1 + if(cmPkRgSsta(pst, ¶m->t.ssta, param->hdr.elmId.elmnt, + eventType, mBuf) != ROK) + RETVALUE(RFAILED); +#else /* LRG_V1 is not defined */ + if(cmPkRgSsta(pst, ¶m->t.ssta, param->hdr.elmId.elmnt, mBuf) != ROK) + RETVALUE(RFAILED); +#endif /* end of LRG_V1*/ + break; + case EVTLRGSTSREQ: + case EVTLRGSTSCFM: + if(cmPkRgSts(¶m->t.sts, param->hdr.elmId.elmnt, mBuf)!= ROK) + RETVALUE(RFAILED); + break; + case EVTLRGCFGREQ: + case EVTLRGCFGCFM: + if(cmPkRgCfg(¶m->t.cfg, param->hdr.elmId.elmnt, mBuf) != ROK) + RETVALUE(RFAILED); + break; + case EVTLRGSCHCFGREQ: + case EVTLRGSCHCFGCFM: + if(cmPkRgCfg(¶m->t.cfg, param->hdr.elmId.elmnt, mBuf) != ROK) + RETVALUE(RFAILED); + break; + default : + RETVALUE(RFAILED); + } + CMCHKPK(cmPkCmStatus, ¶m->cfm, mBuf); + CMCHKPK(cmPkHeader, ¶m->hdr, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgMngmt +* +* +* Desc : This structure holds MAC's Configuration and Control Management Information. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgMngmt +( +Pst *pst, +RgMngmt *param, +U8 eventType, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgMngmt(pst, param, eventType, mBuf) +Pst *pst; +RgMngmt *param; +U8 eventType; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgMngmt) + + CMCHKUNPK(cmUnpkHeader, ¶m->hdr, mBuf); + CMCHKUNPK(cmUnpkCmStatus, ¶m->cfm, mBuf); + switch(eventType) { + case EVTLRGCFGREQ: + case EVTLRGCFGCFM: + case EVTLRGSCHCFGREQ: + case EVTLRGSCHCFGCFM: + if(cmUnpkRgCfg(¶m->t.cfg, param->hdr.elmId.elmnt, mBuf) != ROK) + RETVALUE(RFAILED); + break; + case EVTLRGSTSREQ: + case EVTLRGSTSCFM: + if(cmUnpkRgSts(¶m->t.sts, param->hdr.elmId.elmnt, mBuf) != ROK) + RETVALUE(RFAILED); + break; + case EVTLRGSSTAREQ: + case EVTLRGSSTACFM: + if(cmUnpkRgSsta(pst, ¶m->t.ssta, param->hdr.elmId.elmnt, mBuf) != ROK) + RETVALUE(RFAILED); + break; + case EVTLRGUSTAIND: + case EVTLRGSCHSTAIND: + CMCHKUNPK(cmUnpkRgUsta, ¶m->t.usta, mBuf); + break; + case EVTLRGTRCIND: + CMCHKUNPK(cmUnpkRgTrc, ¶m->t.trc, mBuf); + break; + case EVTLRGCNTRLREQ: + case EVTLRGCNTRLCFM: + case EVTLRGSCHCNTRLREQ: + case EVTLRGSCHCNTRLCFM: + if(cmUnpkRgCntrl(¶m->t.cntrl, param->hdr.elmId.elmnt, mBuf) != ROK) + RETVALUE(RFAILED); + break; + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + +/* lrg_c_001.main_3 - ADD - Added the functions pertaining to LTE_L2_MEAS */ +#ifdef LTE_L2_MEAS + +/** +* @brief This API is used to pack + LrgNmbActvUeQCI elements +* +* @details +* +* Function: cmPkNmbActvUeQciReq +* +* @param[in] LrgNmbActvUeQCI +* @param[in] Buffer *mBuf +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PRIVATE S16 cmPkNmbActvUeQciReq +( +LrgNmbActvUeQCI *nmbActvUeQci, +Buffer *mBuf +) +#else +PRIVATE S16 cmPkNmbActvUeQciReq(nmbActvUeQci, mBuf) +LrgNmbActvUeQCI *nmbActvUeQci; +Buffer *mBuf; +#endif +{ + U8 idx; + + TRC3(cmPkNmbActvUeQciReq) + + for(idx = 0; idx < nmbActvUeQci->numQci; idx++) + { + CMCHKPK(SPkU8, nmbActvUeQci->qci[idx], mBuf); + } + CMCHKPK(SPkU8, nmbActvUeQci->numQci, mBuf); + CMCHKPK(SPkU8, nmbActvUeQci->sampPrd, mBuf); + RETVALUE(ROK); +} + +/** +* @brief This API is used to pack + LrgAvgPrbQci elements +* +* @details +* +* Function: cmPkAvgPrbQciReq +* +* @param[in] LrgNmbActvUeQciReq *avgPrbQciReq +* @param[in] Buffer *mBuf +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PRIVATE S16 cmPkAvgPrbQciReq +( +LrgAvgPrbQCI *avgPrbQciReq, +Buffer *mBuf +) +#else +PRIVATE S16 cmPkAvgPrbQciReq(avgPrbQciReq, mBuf) +LrgAvgPrbQCI *avgPrbQciReq; +Buffer *mBuf; +#endif +{ + U8 idx; + + TRC3(cmPkAvgPrbQciReq) + + for(idx = 0; idx < avgPrbQciReq->numQci; idx++) + { + CMCHKPK(SPkU8, avgPrbQciReq->qci[idx], mBuf); + } + CMCHKPK(SPkU8, avgPrbQciReq->numQci, mBuf); + RETVALUE(ROK); + +} + +/** +* @brief This API is used to send a +L2 Measurement Request from LM to MAC. +* +* @details +* +* Function: cmPkLrgSchL2MeasReq +* +* @param[in] Pst * pst +* @param[in] LrgSchMeasReqInfo * measInfo +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkLrgSchL2MeasReq +( +Pst * pst, +LrgSchMeasReqInfo *measInfo +) +#else +PUBLIC S16 cmPkLrgSchL2MeasReq(pst, measInfo) +Pst * pst; +LrgSchMeasReqInfo *measInfo; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkLrgSchL2MeasReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG049, (ErrVal)0, "SGetMsg failed"); +#endif + RETVALUE(RFAILED); + } + if(measInfo->measType & LRG_L2MEAS_NMB_ACTV_UE_PER_QCI_DL) + { + CMCHKPK(cmPkNmbActvUeQciReq, &measInfo->nmbActvUeQciDl, mBuf); + } + if(measInfo->measType & LRG_L2MEAS_NMB_ACTV_UE_PER_QCI_UL) + { + CMCHKPK(cmPkNmbActvUeQciReq, &measInfo->nmbActvUeQciUl, mBuf); + } + if(measInfo->measType & LRG_L2MEAS_AVG_PRB_PER_QCI_DL) + { + CMCHKPK(cmPkAvgPrbQciReq, &measInfo->avgPrbQciDl, mBuf); + } + if(measInfo->measType & LRG_L2MEAS_AVG_PRB_PER_QCI_UL) + { + CMCHKPK(cmPkAvgPrbQciReq, &measInfo->avgPrbQciUl, mBuf); + } + + CMCHKPK(cmPkLteCellId, measInfo->cellId, mBuf); + CMCHKPK(SPkU32, measInfo->timePrd, mBuf); + CMCHKPK(SPkU16, measInfo->measType, mBuf); + CMCHKPK(cmPkHeader, &measInfo->hdr, mBuf); + pst->event = (Event) EVTLRGSCHL2MEASREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} +/** +* @brief This API is used to stop a +L2 Measurement Request from LM to MAC. +* +* @details +* +* Function: cmPkLrgSchL2MeasStopReq +* +* @param[in] Pst * pst +* @param[in] LrgSchMeasReqInfo * measInfo +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkLrgSchL2MeasStopReq +( +Pst * pst, +LrgSchMeasStopReqInfo *measInfo +) +#else +PUBLIC S16 cmPkLrgSchL2MeasStopReq(pst, measInfo) +Pst * pst; +LrgSchMeasStopReqInfo *measInfo; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkLrgSchL2MeasStopReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG049, (ErrVal)0, "SGetMsg failed"); +#endif + RETVALUE(RFAILED); + } + CMCHKPK(cmPkLteCellId, measInfo->cellId, mBuf); + /*CMCHKPK(SPkU16, measInfo->timePrd, mBuf);*/ + CMCHKPK(SPkU16, measInfo->measType, mBuf); + CMCHKPK(cmPkHeader, &measInfo->hdr, mBuf); + pst->event = (Event) EVTLRGSCHL2MEASSTOPREQ; + RETVALUE(SPstTsk(pst,mBuf)); +}/*cmPkLrgSchL2MeasStopReq*/ + +/** +* @brief This API is used to send a +L2 Measurement Request from LM to MAC. +* +* @details +* +* Function: cmPkLrgSchL2MeasSendReq +* +* @param[in] Pst * pst +* @param[in] LrgSchMeasReqInfo * measInfo +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkLrgSchL2MeasSendReq +( +Pst * pst, +LrgSchMeasSndReqInfo *measInfo +) +#else +PUBLIC S16 cmPkLrgSchL2MeasSendReq(pst, measInfo) +Pst * pst; +LrgSchMeasSndReqInfo *measInfo; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkLrgSchL2MeasSendReq) + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG049, (ErrVal)0, "SGetMsg failed"); +#endif + RETVALUE(RFAILED); + } + CMCHKPK(cmPkLteCellId, measInfo->cellId, mBuf); + CMCHKPK(SPkU32, measInfo->timePrd, mBuf); + CMCHKPK(SPkU16, measInfo->measType, mBuf); + CMCHKPK(cmPkHeader, &measInfo->hdr, mBuf); + pst->event = (Event) EVTLRGSCHL2MEASSENDREQ; + RETVALUE(SPstTsk(pst,mBuf)); +}/*cmPkLrgSchL2MeasSendReq*/ + +/** +* @brief This API is used to unpack AvgPrbQciReq +* +* @details +* +* Function: cmUnpkNmbActvUeQciReq +* +* @param[in] LrgNmbActvUeQCI *param +* @param[in] Buffer * mBuf +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PRIVATE S16 cmUnpkNmbActvUeQciReq +( +LrgNmbActvUeQCI *param, +Buffer *mBuf +) +#else +PRIVATE S16 cmUnpkNmbActvUeQciReq(param, mBuf) +LrgNmbActvUeQCI *param; +Buffer *mBuf; +#endif +{ + U8 idx; + + TRC3(cmUnpkNmbActvUeQciReq) + + CMCHKUNPK(SUnpkU8, ¶m->sampPrd, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numQci, mBuf); + for(idx = param->numQci; idx > 0; idx--) + { + CMCHKUNPK(SUnpkU8, ¶m->qci[idx - 1], mBuf); + } + + RETVALUE(ROK); +} + +/** +* @brief This API is used to unpack AvgPrbQciReq +* +* @details +* +* Function: cmUnpkAvgPrbQciReq +* +* @param[in] LrgAvgPrbQCI *param +* @param[in] Buffer * mBuf +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PRIVATE S16 cmUnpkAvgPrbQciReq +( +LrgAvgPrbQCI *param, +Buffer *mBuf +) +#else +PRIVATE S16 cmUnpkAvgPrbQciReq (param, mBuf) +LrgAvgPrbQCI *param; +Buffer *mBuf; +#endif +{ + U8 idx; + + TRC3(cmUnpkAvgPrbQciReq) + + CMCHKUNPK(SUnpkU8, ¶m->numQci, mBuf); + for(idx = param->numQci; idx > 0; idx--) + { + CMCHKUNPK(SUnpkU8, ¶m->qci[idx - 1], mBuf); + } + RETVALUE(ROK); + +} + +/** +* @brief This API is used to send a +Measurement Request from LM to SCH. +* +* @details +* +* Function: cmUnpkLrgSchL2MeasReq +* +* @param[in] LrgSchMeasReq func +* @param[in] Pst * pst +* @param[in] Buffer * mBuf +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkLrgSchL2MeasReq +( +LrgSchL2MeasReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkLrgSchL2MeasReq(func, pst, mBuf) +LrgSchL2MeasReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + LrgSchMeasReqInfo measInfo; + + TRC3(cmUnpkLrgSchL2MeasReq) + + CMCHKUNPK(cmUnpkHeader, &measInfo.hdr, mBuf); + CMCHKUNPK(SUnpkU16, &measInfo.measType, mBuf); + CMCHKUNPK(SUnpkU32, &measInfo.timePrd, mBuf); + CMCHKUNPK(cmUnpkLteCellId, &measInfo.cellId, mBuf); + if(measInfo.measType & LRG_L2MEAS_AVG_PRB_PER_QCI_UL) + { + CMCHKUNPK(cmUnpkAvgPrbQciReq, &measInfo.avgPrbQciUl, mBuf); + } + if(measInfo.measType & LRG_L2MEAS_AVG_PRB_PER_QCI_DL) + { + CMCHKUNPK(cmUnpkAvgPrbQciReq, &measInfo.avgPrbQciDl, mBuf); + } + if(measInfo.measType & LRG_L2MEAS_NMB_ACTV_UE_PER_QCI_UL) + { + CMCHKUNPK(cmUnpkNmbActvUeQciReq, &measInfo.nmbActvUeQciUl, mBuf); + } + if(measInfo.measType & LRG_L2MEAS_NMB_ACTV_UE_PER_QCI_DL) + { + CMCHKUNPK(cmUnpkNmbActvUeQciReq, &measInfo.nmbActvUeQciDl, mBuf); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, &measInfo)); +} + +/** +* @brief This API is used to stop a +Measurement Request from LM to SCH. +* +* @details +* +* Function: cmUnpkLrgSchL2MeasStopReq +* +* @param[in] LrgSchMeasStopReq func +* @param[in] Pst * pst +* @param[in] Buffer * mBuf +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkLrgSchL2MeasStopReq +( +LrgSchL2MeasStopReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkLrgSchL2MeasStopReq(func, pst, mBuf) +LrgSchL2MeasStopReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + LrgSchMeasStopReqInfo measInfo; + + TRC3(cmUnpkLrgSchL2MeasStopReq) + + CMCHKUNPK(cmUnpkHeader, &measInfo.hdr, mBuf); + CMCHKUNPK(SUnpkU16, &measInfo.measType, mBuf); + /*CMCHKUNPK(SUnpkU16, &measInfo.timePrd, mBuf);*/ + CMCHKUNPK(cmUnpkLteCellId, &measInfo.cellId, mBuf); + SPutMsg(mBuf); + RETVALUE((*func)(pst, &measInfo)); +}/*cmUnpkLrgSchL2MeasStopReq*/ + +/** +* @brief This API is used to send a +Measurement Request from LM to SCH. +* +* @details +* +* Function: cmUnpkLrgSchL2MeasSendReq +* +* @param[in] LrgSchMeasSendReq func +* @param[in] Pst * pst +* @param[in] Buffer * mBuf +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkLrgSchL2MeasSendReq +( +LrgSchL2MeasSendReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkLrgSchL2MeasSendReq(func, pst, mBuf) +LrgSchL2MeasSendReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + LrgSchMeasSndReqInfo measInfo; + CMCHKUNPK(cmUnpkHeader, &measInfo.hdr, mBuf); + CMCHKUNPK(SUnpkU16, &measInfo.measType, mBuf); + CMCHKUNPK(SUnpkU32, &measInfo.timePrd, mBuf); + CMCHKUNPK(cmUnpkLteCellId, &measInfo.cellId, mBuf); + SPutMsg(mBuf); + RETVALUE((*func)(pst, &measInfo)); +}/*cmUnpkLrgSchL2MeasSendReq*/ + +/** +* @brief This API is used to stop a +L2 Measurement confirm from MAC to LM +* +* @details +* +* Function: cmPkLrgSchL2MeasStopCfm +* +* @param[in] Pst * pst +* @param[in] LrgSchMeasCfmInfo * measInfo +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkLrgSchL2MeasStopCfm +( +Pst * pst, +LrgSchMeasCfmInfo *measInfo +) +#else +PUBLIC S16 cmPkLrgSchL2MeasStopCfm(pst, measInfo) +Pst * pst; +LrgSchMeasCfmInfo *measInfo; +#endif +{ + Buffer *mBuf = NULLP; + + TRC3(cmPkLrgSchL2MeasStopCfm) + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG050, (ErrVal)0, "SGetMsg failed"); +#endif + RETVALUE(RFAILED); + } + CMCHKPK(cmPkLteCellId, measInfo->cellId, mBuf); + CMCHKPK(cmPkCmStatus, &measInfo->cfm, mBuf); + CMCHKPK(SPkU16, measInfo->measType, mBuf); + CMCHKPK(cmPkHeader, &measInfo->hdr, mBuf); + pst->event = (Event) EVTLRGSCHL2MEASSTOPCFM; + RETVALUE(SPstTsk(pst,mBuf)); +}/*cmPkLrgSchL2MeasStopCfm*/ +/** +* @brief This API is used to Send a +Measurement Confirm from SCH to LM. +* +* @details +* +* Function: cmUnpkLrgL2SchMeasCfm +* +* @param[in] Pst * pst +* @param[in] Buffer * mBuf +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkLrgSchL2MeasStopCfm +( +LrgSchL2MeasStopCfm func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkLrgSchL2MeasStopCfm(func, pst, mBuf) +LrgSchL2MeasStopCfm func; +Pst *pst; +Buffer *mBuf; +#endif +{ + LrgSchMeasCfmInfo measInfo; + + TRC3(cmUnpkLrgSchL2MeasCfm) + + CMCHKUNPK(cmUnpkHeader, &measInfo.hdr, mBuf); + CMCHKUNPK(SUnpkU16, &measInfo.measType, mBuf); + CMCHKUNPK(cmUnpkCmStatus, &measInfo.cfm, mBuf); + CMCHKUNPK(cmUnpkLteCellId, &measInfo.cellId, mBuf); + + SPutMsg(mBuf); + RETVALUE((*func)(pst, &measInfo)); +}/*cmUnpkLrgSchL2MeasStopCfm*/ + +/** +* @brief This API is used to unpack LrgNumActvUeQCICfm structure +* +* @details +* +* Function: cmPkNumUeQciCfm +* +* @param[in] LrgNumActvUeQCICfm * param +* @param[in] Buffer * mBuf +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PRIVATE S16 cmPkNumUeQciCfm +( +LrgNumActvUeQCICfm *param, +Buffer *mBuf +) +#else +PRIVATE S16 cmPkNumUeQciCfm(param, mBuf) +LrgNumActvUeQCICfm *param; +Buffer *mBuf; +#endif +{ + U8 idx; + + TRC3(cmPkNumUeQciCfm) + + for(idx = 0; idx < param->numQci; idx++) + { +/*LRG : Review Tag*/ + CMCHKPK(SPkU8, param->numActvUeQci[idx].qciValue, mBuf); + CMCHKPK(SPkU8, param->numActvUeQci[idx].numActvUeQci, mBuf); +/*LRG : Review Tag*/ + } + CMCHKPK(SPkU8, param->numQci, mBuf); + RETVALUE(ROK); +} + +/** +* @brief This API is used to unpack LrgAvgPrbQCICfm structure +* +* @details +* +* Function: cmPkAvgPrbQciCfm +* +* @param[in] LrgAvgPrbQCICfm * param +* @param[in] Buffer * mBuf +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PRIVATE S16 cmPkAvgPrbQciCfm +( +LrgAvgPrbQCICfm *param, +Buffer *mBuf +) +#else +PRIVATE S16 cmPkAvgPrbQciCfm(param, mBuf) +LrgAvgPrbQCICfm *param; +Buffer *mBuf; +#endif +{ + U8 idx; + + TRC3(cmPkAvgPrbQciCfm) + for(idx = 0; idx < param->numQci; idx++) + { +/*LRG : Review Tag*/ + CMCHKPK(SPkU8, param->prbPercQci[idx].qciValue, mBuf); + CMCHKPK(SPkU8, param->prbPercQci[idx].prbPercQci, mBuf); +/*LRG : Review Tag*/ + } + CMCHKPK(SPkU8, param->numQci, mBuf); + RETVALUE(ROK); +} + +/** +* @brief This API is used to unpack raPreamblesCfm structure +* +* @details +* +* Function: cmPkRaPrmbsCfm +* +* @param[in] LrgRaPreamblesCfm * param +* @param[in] Buffer * mBuf +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PRIVATE S16 cmPkRaPrmbsCfm +( +LrgRaPreamblesCfm *param, +Buffer *mBuf +) +#else +PRIVATE S16 cmPkRaPrmbsCfm(param, mBuf) +LrgRaPreamblesCfm *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRaPrmbsCfm) + CMCHKPK(SPkU16, param->randSelPreHighRange, mBuf); + CMCHKPK(SPkU16, param->randSelPreLowRange, mBuf); + CMCHKPK(SPkU16, param->dedPreambles, mBuf); + RETVALUE(ROK); +} + +/** +* @brief This API is used to unpack avgPrbCfm structure +* +* @details +* +* Function: cmPkAvgPrbCfm +* +* @param[in] LrgAvgPrbCfm * param +* @param[in] Buffer * mBuf +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PRIVATE S16 cmPkAvgPrbCfm +( +LrgAvgPrbCfm *param, +Buffer *mBuf +) +#else +PRIVATE S16 cmPkAvgPrbCfm(param, mBuf) +LrgAvgPrbCfm *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkAvgPrbCfm) + CMCHKPK(SPkU8, param->prbPerc, mBuf); + RETVALUE(ROK); +} + +/** +* @brief This API is used to send a +L2 Measurement confirm from MAC to LM +* +* @details +* +* Function: cmPkLrgSchL2MeasCfm +* +* @param[in] Pst * pst +* @param[in] LrgSchMeasCfmInfo * measInfo +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkLrgSchL2MeasCfm +( +Pst * pst, +LrgSchMeasCfmInfo *measInfo +) +#else +PUBLIC S16 cmPkLrgSchL2MeasCfm(pst, measInfo) +Pst * pst; +LrgSchMeasCfmInfo *measInfo; +#endif +{ + Buffer *mBuf = NULLP; + + TRC3(cmPkLrgSchL2MeasCfm) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ELRG050, (ErrVal)0, "SGetMsg failed"); +#endif + RETVALUE(RFAILED); + } + if(measInfo->measType & LRG_L2MEAS_NMB_ACTV_UE_PER_QCI_DL) + { + CMCHKPK(cmPkNumUeQciCfm, &measInfo->numUeQciDlCfm, mBuf); + } + if(measInfo->measType & LRG_L2MEAS_NMB_ACTV_UE_PER_QCI_UL) + { + CMCHKPK(cmPkNumUeQciCfm, &measInfo->numUeQciUlCfm, mBuf); + } + if(measInfo->measType & LRG_L2MEAS_RA_PREAMBLE) + { + CMCHKPK(cmPkRaPrmbsCfm, &measInfo->raPrmbsCfm, mBuf); + } + if(measInfo->measType & LRG_L2MEAS_AVG_PRB_PER_QCI_DL) + { + CMCHKPK(cmPkAvgPrbQciCfm, &measInfo->avgPrbQciDlCfm, mBuf); + } + if(measInfo->measType & LRG_L2MEAS_AVG_PRB_PER_QCI_UL) + { + CMCHKPK(cmPkAvgPrbQciCfm, &measInfo->avgPrbQciUlCfm, mBuf); + } + if(measInfo->measType & LRG_L2MEAS_AVG_PRB_DL) + { + CMCHKPK(cmPkAvgPrbCfm, &measInfo->avgPrbDl, mBuf); + } + if(measInfo->measType & LRG_L2MEAS_AVG_PRB_UL) + { + CMCHKPK(cmPkAvgPrbCfm, &measInfo->avgPrbUl, mBuf); + } + if(measInfo->measType & LRG_L2MEAS_TB_TRANS_DL_COUNT) + { + CMCHKPK(SPkU32, measInfo->tbTransDlTotalCnt, mBuf); + } + if(measInfo->measType & LRG_L2MEAS_TB_TRANS_DL_FAULTY_COUNT) + { + CMCHKPK(SPkU32, measInfo->tbTransDlFaulty, mBuf); + } + if(measInfo->measType & LRG_L2MEAS_TB_TRANS_UL_COUNT) + { + CMCHKPK(SPkU32, measInfo->tbTransUlTotalCnt, mBuf); + } + if(measInfo->measType & LRG_L2MEAS_TB_TRANS_UL_FAULTY_COUNT) + { + CMCHKPK(SPkU32, measInfo->tbTransUlFaulty, mBuf); + } + CMCHKPK(cmPkLteCellId, measInfo->cellId, mBuf); + CMCHKPK(cmPkCmStatus, &measInfo->cfm, mBuf); + CMCHKPK(SPkU16, measInfo->measType, mBuf); + CMCHKPK(cmPkHeader, &measInfo->hdr, mBuf); + pst->event = (Event) EVTLRGSCHL2MEASCFM; + RETVALUE(SPstTsk(pst,mBuf)); +} + +/** +* @brief This API is used to unpack LrgNumActvUeQCICfm +* +* @details +* +* Function: cmUnpkNumUeQciCfm +* +* @param[in] LrgNumActvUeQCICfm *param +* @param[in] Buffer * mBuf +* @return Void +* -# ROK +**/ +#ifdef ANSI +PRIVATE S16 cmUnpkNumUeQciCfm +( +LrgNumActvUeQCICfm *param, +Buffer *mBuf +) +#else +PRIVATE S16 cmUnpkNumUeQciCfm(param, mBuf) +LrgNumActvUeQCICfm *param; +Buffer *mBuf; +#endif +{ + U8 idx; + + TRC3(cmUnpkNumUeQciCfm) + CMCHKUNPK(SUnpkU8, ¶m->numQci, mBuf); + for(idx = param->numQci; idx > 0; idx--) + { +/*LRG : Review Tag*/ + CMCHKUNPK(SUnpkU8, ¶m->numActvUeQci[idx - 1].numActvUeQci, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numActvUeQci[idx - 1].qciValue, mBuf); +/*LRG : Review Tag*/ + } + RETVALUE(ROK); +} + +/** +* @brief This API is used to unpack LrgAvgPrbQCICfm +* +* @details +* +* Function: cmUnpkAvgPrbQciCfm +* +* @param[in] LrgAvgPrbQCICfm *param +* @param[in] Buffer * mBuf +* @return Void +* -# ROK +**/ +#ifdef ANSI +PRIVATE S16 cmUnpkAvgPrbQciCfm +( +LrgAvgPrbQCICfm *param, +Buffer *mBuf +) +#else +PRIVATE S16 cmUnpkAvgPrbQciCfm(param, mBuf) +LrgAvgPrbQCICfm *param; +Buffer *mBuf; +#endif +{ + U8 idx; + + TRC3(cmUnpkAvgPrbQciCfm) + + CMCHKUNPK(SUnpkU8, ¶m->numQci, mBuf); + for(idx = param->numQci; idx > 0; idx--) + { +/*LRG : Review Tag*/ + CMCHKUNPK(SUnpkU8, ¶m->prbPercQci[idx - 1].prbPercQci, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->prbPercQci[idx - 1].qciValue, mBuf); +/*LRG : Review Tag*/ + } + RETVALUE(ROK); +} + +/** +* @brief This API is used to unpack LrgRaPreamblesCfm +* +* @details +* +* Function: cmUnpkRaPrmbsCfm +* +* @param[in] LrgRaPreamblesCfm *param +* @param[in] Buffer * mBuf +* @return Void +* -# ROK +**/ +#ifdef ANSI +PRIVATE S16 cmUnpkRaPrmbsCfm +( +LrgRaPreamblesCfm *param, +Buffer *mBuf +) +#else +PRIVATE S16 cmUnpkRaPrmbsCfm(param, mBuf) +LrgRaPreamblesCfm *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRaPrmbsCfm) + + CMCHKUNPK(SUnpkU16, ¶m->dedPreambles, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->randSelPreLowRange, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->randSelPreHighRange, mBuf); + RETVALUE(ROK); +} + +/** +* @brief This API is used to unpack avgPrbCfm +* +* @details +* +* Function: cmUnpkAvgPrbCfm +* +* @param[in] LrgAvgPrbCfm *param +* @param[in] Buffer * mBuf +* @return Void +* -# ROK +**/ +#ifdef ANSI +PRIVATE S16 cmUnpkAvgPrbCfm +( +LrgAvgPrbCfm *param, +Buffer *mBuf +) +#else +PRIVATE S16 cmUnpkAvgPrbCfm(param, mBuf) +LrgAvgPrbCfm *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkAvgPrbCfm) + + CMCHKUNPK(SUnpkU8, ¶m->prbPerc, mBuf); + RETVALUE(ROK); +} + +/** +* @brief This API is used to send a +Measurement Confirm from LM to SCH. +* +* @details +* +* Function: cmUnpkLrgL2SchMeasCfm +* +* @param[in] Pst * pst +* @param[in] Buffer * mBuf +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkLrgSchL2MeasCfm +( +LrgSchL2MeasCfm func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkLrgSchL2MeasCfm(func, pst, mBuf) +LrgSchL2MeasCfm func; +Pst *pst; +Buffer *mBuf; +#endif +{ + LrgSchMeasCfmInfo measInfo; + + TRC3(cmUnpkLrgSchL2MeasCfm) + + CMCHKUNPK(cmUnpkHeader, &measInfo.hdr, mBuf); + CMCHKUNPK(SUnpkU16, &measInfo.measType, mBuf); + CMCHKUNPK(cmUnpkCmStatus, &measInfo.cfm, mBuf); + CMCHKUNPK(cmUnpkLteCellId, &measInfo.cellId, mBuf); + if(measInfo.measType & LRG_L2MEAS_TB_TRANS_UL_FAULTY_COUNT) + { + CMCHKPK(SUnpkU32, &measInfo.tbTransUlFaulty, mBuf); + } + if(measInfo.measType & LRG_L2MEAS_TB_TRANS_UL_COUNT) + { + CMCHKPK(SUnpkU32, &measInfo.tbTransUlTotalCnt, mBuf); + } + if(measInfo.measType & LRG_L2MEAS_TB_TRANS_DL_FAULTY_COUNT) + { + CMCHKPK(SUnpkU32, &measInfo.tbTransDlFaulty, mBuf); + } + if(measInfo.measType & LRG_L2MEAS_TB_TRANS_DL_COUNT) + { + CMCHKPK(SUnpkU32, &measInfo.tbTransDlTotalCnt, mBuf); + } + if(measInfo.measType & LRG_L2MEAS_AVG_PRB_UL) + { + CMCHKUNPK(cmUnpkAvgPrbCfm, &measInfo.avgPrbUl, mBuf); + } + if(measInfo.measType & LRG_L2MEAS_AVG_PRB_DL) + { + CMCHKUNPK(cmUnpkAvgPrbCfm, &measInfo.avgPrbDl, mBuf); + } + if(measInfo.measType & LRG_L2MEAS_AVG_PRB_PER_QCI_UL) + { + CMCHKUNPK(cmUnpkAvgPrbQciCfm, &measInfo.avgPrbQciUlCfm, mBuf); + } + if(measInfo.measType & LRG_L2MEAS_AVG_PRB_PER_QCI_DL) + { + CMCHKUNPK(cmUnpkAvgPrbQciCfm, &measInfo.avgPrbQciDlCfm, mBuf); + } + if(measInfo.measType & LRG_L2MEAS_RA_PREAMBLE) + { + CMCHKUNPK(cmUnpkRaPrmbsCfm, &measInfo.raPrmbsCfm, mBuf); + } + if(measInfo.measType & LRG_L2MEAS_NMB_ACTV_UE_PER_QCI_UL) + { + CMCHKUNPK(cmUnpkNumUeQciCfm, &measInfo.numUeQciUlCfm, mBuf); + } + if(measInfo.measType & LRG_L2MEAS_NMB_ACTV_UE_PER_QCI_DL) + { + CMCHKUNPK(cmUnpkNumUeQciCfm, &measInfo.numUeQciDlCfm, mBuf); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, &measInfo)); +} +#endif +#endif + + +/********************************************************************** + End of file + **********************************************************************/ diff --git a/src/cm/lrg.h b/src/cm/lrg.h index f4a1d3aa2..0428a0f9d 100755 --- a/src/cm/lrg.h +++ b/src/cm/lrg.h @@ -95,6 +95,7 @@ #define STRGRSAP STGEN + 2 #define STTFUSAP STGEN + 4 #define STSCHINST STGEN + 5 /* Scheduler Instance */ +#define STCLCELL STGEN + 6 /* CL cell */ #define LRG_USTA_DGNVAL_MEM 1 #define LRG_USTA_DGNVAL_HARQ 2 diff --git a/src/cm/lrg.x b/src/cm/lrg.x index 77fdce6e0..b1fce636a 100755 --- a/src/cm/lrg.x +++ b/src/cm/lrg.x @@ -34,6 +34,8 @@ #ifndef __LRGX__ #define __LRGX__ +#include "lcl.h" + /* ccpu00121930 : ADD: c++ support*/ #ifdef __cplusplus extern "C" { @@ -176,6 +178,7 @@ typedef struct rgCfg RgUpSapCfg crgSap; /*!< CRG interface SAP */ RgLowSapCfg tfuSap; /*!< TFU interface SAP */ RgSchInstCfg schInstCfg;/*!< General Configuration for scheduler instances */ + ClCellCfg cellCfg; }s; }RgCfg; diff --git a/src/cm/pju.h b/src/cm/pju.h deleted file mode 100755 index a324ccdfc..000000000 --- a/src/cm/pju.h +++ /dev/null @@ -1,185 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: LTE PDCP Interface - - Type: C include file - - Desc: This file contains the defines required by PDCP user. - - File: pju.h - -*********************************************************************21*/ - -#ifndef __PJU_H__ -#define __PJU_H__ - -#ifdef __cplusplus -EXTERN "C" { -#endif /*for extern "C"*/ - -/** - * @file - * @brief Macro for PJU Interface - */ - - -#define PJU_SEL_LC 0 -/* cause for status Indication */ -#define PJU_INTVER_FAILED 1 /*!< Integrity Verification Failed */ -#define PJU_DCIP_FAILED 2 /*!< Deciphering Failed */ -#define PJU_DCOMP_FAILED 3 /*!< Decompression Failed */ -#define PJU_COMP_FAILED 4 /*!< Compression Failed */ -#define PJU_INTPROT_FAILED 5 /*!< Integrity Protection Failed */ -#define PJU_CIPHER_FAILED 6 /*!< Ciphering Failed */ -#define PJU_MAX_SDU_SIZ_EXCEED 7 /*!< Maximum SDU Size Exceeded */ - -/* event values 0x00 - 0x40 is used for CPJ interface */ - -#define EVTPJUBNDREQ 0x40 /*!< Bind request */ -#define EVTPJUBNDCFM 0x41 /*!< Bind confirm */ -#define EVTPJUUBNDREQ 0x42 /*!< Unbind request */ -#define EVTPJUDATREQ 0x43 /*!< Data reqest */ -#define EVTPJUDATIND 0x44 /*!< PJU data indication */ -#define EVTPJUDATCFM 0x45 /*!< Data request confirm */ -#define EVTPJUSTAIND 0x46 /*!< PJU status indication */ -#define EVTPJUDATFWDREQ 0x47 /*!< PJU status indication */ -#define EVTPJUDATFWDIND 0x48 /*!< PJU status indication */ -#ifdef TENB_AS_SECURITY -#define EVTPJUTTIIND 0x49 /*!< TTI Indication from CL just in case - PDCP wants to do some periodic activity*/ -#endif -#define EVTFPPJUDATIND 0x50 /*!< PJU data indication for BC */ -#define EVTPCAPIPDATIND 0x51 /*!< PJU data indication for PCAP Data Indication */ - -#define PJU_DAT_CFM_SUCCESS 0 /*!< Data confirm status */ -#define PJU_RLC_TRANS_FAIL 1 /*!< RLC transaction failed */ -#define PJU_DISCARD_TMR_EXP 2 /*!< Discard timer expiry */ - -/* MAX values */ -#define PJU_MAX_SDU_CFM 1024 /*!< Maximum SDUs that can be - confirmed in a DatCfm */ - -/* Error Codes */ -#define EPJUXXX 0 -#define ERRPJU 0 - -#define EPJU001 (ERRPJU + 1) -#define EPJU002 (ERRPJU + 2) -#define EPJU003 (ERRPJU + 3) -#define EPJU004 (ERRPJU + 4) -#define EPJU005 (ERRPJU + 5) -#define EPJU006 (ERRPJU + 6) -#define EPJU007 (ERRPJU + 7) -#define EPJU008 (ERRPJU + 8) -#define EPJU009 (ERRPJU + 9) -#define EPJU010 (ERRPJU + 10) -#define EPJU011 (ERRPJU + 11) -#define EPJU012 (ERRPJU + 12) -#define EPJU013 (ERRPJU + 13) -#define EPJU014 (ERRPJU + 14) -#define EPJU015 (ERRPJU + 15) -#define EPJU016 (ERRPJU + 16) -#define EPJU017 (ERRPJU + 17) -#define EPJU018 (ERRPJU + 18) -#define EPJU019 (ERRPJU + 19) -#define EPJU020 (ERRPJU + 20) -#define EPJU021 (ERRPJU + 21) -#define EPJU022 (ERRPJU + 22) -#define EPJU023 (ERRPJU + 23) -#define EPJU024 (ERRPJU + 24) -#define EPJU025 (ERRPJU + 25) -#define EPJU026 (ERRPJU + 26) -#define EPJU027 (ERRPJU + 27) -#define EPJU028 (ERRPJU + 28) -#define EPJU029 (ERRPJU + 29) -#define EPJU030 (ERRPJU + 30) -#define EPJU031 (ERRPJU + 31) -#define EPJU032 (ERRPJU + 32) -#define EPJU033 (ERRPJU + 33) -#define EPJU034 (ERRPJU + 34) -#define EPJU035 (ERRPJU + 35) -#define EPJU036 (ERRPJU + 36) -#define EPJU037 (ERRPJU + 37) -#define EPJU038 (ERRPJU + 38) -#define EPJU039 (ERRPJU + 39) -#define EPJU040 (ERRPJU + 40) -#define EPJU041 (ERRPJU + 41) -#define EPJU042 (ERRPJU + 42) -#define EPJU043 (ERRPJU + 43) -#define EPJU044 (ERRPJU + 44) -#define EPJU045 (ERRPJU + 45) -#define EPJU046 (ERRPJU + 46) -#define EPJU047 (ERRPJU + 47) -#define EPJU048 (ERRPJU + 48) -#define EPJU049 (ERRPJU + 49) -#define EPJU050 (ERRPJU + 50) -#define EPJU051 (ERRPJU + 51) -#define EPJU052 (ERRPJU + 52) -#define EPJU053 (ERRPJU + 53) -#define EPJU054 (ERRPJU + 54) -#define EPJU055 (ERRPJU + 55) -#define EPJU056 (ERRPJU + 56) -#define EPJU057 (ERRPJU + 57) -#define EPJU058 (ERRPJU + 58) -#define EPJU059 (ERRPJU + 59) -#define EPJU060 (ERRPJU + 60) -#define EPJU061 (ERRPJU + 61) -#define EPJU062 (ERRPJU + 62) -#define EPJU063 (ERRPJU + 63) -#define EPJU064 (ERRPJU + 64) -#define EPJU065 (ERRPJU + 65) -#define EPJU066 (ERRPJU + 66) -#define EPJU067 (ERRPJU + 67) -#define EPJU068 (ERRPJU + 68) -#define EPJU069 (ERRPJU + 69) -#define EPJU070 (ERRPJU + 70) -#define EPJU071 (ERRPJU + 71) -#define EPJU072 (ERRPJU + 72) -#define EPJU073 (ERRPJU + 73) -#define EPJU074 (ERRPJU + 74) -#define EPJU075 (ERRPJU + 75) -#define EPJU076 (ERRPJU + 76) -#define EPJU077 (ERRPJU + 77) -#define EPJU078 (ERRPJU + 78) -#define EPJU079 (ERRPJU + 79) -#define EPJU080 (ERRPJU + 80) -#define EPJU081 (ERRPJU + 81) -#define EPJU082 (ERRPJU + 82) -#define EPJU083 (ERRPJU + 83) -#define EPJU084 (ERRPJU + 84) -#define EPJU085 (ERRPJU + 85) -#define EPJU086 (ERRPJU + 86) -#define EPJU087 (ERRPJU + 87) -#define EPJU088 (ERRPJU + 88) -#define EPJU089 (ERRPJU + 89) -#define EPJU090 (ERRPJU + 90) -#define EPJU091 (ERRPJU + 91) - -#ifdef __cplusplus -} -#endif /* __cplusplus */ -#endif /* __PJU_H__ */ - - -/********************************************************************30** - - End of file -**********************************************************************/ diff --git a/src/cm/pju.x b/src/cm/pju.x deleted file mode 100755 index 5808d5bc4..000000000 --- a/src/cm/pju.x +++ /dev/null @@ -1,787 +0,0 @@ -/******************************************************************************* -################################################################################ -# Copyright (c) [2017-2019] [Radisys] # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); # -# you may not use this file except in compliance with the License. # -# You may obtain a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -################################################################################ -*******************************************************************************/ - -/********************************************************************20** - - Name: LTE PDCP Interface - - Type: C include file - - Desc: This file contains the Data structures for LTE PDCP Interface. - - File: pju.x - -*********************************************************************21*/ -#ifndef __PJU_X__ -#define __PJU_X__ - -#ifdef __cplusplus -EXTERN "C" { -#endif /*for extern "C"*/ - -/** - * @file - * @brief PJU Interface File - */ - -/************************************************************************* - * START OF STRUCTURES - ************************************************************************/ -typedef U32 PjuSduId; /*!< SDU ID */ -typedef U32 PjuSduLen; /*!< Length of SDU in bytes */ - -/** - * @brief Data Confirmation Status parameters. -*/ - -typedef struct pjuDatCfmSta -{ - PjuSduId sduId; /*!< SDU ID for AM */ - U8 status; /*!< Status, Value can be - - -# PJU_DAT_CFM_SUCCESS, - -# PJU_RLC_TRANS_FAIL, - -# PJU_DISCARD_TMR_EXP */ -}PjuDatCfmSta; - -/** - * @brief Data Confirmation parameters -*/ - -typedef struct pjuDatCfmInfo -{ - U16 numSdus; /*!< Number of SDUs for which cfm is sent */ - PjuDatCfmSta cfmSta[PJU_MAX_SDU_CFM]; /*!< Data Confirm Status */ -}PjuDatCfmInfo; - -/** - * @brief Status Indication parameters -*/ -typedef struct pjuStaIndInfo -{ - U8 cause; /*!< Error cause */ -}PjuStaIndInfo; - -/** - * @brief Data Forward Information -*/ -typedef struct pjuDatFwdInfo -{ - PjuSduId sduId; /*!< SDU ID */ - U16 sn; /*!< SN associated with the SDU */ - Buffer *sdu; /*!< Forwarded SDU sent / received during - handover */ -}PjuDatFwdInfo; - -/** - * @brief Data Forward Request parameters for PDCP - entity mapped to RLC AM -*/ - -typedef struct pjuDatFwdReqInfo -{ - U8 dir; /*!< Data forwarded for - UL/DL PDCP entity */ - U16 numSdus; /*!< Number of SDUs in DatFwdReq */ - PjuDatFwdInfo *datFwdInfo; /*!< Data Forward Information */ - Bool isLastDatFwdInd; /*!< Last Data Foward Indication */ -}PjuDatFwdReqInfo; - -/** - * @brief Data Forward Indication parameters for PDCP - entity mapped to RLC AM -*/ -typedef PjuDatFwdReqInfo PjuDatFwdIndInfo; -typedef struct pjuDatReqInfo -{ - SpId spId; - CmLtePdcpId pdcpId; - PjuSduId sduId; -}PjuDatReqInfo; -typedef struct pjuDatIndInfo -{ - SuId suId; - CmLtePdcpId pdcpId; -}PjuDatIndInfo; -/************************************************************************* - * END OF STRUCTURES - ************************************************************************/ - -/****************************************************************************** - * Prototypes for the selector matrices * - ******************************************************************************/ - - -typedef S16 (*PjuBndReq) ARGS(( - Pst *, - SuId, - SpId - )); - -typedef S16 (*PjuBndCfm) ARGS(( - Pst *, - SuId, - U8 - )); - -typedef S16 (*PjuUbndReq) ARGS(( - Pst *, - SpId, - Reason - )); - -typedef S16 (*PjuDatReq) ARGS(( - Pst *, - SpId, - CmLtePdcpId *, - PjuSduId, - Buffer * - )); - -#ifdef FLAT_BUFFER_OPT -typedef S16 (*PjuDatReqFB) ARGS(( - Pst *, - SpId, - CmLtePdcpId *, - PjuSduId, - FlatBuffer * - )); -#endif - - -typedef S16 (*PjuDatCfm) ARGS(( - Pst *, - SuId, - CmLtePdcpId *, - PjuDatCfmInfo * - )); - -typedef S16 (*PjuDatInd) ARGS(( - Pst *, - SuId, - CmLtePdcpId *, - Buffer * - )); - -typedef S16 (*PjuStaInd) ARGS(( - Pst *, - SuId, - CmLtePdcpId *, - PjuStaIndInfo *, - Buffer * - )); - -typedef S16 (*PjuDatFwdReq) ARGS(( - Pst *, - SpId, - CmLtePdcpId *, - PjuDatFwdReqInfo * - )); - -typedef S16 (*PjuDatFwdInd) ARGS(( - Pst *, - SuId, - CmLtePdcpId *, - PjuDatFwdIndInfo * - )); - -/* pju_x_001.main_2 */ -/************************************************************************* - * Start of Extern Interface Declarations - ************************************************************************/ -/** - * @brief Bind request primitive - * @details - * The function binds the PDCP service user entity to the PDCP product. - * The PDCP service user must bind each PJU SAP individually before sending - * any other request. PDCP acknowledges the receipt of the bind request by - * sending a @ref PjUiPjuBndCfm primitive. - * - * @param[in] pst - Pointer to the pst structure. - * @param[in] suId - Service user ID. This is the reference number used by the - * PDCP service user to identify its SAP. This reference number is - * provided by PDCP in any further primitives sent by PDCP to the service user. - * @param[in] spId - Service provider ID. This is the reference number - * used by the PDCP service user (Relay) to identify its SAP. This reference number - * is provided by PDCP in any further primitives sent by the PDCP - * to the service user. - * - * @return ROK - */ -EXTERN S16 PjUiPjuBndReq ARGS(( Pst* , SuId , SpId)); - -/** - * @brief Bind confirm primitive - * @details - * PDCP invokes the bind confirm primitive to acknowledge the receipt - * of the @ref PjUiPjuBndReq primitive from the service user. The status - * field indicates whether the bind request succeeded or failed. The bind - * request may fail due to invalid parameters in the bind request from the - * service user (for example, an invalid spId). - * - * @param[in] pst - Pointer to the pst structure. - * @param[in] suId - Service user ID. This is the reference number used - * by the PDCP service user (Relay or RRC layer) to identify its SAP. - * @param[in] status - Status field indicates whether the bind request - * succeeded or failed. - * -# TRUE, if successful bind. - * -# FALSE, otherwise. - * - * @return ROK. - */ -EXTERN S16 PjUiPjuBndCfm ARGS(( Pst*, SuId, U8)); - -/** - * @brief Unbind request primitive - * @details - * The PDCP service user initiates this primitive for performing an unbind - * operation. This function brings the link between PDCP and its service user - * down if it is already up, and releases all the resources associated for - * this SAP at PDCP. - * - * @param[in] pst - Pointer to pst structure. - * @param[in] spId - Service provider ID. This is the reference number - * used by the PDCP service user (Relay) to identify its SAP. This reference number - * is provided by the PDCP in any further primitives sent by the PDCP - * to the service user. - * @param[in] reason - Unbind reason. Not used in the current implementation. - * - * @return ROK - */ -EXTERN S16 PjUiPjuUbndReq ARGS(( Pst*, SpId, Reason)); - -/** - * @brief Data request primitive - * @details - * This primitive is used by the PDCP service user to request the PDCP - * for data transfer. - * - * @param[in] pst - Pointer to pst structure. - * @param[in] spId - Service provider ID. This is the reference number - * used by the PDCP service user (Relay) to identify its SAP. This reference number - * is provided by the PDCP in any further primitives sent by the PDCP - * to the service user. - * @param[in] pdcpId - Pointer to CmLtePdcpId structure, PDCP ID is used to - * uniquely identify a PDCP entity. - * @param[in] sduId - SDU ID. - * @param[in] mBuf - Pointer to data buffer. - * - * @return ROK - */ -EXTERN S16 PjUiPjuDatReq ARGS(( Pst*, SpId, CmLtePdcpId *, PjuSduId, Buffer*)); -#ifdef FLAT_BUFFER_OPT -EXTERN S16 PjUiPjuDatReqFB ARGS(( Pst*, SpId, CmLtePdcpId *, PjuSduId, FlatBuffer*)); -#endif - -/** - * @brief Data confirm primitive - * @details - * This primitive is sent to the PDCP user to acknowledge the status of the SDU delivered - * to the lower layer. Its applicable only for PDCP entities mapped with RLC AM. - * - * @param[in] pst - Pointer to pst structure. - * @param[in] suId - Service user ID. This is the reference number used by the PDCP - user to identify its SAP. - * @param[in] pdcpId - Pointer to CmLtePdcpId structure, PDCP ID is used to - uniquely identify a PDCP entity. - * @param[in] datCfm - Pointer to data confirm structure. - * - * @return ROK. - */ -EXTERN S16 PjUiPjuDatCfm ARGS((Pst*, SuId, CmLtePdcpId *, PjuDatCfmInfo *)); - -/** - * @brief Data indication primitive - * @details - * This primitive is used to send the data received from the lower layer - * to the service user. - * - * @param[in] pst - Pointer to pst structure. - * @param[in] suId - Service user ID. This is the reference number used - * by the PDCP user to identify its SAP. - * @param[in] pdcpId - Pointer to CmLtePdcpId structure, PDCP ID is used - * to uniquely identify a PDCP entity. - * @param[in] mBuf - Pointer to data buffer. - * - * @return ROK. - */ -EXTERN S16 PjUiPjuDatInd ARGS((Pst*, SuId, CmLtePdcpId *, Buffer*)); - -/** - * @brief Status indication primitive - * @details - * This primitive is used by the PDCP to indicate to the PDCP service user about - * the arrival of invalid PDUs (integrity protection or ciphering failed). - * - * @param[in] pst - Pointer to pst structure. - * @param[in] suId - Service user ID. This is the reference number used - * by the PDCP user to identify its SAP. - * @param[in] pdcpId - Pointer to CmLtePdcpId structure, PDCP ID is used to - * uniquely identify a PDCP entity. - * @param[in] staInd - Pointer to status indication structure. - * @param[in] mBuf - PDU for which integrity protection failed. - * - * @return ROK. - */ -EXTERN S16 PjUiPjuStaInd ARGS((Pst*, SuId, CmLtePdcpId *, PjuStaIndInfo *, Buffer *)); - - -/** - * @brief Data Forward Request primitive - * @details - * This primitive is used by PDCP user to forward the SDUs along with its SN - * as part of handover (SDUs forwarded from PDCP on source eNB through X2-U - * interface to the PDCP on target eNB). - * - * @param[in] pst - Pointer to pst structure. - * @param[in] spId - Service provider ID. This is the reference number - * used by PDCP service user (Relay) to identify its SAP. This reference number - * is provided by PDCP in any further primitives sent by PDCP - * to the service user. - * @param[in] pdcpId - Pointer to CmLtePdcpId structure, PDCP ID is used to - * uniquely identify a PDCP entity. - * @param[in] datFwdReq - Pointer to data forward information structure. - * - * @return ROK. - */ -EXTERN S16 PjUiPjuDatFwdReq ARGS((Pst*, SpId, CmLtePdcpId *, PjuDatFwdReqInfo *)); - - -/** - * @brief Data Forward Indication primitive - * @details - * This primitive is used by PDCP to forward the SDUs along with its SN - * as part of handover (SDUs forwarded from PDCP on source eNB through X2-U - * interface to the PDCP on target eNB). - * - * @param[in] pst - Pointer to pst structure. - * @param[in] suId - Service user ID. This is the reference number used - * by the PDCP user to identify its SAP. - * @param[in] pdcpId - Pointer to CmLtePdcpId structure, PDCP ID is used to - * uniquely identify a PDCP entity. - * @param[in] datFwdInd - Pointer to data forward information structure. - * - * @return ROK. - */ -EXTERN S16 PjUiPjuDatFwdInd ARGS((Pst*, SuId, CmLtePdcpId *, PjuDatFwdIndInfo *)); - - -/************************************************************************* - * End of Extern Interface Declarations - ************************************************************************/ - -#ifdef DM -EXTERN S16 DmUiPjuBndReq ARGS(( - Pst*, - SuId, - SpId - )); - -EXTERN S16 DmUiPjuUbndReq ARGS(( - Pst*, - SpId, - Reason - )); - - -EXTERN S16 DmUiPjuBndCfm ARGS(( - Pst*, - SuId, - U8 - )); - -EXTERN S16 DmUiPjuDatReq ARGS(( - Pst*, - SpId, - CmLtePdcpId *, - PjuSduId , - Buffer* - )); - -EXTERN S16 DmUiPjuDatInd ARGS(( - Pst*, - SuId, - CmLtePdcpId *, - Buffer* - )); - -EXTERN S16 DmUiPjuDatCfm ARGS(( - Pst*, - SuId, - CmLtePdcpId *, - PjuDatCfmInfo * - )); - -EXTERN S16 DmUiPjuStaInd ARGS(( - Pst*, - SuId, - CmLtePdcpId *, - PjuStaIndInfo * - )); - -EXTERN S16 DmUiPjuDatFwdReq ARGS(( - Pst*, - SpId, - CmLtePdcpId *, - PjuDatFwdReqInfo * - )); - -EXTERN S16 DmUiPjuDatFwdInd ARGS(( - Pst*, - SuId, - CmLtePdcpId *, - PjuDatFwdIndInfo * - )); -#endif /* DM */ - -/****************************************************************************** -* Prototypes for LTE-PDCP layer * -******************************************************************************/ - -#ifdef PX /* for LTE PDCP to PX (Relay) */ - -EXTERN S16 PxLiPjuBndReq ARGS(( - Pst *, - SuId, - SpId - )); - -EXTERN S16 PxLiPjuUbndReq ARGS(( - Pst *, - SuId, - Reason - )); - -EXTERN S16 PxLiPjuDatReq ARGS(( - Pst *, - SpId, - CmLtePdcpId *, - PjuSduId, - Buffer * - )); - -EXTERN S16 PxLiPjuBndCfm ARGS(( - Pst *, - SuId, - U8 - )); - -EXTERN S16 PxLiPjuDatInd ARGS(( - Pst *, - SuId, - CmLtePdcpId *, - Buffer * - )); - -EXTERN S16 PxLiPjuDatCfm ARGS(( - Pst *, - SuId , - CmLtePdcpId *, - PjuDatCfmInfo * - )); - -EXTERN S16 PxLiPjuStaInd ARGS(( - Pst*, - SuId, - CmLtePdcpId *, - PjuStaIndInfo * , - Buffer * - )); - -EXTERN S16 PxLiPjuDatFwdReq ARGS(( - Pst *, - SpId, - CmLtePdcpId *, - PjuDatFwdReqInfo * - )); - - -EXTERN S16 PxLiPjuDatFwdInd ARGS(( - Pst *, - SuId, - CmLtePdcpId *, - PjuDatFwdIndInfo * - )); - -#endif /* PX */ - -#ifdef NH /* for LTE RLC to NH */ - -EXTERN S16 NhLiPjuBndReq ARGS(( - Pst *, - SuId, - SpId - )); - -EXTERN S16 NhLiPjuUbndReq ARGS(( - Pst *, - SuId, - Reason - )); - -EXTERN S16 NhLiPjuDatReq ARGS(( - Pst *, - SpId, - CmLtePdcpId *, - PjuSduId, - Buffer * - )); - -EXTERN S16 NhLiPjuBndCfm ARGS(( - Pst *, - SuId, - U8 - )); - -EXTERN S16 NhLiPjuDatInd ARGS(( - Pst *, - SuId, - CmLtePdcpId *, - Buffer * - )); - -EXTERN S16 NhLiPjuDatCfm ARGS(( - Pst *, - SuId , - CmLtePdcpId *, - PjuDatCfmInfo * - )); - -EXTERN S16 NhLiPjuStaInd ARGS(( - Pst*, - SuId, - CmLtePdcpId *, - PjuStaIndInfo * , - Buffer * - )); - -EXTERN S16 NhLiPjuDatFwdReq ARGS(( - Pst *, - SpId, - CmLtePdcpId *, - PjuDatFwdReqInfo * - )); - - -EXTERN S16 NhLiPjuDatFwdInd ARGS(( - Pst *, - SuId, - CmLtePdcpId *, - PjuDatFwdIndInfo * - )); - -#endif /* NH */ - -/****************************************************************************** - * pack/unpack functions * - ******************************************************************************/ - -#ifdef LCPJU - -EXTERN S16 cmPkPjuBndReq ARGS(( -Pst* pst, -SpId suId, -SuId spId -)); -EXTERN S16 cmUnpkPjuBndReq ARGS(( -PjuBndReq func, -Pst *pst, -Buffer *mBuf -)); -EXTERN S16 cmPkPjuBndCfm ARGS(( -Pst* pst, -SuId suId, -U8 status -)); -EXTERN S16 cmUnpkPjuBndCfm ARGS(( -PjuBndCfm func, -Pst *pst, -Buffer *mBuf -)); -EXTERN S16 cmPkPjuUbndReq ARGS(( -Pst* pst, -SpId spId, -Reason reason -)); -EXTERN S16 cmUnpkPjuUbndReq ARGS(( -PjuUbndReq func, -Pst *pst, -Buffer *mBuf -)); -#ifdef SS_RBUF -EXTERN S16 cmPkFpPjuDatReq ARGS(( -Pst* pst, -SpId spId, -CmLtePdcpId * pdcpId, -PjuSduId sduId, -Buffer * mBuf -)); -#endif -EXTERN S16 cmPkPjuDatReq ARGS(( -Pst* pst, -SpId spId, -CmLtePdcpId * pdcpId, -PjuSduId sduId, -Buffer * mBuf -)); -#ifdef FLAT_BUFFER_OPT -EXTERN S16 cmPkPjuDatReqFB ARGS(( -Pst* pst, -SpId spId, -CmLtePdcpId * pdcpId, -PjuSduId sduId, -FlatBuffer * mBuf -)); -#endif - -#ifdef SS_RBUF -EXTERN S16 cmUnpkFpPjuDatReq ARGS(( -PjuDatReq func, -Pst *pst, -Buffer *mBuf -)); -#endif -EXTERN S16 cmUnpkPjuDatReq ARGS(( -PjuDatReq func, -Pst *pst, -Buffer *mBuf -)); -EXTERN S16 cmPkPjuDatCfm ARGS(( -Pst* pst, -SuId suId, -CmLtePdcpId * pdcpId, -PjuDatCfmInfo * datCfm -)); -EXTERN S16 cmUnpkPjuDatCfm ARGS(( -PjuDatCfm func, -Pst *pst, -Buffer *mBuf -)); -EXTERN S16 cmPkPjuDatInd ARGS(( -Pst* pst, -SuId suId, -CmLtePdcpId * pdcpId, -Buffer * mBuf -)); -EXTERN S16 cmUnpkPjuDatInd ARGS(( -PjuDatInd func, -Pst *pst, -Buffer *mBuf -)); - -#ifdef SS_RBUF -EXTERN S16 cmPkFpPjuDatInd ARGS(( -Pst* pst, -SuId suId, -CmLtePdcpId * pdcpId, -Buffer * mBuf -)); - -EXTERN S16 cmUnpkFpPjuDatInd ARGS(( -PjuDatInd func, -Pst *pst, -Buffer *mBuf -)); -#endif - -EXTERN S16 cmPkPjuStaInd ARGS(( -Pst* pst, -SuId suId, -CmLtePdcpId * pdcpId, -PjuStaIndInfo * staInd, -Buffer *buff -)); -EXTERN S16 cmUnpkPjuStaInd ARGS(( -PjuStaInd func, -Pst *pst, -Buffer *mBuf -)); -EXTERN S16 cmPkPjuDatFwdReq ARGS(( -Pst* pst, -SpId spId, -CmLtePdcpId * pdcpId, -PjuDatFwdReqInfo * datFwdReq -)); -EXTERN S16 cmUnpkPjuDatFwdReq ARGS(( -PjuDatFwdReq func, -Pst *pst, -Buffer *mBuf -)); -EXTERN S16 cmPkPjuDatFwdInd ARGS(( -Pst* pst, -SuId suId, -CmLtePdcpId * pdcpId, -PjuDatFwdIndInfo * datFwdInd -)); -EXTERN S16 cmUnpkPjuDatFwdInd ARGS(( -PjuDatFwdInd func, -Pst *pst, -Buffer *mBuf -)); -EXTERN S16 cmPkPjuDatCfmInfoSta ARGS(( -PjuDatCfmSta *param, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjuDatCfmInfoSta ARGS(( -PjuDatCfmSta *param, -Buffer *mBuf -)); -EXTERN S16 cmPkPjuDatCfmInfo ARGS(( -PjuDatCfmInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjuDatCfmInfo ARGS(( -PjuDatCfmInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmPkPjuStaIndInfo ARGS(( -PjuStaIndInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjuStaIndInfo ARGS(( -PjuStaIndInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmPkPjuDatFwdReqInfo ARGS(( -PjuDatFwdReqInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjuDatFwdReqInfo ARGS(( -Pst *pst, -PjuDatFwdReqInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmPkPjuDatFwdInfo ARGS(( -PjuDatFwdInfo *param, -Buffer *mBuf -)); -EXTERN S16 cmUnpkPjuDatFwdInfo ARGS(( -PjuDatFwdInfo *param, -Buffer *mBuf -)); - -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ -#endif /* __PJU_X__ */ -/********************************************************************30** - - End of file -**********************************************************************/ diff --git a/src/cm/rg_cl_phy.h b/src/cm/rg_cl_phy.h new file mode 100644 index 000000000..8346fb8a4 --- /dev/null +++ b/src/cm/rg_cl_phy.h @@ -0,0 +1,896 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/* Defines API exchanged between MAC and PHY */ +#ifndef __RG_CL_PHY_H___ +#define __RG_CL_PHY_H___ + +#define MSG_HDR_SIZE 8 +#define DCI_PAYLOAD_BTYE_LEN 1 /* TBD */ + +#define MAC_DCI_PER_SLOT 1 /* TBD */ +#define MAX_UL_PDU_PER_SLOT 1 /* TBD */ +#define MAX_UCI_PER_SLOT 1 /* TBD */ +#define MAX_DL_PDU_PER_SLOT 1 /* TBD */ +#define MAX_PARAM_TLV 54 /* Maximum TLVs that can be reported in param response */ +#define MAX_CONFIG_TLV 40 /* Maximum TLVs that can be configured in config request */ +#define MAX_NUM_PDU 255 /* Maximum PDUs that can be included in a message */ +#define MAX_UE_GRP_DL 255 /* Maximum UE groups that can be included in a DL TTI request */ +#define MAX_UE_GRP_UL 8 /* Maximum UE groups that can be included in a UL TTI request */ +#define MAX_UE_PER_GRP_DL 12 /* Maximum UEs included in a group in DL */ +#define MAX_UE_PER_GRP_UL 6 /* Maximum UEs included in a group in UL */ +#define MAX_PRG 275 /* Maximum Precoding Resource Block Group */ +#define MAX_DIGBF_INTF 255 /* Maximum digBf interfaces */ +#define MAX_CODE_WORD_PER_RNTI 2 /* Maximum code word for one RNTI */ +#define MAX_UL_PTRS_PORTS 2 /* Maximum number of UL PTRS ports */ +#define MAX_REPORT_SYMB 4 /* Maximum reported symbols in SRS indication */ +#define MAX_NUM_PRB 272 /* Maximum number of PRBs in SRS indication PDU */ +#define MAX_NUM_PRMBL 64 /* Maximum number of preambles */ +#define MAX_HARQ_SIZE 213 /* Maximum size of HARQ payload */ + +//Defining API type values +#define MSG_TYPE_PARAM_REQ 0x00 +#define MSG_TYPE_PARAM_RSP 0x01 +#define MSG_TYPE_CONFIG_REQ 0x02 +#define MSG_TYPE_CONFIG_RSP 0x03 +#define MSG_TYPE_START_REQ 0x04 +#define MSG_TYPE_STOP_REQ 0x05 +#define MSG_TYPE_STOP_IND 0x06 +#define MSG_TYPE_ERR_IND 0x07 +#define MSG_TYPE_DL_TTI_REQ 0x80 +#define MSG_TYPE_UL_TTI_REQ 0x81 +#define MSG_TYPE_SLOT_IND 0x82 +#define MSG_TYPE_UL_DCI_REQ 0x83 +#define MSG_TYPE_TX_DATA_REQ 0x84 +#define MSG_TYPE_RX_DATA_IND 0x85 +#define MSG_TYPE_CRC_IND 0x86 +#define MSG_TYPE_UCI_IND 0x87 +#define MSG_TYPE_SRS_IND 0x88 +#define MSG_TYPE_RACH_IND 0x89 + +/* Defining TAG for Parameter message TLVs */ +/* Cell Specific Parameters */ +#define PARAM_TAG_REL_CAP 0x0001 /* Release capacity */ +#define PARAM_TAG_PHY_STATE 0x0002 /* PHY state */ +#define PARAM_TAG_SKIP_BLNK_DL_CFG 0x0003 +#define PARAM_TAG_SKIP_BLNK_UL_CFG 0x0004 +#define PARAM_TAG_NUM_CFG_TLV_REP 0x0005 /* Number of config TLVs which will be reported */ + +/* Carrier Specific Parameters */ +#define PARAM_TAG_CYCLIC_PREFIX 0x0006 /* Cyclic prefix */ +#define PARAM_TAG_DL_SUBC_SPC_SUPP 0x0007 /* DL subcarrier spacing supported */ +#define PARAM_TAG_DL_BDW_SUPP 0x0008 /* DL bandwidth supported */ +#define PARAM_TAG_UL_SUBC_SPC_SUPP 0x0009 /* UL subcarrier spacing supported */ +#define PARAM_TAG_UL_BDW_SUPP 0x000A /* DL bandwidth supported */ + +/* PDCCH Parameters */ +#define PARAM_TAG_CCE_MAP_TYPE 0x000B /* CCE Mapping type */ +#define PARAM_TAG_CORES_OUT_FISRT_30SYM 0x000C /* Coreset outside first 30 symbols of slot support */ +#define PARAM_TAG_PRECOD_GRANULAR_CORES 0x000D /* Precoder granularity coreset support */ +#define PARAM_TAG_PDCCH_MU_MIMO 0x000E /* PDCCH multi user mimo support */ +#define PARAM_TAG_PDCCH_PRECOD_CYC 0x000F /* PDCCH precoder cycling support */ +#define PARAM_TAG_MAX_PDCCH_PER_SLOT 0x0010 /* Max PDCCHs per slot */ + +/* PUCCH Parameters */ +#define PARAM_TAG_PUCCH_FORMATS 0x0011 /* PUCCH formats supported */ +#define PARAM_TAG_MAX_PUCCH_PER_SLOT 0x0012 /* Max PUCCHs per slot */ + +/* PDSCH Parameters */ +#define PARAM_TAG_PDSCH_MAP_TYPE 0x0013 /* PDSCH mapping type */ +#define PARAM_TAG_PDSCH_ALLOC_TYPE 0x0014 /* PDSCH allocation type */ +#define PARAM_TAG_PDSCH_VRB_PRB_MAP 0x0015 /* PDSCH vrb to prb mapping */ +#define PARAM_TAG_PDSCH_CBG 0x0016 /* PDSCH code block group support */ +#define PARAM_TAG_PDSCH_DMRS_CFG_TYPE 0x0017 /* PDSCH dmrs configuration types */ +#define PARAM_TAG_PDSCH_DMRS_MAX_LEN 0x0018 /* PDSCH dmrs max length */ +#define PARAM_TAG_PDSCH_DMRS_ADD_POS 0x0019 /* PDSCH dmrs additional position */ +#define PARAM_TAG_MAX_PDSCH_TB_PER_SLOT 0x001A /* Max PDSCH trasnport blocks per slot */ +#define PARAM_TAG_MAX_MIMO_LAYER_PDSCH 0x001B /* Max number of MIMO layers supported for PDSCH */ +#define PARAM_TAG_MAX_MOD_ORDER_SUPP_DL 0x001C /* Max modulation order supported for DL */ +#define PARAM_TAG_MAX_MU_MIMO_USER_DL 0x001D /* Max users of MU MIMO in DL */ +#define PARAM_TAG_PDSCH_DAT_IN_DMRS_SYM 0x001E /* PDSCH data in dmrs symbols supported */ +#define PARAM_TAG_PREEMPT_SUPP 0x001F /* Pre-emption support */ +#define PARAM_TAG_PDSCH_NON_SLOT_SUPP 0x0020 /* PDSCH non slot support */ + +/* PUSCH Parameters */ +#define PARAM_TAG_UCI_MUX_ULSCH_IN_PUSCH 0x0021 +#define PARAM_TAG_UCI_ONLY_PUSCH 0x0022 /* UCI only in PUSCH support */ +#define PARAM_TAG_PUSCH_FREQ_HOP 0x0023 /* PUSCH frequency hopping support */ +#define PARAM_TAG_PUSCH_DMRS_CFG_TYPE 0x0024 /* PUSCH dmrs configuration types */ +#define PARAM_TAG_PUSCH_DMRS_MAX_LEN 0x0025 /* PUSCH dmrs max length */ +#define PARAM_TAG_PUSCH_DMRS_ADD_POS 0x0026 /* PUSCH dmrs additional position */ +#define PARAM_TAG_PUSCH_CBG 0x0027 /* PUSCH code block group support */ +#define PARAM_TAG_PUSCH_MAP_TYPE 0x0028 /* PUSCH mapping type */ +#define PARAM_TAG_PUSCH_ALLOC_TYPE 0x0029 /* PUSCH allocation type */ +#define PARAM_TAG_PUSCH_VRB_PRB_MAP 0x002A /* PUSCH vrb to prb mapping */ +#define PARAM_TAG_PUSCH_MAX_PTRS_PORT 0x002B /* PUSCH max PTRS ports */ +#define PARAM_TAG_MAX_PUSCH_TB_PER_SLOT 0x002C /* Max PUSCH trasnport blocks per slot */ +#define PARAM_TAG_MAX_NUM_MIMO_NON_CB_PUSCH 0x002D /* Max number of MIMO layers for non-contention based PUSCH */ +#define PARAM_TAG_MAX_MOD_ORDER_SUPP_UL 0x002E /* Max modulation order supported for UL */ +#define PARAM_TAG_MAX_MU_MIMO_USER_UL 0x002F /* Max users of MU MIMO in UL */ +#define PARAM_TAG_DFTS_OFDM_SUPP 0x0030 /* DFTS-OFDM support */ +#define PARAM_TAG_PUSCH_AGGR_FACT 0x0031 /* PUSCH aggregation factor */ + +/* PRACH Parameters */ +#define PARAM_TAG_PRACH_LONG_FORMAT 0x0032 /* PRACH long formats */ +#define PARAM_TAG_PRACH_SHORT_FORMAT 0x0033 /* PRACH short formats */ +#define PARAM_TAG_PRACH_RES_SET 0x0034 /* PRACH restricted formats */ +#define PARAM_TAG_MAX_PRACH_FD_OCC_IN_SLOT 0x0035 /* Max PRACH fd occassions in a slot */ + +/* Measurement Parameters */ +#define PARAM_TAG_RSSI_MEAS_SUPP 0x0036 /* RSSI measurement support */ + +/* Defining TAG for Config message TLVs */ +/* Carrier Configuration */ +#define CFG_TAG_DL_BW 0x1001 /* DL bandwidth */ +#define CFG_TAG_DL_FREQ 0x1002 /* DL frequency */ +#define CFG_TAG_DLK0 0x1003 +#define CFG_TAG_DL_GRID_SIZE 0x1004 /* DL grid size */ +#define CFG_TAG_NUM_TX_ANT 0x1005 /* Number of transmission antennas */ +#define CFG_TAG_UL_BW 0x1006 /* Uplink bandwidth */ +#define CFG_TAG_UL_FREQ 0x1007 /* UL frequency */ +#define CFG_TAG_ULK0 0x1008 +#define CFG_TAG_UL_GRID_SIZE 0x1009 /* UL grid size */ +#define CFG_TAG_NUM_RX_ANT 0x100A /* Number of receiver antennas */ +#define CFG_TAG_FREQ_SHIFT_7P5KHZ 0x100B /* Indicates presence of 7.5 KHz frequency shift */ + +/* Cell Configuration */ +#define CFG_TAG_PHY_CELL_ID 0x100C /* Physical cell id */ +#define CFG_TAG_FRAME_DUP_TYPE 0x100D /* Frame duplex type */ + +/* SSB Configuration */ +#define CFG_TAG_SS_PBCH_PWR 0x100E /* SSB Block power */ +#define CFG_TAG_BCH_PAYLOAD 0x100F /* BCH payload options */ +#define CFG_TAG_SCS_COMM 0x1010 /* Subcarrier spacing for common */ + +/* PRACH Configuration */ +#define CFG_TAG_PRACH_SEQ_LEN 0x1011 /* RACH sequence length */ +#define CFG_TAG_PRACH_SUBC_SPAC 0x1012 /* Subcarrier spacing of PRACH */ +#define CFG_TAG_RES_SET_CFG 0x1013 /* PRACH restricted set config */ +#define CFG_TAG_NUM_PRACH_FD_OCC 0x1014 /* Number of PRACH frequency domain occassions */ +#define CFG_TAG_PRACH_ROOT_SEQ_ID 0x1015 /* Starting logical root sequence index */ +#define CFG_TAG_NUM_ROOT_SEQ 0x1016 /* Number of root sequences for a FD occasion */ +#define CFG_TAG_K1 0x1017 /* Frequency offset (for UL Bw) for each FD */ +#define CFG_TAG_PRACH_ZERO_CORR_CFG 0x1018 /* PRACH zero correlation config */ +#define CFG_TAG_NUM_UNUSED_ROOT_SEQ 0x1019 /* Number of unused root sequences avaialable */ +#define CFG_TAG_UNUSED_ROOT_SEQ 0x101A /* Unused root sequence */ +#define CFG_TAG_SSB_PER_RACH 0x101B /* SSB per RACH */ +#define CFG_TAG_PRACH_MULT_CARR_BAND 0x101C /* PRACH multiple carrier support in a band */ + +/* SSB Table */ +#define CFG_TAG_SSB_OFFS_POINT_A 0x101D /* Offset of lowest subcarrier of lowest RB of SS/PBCH block*/ +#define CFG_TAG_BETA_PSS 0x101E /* PSS EPRE to SSS EPRE in as SS/PBCH block */ +#define CFG_TAG_SSB_PERIOD 0x101F /* SSB periodicity in msec */ +#define CFG_TAG_SSB_SUBC_OFFS 0x1020 /* Subcarrier offset */ +#define CFG_TAG_MIB 0x1021 +#define CFG_TAG_SSB_MASK 0x1022 /* Bitmap of actually transmitted SSB */ +#define CFG_TAG_BEAM_ID 0x1023 /* Beam id for each SSB in SSB mask */ +#define CFG_TAG_SS_PBCH_MULT_CARR_BAND 0X1024 /* Multiple carrier support in a band */ +#define CFG_TAG_MULT_CELL_SS_PBCH_CARR 0x1025 /* Multiple cells support in single carrier */ + +/* TDD Table */ +#define CFG_TAG_TDD_PERIOD 0x1026 /* DL UL transmission periodicity */ +#define CFG_TAG_SLOT_CFG 0x1027 /* Slot config */ + +/* Measurement Configuration */ +#define CFG_TAG_RSSI_MEAS 0x1028 /* RSSI Measurement unit */ + +typedef enum +{ + MSG_OK, + MSG_INVALID_STATE, + MSG_INVALID_CONFIG, + SFN_OUT_OF_SYNC, + MSG_SLOT_ERR, + MSG_BCH_MISSING, + MSG_INVALID_SFN, + MSG_UL_DCI_ERR, + MSG_TX_ERR +}ErrorCode; + +typedef struct msgHdr +{ + U8 nMsg; /* Numer of messages in PHY API msg */ + U16 msgType; /* Message type Id */ + U32 msgLen; /* Length of msg body in bytes */ +}MsgHdr; + +typedef struct paramTlv +{ + U16 tag; + U16 length; + U16 value; /* TBD : decide on data type */ +}L1L2Tlv; + +typedef struct sfnSlot +{ + U16 sfn; + U16 slot; +}SfnSlotIE; + +typedef struct pduInfo +{ + U32 handle; + U16 rnti; + U8 ulCqi; + U16 timeAdv; + U16 rssi; +}PduInfo; + +typedef struct bwp +{ + U16 bwpSize; /* Bandwidth part size */ + U16 bwpStart; /* Bandwidth part start RB index from reference CRB */ + U8 sbcSpacing; /* Subcarrier spacing */ + U8 cycPrefix; /* Cyclic prefix */ +}L1L2Bwp; + +typedef struct coreset +{ + U8 startSymIdx; /* Starting OFDM symbol for CORESET */ + U8 durSym; /* Time duration of CORESET in num of symbols */ + U8 freqDomainRes[6]; /* Frequency domain resources */ + U8 cceRegMapType; /* CORESET-CCE-to-REG mapping type */ + U8 regBundleSize; /* Number of registers in a bundle */ + U8 interlvrSize; /* Inter leaver size */ + U8 coreSetType; /* Core set type */ + U16 shiftIdx; + U8 precodGranule; /* Precoder granularity */ +}L1L2Coreset; + +typedef struct txPwrInfo +{ + U8 betaPdcch; /* PDCCH power used for PDCCH format 1_0 */ + U8 pwrCtrlOffSs; /* Power control offset SS : used for all other PDCCH formats */ +}L1L2TxPwrInfo; + +typedef struct codeWrdInfo +{ + U16 tgtCodeRt; /* Target coding rate */ + U8 quamModOdr; /* QAM Modulation */ + U8 mcsIdx; /* MCS index */ + U8 mcsTable; /* MCS-table-PDSCH */ + U8 rvIdx; /* Redundancy version index */ + U32 tbSize; /* Transmit block size */ +}L1L2CodeWrdInfo; + +typedef struct codeWrd +{ + U8 numCodeWrd; /* Number of code words for this RNTI */ + L1L2CodeWrdInfo codeWrdInfo[MAX_CODE_WORD_PER_RNTI]; /* Info of each numCodeWrd */ +}L1L2CodeWrd; + +typedef struct dmrs +{ + U16 symbPos; /* DMRS symbol position */ + U8 cfgType; /* DMRS configuration type */ + U16 scrambleId; /* DMRS scrambling id */ + U8 scId; /* DMRS sequence initialization */ + U8 numCdmGrpNoDat; /* Number of DM-RS CDM groups without data */ + U16 ports; /* DMRS ports */ +}L1L2Dmrs; + +typedef struct ptrs +{ + U8 portIdx; /* PTRS antenna ports */ + U8 timeDens; /* PTRS time density */ + U8 freqDens; /* PTRS frequency desnity */ + U8 reOffset; /* PTRS resource element offset */ + U8 epreRatio; /* PTRS-To-PDSCH EPRE ratio */ +}L1L2Ptrs; + +typedef struct cbg +{ + U8 isLstCbPres; /* Is last CB present in CBG retransmission */ + U8 isInlineTbCrc; /* Is TB CRC part of data paylod or control msg */ + U32 dlTbCrc; /* TB CRC to be used in last CB if last CB pres */ +}L1L2Cbg; + +typedef struct resAllocFreqDom +{ + U8 resAllocType; /* Resource allocation type */ + U8 rbBitmap[36]; /* Bitmap for RBs for alloc type 0 */ + U16 rbStart; /* PDSCH starting RB in BWP for alloc type 1 */ + U16 rbSize; /* Num of RB for PDSCH for alloc type 1 */ + U8 vrbToPrbMap; /* VRB to PRB mapping */ +}L1L2ResAllocFreqDom; + +typedef struct puschAllocFreqDom +{ + L1L2ResAllocFreqDom resFreqDom; /* Resources allocated in frequency domain */ + Bool freqHop; /* Frequency hopping enabled for alloc type 1 */ + U16 txDirCurLoc; /* Uplink Tx direct current location for the carrier */ + Bool ulFreqShft7p5Khz; /* Indicates if 7.5 KHz shift is there */ +}L1L2PuschAllocFreqDom; + +typedef struct resAllocTimeDom +{ + U8 startSymbIdx; /* Start symbol index of PDSCH mapping from the start of slot */ + U8 nrOfSymbols; /* PDSCH duration in symbols */ +}L1L2ResAllocTimeDom; + +typedef struct prgInfo +{ + U16 pmIdx; /* Index to precoding matrix */ + U16 beamIdx[MAX_DIGBF_INTF]; /* Index of digital beam weight vector */ +}L1L2PrgInfo; + +typedef struct precodBeamfrmPdu +{ + U16 numPrgs; /* Number of precoding RB group */ + U16 prgSize; /* Size in RBs of a PRG */ + U8 digBfIntf; /* Number of STD ant ports feeding into digBF */ + L1L2PrgInfo prgInfo[MAX_PRG]; /* Info for numPrgs */ +}L1L2PrecodBeamfrmPdu; + +typedef struct rxBeamFrmPdu +{ + U16 numPrgs; /* Number of precoding RB group */ + U16 prgSize; /* Size in RBs of a PRG */ + U8 digBfIntf; /* Number of STD ant ports feeding into digBF */ + U16 beamIdx[MAX_PRG][MAX_DIGBF_INTF]; /* Rx PRG info */ +}L1L2RxBeamFrmPdu; + +typedef struct phyGenMib +{ + U8 dmrsTypeAPos; /* Position of first DM-RS for DL or UL */ + U8 pdcchCfgSib1; /* PDCCH config SIB1 */ + U8 callBarFlag; /* Flag to indicate if cell is barred */ + U8 intraFreqResel; /* Controls cell selection/re-selection to intra-frequency cell */ +}L1L2PhyGenMib; + +typedef struct bchPayld +{ + union + { + U32 macGenMibPdu; /* MAC generated MIB pdu */ + L1L2PhyGenMib phyGenMibPdu; /* PHY generated MIB pdu */ + }payld; +}L1L2BchPayld; + +typedef struct dlDci +{ + U16 rnti; /* UE RNTI */ + U16 scrambleId; /* PDCCH-DMRS-Scrambling id */ + U16 scrambleRnti; /* PDCCH-DMRS-Scrambling id */ + U8 ceIdx; /* CCE start index to send DCI */ + U8 aggLvl; /* Aggregation Level */ + U16 payldSizeBits; /* Total DCI length including padding bits */ + U8 payld[DCI_PAYLOAD_BTYE_LEN]; /* DCI Paylod. TBD : value of DCI_PAYLOAD_BTYE_LEN */ + L1L2PrecodBeamfrmPdu precodBeamfrmPdu; /* Precoding and Beamforming Info */ + L1L2TxPwrInfo txPwrInfo; /* Transmission power info */ +}L1L2DlDci; + +typedef struct puschMandInfo +{ + U16 tgtCodeRt; /* Target coding rate */ + U8 quamModOdr; /* QAM Modulation */ + U8 mcsIdx; /* MCS index */ + U8 mcsTable; /* MCS-table-PUSCH */ + U8 trnsfrmPrecod; /* Transform precoding enabled */ + U16 scrambleId; /* Data scrambling identity */ + U8 numLayer; /* Number of layers */ +}L1L2PuschMandInfo; + +typedef struct puschData +{ + U8 rvIdx; /* Redundancy version index */ + U8 harqProcId; /* HARQ process number */ + U8 newDatInd; /* Indicates new data or retransmission */ + U32 tbSize; /* Transmission block size */ + U16 numCb; /* Number of Cbs in TB */ + U8 cbPresPos[]; /* Each bit represent if CB is present */ //TBD: size of array +}L1L2PuschData; + +typedef struct puschUci +{ + U16 harqAckBitLen; /* Number of HARQ-ACK bits */ + U16 csiPrt1BitLen; /* Number of CSI-Part1 bits */ + U16 csiPrt2BitLen; /* Number of CSI-Part2 bits */ + U8 alphaScale; /* Alpha scaling */ + U8 betaOffHarqAck; /* Beta offset for HARQ-ACK bits */ + U8 betaOffCsi1; /* Beta offset for CSI-Part1 bits */ + U8 betaOffCsi2; /* Beta offset for CSI-Part2 bits */ +}L1L2PuschUci; + +typedef struct puschPtrsInfo +{ + U8 portIdx; /* PTRS antenna ports */ + U8 dmrsPort; /* DMRS port corresponding to PTRS port */ + U8 reOffset; /* PTRS resource element offset */ +}L1L2PuschPtrsInfo; + +typedef struct puschPtrs +{ + U8 numPorts; /* Number of UL PT-RS ports */ + L1L2PuschPtrsInfo ptrsInfo[MAX_UL_PTRS_PORTS]; + U8 timeDen; /* PT-RS time density */ + U8 freqDen; /* PT-RS frequency density */ + U8 ulPtrsPwr; /* PUSCH to PTRS power ratio per layer pere RE */ +}L1L2PuschPtrs; + +typedef struct dftsOfdm +{ + U8 lowPaprGrpNum; /* Group numer for low PAPR number generation */ + U16 lowPaprSeqNum; /* Low PAPR sequence number */ + U8 ulPtrsSamDen; /* Number of PTRS groups */ + U8 ulPtrsTimeDen; /* Number of samples per PTRS groups */ +}L1L2DftsOfdm; + +typedef struct hopInfo +{ + Bool freqHopFlag; /* Frequency hopping enabled for PUCCH resource */ + U16 secHopPrb; /* Index of first PRB after freq hopping */ + Bool grpHopFlag; /* Indicates group hopping enabled */ + Bool seqHopFlag; /* Indicates sequence hopping enabled */ + U16 hopId; /* Scrambling Id for group and sequence hopping */ + U16 initCyclShft; /* Initial cyclic shift used for frequency hopping */ +}L1L2HopInfo; + +typedef struct pdcchPdu +{ + L1L2Bwp bwp; /* Bandwidth part info */ + L1L2Coreset coreset; /* core set info */ + U16 numDlDci; /* Number of DCI in this core set */ + L1L2DlDci dlDci[MAC_DCI_PER_SLOT]; /* DL DCI for each numDlDci */ +}L1L2PdcchPdu; + +typedef struct pdschPdu +{ + U16 pduBitmap; /* Indicates presence of optional pdus */ + U16 rnti; /* UE RNTI */ + U16 pduIdx; /* PDU index for each PDSCH PDU sent */ + L1L2Bwp bwp; /* Bandwidth part info */ + L1L2CodeWrd codeWrd; /* Code word info */ + U16 scrambleId; /* Data scrambling identity */ + U8 numLayer; /* Number of layers */ + U8 txSch; /* Transmission scheme */ + U8 refPnt; /* Reference point */ + L1L2Dmrs dmrs; + L1L2ResAllocFreqDom resFreqDom; /* PDSCH allocation in frequency domain */ + L1L2ResAllocTimeDom resTimeDom; /* PDSCH allocation in time domain */ + L1L2Ptrs ptrs; + L1L2PrecodBeamfrmPdu precodBeamfrmPdu; /* Precoding and Beamforming Info */ + L1L2TxPwrInfo txPwrInfo; /* Transmission power info */ + L1L2Cbg cbgFields; +}L1L2PdschPdu; + +typedef struct csiRsPdu +{ + L1L2Bwp bwp; /* Bandwidth part info */ + U16 startRb; /* PRB where this CSI resource starts */ + U16 nrOfRb; /* Num of PRBs across which CSI resource spans */ + U8 csiType; /* CSI type */ + U8 row; /* Row entry into CSI resource location table */ + U16 freqDom; /* Bitmap definin frequency domain allocation */ + U8 symbL0; /* Time domain location l0 and first OFDM symbol in time domain */ + U8 symbL1; /* Time domain location l1 and first OFDM symbol in time domain */ + U8 cdmType; /* CDM type */ + U8 freqDens; /* Frequency desnity */ + U16 scrambleId; /* Scrambling Id of CSI-RS */ + L1L2TxPwrInfo txPwrInfo; /* Transmission power info */ + L1L2PrecodBeamfrmPdu precodBeamfrmPdu; /* Precoding and Beamforming Info */ +}L1L2CsiRsPdu; + +typedef struct ssbPdu +{ + U16 phyCellId; /* Physical cell id */ + U8 betaPss; /* PSS EPRE to SSS EPRE in a SS/PBCH block */ + U8 ssbBlkIdx; /* SS/PBCH block index within a SSB burst set */ + U8 ssbSubcOff; /* SSB subcarrier offset */ + U16 ssbOffPointA; /* Offset of lower subcarrier of lowest RB */ + U8 bchPayldFlag; /* Indicates how BCH payload is generated */ + L1L2BchPayld bchPayld; /* BCH payload */ + L1L2PrecodBeamfrmPdu precodBeamfrmPdu; /* Precoding and Beamforming Info */ +}L1L2SsbPdu; + +typedef struct prachPdu +{ + U16 phyCellId; /* Physical cell id */ + U8 numPrachOcas; /* Number of time-domain PRACH occassions */ + U8 prachform; /* RACH format occassion for current FD occassion */ + U8 numRa; /* Frequency domain occassion index */ + U8 startSymb; /* Start symbol for first PRACH TD occassion */ + U16 numCs; /* Zero correlation zone config number */ + L1L2RxBeamFrmPdu beamfrmPdu; /* Rx Beamforming pdu */ +}L1L2PrachPdu; + +typedef struct puschPdu +{ + U16 pduBitmap; /* Indicates optional pdu */ + U16 rnti; /* UE RNTI */ + U32 handle; /* handling returned in Rx data ind or uci ind */ + L1L2Bwp bwp; /* Bandwidth part info */ + L1L2PuschMandInfo mandInfo; /* PUSCH info always included */ + L1L2Dmrs dmrs; /* DMRS info */ + L1L2PuschAllocFreqDom resFreqDom; /* PUSCH allocation in frequency domain */ + L1L2ResAllocTimeDom resTimeDom; /* Resource allocation in time domain */ + //Optional Data depending on pduBitMap + L1L2PuschData puschData; + L1L2PuschUci puschUci; + L1L2PuschPtrs puschPtrs; + L1L2DftsOfdm dftsOfdm; + L1L2RxBeamFrmPdu beamfrmPdu; /* Rx Beamforming pdu */ +}L1L2PuschPdu; + +typedef struct pucchPdu +{ + U16 rnti; /* UE RNTI */ + U32 handle; /* handling returned in uci ind */ + L1L2Bwp bwp; /* Bandwidth part info */ + U8 formType; /* PUCCH format type */ + U8 multSlotTxInd; /* Flush/keep/combine buffer for multi-slot Tx */ + Bool pi2Bpsk; /* Indicates if UE used ppi/2 BPSK instead of QPSK */ + U16 prbStart; /* Starting PRB within BWP for this PUCCH */ + U16 prbSize; /* Number of pRBs within PUCCH */ + L1L2ResAllocTimeDom resTimeDom; /* Resource allocation in time domain */ + L1L2HopInfo hopInfo; /* Hopping information */ + U16 scrambleId; /* Data scrambling Id */ + U8 timeDomOccId; /* Index of orthogonal cover code */ + U8 preDftOccId; /* Index of orthogonal cover code */ + U8 preDftOccLen; /* Length of an orthogonal cover code */ + Bool addDmrsFlag; /* Additional DMRS enabled flag */ + U16 dmrsScrambleId; /* DMRS scrambling id */ + U8 dmrsCyclShft; /* Cyclic shift index for DMRS */ + Bool srFlag; /* Indicates SR opportunity in UCI */ + U8 bitLenHarq; /* Bit length of HARQ payload */ + U16 bitLenCsi1; /* Bit length of CSI part 1 payload */ + U16 bitLenCsi2; /* Bit length of CSI part 2 patload */ + L1L2RxBeamFrmPdu beamfrmPdu; /* Rx Beamforming pdu */ +}L1L2PucchPdu; + +typedef struct srsPdu +{ + U16 rnti; /* UE RNTI */ + U32 handle; /* Handling returned in SRS indication */ + L1L2Bwp bwp; /* Bandwidth part info */ + U8 numAntPort; /* Number of Antenna ports */ + U8 numSymb; /* Number of Symbols */ + U8 numRep; /* Repetition factor */ + U8 timeStartPos; /* Starting position in time domain */ + U8 cfgIdx; /* SRS bandwidth config index */ + U16 seqId; /* SRS sequence Id */ + U8 bwIdx; /* SRS bandwidth index */ + U8 combSize; /* Transmission comb size */ + U8 combOff; /* Transmission comb offset */ + U8 cyclShft; /* Cyclic shift */ + U8 freqPos; /* Frequency domain position */ + U8 freqShft; /* Frequency domain shift */ + U8 freqHop; /* Frequency hopping */ + U8 grpSeqHop; /* Group or sequence hopping configuration */ + U8 resType; /* Type of SRS resource allocation */ + U16 tsrs; /* SRS periodicity in slot */ + U16 tOffset; /* Slot offset value */ + L1L2RxBeamFrmPdu beamfrmPdu; /* Rx Beamforming pdu */ +}L1L2SrsPdu; + +typedef struct dlPduInfo +{ + U16 pduType; + U16 pduSize; + union + { + L1L2PdcchPdu pdcchPdu; + L1L2PdschPdu pdschPdu; + L1L2CsiRsPdu csiRsPdu; + L1L2SsbPdu ssbPdu; + }pduCfg; +}L1L2DlPduInfo; + +typedef struct ulPduInfo +{ + U16 pduType; + U16 pduSize; + union + { + L1L2PrachPdu prachPdu; + L1L2PuschPdu puschPdu; + L1L2PucchPdu pucchPdu; + L1L2SrsPdu srsPdu; + }pduCfg; +}L1L2UlPduInfo; + +typedef struct dlUeGrpInfo +{ + U8 nUe; /* Number of UEs in group */ + U8 pduIdx[MAX_UE_PER_GRP_DL]; /* Index for no. of PDU identified by nPDU in DL msg */ +}L1L2DlUeGrpInfo; + +typedef struct ulUeGrpInfo +{ + U8 nUe; /* Number of UEs in group */ + U8 pduIdx[MAX_UE_PER_GRP_UL]; /* Index for no. of PDU identified by nPDU in UL msg */ +}L1L2UlUeGrpInfo; + +typedef struct crcInfo +{ + PduInfo pduInfo; + U8 harqId; /* HARQ proc id */ + U8 tbCrcSta; /* Indicates CRC status on TB data */ + U16 numCb; /* Number of CBs in TB */ + U8 cbCrcSta[]; /* CRC status on Cb data */ //TBD : Array size +}L1L2CrcInfo; + +typedef struct repSymbInfo +{ + U16 numRb; /* Number of PRBs to be reported */ + U8 rbSnr[MAX_NUM_PRB]; /* SNR value in db for each Rb */ +}L1L2RepSymbInfo; + +typedef struct srsIndPdu +{ + U32 handle; /* Handle sent in UL TTI request SRS PDU */ + U16 rnti; /* RNTI sent in UL TTI request SRS PDU */ + U16 timeAdv; /* Timing advance measured for UE */ + U8 numSymb; /* Number of symbols for SRS */ + U8 wideBandSnr; /* SNR value measured within configured SRS bandwith */ + U8 numRepSymb; /* Number of symbols reported */ + L1L2RepSymbInfo repSymbInfo[MAX_REPORT_SYMB]; /* Reported symbol info */ +}L1L2SrsIndPdu; + +typedef struct prmblInfo +{ + U8 prmblIdx; /* Preamble index */ + U16 timeAdv; /* Timing advance PRACH */ + U32 prmblPwr; /* Received power */ +}L1L2PrmblInfo; + +typedef struct rachIndPdu +{ + U16 phyCellId; /* Physical cell id */ + U8 symbIdx; /* symbol index */ + U8 slotIdx; /* Slot index */ + U8 freqIdx; /* Frequency index */ + U8 avgRssi; /* Average value of RSSI */ + U8 avgSnr; /* Average value of SNR */ + U8 nmbPrmbl; /* Number of detected preambles in PRACH occassion */ + L1L2PrmblInfo prmblInfo[MAX_NUM_PRMBL]; /* List of premable info */ +}L1L2RachIndPdu; + +typedef struct srInfoFrmt01 +{ + Bool srInd; /* Indicates if SR detected */ + U8 srConfLvl; /* Confidence level of detected SR */ +}L1L2SrInfoFrmt01; + +typedef struct srInfoFrmt234 +{ + U16 bitLen; /* Length of SR payload */ + U8 payload; /* Contents of SR */ +}L1L2SrInfoFrmt234; + +typedef struct harqInfoFrmt01 +{ + U8 numHarq; /* Number of HARQ bits in UCI */ + U8 confLvl; /* Confidence level of detected HARQ */ + U8 value[2]; /* Indicates result on HARQ data */ +}L1L2HarqInfoFrmt01; + +typedef struct csiharqInfoFrmt234 +{ + U8 crc; /* CRC result in CSI/HARQ data */ + U16 bitLen; /* Length of CSI/HARQ payload */ + U8 payload[MAX_HARQ_SIZE]; /* CSI/HARQ pdu for format 2, 3 and 4 */ +}L1L2CsiHarqInfoFrmt234; + +typedef struct uciPduInfo +{ + U8 pduBitmap; /* Indicates presence of optional pdu */ + PduInfo pduInfo; /* Commom PDU info */ + L1L2CsiHarqInfoFrmt234 harqInfo; /* HARQ info */ + L1L2CsiHarqInfoFrmt234 csi1Info; /* CSI Part 1 info */ + L1L2CsiHarqInfoFrmt234 csi2Info; /* CSI Part 2 info */ +}L1L2UciPduInfo; + +typedef struct uciPucchFrmt234Pdu +{ + L1L2UciPduInfo uciPucchPduInfo; + U8 pucchFrmt; /* PUCCH format */ + L1L2SrInfoFrmt234 srInfo; /* SR PDU for format 2, 3 and 4 */ +}L1L2UciPucchFrmt234Pdu; + +typedef struct uciPucchFrmt01Pdu +{ + U8 pduBitmap; /* Indicates presence of optional pdu */ + PduInfo pduInfo; /* Commom PDU info */ + U8 pucchFrmt; /* PUCCH format */ + L1L2SrInfoFrmt01 srInfo; /* SR PDU for format 0 and 1 */ + L1L2HarqInfoFrmt01 harqInfo; /* HARQ PDU for format 0 and 1 */ +}L1L2UciPucchFrmt01Pdu; + +typedef struct uciIndPdu +{ + U16 pduType; /* UCI indication type pdu */ + U16 pduSize; /* Size of pdu information */ + union + { + L1L2UciPduInfo uciPuschPdu; /* UCI indication PDU carried on PUSCH */ + L1L2UciPucchFrmt01Pdu uciPucchFrmt01Pdu; /* UCI indication PDU carried on PUCCH format 0 or 1*/ + L1L2UciPucchFrmt234Pdu uciPucchFrmt234Pdu; /* UCI indication PDU carried on PUCCH format 2 or 3 or 4 */ + }uciPdu; +}L1L2UciIndPdu; + +typedef struct rxDatIndPdu +{ + PduInfo pduInfo; /* Commom PDU info */ + U8 harqId; /* HARQ Process id */ + U16 pduLen; /* Length of Pdu */ + U32 *macPdu; /* Contents of MAC pdu */ //TBU:data type +}L1L2RxDatIndPdu; + +typedef struct txDatReqPdu +{ + U16 pduLen; /* PDU length */ + U16 pduIdx; /* Correlates MAC PDU with DL_TTI PDSCH PDU */ + U32 nTlv; /* number of TLVs in TB */ + L1L2Tlv *tlvLst; /* list of TLVs */ //TBD:value of MAX_TLV +}L1L2TxDatReqPdu; + +typedef struct paramReq +{ + MsgHdr hdr; +/* No message body is defined as per FAPI doc */ +}L1L2ParamReq; + +typedef struct paramRsp +{ + MsgHdr hdr; /* Message Header */ + ErrorCode status; /* Error code */ + U8 nTlv; /* Number of TLVs in msg body */ + L1L2Tlv rspTlvLst[MAX_PARAM_TLV]; /* List of TLVs reported by PHY */ +}L1L2ParamRsp; + +typedef struct configReq +{ + MsgHdr hdr; /* Message header */ + U8 carrierId; /* Carrier Id */ + U8 nTlv; /* Number of TLVs in msg body */ + L1L2Tlv *configTlvLst; /* List of TLVs reported by PHY */ +}L1L2ConfigReq; + +typedef struct configRsp +{ + MsgHdr hdr; /* Message header */ + U8 carrierId; /* Carrier Id */ + ErrorCode status; /* Response status */ + U8 numUnsuppTlv; /* Number of invalid or unsupported TLVs */ + U8 numInvTlvForPhySta; /* Number of TLVs not valid in current PHY state */ + U8 numMissingTlv; /* Number of missing TLVs */ + L1L2Tlv *unsuppTlvLst; /* List of invalid or unsupported TLVs */ + L1L2Tlv *phyIdleCfgTlvLst; /* List of invalid TLV that can be configured only in PHY IDLE state */ + L1L2Tlv *phyRunCfgTlvLst; /* List of invalid TLV that can be configured only in PHY RUNNING state */ + L1L2Tlv *missingTlvLst; /* List of missing TLVs */ +}L1L2ConfigRsp; + +typedef struct startReq +{ + MsgHdr hdr; +/* No message body is defined as per FAPI doc */ +}L1L2StartReq; + +typedef struct stopReq +{ + MsgHdr hdr; +/* No message body is defined as per FAPI doc */ +}L1L2StopReq; + +typedef struct stopInd +{ + MsgHdr hdr; +/* No message body is defined as per FAPI doc */ +}L1L2StopInd; + +typedef struct errInd +{ + MsgHdr hdr; /* Message header */ + SfnSlotIE sfnSlot; /* SFN and slot info */ + U8 msgId; /* Indicates which msg received by PHY has error */ + ErrorCode err; /* Error code */ +}L1L2ErrInd; + +typedef struct slotInd +{ + MsgHdr hdr; /* Message header */ + SfnSlotIE sfnSlot; /* SFN and slot info */ +}L1L2SlotInd; + +typedef struct ttiReq +{ + MsgHdr hdr; /* Message header */ + SfnSlotIE sfnSlot; /* SFN and slot info */ + U8 nPdus; /* Number of PDUs in msg */ + U8 nUeGrps; /* Number of UE groups */ +}L1L2TtiReq; + +typedef struct dlTtiReq +{ + L1L2TtiReq ttiReqInfo; + L1L2DlPduInfo pduLst[MAX_NUM_PDU]; /* List of all PDUs in msg */ + L1L2DlUeGrpInfo ueGrpLst[MAX_UE_GRP_DL]; /* List of all UE groups in msg */ +}L1L2DlTtiReq; + +typedef struct ulTtiReq +{ + L1L2TtiReq ttiReqInfo; + Bool rachPres; /* Indicates if RACH PDU will be included in msg */ + U8 nUlschPdu; /* Number of ULSCH pdus in msg */ + U8 nUlcchPdu; /* Number of ULCCH pdus in msg */ + L1L2UlPduInfo pduLst[MAX_NUM_PDU]; /* List of all PDUs in msg */ + L1L2UlUeGrpInfo ueGrpLst[MAX_UE_GRP_UL]; /* List of all UE groups in msg */ +}L1L2UlTtiReq; + +typedef struct ulDciReq +{ + MsgHdr hdr; /* Message header */ + SfnSlotIE sfnSlot; /* SFN and slot info */ + U8 nPdus; /* Number of PDUs in msg */ + L1L2DlPduInfo pduLst[MAX_NUM_PDU]; /* List of PDCCH PDUs in msg */ +}L1L2UlDciReq; + +typedef struct crcInd +{ + MsgHdr hdr; /* Message header */ + SfnSlotIE sfnSlot; /* SFN and slot info */ + U16 numCrc; /* Number of CRCs in msg */ + L1L2CrcInfo crcInfo[MAX_UL_PDU_PER_SLOT]; //TBD : value of MAX_UL_PDU_PER_SLOT +}L1L2CrcInd; + +typedef struct srsInd +{ + MsgHdr hdr; /* Message header */ + SfnSlotIE sfnSlot; /* SFN and slot info */ + U8 nPdus; /* Number of PDUs in msg */ + L1L2SrsIndPdu srsIndPdu[MAX_NUM_PDU]; /* SRS indication PDU list */ +}L1L2SrsInd; + +typedef struct rachInd +{ + MsgHdr hdr; /* Message header */ + SfnSlotIE sfnSlot; /* SFN and slot info */ + U8 nPdus; /* Number of PDUs in msg */ + L1L2RachIndPdu rachIndPdu[MAX_NUM_PDU]; /* RACH indication PDU list */ +}L1L2RachInd; + +typedef struct uciInd +{ + MsgHdr hdr; /* Message header */ + SfnSlotIE sfnSlot; /* SFN and slot info */ + U16 numUci; /* Number of UCIs in msg */ + L1L2UciIndPdu uciIndPdu[MAX_UCI_PER_SLOT]; //TBD : value of MAX_UCI_PER_SLOT +}L1L2UciInd; + +typedef struct rxDatInd +{ + MsgHdr hdr; /* Message header */ + SfnSlotIE sfnSlot; /* SFN and slot info */ + U8 nPdus; /* Number of PDUs in msg */ + L1L2RxDatIndPdu rxDatPdu[MAX_UL_PDU_PER_SLOT]; //TBD: value of MAX_UL_PDU_PER_SLOT +}L1L2RxDatInd; + +typedef struct txDatReq +{ + MsgHdr hdr; /* Message header */ + SfnSlotIE sfnSlot; /* SFN and slot info */ + U8 nPdus; /* Number of PDUs in msg */ + L1L2TxDatReqPdu txDatPdu[MAX_DL_PDU_PER_SLOT]; //TBD: value of MAX_DL_PDU_PER_SLOT +}L1L2TxDatReq; + +#endif + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/cm/rgm.c b/src/cm/rgm.c new file mode 100755 index 000000000..4e9e42d81 --- /dev/null +++ b/src/cm/rgm.c @@ -0,0 +1,1487 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + + +/************************************************************************ + + Name: LTE-MAC layer + + Type: C source file + + Desc: C source code for packing/unpacking of RGM interface + primitives. + + File: rgm.c + +**********************************************************************/ + +/** @file rgm.c +@brief This file contains the packing/unpacking code for the RGM interface + primitives. +*/ + +/* header include files (.h) */ +#include "envopt.h" /* environment options */ +#include "envdep.h" /* environment dependent */ +#include "envind.h" /* environment independent */ +#include "gen.h" /* general */ +#include "ssi.h" /* system services */ +#include "cm_tkns.h" /* Common Token Defines */ +#include "cm_llist.h" /* Common Link List Defines */ +#include "cm_hash.h" /* Common Hash List Defines */ +#include "cm_lte.h" /* Common LTE Defines */ +#include "rgm.h" /* RGM Interface defines */ + +/* header/extern include files (.x) */ +#include "gen.x" /* general */ +#include "ssi.x" /* system services */ +#include "cm_tkns.x" /* Common Token Definitions */ +#include "cm_llist.x" /* Common Link List Definitions */ +#include "cm_lib.x" /* Common Library Definitions */ +#include "cm_hash.x" /* Common Hash List Definitions */ +#include "cm_lte.x" /* Common LTE Defines */ +#include "rgm.x" /* RGM Interface includes */ + +#ifdef RGM_LWLC + + +/** +* @brief Request from RRM to MAC to bind the interface saps +* +* @details +* +* Function : cmPkLwLcRgmBndReq +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] SpId spId +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkLwLcRgmBndReq +( +Pst* pst, +SuId suId, +SpId spId +) +#else +PUBLIC S16 cmPkLwLcRgmBndReq(pst, suId, spId) +Pst* pst; +SuId suId; +SpId spId; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkLwLcRgmBndReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) + { + RETVALUE(RFAILED); + } + + if (SPkS16(spId, mBuf) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (SPkS16(suId, mBuf) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + pst->event = (Event) EVTRGMBNDREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief Request from RRM to MAC to bind the interface saps +* +* @details +* +* Function : cmUnpkLwLcRgmBndReq +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] SpId spId +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkLwLcRgmBndReq +( +RgmBndReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkLwLcRgmBndReq(func, pst, mBuf) +RgmBndReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + SpId spId; + S16 ret; + + TRC3(cmUnpkLwLcRgmBndReq) + + if (SUnpkS16(&suId, mBuf) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (SUnpkS16(&spId, mBuf) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + ret = ((*func)(pst, suId, spId)); + + SPutMsg(mBuf); + + RETVALUE(ret); +} + +/** +* @brief Request from RRM to MAC to Unbind the interface saps +* +* @details +* +* Function : cmPkLwLcRgmUbndReq +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] Reason reason +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkLwLcRgmUbndReq +( +Pst* pst, +SpId spId, +Reason reason +) +#else +PUBLIC S16 cmPkLwLcRgmUbndReq(pst, spId, reason) +Pst* pst; +SpId spId; +Reason reason; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkLwLcRgmUbndReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) + { + RETVALUE(RFAILED); + } + if (SPkS16(reason, mBuf) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(spId, mBuf) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + pst->event = (Event) EVTRGMUBNDREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + +#if 0 + +/** +* @brief Request from RRM to MAC to Unbind the interface saps +* +* @details +* +* Function : cmUnpkLwLcRgmUbndReq +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] Reason reason +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkLwLcRgmUbndReq +( +RgmUbndReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkLwLcRgmUbndReq(func, pst, mBuf) +RgmUbndReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SpId spId; + Reason reason; + + TRC3(cmUnpkLwLcRgmUbndReq) + + if (SUnpkS16(&spId, mBuf) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SUnpkS16(&reason, mBuf) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, spId, reason)); +} +#endif + +/** +* @brief Confirmation from MAC to RRM for the bind/Unbind + * request for the interface saps +* +* @details +* +* Function : cmPkLwLcRgmBndCfm +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] U8 status +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkLwLcRgmBndCfm +( +Pst* pst, +SuId suId, +U8 status +) +#else +PUBLIC S16 cmPkLwLcRgmBndCfm(pst, suId, status) +Pst* pst; +SuId suId; +U8 status; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkLwLcRgmBndCfm) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) + { + RETVALUE(RFAILED); + } + + if (SPkS16(suId, mBuf) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (SPkU8(status, mBuf) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + pst->event = (Event) EVTRGMBNDCFM; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief Confirmation from MAC to RRM for the bind/Unbind + * request for the interface saps +* +* @details +* +* Function : cmUnpkLwLcRgmBndCfm +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] U8 status +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkLwLcRgmBndCfm +( +RgmBndCfm func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkLwLcRgmBndCfm(func, pst, mBuf) +RgmBndCfm func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + U8 status; + + TRC3(cmUnpkLwLcRgmBndCfm) + + if (SUnpkU8(&status, mBuf) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (SUnpkS16(&suId, mBuf) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, suId, status)); +} + + +/** +* @brief Configure the PRB Report Preparation Start/Stop from RRM to MAC +* +* @details +* +* Function : cmPkLwLcRgmCfgPrbRprt +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] RgmPrbRprtCfg * prbRprtCfg +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkLwLcRgmCfgPrbRprt +( +Pst* pst, +SpId spId, +RgmPrbRprtCfg * prbRprtCfg +) +#else +PUBLIC S16 cmPkLwLcRgmCfgPrbRprt(pst, spId, prbRprtCfg) +Pst* pst; +SpId spId; +RgmPrbRprtCfg * prbRprtCfg; +#endif +{ + Buffer *mBuf = NULLP; + U32 len = sizeof(RgmPrbRprtCfg); + TRC3(cmPkLwLcRgmCfgPrbRprt) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) + { + SPutSBuf(pst->region, pst->pool, (Data *)prbRprtCfg, sizeof(RgmPrbRprtCfg)); + RETVALUE(RFAILED); + } + + if(cmPkPtr((PTR)prbRprtCfg, mBuf) != ROK) + { + SPutMsg(mBuf); + SPutSBuf(pst->region, pst->pool, (Data*)prbRprtCfg, len); + RETVALUE(RFAILED); + } + + if (SPkS16(spId, mBuf) != ROK) + { + SPutSBuf(pst->region, pst->pool, (Data *)prbRprtCfg, sizeof(RgmPrbRprtCfg)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + pst->event = (Event) EVTRGMCFGPRBRPRT; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief Configure the PRB Report Preparation Start/Stop from RRM to MAC +* +* @details +* +* Function : cmUnpkLwLcRgmCfgPrbRprt +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] RgmPrbRprtCfg * prbRprtCfg +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkLwLcRgmCfgPrbRprt +( +RgmCfgPrbRprtFptr func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkLwLcRgmCfgPrbRprt(func, pst, mBuf) +RgmCfgPrbRprtFptr func; +Pst *pst; +Buffer *mBuf; +#endif +{ + S16 ret; + SpId spId; + RgmPrbRprtCfg *prbRprtCfg; + + TRC3(cmUnpkLwLcRgmCfgPrbRprt) + + if (SUnpkS16(&spId, mBuf) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (cmUnpkPtr((PTR *)&prbRprtCfg, mBuf) != ROK) + { + SPutMsg(mBuf); + SPutSBuf(pst->region, pst->pool, (Data *)prbRprtCfg, sizeof(RgmPrbRprtCfg)); + RETVALUE(RFAILED); + } + + ret = ((*func)(pst, spId, prbRprtCfg)); + + SPutMsg(mBuf); + RETVALUE(ret); +} + + +/** +* @brief PRB Usage Report Indication from MAC to RRM +* +* @details +* +* Function : cmPkLwLcRgmPrbRprtInd +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] RgmPrbRprtInd * prbRprtInd +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkLwLcRgmPrbRprtInd +( +Pst* pst, +SuId suId, +RgmPrbRprtInd * prbRprtInd +) +#else +PUBLIC S16 cmPkLwLcRgmPrbRprtInd(pst, suId, prbRprtInd) +Pst* pst; +SuId suId; +RgmPrbRprtInd * prbRprtInd; +#endif +{ + Buffer *mBuf = NULLP; + + TRC3(cmPkLwLcRgmPrbRprtInd) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { + SPutSBuf(pst->region, pst->pool, (Data *)prbRprtInd, sizeof(RgmPrbRprtInd)); + RETVALUE(RFAILED); + } + + if(cmPkPtr((PTR)prbRprtInd, mBuf) != ROK) + { + SPutSBuf(pst->region, pst->pool, (Data *)prbRprtInd, sizeof(RgmPrbRprtInd)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (SPkS16(suId, mBuf) != ROK) + { + SPutSBuf(pst->region, pst->pool, (Data *)prbRprtInd, sizeof(RgmPrbRprtInd)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + pst->event = (Event) EVTRGMCFGPRBRPRT; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief PRB Usage Report Indication from MAC to RRM +* +* @details +* +* Function : cmUnpkLwLcRgmPrbRprtInd +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] RgmPrbRprtInd * prbRprtInd +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkLwLcRgmPrbRprtInd +( +RgmPrbRprtIndFptr func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkLwLcRgmPrbRprtInd(func, pst, mBuf) +RgmPrbRprtIndFptr func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + RgmPrbRprtInd *prbRprtInd; + S16 ret; + + TRC3(cmUnpkLwLcRgmPrbRprtInd) + + if (SUnpkS16(&suId, mBuf) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (cmUnpkPtr((PTR *)&prbRprtInd, mBuf) != ROK) + { + SPutMsg(mBuf); + SPutSBuf(pst->region, pst->pool, (Data *)prbRprtInd, sizeof(RgmPrbRprtInd)); + RETVALUE(RFAILED); + } + + + ret = ((*func)(pst, suId, prbRprtInd)); + + SPutMsg(mBuf); + + RETVALUE(ret); +} +#endif + + +/** +* @brief Request from RRM to MAC to bind the interface saps +* +* @details +* +* Function : cmPkRgmBndReq +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] SpId spId +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkRgmBndReq +( +Pst* pst, +SuId suId, +SpId spId +) +#else +PUBLIC S16 cmPkRgmBndReq(pst, suId, spId) +Pst* pst; +SuId suId; +SpId spId; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkRgmBndReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) + { + RETVALUE(RFAILED); + } + + if (SPkS16(spId, mBuf) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (SPkS16(suId, mBuf) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + pst->event = (Event) EVTRGMBNDREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief Request from RRM to MAC to bind the interface saps +* +* @details +* +* Function : cmUnpkRgmBndReq +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] SpId spId +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgmBndReq +( +RgmBndReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgmBndReq(func, pst, mBuf) +RgmBndReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + SpId spId; + S16 ret; + + TRC3(cmUnpkRgmBndReq) + + if (SUnpkS16(&suId, mBuf) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (SUnpkS16(&spId, mBuf) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + ret = ((*func)(pst, suId, spId)); + + SPutMsg(mBuf); + + RETVALUE(ret); +} + +/** +* @brief Request from RRM to MAC to Unbind the interface saps +* +* @details +* +* Function : cmPkRgmUbndReq +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] Reason reason +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkRgmUbndReq +( +Pst* pst, +SpId spId, +Reason reason +) +#else +PUBLIC S16 cmPkRgmUbndReq(pst, spId, reason) +Pst* pst; +SpId spId; +Reason reason; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkRgmUbndReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) + { + RETVALUE(RFAILED); + } + if (SPkS16(reason, mBuf) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(spId, mBuf) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + pst->event = (Event) EVTRGMUBNDREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + +#if 1 + +/** +* @brief Request from RRM to MAC to Unbind the interface saps +* +* @details +* +* Function : cmUnpkRgmUbndReq +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] Reason reason +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgmUbndReq +( +RgmUbndReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgmUbndReq(func, pst, mBuf) +RgmUbndReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SpId spId; + Reason reason; + + TRC3(cmUnpkRgmUbndReq) + + if (SUnpkS16(&spId, mBuf) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SUnpkS16(&reason, mBuf) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, spId, reason)); +} +#endif + +/** +* @brief Confirmation from MAC to RRM for the bind/Unbind + * request for the interface saps +* +* @details +* +* Function : cmPkRgmBndCfm +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] U8 status +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkRgmBndCfm +( +Pst* pst, +SuId suId, +U8 status +) +#else +PUBLIC S16 cmPkRgmBndCfm(pst, suId, status) +Pst* pst; +SuId suId; +U8 status; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkRgmBndCfm) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) + { + RETVALUE(RFAILED); + } + + if (SPkS16(suId, mBuf) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (SPkU8(status, mBuf) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + pst->event = (Event) EVTRGMBNDCFM; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief Confirmation from MAC to RRM for the bind/Unbind + * request for the interface saps +* +* @details +* +* Function : cmUnpkRgmBndCfm +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] U8 status +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgmBndCfm +( +RgmBndCfm func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgmBndCfm(func, pst, mBuf) +RgmBndCfm func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + U8 status; + + TRC3(cmUnpkRgmBndCfm) + + if (SUnpkU8(&status, mBuf) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (SUnpkS16(&suId, mBuf) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, suId, status)); +} + + + + +/** +* @brief Configure the PRB Report Preparation Start/Stop from RRM to MAC +* +* @details +* +* Function : cmPkCfgPrbRprt +* +* @param[in] RgmPrbRprtCfg *prbRprtCfg +* @param[in] Buffer *mBuf +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkCfgPrbRprt +( +RgmPrbRprtCfg * prbRprtCfg, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkCfgPrbRprt(prbRprtCfg, mBuf) +RgmPrbRprtCfg * prbRprtCfg; +Buffer *mBuf; +#endif +{ + TRC3(cmPkCfgPrbRprt); + CMCHKPK(SPkU16, prbRprtCfg->usPrbAvgPeriodicty, mBuf); + CMCHKPK(SPkU8, prbRprtCfg->bConfigType, mBuf); + CMCHKPK(SPkU8, prbRprtCfg->bCellId, mBuf); + RETVALUE(ROK); +} +/** +* @brief Configure the PRB Report Preparation Start/Stop from RRM to MAC +* +* @details +* +* Function : cmUnPkCfgPrbRprt +* +* @param[in] RgmPrbRprtCfg *prbRprtCfg +* @param[in] Buffer *mBuf +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnPkCfgPrbRprt +( +RgmPrbRprtCfg * prbRprtCfg, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnPkCfgPrbRprt(prbRprtCfg, mBuf) +RgmPrbRprtCfg * prbRprtCfg; +Buffer *mBuf; +#endif +{ + TRC3(cmUnPkCfgPrbRprt); + CMCHKUNPK(SUnpkU8, &prbRprtCfg->bCellId, mBuf); + CMCHKUNPK(SUnpkU8, &prbRprtCfg->bConfigType, mBuf); + CMCHKUNPK(SUnpkU16, &prbRprtCfg->usPrbAvgPeriodicty, mBuf); + RETVALUE(ROK); +} + + + + +/** +* @brief Configure the PRB Report Preparation Start/Stop from RRM to MAC +* +* @details +* +* Function : cmPkRgmCfgPrbRprt +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] RgmPrbRprtCfg *prbRprtCfg +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkRgmCfgPrbRprt +( +Pst* pst, +SpId spId, +RgmPrbRprtCfg * prbRprtCfg +) +#else +PUBLIC S16 cmPkRgmCfgPrbRprt(pst, spId, prbRprtCfg) +Pst* pst; +SpId spId; +RgmPrbRprtCfg * prbRprtCfg; +#endif +{ + Buffer *mBuf = NULLP; + U32 len = sizeof(RgmPrbRprtCfg); + TRC3(cmPkRgmCfgPrbRprt) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) + { + SPutSBuf(pst->region, pst->pool, (Data *)prbRprtCfg, sizeof(RgmPrbRprtCfg)); + RETVALUE(RFAILED); + } + + if(cmPkCfgPrbRprt(prbRprtCfg, mBuf) != ROK) + { + SPutMsg(mBuf); + SPutSBuf(pst->region, pst->pool, (Data*)prbRprtCfg, len); + RETVALUE(RFAILED); + } + + if (SPkS16(spId, mBuf) != ROK) + { + SPutSBuf(pst->region, pst->pool, (Data *)prbRprtCfg, sizeof(RgmPrbRprtCfg)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + SPutSBuf(pst->region, pst->pool, (Data *)prbRprtCfg, sizeof(RgmPrbRprtCfg)); + + pst->event = (Event) EVTRGMCFGPRBRPRT; + RETVALUE(SPstTsk(pst,mBuf)); +} + + + +/** +* @brief Configure the PRB Report Preparation Start/Stop from RRM to MAC +* +* @details +* +* Function : cmUnpkRgmCfgPrbRprt +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] RgmPrbRprtCfg * prbRprtCfg +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgmCfgPrbRprt +( +RgmCfgPrbRprtFptr func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgmCfgPrbRprt(func, pst, mBuf) +RgmCfgPrbRprtFptr func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SpId spId; + RgmPrbRprtCfg *prbRprtCfg; + + TRC3(cmUnpkRgmCfgPrbRprt) + if ((SGetSBuf(pst->region, pst->pool, (Data **)&prbRprtCfg, sizeof(RgmPrbRprtCfg))) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (SUnpkS16(&spId, mBuf) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (cmUnPkCfgPrbRprt(prbRprtCfg, mBuf) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + SPutMsg(mBuf); + RETVALUE((*func)(pst, spId, prbRprtCfg)); +} + +/* RRM_SP1_START */ +/** +* @brief Packing of PRB Usage Report for qci for sending +* to RRM from MAC +* +* @details +* +* Function : cmPkRgmPrbQciRpt +* +* @param[in] RgmPrbRptPerQci * qciPrbRprt +* @param[out] Buffer *mBuf +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkRgmPrbQciRpt +( + RgmPrbRptPerQci *qciPrbRprt, + Buffer *mBuf + ) +#else +PUBLIC S16 cmPkRgmPrbQciRpt(qciPrbRprt, mBuf) +RgmPrbRptPerQci *qciPrbRprt; +Buffer *mBuf = NULLP; +#endif +{ + CMCHKPK(SPkU8, qciPrbRprt->bQci, mBuf); + CMCHKPK(SPkU8, qciPrbRprt->bAvgPrbUlUsage, mBuf); + CMCHKPK(SPkU8, qciPrbRprt->bAvgPrbDlUsage, mBuf); + + RETVALUE(ROK); +} + +/** +* @brief Unpacking of PRB Usage Report for qci received from MAC +* +* @details +* +* Function : cmUnpkRgmPrbQciRpt +* +* @param[out] RgmPrbRptPerQci * qciPrbRprt +* @param[in] Buffer *mBuf +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgmPrbQciRpt +( + RgmPrbRptPerQci *qciPrbRprt, + Buffer *mBuf + ) +#else +PUBLIC S16 cmUnpkRgmPrbQciRpt(qciPrbRprt, mBuf) +RgmPrbRptPerQci *qciPrbRprt; +Buffer *mBuf = NULLP; +#endif +{ + CMCHKUNPK(SUnpkU8, &qciPrbRprt->bAvgPrbDlUsage, mBuf); + CMCHKUNPK(SUnpkU8, &qciPrbRprt->bAvgPrbUlUsage, mBuf); + CMCHKUNPK(SUnpkU8, &qciPrbRprt->bQci, mBuf); + + RETVALUE(ROK); +} +/* RRM_SP1_END */ + +/** +* @brief PRB Usage Report Indication from MAC to RRM +* +* @details +* +* Function : cmPkPrbRprtInd +* +* @param[in] RgmPrbRprtInd * prbRprtInd +* @param[in] Buffer *mBuf +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkPrbRprtInd +( + RgmPrbRprtInd * prbRprtInd, + Buffer *mBuf + ) +#else +PUBLIC S16 cmPkPrbRprtInd(prbRprtInd, mBuf) + RgmPrbRprtInd * prbRprtInd; + Buffer *mBuf = NULLP; +#endif +{ + S32 idx = 0; + + TRC3(cmPkPrbRprtInd); + + /* RRM_SP1_START */ + for(idx = RGM_MAX_QCI_REPORTS-1; idx >= 0; idx--) + { + CMCHKPK(cmPkRgmPrbQciRpt, &prbRprtInd->stQciPrbRpts[idx], mBuf); + } + CMCHKPK(SPkU8, prbRprtInd->bPrbUsageMask, mBuf); + CMCHKPK(SPkU8, prbRprtInd->bCellId, mBuf); + /* RRM_SP1_END */ + RETVALUE(ROK); +} + +/** +* @brief PRB Usage Report Indication from MAC to RRM +* +* @details +* +* Function : cmUnpkPrbRprtInd +* +* @param[in] RgmPrbRprtInd * prbRprtInd +* @param[in] Buffer *mBuf +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkPrbRprtInd +( + RgmPrbRprtInd * prbRprtInd, + Buffer *mBuf + ) +#else +PUBLIC S16 cmUnpkPrbRprtInd(prbRprtInd, mBuf) + RgmPrbRprtInd * prbRprtInd; + Buffer *mBuf; +#endif +{ + U32 idx = 0; + + TRC3(cmUnpkPrbRprtInd); + + /* RRM_SP1_START */ + CMCHKUNPK(SUnpkU8, &prbRprtInd->bCellId, mBuf); + CMCHKUNPK(SUnpkU8, &prbRprtInd->bPrbUsageMask, mBuf); + for(idx = 0; idx < RGM_MAX_QCI_REPORTS; idx++) + { + CMCHKUNPK(cmUnpkRgmPrbQciRpt, &prbRprtInd->stQciPrbRpts[idx], mBuf); + } + + /* RRM_SP1_END */ + RETVALUE(ROK); +} + + + +/** +* @brief PRB Usage Report Indication from MAC to RRM +* +* @details +* +* Function : cmPkRgmPrbRprtInd +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] RgmPrbRprtInd * prbRprtInd +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkRgmPrbRprtInd +( +Pst* pst, +SuId suId, +RgmPrbRprtInd * prbRprtInd +) +#else +PUBLIC S16 cmPkRgmPrbRprtInd(pst, suId, prbRprtInd) +Pst* pst; +SuId suId; +RgmPrbRprtInd * prbRprtInd; +#endif +{ + Buffer *mBuf = NULLP; + + TRC3(cmPkRgmPrbRprtInd) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { + SPutSBuf(pst->region, pst->pool, (Data *)prbRprtInd, sizeof(RgmPrbRprtInd)); + RETVALUE(RFAILED); + } + + if(cmPkPrbRprtInd(prbRprtInd, mBuf) != ROK) + { + SPutSBuf(pst->region, pst->pool, (Data *)prbRprtInd, sizeof(RgmPrbRprtInd)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (SPkS16(suId, mBuf) != ROK) + { + SPutSBuf(pst->region, pst->pool, (Data *)prbRprtInd, sizeof(RgmPrbRprtInd)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + SPutSBuf(pst->region, pst->pool, (Data *)prbRprtInd, sizeof(RgmPrbRprtInd)); + + pst->event = (Event) EVTRGMPRBRPRTIND; + RETVALUE(SPstTsk(pst,mBuf)); +} +/** +* @brief PRB Usage Report Indication from MAC to RRM +* +* @details +* +* Function : cmUnpkRgmPrbRprtInd +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] RgmPrbRprtInd * prbRprtInd +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgmPrbRprtInd +( +RgmPrbRprtIndFptr func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgmPrbRprtInd(func, pst, mBuf) +RgmPrbRprtIndFptr func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + RgmPrbRprtInd prbRprtInd; + + TRC3(cmUnpkRgmPrbRprtInd) + + if (SUnpkS16(&suId, mBuf) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (cmUnpkPrbRprtInd(&prbRprtInd, mBuf) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + SPutMsg(mBuf); + RETVALUE((*func)(pst, suId, &prbRprtInd)); +} + +/** +* @brief Transmission Mode Change Indication from MAC to RRM +* +* @details +* +* Function : cmPkTransModeInd +* +* @param[in] RgmTransModeInd *transModeInd +* @param[in] Buffer *mBuf +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkTransModeInd +( + RgmTransModeInd *transModeInd, + Buffer *mBuf + ) +#else +PUBLIC S16 cmPkTransModeInd(transModeInd, mBuf) + RgmTransModeInd *transModeInd; + Buffer *mBuf; +#endif +{ + TRC3(cmPkTransModeInd); + CMCHKPK(SPkU32, transModeInd->eMode, mBuf); + CMCHKPK(SPkU16, transModeInd->usCrnti, mBuf); + CMCHKPK(SPkU8, transModeInd->bCellId, mBuf); + RETVALUE(ROK); +} + +/** +* @brief Transmission Mode Change Indication from MAC to RRM +* +* @details +* +* Function : cmUnpkTransModeInd +* +* @param[in] RgmTransModeInd *transModeInd +* @param[in] Buffer *mBuf +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkTransModeInd +( + RgmTransModeInd *transModeInd, + Buffer *mBuf + ) +#else +PUBLIC S16 cmUnpkTransModeInd(transModeInd, mBuf) + RgmTransModeInd *transModeInd; + Buffer *mBuf; +#endif +{ + U32 tmpModeEnum; + TRC3(cmUnpkTransModeInd); + CMCHKUNPK(SUnpkU8, &transModeInd->bCellId, mBuf); + CMCHKUNPK(SUnpkU16, &transModeInd->usCrnti, mBuf); + CMCHKUNPK(SUnpkU32, (U32 *)&tmpModeEnum, mBuf); + transModeInd->eMode = (RgmTxnMode)tmpModeEnum; + RETVALUE(ROK); +} +/** +* @brief Transmission Mode Change Indication from MAC to RRM +* +* @details +* +* Function : cmPkRgmTransModeInd +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] RgmTransModeInd *transModeInd +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkRgmTransModeInd +( +Pst* pst, +SuId suId, +RgmTransModeInd *transModeInd +) +#else +PUBLIC S16 cmPkRgmTransModeInd(pst, suId, transModeInd) +Pst* pst; +SuId suId; +RgmTransModeInd *transModeInd; +#endif +{ + Buffer *mBuf = NULLP; + + TRC3(cmPkRgmTransModeInd) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { + SPutSBuf(pst->region, pst->pool, (Data *)transModeInd, sizeof(RgmTransModeInd)); + RETVALUE(RFAILED); + } + + if(cmPkTransModeInd(transModeInd, mBuf) != ROK) + { + SPutSBuf(pst->region, pst->pool, (Data *)transModeInd, sizeof(RgmTransModeInd)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (SPkS16(suId, mBuf) != ROK) + { + SPutSBuf(pst->region, pst->pool, (Data *)transModeInd, sizeof(RgmTransModeInd)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + SPutSBuf(pst->region, pst->pool, (Data *)transModeInd, sizeof(RgmTransModeInd)); + + pst->event = (Event) EVTRGMTRANSMODEIND; + RETVALUE(SPstTsk(pst,mBuf)); +} +/** +* @brief Transmission Mode Change Indication from MAC to RRM +* +* @details +* +* Function : cmUnpkRgmTransModeInd +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] RgmTransModeInd *transModeInd +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgmTransModeInd +( +RgmTransModeIndFptr func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgmTransModeInd(func, pst, mBuf) +RgmTransModeIndFptr func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + RgmTransModeInd transModeInd; + + TRC3(cmUnpkRgmTransModeInd) + + if (SUnpkS16(&suId, mBuf) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (cmUnpkTransModeInd(&transModeInd, mBuf) != ROK) + { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + SPutMsg(mBuf); + RETVALUE((*func)(pst, suId, &transModeInd)); +} +/********************************************************************** + + End of file + +**********************************************************************/ diff --git a/src/cm/rgr.c b/src/cm/rgr.c new file mode 100755 index 000000000..b288a0c3e --- /dev/null +++ b/src/cm/rgr.c @@ -0,0 +1,12378 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + + +/************************************************************************ + + Name: LTE-MAC layer + + Type: C source file + + Desc: C source code for pack/unpack of RGR interface primitives. + + File: rgr.c + +**********************************************************************/ + +/** @file rgr.c +@brief This file contains the packing/unpacking code for the RGR interface + primitives. +*/ +/* header include files (.h) */ +#include "envopt.h" /* environment options */ +#include "envdep.h" /* environment dependent */ +#include "envind.h" /* environment independent */ +#include "gen.h" /* general */ +#include "ssi.h" /* system services */ +#include "cm_tkns.h" /* Common Token Defines */ +#include "cm_llist.h" /* Common Link List Defines */ +#include "cm_hash.h" /* Common Hash List Defines */ +#include "cm_lte.h" /* Common LTE Defines */ +/* LTE_ADV_FLAG_REMOVED_START */ +#include "cm_mblk.h" +/* LTE_ADV_FLAG_REMOVED_END */ +#include "rgr.h" /* RGR Interface defines */ + +/* header/extern include files (.x) */ +#include "gen.x" /* general */ +#include "ssi.x" /* system services */ +#include "cm_tkns.x" /* Common Token Definitions */ +#include "cm_llist.x" /* Common Link List Definitions */ +#include "cm_lib.x" /* Common Library Definitions */ +#include "cm_hash.x" /* Common Hash List Definitions */ +#include "cm_lte.x" /* Common LTE Defines */ +/* LTE_ADV_FLAG_REMOVED_START */ +#include "cm_mblk.x" +/* LTE_ADV_FLAG_REMOVED_END */ +#include "rgr.x" /* RGR Interface includes */ + +#if defined(LCRGR) + + +/*********************************************************** +* +* Func : cmPkRgrBndReq +* +* +* Desc : Request from RRM to MAC to bind the interface saps +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrBndReq +( +Pst* pst, +SuId suId, +SpId spId +) +#else +PUBLIC S16 cmPkRgrBndReq(pst, suId, spId) +Pst* pst; +SuId suId; +SpId spId; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkRgrBndReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR001, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR002, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR003, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + pst->event = (Event) EVTRGRBNDREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/*********************************************************** +* +* Func : cmUnpkRgrBndReq +* +* +* Desc : Request from RRM to MAC to bind the interface saps +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrBndReq +( +RgrBndReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrBndReq(func, pst, mBuf) +RgrBndReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + SpId spId; + + TRC3(cmUnpkRgrBndReq) + + if (SUnpkS16(&suId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR004, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SUnpkS16(&spId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR005, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, suId, spId)); +} + + +/*********************************************************** +* +* Func : cmPkRgrBndCfm +* +* +* Desc : Confirmation from MAC to RRM for the bind/Unbind + * request for the interface saps +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrBndCfm +( +Pst* pst, +SuId suId, +U8 status +) +#else +PUBLIC S16 cmPkRgrBndCfm(pst, suId, status) +Pst* pst; +SuId suId; +U8 status; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkRgrBndCfm) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR006, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SPkU8(status, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR007, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR008, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + pst->event = (Event) EVTRGRBNDCFM; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/*********************************************************** +* +* Func : cmUnpkRgrBndCfm +* +* +* Desc : Confirmation from MAC to RRM for the bind/Unbind + * request for the interface saps +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrBndCfm +( +RgrBndCfm func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrBndCfm(func, pst, mBuf) +RgrBndCfm func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + U8 status; + + TRC3(cmUnpkRgrBndCfm) + + if (SUnpkS16(&suId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR009, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SUnpkU8(&status, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR010, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, suId, status)); +} + + +/*********************************************************** +* +* Func : cmPkRgrUbndReq +* +* +* Desc : Request from RRM to MAC to Unbind the interface saps +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUbndReq +( +Pst* pst, +SpId spId, +Reason reason +) +#else +PUBLIC S16 cmPkRgrUbndReq(pst, spId, reason) +Pst* pst; +SpId spId; +Reason reason; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkRgrUbndReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR011, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SPkS16(reason, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR012, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR013, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + pst->event = (Event) EVTRGRUBNDREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/*********************************************************** +* +* Func : cmUnpkRgrUbndReq +* +* +* Desc : Request from RRM to MAC to Unbind the interface saps +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUbndReq +( +RgrUbndReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUbndReq(func, pst, mBuf) +RgrUbndReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SpId spId; + Reason reason; + + TRC3(cmUnpkRgrUbndReq) + + if (SUnpkS16(&spId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR014, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SUnpkS16(&reason, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR015, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, spId, reason)); +} + + +/*********************************************************** +* +* Func : cmPkRgrCfgReq +* +* +* Desc : Configuration Request from RRM to MAC for + * configuring Cell/Ue/Lc +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrCfgReq +( +Pst* pst, +SpId spId, +RgrCfgTransId transId, +RgrCfgReqInfo * cfgReqInfo +) +#else +PUBLIC S16 cmPkRgrCfgReq(pst, spId, transId, cfgReqInfo) +Pst* pst; +SpId spId; +RgrCfgTransId transId; +RgrCfgReqInfo * cfgReqInfo; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkRgrCfgReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR016, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo, sizeof(RgrCfgReqInfo)); + RETVALUE(RFAILED); + } + if (cmPkRgrCfgReqInfo(cfgReqInfo, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR017, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo, sizeof(RgrCfgReqInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (cmPkRgrCfgTransId(&transId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR018, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo, sizeof(RgrCfgReqInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR019, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo, sizeof(RgrCfgReqInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo, sizeof(RgrCfgReqInfo)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR020, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + pst->event = (Event) EVTRGRCFGREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/*********************************************************** +* +* Func : cmUnpkRgrCfgReq +* +* +* Desc : Configuration Request from RRM to MAC for + * configuring Cell/Ue/Lc +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrCfgReq +( +RgrCfgReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrCfgReq(func, pst, mBuf) +RgrCfgReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SpId spId; + RgrCfgTransId transId; + RgrCfgReqInfo *cfgReqInfo; + + TRC3(cmUnpkRgrCfgReq) + + if (SUnpkS16(&spId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR021, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (cmUnpkRgrCfgTransId(&transId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR022, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if ((SGetSBuf(pst->region, pst->pool, (Data **)&cfgReqInfo,sizeof(RgrCfgReqInfo))) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR023, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + cmMemset((U8 *)cfgReqInfo, 0, sizeof(RgrCfgReqInfo)); + if (pst->selector == RGR_SEL_LC) + if (cmUnpkRgrCfgReqInfo(cfgReqInfo, mBuf) != ROK) { + SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo, sizeof(RgrCfgReqInfo)); + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR024, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, spId, transId, cfgReqInfo)); +} + +/* rgr_c_001.main_3: Added TTI indication from MAC to RGR user */ + +/*********************************************************** +* +* Func : cmPkRgrTtiIndInfo +* +* +* Desc : Packs the TTI indication information. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrTtiIndInfo +( +RgrTtiIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrTtiIndInfo(param, mBuf) +RgrTtiIndInfo *param; +Buffer *mBuf; +#endif +{ + TRC3(cmPkRgrTtiInd) + CMCHKPK(SPkU16, param->sfn, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func : cmUnpkRgrTtiIndInfo +* +* +* Desc : Unpacking for RgrTtiIndInfo +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrTtiIndInfo +( +RgrTtiIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrTtiIndInfo(param, mBuf) +RgrTtiIndInfo *param; +Buffer *mBuf; +#endif +{ + TRC3(cmUnpkRgrTtiIndInfo) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->sfn, mBuf); + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func : cmPkRgrTtiInd +* +* +* Desc : TTI indication from MAC to RRM +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrTtiInd +( +Pst* pst, +SuId suId, +RgrTtiIndInfo *ttiInd +) +#else +PUBLIC S16 cmPkRgrTtiInd(pst, suId, ttiInd) +Pst* pst; +SuId suId; +RgrTtiIndInfo *ttiInd; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkRgrTtiInd) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR025, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (cmPkRgrTtiIndInfo(ttiInd, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR026, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)ttiInd, sizeof(RgrTtiIndInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR027, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)ttiInd, sizeof(RgrTtiIndInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + SPutSBuf(pst->region, pst->pool, (Data *)ttiInd, sizeof(RgrTtiIndInfo)); + pst->event = (Event) EVTRGRTTIIND; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/*********************************************************** +* +* Func : cmUnpkRgrTtiInd +* +* +* Desc : TTI indication from MAC to RRM +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrTtiInd +( +RgrTtiInd func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrTtiInd(func, pst, mBuf) +RgrTtiInd func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + RgrTtiIndInfo *ttiInd; + + TRC3(cmUnpkRgrTtiInd) + + if (SUnpkS16(&suId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR028, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if ((SGetSBuf(pst->region, pst->pool, (Data **)&ttiInd, sizeof(RgrTtiIndInfo))) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR029, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (cmUnpkRgrTtiIndInfo(ttiInd, mBuf) != ROK) { + /*ccpu00114888- Memory Leak issue- Start*/ + SPutSBuf(pst->region, pst->pool, (Data *)ttiInd, + sizeof(RgrTtiIndInfo)); + /*ccpu00114888- Memory Leak issue- End*/ + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR030, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, suId, ttiInd)); +} + + +/*********************************************************** +* +* Func : cmPkRgrCfgCfm +* +* +* Desc : Configuration Confirm from MAC to RRM +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrCfgCfm +( +Pst* pst, +SuId suId, +RgrCfgTransId transId, +U8 status +) +#else +PUBLIC S16 cmPkRgrCfgCfm(pst, suId, transId, status) +Pst* pst; +SuId suId; +RgrCfgTransId transId; +U8 status; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkRgrCfgCfm) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR031, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SPkU8(status, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR032, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (cmPkRgrCfgTransId(&transId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR033, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR034, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + pst->event = (Event) EVTRGRCFGCFM; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/*********************************************************** +* +* Func : cmUnpkRgrCfgCfm +* +* +* Desc : Configuration Confirm from MAC to RRM +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrCfgCfm +( +RgrCfgCfm func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrCfgCfm(func, pst, mBuf) +RgrCfgCfm func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + RgrCfgTransId transId; + U8 status; + + TRC3(cmUnpkRgrCfgCfm) + + if (SUnpkS16(&suId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR035, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (cmUnpkRgrCfgTransId(&transId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR036, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SUnpkU8(&status, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR037, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, suId, transId, status)); +} + +/* rgr_c_001.main_4: ADD-Added for SI Enhancement. */ +#ifdef RGR_SI_SCH +/*********************************************************** +* +* Func : cmPkRgrSiCfgCfm +* +* +* Desc : SI Configuration Confirm from MAC to RRM +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrSiCfgCfm +( +Pst* pst, +SuId suId, +RgrCfgTransId transId, +U8 status +) +#else +PUBLIC S16 cmPkRgrSiCfgCfm(pst, suId, transId, status) +Pst* pst; +SuId suId; +RgrCfgTransId transId; +U8 status; +#endif +{ + Buffer *mBuf = NULLP; + + TRC3(cmPkRgrSiCfgCfm) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR038, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SPkU8(status, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR039, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (cmPkRgrCfgTransId(&transId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR040, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR041, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + pst->event = (Event) EVTRGRSICFGCFM; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/*********************************************************** +* +* Func : cmUnpkRgrSiCfgCfm +* +* +* Desc : Configuration Confirm from MAC to RRM +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrSiCfgCfm +( +RgrSiCfgCfm func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrSiCfgCfm(func, pst, mBuf) +RgrSiCfgCfm func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + RgrCfgTransId transId; + U8 status; + + TRC3(cmUnpkRgrSiCfgCfm) + + if (SUnpkS16(&suId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR042, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (cmUnpkRgrCfgTransId(&transId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR043, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SUnpkU8(&status, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR044, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, suId, transId, status)); +} +#endif/*RGR_SI_SCH*/ + + +/*********************************************************** +* +* Func : cmPkRgrCfgTransId +* +* +* Desc : Transaction ID between MAC and RRM +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrCfgTransId +( +RgrCfgTransId *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrCfgTransId(param, mBuf) +RgrCfgTransId *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkRgrCfgTransId) + + for (i=RGR_CFG_TRANSID_SIZE-1; i >= 0; i--) { + CMCHKPK(SPkU8, param->trans[i], mBuf); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrCfgTransId +* +* +* Desc : Transaction ID between MAC and RRM +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrCfgTransId +( +RgrCfgTransId *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrCfgTransId(param, mBuf) +RgrCfgTransId *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmUnpkRgrCfgTransId) + + for (i=0; itrans[i], mBuf); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrDlHqCfg +* +* +* Desc : Downlink HARQ configuration per Cell +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrDlHqCfg +( +RgrDlHqCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrDlHqCfg(param, mBuf) +RgrDlHqCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrDlHqCfg) + + CMCHKPK(SPkU8, param->maxMsg4HqTx, mBuf); + CMCHKPK(SPkU8, param->maxDlHqTx, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrDlHqCfg +* +* +* Desc : Downlink HARQ configuration per Cell +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrDlHqCfg +( +RgrDlHqCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrDlHqCfg(param, mBuf) +RgrDlHqCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrDlHqCfg) + + CMCHKUNPK(SUnpkU8, ¶m->maxDlHqTx, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->maxMsg4HqTx, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrRntiCfg +* +* +* Desc : Range of RNTIs managed by MAC +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrRntiCfg +( +RgrRntiCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrRntiCfg(param, mBuf) +RgrRntiCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrRntiCfg) + + CMCHKPK(SPkU16, param->size, mBuf); + CMCHKPK(cmPkLteRnti, param->startRnti, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrRntiCfg +* +* +* Desc : Range of RNTIs managed by MAC +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrRntiCfg +( +RgrRntiCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrRntiCfg(param, mBuf) +RgrRntiCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrRntiCfg) + + CMCHKUNPK(cmUnpkLteRnti, ¶m->startRnti, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->size, mBuf); + RETVALUE(ROK); +} + +#ifdef EMTC_ENABLE +/*********************************************************** +* +* Func : cmPkRgrEmtcRntiCfg +* +* +* Desc : Range of Emtc RNTIs managed by MAC +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrEmtcRntiCfg +( +RgrEmtcRntiCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrEmtcRntiCfg(param, mBuf) +RgrEmtcRntiCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrEmtcRntiCfg) + + CMCHKPK(SPkU16, param->size, mBuf); + CMCHKPK(cmPkLteRnti, param->rntiCeModeBRange, mBuf); + CMCHKPK(cmPkLteRnti, param->rntiCeModeBStart, mBuf); + CMCHKPK(cmPkLteRnti, param->rntiCeModeARange, mBuf); + CMCHKPK(cmPkLteRnti, param->rntiCeModeAStart, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrEmtcRntiCfg +* +* +* Desc : Range of Emtc RNTIs managed by MAC +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrEmtcRntiCfg +( +RgrEmtcRntiCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrEmtcRntiCfg(param, mBuf) +RgrEmtcRntiCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrEmtcRntiCfg) + + CMCHKUNPK(cmUnpkLteRnti, ¶m->rntiCeModeAStart, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->rntiCeModeARange, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->rntiCeModeBStart, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->rntiCeModeBRange, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->size, mBuf); + + RETVALUE(ROK); +} +#endif + + +/*********************************************************** +* +* Func : cmPkRgrDlCmnCodeRateCfg +* +* +* Desc : Downlink common channel code rate configuration per cell +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrDlCmnCodeRateCfg +( +RgrDlCmnCodeRateCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrDlCmnCodeRateCfg(param, mBuf) +RgrDlCmnCodeRateCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrDlCmnCodeRateCfg) + + CMCHKPK(SPkU8, param->ccchCqi, mBuf); + CMCHKPK(SPkU16, param->pdcchCodeRate, mBuf); + CMCHKPK(SPkU16, param->bcchPchRaCodeRate, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrDlCmnCodeRateCfg +* +* +* Desc : Downlink common channel code rate configuration per cell +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrDlCmnCodeRateCfg +( +RgrDlCmnCodeRateCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrDlCmnCodeRateCfg(param, mBuf) +RgrDlCmnCodeRateCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrDlCmnCodeRateCfg) + + CMCHKUNPK(SUnpkU16, ¶m->bcchPchRaCodeRate, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->pdcchCodeRate, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->ccchCqi, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrCfiCfg +* +* +* Desc : Control Format Indicator (CFI) configuration per cell +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrCfiCfg +( +RgrCfiCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrCfiCfg(param, mBuf) +RgrCfiCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrCfiCfg) + + CMCHKPK(SPkU8, param->cfi, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrCfiCfg +* +* +* Desc : Control Format Indicator (CFI) configuration per cell +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrCfiCfg +( +RgrCfiCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrCfiCfg(param, mBuf) +RgrCfiCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrCfiCfg) + + CMCHKUNPK(SUnpkU8, ¶m->cfi, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrPuschSubBandCfg +* +* +* Desc : PUSCH sub-band configuration per cell +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrPuschSubBandCfg +( +RgrPuschSubBandCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrPuschSubBandCfg(param, mBuf) +RgrPuschSubBandCfg *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkRgrPuschSubBandCfg) + + for (i=param->numSubbands-1; i >= 0; i--) { + CMCHKPK(SPkU8, param->dmrs[i], mBuf); + } + CMCHKPK(SPkU8, param->size, mBuf); + CMCHKPK(SPkU8, param->numSubbands, mBuf); + CMCHKPK(SPkU8, param->subbandStart, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrPuschSubBandCfg +* +* +* Desc : PUSCH sub-band configuration per cell +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrPuschSubBandCfg +( +RgrPuschSubBandCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrPuschSubBandCfg(param, mBuf) +RgrPuschSubBandCfg *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmUnpkRgrPuschSubBandCfg) + + CMCHKUNPK(SUnpkU8, ¶m->subbandStart, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numSubbands, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->size, mBuf); + for (i=0; inumSubbands; i++) { + CMCHKUNPK(SUnpkU8, ¶m->dmrs[i], mBuf); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrUlCmnCodeRateCfg +* +* +* Desc : Uplink common channel code rate configuration per cell +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUlCmnCodeRateCfg +( +RgrUlCmnCodeRateCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUlCmnCodeRateCfg(param, mBuf) +RgrUlCmnCodeRateCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrUlCmnCodeRateCfg) + + CMCHKPK(SPkU8, param->ccchCqi, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrUlCmnCodeRateCfg +* +* +* Desc : Uplink common channel code rate configuration per cell +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUlCmnCodeRateCfg +( +RgrUlCmnCodeRateCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUlCmnCodeRateCfg(param, mBuf) +RgrUlCmnCodeRateCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrUlCmnCodeRateCfg) + + CMCHKUNPK(SUnpkU8, ¶m->ccchCqi, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrUlTrgCqiCfg +* +* +* Desc : Target Uplink CQI to achieve through group power control configured per cell +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUlTrgCqiCfg +( +RgrUlTrgCqiCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUlTrgCqiCfg(param, mBuf) +RgrUlTrgCqiCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrUlTrgCqiCfg) + + CMCHKPK(SPkU8, param->trgCqi, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrUlTrgCqiCfg +* +* +* Desc : Target Uplink CQI to achieve through group power control configured per cell +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUlTrgCqiCfg +( +RgrUlTrgCqiCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUlTrgCqiCfg(param, mBuf) +RgrUlTrgCqiCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrUlTrgCqiCfg) + + CMCHKUNPK(SUnpkU8, ¶m->trgCqi, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrBwCfg +* +* +* Desc : Bandwidth configuration per cell +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrBwCfg +( +RgrBwCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrBwCfg(param, mBuf) +RgrBwCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrBwCfg) + + CMCHKPK(SPkU8, param->ulTotalBw, mBuf); + CMCHKPK(SPkU8, param->dlTotalBw, mBuf); + RETVALUE(ROK); +} + + +#ifdef EMTC_ENABLE +/* EMTC related pack changes start*/ + +#ifdef ANSI +PUBLIC S16 cmPkRgrEmtcSiCfg +( +RgrEmtcSiCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrEmtcSiCfg(param, mBuf) +RgrEmtcSiCfg *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkRgrEmtcSiCfg) + + CMCHKPK(SPkU8, param->siHoppingEnable, mBuf); + CMCHKPK(SPkU32, param->modPrd, mBuf); + CMCHKPK(SPkU8, param->siWinSizeBr, mBuf); + CMCHKPK(SPkU8, param->sib1Repetition, mBuf); + CMCHKPK(SPkU8, param->siRepetition, mBuf); + + CMCHKPK(SPkU16, param->startSymbolLc, mBuf); + //CMCHKPK(SPkU8, param->fddDLOrTddSfBitmapLC.sfnPtnChoice, mBuf); + /*Changes by SIMRAN*/ + if(!(param->fddDLOrTddSfBitmapLC.sfnPtnChoice)) + { + CMCHKPK(SPkU16, param->fddDLOrTddSfBitmapLC.u.ptn10, mBuf); + } + else + { + //CMCHKPK(SPkU64,param->fddDLOrTddSfBitmapLC.u.ptn40, mBuf); + for (i=0; i<2; i++) { + CMCHKPK(SPkU32, param->fddDLOrTddSfBitmapLC.u.ptn40[i], mBuf); + } + + } + CMCHKPK(SPkU8, param->fddDLOrTddSfBitmapLC.sfnPtnChoice, mBuf); + //CMCHKPK(SPkU16, param->fddDlOrTddSfBitmapBR, mBuf); + + for (i= (param->numSi-1); i >= 0; i--) { + CMCHKPK(SPkU8, param->schdInfo[i].emtcSiNarrowBand, mBuf); + CMCHKPK(SPkU16, param->schdInfo[i].emtcSiTbs, mBuf); + } + + for (i= (param->numSi-1); i >= 0; i--) { + CMCHKPK(SPkU32, param->siPeriodicity[i], mBuf); + } + + CMCHKPK(SPkU8, param->numSi, mBuf); + + RETVALUE(ROK); +} + + + + +#ifdef ANSI +PUBLIC S16 cmPkRgrEmtcRachCfg +( +RgrEmtcRachCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrEmtcRachCfg(param, mBuf) +RgrEmtcRachCfg *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkRgrEmtcRachCfg) + + CMCHKPK(SPkU8, param->emtcCeLvlSupported, mBuf); + + for (i=RGR_MAX_CE_LEVEL-1; i >= 0; i--) { + CMCHKPK(SPkU8, param->ceLevelInfo[i].emtcRarHopping, mBuf); + CMCHKPK(SPkU16, param->ceLevelInfo[i].raEmtcWinSize, mBuf); + CMCHKPK(SPkU16, param->ceLevelInfo[i].raEmtcContResTmr, mBuf); + CMCHKPK(SPkU16, param->ceLevelInfo[i].emtcPreambleTransMax, mBuf); + CMCHKPK(SPkU8, param->ceLevelInfo[i].emtcPreambleMap.firstPreamble, mBuf); + CMCHKPK(SPkU8, param->ceLevelInfo[i].emtcPreambleMap.lastPreamble, mBuf); + } + + RETVALUE(ROK); +} + + +#ifdef ANSI +PUBLIC S16 cmPkRgrEmtcPdschCfg +( +RgrEmtcPdschCfg*param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrEmtcPdschCfg(param, mBuf) +RgrEmtcPdschCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrEmtcPdschCfg) + CMCHKPK(SPkU16, param->emtcMaxRepCeModeA, mBuf); + CMCHKPK(SPkU16, param->emtcMaxRepCeModeB, mBuf); + + RETVALUE(ROK); +} + +#ifdef ANSI +PUBLIC S16 cmPkRgrEmtcPuschCfg +( +RgrEmtcPuschCfg*param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrEmtcPuschCfg(param, mBuf) +RgrEmtcPuschCfg *param; +Buffer *mBuf; +#endif +{ + TRC3(cmPkRgrEmtcPuschCfg) + CMCHKPK(SPkU16, param->emtcMaxRepCeModeA, mBuf); + CMCHKPK(SPkU16, param->emtcMaxRepCeModeB, mBuf); + CMCHKPK(SPkU8, param->emtcHoppingOffset, mBuf); + RETVALUE(ROK); +} + + + +#ifdef ANSI +PUBLIC S16 cmPkRgrEmtcPucchCfg +( +RgrEmtcPucchCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrEmtcPucchCfg(param, mBuf) +RgrEmtcPucchCfg *param; +Buffer *mBuf; +#endif +{ + + S32 i; + + TRC3(cmPkRgrEmtcPucchCfg) + for (i=RGR_MAX_CE_LEVEL-1; i >= 0; i--) { + CMCHKPK(SPkU16, param->emtcN1pucchAnInfoLst[i], mBuf); + } + + CMCHKPK(SPkU8, param->emtcPucchNumRepCEMsg4Lvl0, mBuf); + CMCHKPK(SPkU8, param->emtcPucchNumRepCEMsg4Lvl1, mBuf); + CMCHKPK(SPkU8, param->emtcPucchNumRepCEMsg4Lvl2, mBuf); + CMCHKPK(SPkU8, param->emtcPucchNumRepCEMsg4Lvl3, mBuf); + + RETVALUE(ROK); +} + + +#ifdef ANSI +PUBLIC S16 cmPkRgrEmtcPrachCeParamCfg +( +RgrEmtcPrachCEParamLst *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrEmtcPrachCeParamCfg(param, mBuf) +RgrEmtcPrachCEParamLst *param; +Buffer *mBuf; +#endif +{ + TRC3(cmPkRgrEmtcPrachCeParamCfg) + CMCHKPK(SPkU8, param->emtcPrachCfgIdx, mBuf); + CMCHKPK(SPkU8, param->emtcPrachFreqOffset, mBuf); + CMCHKPK(SPkU16, param->emtcPrachStartSubFrame, mBuf); + CMCHKPK(SPkU8, param->emtcMaxPremAttemptCE, mBuf); + CMCHKPK(SPkU8, param->emtcNumRepPerPreambleAtt, mBuf); + CMCHKPK(SPkU8, param->emtcNumMpdcchNBtoMonitor, mBuf); + CMCHKPK(SPkU8, param->emtcMpdcchNBtoMonitor[0], mBuf); + CMCHKPK(SPkU8, param->emtcMpdcchNBtoMonitor[1], mBuf); + CMCHKPK(SPkU16, param->emtcMpdcchNumRep, mBuf); + CMCHKPK(SPkU8, param->emtcPrachHoppingCfg, mBuf); + RETVALUE(ROK); +} + + + +#ifdef ANSI +PUBLIC S16 cmPkRgrEmtcPrachCfg +( +RgrEmtcPrachCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrEmtcPrachCfg(param, mBuf) +RgrEmtcPrachCfg *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkRgrEmtcPrachCfg) + CMCHKPK(SPkU8, param->emtcMpdcchStartSFCssRaFdd, mBuf); + CMCHKPK(SPkU8, param->emtcPrachHopingOffset, mBuf); + CMCHKPK(SPkU8, param->emtcInitialCElevel, mBuf); + for (i=RGR_MAX_CE_LEVEL-1; i >= 0; i--) { + CMCHKPK(cmPkRgrEmtcPrachCeParamCfg, ¶m->emtcPrachCEparmLst[i], mBuf); + } + + RETVALUE(ROK); +} + + + + +#ifdef ANSI +PUBLIC S16 cmPkRgrEmtcCfg +( +RgrEmtcCellCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrEmtcCfg(param, mBuf) +RgrEmtcCellCfg *param; +Buffer *mBuf; +#endif +{ + TRC3(cmPkRgrEmtcCfg) + CMCHKPK(SPkU16, param->pci, mBuf); + CMCHKPK(SPkU32, param->emtcT300Tmr, mBuf); + CMCHKPK(SPkU32, param->emtcT301Tmr, mBuf); + CMCHKPK(cmPkRgrEmtcSiCfg, ¶m->emtcSiCfg, mBuf); + CMCHKPK(cmPkRgrEmtcRachCfg, ¶m->emtcRachCfg, mBuf); + CMCHKPK(cmPkRgrEmtcPdschCfg, ¶m->emtcPdschCfg, mBuf); + CMCHKPK(cmPkRgrEmtcPuschCfg, ¶m->emtcPuschCfg, mBuf); + CMCHKPK(cmPkRgrEmtcPrachCfg, ¶m->emtcPrachCfg, mBuf); + CMCHKPK(cmPkRgrEmtcPucchCfg, ¶m->emtcPucchCfg, mBuf); + CMCHKPK(cmPkRgrEmtcRntiCfg, ¶m->emtcMacRnti, mBuf); + CMCHKPK(SPkU8, param->emtcPdschNbIdx, mBuf); + CMCHKPK(SPkU8, param->emtcMpdcchNbIdx, mBuf); + CMCHKPK(SPkU8, param->emtcPuschNbIdx, mBuf); + + RETVALUE(ROK); +} + +/* EMTC related pack changes end*/ + +/* EMTC related unpack changes start*/ + +#ifdef ANSI +PUBLIC S16 cmUnpkRgrEmtcSiCfg +( +RgrEmtcSiCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrEmtcSiCfg(param, mBuf) +RgrEmtcSiCfg *param; +Buffer *mBuf; +#endif +{ + + S32 i; + U32 tmpEnum; + TRC3(cmUnpkRgrEmtcSiCfg) + CMCHKUNPK(SUnpkU8, ¶m->numSi, mBuf); + + for (i=0; i < param->numSi ; i++) { + CMCHKUNPK(SUnpkU32,(U32*)&tmpEnum,mBuf); + param->siPeriodicity[i] = (RgrSiPeriodicity) tmpEnum; + } + + for (i=0; i < param->numSi ; i++) { + CMCHKUNPK(SUnpkU16, ¶m->schdInfo[i].emtcSiTbs, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->schdInfo[i].emtcSiNarrowBand, mBuf); + } + //CMCHKUNPK(SUnpkU16, ¶m->fddDlOrTddSfBitmapBR, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->fddDLOrTddSfBitmapLC.sfnPtnChoice, mBuf); + /*Changes by SIMRAN*/ + if(!(param->fddDLOrTddSfBitmapLC.sfnPtnChoice)) + { + CMCHKUNPK(SUnpkU16, ¶m->fddDLOrTddSfBitmapLC.u.ptn10, mBuf); + } + else + { + for (i=1; i>=0; i--) { + CMCHKUNPK(SUnpkU32, ¶m->fddDLOrTddSfBitmapLC.u.ptn40[i], mBuf); + } + } + + CMCHKUNPK(SUnpkU16, ¶m->startSymbolLc, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->siRepetition, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->sib1Repetition, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->siWinSizeBr, mBuf); + CMCHKUNPK(SUnpkU32, (U32*)&tmpEnum, mBuf); + param->modPrd = (RgrModPeriodicity) tmpEnum; + CMCHKUNPK(SUnpkU8, ¶m->siHoppingEnable, mBuf); + + RETVALUE(ROK); +} + + + + +#ifdef ANSI +PUBLIC S16 cmUnpkRgrEmtcRachCfg +( +RgrEmtcRachCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrEmtcRachCfg(param, mBuf) +RgrEmtcRachCfg *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmUnpkRgrEmtcRachCfg) + for (i=0; i < RGR_MAX_CE_LEVEL; i++) { + CMCHKUNPK(SUnpkU8, &(param->ceLevelInfo[i].emtcPreambleMap.lastPreamble), mBuf); + CMCHKUNPK(SUnpkU8, &(param->ceLevelInfo[i].emtcPreambleMap.firstPreamble), mBuf); + CMCHKUNPK(SUnpkU16, &(param->ceLevelInfo[i].emtcPreambleTransMax), mBuf); + CMCHKUNPK(SUnpkU16, &(param->ceLevelInfo[i].raEmtcContResTmr), mBuf); + CMCHKUNPK(SUnpkU16, &(param->ceLevelInfo[i].raEmtcWinSize), mBuf); + CMCHKUNPK(SUnpkU8,&(param->ceLevelInfo[i].emtcRarHopping), mBuf); + } + CMCHKUNPK(SUnpkU8, ¶m->emtcCeLvlSupported, mBuf); + RETVALUE(ROK); +} + + +#ifdef ANSI +PUBLIC S16 cmUnpkRgrEmtcPdschCfg +( +RgrEmtcPdschCfg*param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrEmtcPdschCfg(param, mBuf) +RgrEmtcPdschCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrEmtcPdschCfg) + CMCHKUNPK(SUnpkU16, ¶m->emtcMaxRepCeModeB, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->emtcMaxRepCeModeA, mBuf); + RETVALUE(ROK); +} + +#ifdef ANSI +PUBLIC S16 cmUnpkRgrEmtcPuschCfg +( +RgrEmtcPuschCfg*param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrEmtcPuschCfg(param, mBuf) +RgrEmtcPuschCfg *param; +Buffer *mBuf; +#endif +{ + TRC3(cmUnpkRgrEmtcPuschCfg) + CMCHKUNPK(SUnpkU8, ¶m->emtcHoppingOffset, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->emtcMaxRepCeModeB, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->emtcMaxRepCeModeA, mBuf); + RETVALUE(ROK); +} + + + +#ifdef ANSI +PUBLIC S16 cmUnpkRgrEmtcPucchCfg +( +RgrEmtcPucchCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrEmtcPucchCfg(param, mBuf) +RgrEmtcPucchCfg *param; +Buffer *mBuf; +#endif +{ + + S32 i; + + TRC3(cmUnpkRgrEmtcPucchCfg) + + CMCHKUNPK(SUnpkU8, ¶m->emtcPucchNumRepCEMsg4Lvl3, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->emtcPucchNumRepCEMsg4Lvl2, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->emtcPucchNumRepCEMsg4Lvl1, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->emtcPucchNumRepCEMsg4Lvl0, mBuf); + + for (i=0; i < RGR_MAX_CE_LEVEL ; i++) { + CMCHKUNPK(SUnpkU16, ¶m->emtcN1pucchAnInfoLst[i], mBuf); + } + RETVALUE(ROK); +} + + +#ifdef ANSI +PUBLIC S16 cmUnpkRgrEmtcPrachCeParamCfg +( +RgrEmtcPrachCEParamLst *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrEmtcPrachCeParamCfg(param, mBuf) +RgrEmtcPrachCEParamLst *param; +Buffer *mBuf; +#endif +{ + TRC3(cmUnpkRgrEmtcPrachCeParamCfg) + CMCHKUNPK(SUnpkU8, ¶m->emtcPrachHoppingCfg, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->emtcMpdcchNumRep, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->emtcMpdcchNBtoMonitor[1], mBuf); + CMCHKUNPK(SUnpkU8, ¶m->emtcMpdcchNBtoMonitor[0], mBuf); + CMCHKUNPK(SUnpkU8, ¶m->emtcNumMpdcchNBtoMonitor, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->emtcNumRepPerPreambleAtt, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->emtcMaxPremAttemptCE, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->emtcPrachStartSubFrame, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->emtcPrachFreqOffset, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->emtcPrachCfgIdx, mBuf); + RETVALUE(ROK); +} + + + +#ifdef ANSI +PUBLIC S16 cmUnpkRgrEmtcPrachCfg +( +RgrEmtcPrachCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrEmtcPrachCfg(param, mBuf) +RgrEmtcPrachCfg *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmUnpkRgrEmtcPrachCfg) + for (i=0; i < RGR_MAX_CE_LEVEL; i++) { + CMCHKUNPK(cmUnpkRgrEmtcPrachCeParamCfg, ¶m->emtcPrachCEparmLst[i], mBuf); + } + CMCHKUNPK(SUnpkU8, ¶m->emtcInitialCElevel, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->emtcPrachHopingOffset, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->emtcMpdcchStartSFCssRaFdd, mBuf); + + RETVALUE(ROK); +} + +#ifdef ANSI +PUBLIC S16 cmUnpkRgrEmtcCfg +( +RgrEmtcCellCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrEmtcCfg(param, mBuf) +RgrEmtcCellCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrEmtcCfg) + CMCHKUNPK(SUnpkU8, ¶m->emtcPuschNbIdx, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->emtcMpdcchNbIdx, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->emtcPdschNbIdx, mBuf); + CMCHKUNPK(cmUnpkRgrEmtcRntiCfg, ¶m->emtcMacRnti, mBuf); + CMCHKUNPK(cmUnpkRgrEmtcPucchCfg, ¶m->emtcPucchCfg, mBuf); + CMCHKUNPK(cmUnpkRgrEmtcPrachCfg, ¶m->emtcPrachCfg, mBuf); + CMCHKUNPK(cmUnpkRgrEmtcPuschCfg, ¶m->emtcPuschCfg, mBuf); + CMCHKUNPK(cmUnpkRgrEmtcPdschCfg, ¶m->emtcPdschCfg, mBuf); + CMCHKUNPK(cmUnpkRgrEmtcRachCfg, ¶m->emtcRachCfg, mBuf); + CMCHKUNPK(cmUnpkRgrEmtcSiCfg, ¶m->emtcSiCfg, mBuf); + CMCHKUNPK(SUnpkU32,¶m->emtcT301Tmr, mBuf); + CMCHKUNPK(SUnpkU32, ¶m->emtcT300Tmr, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->pci, mBuf); + + + + + + RETVALUE(ROK); +} + +/* EMTC related unpack changes end*/ + + +#endif + + +/*********************************************************** +* +* Func : cmUnpkRgrBwCfg +* +* +* Desc : Bandwidth configuration per cell +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrBwCfg +( +RgrBwCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrBwCfg(param, mBuf) +RgrBwCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrBwCfg) + + CMCHKUNPK(SUnpkU8, ¶m->dlTotalBw, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->ulTotalBw, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrPhichCfg +* +* +* Desc : PHICH configuration per cell +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrPhichCfg +( +RgrPhichCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrPhichCfg(param, mBuf) +RgrPhichCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrPhichCfg) + + CMCHKPK(SPkU8, param->isDurExtend, mBuf); + CMCHKPK(SPkU32, param->ngEnum, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrPhichCfg +* +* +* Desc : PHICH configuration per cell +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrPhichCfg +( +RgrPhichCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrPhichCfg(param, mBuf) +RgrPhichCfg *param; +Buffer *mBuf; +#endif +{ + U32 tmpEnum; + + TRC3(cmUnpkRgrPhichCfg) + + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->ngEnum = (RgrPhichNg) tmpEnum; + CMCHKUNPK(SUnpkU8, ¶m->isDurExtend, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrPucchCfg +* +* +* Desc : PUCCH configuration per cell +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrPucchCfg +( +RgrPucchCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrPucchCfg(param, mBuf) +RgrPucchCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrPucchCfg) + + CMCHKPK(SPkU8, param->maxPucchRb, mBuf); + CMCHKPK(SPkU8, param->cyclicShift, mBuf); + CMCHKPK(SPkU8, param->deltaShift, mBuf); + CMCHKPK(SPkU16, param->n1PucchAn, mBuf); + CMCHKPK(SPkU8, param->resourceSize, mBuf); + + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrPucchCfg +* +* +* Desc : PUCCH configuration per cell +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrPucchCfg +( +RgrPucchCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrPucchCfg(param, mBuf) +RgrPucchCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrPucchCfg) + + CMCHKUNPK(SUnpkU8, ¶m->resourceSize, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->n1PucchAn, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->deltaShift, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->cyclicShift, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->maxPucchRb, mBuf); + + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrSrsCfg +* +* +* Desc : SRS configuration per cell +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrSrsCfg +( +RgrSrsCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrSrsCfg(param, mBuf) +RgrSrsCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrSrsCfg) + + CMCHKPK(SPkU8, param->srsSubFrameCfg, mBuf); + CMCHKPK(SPkU32, param->srsBwEnum, mBuf); + CMCHKPK(SPkU32, param->srsCfgPrdEnum, mBuf); + CMCHKPK(SPkU8, param->isSrsCfgSetup, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrSrsCfg +* +* +* Desc : SRS configuration per cell +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrSrsCfg +( +RgrSrsCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrSrsCfg(param, mBuf) +RgrSrsCfg *param; +Buffer *mBuf; +#endif +{ + U32 tmpEnum; + + TRC3(cmUnpkRgrSrsCfg) + + CMCHKUNPK(SUnpkU8, ¶m->isSrsCfgSetup, mBuf); + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->srsCfgPrdEnum = (RgrSrsCfgPrd) tmpEnum; + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->srsBwEnum = (RgrSrsBwCfg) tmpEnum; + CMCHKUNPK(SUnpkU8, ¶m->srsSubFrameCfg, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrRachCfg +* +* +* Desc : RACH configuration per cell +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrRachCfg +( +RgrRachCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrRachCfg(param, mBuf) +RgrRachCfg *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkRgrRachCfg) + + CMCHKPK(SPkU8, param->prachResource, mBuf); + CMCHKPK(SPkU16, param->msgSizeGrpA, mBuf); + CMCHKPK(SPkU8, param->sizeRaPreambleGrpA, mBuf); + CMCHKPK(SPkU8, param->numRaPreamble, mBuf); + CMCHKPK(SPkU8, param->maxMsg3Tx, mBuf); + for (i=param->raOccasion.size-1; i >= 0; i--) { + CMCHKPK(SPkU8, param->raOccasion.subFrameNum[i], mBuf); + } + CMCHKPK(SPkU32, param->raOccasion.sfnEnum, mBuf); + CMCHKPK(SPkU8, param->raOccasion.size, mBuf); + CMCHKPK(SPkU8, param->raWinSize, mBuf); + CMCHKPK(SPkU8, param->preambleFormat, mBuf); +#ifdef RGR_V1 + /* rgr_c_001.main_5: cccpu00112372: Added contention resolution + * timer configuration */ + CMCHKPK(SPkU8, param->contResTmr, mBuf); +#endif + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrRachCfg +* +* +* Desc : RACH configuration per cell +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrRachCfg +( +RgrRachCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrRachCfg(param, mBuf) +RgrRachCfg *param; +Buffer *mBuf; +#endif +{ + U32 tmpEnum; + + S32 i; + TRC3(cmUnpkRgrRachCfg) +#ifdef RGR_V1 + /* rgr_c_001.main_5: cccpu00112372: Added contention resolution + * timer configuration */ + CMCHKUNPK(SUnpkU8, ¶m->contResTmr, mBuf); +#endif + CMCHKUNPK(SUnpkU8, ¶m->preambleFormat, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->raWinSize, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->raOccasion.size, mBuf); + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->raOccasion.sfnEnum = (RgrRaSfn) tmpEnum; + for (i=0; iraOccasion.size; i++) { + CMCHKUNPK(SUnpkU8, ¶m->raOccasion.subFrameNum[i], mBuf); + } + CMCHKUNPK(SUnpkU8, ¶m->maxMsg3Tx, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numRaPreamble, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->sizeRaPreambleGrpA, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->msgSizeGrpA, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->prachResource, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrSiCfg +* +* +* Desc : SI Configuration per cell +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrSiCfg +( +RgrSiCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrSiCfg(param, mBuf) +RgrSiCfg *param; +Buffer *mBuf; +#endif +{ + /* rgr_c_001.main_4:MOD-Modified for SI Enhancement. */ +#ifdef RGR_SI_SCH + S16 idx; +#endif/*RGR_SI_SCH*/ + + TRC3(cmPkRgrSiCfg) + +#ifdef RGR_SI_SCH + if(param->numSi > sizeof(param->siPeriodicity)/ + sizeof(param->siPeriodicity[0])) + param->numSi = sizeof(param->siPeriodicity)/ + sizeof(param->siPeriodicity[0]); + + for (idx=param->numSi-1; idx >= 0; idx--) { + /* Enum to be packed/unpacked as U32 instead of S32 */ + CMCHKPK(SPkU32, param->siPeriodicity[idx], mBuf); + } + CMCHKPK(SPkU8, param->numSi, mBuf); + /*rgr_c_001.main_9 ccpu00115364 MOD changed modPrd to enum*/ + CMCHKPK(SPkU32, (U32)param->modPrd, mBuf); +#endif/*RGR_SI_SCH*/ + CMCHKPK(SPkU8, param->retxCnt, mBuf); + CMCHKPK(SPkU8, param->siWinSize, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrSiCfg +* +* +* Desc : SI Configuration per cell +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrSiCfg +( +RgrSiCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrSiCfg(param, mBuf) +RgrSiCfg *param; +Buffer *mBuf; +#endif +{ + U32 tmpEnum; + /* rgr_c_001.main_4:MOD-Modified for SI Enhancement. */ +#ifdef RGR_SI_SCH + S16 idx; +#endif/*RGR_SI_SCH*/ + + TRC3(cmUnpkRgrSiCfg) + + CMCHKUNPK(SUnpkU8, ¶m->siWinSize, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->retxCnt, mBuf); +#ifdef RGR_SI_SCH + /*rgr_c_001.main_9 ccpu00115364 MOD changed modPrd to enum*/ + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->modPrd = (RgrModPeriodicity) tmpEnum; + CMCHKUNPK(SUnpkU8, ¶m->numSi, mBuf); + + if(param->numSi > sizeof(param->siPeriodicity)/ + sizeof(param->siPeriodicity[0])) + param->numSi = sizeof(param->siPeriodicity)/ + sizeof(param->siPeriodicity[0]); + + /* Enum to be packed/unpacked as U32 instead of S32 */ + for (idx=0; idx < param->numSi; idx++) { + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->siPeriodicity[idx] = (RgrSiPeriodicity) tmpEnum; + } +#endif/*RGR_SI_SCH*/ + + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrTpcRntiCfg +* +* +* Desc : TPC RNTI Range +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrTpcRntiCfg +( +RgrTpcRntiCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrTpcRntiCfg(param, mBuf) +RgrTpcRntiCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrTpcRntiCfg) + + CMCHKPK(SPkU16, param->size, mBuf); + CMCHKPK(cmPkLteRnti, param->startTpcRnti, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrTpcRntiCfg +* +* +* Desc : TPC RNTI Range +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrTpcRntiCfg +( +RgrTpcRntiCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrTpcRntiCfg(param, mBuf) +RgrTpcRntiCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrTpcRntiCfg) + + CMCHKUNPK(cmUnpkLteRnti, ¶m->startTpcRnti, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->size, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrUlPwrCfg +* +* +* Desc : Cell specific power configuration +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUlPwrCfg +( +RgrUlPwrCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUlPwrCfg(param, mBuf) +RgrUlPwrCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrUlPwrCfg) + + CMCHKPK(cmPkRgrTpcRntiCfg, ¶m->puschPwrFmt3a, mBuf); + CMCHKPK(cmPkRgrTpcRntiCfg, ¶m->puschPwrFmt3, mBuf); + CMCHKPK(cmPkRgrTpcRntiCfg, ¶m->pucchPwrFmt3a, mBuf); + CMCHKPK(cmPkRgrTpcRntiCfg, ¶m->pucchPwrFmt3, mBuf); + CMCHKPK(SPkS8, param->deltaPreambleMsg3, mBuf); + CMCHKPK(SPkS8, param->p0NominalPucch, mBuf); + CMCHKPK(SPkU32, param->alpha, mBuf); + CMCHKPK(SPkS8, param->p0NominalPusch, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrUlPwrCfg +* +* +* Desc : Cell specific power configuration +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUlPwrCfg +( +RgrUlPwrCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUlPwrCfg(param, mBuf) +RgrUlPwrCfg *param; +Buffer *mBuf; +#endif +{ + U32 tmpEnum; + + TRC3(cmUnpkRgrUlPwrCfg) + + CMCHKUNPK(SUnpkS8, ¶m->p0NominalPusch, mBuf); + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->alpha = (RgrPwrAlpha) tmpEnum; + CMCHKUNPK(SUnpkS8, ¶m->p0NominalPucch, mBuf); + CMCHKUNPK(SUnpkS8, ¶m->deltaPreambleMsg3, mBuf); + CMCHKUNPK(cmUnpkRgrTpcRntiCfg, ¶m->pucchPwrFmt3, mBuf); + CMCHKUNPK(cmUnpkRgrTpcRntiCfg, ¶m->pucchPwrFmt3a, mBuf); + CMCHKUNPK(cmUnpkRgrTpcRntiCfg, ¶m->puschPwrFmt3, mBuf); + CMCHKUNPK(cmUnpkRgrTpcRntiCfg, ¶m->puschPwrFmt3a, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrPuschCfg +* +* +* Desc : brief cell specific hopping configuration +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrPuschCfg +( +RgrPuschCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrPuschCfg(param, mBuf) +RgrPuschCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrPuschCfg) + + CMCHKPK(SPkU8, param->hopOffst, mBuf); + CMCHKPK(SPkU8, param->isIntraHop, mBuf); + CMCHKPK(SPkU8, param->numSubBands, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrPuschCfg +* +* +* Desc : brief cell specific hopping configuration +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrPuschCfg +( +RgrPuschCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrPuschCfg(param, mBuf) +RgrPuschCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrPuschCfg) + + CMCHKUNPK(SUnpkU8, ¶m->numSubBands, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->isIntraHop, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->hopOffst, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrCodeBookRstCfg +* +* +* Desc : Number of bits in code book for different transmission modes +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrCodeBookRstCfg +( +RgrCodeBookRstCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrCodeBookRstCfg(param, mBuf) +RgrCodeBookRstCfg *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkRgrCodeBookRstCfg) + + for (i=1-1; i >= 0; i--) { + CMCHKPK(SPkU32, param->pmiBitMap[i], mBuf); + } + CMCHKPK(SPkU8, param->pres, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrCodeBookRstCfg +* +* +* Desc : Number of bits in code book for different transmission modes +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrCodeBookRstCfg +( +RgrCodeBookRstCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrCodeBookRstCfg(param, mBuf) +RgrCodeBookRstCfg *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmUnpkRgrCodeBookRstCfg) + + CMCHKUNPK(SUnpkU8, ¶m->pres, mBuf); + for (i=0; i<1; i++) { + CMCHKUNPK(SUnpkU32, ¶m->pmiBitMap[i], mBuf); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrPreambleSetCfg +* +* +* Desc : Range of PDCCH Order Preamble Set managed by MAC +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrPreambleSetCfg +( +RgrPreambleSetCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrPreambleSetCfg(param, mBuf) +RgrPreambleSetCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrPreambleSetCfg) + + CMCHKPK(SPkU8, param->size, mBuf); + CMCHKPK(SPkU8, param->start, mBuf); + CMCHKPK(SPkU8, param->pres, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrPreambleSetCfg +* +* +* Desc : Range of PDCCH Order Preamble Set managed by MAC +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrPreambleSetCfg +( +RgrPreambleSetCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrPreambleSetCfg(param, mBuf) +RgrPreambleSetCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrPreambleSetCfg) + + CMCHKUNPK(SUnpkU8, ¶m->pres, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->start, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->size, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrCmnLchCfg +* +* +* Desc : Logical channel configuration info for common channels +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrCmnLchCfg +( +RgrCmnLchCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrCmnLchCfg(param, mBuf) +RgrCmnLchCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrCmnLchCfg) + + CMCHKPK(SPkU8, param->ulTrchType, mBuf); + CMCHKPK(SPkU8, param->dlTrchType, mBuf); + CMCHKPK(SPkU8, param->dir, mBuf); + CMCHKPK(cmPkLteLcType, param->lcType, mBuf); + CMCHKPK(cmPkLteLcId, param->lcId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrCmnLchCfg +* +* +* Desc : Logical channel configuration info for common channels +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrCmnLchCfg +( +RgrCmnLchCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrCmnLchCfg(param, mBuf) +RgrCmnLchCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrCmnLchCfg) + + CMCHKUNPK(cmUnpkLteLcId, ¶m->lcId, mBuf); + CMCHKUNPK(cmUnpkLteLcType, ¶m->lcType, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->dir, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->dlTrchType, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->ulTrchType, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrDlfsCfg +* +* +* Desc : RGR configuration for DLFS scheduler +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrDlfsCfg +( +RgrDlfsCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrDlfsCfg(param, mBuf) +RgrDlfsCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrDlfsCfg) + + CMCHKPK(SPkU8, param->thresholdCqi, mBuf); + CMCHKPK(SPkU8, param->isDlFreqSel, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrDlfsCfg +* +* +* Desc : RGR configuration for DLFS scheduler +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrDlfsCfg +( +RgrDlfsCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrDlfsCfg(param, mBuf) +RgrDlfsCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrDlfsCfg) + + CMCHKUNPK(SUnpkU8, ¶m->isDlFreqSel, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->thresholdCqi, mBuf); + RETVALUE(ROK); +} + + +#ifdef LTE_TDD + +#ifdef LTE_TDD + + +/*********************************************************** +* +* Func : cmPkRgrTddPrachInfo +* +* +* Desc : PRACH resource information for TDD +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrTddPrachInfo +( +RgrTddPrachInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrTddPrachInfo(param, mBuf) +RgrTddPrachInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrTddPrachInfo) + + CMCHKPK(SPkU8, param->ulStartSfIdx, mBuf); + CMCHKPK(SPkU8, param->halfFrm, mBuf); + CMCHKPK(SPkU32, param->sfn, mBuf); + CMCHKPK(SPkU8, param->freqIdx, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrTddPrachInfo +* +* +* Desc : PRACH resource information for TDD +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrTddPrachInfo +( +RgrTddPrachInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrTddPrachInfo(param, mBuf) +RgrTddPrachInfo *param; +Buffer *mBuf; +#endif +{ + U32 tmpEnum; + + TRC3(cmUnpkRgrTddPrachInfo) + + CMCHKUNPK(SUnpkU8, ¶m->freqIdx, mBuf); + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->sfn = tmpEnum; + CMCHKUNPK(SUnpkU8, ¶m->halfFrm, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->ulStartSfIdx, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrTddPrachRscInfo +* +* +* Desc : Set of PRACH Information for TDD +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrTddPrachRscInfo +( +RgrTddPrachRscInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrTddPrachRscInfo(param, mBuf) +RgrTddPrachRscInfo *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkRgrTddPrachRscInfo) + + for (i=param->numRsc-1; i >= 0; i--) { + CMCHKPK(cmPkRgrTddPrachInfo, ¶m->prachInfo[i], mBuf); + } + CMCHKPK(SPkU8, param->numRsc, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrTddPrachRscInfo +* +* +* Desc : Set of PRACH Information for TDD +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrTddPrachRscInfo +( +RgrTddPrachRscInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrTddPrachRscInfo(param, mBuf) +RgrTddPrachRscInfo *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmUnpkRgrTddPrachRscInfo) + + CMCHKUNPK(SUnpkU8, ¶m->numRsc, mBuf); + for (i=0; inumRsc; i++) { + CMCHKUNPK(cmUnpkRgrTddPrachInfo, ¶m->prachInfo[i], mBuf); + } + RETVALUE(ROK); +} + + +#endif + +#endif + + +/*********************************************************** +* +* Func : cmPkRgrEnbPfs +* +* +* Desc : PFS Configuration +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrEnbPfs +( +RgrEnbPfs *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrEnbPfs(param, mBuf) +RgrEnbPfs *param; +Buffer *mBuf; +#endif +{ + S32 idx; + TRC3(cmPkRgrEnbPfs) + for(idx = RGR_MAX_NUM_QCI-1; idx >= 0; idx--) + { + CMCHKPK(SPkU32, param->qciWgt[idx], mBuf); + } + CMCHKPK(SPkU8, param->fairCoeffi, mBuf); + CMCHKPK(SPkU8, param->tptCoeffi, mBuf); + + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrEnbPfs +* +* +* Desc : PFS Configuration +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrEnbPfs +( +RgrEnbPfs *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrEnbPfs(param, mBuf) +RgrEnbPfs *param; +Buffer *mBuf; +#endif +{ + S32 idx; + TRC3(cmUnpkRgrEnbPfs) + + CMCHKUNPK(SUnpkU8, ¶m->tptCoeffi, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->fairCoeffi, mBuf); + for(idx = 0; idx < RGR_MAX_NUM_QCI; idx++) + { + CMCHKUNPK(SUnpkU32, ¶m->qciWgt[idx], mBuf); + } + RETVALUE(ROK); +} + +/*rgr_c_001.main_7 - Added support for SPS*/ + +/*********************************************************** +* +* Func : cmPkRgrSpsCellCfg +* +* +* Desc : DL SPS configuration parameters per UE +TODO: Check if this is to be added to re-configuration as well +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrSpsCellCfg +( +RgrSpsCellCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrSpsCellCfg(param, mBuf) +RgrSpsCellCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrSpsCellCfg) + CMCHKPK(SPkU16, param->maxSpsUePerUlSf, mBuf); + CMCHKPK(SPkU16, param->maxSpsUePerDlSf, mBuf); + CMCHKPK(SPkU8, param->maxSpsDlBw, mBuf); + + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrSpsDlCellCfg +* +* +* Desc : DL SPS configuration parameters per UE +TODO: Check if this is to be added to re-configuration as well +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrSpsDlCellCfg +( +RgrSpsCellCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrSpsDlCellCfg(param, mBuf) +RgrSpsCellCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrSpsDlCellCfg) + + CMCHKUNPK(SUnpkU8, ¶m->maxSpsDlBw, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->maxSpsUePerDlSf, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->maxSpsUePerUlSf, mBuf); + + RETVALUE(ROK); +} + +#ifdef RG_5GTF +PUBLIC S16 cmPkRgr5gtfCellCfg +( +Rgr5gtfCellCfg *param, +Buffer *mBuf +) +{ + S8 idx = 0; + for (idx = MAX_5GTF_SUBFRAME_INFO - 1; idx >= 0 ;--idx) + { + + CMCHKPK(SPkU32, param->dynConfig[(U8)idx], mBuf); +#if 0 + printf("\npk dyn:%u\n",param->dynConfig[(U8)idx]); +#endif + } + CMCHKPK(SPkU8, param->uePerGrp, mBuf); + CMCHKPK(SPkU8, param->ueGrpPerTti, mBuf); + CMCHKPK(SPkU8, param->numUes, mBuf); + CMCHKPK(SPkU8, param->numOfCC, mBuf); + CMCHKPK(SPkU8, param->bwPerCC, mBuf); + CMCHKPK(SPkU8, param->cfi, mBuf); +#if 0 + printf("\npk uePerGrp%:%u\n",param->uePerGrp); + printf("\npk ueGrpPerTti:%u\n",param->ueGrpPerTti); + printf("\npk num of UEs:%u\n",param->numUes); + printf("\npk Num of CC:%u\n",param->numOfCC); + printf("\npk bw per cc:%u\n",param->bwPerCC); +#endif + RETVALUE(ROK); +} + +PUBLIC S16 cmUnPkRgr5gtfCellCfg +( +Rgr5gtfCellCfg *param, +Buffer *mBuf +) +{ + S8 idx = 0; + + CMCHKUNPK(SUnpkU8, ¶m->cfi, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->bwPerCC, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numOfCC, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numUes, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->ueGrpPerTti, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->uePerGrp, mBuf); +#if 0 + printf("\nunpk uePerGrp:%u\n",param->uePerGrp); + printf("\nunpk ueGrpPerTti:%u\n",param->ueGrpPerTti); + printf("\nunpk num of ues:%u\n",param->numUes); + printf("\nunpk num of cc:%u\n",param->numOfCC); + printf("\nunpk bw per cc:%u\n",param->bwPerCC); +#endif + for (idx = 0; idx < MAX_5GTF_SUBFRAME_INFO ; ++idx) + { + + CMCHKUNPK(SUnpkU32, ¶m->dynConfig[(U8)idx], mBuf); +#if 0 + printf("\nunpk dyn:%u\n",param->dynConfig[(U8)idx]); +#endif + } + RETVALUE(ROK); +} +#endif + + +/*LAA : functions to pack and unpack LAA params*/ +/*********************************************************** +* +* Func : cmPkRgrLteUCellCfg +* +* +* Desc : LAA configuration for the Cell +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PRIVATE S16 cmPkRgrLteUCellCfg +( +RgrLteUCfg *param, +Buffer *mBuf +) +#else +PRIVATE S16 cmPkRgrLteUCellCfg(param, mBuf) +RgrLteUCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrlteUCellCfg) + CMCHKPK(SPkU8, param->isLaaCell, mBuf); + + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func : cmUnpkRgrLteUCellCfg +* +* +* Desc : LAA configuration for the cell +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PRIVATE S16 cmUnpkRgrLteUCellCfg +( +RgrLteUCfg *param, +Buffer *mBuf +) +#else +PRIVATE S16 cmUnpkRgrLteUCellCfg(param, mBuf) +RgrLteUCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrLteUCellCfg) + + CMCHKUNPK(SUnpkU8, ¶m->isLaaCell, mBuf); + + RETVALUE(ROK); +} + +/* LTE_ADV_FLAG_REMOVED_START */ +/*********************************************************** + * + * Func : cmPkRgrLteAdvancedUeConfig + * + * + * Desc : PAcks LteAdvancedUeConfig + * + * + * Ret : S16 + * + * Notes: + * + * File : + * + **********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrLteAdvancedUeConfig +( + RgrLteAdvancedUeConfig *param, + Buffer *mBuf + ) +#else +PUBLIC S16 cmPkRgrLteAdvancedUeConfig(param, mBuf) + RgrLteAdvancedUeConfig *param; + Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrLteAdvancedUeConfig) + CMCHKPK(SPkU8, param->isUeCellEdge, mBuf); + CMCHKPK(SPkU8, param->isAbsUe, mBuf); + CMCHKPK(SPkU32, param->pres, mBuf); + RETVALUE(ROK); +} + +/*********************************************************** + * + * Func : cmUnpkRgrLteAdvancedUeConfig + * + * + * Desc : unpacks LteAdvancedUeConfig + * + * + * Ret : S16 + * + * Notes: + * + * File : + * + **********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrLteAdvancedUeConfig +( + RgrLteAdvancedUeConfig *param, + Buffer *mBuf + ) +#else +PUBLIC S16 cmUnpkRgrLteAdvancedUeConfig(param, mBuf) + RgrLteAdvancedUeConfig *param; + Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrLteAdvancedUeConfig) + CMCHKUNPK(SUnpkU32, ¶m->pres, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->isAbsUe, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->isUeCellEdge, mBuf); + RETVALUE(ROK); +} + +/*********************************************************** + * + * Func : cmPkRgrAbsConfig + * + * + * Desc : Packs RgrAbsConfig + * + * + * Ret : S16 + * + * Notes: + * + * File : + * + **********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrAbsConfig +( + RgrAbsConfig *param, + Buffer *mBuf + ) +#else +PUBLIC S16 cmPkRgrAbsConfig(param, mBuf) + RgrAbsConfig *param; + Buffer *mBuf; +#endif +{ + S8 indx = 0; + + TRC3(cmPkRgrAbsConfig) + CMCHKPK(SPkU32, (U32)param->status, mBuf); + for (indx = RGR_ABS_PATTERN_LEN-1; indx >= 0; indx--) + { + CMCHKPK(SPkU8, param->absPattern[(U8)indx], mBuf); + } + + CMCHKPK(SPkU32, param->absPatternType, mBuf); + CMCHKPK(SPkU32, param->absLoadPeriodicity, mBuf); + + RETVALUE(ROK); + +} +/*********************************************************** + * + * Func : cmPkRgrSfrConfig + * + * + * Desc : Packs RgrSfrConfig + * + * + * Ret : S16 + * + * Notes: + * + * File : + * + **********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrSfrConfig +( + RgrSfrConfig *param, + Buffer *mBuf + ) +#else +PUBLIC S16 cmPkRgrSfrConfig(param, mBuf) + RgrSfrConfig *param; + Buffer *mBuf; +#endif +{ + TRC3(cmPkRgrSfrConfig) + + CMCHKPK(SPkU32, (U32)param->status, mBuf); +#ifdef TFU_UPGRADE + CMCHKPK(SPkU32, param->pwrThreshold.pHigh, mBuf); + CMCHKPK(SPkU32, param->pwrThreshold.pLow, mBuf); +#endif + CMCHKPK(SPkU8, param->cellEdgeRbRange.endRb, mBuf); + CMCHKPK(SPkU8, param->cellEdgeRbRange.startRb, mBuf); + + RETVALUE(ROK); + +} + + +/*********************************************************** + * + * Func : cmPkRgrDsfrConfig + * + * + * Desc : Packs RgrDsfrConfig + * + * + * Ret : S16 + * + * Notes: AIRSPAN_LTE_ADV_DSFR + * + * File : + * + **********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrDsfrConfig +( + RgrDsfrConfig *param, + Buffer *mBuf + ) +#else +PUBLIC S16 cmPkRgrDsfrConfig(param, mBuf) + RgrDsfrConfig *param; + Buffer *mBuf; +#endif +{ + TRC3(cmPkRgrDsfrConfig) + + CMCHKPK(SPkU32, (U32)param->status, mBuf); + + RETVALUE(ROK); + +} + + +/*********************************************************** + * + * Func : cmUnpkRgrDsfrConfig + * + * + * Desc : UnPacks RgrDsfrConfig + * + * + * Ret : S16 + * + * Notes: AIRSPAN_LTE_ADV_DSFR + * + * File : + * + **********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrDsfrConfig +( + RgrDsfrConfig *param, + Buffer *mBuf + ) +#else +PUBLIC S16 cmUnpkRgrDsfrConfig(param, mBuf) + RgrDsfrConfig *param; + Buffer *mBuf; +#endif +{ + TRC3(cmUnpkRgrDsfrConfig) + + CMCHKUNPK(SUnpkU32, (U32 *)¶m->status, mBuf); + RETVALUE(ROK); + +} + + +/*********************************************************** + * + * Func : cmPkRgrCellLteAdvancedFeatureCfg + * + * + * Desc : Cell LteAdvancedFeatureCfg + * + * + * Ret : S16 + * + * Notes: + * + * File : + * + **********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrCellLteAdvancedFeatureCfg +( + RgrLteAdvancedCellConfig *param, + Buffer *mBuf + ) +#else +PUBLIC S16 cmPkRgrCellLteAdvancedFeatureCfg(param, mBuf) + RgrLteAdvancedCellConfig *param; + Buffer *mBuf; +#endif +{ + TRC3(cmPkRgrCellLteAdvancedFeatureCfg) + + CMCHKPK(SPkU32, param->pres, mBuf); + CMCHKPK(cmPkRgrDsfrConfig, ¶m->dsfrCfg, mBuf); /*AIRSPAN_LTE_ADV_DSFR*/ + CMCHKPK(cmPkRgrSfrConfig, ¶m->sfrCfg, mBuf); + CMCHKPK(cmPkRgrAbsConfig, ¶m->absCfg, mBuf); + + RETVALUE(ROK); + +} + + +/*********************************************************** + * + * Func : cmUnpkRgrAbsConfig + * + * + * Desc : Unpacks AbsConfig + * + * + * Ret : S16 + * + * Notes: + * + * File : + * + **********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrAbsConfig +( + RgrAbsConfig *param, + Buffer *mBuf + ) +#else +PUBLIC S16 cmUnpkRgrAbsConfig(param, mBuf) + RgrAbsConfig *param; + Buffer *mBuf; +#endif +{ + + S8 indx = 0; + TRC3(cmUnpkRgrAbsConfig) + + CMCHKUNPK(SUnpkU32, ¶m->absLoadPeriodicity, mBuf); + CMCHKUNPK(SUnpkU32, ¶m->absPatternType, mBuf); + for (indx = 0; indx absPattern[(U8)indx], mBuf); + } + CMCHKUNPK(SUnpkU32, (U32*)¶m->status, mBuf); + + RETVALUE(ROK); + +} + +/*********************************************************** + * + * Func : cmUnpkRgrSfrConfig + * + * + * Desc : Unpacks SfrConfig + * + * + * Ret : S16 + * + * Notes: + * + * File : + * + **********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrSfrConfig +( + RgrSfrConfig *param, + Buffer *mBuf + ) +#else +PUBLIC S16 cmUnpkRgrSfrConfig(param, mBuf) + RgrSfrConfig *param; + Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrSfrConfig) + + CMCHKUNPK(SUnpkU8, ¶m->cellEdgeRbRange.startRb, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->cellEdgeRbRange.endRb, mBuf); +#ifdef TFU_UPGRADE + CMCHKUNPK(SUnpkU32, (U32*)¶m->pwrThreshold.pLow, mBuf); + CMCHKUNPK(SUnpkU32, (U32*)¶m->pwrThreshold.pHigh, mBuf); +#endif + CMCHKUNPK(SUnpkU32, (U32*)¶m->status, mBuf); + + RETVALUE(ROK); +} + +/*********************************************************** + * + * Func : cmUnpkRgrCellLteAdvancedFeatureCfg + * + * + * Desc : unpacks LteAdvancedFeatureCfg per cell + * + * + * Ret : S16 + * + * Notes: + * + * File : + * + **********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrCellLteAdvancedFeatureCfg +( + RgrLteAdvancedCellConfig *param, + Buffer *mBuf + ) +#else +PUBLIC S16 cmUnpkRgrCellLteAdvancedFeatureCfg(param, mBuf) + RgrLteAdvancedCellConfig *param; + Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrCellLteAdvancedFeatureCfg) + CMCHKUNPK(cmUnpkRgrAbsConfig, ¶m->absCfg, mBuf); + CMCHKUNPK(cmUnpkRgrSfrConfig, ¶m->sfrCfg, mBuf); + CMCHKUNPK(cmUnpkRgrDsfrConfig, ¶m->dsfrCfg, mBuf); /*AIRSPAN_LTE_ADV_DSFR*/ + CMCHKUNPK(SUnpkU32, ¶m->pres, mBuf); + + RETVALUE(ROK); +} + +/* LTE_ADV_FLAG_REMOVED_END */ + +/*********************************************************** +* +* Func : cmPkRgrSchedEnbCfg +* +* Desc : SCH ENB Configurations +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrSchedEnbCfg +( +RgrSchedEnbCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrSchedEnbCfg(param, mBuf) +RgrSchedEnbCfg *param; +Buffer *mBuf; +#endif +{ + + //S32 i; + TRC3(cmPkRgrSchedEnbCfg) + +#ifdef RG_5GTF + CMCHKPK(SPkU8, param->isDynTddEnbld, mBuf); +#endif + CMCHKPK(SPkU32, param->accsMode, mBuf); + switch(param->ulSchdType) + { + case RGR_SCH_TYPE_PFS: + CMCHKPK(cmPkRgrEnbPfs, ¶m->ulSchInfo.ulPfs, mBuf); + break; + default : + break; + } + CMCHKPK(SPkU8, param->ulSchdType, mBuf); + switch(param->dlSchdType) + { + case RGR_SCH_TYPE_PFS: + CMCHKPK(cmPkRgrEnbPfs, ¶m->dlSchInfo.dlPfs, mBuf); + break; + default : + break; + } + CMCHKPK(SPkU8, param->dlSchdType, mBuf); + CMCHKPK(SPkU8, param->numTxAntPorts, mBuf); + RETVALUE(ROK); +} /* cmPkRgrSchedEnbCfg */ + +/*********************************************************** +* +* Func : cmUnpkRgrSchedEnbCfg +* +* +* Desc : SCH Enodeb Configuration to SCH +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrSchedEnbCfg +( +RgrSchedEnbCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrSchedEnbCfg(param, mBuf) +RgrSchedEnbCfg *param; +Buffer *mBuf; +#endif +{ + + //S32 i; + U32 tmpEnum; + TRC3(cmUnpkRgrSchedEnbCfg) + + CMCHKUNPK(SUnpkU8, ¶m->numTxAntPorts, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->dlSchdType, mBuf); + switch(param->dlSchdType) + { + case RGR_SCH_TYPE_PFS: + CMCHKUNPK(cmUnpkRgrEnbPfs, ¶m->dlSchInfo.dlPfs, mBuf); + break; + default : + break; + } + CMCHKUNPK(SUnpkU8, ¶m->ulSchdType, mBuf); + switch(param->ulSchdType) + { + case RGR_SCH_TYPE_PFS: + CMCHKUNPK(cmUnpkRgrEnbPfs, ¶m->ulSchInfo.ulPfs, mBuf); + break; + default : + break; + } + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->accsMode = (RgrCellAccsMode) tmpEnum; +#ifdef RG_5GTF + CMCHKUNPK(SUnpkU8, ¶m->isDynTddEnbld, mBuf); +#endif + RETVALUE(ROK); +} /* cmUnpkRgrSchedEnbCfg */ + + +/*********************************************************** +* +* Func : cmPkRgrCellCfg +* +* +* Desc : Cell Configuration at RRM +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrCellCfg +( +RgrCellCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrCellCfg(param, mBuf) +RgrCellCfg *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkRgrCellCfg) + +#ifdef EMTC_ENABLE +/* EMTC related changes start*/ + + +/* EMTC related changes ends*/ +#endif + +#ifdef RG_5GTF + CMCHKPK(cmPkRgr5gtfCellCfg, ¶m->Cell5gtfCfg, mBuf); +#endif +#ifdef LTE_ADV + CMCHKPK(SPkU8, param->isPucchFormat3Sptd, mBuf); +#endif +/*LAA: Pack LAA params*/ + CMCHKPK(cmPkRgrLteUCellCfg, ¶m->lteUCfg, mBuf); + CMCHKPK(SPkU32, param->msg4pAVal, mBuf); + CMCHKPK(SPkU8, param->isAutoCfgModeEnb, mBuf); + CMCHKPK(SPkU8, param->isDynCfiEnb, mBuf); + CMCHKPK(SPkU16, param->phichTxPwrOffset, mBuf); + CMCHKPK(SPkU16, param->rarTxPwrOffset, mBuf); + CMCHKPK(SPkU16, param->pcchTxPwrOffset, mBuf); + CMCHKPK(SPkU16, param->bcchTxPwrOffset, mBuf); + + CMCHKPK(SPkU16, param->t300TmrVal, mBuf); +/*rgr_c_001.main_7 - Added support for SPS*/ + CMCHKPK(cmPkRgrSpsCellCfg, ¶m->spsCfg, mBuf); + +/* rgr_c_001.main_3: Added TTI indication from MAC to RGR user */ + CMCHKPK(SPkU8, param->rrmTtiIndPrd, mBuf); +#ifdef LTE_TDD + CMCHKPK(cmPkRgrTddPrachRscInfo, ¶m->prachRscInfo, mBuf); + CMCHKPK(SPkU8, param->spclSfCfgIdx, mBuf); + CMCHKPK(SPkU8, param->ulDlCfgIdx, mBuf); + +#endif + CMCHKPK(cmPkRgrCellCsgParamCfg, ¶m->csgParamCfg, mBuf); + for (i=param->numCmnLcs-1; i >= 0; i--) { + CMCHKPK(cmPkRgrCmnLchCfg, ¶m->cmnLcCfg[i], mBuf); + } + CMCHKPK(SPkU8, param->numCmnLcs, mBuf); + CMCHKPK(cmPkRgrPreambleSetCfg, ¶m->macPreambleSet, mBuf); + CMCHKPK(cmPkRgrPuschCfg, ¶m->puschCfg, mBuf); + CMCHKPK(cmPkRgrUlPwrCfg, ¶m->pwrCfg, mBuf); + CMCHKPK(cmPkRgrSiCfg, ¶m->siCfg, mBuf); + CMCHKPK(cmPkRgrRachCfg, ¶m->rachCfg, mBuf); + CMCHKPK(cmPkRgrSrsCfg, ¶m->srsCfg, mBuf); + CMCHKPK(cmPkRgrPucchCfg, ¶m->pucchCfg, mBuf); + CMCHKPK(cmPkRgrPhichCfg, ¶m->phichCfg, mBuf); + /* LTE_ADV_FLAG_REMOVED_START */ + CMCHKPK(cmPkRgrCellLteAdvancedFeatureCfg, ¶m->rgrLteAdvCfg, mBuf); + /* LTE_ADV_FLAG_REMOVED_END */ + CMCHKPK(cmPkRgrBwCfg, ¶m->bwCfg, mBuf); + CMCHKPK(cmPkRgrDlfsCfg, ¶m->dlfsCfg, mBuf); + CMCHKPK(cmPkRgrUlCmnCodeRateCfg, ¶m->ulCmnCodeRate, mBuf); + CMCHKPK(cmPkRgrPuschSubBandCfg, ¶m->puschSubBand, mBuf); + CMCHKPK(cmPkRgrDlCmnCodeRateCfg, ¶m->dlCmnCodeRate, mBuf); + CMCHKPK(cmPkRgrUlTrgCqiCfg, ¶m->trgUlCqi, mBuf); + CMCHKPK(cmPkRgrCfiCfg, ¶m->cfiCfg, mBuf); + CMCHKPK(cmPkRgrRntiCfg, ¶m->macRnti, mBuf); + CMCHKPK(cmPkRgrDlHqCfg, ¶m->dlHqCfg, mBuf); + CMCHKPK(SPkU8, param->dlfsSchdType, mBuf); + + CMCHKPK(SPkS8, param->pMax, mBuf); + CMCHKPK(SPkU8, param->cellModSchm, mBuf); + CMCHKPK(SPkU8, param->isCpDlExtend, mBuf); + CMCHKPK(SPkU8, param->isCpUlExtend, mBuf); + CMCHKPK(SPkU8, param->maxUlUeNewTxPerTti, mBuf); + CMCHKPK(SPkU8, param->maxDlUeNewTxPerTti, mBuf); + CMCHKPK(SPkU8, param->maxDlRetxBw, mBuf); + CMCHKPK(SPkU8, param->maxDlBwPerUe, mBuf); + CMCHKPK(SPkU8, param->maxUlBwPerUe, mBuf); + CMCHKPK(SPkU8, param->maxCcchPerDlSf, mBuf); + CMCHKPK(SPkU8, param->maxUePerDlSf, mBuf); + CMCHKPK(SPkU8, param->maxUePerUlSf, mBuf); +#ifdef RGR_V1 + /* rgr_x_001.main_7: [ccpu00112789] Added configuration for maximum number + of MSG3s */ + CMCHKPK(SPkU8, param->maxMsg3PerUlSf, mBuf); +#endif + CMCHKPK(SPkU8, param->macInst, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + +#ifdef EMTC_ENABLE +/* EMTC related changes start*/ + CMCHKPK(SPkU8, param->emtcEnable, mBuf); + CMCHKPK(cmPkRgrEmtcCfg, ¶m->emtcCellCfg, mBuf); +/* EMTC related changes ends*/ +#endif + + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrCellCfg +* +* +* Desc : Cell Configuration at RRM +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrCellCfg +( +RgrCellCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrCellCfg(param, mBuf) +RgrCellCfg *param; +Buffer *mBuf; +#endif +{ + + S32 i; + + TRC3(cmUnpkRgrCellCfg) +#ifdef EMTC_ENABLE +/* EMTC related changes start*/ + CMCHKUNPK(cmUnpkRgrEmtcCfg, ¶m->emtcCellCfg, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->emtcEnable, mBuf); +/* EMTC related changes ends*/ +#endif + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->macInst, mBuf); +#ifdef RGR_V1 + /* rgr_x_001.main_7: [ccpu00112789] Added configuration for maximum number + of MSG3s */ + CMCHKUNPK(SUnpkU8, ¶m->maxMsg3PerUlSf, mBuf); +#endif + CMCHKUNPK(SUnpkU8, ¶m->maxUePerUlSf, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->maxUePerDlSf, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->maxCcchPerDlSf, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->maxUlBwPerUe, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->maxDlBwPerUe, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->maxDlRetxBw, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->maxDlUeNewTxPerTti, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->maxUlUeNewTxPerTti, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->isCpUlExtend, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->isCpDlExtend, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->cellModSchm, mBuf); + CMCHKUNPK(SUnpkS8, ¶m->pMax, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->dlfsSchdType, mBuf); + CMCHKUNPK(cmUnpkRgrDlHqCfg, ¶m->dlHqCfg, mBuf); + CMCHKUNPK(cmUnpkRgrRntiCfg, ¶m->macRnti, mBuf); + CMCHKUNPK(cmUnpkRgrCfiCfg, ¶m->cfiCfg, mBuf); + CMCHKUNPK(cmUnpkRgrUlTrgCqiCfg, ¶m->trgUlCqi, mBuf); + CMCHKUNPK(cmUnpkRgrDlCmnCodeRateCfg, ¶m->dlCmnCodeRate, mBuf); + CMCHKUNPK(cmUnpkRgrPuschSubBandCfg, ¶m->puschSubBand, mBuf); + CMCHKUNPK(cmUnpkRgrUlCmnCodeRateCfg, ¶m->ulCmnCodeRate, mBuf); + CMCHKUNPK(cmUnpkRgrDlfsCfg, ¶m->dlfsCfg, mBuf); + CMCHKUNPK(cmUnpkRgrBwCfg, ¶m->bwCfg, mBuf); + /* LTE_ADV_FLAG_REMOVED_START */ + CMCHKUNPK(cmUnpkRgrCellLteAdvancedFeatureCfg, ¶m->rgrLteAdvCfg, mBuf); + /* LTE_ADV_FLAG_REMOVED_END */ + CMCHKUNPK(cmUnpkRgrPhichCfg, ¶m->phichCfg, mBuf); + CMCHKUNPK(cmUnpkRgrPucchCfg, ¶m->pucchCfg, mBuf); + CMCHKUNPK(cmUnpkRgrSrsCfg, ¶m->srsCfg, mBuf); + CMCHKUNPK(cmUnpkRgrRachCfg, ¶m->rachCfg, mBuf); + CMCHKUNPK(cmUnpkRgrSiCfg, ¶m->siCfg, mBuf); + CMCHKUNPK(cmUnpkRgrUlPwrCfg, ¶m->pwrCfg, mBuf); + CMCHKUNPK(cmUnpkRgrPuschCfg, ¶m->puschCfg, mBuf); + CMCHKUNPK(cmUnpkRgrPreambleSetCfg, ¶m->macPreambleSet, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numCmnLcs, mBuf); + for (i=0; inumCmnLcs; i++) { + CMCHKUNPK(cmUnpkRgrCmnLchCfg, ¶m->cmnLcCfg[i], mBuf); + } + CMCHKUNPK(cmUnpkRgrCellCsgParamCfg, ¶m->csgParamCfg, mBuf); + +#ifdef LTE_TDD + CMCHKUNPK(SUnpkU8, ¶m->ulDlCfgIdx, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->spclSfCfgIdx, mBuf); + CMCHKUNPK(cmUnpkRgrTddPrachRscInfo, ¶m->prachRscInfo, mBuf); + +#endif +/* rgr_c_001.main_3: Added TTI indication from MAC to RGR user */ + CMCHKUNPK(SUnpkU8, ¶m->rrmTtiIndPrd, mBuf); + /*rgr_c_001.main_7 - Added support for SPS*/ + CMCHKUNPK(cmUnpkRgrSpsDlCellCfg, ¶m->spsCfg, mBuf); + + CMCHKUNPK(SUnpkU16, ¶m->t300TmrVal, mBuf); + CMCHKPK(SUnpkU16, ¶m->bcchTxPwrOffset, mBuf); + CMCHKPK(SUnpkU16, ¶m->pcchTxPwrOffset, mBuf); + CMCHKPK(SUnpkU16, ¶m->rarTxPwrOffset, mBuf); + CMCHKPK(SUnpkU16, ¶m->phichTxPwrOffset, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->isDynCfiEnb, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->isAutoCfgModeEnb, mBuf); + CMCHKPK(SUnpkU32, (U32*)¶m->msg4pAVal, mBuf); + /*LAA: Unpack LAA Cell params*/ + CMCHKUNPK(cmUnpkRgrLteUCellCfg, ¶m->lteUCfg, mBuf); + #ifdef LTE_ADV + CMCHKUNPK(SUnpkU8, ¶m->isPucchFormat3Sptd, mBuf); +#endif +#ifdef RG_5GTF + CMCHKUNPK(cmUnPkRgr5gtfCellCfg, ¶m->Cell5gtfCfg, mBuf); +#endif + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrUeAprdDlCqiCfg +* +* +* Desc : Downlink Aperiodic CQI reporting related configuration per UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUeAprdDlCqiCfg +( +RgrUeAprdDlCqiCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUeAprdDlCqiCfg(param, mBuf) +RgrUeAprdDlCqiCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrUeAprdDlCqiCfg) + /*Pack Aperiodic Trigger List only for Pcell */ +#ifdef LTE_ADV + CMCHKPK(SPkU8, param->triggerSet2, mBuf); + CMCHKPK(SPkU8, param->triggerSet1, mBuf); +#endif + + CMCHKPK(SPkU32, param->aprdModeEnum, mBuf); + CMCHKPK(SPkU8, param->pres, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrUeAprdDlCqiCfg +* +* +* Desc : Downlink Aperiodic CQI reporting related configuration per UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUeAprdDlCqiCfg +( +RgrUeAprdDlCqiCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUeAprdDlCqiCfg(param, mBuf) +RgrUeAprdDlCqiCfg *param; +Buffer *mBuf; +#endif +{ + U32 tmpEnum; + + TRC3(cmUnpkRgrUeAprdDlCqiCfg) + + CMCHKUNPK(SUnpkU8, ¶m->pres, mBuf); + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->aprdModeEnum = (RgrAprdCqiMode) tmpEnum; + +#ifdef LTE_ADV + CMCHKUNPK(SUnpkU8, ¶m->triggerSet1, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->triggerSet2, mBuf); +#endif + + RETVALUE(ROK); +} + + +/* rgr_c_001.main_8. Added changes of TFU_UPGRADE */ +#ifndef TFU_UPGRADE + + +/*********************************************************** +* +* Func : cmPkRgrUePrdDlCqiCfg +* +* +* Desc : Downlink Periodic CQI reporting related configuration per UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUePrdDlCqiCfg +( +RgrUePrdDlCqiCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUePrdDlCqiCfg(param, mBuf) +RgrUePrdDlCqiCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrUePrdDlCqiCfg) + + CMCHKPK(SPkU16, param->cqiPmiCfgIdx, mBuf); + CMCHKPK(SPkU8, param->k, mBuf); + CMCHKPK(SPkS8, param->cqiOffst, mBuf); + CMCHKPK(SPkU8, param->subframeOffst, mBuf); + CMCHKPK(SPkU32, param->prdicityEnum, mBuf); + CMCHKPK(SPkU32, param->prdModeEnum, mBuf); + CMCHKPK(SPkU8, param->pres, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrUePrdDlCqiCfg +* +* +* Desc : Downlink Periodic CQI reporting related configuration per UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUePrdDlCqiCfg +( +RgrUePrdDlCqiCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUePrdDlCqiCfg(param, mBuf) +RgrUePrdDlCqiCfg *param; +Buffer *mBuf; +#endif +{ + U32 tmpEnum; + + TRC3(cmUnpkRgrUePrdDlCqiCfg) + + CMCHKUNPK(SUnpkU8, ¶m->pres, mBuf); + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->prdModeEnum = tmpEnum; + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->prdicityEnum = tmpEnum; + CMCHKUNPK(SUnpkU8, ¶m->subframeOffst, mBuf); + CMCHKUNPK(SUnpkS8, ¶m->cqiOffst, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->k, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->cqiPmiCfgIdx, mBuf); + RETVALUE(ROK); +} + + +#endif + +/* rgr_c_001.main_8. Added changes of TFU_UPGRADE */ +#ifdef TFU_UPGRADE +/*********************************************************** +* +* Func : cmPkRgrUeDlPCqiSetup +* +* +* Desc : Periodic CQI Setup configuration parameters information +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUeDlPCqiSetup +( +RgrUeDlPCqiSetup *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUeDlPCqiSetup(param, mBuf) +RgrUeDlPCqiSetup *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrUeDlPCqiSetup) + + CMCHKPK(SPkU32, param->prdModeEnum, mBuf); + CMCHKPK(SPkU8, param->sANCQI, mBuf); + /*rgr_c_001.main_9 DEL removed unwanted comments*/ + CMCHKPK(SPkU16, param->riCfgIdx, mBuf); + CMCHKPK(SPkU8, param->riEna, mBuf); + CMCHKPK(SPkU8, param->k, mBuf); + CMCHKPK(SPkU8, param->cqiRepType, mBuf); + CMCHKPK(SPkU16, param->cqiPCfgIdx, mBuf); + CMCHKPK(SPkU16, param->cqiPResIdx, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrUeDlPCqiSetup +* +* +* Desc : Periodic CQI Setup configuration parameters information +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUeDlPCqiSetup +( +RgrUeDlPCqiSetup *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUeDlPCqiSetup(param, mBuf) +RgrUeDlPCqiSetup *param; +Buffer *mBuf; +#endif +{ + U32 tmpEnum; + + TRC3(cmUnpkRgrUeDlPCqiSetup) + + CMCHKUNPK(SUnpkU16, ¶m->cqiPResIdx, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->cqiPCfgIdx, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->cqiRepType, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->k, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->riEna, mBuf); + /*rgr_c_001.main_9 DEL removed unwanted comments*/ + CMCHKUNPK(SUnpkU16, ¶m->riCfgIdx, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->sANCQI, mBuf); + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->prdModeEnum = (RgrPrdCqiMode) tmpEnum; + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrUePrdDlCqiCfg +* +* +* Desc : Periodic CQI/PMI/RI configuration parameters information +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUePrdDlCqiCfg +( +RgrUePrdDlCqiCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUePrdDlCqiCfg(param, mBuf) +RgrUePrdDlCqiCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrUePrdDlCqiCfg) + + CMCHKPK(cmPkRgrUeDlPCqiSetup, ¶m->cqiSetup, mBuf); + CMCHKPK(SPkU8, param->type, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrUePrdDlCqiCfg +* +* +* Desc : Periodic CQI/PMI/RI configuration parameters information +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUePrdDlCqiCfg +( +RgrUePrdDlCqiCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUePrdDlCqiCfg(param, mBuf) +RgrUePrdDlCqiCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrUePrdDlCqiCfg) + + CMCHKUNPK(SUnpkU8, ¶m->type, mBuf); + CMCHKUNPK(cmUnpkRgrUeDlPCqiSetup, ¶m->cqiSetup, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrUeUlSrsSetupCfg +* +* +* Desc : SRS configuration setup parameters information. + Reference 36.313 SoundingRS-UL-Config +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUeUlSrsSetupCfg +( +RgrUeUlSrsSetupCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUeUlSrsSetupCfg(param, mBuf) +RgrUeUlSrsSetupCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrUeUlSrsSetupCfg) + + CMCHKPK(SPkU8, param->fDomPosi, mBuf); + CMCHKPK(SPkU8, param->txComb, mBuf); + CMCHKPK(SPkU8, param->sANSrs, mBuf); + CMCHKPK(SPkU8, param->duration, mBuf); + CMCHKPK(SPkU32, param->cycShift, mBuf); + CMCHKPK(SPkU32, param->srsHopBw, mBuf); + CMCHKPK(SPkU32, param->srsBw, mBuf); + /*rgr_c_001.main_9 DEL removed unwanted comments*/ + CMCHKPK(SPkU16, param->srsCfgIdx, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrUeUlSrsSetupCfg +* +* +* Desc : SRS configuration setup parameters information. + Reference 36.313 SoundingRS-UL-Config +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUeUlSrsSetupCfg +( +RgrUeUlSrsSetupCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUeUlSrsSetupCfg(param, mBuf) +RgrUeUlSrsSetupCfg *param; +Buffer *mBuf; +#endif +{ + U32 tmpEnum; + + TRC3(cmUnpkRgrUeUlSrsSetupCfg) + + /*rgr_c_001.main_9 DEL removed unwanted comments*/ + CMCHKUNPK(SUnpkU16, ¶m->srsCfgIdx, mBuf); + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->srsBw = (RgrUlSrsBwInfo) tmpEnum; + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->srsHopBw = (RgrUlSrsHoBwInfo) tmpEnum; + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->cycShift = (RgrUlSrsCycShiftInfo) tmpEnum; + CMCHKUNPK(SUnpkU8, ¶m->duration, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->sANSrs, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->txComb, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->fDomPosi, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrUeSrSetupCfg +* +* +* Desc : SR Setup configuration parameters information +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUeSrSetupCfg +( +RgrUeSrSetupCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUeSrSetupCfg(param, mBuf) +RgrUeSrSetupCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrUeSrSetupCfg) + + /* ccpu00131601:DEL - dTMax Packing removed since this param will not + * be required by Scheduler*/ + CMCHKPK(SPkU8, param->srCfgIdx, mBuf); + CMCHKPK(SPkU16, param->srResIdx, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrUeSrSetupCfg +* +* +* Desc : SR Setup configuration parameters information +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUeSrSetupCfg +( +RgrUeSrSetupCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUeSrSetupCfg(param, mBuf) +RgrUeSrSetupCfg *param; +Buffer *mBuf; +#endif +{ + TRC3(cmUnpkRgrUeSrSetupCfg) + + CMCHKUNPK(SUnpkU16, ¶m->srResIdx, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->srCfgIdx, mBuf); + /* ccpu00131601:DEL - dTMax UnPacking removed since this param will not + * be required by Scheduler*/ + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrUeSrCfg +* +* +* Desc : SR configuration parameters information +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUeSrCfg +( +RgrUeSrCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUeSrCfg(param, mBuf) +RgrUeSrCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrUeSrCfg) + + CMCHKPK(cmPkRgrUeSrSetupCfg, ¶m->srSetup, mBuf); + CMCHKPK(SPkU8, param->type, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrUeSrCfg +* +* +* Desc : SR configuration parameters information +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUeSrCfg +( +RgrUeSrCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUeSrCfg(param, mBuf) +RgrUeSrCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrUeSrCfg) + + CMCHKUNPK(SUnpkU8, ¶m->type, mBuf); + CMCHKUNPK(cmUnpkRgrUeSrSetupCfg, ¶m->srSetup, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrUeUlSrsCfg +* +* +* Desc : SRS configuration parameters information. + Reference 36.313 SoundingRS-UL-Config +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUeUlSrsCfg +( +RgrUeUlSrsCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUeUlSrsCfg(param, mBuf) +RgrUeUlSrsCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrUeUlSrsCfg) + + /*rgr_c_001.main_9 DEL removed unwanted comments*/ + CMCHKPK(cmPkRgrUeUlSrsSetupCfg, ¶m->srsSetup, mBuf); + CMCHKPK(SPkU8, param->type, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrUeUlSrsCfg +* +* +* Desc : SRS configuration parameters information. + Reference 36.313 SoundingRS-UL-Config +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUeUlSrsCfg +( +RgrUeUlSrsCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUeUlSrsCfg(param, mBuf) +RgrUeUlSrsCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrUeUlSrsCfg) + + CMCHKUNPK(SUnpkU8, ¶m->type, mBuf); + /*rgr_c_001.main_9 DEL removed unwanted comments*/ + CMCHKUNPK(cmUnpkRgrUeUlSrsSetupCfg, ¶m->srsSetup, mBuf); + RETVALUE(ROK); +} + + +#endif /*TFU_UPGRADE */ + + +/*********************************************************** +* +* Func : cmPkRgrUeDlCqiCfg +* +* +* Desc : Downlink CQI reporting related configuration per UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUeDlCqiCfg +( +RgrUeDlCqiCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUeDlCqiCfg(param, mBuf) +RgrUeDlCqiCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrUeDlCqiCfg) + + +/* rgr_c_001.main_8. Added changes of TFU_UPGRADE */ +#ifdef TFU_UPGRADE + CMCHKPK(cmPkRgrUePrdDlCqiCfg, ¶m->prdCqiCfg, mBuf); +#endif + +/* rgr_c_001.main_8. Added changes of TFU_UPGRADE */ +#ifndef TFU_UPGRADE + CMCHKPK(cmPkRgrUePrdDlCqiCfg, ¶m->prdCqiCfg, mBuf); +#endif + CMCHKPK(cmPkRgrUeAprdDlCqiCfg, ¶m->aprdCqiCfg, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrUeDlCqiCfg +* +* +* Desc : Downlink CQI reporting related configuration per UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUeDlCqiCfg +( +RgrUeDlCqiCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUeDlCqiCfg(param, mBuf) +RgrUeDlCqiCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrUeDlCqiCfg) + + CMCHKUNPK(cmUnpkRgrUeAprdDlCqiCfg, ¶m->aprdCqiCfg, mBuf); + CMCHKUNPK(cmUnpkRgrUePrdDlCqiCfg, ¶m->prdCqiCfg, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrUeMeasGapCfg +* +* +* Desc : Measurement gap configuration for UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUeMeasGapCfg +( +RgrUeMeasGapCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUeMeasGapCfg(param, mBuf) +RgrUeMeasGapCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrUeMeasGapCfg) + + CMCHKPK(SPkU8, param->gapOffst, mBuf); + CMCHKPK(SPkU8, param->gapPrd, mBuf); + CMCHKPK(SPkU8, param->isMesGapEnabled, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrUeMeasGapCfg +* +* +* Desc : Measurement gap configuration for UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUeMeasGapCfg +( +RgrUeMeasGapCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUeMeasGapCfg(param, mBuf) +RgrUeMeasGapCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrUeMeasGapCfg) + + CMCHKUNPK(SUnpkU8, ¶m->isMesGapEnabled, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->gapPrd, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->gapOffst, mBuf); + RETVALUE(ROK); +} + +/*rgr_c_001.main_9 ADD DRX functionality under flag*/ + +/*********************************************************** +* +* Func : cmPkRgrDrxLongCycleOffst +* +* +* Desc : DRX Long Cycle Offset +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrDrxLongCycleOffst +( +RgrDrxLongCycleOffst *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrDrxLongCycleOffst(param, mBuf) +RgrDrxLongCycleOffst *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrDrxLongCycleOffst) + + CMCHKPK(SPkU16, param->drxStartOffst, mBuf); + CMCHKPK(SPkU16, param->longDrxCycle, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrDrxLongCycleOffst +* +* +* Desc : DRX Long Cycle Offset +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrDrxLongCycleOffst +( +RgrDrxLongCycleOffst *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrDrxLongCycleOffst(param, mBuf) +RgrDrxLongCycleOffst *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrDrxLongCycleOffst) + + CMCHKUNPK(SUnpkU16, ¶m->longDrxCycle, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->drxStartOffst, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrDrxShortDrx +* +* +* Desc : DRX Short Cycle Offset +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrDrxShortDrx +( +RgrDrxShortDrx *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrDrxShortDrx(param, mBuf) +RgrDrxShortDrx *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrDrxShortDrx) + + CMCHKPK(SPkU8, param->drxShortCycleTmr, mBuf); + CMCHKPK(SPkU16, param->shortDrxCycle, mBuf); + CMCHKPK(SPkU8, param->pres, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrDrxShortDrx +* +* +* Desc : DRX Short Cycle Offset +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrDrxShortDrx +( +RgrDrxShortDrx *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrDrxShortDrx(param, mBuf) +RgrDrxShortDrx *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrDrxShortDrx) + + CMCHKUNPK(SUnpkU8, ¶m->pres, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->shortDrxCycle, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->drxShortCycleTmr, mBuf); + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func : cmPkRgrUeDrxCfg +* +* +* Desc : DRX configuration for UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUeDrxCfg +( +RgrUeDrxCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUeDrxCfg(param, mBuf) +RgrUeDrxCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrUeDrxCfg) + + CMCHKPK(cmPkRgrDrxShortDrx, ¶m->drxShortDrx, mBuf); + CMCHKPK(cmPkRgrDrxLongCycleOffst, ¶m->drxLongCycleOffst, mBuf); + CMCHKPK(SPkU16, param->drxRetxTmr, mBuf); +#ifdef EMTC_ENABLE + CMCHKPK(SPkU8, param->drxRetxTmrR13Pres, mBuf); + CMCHKPK(SPkU8, param->drxOnDurTmrR13Pres, mBuf); + CMCHKPK(SPkU16, param->emtcDrxUlRetxTmr, mBuf); + CMCHKPK(SPkU8, param->isEmtcUe, mBuf); +#endif + CMCHKPK(SPkU16, param->drxInactvTmr, mBuf); + CMCHKPK(SPkU16, param->drxOnDurTmr, mBuf); +/*rgr_c_001.main_9 ADD added changes for R9*/ +#ifdef LTEMAC_R9 + CMCHKPK(cmPkTknS32, ¶m->cqiMask, mBuf); +#endif + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrUeDrxCfg +* +* +* Desc : DRX configuration for UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUeDrxCfg +( +RgrUeDrxCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUeDrxCfg(param, mBuf) +RgrUeDrxCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrUeDrxCfg) + +/*rgr_c_001.main_9 ADD added changes for R9*/ +#ifdef LTEMAC_R9 + CMCHKUNPK(cmUnpkTknS32, ¶m->cqiMask, mBuf); +#endif + CMCHKUNPK(SUnpkU16, ¶m->drxOnDurTmr, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->drxInactvTmr, mBuf); +#ifdef EMTC_ENABLE + CMCHKUNPK(SUnpkU8, ¶m->isEmtcUe, mBuf); + CMCHKUNPK(SUnpkU16,¶m->emtcDrxUlRetxTmr, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->drxOnDurTmrR13Pres, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->drxRetxTmrR13Pres, mBuf); +#endif + CMCHKUNPK(SUnpkU16, ¶m->drxRetxTmr, mBuf); + CMCHKUNPK(cmUnpkRgrDrxLongCycleOffst, ¶m->drxLongCycleOffst, mBuf); + CMCHKUNPK(cmUnpkRgrDrxShortDrx, ¶m->drxShortDrx, mBuf); + RETVALUE(ROK); +} + +/*rgr_c_001.main_9 ADD added DRX changes under DRX*/ + +/*********************************************************** +* +* Func : cmPkRgrUeCapCfg +* +* +* Desc : RgrUeCapCfg +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUeCapCfg +( +RgrUeCapCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUeCapCfg(param, mBuf) +RgrUeCapCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrUeCapCfg) + + CMCHKPK(SPkU8, param->txAntSel, mBuf); + CMCHKPK(SPkU8, param->simCqiAckNack, mBuf); + CMCHKPK(SPkU8, param->resAloocType1, mBuf); + CMCHKPK(SPkU8, param->intraSfFeqHop, mBuf); + CMCHKPK(SPkU8, param->pwrClass, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrUeCapCfg +* +* +* Desc : RgrUeCapCfg +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUeCapCfg +( +RgrUeCapCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUeCapCfg(param, mBuf) +RgrUeCapCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrUeCapCfg) + + CMCHKUNPK(SUnpkU8, ¶m->pwrClass, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->intraSfFeqHop, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->resAloocType1, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->simCqiAckNack, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->txAntSel, mBuf); + + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func : cmPkRgrUeAckNackRepCfg +* +* +* Desc : rgrUeAckNackRepCfg +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUeAckNackRepCfg +( +RgrUeAckNackRepCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUeAckNackRepCfg(param, mBuf) +RgrUeAckNackRepCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrUeAckNackRepCfg) + + CMCHKPK(SPkU32, param->ackNackRepFactor, mBuf); + CMCHKPK(SPkU16, param->pucchAckNackRep, mBuf); + CMCHKPK(SPkU8, param->isAckNackEnabled, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrUeAckNackRepCfg +* +* +* Desc : rgrUeAckNackRepCfg +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUeAckNackRepCfg +( +RgrUeAckNackRepCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUeAckNackRepCfg(param, mBuf) +RgrUeAckNackRepCfg *param; +Buffer *mBuf; +#endif +{ + U32 tmpEnum; + + TRC3(cmUnpkRgrUeAckNackRepCfg) + + CMCHKUNPK(SUnpkU8, ¶m->isAckNackEnabled, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->pucchAckNackRep, mBuf); + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->ackNackRepFactor = (RgrAckNackRepFactor) tmpEnum; + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrUeTxModeCfg +* +* +* Desc : Transmission mode configuration per UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUeTxModeCfg +( +RgrUeTxModeCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUeTxModeCfg(param, mBuf) +RgrUeTxModeCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrUeTxModeCfg) + + CMCHKPK(SPkU32, param->txModeEnum, mBuf); + CMCHKPK(SPkU32, param->tmTrnstnState, mBuf); + CMCHKPK(SPkU8, param->pres, mBuf); + + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrUeTxModeCfg +* +* +* Desc : Transmission mode configuration per UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUeTxModeCfg +( +RgrUeTxModeCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUeTxModeCfg(param, mBuf) +RgrUeTxModeCfg *param; +Buffer *mBuf; +#endif +{ + U32 tmpEnum; + + TRC3(cmUnpkRgrUeTxModeCfg) + + CMCHKUNPK(SUnpkU8, ¶m->pres, mBuf); + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->tmTrnstnState = (RgrTxModeTrnstn) tmpEnum; + + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->txModeEnum = (RgrTxMode) tmpEnum; + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrUeUlHqCfg +* +* +* Desc : Uplink HARQ configuration per UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUeUlHqCfg +( +RgrUeUlHqCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUeUlHqCfg(param, mBuf) +RgrUeUlHqCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrUeUlHqCfg) + + CMCHKPK(SPkU8, param->deltaHqOffst, mBuf); + CMCHKPK(SPkU8, param->maxUlHqTx, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrUeUlHqCfg +* +* +* Desc : Uplink HARQ configuration per UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUeUlHqCfg +( +RgrUeUlHqCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUeUlHqCfg(param, mBuf) +RgrUeUlHqCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrUeUlHqCfg) + + CMCHKUNPK(SUnpkU8, ¶m->maxUlHqTx, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->deltaHqOffst, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrUeGrpPwrCfg +* +* +* Desc : Group power configuration per UE for PUCCH and PUSCH group power control +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUeGrpPwrCfg +( +RgrUeGrpPwrCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUeGrpPwrCfg(param, mBuf) +RgrUeGrpPwrCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrUeGrpPwrCfg) + + CMCHKPK(SPkU8, param->idx, mBuf); + CMCHKPK(cmPkLteRnti, param->tpcRnti, mBuf); + CMCHKPK(SPkU8, param->pres, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrUeGrpPwrCfg +* +* +* Desc : Group power configuration per UE for PUCCH and PUSCH group power control +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUeGrpPwrCfg +( +RgrUeGrpPwrCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUeGrpPwrCfg(param, mBuf) +RgrUeGrpPwrCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrUeGrpPwrCfg) + + CMCHKUNPK(SUnpkU8, ¶m->pres, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->tpcRnti, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->idx, mBuf); + RETVALUE(ROK); +} + +/*rgr_c_001.main_7 - Added support for SPS*/ + + +/*********************************************************** +* +* Func : cmPkRgrUeSpsDlCfg +* +* +* Desc : DL SPS configuration parameters per UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUeSpsDlCfg +( +RgrUeSpsDlCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUeSpsDlCfg(param, mBuf) +RgrUeSpsDlCfg *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkRgrUeSpsDlCfg) + CMCHKPK(SPkU16, param->explicitRelCnt, mBuf); + CMCHKPK(SPkU32, param->dlSpsPrdctyEnum, mBuf); + for (i=param->numPucchVal-1; i >= 0; i--) { + CMCHKPK(SPkU32, param->n1PucchVal[i], mBuf); + } + CMCHKPK(SPkU8, param->numPucchVal, mBuf); + CMCHKPK(SPkU8, param->numSpsHqProc, mBuf); + CMCHKPK(SPkU8, param->isDlSpsEnabled, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrUeSpsDlCfg +* +* +* Desc : DL SPS configuration parameters per UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUeSpsDlCfg +( +RgrUeSpsDlCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUeSpsDlCfg(param, mBuf) +RgrUeSpsDlCfg *param; +Buffer *mBuf; +#endif +{ + U32 tmpEnum; + + S32 i; + TRC3(cmUnpkRgrUeSpsDlCfg) + + CMCHKUNPK(SUnpkU8, ¶m->isDlSpsEnabled, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numSpsHqProc, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numPucchVal, mBuf); + for (i=0; inumPucchVal; i++) { + CMCHKUNPK(SUnpkU32, ¶m->n1PucchVal[i], mBuf); + } + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->dlSpsPrdctyEnum = tmpEnum; + CMCHKUNPK(SUnpkU16, ¶m->explicitRelCnt, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrUeSpsUlCfg +* +* +* Desc : UL SPS configuration parameters per UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUeSpsUlCfg +( +RgrUeSpsUlCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUeSpsUlCfg(param, mBuf) +RgrUeSpsUlCfg *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkRgrUeSpsUlCfg) + + CMCHKPK(SPkU8, param->isLcSRMaskEnab, mBuf); + for (i=param->lcCnt-1; i >= 0; i--) { + /* SPS Changes starts */ + CMCHKPK(SPkU8, param->spsLcInfo[i].isSpsEnabled, mBuf); + CMCHKPK(SPkU8, param->spsLcInfo[i].lcId, mBuf); + /* SPS Changes ends */ + } + CMCHKPK(SPkU8, param->lcCnt, mBuf); + CMCHKPK(SPkU32, param->ulSpsPrdctyEnum, mBuf); + CMCHKPK(SPkS8, param->pwrCfg.p0UePuschVal, mBuf); + CMCHKPK(SPkS8, param->pwrCfg.p0NominalPuschVal, mBuf); + CMCHKPK(SPkU8, param->pwrCfgPres, mBuf); + +#ifdef LTE_TDD + CMCHKPK(SPkU8, param->twoIntervalCfg, mBuf); + +#endif + CMCHKPK(SPkU32, param->implicitRelCnt, mBuf); + CMCHKPK(SPkU8, param->isUlSpsEnabled, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrUeSpsUlCfg +* +* +* Desc : UL SPS configuration parameters per UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUeSpsUlCfg +( +RgrUeSpsUlCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUeSpsUlCfg(param, mBuf) +RgrUeSpsUlCfg *param; +Buffer *mBuf; +#endif +{ + U32 tmpEnum; + + S32 i; + TRC3(cmUnpkRgrUeSpsUlCfg) + + CMCHKUNPK(SUnpkU8, ¶m->isUlSpsEnabled, mBuf); + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->implicitRelCnt = tmpEnum; + +#ifdef LTE_TDD + CMCHKUNPK(SUnpkU8, ¶m->twoIntervalCfg, mBuf); + +#endif + CMCHKUNPK(SUnpkU8, ¶m->pwrCfgPres, mBuf); + CMCHKUNPK(SUnpkS8, ¶m->pwrCfg.p0NominalPuschVal, mBuf); + CMCHKUNPK(SUnpkS8, ¶m->pwrCfg.p0UePuschVal, mBuf); + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->ulSpsPrdctyEnum = tmpEnum; + CMCHKUNPK(SUnpkU8, ¶m->lcCnt, mBuf); + for (i=0; ilcCnt; i++) { + CMCHKUNPK(SUnpkU8, ¶m->spsLcInfo[i].lcId, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->spsLcInfo[i].isSpsEnabled, mBuf); + } + CMCHKUNPK(SUnpkU8, ¶m->isLcSRMaskEnab, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrUeSpsCfg +* +* +* Desc : SPS configuration parameters per UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUeSpsCfg +( +RgrUeSpsCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUeSpsCfg(param, mBuf) +RgrUeSpsCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrUeSpsCfg) + + CMCHKPK(cmPkRgrUeSpsUlCfg, ¶m->ulSpsCfg, mBuf); + CMCHKPK(cmPkRgrUeSpsDlCfg, ¶m->dlSpsCfg, mBuf); + CMCHKPK(cmPkLteRnti, param->spsRnti, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrUeSpsCfg +* +* +* Desc : SPS configuration parameters per UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUeSpsCfg +( +RgrUeSpsCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUeSpsCfg(param, mBuf) +RgrUeSpsCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrUeSpsCfg) + + CMCHKUNPK(cmUnpkLteRnti, ¶m->spsRnti, mBuf); + CMCHKUNPK(cmUnpkRgrUeSpsDlCfg, ¶m->dlSpsCfg, mBuf); + CMCHKUNPK(cmUnpkRgrUeSpsUlCfg, ¶m->ulSpsCfg, mBuf); + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func : cmPkRgrUeUlPwrCfg +* +* +* Desc : Uplink power configuration per UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUeUlPwrCfg +( +RgrUeUlPwrCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUeUlPwrCfg(param, mBuf) +RgrUeUlPwrCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrUeUlPwrCfg) + + CMCHKPK(SPkU8, param->trgCqi, mBuf); + CMCHKPK(SPkU8, param->pSRSOffset, mBuf); + CMCHKPK(SPkS8, param->p0UePucch, mBuf); + CMCHKPK(SPkS8, param->p0UePusch, mBuf); + CMCHKPK(SPkU8, param->isDeltaMCSEnabled, mBuf); + CMCHKPK(SPkU8, param->isAccumulated, mBuf); + CMCHKPK(cmPkRgrUeGrpPwrCfg, ¶m->uePucchPwr, mBuf); + CMCHKPK(cmPkRgrUeGrpPwrCfg, ¶m->uePuschPwr, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrUeUlPwrCfg +* +* +* Desc : Uplink power configuration per UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUeUlPwrCfg +( +RgrUeUlPwrCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUeUlPwrCfg(param, mBuf) +RgrUeUlPwrCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrUeUlPwrCfg) + + CMCHKUNPK(cmUnpkRgrUeGrpPwrCfg, ¶m->uePuschPwr, mBuf); + CMCHKUNPK(cmUnpkRgrUeGrpPwrCfg, ¶m->uePucchPwr, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->isAccumulated, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->isDeltaMCSEnabled, mBuf); + CMCHKUNPK(SUnpkS8, ¶m->p0UePusch, mBuf); + CMCHKUNPK(SUnpkS8, ¶m->p0UePucch, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->pSRSOffset, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->trgCqi, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrUeQosCfg +* +* +* Desc : Downlink/Uplink QoS configuration per UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUeQosCfg +( +RgrUeQosCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUeQosCfg(param, mBuf) +RgrUeQosCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrUeQosCfg) + + CMCHKPK(SPkU32, param->ueBr, mBuf); + CMCHKPK(SPkU32, param->dlAmbr, mBuf); + CMCHKPK(SPkU8, param->ambrPres, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrUeQosCfg +* +* +* Desc : Downlink/Uplink QoS configuration per UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUeQosCfg +( +RgrUeQosCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUeQosCfg(param, mBuf) +RgrUeQosCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrUeQosCfg) + + CMCHKUNPK(SUnpkU8, ¶m->ambrPres, mBuf); + CMCHKUNPK(SUnpkU32, ¶m->dlAmbr, mBuf); + CMCHKUNPK(SUnpkU32, ¶m->ueBr, mBuf); + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func : cmPkRgrUePuschDedCfg +* +* +* Desc : PUSCH Config Dedication for UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUePuschDedCfg +( +RgrUePuschDedCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUePuschDedCfg(param, mBuf) +RgrUePuschDedCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrUePuschDedCfg) + + CMCHKPK(SPkU8, param->bCQIIdx, mBuf); + CMCHKPK(SPkU8, param->bRIIdx, mBuf); + CMCHKPK(SPkU8, param->bACKIdx, mBuf); + CMCHKPK(SPkU8, param->pres, mBuf); + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func : cmUnpkRgrUePuschDedCfg +* +* +* Desc : PUSCH Config Dedication for UE +* +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUePuschDedCfg +( +RgrUePuschDedCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUePuschDedCfg(param, mBuf) +RgrUePuschDedCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrUePuschDedCfg) + + CMCHKUNPK(SUnpkU8, ¶m->pres, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->bACKIdx, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->bRIIdx, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->bCQIIdx, mBuf); + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func : cmPkRgrUeTxAntSelCfg +* +* +* Desc : UE Transmit Antenna selection related configuration +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUeTxAntSelCfg +( +RgrUeTxAntSelCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUeTxAntSelCfg(param, mBuf) +RgrUeTxAntSelCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrUeTxAntSelCfg) + + CMCHKPK(SPkU32, param->selType, mBuf); + CMCHKPK(SPkU8, param->pres, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrUeTxAntSelCfg +* +* +* Desc : UE Transmit Antenna selection related configuration +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUeTxAntSelCfg +( +RgrUeTxAntSelCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUeTxAntSelCfg(param, mBuf) +RgrUeTxAntSelCfg *param; +Buffer *mBuf; +#endif +{ + U32 tmpEnum; + + TRC3(cmUnpkRgrUeTxAntSelCfg) + + CMCHKUNPK(SUnpkU8, ¶m->pres, mBuf); + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->selType = (RgrUeTxAntSelType) tmpEnum; + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func : cmPkRgrUeTaTmrCfg +* +* +* Desc : Time Alignment timer configuration per UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUeTaTmrCfg +( +RgrUeTaTmrCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUeTaTmrCfg(param, mBuf) +RgrUeTaTmrCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrUeTaTmrCfg) + + CMCHKPK(SPkU16, param->taTmr, mBuf); + CMCHKPK(SPkU8, param->pres, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrUeTaTmrCfg +* +* +* Desc : Time Alignment timer configuration per UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUeTaTmrCfg +( +RgrUeTaTmrCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUeTaTmrCfg(param, mBuf) +RgrUeTaTmrCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrUeTaTmrCfg) + + CMCHKUNPK(SUnpkU8, ¶m->pres, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->taTmr, mBuf); + RETVALUE(ROK); +} + + +#ifdef EMTC_ENABLE +#ifdef ANSI +PUBLIC S16 cmUnpkRgrEmtcUeCfg +( +RgrUeEmtcCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrEmtcUeCfg(param, mBuf) +RgrUeEmtcCfg *param; +Buffer *mBuf; +#endif +{ + S32 indx=0; + S32 idx=0; + RgrEpdcchConfigRel11 *emtcEpdcchCfg = &(param->emtcEpdcchCfg); + RgrPucchRepCfgRel13 *emtcPucchRepCfg = &(param->emtcPucchRepCfg); + RgrEpdcchAddModLst *epdcchAddModLst; + + CMCHKUNPK(SUnpkU8,¶m->pdschReptLevModeA,mBuf); + /*UnPacking PUCCH Rep */ + CMCHKUNPK(SUnpkU8,&(emtcPucchRepCfg->modeANumPucchRepFormat2),mBuf); + CMCHKUNPK(SUnpkU8,&(emtcPucchRepCfg->modeANumPucchRepFormat1),mBuf); + CMCHKUNPK(SUnpkU8,&(emtcPucchRepCfg->isPucchRepPres),mBuf); + + + + for(indx = 0; indx < RGR_MAX_EPDCCH_SET; indx++) + { + epdcchAddModLst = &(emtcEpdcchCfg->epdcchAddModLst[indx]); + CMCHKUNPK(SUnpkU32,&(epdcchAddModLst->extaddgrp2.mpddchNB),mBuf); + CMCHKUNPK(SUnpkU16,&(epdcchAddModLst->extaddgrp2.mpdcchNumRep),mBuf); + CMCHKUNPK(SUnpkU8,&(epdcchAddModLst->extaddgrp2.mpdcchStartUESSFDD),mBuf); + CMCHKUNPK(SUnpkU8,&(epdcchAddModLst->extaddgrp2.mpddchPdschHop),mBuf); + CMCHKUNPK(SUnpkU8,&(epdcchAddModLst->extaddgrp2.csiNumRep),mBuf); + CMCHKUNPK(SUnpkU8,&(epdcchAddModLst->extaddgrp2.pres),mBuf); + CMCHKUNPK(cmUnpkTknU8,&(epdcchAddModLst->mpdcchNumPRBpair),mBuf); + CMCHKUNPK(cmUnpkTknU32,&(epdcchAddModLst->pdschRemapQLcfgId),mBuf); + CMCHKUNPK(SUnpkU32,&(epdcchAddModLst->pucchResStartoffset),mBuf); + CMCHKUNPK(SUnpkU32,&(epdcchAddModLst->dmrsScrambSeq),mBuf); + for(idx = 0; idx < 5; idx++) + { + CMCHKUNPK(SUnpkU8,&(epdcchAddModLst->resBlkAssignment.rbAssignment[idx]),mBuf); + } + + CMCHKUNPK(SUnpkU8,&(epdcchAddModLst->resBlkAssignment.numPRBpairs),mBuf); + CMCHKUNPK(SUnpkU8,&(epdcchAddModLst->transmissionType),mBuf); + CMCHKUNPK(SUnpkU8,&(epdcchAddModLst->setConfigId),mBuf); + + } + CMCHKUNPK(cmUnpkTknU32,&(emtcEpdcchCfg->startSymbolr11),mBuf); + for(indx = 0; indx < 5; indx++) + { + CMCHKUNPK(SUnpkU8,&(emtcEpdcchCfg->sfPtn.measSfPatFDD[indx]),mBuf); + } + CMCHKUNPK(SUnpkU8, &(emtcEpdcchCfg->sfPtn.pres), mBuf); + CMCHKUNPK(SUnpkU8, &(param->pres), mBuf); + CMCHKUNPK(SUnpkU8, &(param->isHdFddEnbld), mBuf); + +#ifdef EMTC_DEBUG_CONSOLE_PRINTS + printf("\n EMTC RGR UE unpack\n"); + printf("\nemtcEpdcchCfg->sfPtn.pres %d ",emtcEpdcchCfg->sfPtn.pres); + + for(indx = 0; indx < 5; indx++) + { + printf("\nemtcEpdcchCfg->sfPtn.measSfPatFDD[%d] %d ",indx,emtcEpdcchCfg->sfPtn.measSfPatFDD[indx]); + } + printf("\nemtcEpdcchCfg->startSymbolr11 %d ",emtcEpdcchCfg->startSymbolr11.pres); + printf("\nemtcEpdcchCfg->startSymbolr11 %d ",emtcEpdcchCfg->startSymbolr11.val); + + for(indx = 0 ; indx < RGR_MAX_EPDCCH_SET; indx++) + { + epdcchAddModLst = &(emtcEpdcchCfg->epdcchAddModLst[indx]); + printf("\nemtcEpdcchCfg->epdcchRelLst[indx].setCfgId %d %d ", indx,emtcEpdcchCfg->epdcchRelLst[indx].setCfgId.pres); + printf("\nemtcEpdcchCfg->epdcchRelLst[indx].setCfgId %d %d ", indx,emtcEpdcchCfg->epdcchRelLst[indx].setCfgId.val); + printf("\nepdcchAddModLst->setConfigId %d ", epdcchAddModLst->setConfigId); + printf("\nepdcchAddModLst->transmissionType %d ",epdcchAddModLst->transmissionType); + printf("\nepdcchAddModLst->resBlkAssignment.numPRBpairs %d ",epdcchAddModLst->resBlkAssignment.numPRBpairs); + for(idx = 0; idx < 5 ; idx++) + { + printf("\nepdcchAddModLst->resBlkAssignment.rbAssignment[idx] %d ",epdcchAddModLst->resBlkAssignment.rbAssignment[idx]); + } + printf("\nepdcchAddModLst->dmrsScrambSeq %d ",epdcchAddModLst->dmrsScrambSeq); + printf("\nepdcchAddModLst->pucchResStartoffset %d ",epdcchAddModLst->pucchResStartoffset); + printf("\nepdcchAddModLst->pdschRemapQLcfgId.pres %d ",epdcchAddModLst->pdschRemapQLcfgId.pres); + printf("\nepdcchAddModLst->pdschRemapQLcfgId.val %d ", epdcchAddModLst->pdschRemapQLcfgId.val); + printf("\nepdcchAddModLst->mpdcchNumPRBpair.pres %d ", epdcchAddModLst->mpdcchNumPRBpair.pres); + printf("\nepdcchAddModLst->mpdcchNumPRBpair.val %d ", epdcchAddModLst->mpdcchNumPRBpair.val); + printf("\nepdcchAddModLst->extaddgrp2.pres %d ", epdcchAddModLst->extaddgrp2.pres); + printf("\nepdcchAddModLst->extaddgrp2.csiNumRep %d ", epdcchAddModLst->extaddgrp2.csiNumRep); + printf("\nepdcchAddModLst->extaddgrp2.mpddchPdschHop %d ", epdcchAddModLst->extaddgrp2.mpddchPdschHop); + printf("\nepdcchAddModLst->extaddgrp2.mpdcchStartUESSFDD %d ",epdcchAddModLst->extaddgrp2.mpdcchStartUESSFDD); + printf("\nepdcchAddModLst->extaddgrp2.mpdcchNumRep %d ", epdcchAddModLst->extaddgrp2.mpdcchNumRep); + printf("\nepdcchAddModLst->extaddgrp2.mpddchNB %d ", epdcchAddModLst->extaddgrp2.mpddchNB); + } + +#endif + + RETVALUE(ROK); +} + + + +PUBLIC S16 cmPkRgrEmtcUeCfg +( + RgrUeEmtcCfg *param, + Buffer *mBuf + ) +{ + S32 indx=0; + S32 idx=0; + RgrEpdcchConfigRel11 *emtcEpdcchCfg = &(param->emtcEpdcchCfg); + RgrPucchRepCfgRel13 *emtcPucchRepCfg = &(param->emtcPucchRepCfg); + RgrEpdcchAddModLst *epdcchAddModLst; + + CMCHKPK(SPkU8, param->isHdFddEnbld, mBuf); + CMCHKPK(SPkU8, param->pres, mBuf); + CMCHKPK(SPkU8, emtcEpdcchCfg->sfPtn.pres, mBuf); + for(indx = 4; indx >=0; indx--) + { + CMCHKPK(SPkU8,emtcEpdcchCfg->sfPtn.measSfPatFDD[indx],mBuf); + } + CMCHKPK(cmPkTknU32,&emtcEpdcchCfg->startSymbolr11,mBuf); + for(indx = RGR_MAX_EPDCCH_SET-1 ; indx >= 0; indx--) + { + epdcchAddModLst = &(emtcEpdcchCfg->epdcchAddModLst[indx]); + + CMCHKPK(SPkU8,epdcchAddModLst->setConfigId,mBuf); + CMCHKPK(SPkU8,epdcchAddModLst->transmissionType,mBuf); + CMCHKPK(SPkU8,epdcchAddModLst->resBlkAssignment.numPRBpairs,mBuf); + for(idx = 4; idx >= 0; idx--) + { + CMCHKPK(SPkU8,epdcchAddModLst->resBlkAssignment.rbAssignment[idx],mBuf); + } + CMCHKPK(SPkU32,epdcchAddModLst->dmrsScrambSeq,mBuf); + CMCHKPK(SPkU32,epdcchAddModLst->pucchResStartoffset,mBuf); + CMCHKPK(cmPkTknU32,&(epdcchAddModLst->pdschRemapQLcfgId),mBuf); + CMCHKPK(cmPkTknU8,&(epdcchAddModLst->mpdcchNumPRBpair),mBuf); + CMCHKPK(SPkU8,epdcchAddModLst->extaddgrp2.pres,mBuf); + CMCHKPK(SPkU8,epdcchAddModLst->extaddgrp2.csiNumRep,mBuf); + CMCHKPK(SPkU8,epdcchAddModLst->extaddgrp2.mpddchPdschHop,mBuf); + CMCHKPK(SPkU8,epdcchAddModLst->extaddgrp2.mpdcchStartUESSFDD,mBuf); + CMCHKPK(SPkU16,epdcchAddModLst->extaddgrp2.mpdcchNumRep,mBuf); + CMCHKPK(SPkU32,epdcchAddModLst->extaddgrp2.mpddchNB,mBuf); + } + +/*Packing PUCCH Rep */ + CMCHKPK(SPkU8,emtcPucchRepCfg->isPucchRepPres, mBuf); + CMCHKPK(SPkU8,emtcPucchRepCfg->modeANumPucchRepFormat1,mBuf); + CMCHKPK(SPkU8,emtcPucchRepCfg->modeANumPucchRepFormat2,mBuf); + CMCHKPK(SPkU8,param->pdschReptLevModeA,mBuf); + +#ifdef EMTC_DEBUG_CONSOLE_PRINTS + printf("\n EMTC RGR UE pack\n"); + printf("\nemtcEpdcchCfg->sfPtn.pres %d ",emtcEpdcchCfg->sfPtn.pres); + + for(indx = 0; indx < 5; indx++) + { + printf("\nemtcEpdcchCfg->sfPtn.measSfPatFDD[%d] %d ",indx,emtcEpdcchCfg->sfPtn.measSfPatFDD[indx]); + } + printf("\nemtcEpdcchCfg->startSymbolr11 %d ",emtcEpdcchCfg->startSymbolr11.pres); + printf("\nemtcEpdcchCfg->startSymbolr11 %d ",emtcEpdcchCfg->startSymbolr11.val); + + for(indx = 0 ; indx < RGR_MAX_EPDCCH_SET; indx++) + { + epdcchAddModLst = &(emtcEpdcchCfg->epdcchAddModLst[indx]); + /* printf("\nemtcEpdcchCfg->epdcchRelLst[indx].setCfgId %d %d ", indx,emtcEpdcchCfg->epdcchRelLst[indx].setCfgId.pres); + printf("\nemtcEpdcchCfg->epdcchRelLst[indx].setCfgId %d %d ", indx,emtcEpdcchCfg->epdcchRelLst[indx].setCfgId.val);*/ + printf("\nepdcchAddModLst->setConfigId %d ", epdcchAddModLst->setConfigId); + printf("\nepdcchAddModLst->transmissionType %d ",epdcchAddModLst->transmissionType); + printf("\nepdcchAddModLst->resBlkAssignment.numPRBpairs %d ",epdcchAddModLst->resBlkAssignment.numPRBpairs); + for(idx = 0; idx < 5 ; idx++) + { + printf("\nepdcchAddModLst->resBlkAssignment.rbAssignment[idx] %d ",epdcchAddModLst->resBlkAssignment.rbAssignment[idx]); + } + printf("\nepdcchAddModLst->dmrsScrambSeq %d ",epdcchAddModLst->dmrsScrambSeq); + printf("\nepdcchAddModLst->pucchResStartoffset %d ",epdcchAddModLst->pucchResStartoffset); + printf("\nepdcchAddModLst->pdschRemapQLcfgId.pres %d ",epdcchAddModLst->pdschRemapQLcfgId.pres); + printf("\nepdcchAddModLst->pdschRemapQLcfgId.val %d ", epdcchAddModLst->pdschRemapQLcfgId.val); + printf("\nepdcchAddModLst->mpdcchNumPRBpair.pres %d ", epdcchAddModLst->mpdcchNumPRBpair.pres); + printf("\nepdcchAddModLst->mpdcchNumPRBpair.val %d ", epdcchAddModLst->mpdcchNumPRBpair.val); + printf("\nepdcchAddModLst->extaddgrp2.pres %d ", epdcchAddModLst->extaddgrp2.pres); + printf("\nepdcchAddModLst->extaddgrp2.csiNumRep %d ", epdcchAddModLst->extaddgrp2.csiNumRep); + printf("\nepdcchAddModLst->extaddgrp2.mpddchPdschHop %d ", epdcchAddModLst->extaddgrp2.mpddchPdschHop); + printf("\nepdcchAddModLst->extaddgrp2.mpdcchStartUESSFDD %d ",epdcchAddModLst->extaddgrp2.mpdcchStartUESSFDD); + printf("\nepdcchAddModLst->extaddgrp2.mpdcchNumRep %d ", epdcchAddModLst->extaddgrp2.mpdcchNumRep); + printf("\nepdcchAddModLst->extaddgrp2.mpddchNB %d ", epdcchAddModLst->extaddgrp2.mpddchNB); + } + +#endif + + + + RETVALUE(ROK); +} +#endif + +#ifdef RG_5GTF +PUBLIC S16 cmUnpkRgr5gtfUeCfg +( + RgrUe5gtfCfg *param, + Buffer *mBuf +) +{ + CMCHKUNPK(SUnpkU8, ¶m->grpId, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->BeamId, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numCC, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->mcs, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->maxPrb, mBuf); +#if 0 + printf("\nunpk %u,%u,%u,%u,%u\n",param->grpId,param->BeamId,param->numCC,param->mcs,param->maxPrb); +#endif + RETVALUE(ROK); +} + +PUBLIC S16 cmPkRgr5gtfUeCfg +( + RgrUe5gtfCfg *param, + Buffer *mBuf +) +{ + CMCHKPK(SPkU8, param->maxPrb, mBuf); + CMCHKPK(SPkU8, param->mcs, mBuf); + CMCHKPK(SPkU8, param->numCC, mBuf); + CMCHKPK(SPkU8, param->BeamId, mBuf); + CMCHKPK(SPkU8, param->grpId, mBuf); +#if 0 + printf("\npk %u,%u,%u,%u,%u\n",param->grpId,param->BeamId,param->numCC,param->mcs,param->maxPrb); +#endif + RETVALUE(ROK); +} +#endif + + +/*********************************************************** +* +* Func : cmPkRgrUeCfg +* +* +* Desc : UE configuration +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUeCfg +( +RgrUeCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUeCfg(param, mBuf) +RgrUeCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrUeCfg) +#ifdef RG_5GTF + CMCHKPK(cmPkRgr5gtfUeCfg, ¶m->ue5gtfCfg, mBuf); +#endif +#ifdef EMTC_ENABLE + CMCHKPK(cmPkRgrEmtcUeCfg, ¶m->emtcUeCfg, mBuf); +#endif + CMCHKPK(SPkU8, param->csgMmbrSta, mBuf); + + CMCHKPK(SPkU32, param->accessStratumRls, mBuf); + /* LTE_ADV_FLAG_REMOVED_START */ + CMCHKPK(cmPkRgrLteAdvancedUeConfig, ¶m->ueLteAdvCfg, mBuf); + /* LTE_ADV_FLAG_REMOVED_END */ +#ifdef TFU_UPGRADE +/*rgr_c_001.main_9 ADD PDSCH ded cfg*/ + CMCHKPK(cmPkRgrUePdschDedCfg, ¶m->uePdschDedCfg, mBuf); +#endif + /*rgr_c_001.main_9 ccpu00117452 - MOD - Changed macro name from + RGR_RRM_DLPWR_CNTRL to RGR_CQI_REPT */ +#ifdef RGR_CQI_REPT + CMCHKPK(cmPkRgrUeCqiReptCfg, ¶m->ueCqiReptCfg, mBuf); +#endif + CMCHKPK(cmPkRgrUeTxAntSelCfg, ¶m->ulTxAntSel, mBuf); + +/* rgr_c_001.main_8. Added changes of TFU_UPGRADE */ + CMCHKPK(cmPkRgrUePuschDedCfg, ¶m->puschDedCfg, mBuf); + +/*rgr_c_001.main_9 ADD added changes for HDFDD*/ +#ifdef LTEMAC_HDFDD + CMCHKPK(SPkU8, param->isHdFddEnbld, mBuf); +#endif + +#ifdef TFU_UPGRADE + CMCHKPK(cmPkRgrUeSrCfg, ¶m->srCfg, mBuf); + CMCHKPK(cmPkRgrUeUlSrsCfg, ¶m->srsCfg, mBuf); +#endif + + + + CMCHKPK(cmPkRgrUeSpsCfg, ¶m->ueSpsCfg, mBuf); + +#ifdef LTE_TDD + CMCHKPK(SPkU32, param->ackNackModeEnum, mBuf); + +#endif + CMCHKPK(cmPkTknU8, ¶m->dedPreambleId, mBuf); + CMCHKPK(cmPkRgrCodeBookRstCfg, ¶m->ueCodeBookRstCfg, mBuf); + CMCHKPK(cmPkRgrUeCapCfg, ¶m->ueCapCfg, mBuf); + CMCHKPK(cmPkRgrUeMeasGapCfg, ¶m->ueMesGapCfg, mBuf); + CMCHKPK(cmPkRgrUeAckNackRepCfg, ¶m->ueAckNackCfg, mBuf); + CMCHKPK(SPkU8, param->isTtiBundlEnabled, mBuf); +/*rgr_c_001.main_9 ADD added changes for DRX*/ + + /* Anshika - Pack only if DRX is enabled */ + if(TRUE == param->ueDrxCfg.isDrxEnabled) + { + CMCHKPK(cmPkRgrUeDrxCfg, ¶m->ueDrxCfg, mBuf); + } + CMCHKPK(SPkU8, param->ueDrxCfg.isDrxEnabled, mBuf); /* This has to be packed even if + DRX is disabled */ + CMCHKPK(SPkU32, param->ueCatEnum, mBuf); +#ifdef RGR_V1 + /* rgr_c_001.main_5: ccpu00112398: Added periodicBSR-timer and + * retxBSR-timer */ + CMCHKPK(cmPkRgrUeBsrTmrCfg, ¶m->ueBsrTmrCfg, mBuf); +#endif + CMCHKPK(cmPkRgrUeTaTmrCfg, ¶m->ueTaTmrCfg, mBuf); + CMCHKPK(cmPkRgrUeQosCfg, ¶m->ueQosCfg, mBuf); + CMCHKPK(cmPkRgrUeUlPwrCfg, ¶m->ueUlPwrCfg, mBuf); + CMCHKPK(cmPkRgrUeUlHqCfg, ¶m->ueUlHqCfg, mBuf); + CMCHKPK(cmPkRgrUeDlCqiCfg, ¶m->ueDlCqiCfg, mBuf); + CMCHKPK(cmPkRgrUeTxModeCfg, ¶m->txMode, mBuf); + CMCHKPK(cmPkLteRnti, param->crnti, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrUeCfg +* +* +* Desc : UE configuration +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUeCfg +( +RgrUeCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUeCfg(param, mBuf) +RgrUeCfg *param; +Buffer *mBuf; +#endif +{ + U32 tmpEnum; + + TRC3(cmUnpkRgrUeCfg) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->crnti, mBuf); + CMCHKUNPK(cmUnpkRgrUeTxModeCfg, ¶m->txMode, mBuf); + CMCHKUNPK(cmUnpkRgrUeDlCqiCfg, ¶m->ueDlCqiCfg, mBuf); + CMCHKUNPK(cmUnpkRgrUeUlHqCfg, ¶m->ueUlHqCfg, mBuf); + CMCHKUNPK(cmUnpkRgrUeUlPwrCfg, ¶m->ueUlPwrCfg, mBuf); + CMCHKUNPK(cmUnpkRgrUeQosCfg, ¶m->ueQosCfg, mBuf); + CMCHKUNPK(cmUnpkRgrUeTaTmrCfg, ¶m->ueTaTmrCfg, mBuf); +#ifdef RGR_V1 + /* rgr_c_001.main_5: ccpu00112398: Added periodicBSR-timer and + * retxBSR-timer */ + CMCHKUNPK(cmUnpkRgrUeBsrTmrCfg, ¶m->ueBsrTmrCfg, mBuf); +#endif + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->ueCatEnum = (CmLteUeCategory) tmpEnum; +/*rgr_c_001.main_9 ADD added changes for DRX*/ + + /* Anshika - Unpack only if DRX is enabled */ + CMCHKUNPK(SUnpkU8, ¶m->ueDrxCfg.isDrxEnabled, mBuf); + if(TRUE == param->ueDrxCfg.isDrxEnabled) + { + CMCHKUNPK(cmUnpkRgrUeDrxCfg, ¶m->ueDrxCfg, mBuf); + } + CMCHKUNPK(SUnpkU8, ¶m->isTtiBundlEnabled, mBuf); + CMCHKUNPK(cmUnpkRgrUeAckNackRepCfg, ¶m->ueAckNackCfg, mBuf); + CMCHKUNPK(cmUnpkRgrUeMeasGapCfg, ¶m->ueMesGapCfg, mBuf); + CMCHKUNPK(cmUnpkRgrUeCapCfg, ¶m->ueCapCfg, mBuf); + CMCHKUNPK(cmUnpkRgrCodeBookRstCfg, ¶m->ueCodeBookRstCfg, mBuf); + CMCHKUNPK(cmUnpkTknU8, ¶m->dedPreambleId, mBuf); + +#ifdef LTE_TDD + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->ackNackModeEnum = tmpEnum; + +#endif + /*rgr_c_001.main_7 - Added support for SPS*/ + CMCHKUNPK(cmUnpkRgrUeSpsCfg, ¶m->ueSpsCfg, mBuf); + +/* rgr_c_001.main_8. Added changes of TFU_UPGRADE */ +#ifdef TFU_UPGRADE + CMCHKUNPK(cmUnpkRgrUeUlSrsCfg, ¶m->srsCfg, mBuf); + CMCHKUNPK(cmUnpkRgrUeSrCfg, ¶m->srCfg, mBuf); +#endif +/*rgr_c_001.main_9 ADD added changes for HDFDD*/ +#ifdef LTEMAC_HDFDD + CMCHKUNPK(SUnpkU8, ¶m->isHdFddEnbld, mBuf); +#endif + CMCHKUNPK(cmUnpkRgrUePuschDedCfg, ¶m->puschDedCfg, mBuf); + CMCHKUNPK(cmUnpkRgrUeTxAntSelCfg, ¶m->ulTxAntSel, mBuf); +/* rgr_c_001.main_9 ccpu00117452 - MOD - Changed macro name from + RGR_RRM_DLPWR_CNTRL to RGR_CQI_REPT */ +#ifdef RGR_CQI_REPT + CMCHKUNPK(cmUnpkRgrUeCqiReptCfg, ¶m->ueCqiReptCfg, mBuf); +#endif +#ifdef TFU_UPGRADE + CMCHKUNPK(cmUnpkRgrUePdschDedCfg, ¶m->uePdschDedCfg, mBuf); +#endif + /* LTE_ADV_FLAG_REMOVED_START */ + CMCHKUNPK(cmUnpkRgrLteAdvancedUeConfig, ¶m->ueLteAdvCfg, mBuf); + /* LTE_ADV_FLAG_REMOVED_END */ + CMCHKUNPK(SUnpkU32, (U32 *)¶m->accessStratumRls, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->csgMmbrSta, mBuf); + +#ifdef EMTC_ENABLE + CMCHKUNPK(cmUnpkRgrEmtcUeCfg, ¶m->emtcUeCfg, mBuf); +#endif + +#ifdef RG_5GTF + CMCHKUNPK(cmUnpkRgr5gtfUeCfg, ¶m->ue5gtfCfg, mBuf); +#endif + + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrLchQosCfg +* +* +* Desc : QCI, GBR and MBR configuration for dedicated logical channels +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrLchQosCfg +( +RgrLchQosCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrLchQosCfg(param, mBuf) +RgrLchQosCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrLchQosCfg) + + CMCHKPK(SPkU32, param->mbr, mBuf); + CMCHKPK(SPkU32, param->gbr, mBuf); + CMCHKPK(SPkU8, param->qci, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrLchQosCfg +* +* +* Desc : QCI, GBR and MBR configuration for dedicated logical channels +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrLchQosCfg +( +RgrLchQosCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrLchQosCfg(param, mBuf) +RgrLchQosCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrLchQosCfg) + + CMCHKUNPK(SUnpkU8, ¶m->qci, mBuf); + CMCHKUNPK(SUnpkU32, ¶m->gbr, mBuf); + CMCHKUNPK(SUnpkU32, ¶m->mbr, mBuf); + RETVALUE(ROK); +} +/*rgr_c_001.main_7 - Added support for SPS*/ + + +/*********************************************************** +* +* Func : cmPkRgrLchSpsCfg +* +* +* Desc : SPS related configuration for logical channels +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrLchSpsCfg +( +RgrLchSpsCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrLchSpsCfg(param, mBuf) +RgrLchSpsCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrLchSpsCfg) + + /* SPS_DEV */ + CMCHKPK(SPkU8, param->isSpsEnabled, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrLchSpsCfg +* +* +* Desc : SPS related configuration for logical channels +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrLchSpsCfg +( +RgrLchSpsCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrLchSpsCfg(param, mBuf) +RgrLchSpsCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrLchSpsCfg) + + CMCHKUNPK(SUnpkU8, ¶m->isSpsEnabled, mBuf); + + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func : cmPkRgrDlLchCfg +* +* +* Desc : Logical channel configuration info for downlink logical channels +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrDlLchCfg +( +RgrDlLchCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrDlLchCfg(param, mBuf) +RgrDlLchCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrDlLchCfg) +/*rgr_c_001.main_7 - Added support for SPS*/ + + CMCHKPK(SPkU8, param->rlcReorderTmr, mBuf); + CMCHKPK(cmPkRgrLchSpsCfg, ¶m->dlSpsCfg, mBuf); + CMCHKPK(cmPkRgrLchQosCfg, ¶m->dlQos, mBuf); + CMCHKPK(SPkU8, param->dlTrchType, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrDlLchCfg +* +* +* Desc : Logical channel configuration info for downlink logical channels +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrDlLchCfg +( +RgrDlLchCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrDlLchCfg(param, mBuf) +RgrDlLchCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrDlLchCfg) + + CMCHKUNPK(SUnpkU8, ¶m->dlTrchType, mBuf); + CMCHKUNPK(cmUnpkRgrLchQosCfg, ¶m->dlQos, mBuf); + /*rgr_c_001.main_7 - Added support for SPs*/ + CMCHKUNPK(cmUnpkRgrLchSpsCfg, ¶m->dlSpsCfg, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->rlcReorderTmr, mBuf); + + RETVALUE(ROK); +} + + +/*rgr_c_001.main_9 ADD added changes for L2 measurements*/ +#ifdef LTE_L2_MEAS + + +/*********************************************************** +* +* Func : cmPkRgrUlLchCfg +* +* +* Desc : Logical channel configuration information for uplink logical channels +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUlLchCfg +( +RgrUlLchCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUlLchCfg(param, mBuf) +RgrUlLchCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrUlLchCfg) + + CMCHKPK(SPkU8, param->qci, mBuf); + CMCHKPK(cmPkLteLcId, param->lcId, mBuf); + RETVALUE(ROK); +} + + + +/*rgr_c_001.main_9 ADD added changes for L2 measurements*/ +/*********************************************************** +* +* Func : cmUnpkRgrUlLchCfg +* +* +* Desc : Logical channel configuration information for uplink logical channels +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUlLchCfg +( +RgrUlLchCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUlLchCfg(param, mBuf) +RgrUlLchCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrUlLchCfg) + + CMCHKUNPK(cmUnpkLteLcId, ¶m->lcId, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->qci, mBuf); + RETVALUE(ROK); +} + + +#endif + +/*********************************************************** +* +* Func : cmPkRgrUlLcgCfg +* +* +* Desc : Logical channel configuration info for uplink logical channels +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUlLcgCfg +( +RgrUlLcgCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUlLcgCfg(param, mBuf) +RgrUlLcgCfg *param; +Buffer *mBuf; +#endif +{ + +/*rgr_c_001.main_9 ADD added changes for L2 measurements*/ +#ifdef LTE_L2_MEAS + S32 i; +#endif + TRC3(cmPkRgrUlLcgCfg) + CMCHKPK(SPkU32, param->mbr, mBuf); + CMCHKPK(SPkU32, param->gbr, mBuf); + +/*rgr_c_001.main_9 ADD added changes for L2 measurements*/ +#ifdef LTE_L2_MEAS + for (i = param->numLch - 1; i >= 0; i--) + { + CMCHKPK(cmPkRgrUlLchCfg, ¶m->lchUlCfg[i], mBuf); + } + CMCHKPK(SPkU8, param->numLch, mBuf); +#endif + CMCHKPK(SPkU8, param->lcgId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrUlLcgCfg +* +* +* Desc : Logical channel configuration info for uplink logical channels +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUlLcgCfg +( +RgrUlLcgCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUlLcgCfg(param, mBuf) +RgrUlLcgCfg *param; +Buffer *mBuf; +#endif +{ + +/*rgr_c_001.main_9 ADD added changes for L2 measurements*/ +#ifdef LTE_L2_MEAS + S32 i; +#endif + TRC3(cmUnpkRgrUlLcgCfg) + + CMCHKUNPK(SUnpkU8, ¶m->lcgId, mBuf); +/*rgr_c_001.main_9 ADD added changes for L2 measurements*/ +#ifdef LTE_L2_MEAS + CMCHKUNPK(SUnpkU8, ¶m->numLch, mBuf); + for (i = 0; i< param->numLch; i++) + { + CMCHKUNPK(cmUnpkRgrUlLchCfg, ¶m->lchUlCfg[i], mBuf); + } + +#endif + CMCHKUNPK(SUnpkU32, ¶m->gbr, mBuf); + CMCHKUNPK(SUnpkU32, ¶m->mbr, mBuf); + RETVALUE(ROK); +} + +#ifdef ANSI +PUBLIC S16 cmPkRgrUlLchQciCfg +( +RgrUlLchQciCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUlLchQciCfg (param, mBuf) +RgrUlLchQciCfg *param; +Buffer *mBuf; +#endif +{ + CMCHKPK(SPkU8, param->lcId, mBuf); + CMCHKPK(SPkU8, param->qci, mBuf); + CMCHKPK(SPkU8, param->lcgId, mBuf); + RETVALUE(ROK); +} +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUlLchQciCfg +( +RgrUlLchQciCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUlLchQciCfg (param, mBuf) +RgrUlLchQciCfg *param; +Buffer *mBuf; +#endif +{ + CMCHKUNPK(SUnpkU8, ¶m->lcgId, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->qci, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->lcId, mBuf); + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func : cmPkRgrLchCfg +* +* +* Desc : Logical channel configuration info for dedicated channels +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrLchCfg +( +RgrLchCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrLchCfg(param, mBuf) +RgrLchCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrLchCfg) + CMCHKPK(SPkU8, param->lcgId, mBuf); + CMCHKPK(cmPkRgrUlLchQciCfg, ¶m->ulLchQciInfo, mBuf); + CMCHKPK(cmPkRgrDlLchCfg, ¶m->dlInfo, mBuf); + CMCHKPK(cmPkLteLcType, param->lcType, mBuf); + CMCHKPK(cmPkLteLcId, param->lcId, mBuf); + CMCHKPK(cmPkLteRnti, param->crnti, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrLchCfg +* +* +* Desc : Logical channel configuration info for dedicated channels +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrLchCfg +( +RgrLchCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrLchCfg(param, mBuf) +RgrLchCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrLchCfg) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->crnti, mBuf); + CMCHKUNPK(cmUnpkLteLcId, ¶m->lcId, mBuf); + CMCHKUNPK(cmUnpkLteLcType, ¶m->lcType, mBuf); + CMCHKUNPK(cmUnpkRgrDlLchCfg, ¶m->dlInfo, mBuf); + CMCHKUNPK(cmUnpkRgrUlLchQciCfg, ¶m->ulLchQciInfo, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->lcgId, mBuf); + RETVALUE(ROK); +} + + +#ifdef ANSI +PUBLIC S16 cmPkRgrLcgCfg +( +RgrLcgCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrLcgCfg(param, mBuf) +RgrLcgCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrLcgCfg) + + CMCHKPK(cmPkRgrUlLcgCfg, ¶m->ulInfo, mBuf); + CMCHKPK(cmPkLteRnti, param->crnti, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + +#ifdef ANSI +PUBLIC S16 cmUnpkRgrLcgCfg +( +RgrLcgCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrLcgCfg(param, mBuf) +RgrLcgCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrLcgCfg) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->crnti, mBuf); + CMCHKUNPK(cmUnpkRgrUlLcgCfg, ¶m->ulInfo, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrCfg +* +* +* Desc : Basic Configuration structure at RRM +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrCfg +( +RgrCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrCfg(param, mBuf) +RgrCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrCfg) + + switch(param->cfgType) { + case RGR_LCG_CFG: + CMCHKPK(cmPkRgrLcgCfg, ¶m->u.lcgCfg, mBuf); + break; + case RGR_LCH_CFG: + CMCHKPK(cmPkRgrLchCfg, ¶m->u.lchCfg, mBuf); + break; + case RGR_UE_CFG: + CMCHKPK(cmPkRgrUeCfg, ¶m->u.ueCfg, mBuf); + break; + case RGR_CELL_CFG: + CMCHKPK(cmPkRgrCellCfg, ¶m->u.cellCfg, mBuf); + break; + case RGR_ENB_CFG: + CMCHKPK(cmPkRgrSchedEnbCfg, ¶m->u.schedEnbCfg, mBuf); + break; + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkU8, param->cfgType, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrCfg +* +* +* Desc : Basic Configuration structure at RRM +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrCfg +( +RgrCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrCfg(param, mBuf) +RgrCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrCfg) + + CMCHKUNPK(SUnpkU8, ¶m->cfgType, mBuf); + switch(param->cfgType) { + case RGR_ENB_CFG: + CMCHKUNPK(cmUnpkRgrSchedEnbCfg, ¶m->u.schedEnbCfg, mBuf); + break; + case RGR_CELL_CFG: + CMCHKUNPK(cmUnpkRgrCellCfg, ¶m->u.cellCfg, mBuf); + break; + case RGR_UE_CFG: + CMCHKUNPK(cmUnpkRgrUeCfg, ¶m->u.ueCfg, mBuf); + break; + case RGR_LCH_CFG: + CMCHKUNPK(cmUnpkRgrLchCfg, ¶m->u.lchCfg, mBuf); + break; + case RGR_LCG_CFG: + CMCHKUNPK(cmUnpkRgrLcgCfg, ¶m->u.lcgCfg, mBuf); + break; + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrActvTime +* +* +* Desc : Activation time information +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrActvTime +( +RgrActvTime *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrActvTime(param, mBuf) +RgrActvTime *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrActvTime) + + CMCHKPK(cmPkLteTimingInfo, ¶m->actvTime, mBuf); + CMCHKPK(SPkU8, param->pres, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrActvTime +* +* +* Desc : Activation time information +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrActvTime +( +RgrActvTime *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrActvTime(param, mBuf) +RgrActvTime *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrActvTime) + + CMCHKUNPK(SUnpkU8, ¶m->pres, mBuf); + CMCHKUNPK(cmUnpkLteTimingInfo, ¶m->actvTime, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrCellRecfg +* +* +* Desc : Cell reconfiguration structure at RRM +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrCellRecfg +( +RgrCellRecfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrCellRecfg(param, mBuf) +RgrCellRecfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrCellRecfg) + CMCHKPK(cmPkRgrCellCntrlCmdCfg, ¶m->cntrlCmdCfg, mBuf); + CMCHKPK(cmPkRgrCellCsgParamCfg, ¶m->csgParamCfg, mBuf); + CMCHKPK(SPkU8, param->isDynCfiEnb, mBuf); + CMCHKPK(SPkU8, param->isAutoCfgModeEnb, mBuf); + /* LTE_ADV_FLAG_REMOVED_START */ + CMCHKPK(cmPkRgrCellLteAdvancedFeatureCfg, ¶m->rgrLteAdvCfg, mBuf); + /* LTE_ADV_FLAG_REMOVED_END */ + CMCHKPK(SPkU16, param->t300TmrVal, mBuf); + /* rgr_c_001.main_4:MOD-Modified for SI Enhancement. */ +#ifdef RGR_SI_SCH + CMCHKPK(cmPkRgrSiCfg, ¶m->siReCfg, mBuf); +#endif /* RGR_SI_SCH */ + CMCHKPK(cmPkRgrDlfsCfg, ¶m->dlfsRecfg, mBuf); + CMCHKPK(cmPkRgrRachCfg, ¶m->rachRecfg, mBuf); + CMCHKPK(cmPkRgrSrsCfg, ¶m->srsRecfg, mBuf); + CMCHKPK(cmPkRgrPucchCfg, ¶m->pucchRecfg, mBuf); + CMCHKPK(cmPkRgrUlCmnCodeRateCfg, ¶m->ulCmnCodeRate, mBuf); + CMCHKPK(cmPkRgrPuschSubBandCfg, ¶m->puschSubBand, mBuf); + CMCHKPK(cmPkRgrDlCmnCodeRateCfg, ¶m->dlCmnCodeRate, mBuf); + CMCHKPK(cmPkRgrUlTrgCqiCfg, ¶m->trgUlCqi, mBuf); + CMCHKPK(cmPkRgrCfiCfg, ¶m->cfiRecfg, mBuf); + CMCHKPK(cmPkRgrDlHqCfg, ¶m->dlHqRecfg, mBuf); + CMCHKPK(cmPkRgrActvTime, ¶m->recfgActvTime, mBuf); + CMCHKPK(SPkU32, param->recfgTypes, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrCellRecfg +* +* +* Desc : Cell reconfiguration structure at RRM +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrCellRecfg +( +RgrCellRecfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrCellRecfg(param, mBuf) +RgrCellRecfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrCellRecfg) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(SUnpkU32, ¶m->recfgTypes, mBuf); + CMCHKUNPK(cmUnpkRgrActvTime, ¶m->recfgActvTime, mBuf); + CMCHKUNPK(cmUnpkRgrDlHqCfg, ¶m->dlHqRecfg, mBuf); + CMCHKUNPK(cmUnpkRgrCfiCfg, ¶m->cfiRecfg, mBuf); + CMCHKUNPK(cmUnpkRgrUlTrgCqiCfg, ¶m->trgUlCqi, mBuf); + CMCHKUNPK(cmUnpkRgrDlCmnCodeRateCfg, ¶m->dlCmnCodeRate, mBuf); + CMCHKUNPK(cmUnpkRgrPuschSubBandCfg, ¶m->puschSubBand, mBuf); + CMCHKUNPK(cmUnpkRgrUlCmnCodeRateCfg, ¶m->ulCmnCodeRate, mBuf); + CMCHKUNPK(cmUnpkRgrPucchCfg, ¶m->pucchRecfg, mBuf); + CMCHKUNPK(cmUnpkRgrSrsCfg, ¶m->srsRecfg, mBuf); + CMCHKUNPK(cmUnpkRgrRachCfg, ¶m->rachRecfg, mBuf); + CMCHKUNPK(cmUnpkRgrDlfsCfg, ¶m->dlfsRecfg, mBuf); + /* rgr_c_001.main_4-MOD-Modified for SI Enhancement. */ +#ifdef RGR_SI_SCH + CMCHKUNPK(cmUnpkRgrSiCfg, ¶m->siReCfg, mBuf); +#endif /* RGR_SI_SCH */ + CMCHKUNPK(SUnpkU16, ¶m->t300TmrVal, mBuf); + /* LTE_ADV_FLAG_REMOVED_START */ + CMCHKUNPK(cmUnpkRgrCellLteAdvancedFeatureCfg, ¶m->rgrLteAdvCfg, mBuf); + /* LTE_ADV_FLAG_REMOVED_END */ + CMCHKUNPK(SUnpkU8, ¶m->isAutoCfgModeEnb, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->isDynCfiEnb, mBuf); + CMCHKUNPK(cmUnpkRgrCellCsgParamCfg, ¶m->csgParamCfg, mBuf); + CMCHKUNPK(cmUnpkRgrCellCntrlCmdCfg, ¶m->cntrlCmdCfg, mBuf); + + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrUeRecfg +* +* +* Desc : UE reconfiguration info +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUeRecfg +( +RgrUeRecfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUeRecfg(param, mBuf) +RgrUeRecfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrUeRecfg) +#ifdef EMTC_ENABLE + /* Note: As we add more members to emtcUeRecfg, + create a new function for pkUnpk */ + CMCHKPK(SPkU8, param->emtcUeRecfg.isHdFddEnbld, mBuf); +#endif + CMCHKPK(SPkU8, param->csgMmbrSta, mBuf); + + CMCHKPK(SPkU32, param->accessStratumRls, mBuf); +#ifdef LTE_ADV + CMCHKPK(SPkU8, param->simulAckNackCQIFormat3, mBuf); + CMCHKPK(cmPkRgrUeSCellAckPucchCfg, ¶m->sCellAckN1ResCfg,mBuf); + CMCHKPK(cmPkRgrUeSecCellInfo, ¶m->ueSCellCfgInfo,mBuf); +#endif + /* LTE_ADV_FLAG_REMOVED_START */ + CMCHKPK(SPkU8, param->ueLteAdvCfg.isUeCellEdge, mBuf); + CMCHKPK(SPkU8, param->ueLteAdvCfg.isAbsUe, mBuf); + CMCHKPK(SPkU32, param->ueLteAdvCfg.pres, mBuf); + /* LTE_ADV_FLAG_REMOVED_END */ + /*ccpu00130497: Removed the duplicate packing*/ +#ifdef TFU_UPGRADE + CMCHKPK(cmPkRgrUePdschDedCfg, ¶m->uePdschDedCfg, mBuf); +#endif + /* rgr_c_001.main_9 ccpu00117452 - MOD - Changed macro name from + RGR_RRM_DLPWR_CNTRL to RGR_CQI_REPT */ +#ifdef RGR_CQI_REPT + CMCHKPK(cmPkRgrUeCqiReptCfg, ¶m->ueCqiReptCfg, mBuf); +#endif + +/* rgr_c_001.main_8. Added changes of TFU_UPGRADE */ + CMCHKPK(cmPkRgrUePuschDedCfg, ¶m->puschDedCfg, mBuf); + +/*rgr_c_001.main_9 ADD added changes for HDFDD*/ +#ifdef LTEMAC_HDFDD + CMCHKPK(SPkU8, param->isHdFddEnbld, mBuf); +#endif + +#ifdef TFU_UPGRADE + CMCHKPK(cmPkRgrUeSrCfg, ¶m->srCfg, mBuf); + CMCHKPK(cmPkRgrUeUlSrsCfg, ¶m->srsCfg, mBuf); + CMCHKPK(cmPkRgrUePrdDlCqiCfg, ¶m->cqiCfg, mBuf); +#endif + + /*rgr_c_001.main_7 - Added support for SPS*/ + CMCHKPK(cmPkRgrUeSpsCfg, ¶m->ueSpsRecfg, mBuf); + CMCHKPK(cmPkRgrUeTxAntSelCfg, ¶m->ulTxAntSel, mBuf); + + /* rgr_c_001.main_7 - Changes for UE category Reconfiguration */ + CMCHKPK(SPkU32, param->ueCatEnum, mBuf); + + CMCHKPK(cmPkRgrCodeBookRstCfg, ¶m->ueCodeBookRstRecfg, mBuf); + CMCHKPK(cmPkRgrUeMeasGapCfg, ¶m->ueMeasGapRecfg, mBuf); + CMCHKPK(cmPkRgrUeCapCfg, ¶m->ueCapRecfg, mBuf); + CMCHKPK(cmPkRgrUeAckNackRepCfg, ¶m->ueAckNackRecfg, mBuf); + CMCHKPK(SPkU8, param->isTtiBundlEnabled, mBuf); +/*rgr_c_001.main_9 ADD added changes for DRX*/ + + /* Anshika - Pack only if DRX is enabled */ + if(TRUE == param->ueDrxRecfg.isDrxEnabled) + { + CMCHKPK(cmPkRgrUeDrxCfg, ¶m->ueDrxRecfg, mBuf); + } + CMCHKPK(SPkU8, param->ueDrxRecfg.isDrxEnabled, mBuf); /* This has to be packed even if + DRX is disabled */ + CMCHKPK(cmPkRgrUeUlPwrCfg, ¶m->ueUlPwrRecfg, mBuf); +#ifdef RGR_V1 + /* rgr_c_001.main_5: ccpu00112398: Added periodicBSR-timer and + * retxBSR-timer */ + CMCHKPK(cmPkRgrUeBsrTmrCfg, ¶m->ueBsrTmrRecfg, mBuf); +#endif + CMCHKPK(cmPkRgrUeTaTmrCfg, ¶m->ueTaTmrRecfg, mBuf); + CMCHKPK(cmPkRgrUeQosCfg, ¶m->ueQosRecfg, mBuf); + CMCHKPK(cmPkRgrUeUlHqCfg, ¶m->ueUlHqRecfg, mBuf); + +#ifndef TFU_UPGRADE + CMCHKPK(cmPkRgrUePrdDlCqiCfg, ¶m->prdDlCqiRecfg, mBuf); +#endif + + CMCHKPK(cmPkRgrUeAprdDlCqiCfg, ¶m->aprdDlCqiRecfg, mBuf); + CMCHKPK(cmPkRgrUeTxModeCfg, ¶m->txMode, mBuf); + /*rgr_c_001.main_9: changing ueRecfgTypes to U32 */ + /* LTE_ADV_FLAG_REMOVED_START */ + /* KW fix for LTE_ADV */ + CMCHKPK(SPkU32, param->ueRecfgTypes, mBuf); + /* LTE_ADV_FLAG_REMOVED_END */ + CMCHKPK(cmPkLteRnti, param->newCrnti, mBuf); + CMCHKPK(cmPkLteRnti, param->oldCrnti, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrUeRecfg +* +* +* Desc : UE reconfiguration info +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUeRecfg +( +RgrUeRecfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUeRecfg(param, mBuf) +RgrUeRecfg *param; +Buffer *mBuf; +#endif +{ + U32 tmpEnum; + + TRC3(cmUnpkRgrUeRecfg) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->oldCrnti, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->newCrnti, mBuf); + /* LTE_ADV_FLAG_REMOVED_START */ + /*rgr_c_001.main_9: changing ueRecfgTypes to U32 */ + /* KW fix for LTE_ADV */ + CMCHKUNPK(SUnpkU32, ¶m->ueRecfgTypes, mBuf); + /* LTE_ADV_FLAG_REMOVED_END */ + CMCHKUNPK(cmUnpkRgrUeTxModeCfg, ¶m->txMode, mBuf); + + CMCHKUNPK(cmUnpkRgrUeAprdDlCqiCfg, ¶m->aprdDlCqiRecfg, mBuf); + +#ifndef TFU_UPGRADE + CMCHKUNPK(cmUnpkRgrUePrdDlCqiCfg, ¶m->prdDlCqiRecfg, mBuf); +#endif + + CMCHKUNPK(cmUnpkRgrUeUlHqCfg, ¶m->ueUlHqRecfg, mBuf); + CMCHKUNPK(cmUnpkRgrUeQosCfg, ¶m->ueQosRecfg, mBuf); + CMCHKUNPK(cmUnpkRgrUeTaTmrCfg, ¶m->ueTaTmrRecfg, mBuf); +#ifdef RGR_V1 + /* rgr_c_001.main_5: ccpu00112398: Added periodicBSR-timer and + * retxBSR-timer */ + CMCHKUNPK(cmUnpkRgrUeBsrTmrCfg, ¶m->ueBsrTmrRecfg, mBuf); +#endif + CMCHKUNPK(cmUnpkRgrUeUlPwrCfg, ¶m->ueUlPwrRecfg, mBuf); +/*rgr_c_001.main_9 ADD added changes for DRX*/ + + /* Anshika - Unpack only if DRX is enabled */ + CMCHKUNPK(SUnpkU8, ¶m->ueDrxRecfg.isDrxEnabled, mBuf); + if(TRUE == param->ueDrxRecfg.isDrxEnabled) + { + CMCHKUNPK(cmUnpkRgrUeDrxCfg, ¶m->ueDrxRecfg, mBuf); + } + CMCHKUNPK(SUnpkU8, ¶m->isTtiBundlEnabled, mBuf); + CMCHKUNPK(cmUnpkRgrUeAckNackRepCfg, ¶m->ueAckNackRecfg, mBuf); + CMCHKUNPK(cmUnpkRgrUeCapCfg, ¶m->ueCapRecfg, mBuf); + CMCHKUNPK(cmUnpkRgrUeMeasGapCfg, ¶m->ueMeasGapRecfg, mBuf); + CMCHKUNPK(cmUnpkRgrCodeBookRstCfg, ¶m->ueCodeBookRstRecfg, mBuf); +/* rgr_c_001.main_7 - Changes for UE category Reconfiguration */ + CMCHKUNPK(SUnpkU32, (U32 *)&tmpEnum, mBuf); + param->ueCatEnum = (CmLteUeCategory) tmpEnum; + CMCHKUNPK(cmUnpkRgrUeTxAntSelCfg, ¶m->ulTxAntSel, mBuf); + /*rgr_c_001.main_7 - Added support for SPS*/ + CMCHKUNPK(cmUnpkRgrUeSpsCfg, ¶m->ueSpsRecfg, mBuf); + +/* rgr_c_001.main_8. Added changes of TFU_UPGRADE */ +#ifdef TFU_UPGRADE + CMCHKUNPK(cmUnpkRgrUePrdDlCqiCfg, ¶m->cqiCfg, mBuf); + CMCHKUNPK(cmUnpkRgrUeUlSrsCfg, ¶m->srsCfg, mBuf); + CMCHKUNPK(cmUnpkRgrUeSrCfg, ¶m->srCfg, mBuf); +#endif + +/*rgr_c_001.main_9 ADD added changes for HDFDD*/ +#ifdef LTEMAC_HDFDD + CMCHKUNPK(SUnpkU8, ¶m->isHdFddEnbld, mBuf); +#endif + + CMCHKUNPK(cmUnpkRgrUePuschDedCfg, ¶m->puschDedCfg, mBuf); + +/* rgr_c_001.main_9 ccpu00117452 - MOD - Changed macro name from + RGR_RRM_DLPWR_CNTRL to RGR_CQI_REPT */ +#ifdef RGR_CQI_REPT + CMCHKUNPK(cmUnpkRgrUeCqiReptCfg, ¶m->ueCqiReptCfg, mBuf); +#endif +#ifdef TFU_UPGRADE + CMCHKUNPK(cmUnpkRgrUePdschDedCfg, ¶m->uePdschDedCfg, mBuf); +#endif + + /* LTE_ADV_FLAG_REMOVED_START */ + CMCHKUNPK(SUnpkU32, ¶m->ueLteAdvCfg.pres, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->ueLteAdvCfg.isAbsUe, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->ueLteAdvCfg.isUeCellEdge, mBuf); + /* LTE_ADV_FLAG_REMOVED_END */ +#ifdef LTE_ADV + CMCHKUNPK(cmUnpkRgrUeSecCellInfo, ¶m->ueSCellCfgInfo,mBuf); + CMCHKUNPK(cmUnpkRgrUeSCellAckPucchCfg, ¶m->sCellAckN1ResCfg,mBuf); + CMCHKUNPK(SUnpkU8, ¶m->simulAckNackCQIFormat3, mBuf); +#endif + CMCHKUNPK(SUnpkU32, (U32 *)¶m->accessStratumRls, mBuf); + + CMCHKUNPK(SUnpkU8, ¶m->csgMmbrSta, mBuf); +#ifdef EMTC_ENABLE + CMCHKPK(SUnpkU8, ¶m->emtcUeRecfg.isHdFddEnbld, mBuf); +#endif + + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrLchRecfg +* +* +* Desc : Logical channel reconfiguration info for dedicated channels only +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrLchRecfg +( +RgrLchRecfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrLchRecfg(param, mBuf) +RgrLchRecfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrLchRecfg) +/*rgr_c_001.main_7 - Added support for SPS*/ + CMCHKPK(SPkU8, param->lcgId, mBuf); + + CMCHKPK(cmPkRgrUlLchQciCfg, ¶m->ulLchQciInfo, mBuf); + CMCHKPK(cmPkRgrLchSpsCfg, ¶m->dlRecfg.dlSpsRecfg, mBuf); + + CMCHKPK(cmPkRgrLchQosCfg, ¶m->dlRecfg.dlQos, mBuf); + CMCHKPK(cmPkLteLcId, param->lcId, mBuf); + CMCHKPK(cmPkLteRnti, param->crnti, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrLchRecfg +* +* +* Desc : Logical channel reconfiguration info for dedicated channels only +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrLchRecfg +( +RgrLchRecfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrLchRecfg(param, mBuf) +RgrLchRecfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrLchRecfg) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->crnti, mBuf); + CMCHKUNPK(cmUnpkLteLcId, ¶m->lcId, mBuf); + CMCHKUNPK(cmUnpkRgrLchQosCfg, ¶m->dlRecfg.dlQos, mBuf); + /*rgr_c_001.main_7 - Added support for SPs*/ + CMCHKUNPK(cmUnpkRgrLchSpsCfg, ¶m->dlRecfg.dlSpsRecfg, mBuf); + + CMCHKUNPK(cmUnpkRgrUlLchQciCfg, ¶m->ulLchQciInfo, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->lcgId, mBuf); + RETVALUE(ROK); +} + + +#ifdef ANSI +PUBLIC S16 cmPkRgrLcgRecfg +( +RgrLcgRecfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrLcgRecfg(param, mBuf) +RgrLcgRecfg *param; +Buffer *mBuf; +#endif +{ +#ifdef RG_UNUSED + S32 i; +#endif + TRC3(cmPkRgrLcgRecfg) + + CMCHKPK(SPkU32, param->ulRecfg.mbr, mBuf); + CMCHKPK(SPkU32, param->ulRecfg.gbr, mBuf); +#ifdef RG_UNUSED + for (i = param->ulRecfg.numLch - 1; i >= 0; i--) + { + CMCHKPK(cmPkRgrUlLchCfg, ¶m->ulRecfg.lchUlCfg[i], mBuf); + } + CMCHKPK(SPkU8, param->ulRecfg.numLch, mBuf); +#endif + CMCHKPK(SPkU8, param->ulRecfg.lcgId, mBuf); + CMCHKPK(cmPkLteRnti, param->crnti, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + +#ifdef ANSI +PUBLIC S16 cmUnpkRgrLcgRecfg +( +RgrLcgRecfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrLcgRecfg(param, mBuf) +RgrLcgRecfg *param; +Buffer *mBuf; +#endif +{ +#ifdef RG_UNUSED + S32 i; +#endif + TRC3(cmUnpkRgrLcgRecfg) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->crnti, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->ulRecfg.lcgId, mBuf); + +#ifdef RG_UNUSED + CMCHKUNPK(SUnpkU8, ¶m->ulRecfg.numLch, mBuf); + for (i = 0; i < param->ulRecfg.numLch; i++) + { + CMCHKUNPK(cmUnpkRgrUlLchCfg, ¶m->ulRecfg.lchUlCfg[i], mBuf); + } +#endif + CMCHKUNPK(SUnpkU32, ¶m->ulRecfg.gbr, mBuf); + CMCHKUNPK(SUnpkU32, ¶m->ulRecfg.mbr, mBuf); + + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrRecfg +* +* +* Desc : Basic reconfiguration structure at RRM +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrRecfg +( +RgrRecfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrRecfg(param, mBuf) +RgrRecfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrRecfg) + + switch(param->recfgType) { + case RGR_LCG_CFG: + CMCHKPK(cmPkRgrLcgRecfg, ¶m->u.lcgRecfg, mBuf); + break; + case RGR_LCH_CFG: + CMCHKPK(cmPkRgrLchRecfg, ¶m->u.lchRecfg, mBuf); + break; + case RGR_UE_CFG: + CMCHKPK(cmPkRgrUeRecfg, ¶m->u.ueRecfg, mBuf); + break; + case RGR_CELL_CFG: + CMCHKPK(cmPkRgrCellRecfg, ¶m->u.cellRecfg, mBuf); + break; + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkU8, param->recfgType, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrRecfg +* +* +* Desc : Basic reconfiguration structure at RRM +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrRecfg +( +RgrRecfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrRecfg(param, mBuf) +RgrRecfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrRecfg) + + CMCHKUNPK(SUnpkU8, ¶m->recfgType, mBuf); + switch(param->recfgType) { + case RGR_CELL_CFG: + CMCHKUNPK(cmUnpkRgrCellRecfg, ¶m->u.cellRecfg, mBuf); + break; + case RGR_UE_CFG: + CMCHKUNPK(cmUnpkRgrUeRecfg, ¶m->u.ueRecfg, mBuf); + break; + case RGR_LCH_CFG: + CMCHKUNPK(cmUnpkRgrLchRecfg, ¶m->u.lchRecfg, mBuf); + break; + case RGR_LCG_CFG: + CMCHKUNPK(cmUnpkRgrLcgRecfg, ¶m->u.lcgRecfg, mBuf); + break; + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + +#ifdef LTE_ADV +/*********************************************************** +* +* Func : cmPkRgrUeDlSecCellRelInfo +* +* +* Desc : DL Secondary Cell information of the UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUeDlSecCellRelInfo +( +RgrUeDlSecCellRelInfo *param, +Buffer *mBuf +) +#else +PRIVATE S16 cmPkRgrUeDlSecCellRelInfo(param, mBuf) +RgrUeDlSecCellRelInfo *param; +Buffer *mBuf; +#endif +{ + CMCHKPK(SPkU16, param->sCellId, mBuf); + CMCHKPK(SPkU8, param->sCellIdx, mBuf); + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func : cmPkRgrUeSecCellRelInfo +* +* +* Desc : Secondary Cell Delete information of the UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUeSecCellRelInfo +( +RgrUeSecCellRelInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUeSecCellRelInfo(param, mBuf) +RgrUeSecCellRelInfo *param; +Buffer *mBuf; +#endif +{ + S8 idx; + for(idx = param->numSCells - 1; idx >= 0; idx--) + { + CMCHKPK(cmPkRgrUeDlSecCellRelInfo, ¶m->ueSCellRelDedCfg[(U8)idx],mBuf); + } + CMCHKPK(SPkU8, param->numSCells, mBuf); + + RETVALUE(ROK); +} +#endif + + +/*********************************************************** +* +* Func : cmPkRgrDel +* +* +* Desc : Basic Delete info for MAC +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrDel +( +RgrDel *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrDel(param, mBuf) +RgrDel *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrDel) + + switch(param->delType) { + case RGR_LCG_CFG: + CMCHKPK(SPkU8, param->u.lcgDel.lcgId, mBuf); + CMCHKPK(cmPkLteRnti, param->u.lcgDel.crnti, mBuf); + CMCHKPK(cmPkLteCellId, param->u.lcgDel.cellId, mBuf); + break; + case RGR_LCH_CFG: + CMCHKPK(SPkU8, param->u.lchDel.lcgId, mBuf); + CMCHKPK(cmPkLteLcId, param->u.lchDel.lcId, mBuf); + CMCHKPK(cmPkLteRnti, param->u.lchDel.crnti, mBuf); + CMCHKPK(cmPkLteCellId, param->u.lchDel.cellId, mBuf); + break; + case RGR_UE_CFG: + CMCHKPK(cmPkLteRnti, param->u.ueDel.crnti, mBuf); + CMCHKPK(cmPkLteCellId, param->u.ueDel.cellId, mBuf); + break; + case RGR_CELL_CFG: + CMCHKPK(cmPkLteCellId, param->u.cellDel.cellId, mBuf); + break; +#ifdef LTE_ADV + case RGR_SCELL_UE_CFG: + CMCHKPK(cmPkRgrUeSecCellRelInfo, ¶m->u.ueScellRel.ueSCellRelCfgInfo, mBuf); + CMCHKPK(SPkU32, param->u.ueScellRel.ueDelTypes, mBuf); + CMCHKPK(cmPkLteRnti, param->u.ueScellRel.crnti, mBuf); + CMCHKPK(cmPkLteCellId, param->u.ueScellRel.cellId, mBuf); + break; +#endif + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkU8, param->delType, mBuf); + RETVALUE(ROK); +} + + +#ifdef LTE_ADV + +/*********************************************************** +* +* Func : cmUnpkRgrUeDlSecCellRelInfo +* +* +* Desc : DL Secondary Cell information of the UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUeDlSecCellRelInfo +( +RgrUeDlSecCellRelInfo *param, +Buffer *mBuf +) +#else +PRIVATE S16 cmUnpkRgrUeDlSecCellRelInfo(param, mBuf) +RgrUeDlSecCellRelInfo *param; +Buffer *mBuf; +#endif +{ + CMCHKUNPK(SUnpkU8, ¶m->sCellIdx, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->sCellId, mBuf); + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func : cmUnpkRgrUeSecCellRelInfo +* +* +* Desc : Secondary Cell information of the UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUeSecCellRelInfo +( +RgrUeSecCellRelInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUeSecCellRelInfo(param, mBuf) +RgrUeSecCellRelInfo *param; +Buffer *mBuf; +#endif +{ + U8 idx; + + CMCHKUNPK(SUnpkU8, ¶m->numSCells, mBuf); + + for(idx = 0; idx < param->numSCells;idx++) + { + CMCHKUNPK(cmUnpkRgrUeDlSecCellRelInfo, ¶m->ueSCellRelDedCfg[idx],mBuf); + } + RETVALUE(ROK); +} +#endif + +/*********************************************************** +* +* Func : cmUnpkRgrDel +* +* +* Desc : Basic Delete info for MAC +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrDel +( +RgrDel *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrDel(param, mBuf) +RgrDel *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrDel) + + CMCHKUNPK(SUnpkU8, ¶m->delType, mBuf); + switch(param->delType) { + case RGR_CELL_CFG: + CMCHKUNPK(cmUnpkLteCellId, ¶m->u.cellDel.cellId, mBuf); + break; + case RGR_UE_CFG: + CMCHKUNPK(cmUnpkLteCellId, ¶m->u.ueDel.cellId, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->u.ueDel.crnti, mBuf); + break; + case RGR_LCH_CFG: + CMCHKUNPK(cmUnpkLteCellId, ¶m->u.lchDel.cellId, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->u.lchDel.crnti, mBuf); + CMCHKUNPK(cmUnpkLteLcId, ¶m->u.lchDel.lcId, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->u.lchDel.lcgId, mBuf); + break; + case RGR_LCG_CFG: + CMCHKUNPK(cmUnpkLteCellId, ¶m->u.lcgDel.cellId, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->u.lcgDel.crnti, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->u.lcgDel.lcgId, mBuf); + break; +#ifdef LTE_ADV + case RGR_SCELL_UE_CFG: + CMCHKUNPK(cmUnpkLteCellId, ¶m->u.ueScellRel.cellId, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->u.ueScellRel.crnti, mBuf); + CMCHKUNPK(SUnpkU32, ¶m->u.ueScellRel.ueDelTypes, mBuf); + CMCHKUNPK(cmUnpkRgrUeSecCellRelInfo, ¶m->u.ueScellRel.ueSCellRelCfgInfo, mBuf); + break; +#endif + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} +/*********************************************************** +* +* Func : cmPkRgrSonPrbCfg +* +* +* Desc : SON PRB Configuration info for MAC +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrSonPrbCfg +( +RgrPrbCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrSonPrbCfg(param, mBuf) +RgrPrbCfg *param; +Buffer *mBuf; +#endif +{ + S32 count; + TRC3(cmPkRgrPrbCfg) + for(count = RGR_SCH_MAX_PA_PER_PRB - 1; count >= 0; count --) + { + CMCHKPK(SPkU32, param->paLevelPerPrb[count], mBuf); + } + for(count = param->numCellCentreUEs - 1; count >= 0; count --) + { + CMCHKPK(cmPkLteRnti, param->cellCentreUe[count], mBuf); + } + for(count = param->numCellEdgeUEs - 1; count >= 0; count --) + { + CMCHKPK(cmPkLteRnti, param->cellEdgeUe[count], mBuf); + } + CMCHKPK(SPkU8, param->numCellCentreUEs, mBuf); + CMCHKPK(SPkU8, param->numCellEdgeUEs, mBuf); + CMCHKPK(SPkU8, param->isSonIcicEnable, mBuf); + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func : cmUnpkRgrSon +* +* +* Desc : SON configuration info for MAC +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrSonPrbCfg +( +RgrPrbCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrSonPrbCfg(param, mBuf) +RgrPrbCfg *param; +Buffer *mBuf; +#endif +{ + S32 count; + TRC3(cmUnpkRgrSonPrbCfg) + CMCHKUNPK(SUnpkU8, ¶m->isSonIcicEnable, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numCellEdgeUEs, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numCellCentreUEs, mBuf); + for (count = 0; count < param->numCellEdgeUEs; count++) + { + CMCHKUNPK(cmUnpkLteRnti, ¶m->cellEdgeUe[count], mBuf); + } + for (count = 0; count < param->numCellCentreUEs; count++) + { + CMCHKUNPK(cmUnpkLteRnti, ¶m->cellCentreUe[count], mBuf); + } + for(count = 0; count < RGR_SCH_MAX_PA_PER_PRB; count ++) + { + CMCHKUNPK(SUnpkU32,(U32 *) ¶m->paLevelPerPrb[count], mBuf); + } + RETVALUE(ROK); +} +/*********************************************************** +* +* Func : cmPkRgrSonCfg +* +* +* Desc : SON Configuration info for MAC +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrSonCfg +( +RgrSonCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrSonCfg(param, mBuf) +RgrSonCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrSonCfg) + switch(param->cfgType) + { + case RGR_SON_PRB_CFG : + CMCHKPK(cmPkRgrSonPrbCfg, ¶m->u.prbCfg, mBuf); + break; + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkU32, param->cfgType, mBuf); + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func : cmUnpkRgrSon +* +* +* Desc : SON configuration info for MAC +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrSonCfg +( +RgrSonCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrSonCfg(param, mBuf) +RgrSonCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrSonCfg) + CMCHKUNPK(SUnpkU32, (U32 *)¶m->cfgType, mBuf); + switch(param->cfgType) + { + case RGR_SON_PRB_CFG : + { + CMCHKUNPK(cmUnpkRgrSonPrbCfg, ¶m->u.prbCfg, mBuf); + break; + default : + RETVALUE(RFAILED); + } + } + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func : cmPkRgrRst +* +* +* Desc : UE RESET info for MAC +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrRst +( +RgrRst *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrRst(param, mBuf) +RgrRst *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrRst) + + CMCHKPK(cmPkLteRnti, param->crnti, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrRst +* +* +* Desc : UE RESET info for MAC +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrRst +( +RgrRst *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrRst(param, mBuf) +RgrRst *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrRst) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->crnti, mBuf); + RETVALUE(ROK); +} +#ifdef LTE_ADV +/*********************************************************** +* +* Func : cmUnPkRgrSCellActDeactInfo +* +* +* Desc : SCell Activation information of the UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PRIVATE S16 cmUnPkRgrSCellActDeactInfo +( +RgrSCellActDeactInfo *param, +Buffer *mBuf +) +#else +PRIVATE S16 cmUnPkRgrSCellActInfo(param, mBuf) +RgrSCellActDeactInfo *param; +Buffer *mBuf; +#endif +{ + TRC3(cmUnPkRgrSCellActDeactInfo) + + CMCHKUNPK(SUnpkU8, ¶m->sCellIdx, mBuf); + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func : cmUnPkRgrSCellActDeactEvnt +* +* +* Desc : SCell Activation Configuration structure to SCH +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnPkRgrSCellActDeactEvnt +( +RgrSCellActDeactEvnt *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnPkRgrSCellActDeactEvnt(param, mBuf) +RgrSCellActDeactEvnt *param; +Buffer *mBuf; +#endif +{ + TRC3(cmUnPkRgrSCellActDeactEvnt) + + U8 idx; + + CMCHKUNPK(cmUnpkLteRnti, ¶m->crnti, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numOfSCells, mBuf); + + for(idx = 0; idx < param->numOfSCells;idx++) + { + CMCHKUNPK(cmUnPkRgrSCellActDeactInfo, ¶m->sCellActDeactInfo[idx],mBuf); + } + + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func : cmPkRgrSCellActInfo +* +* +* Desc : SCell Activation information of the UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PRIVATE S16 cmPkRgrSCellActDeactInfo +( +RgrSCellActDeactInfo *param, +Buffer *mBuf +) +#else +PRIVATE S16 cmPkRgrSCellActDeactInfo(param, mBuf) +RgrSCellActDeactInfo *param; +Buffer *mBuf; +#endif +{ + TRC3(cmPkRgrSCellActDeactInfo) + + CMCHKPK(SPkU8, param->sCellIdx, mBuf); + + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func : cmPkRgrSCellActDeactEvnt +* +* +* Desc : Basic Configuration structure at SCH +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrSCellActDeactEvnt +( +RgrSCellActDeactEvnt *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrSCellActDeactEvnt(param, mBuf) +RgrSCellActDeactEvnt *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrSCellActDeactEvnt) + + S8 idx; + for(idx = param->numOfSCells - 1; idx >= 0; idx--) + { + CMCHKPK(cmPkRgrSCellActDeactInfo, ¶m->sCellActDeactInfo[(U8)idx], mBuf); + } + + CMCHKPK(SPkU8, param->numOfSCells, mBuf); + CMCHKPK(cmPkLteRnti, param->crnti, mBuf); + + RETVALUE(ROK); +} + + +#endif /* LTE_ADV */ + +/*********************************************************** +* +* Func : cmPkRgrCfgReqInfo +* +* +* Desc : Basic RGR configuration/reconfiguration info at RRM +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrCfgReqInfo +( +RgrCfgReqInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrCfgReqInfo(param, mBuf) +RgrCfgReqInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrCfgReqInfo) + + switch(param->action) { + case RGR_SON_CFG: + CMCHKPK(cmPkRgrSonCfg, ¶m->u.sonCfg, mBuf); + break; + case RGR_RESET: + CMCHKPK(cmPkRgrRst, ¶m->u.rstInfo, mBuf); + break; + case RGR_DELETE: + CMCHKPK(cmPkRgrDel, ¶m->u.delInfo, mBuf); + break; + case RGR_RECONFIG: + CMCHKPK(cmPkRgrRecfg, ¶m->u.recfgInfo, mBuf); + break; + case RGR_CONFIG: + CMCHKPK(cmPkRgrCfg, ¶m->u.cfgInfo, mBuf); + break; +#ifdef LTE_ADV + case RGR_SCELL_ACT: + case RGR_SCELL_DEACT: + case RGR_SCELL_READY: + CMCHKPK(cmPkRgrSCellActDeactEvnt, ¶m->u.sCellActDeactEvnt, mBuf); + break; +#endif + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkU8, param->action, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRgrCfgReqInfo +* +* +* Desc : Basic RGR configuration/reconfiguration info at RRM +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrCfgReqInfo +( +RgrCfgReqInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrCfgReqInfo(param, mBuf) +RgrCfgReqInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrCfgReqInfo) + + CMCHKUNPK(SUnpkU8, ¶m->action, mBuf); + switch(param->action) { + case RGR_CONFIG: + CMCHKUNPK(cmUnpkRgrCfg, ¶m->u.cfgInfo, mBuf); + break; + case RGR_RECONFIG: + CMCHKUNPK(cmUnpkRgrRecfg, ¶m->u.recfgInfo, mBuf); + break; + case RGR_DELETE: + CMCHKUNPK(cmUnpkRgrDel, ¶m->u.delInfo, mBuf); + break; + case RGR_RESET: + CMCHKUNPK(cmUnpkRgrRst, ¶m->u.rstInfo, mBuf); + break; + case RGR_SON_CFG: + CMCHKUNPK(cmUnpkRgrSonCfg, ¶m->u.sonCfg, mBuf); + break; +#ifdef LTE_ADV + case RGR_SCELL_ACT: + case RGR_SCELL_DEACT: + case RGR_SCELL_READY: + CMCHKUNPK(cmUnPkRgrSCellActDeactEvnt, ¶m->u.sCellActDeactEvnt, mBuf); + break; +#endif /* LTE_ADV */ + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} +#ifdef RGR_V1 +/* rgr_c_001.main_5: ccpu00112398: Added periodicBSR-timer and + * retxBSR-timer */ +/*********************************************************** +* +* Func : cmPkRgrUeBsrTmrCfg +* +* +* Desc : BSR timer configuration per UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUeBsrTmrCfg +( +RgrUeBsrTmrCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUeBsrTmrCfg(param, mBuf) +RgrUeBsrTmrCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrUeBsrTmrCfg) + + CMCHKPK(SPkU16, param->prdBsrTmr, mBuf); + CMCHKPK(SPkU16, param->retxBsrTmr, mBuf); + CMCHKPK(SPkU8, param->isPrdBsrTmrPres, mBuf); + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func : cmUnpkRgrUeBsrTmrCfg +* +* +* Desc : BSR timer configuration per UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUeBsrTmrCfg +( +RgrUeBsrTmrCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUeBsrTmrCfg(param, mBuf) +RgrUeBsrTmrCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrUeBsrTmrCfg) + + CMCHKUNPK(SUnpkU8, ¶m->isPrdBsrTmrPres, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->retxBsrTmr, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->prdBsrTmr, mBuf); + RETVALUE(ROK); +} +#endif /* RGR_V1 */ +/* rgr_c_001.main_4-ADD-Added for SI Enhancement. */ +#ifdef RGR_SI_SCH +/*********************************************************** +* +* Func : cmPkRgrSiCfgReq +* +* +* Desc : SI Configuration Request from RRM to MAC for +* configuring SI +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrSiCfgReq +( +Pst* pst, +SpId spId, +RgrCfgTransId transId, +RgrSiCfgReqInfo * cfgReqInfo +) +#else +PUBLIC S16 cmPkRgrSiCfgReq(pst, spId, transId, cfgReqInfo) +Pst* pst; +SpId spId; +RgrCfgTransId transId; +RgrSiCfgReqInfo * cfgReqInfo; +#endif +{ + Buffer *mBuf = NULLP; + + TRC3(cmPkRgrSiCfgReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR045, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo, + sizeof(RgrSiCfgReqInfo)); + RETVALUE(RFAILED); + } + if (cmPkRgrSiCfgReqInfo(cfgReqInfo, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR046, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo, + sizeof(RgrSiCfgReqInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (cmPkRgrCfgTransId(&transId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR047, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo, + sizeof(RgrSiCfgReqInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR048, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo, + sizeof(RgrSiCfgReqInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo, + sizeof(RgrSiCfgReqInfo)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR049, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + pst->event = (Event) EVTRGRSICFGREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + +/*********************************************************** +* +* Func : cmUnpkRgrSiCfgReq +* +* +* Desc : SI Configuration Request from RRM to MAC for +* configuring SI +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrSiCfgReq +( +RgrSiCfgReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrSiCfgReq(func, pst, mBuf) +RgrSiCfgReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SpId spId; + RgrCfgTransId transId; + RgrSiCfgReqInfo *cfgReqInfo; + + TRC3(cmUnpkRgrSiCfgReq) + + if (SUnpkS16(&spId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR050, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (cmUnpkRgrCfgTransId(&transId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR051, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if ((SGetSBuf(pst->region, pst->pool, (Data **)&cfgReqInfo, + sizeof(RgrSiCfgReqInfo))) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR052, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + cmMemset((U8 *)cfgReqInfo, 0, sizeof(RgrSiCfgReqInfo)); + if (pst->selector == RGR_SEL_LC) + if (cmUnpkRgrSiCfgReqInfo(cfgReqInfo, mBuf) != ROK) { + SPutSBuf(pst->region, pst->pool, (Data *)cfgReqInfo, + sizeof(RgrSiCfgReqInfo)); + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR053, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + + RETVALUE((*func)(pst, spId, transId, cfgReqInfo)); +} + +/*********************************************************** +* +* Func : cmPkRgrSiCfgReqInfo +* +* +* Desc : Basic SI configuration/reconfiguration info at RRM +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrSiCfgReqInfo +( +RgrSiCfgReqInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrSiCfgReqInfo(param, mBuf) +RgrSiCfgReqInfo *param; +Buffer *mBuf; +#endif +{ + /* ccpu00111328: S16 is renamed as MsgLen */ + MsgLen msgLen; + + TRC3(cmPkRgrSiCfgReqInfo) + + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + CMCHKPK(SPkS32, param->cfgType, mBuf); + CMCHKPK(SPkU8, param->siId, mBuf); + + if(NULLP != param->pdu) + { + if (SFndLenMsg(param->pdu, &msgLen) != ROK) + RETVALUE(RFAILED); + if (SCatMsg(mBuf, param->pdu, M1M2) != ROK) + RETVALUE(RFAILED); + SPutMsg(param->pdu); + CMCHKPK(cmPkMsgLen, msgLen, mBuf); + } + /*ccpu00140789*/ + else + { + CMCHKPK(cmPkMsgLen, 0, mBuf); + } + + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func : cmUnpkRgrSiCfgReqInfo +* +* +* Desc : Basic SI configuration/reconfiguration info at RRM +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrSiCfgReqInfo +( +RgrSiCfgReqInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrSiCfgReqInfo(param, mBuf) +RgrSiCfgReqInfo *param; +Buffer *mBuf; +#endif +{ + MsgLen msgLen, totalMsgLen; + /*Merge from Mohit Changes*/ + S32 cfgType; + + TRC3(cmUnpkRgrSiCfgReqInfo) + + SFndLenMsg(mBuf, &msgLen); + if(msgLen > 0) + { + CMCHKUNPK(cmUnpkMsgLen, &msgLen, mBuf); + /*ccpu00140789*/ + if(msgLen > 0) + { + if (SFndLenMsg(mBuf, &totalMsgLen) != ROK) + RETVALUE(RFAILED); + if (SSegMsg(mBuf, totalMsgLen-msgLen, ¶m->pdu) != ROK) + RETVALUE(RFAILED); + } + else + { + param->pdu = NULLP; + } + } + + CMCHKUNPK(SUnpkU8, ¶m->siId, mBuf); + /*CMCHKUNPK(SUnpkS32, (S32 *)¶m->cfgType, mBuf);*/ + /*Merge from Mohit Changes*/ + CMCHKUNPK(SUnpkS32,(S32 *)&cfgType, mBuf); + param->cfgType = (RgrSiCfgType) cfgType; + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrWarningSiCfgReq +* +* +* Desc : SI Configuration Request from RRM to MAC for +* configuring warning SI +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrWarningSiCfgReq +( +Pst* pst, +SpId spId, +RgrCfgTransId transId, +RgrWarningSiCfgReqInfo * warningSiCfgReqInfo +) +#else +PUBLIC S16 cmPkRgrWarningSiCfgReq(pst, spId, transId, warningSiCfgReqInfo) +Pst* pst; +SpId spId; +RgrCfgTransId transId; +RgrWarningSiCfgReqInfo * warningSiCfgReqInfo; +#endif +{ + Buffer *mBuf = NULLP; + + TRC3(cmPkRgrWarningSiCfgReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR061, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)warningSiCfgReqInfo, + sizeof(RgrWarningSiCfgReqInfo)); + RETVALUE(RFAILED); + } + + if (cmPkRgrWarningSiCfgReqInfo(pst, warningSiCfgReqInfo, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR062, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)warningSiCfgReqInfo, + sizeof(RgrWarningSiCfgReqInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (cmPkRgrCfgTransId(&transId, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR063, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)warningSiCfgReqInfo, + sizeof(RgrWarningSiCfgReqInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (SPkS16(spId, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR064, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)warningSiCfgReqInfo, + sizeof(RgrWarningSiCfgReqInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + /* if the application wants to retain this structure, the below + * code should be removed */ + if (SPutSBuf(pst->region, pst->pool, (Data *)warningSiCfgReqInfo, + sizeof(RgrWarningSiCfgReqInfo)) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR065, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + pst->event = (Event) EVTRGRWARNINGSICFGREQ; + RETVALUE(SPstTsk(pst,mBuf)); +}/*cmPkRgrWarningSiCfgReq*/ + + +/*********************************************************** +* +* Func : cmUnpkRgrWarningSiCfgReq +* +* +* Desc : SI Configuration Request from RRM to MAC for +* configuring warning SI +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrWarningSiCfgReq +( +RgrWarningSiCfgReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrWarningSiCfgReq(func, pst, mBuf) +RgrWarningSiCfgReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SpId spId; + RgrCfgTransId transId; + RgrWarningSiCfgReqInfo *warningSiCfgReqInfo; + + TRC3(cmUnpkRgrWarningSiCfgReq) + + if (SUnpkS16(&spId, mBuf) != ROK) + { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR066, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + + if (cmUnpkRgrCfgTransId(&transId, mBuf) != ROK) + { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR067, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + + if ((SGetSBuf(pst->region, pst->pool, (Data **)&warningSiCfgReqInfo, + sizeof(RgrWarningSiCfgReqInfo))) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR068, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + + if (pst->selector == RGR_SEL_LC) + { + if (cmUnpkRgrWarningSiCfgReqInfo(pst, warningSiCfgReqInfo, mBuf) != ROK) + { + SPutSBuf(pst->region, pst->pool, (Data *)warningSiCfgReqInfo, + sizeof(RgrWarningSiCfgReqInfo)); + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR069, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + } + SPutMsg(mBuf); + + RETVALUE((*func)(pst, spId, transId, warningSiCfgReqInfo)); +} /* cmUnpkRgrWarningSiCfgReq */ + + +/*********************************************************** +* +* Func : cmPkRgrWarningSiCfgReqInfo +* +* +* Desc : Basic warning SI configuration/reconfiguration +* info at RRM +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrWarningSiCfgReqInfo +( +Pst *pst, +RgrWarningSiCfgReqInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrWarningSiCfgReqInfo(pst, param, mBuf) +Pst *pst; +RgrWarningSiCfgReqInfo *param; +Buffer *mBuf; +#endif +{ + MsgLen msgLen; + U32 count; + CmLList *node, *prevNode; + RgrSegmentInfo *pdu; + + TRC3(cmPkRgrWarningSiCfgReqInfo) + + CMCHKPK(SPkU8, param->emtcEnable, mBuf); + + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + CMCHKPK(SPkU8, param->siId, mBuf); + + count = param->siPduLst.count; + node = param->siPduLst.last; + while (node) + { + pdu = (RgrSegmentInfo *)node->node; + prevNode= node->prev; + if(NULLP != pdu) + { + if (SFndLenMsg(pdu->pdu, &msgLen) != ROK) + RETVALUE(RFAILED); + if (SCatMsg(mBuf, pdu->pdu, M1M2) != ROK) + RETVALUE(RFAILED); + /* The PDU is not Released. This has to be done by + * the caller of the packing function */ + CMCHKPK(cmPkMsgLen, msgLen, mBuf); + SPutMsg(pdu->pdu); + } + cmLListDelFrm(¶m->siPduLst, node); + SPutSBuf(pst->region, pst->pool, (Data *)node, sizeof(RgrSegmentInfo)); + node= prevNode; + } + CMCHKPK(SPkU32, count, mBuf); + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func : cmUnpkRgrWarningSiCfgReqInfo +* +* +* Desc : Unpack warning SI configuration info at SCH +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrWarningSiCfgReqInfo +( +Pst *pst, +RgrWarningSiCfgReqInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrWarningSiCfgReqInfo(pst, param, mBuf) +Pst *pst; +RgrWarningSiCfgReqInfo *param; +Buffer *mBuf; +#endif +{ + MsgLen msgLen, totalMsgLen; + U32 count, loopCnt; + Buffer *pdu; + CmLList *node; + + TRC3(cmUnpkRgrWarningSiCfgReqInfo) + + cmLListInit(¶m->siPduLst); + CMCHKUNPK(SUnpkU32, &count, mBuf); + for (loopCnt=0; loopCnt 0) + { + CMCHKUNPK(cmUnpkMsgLen, &msgLen, mBuf); + if (SFndLenMsg(mBuf, &totalMsgLen) != ROK) + { + RETVALUE(RFAILED); + } + if (SSegMsg(mBuf, totalMsgLen-msgLen, &pdu) != ROK) + { + RETVALUE(RFAILED); + } + } + else + { + RETVALUE(RFAILED); + } + if ((SGetSBuf(pst->region, pst->pool, (Data **)&node, + sizeof(CmLList))) != ROK) + RETVALUE(RFAILED); + node->node = (PTR)pdu; + cmLListAdd2Tail(¶m->siPduLst, node); + } + + CMCHKUNPK(SUnpkU8, ¶m->siId, mBuf); + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKPK(SUnpkU8, ¶m->emtcEnable, mBuf); + + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func : cmPkRgrWarningSiStopReq +* +* Desc : To stop the broadcast for SIB10, SIB11 and SIB12. +* +* Ret : S16 +* +* Notes: +* +* File : +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrWarningSiStopReq +( +Pst *pst, +SpId spId, +RgrCfgTransId transId, +U8 siId +) +#else +PUBLIC S16 cmPkRgrWarningSiStopReq(pst,spId, transId, siId) +Pst *pst; +SpId spId; +RgrCfgTransId transId; +U8 siId; +#endif +{ + Buffer *mBuf = NULLP; + + TRC3(cmPkRgrWarningSiStopReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR070, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + + CMCHKPK(SPkU8, siId, mBuf); + + + if (cmPkRgrCfgTransId(&transId, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR082, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + + if (SPkS16(spId, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR071, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + pst->event = (Event) EVTRGRWARNINGSISTOPREQ; + RETVALUE(SPstTsk(pst,mBuf)); +}/*cmPkRgrWarningSiStopReq */ + + +/*********************************************************** +* +* Func : cmUnpkRgrWarningSiStopReq +* +* Desc : To stop the broadcast for SIB10, SIB11 and SIB12. +* +* Ret : S16 +* +* Notes: +* +* File : +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrWarningSiStopReq +( +RgrWarningSiStopReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrWarningSiStopReq(param, mBuf) +RgrWarningSiStopReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SpId spId; + U8 siId; + RgrCfgTransId transId; + + TRC3(cmUnpkRgrWarningSiStopReq) + + if (SUnpkS16(&spId, mBuf) != ROK) + { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR072, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + + if (cmUnpkRgrCfgTransId(&transId, mBuf) != ROK) + { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR083, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + + CMCHKUNPK(SUnpkU8, &siId, mBuf); + + SPutMsg(mBuf); + + RETVALUE((*func)(pst, spId, transId, siId)); +} /*cmUnpkRgrWarningSiStopReq */ + + +/*********************************************************** +* +* Func : cmPkRgrWarningSiCfgCfm +* +* +* Desc : Warning SI Configuration Confirm from MAC to RRM +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrWarningSiCfgCfm +( +Pst* pst, +SuId suId, +RgrCfgTransId transId, +U8 siId, +U8 status +) +#else +PUBLIC S16 cmPkRgrWarningSiCfgCfm(pst, suId, transId, siId, status) +Pst* pst; +SuId suId; +RgrCfgTransId transId; +U8 siId; +U8 status; +#endif +{ + Buffer *mBuf = NULLP; + + TRC3(cmPkRgrWarningSiCfgCfm) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR073, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + + if (SPkU8(status, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR074, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (SPkU8(siId, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR075, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (cmPkRgrCfgTransId(&transId, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR076, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (SPkS16(suId, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR077, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + pst->event = (Event) EVTRGRWARNINGSICFGCFM; + RETVALUE(SPstTsk(pst,mBuf)); +} /* cmPkRgrWarningSiCfgCfm */ + + +/*********************************************************** +* +* Func : cmUnpkRgrwarningSiCfgCfm +* +* +* Desc : Warning SI Configuration Confirm from MAC to RRM +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrWarningSiCfgCfm +( +RgrWarningSiCfgCfm func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrWarningSiCfgCfm(func, pst, mBuf) +RgrWarningSiCfgCfm func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + U8 siId; + RgrCfgTransId transId; + U8 status; + + TRC3(cmUnpkRgrWarningSiCfgCfm) + + if (SUnpkS16(&suId, mBuf) != ROK) + { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR078, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + + if (cmUnpkRgrCfgTransId(&transId, mBuf) != ROK) + { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR079, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + + if (SUnpkU8(&siId, mBuf) != ROK) + { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR080, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + + if (SUnpkU8(&status, mBuf) != ROK) + { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR081, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, suId, transId, siId, status)); +}/* cmUnpkRgrwarningSiCfgCfm */ +#endif/*RGR_SI_SCH*/ + +/* LTE_ADV_FLAG_REMOVED_START */ +/*********************************************************** +* +* Func : cmPkRgrLoadInfReq +* +* +* Desc : LOAD INF Configuration Request from RRM to MAC for +* configuring RNTP, ABS etc +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrLoadInfReq +( +Pst* pst, +SpId spId, +RgrCfgTransId transId, +RgrLoadInfReqInfo * loadInfReq +) +#else +PUBLIC S16 cmPkRgrLoadInfReq(pst, spId, transId, loadInfReq) +Pst* pst; +SpId spId; +RgrCfgTransId transId; +RgrLoadInfReqInfo * loadInfReq; +#endif +{ + Buffer *mBuf = NULLP; + + TRC3(cmPkRgrLoadInfReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR045, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)loadInfReq, + sizeof(RgrLoadInfReqInfo)); + RETVALUE(RFAILED); + } + if (cmPkRgrLoadInfReqInfo(loadInfReq, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR046, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)loadInfReq, + sizeof(RgrLoadInfReqInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (cmPkRgrCfgTransId(&transId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR047, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)loadInfReq, + sizeof(RgrLoadInfReqInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR048, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)loadInfReq, + sizeof(RgrLoadInfReqInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPutSBuf(pst->region, pst->pool, (Data *)loadInfReq, + sizeof(RgrLoadInfReqInfo)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR049, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + pst->event = (Event) EVTRGRLOADINFREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + +/*********************************************************** +* +* Func : cmUnpkRgrLoadInfReq +* +* +* Desc : LOAD INF Configuration Request from RRM to MAC for +* configuring RNTP, ABS etc +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrLoadInfReq +( +RgrLoadInfReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrLoadInfReq(func, pst, mBuf) +RgrLoadInfReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SpId spId; + RgrCfgTransId transId; + RgrLoadInfReqInfo *loadInfReq; + + TRC3(cmUnpkRgrLoadInfReq) + + if (SUnpkS16(&spId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR050, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + + if (cmUnpkRgrCfgTransId(&transId, mBuf) != ROK) { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR051, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + + if ((SGetSBuf(pst->region, pst->pool, (Data **)&loadInfReq, + sizeof(RgrLoadInfReqInfo))) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR052, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + cmMemset((U8 *)loadInfReq, 0, sizeof(RgrLoadInfReqInfo)); + + if (pst->selector == RGR_SEL_LC) + if (cmUnpkRgrLoadInfReqInfo(loadInfReq, mBuf) != ROK) { + SPutSBuf(pst->region, pst->pool, (Data *)loadInfReq, + sizeof(RgrLoadInfReqInfo)); + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR053, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + + RETVALUE((*func)(pst, spId, transId, loadInfReq)); +} + +/*********************************************************** +* +* Func : cmPkRgrLoadInfReqInfo +* +* +* Desc : Basic LOAD INF configuration/reconfiguration info at RRM +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrLoadInfReqInfo +( +RgrLoadInfReqInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrLoadInfReqInfo(param, mBuf) +RgrLoadInfReqInfo *param; +Buffer *mBuf; +#endif +{ + TRC3(cmPkRgrLoadInfReqInfo) + + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + CMCHKPK(SPkU8, param->rgrCcPHighStartRb, mBuf); + CMCHKPK(SPkU8, param->rgrCcPHighEndRb, mBuf); + + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func : cmUnpkRgrLoadInfReqInfo +* +* +* Desc : Basic LOAD INF configuration/reconfiguration info at RRM +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrLoadInfReqInfo +( +RgrLoadInfReqInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrLoadInfReqInfo(param, mBuf) +RgrLoadInfReqInfo *param; +Buffer *mBuf; +#endif +{ + TRC3(cmUnpkRgrLoadInfReqInfo) + + CMCHKUNPK(SUnpkU8, ¶m->rgrCcPHighEndRb, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->rgrCcPHighStartRb, mBuf); + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + + RETVALUE(ROK); +} +/* LTE_ADV_FLAG_REMOVED_END */ + +/*rgr_c_001.main_9 ccpu00117452 - MOD - Changed macro name from + RGR_RRM_DLPWR_CNTRL to RGR_CQI_REPT */ +#ifdef RGR_CQI_REPT + +/*********************************************************** +* +* Func : cmPkRgrUeCqiReptCfg +* +* +* Desc : Transaction ID between MAC and RRM +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUeCqiReptCfg +( +RgrUeCqiReptCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUeCqiReptCfg(param, mBuf) +RgrUeCqiReptCfg *param; +Buffer *mBuf; +#endif +{ + TRC3(cmPkRgrUeCqiReptCfg) + + CMCHKPK(SPkU8, param->numColltdCqiRept, mBuf); + + RETVALUE(ROK); +} + + +/*rgr_c_001.main_9 ADD added changes for CQI management*/ +/*********************************************************** +* +* Func : cmUnpkRgrUeCqiReptCfg +* +* +* Desc : Transaction ID between MAC and RRM +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUeCqiReptCfg +( +RgrUeCqiReptCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUeCqiReptCfg(param, mBuf) +RgrUeCqiReptCfg *param; +Buffer *mBuf; +#endif +{ + TRC3(cmUnpkRgrUeCqiReptCfg) + + CMCHKUNPK(SUnpkU8, ¶m->numColltdCqiRept, mBuf); + + RETVALUE(ROK); +} + + +/*rgr_c_001.main_9 ADD added changes for CQI management*/ +/*********************************************************** +* +* Func : cmPkRgrStaInd +* +* +* Desc : Packing Sta Indication sent to RRM +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrStaInd +( +Pst* pst, +SuId suId, +RgrStaIndInfo* staInd +) +#else +PUBLIC S16 cmPkRgrStaInd(pst, suId, staInd) +Pst* pst; +SuId suId; +RgrStaIndInfo* staInd; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkRgrStaInd) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR054, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)staInd, + sizeof(RgrStaIndInfo)); + RETVALUE(RFAILED); + } + + if (cmPkRgrStaIndInfo(staInd, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR055, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)staInd, sizeof(RgrStaIndInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (SPkS16(suId, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR056, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)staInd, + sizeof(RgrStaIndInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (SPutSBuf(pst->region, pst->pool, (Data *)staInd, + sizeof(RgrStaIndInfo)) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR057, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + pst->event = (Event) EVTRGRSTAIND; + RETVALUE(SPstTsk(pst,mBuf)); +} + +/*rgr_c_001.main_9 ADD added changes for CQI management*/ +/*********************************************************** +* +* Func : cmUnpkRgrStaInd +* +* +* Desc : Unpacking Sta Indication sent to RRM +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrStaInd +( +RgrStaInd func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrStaInd(func, pst, mBuf) +RgrStaInd func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + RgrStaIndInfo *staInd; + + TRC3(cmUnpkRgrStaInd) + + if (SUnpkS16(&suId, mBuf) != ROK) + { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR058, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + + if ((SGetSBuf(pst->region, pst->pool, (Data **)&staInd, + sizeof(RgrStaIndInfo))) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR059, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (cmUnpkRgrStaIndInfo(staInd, mBuf) != ROK) + { + SPutSBuf(pst->region, pst->pool, (Data *)staInd, + sizeof(RgrStaIndInfo)); + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR060, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + + SPutMsg(mBuf); + RETVALUE((*func)(pst, suId, staInd)); +} + +/*rgr_c_001.main_9 ADD added changes for CQI management*/ +/*********************************************************** +* +* Func : cmPkRgrStaIndInfo +* +* +* Desc : Packing of StaIndInfo structure +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrStaIndInfo +( +RgrStaIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrStaIndInfo(param, mBuf) +RgrStaIndInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrStaIndInfo) + + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + CMCHKPK(cmPkLteRnti, param->crnti, mBuf); + CMCHKPK(cmPkRgrUeCqiInfo, ¶m->ueCqiInfo, mBuf); + + RETVALUE(ROK); +} +/*rgr_c_001.main_9 ADD added changes for CQI management*/ +/*********************************************************** +* +* Func : cmUnpkRgrStaIndInfo +* +* +* Desc : Unpacking of StaIndInfo structure +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrStaIndInfo +( +RgrStaIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrStaIndInfo(param, mBuf) +RgrStaIndInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrStaIndInfo) + + CMCHKUNPK(cmUnpkRgrUeCqiInfo, ¶m->ueCqiInfo, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->crnti, mBuf); + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + + RETVALUE(ROK); +} +/*rgr_c_001.main_9 ADD added changes for CQI management*/ +/*********************************************************** +* +* Func : cmPkRgrUeCqiInfo +* +* +* Desc : Packing of StaIndInfo structure +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUeCqiInfo +( +RgrUeCqiInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUeCqiInfo(param, mBuf) +RgrUeCqiInfo *param; +Buffer *mBuf; +#endif +{ + + S16 idx; + TRC3(cmPkRgrUeCqiInfo) + + for (idx = param->numCqiRept - 1; idx >= 0; idx--) + { + CMCHKPK(cmPkRgrUeCqiRept, ¶m->cqiRept[idx], mBuf); + } + CMCHKPK(SPkU8, param->numCqiRept, mBuf); + + RETVALUE(ROK); +} /* cmPkRgrUeCqiInfo */ + +/*rgr_c_001.main_9 ADD added changes for CQI management*/ +/*********************************************************** +* +* Func : cmUnpkRgrUeCqiInfo +* +* +* Desc : Packing of StaIndInfo structure +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUeCqiInfo +( +RgrUeCqiInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUeCqiInfo(param, mBuf) +RgrUeCqiInfo *param; +Buffer *mBuf; +#endif +{ + + U8 idx; + TRC3(cmUnpkRgrUeCqiInfo) + + CMCHKUNPK(SUnpkU8, ¶m->numCqiRept, mBuf); + for (idx = 0; idx < param->numCqiRept; idx++) + { + CMCHKUNPK(cmUnpkRgrUeCqiRept, ¶m->cqiRept[idx], mBuf); + } + + RETVALUE(ROK); +} /* cmUnpkRgrUeCqiInfo */ + +/*********************************************************** +* +* Func : cmPkRgrSubBandCqiInfo +* +* +* Desc : Packing ofcmPkRgrSubBandCqiInfo structure +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrSubBandCqiInfo +( +RgrSubBandCqiInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrSubBandCqiInfo(param, mBuf) +RgrSubBandCqiInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrSubBandCqiInfo) + + CMCHKPK(SPkU8, param->cqi[0], mBuf); + CMCHKPK(SPkU8, param->cqi[1], mBuf); + CMCHKPK(SPkU8, param->subBandIdx, mBuf); + + RETVALUE(ROK); +} /* cmPkRgrSubBandCqiInfo */ + +/*rgr_c_001.main_9 ADD added changes for CQI management*/ +/*********************************************************** +* +* Func : cmPkRgrUeCqiRept +* +* +* Desc : Packing of StaIndInfo structure +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUeCqiRept +( +RgrUeCqiRept *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUeCqiRept(param, mBuf) +RgrUeCqiRept *param; +Buffer *mBuf; +#endif +{ + S8 idx; + U8 count; + + TRC3(cmPkRgrUeCqiRept) + + CMCHKPK(SPkU8, param->cqi[0], mBuf); + CMCHKPK(SPkU8, param->cqi[1], mBuf); + CMCHKPK(SPkU8, param->cqiMode, mBuf); + for (idx = param->numSubBand - 1; idx >= 0; idx--) + { + count = idx; + CMCHKPK(cmPkRgrSubBandCqiInfo, ¶m->sbCqiInfo[count], mBuf); + } + CMCHKPK(SPkU8, param->numSubBand, mBuf); + RETVALUE(ROK); +} /* cmPkRgrUeCqiRept */ + +/*********************************************************** +* +* Func :cmUnpkRgrSubBandCqiInfo +* +* +* Desc : Packing of cmUnpkRgrSubBandCqiInfo structure +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrSubBandCqiInfo +( +RgrSubBandCqiInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrSubBandCqiInfo(param, mBuf) +RgrSubBandCqiInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrSubBandCqiInfo) + + CMCHKUNPK(SUnpkU8, ¶m->subBandIdx, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->cqi[1], mBuf); + CMCHKUNPK(SUnpkU8, ¶m->cqi[0], mBuf); + + RETVALUE(ROK); +} /* cmUnpkRgrSubBandCqiInfo*/ + +/*rgr_c_001.main_9 ADD added changes for CQI management*/ +/*********************************************************** +* +* Func : cmUnpkRgrUeCqiRept +* +* +* Desc : Packing of StaIndInfo structure +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUeCqiRept +( +RgrUeCqiRept *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUeCqiRept(param, mBuf) +RgrUeCqiRept *param; +Buffer *mBuf; +#endif +{ + U8 idx; + + TRC3(cmUnpkRgrUeCqiRept) + CMCHKUNPK(SUnpkU8, ¶m->numSubBand, mBuf); + for (idx = 0; idx < param->numSubBand; idx++) + { + CMCHKUNPK(cmUnpkRgrSubBandCqiInfo, ¶m->sbCqiInfo[idx], mBuf); + } + CMCHKUNPK(SUnpkU8, ¶m->cqiMode, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->cqi[1], mBuf); + CMCHKUNPK(SUnpkU8, ¶m->cqi[0], mBuf); + + RETVALUE(ROK); +} /* cmUnpkRgrUeCqiRept */ +#endif /* End of ifdef RGR_CQI_REPT */ + +/* LTE_ADV_FLAG_REMOVED_START */ +/*********************************************************** +* +* Func : cmPkRgrLoadInfInd +* +* +* Desc : Packing LOAD INFORMATION Indication sent to RRM +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrLoadInfInd +( +Pst* pst, +SuId suId, +RgrLoadInfIndInfo* loadInfInd +) +#else +PUBLIC S16 cmPkRgrLoadInfInd(pst, suId, loadInfInd) +Pst* pst; +SuId suId; +RgrLoadInfIndInfo* loadInfInd; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkRgrLoadInfInd) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR054, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)loadInfInd, + sizeof(RgrLoadInfIndInfo)); + RETVALUE(RFAILED); + } + + if (cmPkRgrLoadInfIndInfo(loadInfInd, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR055, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)loadInfInd, + sizeof(RgrLoadInfIndInfo)); + SPutMsg(mBuf); + + RETVALUE(RFAILED); + } + + if (SPkS16(suId, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR056, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)loadInfInd, + sizeof(RgrLoadInfIndInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (SPutSBuf(pst->region, pst->pool, (Data *)loadInfInd, + sizeof(RgrLoadInfIndInfo)) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR057, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + pst->event = (Event) EVTRGRLOADINFIND; + RETVALUE(SPstTsk(pst,mBuf)); +} + +/*********************************************************** +* +* Func : cmUnpkRgrLoadInfInd +* +* +* Desc : Unpacking LOAD INFORMATION Indication sent to RRM +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrLoadInfInd +( +RgrLoadInfInd func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrLoadInfInd(func, pst, mBuf) +RgrLoadInfInd func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + RgrLoadInfIndInfo *loadInfInd = NULLP; /* dsfr_pal_fixes ** 21-March-2013 ** SKS */ + + TRC3(cmUnpkRgrLoadInfInd) + + if (SUnpkS16(&suId, mBuf) != ROK) + { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR058, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + + if ((SGetSBuf(pst->region, pst->pool, (Data **)&loadInfInd, + sizeof(RgrLoadInfIndInfo))) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR059, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + /* dsfr_pal_fixes ** 22-March-2013 ** SKS */ + if (cmUnpkRgrLoadInfIndInfo(loadInfInd, pst, mBuf) != ROK) + { + SPutSBuf(pst->region, pst->pool, (Data *)loadInfInd, + sizeof(RgrLoadInfIndInfo)); + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR060, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + + SPutMsg(mBuf); + RETVALUE((*func)(pst, suId, loadInfInd)); +} + + +/*********************************************************** +* +* Func : cmPkRgrLoadInfIndInfo +* +* +* Desc : Packing of LoadInfIndInfo structure +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrLoadInfIndInfo +( +RgrLoadInfIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrLoadInfIndInfo(param, mBuf) +RgrLoadInfIndInfo *param; +Buffer *mBuf; +#endif +{ + U8 idx; + TRC3(cmPkRgrLoadInfIndInfo) + + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + CMCHKPK(SPkU16, param->bw, mBuf); + if(RGR_ABS == param->type) + { + for(idx = 0; idx < RGR_ABS_PATTERN_LEN; idx++) + { + CMCHKPK(SPkU32, param->u.absLoadInfo[idx], mBuf); + } + } + else + { + CMCHKPK(cmPkTknStrOSXL, ¶m->u.rntpInfo, mBuf); + } + + CMCHKPK(SPkU32, param->type, mBuf); + + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func : cmUnpkRgrLoadInfIndInfo +* +* +* Desc : Unpacking of LoadInfIndInfo structure +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrLoadInfIndInfo +( +RgrLoadInfIndInfo *param, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrLoadInfIndInfo(param, pst, mBuf) +RgrLoadInfIndInfo *param; +Pst *pst; +Buffer *mBuf; +#endif +{ + S8 idx; +#if 0 + Ptr ptr; +#endif + + /* dsfr_pal_fixes ** 21-March-2013 ** SKS */ + TknStrOSXL *tknStr; + U16 ndx; + + TRC3(cmUnpkRgrLoadInfIndInfo) + + CMCHKUNPK(SUnpkU32, ¶m->type, mBuf); + if(RGR_ABS == param->type) + { + for(idx = RGR_ABS_PATTERN_LEN -1 ; idx >= 0; idx--) + { + CMCHKUNPK(SUnpkU32, ¶m->u.absLoadInfo[(U8)idx], mBuf); + } + } + else + { +#if 0 + ptr =(Ptr)param; +#endif + + /* dsfr_pal_fixes ** 21-March-2013 ** SKS ** Start */ + tknStr = ¶m->u.rntpInfo; + + CMCHKUNPK(SUnpkU8, &tknStr->pres, mBuf); + + if(tknStr->pres) + { + /* Length */ + CMCHKUNPK(SUnpkU16, &tknStr->len, mBuf); + + if ((SGetSBuf(pst->region, pst->pool, (Data **)&tknStr->val,tknStr->len)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR052, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + /* Value */ + for (ndx = 1; ndx <= tknStr->len; ndx++) + { + CMCHKUNPK(SUnpkU8, &tknStr->val[tknStr->len - ndx], mBuf); + } + } + } + /* dsfr_pal_fixes ** 21-March-2013 ** SKS ** End */ + + /* dsfr_pal_fixes ** 22-March-2013 ** SKS */ + CMCHKUNPK(SUnpkU16, ¶m->bw, mBuf); + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + + RETVALUE(ROK); +} +/* LTE_ADV_FLAG_REMOVED_END */ + +#ifdef TFU_UPGRADE +/*rgr_c_001.main_9 ADD added changes for CQI management*/ +/*********************************************************** +* +* Func : cmPkRgrUepACfg +* +* +* Desc : Transaction ID between MAC and RRM +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUepACfg +( +RgrUepACfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUepACfg(param, mBuf) +RgrUepACfg *param; +Buffer *mBuf; +#endif +{ + TRC3(cmPkRgrUepACfg) + + if(param->pAPrsnt) + { + CMCHKPK(SPkU32, param->pA, mBuf); + } + CMCHKPK(SPkU8, param->pAPrsnt, mBuf); + + RETVALUE(ROK); +} + + +/*rgr_c_001.main_9 ADD added changes for CQI management*/ +/*********************************************************** +* +* Func : cmUnpkRgrUepACfg +* +* +* Desc : Transaction ID between MAC and RRM +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUepACfg +( +RgrUepACfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUepACfg(param, mBuf) +RgrUepACfg *param; +Buffer *mBuf; +#endif +{ + U32 tmpEnum; + TRC3(cmUnpkRgrUepACfg) + + CMCHKUNPK(SUnpkU8, (U8 *)¶m->pAPrsnt, mBuf); + if (param->pAPrsnt) + { + CMCHKUNPK(SUnpkU32, (U32*)&tmpEnum, mBuf); + param->pA = (RgrUeDlPwrCntrlPaCfg) tmpEnum; + } + + RETVALUE(ROK); +} + +/*rgr_c_001.main_9 ADD PDSCH ded cfg*/ +/*********************************************************** +* +* Func : cmPkRgrUePdschDedCfg +* +* +* Desc : Transaction ID between MAC and RRM +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUePdschDedCfg +( +RgrUePdschDedCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUePdschDedCfg(param, mBuf) +RgrUePdschDedCfg *param; +Buffer *mBuf; +#endif +{ + TRC3(cmPkRgrUePdschDedCfg) + + CMCHKPK(cmPkRgrUepACfg, ¶m->uepACfg, mBuf); + + RETVALUE(ROK); +} + + +/*rgr_c_001.main_9 ADD PDSCH ded cfg*/ +/*********************************************************** +* +* Func : cmUnpkRgrUePdschDedCfg +* +* +* Desc : Transaction ID between MAC and RRM +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUePdschDedCfg +( +RgrUePdschDedCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUePdschDedCfg(param, mBuf) +RgrUePdschDedCfg *param; +Buffer *mBuf; +#endif +{ + TRC3(cmUnpkRgrUePdschDedCfg) + + CMCHKUNPK(cmUnpkRgrUepACfg, ¶m->uepACfg, mBuf); + + RETVALUE(ROK); +} +#endif + + +#ifdef LTE_ADV + +/*********************************************************** +* +* Func : cmPkRgrUeUlPwrDedSCellCfg +* +* +* Desc : DL Secondary Cell UL PC Info +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PRIVATE S16 cmPkRgrUeUlPwrDedSCellCfg +( +RgrUeUlPwrDedSCellCfg *param, +Buffer *mBuf +) +#else +PRIVATE S16 cmPkRgrUeUlPwrDedSCellCfg(param, mBuf) +RgrUeUlPwrDedSCellCfg *param; +Buffer *mBuf; +#endif +{ + TRC3(cmPkRgrUeUlPwrDedSCellCfg) + CMCHKPK(SPkU8, param->pSRSOffset, mBuf); + CMCHKPK(SPkS8, param->p0UePusch, mBuf); + CMCHKPK(SPkU8, param->isDeltaMCSEnabled, mBuf); + CMCHKPK(SPkU8, param->isAccumulated, mBuf); + + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func : cmUnpkRgrUeUlPwrDedSCellCfg +* +* +* Desc : Uplink power configuration per UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PRIVATE S16 cmUnpkRgrUeUlPwrDedSCellCfg +( +RgrUeUlPwrDedSCellCfg *param, +Buffer *mBuf +) +#else +PRIVATE S16 cmUnpkRgrUeUlPwrDedSCellCfg(param, mBuf) +RgrUeUlPwrDedSCellCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrUeUlPwrDedSCellCfg) + + CMCHKUNPK(SUnpkU8, ¶m->isAccumulated, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->isDeltaMCSEnabled, mBuf); + CMCHKUNPK(SUnpkS8, ¶m->p0UePusch, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->pSRSOffset, mBuf); + RETVALUE(ROK); +} + + + + +/*********************************************************** +* +* Func : cmPkRgrUeSecCellCfg +* +* +* Desc : DL Secondary Cell information of the UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PRIVATE S16 cmPkRgrUeSecCellCfg +( +RgrUeSecCellCfg *param, +Buffer *mBuf +) +#else +PRIVATE S16 cmPkRgrUeSecCellCfg(param, mBuf) +RgrUeSecCellCfg *param; +Buffer *mBuf; +#endif +{ + CMCHKPK(cmPkRgrUeUlPwrDedSCellCfg,¶m->ueSCellUlDedPwrCfg, mBuf); + CMCHKPK(SPkU8, param->isUlCaEnabled, mBuf); + CMCHKPK(cmPkRgrUeTxModeCfg, ¶m->txMode, mBuf); +#ifdef TFU_UPGRADE +/*rgr_c_001.main_9 ADD PDSCH ded cfg*/ + CMCHKPK(cmPkRgrUePdschDedCfg, ¶m->uePdschDedCfg, mBuf); +#endif + CMCHKPK(cmPkRgrUeDlCqiCfg,¶m->ueSCellDlCqiCfg, mBuf); + CMCHKPK(cmPkTknU32, ¶m->sCellDeActTmr, mBuf); + CMCHKPK(SPkU16, param->sCellId, mBuf); + CMCHKPK(SPkU8, param->sCellIdx, mBuf); + + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRgrUeSecCellInfo +* +* +* Desc : Secondary Cell information of the UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUeSecCellInfo +( +RgrUeSecCellInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUeSecCellInfo(param, mBuf) +RgrUeSecCellInfo *param; +Buffer *mBuf; +#endif +{ + S8 idx; + for(idx = param->numSCells - 1; idx >= 0; idx--) + { + CMCHKPK(cmPkRgrUeSecCellCfg, ¶m->ueSCellDedCfg[(U8)idx],mBuf); + } + + CMCHKPK(SPkU8, param->numSCells, mBuf); + + CMCHKPK(SPkU8, param->useExtBSRSizes, mBuf); + + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func : cmUnpkRgrUeSecCellCfg +* +* +* Desc : DL Secondary Cell information of the UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PRIVATE S16 cmUnpkRgrUeSecCellCfg +( +RgrUeSecCellCfg *param, +Buffer *mBuf +) +#else +PRIVATE S16 cmUnpkRgrUeSecCellCfg(param, mBuf) +RgrUeSecCellCfg *param; +Buffer *mBuf; +#endif +{ + CMCHKUNPK(SUnpkU8, ¶m->sCellIdx, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->sCellId, mBuf); + CMCHKUNPK(cmUnpkTknU32, ¶m->sCellDeActTmr, mBuf); + CMCHKUNPK(cmUnpkRgrUeDlCqiCfg, ¶m->ueSCellDlCqiCfg, mBuf); +#ifdef TFU_UPGRADE + CMCHKUNPK(cmUnpkRgrUePdschDedCfg, ¶m->uePdschDedCfg, mBuf); +#endif + CMCHKUNPK(cmUnpkRgrUeTxModeCfg, ¶m->txMode, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->isUlCaEnabled, mBuf); + CMCHKUNPK(cmUnpkRgrUeUlPwrDedSCellCfg, ¶m->ueSCellUlDedPwrCfg, mBuf); + + RETVALUE(ROK); +} + + + + +/*********************************************************** +* +* Func : cmUnpkRgrUeSecCellInfo +* +* +* Desc : Secondary Cell information of the UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUeSecCellInfo +( +RgrUeSecCellInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUeSecCellInfo(param, mBuf) +RgrUeSecCellInfo *param; +Buffer *mBuf; +#endif +{ + U8 idx; + + CMCHKUNPK(SUnpkU8, ¶m->useExtBSRSizes, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numSCells, mBuf); + + for(idx = 0; idx < param->numSCells;idx++) + { + CMCHKUNPK(cmUnpkRgrUeSecCellCfg, ¶m->ueSCellDedCfg[idx],mBuf); + } + + RETVALUE(ROK); +} +/* Sprint 3 */ +/*********************************************************** +* +* Func : cmPkRgrUeSCellAckPucchCfg +* +* +* Desc : PUCCH Configuration information of the UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUeSCellAckPucchCfg +( +RgrUeSCellAckPucchCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUeSCellAckPucchCfg(param, mBuf) +RgrUeSCellAckPucchCfg *param; +Buffer *mBuf; +#endif +{ + S8 idx; + TRC3(cmPkRgrUeSCellAckPucchCfg); + + if (param->pucchFormatType == RG_SCH_UCI_FORMAT1B_CS || param->pucchFormatType == RG_SCH_UCI_FORMAT1A_1B) + { + for(idx = param->u.format1Bcs.sCellAckN1ResTb2Count - 1; idx >=0 ;idx--) + { + CMCHKPK(SPkU16, param->u.format1Bcs.sCellAckN1ResTb2[(U8)idx], mBuf); + } + + CMCHKPK(SPkU8, param->u.format1Bcs.sCellAckN1ResTb2Count, mBuf); + + for(idx = param->u.format1Bcs.sCellAckN1ResTb1Count - 1; idx >=0 ;idx--) + { + CMCHKPK(SPkU16, param->u.format1Bcs.sCellAckN1ResTb1[(U8)idx], mBuf); + } + + CMCHKPK(SPkU8, param->u.format1Bcs.sCellAckN1ResTb1Count, mBuf); + } + else + { + for(idx = param->u.format3.sCellAckN3ResAntP1Count - 1; idx >=0 ;idx--) + { + CMCHKPK(SPkU16, param->u.format3.sCellAckN3ResAntP1[(U8)idx], mBuf); + } + + CMCHKPK(SPkU8, param->u.format3.sCellAckN3ResAntP1Count, mBuf); + + for(idx = param->u.format3.sCellAckN3ResAntP0Count- 1; idx >=0 ;idx--) + { + CMCHKPK(SPkU16, param->u.format3.sCellAckN3ResAntP0[(U8)idx], mBuf); + } + + CMCHKPK(SPkU8, param->u.format3.sCellAckN3ResAntP0Count, mBuf); + } + CMCHKPK(SPkU32, param->pucchFormatType, mBuf); + + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func : cmUnpkRgrUeSCellAckPucchCfg +* +* +* Desc : PUCCH Configuration information of the UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUeSCellAckPucchCfg +( +RgrUeSCellAckPucchCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUeSCellAckPucchCfg(param, mBuf) +RgrUeSCellAckPucchCfg *param; +Buffer *mBuf; +#endif +{ + U8 idx; + + TRC3(cmUnpkRgrUeSCellAckPucchCfg); + + CMCHKUNPK(SUnpkU32, (U32*)¶m->pucchFormatType, mBuf); + //if (param->pucchFormatType == RG_SCH_UCI_FORMAT1B_CS) + if (param->pucchFormatType == RG_SCH_UCI_FORMAT1B_CS || param->pucchFormatType == RG_SCH_UCI_FORMAT1A_1B) + { + CMCHKUNPK(SUnpkU8, ¶m->u.format1Bcs.sCellAckN1ResTb1Count, mBuf); + + for(idx = 0; idx < param->u.format1Bcs.sCellAckN1ResTb1Count; idx++) + { + CMCHKUNPK(SUnpkU16, ¶m->u.format1Bcs.sCellAckN1ResTb1[idx], mBuf); + } + + CMCHKUNPK(SUnpkU8, ¶m->u.format1Bcs.sCellAckN1ResTb2Count, mBuf); + + for(idx = 0; idx < param->u.format1Bcs.sCellAckN1ResTb2Count; idx++) + { + CMCHKUNPK(SUnpkU16, ¶m->u.format1Bcs.sCellAckN1ResTb2[idx], mBuf); + } + } + else + { + CMCHKUNPK(SUnpkU8, ¶m->u.format3.sCellAckN3ResAntP0Count, mBuf); + + for(idx = 0; idx < param->u.format3.sCellAckN3ResAntP0Count; idx++) + { + CMCHKUNPK(SUnpkU16, ¶m->u.format3.sCellAckN3ResAntP0[idx], mBuf); + } + + CMCHKUNPK(SUnpkU8, ¶m->u.format3.sCellAckN3ResAntP1Count, mBuf); + + for(idx = 0; idx < param->u.format3.sCellAckN3ResAntP1Count; idx++) + { + CMCHKUNPK(SUnpkU16, ¶m->u.format3.sCellAckN3ResAntP1[idx], mBuf); + } + + } + RETVALUE(ROK); +} + + + + +#endif + + +/*********************************************************** +* +* Func : cmPkRgrUeStaInd +* +* +* Desc : Packing Ue Sta Indication sent to RRM +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUeStaInd +( +Pst* pst, +SuId suId, +RgrUeStaIndInfo* ueStaInd +) +#else +PUBLIC S16 cmPkRgrUeStaInd(pst, suId, ueStaInd) +Pst* pst; +SuId suId; +RgrUeStaIndInfo* ueStaInd; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkRgrUeStaInd) + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR054, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)ueStaInd, + sizeof(RgrUeStaIndInfo)); + RETVALUE(RFAILED); + } + + if (cmPkRgrUeStaIndInfo(ueStaInd, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR055, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)ueStaInd, + sizeof(RgrUeStaIndInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (SPkS16(suId, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR056, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)ueStaInd, + sizeof(RgrUeStaIndInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (SPutSBuf(pst->region, pst->pool, (Data *)ueStaInd, + sizeof(RgrUeStaIndInfo)) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR057, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + pst->event = (Event) EVTRGRUESTAIND; + RETVALUE(SPstTsk(pst,mBuf)); +} + +/*rgr_c_001.main_9 ADD added changes for CQI management*/ +/*********************************************************** +* +* Func : cmUnpkRgrUeStaInd +* +* +* Desc : Unpacking Sta Indication sent to RRM +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUeStaInd +( +RgrUeStaInd func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUeStaInd(func, pst, mBuf) +RgrUeStaInd func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + RgrUeStaIndInfo *ueStaInd; + + TRC3(cmUnpkRgrUeStaInd) + + if (SUnpkS16(&suId, mBuf) != ROK) + { + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR058, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + + if ((SGetSBuf(pst->region, pst->pool, (Data **)&ueStaInd, + sizeof(RgrUeStaIndInfo))) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR059, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (cmUnpkRgrUeStaIndInfo(ueStaInd, mBuf) != ROK) + { + SPutSBuf(pst->region, pst->pool, (Data *)ueStaInd, + sizeof(RgrUeStaIndInfo)); + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGR060, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + + SPutMsg(mBuf); + RETVALUE((*func)(pst, suId, ueStaInd)); +} + +/*********************************************************** +* +* Func : cmPkRgrUeStaIndInfo +* +* +* Desc : Packing of UeStaIndInfo structure +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrUeStaIndInfo +( +RgrUeStaIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrUeStaIndInfo(param, mBuf) +RgrUeStaIndInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrUeStaIndInfo) + + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + CMCHKPK(cmPkLteRnti, param->crnti, mBuf); + CMCHKPK(SPkU8, param->status, mBuf); + + RETVALUE(ROK); +} +/*********************************************************** +* +* Func : cmUnpkRgrUeStaIndInfo +* +* +* Desc : Unpacking of UeStaIndInfo structure +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrUeStaIndInfo +( +RgrUeStaIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrUeStaIndInfo(param, mBuf) +RgrUeStaIndInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrUeStaIndInfo) + + CMCHKUNPK(SUnpkU8, ¶m->status, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->crnti, mBuf); + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func : cmPkRgrCellCsgParamCfg +* +* +* Desc : CSG Parameter configuration +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrCellCsgParamCfg +( +RgrCellCsgParamCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrCellCsgParamCfg(param, mBuf) +RgrCellCsgParamCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRgrCellCsgParamCfg) + + CMCHKPK(SPkU8, param->minUlResNonCsg, mBuf); + CMCHKPK(SPkU8, param->minDlResNonCsg, mBuf); + + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func : cmUnpkRgrCellCsgParamCfg +* +* +* Desc : Unpacking of RgrCellCsgParamCfg structure +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrCellCsgParamCfg +( +RgrCellCsgParamCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrCellCsgParamCfg(param, mBuf) +RgrCellCsgParamCfg *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRgrCellCsgParamCfg) + + CMCHKUNPK(SUnpkU8, ¶m->minDlResNonCsg, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->minUlResNonCsg, mBuf); + + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func : cmPkRgrCellCntrlCmdCfg +* +* +* Desc : Packing of RgrCellCntrlCmdCfg structure +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRgrCellCntrlCmdCfg +( +RgrCellCntrlCmdCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRgrCellCntrlCmdCfg(param, mBuf) +RgrCellCntrlCmdCfg *param; +Buffer *mBuf; +#endif +{ + TRC3(cmPkRgrCellCntrlCmdCfg) + + switch(param->cmdType) + { + case RGR_CNTRL_CMD_RACH_OVRLD: + CMCHKUNPK(SPkU8, param->cmdDesc.rachOvrLd.backOffVal, mBuf); + CMCHKUNPK(SPkU8, param->cmdDesc.rachOvrLd.backOffEnb, mBuf); + break; + case RGR_CNTRL_CMD_CPU_OVRLD: + CMCHKUNPK(SPkU8, param->cmdDesc.cpuOvrLd.instruction, mBuf); + break; + default: + break; + } + CMCHKUNPK(SPkU32, param->cmdType, mBuf); + + RETVALUE(ROK); +} +/*********************************************************** +* +* Func : cmUnpkRgrCellCntrlCmdCfg +* +* +* Desc : Unpacking of RgrCellCntrlCmdCfg structure +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRgrCellCntrlCmdCfg +( +RgrCellCntrlCmdCfg *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRgrCellCntrlCmdCfg(param, mBuf) +RgrCellCntrlCmdCfg *param; +Buffer *mBuf; +#endif +{ + U32 tmpEnum; + + TRC3(cmUnpkRgrCellCntrlCmdCfg) + + CMCHKUNPK(SUnpkU32, &tmpEnum, mBuf); + param->cmdType = (RgrCellCntrlCmdType) tmpEnum; + switch(param->cmdType) + { + case RGR_CNTRL_CMD_RACH_OVRLD: + CMCHKUNPK(SUnpkU8, ¶m->cmdDesc.rachOvrLd.backOffEnb, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->cmdDesc.rachOvrLd.backOffVal, mBuf); + break; + case RGR_CNTRL_CMD_CPU_OVRLD: + CMCHKUNPK(SUnpkU8, ¶m->cmdDesc.cpuOvrLd.instruction, mBuf); + break; + default: + break; + } + + RETVALUE(ROK); +} +#endif /* End of if defined(LCRGR) */ + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/cm/rgu.c b/src/cm/rgu.c new file mode 100755 index 000000000..ee3ef41c6 --- /dev/null +++ b/src/cm/rgu.c @@ -0,0 +1,4067 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/************************************************************************ + + Name: LTE-MAC layer + + Type: C source file + + Desc: C source code for packing/unpacking of RGU interface + primitives. + + File: rgu.c + +**********************************************************************/ + +/** @file rgu.c +@brief This file contains the packing/unpacking code for the RGU interface + primitives. +*/ + +/* header include files (.h) */ +#include "envopt.h" /* environment options */ +#include "envdep.h" /* environment dependent */ +#include "envind.h" /* environment independent */ +#include "gen.h" /* general */ +#include "ssi.h" /* system services */ +#include "cm_tkns.h" /* Common Token Defines */ +#include "cm_llist.h" /* Common Link List Defines */ +#include "cm_hash.h" /* Common Hash List Defines */ +#include "cm_lte.h" /* Common LTE Defines */ +#include "rgu.h" /* RGU Interface defines */ + +/* header/extern include files (.x) */ +#include "gen.x" /* general */ +#include "ssi.x" /* system services */ +#include "cm_tkns.x" /* Common Token Definitions */ +#include "cm_llist.x" /* Common Link List Definitions */ +#include "cm_lib.x" /* Common Library Definitions */ +#include "cm_hash.x" /* Common Hash List Definitions */ +#include "cm_lte.x" /* Common LTE Defines */ +#include "rgu.x" /* RGU Interface includes */ + +#ifdef SS_RBUF +#include "ss_rbuf.h" +#include "ss_rbuf.x" +#endif + +#ifdef LCRGU + + +/** +* @brief Request from RLC to MAC to bind the interface saps +* +* @details +* +* Function : cmPkRguBndReq +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] SpId spId +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkRguBndReq +( +Pst* pst, +SuId suId, +SpId spId +) +#else +PUBLIC S16 cmPkRguBndReq(pst, suId, spId) +Pst* pst; +SuId suId; +SpId spId; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkRguBndReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU001, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU002, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU003, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + pst->event = (Event) EVTRGUBNDREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief Request from RLC to MAC to bind the interface saps +* +* @details +* +* Function : cmUnpkRguBndReq +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] SpId spId +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkRguBndReq +( +RguBndReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguBndReq(func, pst, mBuf) +RguBndReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + SpId spId; + + TRC3(cmUnpkRguBndReq) + + if (SUnpkS16(&suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU004, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SUnpkS16(&spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU005, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, suId, spId)); +} + + +/** +* @brief Request from RLC to MAC to Unbind the interface saps +* +* @details +* +* Function : cmPkRguUbndReq +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] Reason reason +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkRguUbndReq +( +Pst* pst, +SpId spId, +Reason reason +) +#else +PUBLIC S16 cmPkRguUbndReq(pst, spId, reason) +Pst* pst; +SpId spId; +Reason reason; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkRguUbndReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU006, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SPkS16(reason, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU007, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU008, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + pst->event = (Event) EVTRGUUBNDREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief Request from RLC to MAC to Unbind the interface saps +* +* @details +* +* Function : cmUnpkRguUbndReq +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] Reason reason +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkRguUbndReq +( +RguUbndReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguUbndReq(func, pst, mBuf) +RguUbndReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SpId spId; + Reason reason; + + TRC3(cmUnpkRguUbndReq) + + if (SUnpkS16(&spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU009, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SUnpkS16(&reason, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU010, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, spId, reason)); +} + + +/** +* @brief Confirmation from MAC to RLC for the bind/Unbind + * request for the interface saps +* +* @details +* +* Function : cmPkRguBndCfm +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] U8 status +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkRguBndCfm +( +Pst* pst, +SuId suId, +U8 status +) +#else +PUBLIC S16 cmPkRguBndCfm(pst, suId, status) +Pst* pst; +SuId suId; +U8 status; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkRguBndCfm) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU011, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SPkU8(status, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU012, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU013, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + pst->event = (Event) EVTRGUBNDCFM; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief Confirmation from MAC to RLC for the bind/Unbind + * request for the interface saps +* +* @details +* +* Function : cmUnpkRguBndCfm +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] U8 status +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkRguBndCfm +( +RguBndCfm func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguBndCfm(func, pst, mBuf) +RguBndCfm func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + U8 status; + + TRC3(cmUnpkRguBndCfm) + + if (SUnpkS16(&suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU014, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SUnpkU8(&status, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU015, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, suId, status)); +} + + +/** +* @brief Request from RLC to MAC for forwarding SDUs on common + * channel for transmission +* +* @details +* +* Function : cmPkRguCDatReq +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] RguCDatReqInfo * datReq +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkRguCDatReq +( +Pst* pst, +SpId spId, +RguCDatReqInfo * datReq +) +#else +PUBLIC S16 cmPkRguCDatReq(pst, spId, datReq) +Pst* pst; +SpId spId; +RguCDatReqInfo * datReq; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkRguCDatReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU016, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)datReq, sizeof(RguCDatReqInfo)); + RETVALUE(RFAILED); + } + if (pst->selector == RGU_SEL_LWLC) + { + CMCHKPK(cmPkPtr,(PTR) datReq, mBuf); + } + else + { + if (cmPkRguCDatReqInfo(datReq, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU017, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, + (Data *)datReq, sizeof(RguCDatReqInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPutSBuf(pst->region, pst->pool, + (Data *)datReq, sizeof(RguCDatReqInfo)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU019, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + datReq = NULLP; + } + + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU018, (ErrVal)0, "Packing failed"); +#endif + + if (datReq != NULLP) + { + SPutSBuf(pst->region, pst->pool, + (Data *)datReq, sizeof(RguCDatReqInfo)); + } + + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + pst->event = (Event) EVTRGUCDATREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief Request from RLC to MAC for forwarding SDUs on common + * channel for transmission +* +* @details +* +* Function : cmUnpkRguCDatReq +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] RguCDatReqInfo * datReq +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkRguCDatReq +( +RguCDatReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguCDatReq(func, pst, mBuf) +RguCDatReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SpId spId; + RguCDatReqInfo *datReq; + + TRC3(cmUnpkRguCDatReq) + + if (SUnpkS16(&spId, mBuf) != ROK) { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (pst->selector == RGU_SEL_LWLC) + { + CMCHKUNPK(cmUnpkPtr,(PTR *) &datReq, mBuf); + } + else + { + if ((SGetSBuf(pst->region, pst->pool, + (Data **)&datReq, sizeof(RguCDatReqInfo))) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU020, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + cmMemset((U8*)datReq, (U8)0, sizeof(RguCDatReqInfo)); + if (cmUnpkRguCDatReqInfo(datReq, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU021, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + SPutSBuf(pst->region, pst->pool, + (Data *)datReq, sizeof(RguCDatReqInfo)); + RETVALUE(RFAILED); + } + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, spId, datReq)); +} + + +/** +* @brief Request from RLC to MAC for forwarding SDUs on + * dedicated channel for transmission +* +* @details +* +* Function : cmPkRguDDatReq +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] RguDDatReqInfo * datReq +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkRguDDatReq +( +Pst* pst, +SpId spId, +RguDDatReqInfo * datReq +) +#else +PUBLIC S16 cmPkRguDDatReq(pst, spId, datReq) +Pst* pst; +SpId spId; +RguDDatReqInfo * datReq; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkRguDDatReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU022, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)datReq, sizeof(RguDDatReqInfo)); + RETVALUE(RFAILED); + } + + if (pst->selector == RGU_SEL_LWLC) + { + CMCHKPK(cmPkPtr,(PTR) datReq, mBuf); + } + else + { + /*rgu_c_001.main_5 - ADD - L2M Support */ +#ifdef LTE_L2_MEAS + if (cmPkRguDDatReqInfo(pst, datReq, mBuf) != ROK) +#else + if (cmPkRguDDatReqInfo(datReq, mBuf) != ROK) +#endif + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU023, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)datReq, + sizeof(RguDDatReqInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (SPutSBuf(pst->region, pst->pool, + (Data *)datReq, sizeof(RguDDatReqInfo)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU025, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + datReq = NULLP; + } + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU024, (ErrVal)0, "Packing failed"); +#endif + if (datReq != NULLP); + { + SPutSBuf(pst->region, pst->pool, + (Data *)datReq, sizeof(RguDDatReqInfo)); + } + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + pst->event = (Event) EVTRGUDDATREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief Request from RLC to MAC for forwarding SDUs on + * dedicated channel for transmission +* +* @details +* +* Function : cmUnpkRguDDatReq +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] RguDDatReqInfo * datReq +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkRguDDatReq +( +RguDDatReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguDDatReq(func, pst, mBuf) +RguDDatReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SpId spId; + RguDDatReqInfo *datReq; + + TRC3(cmUnpkRguDDatReq) + + if (SUnpkS16(&spId, mBuf) != ROK) { + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (pst->selector == RGU_SEL_LWLC) + { + CMCHKUNPK(cmUnpkPtr,(PTR *) &datReq, mBuf); + } + else + { + if ((SGetSBuf(pst->region, pst->pool, + (Data **)&datReq, sizeof(RguDDatReqInfo))) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU026, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + cmMemset((U8*)datReq, (U8)0, sizeof(RguDDatReqInfo)); + /*rgu_c_001.main_5 - ADD - L2M Support */ +#ifdef LTE_L2_MEAS + if (cmUnpkRguDDatReqInfo(pst,datReq, mBuf) != ROK) +#else + if (cmUnpkRguDDatReqInfo(datReq, mBuf) != ROK) +#endif + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU027, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + SPutSBuf(pst->region, pst->pool, (Data *)datReq, + sizeof(RguDDatReqInfo)); + RETVALUE(RFAILED); + } + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, spId, datReq)); +} + + +/** +* @brief Data Indication from MAC to RLC to + * forward the data received for common channels +* +* @details +* +* Function : cmPkRguCDatInd +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] RguCDatIndInfo * datInd +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkRguCDatInd +( +Pst* pst, +SuId suId, +RguCDatIndInfo * datInd +) +#else +PUBLIC S16 cmPkRguCDatInd(pst, suId, datInd) +Pst* pst; +SuId suId; +RguCDatIndInfo * datInd; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkRguCDatInd) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU028, (ErrVal)0, "Packing failed"); +#endif + SPutStaticBuffer(pst->region, pst->pool, (Data *)datInd, sizeof(RguCDatIndInfo),0); + RETVALUE(RFAILED); + } + if (pst->selector == RGU_SEL_LWLC) + { + CMCHKPK(cmPkPtr,(PTR) datInd, mBuf); + } + else + { + if (cmPkRguCDatIndInfo(datInd, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU029, (ErrVal)0, "Packing failed"); +#endif + SPutStaticBuffer(pst->region, pst->pool, (Data *)datInd, + sizeof(RguCDatIndInfo),0); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPutStaticBuffer(pst->region, pst->pool, (Data *)datInd, + sizeof(RguCDatIndInfo),0) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU031, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + datInd = NULLP; + } + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU030, (ErrVal)0, "Packing failed"); +#endif + SPutStaticBuffer(pst->region, pst->pool, (Data *)datInd, sizeof(RguCDatIndInfo),0); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + pst->event = (Event) EVTRGUCDATIND; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief Data Indication from MAC to RLC to + * forward the data received for common channels +* +* @details +* +* Function : cmUnpkRguCDatInd +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] RguCDatIndInfo * datInd +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkRguCDatInd +( +RguCDatInd func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguCDatInd(func, pst, mBuf) +RguCDatInd func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + RguCDatIndInfo *datInd; + + TRC3(cmUnpkRguCDatInd) + + if (SUnpkS16(&suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU032, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (pst->selector == RGU_SEL_LWLC) + { + CMCHKUNPK(cmUnpkPtr,(PTR *) &datInd, mBuf); + } + else + { + if ((SGetStaticBuffer(pst->region, pst->pool, + (Data **)&datInd, sizeof(RguCDatIndInfo),0)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU033, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (cmUnpkRguCDatIndInfo(datInd, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU034, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + SPutStaticBuffer(pst->region, pst->pool, (Data *)datInd, + sizeof(RguCDatIndInfo),0); + RETVALUE(RFAILED); + } + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, suId, datInd)); +} + + +/** +* @brief Data Indication from MAC to RLC to + * forward the data received for dedicated channels +* +* @details +* +* Function : cmPkRguDDatInd +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] RguDDatIndInfo * datInd +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkRguDDatInd +( +Pst* pst, +SuId suId, +RguDDatIndInfo * datInd +) +#else +PUBLIC S16 cmPkRguDDatInd(pst, suId, datInd) +Pst* pst; +SuId suId; +RguDDatIndInfo * datInd; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkRguDDatInd) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU035, (ErrVal)0, "Packing failed"); +#endif + SPutStaticBuffer(pst->region, pst->pool, (Data *)datInd, sizeof(RguDDatIndInfo),0); + RETVALUE(RFAILED); + } + + if (pst->selector == RGU_SEL_LWLC) + { + CMCHKPK(cmPkPtr,(PTR) datInd, mBuf); + } + else + { + if (cmPkRguDDatIndInfo(datInd, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU036, (ErrVal)0, "Packing failed"); +#endif + SPutStaticBuffer(pst->region, pst->pool, (Data *)datInd, sizeof(RguDDatIndInfo),0); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (SPutStaticBuffer(pst->region, pst->pool, + (Data *)datInd, sizeof(RguDDatIndInfo),0) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU038, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + datInd = NULLP; + } + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU037, (ErrVal)0, "Packing failed"); +#endif + SPutStaticBuffer(pst->region, pst->pool, (Data *)datInd, sizeof(RguDDatIndInfo),0); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + pst->event = (Event) EVTRGUDDATIND; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief Data Indication from MAC to RLC to + * forward the data received for dedicated channels +* +* @details +* +* Function : cmUnpkRguDDatInd +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] RguDDatIndInfo * datInd +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkRguDDatInd +( +RguDDatInd func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguDDatInd(func, pst, mBuf) +RguDDatInd func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + RguDDatIndInfo *datInd; + + TRC3(cmUnpkRguDDatInd) + + if (SUnpkS16(&suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU039, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (pst->selector == RGU_SEL_LWLC) + { + CMCHKUNPK(cmUnpkPtr,(PTR *) &datInd, mBuf); + } + else + { + if ((SGetStaticBuffer(pst->region, pst->pool, + (Data **)&datInd, sizeof(RguDDatIndInfo),0)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU040, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (cmUnpkRguDDatIndInfo(datInd, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU041, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + SPutStaticBuffer(pst->region, pst->pool, + (Data *)datInd, sizeof(RguDDatIndInfo),0); + RETVALUE(RFAILED); + } + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, suId, datInd)); +} + + +/** +* @brief Primitive invoked from RLC to MAC to + * inform the BO report for common channels +* +* @details +* +* Function : cmPkRguCStaRsp +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] RguCStaRspInfo * staRsp +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkRguCStaRsp +( +Pst* pst, +SpId spId, +RguCStaRspInfo * staRsp +) +#else +PUBLIC S16 cmPkRguCStaRsp(pst, spId, staRsp) +Pst* pst; +SpId spId; +RguCStaRspInfo * staRsp; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkRguCStaRsp) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU042, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)staRsp, sizeof(RguCStaRspInfo)); + RETVALUE(RFAILED); + } + if (pst->selector == RGU_SEL_LWLC) + { + CMCHKPK(cmPkPtr,(PTR) staRsp, mBuf); + } + else + { + if (cmPkRguCStaRspInfo(staRsp, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU043, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)staRsp, + sizeof(RguCStaRspInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (SPutSBuf(pst->region, pst->pool, (Data *)staRsp, + sizeof(RguCStaRspInfo)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU045, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + staRsp = NULLP; + } + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU044, (ErrVal)0, "Packing failed"); +#endif + if (staRsp != NULLP) + { + SPutSBuf(pst->region, pst->pool, + (Data *)staRsp, sizeof(RguCStaRspInfo)); + } + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + pst->event = (Event) EVTRGUCSTARSP; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief Primitive invoked from RLC to MAC to + * inform the BO report for common channels +* +* @details +* +* Function : cmUnpkRguCStaRsp +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] RguCStaRspInfo * staRsp +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkRguCStaRsp +( +RguCStaRsp func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguCStaRsp(func, pst, mBuf) +RguCStaRsp func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SpId spId; + RguCStaRspInfo *staRsp; + + TRC3(cmUnpkRguCStaRsp) + + if (SUnpkS16(&spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU046, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (pst->selector == RGU_SEL_LWLC) + { + CMCHKUNPK(cmUnpkPtr,(PTR *) &staRsp, mBuf); + } + else + { + if ((SGetSBuf(pst->region, pst->pool, (Data **)&staRsp, + sizeof(RguCStaRspInfo))) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU047, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (cmUnpkRguCStaRspInfo(staRsp, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU048, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + SPutSBuf(pst->region, pst->pool, (Data *)staRsp, + sizeof(RguCStaRspInfo)); + RETVALUE(RFAILED); + } + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, spId, staRsp)); +} + +/*rgu_c_001.main_5 - ADD - L2M & R9 Support */ +#ifdef LTE_L2_MEAS + +/*********************************************************** +* +* Func :cmPkRguL2MUlThrpMeasReqInfo +* +* +* Status Response from RLC to MAC on UL dedicated logical channel for Uplink +* Scheduled throughput measurement +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRguL2MUlThrpMeasReqInfo +( +RguL2MUlThrpMeasReqInfo* param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRguL2MUlThrpMeasReqInfo(param, mBuf) +RguL2MUlThrpMeasReqInfo* param; +Buffer *mBuf; +#endif +{ + S32 loop; + TRC3(cmPkRguL2MUlThrpMeasReqInfo); + + CMCHKPK(SPkU8, param->enbMeas, mBuf); + for (loop=param->numLcId-1; loop >= 0; loop--) + { + CMCHKPK(SPkU8, param->lcId[loop], mBuf); + } + CMCHKPK(cmPkLteLcId, param->numLcId, mBuf); + CMCHKPK(cmPkLteRnti, param->rnti, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func :cmUnpkRguL2MUlThrpMeasReqInfo +* +* +* Status Response from RLC to MAC on UL dedicated logical channel for Uplink +* Scheduled throughput measurement +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRguL2MUlThrpMeasReqInfo +( +RguL2MUlThrpMeasReqInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguL2MUlThrpMeasReqInfo(param, mBuf) +RguL2MUlThrpMeasReqInfo *param; +Buffer *mBuf; +#endif +{ + U8 loop; + TRC3(cmUnpkRguL2MUlThrpMeasReqInfo); + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->rnti, mBuf); + CMCHKUNPK(cmUnpkLteLcId, ¶m->numLcId, mBuf); + for (loop=0; loopnumLcId; loop++) + { + CMCHKUNPK(SUnpkU8, ¶m->lcId[loop], mBuf); + } + CMCHKUNPK(SUnpkU8, ¶m->enbMeas, mBuf); + RETVALUE(ROK); +} + +/** +* @brief Primitive invoked from RLC to MAC to +* inform the On/Off status for Scheduled UL throughput +* measurment for dedicated channels +* +* @details +* +* Function :cmPkRguL2MUlThrpMeasReq +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] RguL2MUlThrpMeasReqInfo* measReq +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkRguL2MUlThrpMeasReq +( +Pst* pst, +SpId spId, +RguL2MUlThrpMeasReqInfo* measReq +) +#else +PUBLIC S16 cmPkRguL2MUlThrpMeasReq(pst, spId, measReq) +Pst* pst; +SpId spId; +RguL2MUlThrpMeasReqInfo* measReq; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkRguL2MUlThrpMeasReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU049, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)measReq, sizeof(RguL2MUlThrpMeasReqInfo)); + RETVALUE(RFAILED); + } + if (pst->selector == RGU_SEL_LWLC) + { + CMCHKPK(cmPkPtr,(PTR) measReq, mBuf); + } + else + { + if (cmPkRguL2MUlThrpMeasReqInfo(measReq, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU050, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)measReq, + sizeof(RguL2MUlThrpMeasReqInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPutSBuf(pst->region, pst->pool, (Data *)measReq, + sizeof(RguL2MUlThrpMeasReqInfo)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU052, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + measReq = NULLP; + } + + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU051, (ErrVal)0, "Packing failed"); +#endif + if (measReq != NULLP) + { + SPutSBuf(pst->region, pst->pool, (Data *)measReq, + sizeof(RguL2MUlThrpMeasReqInfo)); + } + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + pst->event = (Event) EVTRGUL2MULTHRPMEASREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief Primitive invoked from RLC to MAC to +* inform the On/Off status for Scheduled UL throughput +* measurment for dedicated channels +* +* @details +* +* Function :cmUnpkRguL2MUlThrpMeasReq +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] RguL2MUlThrpMeasReqInfo * measReq +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkRguL2MUlThrpMeasReq +( +RguL2MUlThrpMeasReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguL2MUlThrpMeasReq(func, pst, mBuf) +RguL2MUlThrpMeasReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SpId spId; + RguL2MUlThrpMeasReqInfo* measReq; + + TRC3(cmUnpkRguL2MUlThrpMeasReq) + + if (SUnpkS16(&spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU053, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (pst->selector == RGU_SEL_LWLC) + { + CMCHKUNPK(cmUnpkPtr,(PTR *) &measReq, mBuf); + } + else + { + if ((SGetSBuf(pst->region, pst->pool, (Data **)&measReq, + sizeof(RguL2MUlThrpMeasReqInfo))) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU054, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (cmUnpkRguL2MUlThrpMeasReqInfo(measReq, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU055, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + SPutSBuf(pst->region, pst->pool, (Data *)measReq, + sizeof(RguL2MUlThrpMeasReqInfo)); + RETVALUE(RFAILED); + } + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, spId, measReq)); +} + +#endif + + + + +/** +* @brief Primitive invoked from RLC to MAC to + * inform the BO report for dedicated channels +* +* @details +* +* Function : cmPkRguDStaRsp +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] RguDStaRspInfo * staRsp +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkRguDStaRsp +( +Pst* pst, +SpId spId, +RguDStaRspInfo *staRsp +) +#else +PUBLIC S16 cmPkRguDStaRsp(pst, spId, staRsp) +Pst* pst; +SpId spId; +RguDStaRspInfo *staRsp; +#endif +{ + + RguDStaRspInfo *staRspInfo = NULL; + Buffer *mBuf = NULLP; + + if(SGetSBuf(pst->region, pst->pool, (Data **)&staRspInfo, sizeof(RguDStaRspInfo)) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU056, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } +#ifdef ERRCLS_KW + /* staRspInfo cant be NULL here */ + if (staRspInfo == NULLP) + { + RETVALUE(RFAILED); + } +#endif + cmMemcpy((U8 *)staRspInfo, (U8 *)staRsp, sizeof(RguDStaRspInfo)); + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU056, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)staRspInfo, sizeof(RguDStaRspInfo)); + + RETVALUE(RFAILED); + } + if (pst->selector == RGU_SEL_LWLC) + { + CMCHKPK(cmPkPtr,(PTR) staRspInfo, mBuf); + } + else + { + if (cmPkRguDStaRspInfo(staRsp, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU057, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU058, (ErrVal)0, "Packing failed"); +#endif + if (staRspInfo != NULLP) + { + SPutSBuf(pst->region, pst->pool, (Data *)staRspInfo, sizeof(RguDStaRspInfo)); + } + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + pst->event = (Event) EVTRGUDSTARSP; + RETVALUE(SPstTsk(pst,mBuf)); + SPutMsg(mBuf); +} + + +/** +* @brief Primitive invoked from RLC to MAC to + * inform the BO report for dedicated channels +* +* @details +* +* Function : cmUnpkRguDStaRsp +* +* @param[in] Pst* pst +* @param[in] SpId spId +* @param[in] RguDStaRspInfo * staRsp +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkRguDStaRsp +( +RguDStaRsp func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguDStaRsp(func, pst, mBuf) +RguDStaRsp func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SpId spId; + RguDStaRspInfo *staRsp; + + TRC3(cmUnpkRguDStaRsp) + + if (SUnpkS16(&spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU060, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (pst->selector == RGU_SEL_LWLC) + { + CMCHKUNPK(cmUnpkPtr,(PTR *) &staRsp, mBuf); + } + else + { + if ((SGetSBuf(pst->region, pst->pool, (Data **)&staRsp, + sizeof(RguDStaRspInfo))) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU061, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (cmUnpkRguDStaRspInfo(staRsp, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU062, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + SPutSBuf(pst->region, pst->pool, (Data *)staRsp, sizeof(RguDStaRspInfo)); + RETVALUE(RFAILED); + } + } + SPutMsg(mBuf); + (*func)(pst, spId, staRsp); + SPutSBuf(pst->region, pst->pool, (Data *)staRsp, sizeof(RguDStaRspInfo)); + RETVALUE(ROK); +} + + +/** +* @brief Status Indication from MAC to RLC + * as a response to the staRsp primitive from RLC. + * Informs RLC of the totalBufferSize and Timing Info + * for the transmission on common channels. +* +* @details +* +* Function : cmPkRguCStaInd +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] RguCStaIndInfo * staInd +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkRguCStaInd +( +Pst* pst, +SuId suId, +RguCStaIndInfo * staInd +) +#else +PUBLIC S16 cmPkRguCStaInd(pst, suId, staInd) +Pst* pst; +SuId suId; +RguCStaIndInfo * staInd; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkRguCStaInd) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU063, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)staInd, sizeof(RguCStaIndInfo)); + RETVALUE(RFAILED); + } + if (pst->selector == RGU_SEL_LWLC) + { + CMCHKPK(cmPkPtr,(PTR) staInd, mBuf); + } + else + { + if (cmPkRguCStaIndInfo(staInd, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU064, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)staInd, sizeof(RguCStaIndInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPutSBuf(pst->region, pst->pool, + (Data *)staInd, sizeof(RguCStaIndInfo)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU066, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + staInd = NULLP; + } + if (SPkS16(suId,mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU065, (ErrVal)0, "Packing failed"); +#endif + if (staInd != NULLP) + { + SPutSBuf(pst->region, pst->pool, (Data *)staInd, + sizeof(RguCStaIndInfo)); + } + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + pst->event = (Event) EVTRGUCSTAIND; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief Status Indication from MAC to RLC + * as a response to the staRsp primitive from RLC. + * Informs RLC of the totalBufferSize and Timing Info + * for the transmission on common channels. +* +* @details +* +* Function : cmUnpkRguCStaInd +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] RguCStaIndInfo * staInd +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkRguCStaInd +( +RguCStaInd func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguCStaInd(func, pst, mBuf) +RguCStaInd func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + RguCStaIndInfo *staInd; + + TRC3(cmUnpkRguCStaInd) + + if (SUnpkS16(&suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU067, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + if (pst->selector == RGU_SEL_LWLC) + { + CMCHKUNPK(cmUnpkPtr,(PTR *) &staInd, mBuf); + } + else + { + if ((SGetSBuf(pst->region, pst->pool, (Data **)&staInd, sizeof(RguCStaIndInfo))) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU068, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (cmUnpkRguCStaIndInfo(staInd, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU069, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + SPutSBuf(pst->region, pst->pool, (Data *)staInd, sizeof(RguCStaIndInfo)); + RETVALUE(RFAILED); + } + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, suId, staInd)); +} + + /*rgu_c_001.main_5 - ADD - L2M Support */ +#ifdef LTE_L2_MEAS +#if 0 + +/** +* @brief Packing function for RguLchMapInfo +* +* @details +* +* Function : cmPkRguLchMapInfo +* @param[in] RguLchMapInfo *param +* @param[out] Buffer *mBuf +* @return Void +**/ +#ifdef ANSI +PRIVATE S16 cmPkRguLchMapInfo +( +RguLchMapInfo *param, +Buffer *mBuf +) +#else +PRIVATE S16 cmPkRguLchMapInfo(param, mBuf) +RguLchMapInfo *param; +Buffer *mBuf; +#endif +{ + U8 idx; + + TRC3(cmPkRguLchMapInfo); + + for(idx = 0; idx < RGU_MAX_LC; idx++) + { + CMCHKPK(SPkU16, param->snList[idx], mBuf); + } + CMCHKPK(cmPkLteLcId, param->lChId, mBuf); + + RETVALUE(ROK); +} + +/** +* @brief Unpacking function for RguLchMapInfo +* +* @details +* +* Function : cmUnpkRguLchMapInfo +* +* @param[out] RguLchMapInfo *param +* @param[in] Buffer *mBuf +* @return Void +**/ +#ifdef ANSI +PRIVATE S16 cmUnpkRguLchMapInfo +( +RguLchMapInfo *param, +Buffer *mBuf +) +#else +PRIVATE S16 cmUnpkRguLchMapInfo(param, mBuf) +RguLchMapInfo *param; +Buffer *mBuf; +#endif +{ + U8 idx; + + TRC3(cmUnpkRguLchMapInfo) + + CMCHKUNPK(cmUnpkLteLcId, ¶m->lChId, mBuf); + for(idx = RGU_MAX_LC; idx > 0; idx--) + { + CMCHKUNPK(SUnpkU16, ¶m->snList[idx - 1], mBuf); + } + + RETVALUE(ROK); +} +#endif + +/** +* @brief Harq Status Indication from MAC to RLC +* +* @details +* +* Function : cmPkRguHqStaInd +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] RguHarqStatusInd *harqStatusInd +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkRguHqStaInd +( +Pst* pst, +SuId suId, +RguHarqStatusInd *harqStatusInd +) +#else +PUBLIC S16 cmPkRguHqStaInd(pst, suId, harqStatusInd) +Pst* pst; +SuId suId; +RguHarqStatusInd *harqStatusInd; +#endif +{ + + Buffer *mBuf; + U8 idx; + RguHarqStatusInd *harqStaInd = NULL; + + TRC3(cmPkRguHqStaInd) +#ifdef XEON_SPECIFIC_CHANGES + if (SGetSBuf(pst->region, pst->pool, (Data **)&harqStaInd, sizeof(RguHarqStatusInd)) != ROK) +#else + if ((SGetStaticBuffer(pst->region, pst->pool, + (Data **)&harqStaInd, sizeof(RguHarqStatusInd),0)) != ROK) +#endif + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU070, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + + cmMemcpy((U8 *)harqStaInd, (U8 *)harqStatusInd, sizeof(RguHarqStatusInd)); + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU070, (ErrVal)0, "Packing failed"); +#endif +#ifdef XEON_SPECIFIC_CHANGES + SPutSBuf(pst->region, pst->pool, (Data *)harqStaInd, sizeof(RguHarqStatusInd)); +#else + SPutStaticBuffer(pst->region, pst->pool, (Data *)harqStaInd, sizeof(RguHarqStatusInd), 0); +#endif + RETVALUE(RFAILED); + } + + if (pst->selector == RGU_SEL_LWLC) + { + CMCHKPK(cmPkPtr,(PTR) harqStaInd, mBuf); + } + else + { + for(idx = 0; idx < harqStaInd->numTbs; idx++) + { + CMCHKPK(SPkU16, harqStaInd->status[idx], mBuf); + } + for(idx = 0; idx < harqStaInd->numTbs; idx++) + { + CMCHKPK(SPkU32, harqStaInd->tbId[idx], mBuf); + } + CMCHKPK(SPkU8, harqStaInd->numTbs, mBuf); + CMCHKPK(cmPkLteRnti, harqStaInd->ueId, mBuf); + CMCHKPK(cmPkLteCellId, harqStaInd->cellId, mBuf); + } + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU071, (ErrVal)0, "Packing failed"); +#endif +#ifdef XEON_SPECIFIC_CHANGES + SPutSBuf(pst->region, pst->pool, (Data *)harqStaInd, + sizeof(RguHarqStatusInd)); +#else + SPutStaticBuffer(pst->region, pst->pool, (Data *)harqStaInd, sizeof(RguHarqStatusInd), 0); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } +#ifdef XEON_SPECIFIC_CHANGES + if (SPutSBuf(pst->region, pst->pool, (Data *)harqStaInd, + sizeof(RguHarqStatusInd)) != ROK) { +#else + if (pst->selector != RGU_SEL_LWLC) + { + if(SPutStaticBuffer(pst->region, pst->pool, (Data *)harqStaInd, + sizeof(RguHarqStatusInd), 0) != ROK) + { +#endif +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU072, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } +#ifndef XEON_SPECIFIC_CHANGES + } +#endif + + pst->event = (Event) EVTRGUHQSTAIND; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +#if 0 +/** +* @brief Unpacking function for RguSnMapInfo +* +* @details +* +* Function : cmUnpkRguSnMapInfo +* +* @param[out] RguSnMapInfo *param +* @param[in] Buffer *mBuf +* @return Void +**/ +#ifdef ANSI +PRIVATE S16 cmUnpkRguSnMapInfo +( +RguSnMapInfo *param, +Buffer *mBuf +) +#else +PRIVATE S16 cmUnpkRguSnMapInfo(param, mBuf) +RguSnMapInfo *param; +Buffer *mBuf; +#endif +{ + U8 idx; + + TRC3(cmUnpkRguSnMapInfo) + + CMCHKUNPK(SUnpkU32, ¶m->tbId, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numLch, mBuf); + for(idx = param->numLch; idx > 0; idx--) + { + CMCHKUNPK(cmUnpkRguLchMapInfo, ¶m->lchMap[idx - 1], mBuf); + } + RETVALUE(ROK); +} +#endif + +/** +* @brief Harq Status Indication from MAC to RLC +* +* @details +* +* Function : cmUnpkRguHqStaInd +* +* @param[in] RguHqStaInd func +* @param[in] Pst *pst +* @param[in] Buffer *mBuf +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkRguHqStaInd +( +RguHqStaInd func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguHqStaInd(func, pst, mBuf) +RguHqStaInd func; +Pst *pst; +Buffer *mBuf; +#endif +{ + RguHarqStatusInd *hqStaInd; + SuId suId; + U8 idx; + + TRC3(cmUnpkRguHqStaInd) + + if (SUnpkS16(&suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU073, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } +#ifdef XEON_SPECIFIC_CHANGES + if ((SGetSBuf(pst->region, pst->pool, (Data **)&hqStaInd, + sizeof(RguHarqStatusInd))) != ROK) { +#else + if (pst->selector == RGU_SEL_LWLC) + { + CMCHKUNPK(cmUnpkPtr,(PTR *) &hqStaInd, mBuf); + } + else + { + if ((SGetStaticBuffer(pst->region, pst->pool, + (Data **)&hqStaInd, sizeof(RguHarqStatusInd),0)) != ROK) + { +#endif +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU074, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + CMCHKUNPK(cmUnpkLteCellId, &hqStaInd->cellId, mBuf); + CMCHKUNPK(cmUnpkLteRnti, &hqStaInd->ueId, mBuf); + CMCHKUNPK(SUnpkU8, &hqStaInd->numTbs, mBuf); + for(idx = hqStaInd->numTbs; idx > 0; idx--) + { + CMCHKUNPK(SUnpkU32, &hqStaInd->tbId[idx - 1], mBuf); + } + for(idx = hqStaInd->numTbs; idx > 0; idx--) + { + CMCHKUNPK(SUnpkU16, &hqStaInd->status[idx - 1], mBuf); + } +#ifndef XEON_SPECIFIC_CHANGES + } +#endif + SPutMsg(mBuf); + (*func)(pst, suId, hqStaInd); +#ifdef XEON_SPECIFIC_CHANGES + SPutSBuf(pst->region, pst->pool, (Data *)hqStaInd, sizeof(RguHarqStatusInd)); +#else + SPutStaticBuffer(pst->region, pst->pool, (Data *)hqStaInd, sizeof(RguHarqStatusInd), 0); +#endif + RETVALUE(ROK); +} +#endif /* LTE_L2_MEAS */ + + +/** +* @brief Status Indication from MAC to RLC + * as a response to the staRsp primitive from RLC. + * Informs RLC of the totalBufferSize and Timing Info + * for the transmission on dedicated channels. +* +* @details +* +* Function : cmPkRguDStaInd +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] RguDStaIndInfo * staInd +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkRguDStaInd +( +Pst* pst, +SuId suId, +RguDStaIndInfo * staInd +) +#else +PUBLIC S16 cmPkRguDStaInd(pst, suId, staInd) +Pst* pst; +SuId suId; +RguDStaIndInfo * staInd; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkRguDStaInd) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU076, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)staInd, sizeof(RguDStaIndInfo)); + RETVALUE(RFAILED); + } + if (pst->selector == RGU_SEL_LWLC) + { + CMCHKPK(cmPkPtr,(PTR) staInd, mBuf); + } + else + { + if (cmPkRguDStaIndInfo(staInd, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU077, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)staInd, + sizeof(RguDStaIndInfo)); + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (SPutSBuf(pst->region, pst->pool, (Data *)staInd, + sizeof(RguDStaIndInfo)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU079, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + staInd = NULLP; + } + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU078, (ErrVal)0, "Packing failed"); +#endif + if (staInd != NULLP) + { + SPutSBuf(pst->region, pst->pool, (Data *)staInd, sizeof(RguDStaIndInfo)); + } + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + pst->event = (Event) EVTRGUDSTAIND; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/** +* @brief Status Indication from MAC to RLC + * as a response to the staRsp primitive from RLC. + * Informs RLC of the totalBufferSize and Timing Info + * for the transmission on dedicated channels. +* +* @details +* +* Function : cmUnpkRguDStaInd +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] RguDStaIndInfo * staInd +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkRguDStaInd +( +RguDStaInd func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguDStaInd(func, pst, mBuf) +RguDStaInd func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + RguDStaIndInfo *staInd; + + TRC3(cmUnpkRguDStaInd) + + if (SUnpkS16(&suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU080, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (pst->selector == RGU_SEL_LWLC) + { + CMCHKUNPK(cmUnpkPtr,(PTR *) &staInd, mBuf); + } + else + { + if ((SGetSBuf(pst->region, pst->pool, (Data **)&staInd, sizeof(RguDStaIndInfo))) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU081, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (cmUnpkRguDStaIndInfo(staInd, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU082, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + SPutSBuf(pst->region, pst->pool, (Data *)staInd, sizeof(RguDStaIndInfo)); + RETVALUE(RFAILED); + } + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, suId, staInd)); +} + +#ifdef ANSI +PUBLIC S16 cmPkRguLcFlowCntrlInfo +( +RguLcFlowCntrlInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRguLcFlowCntrlInfo (param,mBuf) +RguLcFlowCntrlInfo *param; +Buffer *mBuf; +#endif +{ + TRC3(cmPkRguLcFlowCntrlInfo); + CMCHKPK(SPkU32, param->maxBo4FlowCtrl, mBuf); + CMCHKPK(SPkU32, param->pktAdmitCnt, mBuf); + CMCHKPK(cmPkLteLcId, param->lcId, mBuf); + + RETVALUE(ROK); +} + +#ifdef ANSI +PUBLIC S16 cmPkRguUeFlowCntrlInfo +( +RguUeFlowCntrlInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRguUeFlowCntrlInfo (param,mBuf) +RguUeFlowCntrlInfo *param; +Buffer *mBuf; +#endif +{ + U32 idx; + + TRC3(cmPkRguUeFlowCntrlInfo); + + for(idx=(param->numLcs - 1); idx >= 0; idx--) + { + cmPkRguLcFlowCntrlInfo(¶m->lcInfo[idx],mBuf); + } + CMCHKPK(SPkU32, param->numLcs, mBuf); + CMCHKPK(cmPkLteRnti, param->ueId, mBuf); + RETVALUE(ROK); +} + +#ifdef ANSI +PUBLIC S16 cmPkRguFlowCntrlInfo +( +RguFlowCntrlInd *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRguFlowCntrlInfo(flowCntrlInd, mBuf) +RguFlowCntrlInd *param; +Buffer *mBuf; +#endif +{ + U32 idx; + + TRC3(cmPkRguFlowCntrlInfo); + + for (idx=(param->numUes - 1); idx >= 0; idx--) + { + cmPkRguUeFlowCntrlInfo(¶m->ueFlowCntrlInfo[idx],mBuf); + } + CMCHKPK(SPkU32, param->numUes, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + +/** +* @brief Flow Cntrl Indication from MAC to RLC + * Informs RLC of the LCs on which flow control + * to be performed. +* +* @details +* +* Function : cmPkRguFlowCntrlInd +* +* @param[in] Pst* pst +* @param[in] SuId suId +* @param[in] RguFlowCntrlInd *staInd +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmPkRguFlowCntrlInd +( +Pst* pst, +SuId suId, +RguFlowCntrlInd *flowCntrlInd +) +#else +PUBLIC S16 cmPkRguFlowCntrlInd(pst, suId, flowCntrlInd) +Pst* pst; +SuId suId; +RguFlowCntrlInd *flowCntrlInd; +#endif +{ + Buffer *mBuf = NULLP; + + TRC3(cmPkRguFlowCntrlInd); + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU076, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector == RGU_SEL_LWLC) + { + CMCHKPK(cmPkPtr,(PTR) flowCntrlInd, mBuf); + } + else + { + if (cmPkRguFlowCntrlInfo(flowCntrlInd, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU077, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + } + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU078, (ErrVal)0, "Packing failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + + pst->event = (Event) EVTRGUFLOWCNTRLIND; + RETVALUE(SPstTsk(pst,mBuf)); +} + +#ifdef ANSI +PUBLIC S16 cmUnpkRguLcFlowCntrlInfo +( +RguLcFlowCntrlInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguLcFlowCntrlInfo (param,mBuf) +RguLcFlowCntrlInfo *param; +Buffer *mBuf; +#endif +{ + TRC3(cmUnpkRguLcFlowCntrlInfo); + + CMCHKUNPK(cmUnpkLteLcId, ¶m->lcId, mBuf); + CMCHKUNPK(SUnpkU32, ¶m->pktAdmitCnt, mBuf); + CMCHKUNPK(SUnpkU32, ¶m->maxBo4FlowCtrl, mBuf); + + RETVALUE(ROK); +} +#ifdef ANSI +PUBLIC S16 cmUnpkRguUeFlowCntrlInfo +( +RguUeFlowCntrlInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguUeFlowCntrlInfo (param,mBuf) +RguUeFlowCntrlInfo *param; +Buffer *mBuf; +#endif +{ + U32 idx; + TRC3(cmUnpkRguUeFlowCntrlInfo); + CMCHKUNPK(cmUnpkLteRnti, ¶m->ueId, mBuf); + CMCHKUNPK(SUnpkU32, ¶m->numLcs, mBuf); + for(idx=0; idx < param->numLcs; idx++) + { + cmUnpkRguLcFlowCntrlInfo(¶m->lcInfo[idx],mBuf); + } + RETVALUE(ROK); +} + +#ifdef ANSI +PUBLIC S16 cmUnpkRguFlowCntrlInfo +( +RguFlowCntrlInd *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguFlowCntrlInfo(flowCntrlInfo, mBuf) +RguFlowCntrlInd *param; +Buffer *mBuf; +#endif +{ + U32 idx; + + TRC3(cmUnpkRguFlowCntrlInfo); + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(SUnpkU32, ¶m->numUes, mBuf); + for (idx=0; idx < param->numUes; idx++) + { + cmUnpkRguUeFlowCntrlInfo(¶m->ueFlowCntrlInfo[idx],mBuf); + } + RETVALUE(ROK); +} + +/** +* @brief Flow control indication from MAC to RLC +* Informs RLC of the LCs on which flow control to +* be started +* +* @details +* +* Function : cmUnpkRguFlowCntrlInd +* +* @param[in] RguFlowCntrlInd func +* @param[in] Pst *pst +* @param[in] Buffer *mBuf +* @return S16 +* -# ROK +**/ +#ifdef ANSI +PUBLIC S16 cmUnpkRguFlowCntrlInd +( +RguFlowCntrlIndInfo func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguFlowCntrlInd(func, pst, mBuf) +RguFlowCntrlIndInfo func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + RguFlowCntrlInd *flowCntrlInd; + + TRC3(cmUnpkRguFlowCntrlInd) + + if (SUnpkS16(&suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU080, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (pst->selector == RGU_SEL_LWLC) + { + CMCHKUNPK(cmUnpkPtr,(PTR *) &flowCntrlInd, mBuf); + } + else + { + if ((SGetSBuf(pst->region, pst->pool, (Data **)&flowCntrlInd, sizeof(RguFlowCntrlInd))) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU081, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + RETVALUE(RFAILED); + } + if (cmUnpkRguFlowCntrlInfo(flowCntrlInd, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ERGU082, (ErrVal)0, "UnPacking failed"); +#endif + SPutMsg(mBuf); + SPutSBuf(pst->region, pst->pool, (Data *)flowCntrlInd, sizeof(RguFlowCntrlInd)); + RETVALUE(RFAILED); + } + } + SPutMsg(mBuf); + RETVALUE((*func)(pst, suId, flowCntrlInd)); +} + +/*********************************************************** +* +* Func : cmPkRguPduInfo +* +* +* Desc : RguPduInfo + * PDU information given on a logical channel +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRguPduInfo +( +RguPduInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRguPduInfo(param, mBuf) +RguPduInfo *param; +Buffer *mBuf; +#endif +{ + S32 i; + + TRC3(cmPkRguPduInfo); + + for (i=param->numPdu-1; i >= 0; i--) { + /* rgu_c_001.main_3: ccpu00111328: S16 is renamed as MsgLen */ + MsgLen msgLen = 0; + if (SFndLenMsg(param->mBuf[i], &msgLen) != ROK) + RETVALUE(RFAILED); + if (SCatMsg(mBuf, param->mBuf[i], M1M2) != ROK) + RETVALUE(RFAILED); + SPutMsg(param->mBuf[i]); + CMCHKPK(cmPkMsgLen, msgLen, mBuf); + } + CMCHKPK(SPkU8, param->numPdu, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRguPduInfo +* +* +* Desc : RguPduInfo + * PDU information given on a logical channel +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRguPduInfo +( +RguPduInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguPduInfo(param, mBuf) +RguPduInfo *param; +Buffer *mBuf; +#endif +{ + S32 i; + + TRC3(cmUnpkRguPduInfo); + + CMCHKUNPK(SUnpkU8, ¶m->numPdu, mBuf); + for (i=0; inumPdu; i++) { + MsgLen msgLen, totalMsgLen; + CMCHKUNPK(cmUnpkMsgLen, &msgLen, mBuf); + if (SFndLenMsg(mBuf, &totalMsgLen) != ROK) + RETVALUE(RFAILED); + if (SSegMsg(mBuf, totalMsgLen-msgLen, ¶m->mBuf[i]) != ROK) + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRguDBoReport +* +* +* Desc : RguDBoReport + * Buffer Occupancy Report for dedicated logical channel +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRguDBoReport +( +RguDBoReport *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRguDBoReport(param, mBuf) +RguDBoReport *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRguDBoReport); + + CMCHKPK(SPkU32, param->oldestSduArrTime, mBuf); + CMCHKPK(SPkU32, param->staPduBo, mBuf); +#ifdef CCPU_OPT + CMCHKPK(SPkU8, param->staPduPrsnt, mBuf); + CMCHKPK(SPkU16, param->estRlcHdrSz, mBuf); +#endif + CMCHKPK(SPkS32, param->bo, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRguDBoReport +* +* +* Desc : RguDBoReport + * Buffer Occupancy Report for dedicated logical channel +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRguDBoReport +( +RguDBoReport *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguDBoReport(param, mBuf) +RguDBoReport *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRguDBoReport); + + CMCHKUNPK(SUnpkS32, ¶m->bo, mBuf); +#ifdef CCPU_OPT + CMCHKUNPK(SUnpkU16, ¶m->estRlcHdrSz, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->staPduPrsnt, mBuf); +#endif + + CMCHKUNPK(SUnpkU32, ¶m->staPduBo, mBuf); + CMCHKUNPK(SUnpkU32, ¶m->oldestSduArrTime, mBuf); + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func : cmPkRguCDatReqInfo +* +* +* Desc : RguCDatReqInfo + * DatReq from RLC to MAC for Common Channels(BCCH, PCCH and CCCH) +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRguCDatReqInfo +( +RguCDatReqInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRguCDatReqInfo(param, mBuf) +RguCDatReqInfo *param; +Buffer *mBuf; +#endif +{ + MsgLen msgLen; + + TRC3(cmPkRguCDatReqInfo); + + if (param->pdu != NULLP) + { + if (SFndLenMsg(param->pdu, &msgLen) != ROK) + RETVALUE(RFAILED); + if (SCatMsg(mBuf, param->pdu, M1M2) != ROK) + RETVALUE(RFAILED); + SPutMsg(param->pdu); + CMCHKPK(cmPkMsgLen, msgLen, mBuf); + } + switch(param->lcType) { + case CM_LTE_LCH_CCCH: + CMCHKPK(cmPkLteRnti, param->u.rnti, mBuf); + break; + case CM_LTE_LCH_BCCH: + case CM_LTE_LCH_PCCH: + CMCHKPK(cmPkLteTimingInfo, ¶m->u.timeToTx, mBuf); +#ifdef EMTC_ENABLE + CMCHKPK(SPkU8,param->pnb,mBuf); +#endif + break; + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkU32, param->transId, mBuf); + CMCHKPK(cmPkLteLcType, param->lcType, mBuf); + CMCHKPK(cmPkLteLcId, param->lcId, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRguCDatReqInfo +* +* +* Desc : RguCDatReqInfo + * DatReq from RLC to MAC for Common Channels(BCCH, PCCH and CCCH) +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRguCDatReqInfo +( +RguCDatReqInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguCDatReqInfo(param, mBuf) +RguCDatReqInfo *param; +Buffer *mBuf; +#endif +{ + MsgLen msgLen, totalMsgLen; + + TRC3(cmUnpkRguCDatReqInfo); + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteLcId, ¶m->lcId, mBuf); + CMCHKUNPK(cmUnpkLteLcType, ¶m->lcType, mBuf); + CMCHKUNPK(SUnpkU32, ¶m->transId, mBuf); + switch(param->lcType) { + case CM_LTE_LCH_BCCH: + case CM_LTE_LCH_PCCH: +#ifdef EMTC_ENABLE + CMCHKUNPK(SUnpkU8,¶m->pnb, mBuf); +#endif + CMCHKUNPK(cmUnpkLteTimingInfo, ¶m->u.timeToTx, mBuf); + break; + case CM_LTE_LCH_CCCH: + CMCHKUNPK(cmUnpkLteRnti, ¶m->u.rnti, mBuf); + break; + default : + RETVALUE(RFAILED); + } + SFndLenMsg(mBuf, &msgLen); + if (msgLen > 0) + { + CMCHKUNPK(cmUnpkMsgLen, &msgLen, mBuf); + if (SFndLenMsg(mBuf, &totalMsgLen) != ROK) + RETVALUE(RFAILED); + if (SSegMsg(mBuf, totalMsgLen-msgLen, ¶m->pdu) != ROK) + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRguLchDatReq +* +* +* Desc : RguLchDatReq + * DatReq Information of a logical channel +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRguLchDatReq +( +RguLchDatReq *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRguLchDatReq(param, mBuf) +RguLchDatReq *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRguLchDatReq); + +#ifdef L2_OPTMZ + CMCHKPK(SPkU8, param->freeBuff, mBuf); +#endif + CMCHKPK(SPkU8, param->setMaxUlPrio, mBuf); + CMCHKPK(cmPkRguPduInfo, ¶m->pdu, mBuf); + CMCHKPK(cmPkRguDBoReport, ¶m->boReport, mBuf); + CMCHKPK(cmPkLteLcId, param->lcId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRguLchDatReq +* +* +* Desc : RguLchDatReq + * DatReq Information of a logical channel +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRguLchDatReq +( +RguLchDatReq *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguLchDatReq(param, mBuf) +RguLchDatReq *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRguLchDatReq); + + CMCHKUNPK(cmUnpkLteLcId, ¶m->lcId, mBuf); + CMCHKUNPK(cmUnpkRguDBoReport, ¶m->boReport, mBuf); + CMCHKUNPK(cmUnpkRguPduInfo, ¶m->pdu, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->setMaxUlPrio, mBuf); +#ifdef L2_OPTMZ + CMCHKUNPK(SUnpkU8, ¶m->freeBuff, mBuf); +#endif + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func : cmPkRguDatReqTb +* +* +* Desc : RguDatReqTb +* DatReq from RLC to MAC for dedicated channels of a UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRguDatReqTb +( +RguDatReqTb *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRguDatReqTb(param, mBuf) +RguDatReqTb *param; +Buffer *mBuf; +#endif +{ + S32 i; + + TRC3(cmPkRguDatReqTb); + /*rgu_c_001.main_5 - ADD - L2M Support */ +#ifdef LTE_L2_MEAS + CMCHKPK(SPkU32, param->tbId, mBuf); +#endif + for (i=param->nmbLch-1; i >= 0; i--) { + CMCHKPK(cmPkRguLchDatReq, ¶m->lchData[i], mBuf); + } + CMCHKPK(SPkU8, param->nmbLch, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRguDatReqTb +* +* +* Desc : RguDatReqTb + * DatReq from RLC to MAC for dedicated channels of a UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef LTE_L2_MEAS +#ifdef ANSI +PUBLIC S16 cmUnpkRguDatReqTb +( +Pst *pst, +RguDatReqTb *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguDatReqTb(pst, param, mBuf) +Pst *pst; +RguDatReqTb *param; +Buffer *mBuf; +#endif +#else +#ifdef ANSI +PUBLIC S16 cmUnpkRguDatReqTb +( +RguDatReqTb *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguDatReqTb(param, mBuf) +RguDatReqTb *param; +Buffer *mBuf; +#endif +#endif +{ + S32 i; + + TRC3(cmUnpkRguDatReqTb); + + CMCHKUNPK(SUnpkU8, ¶m->nmbLch, mBuf); + for (i=0; inmbLch; i++) { + CMCHKUNPK(cmUnpkRguLchDatReq, ¶m->lchData[i], mBuf); + } + /*rgu_c_001.main_5 - ADD - L2M Support */ +#ifdef LTE_L2_MEAS + CMCHKUNPK(SUnpkU32, ¶m->tbId, mBuf); +#endif + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func : cmPkRguDDatReqInfo +* +* +* Desc : RguDDatReqInfo + * DatReq from RLC to MAC for dedicated channels of a UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ + /*rgu_c_001.main_5 - ADD - L2M Support */ +#ifdef LTE_L2_MEAS +#ifdef ANSI +PUBLIC S16 cmPkRguDDatReqInfo +( +Pst *pst, +RguDDatReqInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRguDDatReqInfo(pst, param, mBuf) +Pst *pst; +RguDDatReqInfo *param; +Buffer *mBuf; +#endif +#else +#ifdef ANSI +PUBLIC S16 cmPkRguDDatReqInfo +( +RguDDatReqInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRguDDatReqInfo(param, mBuf) +RguDDatReqInfo *param; +Buffer *mBuf; +#endif +#endif +{ + S32 i; + S32 idx; + + TRC3(cmPkRguDDatReqInfo); + + for(idx = (param->nmbOfUeGrantPerTti-1); idx >= 0; idx--) + { + RguDDatReqPerUe *datReq = ¶m->datReq[idx]; + for (i=RGU_MAX_TB-1; i >= 0; i--) + { + CMCHKPK(cmPkRguDatReqTb, &datReq->datReqTb[i], mBuf); + } + CMCHKPK(SPkU8, datReq->nmbOfTbs, mBuf); + CMCHKPK(SPkU32, datReq->transId, mBuf); + CMCHKPK(cmPkLteRnti, datReq->rnti, mBuf); + } + CMCHKPK(SPkU8, param->nmbOfUeGrantPerTti, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRguDDatReqInfo +* +* +* Desc : RguDDatReqInfo + * DatReq from RLC to MAC for dedicated channels of a UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef LTE_L2_MEAS +#ifdef ANSI +PUBLIC S16 cmUnpkRguDDatReqInfo +( +Pst *pst, +RguDDatReqInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguDDatReqInfo(pst, param, mBuf) +Pst *pst; +RguDDatReqInfo *param; +Buffer *mBuf; +#endif +#else +#ifdef ANSI +PUBLIC S16 cmUnpkRguDDatReqInfo +( +RguDDatReqInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguDDatReqInfo(param, mBuf) +RguDDatReqInfo *param; +Buffer *mBuf; +#endif +#endif +{ + S32 i; + /* After Merging from 2.1 to 2.2 */ + /*rgu_c_001.main_5 - ADD - L2M Support */ +#ifdef LTE_L2_MEAS + S16 retVal; +#endif + S32 idx; + + TRC3(cmUnpkRguDDatReqInfo); + + /* After Merging from 2.1 to 2.2 */ + /*rgu_c_001.main_5 - ADD - L2M Support */ +#ifdef LTE_L2_MEAS + retVal = ROK; +#endif + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->nmbOfUeGrantPerTti, mBuf); + for(idx = 0; idx < param->nmbOfUeGrantPerTti; idx++) + { + RguDDatReqPerUe *datReq = ¶m->datReq[idx]; + CMCHKUNPK(cmUnpkLteRnti, &datReq->rnti, mBuf); + CMCHKUNPK(SUnpkU32, &datReq->transId, mBuf); + CMCHKUNPK(SUnpkU8, &datReq->nmbOfTbs, mBuf); + /* rgu_c_001.main_4 - Changes for MIMO feature addition */ + for (i=0; idatReqTb[i], mBuf); + if(retVal != ROK) + { + RETVALUE(RFAILED); + } +#else + CMCHKUNPK(cmUnpkRguDatReqTb, &datReq->datReqTb[i], mBuf); +#endif + } + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRguCDatIndInfo +* +* +* Desc : RguCDatIndInfo + * DatInd from MAC to RLC on CCCH +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRguCDatIndInfo +( +RguCDatIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRguCDatIndInfo(param, mBuf) +RguCDatIndInfo *param; +Buffer *mBuf; +#endif +{ + MsgLen msgLen; + + TRC3(cmPkRguCDatIndInfo); + + if (SFndLenMsg(param->pdu, &msgLen) != ROK) + RETVALUE(RFAILED); + if (SCatMsg(mBuf, param->pdu, M1M2) != ROK) + RETVALUE(RFAILED); + SPutMsg(param->pdu); + CMCHKPK(cmPkMsgLen, msgLen, mBuf); + CMCHKPK(cmPkLteLcId, param->lcId, mBuf); + CMCHKPK(cmPkLteRnti, param->rnti, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRguCDatIndInfo +* +* +* Desc : RguCDatIndInfo + * DatInd from MAC to RLC on CCCH +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRguCDatIndInfo +( +RguCDatIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguCDatIndInfo(param, mBuf) +RguCDatIndInfo *param; +Buffer *mBuf; +#endif +{ + MsgLen msgLen, totalMsgLen; + + TRC3(cmUnpkRguCDatIndInfo); + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->rnti, mBuf); + CMCHKUNPK(cmUnpkLteLcId, ¶m->lcId, mBuf); + CMCHKUNPK(cmUnpkMsgLen, &msgLen, mBuf); + if (SFndLenMsg(mBuf, &totalMsgLen) != ROK) + RETVALUE(RFAILED); + if (SSegMsg(mBuf, totalMsgLen-msgLen, ¶m->pdu) != ROK) + RETVALUE(RFAILED); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRguLchDatInd +* +* +* Desc : RguLchDatInd + * DatInd Information for a logical channel +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRguLchDatInd +( +RguLchDatInd *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRguLchDatInd(param, mBuf) +RguLchDatInd *param; +Buffer *mBuf; +#endif +{ + TRC3(cmPkRguLchDatInd); + + CMCHKPK(cmPkRguPduInfo, ¶m->pdu, mBuf); + CMCHKPK(cmPkLteLcId, param->lcId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRguLchDatInd +* +* +* Desc : RguLchDatInd + * DatInd Information for a logical channel +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRguLchDatInd +( +RguLchDatInd *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguLchDatInd(param, mBuf) +RguLchDatInd *param; +Buffer *mBuf; +#endif +{ + TRC3(cmUnpkRguLchDatInd); + + CMCHKUNPK(cmUnpkLteLcId, ¶m->lcId, mBuf); + CMCHKUNPK(cmUnpkRguPduInfo, ¶m->pdu, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRguDDatIndInfo +* +* +* Desc : RguDDatIndInfo + * Data Indication from MAC to RLC for dedicated channels of a UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRguDDatIndInfo +( +RguDDatIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRguDDatIndInfo(param, mBuf) +RguDDatIndInfo *param; +Buffer *mBuf; +#endif +{ + S32 i; + + TRC3(cmPkRguDDatIndInfo); + +#ifdef LTE_L2_MEAS + CMCHKPK(SPkU8, param->burstInd, mBuf); + CMCHKPK(SPkU32, param->ttiCnt, mBuf); +#endif + for (i=param->numLch-1; i >= 0; i--) { + CMCHKPK(cmPkRguLchDatInd, ¶m->lchData[i], mBuf); + } + CMCHKPK(SPkU8, param->numLch, mBuf); + CMCHKPK(cmPkLteRnti, param->rnti, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRguDDatIndInfo +* +* +* Desc : RguDDatIndInfo + * Data Indication from MAC to RLC for dedicated channels of a UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRguDDatIndInfo +( +RguDDatIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguDDatIndInfo(param, mBuf) +RguDDatIndInfo *param; +Buffer *mBuf; +#endif +{ + S32 i; + + TRC3(cmUnpkRguDDatIndInfo); + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->rnti, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numLch, mBuf); + for (i=0; inumLch; i++) { + CMCHKUNPK(cmUnpkRguLchDatInd, ¶m->lchData[i], mBuf); + } +#ifdef LTE_L2_MEAS + CMCHKUNPK(SUnpkU32, ¶m->ttiCnt, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->burstInd, mBuf); +#endif + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func : cmPkRguCStaRspInfo +* +* +* Desc : RguCStaRspInfo + * Status Response from RLC to MAC for common logical channel +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRguCStaRspInfo +( +RguCStaRspInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRguCStaRspInfo(param, mBuf) +RguCStaRspInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRguCStaRspInfo); + + switch(param->lcType) { + case CM_LTE_LCH_CCCH: + CMCHKPK(cmPkLteRnti, param->u.rnti, mBuf); + break; + case CM_LTE_LCH_BCCH: + case CM_LTE_LCH_PCCH: + CMCHKPK(cmPkLteTimingInfo, ¶m->u.timeToTx, mBuf); +#ifdef EMTC_ENABLE + CMCHKPK(SPkU8,param->pnb,mBuf); + CMCHKPK(SPkU8,param->emtcDiReason,mBuf); +#endif + break; + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkS32, param->bo, mBuf); + CMCHKPK(cmPkLteLcType, param->lcType, mBuf); + CMCHKPK(cmPkLteLcId, param->lcId, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRguCStaRspInfo +* +* +* Desc : RguCStaRspInfo + * Status Response from RLC to MAC for common logical channel +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRguCStaRspInfo +( +RguCStaRspInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguCStaRspInfo(param, mBuf) +RguCStaRspInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRguCStaRspInfo); + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteLcId, ¶m->lcId, mBuf); + CMCHKUNPK(cmUnpkLteLcType, ¶m->lcType, mBuf); + CMCHKUNPK(SUnpkS32, ¶m->bo, mBuf); + switch(param->lcType) { + case CM_LTE_LCH_BCCH: + case CM_LTE_LCH_PCCH: +#ifdef EMTC_ENABLE + CMCHKUNPK(SUnpkU8,¶m->emtcDiReason , mBuf); + CMCHKUNPK(SUnpkU8,¶m->pnb , mBuf); +#endif + CMCHKUNPK(cmUnpkLteTimingInfo, ¶m->u.timeToTx, mBuf); + break; + case CM_LTE_LCH_CCCH: + CMCHKUNPK(cmUnpkLteRnti, ¶m->u.rnti, mBuf); + break; + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRguDStaRspInfo +* +* +* Desc : RguDStaRspInfo + * Status Response from RLC to MAC for dedicated logical channel +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRguDStaRspInfo +( +RguDStaRspInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRguDStaRspInfo(param, mBuf) +RguDStaRspInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRguDStaRspInfo); + + CMCHKPK(cmPkRguDBoReport, ¶m->boReport, mBuf); + CMCHKPK(cmPkLteLcId, param->lcId, mBuf); + CMCHKPK(cmPkLteRnti, param->rnti, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRguDStaRspInfo +* +* +* Desc : RguDStaRspInfo + * Status Response from RLC to MAC for dedicated logical channel +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRguDStaRspInfo +( +RguDStaRspInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguDStaRspInfo(param, mBuf) +RguDStaRspInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRguDStaRspInfo); + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->rnti, mBuf); + CMCHKUNPK(cmUnpkLteLcId, ¶m->lcId, mBuf); + CMCHKUNPK(cmUnpkRguDBoReport, ¶m->boReport, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRguCStaIndInfo +* +* +* Desc : RguCStaIndInfo + * Status Indication from MAC to RLC for common logical channel +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRguCStaIndInfo +( +RguCStaIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRguCStaIndInfo(param, mBuf) +RguCStaIndInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRguCStaIndInfo); +#ifdef EMTC_ENBALE + CMCHKPK(cmPkLteTimingInfo, ¶m->pagingTimingInfo, mBuf); + CMCHKPK(SPkU8, param->isEmtcPaging, mBuf); +#endif + CMCHKPK(cmPkLteRnti, param->rnti, mBuf); + CMCHKPK(SPkU32, param->transId, mBuf); + CMCHKPK(cmPkLteLcId, param->lcId, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRguCStaIndInfo +* +* +* Desc : RguCStaIndInfo + * Status Indication from MAC to RLC for common logical channel +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRguCStaIndInfo +( +RguCStaIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguCStaIndInfo(param, mBuf) +RguCStaIndInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRguCStaIndInfo); + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteLcId, ¶m->lcId, mBuf); + CMCHKUNPK(SUnpkU32, ¶m->transId, mBuf); + /*TODO:Mukesh: Need to check why rnti unpacking is missing*/ +#ifdef EMTC_ENBALE + CMCHKUNPK(SUnpkU8, ¶m->isEmtcPaging, mBuf); + CMCHKUNPK(cmUnpkLteTimingInfo, ¶m->pagingTimingInfo, mBuf); +#endif + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkRguLchStaInd +* +* +* Desc : RguLchStaInd + * StaInd info for each logical channel of a UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRguLchStaInd +( +RguLchStaInd *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRguLchStaInd(param, mBuf) +RguLchStaInd *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkRguLchStaInd); + + CMCHKPK(SPkS16, param->totBufSize, mBuf); + CMCHKPK(cmPkLteLcId, param->lcId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRguLchStaInd +* +* +* Desc : RguLchStaInd + * StaInd info for each logical channel of a UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRguLchStaInd +( +RguLchStaInd *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguLchStaInd(param, mBuf) +RguLchStaInd *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkRguLchStaInd); + + CMCHKUNPK(cmUnpkLteLcId, ¶m->lcId, mBuf); + CMCHKUNPK(SUnpkS16, ¶m->totBufSize, mBuf); + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func : cmPkRguStaIndTb +* +* +* Desc : RguStaIndTb +* StaInd from RLC to MAC for dedicated channels of a UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRguStaIndTb +( +RguStaIndTb *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRguStaIndTb(param, mBuf) +RguStaIndTb *param; +Buffer *mBuf; +#endif +{ + S32 i; + + TRC3(cmPkRguStaIndTb); + +#ifdef LTE_L2_MEAS + CMCHKPK(SPkU16, param->status, mBuf); + CMCHKPK(SPkU32, param->tbId, mBuf); +#endif + for (i=param->nmbLch-1; i >= 0; i--) { + CMCHKPK(cmPkRguLchStaInd, ¶m->lchStaInd[i], mBuf); + } + CMCHKPK(SPkU8, param->nmbLch, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRguStaIndTb +* +* +* Desc : RguStaIndTb +* StaInd from RLC to MAC for dedicated channels of a UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRguStaIndTb +( +RguStaIndTb *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguStaIndTb(param, mBuf) +RguStaIndTb *param; +Buffer *mBuf; +#endif +{ + S32 i; + + TRC3(cmUnpkRguStaIndTb); + + CMCHKUNPK(SUnpkU8, ¶m->nmbLch, mBuf); + for (i=0; inmbLch; i++) { + CMCHKUNPK(cmUnpkRguLchStaInd, ¶m->lchStaInd[i], mBuf); + } +#ifdef LTE_L2_MEAS + CMCHKUNPK(SUnpkU32, ¶m->tbId, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->status, mBuf); +#endif + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func : cmPkRguDStaIndInfo +* +* +* Desc : RguDStaIndInfo + * StaInd from MAC to RLC for dedicated logical channels of a UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkRguDStaIndInfo +( +RguDStaIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkRguDStaIndInfo(param, mBuf) +RguDStaIndInfo *param; +Buffer *mBuf; +#endif +{ + S32 i; + S32 idx; + + TRC3(cmPkRguDStaIndInfo); + + for(idx = (param->nmbOfUeGrantPerTti - 1); idx >= 0 ; idx--) + { + RguDStaIndPerUe *staInd = ¶m->staInd[idx]; + CMCHKPK(SPkU8, staInd->fillCtrlPdu, mBuf); + for (i=staInd->nmbOfTbs-1; i >= 0; i--) { + CMCHKPK(cmPkRguStaIndTb, &staInd->staIndTb[i], mBuf); + } + CMCHKPK(SPkU8, staInd->nmbOfTbs, mBuf); + CMCHKPK(SPkU32,staInd->transId, mBuf); + CMCHKPK(cmPkLteRnti, staInd->rnti, mBuf); + } + CMCHKPK(SPkU8, param->nmbOfUeGrantPerTti, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkRguDStaIndInfo +* +* +* Desc : RguDStaIndInfo + * StaInd from MAC to RLC for dedicated logical channels of a UE +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkRguDStaIndInfo +( +RguDStaIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkRguDStaIndInfo(param, mBuf) +RguDStaIndInfo *param; +Buffer *mBuf; +#endif +{ + S32 i; + S32 idx; + + TRC3(cmUnpkRguDStaIndInfo); + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->nmbOfUeGrantPerTti, mBuf); + for(idx = 0; idx < param->nmbOfUeGrantPerTti; idx++) + { + RguDStaIndPerUe *staInd = ¶m->staInd[idx]; + CMCHKUNPK(cmUnpkLteRnti, &staInd->rnti, mBuf); + CMCHKUNPK(SUnpkU32, &staInd->transId, mBuf); + CMCHKUNPK(SUnpkU8, &staInd->nmbOfTbs, mBuf); + for (i=0; inmbOfTbs; i++) + { + CMCHKUNPK(cmUnpkRguStaIndTb, &staInd->staIndTb[i], mBuf); + } + CMCHKUNPK(SUnpkU8, &staInd->fillCtrlPdu, mBuf); + } + RETVALUE(ROK); +} + +#endif + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/cm/ssi.h b/src/cm/ssi.h index a42c01d52..f4a53cda4 100755 --- a/src/cm/ssi.h +++ b/src/cm/ssi.h @@ -1396,6 +1396,11 @@ #define ENTLAST ENTNL /* last entity id */ #endif /* WR_DG_OAM */ +#ifdef ODU +#define ENTDUAPP 0xeb /* ORAN DU APP */ +#define ENTSCTP 0xec /* ORAN SCTP */ +#define ENTF1AP 0xed /* ORAN F1AP */ +#endif //ORAN /* un-configured procId */ #ifdef SS_MULTIPLE_PROCS #define PROCNC 0xFFFF /* Processor not configured */ diff --git a/src/cm/tfu.c b/src/cm/tfu.c new file mode 100755 index 000000000..d24f3fd78 --- /dev/null +++ b/src/cm/tfu.c @@ -0,0 +1,15627 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + + +/************************************************************************ + + Name: LTE-MAC layer + + Type: C source file + + Desc: C source code for pack/unpack of TFU interface primitives. + + File: tfu.c + +**********************************************************************/ + +/** @file tfu.c +@brief This file contains the packing/unpacking code for the TFU interface + primitives. +*/ + +/* header include files (.h) */ +#include "envopt.h" /* environment options */ +#include "envdep.h" /* environment dependent */ +#include "envind.h" /* environment independent */ +#include "gen.h" /* general */ +#include "ssi.h" /* system services */ +#include "cm_tkns.h" /* Common Token Defines */ +#include "cm_llist.h" /* Common Link List Defines */ +#include "cm_hash.h" /* Common Hash List Defines */ +#include "cm_lte.h" /* Common LTE Defines */ +#include "cm_mblk.h" /* Common LTE Defines */ +#include "tfu.h" /* RGU Interface defines */ + +/* header/extern include files (.x) */ +#include "gen.x" /* general */ +#include "ssi.x" /* system services */ +#include "cm_tkns.x" /* Common Token Definitions */ +#include "cm_llist.x" /* Common Link List Definitions */ +#include "cm_lib.x" /* Common Library Definitions */ +#include "cm_hash.x" /* Common Hash List Definitions */ +#include "cm_lte.x" /* Common LTE Defines */ +#include "cm_mblk.x" /* Common LTE Defines */ +#include "tfu.x" /* RGU Interface includes */ + +#if (defined(LCTFU)) + + +/*********************************************************** +* +* Func : cmPkTfuBndReq +* +* +* Desc : This API is used to send a Bind Request from MAC to PHY. + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service user. + * @param spId SAP ID of the service provider. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuBndReq +( +Pst * pst, +SuId suId, +SpId spId +) +#else +PUBLIC S16 cmPkTfuBndReq(pst, suId, spId) +Pst * pst; +SuId suId; +SpId spId; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkTfuBndReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU001, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU002, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU003, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + pst->event = (Event) EVTTFUBNDREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/*********************************************************** +* +* Func : cmUnpkTfuBndReq +* +* +* Desc : This API is used to send a Bind Request from MAC to PHY. + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service user. + * @param spId SAP ID of the service provider. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuBndReq +( +TfuBndReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuBndReq(func, pst, mBuf) +TfuBndReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + SpId spId; + + TRC3(cmUnpkTfuBndReq) + + if (SUnpkS16(&suId, mBuf) != ROK) { + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU004, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SUnpkS16(&spId, mBuf) != ROK) { + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU005, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + TFU_FREE_MSG(mBuf); + RETVALUE((*func)(pst, suId, spId)); +} + + +/*********************************************************** +* +* Func : cmPkTfuBndCfm +* +* +* Desc : This API is used to receive a Bind Confirm from PHY to MAC. + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service user. + * @param status Status of the bind request. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuBndCfm +( +Pst * pst, +SuId suId, +U8 status +) +#else +PUBLIC S16 cmPkTfuBndCfm(pst, suId, status) +Pst * pst; +SuId suId; +U8 status; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkTfuBndCfm) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU006, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SPkU8(status, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU007, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU008, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + pst->event = (Event) EVTTFUBNDCFM; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/*********************************************************** +* +* Func : cmUnpkTfuBndCfm +* +* +* Desc : This API is used to receive a Bind Confirm from PHY to MAC. + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service user. + * @param status Status of the bind request. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuBndCfm +( +TfuBndCfm func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuBndCfm(func, pst, mBuf) +TfuBndCfm func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + U8 status; + + TRC3(cmUnpkTfuBndCfm) + + if (SUnpkS16(&suId, mBuf) != ROK) { + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU009, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SUnpkU8(&status, mBuf) != ROK) { + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU010, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + TFU_FREE_MSG(mBuf); + RETVALUE((*func)(pst, suId, status)); +} + + +/*********************************************************** +* +* Func : cmPkTfuUbndReq +* +* +* Desc : This API is used to send an Unbind Request from MAC to PHY. + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service provider. + * @param reason Reason for Unbind request. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuUbndReq +( +Pst * pst, +SpId spId, +Reason reason +) +#else +PUBLIC S16 cmPkTfuUbndReq(pst, spId, reason) +Pst * pst; +SpId spId; +Reason reason; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkTfuUbndReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU011, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SPkS16(reason, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU012, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU013, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + pst->event = (Event) EVTTFUUBNDREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/*********************************************************** +* +* Func : cmUnpkTfuUbndReq +* +* +* Desc : This API is used to send an Unbind Request from MAC to PHY. + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service provider. + * @param reason Reason for Unbind request. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuUbndReq +( +TfuUbndReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuUbndReq(func, pst, mBuf) +TfuUbndReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SpId spId; + Reason reason; + + TRC3(cmUnpkTfuUbndReq) + + if (SUnpkS16(&spId, mBuf) != ROK) { + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU014, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SUnpkS16(&reason, mBuf) != ROK) { + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU015, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + TFU_FREE_MSG(mBuf); + RETVALUE((*func)(pst, spId, reason)); +} + + +/*********************************************************** +* +* Func : cmPkTfuSchBndReq +* +* +* Desc : This API is used to send a Bind Request from Scheduler to PHY. + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service user. + * @param spId SAP ID of the service provider. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuSchBndReq +( +Pst * pst, +SuId suId, +SpId spId +) +#else +PUBLIC S16 cmPkTfuSchBndReq(pst, suId, spId) +Pst * pst; +SuId suId; +SpId spId; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkTfuSchBndReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU016, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU017, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU018, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + pst->event = (Event) EVTTFUSCHBNDREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/*********************************************************** +* +* Func : cmUnpkTfuSchBndReq +* +* +* Desc : This API is used to send a Bind Request from Scheduler to PHY. + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service user. + * @param spId SAP ID of the service provider. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuSchBndReq +( +TfuSchBndReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuSchBndReq(func, pst, mBuf) +TfuSchBndReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + SpId spId; + + TRC3(cmUnpkTfuSchBndReq) + + if (SUnpkS16(&suId, mBuf) != ROK) { + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU019, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SUnpkS16(&spId, mBuf) != ROK) { + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU020, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + TFU_FREE_MSG(mBuf); + RETVALUE((*func)(pst, suId, spId)); +} + + +/*********************************************************** +* +* Func : cmPkTfuSchBndCfm +* +* +* Desc : This API is used to receive a Bind Confirm from PHY to Scheduler. + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service user. + * @param status Status of the bind request. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuSchBndCfm +( +Pst * pst, +SuId suId, +U8 status +) +#else +PUBLIC S16 cmPkTfuSchBndCfm(pst, suId, status) +Pst * pst; +SuId suId; +U8 status; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkTfuSchBndCfm) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU021, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SPkU8(status, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU022, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU023, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + pst->event = (Event) EVTTFUSCHBNDCFM; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/*********************************************************** +* +* Func : cmUnpkTfuSchBndCfm +* +* +* Desc : This API is used to receive a Bind Confirm from PHY to Scheduler. + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service user. + * @param status Status of the bind request. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuSchBndCfm +( +TfuSchBndCfm func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuSchBndCfm(func, pst, mBuf) +TfuSchBndCfm func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + U8 status; + + TRC3(cmUnpkTfuSchBndCfm) + + if (SUnpkS16(&suId, mBuf) != ROK) { + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU024, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SUnpkU8(&status, mBuf) != ROK) { + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU025, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + TFU_FREE_MSG(mBuf); + RETVALUE((*func)(pst, suId, status)); +} + + +/*********************************************************** +* +* Func : cmPkTfuSchUbndReq +* +* +* Desc : This API is used to send an Unbind Request from Scheduler to PHY. + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service provider. + * @param reason Reason for Unbind request. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuSchUbndReq +( +Pst * pst, +SpId spId, +Reason reason +) +#else +PUBLIC S16 cmPkTfuSchUbndReq(pst, spId, reason) +Pst * pst; +SpId spId; +Reason reason; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkTfuSchUbndReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU026, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SPkS16(reason, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU027, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU028, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + pst->event = (Event) EVTTFUSCHUBNDREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/*********************************************************** +* +* Func : cmUnpkTfuSchUbndReq +* +* +* Desc : This API is used to send an Unbind Request from Scheduler to PHY. + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service provider. + * @param reason Reason for Unbind request. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuSchUbndReq +( +TfuSchUbndReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuSchUbndReq(func, pst, mBuf) +TfuSchUbndReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SpId spId; + Reason reason; + + TRC3(cmUnpkTfuSchUbndReq) + + if (SUnpkS16(&spId, mBuf) != ROK) { + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU029, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SUnpkS16(&reason, mBuf) != ROK) { + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU030, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + TFU_FREE_MSG(mBuf); + RETVALUE((*func)(pst, spId, reason)); +} + + +/*********************************************************** +* +* Func : cmPkTfuRaReqInd +* +* +* Desc : This API is used to indication Random Access Request reception from + * PHY to Scheduler. + * @details This primitive is used by physical layer to indicate the reception + * of a Random Access Request from a set of UEs. The information passed consists + * of the RA-RNTI and the list of preambles received. + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service user. + * @param raReqInd Pointer to the TfuRaReqIndInfo structure. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuRaReqInd +( +Pst * pst, +SuId suId, +TfuRaReqIndInfo * raReqInd +) +#else +PUBLIC S16 cmPkTfuRaReqInd(pst, suId, raReqInd) +Pst * pst; +SuId suId; +TfuRaReqIndInfo * raReqInd; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkTfuRaReqInd) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU031, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(raReqInd); + RETVALUE(RFAILED); + } + if (pst->selector == TFU_SEL_LC) { + if (cmPkTfuRaReqIndInfo(raReqInd, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU032, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(raReqInd); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + else if(pst->selector == TFU_SEL_LWLC) + { + if (cmPkPtr((PTR)raReqInd, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFUXXX, (ErrVal)0, "LWLC Packing failed"); +#endif + TFU_FREE_MEM(raReqInd); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU033, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(raReqInd); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + if (pst->selector != TFU_SEL_LWLC) { + TFU_FREE_MEM(raReqInd); + } + + pst->event = (Event) EVTTFURAREQIND; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/*********************************************************** +* +* Func : cmUnpkTfuRaReqInd +* +* +* Desc : This API is used to indication Random Access Request reception from + * PHY to Scheduler. + * @details This primitive is used by physical layer to indicate the reception + * of a Random Access Request from a set of UEs. The information passed consists + * of the RA-RNTI and the list of preambles received. + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service user. + * @param raReqInd Pointer to the TfuRaReqIndInfo structure. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuRaReqInd +( +TfuRaReqInd func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuRaReqInd(func, pst, mBuf) +TfuRaReqInd func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + TfuRaReqIndInfo *raReqInd; + + TRC3(cmUnpkTfuRaReqInd) + + if (SUnpkS16(&suId, mBuf) != ROK) { + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU034, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector != TFU_SEL_LWLC) { + Mem sMem; + sMem.region = pst->region; + sMem.pool = pst->pool; + if ((cmAllocEvnt(sizeof(TfuRaReqIndInfo), TFU_BLKSZ, &sMem, (Ptr *)&raReqInd)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU035, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + + + if (pst->selector == TFU_SEL_LC) + { + if (cmUnpkTfuRaReqIndInfo(raReqInd, mBuf) != ROK) { + TFU_FREE_MEM(raReqInd); + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU036, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + } + else if(pst->selector == TFU_SEL_LWLC) + { + if (cmUnpkPtr((PTR *)&raReqInd, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFUXXX, (ErrVal)0, "LWLC un-Packing failed"); +#endif + TFU_FREE_MEM(raReqInd); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + TFU_FREE_MSG(mBuf); + RETVALUE((*func)(pst, suId, raReqInd)); +} + + +/*********************************************************** +* +* Func : cmPkTfuRecpReq +* +* +* Desc : This primitive is sent from Scheduler to PHY. + * @details This primitive provides PHY with all the information required by + * PHY to decode transmissions from the UE on either PUCCH or PUSCH. + * -# On PUCCH UE can transmit the following + * -# SR + * -# HARQ feedback + * -# CQI report + * -# HARQ + CQI + * -# HARQ + SR + * -# On PUSCH UE can transmit the following + * -# Data + * -# Data + CQI + * -# Data + HARQ Feedback + * This primitive carries all the information for the expected subframe for all + * the UEs that have been scheduled to transmit. + * @param pst Pointer to the post structure. + * @param spId SAP ID of the service provider. + * @param recpReq Pointer to the TfuRecpReqInfo structure. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuRecpReq +( +Pst * pst, +SpId spId, +TfuRecpReqInfo * recpReq +) +#else +PUBLIC S16 cmPkTfuRecpReq(pst, spId, recpReq) +Pst * pst; +SpId spId; +TfuRecpReqInfo * recpReq; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkTfuRecpReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU037, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(recpReq); + RETVALUE(RFAILED); + } + if (pst->selector == TFU_SEL_LC) { + if (cmPkTfuRecpReqInfo(recpReq, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU038, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(recpReq); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + else if(pst->selector == TFU_SEL_LWLC) + { + if (cmPkPtr((PTR)recpReq, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFUXXX, (ErrVal)0, "LWLC Packing failed"); +#endif + TFU_FREE_MEM(recpReq); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + + + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU039, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(recpReq); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + if (pst->selector != TFU_SEL_LWLC) { + TFU_FREE_MEM(recpReq); + } + + pst->event = (Event) EVTTFURECPREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/*********************************************************** +* +* Func : cmUnpkTfuRecpReq +* +* +* Desc : This primitive is sent from Scheduler to PHY. + * @details This primitive provides PHY with all the information required by + * PHY to decode transmissions from the UE on either PUCCH or PUSCH. + * -# On PUCCH UE can transmit the following + * -# SR + * -# HARQ feedback + * -# CQI report + * -# HARQ + CQI + * -# HARQ + SR + * -# On PUSCH UE can transmit the following + * -# Data + * -# Data + CQI + * -# Data + HARQ Feedback + * This primitive carries all the information for the expected subframe for all + * the UEs that have been scheduled to transmit. + * @param pst Pointer to the post structure. + * @param spId SAP ID of the service provider. + * @param recpReq Pointer to the TfuRecpReqInfo structure. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuRecpReq +( +TfuRecpReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuRecpReq(func, pst, mBuf) +TfuRecpReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SpId spId; + TfuRecpReqInfo *recpReq; + + TRC3(cmUnpkTfuRecpReq) + + if (SUnpkS16(&spId, mBuf) != ROK) { + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU040, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector != TFU_SEL_LWLC) { + Mem sMem; + sMem.region = pst->region; + sMem.pool = pst->pool; + if ((cmAllocEvnt(sizeof(TfuRecpReqInfo), TFU_BLKSZ, &sMem, (Ptr *)&recpReq)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU041, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + else if(pst->selector == TFU_SEL_LWLC) + { + if (cmUnpkPtr((PTR *)&recpReq, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFUXXX, (ErrVal)0, "LWLC un-Packing failed"); +#endif + TFU_FREE_MEM(recpReq); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + + if (pst->selector == TFU_SEL_LC) + { + if (cmUnpkTfuRecpReqInfo(recpReq, (Ptr)&recpReq->memCp, mBuf) != ROK) { + TFU_FREE_MEM(recpReq); + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU042, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + } + else if(pst->selector == TFU_SEL_LWLC) + { + if (cmUnpkPtr((PTR*)&recpReq, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFUXXX, (ErrVal)0, "LWLC un-Packing failed"); +#endif + TFU_FREE_MEM(recpReq); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + + TFU_FREE_MSG(mBuf); + RETVALUE((*func)(pst, spId, recpReq)); +} + + +/*********************************************************** +* +* Func : cmPkTfuUlCqiInd +* +* +* Desc : This API is used to indicate CQI reporting from PHY to Scheduler + * @details This primitive carries an estimate of the uplink Channel quality + * index (CQI) for a list of UEs. This is an extimate of the uplink channel + * quality i.e. the transmission from UE as calculated at the Physical layer at + * the eNodeB. + * It carries a list of subband CQIs for each UE. + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service user. + * @param ulCqiInd Pointer to the TfuUlCqiIndInfo structure. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuUlCqiInd +( +Pst * pst, +SuId suId, +TfuUlCqiIndInfo * ulCqiInd +) +#else +PUBLIC S16 cmPkTfuUlCqiInd(pst, suId, ulCqiInd) +Pst * pst; +SuId suId; +TfuUlCqiIndInfo * ulCqiInd; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkTfuUlCqiInd) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU043, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(ulCqiInd); + RETVALUE(RFAILED); + } + if (pst->selector == TFU_SEL_LC) { + if (cmPkTfuUlCqiIndInfo(ulCqiInd, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU044, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(ulCqiInd); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + else if(pst->selector == TFU_SEL_LWLC) + { + if (cmPkPtr((PTR)ulCqiInd, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFUXXX, (ErrVal)0, "LWLC Packing failed"); +#endif + TFU_FREE_MEM(ulCqiInd); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU045, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(ulCqiInd); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + if (pst->selector != TFU_SEL_LWLC) { + TFU_FREE_MEM(ulCqiInd); + } + + pst->event = (Event) EVTTFUULCQIIND; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/*********************************************************** +* +* Func : cmUnpkTfuUlCqiInd +* +* +* Desc : This API is used to indicate CQI reporting from PHY to Scheduler + * @details This primitive carries an estimate of the uplink Channel quality + * index (CQI) for a list of UEs. This is an extimate of the uplink channel + * quality i.e. the transmission from UE as calculated at the Physical layer at + * the eNodeB. + * It carries a list of subband CQIs for each UE. + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service user. + * @param ulCqiInd Pointer to the TfuUlCqiIndInfo structure. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuUlCqiInd +( +TfuUlCqiInd func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuUlCqiInd(func, pst, mBuf) +TfuUlCqiInd func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + TfuUlCqiIndInfo *ulCqiInd; + + TRC3(cmUnpkTfuUlCqiInd) + + if (SUnpkS16(&suId, mBuf) != ROK) { + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU046, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector != TFU_SEL_LWLC) { + Mem sMem; + sMem.region = pst->region; + sMem.pool = pst->pool; + if ((cmAllocEvnt(sizeof(TfuUlCqiIndInfo), TFU_BLKSZ, &sMem, (Ptr *)&ulCqiInd)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU047, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + + + if (pst->selector == TFU_SEL_LC) + { + if (cmUnpkTfuUlCqiIndInfo(ulCqiInd, (Ptr)&ulCqiInd->memCp, mBuf) != ROK) { + TFU_FREE_MEM(ulCqiInd); + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU048, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + } + else if(pst->selector == TFU_SEL_LWLC) + { + if (cmUnpkPtr((PTR *)&ulCqiInd, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFUXXX, (ErrVal)0, "LWLC un-Packing failed"); +#endif + TFU_FREE_MEM(ulCqiInd); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + TFU_FREE_MSG(mBuf); + RETVALUE((*func)(pst, suId, ulCqiInd)); +} + + +/*********************************************************** +* +* Func : cmPkTfuHqInd +* +* +* Desc : This Primitive carries the HARQ Feedback from PHY to scheduler + * @details HARQ feedback is sent by the UE to the eNodeB, an ACK is sent if UE + * could successfully recieve the data transmitted by the eNodeB, else a NACK is + * sent. This feedback is utilized by MAC for further scheduling, for instance + * it could schedule an adaptive retransmission of the same data. + * @param pst + * @param spId + * @param tfuHqInd pointer to TfuHqIndInfo + * @return +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuHqInd +( +Pst * pst, +SpId spId, +TfuHqIndInfo * hqInd +) +#else +PUBLIC S16 cmPkTfuHqInd(pst, spId, hqInd) +Pst * pst; +SpId spId; +TfuHqIndInfo * hqInd; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkTfuHqInd) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU049, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(hqInd); + RETVALUE(RFAILED); + } + if (pst->selector == TFU_SEL_LC) { + if (cmPkTfuHqIndInfo(hqInd, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU050, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(hqInd); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + else if(pst->selector == TFU_SEL_LWLC) + { + if (cmPkPtr((PTR)hqInd, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFUXXX, (ErrVal)0, "LWLC Packing failed"); +#endif + TFU_FREE_MEM(hqInd); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU051, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(hqInd); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + if (pst->selector != TFU_SEL_LWLC) { + TFU_FREE_MEM(hqInd); + } + + pst->event = (Event) EVTTFUHQIND; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/*********************************************************** +* +* Func : cmUnpkTfuHqInd +* +* +* Desc : This Primitive carries the HARQ Feedback from PHY to scheduler + * @details HARQ feedback is sent by the UE to the eNodeB, an ACK is sent if UE + * could successfully recieve the data transmitted by the eNodeB, else a NACK is + * sent. This feedback is utilized by MAC for further scheduling, for instance + * it could schedule an adaptive retransmission of the same data. + * @param pst + * @param spId + * @param tfuHqInd pointer to TfuHqIndInfo + * @return +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuHqInd +( +TfuHqInd func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuHqInd(func, pst, mBuf) +TfuHqInd func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SpId spId; + TfuHqIndInfo *hqInd; + + TRC3(cmUnpkTfuHqInd) + + if (SUnpkS16(&spId, mBuf) != ROK) { + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU052, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector != TFU_SEL_LWLC) { + Mem sMem; + sMem.region = pst->region; + sMem.pool = pst->pool; + if ((cmAllocEvnt(sizeof(TfuHqIndInfo), TFU_BLKSZ, &sMem, (Ptr *)&hqInd)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU053, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + + + if (pst->selector == TFU_SEL_LC) + { + if (cmUnpkTfuHqIndInfo(hqInd, (Ptr)&hqInd->memCp, mBuf) != ROK) { + TFU_FREE_MEM(hqInd); + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU054, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + } + else if(pst->selector == TFU_SEL_LWLC) + { + if (cmUnpkPtr((PTR *)&hqInd, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFUXXX, (ErrVal)0, "LWLC un-Packing failed"); +#endif + TFU_FREE_MEM(hqInd); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + TFU_FREE_MSG(mBuf); + RETVALUE((*func)(pst, spId, hqInd)); +} + + +/*********************************************************** +* +* Func : cmPkTfuSrInd +* +* +* Desc : This Primitive carries the SR Indication from PHY to scheduler. + * @details Scheduling Request (SR) is sent by the UE to the eNodeB to request + * for Uplink (UL) grant. This primitive carries a list of SRs for a number of + * UEs received in the indicated subframe. + * @param pst + * @param spId + * @param tfqSrInd pointer to TfuSrIndInfo + * @return +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuSrInd +( +Pst * pst, +SpId spId, +TfuSrIndInfo * srInd +) +#else +PUBLIC S16 cmPkTfuSrInd(pst, spId, srInd) +Pst * pst; +SpId spId; +TfuSrIndInfo * srInd; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkTfuSrInd) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU055, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(srInd); + RETVALUE(RFAILED); + } + if (pst->selector == TFU_SEL_LC) { + if (cmPkTfuSrIndInfo(srInd, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU056, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(srInd); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + else if(pst->selector == TFU_SEL_LWLC) + { + if (cmPkPtr((PTR)srInd, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFUXXX, (ErrVal)0, "LWLC Packing failed"); +#endif + TFU_FREE_MEM(srInd); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU057, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(srInd); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + if (pst->selector != TFU_SEL_LWLC) { + TFU_FREE_MEM(srInd); + } + + pst->event = (Event) EVTTFUSRIND; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/*********************************************************** +* +* Func : cmUnpkTfuSrInd +* +* +* Desc : This Primitive carries the SR Indication from PHY to scheduler. + * @details Scheduling Request (SR) is sent by the UE to the eNodeB to request + * for Uplink (UL) grant. This primitive carries a list of SRs for a number of + * UEs received in the indicated subframe. + * @param pst + * @param spId + * @param tfqSrInd pointer to TfuSrIndInfo + * @return +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuSrInd +( +TfuSrInd func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuSrInd(func, pst, mBuf) +TfuSrInd func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SpId spId; + TfuSrIndInfo *srInd; + + TRC3(cmUnpkTfuSrInd) + + if (SUnpkS16(&spId, mBuf) != ROK) { + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU058, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector != TFU_SEL_LWLC) { + Mem sMem; + sMem.region = pst->region; + sMem.pool = pst->pool; + if ((cmAllocEvnt(sizeof(TfuSrIndInfo), TFU_BLKSZ, &sMem, (Ptr *)&srInd)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU059, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + + + if (pst->selector == TFU_SEL_LC) + { + if (cmUnpkTfuSrIndInfo(srInd, (Ptr)&srInd->memCp, mBuf) != ROK) { + TFU_FREE_MEM(srInd); + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU060, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + } + else if(pst->selector == TFU_SEL_LWLC) + { + if (cmUnpkPtr((PTR *)&srInd, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFUXXX, (ErrVal)0, "LWLC un-Packing failed"); +#endif + TFU_FREE_MEM(srInd); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + TFU_FREE_MSG(mBuf); + RETVALUE((*func)(pst, spId, srInd)); +} + + +/*********************************************************** +* +* Func : cmPkTfuDlCqiInd +* +* +* Desc : This API is used to indicate the reception of CQI report from PHY to + * Scheduler, also carries the RI. + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service user. + * @param dlCqiInd Pointer to the TfuDlCqiIndInfo structure. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDlCqiInd +( +Pst * pst, +SuId suId, +TfuDlCqiIndInfo * dlCqiInd +) +#else +PUBLIC S16 cmPkTfuDlCqiInd(pst, suId, dlCqiInd) +Pst * pst; +SuId suId; +TfuDlCqiIndInfo * dlCqiInd; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkTfuDlCqiInd) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU061, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(dlCqiInd); + RETVALUE(RFAILED); + } + if (pst->selector == TFU_SEL_LC) { + if (cmPkTfuDlCqiIndInfo(dlCqiInd, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU062, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(dlCqiInd); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + else if(pst->selector == TFU_SEL_LWLC) + { + if (cmPkPtr((PTR)dlCqiInd, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFUXXX, (ErrVal)0, "LWLC Packing failed"); +#endif + TFU_FREE_MEM(dlCqiInd); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU063, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(dlCqiInd); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + if (pst->selector != TFU_SEL_LWLC) { + TFU_FREE_MEM(dlCqiInd); + } + pst->event = (Event) EVTTFUDLCQIIND; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/*********************************************************** +* +* Func : cmUnpkTfuDlCqiInd +* +* +* Desc : This API is used to indicate the reception of CQI report from PHY to + * Scheduler, also carries the RI. + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service user. + * @param dlCqiInd Pointer to the TfuDlCqiIndInfo structure. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDlCqiInd +( +TfuDlCqiInd func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDlCqiInd(func, pst, mBuf) +TfuDlCqiInd func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + TfuDlCqiIndInfo *dlCqiInd; + + TRC3(cmUnpkTfuDlCqiInd) + + if (SUnpkS16(&suId, mBuf) != ROK) { + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU064, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector != TFU_SEL_LWLC) { + Mem sMem; + sMem.region = pst->region; + sMem.pool = pst->pool; + if ((cmAllocEvnt(sizeof(TfuDlCqiIndInfo), TFU_BLKSZ, &sMem, (Ptr *)&dlCqiInd)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU065, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + + + if (pst->selector == TFU_SEL_LC) + { + if (cmUnpkTfuDlCqiIndInfo(dlCqiInd, (Ptr)&dlCqiInd->memCp, mBuf) != ROK) { + TFU_FREE_MEM(dlCqiInd); + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU066, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + } + else if(pst->selector == TFU_SEL_LWLC) + { + if (cmUnpkPtr((PTR *)&dlCqiInd, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFUXXX, (ErrVal)0, "LWLC un-Packing failed"); +#endif + TFU_FREE_MEM(dlCqiInd); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + TFU_FREE_MSG(mBuf); + RETVALUE((*func)(pst, suId, dlCqiInd)); +} + + +#ifdef TFU_UPGRADE + + +/*********************************************************** +* +* Func : cmPkTfuRawCqiInd +* +* +* Desc : This Primitive is used to convey the Raw CQI information + * transmitted by the UE. + * @details Raw CQI report is the actual bits transmitted by the UE when + * reporting CQI/PMI/RI. The interpretation of these bits to CQI/subband CQI + * etc. shall be done by MAC. + * + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service user. + * @param cqiInd Pointer to the TfuRawCqiIndInfo structure. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuRawCqiInd +( +Pst * pst, +SuId suId, +TfuRawCqiIndInfo * rawCqiInd +) +#else +PUBLIC S16 cmPkTfuRawCqiInd(pst, suId, rawCqiInd) +Pst * pst; +SuId suId; +TfuRawCqiIndInfo * rawCqiInd; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkTfuRawCqiInd) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU067, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(rawCqiInd); + RETVALUE(RFAILED); + } + cmPkTfuRawCqiIndInfo(rawCqiInd, mBuf); + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU068, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(rawCqiInd); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + TFU_FREE_MEM(rawCqiInd); + pst->event = (Event) EVTTFURAWCQIIND; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/*********************************************************** +* +* Func : cmUnpkTfuRawCqiInd +* +* +* Desc : This Primitive is used to convey the Raw CQI information + * transmitted by the UE. + * @details Raw CQI report is the actual bits transmitted by the UE when + * reporting CQI/PMI/RI. The interpretation of these bits to CQI/subband CQI + * etc. shall be done by MAC. + * + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service user. + * @param cqiInd Pointer to the TfuRawCqiIndInfo structure. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuRawCqiInd +( +TfuRawCqiInd func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuRawCqiInd(func, pst, mBuf) +TfuRawCqiInd func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + TfuRawCqiIndInfo *rawCqiInd; + + TRC3(cmUnpkTfuRawCqiInd) + + if (SUnpkS16(&suId, mBuf) != ROK) { + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU069, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + { + Mem sMem; + sMem.region = pst->region; + sMem.pool = pst->pool; + if ((cmAllocEvnt(sizeof(TfuRawCqiIndInfo), TFU_BLKSZ, &sMem, (Ptr *)&rawCqiInd)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU070, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + cmUnpkTfuRawCqiIndInfo(rawCqiInd, (Ptr)&rawCqiInd->memCp, mBuf); + TFU_FREE_MSG(mBuf); + RETVALUE((*func)(pst, suId, rawCqiInd)); +} + + +/*********************************************************** +* +* Func : cmPkTfuSrsInd +* +* +* Desc : This Primitive is used to convey the information derived by the + * physical layer from the SRS transmission from the UE. + * @details This primitive carries information derived from the SRS transmission + * from the UE. + * + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service user. + * @param srsInd Pointer to the TfuSrIndInfo structure. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuSrsInd +( +Pst * pst, +SuId suId, +TfuSrsIndInfo * srsInd +) +#else +PUBLIC S16 cmPkTfuSrsInd(pst, suId, srsInd) +Pst * pst; +SuId suId; +TfuSrsIndInfo * srsInd; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkTfuSrsInd) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU071, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(srsInd); + RETVALUE(RFAILED); + } + cmPkTfuSrsIndInfo(srsInd, mBuf); + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU072, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(srsInd); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + TFU_FREE_MEM(srsInd); + pst->event = (Event) EVTTFUSRSIND; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/*********************************************************** +* +* Func : cmUnpkTfuSrsInd +* +* +* Desc : This Primitive is used to convey the information derived by the + * physical layer from the SRS transmission from the UE. + * @details This primitive carries information derived from the SRS transmission + * from the UE. + * + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service user. + * @param srsInd Pointer to the TfuSrIndInfo structure. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuSrsInd +( +TfuSrsInd func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuSrsInd(func, pst, mBuf) +TfuSrsInd func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + TfuSrsIndInfo *srsInd; + + TRC3(cmUnpkTfuSrsInd) + + if (SUnpkS16(&suId, mBuf) != ROK) { + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU073, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + { + Mem sMem; + sMem.region = pst->region; + sMem.pool = pst->pool; + if ((cmAllocEvnt(sizeof(TfuSrsIndInfo), TFU_BLKSZ, &sMem, (Ptr *)&srsInd)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU074, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + cmUnpkTfuSrsIndInfo(srsInd, (Ptr)&srsInd->memCp, mBuf); + TFU_FREE_MSG(mBuf); + RETVALUE((*func)(pst, suId, srsInd)); +} +#endif + + + +/*********************************************************** +* +* Func : cmPkTfuDatInd +* +* +* Desc : This Primitive carries the Data PDUs from PHY to MAC. + * @details The uplink Data i.e. the data transmitted by the UEs received by the + * physical layer at the eNodeB in the subframe (indicated by the timingInfo), + * is relayed to MAC using this primitive. + * @param pst + * @param spId + * @param tfuDatInd pointer to TfuDatIndInfo + * @return +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDatInd +( +Pst * pst, +SpId spId, +TfuDatIndInfo * datInd +) +#else +PUBLIC S16 cmPkTfuDatInd(pst, spId, datInd) +Pst * pst; +SpId spId; +TfuDatIndInfo * datInd; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkTfuDatInd) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU075, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(datInd); + RETVALUE(RFAILED); + } + if (pst->selector == TFU_SEL_LC) { + if (cmPkTfuDatIndInfo(datInd, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU076, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(datInd); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + else if(pst->selector == TFU_SEL_LWLC) + { + if(cmPkPtr((PTR)datInd, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFUXXX, (ErrVal)0, "LWLC Packing failed"); +#endif + TFU_FREE_MEM(datInd); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU077, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(datInd); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + if (pst->selector != TFU_SEL_LWLC) { + TFU_FREE_MEM(datInd); + } + + pst->event = (Event) EVTTFUDATIND; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/*********************************************************** +* +* Func : cmUnpkTfuDatInd +* +* +* Desc : This Primitive carries the Data PDUs from PHY to MAC. + * @details The uplink Data i.e. the data transmitted by the UEs received by the + * physical layer at the eNodeB in the subframe (indicated by the timingInfo), + * is relayed to MAC using this primitive. + * @param pst + * @param spId + * @param tfuDatInd pointer to TfuDatIndInfo + * @return +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDatInd +( +TfuDatInd func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDatInd(func, pst, mBuf) +TfuDatInd func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SpId spId; + TfuDatIndInfo *datInd; + + TRC3(cmUnpkTfuDatInd) + + if (SUnpkS16(&spId, mBuf) != ROK) { + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU078, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector != TFU_SEL_LWLC) { + Mem sMem; + sMem.region = pst->region; + sMem.pool = pst->pool; + if ((cmAllocEvnt(sizeof(TfuDatIndInfo), TFU_BLKSZ, &sMem, (Ptr *)&datInd)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU079, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + + + if (pst->selector == TFU_SEL_LC) + { + if (cmUnpkTfuDatIndInfo(datInd, (Ptr)&datInd->memCp, mBuf) != ROK) { + TFU_FREE_MEM(datInd); + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU080, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + } + else if(pst->selector == TFU_SEL_LWLC) + { + if(cmUnpkPtr((PTR *)&datInd, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFUXXX, (ErrVal)0, "LWLC un-Packing failed"); +#endif + TFU_FREE_MEM(datInd); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + TFU_FREE_MSG(mBuf); + RETVALUE((*func)(pst, spId, datInd)); +} + + +/*********************************************************** +* +* Func : cmPkTfuCrcInd +* +* +* Desc : This API is used by the Physical layer to indicate if the CRC Check + * on the PUSCH Data was successful or not. + * @details This primitive carries CRC indication for a list of UEs. This + * is utilized in the scenario where MAC requested the reception of uplink data + * for a particular UE. On reception of the PUSCH data, the CRC check on it + * failed. This CRC failure is indicated to MAC, which would utillize this + * information for further scheduling. + * Physical layer would indicate failure or success for each PUSCH transmission. + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service user. + * @param crcInd Pointer to the TfuCrcIndInfo. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuCrcInd +( +Pst * pst, +SuId suId, +TfuCrcIndInfo * crcIndInfo +) +#else +PUBLIC S16 cmPkTfuCrcInd(pst, suId, crcIndInfo) +Pst * pst; +SuId suId; +TfuCrcIndInfo * crcIndInfo; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkTfuCrcInd) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU081, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(crcIndInfo); + RETVALUE(RFAILED); + } + if (pst->selector == TFU_SEL_LC) { + if (cmPkTfuCrcIndInfo(crcIndInfo, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU082, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(crcIndInfo); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + else if(pst->selector == TFU_SEL_LWLC) + { + if (cmPkPtr((PTR)crcIndInfo, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFUXXX, (ErrVal)0, "LWLC Packing failed"); +#endif + TFU_FREE_MEM(crcIndInfo); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + + + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU083, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(crcIndInfo); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + if (pst->selector != TFU_SEL_LWLC) { + TFU_FREE_MEM(crcIndInfo); + } + + pst->event = (Event) EVTTFUCRCIND; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/*********************************************************** +* +* Func : cmUnpkTfuCrcInd +* +* +* Desc : This API is used by the Physical layer to indicate if the CRC Check + * on the PUSCH Data was successful or not. + * @details This primitive carries CRC indication for a list of UEs. This + * is utilized in the scenario where MAC requested the reception of uplink data + * for a particular UE. On reception of the PUSCH data, the CRC check on it + * failed. This CRC failure is indicated to MAC, which would utillize this + * information for further scheduling. + * Physical layer would indicate failure or success for each PUSCH transmission. + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service user. + * @param crcInd Pointer to the TfuCrcIndInfo. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuCrcInd +( +TfuCrcInd func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuCrcInd(func, pst, mBuf) +TfuCrcInd func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + TfuCrcIndInfo *crcIndInfo; + + TRC3(cmUnpkTfuCrcInd) + + if (SUnpkS16(&suId, mBuf) != ROK) { + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU084, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector != TFU_SEL_LWLC) { + Mem sMem; + sMem.region = pst->region; + sMem.pool = pst->pool; + if ((cmAllocEvnt(sizeof(TfuCrcIndInfo), TFU_BLKSZ, &sMem, (Ptr *)&crcIndInfo)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU085, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + + + if (pst->selector == TFU_SEL_LC) + { + if (cmUnpkTfuCrcIndInfo(crcIndInfo, (Ptr)&crcIndInfo->memCp, mBuf) != ROK) { + TFU_FREE_MEM(crcIndInfo); + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU086, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + } + else if(pst->selector == TFU_SEL_LWLC) + { + if (cmUnpkPtr((PTR *)&crcIndInfo, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFUXXX, (ErrVal)0, "LWLC un-Packing failed"); +#endif + TFU_FREE_MEM(crcIndInfo); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + TFU_FREE_MSG(mBuf); + RETVALUE((*func)(pst, suId, crcIndInfo)); +} + + +/*********************************************************** +* +* Func : cmPkTfuTimingAdvInd +* +* +* Desc : This API is used to indicate a Timing Advance from PHY to Scheduler . + * @details This primitive carries timing advance information for a number of + * UEs that may need timing advance. Timing advance information is an estimate + * of the timing adjustment that a UE would need to apply in order to be + * synchronized in uplink. This estimate is to be calculated by physical layer. + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service user. + * @param timingAdvInd Pointer to the TfuTimingAdvIndInfo structure. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuTimingAdvInd +( +Pst * pst, +SuId suId, +TfuTimingAdvIndInfo * timingAdvInd +) +#else +PUBLIC S16 cmPkTfuTimingAdvInd(pst, suId, timingAdvInd) +Pst * pst; +SuId suId; +TfuTimingAdvIndInfo * timingAdvInd; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkTfuTimingAdvInd) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU087, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(timingAdvInd); + RETVALUE(RFAILED); + } + if (pst->selector == TFU_SEL_LC) { + if (cmPkTfuTimingAdvIndInfo(timingAdvInd, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU088, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(timingAdvInd); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + else if(pst->selector == TFU_SEL_LWLC) + { + if (cmPkPtr((PTR)timingAdvInd, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFUXXX, (ErrVal)0, "LWLC Packing failed"); +#endif + TFU_FREE_MEM(timingAdvInd); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU089, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(timingAdvInd); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + if (pst->selector != TFU_SEL_LWLC) { + TFU_FREE_MEM(timingAdvInd); + } + + pst->event = (Event) EVTTFUTIMINGADVIND; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/*********************************************************** +* +* Func : cmUnpkTfuTimingAdvInd +* +* +* Desc : This API is used to indicate a Timing Advance from PHY to Scheduler . + * @details This primitive carries timing advance information for a number of + * UEs that may need timing advance. Timing advance information is an estimate + * of the timing adjustment that a UE would need to apply in order to be + * synchronized in uplink. This estimate is to be calculated by physical layer. + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service user. + * @param timingAdvInd Pointer to the TfuTimingAdvIndInfo structure. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuTimingAdvInd +( +TfuTimingAdvInd func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuTimingAdvInd(func, pst, mBuf) +TfuTimingAdvInd func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + TfuTimingAdvIndInfo *timingAdvInd; + + TRC3(cmUnpkTfuTimingAdvInd) + + if (SUnpkS16(&suId, mBuf) != ROK) { + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU090, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector != TFU_SEL_LWLC) { + Mem sMem; + sMem.region = pst->region; + sMem.pool = pst->pool; + if ((cmAllocEvnt(sizeof(TfuTimingAdvIndInfo), TFU_BLKSZ, &sMem, (Ptr *)&timingAdvInd)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU091, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + + + if (pst->selector == TFU_SEL_LC) + { + if (cmUnpkTfuTimingAdvIndInfo(timingAdvInd, (Ptr)&timingAdvInd->memCp, mBuf) != ROK) { + TFU_FREE_MEM(timingAdvInd); + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU092, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + } + else if(pst->selector == TFU_SEL_LWLC) + { + if (cmUnpkPtr((PTR *)&timingAdvInd, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFUXXX, (ErrVal)0, "LWLC un-Packing failed"); +#endif + TFU_FREE_MEM(timingAdvInd); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + TFU_FREE_MSG(mBuf); + RETVALUE((*func)(pst, suId, timingAdvInd)); +} + + +/*********************************************************** +* +* Func : cmPkTfuDatReq +* +* +* Desc : This Primitive carries the Data PDUs from MAC to PHY for + * transmission. + * @details The data being sent in this primitive is meant to be transmitted on + * the downlink channel PDSCH and PBCH (if present). To facilitate physical + * layer processing, requisite control information is also sent along with the + * data. + * @sa TfUiTfuCntrlReq + * @param pst + * @param spId + * @param tfuDatReq pointer to TfuDatReqInfo + * @return +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDatReq +( +Pst * pst, +SpId spId, +TfuDatReqInfo * datReq +) +#else +PUBLIC S16 cmPkTfuDatReq(pst, spId, datReq) +Pst * pst; +SpId spId; +TfuDatReqInfo * datReq; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkTfuDatReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU093, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(datReq); + RETVALUE(RFAILED); + } + if (pst->selector == TFU_SEL_LC) { + if (cmPkTfuDatReqInfo(datReq, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU094, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(datReq); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + else if(pst->selector == TFU_SEL_LWLC) + { + if(cmPkPtr((PTR)datReq, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFUXXX, (ErrVal)0, "LWLC Packing failed"); +#endif + TFU_FREE_MEM(datReq); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU095, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(datReq); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + if (pst->selector != TFU_SEL_LWLC) { + TFU_FREE_MEM(datReq); + } + + pst->event = (Event) EVTTFUDATREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/*********************************************************** +* +* Func : cmUnpkTfuDatReq +* +* +* Desc : This Primitive carries the Data PDUs from MAC to PHY for + * transmission. + * @details The data being sent in this primitive is meant to be transmitted on + * the downlink channel PDSCH and PBCH (if present). To facilitate physical + * layer processing, requisite control information is also sent along with the + * data. + * @sa TfUiTfuCntrlReq + * @param pst + * @param spId + * @param tfuDatReq pointer to TfuDatReqInfo + * @return +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDatReq +( +TfuDatReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDatReq(func, pst, mBuf) +TfuDatReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SpId spId; + TfuDatReqInfo *datReq; + + TRC3(cmUnpkTfuDatReq) + + if (SUnpkS16(&spId, mBuf) != ROK) { + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU096, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector != TFU_SEL_LWLC) { + Mem sMem; + sMem.region = pst->region; + sMem.pool = pst->pool; + if ((cmAllocEvnt(sizeof(TfuDatReqInfo), TFU_BLKSZ, &sMem, (Ptr *)&datReq)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU097, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + + + if (pst->selector == TFU_SEL_LC) + { + if (cmUnpkTfuDatReqInfo(datReq, (Ptr)&datReq->memCp, mBuf) != ROK) { + TFU_FREE_MEM(datReq); + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU098, (ErrVal)0, "Unpacking failed"); +#endif + RETVALUE(RFAILED); + } + } + else if (pst->selector == TFU_SEL_LWLC) + { + if(cmUnpkPtr((PTR *)&datReq, mBuf) != ROK) + { + TFU_FREE_MEM(datReq); + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFUXXX, (ErrVal)0, "LWLC Un-Packing failed"); +#endif + RETVALUE(RFAILED); + } + } + TFU_FREE_MSG(mBuf); + RETVALUE((*func)(pst, spId, datReq)); +} + + +/*********************************************************** +* +* Func : cmPkTfuCntrlReq +* +* +* Desc : This Primitive is sent from Scheduler to PHY. It provides PHY with + * all the control information + * @details This primitive carries the information sent on the following + * channels - + * -# PDCCH + * -# PHICH + * -# PCFICH + * + * @param pst + * @param spId + * @param cntrlReq pointer to TfuCntrlReqInfo + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuCntrlReq +( +Pst * pst, +SpId spId, +TfuCntrlReqInfo * cntrlReq +) +#else +PUBLIC S16 cmPkTfuCntrlReq(pst, spId, cntrlReq) +Pst * pst; +SpId spId; +TfuCntrlReqInfo * cntrlReq; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkTfuCntrlReq) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU099, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(cntrlReq); + RETVALUE(RFAILED); + } + if (pst->selector == TFU_SEL_LC) { + if (cmPkTfuCntrlReqInfo(cntrlReq, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU100, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(cntrlReq); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + else if(pst->selector == TFU_SEL_LWLC) + { + if (cmPkPtr((PTR)cntrlReq, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFUXXX, (ErrVal)0, "LWLC Packing failed"); +#endif + TFU_FREE_MEM(cntrlReq); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + + + if (SPkS16(spId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU101, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(cntrlReq); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + if (pst->selector != TFU_SEL_LWLC) { + TFU_FREE_MEM(cntrlReq); + } + + pst->event = (Event) EVTTFUCNTRLREQ; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/*********************************************************** +* +* Func : cmUnpkTfuCntrlReq +* +* +* Desc : This Primitive is sent from Scheduler to PHY. It provides PHY with + * all the control information + * @details This primitive carries the information sent on the following + * channels - + * -# PDCCH + * -# PHICH + * -# PCFICH + * + * @param pst + * @param spId + * @param cntrlReq pointer to TfuCntrlReqInfo + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuCntrlReq +( +TfuCntrlReq func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuCntrlReq(func, pst, mBuf) +TfuCntrlReq func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SpId spId; + TfuCntrlReqInfo *cntrlReq; + + TRC3(cmUnpkTfuCntrlReq) + + if (SUnpkS16(&spId, mBuf) != ROK) { + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU102, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector != TFU_SEL_LWLC) { + Mem sMem; + sMem.region = pst->region; + sMem.pool = pst->pool; + if ((cmAllocEvnt(sizeof(TfuCntrlReqInfo), TFU_BLKSZ, &sMem, (Ptr *)&cntrlReq)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU103, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + + + if (pst->selector == TFU_SEL_LC) + { + if (cmUnpkTfuCntrlReqInfo(cntrlReq, (Ptr)&cntrlReq->memCp, mBuf) != ROK) { + TFU_FREE_MEM(cntrlReq); + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU104, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + } + else if(pst->selector == TFU_SEL_LWLC) + { + if (cmUnpkPtr((PTR *)&cntrlReq, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFUXXX, (ErrVal)0, "LWLC un-Packing failed"); +#endif + TFU_FREE_MEM(cntrlReq); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + TFU_FREE_MSG(mBuf); + RETVALUE((*func)(pst, spId, cntrlReq)); +} + + + +/*********************************************************** +* +* Func : cmPkTfuTtiInd +* +* +* Desc : This API is the TTI indication from PHY to MAC . + * @details This primitive provides the timing information (SFN and subframe) + * which is currently running on the physical layer. + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service user. + * @param ttiInd Pointer to the TfuTtiIndInfo. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuTtiInd +( +Pst * pst, +SuId suId, +TfuTtiIndInfo * ttiInd +) +#else +PUBLIC S16 cmPkTfuTtiInd(pst, suId, ttiInd) +Pst * pst; +SuId suId; +TfuTtiIndInfo * ttiInd; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkTfuTtiInd) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU105, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)ttiInd, sizeof(TfuTtiIndInfo)); + RETVALUE(RFAILED); + } + if (pst->selector == TFU_SEL_LC) { + if (cmPkTfuTtiIndInfo(ttiInd, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU106, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)ttiInd, sizeof(TfuTtiIndInfo)); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + else if(pst->selector == TFU_SEL_LWLC) + { + if (cmPkPtr((PTR)ttiInd, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFUXXX, (ErrVal)0, "LWLC Packing failed"); +#endif + + /*MS_FIX:71858:Changed to SPutSBuf as being allocated with SGetSBuf*/ + SPutSBuf(pst->region, pst->pool, (Data *)ttiInd, sizeof(TfuTtiIndInfo)); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU107, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)ttiInd, sizeof(TfuTtiIndInfo)); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + if (pst->selector != TFU_SEL_LWLC) { + if (SPutSBuf(pst->region, pst->pool, (Data *)ttiInd, sizeof(TfuTtiIndInfo)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU108, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + + pst->event = (Event) EVTTFUTTIIND; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/*********************************************************** +* +* Func : cmUnpkTfuTtiInd +* +* +* Desc : This API is the TTI indication from PHY to MAC . + * @details This primitive provides the timing information (SFN and subframe) + * which is currently running on the physical layer. + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service user. + * @param ttiInd Pointer to the TfuTtiIndInfo. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuTtiInd +( +TfuTtiInd func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuTtiInd(func, pst, mBuf) +TfuTtiInd func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + TfuTtiIndInfo *ttiInd; + + TRC3(cmUnpkTfuTtiInd) + + if (SUnpkS16(&suId, mBuf) != ROK) { + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU109, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector != TFU_SEL_LWLC) { + if ((SGetSBuf(pst->region, pst->pool, (Data **)&ttiInd, sizeof(TfuTtiIndInfo))) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU110, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + + if (pst->selector == TFU_SEL_LC) + { + if (cmUnpkTfuTtiIndInfo(ttiInd, mBuf) != ROK) { + SPutSBuf(pst->region, pst->pool, (Data *)ttiInd, sizeof(TfuTtiIndInfo)); + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU111, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + } + else if(pst->selector == TFU_SEL_LWLC) + { + if (cmUnpkPtr((PTR *)&ttiInd, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFUXXX, (ErrVal)0, "LWLC un-Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)ttiInd, sizeof(TfuTtiIndInfo)); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + TFU_FREE_MSG(mBuf); + /* [ccpu00141698]-MOD- MAC/SCH does not free the TTI ind anymore */ + (*func)(pst, suId, ttiInd); + SPutSBuf(pst->region, pst->pool, (Data *)ttiInd, sizeof(TfuTtiIndInfo)); + + RETVALUE((*func)(pst, suId, ttiInd)); +} + +#if defined(TENB_T2K3K_SPECIFIC_CHANGES) && defined(LTE_TDD) +/*********************************************************** + * + * Func : cmPkTfuNonRtInd + * + * + * Desc : This API is the Non-Rt indication from CL to MAC . + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service user. + * @return ROK/RFAILED + * + * + * Ret : S16 + * + * Notes: + * + * File : + * +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuNonRtInd +( +Pst * pst, +SuId suId +) +#else +PUBLIC S16 cmPkTfuNonRtInd(pst, suId) +Pst * pst; +SuId suId; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkTfuNonRtInd) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU105, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU107, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + pst->event = (Event) EVTTFUNONRTIND; + RETVALUE(SPstTsk(pst,mBuf)); +} + +/*********************************************************** +* +* Func : cmUnpkTfuNonRtInd +* +* +* Desc : This API is the Non Rt indication from PHY to MAC . +* @param pst Pointer to the post structure. +* @param suId SAP ID of the service user. +* @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuNonRtInd +( +TfuNonRtInd func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuNonRtInd(func, pst, mBuf) +TfuNonRtInd func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + TRC3(cmUnpkTfuNonRtInd) + + if (SUnpkS16(&suId, mBuf) != ROK) { + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU109, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + TFU_FREE_MSG(mBuf); + RETVALUE((*func)(pst, suId)); +} + +#endif + +/*********************************************************** +* +* Func : cmPkTfuSchTtiInd +* +* +* Desc : This API is the TTI indication from PHY to scheduler. + * @details This primitive provides the timing information (SFN and subframe) + * which is currently running on the physical layer. + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service user. + * @param ttiInd Pointer to the TfuTtiIndInfo. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuSchTtiInd +( +Pst * pst, +SuId suId, +TfuTtiIndInfo * ttiInd +) +#else +PUBLIC S16 cmPkTfuSchTtiInd(pst, suId, ttiInd) +Pst * pst; +SuId suId; +TfuTtiIndInfo * ttiInd; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkTfuSchTtiInd) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU112, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)ttiInd, sizeof(TfuTtiIndInfo)); + RETVALUE(RFAILED); + } + if (pst->selector == TFU_SEL_LC) { + if (cmPkTfuTtiIndInfo(ttiInd, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU113, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)ttiInd, sizeof(TfuTtiIndInfo)); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + else if(pst->selector == TFU_SEL_LWLC) + { + if (cmPkPtr((PTR)ttiInd, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFUXXX, (ErrVal)0, "LWLC Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)ttiInd, sizeof(TfuTtiIndInfo)); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU114, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)ttiInd, sizeof(TfuTtiIndInfo)); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + if (pst->selector != TFU_SEL_LWLC) { + if (SPutSBuf(pst->region, pst->pool, (Data *)ttiInd, sizeof(TfuTtiIndInfo)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU115, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + pst->event = (Event) EVTTFUSCHTTIIND; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/*********************************************************** +* +* Func : cmUnpkTfuSchTtiInd +* +* +* Desc : This API is the TTI indication from PHY to scheduler. + * @details This primitive provides the timing information (SFN and subframe) + * which is currently running on the physical layer. + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service user. + * @param ttiInd Pointer to the TfuTtiIndInfo. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuSchTtiInd +( +TfuSchTtiInd func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuSchTtiInd(func, pst, mBuf) +TfuSchTtiInd func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + TfuTtiIndInfo *ttiInd; + + TRC3(cmUnpkTfuSchTtiInd) + + if (SUnpkS16(&suId, mBuf) != ROK) { + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU116, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector != TFU_SEL_LWLC) { + if ((SGetSBuf(pst->region, pst->pool, (Data **)&ttiInd, sizeof(TfuTtiIndInfo))) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU117, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + + if (pst->selector == TFU_SEL_LC) + { + if (cmUnpkTfuTtiIndInfo(ttiInd, mBuf) != ROK) { + SPutSBuf(pst->region, pst->pool, (Data *)ttiInd, sizeof(TfuTtiIndInfo)); + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU118, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + } + else if(pst->selector == TFU_SEL_LWLC) + { + if (cmUnpkPtr((PTR *)&ttiInd, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFUXXX, (ErrVal)0, "LWLC un-Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)ttiInd, sizeof(TfuTtiIndInfo)); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + TFU_FREE_MSG(mBuf); + /* [ccpu00141698]-MOD- MAC/SCH does not free the TTI ind anymore */ + (*func)(pst, suId, ttiInd); + SPutSBuf(pst->region, pst->pool, (Data *)ttiInd, sizeof(TfuTtiIndInfo)); + + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func : cmPkTfuPucchDeltaPwr +* +* +* Desc : This Primitive is used to convey PUCCH Delta power calculated by the + * Physical layer. + * This information is utilized by Scheduler for power control. + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service user. + * @param Pointer to the TfuPucchDeltaPwrIndInfo structure. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuPucchDeltaPwr +( +Pst * pst, +SuId suId, +TfuPucchDeltaPwrIndInfo * pucchDeltaPwr +) +#else +PUBLIC S16 cmPkTfuPucchDeltaPwr(pst, suId, pucchDeltaPwr) +Pst * pst; +SuId suId; +TfuPucchDeltaPwrIndInfo * pucchDeltaPwr; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkTfuPucchDeltaPwr) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU119, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)pucchDeltaPwr, sizeof(TfuPucchDeltaPwrIndInfo)); + RETVALUE(RFAILED); + } + if (pst->selector == TFU_SEL_LC) { + if (cmPkTfuPucchDeltaPwrIndInfo(pucchDeltaPwr, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU120, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(pucchDeltaPwr); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + else if(pst->selector == TFU_SEL_LWLC) + { + if (cmPkPtr((PTR)pucchDeltaPwr, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFUXXX, (ErrVal)0, "LWLC Packing failed"); +#endif + TFU_FREE_MEM(pucchDeltaPwr); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU121, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(pucchDeltaPwr); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + if (pst->selector != TFU_SEL_LWLC) { + TFU_FREE_MEM(pucchDeltaPwr); + } + pst->event = (Event) EVTTFUPUCCHDELPWR; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/*********************************************************** +* +* Func : cmUnpkTfuPucchDeltaPwr +* +* +* Desc : This Primitive is used to convey PUCCH Delta power calculated by the + * Physical layer. + * This information is utilized by Scheduler for power control. + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service user. + * @param Pointer to the TfuPucchDeltaPwrIndInfo structure. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuPucchDeltaPwr +( +TfuPucchDeltaPwrInd func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuPucchDeltaPwr(func, pst, mBuf) +TfuPucchDeltaPwrInd func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + TfuPucchDeltaPwrIndInfo *pucchDeltaPwr; + + TRC3(cmUnpkTfuPucchDeltaPwr) + + if (SUnpkS16(&suId, mBuf) != ROK) { + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU122, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector != TFU_SEL_LWLC) { + Mem sMem; + sMem.region = pst->region; + sMem.pool = pst->pool; + if ((cmAllocEvnt(sizeof(TfuPucchDeltaPwrIndInfo), TFU_BLKSZ, &sMem, (Ptr *)&pucchDeltaPwr)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU123, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + + if (pst->selector == TFU_SEL_LC) + { + if (cmUnpkTfuPucchDeltaPwrIndInfo(pucchDeltaPwr, (Ptr)&pucchDeltaPwr->memCp, mBuf) != ROK) { + TFU_FREE_MEM(pucchDeltaPwr); + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU124, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + } + else if(pst->selector == TFU_SEL_LWLC) + { + if (cmUnpkPtr((PTR *)&pucchDeltaPwr, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFUXXX, (ErrVal)0, "LWLC un-Packing failed"); +#endif + TFU_FREE_MEM(pucchDeltaPwr); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + TFU_FREE_MSG(mBuf); + RETVALUE((*func)(pst, suId, pucchDeltaPwr)); +} + +#ifdef TFU_5GTF + +/*********************************************************** +* +* Func : cmPkTfuRbAssignA1Val324 +* +* +* Desc : This structure contains the information needed to convey RIV value 324. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuRbAssignA1Val324 +( +TfuRbAssignA1Val324 *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuRbAssignA1Val324(param, mBuf) +TfuRbAssignA1Val324 *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuRbAssignA1Val324) + + CMCHKPK(SPkU8, param->ndi, mBuf); + CMCHKPK(SPkU8, param->mcs, mBuf); + CMCHKPK(SPkU8, param->hqProcId, mBuf); +#ifdef UL_ADPT_DBG + printf("cmPkTfuRbAssignA1Val324 param->ndi %d mcs %d param->hqProcId %d \n",param->ndi,param->mcs,param->hqProcId); +#endif + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func : cmPkTfuRbAssignB1Val324 +* +* +* Desc : This structure contains the information needed to convey RIV value 324. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuRbAssignB1Val324 +( +TfuRbAssignB1Val324 *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuRbAssignB1Val324(param, mBuf) +TfuRbAssignB1Val324 *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuRbAssignB1Val324) + + CMCHKPK(SPkU8, param->bmiHqAckNack, mBuf); + CMCHKPK(SPkU8, param->RV, mBuf); + CMCHKPK(SPkU8, param->ndi, mBuf); + CMCHKPK(SPkU8, param->mcs, mBuf); + CMCHKPK(SPkU8, param->hqProcId, mBuf); + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func : cmPkTfuRbAssignVal326 +* +* +* Desc : This structure contains the information needed to convey RIV value 326. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuRbAssignVal326 +( +TfuRbAssignVal326 *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuRbAssignVal326(param, mBuf) +TfuRbAssignVal326 *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuRbAssignVal326) + + CMCHKPK(SPkU8, param->CyclicShiftInd, mBuf); + CMCHKPK(SPkU8, param->OCCInd, mBuf); + CMCHKPK(SPkU8, param->FreqBandIdx, mBuf); + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func : cmUnpkTfuRbAssignA1Val324 +* +* +* Desc : This structure contains the information needed to convey RIV value 324. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuRbAssignA1Val324 +( +TfuRbAssignA1Val324 *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuRbAssignA1Val324(param, mBuf) +TfuRbAssignA1Val324 *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuRbAssignA1Val324) + + CMCHKUNPK(SUnpkU8, ¶m->hqProcId, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->mcs, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->ndi, mBuf); + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func : cmUnpkTfuRbAssignB1Val324 +* +* +* Desc : This structure contains the information needed to convey RIV value 324. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuRbAssignB1Val324 +( +TfuRbAssignB1Val324 *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuRbAssignB1Val324(param, mBuf) +TfuRbAssignB1Val324 *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuRbAssignB1Val324) + + CMCHKUNPK(SUnpkU8, ¶m->hqProcId, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->mcs, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->ndi, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->RV, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->bmiHqAckNack, mBuf); + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func : cmUnpkTfuRbAssignVal326 +* +* +* Desc : This structure contains the information needed to convey RIV value 326. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuRbAssignVal326 +( +TfuRbAssignVal326 *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuRbAssignVal326(param, mBuf) +TfuRbAssignVal326 *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuRbAssignVal326) + + CMCHKUNPK(SUnpkU8, ¶m->FreqBandIdx, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->OCCInd, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->CyclicShiftInd, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuDciFormatA1A2Info +* +* +* Desc : This structure contains the information needed to convey DCI format A1/A2. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDciFormatA1A2Info +( +TfuDciFormatA1Info *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuDciFormatA1A2Info(param, mBuf) +TfuDciFormatA1Info *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuDciFormatA1A2Info) + + //printf("5GTF_DBG: cmPkTfuDciFormatA1Info() called by eNB\n"); + CMCHKPK(SPkU8, param->tpcCmd, mBuf); + CMCHKPK(SPkU8, param->UL_PCRS, mBuf); + CMCHKPK(SPkU8, param->PMI, mBuf); + CMCHKPK(SPkU8, param->SCID, mBuf); + + CMCHKPK(SPkU8, param->REMapIdx_DMRS_PCRS_numLayers, mBuf); + CMCHKPK(SPkU8, param->SRS_Symbol, mBuf); + CMCHKPK(SPkU8, param->SRS_Config, mBuf); + CMCHKPK(SPkU8, param->beamSwitch, mBuf); + CMCHKPK(SPkU8, param->uciOnxPUSCH, mBuf); + + CMCHKPK(SPkU8, param->numBSI_Reports, mBuf); + CMCHKPK(SPkU8, param->CSIRS_BRRS_ProcInd, mBuf); + CMCHKPK(SPkU8, param->CSI_BRRS_Indicator, mBuf); + CMCHKPK(SPkU8, param->CSIRS_BRRS_SymbIdx, mBuf); + CMCHKPK(SPkU8, param->CSIRS_BRRS_TxTiming, mBuf); + CMCHKPK(SPkU8, param->CSI_BSI_BRI_Req, mBuf); + + if(param->RBAssign <= TFU_RIV_324) + { + CMCHKPK(cmPkTfuRbAssignA1Val324, ¶m->u.rbAssignA1Val324, mBuf); + } + else if (param->RBAssign == TFU_RIV_326) + { + CMCHKPK(cmPkTfuRbAssignVal326, ¶m->u.rbAssignVal326, mBuf); + } + + CMCHKPK(SPkU8, param->rv, mBuf); + CMCHKPK(SPkU8, param->symbIdx, mBuf); + CMCHKPK(SPkU8, param->beamIndex, mBuf); + CMCHKPK(SPkU16, param->RBAssign, mBuf); + CMCHKPK(SPkU8, param->xPUSCH_TxTiming, mBuf); + CMCHKPK(SPkU8, param->xPUSCHRange, mBuf); + CMCHKPK(SPkU8, param->formatType, mBuf); + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func : cmPkTfuDciFormatB1B2Info +* +* +* Desc : This structure contains the information needed to convey DCI format B1/B2. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDciFormatB1B2Info +( +TfuDciFormatB1Info *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuDciFormatB1B2Info(param, mBuf) +TfuDciFormatB1Info *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuDciFormatB1B2Info) + + CMCHKPK(SPkU8, param->DL_PCRS, mBuf); + CMCHKPK(SPkU8, param->tpcCmd, mBuf); + CMCHKPK(SPkU8, param->SCID, mBuf); + + CMCHKPK(SPkU8, param->AntPorts_numLayers, mBuf); + CMCHKPK(SPkU8, param->SRS_Symbol, mBuf); + CMCHKPK(SPkU8, param->SRS_Config, mBuf); + CMCHKPK(SPkU8, param->beamSwitch, mBuf); + CMCHKPK(SPkU8, param->freqResIdx_xPUCCH, mBuf); + + CMCHKPK(SPkU8, param->xPUCCH_TxTiming, mBuf); + + CMCHKPK(SPkU8, param->numBSI_Reports, mBuf); + CMCHKPK(SPkU8, param->CSIRS_BRRS_ProcInd, mBuf); + CMCHKPK(SPkU8, param->CSI_BRRS_Indicator, mBuf); + CMCHKPK(SPkU8, param->CSIRS_BRRS_SymbIdx, mBuf); + CMCHKPK(SPkU8, param->CSIRS_BRRS_TxTiming, mBuf); + CMCHKPK(SPkU8, param->CSI_BSI_BRI_Req, mBuf); + + if(param->RBAssign <= TFU_RIV_324) + { + CMCHKPK(cmPkTfuRbAssignB1Val324, ¶m->u.rbAssignB1Val324, mBuf); + } + else if (param->RBAssign == TFU_RIV_326) + { + CMCHKPK(cmPkTfuRbAssignVal326, ¶m->u.rbAssignVal326, mBuf); + } + + CMCHKPK(SPkU8, param->symbIdx, mBuf); + CMCHKPK(SPkU8, param->beamIndex, mBuf); + CMCHKPK(SPkU16, param->RBAssign, mBuf); + CMCHKPK(SPkU8, param->xPDSCHRange, mBuf); + CMCHKPK(SPkU8, param->formatType, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuDciFormatA1A2Info +* +* +* Desc : This structure contains the information needed to convey DCI format A1/A2. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDciFormatA1A2Info +( +TfuDciFormatA1Info *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDciFormatA1A2Info(param, mBuf) +TfuDciFormatA1Info *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuDciFormatA1A2Info) + + CMCHKUNPK(SUnpkU8, ¶m->formatType, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->xPUSCHRange, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->xPUSCH_TxTiming, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->RBAssign, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->beamIndex, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->symbIdx, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->rv, mBuf); + + if(param->RBAssign <= TFU_RIV_324) + { + CMCHKUNPK(cmUnpkTfuRbAssignA1Val324, ¶m->u.rbAssignA1Val324, mBuf); + } + else if(param->RBAssign == TFU_RIV_326) + { + CMCHKUNPK(cmUnpkTfuRbAssignVal326, ¶m->u.rbAssignVal326, mBuf); + } + + CMCHKUNPK(SUnpkU8, ¶m->CSI_BSI_BRI_Req, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->CSIRS_BRRS_TxTiming, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->CSIRS_BRRS_SymbIdx, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->CSI_BRRS_Indicator, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->CSIRS_BRRS_ProcInd, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numBSI_Reports, mBuf); + + CMCHKUNPK(SUnpkU8, ¶m->uciOnxPUSCH, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->beamSwitch, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->SRS_Config, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->SRS_Symbol, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->REMapIdx_DMRS_PCRS_numLayers, mBuf); + + CMCHKUNPK(SUnpkU8, ¶m->SCID, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->PMI, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->UL_PCRS, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->tpcCmd, mBuf); + + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func : cmUnpkTfuDciFormatB1B2Info +* +* +* Desc : This structure contains the information needed to convey DCI format B1/B2. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDciFormatB1B2Info +( +TfuDciFormatB1Info *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDciFormatB1B2Info(param, mBuf) +TfuDciFormatB1Info *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuDciFormatB1B2Info) + + CMCHKUNPK(SUnpkU8, ¶m->formatType, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->xPDSCHRange, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->RBAssign, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->beamIndex, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->symbIdx, mBuf); + + if(param->RBAssign <= TFU_RIV_324) + { + CMCHKUNPK(cmUnpkTfuRbAssignB1Val324, ¶m->u.rbAssignB1Val324, mBuf); + } + else if (param->RBAssign == TFU_RIV_326) + { + CMCHKUNPK(cmUnpkTfuRbAssignVal326, ¶m->u.rbAssignVal326, mBuf); + } + + CMCHKUNPK(SUnpkU8, ¶m->CSI_BSI_BRI_Req, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->CSIRS_BRRS_TxTiming, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->CSIRS_BRRS_SymbIdx, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->CSI_BRRS_Indicator, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->CSIRS_BRRS_ProcInd, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numBSI_Reports, mBuf); + + CMCHKUNPK(SUnpkU8, ¶m->xPUCCH_TxTiming, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->freqResIdx_xPUCCH, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->beamSwitch, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->SRS_Config, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->SRS_Symbol, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->AntPorts_numLayers, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->SCID, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->tpcCmd, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->DL_PCRS, mBuf); + + RETVALUE(ROK); +} + + +#endif /* TFU_5GTF */ + + +/*********************************************************** +* +* Func : cmPkTfuDciFormat0Info +* +* +* Desc : This structure contains the information needed to convey DCI format 0. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDciFormat0Info +( +TfuDciFormat0Info *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuDciFormat0Info(param, mBuf) +TfuDciFormat0Info *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuDciFormat0Info) + + /* tfu_c_001.main_3: Adding pack for hqProcId */ + CMCHKPK(SPkU8, param->hqProcId, mBuf); + CMCHKPK(SPkU8, param->txAntenna, mBuf); + CMCHKPK(SPkU8, param->numCqiBit, mBuf); + CMCHKPK(SPkU8, param->cqiReq, mBuf); + CMCHKPK(SPkU8, param->nDmrs, mBuf); + +#ifdef TFU_TDD + CMCHKPK(SPkU8, param->dai, mBuf); + CMCHKPK(SPkU8, param->ulIdx, mBuf); + +#endif + CMCHKPK(SPkU8, param->tpcCmd, mBuf); + CMCHKPK(SPkU8, param->ndi, mBuf); + CMCHKPK(SPkU8, param->mcs, mBuf); + CMCHKPK(SPkU8, param->hoppingBits, mBuf); +/* tfu_c_001.main_7. Added changes of TFU_UPGRADE */ +#ifdef TFU_UPGRADE + CMCHKPK(SPkU32, param->riv, mBuf); +#endif + CMCHKPK(SPkU8, param->numRb, mBuf); + CMCHKPK(SPkU8, param->rbStart, mBuf); + CMCHKPK(SPkU8, param->hoppingEnbld, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuDciFormat0Info +* +* +* Desc : This structure contains the information needed to convey DCI format 0. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDciFormat0Info +( +TfuDciFormat0Info *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDciFormat0Info(param, mBuf) +TfuDciFormat0Info *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuDciFormat0Info) + + CMCHKUNPK(SUnpkU8, ¶m->hoppingEnbld, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->rbStart, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numRb, mBuf); +#ifdef TFU_UPGRADE + CMCHKUNPK(SUnpkU32, ¶m->riv, mBuf); +#endif /* TFU_UPGRADE */ + CMCHKUNPK(SUnpkU8, ¶m->hoppingBits, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->mcs, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->ndi, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->tpcCmd, mBuf); + +#ifdef TFU_TDD + CMCHKUNPK(SUnpkU8, ¶m->ulIdx, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->dai, mBuf); + +#endif + CMCHKUNPK(SUnpkU8, ¶m->nDmrs, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->cqiReq, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numCqiBit, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->txAntenna, mBuf); + /* tfu_c_001.main_3: Adding unpack for hqProcId */ + CMCHKUNPK(SUnpkU8, ¶m->hqProcId, mBuf); + + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuAllocMapOrRiv +* +* +* Desc : This Structure could either contain a resource allocation bit map OR a + * RIV Value as defined in 213 - 7.1.6. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuAllocMapOrRiv +( +TfuAllocMapOrRiv *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuAllocMapOrRiv(param, mBuf) +TfuAllocMapOrRiv *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkTfuAllocMapOrRiv) + + switch(param->type) { + /*tfu_c_001.main_7 - ADD - TFU_RESMAP_CHANGE support */ +#ifdef TFU_RESMAP_CHANGE + case UnKnown: + CMCHKPK(cmPkTfuAllocMap, ¶m->u.allocMap, mBuf); + break; + +#endif + + /*tfu_c_001.main_7 - ADD - TFU_RESMAP_CHANGE support */ +#ifndef TFU_RESMAP_CHANGE + case TFU_ALLOC_TYPE_MAP: + for (i=TFU_MAX_ALLOC_BYTES-1; i >= 0; i--) { + CMCHKPK(SPkU8, param->u.resAllocMap[i], mBuf); + } + break; + +#endif + case TFU_ALLOC_TYPE_RIV: + CMCHKPK(SPkU32, param->u.riv, mBuf); + break; + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkU32, param->type, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuAllocMapOrRiv +* +* +* Desc : This Structure could either contain a resource allocation bit map OR a + * RIV Value as defined in 213 - 7.1.6. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuAllocMapOrRiv +( +TfuAllocMapOrRiv *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuAllocMapOrRiv(param, mBuf) +TfuAllocMapOrRiv *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmUnpkTfuAllocMapOrRiv) + + CMCHKUNPK(SUnpkU32, (U32 *)¶m->type, mBuf); + switch(param->type) { + case TFU_ALLOC_TYPE_RIV: + CMCHKUNPK(SUnpkU32, ¶m->u.riv, mBuf); + break; + + /*tfu_c_001.main_7 - ADD - TFU_RESMAP_CHANGE support */ +#ifndef TFU_RESMAP_CHANGE + case TFU_ALLOC_TYPE_MAP: + for (i=0; iu.resAllocMap[i], mBuf); + } + break; + +#endif + + /*tfu_c_001.main_7 - ADD - TFU_RESMAP_CHANGE support */ +#ifdef TFU_RESMAP_CHANGE + case UnKnown: + CMCHKUNPK(cmUnpkTfuAllocMap, ¶m->u.allocMap, mBuf); + break; + +#endif + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuDciFormat1AllocInfo +* +* +* Desc : This structure contains only the allocation information, thats part + * of DCI format 1. + * @details Allocation information also contains parameters necessary + * for Physical layer to process Downlink Data. This structure accompanies the + * Data that is sent from MAC to PHY in the TfUiTfuDatReq primitive. + * @sa TfuDciFormat1Info +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDciFormat1AllocInfo +( +TfuDciFormat1AllocInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuDciFormat1AllocInfo(param, mBuf) +TfuDciFormat1AllocInfo *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkTfuDciFormat1AllocInfo) + + CMCHKPK(SPkU8, param->rv, mBuf); + CMCHKPK(SPkU8, param->mcs, mBuf); + CMCHKPK(SPkU8, param->ndi, mBuf); + CMCHKPK(SPkU8, param->harqProcId, mBuf); + for (i=TFU_MAX_ALLOC_BYTES-1; i >= 0; i--) { + CMCHKPK(SPkU8, param->resAllocMap[i], mBuf); + } + CMCHKPK(SPkU8, param->isAllocType0, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuDciFormat1AllocInfo +* +* +* Desc : This structure contains only the allocation information, thats part + * of DCI format 1. + * @details Allocation information also contains parameters necessary + * for Physical layer to process Downlink Data. This structure accompanies the + * Data that is sent from MAC to PHY in the TfUiTfuDatReq primitive. + * @sa TfuDciFormat1Info +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDciFormat1AllocInfo +( +TfuDciFormat1AllocInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDciFormat1AllocInfo(param, mBuf) +TfuDciFormat1AllocInfo *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmUnpkTfuDciFormat1AllocInfo) + + CMCHKUNPK(SUnpkU8, ¶m->isAllocType0, mBuf); + for (i=0; iresAllocMap[i], mBuf); + } + CMCHKUNPK(SUnpkU8, ¶m->harqProcId, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->ndi, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->mcs, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->rv, mBuf); + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func : cmPkTfuDciFormat1Info +* +* +* Desc : This structure contains the information needed to convey DCI format 1. + * @details Allocation information is separated from the other control + * information carried in this format. This separation is needed as Data shall + * also carry some control information, essentially allocation information, + * along with it, in order to aid physical layer processing of the data. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDciFormat1Info +( +TfuDciFormat1Info *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuDciFormat1Info(param, mBuf) +TfuDciFormat1Info *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuDciFormat1Info) + + CMCHKPK(SPkU8, param->tpcCmd, mBuf); + +#ifdef TFU_TDD + CMCHKPK(SPkU8, param->dai, mBuf); + +#endif + CMCHKPK(cmPkTfuDciFormat1AllocInfo, ¶m->allocInfo, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuDciFormat1Info +* +* +* Desc : This structure contains the information needed to convey DCI format 1. + * @details Allocation information is separated from the other control + * information carried in this format. This separation is needed as Data shall + * also carry some control information, essentially allocation information, + * along with it, in order to aid physical layer processing of the data. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDciFormat1Info +( +TfuDciFormat1Info *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDciFormat1Info(param, mBuf) +TfuDciFormat1Info *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuDciFormat1Info) + + CMCHKUNPK(cmUnpkTfuDciFormat1AllocInfo, ¶m->allocInfo, mBuf); + +#ifdef TFU_TDD + CMCHKUNPK(SUnpkU8, ¶m->dai, mBuf); + +#endif + CMCHKUNPK(SUnpkU8, ¶m->tpcCmd, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuDciFormat2AAllocInfo +* +* +* Desc : This structure contains only the allocation information, that is part + * of DCI format 2A. + * @details Allocation information also contains parameters necessary + * for Physical layer to process Downlink data. This structure accompanies the + * Data that is sent from MAC to PHY in the TfUiTfuDatReq primitive. + * @sa TfuDciFormat2AInfo +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDciFormat2AAllocInfo +( +TfuDciFormat2AAllocInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuDciFormat2AAllocInfo(param, mBuf) +TfuDciFormat2AAllocInfo *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkTfuDciFormat2AAllocInfo) + + CMCHKPK(SPkU8, param->transSwap, mBuf); + CMCHKPK(SPkU8, param->precoding, mBuf); + + for (i=1; i >= 0; i--) { + CMCHKPK(cmPkTfuDciFormatTbInfo, ¶m->tbInfo[i], mBuf); + } + + CMCHKPK(SPkU8, param->harqProcId, mBuf); + for (i=TFU_MAX_ALLOC_BYTES-1; i >= 0; i--) { + CMCHKPK(SPkU8, param->resAllocMap[i], mBuf); + } + + CMCHKPK(SPkU8, param->isAllocType0, mBuf); + + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuDciFormat2AAllocInfo +* +* +* Desc : This structure contains only the allocation information, that is part + * of DCI format 2A. + * @details Allocation information also contains parameters necessary + * for Physical layer to process Downlink data. This structure accompanies the + * Data that is sent from MAC to PHY in the TfUiTfuDatReq primitive. + * @sa TfuDciFormat2AInfo +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDciFormat2AAllocInfo +( +TfuDciFormat2AAllocInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDciFormat2AAllocInfo(param, mBuf) +TfuDciFormat2AAllocInfo *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmUnpkTfuDciFormat2AAllocInfo) + + +/* tfu_c_001.main_4 - Changes for MIMO feature addition */ +/* tfu_c_001.main_5 - Removed dependency on MIMO compile-time flag */ + CMCHKUNPK(SUnpkU8, ¶m->isAllocType0, mBuf); + + +/* tfu_c_001.main_4 - Changes for MIMO feature addition */ +/* tfu_c_001.main_5 - Removed dependency on MIMO compile-time flag */ + for (i=0; iresAllocMap[i], mBuf); + } + CMCHKUNPK(SUnpkU8, ¶m->harqProcId, mBuf); + +/* tfu_c_001.main_4 - Changes for MIMO feature addition */ +/* tfu_c_001.main_5 - Removed dependency on MIMO compile-time flag */ + +/* tfu_c_001.main_4 - Changes for MIMO feature addition */ +/* tfu_c_001.main_5 - Removed dependency on MIMO compile-time flag */ + for (i=0; i<=1; i++) { + CMCHKUNPK(cmUnpkTfuDciFormatTbInfo, ¶m->tbInfo[i], mBuf); + } + + CMCHKUNPK(SUnpkU8, ¶m->precoding, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->transSwap, mBuf); + RETVALUE(ROK); +} + +#ifdef EMTC_ENABLE +/*********************************************************** +* +* Func : cmPkTfuDciFormat6AAllocInfo +* +* +* Desc : This structure contains only the allocation information, that is part + * of DCI format 6-1A. + * @details Allocation information also contains parameters necessary + * for Physical layer to process Downlink data. This structure accompanies the + * Data that is sent from MAC to PHY in the TfUiTfuDatReq primitive. + * @sa TfuDciFormat61aInfo +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDciFormat6AAllocInfo +( +TfuDciFormat61AllocInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuDciFormat6AAllocInfo(param, mBuf) +TfuDciFormat61AllocInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuDciFormat6AAllocInfo) + + CMCHKPK(SPkU8, param->rv, mBuf); + CMCHKPK(SPkU8, param->mcs, mBuf); + CMCHKPK(SPkU8, param->ndi, mBuf); + CMCHKPK(SPkU8, param->harqProcId, mBuf); + CMCHKPK(SPkU32, param->riv, mBuf); + + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuDciFormat6AAllocInfo +* +* +* Desc : This structure contains only the allocation information, that is part + * of DCI format 6-1A. + * @details Allocation information also contains parameters necessary + * for Physical layer to process Downlink data. This structure accompanies the + * Data that is sent from MAC to PHY in the TfUiTfuDatReq primitive. + * @sa TfuDciFormat61aInfo +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDciFormat6AAllocInfo +( +TfuDciFormat61AllocInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDciFormat6AAllocInfo(param, mBuf) +TfuDciFormat61AllocInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuDciFormat6AAllocInfo) + + CMCHKUNPK(SUnpkU32, ¶m->riv, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->harqProcId, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->ndi, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->mcs, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->rv, mBuf); + printf("In cmUnpkTfuDciFormat6AAllocInfo :: Passed \n"); + RETVALUE(ROK); +} +#endif + + + +/*********************************************************** +* +* Func : cmPkTfuDciFormat2AInfo +* +* +* Desc : This structure contains the information carried by DCI format 2A. + * @details It carries the allocation information and other control information. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDciFormat2AInfo +( +TfuDciFormat2AInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuDciFormat2AInfo(param, mBuf) +TfuDciFormat2AInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuDciFormat2AInfo) + + CMCHKPK(SPkU8, param->tpcCmd, mBuf); + +#ifdef TFU_TDD + CMCHKPK(SPkU8, param->dai, mBuf); + +#endif + CMCHKPK(cmPkTfuDciFormat2AAllocInfo, ¶m->allocInfo, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuDciFormat2AInfo +* +* +* Desc : This structure contains the information carried by DCI format 2A. + * @details It carries the allocation information and other control information. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDciFormat2AInfo +( +TfuDciFormat2AInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDciFormat2AInfo(param, mBuf) +TfuDciFormat2AInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuDciFormat2AInfo) + + CMCHKUNPK(cmUnpkTfuDciFormat2AAllocInfo, ¶m->allocInfo, mBuf); + +#ifdef TFU_TDD + CMCHKUNPK(SUnpkU8, ¶m->dai, mBuf); + +#endif + CMCHKUNPK(SUnpkU8, ¶m->tpcCmd, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuDciFormat2AllocInfo +* +* +* Desc : This structure contains only the allocation information, that is part + * of DCI format 2. + * @details Allocation information also contains parameters necessary + * for Physical layer to process Downlink data. This structure accompanies the + * Data that is sent from MAC to PHY in the TfUiTfuDatReq primitive. + * @sa TfuDciFormat2Info +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDciFormat2AllocInfo +( +TfuDciFormat2AllocInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuDciFormat2AllocInfo(param, mBuf) +TfuDciFormat2AllocInfo *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkTfuDciFormat2AllocInfo) + + +/* tfu_c_001.main_4 - Changes for MIMO feature addition */ +/* tfu_c_001.main_5 - Removed dependency on MIMO compile-time flag */ + for (i=1; i >= 0; i--) { + CMCHKPK(cmPkTfuDciFormatTbInfo, ¶m->tbInfo[i], mBuf); + } + CMCHKPK(SPkU8, param->harqProcId, mBuf); + + CMCHKPK(SPkU8, param->precoding, mBuf); + CMCHKPK(SPkU8, param->transSwap, mBuf); + +/* tfu_c_001.main_4 - Changes for MIMO feature addition */ +/* tfu_c_001.main_5 - Removed dependency on MIMO compile-time flag */ + +#ifdef TFU_TDD + CMCHKPK(SPkU8, param->dai, mBuf); + +#endif + for (i=TFU_MAX_ALLOC_BYTES-1; i >= 0; i--) { + CMCHKPK(SPkU8, param->resAllocMap[i], mBuf); + } + +/* tfu_c_001.main_4 - Changes for MIMO feature addition */ +/* tfu_c_001.main_5 - Removed dependency on MIMO compile-time flag */ + +/* tfu_c_001.main_4 - Changes for MIMO feature addition */ +/* tfu_c_001.main_5 - Removed dependency on MIMO compile-time flag */ + CMCHKPK(SPkU8, param->isAllocType0, mBuf); + + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuDciFormat2AllocInfo +* +* +* Desc : This structure contains only the allocation information, that is part + * of DCI format 2. + * @details Allocation information also contains parameters necessary + * for Physical layer to process Downlink data. This structure accompanies the + * Data that is sent from MAC to PHY in the TfUiTfuDatReq primitive. + * @sa TfuDciFormat2Info +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDciFormat2AllocInfo +( +TfuDciFormat2AllocInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDciFormat2AllocInfo(param, mBuf) +TfuDciFormat2AllocInfo *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmUnpkTfuDciFormat2AllocInfo) + + +/* tfu_c_001.main_4 - Changes for MIMO feature addition */ +/* tfu_c_001.main_5 - Removed dependency on MIMO compile-time flag */ + CMCHKUNPK(SUnpkU8, ¶m->isAllocType0, mBuf); + + +/* tfu_c_001.main_4 - Changes for MIMO feature addition */ +/* tfu_c_001.main_5 - Removed dependency on MIMO compile-time flag */ + for (i=0; iresAllocMap[i], mBuf); + } + +#ifdef TFU_TDD + CMCHKUNPK(SUnpkU8, ¶m->dai, mBuf); + +#endif + +/* tfu_c_001.main_4 - Changes for MIMO feature addition */ +/* tfu_c_001.main_5 - Removed dependency on MIMO compile-time flag */ + CMCHKUNPK(SUnpkU8, ¶m->transSwap, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->precoding, mBuf); + +/* tfu_c_001.main_4 - Changes for MIMO feature addition */ +/* tfu_c_001.main_5 - Removed dependency on MIMO compile-time flag */ + CMCHKUNPK(SUnpkU8, ¶m->harqProcId, mBuf); + for (i=0; i<=1; i++) { + CMCHKUNPK(cmUnpkTfuDciFormatTbInfo, ¶m->tbInfo[i], mBuf); + } + + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuDciFormat2Info +* +* +* Desc : This structure contains the information carried by DCI format 2. + * @details Allocation information is separated from the other control + * information carried in this format. This separation is needed as Data must + * also carry some control information, essentially, allocation information + * along with it, in order to aid physical layer processing of the data. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDciFormat2Info +( +TfuDciFormat2Info *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuDciFormat2Info(param, mBuf) +TfuDciFormat2Info *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuDciFormat2Info) + + +/* tfu_c_001.main_4 - Changes for MIMO feature addition */ +/* tfu_c_001.main_5 - Removed dependency on MIMO compile-time flag */ + +#ifdef TFU_TDD + CMCHKPK(SPkU8, param->dai, mBuf); + +#endif + + CMCHKPK(SPkU8, param->tpcCmd, mBuf); + +/* tfu_c_001.main_4 - Changes for MIMO feature addition */ +/* tfu_c_001.main_5 - Removed dependency on MIMO compile-time flag */ + CMCHKPK(cmPkTfuDciFormat2AllocInfo, ¶m->allocInfo, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuDciFormat2Info +* +* +* Desc : This structure contains the information carried by DCI format 2. + * @details Allocation information is separated from the other control + * information carried in this format. This separation is needed as Data must + * also carry some control information, essentially, allocation information + * along with it, in order to aid physical layer processing of the data. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDciFormat2Info +( +TfuDciFormat2Info *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDciFormat2Info(param, mBuf) +TfuDciFormat2Info *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuDciFormat2Info) + + CMCHKUNPK(cmUnpkTfuDciFormat2AllocInfo, ¶m->allocInfo, mBuf); + +/* tfu_c_001.main_4 - Changes for MIMO feature addition */ +/* tfu_c_001.main_5 - Removed dependency on MIMO compile-time flag */ + CMCHKUNPK(SUnpkU8, ¶m->tpcCmd, mBuf); + +/* tfu_c_001.main_4 - Changes for MIMO feature addition */ +/* tfu_c_001.main_5 - Removed dependency on MIMO compile-time flag */ + +#ifdef TFU_TDD + CMCHKUNPK(SUnpkU8, ¶m->dai, mBuf); + +#endif + + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuDciFormat3Info +* +* +* Desc : This structure contains the information carried in DCI format 3. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDciFormat3Info +( +TfuDciFormat3Info *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuDciFormat3Info(param, mBuf) +TfuDciFormat3Info *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkTfuDciFormat3Info) + + CMCHKPK(SPkU8, param->isPucch, mBuf); + for (i=TFU_MAX_2BIT_TPC-1; i >= 0; i--) { + CMCHKPK(SPkU8, param->tpcCmd[i], mBuf); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuDciFormat3Info +* +* +* Desc : This structure contains the information carried in DCI format 3. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDciFormat3Info +( +TfuDciFormat3Info *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDciFormat3Info(param, mBuf) +TfuDciFormat3Info *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmUnpkTfuDciFormat3Info) + + for (i=0; itpcCmd[i], mBuf); + } + CMCHKUNPK(SUnpkU8, ¶m->isPucch, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuDciFormat3AInfo +* +* +* Desc : This structure contains the information carried by DCI format 3A. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDciFormat3AInfo +( +TfuDciFormat3AInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuDciFormat3AInfo(param, mBuf) +TfuDciFormat3AInfo *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkTfuDciFormat3AInfo) + CMCHKPK(SPkU8, param->isPucch, mBuf); + for (i=TFU_MAX_2BIT_TPC-1; i >= 0; i--) { + CMCHKPK(SPkU8, param->tpcCmd[i], mBuf); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuDciFormat3AInfo +* +* +* Desc : This structure contains the information carried by DCI format 3A. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDciFormat3AInfo +( +TfuDciFormat3AInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDciFormat3AInfo(param, mBuf) +TfuDciFormat3AInfo *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmUnpkTfuDciFormat3AInfo) + + for (i=0; itpcCmd[i], mBuf); + } + CMCHKUNPK(SUnpkU8, ¶m->isPucch, mBuf); + RETVALUE(ROK); +} + +#ifdef EMTC_ENABLE + + +/*********************************************************** +* +* Func : cmPkTfuDciFormat60aInfo +* +* +* Desc : This structure contains the information that is carried in DCI + * format 6-0A +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +************************************************************/ + +#ifdef ANSI +PRIVATE S16 cmPkTfuDciFormat60aInfo +( +TfuDciFormat60aInfo *param, +Buffer *mBuf +) +#else +PRIVATE S16 cmPkTfuDciFormat60aInfo(param, mBuf) +TfuDciFormat60aInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuDciFormat60aInfo) + + CMCHKPK(SPkU8, param->dciRep, mBuf); + CMCHKPK(SPkU8, param->isSrs, mBuf); + CMCHKPK(SPkU8, param->cqiReq, mBuf); +#ifdef TFU_TDD + CMCHKPK(SPkU8, param->dai, mBuf); + CMCHKPK(SPkU8, param->ulIdx, mBuf); +#endif + CMCHKPK(SPkU8, param->tpcCmd, mBuf); + CMCHKPK(SPkU8, param->rv, mBuf); + CMCHKPK(SPkU8, param->ndi, mBuf); + CMCHKPK(SPkU8, param->hqProcId, mBuf); + CMCHKPK(SPkU8, param->rep, mBuf); + CMCHKPK(SPkU8, param->mcs, mBuf); + CMCHKPK(SPkU32, param->riv, mBuf); + CMCHKPK(SPkU8, param->hoppingEnbld, mBuf); + RETVALUE(ROK); +} +/*********************************************************** +* +* Func : cmPkTfuPdcchOrderInfoEmtc +* +* +* Desc : This structure contains the information that is carried in DCI + * format 6-1A in the case of a PDCCH order. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PRIVATE S16 cmPkTfuPdcchOrderInfoEmtc +( +TfuPdcchOrderInfoEmtc *param, +Buffer *mBuf +) +#else +PRIVATE S16 cmPkTfuPdcchOrderInfoEmtc(param, mBuf) +TfuPdcchOrderInfoEmtc *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuPdcchOrderInfoEmtc) + + CMCHKPK(SPkU8, param->ceLevel, mBuf); + CMCHKPK(SPkU8, param->prachMaskIdx, mBuf); + CMCHKPK(SPkU8, param->preambleIdx, mBuf); + CMCHKPK(SPkU32, param->riv, mBuf); + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func : cmPkTfudciformat61aPdsch +* +* +* Desc : This structure contains the information carried in DCI format 6-1A + * when it is NOT used for a PDCCH order. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PRIVATE S16 cmPkTfudciformat61aPdsch +( +Tfudciformat61aPdsch *param, +Buffer *mBuf +) +#else +PRIVATE S16 cmPkTfudciformat61aPdsch(param, mBuf) +Tfudciformat61aPdsch *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfudciformat61aPdsch) + + CMCHKPK(SPkU8, param->isTBMsg4, mBuf); + CMCHKPK(SPkU8, param->dciRep, mBuf); + CMCHKPK(SPkU8, param->harqAckOffst, mBuf); + CMCHKPK(SPkU8, param->pmiCfm, mBuf); + CMCHKPK(SPkU8, param->tPmi, mBuf); + CMCHKPK(SPkU8, param->isSrs, mBuf); + CMCHKPK(SPkU8, param->antPortAndScrId, mBuf); + +#ifdef TFU_TDD + CMCHKPK(SPkU8, param->dai, mBuf); +#endif + CMCHKPK(SPkU8, param->tpcCmd, mBuf); + CMCHKPK(SPkU8, param->rep, mBuf); + CMCHKPK(SPkU8, param->hoppingEnbld, mBuf); + CMCHKPK(cmPkTfuDciFormat6AAllocInfo, ¶m->allocInfo, mBuf); + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func : cmPkTfuDciFormat61aInfo +* +* +* Desc : This structure contains the information needed to convey DCI format 6-1A. + * @details Format can possibly carry PDSCH allocation or information needed for + * a PDCCH order, used to initiate a RACH procedure in cases where UE looses + * sync with eNodeB. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDciFormat61aInfo +( +TfuDciFormat61aInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuDciFormat61aInfo(param, mBuf) +TfuDciFormat61aInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuDciFormat61aInfo) + + switch(param->isPdcchOrder) { + case FALSE: + CMCHKPK(cmPkTfudciformat61aPdsch, ¶m->t.pdschInfo, mBuf); + break; + case TRUE: + CMCHKPK(cmPkTfuPdcchOrderInfoEmtc, ¶m->t.pdcchOrder, mBuf); + break; + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkU8, param->isPdcchOrder, mBuf); + + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func : cmUnpkTfuDciFormat60aInfo +* +* +* Desc : This structure contains the information that is carried in DCI + * format 6-0A. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +* **********************************************************/ + +#ifdef ANSI +PRIVATE S16 cmUnpkTfuDciFormat60aInfo +( +TfuDciFormat60aInfo *param, +Buffer *mBuf +) +#else +PRIVATE S16 cmUnpkTfuDciFormat60aInfo(param, mBuf) +TfuDciFormat60aInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuDciFormat60aInfo) + + printf("In cmUnpkTfuDciFormat60aInfo :: Entry \n"); + CMCHKUNPK(SUnpkU8, ¶m->hoppingEnbld, mBuf); + CMCHKUNPK(SUnpkU32, ¶m->riv, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->mcs, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->rep, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->hqProcId, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->ndi, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->rv, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->tpcCmd, mBuf); +#ifdef TFU_TDD + CMCHKUNPK(SUnpkU8, ¶m->ulIdx, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->dai, mBuf); +#endif + CMCHKUNPK(SUnpkU8, ¶m->cqiReq, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->isSrs, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->dciRep, mBuf); + printf("In cmUnpkTfuDciFormat60aInfo :: Exit \n"); + RETVALUE(ROK); +} +/*********************************************************** +* +* Func : cmUnpkTfuPdcchOrderInfoEmtc +* +* +* Desc : This structure contains the information that is carried in DCI + * format 6-1A in the case of a PDCCH order. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PRIVATE S16 cmUnpkTfuPdcchOrderInfoEmtc +( +TfuPdcchOrderInfoEmtc *param, +Buffer *mBuf +) +#else +PRIVATE S16 cmUnpkTfuPdcchOrderInfoEmtc(param, mBuf) +TfuPdcchOrderInfoEmtc *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuPdcchOrderInfoEmtc) + + printf("In cmUnpkTfuPdcchOrderInfoEmtc :: Entry \n"); + CMCHKUNPK(SUnpkU32, ¶m->riv, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->preambleIdx, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->prachMaskIdx, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->ceLevel, mBuf); + printf("In cmUnpkTfuPdcchOrderInfoEmtc :: Passed \n"); + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func : cmUnpkTfuDciFormat61aInfo +* +* +* Desc : This structure contains the information carried by DCI format 6-1A. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDciFormat61aInfo +( +TfuDciFormat61aInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDciFormat61aInfo(param, mBuf) +TfuDciFormat61aInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuDciFormat61aInfo) + + CMCHKUNPK(SUnpkU8, ¶m->isPdcchOrder, mBuf); + printf("1. cmUnpkTfuDciFormat61aInfo :: isPdcchOrder %d \n", param->isPdcchOrder); + switch(param->isPdcchOrder) { + case TRUE: + CMCHKUNPK(cmUnpkTfuPdcchOrderInfoEmtc, ¶m->t.pdcchOrder, mBuf); + break; + case FALSE: + CMCHKUNPK(cmUnpkTfudciformat61aPdsch, ¶m->t.pdschInfo, mBuf); + break; + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} +#endif + +/*********************************************************** +* +* Func : cmPkTfuDciFormat1dAllocInfo +* +* +* Desc : This structure contains only the allocation information, thats part + * of DCI format 1D. + * @details Allocation information also contains parameters necessary + * for Physical layer to process Downlink Data. This structure accompanies the + * Data that is sent from MAC to PHY in the TfUiTfuDatReq primitive. + * @sa TfuDciFormat1dInfo +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDciFormat1dAllocInfo +( +TfuDciFormat1dAllocInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuDciFormat1dAllocInfo(param, mBuf) +TfuDciFormat1dAllocInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuDciFormat1dAllocInfo) + + CMCHKPK(SPkU8, param->tPmi, mBuf); + CMCHKPK(SPkU8, param->rv, mBuf); + CMCHKPK(SPkU8, param->mcs, mBuf); + CMCHKPK(cmPkTfuAllocMapOrRiv, ¶m->alloc, mBuf); + CMCHKPK(cmPkTknU8, ¶m->nGap2, mBuf); + CMCHKPK(SPkU8, param->isLocal, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuDciFormat1dAllocInfo +* +* +* Desc : This structure contains only the allocation information, thats part + * of DCI format 1D. + * @details Allocation information also contains parameters necessary + * for Physical layer to process Downlink Data. This structure accompanies the + * Data that is sent from MAC to PHY in the TfUiTfuDatReq primitive. + * @sa TfuDciFormat1dInfo +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDciFormat1dAllocInfo +( +TfuDciFormat1dAllocInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDciFormat1dAllocInfo(param, mBuf) +TfuDciFormat1dAllocInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuDciFormat1dAllocInfo) + + CMCHKUNPK(SUnpkU8, ¶m->isLocal, mBuf); + CMCHKUNPK(cmUnpkTknU8, ¶m->nGap2, mBuf); + CMCHKUNPK(cmUnpkTfuAllocMapOrRiv, ¶m->alloc, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->mcs, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->rv, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->tPmi, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuDciFormat1dInfo +* +* +* Desc : This structure contains the information carried by DCI format 1D. + * @details Allocation information is separated from the other control + * information carried in this format. This separation is needed as Data shall + * also carry some control information, essentially allocation information, + * along with it, in order to aid physical layer processing of the data. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDciFormat1dInfo +( +TfuDciFormat1dInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuDciFormat1dInfo(param, mBuf) +TfuDciFormat1dInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuDciFormat1dInfo) + + CMCHKPK(SPkU8, param->dlPwrOffset, mBuf); + +#ifdef TFU_TDD + CMCHKPK(SPkU8, param->dai, mBuf); + +#endif + CMCHKPK(SPkU8, param->tpcCmd, mBuf); + CMCHKPK(SPkU8, param->ndi, mBuf); + CMCHKPK(SPkU8, param->harqProcId, mBuf); + CMCHKPK(cmPkTfuDciFormat1dAllocInfo, ¶m->allocInfo, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuDciFormat1dInfo +* +* +* Desc : This structure contains the information carried by DCI format 1D. + * @details Allocation information is separated from the other control + * information carried in this format. This separation is needed as Data shall + * also carry some control information, essentially allocation information, + * along with it, in order to aid physical layer processing of the data. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDciFormat1dInfo +( +TfuDciFormat1dInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDciFormat1dInfo(param, mBuf) +TfuDciFormat1dInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuDciFormat1dInfo) + + CMCHKUNPK(cmUnpkTfuDciFormat1dAllocInfo, ¶m->allocInfo, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->harqProcId, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->ndi, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->tpcCmd, mBuf); + +#ifdef TFU_TDD + CMCHKUNPK(SUnpkU8, ¶m->dai, mBuf); + +#endif + CMCHKUNPK(SUnpkU8, ¶m->dlPwrOffset, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuDciFormat1cInfo +* +* +* Desc : This structure contains only the allocation information, thats part + * of DCI format 1C. + * @details Allocation information also contains parameters necessary + * for Physical layer to process Downlink Data. This structure accompanies the + * Data that is sent from MAC to PHY in the TfUiTfuDatReq primitive. + * @sa TfuDciFormat1CInfo +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDciFormat1cInfo +( +TfuDciFormat1cInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuDciFormat1cInfo(param, mBuf) +TfuDciFormat1cInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuDciFormat1cInfo) + + CMCHKPK(SPkU8, param->iTbs, mBuf); + CMCHKPK(cmPkTfuAllocMapOrRiv, ¶m->alloc, mBuf); + CMCHKPK(cmPkTknU8, ¶m->nGap2, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuDciFormat1cInfo +* +* +* Desc : This structure contains only the allocation information, thats part + * of DCI format 1C. + * @details Allocation information also contains parameters necessary + * for Physical layer to process Downlink Data. This structure accompanies the + * Data that is sent from MAC to PHY in the TfUiTfuDatReq primitive. + * @sa TfuDciFormat1CInfo +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDciFormat1cInfo +( +TfuDciFormat1cInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDciFormat1cInfo(param, mBuf) +TfuDciFormat1cInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuDciFormat1cInfo) + + CMCHKUNPK(cmUnpkTknU8, ¶m->nGap2, mBuf); + CMCHKUNPK(cmUnpkTfuAllocMapOrRiv, ¶m->alloc, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->iTbs, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuDciFormat1bAllocInfo +* +* +* Desc : This structure contains only the allocation information, thats part + * of DCI format 1 B. + * @details Allocation information also contains parameters necessary + * for Physical layer to process Downlink Data. This structure accompanies the + * Data that is sent from MAC to PHY in the TfUiTfuDatReq primitive. + * @sa TfuDciFormat1BInfo +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDciFormat1bAllocInfo +( +TfuDciFormat1bAllocInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuDciFormat1bAllocInfo(param, mBuf) +TfuDciFormat1bAllocInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuDciFormat1bAllocInfo) + + CMCHKPK(SPkU8, param->pmiCfm, mBuf); + CMCHKPK(SPkU8, param->tPmi, mBuf); + CMCHKPK(SPkU8, param->ndi, mBuf); + CMCHKPK(SPkU8, param->harqProcId, mBuf); + CMCHKPK(SPkU8, param->rv, mBuf); + CMCHKPK(SPkU8, param->mcs, mBuf); + CMCHKPK(cmPkTfuAllocMapOrRiv, ¶m->alloc, mBuf); + CMCHKPK(cmPkTknU8, ¶m->nGap2, mBuf); + CMCHKPK(SPkU8, param->isLocal, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuDciFormat1bAllocInfo +* +* +* Desc : This structure contains only the allocation information, thats part + * of DCI format 1 B. + * @details Allocation information also contains parameters necessary + * for Physical layer to process Downlink Data. This structure accompanies the + * Data that is sent from MAC to PHY in the TfUiTfuDatReq primitive. + * @sa TfuDciFormat1BInfo +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDciFormat1bAllocInfo +( +TfuDciFormat1bAllocInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDciFormat1bAllocInfo(param, mBuf) +TfuDciFormat1bAllocInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuDciFormat1bAllocInfo) + + CMCHKUNPK(SUnpkU8, ¶m->isLocal, mBuf); + CMCHKUNPK(cmUnpkTknU8, ¶m->nGap2, mBuf); + CMCHKUNPK(cmUnpkTfuAllocMapOrRiv, ¶m->alloc, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->mcs, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->rv, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->harqProcId, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->ndi, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->tPmi, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->pmiCfm, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuPdcchOrderInfo +* +* +* Desc : This structure contains the information that is carried in DCI + * format 1A in the case of a PDCCH order. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuPdcchOrderInfo +( +TfuPdcchOrderInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuPdcchOrderInfo(param, mBuf) +TfuPdcchOrderInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuPdcchOrderInfo) + + CMCHKPK(SPkU8, param->prachMaskIdx, mBuf); + CMCHKPK(SPkU8, param->preambleIdx, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuPdcchOrderInfo +* +* +* Desc : This structure contains the information that is carried in DCI + * format 1A in the case of a PDCCH order. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuPdcchOrderInfo +( +TfuPdcchOrderInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuPdcchOrderInfo(param, mBuf) +TfuPdcchOrderInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuPdcchOrderInfo) + + CMCHKUNPK(SUnpkU8, ¶m->preambleIdx, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->prachMaskIdx, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuDciFormat1aAllocInfo +* +* +* Desc : This structure contains only the allocation information, thats part + * of DCI format 1A. + * @details Allocation information also contains parameters necessary + * for Physical layer to process Downlink Data. This structure accompanies the + * Data that is sent from MAC to PHY in the TfUiTfuDatReq primitive. + * @sa TfuDciFormat1AInfo +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDciFormat1aAllocInfo +( +TfuDciFormat1aAllocInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuDciFormat1aAllocInfo(param, mBuf) +TfuDciFormat1aAllocInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuDciFormat1aAllocInfo) + + CMCHKPK(SPkU8, param->ndi, mBuf); + CMCHKPK(cmPkTknU8, ¶m->harqProcId, mBuf); + CMCHKPK(SPkU8, param->rv, mBuf); + CMCHKPK(SPkU8, param->mcs, mBuf); + CMCHKPK(cmPkTfuAllocMapOrRiv, ¶m->alloc, mBuf); + CMCHKPK(cmPkTknU8, ¶m->nGap2, mBuf); + CMCHKPK(SPkU8, param->isLocal, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuDciFormat1aAllocInfo +* +* +* Desc : This structure contains only the allocation information, thats part + * of DCI format 1A. + * @details Allocation information also contains parameters necessary + * for Physical layer to process Downlink Data. This structure accompanies the + * Data that is sent from MAC to PHY in the TfUiTfuDatReq primitive. + * @sa TfuDciFormat1AInfo +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDciFormat1aAllocInfo +( +TfuDciFormat1aAllocInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDciFormat1aAllocInfo(param, mBuf) +TfuDciFormat1aAllocInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuDciFormat1aAllocInfo) + + CMCHKUNPK(SUnpkU8, ¶m->isLocal, mBuf); + CMCHKUNPK(cmUnpkTknU8, ¶m->nGap2, mBuf); + CMCHKUNPK(cmUnpkTfuAllocMapOrRiv, ¶m->alloc, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->mcs, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->rv, mBuf); + CMCHKUNPK(cmUnpkTknU8, ¶m->harqProcId, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->ndi, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfudciformat1aPdsch +* +* +* Desc : This structure contains the information carried in DCI format 1A + * when it is NOT used for a PDCCH order. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfudciformat1aPdsch +( +Tfudciformat1aPdsch *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfudciformat1aPdsch(param, mBuf) +Tfudciformat1aPdsch *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfudciformat1aPdsch) + + CMCHKPK(SPkU8, param->tpcCmd, mBuf); + +#ifdef TFU_TDD + CMCHKPK(cmPkTknU8, ¶m->dai, mBuf); + +#endif + CMCHKPK(cmPkTfuDciFormat1aAllocInfo, ¶m->allocInfo, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfudciformat1aPdsch +* +* +* Desc : This structure contains the information carried in DCI format 1A + * when it is NOT used for a PDCCH order. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfudciformat1aPdsch +( +Tfudciformat1aPdsch *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfudciformat1aPdsch(param, mBuf) +Tfudciformat1aPdsch *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfudciformat1aPdsch) + + CMCHKUNPK(cmUnpkTfuDciFormat1aAllocInfo, ¶m->allocInfo, mBuf); + +#ifdef TFU_TDD + CMCHKUNPK(cmUnpkTknU8, ¶m->dai, mBuf); + +#endif + CMCHKUNPK(SUnpkU8, ¶m->tpcCmd, mBuf); + RETVALUE(ROK); +} + +#ifdef EMTC_ENABLE + + +/*********************************************************** +* +* Func : cmUnpkTfudciformat61aPdsch +* +* +* Desc : This structure contains the information carried in DCI format 6-1A + * when it is NOT used for a PDCCH order. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfudciformat61aPdsch +( +Tfudciformat61aPdsch *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfudciformat61aPdsch(param, mBuf) +Tfudciformat61aPdsch *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfudciformat61aPdsch) + + printf("1. cmUnpkTfudciformat61aPdsch :: Entry \n"); + CMCHKUNPK(cmUnpkTfuDciFormat6AAllocInfo, ¶m->allocInfo, mBuf); + printf("2. cmUnpkTfudciformat61aPdsch :: Entry \n"); + CMCHKUNPK(SUnpkU8, ¶m->hoppingEnbld, mBuf); + printf("3. cmUnpkTfudciformat61aPdsch :: Entry \n"); + CMCHKUNPK(SUnpkU8, ¶m->rep, mBuf); + printf("4. cmUnpkTfudciformat61aPdsch :: Entry \n"); + CMCHKUNPK(SUnpkU8, ¶m->tpcCmd, mBuf); + printf("5. cmUnpkTfudciformat61aPdsch :: Entry \n"); +#ifdef TFU_TDD + CMCHKUNPK(SUnpkU8, ¶m->dai, mBuf); + printf("6. cmUnpkTfudciformat61aPdsch :: Entry \n"); +#endif + CMCHKUNPK(SUnpkU8, ¶m->antPortAndScrId, mBuf); + printf("7. cmUnpkTfudciformat61aPdsch :: Entry \n"); + CMCHKUNPK(SUnpkU8, ¶m->isSrs, mBuf); + printf("8. cmUnpkTfudciformat61aPdsch :: Entry \n"); + CMCHKUNPK(SUnpkU8, ¶m->tPmi, mBuf); + printf("9. cmUnpkTfudciformat61aPdsch :: Entry \n"); + CMCHKUNPK(SUnpkU8, ¶m->pmiCfm, mBuf); + printf("10. cmUnpkTfudciformat61aPdsch :: Entry \n"); + CMCHKUNPK(SUnpkU8, ¶m->harqAckOffst, mBuf); + printf("11. cmUnpkTfudciformat61aPdsch :: Entry \n"); + CMCHKUNPK(SUnpkU8, ¶m->dciRep, mBuf); + printf("12. cmUnpkTfudciformat61aPdsch :: Entry \n"); + CMCHKUNPK(SUnpkU8, ¶m->isTBMsg4, mBuf); + printf("1. cmUnpkTfudciformat61aPdsch :: Passed \n"); + RETVALUE(ROK); +} +/*********************************************************** + * + * Func : cmUnpkTfuDirectIndication + * + * + * Desc : This structure contains the information that is carried in DCI + * format 6-2 in the case of a Direct information indication. + * + * + * Ret : S16 + * + * Notes: + * + * File : + * + **********************************************************/ +#ifdef ANSI +PRIVATE S16 cmUnpkTfuDirectIndication +( + TfuDirectIndication *param, + Buffer *mBuf + ) +#else +PRIVATE S16 cmUnpkTfuDirectIndication(param, mBuf) + TfuDirectIndication *param; + Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuDirectIndication) + CMCHKUNPK(SUnpkU8, ¶m->directInd, mBuf); + + + + RETVALUE(ROK); +} +/*********************************************************** + * + * Func : cmUnpkTfuDciFormat62AllocInfo + * + * + * Desc : This structure contains only the allocation information, that is part + * of DCI format 6-2. + * @details Allocation information also contains parameters necessary + * for Physical layer to process Downlink data. This structure accompanies the + * Data that is sent from MAC to PHY in the TfUiTfuDatReq primitive. + * @sa TfuDciFormat62Info + * + * + * Ret : S16 + * + * Notes: + * + * File : + * + **********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDciFormat62AllocInfo +( + TfuDciFormat62AllocInfo *param, + Buffer *mBuf + ) +#else +PUBLIC S16 cmUnpkTfuDciFormat62AllocInfo(param, mBuf) + TfuDciFormat62AllocInfo *param; + Buffer *mBuf; +#endif +{ + TRC3(cmUnpkTfuDciFormat62AllocInfo) + CMCHKUNPK(SUnpkU8, ¶m->riv, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->mcs, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->rv, mBuf); + + RETVALUE(ROK); +} + +/*********************************************************** + * + * Func : cmUnpkTfudciformat62Pdsch + * + * + * Desc : This structure contains the information carried in DCI format 6-2 + * when It is used for Paging message. + * + * + * Ret : S16 + * + * Notes: + * + * File : + * + **********************************************************/ +#ifdef ANSI +PRIVATE S16 cmUnpkTfudciformat62Pdsch +( + Tfudciformat62Pdsch *param, + Buffer *mBuf + ) +#else +PRIVATE S16 cmUnpkTfudciformat62Pdsch(param, mBuf) + Tfudciformat62Pdsch *param; + Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfudciformat62Pdsch) + + + CMCHKUNPK(cmUnpkTfuDciFormat62AllocInfo, ¶m->format62AllocInfo, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->repNum, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->dciSubRepNum, mBuf); + RETVALUE(ROK); +} + + +/*********************************************************** + * + * Func : cmUnpkTfuDciFormat62Info + * + * + * Desc : This structure contains the information needed to convey DCI format 6-2. + * @details Format can possibly carry PDSCH allocation or information needed for + * a Direct information Indication. + * + * + * + * Ret : S16 + * + * Notes: + * + * File : + * + **********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDciFormat62Info +( + TfuDciFormat62Info *param, + Buffer *mBuf + ) +#else +PUBLIC S16 cmUnpkTfuDciFormat62Info(param, mBuf) + TfuDciFormat62Info *param; + Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuDciFormat62Info) + CMCHKUNPK(SUnpkU8, ¶m->isPaging, mBuf); + switch(param->isPaging) { + case FALSE: + CMCHKUNPK(cmUnpkTfuDirectIndication, ¶m->t.directIndication, mBuf); + break; + case TRUE: + CMCHKUNPK(cmUnpkTfudciformat62Pdsch, ¶m->t.pdschInfo, mBuf); + break; + default : + RETVALUE(RFAILED); + } + + + RETVALUE(ROK); +} + + + + + + + + + + + + +/*********************************************************** + * + * Func : cmPkTfuDirectIndication + * + * + * Desc : This structure contains the information that is carried in DCI + * format 6-2 in the case of a Direct information indication. + * + * + * Ret : S16 + * + * Notes: + * + * File : + * + **********************************************************/ +#ifdef ANSI +PRIVATE S16 cmPkTfuDirectIndication +( + TfuDirectIndication *param, + Buffer *mBuf + ) +#else +PRIVATE S16 cmPkTfuDirectIndication(param, mBuf) + TfuDirectIndication *param; + Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuDirectIndication) + CMCHKPK(SPkU8, param->directInd, mBuf); + + + RETVALUE(ROK); +} + + + +/*********************************************************** + * + * Func : cmPkTfuDciFormat62AllocInfo + * + * + * Desc : This structure contains only the allocation information, that is part + * of DCI format 6-2. + * @details Allocation information also contains parameters necessary + * for Physical layer to process Downlink data. This structure accompanies the + * Data that is sent from MAC to PHY in the TfUiTfuDatReq primitive. + * @sa TfuDciFormat62Info + * + * + * Ret : S16 + * + * Notes: + * + * File : + * + **********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDciFormat62AllocInfo +( + TfuDciFormat62AllocInfo *param, + Buffer *mBuf + ) +#else +PUBLIC S16 cmPkTfuDciFormat62AllocInfo(param, mBuf) + TfuDciFormat62AllocInfo *param; + Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuDciFormat6AAllocInfo) + + CMCHKPK(SPkU8, param->rv, mBuf); + CMCHKPK(SPkU8, param->mcs, mBuf); + CMCHKPK(SPkU8, param->riv, mBuf); + + RETVALUE(ROK); +} + + + +/*********************************************************** + * + * Func : cmPkTfudciformat62Pdsch + * + * + * Desc : This structure contains the information carried in DCI format 6-2 + * when It is used for Paging message. + * + * + * Ret : S16 + * + * Notes: + * + * File : + * + **********************************************************/ +#ifdef ANSI +PRIVATE S16 cmPkTfudciformat62Pdsch +( + Tfudciformat62Pdsch *param, + Buffer *mBuf + ) +#else +PRIVATE S16 cmPkTfudciformat62Pdsch(param, mBuf) + Tfudciformat62Pdsch *param; + Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfudciformat62Pdsch) + CMCHKPK(SPkU8, param->dciSubRepNum, mBuf); + CMCHKPK(SPkU8, param->repNum, mBuf); + CMCHKPK(cmPkTfuDciFormat62AllocInfo, ¶m->format62AllocInfo, mBuf); + RETVALUE(ROK); +} + + + + +/*********************************************************** + * + * Func : cmPkTfuDciFormat62Info + * + * + * Desc : This structure contains the information needed to convey DCI format 6-2. + * @details Format can possibly carry PDSCH allocation or information needed for + * a Direct information Indication. + * + * + * + * Ret : S16 + * + * Notes: + * + * File : + * + **********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDciFormat62Info +( + TfuDciFormat62Info *param, + Buffer *mBuf + ) +#else +PUBLIC S16 cmPkTfuDciFormat62Info(param, mBuf) + TfuDciFormat62Info *param; + Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuDciFormat62Info) + + switch(param->isPaging) { + case TRUE: + CMCHKPK(cmPkTfudciformat62Pdsch, ¶m->t.pdschInfo, mBuf); + break; + case FALSE: + CMCHKPK(cmPkTfuDirectIndication, ¶m->t.directIndication, mBuf); + break; + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkU8, param->isPaging, mBuf); + + RETVALUE(ROK); +} + + + + + + +#endif + + +/*********************************************************** +* +* Func : cmPkTfuDciFormat1aInfo +* +* +* Desc : This structure contains the information needed to convey DCI format 1A. + * @details Format can possibly carry PDSCH allocation or information needed for + * a PDCCH order, used to initiate a RACH procedure in cases where UE looses + * sync with eNodeB. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDciFormat1aInfo +( +TfuDciFormat1aInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuDciFormat1aInfo(param, mBuf) +TfuDciFormat1aInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuDciFormat1aInfo) + + switch(param->isPdcchOrder) { + case FALSE: + CMCHKPK(cmPkTfudciformat1aPdsch, ¶m->t.pdschInfo, mBuf); + break; + case TRUE: + CMCHKPK(cmPkTfuPdcchOrderInfo, ¶m->t.pdcchOrder, mBuf); + break; + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkU8, param->isPdcchOrder, mBuf); + + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuDciFormat1aInfo +* +* +* Desc : This structure contains the information needed to convey DCI format 1A. + * @details Format can possibly carry PDSCH allocation or information needed for + * a PDCCH order, used to initiate a RACH procedure in cases where UE looses + * sync with eNodeB. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDciFormat1aInfo +( +TfuDciFormat1aInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDciFormat1aInfo(param, mBuf) +TfuDciFormat1aInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuDciFormat1aInfo) + + CMCHKUNPK(SUnpkU8, ¶m->isPdcchOrder, mBuf); + switch(param->isPdcchOrder) { + case TRUE: + CMCHKUNPK(cmUnpkTfuPdcchOrderInfo, ¶m->t.pdcchOrder, mBuf); + break; + case FALSE: + CMCHKUNPK(cmUnpkTfudciformat1aPdsch, ¶m->t.pdschInfo, mBuf); + break; + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuDciFormat1bInfo +* +* +* Desc : This structure contains the information needed to convey DCI format 1A. + * @details Allocation information is separated from the other control + * information carried in this format. This separation is needed as Data shall + * also carry some control information, essentially allocation information, + * along with it, in order to aid physical layer processing of the data. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDciFormat1bInfo +( +TfuDciFormat1bInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuDciFormat1bInfo(param, mBuf) +TfuDciFormat1bInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuDciFormat1bInfo) + + CMCHKPK(SPkU8, param->tpcCmd, mBuf); + +#ifdef TFU_TDD + CMCHKPK(SPkU8, param->dai, mBuf); + +#endif + CMCHKPK(cmPkTfuDciFormat1bAllocInfo, ¶m->allocInfo, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuDciFormat1bInfo +* +* +* Desc : This structure contains the information needed to convey DCI format 1A. + * @details Allocation information is separated from the other control + * information carried in this format. This separation is needed as Data shall + * also carry some control information, essentially allocation information, + * along with it, in order to aid physical layer processing of the data. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDciFormat1bInfo +( +TfuDciFormat1bInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDciFormat1bInfo(param, mBuf) +TfuDciFormat1bInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuDciFormat1bInfo) + + CMCHKUNPK(cmUnpkTfuDciFormat1bAllocInfo, ¶m->allocInfo, mBuf); + +#ifdef TFU_TDD + CMCHKUNPK(SUnpkU8, ¶m->dai, mBuf); + +#endif + CMCHKUNPK(SUnpkU8, ¶m->tpcCmd, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuDciInfo +* +* +* Desc : This structure contains the information needed to convey the possible DCI + * formats. The following are the supported formats - + * -# Format 0 - used for PUSCH scheduling + * -# Format 1 - used for PDSCH scheduling + * -# Format 1A - used for compact scheduling of PDSCH or RA procedure + * intitiated by a PDCCH order. + * -# Format 1B - used for compact scheduling of PDSCH with precoding + * information. + * -# Format 1C - used for very compact scheduling of PDSCH. + * -# Format 1D - used for compact scheduling for PDSCH with precoding + * information with power offset. + * -# Format 2 - used for PDSCH Scheduling + * -# Format 2A - used for PDSCH Scheduling + * -# Format 3 - used for power control + * -# Format 3A - used for power control +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDciInfo +( +TfuDciInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuDciInfo(param, mBuf) +TfuDciInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuDciInfo) + + switch(param->dciFormat) { +#ifdef TFU_5GTF + case TFU_DCI_FORMAT_B1: + CMCHKPK(cmPkTfuDciFormatB1B2Info, ¶m->u.formatB1Info, mBuf); + break; + case TFU_DCI_FORMAT_B2: + CMCHKPK(cmPkTfuDciFormatB1B2Info, ¶m->u.formatB2Info, mBuf); + break; + case TFU_DCI_FORMAT_A1: + CMCHKPK(cmPkTfuDciFormatA1A2Info, ¶m->u.formatA1Info, mBuf); + break; + case TFU_DCI_FORMAT_A2: + CMCHKPK(cmPkTfuDciFormatA1A2Info, ¶m->u.formatA2Info, mBuf); + break; +#endif +#ifdef EMTC_ENABLE + case TFU_DCI_FORMAT_6_2: + CMCHKPK(cmPkTfuDciFormat62Info, ¶m->u.format62Info, mBuf); + break; + case TFU_DCI_FORMAT_6_1A: + CMCHKPK(cmPkTfuDciFormat61aInfo, ¶m->u.format61aInfo, mBuf); + break; + case TFU_DCI_FORMAT_6_0A: + CMCHKPK(cmPkTfuDciFormat60aInfo, ¶m->u.format60aInfo, mBuf); + break; +#endif + case TFU_DCI_FORMAT_3A: + CMCHKPK(cmPkTfuDciFormat3AInfo, ¶m->u.format3AInfo, mBuf); + break; + case TFU_DCI_FORMAT_3: + CMCHKPK(cmPkTfuDciFormat3Info, ¶m->u.format3Info, mBuf); + break; + case TFU_DCI_FORMAT_2A: + CMCHKPK(cmPkTfuDciFormat2AInfo, ¶m->u.format2AInfo, mBuf); + break; + case TFU_DCI_FORMAT_2: + CMCHKPK(cmPkTfuDciFormat2Info, ¶m->u.format2Info, mBuf); + break; + case TFU_DCI_FORMAT_1D: + CMCHKPK(cmPkTfuDciFormat1dInfo, ¶m->u.format1dInfo, mBuf); + break; + case TFU_DCI_FORMAT_1C: + CMCHKPK(cmPkTfuDciFormat1cInfo, ¶m->u.format1cInfo, mBuf); + break; + case TFU_DCI_FORMAT_1B: + CMCHKPK(cmPkTfuDciFormat1bInfo, ¶m->u.format1bInfo, mBuf); + break; + case TFU_DCI_FORMAT_1A: + CMCHKPK(cmPkTfuDciFormat1aInfo, ¶m->u.format1aInfo, mBuf); + break; + case TFU_DCI_FORMAT_1: + CMCHKPK(cmPkTfuDciFormat1Info, ¶m->u.format1Info, mBuf); + break; + case TFU_DCI_FORMAT_0: + CMCHKPK(cmPkTfuDciFormat0Info, ¶m->u.format0Info, mBuf); + break; + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkU32, param->dciFormat, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuDciInfo +* +* +* Desc : This structure contains the information needed to convey the possible DCI + * formats. The following are the supported formats - + * -# Format 0 - used for PUSCH scheduling + * -# Format 1 - used for PDSCH scheduling + * -# Format 1A - used for compact scheduling of PDSCH or RA procedure + * intitiated by a PDCCH order. + * -# Format 1B - used for compact scheduling of PDSCH with precoding + * information. + * -# Format 1C - used for very compact scheduling of PDSCH. + * -# Format 1D - used for compact scheduling for PDSCH with precoding + * information with power offset. + * -# Format 2 - used for PDSCH Scheduling + * -# Format 2A - used for PDSCH Scheduling + * -# Format 3 - used for power control + * -# Format 3A - used for power control +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDciInfo +( +TfuDciInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDciInfo(param, mBuf) +TfuDciInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuDciInfo) + + + CMCHKUNPK(SUnpkU32, (U32 *)¶m->dciFormat, mBuf); + switch(param->dciFormat) { + case TFU_DCI_FORMAT_0: + CMCHKUNPK(cmUnpkTfuDciFormat0Info, ¶m->u.format0Info, mBuf); + break; + case TFU_DCI_FORMAT_1: + CMCHKUNPK(cmUnpkTfuDciFormat1Info, ¶m->u.format1Info, mBuf); + break; + case TFU_DCI_FORMAT_1A: + CMCHKUNPK(cmUnpkTfuDciFormat1aInfo, ¶m->u.format1aInfo, mBuf); + break; + case TFU_DCI_FORMAT_1B: + CMCHKUNPK(cmUnpkTfuDciFormat1bInfo, ¶m->u.format1bInfo, mBuf); + break; + case TFU_DCI_FORMAT_1C: + CMCHKUNPK(cmUnpkTfuDciFormat1cInfo, ¶m->u.format1cInfo, mBuf); + break; + case TFU_DCI_FORMAT_1D: + CMCHKUNPK(cmUnpkTfuDciFormat1dInfo, ¶m->u.format1dInfo, mBuf); + break; + case TFU_DCI_FORMAT_2: + CMCHKUNPK(cmUnpkTfuDciFormat2Info, ¶m->u.format2Info, mBuf); + break; + case TFU_DCI_FORMAT_2A: + CMCHKUNPK(cmUnpkTfuDciFormat2AInfo, ¶m->u.format2AInfo, mBuf); + break; + case TFU_DCI_FORMAT_3: + CMCHKUNPK(cmUnpkTfuDciFormat3Info, ¶m->u.format3Info, mBuf); + break; + case TFU_DCI_FORMAT_3A: + CMCHKUNPK(cmUnpkTfuDciFormat3AInfo, ¶m->u.format3AInfo, mBuf); + break; +#ifdef EMTC_ENABLE + case TFU_DCI_FORMAT_6_0A: + CMCHKUNPK(cmUnpkTfuDciFormat60aInfo, ¶m->u.format60aInfo, mBuf); + printf("2. cmUnpkTfuDciInfo :: dciFormat %d \n", param->dciFormat); + break; + case TFU_DCI_FORMAT_6_1A: + CMCHKUNPK(cmUnpkTfuDciFormat61aInfo, ¶m->u.format61aInfo, mBuf); + printf("2. cmUnpkTfuDciInfo :: dciFormat %d \n", param->dciFormat); + break; + case TFU_DCI_FORMAT_6_2: + CMCHKUNPK(cmUnpkTfuDciFormat62Info, ¶m->u.format62Info, mBuf); + break; + +#endif +#ifdef TFU_5GTF + case TFU_DCI_FORMAT_A1: + CMCHKUNPK(cmUnpkTfuDciFormatA1A2Info, ¶m->u.formatA1Info, mBuf); + break; + case TFU_DCI_FORMAT_A2: + CMCHKUNPK(cmUnpkTfuDciFormatA1A2Info, ¶m->u.formatA2Info, mBuf); + break; + case TFU_DCI_FORMAT_B1: + CMCHKUNPK(cmUnpkTfuDciFormatB1B2Info, ¶m->u.formatB1Info, mBuf); + break; + case TFU_DCI_FORMAT_B2: + CMCHKUNPK(cmUnpkTfuDciFormatB1B2Info, ¶m->u.formatB2Info, mBuf); + break; +#endif + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuSubbandInfo +* +* +* Desc : This structure contains the information needed to convey the start and size + * of the subband in the CQI report. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuSubbandInfo +( +TfuSubbandInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuSubbandInfo(param, mBuf) +TfuSubbandInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuSubbandInfo) + + CMCHKPK(SPkU8, param->numRb, mBuf); + CMCHKPK(SPkU8, param->rbStart, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuSubbandInfo +* +* +* Desc : This structure contains the information needed to convey the start and size + * of the subband in the CQI report. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuSubbandInfo +( +TfuSubbandInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuSubbandInfo(param, mBuf) +TfuSubbandInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuSubbandInfo) + + CMCHKUNPK(SUnpkU8, ¶m->rbStart, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numRb, mBuf); + RETVALUE(ROK); +} + + + + +/*********************************************************** +* +* Func : cmPkTfuSubbandCqiInfo +* +* +* Desc : This structure is used to convey the subbannd CQI reported. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuSubbandCqiInfo +( +TfuSubbandCqiInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuSubbandCqiInfo(param, mBuf) +TfuSubbandCqiInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuSubbandCqiInfo) + + CMCHKPK(SPkU8, param->cqiIdx, mBuf); + CMCHKPK(cmPkTfuSubbandInfo, ¶m->subband, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuSubbandCqiInfo +* +* +* Desc : This structure is used to convey the subbannd CQI reported. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuSubbandCqiInfo +( +TfuSubbandCqiInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuSubbandCqiInfo(param, mBuf) +TfuSubbandCqiInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuSubbandCqiInfo) + + CMCHKUNPK(cmUnpkTfuSubbandInfo, ¶m->subband, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->cqiIdx, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuPdcchCceInfo +* +* +* Desc : This structure conveys the CCE information. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuPdcchCceInfo +( +TfuPdcchCceInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuPdcchCceInfo(param, mBuf) +TfuPdcchCceInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuPdcchCceInfo) + + CMCHKPK(cmPkLteAggrLvl, param->aggrLvl, mBuf); + CMCHKPK(SPkU8, param->cceIdx, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuPdcchCceInfo +* +* +* Desc : This structure conveys the CCE information. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuPdcchCceInfo +( +TfuPdcchCceInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuPdcchCceInfo(param, mBuf) +TfuPdcchCceInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuPdcchCceInfo) + + CMCHKUNPK(SUnpkU8, ¶m->cceIdx, mBuf); + CMCHKUNPK(cmUnpkLteAggrLvl,(U32 *)¶m->aggrLvl, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuCqiPucchMode10 +* +* +* Desc : This structure maps to the CQI mode 10. The report could either + * convey a Rank index or a wideband CQI. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuCqiPucchMode10 +( +TfuCqiPucchMode10 *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuCqiPucchMode10(param, mBuf) +TfuCqiPucchMode10 *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuCqiPucchMode10) + + switch(param->type) { + case TFU_RPT_CQI: + CMCHKPK(SPkU8, param->u.cqi, mBuf); + break; + case TFU_RPT_RI: + CMCHKPK(SPkU8, param->u.ri, mBuf); + break; + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkU32, param->type, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuCqiPucchMode10 +* +* +* Desc : This structure maps to the CQI mode 10. The report could either + * convey a Rank index or a wideband CQI. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuCqiPucchMode10 +( +TfuCqiPucchMode10 *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuCqiPucchMode10(param, mBuf) +TfuCqiPucchMode10 *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuCqiPucchMode10) + + CMCHKUNPK(SUnpkU32, (U32 *)¶m->type, mBuf); + switch(param->type) { + case TFU_RPT_RI: + CMCHKUNPK(SUnpkU8, ¶m->u.ri, mBuf); + break; + case TFU_RPT_CQI: + CMCHKUNPK(SUnpkU8, ¶m->u.cqi, mBuf); + break; + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuCqiMode11Cqi +* +* +* Desc : This structure contains a wideband CQI, PMI and optionally a + * wideband differential CQI. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuCqiMode11Cqi +( +TfuCqiMode11Cqi *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuCqiMode11Cqi(param, mBuf) +TfuCqiMode11Cqi *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuCqiMode11Cqi) + + CMCHKPK(cmPkTknU8, ¶m->wideDiffCqi, mBuf); + CMCHKPK(SPkU8, param->pmi, mBuf); + CMCHKPK(SPkU8, param->cqi, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuCqiMode11Cqi +* +* +* Desc : This structure contains a wideband CQI, PMI and optionally a + * wideband differential CQI. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuCqiMode11Cqi +( +TfuCqiMode11Cqi *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuCqiMode11Cqi(param, mBuf) +TfuCqiMode11Cqi *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuCqiMode11Cqi) + + CMCHKUNPK(SUnpkU8, ¶m->cqi, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->pmi, mBuf); + CMCHKUNPK(cmUnpkTknU8, ¶m->wideDiffCqi, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuCqiPucchMode11 +* +* +* Desc : This structure maps to the CQI mode 11. The report could either + * convey a Rank index or a CQI report. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuCqiPucchMode11 +( +TfuCqiPucchMode11 *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuCqiPucchMode11(param, mBuf) +TfuCqiPucchMode11 *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuCqiPucchMode11) + + switch(param->type) { + case TFU_RPT_CQI: + CMCHKPK(cmPkTfuCqiMode11Cqi, ¶m->u.cqi, mBuf); + break; + case TFU_RPT_RI: + CMCHKPK(SPkU8, param->u.ri, mBuf); + break; + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkU32, param->type, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuCqiPucchMode11 +* +* +* Desc : This structure maps to the CQI mode 11. The report could either + * convey a Rank index or a CQI report. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuCqiPucchMode11 +( +TfuCqiPucchMode11 *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuCqiPucchMode11(param, mBuf) +TfuCqiPucchMode11 *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuCqiPucchMode11) + + CMCHKUNPK(SUnpkU32, (U32 *)¶m->type, mBuf); + switch(param->type) { + case TFU_RPT_RI: + CMCHKUNPK(SUnpkU8, ¶m->u.ri, mBuf); + break; + case TFU_RPT_CQI: + CMCHKUNPK(cmUnpkTfuCqiMode11Cqi, ¶m->u.cqi, mBuf); + break; + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuCqiMode20SubCqi +* +* +* Desc : This structure contains the SubBand CQI for mode 2-0. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuCqiMode20SubCqi +( +TfuCqiMode20SubCqi *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuCqiMode20SubCqi(param, mBuf) +TfuCqiMode20SubCqi *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuCqiMode20SubCqi) + + CMCHKPK(SPkU8, param->l, mBuf); + CMCHKPK(SPkU8, param->cqi, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuCqiMode20SubCqi +* +* +* Desc : This structure contains the SubBand CQI for mode 2-0. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuCqiMode20SubCqi +( +TfuCqiMode20SubCqi *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuCqiMode20SubCqi(param, mBuf) +TfuCqiMode20SubCqi *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuCqiMode20SubCqi) + + CMCHKUNPK(SUnpkU8, ¶m->cqi, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->l, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuCqiMode20Cqi +* +* +* Desc : This structure contains Mode20 CQI report. It could either be a + * wideband CQI or a sub-band CQI. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuCqiMode20Cqi +( +TfuCqiMode20Cqi *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuCqiMode20Cqi(param, mBuf) +TfuCqiMode20Cqi *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuCqiMode20Cqi) + + switch(param->isWideband) { + case FALSE: + CMCHKPK(cmPkTfuCqiMode20SubCqi, ¶m->u.subCqi, mBuf); + break; + case TRUE: + CMCHKPK(SPkU8, param->u.wideCqi, mBuf); + break; + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkU8, param->isWideband, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuCqiMode20Cqi +* +* +* Desc : This structure contains Mode20 CQI report. It could either be a + * wideband CQI or a sub-band CQI. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuCqiMode20Cqi +( +TfuCqiMode20Cqi *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuCqiMode20Cqi(param, mBuf) +TfuCqiMode20Cqi *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuCqiMode20Cqi) + + CMCHKUNPK(SUnpkU8, ¶m->isWideband, mBuf); + switch(param->isWideband) { + case TRUE: + CMCHKUNPK(SUnpkU8, ¶m->u.wideCqi, mBuf); + break; + case FALSE: + CMCHKUNPK(cmUnpkTfuCqiMode20SubCqi, ¶m->u.subCqi, mBuf); + break; + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuCqiPucchMode20 +* +* +* Desc : This structure maps to CQI mode 20. The report either contains a + * Rank Index or a CQI report. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuCqiPucchMode20 +( +TfuCqiPucchMode20 *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuCqiPucchMode20(param, mBuf) +TfuCqiPucchMode20 *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuCqiPucchMode20) + + switch(param->type) { + case TFU_RPT_CQI: + CMCHKPK(cmPkTfuCqiMode20Cqi, ¶m->u.cqi, mBuf); + break; + case TFU_RPT_RI: + CMCHKPK(SPkU8, param->u.ri, mBuf); + break; + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkU32, param->type, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuCqiPucchMode20 +* +* +* Desc : This structure maps to CQI mode 20. The report either contains a + * Rank Index or a CQI report. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuCqiPucchMode20 +( +TfuCqiPucchMode20 *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuCqiPucchMode20(param, mBuf) +TfuCqiPucchMode20 *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuCqiPucchMode20) + + CMCHKUNPK(SUnpkU32, (U32 *)¶m->type, mBuf); + switch(param->type) { + case TFU_RPT_RI: + CMCHKUNPK(SUnpkU8, ¶m->u.ri, mBuf); + break; + case TFU_RPT_CQI: + CMCHKUNPK(cmUnpkTfuCqiMode20Cqi, ¶m->u.cqi, mBuf); + break; + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuCqiMode21SubCqi +* +* +* Desc : This structure contains the sub-band CQI report for mode 2-1. + * It carries a CQI, 'L' bit sub-band label, and optionally a differential CQI. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuCqiMode21SubCqi +( +TfuCqiMode21SubCqi *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuCqiMode21SubCqi(param, mBuf) +TfuCqiMode21SubCqi *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuCqiMode21SubCqi) + + CMCHKPK(cmPkTknU8, ¶m->diffCqi, mBuf); + CMCHKPK(SPkU8, param->l, mBuf); + CMCHKPK(SPkU8, param->cqi, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuCqiMode21SubCqi +* +* +* Desc : This structure contains the sub-band CQI report for mode 2-1. + * It carries a CQI, 'L' bit sub-band label, and optionally a differential CQI. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuCqiMode21SubCqi +( +TfuCqiMode21SubCqi *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuCqiMode21SubCqi(param, mBuf) +TfuCqiMode21SubCqi *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuCqiMode21SubCqi) + + CMCHKUNPK(SUnpkU8, ¶m->cqi, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->l, mBuf); + CMCHKUNPK(cmUnpkTknU8, ¶m->diffCqi, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuCqiMode21WideCqi +* +* +* Desc : This structure contains the wideband CQI report for mode 2-1. + * It carries a wideband CQI, PMI and optionally a differential CQI. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuCqiMode21WideCqi +( +TfuCqiMode21WideCqi *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuCqiMode21WideCqi(param, mBuf) +TfuCqiMode21WideCqi *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuCqiMode21WideCqi) + + CMCHKPK(cmPkTknU8, ¶m->diffCqi, mBuf); + CMCHKPK(SPkU8, param->pmi, mBuf); + CMCHKPK(SPkU8, param->cqi, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuCqiMode21WideCqi +* +* +* Desc : This structure contains the wideband CQI report for mode 2-1. + * It carries a wideband CQI, PMI and optionally a differential CQI. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuCqiMode21WideCqi +( +TfuCqiMode21WideCqi *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuCqiMode21WideCqi(param, mBuf) +TfuCqiMode21WideCqi *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuCqiMode21WideCqi) + + CMCHKUNPK(SUnpkU8, ¶m->cqi, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->pmi, mBuf); + CMCHKUNPK(cmUnpkTknU8, ¶m->diffCqi, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuCqiMode21Cqi +* +* +* Desc : This structure conveys CQI report for mode 2-1. The reported value + * could either be wideband or sub-band. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuCqiMode21Cqi +( +TfuCqiMode21Cqi *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuCqiMode21Cqi(param, mBuf) +TfuCqiMode21Cqi *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuCqiMode21Cqi) + + switch(param->isWideband) { + case FALSE: + CMCHKPK(cmPkTfuCqiMode21SubCqi, ¶m->u.subCqi, mBuf); + break; + case TRUE: + CMCHKPK(cmPkTfuCqiMode21WideCqi, ¶m->u.wideCqi, mBuf); + break; + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkU8, param->isWideband, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuCqiMode21Cqi +* +* +* Desc : This structure conveys CQI report for mode 2-1. The reported value + * could either be wideband or sub-band. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuCqiMode21Cqi +( +TfuCqiMode21Cqi *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuCqiMode21Cqi(param, mBuf) +TfuCqiMode21Cqi *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuCqiMode21Cqi) + + CMCHKUNPK(SUnpkU8, ¶m->isWideband, mBuf); + switch(param->isWideband) { + case TRUE: + CMCHKUNPK(cmUnpkTfuCqiMode21WideCqi, ¶m->u.wideCqi, mBuf); + break; + case FALSE: + CMCHKUNPK(cmUnpkTfuCqiMode21SubCqi, ¶m->u.subCqi, mBuf); + break; + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuCqiPucchMode21 +* +* +* Desc : This structure maps to the CQI reporting mode 2-1. The report either + * conveys a Rank Indicator or a CQI report. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuCqiPucchMode21 +( +TfuCqiPucchMode21 *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuCqiPucchMode21(param, mBuf) +TfuCqiPucchMode21 *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuCqiPucchMode21) + + switch(param->type) { + case TFU_RPT_CQI: + CMCHKPK(cmPkTfuCqiMode21Cqi, ¶m->u.cqi, mBuf); + break; + case TFU_RPT_RI: + CMCHKPK(SPkU8, param->u.ri, mBuf); + break; + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkU32, param->type, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuCqiPucchMode21 +* +* +* Desc : This structure maps to the CQI reporting mode 2-1. The report either + * conveys a Rank Indicator or a CQI report. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuCqiPucchMode21 +( +TfuCqiPucchMode21 *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuCqiPucchMode21(param, mBuf) +TfuCqiPucchMode21 *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuCqiPucchMode21) + + CMCHKUNPK(SUnpkU32, (U32 *)¶m->type, mBuf); + switch(param->type) { + case TFU_RPT_RI: + CMCHKUNPK(SUnpkU8, ¶m->u.ri, mBuf); + break; + case TFU_RPT_CQI: + CMCHKUNPK(cmUnpkTfuCqiMode21Cqi, ¶m->u.cqi, mBuf); + break; + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuDlCqiPucch +* +* +* Desc : This structure conveys the Downlink CQI reported on PUCCH. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDlCqiPucch +( +TfuDlCqiPucch *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuDlCqiPucch(param, mBuf) +TfuDlCqiPucch *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuDlCqiPucch) + + switch(param->mode) { + case TFU_PUCCH_CQI_MODE21: + CMCHKPK(cmPkTfuCqiPucchMode21, ¶m->u.mode21Info, mBuf); + break; + case TFU_PUCCH_CQI_MODE20: + CMCHKPK(cmPkTfuCqiPucchMode20, ¶m->u.mode20Info, mBuf); + break; + case TFU_PUCCH_CQI_MODE11: + CMCHKPK(cmPkTfuCqiPucchMode11, ¶m->u.mode11Info, mBuf); + break; + case TFU_PUCCH_CQI_MODE10: + CMCHKPK(cmPkTfuCqiPucchMode10, ¶m->u.mode10Info, mBuf); + break; + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkU32, param->mode, mBuf); + CMCHKPK(SPkU8, param->cellIdx, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuDlCqiPucch +* +* +* Desc : This structure conveys the Downlink CQI reported on PUCCH. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDlCqiPucch +( +TfuDlCqiPucch *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDlCqiPucch(param, mBuf) +TfuDlCqiPucch *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuDlCqiPucch) + + CMCHKUNPK(SUnpkU8, ¶m->cellIdx, mBuf); + CMCHKUNPK(SUnpkU32, (U32 *)¶m->mode, mBuf); + switch(param->mode) { + case TFU_PUCCH_CQI_MODE10: + CMCHKUNPK(cmUnpkTfuCqiPucchMode10, ¶m->u.mode10Info, mBuf); + break; + case TFU_PUCCH_CQI_MODE11: + CMCHKUNPK(cmUnpkTfuCqiPucchMode11, ¶m->u.mode11Info, mBuf); + break; + case TFU_PUCCH_CQI_MODE20: + CMCHKUNPK(cmUnpkTfuCqiPucchMode20, ¶m->u.mode20Info, mBuf); + break; + case TFU_PUCCH_CQI_MODE21: + CMCHKUNPK(cmUnpkTfuCqiPucchMode21, ¶m->u.mode21Info, mBuf); + break; + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuSubbandMode12 +* +* +* Desc : This structure carries subband information and PMI, in the CQI + * reporting format 1-2. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuSubbandMode12 +( +TfuSubbandMode12 *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuSubbandMode12(param, mBuf) +TfuSubbandMode12 *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuSubbandMode12) + + CMCHKPK(cmPkTfuSubbandInfo, ¶m->subBand, mBuf); + CMCHKPK(SPkU8, param->pmi, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuSubbandMode12 +* +* +* Desc : This structure carries subband information and PMI, in the CQI + * reporting format 1-2. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuSubbandMode12 +( +TfuSubbandMode12 *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuSubbandMode12(param, mBuf) +TfuSubbandMode12 *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuSubbandMode12) + + CMCHKUNPK(SUnpkU8, ¶m->pmi, mBuf); + CMCHKUNPK(cmUnpkTfuSubbandInfo, ¶m->subBand, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuCqiPuschMode12 +* +* +* Desc : This structure conveys information present in CQI reporting mode 1-2 received + * over PUSCH. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuCqiPuschMode12 +( +TfuCqiPuschMode12 *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuCqiPuschMode12(param, mBuf) +TfuCqiPuschMode12 *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkTfuCqiPuschMode12) + + for (i=TFU_MAX_DL_SUBBAND-1; i >= 0; i--) { + CMCHKPK(cmPkTfuSubbandMode12, ¶m->subbandArr[i], mBuf); + } + for (i=TFU_MAX_TB-1; i >= 0; i--) { + CMCHKPK(SPkU8, param->cqiIdx[i], mBuf); + } + CMCHKPK(SPkU8, param->numSubband, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuCqiPuschMode12 +* +* +* Desc : This structure conveys information present in CQI reporting mode 1-2 received + * over PUSCH. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuCqiPuschMode12 +( +TfuCqiPuschMode12 *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuCqiPuschMode12(param, mBuf) +TfuCqiPuschMode12 *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmUnpkTfuCqiPuschMode12) + + CMCHKUNPK(SUnpkU8, ¶m->numSubband, mBuf); + for (i=0; icqiIdx[i], mBuf); + } + for (i=0; isubbandArr[i], mBuf); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuCqiPuschMode20 +* +* +* Desc : This structure conveys information present in CQI reporting mode 2-0 received + * over PUSCH. This mode is for UE selected sub-band feedback. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuCqiPuschMode20 +( +TfuCqiPuschMode20 *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuCqiPuschMode20(param, mBuf) +TfuCqiPuschMode20 *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkTfuCqiPuschMode20) + + for (i=TFU_MAX_DL_SUBBAND-1; i >= 0; i--) { + CMCHKPK(cmPkTfuSubbandInfo, ¶m->subbandArr[i], mBuf); + } + CMCHKPK(SPkU8, param->numSubband, mBuf); + CMCHKPK(SPkU8, param->wideBandCqi, mBuf); + CMCHKPK(SPkU8, param->cqiIdx, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuCqiPuschMode20 +* +* +* Desc : This structure conveys information present in CQI reporting mode 2-0 received + * over PUSCH. This mode is for UE selected sub-band feedback. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuCqiPuschMode20 +( +TfuCqiPuschMode20 *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuCqiPuschMode20(param, mBuf) +TfuCqiPuschMode20 *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmUnpkTfuCqiPuschMode20) + + CMCHKUNPK(SUnpkU8, ¶m->cqiIdx, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->wideBandCqi, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numSubband, mBuf); + for (i=0; isubbandArr[i], mBuf); + } + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func : cmPkTfuCqiPuschMode22 +* +* +* Desc : This structure conveys information present in CQI reporting mode 2-2 received + * over PUSCH. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuCqiPuschMode22 +( +TfuCqiPuschMode22 *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuCqiPuschMode22(param, mBuf) +TfuCqiPuschMode22 *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkTfuCqiPuschMode22) + + + for (i=TFU_MAX_DL_SUBBAND-1; i >= 0; i--) { + CMCHKPK(cmPkTfuSubbandInfo, ¶m->subbandArr[i], mBuf); + } + + CMCHKPK(SPkU8, param->numSubband, mBuf); + CMCHKPK(SPkU8, param->wideBandPmi, mBuf); + for (i=TFU_MAX_TB-1; i >= 0; i--) { + CMCHKPK(SPkU8, param->wideBandCqi[i], mBuf); + } + CMCHKPK(SPkU8, param->pmi, mBuf); + for (i=TFU_MAX_TB-1; i >= 0; i--) { + CMCHKPK(SPkU8, param->cqi[i], mBuf); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuCqiPuschMode22 +* +* +* Desc : This structure conveys information present in CQI reporting mode 2-2 received + * over PUSCH. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuCqiPuschMode22 +( +TfuCqiPuschMode22 *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuCqiPuschMode22(param, mBuf) +TfuCqiPuschMode22 *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmUnpkTfuCqiPuschMode22) + + for (i=0; icqi[i], mBuf); + } + CMCHKUNPK(SUnpkU8, ¶m->pmi, mBuf); + for (i=0; iwideBandCqi[i], mBuf); + } + CMCHKUNPK(SUnpkU8, ¶m->wideBandPmi, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numSubband, mBuf); + + for (i=0; isubbandArr[i], mBuf); + } + + RETVALUE(ROK); +} + + +#ifdef ANSI +PUBLIC S16 cmPkTfuSubbandMode30 +( +TfuSubbandMode30 *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuSubbandMode30(param, mBuf) +TfuSubbandMode30 *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuSubbandMode30) + + CMCHKPK(cmPkTfuSubbandInfo, ¶m->subBand, mBuf); + CMCHKPK(SPkU8, param->cqi, mBuf); + RETVALUE(ROK); +} + + +#ifdef ANSI +PUBLIC S16 cmUnpkTfuSubbandMode30 +( +TfuSubbandMode30 *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuSubbandMode30(param, mBuf) +TfuSubbandMode30 *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuSubbandMode30) + + CMCHKUNPK(SUnpkU8, ¶m->cqi, mBuf); + CMCHKUNPK(cmUnpkTfuSubbandInfo, ¶m->subBand, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuCqiPuschMode30 +* +* +* Desc : This structure conveys information present in CQI reporting mode 3-0 + * received over PUSCH. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuCqiPuschMode30 +( +TfuCqiPuschMode30 *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuCqiPuschMode30(param, mBuf) +TfuCqiPuschMode30 *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkTfuCqiPuschMode30) + + for (i=TFU_MAX_DL_SUBBAND-1; i >= 0; i--) { + CMCHKPK(cmPkTfuSubbandMode30, ¶m->subbandArr[i], mBuf); + } + CMCHKPK(SPkU8, param->numSubband, mBuf); + CMCHKPK(SPkU8, param->wideBandCqi, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuCqiPuschMode30 +* +* +* Desc : This structure conveys information present in CQI reporting mode 3-0 + * received over PUSCH. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuCqiPuschMode30 +( +TfuCqiPuschMode30 *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuCqiPuschMode30(param, mBuf) +TfuCqiPuschMode30 *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmUnpkTfuCqiPuschMode30) + + CMCHKUNPK(SUnpkU8, ¶m->wideBandCqi, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numSubband, mBuf); + for (i=0; isubbandArr[i], mBuf); + } + RETVALUE(ROK); +} + + +#ifdef ANSI +PUBLIC S16 cmPkTfuSubbandMode31 +( +TfuSubbandMode31 *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuSubbandMode31(param, mBuf) +TfuSubbandMode31 *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkTfuSubbandMode31) + + CMCHKPK(cmPkTfuSubbandInfo, ¶m->subBand, mBuf); + for (i=TFU_MAX_TB-1; i >= 0; i--) { + CMCHKPK(SPkU8, param->cqi[i], mBuf); + } + RETVALUE(ROK); +} + + +#ifdef ANSI +PUBLIC S16 cmUnpkTfuSubbandMode31 +( +TfuSubbandMode31 *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuSubbandMode31(param, mBuf) +TfuSubbandMode31 *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmUnpkTfuSubbandMode31) + + for (i=0; icqi[i], mBuf); + } + CMCHKUNPK(cmUnpkTfuSubbandInfo, ¶m->subBand, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuCqiPuschMode31 +* +* +* Desc : This structure conveys information present in CQI reporting mode 3-1 + * received over PUSCH. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuCqiPuschMode31 +( +TfuCqiPuschMode31 *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuCqiPuschMode31(param, mBuf) +TfuCqiPuschMode31 *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkTfuCqiPuschMode31) + + +/* tfu_c_001.main_4 - Changes for MIMO feature addition */ +/* tfu_c_001.main_5 - Removed dependency on MIMO compile-time flag */ + +/* tfu_c_001.main_4 - Changes for MIMO feature addition */ +/* tfu_c_001.main_5 - Removed dependency on MIMO compile-time flag */ + for (i=param->numSubband-1; i >= 0; i--) { + CMCHKPK(cmPkTfuSubbandDlCqiInfo, ¶m->subbandCqiArr[i], mBuf); + } + + CMCHKPK(SPkU8, param->numSubband, mBuf); + for (i=TFU_MAX_TB-1; i >= 0; i--) { + CMCHKPK(SPkU8, param->wideBandCqi[i], mBuf); + } + CMCHKPK(SPkU8, param->pmi, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuCqiPuschMode31 +* +* +* Desc : This structure conveys information present in CQI reporting mode 3-1 + * received over PUSCH. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuCqiPuschMode31 +( +TfuCqiPuschMode31 *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuCqiPuschMode31(param, mBuf) +TfuCqiPuschMode31 *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmUnpkTfuCqiPuschMode31) + + CMCHKUNPK(SUnpkU8, ¶m->pmi, mBuf); + for (i=0; iwideBandCqi[i], mBuf); + } + CMCHKUNPK(SUnpkU8, ¶m->numSubband, mBuf); + +/* tfu_c_001.main_4 - Changes for MIMO feature addition */ +/* tfu_c_001.main_5 - Removed dependency on MIMO compile-time flag */ + for (i=0; inumSubband; i++) { + CMCHKUNPK(cmUnpkTfuSubbandDlCqiInfo, ¶m->subbandCqiArr[i], mBuf); + } + + +/* tfu_c_001.main_4 - Changes for MIMO feature addition */ +/* tfu_c_001.main_5 - Removed dependency on MIMO compile-time flag */ + + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuDlCqiPusch +* +* +* Desc : This structure conveys Downlink CQI information (mode and corresponding + * CQI) received over PUSCH. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDlCqiPusch +( +TfuDlCqiPusch *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuDlCqiPusch(param, mBuf) +TfuDlCqiPusch *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuDlCqiPusch) + + switch(param->mode) { + case TFU_PUSCH_CQI_MODE_31: + CMCHKPK(cmPkTfuCqiPuschMode31, ¶m->u.mode31Info, mBuf); + break; + case TFU_PUSCH_CQI_MODE_30: + CMCHKPK(cmPkTfuCqiPuschMode30, ¶m->u.mode30Info, mBuf); + break; + case TFU_PUSCH_CQI_MODE_22: + CMCHKPK(cmPkTfuCqiPuschMode22, ¶m->u.mode22Info, mBuf); + break; + case TFU_PUSCH_CQI_MODE_20: + CMCHKPK(cmPkTfuCqiPuschMode20, ¶m->u.mode20Info, mBuf); + break; + case TFU_PUSCH_CQI_MODE_12: + CMCHKPK(cmPkTfuCqiPuschMode12, ¶m->u.mode12Info, mBuf); + break; + default : + RETVALUE(RFAILED); + } + + CMCHKPK(cmPkTknU8, ¶m->ri, mBuf); + CMCHKPK(SPkU32, param->mode, mBuf); + + CMCHKPK(SPkU8, param->cellIdx, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuDlCqiPusch +* +* +* Desc : This structure conveys Downlink CQI information (mode and corresponding + * CQI) received over PUSCH. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDlCqiPusch +( +TfuDlCqiPusch *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDlCqiPusch(param, mBuf) +TfuDlCqiPusch *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuDlCqiPusch) + + CMCHKUNPK(SUnpkU8, ¶m->cellIdx, mBuf); + CMCHKUNPK(SUnpkU32, (U32 *)¶m->mode, mBuf); + CMCHKUNPK(cmUnpkTknU8, ¶m->ri, mBuf); + switch(param->mode) { + case TFU_PUSCH_CQI_MODE_12: + CMCHKUNPK(cmUnpkTfuCqiPuschMode12, ¶m->u.mode12Info, mBuf); + break; + case TFU_PUSCH_CQI_MODE_20: + CMCHKUNPK(cmUnpkTfuCqiPuschMode20, ¶m->u.mode20Info, mBuf); + break; + case TFU_PUSCH_CQI_MODE_22: + CMCHKUNPK(cmUnpkTfuCqiPuschMode22, ¶m->u.mode22Info, mBuf); + break; + case TFU_PUSCH_CQI_MODE_30: + CMCHKUNPK(cmUnpkTfuCqiPuschMode30, ¶m->u.mode30Info, mBuf); + break; + case TFU_PUSCH_CQI_MODE_31: + CMCHKUNPK(cmUnpkTfuCqiPuschMode31, ¶m->u.mode31Info, mBuf); + break; + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func : cmPkTfuDlCqiInfo +* +* +* Desc : This structure contains CQI information received over PUCCH or PUSCH. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDlCqiInfo +( +U8 selector, +TfuDlCqiInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuDlCqiInfo(selector, param, mBuf) +U8 selector; +TfuDlCqiInfo *param; +Buffer *mBuf; +#endif +{ + U32 idx; + + TRC3(cmPkTfuDlCqiInfo) + + switch(selector) { + case FALSE: + for (idx = 0; idx < param->pusch.numOfCells; idx++) + { + CMCHKPK(cmPkTfuDlCqiPusch, ¶m->pusch.puschCqi[idx], mBuf); + } + CMCHKPK(SPkU8, param->pusch.numOfCells, mBuf); + break; + case TRUE: + CMCHKPK(cmPkTfuDlCqiPucch, ¶m->pucchCqi, mBuf); + break; + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuDlCqiInfo +* +* +* Desc : This structure contains CQI information received over PUCCH or PUSCH. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDlCqiInfo +( +U8 selector, +TfuDlCqiInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDlCqiInfo(selector, param, mBuf) +U8 selector; +TfuDlCqiInfo *param; +Buffer *mBuf; +#endif +{ + + U8 idx; + TRC3(cmUnpkTfuDlCqiInfo) + + switch(selector) { + case TRUE: + CMCHKUNPK(cmUnpkTfuDlCqiPucch, ¶m->pucchCqi, mBuf); + break; + case FALSE: + CMCHKUNPK(SUnpkU8, ¶m->pusch.numOfCells, mBuf); + for (idx = param->pusch.numOfCells; idx > 0; idx--) + { + CMCHKUNPK(cmUnpkTfuDlCqiPusch, ¶m->pusch.puschCqi[idx-1], mBuf); + } + break; + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuRecpReqInfo +* +* +* Desc : This structure is sent from Scheduler to PHY. This includes params + * needed by PHY to decode the following + * 1. DATA on PUSCH + * 2. HARQ Feedback on PUCCH + * 3. CQI Report + * 4. RI Report + * 5. SR Indications. + * This structure carries the reception information for all the scheduled UE. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuRecpReqInfo +( +TfuRecpReqInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuRecpReqInfo(param, mBuf) +TfuRecpReqInfo *param; +Buffer *mBuf; +#endif +{ + CmLList *node; + U32 count; + TfuUeRecpReqInfo *tfuUeRecpReqInfo; + + TRC3(cmPkTfuRecpReqInfo) + + /*ccpu00116923 - ADD - SRS present support*/ + /*tfu_c_001.main_7 - ADD - SRS present field inclusion */ +#ifdef TFU_UPGRADE + CMCHKPK(SPkU8, param->srsPres, mBuf); +#endif + count = param->ueRecpReqLst.count; + node = param->ueRecpReqLst.last; + while (node) { + tfuUeRecpReqInfo = (TfuUeRecpReqInfo *)node->node; + node=node->prev; + CMCHKPK(cmPkTfuUeRecpReqInfo, tfuUeRecpReqInfo, mBuf); + cmLListDelFrm(¶m->ueRecpReqLst, &tfuUeRecpReqInfo->lnk); + tfuUeRecpReqInfo->lnk.node = (PTR)NULLP; + } + CMCHKPK(SPkU32, count, mBuf); + CMCHKPK(cmPkLteTimingInfo, ¶m->timingInfo, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuRecpReqInfo +* +* +* Desc : This structure is sent from Scheduler to PHY. This includes params + * needed by PHY to decode the following + * 1. DATA on PUSCH + * 2. HARQ Feedback on PUCCH + * 3. CQI Report + * 4. RI Report + * 5. SR Indications. + * This structure carries the reception information for all the scheduled UE. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuRecpReqInfo +( +TfuRecpReqInfo *param, +Ptr memCp, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuRecpReqInfo(param, memCp, mBuf) +TfuRecpReqInfo *param; +Ptr memCp; +Buffer *mBuf; +#endif +{ + + U32 count, loopCnt; + TfuUeRecpReqInfo *tfuUeRecpReqInfo; + + TRC3(cmUnpkTfuRecpReqInfo) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteTimingInfo, ¶m->timingInfo, mBuf); + cmLListInit(¶m->ueRecpReqLst); + CMCHKUNPK(SUnpkU32, &count, mBuf); + for (loopCnt=0; loopCntueRecpReqLst, &tfuUeRecpReqInfo->lnk); + tfuUeRecpReqInfo->lnk.node = (PTR)tfuUeRecpReqInfo; + } + /*ccpu00116923 - ADD - SRS present support*/ + /*tfu_c_001.main_7 - ADD - SRS present field inclusion */ +#ifdef TFU_UPGRADE + CMCHKUNPK(SUnpkU8, ¶m->srsPres, mBuf); +#endif + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuPdcchInfo +* +* +* Desc : This structure contains the PDCCH to be sent on PHY i.e. DCI + * formats. This information is associated with an RNTI. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuPdcchInfo +( +TfuPdcchInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuPdcchInfo(param, mBuf) +TfuPdcchInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuPdcchInfo) +#ifdef TFU_5GTF + CMCHKPK(SPkU8, param->grpId, mBuf); + CMCHKPK(SPkU8, param->sccIdx, mBuf); + CMCHKPK(SPkU8, param->sectorId, mBuf); +#endif /* TFU_5GTF */ + CMCHKPK(cmPkTfuDciInfo, ¶m->dci, mBuf); + CMCHKPK(SPkU8, param->dciNumOfBits, mBuf); + CMCHKPK(cmPkLteAggrLvl, param->aggrLvl, mBuf); + CMCHKPK(SPkU16, param->nCce, mBuf); +#ifdef LTEMAC_SPS + CMCHKPK(cmPkLteRnti, param->crnti, mBuf); + CMCHKPK(SPkU8, param->isSpsRnti, mBuf); +#endif + CMCHKPK(cmPkLteRnti, param->rnti, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuPdcchInfo +* +* +* Desc : This structure contains the PDCCH to be sent on PHY i.e. DCI + * formats. This information is associated with an RNTI. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuPdcchInfo +( +TfuPdcchInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuPdcchInfo(param, mBuf) +TfuPdcchInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuPdcchInfo) + + CMCHKUNPK(cmUnpkLteRnti, ¶m->rnti, mBuf); +#ifdef LTEMAC_SPS + CMCHKUNPK(SUnpkU8, ¶m->isSpsRnti, mBuf); + CMCHKUNPK(cmUnpkLteRnti, ¶m->crnti, mBuf); +#endif + CMCHKUNPK(SUnpkU16, ¶m->nCce, mBuf); + CMCHKUNPK(cmUnpkLteAggrLvl, (U32*)¶m->aggrLvl, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->dciNumOfBits, mBuf); + CMCHKUNPK(cmUnpkTfuDciInfo, ¶m->dci, mBuf); +#ifdef TFU_5GTF + CMCHKUNPK(SUnpkU8, ¶m->sectorId, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->sccIdx, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->grpId, mBuf); +#endif /* TFU_5GTF */ + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuPhichInfo +* +* +* Desc : This structure contains one PHICH information. In order to locate the + * resources to be used for PHICH the following information is provided along + * with the feedback - + * -# rbStart + * -# nDmrs +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuPhichInfo +( +TfuPhichInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuPhichInfo(param, mBuf) +TfuPhichInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuPhichInfo) +/* tfu_c_001.main_7. Added changes of TFU_UPGRADE */ +#ifdef TFU_UPGRADE + CMCHKPK(SPkU16, param->txPower, mBuf); +#endif +#ifdef TFU_TDD + CMCHKPK(SPkU8, param->iPhich, mBuf); +#endif + CMCHKPK(SPkU8, param->isAck, mBuf); + CMCHKPK(SPkU8, param->nDmrs, mBuf); + CMCHKPK(SPkU8, param->rbStart, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuPhichInfo +* +* +* Desc : This structure contains one PHICH information. In order to locate the + * resources to be used for PHICH the following information is provided along + * with the feedback - + * -# rbStart + * -# nDmrs +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuPhichInfo +( +TfuPhichInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuPhichInfo(param, mBuf) +TfuPhichInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuPhichInfo) + + CMCHKUNPK(SUnpkU8, ¶m->rbStart, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->nDmrs, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->isAck, mBuf); +/* tfu_c_001.main_7. Added changes of TFU_UPGRADE */ +#ifdef TFU_TDD + CMCHKUNPK(SUnpkU8, ¶m->iPhich, mBuf); +#endif +#ifdef TFU_UPGRADE + CMCHKUNPK(SUnpkU16, ¶m->txPower, mBuf); +#endif + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuCntrlReqInfo +* +* +* Desc : This structure is sent from Scheduler to PHY. This includes all the + * control information to be sent to the UE. + * -# PDCCH Physical Downlink Control Channel + * -# PHICH Physical HARQ Indicator Channel + * -# PCFICH Physical Control Format Indicator Channel +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuCntrlReqInfo +( +TfuCntrlReqInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuCntrlReqInfo(param, mBuf) +TfuCntrlReqInfo *param; +Buffer *mBuf; +#endif +{ + + TfuPdcchInfo *tfuPdcchInfo; + TfuPhichInfo *tfuPhichInfo; + CmLList *node; + U32 count; + + TRC3(cmPkTfuCntrlReqInfo) +#ifdef EMTC_ENABLE + count = param->dlMpdcchLst.count; + node = param->dlMpdcchLst.last; + while (node) { + tfuPdcchInfo = (TfuPdcchInfo *)node->node; + node=node->prev; + CMCHKPK(cmPkTfuPdcchInfo, tfuPdcchInfo, mBuf); + cmLListDelFrm(¶m->dlMpdcchLst, &tfuPdcchInfo->lnk); + tfuPdcchInfo->lnk.node = (PTR)NULLP; + } + CMCHKPK(SPkU32, count, mBuf); + count = param->ulMpdcchLst.count; + node = param->ulMpdcchLst.last; + while (node) { + tfuPdcchInfo = (TfuPdcchInfo *)node->node; + node=node->prev; + CMCHKPK(cmPkTfuPdcchInfo, tfuPdcchInfo, mBuf); + cmLListDelFrm(¶m->ulMpdcchLst, &tfuPdcchInfo->lnk); + tfuPdcchInfo->lnk.node = (PTR)NULLP; + } + CMCHKPK(SPkU32, count, mBuf); +#endif +#ifdef LTEMAC_SPS /* SPS_NEW_CHGS */ + CMCHKPK(cmPkBool, param->isSPSOcc, mBuf); +#endif + count = param->phichLst.count; + node = param->phichLst.last; + while (node) { + tfuPhichInfo = (TfuPhichInfo *)node->node; + node=node->prev; + CMCHKPK(cmPkTfuPhichInfo, tfuPhichInfo, mBuf); + cmLListDelFrm(¶m->phichLst, &tfuPhichInfo->lnk); + tfuPhichInfo->lnk.node = (PTR)NULLP; + } + CMCHKPK(SPkU32, count, mBuf); + count = param->dlPdcchLst.count; + node = param->dlPdcchLst.last; + while (node) { + tfuPdcchInfo = (TfuPdcchInfo *)node->node; + node=node->prev; + CMCHKPK(cmPkTfuPdcchInfo, tfuPdcchInfo, mBuf); + cmLListDelFrm(¶m->dlPdcchLst, &tfuPdcchInfo->lnk); + tfuPdcchInfo->lnk.node = (PTR)NULLP; + } + CMCHKPK(SPkU32, count, mBuf); + count = param->ulPdcchLst.count; + node = param->ulPdcchLst.last; + while (node) { + tfuPdcchInfo = (TfuPdcchInfo *)node->node; + node=node->prev; +#ifdef UL_ADPT_DBG + printf("ulPdcchLst count %d time[ %d %d] \n",count,param->ulTiming.sfn,param->ulTiming.subframe); +#endif + CMCHKPK(cmPkTfuPdcchInfo, tfuPdcchInfo, mBuf); + cmLListDelFrm(¶m->ulPdcchLst, &tfuPdcchInfo->lnk); + tfuPdcchInfo->lnk.node = (PTR)NULLP; + } + CMCHKPK(SPkU32, count, mBuf); + CMCHKPK(SPkU8, param->cfi, mBuf); + CMCHKPK(cmPkLteTimingInfo, ¶m->dlTiming, mBuf); + CMCHKPK(cmPkLteTimingInfo, ¶m->ulTiming, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuCntrlReqInfo +* +* +* Desc : This structure is sent from Scheduler to PHY. This includes all the + * control information to be sent to the UE. + * -# PDCCH Physical Downlink Control Channel + * -# PHICH Physical HARQ Indicator Channel + * -# PCFICH Physical Control Format Indicator Channel +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuCntrlReqInfo +( +TfuCntrlReqInfo *param, +Ptr memCp, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuCntrlReqInfo(param, memCp, mBuf) +TfuCntrlReqInfo *param; +Ptr memCp; +Buffer *mBuf; +#endif +{ + + TfuPdcchInfo *tfuPdcchInfo; + U32 count, loopCnt; + TfuPhichInfo *tfuPhichInfo; + + TRC3(cmUnpkTfuCntrlReqInfo) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteTimingInfo, ¶m->ulTiming, mBuf); + CMCHKUNPK(cmUnpkLteTimingInfo, ¶m->dlTiming, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->cfi, mBuf); + cmLListInit(¶m->ulPdcchLst); + CMCHKUNPK(SUnpkU32, &count, mBuf); + for (loopCnt=0; loopCntulPdcchLst, &tfuPdcchInfo->lnk); + tfuPdcchInfo->lnk.node = (PTR)tfuPdcchInfo; + } + cmLListInit(¶m->dlPdcchLst); + CMCHKUNPK(SUnpkU32, &count, mBuf); + for (loopCnt=0; loopCntdlPdcchLst, &tfuPdcchInfo->lnk); + tfuPdcchInfo->lnk.node = (PTR)tfuPdcchInfo; + } + cmLListInit(¶m->phichLst); + CMCHKUNPK(SUnpkU32, &count, mBuf); + for (loopCnt=0; loopCntphichLst, &tfuPhichInfo->lnk); + tfuPhichInfo->lnk.node = (PTR)tfuPhichInfo; + } + +#ifdef LTEMAC_SPS /* SPS_NEW_CHGS */ + CMCHKUNPK(cmUnpkBool, ¶m->isSPSOcc, mBuf); +#endif +#ifdef EMTC_ENABLE + cmLListInit(¶m->ulMpdcchLst); + CMCHKUNPK(SUnpkU32, &count, mBuf); + for (loopCnt=0; loopCntulMpdcchLst, &tfuPdcchInfo->lnk); + tfuPdcchInfo->lnk.node = (PTR)tfuPdcchInfo; + } + cmLListInit(¶m->dlMpdcchLst); + CMCHKUNPK(SUnpkU32, &count, mBuf); + printf("4. cmUnpkTfuCntrlReqInfo :: count %ld \n", count); + for (loopCnt=0; loopCntdlMpdcchLst, &tfuPdcchInfo->lnk); + tfuPdcchInfo->lnk.node = (PTR)tfuPdcchInfo; + printf("5. cmUnpkTfuCntrlReqInfo :: Failed \n"); + } +#endif + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuPdschDciInfo +* +* +* Desc : This structure Carries the control information that would be needed + * by the Physical layer to process the data to be sent on PDSCH. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuPdschDciInfo +( +TfuPdschDciInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuPdschDciInfo(param, mBuf) +TfuPdschDciInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuPdschDciInfo) + + switch(param->format) { +#ifdef TFU_5GTF + case TFU_DCI_FORMAT_B1: + /* + if (param->u.formatB1Info.RBAssign <= 324) + { + printf("DCI Format: [B1] RBAssign: [%d] MCS: [%d]", + param->u.formatB1Info.RBAssign, + param->u.formatB1Info.u.rbAssignB1Val324.mcs); + } + */ + CMCHKPK(cmPkTfuDciFormatB1B2Info, ¶m->u.formatB1Info, mBuf); + break; + case TFU_DCI_FORMAT_B2: + /* + if (param->u.formatB2Info.RBAssign <= 324) + { + printf("DCI Format: [B2] RBAssign: [%d] MCS: [%d]", + param->u.formatB2Info.RBAssign, + param->u.formatB2Info.u.rbAssignB1Val324.mcs); + } + */ + CMCHKPK(cmPkTfuDciFormatB1B2Info, ¶m->u.formatB2Info, mBuf); + break; + case TFU_DCI_FORMAT_A1: + CMCHKPK(cmPkTfuDciFormatA1A2Info, ¶m->u.formatA1Info, mBuf); + break; + case TFU_DCI_FORMAT_A2: + CMCHKPK(cmPkTfuDciFormatA1A2Info, ¶m->u.formatA2Info, mBuf); + break; +#endif +#ifdef EMTC_ENABLE + case TFU_DCI_FORMAT_6_2: + CMCHKPK(cmPkTfuDciFormat62AllocInfo, ¶m->u.format62AllocInfo, mBuf); + break; + case TFU_DCI_FORMAT_6_1A: + CMCHKPK(cmPkTfuDciFormat6AAllocInfo, ¶m->u.format61AllocInfo, mBuf); + break; +#endif + case TFU_DCI_FORMAT_2A: + CMCHKPK(cmPkTfuDciFormat2AAllocInfo, ¶m->u.format2AAllocInfo, mBuf); + break; + case TFU_DCI_FORMAT_2: + CMCHKPK(cmPkTfuDciFormat2AllocInfo, ¶m->u.format2AllocInfo, mBuf); + break; + case TFU_DCI_FORMAT_1D: + CMCHKPK(cmPkTfuDciFormat1dAllocInfo, ¶m->u.format1dAllocInfo, mBuf); + break; + case TFU_DCI_FORMAT_1C: + CMCHKPK(cmPkTfuDciFormat1cInfo, ¶m->u.format1cAllocInfo, mBuf); + break; + case TFU_DCI_FORMAT_1B: + CMCHKPK(cmPkTfuDciFormat1bAllocInfo, ¶m->u.format1bAllocInfo, mBuf); + break; + case TFU_DCI_FORMAT_1A: + CMCHKPK(cmPkTfuDciFormat1aAllocInfo, ¶m->u.format1aAllocInfo, mBuf); + break; + case TFU_DCI_FORMAT_1: + CMCHKPK(cmPkTfuDciFormat1AllocInfo, ¶m->u.format1AllocInfo, mBuf); + break; + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkU32, param->format, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuPdschDciInfo +* +* +* Desc : This structure Carries the control information that would be needed + * by the Physical layer to process the data to be sent on PDSCH. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuPdschDciInfo +( +TfuPdschDciInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuPdschDciInfo(param, mBuf) +TfuPdschDciInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuPdschDciInfo) + + CMCHKUNPK(SUnpkU32, (U32 *)¶m->format, mBuf); + switch(param->format) { + case TFU_DCI_FORMAT_1: + CMCHKUNPK(cmUnpkTfuDciFormat1AllocInfo, ¶m->u.format1AllocInfo, mBuf); + break; + case TFU_DCI_FORMAT_1A: + CMCHKUNPK(cmUnpkTfuDciFormat1aAllocInfo, ¶m->u.format1aAllocInfo, mBuf); + break; + case TFU_DCI_FORMAT_1B: + CMCHKUNPK(cmUnpkTfuDciFormat1bAllocInfo, ¶m->u.format1bAllocInfo, mBuf); + break; + case TFU_DCI_FORMAT_1C: + CMCHKUNPK(cmUnpkTfuDciFormat1cInfo, ¶m->u.format1cAllocInfo, mBuf); + break; + case TFU_DCI_FORMAT_1D: + CMCHKUNPK(cmUnpkTfuDciFormat1dAllocInfo, ¶m->u.format1dAllocInfo, mBuf); + break; + case TFU_DCI_FORMAT_2: + CMCHKUNPK(cmUnpkTfuDciFormat2AllocInfo, ¶m->u.format2AllocInfo, mBuf); + break; + case TFU_DCI_FORMAT_2A: + CMCHKUNPK(cmUnpkTfuDciFormat2AAllocInfo, ¶m->u.format2AAllocInfo, mBuf); + break; +#ifdef EMTC_ENABLE + case TFU_DCI_FORMAT_6_1A: + CMCHKUNPK(cmUnpkTfuDciFormat6AAllocInfo, ¶m->u.format61AllocInfo, mBuf); + break; + case TFU_DCI_FORMAT_6_2: + CMCHKUNPK(cmUnpkTfuDciFormat62AllocInfo, ¶m->u.format62AllocInfo, mBuf); + break; +#endif +#ifdef TFU_5GTF + case TFU_DCI_FORMAT_A1: + CMCHKUNPK(cmUnpkTfuDciFormatA1A2Info, ¶m->u.formatA1Info, mBuf); + break; + case TFU_DCI_FORMAT_A2: + CMCHKUNPK(cmUnpkTfuDciFormatA1A2Info, ¶m->u.formatA2Info, mBuf); + break; + case TFU_DCI_FORMAT_B1: + CMCHKUNPK(cmUnpkTfuDciFormatB1B2Info, ¶m->u.formatB1Info, mBuf); + break; + case TFU_DCI_FORMAT_B2: + CMCHKUNPK(cmUnpkTfuDciFormatB1B2Info, ¶m->u.formatB2Info, mBuf); + break; +#endif + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} +/* tfu_c_001.main_7. Added changes of TFU_UPGRADE */ +#ifdef TFU_UPGRADE +/*********************************************************** +* +* Func : cmPkTfuBfVectorInfo +* +* +* Desc : This structure conveys the BeamForming Vector +* Information that hold relevance to Tx Mode 7 +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuBfVectorInfo +( +TfuBfVectorInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuBfVectorInfo(param, mBuf) +TfuBfVectorInfo *param; +Buffer *mBuf; +#endif +{ + S32 idx, idx2; + TRC3(cmPkTfuBfVectorInfo) + for(idx=TFU_MAX_DL_SUBBAND-1;idx>=0; idx--) + { + for (idx2=param->numPhyAnt -1; idx2 >= 0; idx2--) { + CMCHKPK(SPkU16, param->bfValue[idx2], mBuf);} + CMCHKPK(SPkU8, param->numPhyAnt, mBuf); + CMCHKPK(SPkU8, param->sbIndex, mBuf); + } + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func : cmUnpkTfuBfVectorInfo +* +* +* Desc : This structure conveys the BeamForming Vector +* Information that hold relevance to Tx Mode 7 +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuBfVectorInfo +( + TfuBfVectorInfo *param, + Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuBfVectorInfo(param, mBuf) + TfuBfVectorInfo *param; + Buffer *mBuf; +#endif +{ + S32 idx, idx2; + TRC3(cmUnpkTfuBfVectorInfo) + for(idx=0;idxsbIndex, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numPhyAnt, mBuf); + for (idx2=0; idx2 numPhyAnt; idx2++) { + CMCHKUNPK(SUnpkU16, ¶m->bfValue[idx2], mBuf);} + } + + RETVALUE(ROK); +} +#endif + +/*********************************************************** +* +* Func : cmPkTfuDatReqPduInfo +* +* +* Desc : Pack Function for Tfu Dat Req PDU. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDatReqPduInfo +( +TfuDatReqPduInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuDatReqPduInfo(param, mBuf) +TfuDatReqPduInfo *param; +Buffer *mBuf; +#endif +{ + + S32 i; + U8 tbMask = 0; +#ifdef L2_OPTMZ + U32 lchIdx, pduIdx; +#endif + + TRC3(cmPkTfuDatReqPduInfo) + + /* LTE_ADV_FLAG_REMOVED_START */ + CMCHKPK(SPkU8, param->isEnbSFR, mBuf); + /* LTE_ADV_FLAG_REMOVED_END */ + + /* tfu_c_001.main_7. Added changes of TFU_UPGRADE */ +#ifdef TFU_UPGRADE + CMCHKPK(SPkU16, param->txPwrOffset, mBuf); + if(param->transMode == TFU_UE_TM_7) + { + CMCHKPK(cmPkTfuBfVectorInfo, param->bfVector, mBuf); + CMCHKPK(SPkU8, param->numBfVectors, mBuf); + CMCHKPK(SPkU8, param->numBfPrbPerSb, mBuf); + } + CMCHKPK(SPkU8, param->deltaPowOffIdx, mBuf); + /* LTE_ADV_FLAG_REMOVED_START */ + CMCHKPK(SPkU8, param->pa, mBuf); + /* LTE_ADV_FLAG_REMOVED_END */ + CMCHKPK(SPkU8, param->numLayers, mBuf); +#endif + CMCHKPK(cmPkBool, param->isTApres, mBuf); + CMCHKPK(cmPkTknU32, ¶m->doa, mBuf); + CMCHKPK(SPkU32, param->transMode, mBuf); + CMCHKPK(cmPkTfuDlCqiPuschInfo, ¶m->puschPmiInfo, mBuf); + CMCHKPK(SPkU8, param->puschRptUsd, mBuf); + for (i = 0; i < TFU_MAX_TB; i++) + { +#ifndef L2_OPTMZ + if (param->mBuf[i] != NULLP) + { + tbMask = tbMask | (1 << i); + } +#else /* L2_OPTMZ */ + for(lchIdx = 0; lchIdx < param->tbInfo[i].numLch; lchIdx++) + { + for(pduIdx = 0; pduIdx < param->tbInfo[i].lchInfo[lchIdx].numPdu; + pduIdx++) + { + if (param->tbInfo[i].lchInfo[lchIdx].mBuf[pduIdx] != NULLP) + { + tbMask = tbMask | (1 << i); + } + } + } +#endif /* L2_OPTMZ */ + } + /* tfu_c_001.main_2: Packing should consider nmbOfTBs.*/ + for (i=TFU_MAX_TB - 1; i >= 0; i--) { +#ifndef L2_OPTMZ + if (param->mBuf[i] != NULLP) + { + CMCHKPK(cmPkBuffer, ¶m->mBuf[i], mBuf); + } +#else + // CMCHKPK(cmPkBuffer, ¶m->tbInfo[i].macPad, mBuf); + for(lchIdx = 0; lchIdx < param->tbInfo[i].numLch; lchIdx++) + { + for(pduIdx = 0; pduIdx < param->tbInfo[i].lchInfo[lchIdx].numPdu; + pduIdx++) + { + CMCHKPK(cmPkBuffer, ¶m->tbInfo[i].lchInfo[lchIdx].mBuf[pduIdx], + mBuf); + + } + CMCHKPK(SPkU32, param->tbInfo[i].lchInfo[lchIdx].numPdu, mBuf); + } + CMCHKPK(SPkU32, param->tbInfo[i].numLch, mBuf); + CMCHKPK(SPkU32, param->tbInfo[i].padSize, mBuf); + CMCHKPK(cmPkBuffer, ¶m->tbInfo[i].macCes, mBuf); + CMCHKPK(cmPkBuffer, ¶m->tbInfo[i].macHdr, mBuf); + CMCHKPK(cmPkMsgLen, param->tbInfo[i].tbSize, mBuf); + CMCHKPK(cmPkBool, param->tbInfo[i].tbPres, mBuf); +#endif + } + CMCHKPK(SPkU8, tbMask, mBuf); + CMCHKPK(SPkU8, param->nmbOfTBs, mBuf); + CMCHKPK(cmPkTfuPdschDciInfo, ¶m->dciInfo, mBuf); + CMCHKPK(cmPkLteRnti, param->rnti, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuDatReqPduInfo +* +* +* Desc : UnPack function for Tfu Dat req pdu . +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDatReqPduInfo +( +TfuDatReqPduInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDatReqPduInfo(param, mBuf) +TfuDatReqPduInfo *param; +Buffer *mBuf; +#endif +{ + + U8 i; + U8 tbMask = 0; +#ifdef L2_OPTMZ + U32 lchIdx, pduIdx; +#endif + TRC3(cmUnpkTfuDatReqPduInfo) + + CMCHKUNPK(cmUnpkLteRnti, ¶m->rnti, mBuf); + CMCHKUNPK(cmUnpkTfuPdschDciInfo, ¶m->dciInfo, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->nmbOfTBs, mBuf); + + CMCHKUNPK(SUnpkU8, &tbMask, mBuf); + for (i=0; imBuf[i], mBuf); + } + else + { + param->mBuf[i] = NULLP; + } +#else /* L2_OPTMZ*/ + CMCHKUNPK(cmUnpkBool, ¶m->tbInfo[i].tbPres, mBuf); + CMCHKUNPK(cmUnpkMsgLen, ¶m->tbInfo[i].tbSize, mBuf); + CMCHKUNPK(cmUnpkBuffer, ¶m->tbInfo[i].macHdr, mBuf); + CMCHKUNPK(cmUnpkBuffer, ¶m->tbInfo[i].macCes, mBuf); + CMCHKUNPK(SUnpkU32, ¶m->tbInfo[i].padSize, mBuf); + CMCHKUNPK(SUnpkU32, (U32 *)¶m->tbInfo[i].numLch, mBuf); + for(lchIdx = 0; lchIdx < param->tbInfo[i].numLch; lchIdx++) + { + CMCHKUNPK(SUnpkU32, (U32 *)¶m->tbInfo[i].lchInfo[lchIdx].numPdu, + mBuf); + for(pduIdx = 0; pduIdx < param->tbInfo[i].lchInfo[lchIdx].numPdu; + pduIdx++) + { + if (tbMask & (1<tbInfo[i].lchInfo[lchIdx].\ + mBuf[pduIdx], mBuf); + } + else + { + param->tbInfo[i].lchInfo[lchIdx].mBuf[pduIdx] = NULLP; + } + } + } + //CMCHKUNPK(cmUnpkBuffer, ¶m->tbInfo[i].macPad, mBuf); +#endif /* L2_OPTMZ*/ + } + + CMCHKUNPK(SUnpkU8, ¶m->puschRptUsd, mBuf); + CMCHKUNPK(cmUnpkTfuDlCqiPuschInfo, ¶m->puschPmiInfo, mBuf); + CMCHKUNPK(SUnpkU32, (U32 *)¶m->transMode, mBuf); + CMCHKUNPK(cmUnpkTknU32, ¶m->doa, mBuf); + CMCHKUNPK(cmUnpkBool, ¶m->isTApres, mBuf); +/* tfu_c_001.main_7. Added changes of TFU_UPGRADE */ +#ifdef TFU_UPGRADE + CMCHKUNPK(SUnpkU8, ¶m->numLayers, mBuf); + /* LTE_ADV_FLAG_REMOVED_START */ + CMCHKUNPK(SUnpkU8, ¶m->pa, mBuf); + /* LTE_ADV_FLAG_REMOVED_END */ + CMCHKUNPK(SUnpkU8, ¶m->deltaPowOffIdx, mBuf); + if(param->transMode == TFU_UE_TM_7) + { + CMCHKUNPK(SUnpkU8, ¶m->numBfPrbPerSb, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numBfVectors, mBuf); + CMCHKUNPK(cmUnpkTfuBfVectorInfo, param->bfVector, mBuf); + } + CMCHKUNPK(SUnpkU16, ¶m->txPwrOffset, mBuf); +#endif + + /* LTE_ADV_FLAG_REMOVED_START */ + CMCHKUNPK(SUnpkU8, ¶m->isEnbSFR, mBuf); + /* LTE_ADV_FLAG_REMOVED_END */ + + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuDatReqInfo +* +* +* Desc : This structure contains the Data PDUs + * @details This structure contains Data meant to be sent on both PBCH and + * PDSCH. Control information necessary for processing of the data is sent along + * with the Data. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDatReqInfo +( +TfuDatReqInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuDatReqInfo(param, mBuf) +TfuDatReqInfo *param; +Buffer *mBuf; +#endif +{ + + CmLList *node; + U32 count; + TfuDatReqPduInfo *tfuDatReqPduInfo; + + TRC3(cmPkTfuDatReqInfo) + + count = param->pdus.count; + node = param->pdus.last; + while (node) { + tfuDatReqPduInfo = (TfuDatReqPduInfo *)node->node; + node=node->prev; + CMCHKPK(cmPkTfuDatReqPduInfo, tfuDatReqPduInfo, mBuf); + cmLListDelFrm(¶m->pdus, &tfuDatReqPduInfo->lnk); + tfuDatReqPduInfo->lnk.node = (PTR)NULLP; + } + CMCHKPK(SPkU32, count, mBuf); + CMCHKPK(cmPkTknBuf, ¶m->bchDat, mBuf); + CMCHKPK(cmPkLteTimingInfo, ¶m->timingInfo, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuDatReqInfo +* +* +* Desc : This structure contains the Data PDUs + * @details This structure contains Data meant to be sent on both PBCH and + * PDSCH. Control information necessary for processing of the data is sent along + * with the Data. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDatReqInfo +( +TfuDatReqInfo *param, +Ptr memCp, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDatReqInfo(param, memCp, mBuf) +TfuDatReqInfo *param; +Ptr memCp; +Buffer *mBuf; +#endif +{ + + U32 count, loopCnt; + TfuDatReqPduInfo *tfuDatReqPduInfo; + + TRC3(cmUnpkTfuDatReqInfo) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteTimingInfo, ¶m->timingInfo, mBuf); + CMCHKUNPK(cmUnpkTknBuf, ¶m->bchDat, &mBuf); + cmLListInit(¶m->pdus); + CMCHKUNPK(SUnpkU32, &count, mBuf); + for (loopCnt=0; loopCntpdus, &tfuDatReqPduInfo->lnk); + tfuDatReqPduInfo->lnk.node = (PTR)tfuDatReqPduInfo; + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuDatInfo +* +* +* Desc : This structure contains the Data PDU and the RNTI of the UE. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDatInfo +( +TfuDatInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuDatInfo(param, mBuf) +TfuDatInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuDatInfo) + + CMCHKPK(cmPkBuffer, ¶m->mBuf, mBuf); + CMCHKPK(cmPkLteRnti, param->rnti, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuDatInfo +* +* +* Desc : This structure contains the Data PDU and the RNTI of the UE. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDatInfo +( +TfuDatInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDatInfo(param, mBuf) +TfuDatInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuDatInfo) + + CMCHKUNPK(cmUnpkLteRnti, ¶m->rnti, mBuf); + CMCHKUNPK(cmUnpkBuffer, ¶m->mBuf, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuDatIndInfo +* +* +* Desc : This structure contains the Data PDUs received at Physical Layer. + * @details All the PDUs received by Physical layer in one subframe are clubbed + * together into a single data structure and sent to MAC for processing. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDatIndInfo +( +TfuDatIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuDatIndInfo(param, mBuf) +TfuDatIndInfo *param; +Buffer *mBuf; +#endif +{ + + CmLList *node; + U32 count; + TfuDatInfo *tfuDatInfo; + + TRC3(cmPkTfuDatIndInfo) + +#ifdef TFU_5GTF + CMCHKPK(SPkU8, param->sccIdx, mBuf); + CMCHKPK(SPkU8, param->sectorId, mBuf); +#endif /* TFU_5GTF */ + count = param->datIndLst.count; + node = param->datIndLst.last; + while (node) { + tfuDatInfo = (TfuDatInfo *)node->node; + node=node->prev; + CMCHKPK(cmPkTfuDatInfo, tfuDatInfo, mBuf); + cmLListDelFrm(¶m->datIndLst, &tfuDatInfo->lnk); + tfuDatInfo->lnk.node = (PTR)NULLP; + } + CMCHKPK(SPkU32, count, mBuf); + CMCHKPK(cmPkLteTimingInfo, ¶m->timingInfo, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuDatIndInfo +* +* +* Desc : This structure contains the Data PDUs received at Physical Layer. + * @details All the PDUs received by Physical layer in one subframe are clubbed + * together into a single data structure and sent to MAC for processing. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDatIndInfo +( +TfuDatIndInfo *param, +Ptr memCp, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDatIndInfo(param, memCp, mBuf) +TfuDatIndInfo *param; +Ptr memCp; +Buffer *mBuf; +#endif +{ + + U32 count, loopCnt; + TfuDatInfo *tfuDatInfo; + + TRC3(cmUnpkTfuDatIndInfo) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteTimingInfo, ¶m->timingInfo, mBuf); + cmLListInit(¶m->datIndLst); + CMCHKUNPK(SUnpkU32, &count, mBuf); + for (loopCnt=0; loopCntdatIndLst, &tfuDatInfo->lnk); + tfuDatInfo->lnk.node = (PTR)tfuDatInfo; + } +#ifdef TFU_5GTF + CMCHKUNPK(SUnpkU8, ¶m->sectorId, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->sccIdx, mBuf); +#endif /* TFU_5GTF */ + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuSrInfo +* +* +* Desc : This structure contains the SR indication for a UE, identified by + * the given RNTI. The structure also contains a PUCCH Delta power, that is + * calculated by the physical layer, and is used by the scheduler for Power + * control of the UE. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuSrInfo +( +TfuSrInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuSrInfo(param, mBuf) +TfuSrInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuSrInfo) + + CMCHKPK(cmPkLteRnti, param->rnti, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuSrInfo +* +* +* Desc : This structure contains the SR indication for a UE, identified by + * the given RNTI. The structure also contains a PUCCH Delta power, that is + * calculated by the physical layer, and is used by the scheduler for Power + * control of the UE. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuSrInfo +( +TfuSrInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuSrInfo(param, mBuf) +TfuSrInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuSrInfo) + + CMCHKUNPK(cmUnpkLteRnti, ¶m->rnti, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuSrIndInfo +* +* +* Desc : This structure contains all the Scheduling Requests (SR) indications + * received in a subframe. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuSrIndInfo +( +TfuSrIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuSrIndInfo(param, mBuf) +TfuSrIndInfo *param; +Buffer *mBuf; +#endif +{ + + CmLList *node; + U32 count; + TfuSrInfo *tfuSrInfo; + + TRC3(cmPkTfuSrIndInfo) + + count = param->srLst.count; + node = param->srLst.last; + while (node) { + tfuSrInfo = (TfuSrInfo *)node->node; + node=node->prev; + CMCHKPK(cmPkTfuSrInfo, tfuSrInfo, mBuf); + cmLListDelFrm(¶m->srLst, &tfuSrInfo->lnk); + tfuSrInfo->lnk.node = (PTR)NULLP; + } + CMCHKPK(SPkU32, count, mBuf); + CMCHKPK(cmPkLteTimingInfo, ¶m->timingInfo, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuSrIndInfo +* +* +* Desc : This structure contains all the Scheduling Requests (SR) indications + * received in a subframe. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuSrIndInfo +( +TfuSrIndInfo *param, +Ptr memCp, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuSrIndInfo(param, memCp, mBuf) +TfuSrIndInfo *param; +Ptr memCp; +Buffer *mBuf; +#endif +{ + + U32 count, loopCnt; + TfuSrInfo *tfuSrInfo; + + TRC3(cmUnpkTfuSrIndInfo) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteTimingInfo, ¶m->timingInfo, mBuf); + cmLListInit(¶m->srLst); + CMCHKUNPK(SUnpkU32, &count, mBuf); + for (loopCnt=0; loopCntsrLst, &tfuSrInfo->lnk); + tfuSrInfo->lnk.node = (PTR)tfuSrInfo; + } + RETVALUE(ROK); +} + +/* tfu_c_001.main_7. Added changes of TFU_UPGRADE */ +/*********************************************************** +* +* Func : cmPkTfuHqInfo +* +* +* Desc : This structure contains the HARQ feedback for a single UE. + * @details RNTI is present to identify the UE. + * For FDD a single feedback is present. + * For TDD HARQ multiplexing a list of HARQ feedbacks is present. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuHqInfo +( +TfuHqInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuHqInfo(param, mBuf) +TfuHqInfo *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkTfuHqInfo) + + CMCHKPK(SPkU8, param->isPusch, mBuf); + for (i=TFU_MAX_HARQ_FDBKS-1; i >= 0; i--) { + CMCHKPK(SPkU32, param->isAck[i], mBuf); + } +#ifdef TFU_TDD + CMCHKPK(SPkU8, param->M, mBuf); +#endif/*TFU_TDD*/ + CMCHKPK(SPkU8, param->noOfTbs, mBuf); +/* ACC-TDD ccpu00130520 */ + CMCHKPK(SPkU32, param->hqFdbkMode, mBuf); + CMCHKPK(cmPkLteRnti, param->rnti, mBuf); + RETVALUE(ROK); +} + +/* tfu_c_001.main_7. Added changes of TFU_UPGRADE */ +/*********************************************************** +* +* Func : cmUnpkTfuHqInfo +* +* +* Desc : This structure contains the HARQ feedback for a single UE. + * @details RNTI is present to identify the UE. + * For FDD a single feedback is present. + * For TDD HARQ multiplexing a list of HARQ feedbacks is present. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuHqInfo +( +TfuHqInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuHqInfo(param, mBuf) +TfuHqInfo *param; +Buffer *mBuf; +#endif +{ + S32 i; + TRC3(cmUnpkTfuHqInfo) + + CMCHKUNPK(cmUnpkLteRnti, ¶m->rnti, mBuf); +/* ACC-TDD ccpu00130520 */ + CMCHKUNPK(SUnpkU32, (U32 *)¶m->hqFdbkMode, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->noOfTbs, mBuf); +#ifdef TFU_TDD + CMCHKUNPK(SUnpkU8, ¶m->M, mBuf); +#endif + for (i=0; iisAck[i], mBuf); + } + CMCHKUNPK(SUnpkU8, ¶m->isPusch, mBuf); + RETVALUE(ROK); +} + + + + + +/*********************************************************** +* +* Func : cmPkTfuHqIndInfo +* +* +* Desc : This structure contains a list of HARQ feedback for a number of UEs. + * @details All the HARQ feedback received in the subframe are clubbed together + * in this data structure and given to the scheduler for processing. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuHqIndInfo +( +TfuHqIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuHqIndInfo(param, mBuf) +TfuHqIndInfo *param; +Buffer *mBuf; +#endif +{ + + CmLList *node; + U32 count; + TfuHqInfo *tfuHqInfo; + + TRC3(cmPkTfuHqIndInfo) + + count = param->hqIndLst.count; + node = param->hqIndLst.last; + while (node) { + tfuHqInfo = (TfuHqInfo *)node->node; + node=node->prev; + CMCHKPK(cmPkTfuHqInfo, tfuHqInfo, mBuf); + cmLListDelFrm(¶m->hqIndLst, &tfuHqInfo->lnk); + tfuHqInfo->lnk.node = (PTR)NULLP; + } + CMCHKPK(SPkU32, count, mBuf); + CMCHKPK(cmPkLteTimingInfo, ¶m->timingInfo, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuHqIndInfo +* +* +* Desc : This structure contains a list of HARQ feedback for a number of UEs. + * @details All the HARQ feedback received in the subframe are clubbed together + * in this data structure and given to the scheduler for processing. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuHqIndInfo +( +TfuHqIndInfo *param, +Ptr memCp, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuHqIndInfo(param, memCp, mBuf) +TfuHqIndInfo *param; +Ptr memCp; +Buffer *mBuf; +#endif +{ + + U32 count, loopCnt; + TfuHqInfo *tfuHqInfo; + + TRC3(cmUnpkTfuHqIndInfo) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteTimingInfo, ¶m->timingInfo, mBuf); + cmLListInit(¶m->hqIndLst); + CMCHKUNPK(SUnpkU32, &count, mBuf); + for (loopCnt=0; loopCnthqIndLst, &tfuHqInfo->lnk); + tfuHqInfo->lnk.node = (PTR)tfuHqInfo; + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuUlCqiInfo +* +* +* Desc : This structure conveys the Uplink CQI information for a single subband. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuUlCqiInfo +( +TfuUlCqiInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuUlCqiInfo(param, mBuf) +TfuUlCqiInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuUlCqiInfo) + + CMCHKPK(cmPkTfuSubbandCqiInfo, ¶m->subbandCqi, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuUlCqiInfo +* +* +* Desc : This structure conveys the Uplink CQI information for a single subband. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuUlCqiInfo +( +TfuUlCqiInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuUlCqiInfo(param, mBuf) +TfuUlCqiInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuUlCqiInfo) + + CMCHKUNPK(cmUnpkTfuSubbandCqiInfo, ¶m->subbandCqi, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuUlCqiRpt +* +* +* Desc : This structure contains the UL CQI estimated by the physical layer. + * @details The report could be wideband CQI or subBand CQI or both. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuUlCqiRpt +( +TfuUlCqiRpt *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuUlCqiRpt(param, mBuf) +TfuUlCqiRpt *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkTfuUlCqiRpt) + + for (i=TFU_MAX_UL_SUBBAND-1; i >= 0; i--) { + CMCHKPK(cmPkTfuUlCqiInfo, ¶m->ulCqiInfoArr[i], mBuf); + } + CMCHKPK(SPkU8, param->numSubband, mBuf); + CMCHKPK(SPkU8, param->wideCqi, mBuf); + CMCHKPK(SPkU8, param->isTxPort0, mBuf); + CMCHKPK(cmPkLteRnti, param->rnti, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuUlCqiRpt +* +* +* Desc : This structure contains the UL CQI estimated by the physical layer. + * @details The report could be wideband CQI or subBand CQI or both. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuUlCqiRpt +( +TfuUlCqiRpt *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuUlCqiRpt(param, mBuf) +TfuUlCqiRpt *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmUnpkTfuUlCqiRpt) + + CMCHKUNPK(cmUnpkLteRnti, ¶m->rnti, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->isTxPort0, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->wideCqi, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numSubband, mBuf); + for (i=0; iulCqiInfoArr[i], mBuf); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuUlCqiIndInfo +* +* +* Desc : This structure conveys the Uplink CQI information. + * @details Uplink CQI is calculated by the physical layer, and is this + * information is provided to the scheduler. + * This data structure clubs together the UL CQI estimates for all the UEs that + * have been scheduled in the subframe for uplink transmission. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuUlCqiIndInfo +( +TfuUlCqiIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuUlCqiIndInfo(param, mBuf) +TfuUlCqiIndInfo *param; +Buffer *mBuf; +#endif +{ + + CmLList *node; + U32 count; + TfuUlCqiRpt *tfuUlCqiRpt; + + TRC3(cmPkTfuUlCqiIndInfo) + + count = param->ulCqiRpt.count; + node = param->ulCqiRpt.last; + while (node) { + tfuUlCqiRpt = (TfuUlCqiRpt *)node->node; + node=node->prev; + CMCHKPK(cmPkTfuUlCqiRpt, tfuUlCqiRpt, mBuf); + cmLListDelFrm(¶m->ulCqiRpt, &tfuUlCqiRpt->lnk); + tfuUlCqiRpt->lnk.node = (PTR)NULLP; + } + CMCHKPK(SPkU32, count, mBuf); + CMCHKPK(cmPkLteTimingInfo, ¶m->timingInfo, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuUlCqiIndInfo +* +* +* Desc : This structure conveys the Uplink CQI information. + * @details Uplink CQI is calculated by the physical layer, and is this + * information is provided to the scheduler. + * This data structure clubs together the UL CQI estimates for all the UEs that + * have been scheduled in the subframe for uplink transmission. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuUlCqiIndInfo +( +TfuUlCqiIndInfo *param, +Ptr memCp, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuUlCqiIndInfo(param, memCp, mBuf) +TfuUlCqiIndInfo *param; +Ptr memCp; +Buffer *mBuf; +#endif +{ + + U32 count, loopCnt; + TfuUlCqiRpt *tfuUlCqiRpt; + + TRC3(cmUnpkTfuUlCqiIndInfo) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteTimingInfo, ¶m->timingInfo, mBuf); + cmLListInit(¶m->ulCqiRpt); + CMCHKUNPK(SUnpkU32, &count, mBuf); + for (loopCnt=0; loopCntulCqiRpt, &tfuUlCqiRpt->lnk); + tfuUlCqiRpt->lnk.node = (PTR)tfuUlCqiRpt; + } + RETVALUE(ROK); +} + + + + +/*********************************************************** +* +* Func : cmPkTfuDlCqiRpt +* +* +* Desc : This structure contains the DL CQI report for a single UE. + * @details The report could either be reported on PUCCH or PUSCH, a flag + * conveys this information. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDlCqiRpt +( +TfuDlCqiRpt *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuDlCqiRpt(param, mBuf) +TfuDlCqiRpt *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuDlCqiRpt) + + if (cmPkTfuDlCqiInfo(param->isPucchInfo, ¶m->dlCqiInfo, mBuf) != ROK) + RETVALUE(RFAILED); + CMCHKPK(SPkU8, param->isPucchInfo, mBuf); + CMCHKPK(cmPkLteRnti, param->rnti, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuDlCqiRpt +* +* +* Desc : This structure contains the DL CQI report for a single UE. + * @details The report could either be reported on PUCCH or PUSCH, a flag + * conveys this information. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDlCqiRpt +( +TfuDlCqiRpt *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDlCqiRpt(param, mBuf) +TfuDlCqiRpt *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuDlCqiRpt) + + CMCHKUNPK(cmUnpkLteRnti, ¶m->rnti, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->isPucchInfo, mBuf); + if (cmUnpkTfuDlCqiInfo (param->isPucchInfo, ¶m->dlCqiInfo, mBuf) != ROK) + RETVALUE(RFAILED); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuDlCqiIndInfo +* +* +* Desc : This structure contains a list of Downlink CQI reports transmitted by + * UEs. + * @details This structure clubs together DL CQI reports for a number of UEs. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDlCqiIndInfo +( +TfuDlCqiIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuDlCqiIndInfo(param, mBuf) +TfuDlCqiIndInfo *param; +Buffer *mBuf; +#endif +{ + + CmLList *node; + U32 count; + TfuDlCqiRpt *tfuDlCqiRpt; + + TRC3(cmPkTfuDlCqiIndInfo) + + count = param->dlCqiRptsLst.count; + node = param->dlCqiRptsLst.last; + while (node) { + tfuDlCqiRpt = (TfuDlCqiRpt *)node->node; + node=node->prev; + CMCHKPK(cmPkTfuDlCqiRpt, tfuDlCqiRpt, mBuf); + cmLListDelFrm(¶m->dlCqiRptsLst, &tfuDlCqiRpt->lnk); + tfuDlCqiRpt->lnk.node = (PTR)NULLP; + } + CMCHKPK(SPkU32, count, mBuf); + CMCHKPK(cmPkLteTimingInfo, ¶m->timingInfo, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuDlCqiIndInfo +* +* +* Desc : This structure contains a list of Downlink CQI reports transmitted by + * UEs. + * @details This structure clubs together DL CQI reports for a number of UEs. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDlCqiIndInfo +( +TfuDlCqiIndInfo *param, +Ptr memCp, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDlCqiIndInfo(param, memCp, mBuf) +TfuDlCqiIndInfo *param; +Ptr memCp; +Buffer *mBuf; +#endif +{ + + U32 count, loopCnt; + TfuDlCqiRpt *tfuDlCqiRpt; + + TRC3(cmUnpkTfuDlCqiIndInfo) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteTimingInfo, ¶m->timingInfo, mBuf); + cmLListInit(¶m->dlCqiRptsLst); + CMCHKUNPK(SUnpkU32, &count, mBuf); + for (loopCnt=0; loopCntdlCqiRptsLst, &tfuDlCqiRpt->lnk); + tfuDlCqiRpt->lnk.node = (PTR)tfuDlCqiRpt; + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuCrcInfo +* +* +* Desc : This structure contains the CRC indication for a single + * UE. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuCrcInfo +( +TfuCrcInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuCrcInfo(param, mBuf) +TfuCrcInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuCrcInfo) + + CMCHKPK(cmPkTknU8, ¶m->rv, mBuf); + CMCHKPK(SPkU8, param->isFailure, mBuf); + CMCHKPK(cmPkLteRnti, param->rnti, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuCrcInfo +* +* +* Desc : This structure contains the CRC indication for a single + * UE. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuCrcInfo +( +TfuCrcInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuCrcInfo(param, mBuf) +TfuCrcInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuCrcInfo) + + CMCHKUNPK(cmUnpkLteRnti, ¶m->rnti, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->isFailure, mBuf); + CMCHKUNPK(cmUnpkTknU8, ¶m->rv, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuCrcIndInfo +* +* +* Desc : This structure contains information that is passed as a part of the + * CRC Indication from PHY to MAC. + * @details This structure clubs together all the CRC indications for + * a single subframe and conveys this information to the scheduler. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuCrcIndInfo +( +TfuCrcIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuCrcIndInfo(param, mBuf) +TfuCrcIndInfo *param; +Buffer *mBuf; +#endif +{ + + CmLList *node; + U32 count; + TfuCrcInfo *tfuCrcIndInfo; + + TRC3(cmPkTfuCrcIndInfo) + +#ifdef TFU_5GTF + CMCHKPK(SPkU8, param->sccIdx, mBuf); + CMCHKPK(SPkU8, param->sectorId, mBuf); +#endif /* TFU_5GTF */ + count = param->crcLst.count; + node = param->crcLst.last; + while (node) { + tfuCrcIndInfo = (TfuCrcInfo *)node->node; + node=node->prev; + CMCHKPK(cmPkTfuCrcInfo, tfuCrcIndInfo, mBuf); + cmLListDelFrm(¶m->crcLst, &tfuCrcIndInfo->lnk); + tfuCrcIndInfo->lnk.node = (PTR)NULLP; + } + CMCHKPK(SPkU32, count, mBuf); + CMCHKPK(cmPkLteTimingInfo, ¶m->timingInfo, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuCrcIndInfo +* +* +* Desc : This structure contains information that is passed as a part of the + * CRC Indication from PHY to MAC. + * @details This structure clubs together all the CRC indications for + * a single subframe and conveys this information to the scheduler. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuCrcIndInfo +( +TfuCrcIndInfo *param, +Ptr memCp, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuCrcIndInfo(param, memCp, mBuf) +TfuCrcIndInfo *param; +Ptr memCp; +Buffer *mBuf; +#endif +{ + + U32 count, loopCnt; + TfuCrcInfo *tfuCrcIndInfo; + + TRC3(cmUnpkTfuCrcIndInfo) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteTimingInfo, ¶m->timingInfo, mBuf); + cmLListInit(¶m->crcLst); + CMCHKUNPK(SUnpkU32, &count, mBuf); + for (loopCnt=0; loopCntcrcLst, &tfuCrcIndInfo->lnk); + tfuCrcIndInfo->lnk.node = (PTR)tfuCrcIndInfo; + } +#ifdef TFU_5GTF + CMCHKUNPK(SUnpkU8, ¶m->sectorId, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->sccIdx, mBuf); +#endif /* TFU_5GTF */ + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuTimingAdvInfo +* +* +* Desc : This structure contains the timing advance information for a single + * UE. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuTimingAdvInfo +( +TfuTimingAdvInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuTimingAdvInfo(param, mBuf) +TfuTimingAdvInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuTimingAdvInfo) + + CMCHKPK(SPkU8, param->timingAdv, mBuf); + CMCHKPK(cmPkLteRnti, param->rnti, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuTimingAdvInfo +* +* +* Desc : This structure contains the timing advance information for a single + * UE. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuTimingAdvInfo +( +TfuTimingAdvInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuTimingAdvInfo(param, mBuf) +TfuTimingAdvInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuTimingAdvInfo) + + CMCHKUNPK(cmUnpkLteRnti, ¶m->rnti, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->timingAdv, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuTimingAdvIndInfo +* +* +* Desc : This structure contains information that is passed as part of the Timing + * Advance indication from PHY to MAC. + * @details This structure clubs together timing advances for a number of UEs. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuTimingAdvIndInfo +( +TfuTimingAdvIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuTimingAdvIndInfo(param, mBuf) +TfuTimingAdvIndInfo *param; +Buffer *mBuf; +#endif +{ + + CmLList *node; + U32 count; + TfuTimingAdvInfo *tfuTimingAdvInfo; + + TRC3(cmPkTfuTimingAdvIndInfo) + + count = param->timingAdvLst.count; + node = param->timingAdvLst.last; + while (node) { + tfuTimingAdvInfo = (TfuTimingAdvInfo *)node->node; + node=node->prev; + CMCHKPK(cmPkTfuTimingAdvInfo, tfuTimingAdvInfo, mBuf); + cmLListDelFrm(¶m->timingAdvLst, &tfuTimingAdvInfo->lnk); + tfuTimingAdvInfo->lnk.node = (PTR)NULLP; + } + CMCHKPK(SPkU32, count, mBuf); + CMCHKPK(cmPkLteTimingInfo, ¶m->timingInfo, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuTimingAdvIndInfo +* +* +* Desc : This structure contains information that is passed as part of the Timing + * Advance indication from PHY to MAC. + * @details This structure clubs together timing advances for a number of UEs. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuTimingAdvIndInfo +( +TfuTimingAdvIndInfo *param, +Ptr memCp, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuTimingAdvIndInfo(param, memCp, mBuf) +TfuTimingAdvIndInfo *param; +Ptr memCp; +Buffer *mBuf; +#endif +{ + + U32 count, loopCnt; + TfuTimingAdvInfo *tfuTimingAdvInfo; + + TRC3(cmUnpkTfuTimingAdvIndInfo) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteTimingInfo, ¶m->timingInfo, mBuf); + cmLListInit(¶m->timingAdvLst); + CMCHKUNPK(SUnpkU32, &count, mBuf); + for (loopCnt=0; loopCnttimingAdvLst, &tfuTimingAdvInfo->lnk); + tfuTimingAdvInfo->lnk.node = (PTR)tfuTimingAdvInfo; + } + RETVALUE(ROK); +} + +/*CA dev Start*/ +/*********************************************************** +* +* Func : cmPkTfuTtiCellInfo +* +* +* Desc : This structure contains information that is +* passed as a part of the TTI indication sent +* from CL to MAC and SCH +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuTtiCellInfo +( +TfuTtiCellInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuTtiCellInfo(param, mBuf) +TfuTtiCellInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuTtiCellInfo) + + CMCHKPK(SPkU8, param->ulBlankSf, mBuf); + CMCHKPK(SPkU8, param->dlBlankSf, mBuf); + CMCHKPK(SPkU8, param->schTickDelta, mBuf); + CMCHKPK(cmPkBool, param->isDummyTti, mBuf); + CMCHKPK(cmPkLteTimingInfo, ¶m->timingInfo, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} +/*CA dev End*/ + +/*********************************************************** +* +* Func : cmPkTfuTtiIndInfo +* +* +* Desc : This structure contains information that is passed as a part of the TTI + * indication sent from PHY to MAC. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuTtiIndInfo +( +TfuTtiIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuTtiIndInfo(param, mBuf) +TfuTtiIndInfo *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkTfuTtiIndInfo) + + /*CA dev Start*/ + for (i=(param->numCells-1); i >= 0; i--) { + CMCHKPK(cmPkTfuTtiCellInfo, ¶m->cells[i], mBuf); + } + CMCHKPK(SPkU8, param->numCells, mBuf); + /*CA dev End*/ + RETVALUE(ROK); +} + +/* CA dev Start */ +/*********************************************************** +* +* Func : cmUnpkTfuTtiCellInfo +* +* +* Desc : This structure contains information that is +* passed as a part of the TTI indication sent +* from CL to MAC and SCH +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuTtiCellInfo +( +TfuTtiCellInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuTtiCellInfo(param, mBuf) +TfuTtiCellInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuTtiCellInfo) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteTimingInfo, ¶m->timingInfo, mBuf); + CMCHKUNPK(cmUnpkBool, ¶m->isDummyTti, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->schTickDelta, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->dlBlankSf, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->ulBlankSf, mBuf); + RETVALUE(ROK); +} +/* CA dev End */ + + +/*********************************************************** +* +* Func : cmUnpkTfuTtiIndInfo +* +* +* Desc : This structure contains information that is passed as a part of the TTI + * indication sent from PHY to MAC. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuTtiIndInfo +( +TfuTtiIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuTtiIndInfo(param, mBuf) +TfuTtiIndInfo *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmUnpkTfuTtiIndInfo) + + /* CA dev Start */ + CMCHKUNPK(SUnpkU8, ¶m->numCells, mBuf); + for (i=0; i<(param->numCells); i++) { + CMCHKUNPK(cmUnpkTfuTtiCellInfo, ¶m->cells[i], mBuf); + } + /* CA dev End */ + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuRaReqInfo +* +* +* Desc : This structure contains the information for a single Random Access Request. + * @details The information present in this structure is for a single preamble. + * Associated with each preamble are fields that the physical layer calculates + * based on the reception of the Random Access Request. These are the following + * -# Timing Advance + * -# TPC + * -# CQI (optional). +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuRaReqInfo +( +TfuRaReqInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuRaReqInfo(param, mBuf) +TfuRaReqInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuRaReqInfo) + + CMCHKPK(SPkU8, param->cqiIdx, mBuf); + CMCHKPK(SPkU8, param->cqiPres, mBuf); + CMCHKPK(SPkU8, param->tpc, mBuf); + CMCHKPK(SPkU16, param->ta, mBuf); + CMCHKPK(SPkU8, param->rapId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuRaReqInfo +* +* +* Desc : This structure contains the information for a single Random Access Request. + * @details The information present in this structure is for a single preamble. + * Associated with each preamble are fields that the physical layer calculates + * based on the reception of the Random Access Request. These are the following + * -# Timing Advance + * -# TPC + * -# CQI (optional). +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuRaReqInfo +( +TfuRaReqInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuRaReqInfo(param, mBuf) +TfuRaReqInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuRaReqInfo) + + CMCHKUNPK(SUnpkU8, ¶m->rapId, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->ta, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->tpc, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->cqiPres, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->cqiIdx, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuRachInfo +* +* +* Desc : This structure contains RACH request information for a single + * RA-RNTI. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuRachInfo +( + CmMemListCp memCp, +TfuRachInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuRachInfo(memCp, param, mBuf) + CmMemListCp memCp; +TfuRachInfo *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkTfuRachInfo) + + for (i= (param->numRaReqInfo - 1); i >= 0; i--) { + CMCHKPK(cmPkTfuRaReqInfo, &(param->raReqInfoArr[i]), mBuf); + } +#ifdef PRACH_5GTF + CMCHKPK(SPkU16, param->nPwrFactor, mBuf); + CMCHKPK(SPkU8, param->nPRACHSymbIndex, mBuf); + CMCHKPK(SPkU8, param->nf1Value, mBuf); + CMCHKPK(SPkU8, param->nCyclicShift, mBuf); + CMCHKPK(SPkU8, param->nRootSeq, mBuf); + CMCHKPK(SPkU8, param->nPRACHConfiguration, mBuf); + CMCHKPK(SPkU8, param->nPreambleFormat, mBuf); +#endif + CMCHKPK(SPkU8, param->numRaReqInfo, mBuf); + CMCHKPK(cmPkLteRnti, param->raRnti, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuRachInfo +* +* +* Desc : This structure contains RACH request information for a single + * RA-RNTI. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuRachInfo +( +CmMemListCp memCp, +TfuRachInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuRachInfo(memCp, param, mBuf) +CmMemListCp memCp; +TfuRachInfo *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmUnpkTfuRachInfo) + + CMCHKUNPK(cmUnpkLteRnti, ¶m->raRnti, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numRaReqInfo, mBuf); +#ifdef PRACH_5GTF + CMCHKUNPK(SPkU8, param->nPreambleFormat, mBuf); + CMCHKUNPK(SPkU8, param->nPRACHConfiguration, mBuf); + CMCHKUNPK(SPkU8, param->nRootSeq, mBuf); + CMCHKUNPK(SPkU8, param->nCyclicShift, mBuf); + CMCHKUNPK(SPkU8, param->nf1Value, mBuf); + CMCHKUNPK(SPkU8, param->nPRACHSymbIndex, mBuf); + CMCHKUNPK(SPkU16, param->nPwrFactor, mBuf); +#endif + if (cmGetMem (&(memCp), (sizeof(TfuRaReqInfo) * param->numRaReqInfo), + (Ptr *)¶m->raReqInfoArr) != ROK) + { + RETVALUE(RFAILED); + } + for (i=0; inumRaReqInfo; i++) { + CMCHKUNPK(cmUnpkTfuRaReqInfo, ¶m->raReqInfoArr[i], mBuf); + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuRaReqIndInfo +* +* +* Desc : This structure contains the list of Random Access Requests received in a + * single TTI. + * @details Random Access Request is associated with a RA-RNTI, which remains + * common for all the Random access requests within a subframe. This structure + * thus carries the RA-RNTI and a list of Random Access Request information. + * This information consists of the following + * -# preamble-id - this corresponds to the Index of the Preamble choosen by the + * UE. + * -# Timing Advance - this corresponds to the timing adjustment that the UE + * needs to be uplink synchronized. This value is calculated by physical layer. + * -# tpc - this is the power control command that the physical layer calculates + * from the received RA request. This value is transmitted in the RA Response + * sent out by MAC. + * -# CQI - this is the Channel quality index of the UL channel estimated by the + * physical layer. This aids MAC in the scheduling of this UE. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuRaReqIndInfo +( +TfuRaReqIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuRaReqIndInfo(param, mBuf) +TfuRaReqIndInfo *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkTfuRaReqIndInfo) + + for (i= (param->nmbOfRaRnti-1); i >= 0; i--) + { + if (ROK != cmPkTfuRachInfo(param->memCp, + &(param->rachInfoArr[i]), mBuf)) + { + RETVALUE(RFAILED); + } + } + CMCHKPK(SPkU8, param->nmbOfRaRnti, mBuf); + CMCHKPK(cmPkLteTimingInfo, ¶m->timingInfo, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuRaReqIndInfo +* +* +* Desc : This structure contains the list of Random Access Requests received in a + * single TTI. + * @details Random Access Request is associated with a RA-RNTI, which remains + * common for all the Random access requests within a subframe. This structure + * thus carries the RA-RNTI and a list of Random Access Request information. + * This information consists of the following + * -# preamble-id - this corresponds to the Index of the Preamble choosen by the + * UE. + * -# Timing Advance - this corresponds to the timing adjustment that the UE + * needs to be uplink synchronized. This value is calculated by physical layer. + * -# tpc - this is the power control command that the physical layer calculates + * from the received RA request. This value is transmitted in the RA Response + * sent out by MAC. + * -# CQI - this is the Channel quality index of the UL channel estimated by the + * physical layer. This aids MAC in the scheduling of this UE. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuRaReqIndInfo +( +TfuRaReqIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuRaReqIndInfo(param, mBuf) +TfuRaReqIndInfo *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmUnpkTfuRaReqIndInfo) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteTimingInfo, ¶m->timingInfo, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->nmbOfRaRnti, mBuf); + if (cmGetMem (&(param->memCp), (sizeof(TfuRachInfo) * param->nmbOfRaRnti), + (Ptr *)¶m->rachInfoArr) != ROK) + { + RETVALUE(RFAILED); + } + for (i=0; inmbOfRaRnti; i++) + { + if (ROK != cmUnpkTfuRachInfo(param->memCp, ¶m->rachInfoArr[i], mBuf)) + { + RETVALUE(RFAILED); + } + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuPucchDeltaPwr +* +* +* Desc : This structure contains PUCCH Delta power for a single UE. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuPucchDeltaPwrInfo +( +TfuPucchDeltaPwr *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuPucchDeltaPwrInfo(param, mBuf) +TfuPucchDeltaPwr *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuPucchDeltaPwrInfo) + + CMCHKPK(SPkS8, param->pucchDeltaPwr, mBuf); + CMCHKPK(cmPkLteRnti, param->rnti, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuPucchDeltaPwr +* +* +* Desc : This structure contains PUCCH Delta power for a single UE. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuPucchDeltaPwrInfo +( +TfuPucchDeltaPwr *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuPucchDeltaPwrInfo(param, mBuf) +TfuPucchDeltaPwr *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuPucchDeltaPwrInfo) + + CMCHKUNPK(cmUnpkLteRnti, ¶m->rnti, mBuf); + CMCHKUNPK(SUnpkS8, ¶m->pucchDeltaPwr, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuPucchDeltaPwrIndInfo +* +* +* Desc : This structure contains information that is passed as a part of the + * PUCCH Delta power indication from PHY to SCH. + * @details This structure clubs together PUCCH Delta power values for a number + * of UEs. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuPucchDeltaPwrIndInfo +( +TfuPucchDeltaPwrIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuPucchDeltaPwrIndInfo(param, mBuf) +TfuPucchDeltaPwrIndInfo *param; +Buffer *mBuf; +#endif +{ + + CmLList *node; + U32 count; + TfuPucchDeltaPwr *tfuPucchDeltaPwr; + + TRC3(cmPkTfuPucchDeltaPwrIndInfo) + + count = param->pucchDeltaPwrLst.count; + node = param->pucchDeltaPwrLst.last; + while (node) { + tfuPucchDeltaPwr = (TfuPucchDeltaPwr *)node->node; + node=node->prev; + CMCHKPK(cmPkTfuPucchDeltaPwrInfo, tfuPucchDeltaPwr, mBuf); + cmLListDelFrm(¶m->pucchDeltaPwrLst, &tfuPucchDeltaPwr->lnk); + tfuPucchDeltaPwr->lnk.node = (PTR)NULLP; + } + CMCHKPK(SPkU32, count, mBuf); + CMCHKPK(cmPkLteTimingInfo, ¶m->timingInfo, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuPucchDeltaPwrIndInfo +* +* +* Desc : This structure contains information that is passed as a part of the + * PUCCH Delta power indication from PHY to SCH. + * @details This structure clubs together PUCCH Delta power values for a number + * of UEs. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuPucchDeltaPwrIndInfo +( +TfuPucchDeltaPwrIndInfo *param, +Ptr memCp, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuPucchDeltaPwrIndInfo(param, memCp, mBuf) +TfuPucchDeltaPwrIndInfo *param; +Ptr memCp; +Buffer *mBuf; +#endif +{ + + U32 count, loopCnt; + TfuPucchDeltaPwr *tfuPucchDeltaPwr; + + TRC3(cmUnpkTfuPucchDeltaPwrIndInfo) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteTimingInfo, ¶m->timingInfo, mBuf); + cmLListInit(¶m->pucchDeltaPwrLst); + CMCHKUNPK(SUnpkU32, &count, mBuf); + for (loopCnt=0; loopCntpucchDeltaPwrLst, &tfuPucchDeltaPwr->lnk); + tfuPucchDeltaPwr->lnk.node = (PTR)tfuPucchDeltaPwr; + } + RETVALUE(ROK); +} + +#ifdef ANSI +PUBLIC S16 cmPkBuffer +( +Buffer **param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkBuffer(param, mBuf) +Buffer **param; +Buffer *mBuf; +#endif +{ + MsgLen msgLen=0; + TRC3(cmPkBuffer) + if (SFndLenMsg(*param, &msgLen) != ROK) + RETVALUE(RFAILED); + if (SCatMsg(mBuf, *param, M1M2) != ROK) + RETVALUE(RFAILED); + TFU_FREE_MSG(*param); + *param = NULLP; + CMCHKPK(cmPkMsgLen, msgLen, mBuf); + RETVALUE(ROK); +} +#ifdef ANSI +PUBLIC S16 cmUnpkBuffer +( +Buffer **param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkBuffer(param, mBuf) +Buffer **param; +Buffer *mBuf; +#endif +{ + MsgLen msgLen=0, totalMsgLen=0; + TRC3(cmUnpkBuffer) + CMCHKUNPK(cmUnpkMsgLen, &msgLen, mBuf); + if (SFndLenMsg(mBuf, &totalMsgLen) != ROK) + RETVALUE(RFAILED); + if (SSegMsg(mBuf, totalMsgLen-msgLen, param) != ROK) + RETVALUE(RFAILED); + RETVALUE(ROK); +} + + +/*********************************************************** +* +* Func : cmPkTfuDoaInd +* +* +* Desc : This API is used to indicate DOA(Direction Of Arrival) + * identifier for one or more UEs. + * It carries a DOA for each UE. + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service user. + * @param doaInd Pointer to the TfuDoaIndInfo structure. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDoaInd +( +Pst * pst, +SuId suId, +TfuDoaIndInfo * doaInd +) +#else +PUBLIC S16 cmPkTfuDoaInd(pst, suId, doaInd) +Pst * pst; +SuId suId; +TfuDoaIndInfo * doaInd; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkTfuDoaInd) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU125, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)doaInd, sizeof(TfuDoaIndInfo)); + RETVALUE(RFAILED); + } + cmPkTfuDoaIndInfo(doaInd, mBuf); + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU126, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MEM(doaInd); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + TFU_FREE_MEM(doaInd); + pst->event = (Event) EVTTFUDOAIND; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/*********************************************************** +* +* Func : cmUnpkTfuDoaInd +* +* +* Desc : This API is used to indicate DOA(Direction Of Arrival) + * identifier for one or more UEs. + * It carries a DOA for each UE. + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service user. + * @param doaInd Pointer to the TfuDoaIndInfo structure. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDoaInd +( +TfuDoaInd func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDoaInd(func, pst, mBuf) +TfuDoaInd func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + TfuDoaIndInfo *doaInd; + + TRC3(cmUnpkTfuDoaInd) + + if (SUnpkS16(&suId, mBuf) != ROK) { + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU127, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + { + Mem sMem; + sMem.region = pst->region; + sMem.pool = pst->pool; + if ((cmAllocEvnt(sizeof(TfuDoaIndInfo), TFU_BLKSZ, &sMem, (Ptr *)&doaInd)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU128, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + + cmUnpkTfuDoaIndInfo(doaInd, (Ptr)&doaInd->memCp, mBuf); + TFU_FREE_MSG(mBuf); + RETVALUE((*func)(pst, suId, doaInd)); +} + + + +/*********************************************************** +* +* Func : cmPkTfuDciFormatTbInfo +* +* +* Desc : This structure contains the TB level DCI signalling + * parameters in case of DCI formats 2 and 2A +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDciFormatTbInfo +( +TfuDciFormatTbInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuDciFormatTbInfo(param, mBuf) +TfuDciFormatTbInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuDciFormatTbInfo) + + CMCHKPK(SPkU8, param->mcs, mBuf); + CMCHKPK(SPkU8, param->rv, mBuf); + CMCHKPK(SPkU8, param->ndi, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuDciFormatTbInfo +* +* +* Desc : This structure contains the TB level DCI signalling + * parameters in case of DCI formats 2 and 2A +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDciFormatTbInfo +( +TfuDciFormatTbInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDciFormatTbInfo(param, mBuf) +TfuDciFormatTbInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuDciFormatTbInfo) + + CMCHKUNPK(SUnpkU8, ¶m->ndi, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->rv, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->mcs, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuSubbandDlCqiInfo +* +* +* Desc : This structure is used to convey the subbannd CQI reported. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuSubbandDlCqiInfo +( +TfuSubbandDlCqiInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuSubbandDlCqiInfo(param, mBuf) +TfuSubbandDlCqiInfo *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkTfuSubbandDlCqiInfo) + + for (i=TFU_MAX_TB-1; i >= 0; i--) { + CMCHKPK(SPkU8, param->cqiIdx[i], mBuf); + } + CMCHKPK(cmPkTfuSubbandInfo, ¶m->subband, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuSubbandDlCqiInfo +* +* +* Desc : This structure is used to convey the subbannd CQI reported. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuSubbandDlCqiInfo +( +TfuSubbandDlCqiInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuSubbandDlCqiInfo(param, mBuf) +TfuSubbandDlCqiInfo *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmUnpkTfuSubbandDlCqiInfo) + + CMCHKUNPK(cmUnpkTfuSubbandInfo, ¶m->subband, mBuf); + for (i=0; icqiIdx[i], mBuf); + } + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func : cmPkTfuDlCqiPuschInfo +* +* +* Desc : This structure conveys explicitly the PMI information in case + * of PUSCH feedback usage in scheduling. Applicable for TM 4,5,6. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDlCqiPuschInfo +( +TfuDlCqiPuschInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuDlCqiPuschInfo(param, mBuf) +TfuDlCqiPuschInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuDlCqiPuschInfo) + + switch(param->mode) { + case TFU_PUSCH_CQI_MODE_31: + CMCHKPK(cmPkTfuCqiPuschMode31, ¶m->u.mode31Info, mBuf); + break; + case TFU_PUSCH_CQI_MODE_22: + CMCHKPK(cmPkTfuCqiPuschMode22, ¶m->u.mode22Info, mBuf); + break; + case TFU_PUSCH_CQI_MODE_12: + CMCHKPK(cmPkTfuCqiPuschMode12, ¶m->u.mode12Info, mBuf); + break; + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkU32, param->mode, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuDlCqiPuschInfo +* +* +* Desc : This structure conveys explicitly the PMI information in case + * of PUSCH feedback usage in scheduling. Applicable for TM 4,5,6. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDlCqiPuschInfo +( +TfuDlCqiPuschInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDlCqiPuschInfo(param, mBuf) +TfuDlCqiPuschInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuDlCqiPuschInfo) + + CMCHKUNPK(SUnpkU32, (U32 *)¶m->mode, mBuf); + switch(param->mode) { + case TFU_PUSCH_CQI_MODE_12: + CMCHKUNPK(cmUnpkTfuCqiPuschMode12, ¶m->u.mode12Info, mBuf); + break; + case TFU_PUSCH_CQI_MODE_22: + CMCHKUNPK(cmUnpkTfuCqiPuschMode22, ¶m->u.mode22Info, mBuf); + break; + case TFU_PUSCH_CQI_MODE_31: + CMCHKUNPK(cmUnpkTfuCqiPuschMode31, ¶m->u.mode31Info, mBuf); + break; + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func : cmPkTfuDoaRpt +* +* +* Desc : This structure contains the DOA estimated by the physical layer. + * @details DOA for a given UE. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDoaRpt +( +TfuDoaRpt *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuDoaRpt(param, mBuf) +TfuDoaRpt *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuDoaRpt) + + CMCHKPK(SPkU32, param->doa, mBuf); + CMCHKPK(cmPkLteRnti, param->rnti, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuDoaRpt +* +* +* Desc : This structure contains the DOA estimated by the physical layer. + * @details DOA for a given UE. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDoaRpt +( +TfuDoaRpt *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDoaRpt(param, mBuf) +TfuDoaRpt *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuDoaRpt) + + CMCHKUNPK(cmUnpkLteRnti, ¶m->rnti, mBuf); + CMCHKUNPK(SUnpkU32, ¶m->doa, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuDoaIndInfo +* +* +* Desc : This structure conveys the DOA(Direction Of Arrival) indicator. + * @details DOA is calculated by the physical layer, and this + * information is provided to the scheduler. + * This data structure clubs together the DOAs for all the UEs + * calculated by PHY in this subframe. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuDoaIndInfo +( +TfuDoaIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuDoaIndInfo(param, mBuf) +TfuDoaIndInfo *param; +Buffer *mBuf; +#endif +{ + + CmLList *node; + U32 count; + TfuDoaRpt *tfuDoaRpt; + TRC3(cmPkTfuDoaIndInfo) + + count = param->doaRpt.count; + node = param->doaRpt.last; + while (node) { + tfuDoaRpt = (TfuDoaRpt *)node->node; + node=node->prev; + CMCHKPK(cmPkTfuDoaRpt, tfuDoaRpt, mBuf); + cmLListDelFrm(¶m->doaRpt, &tfuDoaRpt->lnk); + tfuDoaRpt->lnk.node = (PTR)NULLP; + } + CMCHKPK(SPkU32, count, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuDoaIndInfo +* +* +* Desc : This structure conveys the DOA(Direction Of Arrival) indicator. + * @details DOA is calculated by the physical layer, and this + * information is provided to the scheduler. + * This data structure clubs together the DOAs for all the UEs + * calculated by PHY in this subframe. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuDoaIndInfo +( +TfuDoaIndInfo *param, +Ptr memCp, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuDoaIndInfo(param, memCp, mBuf) +TfuDoaIndInfo *param; +Ptr memCp; +Buffer *mBuf; +#endif +{ + + U32 count, loopCnt; + TfuDoaRpt *tfuDoaRpt; + TRC3(cmUnpkTfuDoaIndInfo) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + cmLListInit(¶m->doaRpt); + CMCHKUNPK(SUnpkU32, &count, mBuf); + for (loopCnt=0; loopCntdoaRpt, &tfuDoaRpt->lnk); + tfuDoaRpt->lnk.node = (PTR)tfuDoaRpt; + } + RETVALUE(ROK); +} + + +/* tfu_c_001.main_7. Added changes of TFU_UPGRADE */ +#ifdef TFU_UPGRADE + + +/*********************************************************** +* +* Func : cmPkTfuSrsRpt +* +* +* Desc : This structure conveys the Uplink SRS indication of a UE. + * @details Uplink SRS from each UE is received by the physical layer, and this + * information is provided to the scheduler. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuSrsRpt +( +TfuSrsRpt *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuSrsRpt(param, mBuf) +TfuSrsRpt *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkTfuSrsRpt) + + CMCHKPK(SPkU8, param->wideCqi, mBuf); + CMCHKPK(SPkU8, param->wideCqiPres, mBuf); + for (i=TFU_MAX_UL_RB-1; i >= 0; i--) { + CMCHKPK(SPkU8, param->snr[i], mBuf); + } + CMCHKPK(SPkU8, param->rbStart, mBuf); + CMCHKPK(SPkU8, param->numRbs, mBuf); + CMCHKPK(SPkU16, param->ta, mBuf); + CMCHKPK(SPkU16, param->dopEst, mBuf); + CMCHKPK(cmPkLteRnti, param->ueId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuSrsRpt +* +* +* Desc : This structure conveys the Uplink SRS indication of a UE. + * @details Uplink SRS from each UE is received by the physical layer, and this + * information is provided to the scheduler. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuSrsRpt +( +TfuSrsRpt *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuSrsRpt(param, mBuf) +TfuSrsRpt *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmUnpkTfuSrsRpt) + + CMCHKUNPK(cmUnpkLteRnti, ¶m->ueId, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->dopEst, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->ta, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numRbs, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->rbStart, mBuf); + for (i=0; isnr[i], mBuf); + } + CMCHKUNPK(SUnpkU8, ¶m->wideCqiPres, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->wideCqi, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuSrsIndInfo +* +* +* Desc : This structure conveys the Uplink SRS indication. + * @details Uplink SRS is received by the physical layer, and this + * information is provided to the scheduler. + * This data structure clubs together the UL SRS indications of all the UEs + * in the subframe. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuSrsIndInfo +( +TfuSrsIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuSrsIndInfo(param, mBuf) +TfuSrsIndInfo *param; +Buffer *mBuf; +#endif +{ + + CmLList *node; + U32 count; + TfuSrsRpt *tfuSrsRpt; + + TRC3(cmPkTfuSrsIndInfo) + + count = param->srsRpt.count; + node = param->srsRpt.last; + while (node) { + tfuSrsRpt = (TfuSrsRpt *)node->node; + node=node->prev; + CMCHKPK(cmPkTfuSrsRpt, tfuSrsRpt, mBuf); + cmLListDelFrm(¶m->srsRpt, &tfuSrsRpt->lnk); + tfuSrsRpt->lnk.node = (PTR)NULLP; + } + CMCHKPK(SPkU32, count, mBuf); + CMCHKPK(cmPkLteTimingInfo, ¶m->timingInfo, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuSrsIndInfo +* +* +* Desc : This structure conveys the Uplink SRS indication. + * @details Uplink SRS is received by the physical layer, and this + * information is provided to the scheduler. + * This data structure clubs together the UL SRS indications of all the UEs + * in the subframe. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuSrsIndInfo +( +TfuSrsIndInfo *param, +Ptr memCp, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuSrsIndInfo(param, memCp, mBuf) +TfuSrsIndInfo *param; +Ptr memCp; +Buffer *mBuf; +#endif +{ + + U32 count, loopCnt; + TfuSrsRpt *tfuSrsRpt; + + TRC3(cmUnpkTfuSrsIndInfo) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteTimingInfo, ¶m->timingInfo, mBuf); + cmLListInit(¶m->srsRpt); + CMCHKUNPK(SUnpkU32, &count, mBuf); + for (loopCnt=0; loopCntsrsRpt, &tfuSrsRpt->lnk); + tfuSrsRpt->lnk.node = (PTR)tfuSrsRpt; + } + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuRawCqiRpt +* +* +* Desc : This structure contains the Raw CQI information i.e. the CQI report + * as transmitted by the UE. + * @details These bits shall be interpretted by MAC to derive the following + * -# Wideband CQI + * -# Subband CQI + * -# PMI + * -# RI +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuRawCqiRpt +( +TfuRawCqiRpt *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuRawCqiRpt(param, mBuf) +TfuRawCqiRpt *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuRawCqiRpt) +#ifdef TFU_5GTF + CMCHKPK(SPkU32, param->uciPayload, mBuf); +#else + S32 i; + for (i=CM_LTE_MAX_CELLS-1; i >= 0; i--) { + CMCHKPK(SPkU8, param->ri[i], mBuf); + } + for (i=TFU_MAX_CQI_BYTES-1; i >= 0; i--) { + CMCHKPK(SPkU8, param->cqiBits[i], mBuf); + } +#endif + CMCHKPK(SPkU8, param->numBits, mBuf); + CMCHKPK(cmPkLteRnti, param->crnti, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuRawCqiRpt +* +* +* Desc : This structure contains the Raw CQI information i.e. the CQI report + * as transmitted by the UE. + * @details These bits shall be interpretted by MAC to derive the following + * -# Wideband CQI + * -# Subband CQI + * -# PMI + * -# RI +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuRawCqiRpt +( +TfuRawCqiRpt *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuRawCqiRpt(param, mBuf) +TfuRawCqiRpt *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuRawCqiRpt) + + CMCHKUNPK(cmUnpkLteRnti, ¶m->crnti, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numBits, mBuf); +#ifndef TFU_5GTF + S32 i; + for (i=0; icqiBits[i], mBuf); + } + for (i=0; iri[i], mBuf); + } +#else + CMCHKUNPK(SUnpkU32, ¶m->uciPayload, mBuf); +#endif + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuRawCqiIndInfo +* +* +* Desc : This structure contains the Raw CQI reports received for the + * transmitting UEs in a single subframe. + * @details Raw CQI corresponds to the actual bits transmitted by the UE, whose + * interpretation is upto the MAC layer. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuRawCqiIndInfo +( +TfuRawCqiIndInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuRawCqiIndInfo(param, mBuf) +TfuRawCqiIndInfo *param; +Buffer *mBuf; +#endif +{ + + U32 count; + TfuRawCqiRpt *tfuRawCqiRpt; + CmLList *node; + + TRC3(cmPkTfuRawCqiIndInfo) + + count = param->rawCqiRpt.count; + node = param->rawCqiRpt.last; + while (node) { + tfuRawCqiRpt = (TfuRawCqiRpt *)node->node; + node=node->prev; + CMCHKPK(cmPkTfuRawCqiRpt, tfuRawCqiRpt, mBuf); + cmLListDelFrm(¶m->rawCqiRpt, &tfuRawCqiRpt->lnk); + tfuRawCqiRpt->lnk.node = (PTR)NULLP; + } + CMCHKPK(SPkU32, count, mBuf); + CMCHKPK(cmPkLteTimingInfo, ¶m->timingInfo, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuRawCqiIndInfo +* +* +* Desc : This structure contains the Raw CQI reports received for the + * transmitting UEs in a single subframe. + * @details Raw CQI corresponds to the actual bits transmitted by the UE, whose + * interpretation is upto the MAC layer. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuRawCqiIndInfo +( +TfuRawCqiIndInfo *param, +Ptr memCp, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuRawCqiIndInfo(param, memCp, mBuf) +TfuRawCqiIndInfo *param; +Ptr memCp; +Buffer *mBuf; +#endif +{ + + U32 count, loopCnt; + TfuRawCqiRpt *tfuRawCqiRpt; + + TRC3(cmUnpkTfuRawCqiIndInfo) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteTimingInfo, ¶m->timingInfo, mBuf); + cmLListInit(¶m->rawCqiRpt); + CMCHKUNPK(SUnpkU32, &count, mBuf); + for (loopCnt=0; loopCntrawCqiRpt, &tfuRawCqiRpt->lnk); + tfuRawCqiRpt->lnk.node = (PTR)tfuRawCqiRpt; + } + RETVALUE(ROK); +} + + +#ifdef TFU_TDD + +#ifdef TFU_TDD + + +/*********************************************************** +* +* Func : cmPkTfuUePucchHqRecpInfo +* +* +* Desc : This structure is sent from scheduler to PHY in order to request the + * reception of harq information on PUCCH. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuUePucchHqRecpInfo +( +TfuUePucchHqRecpInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuUePucchHqRecpInfo(param, mBuf) +TfuUePucchHqRecpInfo *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmPkTfuUePucchHqRecpInfo) + + CMCHKPK(SPkU8, param->a, mBuf); + for (i=TFU_MAX_HQ_RES-1; i >= 0; i--) { + CMCHKPK(SPkU16, param->hqRes[i], mBuf); + } + CMCHKPK(SPkU8, param->pucchResCnt, mBuf); + CMCHKPK(SPkU8, param->hqSz, mBuf); + CMCHKPK(SPkU32, param->hqFdbkMode, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuUePucchHqRecpInfo +* +* +* Desc : This structure is sent from scheduler to PHY in order to request the + * reception of harq information on PUCCH. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuUePucchHqRecpInfo +( +TfuUePucchHqRecpInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuUePucchHqRecpInfo(param, mBuf) +TfuUePucchHqRecpInfo *param; +Buffer *mBuf; +#endif +{ + + S32 i; + TRC3(cmUnpkTfuUePucchHqRecpInfo) + + CMCHKUNPK(SUnpkU32, (U32 *)¶m->hqFdbkMode, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->hqSz, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->pucchResCnt, mBuf); + for (i=0; ihqRes[i], mBuf); + } + CMCHKUNPK(SUnpkU8, ¶m->a, mBuf); + RETVALUE(ROK); +} + + +#endif + +#endif + +#ifndef TFU_TDD /* else of TFU_TDD */ + +#ifndef TFU_TDD /* else of TFU_TDD */ + + +/*********************************************************** +* +* Func : cmPkTfuUePucchHqRecpInfo +* +* +* Desc : This structure is sent from scheduler to PHY in order to request the + * reception of harq information on PUCCH. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuUePucchHqRecpInfo +( +TfuUePucchHqRecpInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuUePucchHqRecpInfo(param, mBuf) +TfuUePucchHqRecpInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuUePucchHqRecpInfo) +#ifdef LTE_ADV + S32 idx; + for (idx=(TFU_MAX_HQ_RES-1); idx >= 0; idx--) { + CMCHKPK(SPkU16, param->hqRes[idx], mBuf); + } +#else + CMCHKPK(SPkU16, param->hqRes[0], mBuf); +#endif + CMCHKPK(SPkU8, param->pucchResCnt, mBuf); + CMCHKPK(SPkU8, param->hqSz, mBuf); + CMCHKPK(SPkU32, param->hqFdbkMode, mBuf); + + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuUePucchHqRecpInfo +* +* +* Desc : This structure is sent from scheduler to PHY in order to request the + * reception of harq information on PUCCH. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuUePucchHqRecpInfo +( +TfuUePucchHqRecpInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuUePucchHqRecpInfo(param, mBuf) +TfuUePucchHqRecpInfo *param; +Buffer *mBuf; +#endif +{ + TRC3(cmUnpkTfuUePucchHqRecpInfo) + + CMCHKUNPK(SUnpkU32, (U32 *)¶m->hqFdbkMode, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->hqSz, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->pucchResCnt, mBuf); +#ifdef LTE_ADV + S32 idx; + for (idx=0; idxhqRes[idx], mBuf); + } +#else + CMCHKUNPK(SUnpkU16, ¶m->hqRes[0], mBuf); +#endif + + RETVALUE(ROK); +} + + +#endif + +#endif + + +/*********************************************************** +* +* Func : cmPkTfuUePucchSrRecpInfo +* +* +* Desc : This structure is sent from scheduler to PHY in order to request the + * reception of SR information on PUCCH. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuUePucchSrRecpInfo +( +TfuUePucchSrRecpInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuUePucchSrRecpInfo(param, mBuf) +TfuUePucchSrRecpInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuUePucchSrRecpInfo) + + CMCHKPK(SPkU16, param->n1PucchIdx, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuUePucchSrRecpInfo +* +* +* Desc : This structure is sent from scheduler to PHY in order to request the + * reception of SR information on PUCCH. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuUePucchSrRecpInfo +( +TfuUePucchSrRecpInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuUePucchSrRecpInfo(param, mBuf) +TfuUePucchSrRecpInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuUePucchSrRecpInfo) + + CMCHKUNPK(SUnpkU16, ¶m->n1PucchIdx, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuUePucchCqiRecpInfo +* +* +* Desc : This structure is sent from scheduler to PHY in order to request the + * reception of CQI information on PUCCH. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuUePucchCqiRecpInfo +( +TfuUePucchCqiRecpInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuUePucchCqiRecpInfo(param, mBuf) +TfuUePucchCqiRecpInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuUePucchCqiRecpInfo) + + CMCHKPK(SPkU8, param->cqiPmiSz, mBuf); + CMCHKPK(SPkU16, param->n2PucchIdx, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuUePucchCqiRecpInfo +* +* +* Desc : This structure is sent from scheduler to PHY in order to request the + * reception of CQI information on PUCCH. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuUePucchCqiRecpInfo +( +TfuUePucchCqiRecpInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuUePucchCqiRecpInfo(param, mBuf) +TfuUePucchCqiRecpInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuUePucchCqiRecpInfo) + + CMCHKUNPK(SUnpkU16, ¶m->n2PucchIdx, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->cqiPmiSz, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuUePucchSrsRecpInfo +* +* +* Desc : This structure is sent from scheduler to PHY in order to request the + * reception of SRS information on PUCCH. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuUePucchSrsRecpInfo +( +TfuUePucchSrsRecpInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuUePucchSrsRecpInfo(param, mBuf) +TfuUePucchSrsRecpInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuUePucchSrsRecpInfo) + + CMCHKPK(SPkU32, param->srsCyclicShft, mBuf); + CMCHKPK(SPkU16, param->srsCfgIdx, mBuf); + CMCHKPK(SPkU8, param->transComb, mBuf); + CMCHKPK(SPkU32, param->srsHopBw, mBuf); + CMCHKPK(SPkU8, param->nRrc, mBuf); + CMCHKPK(SPkU32, param->srsBw, mBuf); + RETVALUE(ROK); +} + +#ifdef TFU_5GTF +#ifdef ANSI +PUBLIC S16 cmPkTfuUePucchUciRecpInfo +( +TfuUePucchUciRecpInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuUePucchUciRecpInfo(param, mBuf) +TfuUePucchUciRecpInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuUePucchUciRecpInfo) + + CMCHKPK(SPkU8, param->SCID, mBuf); + CMCHKPK(SPkU8, param->pucchIndex, mBuf); + CMCHKPK(SPkU8, param->numBits, mBuf); + RETVALUE(ROK); +} +#endif + + +/*********************************************************** +* +* Func : cmUnpkTfuUePucchSrsRecpInfo +* +* +* Desc : This structure is sent from scheduler to PHY in order to request the + * reception of SRS information on PUCCH. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuUePucchSrsRecpInfo +( +TfuUePucchSrsRecpInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuUePucchSrsRecpInfo(param, mBuf) +TfuUePucchSrsRecpInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuUePucchSrsRecpInfo) + + CMCHKUNPK(SUnpkU32, (U32 *)¶m->srsBw, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->nRrc, mBuf); + CMCHKUNPK(SUnpkU32, (U32 *)¶m->srsHopBw, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->transComb, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->srsCfgIdx, mBuf); + CMCHKUNPK(SUnpkU32, (U32 *)¶m->srsCyclicShft, mBuf); + RETVALUE(ROK); +} + +#ifdef TFU_5GTF +/*********************************************************** +* +* Func : cmPkTfuUePucchBsiBriRecpInfo +* +* +* Desc : This structure is sent from scheduler to PHY in order to request the + * reception of BSI_BRI information on PUCCH. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuUePucchBsiBriRecpInfo +( +TfuUePucchBsiBriRecpInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuUePucchBsiBriRecpInfo(param, mBuf) +TfuUePucchBsiBriRecpInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuUePucchBsiBriRecpInfo) + + CMCHKPK(SPkU8, param->briRpt, mBuf); + CMCHKPK(SPkU8, param->bsiRpt, mBuf); + CMCHKPK(SPkU8, param->SCID, mBuf); + CMCHKPK(SPkU8, param->pucchIndex, mBuf); + CMCHKPK(SPkU8, param->puschFlag, mBuf); + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func : cmUnpkTfuUePucchBsiBriRecpInfo +* +* +* Desc : This structure is sent from scheduler to PHY in order to request the + * reception of BSI_BRI information on PUCCH. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuUePucchBsiBriRecpInfo +( +TfuUePucchBsiBriRecpInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuUePucchBsiBriRecpInfo(param, mBuf) +TfuUePucchBsiBriRecpInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuUePucchBsiBriRecpInfo) + + CMCHKUNPK(SUnpkU8, ¶m->puschFlag, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->pucchIndex, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->SCID, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->bsiRpt, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->briRpt, mBuf); + RETVALUE(ROK); +} +#endif + +#ifdef TFU_5GTF +#ifdef ANSI +PUBLIC S16 cmUnpkTfuUePucchUciRecpInfo +( +TfuUePucchUciRecpInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuUePucchUciRecpInfo(param, mBuf) +TfuUePucchUciRecpInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuUePucchUciRecpInfo) + + CMCHKUNPK(SUnpkU8, ¶m->numBits, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->pucchIndex, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->SCID, mBuf); + + RETVALUE(ROK); +} +#endif + + +/*********************************************************** +* +* Func : cmPkTfuUePucchRecpReq +* +* +* Desc : This structure is sent from scheduler to PHY in order to request the + * reception of UCI on PUCCH. This may contain the following: + * -# HARQ + * -# SR + * -# SRS + * -# CQI + * -# HARQ+SR + * -# HARQ+SRS + * -# HARQ+CQI + * -# HARQ+SR+SRS + * -# HARQ+SR+CQI + * -# SR+SRS + * -# SR+CQI +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuUePucchRecpReq +( +TfuUePucchRecpReq *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuUePucchRecpReq(param, mBuf) +TfuUePucchRecpReq *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuUePucchRecpReq) + +#ifdef TFU_5GTF + CMCHKPK(cmPkTfuUePucchBsiBriRecpInfo, ¶m->bsiBriInfo, mBuf); + CMCHKPK(cmPkTfuUePucchUciRecpInfo, ¶m->uciPduInfo, mBuf); +#endif /* TFU_5GTF */ + CMCHKPK(cmPkTfuUePucchSrsRecpInfo, ¶m->srsInfo, mBuf); + CMCHKPK(cmPkTfuUePucchHqRecpInfo, ¶m->hqInfo, mBuf); + CMCHKPK(cmPkTfuUePucchSrRecpInfo, ¶m->srInfo, mBuf); + CMCHKPK(cmPkTfuUePucchCqiRecpInfo, ¶m->cqiInfo, mBuf); + CMCHKPK(SPkU32, param->uciInfo, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuUePucchRecpReq +* +* +* Desc : This structure is sent from scheduler to PHY in order to request the + * reception of UCI on PUCCH. This may contain the following: + * -# HARQ + * -# SR + * -# SRS + * -# CQI + * -# HARQ+SR + * -# HARQ+SRS + * -# HARQ+CQI + * -# HARQ+SR+SRS + * -# HARQ+SR+CQI + * -# SR+SRS + * -# SR+CQI +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuUePucchRecpReq +( +TfuUePucchRecpReq *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuUePucchRecpReq(param, mBuf) +TfuUePucchRecpReq *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuUePucchRecpReq) + + CMCHKUNPK(SUnpkU32, (U32 *)¶m->uciInfo, mBuf); + CMCHKUNPK(cmUnpkTfuUePucchCqiRecpInfo, ¶m->cqiInfo, mBuf); + CMCHKUNPK(cmUnpkTfuUePucchSrRecpInfo, ¶m->srInfo, mBuf); + CMCHKUNPK(cmUnpkTfuUePucchHqRecpInfo, ¶m->hqInfo, mBuf); + CMCHKUNPK(cmUnpkTfuUePucchSrsRecpInfo, ¶m->srsInfo, mBuf); +#ifdef TFU_5GTF + CMCHKUNPK(cmUnpkTfuUePucchUciRecpInfo, ¶m->uciPduInfo, mBuf); + CMCHKUNPK(cmUnpkTfuUePucchBsiBriRecpInfo, ¶m->bsiBriInfo, mBuf); +#endif /* TFU_5GTF */ + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuUeUlSchRecpInfo +* +* +* Desc : This structure is sent from scheduler to PHY in order to request the + * reception of UEs data on ULSCH. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuUeUlSchRecpInfo +( +TfuUeUlSchRecpInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuUeUlSchRecpInfo(param, mBuf) +TfuUeUlSchRecpInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuUeUlSchRecpInfo) +#ifdef TFU_5GTF + CMCHKPK(SPkU8, param->beamIndex, mBuf); + CMCHKPK(SPkU8, param->uciWoTBFlag, mBuf); + CMCHKPK(SPkU8, param->PMI, mBuf); + CMCHKPK(SPkU8, param->SCID, mBuf); + CMCHKPK(SPkU8, param->nAntPortLayer, mBuf); + CMCHKPK(SPkU8, param->xPUSCHRange, mBuf); + CMCHKPK(SPkU8, param->numRbg, mBuf); + CMCHKPK(SPkU8, param->rbgStart, mBuf); +#endif + CMCHKPK(SPkU8, param->mcs, mBuf); + CMCHKPK(SPkU8, param->nSrs, mBuf); + CMCHKPK(SPkU8, param->crntTxNb, mBuf); + CMCHKPK(SPkU8, param->txMode, mBuf); + CMCHKPK(SPkU8, param->harqProcId, mBuf); + CMCHKPK(SPkU8, param->rv, mBuf); + CMCHKPK(SPkU8, param->ndi, mBuf); + CMCHKPK(SPkU8, param->isRtx, mBuf); + CMCHKPK(SPkU8, param->hoppingBits, mBuf); + CMCHKPK(SPkU8, param->hoppingEnbld, mBuf); + CMCHKPK(SPkU8, param->nDmrs, mBuf); + CMCHKPK(SPkU32, param->modType, mBuf); + CMCHKPK(SPkU8, param->numRb, mBuf); + CMCHKPK(SPkU8, param->rbStart, mBuf); + CMCHKPK(SPkU16, param->size, mBuf); + + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuUeUlSchRecpInfo +* +* +* Desc : This structure is sent from scheduler to PHY in order to request the + * reception of UEs data on ULSCH. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuUeUlSchRecpInfo +( +TfuUeUlSchRecpInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuUeUlSchRecpInfo(param, mBuf) +TfuUeUlSchRecpInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuUeUlSchRecpInfo) + + CMCHKUNPK(SUnpkU16, ¶m->size, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->rbStart, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numRb, mBuf); + CMCHKUNPK(SUnpkU32, (U32 *)¶m->modType, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->nDmrs, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->hoppingEnbld, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->hoppingBits, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->isRtx, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->ndi, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->rv, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->harqProcId, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->txMode, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->crntTxNb, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->nSrs, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->mcs, mBuf); +#ifdef TFU_5GTF + CMCHKUNPK(SUnpkU8, ¶m->rbgStart, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numRbg, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->xPUSCHRange, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->nAntPortLayer, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->SCID, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->PMI, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->uciWoTBFlag, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->beamIndex, mBuf); +#endif + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuUePuschCqiRecpInfo +* +* +* Desc : This structure is sent from scheduler to PHY in order to request the + * reception of CQI_RI info on PUSCH. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuUePuschCqiRecpInfo +( +TfuUePuschCqiRecpInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuUePuschCqiRecpInfo(param, mBuf) +TfuUePuschCqiRecpInfo *param; +Buffer *mBuf; +#endif +{ + + U32 idx = 0; + TRC3(cmPkTfuUePuschCqiRecpInfo) + + CMCHKPK(SPkU8, param->riBetaOff, mBuf); + CMCHKPK(SPkU8, param->cqiBetaOff, mBuf); + for (idx = 0; idx < param->cCNum; idx++) + { + CMCHKPK(cmPkTknU8, ¶m->riSz[idx], mBuf); + CMCHKPK(SPkU8, param->cqiPmiSzRn1[idx], mBuf); + CMCHKPK(SPkU8, param->cqiPmiSzR1[idx], mBuf); + } + CMCHKPK(SPkU8, param->cCNum, mBuf); + CMCHKPK(SPkU8, param->reportType, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuUePuschCqiRecpInfo +* +* +* Desc : This structure is sent from scheduler to PHY in order to request the + * reception of CQI_RI info on PUSCH. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuUePuschCqiRecpInfo +( +TfuUePuschCqiRecpInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuUePuschCqiRecpInfo(param, mBuf) +TfuUePuschCqiRecpInfo *param; +Buffer *mBuf; +#endif +{ + + U32 idx; + TRC3(cmUnpkTfuUePuschCqiRecpInfo) + + CMCHKUNPK(SUnpkU8, ¶m->reportType, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->cCNum, mBuf); + for (idx = param->cCNum; idx > 0; idx--) + { + CMCHKUNPK(SUnpkU8, ¶m->cqiPmiSzR1[idx-1], mBuf); + CMCHKUNPK(SUnpkU8, ¶m->cqiPmiSzRn1[idx-1], mBuf); + CMCHKUNPK(cmUnpkTknU8, ¶m->riSz[idx-1], mBuf); + } + CMCHKUNPK(SUnpkU8, ¶m->cqiBetaOff, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->riBetaOff, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuUePuschHqRecpInfo +* +* +* Desc : This structure is sent from scheduler to PHY in order to request the + * reception of Harq info on PUSCH. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuUePuschHqRecpInfo +( +TfuUePuschHqRecpInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuUePuschHqRecpInfo(param, mBuf) +TfuUePuschHqRecpInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuUePuschHqRecpInfo) + + +#ifdef TFU_TDD + CMCHKPK(SPkU8, param->ulDai, mBuf); + CMCHKPK(SPkU8, param->nBundled, mBuf); + CMCHKPK(SPkU32, param->hqFdbkMode, mBuf); +#endif + CMCHKPK(SPkU8, param->hqBetaOff, mBuf); + CMCHKPK(SPkU8, param->hqSz, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuUePuschHqRecpInfo +* +* +* Desc : This structure is sent from scheduler to PHY in order to request the + * reception of Harq info on PUSCH. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuUePuschHqRecpInfo +( +TfuUePuschHqRecpInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuUePuschHqRecpInfo(param, mBuf) +TfuUePuschHqRecpInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuUePuschHqRecpInfo) + + CMCHKUNPK(SUnpkU8, ¶m->hqSz, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->hqBetaOff, mBuf); + +#ifdef TFU_TDD + CMCHKUNPK(SUnpkU32, (U32 *)¶m->hqFdbkMode, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->nBundled, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->ulDai, mBuf); +#endif + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuUePuschRecpReq +* +* +* Desc : This structure is sent from scheduler to PHY in order to request the + * reception of UEs data on PUSCH. This may contain the following: + * -# Data + * -# Data + SRS + * -# Data + HARQ + * -# Data + HARQ + SRS + * -# Data + CQI/RI + * -# Data + CQI/RI + SRS + * -# Data + CQI/RI + HARQ + * -# Data + CQI/RI + HARQ + SRS +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuUePuschRecpReq +( +TfuUePuschRecpReq *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuUePuschRecpReq(param, mBuf) +TfuUePuschRecpReq *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuUePuschRecpReq) + + CMCHKPK(cmPkTknU8, ¶m->initialNumRbs, mBuf); + CMCHKPK(cmPkTknU8, ¶m->initialNSrs, mBuf); + CMCHKPK(cmPkTfuUePucchSrsRecpInfo, ¶m->srsInfo, mBuf); + CMCHKPK(cmPkTfuUePuschHqRecpInfo, ¶m->hqInfo, mBuf); + CMCHKPK(cmPkTfuUePuschCqiRecpInfo, ¶m->cqiRiInfo, mBuf); + CMCHKPK(cmPkTfuUeUlSchRecpInfo, ¶m->ulSchInfo, mBuf); + CMCHKPK(SPkU32, param->rcpInfo, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuUePuschRecpReq +* +* +* Desc : This structure is sent from scheduler to PHY in order to request the + * reception of UEs data on PUSCH. This may contain the following: + * -# Data + * -# Data + SRS + * -# Data + HARQ + * -# Data + HARQ + SRS + * -# Data + CQI/RI + * -# Data + CQI/RI + SRS + * -# Data + CQI/RI + HARQ + * -# Data + CQI/RI + HARQ + SRS +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuUePuschRecpReq +( +TfuUePuschRecpReq *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuUePuschRecpReq(param, mBuf) +TfuUePuschRecpReq *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuUePuschRecpReq) + + CMCHKUNPK(SUnpkU32, (U32 *)¶m->rcpInfo, mBuf); + CMCHKUNPK(cmUnpkTfuUeUlSchRecpInfo, ¶m->ulSchInfo, mBuf); + CMCHKUNPK(cmUnpkTfuUePuschCqiRecpInfo, ¶m->cqiRiInfo, mBuf); + CMCHKUNPK(cmUnpkTfuUePuschHqRecpInfo, ¶m->hqInfo, mBuf); + CMCHKUNPK(cmUnpkTfuUePucchSrsRecpInfo, ¶m->srsInfo, mBuf); + CMCHKUNPK(cmUnpkTknU8, ¶m->initialNSrs, mBuf); + CMCHKUNPK(cmUnpkTknU8, ¶m->initialNumRbs, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuUeRecpReqInfo +* +* +* Desc : This structure is a Per UE reception request for either PUCCH or PUSCH + * data. This contains information needed by PHY to decode the data sent by the + * UE. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuUeRecpReqInfo +( +TfuUeRecpReqInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuUeRecpReqInfo(param, mBuf) +TfuUeRecpReqInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuUeRecpReqInfo) + + switch(param->type) { + case TFU_RECP_REQ_PUSCH: + CMCHKPK(cmPkTfuUePuschRecpReq, ¶m->t.puschRecpReq, mBuf); + break; + case TFU_RECP_REQ_PUCCH: + CMCHKPK(cmPkTfuUePucchRecpReq, ¶m->t.pucchRecpReq, mBuf); + break; + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkU32, param->type, mBuf); +#ifdef TFU_5GTF + CMCHKPK(SPkU8, param->groupId, mBuf); +#endif /* TFU_5GTF */ + CMCHKPK(cmPkLteRnti, param->rnti, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuUeRecpReqInfo +* +* +* Desc : This structure is a Per UE reception request for either PUCCH or PUSCH + * data. This contains information needed by PHY to decode the data sent by the + * UE. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuUeRecpReqInfo +( +TfuUeRecpReqInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuUeRecpReqInfo(param, mBuf) +TfuUeRecpReqInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuUeRecpReqInfo) + + CMCHKUNPK(cmUnpkLteRnti, ¶m->rnti, mBuf); +#ifdef TFU_5GTF + CMCHKUNPK(SUnpkU8, ¶m->groupId, mBuf); +#endif /* TFU_5GTF */ + CMCHKUNPK(SUnpkU32, (U32 *)¶m->type, mBuf); + switch(param->type) { + case TFU_RECP_REQ_PUCCH: + CMCHKUNPK(cmUnpkTfuUePucchRecpReq, ¶m->t.pucchRecpReq, mBuf); + break; + case TFU_RECP_REQ_PUSCH: + CMCHKUNPK(cmUnpkTfuUePuschRecpReq, ¶m->t.puschRecpReq, mBuf); + break; + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} +#endif /* TFU_UPGRADE */ +#ifndef TFU_UPGRADE /* TFU_UPGRADE */ +/*********************************************************** +* +* Func : cmPkTfuUePucchRecpReq +* +* +* Desc : This structure is sent from Scheduler to PHY in order to request the + * reception of an UEs data on PUCCH. This may contain the following: + * -# HARQ-ACK + * -# Scheduling Request (SR) + * -# HARQ-ACK and SR + * -# CQI + * -# CQI and HARQ-ACK +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuUePucchRecpReq +( +TfuUePucchRecpReq *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuUePucchRecpReq(param, mBuf) +TfuUePucchRecpReq *param; +Buffer *mBuf; +#endif +{ + +#ifdef TFU_TDD + S32 i; +#endif + TRC3(cmPkTfuUePucchRecpReq) + + +#ifdef TFU_TDD + for (i=TFU_MAX_M-1; i >= 0; i--) { + CMCHKPK(SPkU8, param->p[i], mBuf); + } + for (i=TFU_MAX_M-1; i >= 0; i--) { + CMCHKPK(SPkU8, param->m[i], mBuf); + } + CMCHKPK(SPkU8, param->M, mBuf); + CMCHKPK(SPkU8, param->multCnt, mBuf); + +#endif + CMCHKPK(SPkU32, param->type, mBuf); + switch(param->hqType) { + case TFU_HQ_RECP_REQ_N1PUCCH: + CMCHKPK(SPkU16, param->t.n1Pucch, mBuf); + break; + +#ifdef TFU_TDD + case TFU_HQ_RECP_REQ_NORMAL: + for (i=TFU_MAX_M-1; i >= 0; i--) { + CMCHKPK(SPkU16, param->t.nCce[i], mBuf); + } + break; + +#endif + +#ifndef TFU_TDD + case TFU_HQ_RECP_REQ_NORMAL: + CMCHKPK(SPkU16, param->t.nCce, mBuf); + break; + +#endif + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkU32, param->hqType, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuUePucchRecpReq +* +* +* Desc : This structure is sent from Scheduler to PHY in order to request the + * reception of an UEs data on PUCCH. This may contain the following: + * -# HARQ-ACK + * -# Scheduling Request (SR) + * -# HARQ-ACK and SR + * -# CQI + * -# CQI and HARQ-ACK +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuUePucchRecpReq +( +TfuUePucchRecpReq *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuUePucchRecpReq(param, mBuf) +TfuUePucchRecpReq *param; +Buffer *mBuf; +#endif +{ + +#ifdef TFU_TDD + S32 i; +#endif + TRC3(cmUnpkTfuUePucchRecpReq) + + CMCHKUNPK(SUnpkU32, (U32 *)¶m->hqType, mBuf); + switch(param->hqType) { + +#ifndef TFU_TDD + case TFU_HQ_RECP_REQ_NORMAL: + CMCHKUNPK(SUnpkU16, ¶m->t.nCce, mBuf); + break; + +#endif + +#ifdef TFU_TDD + case TFU_HQ_RECP_REQ_NORMAL: + for (i=0; it.nCce[i], mBuf); + } + break; + +#endif + case TFU_HQ_RECP_REQ_N1PUCCH: + CMCHKUNPK(SUnpkU16, ¶m->t.n1Pucch, mBuf); + break; + default : + RETVALUE(RFAILED); + } + CMCHKUNPK(SUnpkU32, (U32 *)¶m->type, mBuf); + +#ifdef TFU_TDD + CMCHKUNPK(SUnpkU8, ¶m->multCnt, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->M, mBuf); + for (i=0; im[i], mBuf); + } + for (i=0; ip[i], mBuf); + } + +#endif + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuUeMsg3RecpReq +* +* +* Desc : This structure is sent from scheduler to PHY in order to request the + * reception of UEs data sent as MSG3 for Random access. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuUeMsg3RecpReq +( +TfuUeMsg3RecpReq *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuUeMsg3RecpReq(param, mBuf) +TfuUeMsg3RecpReq *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuUeMsg3RecpReq) + + CMCHKPK(SPkU32, param->modType, mBuf); + CMCHKPK(SPkU16, param->size, mBuf); + /*ccpu00128993 - ADD - fix for msg3 softcombining bug*/ + CMCHKPK(SPkU8, param->nDmrs, mBuf); + CMCHKPK(SPkU8, param->rv, mBuf); + CMCHKPK(SPkU8, param->ndi, mBuf); + CMCHKPK(SPkU8, param->harqProcId, mBuf); + CMCHKPK(SPkU8, param->isRtx, mBuf); + CMCHKPK(SPkU8, param->ulDelay, mBuf); + CMCHKPK(SPkU8, param->expCqi, mBuf); + CMCHKPK(SPkU8, param->mcs, mBuf); + CMCHKPK(SPkU8, param->numRb, mBuf); + CMCHKPK(SPkU8, param->rbStart, mBuf); + CMCHKPK(SPkU8, param->hoppingEnbld, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuUeMsg3RecpReq +* +* +* Desc : This structure is sent from scheduler to PHY in order to request the + * reception of UEs data sent as MSG3 for Random access. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuUeMsg3RecpReq +( +TfuUeMsg3RecpReq *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuUeMsg3RecpReq(param, mBuf) +TfuUeMsg3RecpReq *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuUeMsg3RecpReq) + + CMCHKUNPK(SUnpkU8, ¶m->hoppingEnbld, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->rbStart, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numRb, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->mcs, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->expCqi, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->ulDelay, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->isRtx, mBuf); + /*ccpu00128993 - ADD - fix for msg3 softcombining bug*/ + CMCHKUNPK(SUnpkU8, ¶m->harqProcId, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->ndi, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->rv, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->nDmrs, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->size, mBuf); + CMCHKUNPK(SUnpkU32, (U32 *)¶m->modType, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuUePuschRecpReq +* +* +* Desc : This structure is sent from scheduler to PHY in order to request the + * reception of UEs data on PUSCH. This may contain the following: + * -# Data + * -# Data + CQI and RI + * -# Data + CQI and HARQ +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuUePuschRecpReq +( +TfuUePuschRecpReq *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuUePuschRecpReq(param, mBuf) +TfuUePuschRecpReq *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuUePuschRecpReq) + + CMCHKPK(SPkU32, param->modType, mBuf); + CMCHKPK(SPkU16, param->size, mBuf); + CMCHKPK(SPkU32, param->mode, mBuf); + CMCHKPK(SPkU8, param->expHarq, mBuf); + CMCHKPK(SPkU8, param->expCqi, mBuf); + CMCHKPK(SPkU8, param->nDmrs, mBuf); + CMCHKPK(SPkU8, param->rv, mBuf); + CMCHKPK(SPkU8, param->isRtx, mBuf); + CMCHKPK(SPkU8, param->ndi, mBuf); + CMCHKPK(SPkU8, param->harqProcId, mBuf); + CMCHKPK(SPkU8, param->mcs, mBuf); + CMCHKPK(SPkU8, param->numRb, mBuf); + CMCHKPK(SPkU8, param->rbStart, mBuf); + CMCHKPK(SPkU8, param->hoppingBits, mBuf); + CMCHKPK(SPkU8, param->hoppingEnbld, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuUePuschRecpReq +* +* +* Desc : This structure is sent from scheduler to PHY in order to request the + * reception of UEs data on PUSCH. This may contain the following: + * -# Data + * -# Data + CQI and RI + * -# Data + CQI and HARQ +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuUePuschRecpReq +( +TfuUePuschRecpReq *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuUePuschRecpReq(param, mBuf) +TfuUePuschRecpReq *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuUePuschRecpReq) + + CMCHKUNPK(SUnpkU8, ¶m->hoppingEnbld, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->hoppingBits, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->rbStart, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->numRb, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->mcs, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->harqProcId, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->ndi, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->isRtx, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->rv, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->nDmrs, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->expCqi, mBuf); + CMCHKUNPK(SUnpkU8, ¶m->expHarq, mBuf); + CMCHKUNPK(SUnpkU32, (U32 *)¶m->mode, mBuf); + CMCHKUNPK(SUnpkU16, ¶m->size, mBuf); + CMCHKUNPK(SUnpkU32, (U32 *)¶m->modType, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmPkTfuUeRecpReqInfo +* +* +* Desc : This structure is a Per UE reception request for either PUCCH or PUSCH + * data. This contains information needed by PHY to decode the data sent by the + * UE. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuUeRecpReqInfo +( +TfuUeRecpReqInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmPkTfuUeRecpReqInfo(param, mBuf) +TfuUeRecpReqInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuUeRecpReqInfo) + + switch(param->type) { + case TFU_RECP_REQ_PUSCH: + CMCHKPK(cmPkTfuUePuschRecpReq, ¶m->t.puschRecpReq, mBuf); + break; + case TFU_RECP_REQ_MSG3: + CMCHKPK(cmPkTfuUeMsg3RecpReq, ¶m->t.msg3RecpReq, mBuf); + break; + case TFU_RECP_REQ_PUCCH: + CMCHKPK(cmPkTfuUePucchRecpReq, ¶m->t.pucchRecpReq, mBuf); + break; + default : + RETVALUE(RFAILED); + } + CMCHKPK(SPkU32, param->type, mBuf); + CMCHKPK(cmPkLteRnti, param->rnti, mBuf); + RETVALUE(ROK); +} + + + +/*********************************************************** +* +* Func : cmUnpkTfuUeRecpReqInfo +* +* +* Desc : This structure is a Per UE reception request for either PUCCH or PUSCH + * data. This contains information needed by PHY to decode the data sent by the + * UE. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuUeRecpReqInfo +( +TfuUeRecpReqInfo *param, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuUeRecpReqInfo(param, mBuf) +TfuUeRecpReqInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuUeRecpReqInfo) + + CMCHKUNPK(cmUnpkLteRnti, ¶m->rnti, mBuf); + CMCHKUNPK(SUnpkU32, (U32 *)¶m->type, mBuf); + switch(param->type) { + case TFU_RECP_REQ_PUCCH: + CMCHKUNPK(cmUnpkTfuUePucchRecpReq, ¶m->t.pucchRecpReq, mBuf); + break; + case TFU_RECP_REQ_MSG3: + CMCHKUNPK(cmUnpkTfuUeMsg3RecpReq, ¶m->t.msg3RecpReq, mBuf); + break; + case TFU_RECP_REQ_PUSCH: + CMCHKUNPK(cmUnpkTfuUePuschRecpReq, ¶m->t.puschRecpReq, mBuf); + break; + default : + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + + +#endif /* ifndef TFU_UPGRADE */ +/*LAA: Packing and Unpacking*/ + +/*********************************************************** +* +* Func : cmPkTfuErrIndInfo +* +* +* Desc : This structure contains information that is passed as a part of +* the ERR indication sent from PHY to MAC. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PRIVATE S16 cmPkTfuErrIndInfo +( +TfuErrIndInfo *param, +Buffer *mBuf +) +#else +PRIVATE S16 cmPkTfuErrIndInfo(param, mBuf) +TfuErrIndInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmPkTfuErrIndInfo) + + CMCHKPK(cmPkLteTimingInfo, ¶m->timingInfo, mBuf); + CMCHKPK(cmPkLteCellId, param->cellId, mBuf); + RETVALUE(ROK); +} +/*********************************************************** +* +* Func : cmUnpkTfuErrIndInfo +* +* +* Desc : This structure contains information that is passed as a part of the ERR + * indication sent from PHY to MAC. +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PRIVATE S16 cmUnpkTfuErrIndInfo +( +TfuErrIndInfo *param, +Buffer *mBuf +) +#else +PRIVATE S16 cmUnpkTfuErrIndInfo(param, mBuf) +TfuErrIndInfo *param; +Buffer *mBuf; +#endif +{ + + TRC3(cmUnpkTfuErrIndInfo) + + CMCHKUNPK(cmUnpkLteCellId, ¶m->cellId, mBuf); + CMCHKUNPK(cmUnpkLteTimingInfo, ¶m->timingInfo, mBuf); + RETVALUE(ROK); +} + +/*********************************************************** +* +* Func : cmPkTfuErrInd +* +* + * This API is invoked by PHY to send ERROR INDICATION to scheduler + * Currently invoked in the cases when the Unlicensed SCell transmission + * fails. + * This API contains the Cell and subframe information for which the + * transmission failed. + * + * @param[in] Pst *pst + * @param[in] SuId suId + * @param[in] TfuErrIndInfo *errIndInfo + * @return S16 + * -# ROK + * -# RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmPkTfuErrInd +( +Pst * pst, +SuId suId, +TfuErrIndInfo * errInd +) +#else +PUBLIC S16 cmPkTfuErrInd(pst, suId, errInd) +Pst * pst; +SuId suId; +TfuErrIndInfo * errInd; +#endif +{ + Buffer *mBuf = NULLP; + TRC3(cmPkTfuErrInd) + + if (SGetMsg(pst->region, pst->pool, &mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU105, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)errInd, sizeof(TfuErrIndInfo)); + RETVALUE(RFAILED); + } + if (pst->selector == TFU_SEL_LC) { + if (cmPkTfuErrIndInfo(errInd, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU106, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)errInd, sizeof(TfuErrIndInfo)); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + else if(pst->selector == TFU_SEL_LWLC) + { + if (cmPkPtr((PTR)errInd, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFUXXX, (ErrVal)0, "LWLC Packing failed"); +#endif + + /*MS_FIX:71858:Changed to SPutSBuf as being allocated with SGetSBuf*/ + SPutSBuf(pst->region, pst->pool, (Data *)errInd, sizeof(TfuErrIndInfo)); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + + if (SPkS16(suId, mBuf) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU107, (ErrVal)0, "Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)errInd, sizeof(TfuErrIndInfo)); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + if (pst->selector != TFU_SEL_LWLC) { + if (SPutSBuf(pst->region, pst->pool, (Data *)errInd, sizeof(TfuErrIndInfo)) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU108, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + + pst->event = (Event) EVTTFUERRIND; + RETVALUE(SPstTsk(pst,mBuf)); +} + + +/*********************************************************** +* +* Func : cmUnpkTfuErrInd +* +* + * This API is invoked by PHY to send ERROR INDICATION to scheduler + * Currently invoked in the cases when the Unlicensed SCell transmission + * fails. + * This API contains the Cell and subframe information for which the + * transmission failed. + * @param pst Pointer to the post structure. + * @param suId SAP ID of the service user. + * @param errInd Pointer to the TfuErrIndInfo. + * @return ROK/RFAILED +* +* +* Ret : S16 +* +* Notes: +* +* File : +* +**********************************************************/ +#ifdef ANSI +PUBLIC S16 cmUnpkTfuErrInd +( +TfuErrInd func, +Pst *pst, +Buffer *mBuf +) +#else +PUBLIC S16 cmUnpkTfuErrInd(func, pst, mBuf) +TfuErrInd func; +Pst *pst; +Buffer *mBuf; +#endif +{ + SuId suId; + TfuErrIndInfo *errInd; + + TRC3(cmUnpkTfuErrInd) + + if (SUnpkS16(&suId, mBuf) != ROK) { + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU109, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + if (pst->selector != TFU_SEL_LWLC) { + if ((SGetSBuf(pst->region, pst->pool, (Data **)&errInd, sizeof(TfuErrIndInfo))) != ROK) { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU110, (ErrVal)0, "Packing failed"); +#endif + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + + if (pst->selector == TFU_SEL_LC) + { + if (cmUnpkTfuErrIndInfo(errInd, mBuf) != ROK) { + SPutSBuf(pst->region, pst->pool, (Data *)errInd, sizeof(TfuErrIndInfo)); + TFU_FREE_MSG(mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFU111, (ErrVal)0, "Packing failed"); +#endif + RETVALUE(RFAILED); + } + } + else if(pst->selector == TFU_SEL_LWLC) + { + if (cmUnpkPtr((PTR *)&errInd, mBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SLogError(pst->srcEnt, pst->srcInst, pst->srcProcId, + __FILE__, __LINE__, (ErrCls)ERRCLS_ADD_RES, + (ErrVal)ETFUXXX, (ErrVal)0, "LWLC un-Packing failed"); +#endif + SPutSBuf(pst->region, pst->pool, (Data *)errInd, sizeof(TfuErrIndInfo)); + TFU_FREE_MSG(mBuf); + RETVALUE(RFAILED); + } + } + TFU_FREE_MSG(mBuf); + /* [ccpu00141698]-MOD- MAC/SCH does not free the TTI ind anymore */ + (*func)(pst, suId, errInd); + SPutSBuf(pst->region, pst->pool, (Data *)errInd, sizeof(TfuErrIndInfo)); + RETVALUE(ROK); + +} +#endif /* if defined(LCTFU) */ + +/********************************************************************** + End of file + **********************************************************************/ diff --git a/src/cu_app/cu_app_f1ap.c b/src/cu_app/cu_app_f1ap.c new file mode 100644 index 000000000..6f5a1121d --- /dev/null +++ b/src/cu_app/cu_app_f1ap.c @@ -0,0 +1,58 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/* This file contains handler for incoming F1AP message and sending of F1AP response */ + +#include "cu_mgr_main.h" +#include "cu_sctp.h" + +/******************************************************************* + * + * @brief Handles received F1AP message and sends back response + * + * @details + * + * Function : cuAppInmsgHdlr + * + * Functionality: + * - Decodes received F1AP control message + * - Prepares response message, encodes and sends to SCTP + * + * @params[in] + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +void cuAppInmsgHdlr(char *recvBuf, U8 len) +{ + char *respBuf; + U8 respLen = 0; + + /* TODO : + call ASN decoder for incoming message + Check message type and fills its response + Call ASN encoder for response + Send Message to SCTP */ + + sctpOutMsgSend(respBuf, respLen); + +} /* End of cuAppInmsgHdlr */ + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/cu_app/cu_common.h b/src/cu_app/cu_common.h new file mode 100644 index 000000000..b2eeb9152 --- /dev/null +++ b/src/cu_app/cu_common.h @@ -0,0 +1,58 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/* This file contains common defines for CU Config Params */ + +#ifndef __CU_COMMON_H__ +#define __CU_COMMON_H__ + +#include "envdep.h" + +#define MAX_IPV4_LEN 16 +#define MAX_IPV6_LEN 40 +#define CU_DU_NAME_LEN_MAX 150 /* Max length of CU/DU name string */ + +typedef struct ipAddr +{ + Bool ipV4Pres; + char ipV4Addr[MAX_IPV4_LEN]; + Bool ipV6Pres; + char ipV6Addr[MAX_IPV6_LEN]; +}SctpIpAddr; + +typedef struct sctpParams +{ + SctpIpAddr duIpAddr; + U16 duPort; + SctpIpAddr cuIpAddr; + U16 cuPort; +}SctpParams; + +typedef struct cuCfgParams +{ + U32 cuId; + char cuName[CU_DU_NAME_LEN_MAX]; + SctpParams sctpParams; +}CuCfgParams; + +extern CuCfgParams cuCfgParams; + +#endif +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/cu_app/cu_mgr_main.c b/src/cu_app/cu_mgr_main.c new file mode 100644 index 000000000..ee878d01a --- /dev/null +++ b/src/cu_app/cu_mgr_main.c @@ -0,0 +1,59 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/* This functions contains main() for cu_app */ + +#include "cu_mgr_main.h" +#include "cu_sctp.h" + +/******************************************************************* + * + * @brief Main function of CU APP + * + * @details + * + * Function : main + * + * Functionality: + * - Reads CU related configurations + * - Initialize SCTP Parameters + * - Start SCTP receiver thread + * + * @params[in] + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ + +void main() +{ + printf("\nStarting cu_app"); + + /* Read CU configurations */ + readCuCfg(); + + /* Initializing SCTP global parameters */ + sctpActvInit(0, 0, 0, 0); + + /* Start CU-SCTP to listen on incoming connection */ + sctpStartReq(); +} + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/cu_app/cu_mgr_main.h b/src/cu_app/cu_mgr_main.h new file mode 100644 index 000000000..15ac29be8 --- /dev/null +++ b/src/cu_app/cu_mgr_main.h @@ -0,0 +1,50 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +#ifndef __CU_MGR_MAIN_H__ +#define __CU_MGR_MAIN_H__ + + +#include "stdio.h" +#include "stdlib.h" +#include "string.h" +#include "ctype.h" +#include "stdbool.h" +#include "envopt.h" /* Environment options */ +#include "envdep.h" /* Environment dependent */ +#include "envind.h" /* Environment independent */ + +#include "gen.h" /* General */ +#include "ssi.h" /* System services */ + +#include "cu_common.h" + +#include "gen.x" /* General */ +#include "ssi.x" /* System services */ +#include "cm_lib.x" + +CuCfgParams cuCfgParams; //global variable to hold all configs + +void readCuCfg(); +void cuAppInmsgHdlr(char *recvBuf,U8 len); + +#endif + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/cu_app/cu_sctp.c b/src/cu_app/cu_sctp.c new file mode 100644 index 000000000..a1543c09c --- /dev/null +++ b/src/cu_app/cu_sctp.c @@ -0,0 +1,629 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/* This file contains all SCTP related functionality */ + +#include +#include +#include +#include +#include +#include + +#include "cu_sctp.h" + +/* Global variable declaration */ +S8 sockFd; +S8 lstnSockFd; +U8 socket_type; +Bool nonblocking; +Bool connUp; +int assocId; + +sockaddr_storage_t local_addr; +sockaddr_storage_t remote_addr; +U8 la_len; +U8 ra_len; + +SctpParams *sctpCfg; + +/************************************************************************** + * @brief Task Initiation callback function. + * + * @details + * + * Function : sctpActvInit + * + * Functionality: + * This function is supplied as one of parameters during SCTP's + * task registration. SSI will invoke this function once, after + * it creates and attaches this TAPA Task to a system task. + * + * @param[in] Ent entity, the entity ID of this task. + * @param[in] Inst inst, the instance ID of this task. + * @param[in] Region region, the region ID registered for memory + * usage of this task. + * @param[in] Reason reason. + * @return ROK - success + * RFAILED - failure + ***************************************************************************/ +S16 sctpActvInit(Ent entity, Inst inst, Region region, Reason reason) +{ + sockFd = 0; + lstnSockFd = 0; + connUp = FALSE; + assocId = 0; + nonblocking = FALSE; + sctpCfg = &(cuCfgParams.sctpParams); + return ROK; + +} + +/************************************************************************** + * @brief Task Activation callback function. + * + * @details + * + * Function : sctpActvTsk + * + * Functionality: + * This function handles all SCTP messages received + * This API is registered with SSI during the + * Task Registration of DU APP. + * + * @param[in] Pst *pst, Post structure of the primitive. + * @param[in] Buffer *mBuf, Packed primitive parameters in the + * buffer. + * @return ROK - success + * RFAILED - failure + * + ***************************************************************************/ +S16 sctpActvTsk(Pst *pst, Buffer *mBuf) +{ + +//TODO: TBD + return ROK; +} + +/******************************************************************* + * + * @brief Converts internet address to sockaddr type + * + * @details + * + * Function : getSockAddr + * + * Functionality: + * Converts internet address to sockaddr type + * + * @params[in] + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ + +S16 getSockAddr(char *hostIp, U16 portNum, Bool ipv4Pres, Bool local) +{ + sockaddr_storage_t address; + struct hostent *host; + void *la_raw; + U8 addr_len; + + /* Getting the transport address for local host name */ + if(ipv4Pres) + { + host = gethostbyname(hostIp); + if (host == NULL || host->h_length < 1) + { + printf("\nBad hostname: %s", hostIp); + RETVALUE(NULLP); + } + addr_len = sizeof(address.v4); + la_raw = &address.v4.sin_addr; + address.v4.sin_family = AF_INET; + address.v4.sin_port = htons(portNum); + } + else + { + host = gethostbyname2(hostIp, AF_INET6); + if (host == NULL || host->h_length < 1) + { + printf("\n Bad hostname: %s", hostIp); + RETVALUE(RFAILED); + } + addr_len = sizeof(address.v6); + la_raw = &address.v6.sin6_addr; + address.v6.sin6_family = AF_INET6; + address.v6.sin6_port = htons(portNum); + address.v6.sin6_scope_id = 0; + } + + memcpy((U8 *)la_raw, (U8 *)host->h_addr_list[0], host->h_length); + + if(local) + { + local_addr = address; + la_len = addr_len; + } + else + { + remote_addr = address; + ra_len = addr_len; + } + + RETVALUE(ROK); +} /* End of getSockAddr() */ + +/******************************************************************* + * + * @brief Opens a non-blocking socket and binds to local address + * + * @details + * + * Function : openSctpEndp + * + * Functionality: + * Opens a non-blocking socket and binds to local address + * + * @params[in] + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +S16 openSctpEndp() +{ + sa_family_t la_family; + U8 la_len; + U8 error; + + printf("\nEntering openSctpEndp"); + + /* Getting the transport address for local host name */ + if(sctpCfg->cuIpAddr.ipV4Pres) + { + printf("\nLocal Host Address %s",cuCfgParams.sctpParams.cuIpAddr.ipV4Addr); + if(getSockAddr(sctpCfg->cuIpAddr.ipV4Addr, sctpCfg->cuPort, TRUE, TRUE) != ROK ) + { + printf("\nUnable to get local address"); + RETVALUE(RFAILED); + } + la_len = sizeof(local_addr.v4); + la_family = AF_INET; + } + else + { + if(getSockAddr(sctpCfg->cuIpAddr.ipV6Addr, sctpCfg->cuPort, FALSE, TRUE) != ROK ) + { + printf("\nUnable to get local address"); + RETVALUE(RFAILED); + } + la_len = sizeof(local_addr.v6); + la_family = AF_INET6; + } + + socket_type = SOCK_STREAM; + + /* Creating new end point */ + lstnSockFd = socket(la_family, socket_type, IPPROTO_SCTP); + if (lstnSockFd < 0) + { + printf("\n Failed to create socket %s", strerror(errno)); + RETVALUE(RFAILED); + } + + /* Binding socket to local address and port */ + error = bind(lstnSockFd, &local_addr.sa, la_len); + if(error != 0) + { + printf("\n Failed to bind to socket. Error [%s]", strerror(errno)); + RETVALUE(RFAILED); + } + + /* Setting socket as non-blocking*/ + error = fcntl(lstnSockFd, F_SETFL, O_NONBLOCK); + if (error != 0) + { + printf("\n Failed to set socket as non blocking. Error [%s]", strerror(errno)); + RETVALUE(RFAILED); + } + else + { + nonblocking = TRUE; + } + + RETVALUE(ROK); + +} /* End of openSctpEndp() */ + +/******************************************************************* + * + * @brief Listens for connection request from peer SCTP + * + * @details + * + * Function : sctpConnAccept + * + * Functionality: + * Listens and accepts SCTP connection request from peer. + * Here, DU-SCTP will initate connection towards CU-SCTP + * + * @params[in] + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +S16 sctpConnAccept() +{ + U8 error; + U8 ret; + socklen_t len = 0; + + /* Getting the transport address for remote host name */ + if(sctpCfg->duIpAddr.ipV4Pres) + { + ret = getSockAddr(sctpCfg->duIpAddr.ipV4Addr, sctpCfg->duPort, TRUE, FALSE); + } + else + { + ret = getSockAddr(sctpCfg->duIpAddr.ipV6Addr, sctpCfg->duPort, FALSE, FALSE); + } + if(ret != ROK) + { + printf("\nUnable to get remote address"); + RETVALUE(RFAILED); + } + + printf("\nStart listening on sockFd %d", lstnSockFd); + /* Mark sockFd as being able to accept new associations */ + error = listen(lstnSockFd, 5); + if (error != 0) + { + printf("\nListen Failure: %s", strerror(errno)); + RETVALUE(RFAILED); + } + + while(!connUp) + { + len = 0; + if (!sockFd) + { + if ((sockFd = accept(lstnSockFd, &remote_addr.sa, &len)) < 0) + { + if(errno == EAGAIN && nonblocking) + { + sockFd = 0; + continue; + } + printf("\nFailure in accepting connection request. Error: %s", strerror(errno)); + RETVALUE(RFAILED); + } + else + { + /* Mark connection UP */ + printf("\nCommunication UP. Sock Fd %d", sockFd); + connUp = TRUE; + } + } + } + + RETVALUE(ROK); +}/* End of sctpConnAccept */ + +/******************************************************************* + * + * @brief Handles an incoming message + * + * @details + * + * Function : sctpInmsgHdlr + * + * Functionality: + * Handles an incoming message + * + * @params[in] Socket file descriptor + * Incoming message header + * Message Length + * + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +S16 sctpInmsgHdlr(struct msghdr *msg, size_t msgLen) +{ + sctp_cmsg_data_t *data; + struct cmsghdr *cmsg; + union sctp_notification *sn; + + for (cmsg = CMSG_FIRSTHDR(msg); cmsg != NULL; cmsg = CMSG_NXTHDR(msg, cmsg)) + { + data = (sctp_cmsg_data_t *)CMSG_DATA(cmsg); + } + + printf("\nReceived Message"); + /* if incoming message is data */ + if (!(MSG_NOTIFICATION & msg->msg_flags)) + { + U8 index = 0; + char *recvBuf; + char *temp = recvBuf; + U8 len = msgLen; + U8 temp_len; + U8 i; + + /* Extracting the received message */ + while( msgLen > 0) + { + temp = msg->msg_iov[index].iov_base; + temp_len = msg->msg_iov[index].iov_len; + + if(temp_len > msgLen) + { + temp[(temp_len = msgLen) - 1] = '\0'; + } + + if((msgLen -= temp_len) > 0) + { + index++; + } + for (i = 0; i < temp_len-1 ; ++i) + { + if (!isprint(temp[i])) + temp[i] = '.'; + } + printf("\nPrinting temp %s", temp); + temp = temp + temp_len; + index++; + } + recvBuf[len - 1] = '\0'; + printf("\n Message: %s temp %s", recvBuf, temp); + + /* Send received message to cu_app handler */ + cuAppInmsgHdlr(recvBuf, len); + + } + else /* If the incoming message is notification */ + { + /* Extract and perform necessary action + Change the connUp state accordingly */ + union sctp_notification *notify; + notify = (union sctp_notification *)msg->msg_iov->iov_base; + + if (SCTP_ASSOC_CHANGE != notify->sn_header.sn_type) + { + printf("\nReceived unexpected notification: %d", notify->sn_header.sn_type); + RETVALUE(RFAILED); + } + + switch(notify->sn_assoc_change.sac_state) + { + case SCTP_COMM_UP: + printf("Received SCTP_COMM_UP\n"); + break; + case SCTP_COMM_LOST: + printf("Received SCTP_COMM_LOST\n"); + break; + case SCTP_RESTART: + printf("Received SCTP_RESTART\n"); + break; + case SCTP_SHUTDOWN_COMP: + printf("Received SCTP_SHUTDOWN_COMP\n"); + break; + case SCTP_CANT_STR_ASSOC: + printf("Received SCTP_CANT_STR_ASSOC\n"); + break; + } + } + RETVALUE(ROK); +} + +/******************************************************************* + * + * @brief Receives message on the socket + * + * @details + * + * Function : sctpSockPoll + * + * Functionality: + * Receives message on the socket + * + * @params[in] + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +S16 sctpSockPoll() +{ + U8 error; + struct msghdr inmessage; + struct iovec iov; + char incmsg[CMSG_SPACE(sizeof(_sctp_cmsg_data_t))]; + sockaddr_storage_t msgname; + + /* Initialize inmessage with enough space for DATA... */ + memset(&inmessage, 0, sizeof(inmessage)); + if ((iov.iov_base = malloc(REALLY_BIG)) == NULL) + { + printf("\n malloc not enough memory!!!"); + close(sockFd); + connUp = FALSE; + RETVALUE(RFAILED); + } + iov.iov_len = REALLY_BIG; + inmessage.msg_iov = &iov; + inmessage.msg_iovlen = 1; + /* or a control message. */ + inmessage.msg_control = incmsg; + inmessage.msg_controllen = sizeof(incmsg); + inmessage.msg_name = &msgname; + inmessage.msg_namelen = sizeof(msgname); + + while (connUp) + { + error = recvmsg(sockFd, &inmessage, MSG_WAITALL); + if (error < 0) + { + if (nonblocking && (EAGAIN == errno)) + { + error = 0; + continue; + } + if (socket_type == SOCK_STREAM) + { + if (ENOTCONN != errno) + { + break; + } + printf("No association is present now!!\n"); + close(sockFd); + sockFd = 0; + connUp = FALSE; + } + break; + } + + sctpInmsgHdlr(&inmessage, error); + + inmessage.msg_control = incmsg; + inmessage.msg_controllen = sizeof(incmsg); + inmessage.msg_name = &msgname; + inmessage.msg_namelen = sizeof(msgname); + iov.iov_len = REALLY_BIG; + + }/* End of while(connUp) */ + + RETVALUE(ROK); +}/* End of sctpSockPoll() */ + +/******************************************************************* + * + * @brief Send message on SCTP socket + * + * @details + * + * Function : sctpOutMsgSend + * + * Functionality: + * Send message on SCTP socket + * + * @params[in] + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +S16 sctpOutMsgSend(char *message, U8 msglen) +{ + struct msghdr outmsg; + struct iovec iov; + int error = 0; + + do{ + if(connUp && msglen != 0) + { + iov.iov_base = message; + iov.iov_len = msglen; + + outmsg.msg_iov = &iov; + outmsg.msg_iovlen = 1; + outmsg.msg_control = NULL; + outmsg.msg_controllen = 0; + outmsg.msg_name = &remote_addr; + outmsg.msg_namelen = ra_len; + outmsg.msg_flags = 0; + + error = sendmsg(sockFd, &outmsg, 0); + } + + if(error != msglen) + { + if(nonblocking && EAGAIN == errno) + { + continue; + } + else + { + printf("\n Error [%s] while sending message on SCTP assoc", strerror(errno)); + RETVALUE(RFAILED); + } + } + else + { + break; + } + }while(error != msglen); + + RETVALUE(ROK); + +} /* End of sctpOutMsgSend */ + +/******************************************************************* + * + * @brief SCTP Assoc establishment request from DU + * + * @details + * + * Function : sctpAssocReq + * + * Functionality: + * This function opens a socket at DU and + * intiates SCTP connection. + * + * @params[in] + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ + +void sctpStartReq() +{ + printf("\nStarting CU SCTP"); + + /* Open SCTP socket and bind to local address */ + if(openSctpEndp() != ROK) + { + printf("\nFailed while opening SCTP endpoint"); + if(lstnSockFd > 0 ) + { + close(lstnSockFd); + lstnSockFd = 0; + } + /* TODO : Send Assoc establishment failure to cu_app if needed*/ + } + else if(sctpConnAccept() != ROK) /* send connection request */ + { + printf("\nFailed while connecting to peer"); + close(lstnSockFd); + lstnSockFd = 0; + assocId = 0; + nonblocking = FALSE; + /* TODO : Send Assoc establishment failure to cu_app */ + } + else + { + /* Send AssocCfm to cu_app */ + if(sctpSockPoll() != ROK) + { + printf("\nFailed while polling"); + /* Send failure to cu_app */ + } + } +} /* End of sctpStartReq */ + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/cu_app/cu_sctp.h b/src/cu_app/cu_sctp.h new file mode 100644 index 000000000..1d1c371aa --- /dev/null +++ b/src/cu_app/cu_sctp.h @@ -0,0 +1,57 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/* This file contains all SCTP related functionality */ + +#ifndef __CU_SCTP_H__ +#define __CU_SCTP_H__ + +#include +#include +#include "cu_mgr_main.h" + +EXTERN S16 sctpActvInit(Ent entity, Inst inst, Region region, Reason reason); +EXTERN S16 sctpActvTsk(Pst *pst, Buffer *mBuf); +EXTERN void sctpStartReq(); +EXTERN S16 sctpOutMsgSend(char *message, U8 msglen); + +#define REALLY_BIG 65536 + +/* Convenience structure to determine space needed for cmsg. */ +typedef union +{ + struct sctp_initmsg init; + struct sctp_sndrcvinfo sndrcvinfo; +}_sctp_cmsg_data_t; + +#define CMSG_SPACE_INITMSG (CMSG_SPACE(sizeof(struct sctp_initmsg))) +#define CMSG_SPACE_SNDRCV (CMSG_SPACE(sizeof(struct sctp_sndrcvinfo))) + +typedef union +{ + struct sockaddr_storage ss; + struct sockaddr_in v4; + struct sockaddr_in6 v6; + struct sockaddr sa; +} sockaddr_storage_t; + +#endif + +/********************************************************************** + End of file + **********************************************************************/ diff --git a/src/cu_app/cu_util.c b/src/cu_app/cu_util.c new file mode 100644 index 000000000..10741f0b1 --- /dev/null +++ b/src/cu_app/cu_util.c @@ -0,0 +1,76 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/* This file contains configurations for CU */ + +#include "cu_mgr_main.h" + +#define CU_ID 1 +#define CU_NAME "Oran_OAM_CU" +#define DU_IP_V4_ADDR "127.0.0.1" +#define CU_IP_V4_ADDR "127.0.0.2" +#define DU_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0001" +#define CU_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0011" +#define DU_PORT 38472 +#define CU_PORT 38472 + +/******************************************************************* + * + * @brief Read CU related configuration + * + * @details + * + * Function : readCuCfg + * + * Functionality: + * - RRead CU related configuration + * + * @params[in] + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ + +void readCuCfg() +{ + printf("\nReading CU configurations"); + + cuCfgParams.cuId = CU_ID; + strcpy(cuCfgParams.cuName, CU_NAME); + + /* DU IP Address and Port*/ + cuCfgParams.sctpParams.duIpAddr.ipV4Pres = true; + strcpy(cuCfgParams.sctpParams.duIpAddr.ipV4Addr, (char*)DU_IP_V4_ADDR); + cuCfgParams.sctpParams.duIpAddr.ipV6Pres = false; + strcpy(cuCfgParams.sctpParams.duIpAddr.ipV6Addr, (char*)DU_IP_V6_ADDR); + cuCfgParams.sctpParams.duPort = DU_PORT; + + /* CU IP Address and Port*/ + cuCfgParams.sctpParams.cuIpAddr.ipV4Pres = true; + strcpy(cuCfgParams.sctpParams.cuIpAddr.ipV4Addr, (char*)CU_IP_V4_ADDR); + printf("\nCU IP Address %s",cuCfgParams.sctpParams.cuIpAddr.ipV4Addr); + cuCfgParams.sctpParams.cuIpAddr.ipV6Pres = false; + printf("\nCU IP Address %s",cuCfgParams.sctpParams.cuIpAddr.ipV4Addr); + strcpy(cuCfgParams.sctpParams.cuIpAddr.ipV6Addr, DU_IP_V6_ADDR); + cuCfgParams.sctpParams.cuPort = CU_PORT; + +} /* End of readCuCfg */ + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/du_app/F1AP/f1ap_msg_hdl.c b/src/du_app/F1AP/f1ap_msg_hdl.c new file mode 100644 index 000000000..8cf5b05de --- /dev/null +++ b/src/du_app/F1AP/f1ap_msg_hdl.c @@ -0,0 +1,68 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/* This file contains F1AP message handler functions */ + +#include "du_mgr.h" +/*************************************************************************** + * + * + * + * + * + * + * + * + * + * ************************************************************************/ + +S16 BuildAndSendF1SetupReq() +{ + S16 ret = ROK; + +//in case of any failure, assign RFAILED to ret + + + return ret; +} + +/*************************************************************************** + * + * + * + * + * + * + * + * + * + * ************************************************************************/ + +S16 ExtractSendF1SetupRsp() +{ + S16 ret = ROK; + +//in case of any failure, assign RFAILED to ret + + + return ret; +} + +/********************************************************************** + End of file + **********************************************************************/ diff --git a/src/du_app/du_common.h b/src/du_app/du_common.h new file mode 100644 index 000000000..3c46e85e3 --- /dev/null +++ b/src/du_app/du_common.h @@ -0,0 +1,814 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +#ifndef __DU_COMMON_H__ +#define __DU_COMMON_H__ + +#include "envdep.h" +#include "lcl.h" + +#define DU_PROC 0 +#define DU_POOL 1 +/* Events */ +#define EVTCFG 0 + +/* Selector */ +#define DU_SELECTOR_LC 0 +#define DU_SELECTOR_TC 1 +#define DU_SELECTOR_LWLC 2 + + +/* Macro definitions for F1 procedures */ +#define CU_DU_NAME_LEN_MAX 150 /* Max length of CU/DU name string */ +#define MAX_F1_CONNECTIONS 65536 /* Max num of F1 connections */ +#define MAXCELLINGNBDU 512 /* Max num of cells served by gNB-DU */ +#define MAXNUMOFBPLMN 6 /* Max num of broadcast PLMN ids */ +#define MAXNRARFCN 3279165 /* Maximum values of NRAFCN */ +#define MAXNRCELLBANDS 32 /* Maximum number of frequency bands */ +#define MAXNUMOFSLICEITEMS 1024 /* Maximum number of signalled slice support items */ +#define MAXBPLMNNRMINUS1 11 /* Maximum number of PLMN Ids broadcast in an NR cell minus 1 */ +#define MAXNUMOFSIBTYPES 32 /* Maximum number of SIB types */ +#define MAX_UEID 512 /* Maximum number of UE Ids */ +#define MAXNUMOFTNLASSOCS 32 /* Max num of TNL Assoc between CU and DU */ +#define MAXCELLINENB 256 /* Max num of cells served by eNB */ +#define MAXNUMOFUEID 65536 /* Max num of UEs served by DU */ +#define MAXNUMOFUACPLMN 12 /* Maximum number of PLMN ids*/ +#define MAXNUMOFUACPERPLMN 64 /* Maximum number of signalled categories per PLMN */ + +#define MAX_IPV4_LEN 16 /* Max lenght of IPV4 Address */ +#define MAX_IPV6_LEN 40 /* Max lenght of IPV6 Address */ + + +typedef enum +{ + F1_DOWN, + F1_UP +}F1Status; + +typedef enum +{ + GNBDU, + GNBCU +}F1Entity; + +typedef enum +{ + UNSPECIFIED, + RL_FAILURE_RLC, + INVALID_CU_UE_F1AP_ID, + INVALID_DU_UE_F1AP_ID, + INTERACTION_WITH_OTHER_PROC, + INVALID_QCI_VALUE, + RADIO_RELATED_REASON, + INSUFFICIENT_RADIO_RESOURCE, + PROCEDURE_CANCELLED, + NORMAL_RELEASE, + UNAVAILABLE_CELL, + RL_FAILURE_OTHERS, + UE_ACCESS_REJECTED, + SLICE_RESOURCE_UNAVAILABLE, + AMF_ABNORMAL_RELEASE, + INVALID_PLMN +}RadioNwCause; + +typedef enum +{ + TRANS_CAUSE_UNSPECIFIED, + TRANSPORT_RESOURCE_UNAVAIL +}TransLayerCause; + +typedef enum +{ + TRANSFER_SYNTAX_ERR, + ABSTRACT_SYNTAX_ERR_REJECT, + ABSTRACT_SYNTAX_ERR_NOTIFY, + INCOMPATIBLE_MESSAGE, + SEMANTIC_ERROR, + ABSTRACT_SYNTAX_ERR_MSG_CONSTRUCT, + PROTOCOL_CAUSE_UNSPECIFIED +}ProtocolCause; + +typedef enum +{ + CONTROL_PROC_OVERLOAD, + INSUFF_USER_PLANE_RESOURCE, + HARDWARE_FAILURE, + O_AND_M_INTERVENTION, + MISC_CAUSE_UNSPECIFIED +}MiscCause; + +typedef enum +{ + ALL +}F1ResetAll; + +typedef enum +{ + IN_SERVICE, + OUT_OF_SERVICE +}SrvState; + +typedef enum +{ + INITIATING_MSG, + SUCCESSFUL_OUTCOME, + UNSUCCESSFUL_OUTCOME +}F1TriggMsgVal; + +typedef enum +{ + CRIT_REJECT, + CRIT_IGNORE, + CRIT_NOTIFY +}F1ProcCritVal; + +typedef enum +{ + NOT_UNDERSTOOD, + MISSING_IE +}F1ErrorType; + +typedef enum +{ + SCS_15, + SCS_30, + SCS_60, + SCS_120 +}F1NrScs; + +typedef enum +{ + NRB_11, + NRB_18, + NRB_24, + NRB_25, + NRB_31, + NRB_32, + NRB_38, + NRB_51, + NRB_52, + NRB_65, + NRB_66, + NRB_78, + NRB_79, + NRB_93, + NRB_106, + NRB_107, + NRB_121, + NRB_132, + NRB_133, + NRB_135, + NRB_160, + NRB_162, + NRB_189, + NRB_216, + NRB_217, + NRB_245, + NRB_264, + NRB_270, + NRB_273 +}F1Nrb; + +typedef enum +{ + VERY_SMALL, + SMALL, + MEDIUM, + LARGE +}F1CellType; + +typedef enum +{ + DL_ONLY, + UL_ONLY, + UL_DL +}F1CellDir; + +typedef enum +{ + UE_USAGE, + NON_UE_USAGE, + BOTH +}F1AssocUsage; + +typedef enum +{ + BARRED, + NOT_BARRED +}CellBarred; + +typedef enum +{ + OFFER, + EXECUTION +}F1ReqType; + +typedef enum +{ + IGNORE_YES, + IGNORE_NO +}F1IgnoreReq; + +typedef enum +{ + OVERLOADED, + NOT_OVERLOADED +}F1GnbDuOvrloadInfo; + +typedef enum +{ + REJECT_RRC_CONN_NON_EMERG_MODT, + REJECT_RRC_CONN_SIGNALLING, + PERMIT_EMERG_SESSION_AND_MOBILE_TERM_SERVICE, + PERMIT_HIGH_PRIOR_SESSION_AND_MOBILE_TERM_SERVICE +}F1UacStandardAction; + +typedef struct f1RrcVersion +{ + U8 rrcVer; /* Latest RRC Version */ + U32 extRrcVer; /* Latest RRC version extended */ +}F1RrcVersion; + +typedef struct f1FailCause +{ + union + { + RadioNwCause radioNwCause; /* Radio Network Layer Cause */ + TransLayerCause transLayerCause; /* Transport Layer Cause */ + ProtocolCause protCause; /* Protocol Cause */ + MiscCause miscCause; /* Miscellaneous Cause */ + }cause; +}F1FailCause; + +typedef struct f1ProcCode +{ + Bool pres; + U8 value; +}F1ProcCode; + +typedef struct f1TriggMsg +{ + Bool pres; + F1TriggMsgVal value; +}F1TriggMsg; + +typedef struct f1ProcCrit +{ + Bool pres; + F1ProcCritVal value; +}F1ProcCrit; + +typedef struct f1CritDignosIE +{ + F1ProcCritVal ieCritVal; + U16 ieId; + F1ErrorType type; +}F1CritDignosIE; + +typedef struct f1CritDiagnostic +{ + Bool pres; + F1ProcCode procCode; /* Procedure Code */ + F1TriggMsg triggeringMsg; /* Triggering Message */ + F1ProcCrit procCrit; /* Criticality of Triggering msg/proc */ + U32 transId; + F1CritDignosIE diagnosIE; +}F1CritDiagnostic; + +typedef struct f1FailureIE +{ + U32 transId; /* Uniquely identify transaction */ + F1FailCause cause; /* Failure cause */ + U8 timeToWait; /* Seconds to be waited before retry */ + F1CritDiagnostic critDiagnostic; /* Critical diagnostics */ +}F1FailureIE; + +typedef struct f1LogicalConnUeAssoc +{ + U32 gnbCuUeF1apId; + U32 gnbDuUeF1apId; +}F1LogicalConnUeAssoc; + +typedef struct f1ResetType +{ + union + { + F1ResetAll resetAll; /* Reset All */ + F1LogicalConnUeAssoc ueAssocLogicalConn[MAX_F1_CONNECTIONS]; /* In case of Partial Reset : UE associated logical F1 conn list*/ + }type; +}F1ResetType; + +typedef struct f1PLMN +{ +//<<<<<<< HEAD + U8 mcc[3]; + U8 mnc[3]; +//======= + //char mcc[3]; + //char mnc[3]; +//>>>>>>> 0fec7aba84be690775c36e49eb31082dc2180f38 +}F1Plmn; + +typedef struct nrEcgi +{ + F1Plmn plmn; + U32 cellId; +}NrEcgi; + +typedef struct f1SibType +{ + U8 sibType; + U8 sibMsg; + U8 value; +}F1SibType; + +typedef struct f1TxBw +{ + F1NrScs nrScs; /* NR subcarrier spacing */ + F1Nrb nrb; /* Transmission bandwidth expressed in units of RBs */ +}F1TxBw; + +typedef struct f1SulInfo +{ + Bool pres; + U32 sulArfcn; /* SUL ARFCN */ + F1TxBw sulTxBw; /* SUL transmission bandwidth */ +}F1SulInfo; + +typedef struct f1FreqBand +{ + U16 nrFreqBand; + U16 sulBand[MAXNRCELLBANDS]; +}F1FreqBand; + +typedef struct f1NrFreqInfo +{ + U32 nrArfcn; + F1SulInfo sulInfo; + F1FreqBand freqBand[MAXNRCELLBANDS]; +}F1NrFreqInfo; + +typedef struct f1NrFddInfo +{ + F1NrFreqInfo ulNrFreqInfo; /* UL NR Frequency Info */ + F1NrFreqInfo dlNrFreqInfo; /* DL NR Frequency Info */ + F1TxBw ulTxBw; /* UL Transmission bandwidth */ + F1TxBw dlTxBw; /* DL Transmission bandwidth */ +}F1NrFddInfo; + +typedef struct f1NrTddInfo +{ + F1NrFreqInfo nrFreqInfo; /* NR Frequency Info */ + F1TxBw nrTxBw; /* NR Transmission Bandwidth */ +}F1NrTddInfo; + +typedef struct f1NrModeInfo +{ + union + { + F1NrFddInfo fdd; + F1NrTddInfo tdd; + }mode; +}F1NrModeInfo; + +typedef struct f1EutraFddInfo +{ + U16 ulOffset; /* UL offset to Point A */ + U16 dlOffset; /* DL offset to Point A */ +}F1EutraFDDInfo; + +typedef struct f1EutraTddInfo +{ + U16 tddOffset; /* Offset to Point A */ +}F1EutraTDDInfo; + +typedef struct f1EutraModeInfo +{ + union + { + F1EutraFDDInfo fdd; + F1EutraTDDInfo tdd; + }mode; +}F1EutraModeInfo; + +typedef struct f1Tac +{ + Bool pres; + U16 tac; +}F1Tac; + +typedef struct f1Snsaai +{ + U8 sst; + U32 sd; +}F1Snsaai; + +typedef struct epIpAddr +{ + char transportAddr[20]; /* Transport Layer Address */ +}EpIpAddr; + +typedef struct epIpAddrPort +{ + EpIpAddr epIpAddr; + char port[2]; +}EpIpAddrPort; + +typedef struct f1TaiSliceSuppLst +{ + Bool pres; + F1Snsaai snssai[MAXNUMOFSLICEITEMS]; +}F1TaiSliceSuppLst; + +typedef struct f1SrvdPlmn +{ + F1Plmn plmn; + F1TaiSliceSuppLst taiSliceSuppLst; +}F1SrvdPlmn; + +typedef struct f1BrdcstPlmnInfo +{ + F1Plmn plmn[MAXNUMOFBPLMN]; /* PLMN id list */ + F1Plmn extPlmn[MAXNUMOFBPLMN]; /* Extended PLMN id list */ + F1Tac tac; /* 5GS-TAC */ + U32 nrCellId; /* NR Cell id */ + U8 ranac; /* RAN Area code */ + +}F1BrdcstPlmnInfo; + +typedef struct f1CellInfo +{ + NrEcgi nrCgi; /* Cell global Identity */ + U32 nrPci; /* Physical Cell Identity */ + F1Plmn plmn[MAXNUMOFBPLMN]; /* Available PLMN list */ + F1Plmn extPlmn[MAXNUMOFBPLMN]; /* Extended available PLMN list */ +}F1CellInfo; + +typedef struct f1DuCellInfo +{ + F1CellInfo cellInfo; /* cell info */ + F1Tac tac; /* tracking area code */ + F1Tac epsTac; /* Configured EPS TAC */ + F1NrModeInfo f1Mode; /* NR mode info : FDD/TDD */ + U8 measTimeCfg; /* Measurement timing configuration */ + F1CellDir cellDir; /* Cell Direction */ + F1CellType cellType; /* Cell Type */ + F1BrdcstPlmnInfo brdcstPlmnInfo[MAXBPLMNNRMINUS1]; /* Broadcast PLMN Identity Info List */ +}F1DuCellInfo; + +typedef struct f1DuSysInfo +{ + U8 mibMsg; /* MIB message */ + U8 sib1Msg; /* SIB1 message */ +}F1DuSysInfo; + +typedef struct f1CuSysInfo +{ + F1SibType sibTypeToUpd[MAXNUMOFSIBTYPES]; /* SIB types to be updated */ +}F1CuSysInfo; + +typedef struct f1DuSrvdCellInfo +{ + F1DuCellInfo duCellInfo; /* gNB-DU served cell info */ + F1DuSysInfo duSysInfo; /* gNB-DU System Information */ +}F1DuSrvdCellInfo; + +typedef struct f1DuSrvdCellToDel +{ + NrEcgi oldNrCgi; /* Old NR CGI */ + F1DuSrvdCellInfo srvdCellInfo; /* Info of served cell to be deleted */ +}F1DuSrvdCellToDel; + +typedef struct f1CuActCellInfo +{ + F1CellInfo cuCellInfo; /* gNB-CU available cell info */ + F1CuSysInfo cuSysInfo; /* gNB-CU System Information */ +}F1CuActCellInfo; + +typedef struct f1ActCellFail +{ + NrEcgi nrCgi; + F1FailCause cause; +}F1ActCellFail; + +typedef struct srvStatus +{ + SrvState state; + Bool switchOffOngoing; +}SrvStatus; + +typedef struct f1CellStatus +{ + NrEcgi nrEcgi; + SrvStatus status; /* Service status */ +}F1CellStatus; + +typedef struct f1DedSIDelUE +{ + U32 gnbCuUeF1apId; + NrEcgi nrEcgi; +}F1DedSIDelUE; + +typedef struct tnlAssocInfo +{ + Bool pres; + EpIpAddr epIpAddr; /* Endpoint-IP Address */ + EpIpAddrPort epIpAddrport; /* Endpoint-IP Address and Port */ +}F1TnlAssocAddr; + +typedef struct f1TnlAssocUsage +{ + Bool pres; + F1AssocUsage usage; +}F1TnlAssocUsage; + +typedef struct f1TnlAssoc +{ + F1TnlAssocAddr assocInfo; /* TNL Assoc Transport Layer Info */ + F1TnlAssocUsage assocUsage; /* TNL Assoc usage */ +}F1TnlAssoc; + +typedef struct f1TnlAssocToRmv +{ + F1TnlAssocAddr assocInfoCu; /* TNL Assoc Transport Layer Info of CU */ + F1TnlAssocAddr assocInfoDu; /* TNL Assoc Transport Layer Info of DU */ +}F1TnlAssocToRmv; + +typedef struct f1TnlAssocSetupFail +{ + F1TnlAssocAddr assocInfo; + F1FailCause cause; +}F1TnlAssocSetupFail; + + +typedef struct f1CellBarred +{ + NrEcgi nrcgi; + CellBarred cellBarred; +}F1CellBarred; + +typedef struct f1EutraCell +{ + U32 eutraCellId; /* EUTRA cell id */ + F1EutraModeInfo mode; /* EUTRA mode info : FDD/TDD */ + U8 rsrcInd; /* Protected EUTRA resource Indication */ +}F1EutraCell; + +typedef struct f1ProtectEUTRARsrc +{ + U32 specShareGrpId; /* Spectrum sharing group id */ + F1EutraCell eutraCellList[MAXCELLINENB]; /* EUTRA cells list */ +}F1ProtectEUTRARsrc; + +typedef struct f1UacOperatorDefined +{ + U8 accessCategory; + U8 accessId; +}F1UacOperatorDefined; + +typedef struct f1UacCategoryType +{ + union + { + F1UacStandardAction action; /* UAC standardized action */ + F1UacOperatorDefined operatorDef; /* UAC operator defined */ + }type; +}F1UacCategoryType; + +typedef struct f1UacType +{ + U8 uacReducInd; /* Value 0 means no access rate reduction. Value 100 means full access rate reduction */ + F1UacCategoryType uacCategoryType; /* UAC Category type */ +}F1UacType; + +/* Unified Access Class Assistance Information */ +typedef struct f1UacAssistInfo +{ + F1Plmn plmn[MAXNUMOFUACPLMN]; /* UAC PLMN list */ + F1UacType uacType[MAXNUMOFUACPERPLMN]; /* UAC Type list */ +}F1UacAssistInfo; + +/* F1 setup related structures */ + +typedef struct f1SetupReq +{ + U32 transId; /* Uniquely identify transaction */ + U32 duId; /* DU ID */ + char duName[CU_DU_NAME_LEN_MAX]; /* DU name */ + F1DuSrvdCellInfo srvdCellLst[MAXCELLINGNBDU]; /* Serving cell list */ + F1RrcVersion rrcVersion; /* RRC version */ +}F1SetupReq; + +typedef struct f1setupRsp +{ + U32 transId; /* Uniquely identify transaction */ + U32 cuId; /* CU ID */ + char cuName[CU_DU_NAME_LEN_MAX]; /* CU Name */ + F1CuActCellInfo actCellInfo; /* cells to be activated */ + F1RrcVersion rrcVersion; /* RRC version */ +}F1SetupRsp; + +typedef struct f1SetupFail +{ + F1FailureIE setupFail; +}F1SetupFail; + +/* At reception of the RESET message the gNB-DU shall release all allocated resources on F1 + * and radio resources related to the UE association(s) indicated explicitly or implicitly in + * the RESET message and remove the indicated UE contexts including F1AP ID. */ +typedef struct f1Reset +{ + U32 transId; /* Uniquely identify transaction */ + F1FailCause cause; /* Failure cause */ + F1ResetType resetType; /* type of reset */ +}F1Reset; + +/* After the gNB-CU has released all assigned F1 resources and the UE F1AP IDs for all indicated + * UE associations which can be used for new UE-associated logical F1-connections over the F1 interface, + * the gNB-CU shall respond with the RESET ACKNOWLEDGE message. */ +typedef struct f1ResetAck +{ + U32 transId; /* Uniquely identify transaction */ + F1LogicalConnUeAssoc ueAssocLogicalConn[MAX_F1_CONNECTIONS]; /* UE associated logical F1-connection list */ + F1CritDiagnostic critDiagnostic; /* Critical diagnostics */ +}F1ResetAck; + +typedef struct f1ErrorInd +{ + U32 transId; /* Uniquely identify transaction */ + F1Entity errorOrigin; /* Specifies if error is originated at DU or CU */ + F1FailCause cause; /* Failure cause */ +/* If failure is due to Ue related message. */ + U32 gnbCuUeF1apId; /* gNB-CU UE F1AP Id */ + U32 gnbDuUeF1apId; /* gNB-DU UE F1AP Id */ + F1CritDiagnostic critDiagnostic; /* Critical diagnostics */ +}F1ErrorInd; + +typedef struct f1GnbDuCfgUpd +{ + U32 transId; /* Uniquely identify transaction */ + F1DuSrvdCellInfo srvdCellLstAdd[MAXCELLINGNBDU]; /* Served cell list to be added */ + F1DuSrvdCellToDel srvdCellLstMod[MAXCELLINGNBDU]; /* Served cell list to be modified */ + NrEcgi srvdCellLstDel[MAXCELLINGNBDU]; /* Served cell list to be deleted */ + F1CellStatus cellStatus[MAXCELLINGNBDU]; /* Cell status */ + F1DedSIDelUE ueLst[MAX_UEID]; /* Ue list that requires dedicated SI delivery */ + U32 gnbDuId; + F1TnlAssocToRmv gnbDuTnlAssocRmv[MAXNUMOFTNLASSOCS]; /* TNL Assoc list to remove */ +}F1GnbDuCfgUpd; + +typedef struct f1GnbDuCfgUpdAck +{ + U32 transId; /* Uniquely identify transaction */ + F1CuActCellInfo cellLstAct[MAXCELLINGNBDU]; /* List of cells to be activated */ + F1CritDiagnostic critDiagnostic; /* Critical diagnostics */ + NrEcgi cellLstDeact[MAXCELLINGNBDU]; /* List of cells to be deactivated */ +}F1GnbDuCfgUpdAck; + +typedef struct f1GnbDuCfgUpdFail +{ + F1FailureIE gnbDuCfgUpdFail; +}F1GnbDuCfgUpdFail; + +/* Sent by the gNB-CU to transfer updated information associated to an F1-C interface instance */ +typedef struct f1GnbCuCfgUpd +{ + U32 transId; /* Uniquely identifies transaction */ + F1CuActCellInfo cellLstAct[MAXCELLINGNBDU]; /* List of cells to be activated */ + NrEcgi cellLstDeact[MAXCELLINGNBDU]; /* List of cells to be deactivated */ + F1TnlAssoc assocLstAdd[MAXNUMOFTNLASSOCS]; /* List of TNL assocs to be added */ + F1TnlAssoc assocLstUpd[MAXNUMOFTNLASSOCS]; /* List of TNL assocs to be updated */ + F1TnlAssocToRmv assocLstRmv[MAXNUMOFTNLASSOCS]; /* List of TNL assocs to be removed */ + F1CellBarred cellToBarList[MAXCELLINGNBDU]; /* List of Cells to be barred */ + F1ProtectEUTRARsrc protectEutraRsrcList[MAXCELLINENB]; /* List of Protected EUTRA resources */ +}F1GnbCuCfgUpd; + +/* Sent by a gNB-DU to a gNB-CU to acknowledge update of information + * associated to an F1-C interface instance */ +typedef struct f1GnbCuCfgUpdAck +{ + U32 transId; /* Uniquely identify transaction */ + F1ActCellFail actCellFailList[MAXCELLINGNBDU]; /* Cells failed to be activated list */ + F1CritDiagnostic critDiagnostic; /* Critical diagnostics */ + F1TnlAssocAddr assocSetupList[MAXNUMOFTNLASSOCS]; /* TNL Assoc Setup list */ + F1TnlAssocSetupFail assocSetupFailList[MAXNUMOFTNLASSOCS]; /* TNL Assoc Setup fail list */ + F1DedSIDelUE dedSiDelUelist[MAXNUMOFUEID]; /* Dedicated SI delivery needed UE list */ +}F1GnbCuCfgUpdAck; + +typedef struct f1GnbCuCfgUpdFail +{ + F1FailureIE gnbCuCfgUpdFail; +}F1GnbCuCfgUpdFail; + +/* This procedure enables coordination of radio resource allocation between a gNB-CU and + * a gNB-DU. Coordination request is sent by CU to DU */ +typedef struct f1GnbDuRsrcCoordReq +{ + U32 transId; /* Uniquely identifies transaction */ + F1ReqType reqType; /* Request type */ + U8 cellResCoordReqCont; /* Container for X2AP E-UTRA - NR cell resource coordination request */ + F1IgnoreReq ignoreReq; /* Ignore coordination request */ +}F1GnbDuRsrcCoordReq; + +/* This message is sent by a gNB-DU to a gNB-CU, to express the desired resource allocation + * for data traffic, as a response to the GNB-DU RESOURCE COORDINATION REQUEST. */ +typedef struct f1GnbDuRsrcCoordRsp +{ + U32 transId; /* Uniquely identifies transaction */ + U8 cellResCoordRspCont; /* Container for X2AP E-UTRA - NR cell resource coordination response */ +}F1GnbDuRsrcCoordRsp; + +/* This message is sent by the gNB-DU to indicate to the gNB-CU its status of overload */ +typedef struct f1GnbDuStatusInd +{ + U32 transId; /* Uniquely identifies transaction */ + F1GnbDuOvrloadInfo ovrloadInfo; /* gNB-DU overloaded information */ +}F1GnbDuStatusInd; + +/* This message is sent by either the gNB-DU or the gNB-CU to intiate the removal + * of the interface instance and the related resources */ +typedef struct f1RmvReq +{ + U32 transId; /* Uniquely identifies transaction */ +}F1RmvReq; + +/* This message acknowledges the initiation of removal of the interface + * instance and the related resources */ +typedef struct f1RmvRsp +{ + U32 transId; /* Uniquely identifies transaction */ + F1CritDiagnostic critDiagnos; /* Crititcality diagnostics */ +}F1RmvRsp; + +/* This message indicates that removing the interface instance and the related + * resources cannot be accepted */ +typedef struct f1RmvFail +{ + U32 transId; /* Uniquely identifies transaction */ + F1FailCause cause; /* Failure cause */ + F1CritDiagnostic critDiagnostic; /* Criticality diagnostics */ +}F1RmvFail; + +/* This message is sent by the gNB-CU to indicate to the gNB-DU a need to reduce + * the rate at which UEs access the network. */ +typedef struct f1NwkAccessRateRed +{ + U32 transId; /* Uniquely identifies transaction */ + F1UacAssistInfo uacAssistInfo; /* UAC Assistance Information */ +}F1NwkAccessRateRed; + +typedef struct f1Ipaddr +{ + Bool ipV4Pres; + char ipV4Addr[MAX_IPV4_LEN]; + Bool ipV6Pres; + char ipV6Addr[MAX_IPV6_LEN]; +}F1IpAddr; + +typedef struct f1SctpParams +{ + F1IpAddr duIpAddr; + U16 duPort; + F1IpAddr cuIpAddr; + U16 cuPort; +}F1SctpParams; + +typedef struct duCfgParams +{ + F1SctpParams sctpParams; /* SCTP Params */ + U32 duId; + char duName[CU_DU_NAME_LEN_MAX]; + F1DuSrvdCellInfo srvdCellLst[MAXCELLINGNBDU]; /* Serving cell list */ + F1RrcVersion rrcVersion; /* RRC version */ + ClCellCfg clCellCfg; /* CL cell configuration */ + +}DuCfgParams; + +extern DuCfgParams ducfgparam; + +typedef struct cuCfgParams +{ + U32 cuId; + char cuName[CU_DU_NAME_LEN_MAX]; + +}CuCfgParams; + +#endif /* __DU_COMMON_H__ */ + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/du_app/du_mgr.h b/src/du_app/du_mgr.h new file mode 100644 index 000000000..bdd843657 --- /dev/null +++ b/src/du_app/du_mgr.h @@ -0,0 +1,84 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/* This file contains message handling functionality for DU cell management */ +#ifndef __DU_MGR_H__ +#define __DU_MGR_H__ + +#include "stdio.h" +#include "ctype.h" +#include "envopt.h" /* Environment options */ +#include "envdep.h" /* Environment dependent */ +#include "envind.h" /* Environment independent */ +#include "gen.h" /* General */ +#include "ssi.h" /* System services */ +#include "cm5.h" /* Common timer defines */ +#include "cm_tkns.h" /* Common tokens defines */ +#include "cm_mblk.h" /* Common memory allocation library defines */ +#include "cm_llist.h" /* Common link list defines */ +#include "cm_hash.h" /* Common hashlist defines */ +#include "cm_lte.h" +#include "cm_inet.h" +#include "lkw.h" +#include "lrg.h" + +#include "du_common.h" + +#include "gen.x" /* General */ +#include "ssi.x" /* System services */ + +#include "cm5.x" /* Common timer library */ +#include "cm_tkns.x" /* Common tokens */ +#include "cm_mblk.x" /* Common memory allocation */ +#include "cm_llist.x" /* Common link list */ +#include "cm_hash.x" /* Common hashlist */ +#include "cm_lte.x" +#include "cm_inet.x" +#include "cm_lib.x" +#include "lkw.x" +#include "lrg.x" + +#define DU_PROC 0 +#define DU_POOL 1 +/* Events */ +#define EVTCFG 0 +#define EVTSCTPUP 1 + +/* Selector */ +#define DU_SELECTOR_LC 0 +#define DU_SELECTOR_TC 1 +#define DU_SELECTOR_LWLC 2 + +/* DU APP DB */ +typedef struct duDb +{ + F1Status f1Status; + +}DuDb; + + +/* DU Cell Functions */ +S16 duActvInit(Ent entity, Inst inst, Region region, Reason reason); +S16 duActvTsk(Pst *pst, Buffer *mBuf); +S16 duProcCfgComplete(); + +#endif + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/du_app/du_mgr_ex_ms.c b/src/du_app/du_mgr_ex_ms.c new file mode 100644 index 000000000..663583283 --- /dev/null +++ b/src/du_app/du_mgr_ex_ms.c @@ -0,0 +1,181 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/* This file contains message handling functionality for DU cell management */ + +#include "du_mgr.h" + +/************************************************************************** + * @brief Task Initiation callback function. + * + * @details + * + * Function : duActvInit + * + * Functionality: + * This function is supplied as one of parameters during DU APP's + * task registration. SSI will invoke this function once, after + * it creates and attaches this TAPA Task to a system task. + * + * @param[in] Ent entity, the entity ID of this task. + * @param[in] Inst inst, the instance ID of this task. + * @param[in] Region region, the region ID registered for memory + * usage of this task. + * @param[in] Reason reason. + * @return ROK - success + * RFAILED - failure + ***************************************************************************/ +S16 duActvInit(Ent entity, Inst inst, Region region, Reason reason) +{ +//TODO: TBD + + return ROK; + +} + +/************************************************************************** + * @brief Task Activation callback function. + * + * @details + * + * Function : duActvTsk + * + * Functionality: + * Primitives invoked by DU APP's users/providers through + * a loosely coupled interface arrive here by means of + * SSI's message handling. This API is registered with + * SSI during the Task Registration of DU APP. + * + * @param[in] Pst *pst, Post structure of the primitive. + * @param[in] Buffer *mBuf, Packed primitive parameters in the + * buffer. + * @return ROK - success + * RFAILED - failure + * + ***************************************************************************/ +S16 duActvTsk(Pst *pst, Buffer *mBuf) +{ + S16 ret = ROK; + + switch(pst->srcEnt) + { + case ENTDUAPP: + { + switch(pst->event) + { + case EVTCFG: + { + duProcCfgComplete(); + SPutMsg(mBuf); + break; + } + default: + { + printf("\nInvalid event received at duActvTsk from ENTDUAPP"); + SPutMsg(mBuf); + ret = RFAILED; + } + } + + break; + } + case ENTF1AP: + { + + break; + } + case ENTRG: //TODO: Layer cfg for RLC UL, DL and MAC must be done + { + switch(pst->event) + { + //Config complete + case EVTCFG: + { + //TODO: Implement duEstablishSctpToCu(); + SPutMsg(mBuf); + break; + } + default: + { + printf("\nInvalid event received at duActvTsk from ENTRG"); + SPutMsg(mBuf); + ret = RFAILED; + } + } + + break; + } + case ENTSCTP: + { + switch(pst->event) + { + case EVTSCTPUP: + { + //Setup F1-C + SPutMsg(mBuf); + break; + } + default: + { + printf("\nInvalid event received at duActvTsk from ENTRG"); + SPutMsg(mBuf); + ret = RFAILED; + } + + } + } + default: + { + printf("\n DU APP can not process message from Entity %d", pst->srcEnt); + SPutMsg(mBuf); + ret = RFAILED; + } + + } + + SExitTsk(); + return ret; +} + +/************************************************************************** + * @brief Function to invoke DU Layer Configs + * + * @details + * + * Function : duProcCfgComplete + * + * Functionality: + * Initiates Configs towards layers of DU + * + * @param[in] void + * @return ROK - success + * RFAILED - failure + * + ***************************************************************************/ +S16 duProcCfgComplete() +{ +//TBD: invoke SCTP/layer config + +// duHdlRlcUlCfgEvent(); + + return ROK; +} + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/du_app/du_mgr_main.c b/src/du_app/du_mgr_main.c new file mode 100644 index 000000000..576177db1 --- /dev/null +++ b/src/du_app/du_mgr_main.c @@ -0,0 +1,327 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/* This file is the entry point for DU APP */ + +#include "du_mgr_main.h" +#include "du_sctp.h" + +extern S16 kwUlActvTsk (Pst *, Buffer *); +extern S16 kwUlActvInit (Ent, Inst, Region, Reason); +extern S16 kwDlActvTsk (Pst *, Buffer *); +extern S16 kwDlActvInit (Ent, Inst, Region, Reason); +extern S16 rgActvTsk (Pst *, Buffer *); +extern S16 rgActvInit (Ent, Inst, Region, Reason); + +DuCfgParams ducfgparam; //global variable to hold all configs + + +/******************************************************************* + * + * @brief Initializes DU APP + * + * @details + * + * Function : duAppInit + * + * Functionality: + * - Registers and attaches TAPA tasks belonging to + * DU_APP sys task + * + * @params[in] system task ID + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +S16 duAppInit(SSTskId sysTskId) +{ + /* Register DU APP TAPA Task for DU */ + if(SRegTTsk((Ent)ENTDUAPP, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0, + duActvInit, (ActvTsk)duActvTsk) != ROK) + { + return RFAILED; + } + /* Attach DU APP TAPA Task for DU */ + if (SAttachTTsk((Ent)ENTDUAPP, (Inst)0, sysTskId)!= ROK) + { + return RFAILED; + } + + printf("\nDU APP created and registered \ + to %d sys task\n", sysTskId); + return ROK; +} + +/******************************************************************* + * + * @brief Initializes SCTP task + * + * @details + * + * Function : sctpInit + * + * Functionality: + * - Registers and attaches TAPA tasks for SCTP receiver + * + * @params[in] system task ID + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +S16 sctpInit(SSTskId sysTskId) +{ + /* Register SCTP TAPA Task */ + if(SRegTTsk((Ent)ENTSCTP, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0, + sctpActvInit, (ActvTsk)sctpActvTsk) != ROK) + { + return RFAILED; + } + /* Attach SCTP TAPA Task */ + if (SAttachTTsk((Ent)ENTSCTP, (Inst)0, sysTskId)!= ROK) + { + return RFAILED; + } + + printf("\nSCTP TAPA task created and registered to %d sys task\n", + sysTskId); + return ROK; +} + +/******************************************************************* + * + * @brief Initializes RLC DL, MAC TAPA task + * + * @details + * + * Function : rlcDlInit + * + * Functionality: + * - Registers and attaches TAPA tasks for MAC and RLC DL + * + * @params[in] system task ID + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +S16 rlcDlInit(SSTskId sysTskId) +{ + /* Register RLC DL TAPA Task */ + if(SRegTTsk((Ent)ENTKW, (Inst)1, (Ttype)TTNORM, (Prior)PRIOR0, + kwDlActvInit, (ActvTsk)kwDlActvTsk) != ROK) + { + return RFAILED; + } + /* Attach RLC DL Task */ + if (SAttachTTsk((Ent)ENTKW, (Inst)1, sysTskId)!= ROK) + { + return RFAILED; + } + + /* Register MAC TAPA Task */ + if(SRegTTsk((Ent)ENTRG, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0, + rgActvInit, (ActvTsk)rgActvTsk) != ROK) + { + return RFAILED; + } + /* Attach MAC Task */ + if (SAttachTTsk((Ent)ENTRG, (Inst)0, sysTskId)!= ROK) + { + return RFAILED; + } + + printf("\nRLC DL and MAC TAPA task created and registered to \ + %d sys task\n", sysTskId); + return ROK; +} + +/******************************************************************* + * + * @brief Initializes RLC UL TAPA task + * + * @details + * + * Function : rlcUlInit + * + * Functionality: + * - Registers and attaches TAPA task for RLC UL + * + * @params[in] system task ID + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +S16 rlcUlInit(SSTskId sysTskId) +{ + /* Register RLC UL TAPA Task */ + if(SRegTTsk((Ent)ENTKW, (Inst)0, (Ttype)TTNORM, (Prior)PRIOR0, + kwUlActvInit, (ActvTsk)kwUlActvTsk) != ROK) + { + return RFAILED; + } + /* Attach RLC DL Task */ + if (SAttachTTsk((Ent)ENTKW, (Inst)0, sysTskId)!= ROK) + { + return RFAILED; + } + printf("\nRLC UL TAPA task created and registered to \ + %d sys task\n", sysTskId); + return ROK; +} + +/******************************************************************* + * + * @brief Initializes system and TAPA tasks + * + * @details + * + * Function : commonInit + * + * Functionality: + * - Registers and attaches system and TAPA tasks + * + * @params[in] void + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +S16 commonInit() +{ + /* Declare system task Ids */ + SSTskId du_app_stsk, sctp_stsk, rlc_ul_stsk, rlc_mac_cl_stsk; + + pthread_attr_t attr; + + SSetProcId(DU_PROC); + //TODO: check regarding cores and add info here + + /* system task for DU APP */ + SCreateSTsk(PRIOR0, &du_app_stsk); + //TODO: check core info to pin the above task to whcih core + + /* system task for RLC_DL and MAC */ + SCreateSTsk(PRIOR0, &rlc_mac_cl_stsk); + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + //TODO: check core info to pin the above task to whcih core + + /* system task for RLC UL */ + SCreateSTsk(PRIOR1, &rlc_ul_stsk); + //TODO: check core info to pin the above task to whcih core + + /* system task for SCTP receiver thread */ + SCreateSTsk(PRIOR3, &sctp_stsk); + //TODO: check core info to pin the above task to whcih core + + /* Create TAPA tasks */ + if(duAppInit(du_app_stsk) != ROK) + { + printf("\nDU APP TAPA Task initialization failed"); + return RFAILED; + } + + if(sctpInit(sctp_stsk) != ROK) + { + printf("\nSCTP TAPA Task initialization failed"); + return RFAILED; + } + + if(rlcDlInit(rlc_mac_cl_stsk) != ROK) + { + printf("\nRLC DL Tapa Task initialization failed"); + return RFAILED; + } + + if(rlcUlInit(rlc_ul_stsk) != ROK) + { + printf("\nRLC UL Tapa Task initialization failed"); + return RFAILED; + } + return ROK; +} + +/******************************************************************* + * + * @brief Initializes the DU + * + * @details + * + * Function : duInit + * + * Functionality: + * - Calls commonInit + * - Registers DU Layers + * + * @params[in] void + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +S16 duInit() +{ + int ret = ROK; + if(commonInit() != ROK) + { + ret = RFAILED; + } + + return ret; +} + +/******************************************************************* + * + * @brief Entry point for the DU APP + * + * @details + * + * Function : main + * + * Functionality: + * - Read config params into duCfgParams + * - Initiate the init functions + * + * @params[in] void + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +S16 tst(void) +{ + + //Initialize TAPA layers + if(duInit() != ROK) + { + return RFAILED; + } + + //Read all the configs from du_utils.c into duCfgParams + duReadCfg(); + +#if 0 + //Establish SCTP connection + while(ret == -1) + { + printf("\nEstablishing SCTP link with CU... \n"); + //ret = establishSctp(); //To be implemeted in du_sctp.c + } +#endif + return ROK; +}/* end of main()*/ + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/5gnrpdcp/pj_ptsec.h b/src/du_app/du_mgr_main.h old mode 100755 new mode 100644 similarity index 78% rename from src/5gnrpdcp/pj_ptsec.h rename to src/du_app/du_mgr_main.h index bcfef9742..7661a51b7 --- a/src/5gnrpdcp/pj_ptsec.h +++ b/src/du_app/du_mgr_main.h @@ -16,28 +16,26 @@ ################################################################################ *******************************************************************************/ -/********************************************************************** - - Name: LTE PDCP PAL INTERFACE - - Type: C include file - - Desc: Defines required by LTE PDCP SPACC INTERFACE - - File: pj_ptsec.h - -**********************************************************************/ - -#ifndef __PJ_PTSEC_PAL_H__ -#define __PJ_PTSEC_PAL_H__ - - -#define PJ_QUE_CHECK_FOR_MS(_rxEnt,_ulCb,_gCb); - - - -#endif/* __pj_ptsec_pal.h_*/ -/********************************************************************30** +#ifndef __DU_MGR_MAIN_H__ +#define __DU_MGR_MAIN_H__ + +#include "du_mgr.h" + +/* Function declarations */ +S16 duReadCfg(); +void readCfg(); +void readClCfg(); +void fillSlotConfig(); +S16 duAppInit(SSTskId sysTskId); +S16 sctpInit(SSTskId sysTskId); +S16 rlcDlInit(SSTskId sysTskId); +S16 rlcUlInit(SSTskId sysTskId); +S16 commonInit(); +S16 duInit(); +S16 tst(void); + +#endif +/********************************************************************** End of file **********************************************************************/ diff --git a/src/du_app/du_sctp.c b/src/du_app/du_sctp.c new file mode 100644 index 000000000..9ba579151 --- /dev/null +++ b/src/du_app/du_sctp.c @@ -0,0 +1,622 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/* This file contains all SCTP related functionality */ + +#include +#include +#include +#include +#include +#include +#include + +#include "du_sctp.h" +#include "du_common.h" + +/* Global variable declaration */ +S8 sockFd; /* Socket file descriptor */ +U8 socket_type; /* Socket type */ +Bool nonblocking; /* Blocking/Non-blocking socket */ +Bool connUp; /* Is connection up */ +int assocId; /* Assoc Id of connected assoc */ + +sockaddr_storage_t local_addr; /* Local Address */ +sockaddr_storage_t remote_addr; /* Remote Address */ +U8 la_len; /* Local Address length */ +U8 ra_len; /* Remote Address length */ +F1SctpParams *sctpCfg; /* SCTP configurations at DU */ + +/************************************************************************** + * @brief Task Initiation callback function. + * + * @details + * + * Function : sctpActvInit + * + * Functionality: + * This function is supplied as one of parameters during SCTP's + * task registration. SSI will invoke this function once, after + * it creates and attaches this TAPA Task to a system task. + * + * @param[in] Ent entity, the entity ID of this task. + * @param[in] Inst inst, the instance ID of this task. + * @param[in] Region region, the region ID registered for memory + * usage of this task. + * @param[in] Reason reason. + * @return ROK - success + * RFAILED - failure + ***************************************************************************/ +S16 sctpActvInit(Ent entity, Inst inst, Region region, Reason reason) +{ + sockFd = 0; + connUp = FALSE; + assocId = 0; + nonblocking = FALSE; + sctpCfg = &(ducfgparam.sctpParams); + return ROK; + +} + +/************************************************************************** + * @brief Task Activation callback function. + * + * @details + * + * Function : sctpActvTsk + * + * Functionality: + * This function handles all SCTP messages received + * This API is registered with SSI during the + * Task Registration of DU APP. + * + * @param[in] Pst *pst, Post structure of the primitive. + * @param[in] Buffer *mBuf, Packed primitive parameters in the + * buffer. + * @return ROK - success + * RFAILED - failure + * + ***************************************************************************/ +S16 sctpActvTsk(Pst *pst, Buffer *mBuf) +{ + +//TODO: TBD + return ROK; +} + +/******************************************************************* + * + * @brief Converts internet address to sockaddr type + * + * @details + * + * Function : getSockAddr + * + * Functionality: + * Converts internet address to sockaddr type + * + * @params[in] + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ + +S16 getSockAddr(char *hostIp, U16 portNum, Bool ipv4Pres, Bool local) +{ + sockaddr_storage_t address; + struct hostent *host; + void *la_raw; + + /* Getting the transport address for local host name */ + if(ipv4Pres) + { + host = gethostbyname(hostIp); + if (host == NULL || host->h_length < 1) + { + printf("\nBad hostname: %s", hostIp); + RETVALUE(NULLP); + } + la_raw = &address.v4.sin_addr; + address.v4.sin_family = AF_INET; + address.v4.sin_port = htons(portNum); + } + else + { + host = gethostbyname2(hostIp, AF_INET6); + if (host == NULL || host->h_length < 1) + { + printf("\n Bad hostname: %s", hostIp); + RETVALUE(RFAILED); + } + la_raw = &address.v6.sin6_addr; + address.v6.sin6_family = AF_INET6; + address.v6.sin6_port = htons(portNum); + address.v6.sin6_scope_id = 0; + } + + memcpy((U8 *)la_raw, (U8 *)host->h_addr_list[0], host->h_length); + + if(local) + { + local_addr = address; + } + else + { + remote_addr = address; + } + + RETVALUE(ROK); +} /* End of getSockAddr() */ + +/******************************************************************* + * + * @brief Opens a non-blocking socket and binds to local address + * + * @details + * + * Function : openSctpEndp + * + * Functionality: + * Opens a non-blocking socket and binds to local address + * + * @params[in] + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +S16 openSctpEndp() +{ + sa_family_t la_family; + U8 error; + + + /* Getting the transport address for local host name */ + if(sctpCfg->duIpAddr.ipV4Pres) + { + if(getSockAddr(sctpCfg->duIpAddr.ipV4Addr, sctpCfg->duPort, TRUE, TRUE) != ROK ) + { + printf("\nUnable to get local address"); + RETVALUE(RFAILED); + } + la_family = AF_INET; + } + else + { + if(getSockAddr(sctpCfg->duIpAddr.ipV6Addr, sctpCfg->duPort, FALSE, TRUE) != ROK ) + { + printf("\nUnable to get local address"); + RETVALUE(RFAILED); + } + la_family = AF_INET6; + } + + socket_type = SOCK_STREAM; + + /* Creating new end point */ + sockFd = socket(la_family, socket_type, IPPROTO_SCTP); + if (sockFd < 0) + { + printf("\n Failed to create socket %s", strerror(errno)); + RETVALUE(RFAILED); + } + + /* Binding socket to local address and port */ + error = bind(sockFd, &local_addr.sa, la_len); + if(error != 0) + { + printf("\n Failed to bind to socket. Error [%s]", strerror(errno)); + RETVALUE(RFAILED); + } + + /* Setting socket as non-blocking*/ + error = fcntl(sockFd, F_SETFL, O_NONBLOCK); + if (error != 0) + { + printf("\n Failed to set socket as non blocking. Error [%s]", strerror(errno)); + RETVALUE(RFAILED); + } + else + { + nonblocking = TRUE; + } + + RETVALUE(ROK); + +} /* End of openSctpEndp() */ + +/******************************************************************* + * + * @brief Initiates connection with peer SCTP + * + * @details + * + * Function : sctpConnect + * + * Functionality: + * Establishes SCTP connection with peer. + * Here, DU-SCTP will initate connection towards CU-SCTP + * + * @params[in] + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +S16 sctpConnect() +{ + U8 error; + U8 ret; + + /* Getting the transport address for remote host name */ + if(sctpCfg->cuIpAddr.ipV4Pres) + { + ret = getSockAddr(sctpCfg->cuIpAddr.ipV4Addr, sctpCfg->cuPort, TRUE, FALSE); + } + else + { + ret = getSockAddr(sctpCfg->cuIpAddr.ipV6Addr, sctpCfg->cuPort, FALSE, FALSE); + } + if(ret != ROK) + { + printf("\nUnable to get remote address"); + RETVALUE(RFAILED); + } + + /* Initiating connection establishment with remote */ + if(!connUp) + { + error = sctp_connectx(sockFd, &remote_addr.sa, 1, &assocId); + if(error != 0) + { + printf("\nError connecting to peer. Error[%s]", strerror(errno)); + RETVALUE(RFAILED); + } + else + { + /* Mark SCTP connection UP */ + connUp = TRUE; + } + } + + RETVALUE(ROK); +}/* End of sctpConnect() */ + +/******************************************************************* + * + * @brief Handles an incoming message + * + * @details + * + * Function : sctpInmsgHdlr + * + * Functionality: + * Handles an incoming message + * + * @params[in] Socket file descriptor + * Incoming message header + * Message Length + * + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +S16 sctpInmsgHdlr(struct msghdr *msg, size_t msgLen) +{ + sctp_cmsg_data_t *data; + struct cmsghdr *cmsg; + union sctp_notification *sn; + Buffer *mBuf; + Pst *pst; + + for (cmsg = CMSG_FIRSTHDR(msg); cmsg != NULL; cmsg = CMSG_NXTHDR(msg, cmsg)) + { + data = (sctp_cmsg_data_t *)CMSG_DATA(cmsg); + } + + printf("\nReceived Message"); + + /* if incoming message is data */ + if (!(MSG_NOTIFICATION & msg->msg_flags)) + { + /* Extract message */ + U8 index = 0; + char *recvBuf; + char *temp = recvBuf; + U8 len = msgLen; + U8 temp_len; + U8 i; + + while( msgLen > 0) + { + temp = msg->msg_iov[index].iov_base; + temp_len = msg->msg_iov[index].iov_len; + + if(temp_len > msgLen) + { + temp[(temp_len = msgLen) - 1] = '\0'; + } + + if((msgLen -= temp_len) > 0) + { + index++; + } + for (i = 0; i < temp_len-1 ; ++i) + { + if (!isprint(temp[i])) + temp[i] = '.'; + } + printf("\nPrinting temp %s", temp); + temp = temp + temp_len; + index++; + } + recvBuf[len - 1] = '\0'; + printf("\n Message: %s temp %s", recvBuf, temp); + + /* Post received message to du_App */ + if(SGetMsg(0, 0, &mBuf) == ROK ) + { + if(SAddPstMsgMult((Data *)recvBuf, len, mBuf) == ROK) + { + pst->dstProcId; + pst->srcProcId; + pst->dstEnt = ENTDUAPP; + pst->dstInst = 0; + pst->srcEnt = ENTSCTP; + pst->srcInst = 0; + pst->prior; + pst->route; + pst->event = EVTSCTPUP; + pst->region = 0; + pst->pool = 0; + pst->selector = 0; + pst->intfVer; + + SPstTsk(pst, mBuf); + } + } + + + } + else /* If the incoming message is notification */ + { + /* Extract and perform necessary action + Change the connUp state accordingly */ + union sctp_notification *notify; + notify = (union sctp_notification *)msg->msg_iov->iov_base; + + if (SCTP_ASSOC_CHANGE != notify->sn_header.sn_type) + { + printf("\nReceived unexpected notification: %d", notify->sn_header.sn_type); + RETVALUE(RFAILED); + } + + switch(notify->sn_assoc_change.sac_state) + { + case SCTP_COMM_UP: + printf("Received SCTP_COMM_UP\n"); + break; + case SCTP_COMM_LOST: + printf("Received SCTP_COMM_LOST\n"); + break; + case SCTP_RESTART: + printf("Received SCTP_RESTART\n"); + break; + case SCTP_SHUTDOWN_COMP: + printf("Received SCTP_SHUTDOWN_COMP\n"); + break; + case SCTP_CANT_STR_ASSOC: + printf("Received SCTP_CANT_STR_ASSOC\n"); + break; + } + } + RETVALUE(ROK); +} + +/******************************************************************* + * + * @brief Receives message on the socket + * + * @details + * + * Function : sctpSockPoll + * + * Functionality: + * Receives message on the socket + * + * @params[in] + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +S16 sctpSockPoll() +{ + U8 error; + struct msghdr inmessage; + struct iovec iov; + char incmsg[CMSG_SPACE(sizeof(_sctp_cmsg_data_t))]; + sockaddr_storage_t msgname; + + /* Initialize inmessage with enough space for DATA... */ + memset(&inmessage, 0, sizeof(inmessage)); + if ((iov.iov_base = malloc(REALLY_BIG)) == NULL) + { + printf("\n malloc not enough memory!!!"); + close(sockFd); + connUp = FALSE; + RETVALUE(RFAILED); + } + iov.iov_len = REALLY_BIG; + inmessage.msg_iov = &iov; + inmessage.msg_iovlen = 1; + /* or a control message. */ + inmessage.msg_control = incmsg; + inmessage.msg_controllen = sizeof(incmsg); + inmessage.msg_name = &msgname; + inmessage.msg_namelen = sizeof(msgname); + + while (connUp) + { + error = recvmsg(sockFd, &inmessage, MSG_WAITALL); + if (error < 0) + { + if (nonblocking && (EAGAIN == errno)) + { + error = 0; + continue; + } + if (socket_type == SOCK_STREAM) + { + if (ENOTCONN != errno) + { + break; + } + printf("No association is present now!!\n"); + close(sockFd); + sockFd = 0; + connUp = FALSE; + } + break; + } + + sctpInmsgHdlr(&inmessage, error); + + inmessage.msg_control = incmsg; + inmessage.msg_controllen = sizeof(incmsg); + inmessage.msg_name = &msgname; + inmessage.msg_namelen = sizeof(msgname); + iov.iov_len = REALLY_BIG; + + }/* End of while(connUp) */ + + RETVALUE(ROK); +}/* End of sctpSockPoll() */ + +/******************************************************************* + * + * @brief Send message on SCTP socket + * + * @details + * + * Function : sctpOutMsgSend + * + * Functionality: + * Send message on SCTP socket + * + * @params[in] + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ +S16 sctpOutMsgSend(char *message, U8 msglen) +{ + struct msghdr outmsg; + struct iovec iov; + int error = 0; + + do{ + if(connUp && msglen != 0) + { + iov.iov_base = message; + iov.iov_len = msglen; + + outmsg.msg_iov = &iov; + outmsg.msg_iovlen = 1; + outmsg.msg_control = NULL; + outmsg.msg_controllen = 0; + outmsg.msg_name = &remote_addr; + outmsg.msg_namelen = ra_len; + outmsg.msg_flags = 0; + + error = sendmsg(sockFd, &outmsg, 0); + } + + if(error != msglen) + { + if(nonblocking && EAGAIN == errno) + { + continue; + } + else + { + printf("\n Error [%s] while sending message on SCTP assoc", strerror(errno)); + RETVALUE(RFAILED); + } + } + else + { + break; + } + }while(error != msglen); + + RETVALUE(ROK); + +} /* End of sctpOutMsgSend */ + +/******************************************************************* + * + * @brief SCTP Assoc establishment request from DU + * + * @details + * + * Function : sctpAssocReq + * + * Functionality: + * This function opens a socket at DU and + * intiates SCTP connection. + * + * @params[in] + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ + +void sctpAssocReq() +{ + /* Open SCTP socket and bind to local address */ + if(openSctpEndp() != ROK) + { + printf("\nFailed while opening SCTP endpoint"); + if(sockFd > 0 ) + { + close(sockFd); + sockFd = 0; + } + /* TODO : Send Assoc establishment failure to du_app if needed*/ + } + else if(sctpConnect() != ROK) /* send connection request */ + { + printf("\nFailed while connecting to peer"); + close(sockFd); + sockFd = 0; + assocId = 0; + nonblocking = FALSE; + /* TODO : Send Assoc establishment failure to du_app */ + } + else + { + /* Send AssocCfm to du_app */ + if(sctpSockPoll() != ROK) + { + printf("\nFailed while polling"); + /* Send failure to du_app */ + } + } +} /* End of sctpAssocReq */ + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/du_app/du_sctp.h b/src/du_app/du_sctp.h new file mode 100644 index 000000000..efdffc36b --- /dev/null +++ b/src/du_app/du_sctp.h @@ -0,0 +1,55 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/* This file contains all SCTP related functionality */ + +#ifndef __DU_SCTP_H__ +#define __DU_SCTP_H__ + +#include +#include +#include "du_mgr.h" + +S16 sctpActvInit(Ent entity, Inst inst, Region region, Reason reason); +S16 sctpActvTsk(Pst *pst, Buffer *mBuf); + +#define REALLY_BIG 65536 + +/* Convenience structure to determine space needed for cmsg. */ +typedef union +{ + struct sctp_initmsg init; + struct sctp_sndrcvinfo sndrcvinfo; +}_sctp_cmsg_data_t; + +#define CMSG_SPACE_INITMSG (CMSG_SPACE(sizeof(struct sctp_initmsg))) +#define CMSG_SPACE_SNDRCV (CMSG_SPACE(sizeof(struct sctp_sndrcvinfo))) + +typedef union +{ + struct sockaddr_storage ss; + struct sockaddr_in v4; + struct sockaddr_in6 v6; + struct sockaddr sa; +} sockaddr_storage_t; + +#endif + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/du_app/du_utils.c b/src/du_app/du_utils.c new file mode 100644 index 000000000..da5a29b02 --- /dev/null +++ b/src/du_app/du_utils.c @@ -0,0 +1,442 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/* This file contains all utility functions */ +#if 0 +#include +#include +#include +#include +#include +#endif +#include "du_mgr.h" + +#define DU_INST 0 +#define DU_ID 1 +#define DU_IP_V4_ADDR "168.168.31.12" +#define CU_IP_V4_ADDR "168.168.31.57" +#define DU_IP_V6_ADDR "0000:0000:0000:0000:0000:0000:0000:0001" +#define DU_PORT 38472 +#define CU_PORT 38472 +#define NR_PCI 1 +#define NR_CELL_ID 1 +#define DU_NAME "Oran_OAM_DU" +#define CELL_DIR UL_DL +#define CELL_TYPE SMALL +#define DUPLEX_MODE DUP_MODE_TDD +#define DU_TAC 1 +#define PLMN_MCC0 3 +#define PLMN_MCC1 1 +#define PLMN_MCC2 1 +#define PLMN_MNC0 4 +#define PLMN_MNC1 8 +#define PLMN_MNC2 0 +#define NR_ARFCN 2079427 +#define SUL_ARFCN 100 +#define NR_FREQ_BAND 257 +#define SUL_BAND 2 +#define TIME_CFG 10 +#define NR_RANAC 150 +#define CARRIER_IDX 1 +#define NUM_TX_ANT 2 +#define NUM_RX_ANT 2 +#define FREQ_SHIFT_7P5KHZ FALSE +#define SSB_PBCH_PWR 0 +#define BCH_PAYLOAD MAC_GEN_FULL_PBCH_PAYLD +#define SUBCARRIER_SPACING 3 +#define PRB_OFFSET 0 +#define BETA_PSS BETA_PSS_0DB +#define SSB_PERIODICITTY SSB_PRDCTY_MS_20 +#define SSB_SUBCARRIER_OFFSET 0 +#define SSB_MULT_CARRIER_BAND FALSE +#define MULT_CELL_CARRIER FALSE + +#define PRACH_SEQ_LEN SHORT_SEQUENCE +#define PRACH_SUBCARRIER_SPACING 3 +#define PRACH_RESTRICTED_SET_CFG UNRESTRICTED +#define NUM_PRACH_FDM 1 +#define ROOT_SEQ_IDX 0 +#define NUM_ROOT_SEQ 1 +#define ZERO_CORRELATION_ZONE_CFG 2 +#define NUM_UNUSED_ROOT_SEQ 1 +#define UNUSED_ROOT_SEQ 1 +#define SSB_PER_RACH 3 +#define PRACH_MULT_CARRIER_BAND FALSE +#define TDD_PERIODICITY TX_PRDCTY_MS_2P5 +#define RSS_MEASUREMENT_UNIT DONT_REPORT_RSSI + +extern DuCfgParams ducfgparam; + + +/* Filling Slot configuration as : + * Slot Sym 0 Sym 1 Sym 2 Sym 3 Sym 4 Sym 5 Sym 6 Sym 7 Sym 8 Sym 9 Sym10 Sym11 Sym12 Sym13 + * 0 DL DL DL DL DL DL DL DL DL DL DL DL DL DL + * 1 DL DL DL DL DL DL DL DL DL DL DL DL DL DL + * 2 DL DL DL DL DL DL DL DL DL DL DL DL DL DL + * 3 DL DL DL DL DL DL DL DL DL DL GD GD GD UL + * 4 UL UL UL UL UL UL UL UL UL UL UL UL UL UL +*/ + +/******************************************************************* + * + * @brief Fills the Slot configuration + * + * @details + * + * Function : fillSlotConfig + * + * Functionality:Fill the Slot configuration values + * + * @params[in] void + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ + + +void fillSlotConfig() +{ + U8 slot; + U8 symbol; + + for(slot = 0; slot <= 3; slot++) + { + for(symbol = 0; symbol < MAX_SYMB_PER_SLOT; symbol++) + ducfgparam.clCellCfg.tddCfg.slotCfg[slot][symbol] = DL_SLOT; + } + + ducfgparam.clCellCfg.tddCfg.slotCfg[3][10] = GUARD_SLOT; + ducfgparam.clCellCfg.tddCfg.slotCfg[3][11] = GUARD_SLOT; + ducfgparam.clCellCfg.tddCfg.slotCfg[3][12] = GUARD_SLOT; + ducfgparam.clCellCfg.tddCfg.slotCfg[3][13] = UL_SLOT; + + for(symbol = 0; symbol < MAX_SYMB_PER_SLOT; symbol++) + ducfgparam.clCellCfg.tddCfg.slotCfg[4][symbol] = UL_SLOT; + +} + +/******************************************************************* + * + * @brief Reads the CL Configuration. + * + * @details + * + * Function : readClCfg + * + * Functionality: + * - Fills up the cell configuration for CL. + * - Calls fillSlotConfig() + * + * @params[in] void + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ + + +/* This function is used to fill up the cell configuration for CL */ +void readClCfg() +{ + ducfgparam.clCellCfg.carrierId = CARRIER_IDX; + + /* Cell configuration */ + ducfgparam.clCellCfg.cellId = NR_CELL_ID; + ducfgparam.clCellCfg.phyCellId = NR_PCI; + ducfgparam.clCellCfg.dupType = DUPLEX_MODE; + + /* DL carrier configuration */ + ducfgparam.clCellCfg.dlCarrCfg.pres = TRUE; + ducfgparam.clCellCfg.dlCarrCfg.bw = SUL_ARFCN; + ducfgparam.clCellCfg.dlCarrCfg.freq = NR_ARFCN; + ducfgparam.clCellCfg.dlCarrCfg.k0[0] = 1; + ducfgparam.clCellCfg.dlCarrCfg.k0[1] = 1; + ducfgparam.clCellCfg.dlCarrCfg.k0[2] = 1; + ducfgparam.clCellCfg.dlCarrCfg.k0[3] = 1; + ducfgparam.clCellCfg.dlCarrCfg.k0[4] = 1; + ducfgparam.clCellCfg.dlCarrCfg.gridSize[0] = 1; + ducfgparam.clCellCfg.dlCarrCfg.gridSize[1] = 1; + ducfgparam.clCellCfg.dlCarrCfg.gridSize[2] = 1; + ducfgparam.clCellCfg.dlCarrCfg.gridSize[3] = 1; + ducfgparam.clCellCfg.dlCarrCfg.gridSize[4] = 1; + ducfgparam.clCellCfg.dlCarrCfg.numAnt = NUM_TX_ANT; + + /* UL Carrier configuration */ + ducfgparam.clCellCfg.ulCarrCfg.pres = TRUE; + ducfgparam.clCellCfg.ulCarrCfg.bw = SUL_ARFCN; + ducfgparam.clCellCfg.ulCarrCfg.freq = NR_ARFCN; + ducfgparam.clCellCfg.ulCarrCfg.k0[0] = 1; + ducfgparam.clCellCfg.ulCarrCfg.k0[1] = 1; + ducfgparam.clCellCfg.ulCarrCfg.k0[2] = 1; + ducfgparam.clCellCfg.ulCarrCfg.k0[3] = 1; + ducfgparam.clCellCfg.ulCarrCfg.k0[4] = 1; + ducfgparam.clCellCfg.ulCarrCfg.gridSize[0] = 1; + ducfgparam.clCellCfg.ulCarrCfg.gridSize[1] = 1; + ducfgparam.clCellCfg.ulCarrCfg.gridSize[2] = 1; + ducfgparam.clCellCfg.ulCarrCfg.gridSize[3] = 1; + ducfgparam.clCellCfg.ulCarrCfg.gridSize[4] = 1; + ducfgparam.clCellCfg.ulCarrCfg.numAnt = NUM_RX_ANT; + + ducfgparam.clCellCfg.freqShft = FREQ_SHIFT_7P5KHZ; + + /* SSB configuration */ + ducfgparam.clCellCfg.ssbCfg.ssbPbchPwr = SSB_PBCH_PWR; + ducfgparam.clCellCfg.ssbCfg.bchPayload = BCH_PAYLOAD; + ducfgparam.clCellCfg.ssbCfg.scsCmn = SUBCARRIER_SPACING; + ducfgparam.clCellCfg.ssbCfg.ssbPrbOffset = PRB_OFFSET; + ducfgparam.clCellCfg.ssbCfg.betaPss = BETA_PSS; + ducfgparam.clCellCfg.ssbCfg.ssbPeriod = SSB_PERIODICITTY; + ducfgparam.clCellCfg.ssbCfg.ssbSubcOffset = SSB_SUBCARRIER_OFFSET; + ducfgparam.clCellCfg.ssbCfg.mibPdu = 104; + ducfgparam.clCellCfg.ssbCfg.nSSBMask[0] = 2162721; + ducfgparam.clCellCfg.ssbCfg.nSSBMask[1] = 0; + ducfgparam.clCellCfg.ssbCfg.multCarrBand = SSB_MULT_CARRIER_BAND; + ducfgparam.clCellCfg.ssbCfg.multCellCarr = MULT_CELL_CARRIER; + + /* PRACH configuration */ + ducfgparam.clCellCfg.prachCfg.pres = TRUE; + ducfgparam.clCellCfg.prachCfg.prachSeqLen = PRACH_SEQ_LEN; + ducfgparam.clCellCfg.prachCfg.prachSubcSpacing = PRACH_SUBCARRIER_SPACING; + ducfgparam.clCellCfg.prachCfg.prachRstSetCfg = PRACH_RESTRICTED_SET_CFG; + ducfgparam.clCellCfg.prachCfg.prachFdm = NUM_PRACH_FDM; + ducfgparam.clCellCfg.prachCfg.fdm[0].rootSeqIdx = ROOT_SEQ_IDX; + ducfgparam.clCellCfg.prachCfg.fdm[0].numRootSeq = NUM_ROOT_SEQ; + ducfgparam.clCellCfg.prachCfg.fdm[0].k1 = 1; + ducfgparam.clCellCfg.prachCfg.fdm[0].zeroCorrZoneCfg = ZERO_CORRELATION_ZONE_CFG; + ducfgparam.clCellCfg.prachCfg.fdm[0].numUnusedRootSeq = NUM_UNUSED_ROOT_SEQ; + *(ducfgparam.clCellCfg.prachCfg.fdm[0].unsuedRootSeq) = UNUSED_ROOT_SEQ; + ducfgparam.clCellCfg.prachCfg.ssbPerRach = SSB_PER_RACH; + ducfgparam.clCellCfg.prachCfg.prachMultCarrBand = PRACH_MULT_CARRIER_BAND; + + /* TDD configuration */ + ducfgparam.clCellCfg.tddCfg.pres = TRUE; + ducfgparam.clCellCfg.tddCfg.tddPeriod = TDD_PERIODICITY; + + fillSlotConfig(); + + /* RSSI Measurement configuration */ + ducfgparam.clCellCfg.rssiUnit = RSS_MEASUREMENT_UNIT; + + /* This should be calculated based on + (number of mandatory parameters) + (number of otional parameters being filled) */ + ducfgparam.clCellCfg.numTlv = 39; + +} +/******************************************************************* + * + * @brief Configures the DU Parameters + * + * @details + * + * Function : readCfg + * + * Functionality: + * - Initializes the DuCfg members. + * - Calls readClCfg() + * + * @params[in] system task ID + * @return ROK - success + * RFAILED - failure + * + * ****************************************************************/ + +void readCfg() +{ + U8 i,j,k; + + /* F1 DU IP Address and Port*/ + ducfgparam.sctpParams.duIpAddr.ipV4Pres = TRUE; + strcpy(ducfgparam.sctpParams.duIpAddr.ipV4Addr, (char*)DU_IP_V4_ADDR); + ducfgparam.sctpParams.duIpAddr.ipV6Pres = FALSE; + strcpy(ducfgparam.sctpParams.duIpAddr.ipV6Addr, (char*)DU_IP_V6_ADDR); + ducfgparam.sctpParams.duPort = DU_PORT; + + /* F1 CU IP Address and Port*/ + ducfgparam.sctpParams.cuIpAddr.ipV4Pres = TRUE; + strcpy(ducfgparam.sctpParams.cuIpAddr.ipV4Addr, (char*)CU_IP_V4_ADDR); + ducfgparam.sctpParams.cuIpAddr.ipV6Pres = FALSE; + strcpy(ducfgparam.sctpParams.cuIpAddr.ipV6Addr, DU_IP_V6_ADDR); + ducfgparam.sctpParams.cuPort = CU_PORT; + + /* DU Info */ + ducfgparam.duId = DU_ID; + strcpy(ducfgparam.duName,DU_NAME); + + for(i=0;i +#include +#include +#include +#include +#include +#include +#include +#include +#include + /* mt003.301: included sys/time.h + * for both solaris and linux + * */ +#include + /* mt008.21: addition */ +#include + + + +/* header include files (.h) */ + + +#include "gen.h" /* general layer */ +#include "ssi.h" /* system services */ + +#include "cm5.h" /* common timers */ + +#include "mt_ss.h" /* MTSS specific */ +#include "mt_err.h" /* MTSS error defines */ + +#include "ss_queue.h" /* queues */ +#include "ss_task.h" /* tasking */ +#include "ss_msg.h" /* messaging */ +#include "ss_mem.h" /* memory management interface */ +#include "ss_gen.h" /* general */ +/* mt003.301 Additions - Task deregistration */ +#include "ss_err.h" /* error */ +#include "cm_mem.h" /* common memory manager */ +#include "cm_lte.h" /* common lte param */ +/* mt001.301 : Additions */ +#ifdef SS_THREAD_PROFILE +#include "ss_err.h" +#endif +#ifdef SS_LOCKLESS_MEMORY +#include "cm_llist.h" +#include "cm_hash.h" +#endif + +/* multi-core support enhancement */ +/*mt013.301 :Added SS_AFFINITY_SUPPORT */ +#if defined(SS_MULTICORE_SUPPORT) ||defined(SS_AFFINITY_SUPPORT) +#ifdef SS_LINUX +#include +#include +#else +#ifdef SUNOS +#include +#include +#include +#endif /* SUNOS */ +#endif /* SS_LINUX */ +#endif /* SS_MULTICORE_SUPPORT || SS_AFFINITY_SUPPORT */ +/* mt001.301 : Additions */ +#ifdef SS_WATCHDOG +#include +#include +#include +#include +#endif /* SS_WATCHDOG */ + +/* header/extern include files (.x) */ + +#include "gen.x" /* general layer */ +#include "ssi.x" /* system services */ + +#include "cm5.x" /* common timers */ + +#include "mt_ss.x" /* MTSS specific */ +#ifdef SS_LOCKLESS_MEMORY +#include "mt_ss_wl.x" /* MTSS specific */ +#endif /* SS_LOCKLESS_MEMORY */ + +#include "ss_queue.x" /* queues */ +#include "ss_task.x" /* tasking */ +#include "ss_timer.x" /* timers */ +#include "ss_strm.x" /* STREAMS */ +#include "ss_msg.x" /* messaging */ +#include "ss_mem.x" /* memory management interface */ +#include "ss_drvr.x" /* driver tasks */ +#include "ss_gen.x" /* general */ +#ifdef SS_LOCKLESS_MEMORY +#include "cm_llist.x" +#include "cm_hash.x" +#include "cm_mem_wl.x" /* common memory manager */ +#else +#include "cm_mem.x" /* common memory manager */ +#endif /* SS_LOCKLESS_MEMORY */ +#include "cm_lte.x" /* common memory manager */ +/* mt001.301 : Additions */ +#ifdef SS_LOGGER_SUPPORT +#include "cm_lib.x" +#endif /* SS_LOGGER_SUPPORT */ + +/*mt005.301: Cavium Changes */ +#ifdef SS_SEUM_CAVIUM +/* cvmx includes files */ +#include "cvmx-config.h" +#include "cvmx.h" +#include "cvmx-pow.h" +#include "cvmx-tim.h" +#include "cvmx-fpa.h" +#include "cvmx-helper-fpa.h" +#include "cvmx-malloc.h" +#endif /* SS_SEUM_CAVIUM */ + +#ifdef L2_L3_SPLIT +#include "mt_plat_t33.h" +#include "mt_plat_t33.x" +#include "sys/syscall.h" +#endif + +#ifdef RGL_SPECIFIC_CHANGES +#include +#include +#endif + +#if defined(SPLIT_RLC_DL_TASK) && defined(RLC_MAC_STA_RSP_RBUF) +EXTERN S16 rgBatchProc (Void); +#endif +#ifdef RLC_MAC_DAT_REQ_RBUF +EXTERN S16 rgDlDatReqBatchProc ARGS(( + Void)); +#endif +#if defined(SPLIT_RLC_DL_TASK) && defined(RLC_MAC_STA_RSP_RBUF) +EXTERN S16 rgBatchProc ARGS(( + Void)); +#endif + +#ifdef TENB_T2K3K_SPECIFIC_CHANGES +/* general purpose debug zone */ +char my_buffer2[4096 * 4] = { 0 }; +char my_buffer[4096] = { 0 }; +int my_buffer_idx = 0; + + + +#define sigsegv_print(x, ...) my_buffer_idx += sprintf(&my_buffer[my_buffer_idx], x "\n", ##__VA_ARGS__) + +struct sigcontext my_uc_mcontext = { 0 }; + + +#include +#include +#include +#include + + +#define SIGSEGV_STACK_GENERIC +#define REGFORMAT "%x\n" + +#ifdef XEON_SPECIFIC_CHANGES +Void cmPrcTmr ARGS((CmTqCp* tqCp, CmTqType* tq, PFV func)); +#endif + +void dump_external(void); + +#ifdef ANSI +PRIVATE Void mtDelSigals +( +Void +) +#else +PRIVATE Void mtDelSignals() +#endif +{ + struct sigaction sa; + + memset(&sa, 0, sizeof(struct sigaction)); + sigemptyset(&sa.sa_mask); + sa.sa_handler = SIG_DFL; + sigaction(SIGSEGV, &sa, NULL); + + memset(&sa, 0, sizeof(struct sigaction)); + sigemptyset(&sa.sa_mask); + sa.sa_handler = SIG_DFL; + sigaction(SIGILL, &sa, NULL); + + RETVOID; +} +static void signal_segv(int signum, siginfo_t * info, void *ptr) +{ + static const char *si_codes[3] = { "", "SEGV_MAPERR", "SEGV_ACCERR" }; + int sz; + int i; + ucontext_t *ucontext = (ucontext_t *) ptr; +#ifdef XEON_SPECIFIC_CHANGES +#else + int *p32 = (int *) 0x2fff0000; +#endif + void *buffer[100]; + char **strings; + + printf("segv ooops @ %p\n", info->si_addr); + my_buffer2[0] = 1; + + printf("Segmentation Fault!\n"); + printf("info.si_signo = %d\n", signum); + printf("info.si_errno = %d\n", info->si_errno); + printf("info.si_code = %d (%s)\n", info->si_code, si_codes[info->si_code]); + printf("info.si_addr = %p\n", info->si_addr); + + memcpy(&my_uc_mcontext, &ucontext->uc_mcontext, sizeof(struct sigcontext)); + + i = 0; +#ifndef RGL_SPECIFIC_CHANGES + printf("reg[%02d] = 0x" REGFORMAT, i++, (unsigned int)ucontext->uc_mcontext.arm_r0); + printf("reg[%02d] = 0x" REGFORMAT, i++, (unsigned int)ucontext->uc_mcontext.arm_r1); + printf("reg[%02d] = 0x" REGFORMAT, i++, (unsigned int)ucontext->uc_mcontext.arm_r2); + printf("reg[%02d] = 0x" REGFORMAT, i++, (unsigned int)ucontext->uc_mcontext.arm_r3); + printf("reg[%02d] = 0x" REGFORMAT, i++, (unsigned int)ucontext->uc_mcontext.arm_r4); + printf("reg[%02d] = 0x" REGFORMAT, i++, (unsigned int)ucontext->uc_mcontext.arm_r5); + printf("reg[%02d] = 0x" REGFORMAT, i++, (unsigned int)ucontext->uc_mcontext.arm_r6); + printf("reg[%02d] = 0x" REGFORMAT, i++, (unsigned int)ucontext->uc_mcontext.arm_r7); + printf("reg[%02d] = 0x" REGFORMAT, i++, (unsigned int)ucontext->uc_mcontext.arm_r8); + printf("reg[%02d] = 0x" REGFORMAT, i++, (unsigned int)ucontext->uc_mcontext.arm_r9); + printf("reg[%02d] = 0x" REGFORMAT, i++, (unsigned int)ucontext->uc_mcontext.arm_r10); + printf("reg[%02d] = 0x" REGFORMAT, i++, (unsigned int)ucontext->uc_mcontext.arm_fp); + printf("reg[%02d] = 0x" REGFORMAT, i++, (unsigned int)ucontext->uc_mcontext.arm_ip); + printf("reg[sp] = 0x" REGFORMAT, (unsigned int)ucontext->uc_mcontext.arm_sp); + printf("reg[lr] = 0x" REGFORMAT, (unsigned int)ucontext->uc_mcontext.arm_lr); + printf("reg[pc] = 0x" REGFORMAT, (unsigned int)ucontext->uc_mcontext.arm_pc); + printf("reg[cpsr] = 0x" REGFORMAT, (unsigned int)ucontext->uc_mcontext.arm_cpsr); +#endif + + printf("Stack trace (non-dedicated):\n"); + + sz = backtrace(buffer, 50); + strings = backtrace_symbols(buffer, sz); + for (i = 0; i < sz; ++i) + printf("%s\n", strings[i]); + + printf("End of stack trace."); + +#ifdef XEON_SPECIFIC_CHANGES +#else + p32[0] = 1; +#endif + + /* Lets first print our debug information */ + printf("Before dumping our Debug info\n"); + mtStopHndlr(); + printf("After dumping our Debug info\n"); + + /* Disable the signal and make the enodeb to dump. This will make + * eNB to generate the core with dumping the ccpu log + */ + { + char *abc = NULL; + mtDelSigals(); + *abc = 100; + } + /* End printing debug information */ + exit(1); + /*while (1);*/ +} +#endif +/*** TBD: IMPORTANT *** + *** The following definition is temporary. This must be removed + *** when all products have been updated with latest ssi.h file OR + *** all ssi.h files have been updated to contain this definitions + ***/ +/* New error class for FTHA added */ +#ifndef ERRCLS_FTHA +#define ERRCLS_FTHA 0x8 +#endif /* ERRCLS_FTHA */ + +typedef struct _SPThreadCreateArg +{ + void *argument; /* argument that is to be passed to the actual pthread */ + void *(*start_routine) (void *); /* function from which pthread starts */ +}SPThreadCreateArg; + +PUBLIC void *pthreadCreateHdlr(void* arg); + +#ifdef SS_LOCKLESS_MEMORY +PUBLIC Buffer *mtTskBuffer1; +PUBLIC Buffer *mtTskBuffer2; + +EXTERN pthread_t tmpRegTidMap[20]; +EXTERN U8 stopBtInfo; +EXTERN S16 SGlobMemInfoShow(void); +#endif /* SS_LOCKLESS_MEMORY */ + +#ifdef L2_L3_SPLIT +EXTERN APP_CONTEXT AppContext; +EXTERN S32 clusterMode; +#endif + +#ifdef TENB_T2K3K_SPECIFIC_CHANGES +EXTERN unsigned int tlPost(void *handle); +#endif + +/* forward references */ +/* mt003.301 Modifications - Moved to ss_gen.x */ +#ifdef TENB_T2K3K_SPECIFIC_CHANGES +PUBLIC Void *mtTskHdlrT2kL2 ARGS((Void*)); +PUBLIC void mtSigSegvHndlr ARGS((void)); +PUBLIC void mtSigUsr2Hndlr ARGS((void)); +#endif + +PRIVATE S16 ssdSetPthreadAttr ARGS ((S32 tskPrior, pthread_attr_t *attr)); +PRIVATE Void *mtTskHdlr ARGS((void *)); +PRIVATE S16 mtTskHdlMsg ARGS((SsSTskEntry *sTsk)); + +PRIVATE Void *mtTmrHdlr ARGS((void *)); +PRIVATE Void mtTimeout ARGS((PTR tCb, S16 evnt)); + +/*mt010.301 Fix for core when run with -o option and when killed with SIGINT*/ +PRIVATE Void mtIntSigHndlr ARGS((int)); +PRIVATE Void mtExitClnup ARGS((void)); + +#ifdef CONAVL +PRIVATE Void *mtConHdlr ARGS((void *)); +#endif + +#ifndef L2_L3_SPLIT +#ifdef SS_DRVR_SUPPORT +PRIVATE Void *mtIsTskHdlr ARGS((void *)); +#endif +#endif + +/* mt020.201 - Addition for no command line available */ +#ifndef NOCMDLINE +PRIVATE Void mtGetOpts ARGS((void)); +/* mt003.301 Additions - File Based task registration made + * common for both MULTICORE and NON-MULTICORE + */ +PRIVATE Bool fileBasedMemCfg = FALSE; +#endif + +/* mt033.201 - addition of local function to print the statistics such as +* (size vs. numAttempts) and (allocations vs. deallocations) +*/ +#ifdef SSI_DEBUG_LEVEL1 +PRIVATE S16 SPrintRegMemStats ARGS((Region region)); +#endif /* SSI_DEBUG_LEVEL1 */ + +#ifdef SS_MULTICORE_SUPPORT +PRIVATE SsSTskEntry* ssdAddTmrSTsk(Void); +PRIVATE SsSTskEntry* ssdReAddTmrSTsk ARGS((U8 idx)); +#ifndef SS_LOCKLESS_MEMORY +#ifndef RGL_SPECIFIC_CHANGES +PRIVATE S16 ssdInitMemInfo ARGS((void)); +#endif +#endif +#endif + +/* mt005.301: Cavium changes */ +#ifdef SS_SEUM_CAVIUM +PRIVATE Void *workRcvTsk ARGS((void *)); +#endif /* SS_SEUM_CAVIUM */ + +#ifdef SS_THR_REG_MAP +PUBLIC S32 ssCheckAndAddMemoryRegionMap ARGS((pthread_t threadId, + Region region)); +PUBLIC S32 ssCheckAndDelMemoryRegionMap ARGS((pthread_t threadId)); +#endif /* SS_THR_REG_MAP */ + +/* type declarations */ + +#ifdef SS_DRVR_SUPPORT +typedef struct mtIsFlag +{ + U16 id; + U8 action; + +} MtIsFlag; +#endif + + + +/* public variable declarations */ + +PUBLIC Cntr cfgNumRegs = SS_MAX_REGS; +/* Set memory configuration as false. + * Set to true if memory configuration through file is successfull. + */ +PUBLIC Bool memConfigured = FALSE; +/* mt022.201 - Modification for shared memory relay region and memcal tool */ +PUBLIC SsRegCfg cfgRegInfo[SS_MAX_REGS] = +{ + { + SS_DFLT_REGION, SS_MAX_POOLS_PER_REG - 1, + { + { SS_POOL_DYNAMIC, MT_POOL_0_DSIZE }, + { SS_POOL_DYNAMIC, MT_POOL_1_DSIZE }, + { SS_POOL_DYNAMIC, MT_POOL_2_DSIZE }, + { SS_POOL_DYNAMIC, MT_POOL_3_DSIZE }, + { SS_POOL_STATIC, 0 } + } + } +#ifdef INTEL_WLS + , + { + SS_DFLT_REGION + 1, SS_MAX_POOLS_PER_REG - 1, + { + { SS_POOL_DYNAMIC, MT_POOL_0_DSIZE }, + { SS_POOL_DYNAMIC, MT_POOL_1_DSIZE }, + { SS_POOL_DYNAMIC, MT_POOL_2_DSIZE }, + { SS_POOL_DYNAMIC, MT_POOL_3_DSIZE }, + { SS_POOL_STATIC, 0 } + } + } +#endif /* INTEL_WLS */ + +#ifdef SS_LOCKLESS_MEMORY + , + { + SS_DFLT_REGION + 1, SS_MAX_POOLS_PER_REG - 1, + { + { SS_POOL_DYNAMIC, MT_POOL_0_DSIZE }, + { SS_POOL_DYNAMIC, MT_POOL_1_DSIZE }, + { SS_POOL_DYNAMIC, MT_POOL_2_DSIZE }, + { SS_POOL_DYNAMIC, MT_POOL_3_DSIZE }, + { SS_POOL_STATIC, 0 } + } + }, + { + SS_DFLT_REGION + 2, SS_MAX_POOLS_PER_REG - 1, + { + { SS_POOL_DYNAMIC, MT_POOL_0_DSIZE }, + { SS_POOL_DYNAMIC, MT_POOL_1_DSIZE }, + { SS_POOL_DYNAMIC, MT_POOL_2_DSIZE }, + { SS_POOL_DYNAMIC, MT_POOL_3_DSIZE }, + { SS_POOL_STATIC, 0 } + } + }, + { + SS_DFLT_REGION + 3, SS_MAX_POOLS_PER_REG - 1, + { + { SS_POOL_DYNAMIC, MT_POOL_0_DSIZE }, + { SS_POOL_DYNAMIC, MT_POOL_1_DSIZE }, + { SS_POOL_DYNAMIC, MT_POOL_2_DSIZE }, + { SS_POOL_DYNAMIC, MT_POOL_3_DSIZE }, + { SS_POOL_STATIC, 0 } + } + } +#endif /* SS_LOCKLESS_MEMORY */ +}; +/* mt003.301 Modifications - File Based task registration made + * common for both MULTICORE and NON-MULTICORE + */ + +#ifdef SS_LOCKLESS_MEMORY +PUBLIC MtDynMemCfg mtDynMemoCfg = +{ + SS_MAX_REGS, /* number of regions */ + { + { + SS_DFLT_REGION, /* region id */ + MT_MAX_BKTS, /* number of buckets */ + { + /* block size, no. of blocks, Upper threshold, lower threshold */ + {SS_BLK_RELEASE_THRESHOLD, SS_BLK_ACQUIRE_THRESHOLD}, + {SS_BLK_RELEASE_THRESHOLD, SS_BLK_ACQUIRE_THRESHOLD}, + {SS_BLK_RELEASE_THRESHOLD, SS_BLK_ACQUIRE_THRESHOLD}, + {SS_BLK_RELEASE_THRESHOLD, SS_BLK_ACQUIRE_THRESHOLD} + } + }, + { + SS_DFLT_REGION + 1, /* region id */ + MT_MAX_BKTS, /* number of buckets */ + { + /* block size, no. of blocks, Upper threshold, lower threshold */ + {SS_BLK_RELEASE_THRESHOLD, SS_BLK_ACQUIRE_THRESHOLD}, + {SS_BLK_RELEASE_THRESHOLD, SS_BLK_ACQUIRE_THRESHOLD}, + {SS_BLK_RELEASE_THRESHOLD, SS_BLK_ACQUIRE_THRESHOLD}, + {SS_BLK_RELEASE_THRESHOLD, SS_BLK_ACQUIRE_THRESHOLD} + } + }, + { + SS_DFLT_REGION + 2, /* region id */ + MT_MAX_BKTS, /* number of buckets */ + { + /* block size, no. of blocks, Upper threshold, lower threshold */ + {SS_BLK_RELEASE_THRESHOLD, SS_BLK_ACQUIRE_THRESHOLD}, + {SS_BLK_RELEASE_THRESHOLD, SS_BLK_ACQUIRE_THRESHOLD}, + {SS_BLK_RELEASE_THRESHOLD, SS_BLK_ACQUIRE_THRESHOLD}, + {SS_BLK_RELEASE_THRESHOLD, SS_BLK_ACQUIRE_THRESHOLD} + } + }, + { + SS_DFLT_REGION + 3, /* region id */ + MT_MAX_BKTS, /* number of buckets */ + { + /* block size, no. of blocks, Upper threshold, lower threshold */ + {SS_BLK_RELEASE_THRESHOLD, SS_BLK_ACQUIRE_THRESHOLD}, + {SS_BLK_RELEASE_THRESHOLD, SS_BLK_ACQUIRE_THRESHOLD}, + {SS_BLK_RELEASE_THRESHOLD, SS_BLK_ACQUIRE_THRESHOLD}, + {SS_BLK_RELEASE_THRESHOLD, SS_BLK_ACQUIRE_THRESHOLD} + } + } +#if ((defined (SPLIT_RLC_DL_TASK)) && (!defined (L2_L3_SPLIT))) + , + { + SS_DFLT_REGION + 4, /* region id */ + MT_MAX_BKTS, /* number of buckets */ + { + /* block size, no. of blocks, Upper threshold, lower threshold */ + {SS_BLK_RELEASE_THRESHOLD, SS_BLK_ACQUIRE_THRESHOLD}, + {SS_BLK_RELEASE_THRESHOLD, SS_BLK_ACQUIRE_THRESHOLD}, + {SS_BLK_RELEASE_THRESHOLD, SS_BLK_ACQUIRE_THRESHOLD}, + {SS_BLK_RELEASE_THRESHOLD, SS_BLK_ACQUIRE_THRESHOLD} + } + } +#endif + } + +}; + +PUBLIC MtGlobMemCfg mtGlobMemoCfg = +{ + MT_MAX_BKTS, /* number of buckets */ + { +#if 1 + /* block size, no. of blocks, Upper threshold, lower threshold */ + {MT_BKT_0_DSIZE, (MT_BKT_0_NUMBLKS + MT_BKT_0_NUMBLKS), SS_DFLT_MEM_BLK_SET_SIZE}, + {MT_BKT_1_DSIZE, MT_BKT_1_NUMBLKS, SS_DFLT_MEM_BLK_SET_SIZE}, + {MT_BKT_2_DSIZE, MT_BKT_2_NUMBLKS, SS_DFLT_MEM_BLK_SET_SIZE}, + {MT_BKT_3_DSIZE, MT_BKT_3_NUMBLKS, SS_DFLT_MEM_BLK_SET_SIZE} +#else + {1024, 12800 /* MT_BKT_0_NUMBLKS */, SS_DFLT_MEM_BLK_SET_SIZE}, + {1664, 12800 /* MT_BKT_1_NUMBLKS */, SS_DFLT_MEM_BLK_SET_SIZE}, + {4096, 3840 /* MT_BKT_2_NUMBLKS*/, SS_DFLT_MEM_BLK_SET_SIZE}, + {MT_BKT_3_DSIZE, 12800 /* MT_BKT_3_NUMBLKS */, SS_DFLT_MEM_BLK_SET_SIZE} +#endif + } +}; +#endif /* SS_LOCKLESS_MEMORY */ + +/* mt022.201 - Modification for memory calculator tool */ +/* mt018.201 - added memory configuration matrix */ +PUBLIC MtMemCfg mtMemoCfg = +{ +#ifdef RY_ENBS5SHM + SS_MAX_REGS - 1, /* number of regions */ +#else +#ifndef XEON_SPECIFIC_CHANGES + SS_MAX_REGS, /* number of regions */ +#else + 2, +#endif +#endif + { + { + SS_DFLT_REGION, /* region id */ + MT_MAX_BKTS, /* number of buckets */ + MT_HEAP_SIZE, /* heap size */ + { +#ifndef XEON_SPECIFIC_CHANGES + {MT_BKT_0_DSIZE, MT_BKT_0_STATIC_NUMBLKS}, /* block size, no. of blocks */ + {MT_BKT_1_DSIZE, MT_BKT_1_STATIC_NUMBLKS}, /* block size, no. of blocks */ + {MT_BKT_2_DSIZE, MT_BKT_2_STATIC_NUMBLKS}, /* block size, no. of blocks */ + {MT_BKT_3_DSIZE, MT_BKT_3_STATIC_NUMBLKS} /* block size, no. of blocks */ +#else +#if 0 + {256, 500000}, + {512, 11000}, + {2048, 100000}, + {8192, 75128}, + {16384, 4096} +#else /* Page boundary alignment */ + {256, 491520}, /* 60 pages of 2M*/ + {512, 12288}, /* 3 pages of 2M */ + {2048, 99328}, /* 97 Pages of 2M */ + {8192, 75008}, /* 293 Pages of 2M */ + {16384, 4096} /* 32 pages of 2M */ +#endif +#endif + } + }, +#ifdef INTEL_WLS +#ifndef SS_LOCKLESS_MEMORY + { + SS_DFLT_REGION + 1, /* region id */ + MT_MAX_BKTS, /* number of buckets */ + /*MT_HEAP_SIZE 7194304 */ 10485760, /* heap size */ + { + //{MT_BKT_0_DSIZE, MT_BKT_0_STATIC_NUMBLKS}, /* block size, no. of blocks */ + //{MT_BKT_1_DSIZE, MT_BKT_1_STATIC_NUMBLKS}, /* block size, no. of blocks */ + //{MT_BKT_2_DSIZE, MT_BKT_2_STATIC_NUMBLKS}, /* block size, no. of blocks */ + //{MT_BKT_3_DSIZE, MT_BKT_3_STATIC_NUMBLKS} /* block size, no. of blocks */ + {128, 500000}, + {256, 500000}, + {2048, 200000}, + {4096, 40960}, + {18432, 10240} + } + }, +#endif /* SS_LOCKLESS_MEMORY */ +#endif /* INTEL_WLS */ +#ifdef SS_LOCKLESS_MEMORY + { + SS_DFLT_REGION + 1, /* region id */ + MT_MAX_BKTS, /* number of buckets */ + MT_HEAP_SIZE, /* heap size */ + { + {MT_BKT_0_DSIZE, MT_BKT_0_STATIC_NUMBLKS}, /* block size, no. of blocks */ + {MT_BKT_1_DSIZE, MT_BKT_1_STATIC_NUMBLKS}, /* block size, no. of blocks */ + {MT_BKT_2_DSIZE, MT_BKT_2_STATIC_NUMBLKS}, /* block size, no. of blocks */ + {MT_BKT_3_DSIZE, MT_BKT_3_STATIC_NUMBLKS} /* block size, no. of blocks */ + } + }, + { + SS_DFLT_REGION + 2, /* region id */ + MT_MAX_BKTS, /* number of buckets */ + MT_HEAP_SIZE, /* heap size */ + { + {MT_BKT_0_DSIZE, MT_BKT_0_STATIC_NUMBLKS}, /* block size, no. of blocks */ + {MT_BKT_1_DSIZE, MT_BKT_1_STATIC_NUMBLKS}, /* block size, no. of blocks */ + {MT_BKT_2_DSIZE, MT_BKT_2_STATIC_NUMBLKS}, /* block size, no. of blocks */ + {MT_BKT_3_DSIZE, MT_BKT_3_STATIC_NUMBLKS} /* block size, no. of blocks */ + } + }, + { + SS_DFLT_REGION + 3, /* region id */ + MT_MAX_BKTS, /* number of buckets */ + MT_HEAP_SIZE, /* heap size */ + { + {MT_BKT_0_DSIZE, MT_BKT_0_STATIC_NUMBLKS}, /* block size, no. of blocks */ + {MT_BKT_1_DSIZE, MT_BKT_1_STATIC_NUMBLKS}, /* block size, no. of blocks */ + {MT_BKT_2_DSIZE, MT_BKT_2_STATIC_NUMBLKS}, /* block size, no. of blocks */ + {MT_BKT_3_DSIZE, MT_BKT_3_STATIC_NUMBLKS} /* block size, no. of blocks */ + } + } +#endif /* SS_LOCKLESS_MEMORY */ + STATIC_MEM_CFG + } +}; +/* mt003.301 Modifications - File Based task registration made + * common for both MULTICORE and NON-MULTICORE + * bucket info, as different regions may request for different no. + * of blocks + */ +PUBLIC MtBktCfg mtBktInfo[MT_MAX_BKTS]; +PUBLIC S16 msArgc; /* argc */ +PUBLIC Txt **msArgv; /* argv */ +PUBLIC S16 msOptInd; /* SGetOpt vars */ +PUBLIC S8 *msOptArg; /* SGetOpt vars */ + + +#ifdef INTEL_WLS +typedef struct _MtRegMemSz +{ + U32 reqdSz; + U8 *startAddr; +}MtRegMemSz; + +PRIVATE MtRegMemSz mtRegMemSz[MT_MAX_BKTS+1]; +#endif + + +/* private variable declarations */ +/* mt018.201 - change mtCMMRegCfg as array of pointers */ +PRIVATE CmMmRegCfg *mtCMMRegCfg[SS_MAX_REGS]; +PRIVATE CmMmRegCb *mtCMMRegCb[SS_MAX_REGS]; +/* mt003.301 - Fixed compilation warnings */ +/*mt004.301-addede new veriable for FAP*/ +/*mt010.301 - removed veriable defined for FA*/ + + +#ifdef INTEL_WLS + +#ifdef NTL_LIB +void mtSetNtlHdl(unsigned int hdl) +{ + osCp.ntl.hdl = hdl; +} + +unsigned int mtGetNtlHdl() +{ + return(osCp.ntl.hdl); +} + +#endif /* NTL_LIB */ + +void * mtGetWlsHdl() +{ + RETVALUE(osCp.wls.intf); +} + +#ifdef XEON_MULTIPLE_CELL_CHANGES +EXTERN S8 gWrWlsDeviceName[MAX_WLS_DEVICE_NAME_LEN]; +EXTERN S16 smWrReadWlsConfigParams (Void); +#endif + +PRIVATE int SOpenWlsIntf() +{ + void *hdl; + #define WLS_DEVICE_NAME "/dev/wls" + +#ifdef XEON_SPECIFIC_CHANGES +#ifdef XEON_MULTIPLE_CELL_CHANGES + hdl = WLS_Open(gWrWlsDeviceName, 1); +#else + hdl = WLS_Open(WLS_DEVICE_NAME, 1); +#endif +#else + hdl = WLS_Open(WLS_DEVICE_NAME, 0); +#endif + + osCp.wls.intf = hdl; + + if(!osCp.wls.intf) + { + printf("Could not open WLS Interface \n"); + RETVALUE(0); + } + + RETVALUE(1); +} +#endif + +/* mt028.201 */ +#ifndef API_MAIN + +/* +* +* Fun: main +* +* Desc: This function is the entry point for the final binary. It +* calls SInit() in the common code. It can be replaced by a +* user function if required (SInit() must still be called). +* +* Ret: none on success +* exit on failure +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC int main +( +int argc, /* argument count */ +char **argv /* argument vector */ +) +#else +PUBLIC int main(argc, argv) +int argc; /* argument count */ +char **argv; /* argument vector */ +#endif +{ + TRC0(main); + +#ifdef XEON_MULTIPLE_CELL_CHANGES + /* Read the WLS parameters from the file and copy into global control block */ + if(smWrReadWlsConfigParams() != ROK) + { + fprintf(stderr, "Failed to read WLS params from file wr_cfg.txt"); + RETVALUE(RFAILED); + } /* end of if statement */ +#endif + +#ifdef INTEL_WLS + if(!SOpenWlsIntf()) + RETVALUE(0); +#endif /* INTEL_WLS */ + + msArgc = argc; + msArgv = argv; + /* mt003.301 Modifications */ + if( ROK != SInit()) + { + printf("\n SInit failed, SSI could not start \n"); + /* pthread_exit(NULLP);*/ /* Commented to Come out of Main thread*/ + + RETVALUE(0); + } + /*mt010.301 cleanup part exposed to user*/ + SFini(); + RETVALUE(0); +} + +#else + +/* +* +* Fun: ssMain +* +* Desc: This function is the entry point for the final binary. It +* calls SInit() in the common code. It can be replaced by a +* user function if required (SInit() must still be called). +* +* Ret: none on success +* exit on failure +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC int ssMain +( +int argc, /* argument count */ +char **argv /* argument vector */ +) +#else +PUBLIC int ssMain(argc, argv) +int argc; /* argument count */ +char **argv; /* argument vector */ +#endif +{ + TRC0(ssMain); + + + msArgc = argc; + msArgv = argv; + + + SInit(); + + RETVALUE(0); +} + +#endif +/* +* initialization functions +*/ + +/* +* +* Fun: Initialize OS control point +* +* Desc: This function initializes MTSS-specific information +* in the OS control point. +* +* Ret: ROK - ok +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 ssdInitGen +( +void +) +#else +PUBLIC S16 ssdInitGen() +#endif +{ + struct sigaction act; + sigset_t set; +#ifdef TENB_T2K3K_SPECIFIC_CHANGES + struct sigaction sa; +#endif + + TRC0(ssdInitGen); + + /*mt014.301 : 4GMX release related changes*/ +#ifdef SS_4GMX_UCORE + uarmInit(); +#endif +/* mt005.301 : Cavium changes */ +#ifdef SS_SEUM_CAVIUM + /* set group mask for the core */ + cvmx_pow_set_group_mask(cvmx_get_core_num(), SS_CVMX_GRP_MASK); +#endif /* SS_SEUM_CAVIUM */ + + osCp.dep.sysTicks = 0; + + /* mt020.201 - Addition for no command line available */ +#ifndef NOCMDLINE + /* parse command line */ + mtGetOpts(); + /* mt003.301 Additions */ + if(fileBasedMemCfg == TRUE && memConfigured == FALSE) + { + printf("\n File Based Memory configuration failed \n"); + RETVALUE(RFAILED); + } +#endif + +#ifndef RGL_SPECIFIC_CHANGES /* ANOOP :: This ssdInitMemInfo() was present in 2.1 */ +#ifndef SS_LOCKLESS_MEMORY +#ifdef SS_MULTICORE_SUPPORT + if(memConfigured == FALSE) + ssdInitMemInfo(); +#endif +#endif +#endif + + /* initialize the started semaphore */ + if (sem_init(&osCp.dep.ssStarted, 0, 0) != 0) + { + RETVALUE(RFAILED); + } + + /* mt028.201 added compile time flag to allow not to mask signals */ +#ifndef UNMASK_SIG + /* mask all signals in the main thread */ + sigfillset(&set); + sigdelset(&set, SIGINT); +#ifdef TENB_T2K3K_SPECIFIC_CHANGES + sigdelset(&set, SIGSEGV); + sigdelset(&set, SIGUSR2); + sigdelset(&set, SIGILL); +#ifdef XEON_SPECIFIC_CHANGES + sigdelset(&set, SIGABRT); + sigdelset(&set, SIGTERM); + sigdelset(&set, SIGHUP); +#endif +#endif + pthread_sigmask(SIG_SETMASK, &set, NULLP); +#endif /* UNMASK_SIG */ + + /* install a SIGINT handler to shutdown */ + /*mt010.301 Fix for core when run with -o option and when killed with SIGINT*/ + + /*Initialize SIGSEGV Signal */ +#ifdef TENB_T2K3K_SPECIFIC_CHANGES +#if 1 + memset(&sa, 0, sizeof(struct sigaction)); + sigemptyset(&sa.sa_mask); + sa.sa_sigaction = signal_segv; + sa.sa_flags = SA_SIGINFO; +#ifndef XEON_SPECIFIC_CHANGES + sigaction(SIGSEGV, &sa, NULL); + + memset(&sa, 0, sizeof(struct sigaction)); + sigemptyset(&sa.sa_mask); + sa.sa_sigaction = signal_segv; + sa.sa_flags = SA_SIGINFO; + + sigaction(SIGILL, &sa, NULL); +#else + if(sigaction(SIGILL, &sa, NULL) != 0) + { + printf("Failed to process sigaction for the SIGILL\n"); + RETVALUE(RFAILED); + } + if(sigaction(SIGSEGV, &sa, NULL) != 0) + { + printf("Failed to process sigaction for the SIGSEGV\n"); + RETVALUE(RFAILED); + } + if(sigaction(SIGABRT, &sa, NULL) != 0) + { + printf("Failed to process sigaction for the SIGABRT\n"); + RETVALUE(RFAILED); + } + if(sigaction(SIGTERM, &sa, NULL) != 0) + { + printf("Failed to process sigaction for the SIGTERM\n"); + RETVALUE(RFAILED); + } + if(sigaction(SIGHUP, &sa, NULL) != 0) + { + printf("Failed to process sigaction for the SIGHUP\n"); + RETVALUE(RFAILED); + } +#endif +#else + signal (SIGSEGV, mtSigSegvHndlr); + signal (SIGKILL, mtSigSegvHndlr); + signal (SIGUSR2, mtSigUsr2Hndlr); +#endif +#endif + +#ifdef MLOG_XEON + signal (SIGINT, mtStopHndlr); +#else + + act.sa_handler = mtIntSigHndlr; + sigfillset(&act.sa_mask); + act.sa_flags = 0; + if (sigaction(SIGINT, &act, NULLP) != 0) + { + RETVALUE(RFAILED); + } +#endif + + /* mt040.201 initialise random seed */ + osCp.dep.randSeed = time(NULLP); + + RETVALUE(ROK); +} + + +/* +* +* Fun: De-initialize OS control point +* +* Desc: This function reverses the initialization in ssdInitGen(). +* +* Ret: ROK - ok +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC Void ssdDeinitGen +( +void +) +#else +PUBLIC Void ssdDeinitGen() +#endif +{ + TRC0(ssdDeinitGen); + + + sem_destroy(&osCp.dep.ssStarted); + + + RETVOID; +} +#ifdef SS_LOCKLESS_MEMORY +#ifdef USE_MALLOC +/* +* +* Fun: ssPutDynMemBlkSet +* +* Desc: Returns the set of dynamic Blocks into the global region +* +* +* Ret: ROK - successful, +* RFAILED - unsuccessful. +* +* Notes: +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PUBLIC S16 ssPutDynMemBlkSet +( +U8 bktIdx, /* Index to bucket list */ +CmMmBlkSetElement *dynMemSetElem /* Memory set element which is needs to be + added to global region */ +) +#else +PUBLIC S16 ssPutDynMemBlkSet(bktIdx, dynMemSetElem) +U8 bktIdx; /* Index to bucket list */ +CmMmBlkSetElement *dynMemSetElem; /* Memory set element which is needs to be + added to global region */ +#endif +{ + CmMmGlobRegCb *globReg; + CmMmGlobalBktCb *bktCb; + Data *blkPtr; + U8 blkCnt; + + globReg = osCp.globRegCb; + +#if (ERRCLASS & ERRCLS_INT_PAR) + if(bktIdx >= globReg->numBkts) + { + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + bktCb = &(globReg->bktTbl[bktIdx]); + + for(blkCnt = 0; blkCnt < bktCb->bucketSetSize; blkCnt++) + { + blkPtr = dynMemSetElem->nextBktPtr; + dynMemSetElem->nextBktPtr = *((CmMmEntry **)blkPtr); + free((Void *)blkPtr); + } + + dynMemSetElem->nextBktPtr = NULLP; + dynMemSetElem->numFreeBlks = 0; + + RETVALUE(ROK); +} + +/* +* +* Fun: ssGetDynMemBlkSet +* +* Desc: Gets the set of dynamic memory blocks from the global region +* +* +* Ret: ROK - successful, +* RFAILED - unsuccessful. +* +* Notes: +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PUBLIC S16 ssGetDynMemBlkSet +( +U8 bktIdx, /* Index to bucket list */ +CmMmBlkSetElement *dynMemSetElem /* Memory set element which is updated + with new set values */ +) +#else +PUBLIC S16 ssGetDynMemBlkSet(bktIdx, dynMemSetElem) +U8 bktIdx; /* Index to bucket list */ +CmMmBlkSetElement *dynMemSetElem; /* Memory set element which is updated + with new set values */ +#endif +{ + + CmMmGlobRegCb *globReg; + CmMmGlobalBktCb *bktCb; + Data **basePtr; + Data *blkPtr; + U8 blkCnt; + + globReg = osCp.globRegCb; + +#if (ERRCLASS & ERRCLS_INT_PAR) + if(bktIdx >= globReg->numBkts) + { + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + bktCb = &(globReg->bktTbl[bktIdx]); + basePtr = &(dynMemSetElem->nextBktPtr); + + for(blkCnt = 0; blkCnt < bktCb->bucketSetSize; blkCnt++) + { + blkPtr = (Data *)malloc(bktCb->size); + *basePtr = blkPtr; + basePtr = (CmMmEntry **)blkPtr; + } + + dynMemSetElem->numFreeBlks = bktCb->bucketSetSize; + + RETVALUE(ROK); + +} /* ssGetDynMemBlkSet */ + +#else +/* +* +* Fun: ssPutDynMemBlkSet +* +* Desc: Returns the set of dynamic Blocks into the global region +* +* +* Ret: ROK - successful, +* RFAILED - unsuccessful. +* +* Notes: +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PUBLIC S16 ssPutDynMemBlkSet +( +U8 bktIdx, /* Index to bucket list */ +CmMmBlkSetElement *dynMemSetElem, /* Memory set element which is needs to be + added to global region */ +U32 doNotBlockForLock /* Boolean whether to block for lock or not */ +) +#else +PUBLIC S16 ssPutDynMemBlkSet(bktIdx, dynMemSetElem) +U8 bktIdx; /* Index to bucket list */ +CmMmBlkSetElement *dynMemSetElem; /* Memory set element which is needs to be + added to global region */ +U32 doNotBlockForLock; /* Boolean whether to block for lock or not */ +#endif +{ + CmMmGlobRegCb *globReg; + CmMmGlobalBktCb *bktCb; + CmLList *lstNode; + CmMmBlkSetElement *globMemNode; + S16 lockRet = 0; + + TRC1(ssPutDynMemBlkSet); + + globReg = osCp.globRegCb; + +#if (ERRCLASS & ERRCLS_INT_PAR) + if(bktIdx >= globReg->numBkts) + { + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + bktCb = &(globReg->bktTbl[bktIdx]); + + /* Lock the global region first. If the doNotBlockForLock is non-zero, the + try lock is used as it is not required to block as it will be taken + in the next go else it will be blocked for lock as we have to get the + blocks must */ + { + SLock(&(bktCb->bucketLock)); + } + + if(lockRet == 0) + { + + /* Get a free node from the free node linked list */ + lstNode = cmLListFirst(&(bktCb->listFreeBktSet)); + if(lstNode == NULLP) + { + SUnlock(&(bktCb->bucketLock)); + RETVALUE(RFAILED); + } + + cmLListDelFrm(&(bktCb->listFreeBktSet), lstNode); + + /* Copy the content of the received element information on to free node + * and add it to valid linked list */ + globMemNode = (CmMmBlkSetElement *)lstNode->node; + globMemNode->numFreeBlks = dynMemSetElem->numFreeBlks; + globMemNode->nextBktPtr = dynMemSetElem->nextBktPtr; + dynMemSetElem->numFreeBlks = 0; + dynMemSetElem->nextBktPtr = NULLP; + + cmLListAdd2Tail(&(bktCb->listValidBktSet), &(globMemNode->memSetNode)); + + SUnlock(&(bktCb->bucketLock)); + } + + RETVALUE(ROK); +} + +/* +* +* Fun: ssGetDynMemBlkSet +* +* Desc: Gets the set of dynamic memory blocks from the global region +* +* +* Ret: ROK - successful, +* RFAILED - unsuccessful. +* +* Notes: The parameter doNotBlockForLock specifies whether to block for lock +* or not +* +* File: cm_mem.c +* +*/ +#ifdef ANSI +PUBLIC S16 ssGetDynMemBlkSet +( +U8 bktIdx, /* Index to bucket list */ +CmMmBlkSetElement *dynMemSetElem, /* Memory set element which is updated + with new set values */ +U32 doNotBlockForLock /* Boolean whether to block for lock or not */ +) +#else +PUBLIC S16 ssGetDynMemBlkSet(bktIdx, dynMemSetElem) +U8 bktIdx; /* Index to bucket list */ +CmMmBlkSetElement *dynMemSetElem; /* Memory set element which is updated + with new set values */ +U32 doNotBlockForLock; /* Boolean whether to block for lock or not */ +#endif +{ + CmMmGlobRegCb *globReg; + CmMmGlobalBktCb *bktCb; + CmLList *lstNode; + CmMmBlkSetElement *globMemNode; + S16 lockRet = 0; + + TRC1(ssGetDynMemBlkSet); + + globReg = osCp.globRegCb; + +#if (ERRCLASS & ERRCLS_INT_PAR) + if(bktIdx >= globReg->numBkts) + { + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + bktCb = &(globReg->bktTbl[bktIdx]); + + /* Lock the global region first. If the doNotBlockForLock is non-zero, the + try lock is used as it is not required to block as it will be taken + in the next go else it will be blocked for lock as we have to get the + blocks must */ + { + SLock(&(bktCb->bucketLock)); + } + + if(lockRet == 0) + { + lstNode = cmLListFirst(&(bktCb->listValidBktSet)); + + if(lstNode == NULLP) + { + SUnlock(&(bktCb->bucketLock)); + RETVALUE(RFAILED); + } + + /* Delete the node from the valid linked list and copy the values of the + * elements of structrues into pointer */ + cmLListDelFrm(&(bktCb->listValidBktSet), lstNode); + globMemNode = (CmMmBlkSetElement *)lstNode->node; + dynMemSetElem->numFreeBlks = globMemNode->numFreeBlks; + dynMemSetElem->nextBktPtr = globMemNode->nextBktPtr; + + /* Add this node to the free node linked list */ + cmLListAdd2Tail(&(bktCb->listFreeBktSet), lstNode); + + SUnlock(&(bktCb->bucketLock)); + } + + RETVALUE(ROK); +} /* ssGetDynMemBlkSet */ + + +#define NUM_CALLS_TO_CHECK_MEM_DYN_AGAIN 100 +U32 gDynMemAlrm[4]; +PRIVATE U32 memoryCheckCounter; + +#ifdef ANSI +PUBLIC U32 isMemThreshReached( +Region reg +) +#else +PUBLIC U32 isMemThreshReached(reg) +Region reg; +#endif +{ + CmMmGlobRegCb *globReg; + CmMmGlobalBktCb *bktCb; + U8 blkCnt; + U8 bktIdx= reg; + TRC3(isMemThreshReached) + + globReg = osCp.globRegCb; + +#if (ERRCLASS & ERRCLS_INT_PAR) + if(bktIdx >= globReg->numBkts) + { + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + bktCb = &(globReg->bktTbl[bktIdx]); + + if(gDynMemAlrm[bktIdx]) + { + // printf ("under memory bktCb->listValidBktSet.count %d bktIdx %d\n",bktCb->listValidBktSet.count ,bktIdx); + SLock(&(bktCb->bucketLock)); + if(bktCb->listValidBktSet.count > 25) + { + gDynMemAlrm[bktIdx] = FALSE; + // printf ("recoverd bktCb->listValidBktSet.count %d bktIdx %d\n",bktCb->listValidBktSet.count ,bktIdx); + } + SUnlock(&(bktCb->bucketLock)); + RETVALUE(RFAILED); + } + else + { + + if(memoryCheckCounter++ >= NUM_CALLS_TO_CHECK_MEM_DYN_AGAIN) + { + // printf ("CHECK bktCb->listValidBktSet.count %d bktIdx %d\n",bktCb->listValidBktSet.count ,bktIdx); + SLock(&(bktCb->bucketLock)); + if(bktCb->listValidBktSet.count < 15 ) + gDynMemAlrm[bktIdx] = TRUE; + memoryCheckCounter = 0; + SUnlock(&(bktCb->bucketLock)); + } + } + RETVALUE(ROK); +} + +#endif /* USE_MALLOC */ +#endif /* SS_LOCKLESS_MEMORY */ + +#ifdef SS_USE_ICC_MEMORY +/* +* +* Fun: Initialize region/pool tables +* +* Desc: This function initializes MTSS-specific information +* in the region/pool tables and configures the common +* memory manager for use. +* +* Ret: ROK - ok +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC Void * ssGetIccHdl +( +Region region +) +#else +PUBLIC Void * ssGetIccHdl() +Region region; +#endif +{ + CmMmDynRegCb *dynRegCb; + + /* Klock work fix ccpu00148484 */ + if(!(region < SS_MAX_REGS)) + { + RETVALUE(NULLP); + } + + dynRegCb = (CmMmDynRegCb *)osCp.dynRegionTbl[region].regCb; + + RETVALUE(dynRegCb->iccHdl); +} +#endif /* SS_USE_ICC_MEMORY */ + +#ifdef T2K_MEM_LEAK_DBG +extern RegionMemLeakInfo regMemLeakInfo; +#endif /* T2K_MEM_LEAK_DBG */ + +#ifdef INTEL_WLS + +PUBLIC S16 SPartitionWlsMemory() +{ + U32 i; +#ifndef ALIGN_64BIT + U64 reqdSz; + U64 pageSize[1], hugePageSize; +#else + long int reqdSz; + long int pageSize[1], hugePageSize; +#endif + U32 numHugePg; + #define DIV_ROUND_OFFSET(X,Y) ( X/Y + ((X%Y)?1:0) ) + + U8 *regMemStrtAddr = (U8 *)osCp.wls.allocAddr; + + gethugepagesizes(pageSize,1); + hugePageSize = pageSize[0]; + for (i = 0; i < 1; i++) + { + mtRegMemSz[i].startAddr = regMemStrtAddr; + CM_LOG_DEBUG(CM_LOG_ID_MT, "Global Region-->Bkt[%d] Addr:%p\n", i, mtRegMemSz[i].startAddr); + + numHugePg = DIV_ROUND_OFFSET(mtRegMemSz[i].reqdSz, hugePageSize); + reqdSz = numHugePg * hugePageSize; + regMemStrtAddr += reqdSz; +#ifdef T2K_MEM_LEAK_DBG + /* Since wls is region 0 */ + regMemLeakInfo.regStartAddr[i] = (U64)mtRegMemSz[i].startAddr; + regMemLeakInfo.numActvRegions++; +#endif /* T2K_MEM_LEAK_DBG */ + } + //Store last region addr for validation + mtRegMemSz[i].startAddr = regMemStrtAddr; + RETVALUE(ROK); +} + +#ifdef SS_MEM_WL_DEBUG +PUBLIC Void SChkAddrValid(int type, int region, PTR ptr) +{ + char *tryPtr = NULL; + if(type == 0) //Global + { + if(ptr < mtRegMemSz[0].startAddr || ptr >= + (mtRegMemSz[mtGlobMemoCfg.numBkts].startAddr + mtGlobMemoCfg.heapSize)) + { + printf("****INVALID PTR in Global Region: ptr:%p start:%p end:%p***\n", ptr, mtRegMemSz[0].startAddr, mtRegMemSz[mtGlobMemoCfg.numBkts].startAddr); + *tryPtr = 0; + } + } + else + { + if(ptr > mtRegMemSz[0].startAddr && ptr <= mtRegMemSz[mtGlobMemoCfg.numBkts].startAddr ) + { + printf("****INVALID PTR in Static Region: ptr:%p start:%p end:%p***\n", ptr, mtRegMemSz[0].startAddr, mtRegMemSz[mtGlobMemoCfg.numBkts].startAddr); + *tryPtr = 0; + } + + } +} +#endif /* SS_MEM_WL_DEBUG */ + +PUBLIC S16 SPartitionStaticMemory(U8 *startAddr) +{ + int i; + U32 reqdSz; + + U8 *regMemStrtAddr = (U8 *)startAddr; + + + //for (i = 0; i < mtMemoCfg.numRegions; i++) + for (i = 1; i < mtMemoCfg.numRegions; i++) + { + mtRegMemSz[i].startAddr = regMemStrtAddr; + reqdSz = /* regMemStrtAddr + */mtRegMemSz[i].reqdSz; + regMemStrtAddr += reqdSz; +#ifdef T2K_MEM_LEAK_DBG + { /* Since region 1 onwards are used for non wls */ + regMemLeakInfo.regStartAddr[i] = (U64)mtRegMemSz[i].startAddr; + regMemLeakInfo.numActvRegions++; + } +#endif /* T2K_MEM_LEAK_DBG */ + } + RETVALUE(ROK); +} +PUBLIC S16 SAllocateWlsMem() +{ + + U32 reqdMemSz; + U32 i, j; + MtRegCfg *region; + + reqdMemSz = 0; + //memset(&mtRegMemSz[0], sizeof(mtRegMemSz), 0); + memset(&mtRegMemSz[0], 0, sizeof(mtRegMemSz)); + + for (i = 0; i < 1; i++) + { + /* allocate space for the region */ + region = &mtMemoCfg.region[i]; + reqdMemSz += region->heapsize; + mtRegMemSz[i].reqdSz += region->heapsize; + + for (j = 0; j < region->numBkts; j++) + { + reqdMemSz += region->bkt[j].blkSize * region->bkt[j].numBlks; + mtRegMemSz[i].reqdSz += region->bkt[j].blkSize * region->bkt[j].numBlks; + } + } + osCp.wls.allocAddr = WLS_Alloc(osCp.wls.intf, (512 *1024 * 1024)); + //osCp.wls.allocAddr = WLS_Alloc(osCp.wls.intf, (reqdMemSz + (1024 * 1024 * 2 * 2))); +#ifndef ALIGN_64BIT + printf("\n ************* \n WLS memory: %llx, %ld\n ****** \n", osCp.wls.allocAddr, reqdMemSz); +#else + printf("\n ************* \n WLS memory: %lx, %d\n ****** \n", (PTR)osCp.wls.allocAddr, reqdMemSz); +#endif + SPartitionWlsMemory(); + RETVALUE(ROK); +} +PUBLIC S16 SAllocateStaticMem() +{ + + U32 reqdMemSz; + int i, j; + MtRegCfg *region; + U8 *startAddr; + + reqdMemSz = 0; + //memset(&mtRegMemSz[0], sizeof(mtRegMemSz), 0); + + //for (i = 0; i < mtMemoCfg.numRegions; i++) + for (i = 1; i < mtMemoCfg.numRegions; i++) + { + /* allocate space for the region */ + region = &mtMemoCfg.region[i]; + reqdMemSz += region->heapsize; + mtRegMemSz[i].reqdSz += region->heapsize; + + for (j = 0; j < region->numBkts; j++) + { + reqdMemSz += region->bkt[j].blkSize * region->bkt[j].numBlks; + mtRegMemSz[i].reqdSz += region->bkt[j].blkSize * region->bkt[j].numBlks; + } + } + + startAddr = malloc(reqdMemSz + (1024 * 10)); +#ifndef ALIGN_64BIT + printf("\n ************* \n Static memory: %llx, %ld\n ****** \n", startAddr, reqdMemSz); +#else + printf("\n ************* \n Static memory: %lx, %d\n ****** \n", (PTR)startAddr, reqdMemSz); +#endif + SPartitionStaticMemory(startAddr); + RETVALUE(ROK); +} +#endif /* INTEL_WLS */ + + + +/* +* +* Fun: Initialize region/pool tables +* +* Desc: This function initializes MTSS-specific information +* in the region/pool tables and configures the common +* memory manager for use. +* +* Ret: ROK - ok +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 ssdInitMem +( +void +) +#else +PUBLIC S16 ssdInitMem() +#endif +{ + /* mt018.201 - added local variable */ + U8 i; + U16 j; + U8 k; + MtRegCfg *region; + Txt errMsg[256] = {'\0'}; +#ifdef SS_LOCKLESS_MEMORY + CmMmDynRegCb *dynRegCb; +#ifdef SS_USE_ICC_MEMORY +#else + CmMmGlobRegCb *globReg; + Size memSize; +#endif +#endif /* SS_LOCKLESS_MEMORY */ + + TRC0(ssdInitMem); + + /* Use the default SSI memory manager if the ICC memory manager is not + * avilable. If ICC memory manager is avilable, it will be used for + * all sharable memory allocation and de-allocation */ +#ifdef SS_LOCKLESS_MEMORY +#ifdef SS_USE_ICC_MEMORY +#ifndef YS_PHY_3_8_2 +#endif + for (i = 0; i < mtDynMemoCfg.numRegions; i++) + { + dynRegCb = (CmMmDynRegCb *)calloc(1, sizeof(CmMmDynRegCb)); + if(dynRegCb == NULLP) + { + RETVALUE(RFAILED); + } + for(k = 0; k < mtDynMemoCfg.region[i].numBkts; k++) + { + dynRegCb->bktSize[k] = mtGlobMemoCfg.bkt[k].blkSize; + } + dynRegCb->region = i; + cmMmDynRegInit(dynRegCb); + printf("iccHdl = %lx\n", (PTR)dynRegCb->iccHdl); + sleep(1); + } + /* ysIccHdl = dynRegCb->iccHdl; */ + +#else + /* Initialize the global region first */ + osCp.globRegCb = calloc(1, sizeof(CmMmGlobRegCb)); + + if(osCp.globRegCb == NULLP) + { + RETVALUE(RFAILED); + } + + globReg = (CmMmGlobRegCb *)osCp.globRegCb; + + for(i = 0; i < mtGlobMemoCfg.numBkts; i++) + { + memSize = (mtGlobMemoCfg.bkt[i].blkSize * mtGlobMemoCfg.bkt[i].numBlks); +#ifndef INTEL_WLS + globReg->bktTbl[i].startAddr = (Data *)calloc(memSize, sizeof(Data)); +#else + globReg->bktTbl[i].startAddr = (Data *)mtRegMemSz[i].startAddr; +#endif + if(globReg->bktTbl[i].startAddr == NULLP) + { + RETVALUE(RFAILED); + } + globReg->bktTbl[i].poolId = i; + globReg->bktTbl[i].size = mtGlobMemoCfg.bkt[i].blkSize; + globReg->bktTbl[i].numBlks = mtGlobMemoCfg.bkt[i].numBlks; + globReg->bktTbl[i].bucketSetSize = mtGlobMemoCfg.bkt[i].bucketSetSize; + } + + globReg->numBkts = mtGlobMemoCfg.numBkts; + cmMmGlobRegInit(globReg); + + /* Initialize the dynamic task regions and sanity check for the theshold + * values */ + for (i = 0; i < mtDynMemoCfg.numRegions; i++) + { + dynRegCb = (CmMmDynRegCb *)calloc(1, sizeof(CmMmDynRegCb)); + if(dynRegCb == NULLP) + { + RETVALUE(RFAILED); + } + for(k = 0; k < mtDynMemoCfg.region[i].numBkts; k++) + { + if((mtDynMemoCfg.region[i].bkt[k].blkSetRelThreshold < + mtDynMemoCfg.region[i].bkt[k].blkSetAcquireThreshold) || + (mtDynMemoCfg.region[i].bkt[k].blkSetAcquireThreshold == 0) || + (mtDynMemoCfg.region[i].bkt[k].blkSetRelThreshold == 0)) + { +#ifdef XEON_SPECIFIC_CHANGES + free(dynRegCb); +#endif + RETVALUE(RFAILED); + } + dynRegCb->bktTbl[k].size = mtGlobMemoCfg.bkt[k].blkSize; + dynRegCb->bktTbl[k].blkSetRelThreshold = mtDynMemoCfg.region[i].bkt[k].blkSetRelThreshold; + dynRegCb->bktTbl[k].blkSetAcquireThreshold = mtDynMemoCfg.region[i].bkt[k].blkSetAcquireThreshold; + dynRegCb->bktTbl[k].bucketSetSize = mtGlobMemoCfg.bkt[k].bucketSetSize; + if(dynRegCb->bktMaxBlkSize < dynRegCb->bktTbl[k].size) + { + dynRegCb->bktMaxBlkSize = dynRegCb->bktTbl[k].size; + } + } + dynRegCb->region = i; + dynRegCb->numBkts = mtDynMemoCfg.region[i].numBkts; + cmMmDynRegInit(dynRegCb); + } +#endif /* SS_USE_ICC_MEMORY */ +#endif /* SS_LOCKLESS_MEMORY */ + +#ifdef T2K_MEM_LEAK_DBG + U8 reg; + /* Initailize mem leak tool memorys for debguing */ + regMemLeakInfo.numActvRegions=0; + for(reg=0; reg vAddr); + free(mtCMMRegCb[k]); + free(mtCMMRegCfg[k]); + } + RETVALUE(RFAILED); + } + + mtCMMRegCfg[i] = (CmMmRegCfg *)calloc(1, sizeof(CmMmRegCfg)); +#ifdef TENB_RTLIN_CHANGES + mlock(mtCMMRegCfg[i], sizeof(CmMmRegCfg)); +#endif + if (mtCMMRegCfg[i] == NULLP) + { + for (k = 0; k < i; k++) + { + cmMmRegDeInit(mtCMMRegCb[k]); + free(mtCMMRegCfg[k]->vAddr); + free(mtCMMRegCb[k]); + free(mtCMMRegCfg[k]); + } + free(mtCMMRegCb[i]); + RETVALUE(RFAILED); + } + + + /* allocate space for the region */ + region = &mtMemoCfg.region[i]; + mtCMMRegCfg[i]->size = region->heapsize; + for (j = 0; j < region->numBkts; j++) + { +/* mt033.201 - addition for including the header size while computing the total size */ +#ifdef SSI_DEBUG_LEVEL1 + mtCMMRegCfg[i]->size += (region->bkt[j].blkSize + sizeof(CmMmBlkHdr)) *\ + (region->bkt[j].numBlks); +#else + mtCMMRegCfg[i]->size += region->bkt[j].blkSize * region->bkt[j].numBlks; +#endif /* SSI_DEBUG_LEVEL1 */ + } +#ifdef INTEL_WLS + mtCMMRegCfg[i]->vAddr = (Data *)mtRegMemSz[i].startAddr; +#else + mtCMMRegCfg[i]->vAddr = (Data *)calloc(mtCMMRegCfg[i]->size, + sizeof(Data)); +#endif +#ifdef XEON_SPECIFIC_CHANGES + CM_LOG_DEBUG(CM_LOG_ID_MT, "Static Region-->Bkt[%d] Addr:[%p] RegionId=[%d] Size=[%d] \n", + i, mtCMMRegCfg[i]->vAddr, region->regionId, mtCMMRegCfg[i]->size); +#endif +#ifdef TENB_RTLIN_CHANGES + mlock(mtCMMRegCfg[i]->vAddr, mtCMMRegCfg[i]->size*sizeof(Data)); +#endif + + if (mtCMMRegCfg[i]->vAddr == NULLP) + { + sprintf(errMsg,"\n ssdInitMem(): Could not allocate memory \ + for the Region:%d \n",i); + SPrint(errMsg); + for (k = 0; k < i; k++) + { + cmMmRegDeInit(mtCMMRegCb[k]); + free(mtCMMRegCfg[k]->vAddr); + free(mtCMMRegCb[k]); + free(mtCMMRegCfg[k]); + } + free(mtCMMRegCb[i]); + free(mtCMMRegCfg[i]); + RETVALUE(RFAILED); + } + + + /* set up the CMM configuration structure */ + mtCMMRegCfg[i]->lType = SS_LOCK_MUTEX; + mtCMMRegCfg[i]->chFlag = 0; + mtCMMRegCfg[i]->bktQnSize = MT_BKTQNSIZE; + mtCMMRegCfg[i]->numBkts = region->numBkts; + + for (j = 0; j < region->numBkts; j++) + { + mtCMMRegCfg[i]->bktCfg[j].size = region->bkt[j].blkSize; + mtCMMRegCfg[i]->bktCfg[j].numBlks = region->bkt[j].numBlks; + } + + /* initialize the CMM */ +#ifdef SS_LOCKLESS_MEMORY + if (cmMmStatRegInit(region->regionId, mtCMMRegCb[i], mtCMMRegCfg[i]) != ROK) +#else + if (cmMmRegInit(region->regionId, mtCMMRegCb[i], mtCMMRegCfg[i]) != ROK) +#endif /* SS_LOCKLESS_MEMORY */ + { + for (k = 0; k < i; k++) + { + cmMmRegDeInit(mtCMMRegCb[k]); + free(mtCMMRegCfg[k]->vAddr); + free(mtCMMRegCb[k]); + free(mtCMMRegCfg[k]); + } + free(mtCMMRegCfg[i]->vAddr); + free(mtCMMRegCb[i]); + free(mtCMMRegCfg[i]); + RETVALUE(RFAILED); + } + + + /* initialize the STREAMS module */ + /* mt019.201: STREAMS module will only apply to DFLT_REGION */ + if (region->regionId == 0) + { + if (ssStrmCfg(region->regionId, region->regionId) != ROK) + { + for (k = 0; k < i; k++) + { + cmMmRegDeInit(mtCMMRegCb[k]); + free(mtCMMRegCfg[k]->vAddr); + free(mtCMMRegCb[k]); + free(mtCMMRegCfg[k]); + } + cmMmRegDeInit(mtCMMRegCb[i]); + free(mtCMMRegCfg[i]->vAddr); + free(mtCMMRegCb[i]); + free(mtCMMRegCfg[i]); + RETVALUE(RFAILED); + } + } + } +/* mt001.301 : Additions */ +#ifdef SS_MEM_LEAK_STS + cmInitMemLeakMdl(); +#endif /* SS_MEM_LEAK_STS */ + + + RETVALUE(ROK); +} + + +/* +* +* Fun: De-initialize region/pool tables +* +* Desc: This function reverses the initialization in ssdInitMem(). +* +* Ret: ROK - ok +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC Void ssdDeinitMem +( +void +) +#else +PUBLIC Void ssdDeinitMem() +#endif +{ + /* mt018.201 - added local variables */ + U8 i; + + TRC0(ssdDeinitMem); + /* mt008.301 Additions */ +#ifdef SS_MEM_LEAK_STS + cmDeinitMemLeakMdl(); +#endif /* SS_MEM_LEAK_STS */ + + for (i = 0; i < mtMemoCfg.numRegions; i++) + { + cmMmRegDeInit(mtCMMRegCb[i]); + free(mtCMMRegCfg[i]->vAddr); + free(mtCMMRegCb[i]); + free(mtCMMRegCfg[i]); + } + + RETVOID; +} + + +/* +* +* Fun: Initialize task table +* +* Desc: This function initializes MTSS-specific information +* in the task table. +* +* Ret: ROK - ok +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 ssdInitTsk +( +void +) +#else +PUBLIC S16 ssdInitTsk() +#endif +{ +/* mt001.301 : Additions */ +/*mt013.301 :Added SS_AFFINITY_SUPPORT */ +#if defined(SS_MULTICORE_SUPPORT) ||defined(SS_AFFINITY_SUPPORT) + U32 tskInd = 0; +#endif /* SS_MULTICORE_SUPPORT || SS_AFFINITY_SUPPORT */ + + TRC0(ssdInitTsk); + + +/*mt013.301 :Added SS_AFFINITY_SUPPORT */ +#if defined(SS_MULTICORE_SUPPORT) || defined(SS_AFFINITY_SUPPORT) + /* initialize system task information */ + for (tskInd = 0; tskInd < SS_MAX_STSKS; tskInd++) + { + osCp.sTskTbl[tskInd].dep.lwpId = 0; + } +#endif /* SS_MULTICORE_SUPPORT || SS_AFFINITY_SUPPORT */ + RETVALUE(ROK); +} + + +/* +* +* Fun: Deinitialize task table +* +* Desc: This function reverses the initialization perfomed in +* ssdInitTsk(). +* +* Ret: ROK - ok +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC Void ssdDeinitTsk +( +void +) +#else +PUBLIC Void ssdDeinitTsk() +#endif +{ + TRC0(ssdDeinitTsk); + + RETVOID; +} + + +#ifdef SS_DRVR_SUPPORT +/* +* +* Fun: Initialize driver task table +* +* Desc: This function initializes MTSS-specific information +* in the driver task table. +* +* Ret: ROK - ok +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 ssdInitDrvr +( +void +) +#else +PUBLIC S16 ssdInitDrvr() +#endif +{ + S16 i; +#ifndef L2_L3_SPLIT + pthread_attr_t attr; +#endif + + TRC0(ssdInitDrvr); + + + /* initialize the dependent portion of the driver task entries */ + for (i = 0; i < SS_MAX_DRVRTSKS; i++) + { + osCp.drvrTskTbl[i].dep.flag = FALSE; + } + + + /* create pipe for communication between SSetIntPend() and + * the isTskHdlr thread. + */ + if (pipe(osCp.dep.isFildes) != 0) + { + RETVALUE(RFAILED); + } + +#ifndef L2_L3_SPLIT + /* create the isTskHdlr thread */ + pthread_attr_init(&attr); + /* mt021.201 - Addition to set stack size */ + pthread_attr_setstacksize(&attr, (size_t)MT_ISTASK_STACK); + pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + if ((pthread_create(&osCp.dep.isTskHdlrTID, &attr, mtIsTskHdlr, NULLP)) != 0) + { + /* mt020.201 - Addition for destroying thread attribute object attr */ + pthread_attr_destroy(&attr); + + RETVALUE(RFAILED); + } +#endif + + /*mt014.301 : 4GMX release related changes*/ +#ifdef SS_4GMX_UCORE + uarmDrvrInit(); +#endif + +#ifdef L2_L3_SPLIT + drvrTskInit(); +#endif +#ifndef L2_L3_SPLIT + /* mt020.201 - Addition for destroying thread attribute object attr */ + pthread_attr_destroy(&attr); +#endif + + RETVALUE(ROK); +} + + +/* +* +* Fun: Deinitialize driver information +* +* Desc: This function reverses the initialization performed in +* ssdInitDrvr(). +* +* Ret: ROK - ok +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC Void ssdDeinitDrvr +( +void +) +#else +PUBLIC Void ssdDeinitDrvr() +#endif +{ + TRC0(ssdDeinitDrvr); + /* mt008.301: Terminate the Driver Task on exit */ + while(pthread_cancel(osCp.dep.isTskHdlrTID)); + +#ifdef L2_L3_SPLIT + TL_Close(AppContext.hUAII); + if (clusterMode == RADIO_CLUSTER_MODE) + { + TL_Close(AppContext.hUAII_second); + } +#endif + + RETVOID; +} +#endif /* SS_DRVR_SUPPORT */ + + +/* +* +* Fun: Initialize timer table +* +* Desc: This function initializes MTSS-specific information +* in the timer table. +* +* Ret: ROK - ok +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 ssdInitTmr +( +void +) +#else +PUBLIC S16 ssdInitTmr() +#endif +{ + pthread_attr_t attr; + struct sched_param param_sched; + /* mt010.21: addition */ + S32 i; +#ifdef SS_MULTICORE_SUPPORT + SsSTskEntry *sTsk; +#endif /* SS_MULTICORE_SUPPORT */ +#ifdef SS_THR_REG_MAP + U32 threadCreated = FALSE; +#endif /* SS_THR_REG_MAP */ + + TRC0(ssdInitTmr); + + + osCp.dep.tmrTqCp.tmrLen = SS_MAX_TMRS; + /* mt010.21: addition */ + osCp.dep.tmrTqCp.nxtEnt = 0; + for (i=0; i< SS_MAX_TMRS; i++) + { + osCp.dep.tmrTq[i].first = (CmTimer *)NULLP; + } + +#ifdef SS_MULTICORE_SUPPORT + sTsk = ssdAddTmrSTsk(); + if(!sTsk) + { + RETVALUE(RFAILED); + } +#endif /* SS_MULTICORE_SUPPORT */ + /* create the timer handler thread */ + pthread_attr_init(&attr); + /* mt021.201 - Addition to set stack size */ + pthread_attr_setstacksize(&attr, (size_t)MT_TMRTASK_STACK); + pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + pthread_attr_setschedpolicy(&attr, SCHED_FIFO); + param_sched.sched_priority = sched_get_priority_max(SCHED_FIFO); + pthread_attr_setschedparam(&attr, ¶m_sched); + + +#ifdef SS_THR_REG_MAP + /* When the thread is created, we check for the memory mapping table if + * threadId can be placed in thread memory map table. If it is not able to place + * threadId is stored in tmporary array. Once thread is created successful, + * thread_cancel is sent for each thread which are created before. All the + * threads are made to wait on sema which is cancel point for thread. + */ + while(threadCreated == FALSE) + { +#endif + if ((pthread_create(&osCp.dep.tmrHdlrTID, &attr, mtTmrHdlr, NULLP)) != 0) + { + /* mt020.201 - Addition for destroying thread attribute object attr */ + pthread_attr_destroy(&attr); + + RETVALUE(RFAILED); + } + +#ifdef SS_THR_REG_MAP + threadCreated = ssCheckAndAddMemoryRegionMap(osCp.dep.tmrHdlrTID, + sTsk->region); + } +#endif /* SS_THR_REG_MAP */ +#ifdef SS_MEM_WL_DEBUG + tmpRegTidMap[sTsk->region] = osCp.dep.tmrHdlrTID; +#endif + + /* mt020.201 - Addition for destroying thread attribute object attr */ + pthread_attr_destroy(&attr); + + + RETVALUE(ROK); +} + + +/* +* +* Fun: Deinitialize timer table +* +* Desc: This function reverses the initialization performed in +* ssdInitTmr(). +* +* Ret: ROK - ok +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC Void ssdDeinitTmr +( +void +) +#else +PUBLIC Void ssdDeinitTmr() +#endif +{ +#ifdef SS_MULTICORE_SUPPORT + SsSTskEntry *sTsk; + S16 ret; +#endif /* SS_MULTICORE_SUPPORT */ + + TRC0(ssdDeinitTmr); + +#ifdef SS_MULTICORE_SUPPORT + ret = SLock(&osCp.sTskTblLock); + if (ret != ROK) + { + +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMT008, (ErrVal) ret, + "Could not lock system task table"); +#endif + RETVOID; + } + sTsk = &osCp.sTskTbl[0]; /* first entry is timer entry always */ + /* clean up the system task entry */ + sTsk->used = FALSE; + sTsk->tskPrior = 0; + sTsk->numTTsks = 0; + SDestroyLock(&sTsk->lock); + ssDestroyDmndQ(&sTsk->dQ); + + + /* make this entry available in the system task table */ + sTsk->nxt = osCp.nxtSTskEntry; + osCp.nxtSTskEntry = 0; + + osCp.numSTsks--; + + /* unlock the system task table */ + SUnlock(&osCp.sTskTblLock); + +#endif /* SS_MULTICORE_SUPPORT */ + /* mt008.301: Terminate the timer thread on exit */ + while(pthread_cancel(osCp.dep.tmrHdlrTID)); + RETVOID; +} + + + +/* +* +* Fun: ssdInitLog +* +* Desc: Pre-tst() initialization. +* +* Ret: ROK - ok +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 ssdInitLog +( +void +) +#else +PUBLIC S16 ssdInitLog() +#endif +{ +/* mt027.201 - Modification to fix warnings with no STDIN and STDOUT */ +#ifdef CONAVL +#ifndef CONRD + S32 flags; + pthread_attr_t attr; +#ifndef CONSTDIO + struct termios tio; +#endif /* CONSTDIO */ + S16 fd; +#endif /* CONRD */ +#endif /* CONAVL */ + +/* mt008.301: ssdInitFinal changed to ssdInitLog */ + TRC0(ssdInitLog); + + +#ifdef CONAVL + + osCp.dep.conInFp = (FILE *) stdin; + osCp.dep.conOutFp = (FILE *) stdout; +/* added compile time flag CONRD: mt017.21 */ +#ifndef CONRD +#ifndef CONSTDIO + + /* disable canonical input processing */ + fd = fileno(osCp.dep.conInFp); + if ((tcgetattr(fd, &tio)) != 0) + { + printf("Error: disable canonical input processing\n"); + RETVALUE(RFAILED); + } + + tio.c_lflag &= ~ICANON; + tio.c_cc[VMIN] = 1; /* wait for a minimum of 1 character input */ + tio.c_cc[VTIME] = 0; + if ((tcsetattr(fd, TCSANOW, &tio)) != 0) + { + printf("Error: while tcsetattr() processing\n"); + RETVALUE(RFAILED); + } + +#endif /* CONSTDIO */ + + + /* set up the input fd to block when no data is available */ + fd = fileno(osCp.dep.conInFp); + flags = fcntl(fd, F_GETFL, &flags); + flags &= ~O_NONBLOCK; + if (fcntl(fd, F_SETFL, flags) == -1) + { + printf("Error: while fcntl processing\n"); + RETVALUE(RFAILED); + } + + + /* create the console handler thread */ + pthread_attr_init(&attr); + /* mt021.201 - Addition to set stack size */ + pthread_attr_setstacksize(&attr, (size_t)MT_CONSOLE_STACK); + pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + + + if((SCreatePThread(&osCp.dep.conHdlrTID, &attr, mtConHdlr, NULLP)) != 0) + { + /* mt020.201 - Addition for destroying thread attribute object attr */ + pthread_attr_destroy(&attr); + + printf("Error: Logging Thread creation failed \n"); + RETVALUE(RFAILED); + } + + /* mt020.201 - Addition for destroying thread attribute object attr */ + pthread_attr_destroy(&attr); + +#endif /* CONRD */ +#endif /* CONAVL */ + + + RETVALUE(ROK); +} + + +/* +* +* Fun: ssdDeinitLog +* +* Desc: This function reverses the initialization performed in +* ssdInitLog(). +* +* Ret: ROK - ok +* +* Notes: +* +* File: mt_ss.c +* +*/ +/* mt008.301: ssdDeinitFinal changed to ssdDeinitLog */ +#ifdef ANSI +PUBLIC Void ssdDeinitLog +( +void +) +#else +PUBLIC Void ssdDeinitLog() +#endif +{ +/* mt008.301: ssdDeinitFinal changed to ssdDeinitLog */ + TRC0(ssdDeinitLog); +#ifdef CONAVL +#ifndef CONRD + /* mt008.301: Terminate the console reader on exit */ + while(pthread_cancel(osCp.dep.conHdlrTID)); +#endif /* CONRD */ +#endif /* CONVAL */ + + RETVOID; +} +/* mt001.301 : Additions */ +#ifdef SS_WATCHDOG + + +#ifdef ANSI +PUBLIC S16 ssdInitWatchDog +( +U16 port +) +#else +PUBLIC S16 ssdInitWatchDog(port) +U16 port; +#endif +{ + U8 idx; + Txt prntBuf[PRNTSZE]; + Pst pst; + Buffer *mBuf; +#ifdef SS_WATCHDOG_IPV6 + struct sockaddr_in6 tmpaddr; +#else + struct sockaddr_in tmpaddr; +#endif /* SS_WATCHDOG_IPV6 */ +#ifdef SS_MULTIPLE_PROCS + ProcId procId = SS_WD_WDPROC; + if (SAddProcIdLst(1, &procId) != ROK) + { + RETVALUE(RFAILED); + } +#endif /* SS_MULTIPLE_PROCS */ + + TRC0(ssdInitWatchDog); + + SInitLock(&osCp.wdCp.wdLock, SS_LOCK_MUTEX); + + /* Create a watch dog system task */ + SCreateSTsk(0, &(osCp.wdCp.watchDgTskId)); + + /* Create a watch dog reveiver system task */ + SCreateSTsk(0, &(osCp.wdCp.watchDgRcvrTskId)); + + /* Register and attach watch dog TAPA task */ +#ifdef SS_MULTIPLE_PROCS + SRegTTsk (procId, ENTDW, INST0, TTNORM, PRIOR0, NULLP, watchDgActvTsk); + SAttachTTsk (procId, ENTDW, INST0, osCp.wdCp.watchDgTskId); +#else + SRegTTsk ( ENTDW, INST0, TTNORM, PRIOR0, NULLP, watchDgActvTsk); + SAttachTTsk ( ENTDW, INST0, osCp.wdCp.watchDgTskId); +#endif /* SS_MULTIPLE_PROCS */ + /* Register and attach watch dog receiver TAPA task */ +#ifdef SS_MULTIPLE_PROCS + SRegTTsk (procId, ENTHB, INST0, TTNORM, PRIOR0, NULLP, watchDgRcvrActvTsk); + SAttachTTsk (procId, ENTHB, INST0, osCp.wdCp.watchDgRcvrTskId); +#else + SRegTTsk ( ENTHB, INST0, TTNORM, PRIOR0, NULLP, watchDgRcvrActvTsk); + SAttachTTsk ( ENTHB, INST0, osCp.wdCp.watchDgRcvrTskId); +#endif /* SS_MULTIPLE_PROCS */ + +#ifndef SS_MULTIPLE_PROCS + osCp.wdCp.watchDgPst.srcProcId = SFndProcId(); + osCp.wdCp.watchDgPst.dstProcId = SFndProcId(); +#else + osCp.wdCp.watchDgPst.srcProcId = procId; + osCp.wdCp.watchDgPst.dstProcId = procId; +#endif /* SS_MULTIPLE_PROCS */ + + /* Initialise the pst structure */ + ssdInitWatchDgPst(&(osCp.wdCp.watchDgPst)); + /* Initialize the watch dog timer resolution default is 1 sec */ + + cmInitTimers(osCp.wdCp.watchDgTmr, (U8)1); + osCp.wdCp.watchDgTqCp.nxtEnt = 0; + osCp.wdCp.watchDgTqCp.tmrLen = 1; + for(idx = 0; idx < 1; idx++) + { + osCp.wdCp.watchDgTs[idx].first = NULLP; + osCp.wdCp.watchDgTs[idx].tail = NULLP; + } +#ifdef SS_MULTIPLE_PROCS + SRegCfgTmr(procId,ENTDW, INST0, 10, SS_100MS, ssdWatchDgActvTmr); +#else + SRegCfgTmr(ENTDW, INST0, 10, SS_100MS, ssdWatchDgActvTmr); +#endif /* SS_MULTIPLE_PROCS */ + + /* Create the watch dog receiver socket */ + osCp.wdCp.globWd.sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + if(osCp.wdCp.globWd.sock == -1) + { + sprintf(prntBuf,"ssdInitWatchDog: socket failed errno [%d]\n", errno); + SPrint(prntBuf); + } + +#ifdef SS_WATCHDOG_IPV6 + tmpaddr.sin6_len = sizeof(tmpadDr); + tmpaddr.sin6_family = AF_INET6; + tmpaddr.sin6_addr = in6addr_any; + tmpaddr.sin6_port = htons(port); +#else + tmpaddr.sin_family = AF_INET; + tmpaddr.sin_addr.s_addr = htonl(INADDR_ANY); + tmpaddr.sin_port = htons(port); +#endif /* SS_WATCHDOG_IPV6 */ + + if(bind(osCp.wdCp.globWd.sock, (struct sockaddr *)&tmpaddr, sizeof(struct sockaddr)) != 0 +) + { + sprintf(prntBuf,"ssdInitWatchDog: bind failed errno [%d]\n", errno); + SPrint(prntBuf); + } + + if (SGetMsg(SS_DFLT_REGION, SS_DFLT_POOL, &mBuf) != ROK) + { + RETVALUE(RFAILED); + } +#ifndef SS_MULTIPLE_PROCS + pst.srcProcId = SFndProcId(); + pst.dstProcId = SFndProcId(); +#else + pst.srcProcId = procId; + pst.dstProcId = procId; +#endif /* SS_MULTIPLE_PROCS */ + pst.event = EVTSSHRTBTREQ; + ssdInitWatchDgPst(&pst); + SPstTsk(&pst, mBuf); + + RETVALUE(ROK); +} + +#ifdef ANSI +PUBLIC S16 ssdInitWatchDgPst +( +Pst *pst +) +#else +PUBLIC S16 ssdInitWatchDgPst(pst) +Pst *pst; +#endif +{ + TRC1(ssInitWatchDgPst); + + pst->selector = SS_LOOSE_COUPLING; + + pst->region = DFLT_REGION; /* region */ + pst->pool = DFLT_POOL; /* pool */ + + pst->prior = PRIOR0; /* priority */ + pst->route = RTESPEC; /* route */ + + pst->dstEnt = ENTHB; /* destination entity */ + pst->dstInst = 0; + pst->srcEnt = ENTDW; /* source entity */ + pst->srcInst = 0; + + RETVALUE(ROK); +} + +#ifdef SS_MULTIPLE_PROCS +#ifdef ANSI +PUBLIC S16 ssdWatchDgActvTmr +( +ProcId proc, +Ent ent, +Inst inst +) +#else +PUBLIC S16 ssdWatchDgActvTmr(proc, ent, inst) +#endif +#else +#ifdef ANSI +PUBLIC S16 ssdWatchDgActvTmr +( +Void +) +#else +PUBLIC S16 ssdWatchDgActvTmr() +#endif +#endif /* SS_MULTIPLE_PROCS */ +{ + TRC3(ssWatchDgActvTmr); + + cmPrcTmr(&osCp.wdCp.watchDgTqCp, osCp.wdCp.watchDgTs, (PFV)ssdWatchDgTmrEvt); + + RETVALUE(ROK); +} + +#ifdef ANSI +PUBLIC Void ssdWatchDgTmrEvt +( +PTR cb, /* control block */ +S16 event /* timer number */ +) +#else +PUBLIC Void ssdWatchDgTmrEvt(cb, event) +PTR cb; /* control block */ +S16 event; /* timer number */ +#endif +{ +/* mt003.301 Fixed warings */ +#ifdef DEBUGP + DateTime dt; +#endif /* DEBUGP */ + Txt prntBuf[PRNTSZE]; + Bool restartTmr; + int i; + + TRC2(ssWatchDgTmrEvt); + + switch(event) + { + case SS_TMR_HRTBT: +#ifdef DEBUGP + SPrint("Timer Heartbeat Request Expired"); + SGetDateTime(&dt); + sprintf(prntBuf," Time: %02d:%02d:%02d\n",dt.hour,dt.min, dt.sec); + SPrint(prntBuf); +#endif + restartTmr=TRUE; + + SLock(&osCp.wdCp.wdLock); + for(i=0; i < osCp.wdCp.globWd.numNodes; i++) + { + if(osCp.wdCp.globWd.wdsta[i].status == 0) + { + sprintf(prntBuf, "Node [ %s ] Down. Calling user callback\n", inet_ntoa(osCp.wdCp.globWd.wdsta[i].addr)); + SPrint(prntBuf); + if(osCp.wdCp.globWd.callback != 0) + { + osCp.wdCp.globWd.callback(osCp.wdCp.globWd.data); + } + } + } + SUnlock(&osCp.wdCp.wdLock); + + if(!osCp.wdCp.globWd.watchdogStop) + { + ssdStartWatchDgTmr(NULLP, SS_TMR_HRTBT, osCp.wdCp.globWd.timeout); + ssdSndHrtBtMsg(restartTmr, SS_WD_HB_REQ); + } + break; + + default: + break; + } + +} + +#ifdef ANSI +PUBLIC Void ssdStartWatchDgTmr +( +void *cb, +S16 event, +U16 wait +) +#else +PUBLIC Void ssdStartWatchDgTmr(cb, event, wait) +void *cb; +S16 event; +U16 wait; +#endif +{ + CmTmrArg arg; + int i; +#ifdef DEBUGP + DateTime dt; + Txt prntBuf[PRNTSZE]; +#endif + + + TRC2(ssStartWatchDgTmr) + /* mt003.301 Modifications */ +#ifdef DEBUGP + SGetDateTime(&dt); + sprintf(prntBuf," Time: %02d:%02d:%02d\n",dt.hour,dt.min, dt.sec); + if(event == SS_TMR_HRTBT) + { + SPrint("\nSTART SS_TMR_HRTBT"); + SPrint(prntBuf); + } +#endif + + /* Re-init ACKs */ + + SLock(&osCp.wdCp.wdLock); + for(i=0; i < osCp.wdCp.globWd.numNodes; i++) + { + osCp.wdCp.globWd.wdsta[i].status = 0; + } + SUnlock(&osCp.wdCp.wdLock); + + arg.tq = osCp.wdCp.watchDgTs; + arg.tqCp = &osCp.wdCp.watchDgTqCp; + arg.timers = osCp.wdCp.watchDgTmr; + arg.cb = (PTR)NULLP; + arg.evnt = event; + arg.wait = osCp.wdCp.globWd.timeout = wait; + arg.tNum = NOTUSED; + arg.max = 1; + cmPlcCbTq(&arg); + + RETVOID; +} + +#ifdef ANSI +PUBLIC Void ssdStopWatchDgTmr +( +void *cb, +S16 event +) +#else +PUBLIC Void ssdStopWatchDgTmr(cb, event) +void *cb; +S16 event; +#endif +{ + CmTmrArg arg; +#ifdef DEBUGP + DateTime dt; + Txt prntBuf[PRNTSZE]; + int i; +#endif + + TRC2(ssStopWatchDgTmr) + /* mt003.301 Modifications */ +#ifdef DEBUGP + SGetDateTime(&dt); + sprintf(prntBuf," Time: %02d:%02d:%02d\n",dt.hour,dt.min, dt.sec); + if(event == SS_TMR_HRTBT) + { + SPrint("STOP SS_TMR_HRTBT"); + SPrint(prntBuf); + } + /* Re-init ACKs */ + SLock(&osCp.wdCp.wdLock); + for(i=0; i < osCp.wdCp.globWd.numNodes; i++) + { + osCp.wdCp.globWd.wdsta[i].status = 0; + } + SUnlock(&osCp.wdCp.wdLock); + +#endif + arg.tq = osCp.wdCp.watchDgTs; + arg.tqCp = &osCp.wdCp.watchDgTqCp; + arg.timers = osCp.wdCp.watchDgTmr; + arg.cb = (PTR)NULLP; + arg.evnt = event; + arg.wait = NOTUSED; + arg.tNum = NOTUSED; + arg.max = 1; + cmRmvCbTq(&arg); + + RETVOID; +} + +#ifdef ANSI +PUBLIC S16 ssdSndHrtBtMsg +( +Bool restart, +U32 type +) +#else +PUBLIC S16 ssdSndHrtBtMsg(restart, type) +Bool restart; +U32 type; +#endif +{ + S16 ret = ROK; +#ifdef DEBUGP + DateTime dt; + Txt prntBuf[PRNTSZE]; +#endif + struct sockaddr_in tmpaddr; + char hbMsg[SS_WD_HB_MSG_SIZE]; + int n; + int err; + + TRC2(ssdSndHrtBtReq) + +#ifdef DEBUGP + SGetDateTime(&dt); + sprintf(prntBuf,"TX HEARTBEAT REQ Time: %02d:%02d:%02d\n", dt.hour, dt.min, dt.sec); + SPrint(prntBuf); +#endif + + /* Pack the message */ + strcpy(hbMsg, "REQ"); + + /* Send the heartbeat messages to all the configured nodes */ + SLock(&osCp.wdCp.wdLock); + for (n=0; n < osCp.wdCp.globWd.numNodes; n++) + { + if(osCp.wdCp.globWd.wdsta[n].addr.s_addr == 0) + { + continue; + } + + /* Identify the destination node */ +#ifdef SS_WATCHDOG_IPV6 + tmpaddr.sin6_len = sizeof(tmpaddr); + tmpaddr.sin6_family = AF_INET6; + tmpaddr.sin6_addr = osCp.wdCp.globWd.wdsta[n].addr; + tmpaddr.sin_port = osCp.wdCp.globWd.wdsta[n].port; +#else + tmpaddr.sin_family = AF_INET; + tmpaddr.sin_addr.s_addr = osCp.wdCp.globWd.wdsta[n].addr.s_addr; + tmpaddr.sin_port = osCp.wdCp.globWd.wdsta[n].port; +#endif /* SS_WATCHDOG_IPV6 */ + + err = sendto(osCp.wdCp.globWd.sock, hbMsg, strlen(hbMsg), 0, (struct sockaddr *)&tmpaddr, sizeof(struct sockaddr)); + if(err == -1) + { +#ifdef DEBUGP + sprintf(prntBuf,"ssdSndHrtBtMsg: HB to node [%s:%d] failed status[%d]\n", + inet_ntoa(tmpaddr.sin_addr), tmpaddr.sin_port, errno); + SPrint(prntBuf); +#endif /* DEBUGP */ + } + else + { +#ifdef DEBUGP + sprintf(prntBuf,"ssdSndHrtBtMsg: HB to node [%s:%d] sent[%d]\n", inet_ntoa(tmpaddr.sin_addr), tmpaddr.sin_port, err); + SPrint(prntBuf); +#endif /* DEBUGP */ + } + } + SUnlock(&osCp.wdCp.wdLock); + + RETVALUE(ret); +} + +#endif /* SS_WATCHDOG */ + + + +/* mt022.201 - Modification to fix problem when NOCMDLINE is defined */ +#ifndef NOCMDLINE +/* +* +* Fun: mtGetOpts +* +* Desc: This function gets command line options. +* +* Ret: +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PRIVATE Void mtGetOpts +( +void +) +#else +PRIVATE Void mtGetOpts() +#endif +{ + S32 argc; + S8 **argv; + S16 ret; + /* mt028.201 */ +#ifndef NOFILESYS + FILE *memOpt; /* memory options file pointer */ + Txt pBuf[128]; + U8 i; +/* mt007.301 : Fix related to file based mem config on 64 bit machine */ + PTR numReg; + PTR numBkts; + PTR bktSz = NULLP; + PTR heapSz=0; + PTR bktNum; + /*KWORK_FIX: Initializing the variable for avoidning corruption */ + PTR bktIdx = 0; + /*mt010.301 Fix for reading the variables on 64 bit/32bit platforms correctly */ + PTR bktUpdtCnt = 0; + PTR regUpdtCnt = 0; + PTR regId; + PTR numPools; + PTR poolIdx; +#ifdef SS_LOCKLESS_MEMORY + PTR bktSetSize; + PTR bktRelThr; + PTR bktAqurThr; +#endif + Txt line[256]; + Bool error = FALSE; + Cntr idx=0; +#endif + + TRC0(mtGetOpts); + + + msOptInd = 1; + +#ifndef NOFILESYS + osCp.dep.fileOutFp = (FILE *)NULLP; + + /* initialize memOpt */ + memOpt = (FILE *) NULLP; +#endif + + argc = msArgc; + argv = msArgv; + + /* mt028.201 */ + while ((ret = SGetOpt(argc, argv, "o:f:s:m:c:")) != EOF) + { + switch (ret) + { +#ifndef NOFILESYS +/* mt001.301 : Additions */ +#ifdef SS_MEM_LEAK_STS + case 'm': + cmMemOpenMemLkFile(msOptArg); + break; +#endif + case 'o': + osCp.dep.fileOutFp = fopen(msOptArg, "w"); + break; + case 'f': + fileBasedMemCfg = TRUE; + memOpt = fopen(msOptArg, "r"); + + /* if file does not exist or could not be opened then use the + * default memory configuration as defined in mt_ss.h + */ + if (memOpt == (FILE *) NULLP) + { + sprintf(pBuf, "\nMTSS: Memory configuration file: %s could not\ + be opened, using default mem configuration\n", msOptArg); + SPrint(pBuf); + break; + } + i = 0; + while (fgets((Txt *)line, 256, memOpt) != NULLP) + { + if(line[0] == '#' || line[0] < '0' || line[0] > '9') /* Comment line or non numeric character, so skip it and read next line */ + continue; + if(error == TRUE) + break; + switch (i) + { + case 0: /*** INPUT: Number of regions ***/ + sscanf(line, "%ld", (long *) &numReg); + mtMemoCfg.numRegions = numReg; + if(mtMemoCfg.numRegions > SS_MAX_REGS) + { + printf("\n No. of regions are > SS_MAX_REGS:%d \n",SS_MAX_REGS); + error = TRUE; + break; + } + i++; + break; + case 1: /*** INPUT: Number of buckets and number of Pools ***/ + sscanf(line, "%ld %ld", (long *) &numBkts, (long *) &numPools); + if(numBkts > MT_MAX_BKTS) + { + printf("\n No. of buckets are > MT_MAX_BKTS :%d \n",MT_MAX_BKTS); + error = TRUE; + break; + } + if(numPools > SS_MAX_POOLS_PER_REG) + { + printf("\n No. of pools are > SS_MAX_POOLS_PER_REG:%d \n",SS_MAX_POOLS_PER_REG); + error = TRUE; + break; + } + /* + * Delay updation from local variable to global + * structure of number of regions and heap data to + * counter error conditions present above. + */ + for(idx = 0; idx < cfgNumRegs; idx++) + { + mtMemoCfg.region[idx].numBkts = numBkts; + cfgRegInfo[idx].region = idx; + cfgRegInfo[idx].numPools = numPools; + /* + * Initialize the pool info as static type with size zero + */ + for(poolIdx = 0; poolIdx < numPools; poolIdx++) + { + cfgRegInfo[idx].pools[poolIdx].type = SS_POOL_STATIC; + cfgRegInfo[idx].pools[poolIdx].size = 0; + } + } + i++; + break; + case 2: /*** INPUT: Bucket Id and size of the bucket ***/ + if(bktUpdtCnt < numBkts) /* more set of bucket can be added */ + { + sscanf(line, "%ld %ld",(long *)&bktIdx, (long *) &bktSz); + } + if(bktIdx >= numBkts) + { + printf("\n Invalid Bucket Id, may be >= the No. of buckets:%ld\n",numBkts); + error = TRUE; + break; + + } + mtBktInfo[bktIdx].blkSize = bktSz; + bktUpdtCnt++; + if(bktUpdtCnt == numBkts) + { + i++; /*done reading bkt info, start reading individual region info*/ + bktUpdtCnt = 0; + } + break; + case 3: /*** INPUT: Region Id (ranges from 0 to numRegions-1) **/ + sscanf(line,"%ld",(long *) ®Id); + if(regId >= mtMemoCfg.numRegions) + { + printf("\n Invalid Region Id, may be >= the No. of regions:%d\n",mtMemoCfg.numRegions); +#ifndef XEON_SPECIFIC_CHANGES + error = TRUE; +#endif + break; + } + mtMemoCfg.region[regId].regionId = regId; + i++; + break; + case 4: /*** INPUT: BktId (ranges from 0 to numBkts-1), No. of blks ***/ + if(bktUpdtCnt < numBkts) + { + sscanf(line, "%ld %ld",(long *)&bktIdx, (long *)&bktNum); + if(bktIdx >= numBkts) + { + printf("\n Invalid Bucket Id, may be >= the No. of buckets:%ld\n",numBkts); + error = TRUE; + break; + + } + if(bktIdx < MT_MAX_BKTS) + { + mtMemoCfg.region[regId].bkt[bktIdx].blkSize = mtBktInfo[bktIdx].blkSize; + mtMemoCfg.region[regId].bkt[bktIdx].numBlks = bktNum; + cfgRegInfo[regId].pools[bktIdx].type = SS_POOL_DYNAMIC; + cfgRegInfo[regId].pools[bktIdx].size = mtBktInfo[bktIdx].blkSize - (sizeof(SsMblk)+sizeof(SsDblk)); + } + bktUpdtCnt++; + if(bktUpdtCnt == numBkts) + { + i++; + bktUpdtCnt = 0; + } + } + break; + case 5: /* INPUT: Heapsize ***/ + sscanf(line, "%ld", (long *) &heapSz); + mtMemoCfg.region[regId].heapsize = heapSz; + regUpdtCnt++; + if(regUpdtCnt != mtMemoCfg.numRegions) + { + i = 3; + } + else + { + i++; + } + break; +#ifdef SS_LOCKLESS_MEMORY + case 6: + sscanf(line, "%ld", (long *) &numBkts); + mtGlobMemoCfg.numBkts = numBkts; +#ifndef XEON_SPECIFIC_CHANGES + mtDynMemoCfg.numRegions = mtMemoCfg.numRegions; +#endif + +#ifdef XEON_SPECIFIC_CHANGES + CM_LOG_DEBUG(CM_LOG_ID_MT, "numRegions = %d numBkts = %d\n", + mtDynMemoCfg.numRegions, mtGlobMemoCfg.numBkts); + for(idx = 0; idx < mtDynMemoCfg.numRegions; idx++) +#else + for(idx = 0; idx < mtMemoCfg.numRegions; idx++) +#endif + { + mtDynMemoCfg.region[idx].regionId = idx; + mtDynMemoCfg.region[idx].numBkts = numBkts; + } + + bktUpdtCnt = 0; + i++; + break; + + case 7: + if(bktUpdtCnt < numBkts) + { + sscanf(line, "%ld %ld %ld %ld %ld %ld", (long *) &bktIdx, + (long *) &bktSz, (long *) &bktNum, + (long *) &bktSetSize, (long *) &bktRelThr, + (long *) &bktAqurThr); + /* Klock work fix ccpu00148484 */ + if(bktIdx < SS_MAX_POOLS_PER_REG) + { + mtGlobMemoCfg.bkt[bktIdx].blkSize = bktSz; + mtGlobMemoCfg.bkt[bktIdx].numBlks = bktNum; + mtGlobMemoCfg.bkt[bktIdx].bucketSetSize = bktSetSize; +#ifdef XEON_SPECIFIC_CHANGES + CM_LOG_DEBUG(CM_LOG_ID_MT, "Pool [%d] blkSize %d numBlks %d bucketSetSize %d\n", + bktUpdtCnt, mtGlobMemoCfg.bkt[bktIdx].blkSize, + mtGlobMemoCfg.bkt[bktIdx].numBlks, mtGlobMemoCfg.bkt[bktIdx].bucketSetSize); + + if(bktIdx >= SS_MAX_POOLS_PER_REG) + { + printf("\nNo. of Buckets/pools are > SS_MAX_POOLS_PER_REG:%d\n",SS_MAX_POOLS_PER_REG); + error = TRUE; + break; + } + +#endif + for(idx = 0; idx < mtMemoCfg.numRegions; idx++) + { + mtDynMemoCfg.region[idx].bkt[bktIdx].blkSetRelThreshold = bktRelThr; + mtDynMemoCfg.region[idx].bkt[bktIdx].blkSetAcquireThreshold = bktAqurThr; +#ifdef XEON_SPECIFIC_CHANGES + CM_LOG_DEBUG(CM_LOG_ID_MT, "Pool [%d] blkSetRelThreshold %d blkSetAcquireThreshold %d\n", + bktUpdtCnt, mtDynMemoCfg.region[idx].bkt[bktIdx].blkSetRelThreshold, + mtDynMemoCfg.region[idx].bkt[bktIdx].blkSetAcquireThreshold); +#endif + } + } + bktUpdtCnt++; + } +#ifdef XEON_SPECIFIC_CHANGES + if(bktUpdtCnt == numBkts) + { + i=8; + } + break; + + case 8: /* INPUT: Global Heapsize ***/ + sscanf(line, "%ld", (long *) &heapSz); + mtGlobMemoCfg.heapSize = heapSz; + CM_LOG_DEBUG(CM_LOG_ID_MT, "Global Heap size = %d\n", mtGlobMemoCfg.heapSize); +#endif + break; +#endif + } + } + if(error == TRUE) + { + memConfigured = FALSE; + } + else + { + memConfigured = TRUE; + } + fclose (memOpt); + break; +#endif + + + case 's': +/* mt028.201: modification: multiple procs support related changes */ +#ifndef SS_MULTIPLE_PROCS + +#ifdef ENB_RELAY + osCp.procId = PID_STK((ProcId) strtol(msOptArg, NULLP, 0)); +#else + osCp.procId = (ProcId) strtol(msOptArg, NULLP, 0); +#endif + +#else /* SS_MULTIPLE_PROCS */ + { + ProcId procId; +#ifdef ENB_RELAY + procId = PID_STK((ProcId) strtol(msOptArg, NULLP, 0)); +#else + procId = (ProcId) strtol(msOptArg, NULLP, 0); +#endif + SAddProcIdLst(1, &procId); + } + +#endif /* SS_MULTIPLE_PROCS */ + break; + + case 'c': + osCp.configFilePath = msOptArg; + break; + + case '?': + /* fall through */ + + + default: + break; + } + } + + msOptInd = 1; + + + RETVOID; +} +#endif + + +/* +* +* Fun: SGetOpt +* +* Desc: Get options from command line +* +* Ret: option - success +* '?' - fail +* EOF - end of options +* +* Notes: Handles command lines like the following +* +* if opts = "abc:d" +* then command line should look like this... +* -a foo -b foo1 -c -d foo +* +* code usage: +* +* while ((ret = SGetOpt(msArgc, msArgv, "ls")) != EOF ) +* { +* switch(ret) +* { +* case 'l': +* nloops = atoi(msArgv[msOptInd]); +* break; +* case 's': +* state1 = atoi(msArgv[msOptInd]); +* case '?': +* default: +* break; +* } +* } +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 SGetOpt +( +int argc, /* argument count */ +char **argv, /* argument value */ +char *opts /* options */ +) +#else +PUBLIC S16 SGetOpt(argc, argv, opts) +int argc; /* argument count */ +char **argv; /* argument value */ +char *opts; /* options */ +#endif +{ + /* mt020.201 - Removed for no command line */ +#ifndef NOCMDLINE + S16 sp; + S16 c; + S8 *cp; +#endif + + TRC1(SGetOpt); + + /* mt020.201 - Addition for no command line */ +#ifdef NOCMDLINE + UNUSED(argc); + UNUSED(argv); + UNUSED(opts); + + RETVALUE(EOF); +#else + + sp = 1; + if (sp == 1) + { + /*mt013.301 : Changes as per coding standards*/ + if (msOptInd >= (S16) argc || argv[msOptInd][0] == '\0') + { + RETVALUE(EOF); + } + else + { + if (!strcmp(argv[msOptInd], "--")) + { + msOptInd++; + RETVALUE(EOF); + } + else if (argv[msOptInd][0] != '-') + { + msOptInd++; + RETVALUE('?'); + } + } + } + + c = argv[msOptInd][sp]; + if (c == ':' || (cp = (S8 *) strchr(opts, c)) == (S8 *) NULLP) + { + if (argv[msOptInd][++sp] == '\0') + { + msOptInd++; + sp = 1; + } + + RETVALUE('?'); + } + + if (*++cp == ':') + { + if (argv[msOptInd][sp+1] != '\0') msOptArg = &argv[msOptInd++][sp+1]; + else + { + if (++msOptInd >= (S16) argc) + { + sp = 1; + RETVALUE('?'); + } + else msOptArg = argv[msOptInd++]; + + sp = 1; + } + } + else + { + if (argv[msOptInd][++sp] == '\0') + { + sp = 1; + msOptInd++; + } + + msOptArg = NULLP; + } + + + RETVALUE(c); + +#endif /* NOCMDLINE */ +} + + +/* +* +* Fun: ssdStart +* +* Desc: This function starts system services execution; the +* permanent tasks are started and the system enters a +* ready state. +* +* Ret: Void +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC Void ssdStart +( +void +) +#else +PUBLIC Void ssdStart() +#endif +{ + S16 i; + + + TRC0(ssdStart); + + + /* mt025.201 - Modification for adding lock to timer handler */ + for (i = 0; i <= SS_MAX_STSKS + 5; i++) + { + sem_post(&osCp.dep.ssStarted); + } + + + RETVOID; +} + + +/* +* indirect interface functions to system services service user +*/ + + +/* +* +* Fun: ssdAttachTTsk +* +* Desc: This function sends the initial tick message to a TAPA +* task if the task is a permanent task. +* +* Ret: ROK - ok +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 ssdAttachTTsk +( +SsTTskEntry *tTsk /* pointer to TAPA task entry */ +) +#else +PUBLIC S16 ssdAttachTTsk(tTsk) +SsTTskEntry *tTsk; /* pointer to TAPA task entry */ +#endif +{ + Buffer *mBuf; + SsMsgInfo *mInfo; + S16 ret; + + + TRC0(ssdAttachTTsk); + + + if (tTsk->tskType == SS_TSK_PERMANENT) + { + /* Send a permanent tick message to this task, to start + * execution. + */ + ret = SGetMsg(SS_DFLT_REGION, SS_DFLT_POOL, &mBuf); + if (ret != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMT001, ret, "SGetMsg() failed"); +#endif + RETVALUE(RFAILED); + } + + mInfo = (SsMsgInfo *)mBuf->b_rptr; + mInfo->eventInfo.event = SS_EVNT_PERMTICK; + + /* set up post structure */ +/* mt028.201: modification: multiple procs support related changes */ +#ifndef SS_MULTIPLE_PROCS + mInfo->pst.dstProcId = SFndProcId(); + mInfo->pst.srcProcId = SFndProcId(); +#else /* SS_MULTIPLE_PROCS */ + mInfo->pst.dstProcId = tTsk->proc; + mInfo->pst.srcProcId = tTsk->proc; +#endif /* SS_MULTIPLE_PROCS */ + mInfo->pst.selector = SEL_LC_NEW; + mInfo->pst.region = DFLT_REGION; + mInfo->pst.pool = DFLT_POOL; + mInfo->pst.prior = PRIOR3; + mInfo->pst.route = RTESPEC; + mInfo->pst.event = 0; + mInfo->pst.dstEnt = tTsk->ent; + mInfo->pst.dstInst = tTsk->inst; + mInfo->pst.srcEnt = tTsk->ent; + mInfo->pst.srcInst = tTsk->inst; + + ret = ssDmndQPutLast(&tTsk->sTsk->dQ, mBuf, + (tTsk->tskPrior * SS_MAX_MSG_PRI) + PRIOR3); + + if (ret != ROK) + { + SPutMsg(mBuf); + +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMT002, ret, + "Could not write to demand queue"); +#endif + RETVALUE(RFAILED); + } + } + + + RETVALUE(ROK); +} + + +/* +* +* Fun: ssdDetachTTsk +* +* Desc: Does nothing. +* +* Ret: ROK - ok +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 ssdDetachTTsk +( +SsTTskEntry *tTsk /* pointer to TAPA task entry */ +) +#else +PUBLIC S16 ssdDetachTTsk(tTsk) +SsTTskEntry *tTsk; /* pointer to TAPA task entry */ +#endif +{ + TRC0(ssdDetachTTsk); + + + RETVALUE(ROK); +} + + +/* +* +* Fun: ssdCreateSTsk +* +* Desc: This function creates a system task. A thread is started +* on the system task handler function defined later. +* +* Ret: ROK - ok +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 ssdCreateSTsk +( +SsSTskEntry *sTsk /* pointer to system task entry */ +) +#else +PUBLIC S16 ssdCreateSTsk(sTsk) +SsSTskEntry *sTsk; /* pointer to system task entry */ +#endif +{ + pthread_attr_t attr; + /* struct sched_param param_sched;*/ + +#ifdef SS_THR_REG_MAP + U32 threadCreated = FALSE; +#endif + + TRC0(ssdCreateSTsk); + + +#ifdef SS_SINGLE_THREADED +/* mt001.301 : Additions */ +#ifndef SS_WATCHDOG +#ifdef SS_MULTICORE_SUPPORT + if (osCp.numSTsks > 1) +#else + if (osCp.numSTsks > 0) +#endif /* SS_MULTICORE_SUPPORT */ +#else +#ifdef SS_MULTICORE_SUPPORT + if (osCp.numSTsks > 3) +#else + if (osCp.numSTsks > 2) +#endif /* SS_MULTICORE_SUPPORT */ +#endif /* SS_WATCHDOG */ + { + RETVALUE(ROK); + } +#endif + + + /* set the current executing entity and instance IDs to + * 'not configured'. create the lock to access them. + */ + sTsk->dep.ent = ENTNC; + sTsk->dep.inst = INSTNC; + + + /* create the thread */ + pthread_attr_init(&attr); + ssdSetPthreadAttr(sTsk->tskPrior, &attr); + + printf("Creating thread here %s %d\n", __FILE__, __LINE__); +#ifdef TENB_T2K3K_SPECIFIC_CHANGES + if (sTsk->tskPrior == 0) + { + printf("Creating RT thread #######################\n"); +#ifdef SS_THR_REG_MAP + /* When the thread is created, we check for the memory mapping table if + * threadId can be placed in thread memory map table. If it is not able to place + * threadId is stored in tmporary array. Once thread is created successful, + * thread_cancel is sent for each thread which are created before. All the + * threads are made to wait on sema which is cancel point for thread. + */ + while(threadCreated == FALSE) + { +#endif + if ((pthread_create(&sTsk->dep.tId, &attr, mtTskHdlrT2kL2, (Ptr)sTsk)) != 0) + { + + pthread_attr_destroy(&attr); + +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMT004, ERRZERO, "Could not create thread"); +#endif + + RETVALUE(RFAILED); + } +#ifdef SS_THR_REG_MAP + threadCreated = ssCheckAndAddMemoryRegionMap(sTsk->dep.tId, + sTsk->region); + } +#endif + } + else +#endif + { +#ifdef SS_THR_REG_MAP + /* When the thread is created, we check for the memory mapping table if + * threadId can be placed in thread memory map table. If it is not able to place + * threadId is stored in tmporary array. Once thread is created successful, + * thread_cancel is sent for each thread which are created before. All the + * threads are made to wait on sema which is cancel point for thread. + */ + while(threadCreated == FALSE) + { +#endif + if ((pthread_create(&sTsk->dep.tId, &attr, mtTskHdlr, (Ptr)sTsk)) != 0) + { + + /* mt020.201 - Addition for destroying thread attribute object attr */ + pthread_attr_destroy(&attr); + +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMT004, ERRZERO, "Could not create thread"); +#endif + + RETVALUE(RFAILED); + } +#ifdef SS_THR_REG_MAP + threadCreated = ssCheckAndAddMemoryRegionMap(sTsk->dep.tId, + sTsk->region); + } +#endif + } + + +/*mt013.301 :Added SS_AFFINITY_SUPPORT */ +#if defined(SS_MULTICORE_SUPPORT) ||defined(SS_AFFINITY_SUPPORT) + { + static U32 stLwpId = 3; + sTsk->dep.lwpId = ++stLwpId; + } +#endif /* SS_MULTICORE_SUPPORT || SS_AFFINITY_SUPPORT */ + + /* mt020.201 - Addition for destroying thread attribute object attr */ + pthread_attr_destroy(&attr); + + RETVALUE(ROK); +} + + +#ifdef ANSI +PUBLIC int SCreatePThread +( +pthread_t* tid, +pthread_attr_t* attr, +void *(*start_routine) (void *), +void* arg +) +#else +PUBLIC int SCreatePThread(tid, attr, start_routine, arg) +pthread_t* tid; +pthread_attr_t* attr; +void *(*start_routine) (void *); +void* arg; +#endif +{ + int retVal = 0; +#ifdef SS_THR_REG_MAP + U32 threadCreated = FALSE; +#endif + + SPThreadCreateArg* threadArg = (SPThreadCreateArg*)malloc(sizeof(SPThreadCreateArg)); + /* Klock work fix ccpu00148484 */ + if(threadArg == NULLP) + { + RETVALUE(RFAILED); + } + threadArg->argument = arg; + threadArg->start_routine = start_routine; + + TRC0(SCreatePThread); + + printf("Creating thread here %s %d\n", __FILE__, __LINE__); + { +#ifdef SS_THR_REG_MAP + /* When the thread is created, we check for the memory mapping table if + * threadId can be placed in thread memory map table. If it is not able to place + * threadId is stored in tmporary array. Once thread is created successful, + * thread_cancel is sent for each thread which are created before. All the + * threads are made to wait on sema which is cancel point for thread. + */ + while(threadCreated == FALSE) + { +#endif + /*pthreadCreateHdlr */ + if (((retVal = pthread_create(tid, attr, pthreadCreateHdlr, threadArg))) != 0) + { + + RETVALUE(retVal); + } +#ifdef SS_THR_REG_MAP + threadCreated = ssCheckAndAddMemoryRegionMap(*tid, SS_MAX_REGS - 1); + } +#endif + } + + RETVALUE(retVal); +} + + +/* +* +* Fun: Set Pthread Attributes +* +* Desc: This function is used to set various explicit +* pthread attributes like, priority scheduling,etc +* +* Ret: ROK - ok +* +* Notes: +* +* File: mt_ss.c +* +*/ + +#ifdef ANSI +PRIVATE S16 ssdSetPthreadAttr +( +S32 tskPrior, +pthread_attr_t *attr +) +#else +PRIVATE S16 ssdSetPthreadAttr(sTsk, attr) +S32 tskPrior, +pthread_attr_t *attr +#endif +{ + struct sched_param param; + + TRC0 (ssdSetPthreadAttr) + + SMemSet(¶m, 0, sizeof(param)); + +#ifndef TENB_T2K3K_SPECIFIC_CHANGES + param.sched_priority = 100 - 1 - tskPrior; +#else + param.sched_priority = 100 - 10 - tskPrior; +#endif + +#if 1/* Nawas:: Overriding DL RLC prority to one higher than iccserv */ + /* TODO:: This can be avoided by reducing the priority + * of iccserv thread in l1_master.sh*/ +#ifdef L2_L3_SPLIT + if (clusterMode == RADIO_CLUSTER_MODE) + { + if(tskPrior == PRIOR1) + {/* DL RLC */ + param.sched_priority = 91; + } + } + +#endif +#endif + + printf("Set priority %u\n", param.sched_priority); + + /* Set Scheduler to explicit, without this non of the below + pthread attr works */ +#ifdef TENB_RTLIN_CHANGES + pthread_attr_setinheritsched(attr, PTHREAD_EXPLICIT_SCHED); +#endif + + pthread_attr_setstacksize(attr, (size_t)MT_TASK_STACK); + pthread_attr_setscope(attr, PTHREAD_SCOPE_SYSTEM); + pthread_attr_setdetachstate(attr, PTHREAD_CREATE_DETACHED); +#ifdef TENB_RTLIN_CHANGES + pthread_attr_setschedpolicy(attr, SCHED_FIFO); +#endif + pthread_attr_setschedparam(attr, ¶m); + + RETVALUE (ROK); + +} /* ssdSetPthreadAttr */ + +/************* multi-core support **************/ +/*mt013.301 :Added SS_AFFINITY_SUPPORT */ +#if defined(SS_MULTICORE_SUPPORT) ||defined(SS_AFFINITY_SUPPORT) + +/* +* +* Fun: Get the current core/cpu affinity for a thread/lwp +* +* Desc: This function is used to get the current processor/core +* affinity for a a system task (thread/lwp). It sets the +* affinity based on the mode supplied by the caller. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: +* +* File: ss_task.c +* +*/ +#ifdef ANSI +PUBLIC S16 ssdGetAffinity +( +SSTskId *tskId, /* filled in with system task ID */ +U32 *coreId /* the core/processor id to which the affinity is set */ +) +#else +PUBLIC S16 ssdGetAffinity(tskId, coreId) +SSTskId *tskId; /* filled in with system task ID */ +U32 *coreId; /* the core/processor id to which the affinity is set */ +#endif +{ + + U32 tskInd; + +#ifdef SS_LINUX + + pthread_t tId =0; + cpu_set_t cpuSet; + U32 cpuInd = 0; + /*mt013.301 :Fix for TRACE5 feature crash due to missing TRC MACRO*/ +#else +#ifdef SUNOS + U32 lwpId = *tskId; +#endif /*SUNOS*/ +#endif /*SS_LINUX*/ + TRC0(ssdGetAffinity); +#ifdef SS_LINUX + for (tskInd = 0; tskInd < SS_MAX_STSKS; tskInd++) + { + if (osCp.sTskTbl[tskInd].tskId == *tskId) + { + tId = osCp.sTskTbl[tskInd].dep.tId; + break; + } /* end if */ + } /* end for */ + + /* if tskId is not found in the tskTbl */ + if (tskInd == SS_MAX_STSKS) + { + MTLOGERROR(ERRCLS_DEBUG, EMT036, ERRZERO, "Invalid system task Id\n"); + RETVALUE(RFAILED); + } + + + /* initialize the cpu mask */ + CPU_ZERO( &cpuSet); + + /* set thread affinity for linux */ + if (pthread_getaffinity_np(tId, sizeof(cpuSet), &cpuSet) < 0) + { +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMT037, ERRZERO, "Could not get thread affinity\n"); +#endif + RETVALUE(RFAILED); + } /* end if pthread_setaffinity fails */ + + for (cpuInd = 0; cpuInd b_rptr; + mInfo->eventInfo.event = SS_EVNT_TERM; + + if (ssDmndQPutLast(&sTsk->dQ, mBuf, 0) != ROK) + { + SPutMsg(mBuf); + +#if (ERRCLASS & ERRCLASS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMT006, ERRZERO, + "Could not write to demand queue"); +#endif + + RETVALUE(RFAILED); + } + + + RETVALUE(ROK); +} + +/* mt023.201 - Added SThreadYield function to yield CPU +* +* Fun: SThreadYield +* +* Desc: This function defers thread execution to any other ready +* thread. +* +* Ret: ROK - ok +* RFAILED - failure +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 SThreadYield +( +void +) +#else +PUBLIC S16 SThreadYield() +#endif +{ + + TRC0(SThreadYield); + +/* mt024.201 - seperated Linux and other UNIX implementations + */ +#ifdef SS_LINUX + { + struct timeval tw; + + /* Set sleep value to 0 to yield CPU */ + tw.tv_sec=0; + tw.tv_usec=0; + + RETVALUE(select(0,0,0,0,&tw) == 0 ? ROK : RFAILED); + } +#else /* other UNICes */ + + RETVALUE(sleep(0) == 0 ? ROK : RFAILED); + +#endif /* SS_LINUX */ + +} + + +/* +* +* Fun: Register timer +* +* Desc: This function is used to register a timer +* function for the service user. System services +* will invoke the timer activation function +* passed to it at the specified intervals. +* +* Ret: ROK - ok +* +* Notes: Timing is handled by the common timers. The +* ticks are handled by a thread that uses +* nanosleep() and thus timing precision will not +* be very accurate. +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 ssdRegTmr +( +SsTmrEntry *tmr /* pointer to timer entry */ +) +#else +PUBLIC S16 ssdRegTmr(tmr) +SsTmrEntry *tmr; /* pointer to timer entry */ +#endif +{ + CmTmrArg arg; + + + TRC0(ssdRegTmr); + + + /* initialize common timers */ + cmInitTimers(tmr->dep.timers, TMR_DEF_MAX); + + + /* start the timer */ + arg.tq = osCp.dep.tmrTq; + arg.tqCp = &osCp.dep.tmrTqCp; + arg.timers = tmr->dep.timers; + arg.cb = (PTR) tmr; + arg.evnt = TMR_DEF; + arg.wait = 0; + arg.tNum = NOTUSED; + arg.max = TMR_DEF_MAX; + arg.wait = tmr->interval; + cmPlcCbTq(&arg); + + + RETVALUE(ROK); +} + + +/* +* +* Fun: Deregister timer +* +* Desc: This function is used to deregister a timer function. +* +* Ret: ROK - ok +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 ssdDeregTmr +( +SsTmrEntry *tmr /* pointer to timer entry */ +) +#else +PUBLIC S16 ssdDeregTmr(tmr) +SsTmrEntry *tmr; /* pointer to timer entry */ +#endif +{ + CmTmrArg arg; + + + TRC0(ssdDeregTmr); + + + /* stop the timer */ + arg.tq = osCp.dep.tmrTq; + arg.tqCp = &osCp.dep.tmrTqCp; + arg.timers = tmr->dep.timers; + arg.cb = (PTR) tmr; + arg.evnt = TMR_DEF; + arg.wait = 0; + arg.tNum = NOTUSED; + arg.max = TMR_DEF_MAX; + arg.wait = tmr->interval; + cmRmvCbTq(&arg); + + + RETVALUE(ROK); +} + + +/* +* +* Fun: Critical error +* +* Desc: This function is called when a critical error occurs. +* +* Ret: ROK - ok +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 ssdError +( +Seq seq, /* sequence number */ +Reason reason /* reset reason */ +) +#else +PUBLIC S16 ssdError(seq, reason) +Seq seq; /* sequence number */ +Reason reason; /* reset reason */ +#endif +{ + S16 i; + pthread_t tId; + Txt errBuf[256]; + + + TRC0(ssdError); + + + /* get calling task ID */ + tId = pthread_self(); + + + /* set up the message to display */ + sprintf(errBuf, "\n\nFATAL ERROR - taskid = %x, errno = %d," + "reason = %d\n\n", (U8)tId, seq, reason); + SPrint(errBuf); + + + /* delete all system tasks */ + for (i = 0; i < SS_MAX_STSKS; i++) + { + if (osCp.sTskTbl[i].used + && !pthread_equal(osCp.sTskTbl[i].dep.tId, tId)) + { + pthread_kill(osCp.sTskTbl[i].dep.tId, SIGKILL); + } + } + + + /* delete self */ + pthread_exit(NULLP); + + + /* won't reach here */ + RETVALUE(ROK); +} + + +/* +* +* Fun: Log error +* +* Desc: This function is called to log an error. +* +* Ret: ROK - ok +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC Void ssdLogError +( +Ent ent, /* Calling layer's entity id */ +Inst inst, /* Calling layer's instance id */ +ProcId procId, /* Calling layer's processor id */ +Txt *file, /* file name where error occured */ +S32 line, /* line in file where error occured */ +ErrCls errCls, /* error class */ +ErrCode errCode, /* layer unique error code */ +ErrVal errVal, /* error value */ +Txt *errDesc /* description of error */ +) +#else +PUBLIC Void ssdLogError(ent, inst, procId, file, line, + errCls, errCode, errVal, errDesc) +Ent ent; /* Calling layer's entity id */ +Inst inst; /* Calling layer's instance id */ +ProcId procId; /* Calling layer's processor id */ +Txt *file; /* file name where error occured */ +S32 line; /* line in file where error occured */ +ErrCls errCls; /* error class */ +ErrCode errCode; /* layer unique error code */ +ErrVal errVal; /* error value */ +Txt *errDesc; /* description of error */ +#endif +{ +#ifndef DEBUGNOEXIT + S16 i; + pthread_t tId; +#endif + Txt *errClsMsg; + Txt errBuf[512]; + + + TRC0(ssdLogError); + + + /* get calling task ID */ +#ifndef DEBUGNOEXIT + tId = pthread_self(); +#endif + + + switch(errCls) + { + case ERRCLS_ADD_RES: + errClsMsg = "ERRCLS_ADD_RES"; + break; + + case ERRCLS_INT_PAR: + errClsMsg = "ERRCLS_INT_PAR"; + break; + + case ERRCLS_DEBUG: + errClsMsg = "ERRCLS_DEBUG"; + break; + +/* mt028.201 : Addition - ERRCLS_FTHA changes */ + case ERRCLS_FTHA: + errClsMsg = "ERRCLS_FTHA"; + break; + + default: + errClsMsg = "INVALID ERROR CLASS!"; + break; + } + + +/*mt009.301 Fixed 64BIT compilation warnings*/ +#ifdef ALIGN_64BIT + sprintf(errBuf, + "\nmtss(posix): sw error: ent: %03d inst: %03d proc id: %03d \n" + "file: %s line: %03d errcode: %05d errcls: %s\n" + "errval: %05d errdesc: %s\n", + ent, inst, procId, file, line, errCode, errClsMsg, errVal, errDesc); +#else + sprintf(errBuf, + "\nmtss(posix): sw error: ent: %03d inst: %03d proc id: %03d \n" + "file: %s line: %03ld errcode: %05ld errcls: %s\n" + "errval: %05ld errdesc: %s\n", + ent, inst, procId, file, line, errCode, errClsMsg, errVal, errDesc); +#endif + SDisplay(0, errBuf); +/* mt001.301 : Additions */ +#ifdef SS_LOGGER_SUPPORT + SWrtLogBuf(errBuf); +#endif /* SS_LOGGER_SUPPORT */ + + +#ifndef DEBUGNOEXIT + /* debug errors halt the system */ + if (errCls == ERRCLS_DEBUG) + { +/* mt001.301 : Additions */ +#ifdef SS_LOGGER_SUPPORT + SCleanUp(); +#endif /* SS_LOGGER_SUPPORT */ + /* delete all system tasks */ + for (i = 0; i < SS_MAX_STSKS; i++) + { + if (osCp.sTskTbl[i].used + && !pthread_equal(osCp.sTskTbl[i].dep.tId, tId)) + { + pthread_kill(osCp.sTskTbl[i].dep.tId, SIGKILL); + } + } + + + /* delete self */ + pthread_exit(NULLP); + } +#endif + + + RETVOID; +} + +#ifdef ENB_RELAY + +/* +* +* Fun: Register driver task +* +* Desc: This function is called to register the handlers for a +* driver task. +* +* Ret: ROK - ok +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 ssdRegDrvrTsk +( +SsDrvrTskEntry *drvrTsk /* driver task entry */ +) +#else +PUBLIC S16 ssdRegDrvrTsk(drvrTsk) +SsDrvrTskEntry *drvrTsk; /* driver task entry */ +#endif +{ + TRC0(ssdRegDrvrTsk); + + + RETVALUE(ROK); +} +/* mt001.30 : Additions */ +/* +* +* Fun: Deregister driver task +* +* Desc: This function is called to deregister the handlers for a +* driver task. +* +* Ret: ROK - ok +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 ssdDeregDrvrTsk +( +SsDrvrTskEntry *drvrTsk /* driver task entry */ +) +#else +PUBLIC S16 ssdDeregDrvrTsk(drvrTsk) +SsDrvrTskEntry *drvrTsk; /* driver task entry */ +#endif +{ + TRC0(ssdDeregDrvrTsk); + + + RETVALUE(ROK); +} +#endif + + + + +/* + * mt003.301 Additions - SDeRegTTsk fix + */ +#ifdef SS_MULTIPLE_PROCS +#ifdef ANSI +PUBLIC S16 ssdProcTTskTerm +( +ProcId procIdx, +SsTTskEntry *tTsk, +SsIdx idx +) +#else +PUBLIC S16 ssdProcTTskTerm(procIdx, tTsk, idx) +ProcId procIdx; +SsTTskEntry *tTsk; +SsIdx idx; +#endif +#else /*SS_MULTIPLE_PROCS*/ +#ifdef ANSI +PUBLIC S16 ssdProcTTskTerm +( +SsTTskEntry *tTsk, +SsIdx idx +) +#else +PUBLIC S16 ssdProcTTskTerm(tTsk, idx) +SsTTskEntry *tTsk; +SsIdx idx; +#endif +#endif /*SS_MULTIPLE_PROCS*/ +{ +#ifdef SS_MULTIPLE_PROCS + ProcId proc; +#endif + Ent ent; + Inst inst; + SsSTskEntry *sTsk; + S16 n; + S16 ret; + + TRC0(ssdProcTTskTerm); + + + ent = tTsk->ent; + inst = tTsk->inst; + /* We check the sTsk element; if it is not NULLP, the + * task is attached. So we have to detach it before + * deregistering the task. + */ + ret = SLock(&osCp.sTskTblLock); + if (ret != ROK) + { + MTLOGERROR(ERRCLS_DEBUG, EMTXXX, ERRZERO, "Could not lock system task table"); + RETVALUE(RFAILED); + } + SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret); + if (ret != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMTXXX, ERRZERO, "Could not lock TAPA task table"); +#endif + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMTXXX, ERRZERO, "Could not Unlock system task table"); + RETVALUE(RFAILED); +#endif + } + + RETVALUE(RFAILED); + } + +#ifdef SS_MULTIPLE_PROCS + proc = tTsk->proc; + if (tTsk->initTsk != NULLP) + { +#ifndef USE_MEMCAL + (Void)(*(tTsk->initTsk))(proc, ent, inst, + DFLT_REGION, + NRM_TERM, + &(osCp.tTskTbl[idx].xxCb)); +#else + (Void)(*(tTsk->initTsk))(proc, ent, inst, + SS_STATIC_REGION, + NRM_TERM, + &(osCp.tTskTbl[idx].xxCb)); +#endif /* USE_MEMCAL */ + } +#endif /* SS_MULTIPLE_PROCS */ + + if (tTsk->sTsk != NULLP) + { + sTsk = tTsk->sTsk; + + sTsk->dep.ent = ent; + sTsk->dep.inst = inst; + + for (n = 0; n < SS_MAX_TTSKS; n++) + { + if (sTsk->tTsks[n] == idx) + { + sTsk->tTsks[n] = SS_INVALID_IDX; + sTsk->numTTsks--; + break; + } + } + + /* call the implementation to detach the task */ + ssdDetachTTsk(tTsk); + /* 100178 */ + sTsk->dep.ent = ENTNC; + sTsk->dep.inst = INSTNC; + } + + /* Now we empty the entry for this task and update the table + * information + */ +#ifdef SS_MULTIPLE_PROCS + osCp.tTskIds[procIdx][ent][inst] = SS_TSKNC; +#else /* SS_MULTIPLE_PROCS */ + osCp.tTskIds[ent][inst] = SS_TSKNC; +#endif /* SS_MULTIPLE_PROCS */ + + tTsk->used = FALSE; +#ifdef SS_MULTIPLE_PROCS + tTsk->proc = PROCNC; +#endif /* SS_MULTIPLE_PROCS */ + tTsk->ent = ENTNC; + tTsk->inst = INSTNC; + tTsk->tskType = TTUND; + tTsk->initTsk = NULLP; + tTsk->actvTsk = NULLP; + tTsk->sTsk = NULLP; + + tTsk->nxt = osCp.nxtTTskEntry; + osCp.nxtTTskEntry = idx; + osCp.numTTsks--; + +#ifdef SS_MULTIPLE_PROCS + /* mark the control block for this task as invalid */ + osCp.tTskTbl[idx].xxCb = NULLP; +#endif + + SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem); + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMTXXX, ERRZERO, "Could not Unlock system task table"); +#endif + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + +//#ifndef SPLIT_RLC_DL_TASK +#ifdef TENB_T2K3K_SPECIFIC_CHANGES +#if defined (L2_L3_SPLIT) && defined(SPLIT_RLC_DL_TASK) +EXTERN Void ysMtTskHdlr(Void); +EXTERN Void ysMtPollPhyMsg(U8 region); +EXTERN Void ysMtRcvPhyMsg(Void); +#ifdef ANSI +PUBLIC Void *mtTskHdlrT2kL2 +( +Ptr tskPtr /* pointer to task entry */ +) +#else +PUBLIC Void *mtTskHdlrT2kL2(tskPtr) +Ptr tskPtr; /* pointer to task entry */ +#endif +{ + S16 ret; + + + /* wait for SS to come up */ + /* It is required to block on this semaphore before starting actual processing of + the thread becasue the creator of this thread might want to cance it without + doing any processing. When this semaphore is released, means the creator gives + the go ahead for actual processing and we should never come back to this point */ + while ((ret = sem_wait(&osCp.dep.ssStarted) != ROK) && (errno == EINTR)) + continue; + +#ifdef YS_PHY_3_8_2 + tlSetReady(NULL); +#endif + + while(1) + { + ysMtPollPhyMsg(0); /* blocks, waiting for messages for L2 + * (processes L1 msgs) */ + } + + RETVALUE(NULLP); +} +#else +EXTERN Void ysMtTskHdlr(Void); +EXTERN Void YsPhyRecvMsg(); +#ifdef ANSI +PUBLIC Void *mtTskHdlrT2kL2 +( +Ptr tskPtr /* pointer to task entry */ +) +#else +PUBLIC Void *mtTskHdlrT2kL2(tskPtr) +Ptr tskPtr; /* pointer to task entry */ +#endif +{ + S16 ret; + SsSTskEntry *sTsk; + + /* get out the system task entry from the parameter */ + sTsk = (SsSTskEntry *) tskPtr; + + /* wait for SS to come up */ + /* It is required to block on this semaphore before starting actual processing of + the thread becasue the creator of this thread might want to cance it without + doing any processing. When this semaphore is released, means the creator gives + the go ahead for actual processing and we should never come back to this point */ + while ((ret = sem_wait(&osCp.dep.ssStarted) != ROK) && (errno == EINTR)) + continue; + +#ifndef RGL_SPECIFIC_CHANGES +#ifdef YS_PHY_3_8_2 + tlSetReady(NULL); +#endif +#endif + + while(1) + { +#ifdef V5GTF_SPECIFIC_CHANGES + YsPhyRecvMsg(); +#else + ysMtTskHdlr(); /* blocks, waiting for messages for L2 + * (processes L1 msgs) */ +#endif + /* get a message from the demand queue */ + /* RT Processing */ +#ifdef RLC_MAC_DAT_REQ_RBUF + rgDlDatReqBatchProc(); +#endif + + ret = mtTskHdlMsg(sTsk); + if (ret != ROK) + { + /* exit the for loop here */ + break; + } +#if defined(SPLIT_RLC_DL_TASK) && defined(RLC_MAC_STA_RSP_RBUF) + rgBatchProc(); +#endif + } + + RETVALUE(NULLP); +} +#endif /* TENB_T2K3K_SPECIFIC_CHANGES */ +#endif + +#ifdef ANSI +PUBLIC void *pthreadCreateHdlr +( +void * arg +) +#else +PUBLIC void *pthreadCreateHdlr(pthreadCreateArg) +void *arg; +#endif +{ + S16 ret; + SPThreadCreateArg* pthreadCreateArg = (SPThreadCreateArg*)arg; + /* mt038.201 changed how sem_wait is called */ + while ((ret = sem_wait(&osCp.dep.ssStarted) != ROK) && (errno == EINTR)) + continue; + + pthreadCreateArg->start_routine(pthreadCreateArg->argument); + RETVALUE(ROK); +} + +/* +* +* Fun: Task handler +* +* Desc: This is the system task handler function. It blocks on +* the system task's demand queue. On receiving a message, +* it identifies the target TAPA task, verifies that the +* TAPA task belongs to this system task and if so, calls +* the activation function of that TAPA task with the +* received message. The task activation function or the +* timer activation function may be called. +* +* Ret: (thread function) +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC Void *mtTskHdlr +( +Ptr tskPtr /* pointer to task entry */ +) +#else +PUBLIC Void *mtTskHdlr(tskPtr) +Ptr tskPtr; /* pointer to task entry */ +#endif +{ + S16 ret; + SsSTskEntry *sTsk; + + /* get out the system task entry from the parameter */ + sTsk = (SsSTskEntry *) tskPtr; + + + /* wait for SS to come up */ + + /* mt038.201 changed how sem_wait is called */ + while ((ret = sem_wait(&osCp.dep.ssStarted) != ROK) && (errno == EINTR)) + continue; +#ifdef XEON_SPECIFIC_CHANGES + printf("\n**********MT Task Handler********\n"); +#endif + while (1) + { + /* Wait for a message from the demand queue */ +#ifdef SS_CDMNDQ_SUPPORT + ret = ssCDmndQWait(&sTsk->dQ); +#else + ret = ssDmndQWait(&sTsk->dQ); +#endif + if (ret != ROK) + continue; + + ret = mtTskHdlMsg(sTsk); + if (ret != ROK) + { + break; + } + } + + RETVALUE(NULLP); +} + + +/* +* +* Fun: Task handler +* +* Desc: This is the system task handler function. It blocks on +* the system task's demand queue. On receiving a message, +* it identifies the target TAPA task, verifies that the +* TAPA task belongs to this system task and if so, calls +* the activation function of that TAPA task with the +* received message. The task activation function or the +* timer activation function may be called. +* +* Ret: (thread function) +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 mtTskHdlMsg +( +SsSTskEntry *sTsk +) +#else +PUBLIC S16 mtTskHdlMsg(sTsk) +SsSTskEntry *sTsk +#endif +{ + S16 i; + S16 ret; + SsIdx idx; + SsTTskEntry *tTsk; + Buffer *mBuf; +#ifdef SS_PERF + Buffer *mBuf2; +#endif + SsMsgInfo *mInfo; + Pst nPst; +/* mt028.201: modification: multiple procs support related changes */ +#ifndef SS_MULTIPLE_PROCS +#ifdef SS_MT_TMR + PAIFTMRS16 tmrActvFnMt = NULLP; +#endif + /* mt015.301 Initialized the timer activation functions with NULLP */ + PFS16 tmrActvFn = NULLP; +#else + PAIFTMRS16 tmrActvFn; + U16 procIdIdx; +#endif /* SS_MULTIPLE_PROCS */ + /* mt003.301 Modifications */ +#ifdef SS_THREAD_PROFILE + EpcTime et1,et2; +#endif /* SS_THREAD_PROFILE */ + + + ret = ssDmndQGet(&sTsk->dQ, &mBuf, SS_DQ_FIRST); + if (ret != ROK) + { + /* nothing to receive */ + RETVALUE(ROK); + } + + /* if we can't lock this system task entry, return the message */ + ret = SLock(&sTsk->lock); + if (ret != ROK) + { + +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMT007, (ErrVal) ret, + "Could not lock system task entry"); +#endif + SPutMsg(mBuf); + RETVALUE(ROK); + } + +/* mt034.201 */ +#ifdef SS_PERF + do + { + mBuf2 = mBuf->b_next; +#endif + /* find out what kind of message this is */ + mInfo = (SsMsgInfo *)mBuf->b_rptr; +#ifdef SS_MEM_WL_DEBUG + mtTskBuffer1 = mBuf2; + if(mBuf2) + mtTskBuffer2 = mBuf2->b_next; + + if(mInfo == 0x5050505) + { + stopBtInfo = TRUE; + SGlobMemInfoShow(); + cmAnalyseBtInfo((PTR) mBuf,4); + SGlobMemInfoShow(); + printf("\n In trouble .... \n"); + } + else if (mInfo == 0x2020202) + { + stopBtInfo = TRUE; + cmAnalyseBtInfo((PTR) mBuf,1); + printf("\n In trouble .... \n"); + } +#endif /* SS_MEM_WL_DEBUG */ + switch (mInfo->eventInfo.event) + { + /* this is a termination event, we die */ + case SS_EVNT_TERM: + /* release the message */ + SPutMsg(mBuf); + + /* Unlock the system task entry and lock the system + * task table to clean our entry up. + */ + SUnlock(&sTsk->lock); + + ret = SLock(&osCp.sTskTblLock); + if (ret != ROK) + { + +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMT008, (ErrVal) ret, + "Could not lock system task table"); +#endif + /* what to do here? */ + RETVALUE(ROK); + } + + /* clean up the system task entry */ + sTsk->used = FALSE; + sTsk->tskPrior = 0; + /* mt003.301 Modifications - SDeRegTTsk */ + /* sTsk->numTTsks = 0; */ + SDestroyLock(&sTsk->lock); + ssDestroyDmndQ(&sTsk->dQ); + + /* lock for current executing TAPA task ID */ + + /* make this entry available in the system task table */ + sTsk->nxt = osCp.nxtSTskEntry; + for (i = 0; i < SS_MAX_STSKS; i++) + { + if (sTsk == &osCp.sTskTbl[i]) + { + osCp.nxtSTskEntry = i; + break; + } + } + + osCp.numSTsks--; + + /* unlock the system task table */ + SUnlock(&osCp.sTskTblLock); + + RETVALUE(RFAILED); + + + /* this is a data message or a permanent task keep-alive message */ + case SS_EVNT_DATA: + case SS_EVNT_PERMTICK: + /* message to a task. find the destination task */ +/* mt028.201: modification: multiple procs support related changes */ +#ifdef SS_MULTIPLE_PROCS + procIdIdx = SGetProcIdIdx(mInfo->pst.dstProcId); + + if (procIdIdx == SS_INV_PROCID_IDX) + { + SPutMsg(mBuf); + break; + } + + idx = osCp.tTskIds[procIdIdx][mInfo->pst.dstEnt][mInfo->pst.dstInst]; +#else /* SS_MULTIPLE_PROCS */ + idx = osCp.tTskIds[mInfo->pst.dstEnt][mInfo->pst.dstInst]; +#endif /* SS_MULTIPLE_PROCS */ + + /* verify that it hasn't been deregistered */ + if (idx == SS_TSKNC) + { + SPutMsg(mBuf); + break; + } + + /* verify that this system task is still running it */ + tTsk = &osCp.tTskTbl[idx]; + if (tTsk->sTsk != sTsk) + { + SPutMsg(mBuf); + break; + } + + /* set the current executing TAPA task ID */ + sTsk->dep.ent = mInfo->pst.dstEnt; + sTsk->dep.inst = mInfo->pst.dstInst; + + /* copy the Pst structure into a local duplicate */ + for (i = 0; i < (S16) sizeof(Pst); i++) + *(((U8 *)(&nPst)) + i) = *(((U8 *)&mInfo->pst) + i); + + /* Give the message to the task activation function. If + * its a normal data message, we pass it, if this is a + * keep-alive message for a permanent task then we pass + * NULLP in place of the message to the task activation + * function. + */ + if (mInfo->eventInfo.event == SS_EVNT_DATA) + { +#ifndef RGL_SPECIFIC_CHANGES +#ifdef SS_TSKLOG_ENABLE + U32 t = MacGetTick(); +#endif +#endif + /* mt003.301 Modifications */ +#if SS_THREAD_PROFILE + tTsk->curEvent = nPst.event; + SGetEpcTime(&et1); +#endif /* SS_THREAD_PROFILE */ + tTsk->actvTsk(&nPst, mBuf); +#ifndef RGL_SPECIFIC_CHANGES +#ifdef SS_TSKLOG_ENABLE + SStopTask(t,PID_SSI_TSK); +#endif +#endif +#if SS_THREAD_PROFILE + SGetEpcTime(&et2); + tTsk->curEvtTime = (U32)(et2 - et1); + tTsk->totTime += (U64)tTsk->curEvtTime; +#endif /* SS_THREAD_PROFILE */ + } + else + { +#if (ERRCLASS & ERRCLS_DEBUG) + /* this message should only come to a permanent task */ + if (tTsk->tskType != SS_TSK_PERMANENT) + { + MTLOGERROR(ERRCLS_DEBUG, EMT009, ERRZERO, "Logic failure"); + break; + } +#endif + tTsk->actvTsk(&nPst, NULLP); + + /* We need to re-send this message back to ourselves so + * the permanent task continues to run. + */ + /* Check if this task got deregistered or detached + * by the activation function; if so, there's nothing + * more to do here, otherwise go ahead. + */ + ret = ROK; + if (tTsk->used == TRUE && tTsk->sTsk != NULLP) + { + ret = ssDmndQPutLast(&tTsk->sTsk->dQ, mBuf, + ((tTsk->tskPrior) * SS_MAX_MSG_PRI) + + mInfo->pst.prior); + } + + /* failure here is a real problem */ + if (ret != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMT010, ERRZERO, + "Could not write to demand queue"); +#endif + SPutMsg(mBuf); + } + } + + /* unset the current executing TAPA task ID */ + sTsk->dep.ent = ENTNC; + sTsk->dep.inst = INSTNC; + break; + + + case SS_EVNT_TIMER: + /* timer event. find the timer entry */ + idx = mInfo->eventInfo.u.tmr.tmrIdx; + + /* lock the timer table, coz we're going to peek in it */ + ret = SLock(&osCp.tmrTblLock); + if (ret != ROK) + { + +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMT011, (ErrVal) ret, + "Could not lock timer table"); +#endif + SPutMsg(mBuf); + break; + } + + /* Verify that this timer entry is still around and that it + * belongs to our task. + */ + if (osCp.tmrTbl[idx].used == FALSE +/* mt028.201: modification: multiple procs support related changes */ +#ifdef SS_MULTIPLE_PROCS + || osCp.tmrTbl[idx].ownerProc != mInfo->pst.dstProcId +#endif /* SS_MULTIPLE_PROCS */ + || osCp.tmrTbl[idx].ownerEnt != mInfo->pst.dstEnt + || osCp.tmrTbl[idx].ownerInst != mInfo->pst.dstInst) + { + SUnlock(&osCp.tmrTblLock); + SPutMsg(mBuf); + break; + } + + /* mt005.21: addition */ + /* set the current executing TAPA task ID */ + sTsk->dep.ent = mInfo->pst.dstEnt; + sTsk->dep.inst = mInfo->pst.dstInst; + +#ifndef SS_MULTIPLE_PROCS +#ifdef SS_MT_TMR + /*mt006.301 Adding Initializing the tmrActvFnMt*/ + tmrActvFnMt = NULLP; + if (osCp.tmrTbl[idx].ssTmrActvFn.mtFlag == TRUE) + { + tmrActvFnMt = osCp.tmrTbl[idx].ssTmrActvFn.actvFnc.tmrActvFnMt; + } + else +#endif +#endif + { + tmrActvFn = osCp.tmrTbl[idx].ssTmrActvFn.actvFnc.tmrActvFn; + } + + /* unlock the timer table */ + SUnlock(&osCp.tmrTblLock); + + /* activate the timer function */ +/* mt028.201: modification: multiple procs support related changes */ +#ifndef SS_MULTIPLE_PROCS +#ifdef SS_MT_TMR + if (tmrActvFnMt) + { + tmrActvFnMt(osCp.tmrTbl[idx].ownerEnt, + osCp.tmrTbl[idx].ownerInst); + } + else +#endif + { + tmrActvFn(); + } +#else + tmrActvFn(osCp.tmrTbl[idx].ownerProc, osCp.tmrTbl[idx].ownerEnt, + osCp.tmrTbl[idx].ownerInst); +#endif /* SS_MULTIPLE_PROCS */ + + /*mt005.21: addition */ + /* unset the current executing TAPA task ID */ + sTsk->dep.ent = ENTNC; + sTsk->dep.inst = INSTNC; + + + /* return the message buffer */ + SPutMsg(mBuf); + break; + /* + * mt003.301 - SDeRegTTsk fix + */ + case SS_EVNT_TTSK_TERM: +#ifdef SS_MULTIPLE_PROCS + procIdIdx = SGetProcIdIdx(mInfo->pst.dstProcId); + + if (procIdIdx == SS_INV_PROCID_IDX) + { + SPutMsg(mBuf); + break; + } + + idx = osCp.tTskIds[procIdIdx][mInfo->pst.dstEnt][mInfo->pst.dstInst]; +#else /* SS_MULTIPLE_PROCS */ + idx = osCp.tTskIds[mInfo->pst.dstEnt][mInfo->pst.dstInst]; +#endif /* SS_MULTIPLE_PROCS */ + + /* verify that it hasn't been deregistered */ + if (idx == SS_TSKNC) + { + SPutMsg(mBuf); + break; + } + + /* verify that this system task is still running it */ + tTsk = &osCp.tTskTbl[idx]; + if (tTsk->sTsk != sTsk) + { + SPutMsg(mBuf); + break; + } +#ifdef SS_MULTIPLE_PROCS + ssdProcTTskTerm(procIdIdx, tTsk, idx); +#else + ssdProcTTskTerm(tTsk, idx); +#endif + SPutMsg(mBuf); + break; + + default: +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMT012, (ErrVal) ret, + "Illegal event"); +#endif + break; + } +#ifdef SS_PERF + mBuf = mBuf2; + } while (mBuf != NULLP); +#endif + + /* unlock the system task entry */ + SUnlock(&sTsk->lock); + +#ifndef SS_PERF + /* yield for other threads */ + /* mt024.201 - changed to use SSI SThreadYield instead of sleep */ + SThreadYield(); +#endif + + RETVALUE(ROK); +} + +Bool g_usettitmr; +/* +* Fun: mtTmrHdlrPublic +*/ +#ifdef ANSI +PUBLIC Void mtTmrHdlrPublic +( +) +#else +PUBLIC Void mtTmrHdlrPublic() +#endif +{ + if (SLock(&osCp.tmrTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMT016, ERRZERO, "Could not lock timer table"); +#endif + return; + } + cmPrcTmr(&osCp.dep.tmrTqCp, osCp.dep.tmrTq, mtTimeout); + /* unlock the timer table */ + SUnlock(&osCp.tmrTblLock); +} + + +/* +* +* Fun: mtTmrHdlr +* +* Desc: The timer handler thread function. Counts time +* and invokes the common timer function on each +* tick. +* +* Ret: (thread function) +* +* Notes: +* +* File: mt_ss.c +* +*/ +/*mt041.201 Modified SSI tick handling in mtTmrHdlr() */ +#ifdef ANSI +PRIVATE Void *mtTmrHdlr +( +void *parm /* unused */ +) +#else + /* mt009.21: addition */ +PRIVATE Void *mtTmrHdlr(parm) +void *parm; /* unused */ +#endif +{ +/*mt004.301-addede new region*/ +/* mt010.301 Removed SS_FAP portion and + * enabled oroginal code in function mtTmrHdlr */ + + struct timespec ts; + U32 time_int; + U32 i, cnt, oldTicks, newTicks; + struct timeval tv1,tv2; + /* mt038.201 added return */ + S16 ret; + /* mt039.201 changes for nanosleep */ + struct timespec tsN; + PRIVATE U32 err_in_usec; + + /*mt013.301 : doesn't need TRC macro ,as this will never return*/ + + + UNUSED(parm); + + /* mt027.201 - Modification for SRegCfgTmr support */ + /* check SS_TICKS_SEC */ + if (SS_1MS < SS_TICKS_SEC) + { + MTLOGERROR(ERRCLS_DEBUG, EMT013, ERRZERO, "Minimum SSI ticks is 1ms"); + } + + /* mt025.201 - Addition to stop timer handler till task registration is done */ + /* wait for SS to come up */ + /* mt038.201 changed how sem_wait is called */ + while ((ret = sem_wait(&osCp.dep.ssStarted) != ROK) && (errno == EINTR)) + continue; + + /* mt027.201 - Modification for SRegCfgTmr support */ + /* set up parameter to nanosleep() for SS_TICKS_SEC */ + ts.tv_sec = 0; + ts.tv_nsec = (MT_TICK_CNT * 1000); + /* mt039.201 changes for nanosleep */ + tsN.tv_sec = 0; + tsN.tv_nsec = 0; + + err_in_usec = 0; + + if (gettimeofday(&tv1, NULL) == -1) + { +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMT014, (ErrVal) errno, + "Error in clock_gettime"); +#endif + } + + /* infinite loop */ + for (; ;) + { +#if 1 + if (g_usettitmr) + { +#ifndef STUB_TTI_HANDLING_5GTF + printf("Returning from mtTmrHdlr()\n"); + return NULL; +#endif + } +#endif + /* mt039.201 changes for nanosleep */ + /* sleep for MT_TICK_CNT milli seconds */ + ts.tv_nsec = (MT_TICK_CNT - err_in_usec) * 1000; + while ((ret = nanosleep (&ts, &tsN) != ROK) && (errno == EINTR)) + { + ts.tv_nsec = tsN.tv_nsec; + tsN.tv_nsec = 0; + continue; + } + + if (gettimeofday(&tv2,NULL) == -1) + { +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMT015, (ErrVal) errno, + "Error in clock_gettime"); +#endif + } + + /*mt013.301 : changed check while calculating timer to fix + * diffrence between MTSS time and real unix time + */ + if ((tv2.tv_sec == tv1.tv_sec)&&(tv2.tv_usec > tv1.tv_usec)) + { + time_int = (tv2.tv_usec - tv1.tv_usec); + } + else if (tv2.tv_sec > tv1.tv_sec) + { + time_int = ((tv2.tv_sec - tv1.tv_sec)*1000000) + (tv2.tv_usec - tv1.tv_usec); + } + else /* ts2 < ts1, this will not happen in normal scenario */ + { + /* to make sure cnt = 1 */ + err_in_usec = 0; + time_int = MT_TICK_CNT; + } + + oldTicks = osCp.dep.sysTicks; + osCp.dep.sysTicks += (time_int/(MT_TICK_CNT - err_in_usec)); + err_in_usec = (time_int % (MT_TICK_CNT - err_in_usec)); + newTicks = osCp.dep.sysTicks; + tv1.tv_usec = tv2.tv_usec; + tv1.tv_sec = tv2.tv_sec; + + cnt = newTicks - oldTicks; + + while(err_in_usec >= MT_TICK_CNT) + { + cnt++; + err_in_usec -= MT_TICK_CNT; + } + if( cnt >= MT_MAX_TICK_CNT_VAL) + cnt = MT_MIN_TICK_CNT_VAL; + /* call the common timer tick handler */ + for (i = 0; i < cnt; i++) + { + /* mt008.301: cmPrcTmr is guarded with a lock */ + /* lock the timer table */ + if (SLock(&osCp.tmrTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMT016, ERRZERO, "Could not lock timer table"); +#endif + continue; + } + cmPrcTmr(&osCp.dep.tmrTqCp, osCp.dep.tmrTq, mtTimeout); + /* unlock the timer table */ + SUnlock(&osCp.tmrTblLock); + } + } + + /* mt009.21: addition */ + RETVALUE( (Void *) NULLP); + /* will not reach here */ +} + + +/* +* +* Fun: mtTimeout +* +* Desc: Process timer event. Called from the common timer +* code when a timeout occurs. +* +* Ret: Void +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC Void mtTimeout +( +PTR tCb, /* control block */ +S16 evnt /* event */ +) +#else +PUBLIC Void mtTimeout(tCb, evnt) +PTR tCb; /* control block */ +S16 evnt; /* event */ +#endif +{ + Buffer *mBuf; + SsMsgInfo *mInfo; + CmTmrArg arg; + SsTmrEntry *tEnt; + SsTTskEntry *tTsk; + SsIdx idx; +#ifndef TENB_RTLIN_CHANGES + S16 ret; +#endif +/* mt028.201: modification: multiple procs support related changes */ +#ifdef SS_MULTIPLE_PROCS + U16 procIdIdx; +#endif /* SS_MULTIPLE_PROCS */ +#ifdef RGL_SPECIFIC_CHANGES +#ifdef MSPD_MLOG_NEW + U32 t = GetTIMETICK(); +#endif +#endif + + TRC0(mtTimeout); + + + /* get the timer entry */ + tEnt = (SsTmrEntry *) tCb; + + + /* if the timer was deleted, this will be NULL, so drop it */ + if (tEnt == NULL) + { + RETVOID; + } + +/* mt008.301 Deletion: tmrTbl Lock is moved to mtTmrHdlr */ + + + /* Hmmmm, the timer might have been deleted while we've been + * working at getting here, so we just skip this. + */ + if (tEnt->used == FALSE) + { + RETVOID; + } + + + /* Set up and send a timer message to the destination tasks' + * demand queue. + */ +#ifndef SS_MULTICORE_SUPPORT + if (SGetMsg(SS_DFLT_REGION, SS_DFLT_POOL, &mBuf) != ROK) +#else +#ifdef RGL_SPECIFIC_CHANGES + if (SGetMsg((SS_DFLT_REGION), SS_DFLT_POOL, &mBuf) != ROK) +#else + if (SGetMsg((osCp.sTskTbl[0].region), SS_DFLT_POOL, &mBuf) != ROK) +#endif +#endif + { + +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMT017, ERRZERO, "Could not get message"); +#endif + + RETVOID; + } + + mInfo = (SsMsgInfo *)mBuf->b_rptr; + mInfo->eventInfo.event = SS_EVNT_TIMER; + mInfo->eventInfo.u.tmr.tmrIdx = tEnt->tmrId; + + mInfo->pst.dstEnt = tEnt->ownerEnt; + mInfo->pst.dstInst = tEnt->ownerInst; + mInfo->pst.srcEnt = tEnt->ownerEnt; + mInfo->pst.srcInst = tEnt->ownerInst; +/* mt028.201: modification: multiple procs support related changes */ +#ifndef SS_MULTIPLE_PROCS + mInfo->pst.dstProcId = SFndProcId(); + mInfo->pst.srcProcId = SFndProcId(); +#else /* SS_MULTIPLE_PROCS */ + mInfo->pst.dstProcId = tEnt->ownerProc; + mInfo->pst.srcProcId = tEnt->ownerProc; +#endif /* SS_MULTIPLE_PROCS */ + mInfo->pst.selector = SEL_LC_NEW; +#ifndef SS_MULTICORE_SUPPORT + mInfo->pst.region = DFLT_REGION; +#else +#endif + mInfo->pst.pool = DFLT_POOL; + mInfo->pst.prior = PRIOR0; + mInfo->pst.route = RTESPEC; + mInfo->pst.event = 0; + + +#ifndef TENB_RTLIN_CHANGES + /* get a semaphore for the TAPA task table */ + SS_ACQUIRE_SEMA(&osCp.tTskTblSem, ret); + if (ret != ROK) + { + SPutMsg(mBuf); + +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMT018, ret, "Could not lock TAPA task table"); +#endif + + RETVOID; + } +#endif + + + /* find the owner TAPA task */ +/* mt028.201: modification: multiple procs support related changes */ +#ifdef SS_MULTIPLE_PROCS + procIdIdx = SGetProcIdIdx(tEnt->ownerProc); + idx = osCp.tTskIds[procIdIdx][tEnt->ownerEnt][tEnt->ownerInst]; +#else /* SS_MULTIPLE_PROCS */ + idx = osCp.tTskIds[tEnt->ownerEnt][tEnt->ownerInst]; +#endif /* SS_MULTIPLE_PROCS */ + if (idx == SS_TSKNC) + { +#ifndef TENB_RTLIN_CHANGES + SS_RELEASE_SEMA(&osCp.tTskTblSem); +#endif + SPutMsg(mBuf); + RETVOID; + } + + + /* ensure that the TAPA task is hale and hearty */ + tTsk = &osCp.tTskTbl[idx]; + if (!tTsk->used) + { +#ifndef TENB_RTLIN_CHANGES + SS_RELEASE_SEMA(&osCp.tTskTblSem); +#endif + SPutMsg(mBuf); + RETVOID; + } + /* Klock work fix ccpu00148484 */ + /* write the timer message to the queue of the destination task */ + /* mt008.301 : check sTsk before putting into it's DQ */ + if (tTsk->sTsk == NULLP) + { +#ifndef TENB_RTLIN_CHANGES + SS_RELEASE_SEMA(&osCp.tTskTblSem); +#endif + SPutMsg(mBuf); + +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMT019, ERRZERO, + "Could not write to demand queue"); +#endif + + RETVOID; + } +#ifdef SS_LOCKLESS_MEMORY + mInfo->pst.region = tTsk->sTsk->region; + mInfo->region = tTsk->sTsk->region; +#endif /* SS_LOCKLESS_MEMORY */ + if (ssDmndQPutLast(&tTsk->sTsk->dQ, mBuf, + (tTsk->tskPrior * SS_MAX_MSG_PRI) + PRIOR0) != ROK) + { +#ifndef TENB_RTLIN_CHANGES + SS_RELEASE_SEMA(&osCp.tTskTblSem); +#endif + SPutMsg(mBuf); + +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMT019, ERRZERO, + "Could not write to demand queue"); +#endif + + RETVOID; + } +/* Fix for ccpu00130657 */ +#ifdef TENB_T2K3K_SPECIFIC_CHANGES + if (tTsk->sTsk->tskPrior == PRIOR0) + { +#ifdef INTEL_WLS + WLS_WakeUp(mtGetWlsHdl()); +#else + tlPost(NULLP); +#endif + } +#endif + + /* release the semaphore for the TAPA task table */ +#ifndef TENB_RTLIN_CHANGES + SS_RELEASE_SEMA(&osCp.tTskTblSem); +#endif + + + /* restart the timer */ + arg.tq = osCp.dep.tmrTq; + arg.tqCp = &osCp.dep.tmrTqCp; + arg.timers = tEnt->dep.timers; + arg.cb = (PTR) tEnt; + arg.evnt = TMR_DEF; + arg.wait = 0; + arg.tNum = NOTUSED; + arg.max = TMR_DEF_MAX; + arg.wait = tEnt->interval; + cmPlcCbTq(&arg); +#ifdef RGL_SPECIFIC_CHANGES +#ifdef MSPD_MLOG_NEW + MLogTask(131313, RESOURCE_LARM, t, GetTIMETICK()); +#endif +#endif + RETVOID; +} + + +#ifdef CONAVL +/* +* +* Fun: mtConHdlr +* +* Desc: This thread reads the console and hands over any +* data read to a user function. +* +* Ret: (thread function) +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PRIVATE Void *mtConHdlr +( +Ptr parm /* unused */ +) +#else + /* mt009.21: addition */ +PRIVATE Void *mtConHdlr(parm) +Ptr parm; /* unused */ +#endif +{ + int fd; + Data data; + + + /*mt013.301 : doesn't need TRC macro ,as this will never return*/ + + + UNUSED(parm); + + + /* check if we have a console input file handle */ + if (osCp.dep.conInFp == NULLP) + { + /* die */ + RETVALUE(NULLP); + } + + fd = fileno(osCp.dep.conInFp); + + /* infinite loop */ + for (; ;) + { + if ((read(fd, &data, 1)) != 1) + { + continue; + } + + + /* call rdConQ, defined by the system service user */ + //rdConQ(data); + } + + + /* not reached */ +} +#endif /* CONAVL */ + +#ifndef L2_L3_SPLIT +#ifdef SS_DRVR_SUPPORT +/* +* +* Fun: Interrupt service task handler +* +* Desc: This is the interrupt service task handler. It blocks +* on a pipe from which it reads an isFlag structure. The +* structure indicates which interrupt service task is to +* be executed. The thread identifies the task, calls the +* isTsk function and sends itself a message to repeat +* this operation until it receives a message to cease. +* +* Ret: ROK - ok +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI + /* mt009.21: addition */ +PRIVATE Void *mtIsTskHdlr +( +Ptr tskPtr /* pointer to task entry */ +) +#else + /* mt009.21: addition */ +PRIVATE Void *mtIsTskHdlr(tskPtr) +Ptr tskPtr; /* pointer to task entry */ +#endif +{ +#if (ERRCLASS & ERRCLS_DEBUG) + int ret; +#endif + MtIsFlag isFlag; + + + TRC0(mtIsTskHdlr); + + + for (; ;) + { + if (read(osCp.dep.isFildes[0], &isFlag, sizeof(isFlag)) != sizeof(isFlag)) + { + continue; + } + + switch (isFlag.action) + { + case MT_IS_SET: + osCp.drvrTskTbl[isFlag.id].dep.flag = TRUE; + + /* call the interrupt service task activation function */ + osCp.drvrTskTbl[isFlag.id].isTsk(isFlag.id); + + /* send self a message to keep doing this */ + isFlag.action = MT_IS_RESET; + +#if (ERRCLASS & ERRCLS_DEBUG) + ret = write(osCp.dep.isFildes[1], &isFlag, sizeof(isFlag)); + if (ret != sizeof(isFlag)) + { + MTLOGERROR(ERRCLS_DEBUG, EMT020, ERRZERO, + "write() to pipe failed"); + } +#else + write(osCp.dep.isFildes[1], &isFlag, sizeof(isFlag)); +#endif + + break; + + + case MT_IS_UNSET: + osCp.drvrTskTbl[isFlag.id].dep.flag = FALSE; + break; + + + case MT_IS_RESET: + if (osCp.drvrTskTbl[isFlag.id].dep.flag) + { + /* call the interrupt service task activation function */ + osCp.drvrTskTbl[isFlag.id].isTsk(isFlag.id); + +#if (ERRCLASS & ERRCLS_DEBUG) + /* send self a message to do this again */ + ret = write(osCp.dep.isFildes[1], &isFlag, sizeof(isFlag)); + + if (ret != sizeof(isFlag)) + { + MTLOGERROR(ERRCLS_DEBUG, EMT021, ERRZERO, + "write() to pipe failed"); + } +#else + write(osCp.dep.isFildes[1], &isFlag, sizeof(isFlag)); +#endif + + } + break; + + + default: + /* where did THIS come from?? */ + break; + } + } + /* mt009.21: addition */ + RETVALUE( (Void *) NULLP); + + /* not reached */ +} +#endif /* SS_DRVR_SUPPORT */ +#endif /* L2_L3_SPLIT */ + +/*mt010.301 Fix for core when run with -o option and when killed with SIGINT*/ + +/* +* +* Fun: mtIntSigHndlr +* +* Desc: Exit function, shuts down. +* +* Ret: Void +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC Void mtIntSigHndlr +( +int arg +) +#else +PUBLIC Void mtIntSigHndlr(arg) +int arg; +#endif +{ + + TRC0(mtIntSigHndlr); + + osCp.dep.sigEvnt=TRUE; + +#ifdef MSPD +#ifdef TENB_RTLIN_CHANGES + mtStopHndlr(); +#endif +#endif + + RETVOID; +} + +/*mt010.301 Fix for core when run with -o option and when killed with SIGINT*/ +/* +* +* Fun: mtExitClnup +* +* Desc: function, shuts down. +* +* Ret: Void +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC Void mtExitClnup +( +void +) +#else +PUBLIC Void mtExitClnup() +#endif +{ + Ticks ticks; + S8 buf[128]; + + + TRC0(mtExitClnup); + + SGetSysTime(&ticks); +#ifdef ALIGN_64BIT + sprintf(buf, "\n\nmtss(posix) ends\nticks: %u\n", ticks); +#else + sprintf(buf, "\n\nmtss(posix) ends\nticks: %lu\n", ticks); +#endif +#ifdef SS_HISTOGRAM_SUPPORT + SDisplay(0, buf); +#endif + + osCp.dep.sigEvnt=FALSE; +#ifndef NOFILESYS + if (osCp.dep.fileOutFp) + { + fclose(osCp.dep.fileOutFp); + } +#endif + + exit(0); +} + +Ticks TtiCount = 0; +Void SIncrementTtiCount(Void) +{ + TtiCount++; +} + +Ticks SGetTtiCount(Void) +{ + return TtiCount; +} + +/* +* +* Fun: SDisplay +* +* Desc: This function displays a string to a given output +* channel. +* +* Ret: ROK - ok +* +* Notes: Buffer should be null terminated. +* +* channel 0 is reserved for backwards compatibility +* with SPrint +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 SDisplay +( +S16 chan, /* channel */ +Txt *buf /* buffer */ +) +#else +PUBLIC S16 SDisplay(chan, buf) +S16 chan; /* channel */ +Txt *buf; /* buffer */ +#endif +{ + TRC1(SDisplay); + +/* mt020.201 - Fixed typo */ +#if (ERRCLASS & ERRCLS_INT_PAR) + if (buf == NULLP) + { + MTLOGERROR(ERRCLS_INT_PAR, EMT022, ERRZERO, "Null pointer"); + RETVALUE(RFAILED); + } +#endif + +#ifndef XEON_SPECIFIC_CHANGES +#ifdef TENB_T2K3K_SPECIFIC_CHANGES + ssMemlog(buf, strlen(buf)); + RETVALUE(ROK); +#endif +#endif + + /* mt012.301 :FIX for LOG RELATED ISSUE */ +#ifdef CONAVL + if(chan==1) + { + printf("%s",buf); + } + else + { + if (osCp.dep.conOutFp) fwrite(buf, strlen(buf), 1, osCp.dep.conOutFp); + } +#endif + + +#ifndef NOFILESYS + if (osCp.dep.fileOutFp) + fwrite(buf, strlen(buf), 1, osCp.dep.fileOutFp); + /*mt031.201 added under compile time flag FLUSHBUFF a call to fflush() */ +#ifdef FLUSHBUFF + + fflush(osCp.dep.fileOutFp); + +#endif +#endif + + RETVALUE(ROK); +} + +/*mt010.301 */ +/* +* +* Fun: SFini +* +* Desc: function, shuts down. +* +* Ret: Void +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 SFini +( +void +) +#else +PUBLIC S16 SFini() +#endif +{ + TRC1(SFini); + + /* mt030.201 added under compilet time flag SS_LINUX and SLES9_PLUS + a loop to overcome the child processes being killed upon exiting the + thread */ +#ifdef SS_LINUX /* this should have already been defined */ + /* mt010.301 removed flag SLES9_PLUS */ + /* wait forever for children */ + for (;;) + { + pause(); + if(osCp.dep.sigEvnt==TRUE) + { + mtExitClnup(); + } + } + +#endif + pthread_exit(NULLP); + RETVALUE(0); +} + +/* +* +* Fun: Set date and time +* +* Desc: This function is used to set the calendar +* date and time. +* +* Ret: ROK - ok +* +* Notes: Unimplemented +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 SSetDateTime +( +REG1 DateTime *dt /* date and time */ +) +#else +PUBLIC S16 SSetDateTime(dt) +REG1 DateTime *dt; /* date and time */ +#endif +{ + TRC1(SSetDateTime); + + + UNUSED(dt); + + + RETVALUE(ROK); +} + + +/* +* +* Fun: Get date and time +* +* Desc: This function is used to determine the calendar +* date and time. This information may be used for +* some management functions. +* +* Ret: ROK - ok +* RFAILED - error +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 SGetDateTime +( +REG1 DateTime *dt /* date and time */ +) +#else +PUBLIC S16 SGetDateTime(dt) +REG1 DateTime *dt; /* date and time */ +#endif +{ + /*-- mt035.201 : SSI enhancements for micro second in datetime struct --*/ + /* time_t tt; --*/ +#ifndef SS_LINUX + struct timespec ptime; +#else + struct timeval ptime; +#endif + + struct tm tme; + + + TRC1(SGetDateTime); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (dt == NULLP) + { + MTLOGERROR(ERRCLS_INT_PAR, EMT023, ERRZERO, "Null pointer"); + RETVALUE(RFAILED); + } +#endif + + +/*-- mt035.201 --*/ + /*-- + time(&tt); + localtime_r(&tt, &tme); + --*/ +#ifndef SS_LINUX + clock_gettime(CLOCK_REALTIME, &ptime); +#else + gettimeofday(&ptime, NULL); +#endif + localtime_r(&ptime.tv_sec, &tme); + + dt->month = (U8) tme.tm_mon + 1; + dt->day = (U8) tme.tm_mday; + dt->year = (U8) tme.tm_year; + dt->hour = (U8) tme.tm_hour; + dt->min = (U8) tme.tm_min; + dt->sec = (U8) tme.tm_sec; + dt->tenths = 0; + +#ifdef SS_DATETIME_USEC +#ifndef SS_LINUX + dt->usec = ptime.tv_nsec / 1000; +#else + dt->usec = ptime.tv_usec; +#endif +#endif /*-- SS_DATETIME_USEC --*/ + + RETVALUE(ROK); +} + +/* +* Get time from epoch in milliseconds +* +* Fun: Get time from epoch in milliseconds +* +* Desc: This function is used to get the time from epoch in milli seconds. +* This information may be used for calculating a layer's activation function +* execution time used for thread profiling. +* +* Ret: ROK - ok +* RFAILED - error +* +* Notes: +* +* File: mt_ss.c +*/ +/* mt003.301 Modifications */ +#ifdef ANSI +PUBLIC S16 SGetEpcTime +( +EpcTime *et /* date and time */ +) +#else +PUBLIC S16 SGetEpcTime(et) +EpcTime *et; /* date and time */ +#endif +{ +/* mt003.301 Modifications */ +PRIVATE U64 now; + U64 to_sec = 1000000; + U64 to_nsec = 1000; +#ifndef SS_LINUX + struct timespec ptime; +#else + struct timeval ptime; +#endif + + TRC1(SEpcTime); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (et == NULLP) + { + RETVALUE(RFAILED); + } +#endif + + +#ifndef SS_LINUX + clock_gettime(CLOCK_REALTIME, &ptime); +#else + gettimeofday(&ptime, NULL); +#endif /* SS_LINUX */ + + now = (ptime.tv_sec * to_sec); + +#ifndef SS_LINUX + now += (ptime.tv_nsec / to_nsec); +#else /* SS_LINUX */ + now += (ptime.tv_usec); + +#endif /* SS_LINUX */ + now = (now / to_nsec); + + *et = now; + + RETVALUE(ROK); +} + + + +/* +* +* Fun: Get system time +* +* Desc: This function is used to determine the system time. +* +* Ret: ROK - ok +* +* Notes: osCp.dep.sysTicks is updated by the timer thread. +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 SGetSysTime +( +Ticks *sysTime /* system time */ +) +#else +PUBLIC S16 SGetSysTime(sysTime) +Ticks *sysTime; /* system time */ +#endif +{ + TRC1(SGetSysTime); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (sysTime == NULLP) + { + MTLOGERROR(ERRCLS_INT_PAR, EMT024, ERRZERO, "Null pointer"); + RETVALUE(RFAILED); + } +#endif + + + *sysTime = osCp.dep.sysTicks; + + + RETVALUE(ROK); +} + +/* mt021.201 - Addition of SGetRefTime function */ +/* +* +* Fun: Get referenced time +* +* Desc: This function is used to determine the time in seconds +* and microseconds from a reference time. The reference +* time is expressed in seconds from UTC EPOC, January 1, +* 1970. +* +* Ret: ROK - ok +* RFAILED - fail +* +* Notes: Macros are defined for reference times: +* SS_REFTIME_01_01_1970 +* SS_REFTIME_01_01_2002 +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 SGetRefTime +( +U32 refTime, /* reference time */ +U32 *sec, +U32 *usec +) +#else +PUBLIC S16 SGetRefTime(refTime, sec, usec) +U32 refTime; /* reference time */ +U32 *sec; +U32 *usec; +#endif +{ + +#ifndef SS_LINUX + struct timespec ptime; +#else + struct timeval ptime; +#endif + + TRC1(SGetSysTime); + +#ifndef SS_LINUX + clock_gettime(CLOCK_REALTIME, &ptime); +#else + gettimeofday(&ptime, NULL); +#endif + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (sec == NULLP || usec == NULLP) + { + MTLOGERROR(ERRCLS_INT_PAR, EMT025, ERRZERO, "Null pointer"); + RETVALUE(RFAILED); + } + /* mt022.201 - Modification to fix compile warning */ + if (refTime > (U32)(ptime.tv_sec)) + { + MTLOGERROR(ERRCLS_INT_PAR, EMT026, ERRZERO, "Reference time exceeds present time"); + RETVALUE(RFAILED); + } +#endif + + *sec = ptime.tv_sec - refTime; +#ifndef SS_LINUX + *usec = ptime.tv_nsec / 1000; +#else + *usec = ptime.tv_usec; +#endif + + RETVALUE(ROK); + +} + + +/* +* +* Fun: Get Random Number +* +* Desc: Invoked by layer when a pseudorandom number is required. +* +* Ret: ROK - ok +* +* Notes: Suggested approach uses shuffled Linear Congruential +* Operators as described in Byte magazine October +* 1984; "Generating and Testing Pseudorandom Numbers" +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 SRandom +( +Random *value /* random number */ +) +#else +PUBLIC S16 SRandom(value) +Random *value; /* random number */ +#endif +{ + TRC1(SRandom); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (value == NULLP) + { + /* mt011.21: addition */ + MTLOGERROR(ERRCLS_INT_PAR, EMT028, (ErrVal)0 , "Null pointer"); + RETVALUE(RFAILED); + } +#endif + + + *value = (Random) rand_r(&osCp.dep.randSeed); + + + RETVALUE(ROK); +} + + +/* +* +* Fun: Exit Task +* +* Desc: This function exits from a task. +* +* Ret: ROK - ok +* +* Notes: Currently does nothing. +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 SExitTsk +( +void +) +#else +PUBLIC S16 SExitTsk() +#endif +{ + TRC1(SExitTsk); + + + RETVALUE(ROK); +} + + +/* +* +* Fun: Exit Interrupt +* +* Desc: This function exits from an interrupt. +* +* Ret: ROK - ok +* +* Notes: Currently does nothing. +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 SExitInt +( +void +) +#else +PUBLIC S16 SExitInt() +#endif +{ + TRC1(SExitInt); + + + RETVALUE(ROK); +} + + +/* +* +* Fun: Hold Interrupt +* +* Desc: This function prohibits interrupts from being enabled until +* release interrupt. This function should be called when +* interrupts are disabled and prior to any call to system +* services either by entry to an interrupt service routine or +* by explicit call to disable interrupt. +* +* Ret: ROK - ok +* +* Notes: Currently does nothing +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 SHoldInt +( +void +) +#else +PUBLIC S16 SHoldInt() +#endif +{ + TRC1(SHoldInt); + + + RETVALUE(ROK); +} + + +/* +* +* Fun: Release Interrupt +* +* Desc: This function allows interrupts to be enabled. +* +* Ret: ROK - ok +* +* Notes: Currently does nothing. +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 SRelInt +( +void +) +#else +PUBLIC S16 SRelInt() +#endif +{ + TRC1(SRelInt); + + + RETVALUE(ROK); +} + + +/* +* +* Fun: SEnbInt +* +* Desc: Enable interrupts +* +* Ret: ROK on success +* RFAILED on error +* +* Notes: Currently does nothing. +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC INLINE S16 SEnbInt +( +void +) +#else +PUBLIC INLINE S16 SEnbInt() +#endif +{ + TRC1(SEnbInt); + + + RETVALUE(ROK); +} + + +/* +* +* Fun: SDisInt +* +* Desc: Disable interrupts +* +* Ret: ROK on success +* RFAILED on error +* +* Notes: Currently does nothing. +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC INLINE S16 SDisInt +( +void +) +#else +PUBLIC INLINE S16 SDisInt() +#endif +{ + TRC1(SDisInt); + + + RETVALUE(ROK); +} + + +/* +* +* Fun: Get Vector +* +* Desc: This function gets the function address stored at the +* specified interrupt vector. +* +* Ret: ROK - ok +* +* Notes: Currently does nothing. +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 SGetVect +( +VectNmb vectNmb, /* vector number */ +PIF *vectFnct /* vector function */ +) +#else +PUBLIC S16 SGetVect(vectNmb, vectFnct) +VectNmb vectNmb; /* vector number */ +PIF *vectFnct; /* vector function */ +#endif +{ + TRC1(SGetVect); + + + UNUSED(vectNmb); + UNUSED(vectFnct); + + + RETVALUE(ROK); +} + + +/* +* +* Fun: Put Vector +* +* Desc: This function installs the specified function at the +* specified interrupt vector. +* +* Ret: ROK - ok +* +* Notes: Currently does nothing. +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 SPutVect +( +VectNmb vectNmb, /* vector number */ +PIF vectFnct /* vector function */ +) +#else +PUBLIC S16 SPutVect(vectNmb, vectFnct) +VectNmb vectNmb; /* vector number */ +PIF vectFnct; /* vector function */ +#endif +{ + TRC1(SPutVect); + + + UNUSED(vectNmb); + UNUSED(vectFnct); + + + RETVALUE(ROK); +} + +/* mt028.201: modification: multiple procs support related changes */ +#ifndef SS_MULTIPLE_PROCS + +/* +* +* Fun: SGetEntInst +* +* Desc: This function gets the current entity and instance. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: This function may be called by the OS or Layer 1 +* hardware drivers. +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 SGetEntInst +( +Ent *ent, /* entity */ +Inst *inst /* instance */ +) +#else +PUBLIC S16 SGetEntInst(ent, inst) +Ent *ent; /* entity */ +Inst *inst; /* instance */ +#endif +{ + S16 i; + S16 ret; + pthread_t tId; + SsSTskEntry *sTsk; + + + TRC1(SGetEntInst); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check pointers */ + if (ent == NULLP || inst == NULLP) + { + MTLOGERROR(ERRCLS_INT_PAR, EMT029, ERRZERO, "Null pointer"); + RETVALUE(RFAILED); + } +#endif + + + /* get the thread id */ + tId = pthread_self(); + + + /* find the system task in whose context we're running */ + sTsk = NULLP; + ret = SLock(&osCp.sTskTblLock); + if (ret != ROK) + { + RETVALUE(RFAILED); + } + for (i = 0; i < SS_MAX_STSKS; i++) + { + if (pthread_equal(osCp.sTskTbl[i].dep.tId, tId)) + { + sTsk = &osCp.sTskTbl[i]; + break; + } + } + if (sTsk != NULLP) + { + *ent = sTsk->dep.ent; + *inst = sTsk->dep.inst; + } + SUnlock(&osCp.sTskTblLock); + + + RETVALUE(ret == ROK ? ROK : RFAILED); +} + + +/* +* +* Fun: SSetEntInst +* +* Desc: This function sets the current entity and instance. +* +* Ret: ROK - ok +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 SSetEntInst +( +Ent ent, /* entity */ +Inst inst /* instance */ +) +#else +PUBLIC S16 SSetEntInst(ent, inst) +Ent ent; /* entity */ +Inst inst; /* instance */ +#endif +{ + S16 i; + S16 ret; + pthread_t tId; + SsSTskEntry *sTsk; + + + TRC1(SSetEntInst); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check entity and instance IDs */ + if (ent >= ENTNC || inst >= INSTNC) + { + MTLOGERROR(ERRCLS_INT_PAR, EMT030, ERRZERO, "Invalid entity/instance"); + RETVALUE(RFAILED); + } +#endif + + + /* get the thread id */ + tId = pthread_self(); + + + /* find the system task in whose context we're running */ + sTsk = NULLP; + ret = SLock(&osCp.sTskTblLock); + if (ret != ROK) + { + RETVALUE(RFAILED); + } + for (i = 0; i < SS_MAX_STSKS; i++) + { + if (pthread_equal(osCp.sTskTbl[i].dep.tId, tId)) + { + sTsk = &osCp.sTskTbl[i]; + break; + } + } + if (sTsk != NULLP) + { + sTsk->dep.ent = ent; + sTsk->dep.inst = inst; + } + SUnlock(&osCp.sTskTblLock); + + + RETVALUE(ret == ROK ? ROK : RFAILED); +} + +#endif /* SS_MULTIPLE_PROCS */ + +#ifdef SS_DRVR_SUPPORT + +/* +* +* Fun: SSetIntPend +* +* Desc: Set interrupt pending flag +* +* Ret: ROK on success +* RFAILED on error +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC INLINE S16 SSetIntPend +( +U16 id, /* driver task identifier */ +Bool flag /* flag */ +) +#else +PUBLIC INLINE S16 SSetIntPend(id, flag) +U16 id; /* driver task identifier */ +Bool flag; /* flag */ +#endif +{ + MtIsFlag isFlag; + + + TRC1(SSetIntPend); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (id >= SS_MAX_DRVRTSKS || osCp.drvrTskTbl[id].used == FALSE) + { + MTLOGERROR(ERRCLS_INT_PAR, EMT031, id, "Invalid instance"); + RETVALUE(RFAILED); + } +#endif + + + isFlag.id = id; + isFlag.action = (flag ? MT_IS_SET : MT_IS_UNSET); + + if (write(osCp.dep.isFildes[1], &isFlag, sizeof(isFlag)) != sizeof(isFlag)) + { + RETVALUE(RFAILED); + } + + + RETVALUE(ROK); +} +#endif /* SS_DRVR_SUPPORT */ + + +#ifdef SS_LOCKLESS_MEMORY +/* +* +* Fun: SGlobMemInfoShow +* +* Desc: This function displays the memory usage information +* for the destined region. It will show the usage of +* each configured bucket and the heap for the specified region. +* +* Ret: ROK OK +* RFAILED Region not registered +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 SGlobMemInfoShow +( +Void +) +#else +PUBLIC S16 SGlobMemInfoShow() +#endif +{ + U16 idx; + Txt prntBuf[100]; + CmMmGlobRegCb *globReg; + + TRC1(SGlobMemInfoShow); + + globReg = osCp.globRegCb; + + sprintf(prntBuf, "--------------------------------------------------------------\n"); + SDisplay(0, prntBuf); + sprintf(prntBuf, "Global Region Bucket Information\n"); + SDisplay(0, prntBuf); + sprintf(prntBuf, "====================================================\n"); + SDisplay(0, prntBuf); + sprintf(prntBuf, "Bucket Id Set Size Free Sets Allocated\n"); + SDisplay(0, prntBuf); + sprintf(prntBuf, "====================================================\n"); + SDisplay(0, prntBuf); + + + for (idx = 0; idx < globReg->numBkts; idx++) + { +#ifdef XEON_SPECIFIC_CHANGES + sprintf(prntBuf, "%2u %12lu %12lu %8lu %9lu\n", + idx, globReg->bktTbl[idx].size, globReg->bktTbl[idx].bucketSetSize, globReg->bktTbl[idx].listValidBktSet.count, globReg->bktTbl[idx].listFreeBktSet.count); +#else +#ifndef ALIGN_64BIT + sprintf(prntBuf, "%2u %12lu %8lu %9lu\n", + idx, globReg->bktTbl[idx].bucketSetSize, globReg->bktTbl[idx].listValidBktSet.count, globReg->bktTbl[idx].listFreeBktSet.count); +#else + sprintf(prntBuf, "%2u %12u %8u %9u\n", + idx, globReg->bktTbl[idx].bucketSetSize, globReg->bktTbl[idx].listValidBktSet.count, globReg->bktTbl[idx].listFreeBktSet.count); +#endif +#endif + SDisplay(0, prntBuf); + } + sprintf(prntBuf, "--------------------------------------------------------------\n"); + SDisplay(0, prntBuf); + + RETVALUE(ROK); +} + +#endif /* SS_LOCKLESS_MEMORY */ + +/* +Bool IsMemoryThresholdHit(Region reg, Pool pool) +{ + if((mtCMMRegCb[reg]->bktTbl[pool].numAlloc * 100 )/mtCMMRegCb[reg]->bktTbl[pool].numBlks > 70) + { + MSPD_DBG("Threshold reached reg(%d) pool(%d) numAllc(%d) numBlks(%d)\n", + reg, + pool, + mtCMMRegCb[reg]->bktTbl[pool].numAlloc, + mtCMMRegCb[reg]->bktTbl[pool].numBlks); + RETVALUE(TRUE); + } + RETVALUE(FALSE); +} +*/ + +/* mt022.201 - Addition of SRegInfoShow function */ +/* +* +* Fun: SRegInfoShow +* +* Desc: This function displays the memory usage information +* for the destined region. It will show the usage of +* each configured bucket and the heap for the specified region. +* +* Ret: ROK OK +* RFAILED Region not registered +* +* Notes: A Sample Output from the function +* Bucket Memory: region 1 +* ==================================================== +* Bucket Number of Blks configured Size Allocated +* ==================================================== +* 0 1 16 1 +* 1 1 32 0 +* 2 1 80 0 +* 3 1 256 0 +* 4 1 320 0 +* +* --------------- +* Heap Memory: region 1 +* Heap Size: 0 +* Heap Allocated: 0 +* Heap Segmented blocks: 0 +* +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 SRegInfoShow +( +Region region, +U32 *availmem +) +#else +PUBLIC S16 SRegInfoShow(region, availmem) +Region region; +U32 *availmem; +#endif +{ + U16 idx; + Txt prntBuf[100]; + + TRC1(SRegInfoShow); + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (region > (SS_MAX_REGS-1) ) + { + MTLOGERROR(ERRCLS_INT_PAR, EMT032, ERRZERO, "Invalid Region"); + RETVALUE(RFAILED); + } +#endif + + *availmem = 0; + +#ifndef TENB_T2K3K_SPECIFIC_CHANGES + sprintf(prntBuf, "\n\nBucket Memory: region %d\n", region); + SDisplay(0, prntBuf); + sprintf(prntBuf, "====================================================\n"); + SDisplay(0, prntBuf); + sprintf(prntBuf, "Bucket Number of Blks configured Size Allocated\n"); + SDisplay(0, prntBuf); + sprintf(prntBuf, "====================================================\n"); + SDisplay(0, prntBuf); +#endif + + + for (idx = 0; idx < mtCMMRegCb[region]->numBkts; idx++) + { +#ifdef TENB_T2K3K_SPECIFIC_CHANGES +#ifdef ALIGN_64BIT + sprintf((char *)prntBuf, "%2u %8u %5u %8u %8u\n", + idx, mtCMMRegCb[region]->bktTbl[idx].numBlks, + mtCMMRegCb[region]->bktTbl[idx].size, + mtCMMRegCb[region]->bktTbl[idx].numAlloc, + mtCMMRegCb[region]->bktTbl[idx].maxAlloc); +#else + sprintf((char *)prntBuf, "%2u %8lu %5lu %8lu %8lu\n", + idx, mtCMMRegCb[region]->bktTbl[idx].numBlks, + mtCMMRegCb[region]->bktTbl[idx].size, + mtCMMRegCb[region]->bktTbl[idx].numAlloc, + mtCMMRegCb[region]->bktTbl[idx].maxAlloc); +#endif +#else +/*mt009.301 Fixed 64BIT compilation warnings*/ +#ifdef ALIGN_64BIT + sprintf(prntBuf, "%2u %8u %5u %8u\n", + idx, mtCMMRegCb[region]->bktTbl[idx].numBlks, + mtCMMRegCb[region]->bktTbl[idx].size, + mtCMMRegCb[region]->bktTbl[idx].numAlloc); +#else + sprintf(prntBuf, "%2u %8lu %5lu %8lu\n", + idx, mtCMMRegCb[region]->bktTbl[idx].numBlks, + mtCMMRegCb[region]->bktTbl[idx].size, + mtCMMRegCb[region]->bktTbl[idx].numAlloc); +#endif +#endif /* not TENB_RTLIN_CHANGES */ + SDisplay(0, prntBuf); + *availmem = *availmem + (mtCMMRegCb[region]->bktTbl[idx].size * \ + (mtCMMRegCb[region]->bktTbl[idx].numBlks - \ + mtCMMRegCb[region]->bktTbl[idx].numAlloc)); + } + sprintf(prntBuf, "\n---------------\n"); + SDisplay(0, prntBuf); + sprintf(prntBuf, "Heap Memory: region %d\n", region); + SDisplay(0, prntBuf); +/*mt009.301 Fixed 64BIT compilation warnings*/ +#ifdef ALIGN_64BIT + sprintf(prntBuf, "Heap Size: %u\n", mtCMMRegCb[region]->heapSize); +#else + sprintf(prntBuf, "Heap Size: %lu\n", mtCMMRegCb[region]->heapSize); +#endif + SDisplay(0, prntBuf); +/*mt009.301 Fixed 64BIT compilation warnings*/ +#ifdef ALIGN_64BIT + sprintf(prntBuf, "Heap Allocated: %u\n", + (mtCMMRegCb[region]->heapSize - mtCMMRegCb[region]->heapCb.avlSize)); +#else + sprintf(prntBuf, "Heap Allocated: %lu\n", + (mtCMMRegCb[region]->heapSize - mtCMMRegCb[region]->heapCb.avlSize)); +#endif + SDisplay(0, prntBuf); + *availmem = *availmem + mtCMMRegCb[region]->heapCb.avlSize; +#if (ERRCLASS & ERRCLS_DEBUG) + sprintf(prntBuf, "Heap Segmented blocks: %d\n", + mtCMMRegCb[region]->heapCb.numFragBlk); + SDisplay(0, prntBuf); +#endif + + RETVALUE(ROK); +} +#ifdef XEON_SPECIFIC_CHANGES +#define SSI_MAX_BKT_THRESHOLD 6 +#define SSI_MAX_REG_THRESHOLD 2 +U32 SMemMaxThreshold[SSI_MAX_REG_THRESHOLD][SSI_MAX_BKT_THRESHOLD] = {{0}}; +U32 SMemMidThreshold[SSI_MAX_REG_THRESHOLD][SSI_MAX_BKT_THRESHOLD] = {{0}}; +U32 SMemLowThreshold[SSI_MAX_REG_THRESHOLD][SSI_MAX_BKT_THRESHOLD] = {{0}}; + +#ifdef ANSI +PRIVATE Void SInitMemThreshold +( +Region region, +U8 maxBkt +) +#else +PRIVATE Void SInitMemThreshold(region, maxBkt) +Region region; +U8 maxBkt; +#endif +{ + U8 idx = 0; + for (idx = 0; (idx < maxBkt && idx < mtCMMRegCb[region]->numBkts); idx++) + { + SMemMaxThreshold[region][idx] = (mtCMMRegCb[region]->bktTbl[idx].numBlks*95)/100; + SMemMidThreshold[region][idx] = (mtCMMRegCb[region]->bktTbl[idx].numBlks*85)/100; + SMemLowThreshold[region][idx] = (mtCMMRegCb[region]->bktTbl[idx].numBlks*80)/100; + printf("REGION:%d, BKT:%d max:%d mid:%d low:%d\n", region, idx, SMemMaxThreshold[region][idx], SMemMidThreshold[region][idx], SMemLowThreshold[region][idx]); + } +} + +#ifdef ANSI +PUBLIC S16 SRegReachedMemThreshold +( +Region region, +U8 maxBkt +) +#else +PUBLIC S16 SRegReachedMemThreshold(region, maxBkt) +Region region; +U8 maxBkt; +#endif +{ + U8 idx = 0; + U8 memStatus = 3; + PRIVATE U8 initFlag = 1; + if(initFlag) + { + initFlag = 0; + SInitMemThreshold(region, maxBkt); + } + + for (idx = 0; (idx < maxBkt && idx < mtCMMRegCb[region]->numBkts); idx++) + { + if(mtCMMRegCb[region]->bktTbl[idx].numAlloc >= SMemMaxThreshold[region][idx]) + { + memStatus = 0; + break; + } + else if((mtCMMRegCb[region]->bktTbl[idx].numAlloc >= SMemMidThreshold[region][idx]) && (memStatus >1)) + { + memStatus = 1; + } + else if((mtCMMRegCb[region]->bktTbl[idx].numAlloc >= SMemLowThreshold[region][idx]) && (memStatus >2)) + { + memStatus = 2; + } + } + RETVALUE(memStatus); +} +#endif +/* mt033.201 - addition of API to return the memory statistical data */ +/* +* +* Fun: SGetRegInfo +* +* Desc: This function returns the memory usage information +* for the destined region. It will return the usage of +* each configured bucket and the heap for the specified region. +* +* Ret: ROK OK +* RFAILED Region not registered +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 SGetRegInfo +( +Region region, +SsMemDbgInfo *dbgInfo +) +#else +PUBLIC S16 SGetRegInfo(region, dbgInfo) +Region region; +SsMemDbgInfo *dbgInfo; +#endif +{ + U32 idx; + + TRC1(SGetRegInfo); + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (region >= mtMemoCfg.numRegions ) + { + MTLOGERROR(ERRCLS_INT_PAR, EMT033, ERRZERO, "Invalid Region"); + RETVALUE(RFAILED); + } +#endif + + dbgInfo->availmem = 0; + + if (mtCMMRegCb[region]->numBkts > SS_MAX_BKT_PER_DBGTBL) + dbgInfo->numBkts = SS_MAX_BKT_PER_DBGTBL; + else + dbgInfo->numBkts = mtCMMRegCb[region]->numBkts; + + for (idx = 0; (idx < mtCMMRegCb[region]->numBkts) && (idx < SS_MAX_BKT_PER_DBGTBL); idx++) + { + dbgInfo->bktDbgTbl[idx].numBlks = mtCMMRegCb[region]->bktTbl[idx].numBlks; + dbgInfo->bktDbgTbl[idx].size = mtCMMRegCb[region]->bktTbl[idx].size; + dbgInfo->bktDbgTbl[idx].numAlloc = mtCMMRegCb[region]->bktTbl[idx].numAlloc; + + dbgInfo->availmem += (mtCMMRegCb[region]->bktTbl[idx].size * \ + (mtCMMRegCb[region]->bktTbl[idx].numBlks - \ + mtCMMRegCb[region]->bktTbl[idx].numAlloc)); + } + + dbgInfo->region = region; + + dbgInfo->heapSize = mtCMMRegCb[region]->heapSize; + + dbgInfo->heapAlloc = (mtCMMRegCb[region]->heapSize - \ + mtCMMRegCb[region]->heapCb.avlSize); + + dbgInfo->availmem += mtCMMRegCb[region]->heapCb.avlSize; + +#if (ERRCLASS & ERRCLS_DEBUG) + dbgInfo->numFragBlk = mtCMMRegCb[region]->heapCb.numFragBlk; +#endif + + RETVALUE(ROK); +} + +#ifdef ANSI +PUBLIC S16 SGetRegPoolInfo +( +U8 *numRegion, +U8 *numPool +) +#else +PUBLIC S16 SGetRegPoolInfo(numRegion, numPool) +U8 *numRegion; +U8 *numPool; +#endif +{ + /* Send number of Region available */ + *numRegion = mtMemoCfg.numRegions; + /* Send number of Pools available */ + *numPool = cfgRegInfo[0].numPools; + + RETVALUE(ROK); +} + +/* mt033.201 - addition of APIs to print the memory statistical data + * as defined by SSI enhancements + */ +#ifdef SSI_DEBUG_LEVEL1 +/* + * + * Fun: SPrintRegMemStatusInfo + * + * Desc: This function displays the memory usage information + * for the destined region. It will show the total memory + * used for static and dynamic memory if typeFlag is + * SS_MEM_BKT_ALLOC_PROFILE. It will show the number of +* memory block allocated for a particular size if typeFlag +* is SS_MEM_BLK_SIZE_PROFILE from the hash list by +* calling SRegPrintMemStats. +* +* Ret: ROK +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 SPrintRegMemStatusInfo +( +Region region, +U8 typeFlag +) +#else +PUBLIC S16 SPrintRegMemStatusInfo(region, typeFlag) +Region region; +U8 typeFlag; +#endif +{ + Txt prntBuf[150]; + U32 idx; + U32 statMemSize; + U32 dynMemSize; + + TRC1(SPrintRegMemStatusInfo); + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (region >= mtMemoCfg.numRegions ) + { + MTLOGERROR(ERRCLS_INT_PAR, EMT034, ERRZERO, "Invalid Region"); + RETVALUE(RFAILED); + } +#endif + + /* initialize the counters*/ + statMemSize = 0; + dynMemSize = 0; + + if (typeFlag == SS_MEM_BKT_ALLOC_PROFILE) + { + /* total static and dynamic memory allocated from all the buckets in region requested */ + sprintf(prntBuf, "\nAllocated Memory profile of Buckets from region: %d \n", region); + SDisplay(0, prntBuf); + sprintf(prntBuf, "===========================================\n"); + SDisplay(0, prntBuf); + sprintf(prntBuf, "Bucket Static Memory Dynamic Memory\n"); + SDisplay(0, prntBuf); + sprintf(prntBuf, "===========================================\n"); + SDisplay(0, prntBuf); + for (idx = 0; idx < mtCMMRegCb[region]->numBkts; idx++) + { +/*mt009.301 Fixed 64BIT compilation warnings*/ +#ifdef ALIGN_64BIT + sprintf(prntBuf, "%2u %8u %8u\n", idx, + mtCMMRegCb[region]->bktTbl[idx].staticMemUsed, + mtCMMRegCb[region]->bktTbl[idx].dynamicMemUsed); +#else + sprintf(prntBuf, "%2lu %8lu %8lu\n", idx, + mtCMMRegCb[region]->bktTbl[idx].staticMemUsed, + mtCMMRegCb[region]->bktTbl[idx].dynamicMemUsed); +#endif + SDisplay(0, prntBuf); + /* update the total count */ + statMemSize += mtCMMRegCb[region]->bktTbl[idx].staticMemUsed; + dynMemSize += mtCMMRegCb[region]->bktTbl[idx].dynamicMemUsed; + } + /* from buckets */ +/*mt009.301 Fixed 64BIT compilation warnings*/ +#ifdef ALIGN_64BIT + sprintf(prntBuf, "Total Static Memory allocated from buckets: %u\n", statMemSize); + SDisplay(0, prntBuf); + sprintf(prntBuf, "Total Dynamic Memory allocated from buckets: %u\n", dynMemSize); +#else + sprintf(prntBuf, "Total Static Memory allocated from buckets: %lu\n", statMemSize); + SDisplay(0, prntBuf); + /*mt010.301 fix for compilation error*/ + sprintf(prntBuf, "Total Dynamic Memory allocated from buckets: %lu\n", dynMemSize); +#endif + SDisplay(0, prntBuf); + /* from heap */ + sprintf(prntBuf, "\n\nAllocated Memory profile from Heap of region: %d \n", region); + SDisplay(0, prntBuf); +/*mt009.301 Fixed 64BIT compilation warnings*/ +#ifdef ALIGN_64BIT + sprintf(prntBuf, "STATIC MEMORY: %u DYNAMIC MEMORY:%u \n", + mtCMMRegCb[region]->heapCb.staticHeapMemUsed, mtCMMRegCb[region]->heapCb.dynamicHeapMemUsed); +#else + sprintf(prntBuf, "STATIC MEMORY: %lu DYNAMIC MEMORY:%lu \n", + mtCMMRegCb[region]->heapCb.staticHeapMemUsed, mtCMMRegCb[region]->heapCb.dynamicHeapMemUsed); +#endif + SDisplay(0, prntBuf); + } + else if (typeFlag == SS_MEM_BLK_SIZE_PROFILE) + { + /* Bucket Memory allocation Statistics */ + RETVALUE(SPrintRegMemStats(region)); + } + else + { + /* error case */ + sprintf(prntBuf, "\n Invalid choice \n"); + SDisplay(0, prntBuf); + } + + RETVALUE(ROK); +} + +/* +* +* Fun: SPrintRegMemStats +* +* Desc: This function displays the memory usage information for +* the destined region. It will show the number of memory +* block allocated for a particular size from the hash list. +* +* Ret: ROK +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PRIVATE S16 SPrintRegMemStats +( +Region region +) +#else +PRIVATE S16 SPrintRegMemStats(region) +Region region; +#endif +{ + CmMmHashListCp *hashListCp; + Txt prntBuf[150]; + U32 idx; + U32 cntEnt; + + TRC1(SPrintRegMemStats); + + hashListCp = &mtCMMRegCb[region]->hashListCp; + + sprintf(prntBuf, "\n\nSize Vs. NumAttempts and Alloc/Dealloc profile of region %d\n", region); + SDisplay(0, prntBuf); + sprintf(prntBuf, "Maximum Entries: %u Current Entries: %u\n", + hashListCp->numOfbins, hashListCp->numOfEntries); + SDisplay(0, prntBuf); + sprintf(prntBuf, "===================================\n"); + SDisplay(0, prntBuf); + sprintf(prntBuf, "Block Size Total number of requests\n"); + SDisplay(0, prntBuf); + sprintf(prntBuf, "===================================\n"); + SDisplay(0, prntBuf); + + for (idx = 0, cntEnt=0; (cntEnt < hashListCp->numOfEntries) && + (idx < CMM_STAT_HASH_TBL_LEN); idx++) + { + if (hashListCp->hashList[idx].numAttempts) + { + cntEnt++; +/*mt009.301 Fixed 64BIT compilation warnings*/ +#ifdef ALIGN_64BIT + sprintf(prntBuf, "%8u %8u\n", hashListCp->hashList[idx].size, + hashListCp->hashList[idx].numAttempts); +#else + sprintf(prntBuf, "%8lu %8lu\n", hashListCp->hashList[idx].size, + hashListCp->hashList[idx].numAttempts); +#endif + SDisplay(0, prntBuf); + } + } + + sprintf(prntBuf, "\nAllocation/De-allocation profile in Buckets\n"); + SDisplay(0, prntBuf); + sprintf(prntBuf, "=================================================\n"); + SDisplay(0, prntBuf); + sprintf(prntBuf, "Bucket Num of Alloc Attempts Num of De-alloc Attempts\n"); + SDisplay(0, prntBuf); + sprintf(prntBuf, "=================================================\n"); + SDisplay(0, prntBuf); + + /* Print the statistics of total number of alloc/de-alloc attempts in each bucket of this region */ + for (idx = 0; idx < mtCMMRegCb[region]->numBkts; idx++) + { +/*mt009.301 Fixed 64BIT compilation warnings*/ +#ifdef ALIGN_64BIT + sprintf(prntBuf, "%4u %8u %8u\n", idx, + mtCMMRegCb[region]->bktTbl[idx].numAllocAttempts, + mtCMMRegCb[region]->bktTbl[idx].numDeallocAttempts); +#else + sprintf(prntBuf, "%4lu %8lu %8lu\n", idx, + mtCMMRegCb[region]->bktTbl[idx].numAllocAttempts, + mtCMMRegCb[region]->bktTbl[idx].numDeallocAttempts); +#endif + SDisplay(0, prntBuf); + } + sprintf(prntBuf, "\nAllocation/De-allocation profile in Heap\n"); + SDisplay(0, prntBuf); +/*mt009.301 Fixed 64BIT compilation warnings*/ +#ifdef ALIGN_64BIT + sprintf(prntBuf, "Num of Alloc Attempts: %u Num of De-alloc Attempts: %u\n", + mtCMMRegCb[region]->heapCb.numAllocAttempts, + mtCMMRegCb[region]->heapCb.numDeallocAttempts); +#else + sprintf(prntBuf, "Num of Alloc Attempts: %lu Num of De-alloc Attempts: %lu\n", + mtCMMRegCb[region]->heapCb.numAllocAttempts, + mtCMMRegCb[region]->heapCb.numDeallocAttempts); +#endif + SDisplay(0, prntBuf); + sprintf(prntBuf, "\n"); + SDisplay(0, prntBuf); + + RETVALUE(ROK); +} + +/* +* +* Fun: SRegMemErrHdlr +* +* Desc: This function handles the errors returned from the memory +* related functions. Customers are suggested to modify this +* API according to their specific requirement. +* +* Ret: ROK OK +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC Void SRegMemErrHdlr +( +Region region, +Data *ptr, +S16 errCode +) +#else +PUBLIC Void SRegMemErrHdlr(region, ptr, errCode) +Region region; +Data *ptr; +S16 errCode; +#endif +{ + Txt prntBuf[150]; + + TRC1(SRegMemErrHdlr); + + if (errCode == RDBLFREE) + { + sprintf(prntBuf, "\nDouble free attempted at location:%8p in region:%d\n", ptr, region); + SDisplay(0, prntBuf); + } + else if (errCode == RTRAMPLINGNOK) + { + sprintf(prntBuf, "\nMemory Trampling crossed Threshold in region:%d\n", region); + SDisplay(0, prntBuf); + } + + RETVOID; +} + +/* +* +* Fun: SPrintRegMemProfile +* +* Desc: This function displays the memory profile information +* for the destined region. This function prints for: +* 1) each memory bucket-Block address, size, size for which it is allocated, free/allocated, static/dynamic +* 2) heap - memory block address, size, requested size, free/allocated, static/dynamic +* +* Ret: ROK OK +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 SPrintRegMemProfile +( +Region region +) +#else +PUBLIC S16 SPrintRegMemProfile(region) +Region region; +#endif +{ + CmMmHeapCb *heapCb; + CmMmRegCb *regCb; + CmMmBlkHdr *curBktBlk; + CmHEntry *curHBlk; + Size offsetToNxtBlk; + Size hdrSize; + Txt prntBuf[250]; + U32 idx; + U32 blkCnt; + + + TRC1(SPrintRegMemProfile); + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (region >= mtMemoCfg.numRegions ) + { + MTLOGERROR(ERRCLS_INT_PAR, EMT035, ERRZERO, "Invalid Region"); + RETVALUE(RFAILED); + } +#endif + + regCb = mtCMMRegCb[region]; + + /* memory profile */ + sprintf(prntBuf, "\n\nFull Memory Profile of region %d\n", region); + SDisplay(0, prntBuf); + + /* bucket profile */ + sprintf(prntBuf, "\nBucket Profile\n"); + SDisplay(0, prntBuf); + + for (idx = 0; idx < regCb->numBkts; idx++) + { + +/*mt009.301 Fixed 64BIT compilation warnings*/ +#ifdef ALIGN_64BIT + sprintf(prntBuf, "\nBucket number:%4u of Size:%u Num of Blocks: %u\n", + idx, regCb->bktTbl[idx].size, regCb->bktTbl[idx].numBlks); +#else + sprintf(prntBuf, "\nBucket number:%4lu of Size:%lu Num of Blocks: %lu\n", + idx, regCb->bktTbl[idx].size, regCb->bktTbl[idx].numBlks); +#endif + SDisplay(0, prntBuf); + + sprintf(prntBuf, "==========================================================================\n"); + SDisplay(0, prntBuf); + sprintf(prntBuf, " Block Location Free/Allocated Static/dynamic Size requested\n"); + SDisplay(0, prntBuf); + sprintf(prntBuf, "==========================================================================\n"); + SDisplay(0, prntBuf); + + offsetToNxtBlk = regCb->bktTbl[idx].size + sizeof(CmMmBlkHdr); + + for (blkCnt=0, curBktBlk = (CmMmBlkHdr *)(regCb->bktTbl[idx].bktStartPtr); + ((curBktBlk) && (blkCnt < regCb->bktTbl[idx].numBlks)); + curBktBlk = (CmMmBlkHdr *)((Data *)curBktBlk + offsetToNxtBlk), blkCnt++) + { +/*mt009.301 Fixed 64BIT compilation warnings*/ +#ifdef ALIGN_64BIT + sprintf(prntBuf, "%6u %8p", blkCnt, (void *)curBktBlk); +#else + sprintf(prntBuf, "%6lu %8p", blkCnt, (void *)curBktBlk); +#endif + SDisplay(0, prntBuf); + /* check if it is a sane block, elxe jump to next block */ + if (cmMmRegIsBlkSane(curBktBlk) != ROK) + { + sprintf(prntBuf, " Trampled \n"); + SDisplay(0, prntBuf); + + continue; + } + + if (CMM_IS_STATIC(curBktBlk->memFlags)) + { +/*mt009.301 Fixed 64BIT compilation warnings*/ +#ifdef ALIGN_64BIT + sprintf(prntBuf, " Allocated Static %8u\n", curBktBlk->requestedSize); +#else + sprintf(prntBuf, " Allocated Static %8lu\n", curBktBlk->requestedSize); +#endif + SDisplay(0, prntBuf); + } + else if (CMM_IS_DYNAMIC(curBktBlk->memFlags)) + { +/*mt009.301 Fixed 64BIT compilation warnings*/ +#ifdef ALIGN_64BIT + sprintf(prntBuf, " Allocated Dynamic %8u\n", curBktBlk->requestedSize); +#else + sprintf(prntBuf, " Allocated Dynamic %8lu\n", curBktBlk->requestedSize); +#endif + SDisplay(0, prntBuf); + } + else if (CMM_IS_FREE(curBktBlk->memFlags)) + { +/*mt009.301 Fixed 64BIT compilation warnings*/ +#ifdef ALIGN_64BIT + sprintf(prntBuf, " Free %8u\n", curBktBlk->requestedSize); +#else + sprintf(prntBuf, " Free %8lu\n", curBktBlk->requestedSize); +#endif + SDisplay(0, prntBuf); + } + else + { + sprintf(prntBuf, " Trampled \n"); + SDisplay(0, prntBuf); + } + } + } + + /* heap profile */ + sprintf(prntBuf, "\nHeap Profile\n"); + SDisplay(0, prntBuf); + + /* point to heapCb */ + heapCb = &(regCb->heapCb); + + sprintf(prntBuf, "\nHeap Start: %8p Heap End: %8p\n", heapCb->vStart, heapCb->vEnd); + SDisplay(0, prntBuf); + sprintf(prntBuf, "==========================================================================\n"); + SDisplay(0, prntBuf); + sprintf(prntBuf, " Block Location Size Free/Allocated Static/dynamic Size requested\n"); + SDisplay(0, prntBuf); + sprintf(prntBuf, "==========================================================================\n"); + SDisplay(0, prntBuf); + + /* traverse the entire heap to output the heap profile */ + hdrSize = sizeof(CmHEntry); + for (blkCnt=0, curHBlk = (CmHEntry *)heapCb->vStart; + ((curHBlk) && (curHBlk < (CmHEntry *)heapCb->vEnd)); blkCnt++) + { +/*mt009.301 Fixed 64BIT compilation warnings*/ +#ifdef ALIGN_64BIT + sprintf(prntBuf, "%6u %8p", blkCnt, (void *)curHBlk); +#else + sprintf(prntBuf, "%6lu %8p", blkCnt, (void *)curHBlk); +#endif + SDisplay(0, prntBuf); + + /* check if it is a sane block, elxe jump to next block */ + if (cmMmRegIsBlkSane((CmMmBlkHdr *)curHBlk) != ROK) + { + sprintf(prntBuf, " Trampled \n"); + SDisplay(0, prntBuf); + + sprintf(prntBuf, "Trampled block encountered: Stopping heap profile\n"); + SDisplay(0, prntBuf); + + /* + * To go to next block in the heap we do not have any offset value + * other than curHBlk->size. As the block is already trampled + * we cannot rely on this size. So it is better to stop here unless there + * exists any other mechanism(?) to know the offset to next block. + */ + RETVALUE(ROK); + } + +/*mt009.301 Fixed 64BIT compilation warnings*/ +#ifdef ALIGN_64BIT + sprintf(prntBuf, " %8u", curHBlk->size); +#else + sprintf(prntBuf, " %8lu", curHBlk->size); +#endif + SDisplay(0, prntBuf); + + if (CMM_IS_STATIC(curHBlk->memFlags)) + { +/*mt009.301 Fixed 64BIT compilation warnings*/ +#ifdef ALIGN_64BIT + sprintf(prntBuf, " Allocated Static %8u\n", curHBlk->requestedSize); +#else + sprintf(prntBuf, " Allocated Static %8lu\n", curHBlk->requestedSize); +#endif + SDisplay(0, prntBuf); + } + else if (CMM_IS_DYNAMIC(curHBlk->memFlags)) + { +/*mt009.301 Fixed 64BIT compilation warnings*/ +#ifdef ALIGN_64BIT + sprintf(prntBuf, " Allocated Dynamic %8u\n", curHBlk->requestedSize); +#else + sprintf(prntBuf, " Allocated Dynamic %8lu\n", curHBlk->requestedSize); +#endif + SDisplay(0, prntBuf); + } + else if (CMM_IS_FREE(curHBlk->memFlags)) + { +/*mt009.301 Fixed 64BIT compilation warnings*/ +#ifdef ALIGN_64BIT + sprintf(prntBuf, " Free %8u\n", curHBlk->requestedSize); +#else + sprintf(prntBuf, " Free %8lu\n", curHBlk->requestedSize); +#endif + SDisplay(0, prntBuf); + } + else + { + sprintf(prntBuf, " Trampled \n"); + SDisplay(0, prntBuf); + } + /* goto next block in the heap */ + curHBlk = (CmHEntry *)((Data *)curHBlk + hdrSize + curHBlk->size); + + } + + RETVALUE(ROK); +} +#endif /* SSI_DEBUG_LEVEL1 */ + +/*-- mt035.201 : Added new API for timestamp --*/ +/*-- +* +* Fun: Get TimeStamp +* +* Desc: This function is used to Get TimeStamp in micro seconds +* +* Ret: ROK - ok +* RFAILED - error +* +* Notes: +* +* File: mt_ss.c +* +--*/ +#ifdef ANSI +PUBLIC S16 SGetTimeStamp +( +S8 *ts +) +#else +PUBLIC S16 SGetTimeStamp(ts) +S8 *ts; +#endif +{ + +#ifndef SS_LINUX + struct timespec ptime; +#else + struct timeval ptime; +#endif + + struct tm* ptm; + S8 time_string[40]; + S32 microseconds; + + TRC1(SGetTimeStamp); + +#ifndef SS_LINUX + clock_gettime(CLOCK_REALTIME, &ptime); +#else + gettimeofday(&ptime, NULL); +#endif + + /* Obtain the time of day, and convert it to a tm struct. --*/ + ptm = localtime (&ptime.tv_sec); + /* Klock work fix ccpu00148484 */ + if(ptm != NULLP) + { + /* Format the date and time, down to a single second. --*/ + strftime (time_string, sizeof (time_string), "%a %b %d %Y %H:%M:%S", ptm); + } + + /* Compute microseconds. --*/ +#ifndef SS_LINUX + microseconds = ptime.tv_nsec / 1000; +#else + microseconds = ptime.tv_usec; +#endif + + /* Print the formatted time, in seconds, followed by a decimal point + and the microseconds. --*/ +/*mt009.301 Fixed 64BIT compilation warnings*/ +#ifdef ALIGN_64BIT + sprintf(ts, "%s.%03d", time_string, microseconds); +#else + sprintf(ts, "%s.%03ld", time_string, microseconds); +#endif + + RETVALUE(ROK); + +} +/*-- mt037.201 : Added new API for SGetSystemTsk --*/ +/* +* +* Fun: Get SGetSystemTsk +* +* Desc: This function is used to Get sytem task id +* +* Ret: task id +* +* Notes: +* +* File: mt_ss.c +* +--*/ +#ifdef ANSI +PUBLIC U32 SGetSystemTsk +( +Void +) +#else +PUBLIC U32 SGetSystemTsk() +#endif +{ + TRC1(SGetSystemTskS); + + RETVALUE(pthread_self()); + +} /* end of SGetSystemTsk */ + +#ifdef SS_MULTICORE_SUPPORT +/* +* +* Fun: Add Timer thread into system task table +* +* Desc: This function is used to add the system task +* associated with Timer thread. +* +* Ret: None +* +* Notes: +* +* File: mt_ss.c +* +--*/ +#ifdef ANSI +PRIVATE SsSTskEntry* ssdAddTmrSTsk(Void) +#else +PRIVATE SsSTskEntry* ssdAddTmrSTsk() +#endif +{ + SsSTskEntry *sTsk; + S16 ret; + + TRC1(ssdAddTmrSTsk); + sTsk = NULLP; + /* lock the system task table */ + ret = SLock(&osCp.sTskTblLock); + if (ret != ROK) + { + +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMT039, (ErrVal) ret, + "Could not lock system task table"); +#endif + + RETVALUE(sTsk); + } + + /* check count of system tasks */ + if (osCp.numSTsks == SS_MAX_STSKS) + { + + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMT040, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(sTsk); +#endif + } + +#if (ERRCLASS & ERRCLS_ADD_RES) + MTLOGERROR(ERRCLS_ADD_RES, EMT041, ERRZERO, "Too many system tasks"); +#endif + + RETVALUE(sTsk); + } + + + /* initialize the system task entry with the information we have */ + sTsk = &osCp.sTskTbl[osCp.nxtSTskEntry]; + + /* store the system task priority */ + sTsk->tskPrior = SS_NORM_TSK_PRI; + + /* initialize the demand queue */ + if (ssInitDmndQ(&sTsk->dQ) != ROK) + { + + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMT042, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(NULLP); +#endif + } + +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMT043, (ErrVal) ret, + "Could not initialize demand queue"); +#endif + + RETVALUE(NULLP); + } + + /* initialize the system task entry lock */ + if (SInitLock(&sTsk->lock, SS_STSKENTRY_LOCK) != ROK) + { + ssDestroyDmndQ(&sTsk->dQ); + + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMT044, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(NULLP); +#endif + } + +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMT045, (ErrVal) ret, + "Could not initialize system task entry lock"); +#endif + + RETVALUE(NULLP); + } + + + /* success, update the table */ + sTsk->tskId = osCp.nxtSTskEntry; + sTsk->used = TRUE; + sTsk->termPend = FALSE; + osCp.nxtSTskEntry = sTsk->nxt; + osCp.numSTsks++; + + /* unlock the system task table */ + + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMT046, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(NULLP); +#endif + } + + RETVALUE(sTsk); +} +#endif /* SS_MULTICORE_SUPPORT */ +/* mt003.301 Readwrite lock and recursive mutex additions */ +#ifdef SS_LOCK_SUPPORT +/* +* +* Fun: ssdInitLockNew +* +* Desc: This function is used to initialise lock/mutex +* +* Ret: ROK OK +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 ssdInitLockNew +( +SLockInfo *lockId, +U8 lockType +) +#else +PUBLIC S16 ssdInitLockNew(lockId, lockType) +SLockInfo *lockId; +U8 lockType; +#endif +{ + +#ifdef SS_REC_LOCK_SUPPORT + pthread_mutexattr_t attr; +#endif /* SS_REC_LOCK_SUPPORT */ + Txt prntBuf[PRNTSZE]; + S16 retVal = ROK; + + TRC1(ssdInitLockNew); + + switch(lockType) + { +#ifdef SS_RDWR_LOCK_SUPPORT + case SRDWRLOCK : + { + if((retVal = pthread_rwlock_init((&(lockId->l.rdWrLockId)), NULLP)) != ROK) + { + sprintf(prntBuf, "\n\n ssdInitLockNew(): Initialization of read write lock failed,Error# retVal %d\n", retVal); + SDisplay(0, prntBuf); + RETVALUE(RFAILED); + } + break; + } +#endif /* SS_RDWR_LOCK_SUPPORT */ +#ifdef SS_REC_LOCK_SUPPORT + case SMUTEXRECUR: + { + retVal = pthread_mutexattr_init(&attr); + + if(retVal != 0) + { + sprintf(prntBuf,"\n ssdInitLockNew(): mutexattr init failed,Error# %d \n",retVal); + SPrint(prntBuf); + RETVALUE(RFAILED); + } +#ifdef SS_LINUX + retVal = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP); +#else + retVal = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); +#endif + if(retVal != 0) + { + sprintf(prntBuf,"\n ssdInitLockNew(): mutexattr settype failed,Error# %d \n",retVal); + pthread_mutexattr_destroy(&attr); + SPrint(prntBuf); + RETVALUE(RFAILED); + } + retVal = pthread_mutex_init((pthread_mutex_t *)&(lockId->l.recurLock), &attr); + if(retVal != 0) + { + sprintf(prntBuf,"\n ssdInitLockNew(): mutex init failed,Error# %d \n",retVal); + pthread_mutexattr_destroy(&attr); + SPrint(prntBuf); + RETVALUE(RFAILED); + } + break; + } +#endif /* SS_REC_LOCK_SUPPORT */ + default : + { + sprintf(prntBuf, "\n\n ssdInitLockNew(): Invalid lock type %d\n", lockType); + SDisplay(0, prntBuf); + RETVALUE(RFAILED); + } + } + RETVALUE(ROK); +} +/* +* +* Fun: ssdLockNew +* +* Desc: This function is used to aquire the read write lock +* +* Ret: ROK OK +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 ssdLockNew +( +SLockInfo *lockId, +U8 lockType +) +#else +PUBLIC S16 ssdLockNew(lockId, lockType) +SLockInfo *lockId; +U8 lockType; +#endif +{ + + Txt prntBuf[PRNTSZE]; + S16 retVal = ROK; + + TRC1(ssdLockNew); + + switch(lockType) + { +#ifdef SS_RDWR_LOCK_SUPPORT + case SRDLOCK : + { + if((retVal = pthread_rwlock_rdlock(&(lockId->l.rdWrLockId))) != ROK) + { + sprintf(prntBuf, "\n\n ssdLockNew(): Failed to aquire the read lock,Error# %d\n", retVal); + SDisplay(0, prntBuf); + RETVALUE(RFAILED); + } + break; + } + case SWRLOCK : + { + if((retVal = pthread_rwlock_wrlock(&(lockId->l.rdWrLockId))) != ROK) + { + sprintf(prntBuf, "\n\n ssdLockNew(): Failed to aquire the write lock,Error# %d\n", retVal); + SDisplay(0, prntBuf); + RETVALUE(RFAILED); + } + break; + } + case STRYRDLOCK : + { + if((retVal = pthread_rwlock_tryrdlock(&(lockId->l.rdWrLockId))) != ROK) + { + sprintf(prntBuf, "\n\n ssdLockNew(): Failed to aquire the read lock,Error# %d\n", retVal); + SDisplay(0, prntBuf); + RETVALUE(RFAILED); + } + break; + } + case STRYWRLOCK: + { + if((retVal = pthread_rwlock_trywrlock(&(lockId->l.rdWrLockId))) != ROK) + { + sprintf(prntBuf, "\n\n ssdLockNew(): Failed to aquire the read lock,Error# %d\n", retVal); + SDisplay(0, prntBuf); + RETVALUE(RFAILED); + } + break; + } +#endif /* SS_RDWR_LOCK_SUPPORT */ +#ifdef SS_REC_LOCK_SUPPORT + case SMUTEXRECUR: + { + if((retVal = pthread_mutex_lock(&(lockId->l.recurLock)) != ROK)) + { + sprintf(prntBuf, "\n\n ssdLockNew(): Failed to aquire the recursive mutex,Error# %d\n", retVal); + SDisplay(0, prntBuf); + RETVALUE(RFAILED); + } + break; + } +#endif /* SS_REC_LOCK_SUPPORT */ + default : + { + sprintf(prntBuf, "\n\n ssdLockNew(): Invalid lock type %d\n", lockType); + SDisplay(0, prntBuf); + RETVALUE(RFAILED); + } + } + + RETVALUE(ROK); +} + + +/* +* +* Fun: ssdUnlockNew +* +* Desc: This function is used to Unlock the read write lock +* +* Ret: ROK OK +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 ssdUnlockNew +( +SLockInfo *lockId, +U8 lockType +) +#else +PUBLIC S16 ssdUnlockNew(lockId, lockType) +SLockInfo *lockId; +U8 lockType; +#endif +{ + + Txt prntBuf[PRNTSZE]; + S16 retVal = ROK; + + TRC1(ssdUnlockNew); + + switch(lockType) + { +#ifdef SS_RDWR_LOCK_SUPPORT + case SRDWRLOCK : + { + if((retVal = pthread_rwlock_unlock(&(lockId->l.rdWrLockId))) != ROK) + { + sprintf(prntBuf, "\n\n ssdUnLockNew(): Failed to unlock the lock,Error# %d\n", retVal); + SDisplay(0, prntBuf); + RETVALUE(RFAILED); + } + break; + } +#endif /* SS_RDWR_LOCK_SUPPORT */ +#ifdef SS_REC_LOCK_SUPPORT + case SMUTEXRECUR: + { + if((retVal = pthread_mutex_unlock(&(lockId->l.recurLock)) != ROK)) + { + sprintf(prntBuf, "\n\n ssdUnLockNew(): Failed to aquire the recursive mutex,Error# %d\n", retVal); + SDisplay(0, prntBuf); + RETVALUE(RFAILED); + } + break; + } +#endif /* SS_REC_LOCK_SUPPORT */ + default : + { + sprintf(prntBuf, "\n\n ssdUnlockNew(): Invalid lock type %d\n", lockType); + SDisplay(0, prntBuf); + RETVALUE(RFAILED); + } + } + RETVALUE(ROK); +} + +/* +* +* Fun: ssdDestroyLockNew +* +* Desc: This function is used to destroy the read write lock +* +* Ret: ROK OK +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 ssdDestroyLockNew +( +SLockInfo *lockId, +U8 lockType +) +#else +PUBLIC S16 ssdDestroyLockNew(lockId, lockType) +SLockInfo *lockId; +U8 lockType; +#endif +{ + Txt prntBuf[PRNTSZE]; + S16 retVal = ROK; + + TRC1(ssdDestroyLockNew); + + switch(lockType) + { +#ifdef SS_RDWR_LOCK_SUPPORT + case SRDWRLOCK : + { + if((retVal = pthread_rwlock_destroy(&(lockId->l.rdWrLockId))) != ROK) + { + sprintf(prntBuf, "\n\n ssdDestroyLockNew(): Failed to destroy the lock,Error# %d\n", retVal); + SDisplay(0, prntBuf); + RETVALUE(RFAILED); + } + break; + } +#endif /* SS_RDWR_LOCK_SUPPORT */ +#ifdef SS_REC_LOCK_SUPPORT + case SMUTEXRECUR: + { + if((retVal = pthread_mutex_destroy(&(lockId->l.recurLock)) != ROK)) + { + sprintf(prntBuf, "\n\n ssdDestroyLockNew(): Failed to destroy the mutex,Error# %d\n", retVal); + SDisplay(0, prntBuf); + RETVALUE(RFAILED); + } + break; + } +#endif /* SS_REC_LOCK_SUPPORT */ + default : + { + sprintf(prntBuf, "\n\n ssdDestroyLockNew(): Invalid lock type %d\n", lockType); + SDisplay(0, prntBuf); + RETVALUE(RFAILED); + } + } + RETVALUE(ROK); +} +#endif /* SS_LOCK_SUPPORT */ + +/* mt005.301 : Cavium Changes */ +#ifdef SS_SEUM_CAVIUM + +/* + * + * Fun: ssInitRcvWork + * + * Desc: This is the initializtion function of receive + * work thread. + * + * Ret: ROK - ok + * RFAILED - failed, general (optional) + * + * Notes: Function to initialize the work queue packet + * receiving thread. This creates the new thread to + * receive the work and sets the affinity. + * + * File: + * + **/ +#ifdef ANSI +PUBLIC S16 ssInitRcvWork +( + void + ) +#else +PUBLIC S16 ssInitRcvWork() +#endif +{ + pthread_attr_t attr; + pthread_t thread; + + TRC1(ssInitRcvWork); + + /* set the required attributes */ + pthread_attr_init(&attr); + pthread_attr_setstacksize(&attr, (size_t)MT_ISTASK_STACK); + pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + + /* Create a new thread to receive the work queue messages */ + if ((pthread_create(&thread, &attr, workRcvTsk, NULLP)) != 0) + { + pthread_attr_destroy(&attr); + + RETVALUE(RFAILED); + } + + pthread_attr_destroy(&attr); + + RETVALUE(ROK); + +}/* ssInitRcvWork */ + + +/* + * + * Fun: workRcvTsk + * + * Desc: This is the handler function of receive + * work thread. + * + * Ret: ROK - ok + * RFAILED - failed, general (optional) + * + * Notes:The handler function of the work queue receiver task. + * This will be waiting for the work and after receiving + * it, work will converted and posted to that entityt + * + * File: + * + **/ + +#ifdef ANSI +PRIVATE void *workRcvTsk +( + Ptr ptr + ) +#else +PRIVATE void *workRcvTsk (ptr) + Ptr ptr; +#endif +{ + + cvmx_wqe_t *workPtr; + Buffer *mBuf, *rcvdBuf; + SsMsgInfo *minfoPtr; + S16 ret; + struct timespec ts; + Pst pst; + + TRC1(workRcvTsk); + + + for (;;) + { + /* get the work if its avilable */ + workPtr = cvmx_pow_work_request_sync(CVMX_POW_NO_WAIT); + + if ( workPtr == NULLP ) + { + /* If there is no work then sleep for 10 usec */ + ts.tv_sec = 0; + ts.tv_nsec = 500000; + + nanosleep(&ts, NULLP); + continue; + } + + switch(workPtr->tag) + { + /* Switch over according to the tag value */ + case SS_CVMX_MBUF_TAG: + + rcvdBuf = (Buffer*)workPtr->packet_ptr.ptr; + + /* Convert the physical address to Pointers */ + ret = SConvPhyPtr(&rcvdBuf); + if (ret != ROK) + { + /* mt011.301: Cavium 32 bit changes */ + cvmx_fpa_free(workPtr, SS_CVMX_WQE_POOL, 0); + continue; + } + + /* Copy the buffer to this region */ + ret = SCpyFpaMsg(rcvdBuf, SS_DFLT_REGION, SS_DFLT_POOL, &mBuf); + if( ret != ROK ) + { + /* mt011.301: Cavium 32 bit changes */ + cvmx_fpa_free(workPtr, SS_CVMX_WQE_POOL, 0); + continue; + } + + /* mt011.301: Cavium 32 bit changes */ + cvmx_fpa_free(workPtr, SS_CVMX_WQE_POOL, 0); + + minfoPtr = (SsMsgInfo*)mBuf->b_rptr; + + /* Get the post strucutre and Post the message */ + if ( minfoPtr != NULLP) + { + SMemCpy( &pst, &minfoPtr->pst, sizeof(Pst)); + + (Void)SPstTsk(&pst, mBuf); + } + /* Free the buffer allocated if it cannot be sent */ + else + { + SPutMsg(mBuf); + } + break; + + default: + { + /* Invalid tag value, drop the work */ + /* mt011.301: Cavium 32 bit changes */ + cvmx_fpa_free(workPtr, SS_CVMX_WQE_POOL, 0); + continue; + } + break; + } + + } +} /* workRcvTsk */ + +#endif /* SS_SEUM_CAVIUM */ + +#ifdef TENB_RTLIN_CHANGES +PUBLIC S16 SInitLock(SLockId *l, U8 t) +{ + S16 r = 0; + pthread_mutexattr_t prior; + pthread_mutexattr_init(&prior); +#ifndef RGL_SPECIFIC_CHANGES + pthread_mutexattr_setprotocol(&prior, PTHREAD_PRIO_INHERIT); +#endif + r = pthread_mutex_init(l, &prior); + pthread_mutexattr_destroy(&prior); + return r; +} +#endif +#ifdef SS_THR_REG_MAP +/* + * + * Fun: ssRegMainThread + * + * Desc: This function is used to add the memory region + * mapping for the main thread. + * + * Ret: VOID (Always successful) + * + * Notes: + * + * File: mt_ss.c + * + */ + +PUBLIC Void ssRegMainThread(Void) +{ + +#if 0 +#else + if(SS_INVALID_THREAD_REG_MAP != SS_GET_THREAD_MEM_REGION()) +#endif + { + printf("not able to get different Id for main thread\n"); + exit(1); + } + /* Here the default region is added as we dont have any region associated with + * Main thread. The thread should not perform any allocation except + * the initial configuratin + */ +#if 0 +#else +#ifdef XEON_SPECIFIC_CHANGES + SS_GET_THREAD_MEM_REGION() = mtMemoCfg.numRegions; +#else + SS_GET_THREAD_MEM_REGION() = +#endif +#endif + DFLT_REGION; +} + +/* + * + * Fun: ssCheckAndAddMemoryRegionMap + * + * Desc: This function is used to add the memory region + * mapping for the provided sTsk associated thread. + * If the threadId can be placed in the thread memory + * region mapping table and returns success if it is able + * to place. If not, it keeps the thread ID in the static + * local array and increments the count. Once thread Id + * is successfully placed in the thread memory region mapping + * table, pthread_cancel is sent for all the previous threads + * which are failed to place in table. + * + * Ret: TRUE - Thread ID successfully placed in thread memory region + * mapping table + * FALSE - If thread Id is not placed in thread memory region + * mapping table + * + * Notes:mapping tablemapping tablng tablee + * + * File: mt_ss.c + * + */ +PUBLIC S32 ssCheckAndAddMemoryRegionMap +( +pthread_t threadId, /* Thread Id of system task */ +Region region /* Region associated with thread */ +) +{ + PRIVATE U32 createdThreads; + PRIVATE pthread_t createdThreadIds[SS_MAX_THREAD_CREATE_RETRY]; + U32 indx; + + TRC1(ssCheckAndAddMemoryRegionMap); + + /* Here 0xFF is considered as invalid region and if the mapping table + * contains 0xFF, that mapping entry is free + */ +#if 0 +#else + if(SS_INVALID_THREAD_REG_MAP != + osCp.threadMemoryRegionMap[((threadId >> SS_MEM_THREAD_ID_SHIFT) % SS_MAX_THREAD_REGION_MAP)]) +#endif + { + /* Klock work fix ccpu00148484 */ + if(!(createdThreads < SS_MAX_THREAD_CREATE_RETRY)) + { + printf("failed in index = %ld\n", ((threadId >> SS_MEM_THREAD_ID_SHIFT) % SS_MAX_THREAD_REGION_MAP)); + printf("Not able to get the different thread ID, exiting\n"); + exit(1); + } + createdThreadIds[createdThreads++] = threadId; + RETVALUE(FALSE); + } + /* If we found free mapping table entry, place the region and send pthread_cancel + * for all the thread Ids which are created before this + */ +#if 0 +#else + osCp.threadMemoryRegionMap[((threadId >> SS_MEM_THREAD_ID_SHIFT) % SS_MAX_THREAD_REGION_MAP)] = region; +#ifdef XEON_SPECIFIC_CHANGES + printf("ThreadId %ld, Thread Idx %d, Region %d\n", threadId, + ((threadId >> SS_MEM_THREAD_ID_SHIFT) % + SS_MAX_THREAD_REGION_MAP), region); +#endif +#endif + for(indx = 0; indx < createdThreads; indx++) + { +#ifdef XEON_SPECIFIC_CHANGES + printf("Sending pthred Cancel to thread Id %d \n",createdThreadIds[indx]); +#endif + pthread_cancel(createdThreadIds[indx]); + } + createdThreads = 0; + + RETVALUE(TRUE); + +} /* ssCheckAndAddMemoryRegionMap */ + +/* + * + * Fun: ssCheckAndDelMemoryRegionMap + * + * Desc: This function is used to add the memory region + * mapping for the provided sTsk associated thread. + * If the threadId can be placed in the thread memory + * region mapping table and returns success if it is able + * to place. If not, it keeps the thread ID in the static + * local array and increments the count. Once thread Id + * is successfully placed in the thread memory region mapping + * table, pthread_cancel is sent for all the previous threads + * which are failed to place in table. + * + * Ret: TRUE - Thread ID successfully placed in thread memory region + * mapping table + * FALSE - If thread Id is not placed in thread memory region + * mapping table + * + * Notes:mapping tablemapping tablng tablee + * + * File: mt_ss.c + * + */ +PUBLIC S32 ssCheckAndDelMemoryRegionMap +( +pthread_t threadId /* Thread Id of system task */ +) +{ + + TRC1(ssCheckAndDelMemoryRegionMap); + + /* Raghu To-Do Check with team, is it necessary to acquire lock + * as del and add may go parallel */ + /* Here 0xFF is considered as invalid region and if the mapping table + * contains 0xFF, that mapping entry is free + */ + if(SS_INVALID_THREAD_REG_MAP == + osCp.threadMemoryRegionMap[((threadId >> SS_MEM_THREAD_ID_SHIFT) % SS_MAX_THREAD_REGION_MAP)]) + { +#ifndef ALIGN_64BIT + printf("Invalid Thread ID (%ld)\n", (U32)threadId); +#else + printf("Invalid Thread ID (%d)\n", (U32)threadId); +#endif + RETVALUE(RFAILED); + } + /* If we found free mapping table entry, place the region and send pthread_cancel + * for all the thread Ids which are created before this + */ + osCp.threadMemoryRegionMap[((threadId >> SS_MEM_THREAD_ID_SHIFT) % SS_MAX_THREAD_REGION_MAP)] = SS_INVALID_THREAD_REG_MAP; + + RETVALUE(ROK); + +} /* ssCheckAndAddMemoryRegionMap */ + + +#endif +#ifdef SS_TSKLOG_ENABLE +/* +* +* Fun: SStartTask +* +* Desc: This function will return current time through input parameter. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* +* File: pt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 SStartTask +( +VOLATILE U32 *startTime, +U32 taskId +) +#else +PUBLIC S16 SStartTask(startTime, taskId) +VOLATILE U32 *startTime; +U32 taskId; +#endif +{ +#ifdef MSPD_MLOG_NEW + *startTime = GetTIMETICK(); +#endif + RETVALUE(ROK); +} + +/* +* +* Fun: SStopTask +* +* Desc: This function will return current time through input parameter. +* and take the difference of start time provided as input parameter +* and current time. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* +* File: pt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 SStopTask +( +VOLATILE U32 startTime, +U32 taskId +) +#else +PUBLIC S16 SStopTask(startTime, taskId) +VOLATILE U32 startTime; +U32 taskId; +#endif +{ + /*U32 stopTime;*/ + switch(taskId) + { + case PID_MAC_HARQ_IND: + case PID_SCH_TTI_IND: + case PID_SSI_TSK: + case PID_MAC_DAT_IND: + case PID_MAC_SF_ALLOC_REQ: + case PID_MAC_STA_RSP: + case PID_MAC_DL_SCHD: + case PID_MAC_DL_CQI_IND: + case PID_MAC_UL_CQI_IND: + case PID_MAC_UL_SCHD: + case PID_MAC_TTI_IND: + case PID_CL_RCV_PHY_MSG: + case PID_CL_HARQ_STA_IND: + case PID_MAC_AM_HARQ_RLS: + case PID_CL_DL_BATCH_PROC: + case PID_CL_DLM_PRC_TTI_IND: + case PID_CRC_IND_REAL: + case PID_CRC_IND_DUMMY: + case PID_TTI_LATENCY: + case PID_RECPREQ_PROC: +#ifdef CA_PHY +#ifndef LTE_TDD + MLogTask(0, taskId, RESOURCE_LARM, startTime, GetTIMETICK()); +#else + MLogTask(taskId, RESOURCE_LARM, startTime, GetTIMETICK()); +#endif +#else + MLogTask(taskId, RESOURCE_LARM, startTime, GetTIMETICK()); +#endif + break; + } + RETVALUE(ROK); +} +#else +#ifdef ANSI +PUBLIC S16 SStartTask +( +VOLATILE U32 * startTime, +U32 taskId +) +#else +PUBLIC S16 SStartTask(startTime, taskId) +VOLATILE U32 * startTime; +U32 taskId; +#endif +{ + *startTime = 0; + RETVALUE(ROK); +} + +#ifdef ANSI +PUBLIC S16 SStopTask +( +VOLATILE U32 startTime, +U32 taskId +) +#else +PUBLIC S16 SStopTask(startTime, taskId) +VOLATILE U32 startTime; +U32 taskId; +#endif +{ + RETVALUE(ROK); +} + +#endif /*#ifdef SS_TSKLOG_ENABLE */ +#ifdef TENB_T2K3K_SPECIFIC_CHANGES +/** @details +* This primitive is used to calculate the CPU Utilization per Core +* for Intel T2200 +* +* @param [in] Void +* +* @return Void - function is always success +*/ +#ifdef ANSI +PUBLIC Void UpdateSocCpuInfo +( +CmCpuStatsInfo *cpuInfo, +U8 idx +) +#else +PUBLIC Void UpdateSocCpuInfo(*cpuInfo, idx) +CmCpuStatsInfo *cpuInfo; +U8 idx; +#endif +{ + FILE *mipsFd; + S8 mipsStr[MIPS_STRING_LEN]; + S8 *strPart; + U32 l2FreeCpu; + U32 l2CpuUsed; + U32 l3FreeCpu; + U32 l3CpuUsed; + + /* Open the file which holds the MIPS available value */ + mipsFd = fopen(MIPS_FILE, "r"); + + if(mipsFd == NULLP) + { + RETVOID; + } + + /* Get the free mips available value from the file */ + if(NULLP == fgets(mipsStr, 24, mipsFd)) + { + printf("fgets to get the free mips available failed\n"); + fclose(mipsFd); + RETVOID; + } + + strtok(mipsStr, " "); + + strPart = strtok(NULLP, " "); + + if(idx == CM_L2_CPU_UTIL) + { + if(strPart != NULLP) + { + l2FreeCpu = atoi(strPart); + l2CpuUsed = 100 - l2FreeCpu; + cpuInfo->cpuUtil[0].totCpuUtil += l2CpuUsed; + cpuInfo->cpuUtil[0].maxCpuUtil = GET_CPU_MAX((cpuInfo->cpuUtil[0].maxCpuUtil), l2CpuUsed);; + cpuInfo->cpuUtil[0].numSamples++; + } + } + if(idx == CM_L3_CPU_UTIL) + { + strPart = strtok(NULLP, " "); + if(strPart != NULLP) + { + l3FreeCpu = atoi(strPart); + l3CpuUsed = 100 - l3FreeCpu; + cpuInfo->cpuUtil[0].totCpuUtil += l3CpuUsed; + cpuInfo->cpuUtil[0].maxCpuUtil = GET_CPU_MAX((cpuInfo->cpuUtil[0].maxCpuUtil), l3CpuUsed);; + cpuInfo->cpuUtil[0].numSamples++; + } + } + if(idx == CM_L2_CPU_UTIL) + { + cpuInfo->numCores = CM_NUM_L2_CORES ; + } + else if(idx == CM_L3_CPU_UTIL) + { + cpuInfo->numCores = CM_NUM_L3_CORES ; + } + fclose(mipsFd); + + RETVOID; +} +#endif /* TENB_T2K3K_SPECIFIC_CHANGES */ +#ifdef SS_MULTICORE_SUPPORT +/* +* +* Fun: Add Timer thread into system task table +* +* Desc: This function is used to add the system task +* associated with Timer thread. +* +* Ret: None +* +* Notes: +* +* File: mt_ss.c +* +--*/ +#ifdef ANSI +PRIVATE SsSTskEntry* ssdReAddTmrSTsk( +U8 idx +) +#else +PRIVATE SsSTskEntry* ssdReAddTmrSTsk(idx) +U8 idx; +#endif +{ + SsSTskEntry *sTsk; + S16 ret; + + TRC1(ssdReAddTmrSTsk); + sTsk = NULLP; + /* lock the system task table */ + ret = SLock(&osCp.sTskTblLock); + if (ret != ROK) + { + +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMT039, (ErrVal) ret, + "Could not lock system task table"); +#endif + + RETVALUE(sTsk); + } + + /* initialize the system task entry with the information we have */ + sTsk = &osCp.sTskTbl[idx]; + + sTsk->used = FALSE; + sTsk->tskPrior = 0; + sTsk->numTTsks = 0; + SDestroyLock(&sTsk->lock); + ssDestroyDmndQ(&sTsk->dQ); + + + /* store the system task priority */ + sTsk->tskPrior = SS_NORM_TSK_PRI; + + /* initialize the demand queue */ + if (ssInitDmndQ(&sTsk->dQ) != ROK) + { + + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMT042, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(NULLP); +#endif + } + +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMT043, (ErrVal) ret, + "Could not initialize demand queue"); +#endif + + RETVALUE(NULLP); + } + + /* initialize the system task entry lock */ + if (SInitLock(&sTsk->lock, SS_STSKENTRY_LOCK) != ROK) + { + ssDestroyDmndQ(&sTsk->dQ); + + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMT044, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(NULLP); +#endif + } + +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMT045, (ErrVal) ret, + "Could not initialize system task entry lock"); +#endif + + RETVALUE(NULLP); + } + + + /* success, update the table */ + sTsk->tskId = idx + 1; + sTsk->used = TRUE; + sTsk->termPend = FALSE; + + /* unlock the system task table */ + + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMT046, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(NULLP); +#endif + } + + RETVALUE(sTsk); +} +#endif /* SS_MULTICORE_SUPPORT */ + + +/* +* +* Fun: Initialize timer table +* +* Desc: This function initializes MTSS-specific information +* in the timer table. +* +* Ret: ROK - ok +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 ssdReInitTmr +( +void +) +#else +PUBLIC S16 ssdReInitTmr() +#endif +{ + pthread_attr_t attr; + struct sched_param param_sched; +#ifndef XEON_SPECIFIC_CHANGES + U8 ret = ROK; +#endif +#ifdef SS_MULTICORE_SUPPORT + SsSTskEntry *sTsk; +#endif /* SS_MULTICORE_SUPPORT */ +#ifdef SS_THR_REG_MAP + U32 threadCreated = FALSE; +#endif /* SS_THR_REG_MAP */ + + TRC0(ssdReInitTmr); + +#ifndef XEON_SPECIFIC_CHANGES + ret = ssCheckAndDelMemoryRegionMap(osCp.dep.tmrHdlrTID); + if(ret != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + MTLOGERROR(ERRCLS_DEBUG, EMT046, ERRZERO, + "Could not give the Semaphore"); +#endif + RETVALUE(RFAILED); + } +#endif + + osCp.dep.tmrTqCp.tmrLen = SS_MAX_TMRS; + /* mt010.21: addition */ + +#ifdef SS_MULTICORE_SUPPORT + sTsk = ssdReAddTmrSTsk(0); + if(!sTsk) + { + RETVALUE(RFAILED); + } +#endif /* SS_MULTICORE_SUPPORT */ + /* create the timer handler thread */ + + pthread_attr_init(&attr); + /* mt021.201 - Addition to set stack size */ + pthread_attr_setstacksize(&attr, (size_t)MT_TMRTASK_STACK); + pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + pthread_attr_setschedpolicy(&attr, SCHED_FIFO); + param_sched.sched_priority = sched_get_priority_max(SCHED_FIFO); + pthread_attr_setschedparam(&attr, ¶m_sched); + + +#ifdef SS_THR_REG_MAP + /* When the thread is created, we check for the memory mapping table if + * threadId can be placed in thread memory map table. If it is not able to place + * threadId is stored in tmporary array. Once thread is created successful, + * thread_cancel is sent for each thread which are created before. All the + * threads are made to wait on sema which is cancel point for thread. + */ + while(threadCreated == FALSE) + { +#endif + if ((pthread_create(&osCp.dep.tmrHdlrTID, &attr, mtTmrHdlr, NULLP)) != 0) + { + /* mt020.201 - Addition for destroying thread attribute object attr */ + pthread_attr_destroy(&attr); + + RETVALUE(RFAILED); + } + +#ifdef SS_THR_REG_MAP + threadCreated = ssCheckAndAddMemoryRegionMap(osCp.dep.tmrHdlrTID, + sTsk->region); + } +#endif /* SS_THR_REG_MAP */ +#ifdef SS_MEM_WL_DEBUG + tmpRegTidMap[sTsk->region] = osCp.dep.tmrHdlrTID; +#endif + + /* mt020.201 - Addition for destroying thread attribute object attr */ + pthread_attr_destroy(&attr); + sem_post(&osCp.dep.ssStarted); + RETVALUE(ROK); +} + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/mt/mt_ss_wl.x b/src/mt/mt_ss_wl.x new file mode 100755 index 000000000..96198b503 --- /dev/null +++ b/src/mt/mt_ss_wl.x @@ -0,0 +1,219 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/********************************************************************20** + + Name: MTSS -- implementation specific definitions + + Type: C include file + + Desc: Data structure definitions demanded by systems services. + The contents of these are for the MTSS implementation. + + File: mt_ss.x + +*********************************************************************21*/ + + +#ifndef __MTSSWLX__ +#define __MTSSWLX__ + +#if 0 +/* mt001.301: Addition */ +#ifdef SS_LOGGER_SUPPORT +/* #define __USE_POSIX */ +#include +#include +#endif /* SS_LOGGER_SUPPORT */ + +/* TAPA task entry doesn't need anything extra for MTSS */ +typedef S8 SsdTTskEntry; + + +/* System task entry */ +typedef struct ssdSTskEntry +{ + pthread_t tId; + Ent ent; + Inst inst; + SLockId lock; + +#ifdef SS_MULTICORE_SUPPORT + U32 lwpId; +#endif /* SS_MULTICORE_SUPPORT */ +} SsdSTskEntry; + + +#ifdef SS_DRVR_SUPPORT +/* Driver task entry */ +typedef struct ssdDrvrTskEntry +{ + Bool flag; + +} SsdDrvrTskEntry; +#endif + + +/* timer entry--MTSS uses common timers */ +typedef struct ssdTmrEntry +{ + CmTimer timers[TMR_DEF_MAX]; + +} SsdTmrEntry; + + +/* dynamic pool doesn't need anything extra for MTSS */ +typedef S8 SsdDPoolEntry; + + +/* static pool -- information for the memory management scheme */ +typedef S8 SsdSPoolEntry; + + +/* generic pool doesn't need anything extra for MTSS */ +typedef S8 SsdPoolEntry; + + +/* region doesn't need anything extra for MTSS */ +typedef S8 SsdRegionEntry; + + +/* system services control point--tick count, timer implementation, + * console implementation, IS task implementation + */ +typedef struct ssdOs +{ + unsigned randSeed; /* random number generator seed */ + + Ticks sysTicks; /* elapsed system ticks */ + + pthread_t tmrHdlrTID; /* timer handler thread */ + CmTqCp tmrTqCp; /* common timer control point */ + CmTqType tmrTq[SS_MAX_TMRS]; /* common timer queue */ + + sem_t ssStarted; /* posted when SS completes init */ +#ifdef CONAVL + FILE *conInFp; /* console input file pointer */ + FILE *conOutFp; /* console output file pointer */ + pthread_t conHdlrTID; /* console handler thread ID */ +#endif + +#ifndef NOFILESYS + FILE *fileOutFp; /* output file pointer */ +#endif + +#ifdef SS_DRVR_SUPPORT + pthread_t isTskHdlrTID; /* IS task handler thread ID */ + int isFildes[2]; /* pipe for SSetIntPend to isTskHdlr */ +#endif + Bool sigEvnt; /*mt010.301 Flag to check interupt signal(SIGINT)*/ + +} SsdOs; + +/* mt018.201 - added for memory configuration */ +typedef struct mtBktCfg +{ + Size blkSize; /* bucket quantum size */ + U32 numBlks; /* the total blocks in the bucket */ +} MtBktCfg; + +typedef struct mtRegCfg +{ + Region regionId; + U16 numBkts; + Size heapsize; + MtBktCfg bkt[SS_MAX_POOLS_PER_REG]; +} MtRegCfg; + +typedef struct mtMemCfg +{ + U8 numRegions; + MtRegCfg region[SS_MAX_REGS]; +} MtMemCfg; + +#endif + + + + +typedef struct mtDynBktCfg +{ + U16 blkSetRelThreshold; /* threshold value for releasing memory blocks */ + U16 blkSetAcquireThreshold; /* threshold for requesting additional memory blocks */ +} MtDynBktCfg; + +/* The number of blocks in the buckets and size of bloks must be + same as the configured in mtGlobMemCfg. */ +typedef struct mtDynRegCfg +{ + Region regionId; /* Region Id */ + U16 numBkts; /* Number of buckets */ + MtDynBktCfg bkt[SS_MAX_POOLS_PER_REG]; /* Threshold value configuration for each buckets */ +} MtDynRegCfg; + +/* This structure is used to store the initial values of the configuraiton + * of the individual system taks regions. The number of buckets is same + * as of the one configured in the gloabl region */ +typedef struct mtDynMemCfg +{ + U8 numRegions; /* Number of regions */ + MtDynRegCfg region[SS_MAX_REGS]; /* Configuration details of each region */ +} MtDynMemCfg; + +/* Global bucket configuration, the number of bucket, block size and the memory + * block set size for each bucket */ +typedef struct mtGlobBktCfg +{ + Size blkSize; /* bucket quantum size */ + U32 numBlks; /* the total blocks in the bucket */ + U16 bucketSetSize; /* Size of each bucket set */ +} MtGlobBktCfg; + +typedef struct mtGlobMemCfg +{ + U16 numBkts; +#ifdef XEON_SPECIFIC_CHANGES + Size heapSize; +#endif + MtGlobBktCfg bkt[SS_MAX_POOLS_PER_REG]; +}MtGlobMemCfg; + + +#if 0 + +/* mt003.301 Readwrite lock additions */ +#ifdef SS_LOCK_SUPPORT +typedef struct sLockInfo +{ + union + { +#ifdef SS_RDWR_LOCK_SUPPORT + pthread_rwlock_t rdWrLockId; +#endif /* SS_RDWR_LOCK_SUPPORT */ +#ifdef SS_REC_LOCK_SUPPORT + pthread_mutex_t recurLock; +#endif /* SS_REC_LOCK_SUPPORT */ + }l; +}SLockInfo; +#endif /* SS_LOCK_SUPPORT */ +#endif /* __MTSSX__ */ +#endif + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/mt/ss_drvr.c b/src/mt/ss_drvr.c new file mode 100644 index 000000000..3bc15db06 --- /dev/null +++ b/src/mt/ss_drvr.c @@ -0,0 +1,308 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/********************************************************************20** + + Name: System Services -- Driver + + Type: C source file + + Desc: Source code for those functions in System Services + that exist for driver support. + + File: ss_drvr.c + +*********************************************************************21*/ + + + +/* header include files (.h) */ + +#include "envopt.h" /* environment options */ +#include "envdep.h" /* environment dependent */ +#include "envind.h" /* environment independent */ + +#include "gen.h" /* general layer */ +#include "ssi.h" /* system services */ + +#include "ss_err.h" /* errors */ +#include "ss_dep.h" /* implementation-specific */ +#include "ss_queue.h" /* queues */ +#include "ss_msg.h" /* messaging */ +#include "ss_mem.h" /* memory management interface */ +#include "ss_gen.h" /* general */ +#include "cm_mem.h" /* memory management */ + + + +/* header/extern include files (.x) */ + +#include "gen.x" /* general layer */ +#include "ssi.x" /* system services */ + + +#include "ss_dep.x" /* implementation-specific */ +#include "ss_queue.x" /* queues */ +#include "ss_task.x" /* tasking */ +#include "ss_timer.x" /* timers */ +#include "ss_strm.x" /* STREAMS */ +#include "ss_msg.x" /* messaging */ +#include "ss_mem.x" /* memory management interface */ +#include "ss_drvr.x" /* driver tasks */ +#ifdef SS_LOCKLESS_MEMORY +#include "cm_llist.x" +#include "cm_hash.x" +#include "cm_mem_wl.x" /* common memory manager */ +#else +#include "cm_mem.x" /* common memory manager */ +#endif /* SS_LOCKLESS_MEMORY */ +#include "ss_gen.x" /* general */ + + +#ifdef SS_DRVR_SUPPORT + + + +/* +* +* Fun: SRegDrvrTsk +* +* Desc: This function is used to register a driver task. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: +* +* File: ss_drvr.c +* +*/ +#ifdef ANSI +PUBLIC S16 SRegDrvrTsk +( +Inst channel, /* channel instance */ +ProcId low, /* processor ID -- low */ +ProcId high, /* processor ID -- high */ +ActvTsk actvTsk, /* activation function */ +ISTsk isTsk /* interrupt service function */ +) +#else +PUBLIC S16 SRegDrvrTsk(channel, low, high, actvTsk, isTsk) +Inst channel; /* channel instance */ +ProcId low; /* processor ID -- low */ +ProcId high; /* processor ID -- high */ +ActvTsk actvTsk; /* activation function */ +ISTsk isTsk; /* interrupt service function */ +#endif +{ + S16 ret; +#if (ERRCLASS & ERRCLS_INT_PAR) + +/* ss029.103: modification: multiple procId related changes */ +#ifndef SS_MULTIPLE_PROCS + ProcId thisProcId; +#endif + +/* ss029.103: modification: multiple procId related changes */ +#ifdef SS_MULTIPLE_PROCS + U16 count; + U16 i; + ProcId procIdLst[SS_MAX_PROCS]; +#endif /* SS_MULTIPLE_PROCS */ + +#endif + + TRC1(SRegDrvrTsk); + +#if (ERRCLASS & ERRCLS_INT_PAR) + +/* ss029.103: modification: multiple procId related changes */ +#ifdef SS_MULTIPLE_PROCS + if (SGetProcIdLst(&count, procIdLst) != ROK) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS001, ERRZERO, "Null procId list"); + RETVALUE(RFAILED); + } + + for (i = 0; i < count; i++) + { + if (procIdLst[i] >= low && procIdLst[i] <= high) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS002, ERRZERO, "Invalid procId range"); + RETVALUE(RFAILED); + } + } +#else /* SS_MULTIPLE_PROCS */ + thisProcId = SFndProcId(); + if (thisProcId >= low && thisProcId <= high) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS003, ERRZERO, "Invalid procId range"); + RETVALUE(RFAILED); + } +#endif /* SS_MULTIPLE_PROCS */ + + if (channel >= SS_MAX_DRVRTSKS) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS004, channel, "Invalid channel"); + RETVALUE(RFAILED); + } + + /* check activation functions */ + if (actvTsk == NULLP || isTsk == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS005, ERRZERO, "Null pointer"); + RETVALUE(RFAILED); + } + + /* check if already registered */ + if (osCp.drvrTskTbl[channel].used == TRUE) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS006, ERRZERO, + "Driver task already registered"); + RETVALUE(RFAILED); + } +#endif + + +#if (ERRCLASS & ERRCLS_DEBUG) + /* check count of tasks */ + if (osCp.numDrvrTsks == SS_MAX_DRVRTSKS) + { + SSLOGERROR(ERRCLS_DEBUG, ESS007, ERRZERO, "Too many tasks"); + RETVALUE(ROUTRES); + } +#endif + + + if (SInitLock(&osCp.drvrTskTbl[channel].lock, SS_DRVRENTRY_LOCK) != ROK) + { + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS008, ERRZERO, "Could not initialize lock"); +#endif + + RETVALUE(RFAILED); + } + + osCp.drvrTskTbl[channel].channel = channel; + osCp.drvrTskTbl[channel].actvTsk = actvTsk; + osCp.drvrTskTbl[channel].isTsk = isTsk; + osCp.drvrTskTbl[channel].low = low; + osCp.drvrTskTbl[channel].high = high; + + ret = ssdRegDrvrTsk(&osCp.drvrTskTbl[channel]); + if (ret != ROK) + { + osCp.drvrTskTbl[channel].channel = 0; + osCp.drvrTskTbl[channel].actvTsk = NULLP; + osCp.drvrTskTbl[channel].isTsk = NULLP; + osCp.drvrTskTbl[channel].low = 0; + osCp.drvrTskTbl[channel].high = 0; + SDestroyLock(&osCp.drvrTskTbl[channel].lock); + } + else + { + osCp.drvrTskTbl[channel].used = TRUE; + osCp.numDrvrTsks++; + } + + + RETVALUE(ret); +} + +/* ss001.301: Additions */ +/* +* +* Fun: SDeregDrvrTsk +* +* Desc: This function is used to de-register a driver task. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: +* +* File: ss_drvr.c +* +*/ +#ifdef ANSI +PUBLIC S16 SDeregDrvrTsk +( +Inst channel /* channel instance */ +) +#else +PUBLIC S16 SDeregDrvrTsk(channel) +Inst channel; +#endif +{ + /* ss002.301 Modifications */ + TRC1(SRegDrvrTsk); + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (channel >= SS_MAX_DRVRTSKS) + { + SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, channel, "Invalid channel"); + RETVALUE(RFAILED); + } + + /* check if already registered */ + if (osCp.drvrTskTbl[channel].used != TRUE) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS477, ERRZERO, + "Driver task is not registered"); + RETVALUE(RFAILED); + } +#endif + + + if(SLock(&osCp.drvrTskTbl[channel].lock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS477, ERRZERO, + "Could not lock driver task lock"); +#endif + RETVALUE(RFAILED); + } + ssdDeregDrvrTsk(&osCp.drvrTskTbl[channel]); + + osCp.drvrTskTbl[channel].channel = 0; + osCp.drvrTskTbl[channel].actvTsk = NULLP; + osCp.drvrTskTbl[channel].isTsk = NULLP; + osCp.drvrTskTbl[channel].low = 0; + osCp.drvrTskTbl[channel].high = 0; + + osCp.drvrTskTbl[channel].used = FALSE; + osCp.numDrvrTsks--; + if(SUnlock(&osCp.drvrTskTbl[channel].lock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS477, ERRZERO, + "Could not unlock driver task lock"); +#endif + RETVALUE(RFAILED); + } + SDestroyLock(&osCp.drvrTskTbl[channel].lock); + /* ss002.301 Modifications */ + RETVALUE(ROK); +} +#endif /* SS_DRVR_SUPPORT */ +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/mt/ss_err.h b/src/mt/ss_err.h new file mode 100755 index 000000000..857e5b420 --- /dev/null +++ b/src/mt/ss_err.h @@ -0,0 +1,962 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/********************************************************************20** + + Name: System Services - errors + + Type: C include file + + Desc: Error defines required by System Services. + + File: ss_err.h + +*********************************************************************21*/ + +#ifndef __SSERRH__ +#define __SSERRH__ + +#ifdef __cplusplus +extern "C" { +#endif + + + +/* log error macro */ +/* ss029.103: modification: SFndProcId is not supported with multiple procs */ +#ifndef SS_MULTIPLE_PROCS +#define SSLOGERROR(errCls, errCode, errVal, errDesc) \ + SLogError((Ent)ENTSS, (Inst)0 , SFndProcId(), \ + (Txt *)__FILE__, __LINE__, \ + (ErrCls)errCls, (ErrVal)errCode, \ + (ErrVal)errVal, (Txt *)errDesc) +#else /* SS_MULTIPLE_PROCS */ +#define SSLOGERROR(errCls, errCode, errVal, errDesc) \ + SLogError((Ent)ENTSS, (Inst)0 , PROCNC, \ + (Txt *)__FILE__, __LINE__, \ + (ErrCls)errCls, (ErrVal)errCode, \ + (ErrVal)errVal, (Txt *)errDesc) +#endif /* SS_MULTIPLE_PROCS */ + +/* defines */ +#define ERRSS 0 +#define ESSBASE (ERRSS + 0) /* reserved */ +#define ESSXXX (ESSBASE) /* reserved */ + +#define ESS001 (ERRSS + 1) /* sm_drvr.c: 185 */ +#define ESS002 (ERRSS + 2) /* sm_drvr.c: 193 */ +#define ESS003 (ERRSS + 3) /* sm_drvr.c: 201 */ +#define ESS004 (ERRSS + 4) /* sm_drvr.c: 208 */ +#define ESS005 (ERRSS + 5) /* sm_drvr.c: 215 */ +#define ESS006 (ERRSS + 6) /* sm_drvr.c: 222 */ +#define ESS007 (ERRSS + 7) /* sm_drvr.c: 233 */ +#define ESS008 (ERRSS + 8) /* sm_drvr.c: 243 */ + +#define ESS009 (ERRSS + 9) /* sm_gen.c: 269 */ +#define ESS010 (ERRSS + 10) /* sm_gen.c: 372 */ +#define ESS011 (ERRSS + 11) /* sm_gen.c: 397 */ +#define ESS012 (ERRSS + 12) /* sm_gen.c: 534 */ +#define ESS013 (ERRSS + 13) /* sm_gen.c: 551 */ +#define ESS014 (ERRSS + 14) /* sm_gen.c: 610 */ +#define ESS015 (ERRSS + 15) /* sm_gen.c: 622 */ +#define ESS016 (ERRSS + 16) /* sm_gen.c:1026 */ +#define ESS017 (ERRSS + 17) /* sm_gen.c:1036 */ +#define ESS018 (ERRSS + 18) /* sm_gen.c:1043 */ +#define ESS019 (ERRSS + 19) /* sm_gen.c:1087 */ +#define ESS020 (ERRSS + 20) /* sm_gen.c:1133 */ +#define ESS021 (ERRSS + 21) /* sm_gen.c:1143 */ +#define ESS022 (ERRSS + 22) /* sm_gen.c:1157 */ +#define ESS023 (ERRSS + 23) /* sm_gen.c:1164 */ +#define ESS024 (ERRSS + 24) /* sm_gen.c:1179 */ +#define ESS025 (ERRSS + 25) /* sm_gen.c:1293 */ +#define ESS026 (ERRSS + 26) /* sm_gen.c:1357 */ +#define ESS027 (ERRSS + 27) /* sm_gen.c:1372 */ + +#define ESS028 (ERRSS + 28) /* sm_mem.c: 162 */ +#define ESS029 (ERRSS + 29) /* sm_mem.c: 169 */ +#define ESS030 (ERRSS + 30) /* sm_mem.c: 181 */ +#define ESS031 (ERRSS + 31) /* sm_mem.c: 195 */ +#define ESS032 (ERRSS + 32) /* sm_mem.c: 256 */ +#define ESS033 (ERRSS + 33) /* sm_mem.c: 268 */ +#define ESS034 (ERRSS + 34) /* sm_mem.c: 281 */ +#define ESS035 (ERRSS + 35) /* sm_mem.c: 349 */ +#define ESS036 (ERRSS + 36) /* sm_mem.c: 362 */ +#define ESS037 (ERRSS + 37) /* sm_mem.c: 383 */ +#define ESS038 (ERRSS + 38) /* sm_mem.c: 390 */ +#define ESS039 (ERRSS + 39) /* sm_mem.c: 417 */ +#define ESS040 (ERRSS + 40) /* sm_mem.c: 476 */ +#define ESS041 (ERRSS + 41) /* sm_mem.c: 483 */ +#define ESS042 (ERRSS + 42) /* sm_mem.c: 490 */ +#define ESS043 (ERRSS + 43) /* sm_mem.c: 504 */ +#define ESS044 (ERRSS + 44) /* sm_mem.c: 523 */ +#define ESS045 (ERRSS + 45) /* sm_mem.c: 530 */ +#define ESS046 (ERRSS + 46) /* sm_mem.c: 550 */ + +#define ESS047 (ERRSS + 47) /* sm_msg.c: 203 */ +#define ESS048 (ERRSS + 48) /* sm_msg.c: 209 */ +#define ESS049 (ERRSS + 49) /* sm_msg.c: 216 */ +#define ESS050 (ERRSS + 50) /* sm_msg.c: 337 */ +#define ESS051 (ERRSS + 51) /* sm_msg.c: 342 */ +#define ESS052 (ERRSS + 52) /* sm_msg.c: 349 */ +#define ESS053 (ERRSS + 53) /* sm_msg.c: 363 */ +#define ESS054 (ERRSS + 54) /* sm_msg.c: 381 */ +#define ESS055 (ERRSS + 55) /* sm_msg.c: 387 */ +#define ESS056 (ERRSS + 56) /* sm_msg.c: 396 */ +#define ESS057 (ERRSS + 57) /* sm_msg.c: 408 */ +#define ESS058 (ERRSS + 58) /* sm_msg.c: 416 */ +#define ESS059 (ERRSS + 59) /* sm_msg.c: 422 */ +#define ESS060 (ERRSS + 60) /* sm_msg.c: 489 */ +#define ESS061 (ERRSS + 61) /* sm_msg.c: 494 */ +#define ESS062 (ERRSS + 62) /* sm_msg.c: 564 */ +#define ESS063 (ERRSS + 63) /* sm_msg.c: 569 */ +#define ESS064 (ERRSS + 64) /* sm_msg.c: 638 */ +#define ESS065 (ERRSS + 65) /* sm_msg.c: 643 */ +#define ESS066 (ERRSS + 66) /* sm_msg.c: 672 */ +#define ESS067 (ERRSS + 67) /* sm_msg.c: 742 */ +#define ESS068 (ERRSS + 68) /* sm_msg.c: 747 */ +#define ESS069 (ERRSS + 69) /* sm_msg.c: 761 */ +#define ESS070 (ERRSS + 70) /* sm_msg.c: 842 */ +#define ESS071 (ERRSS + 71) /* sm_msg.c: 848 */ +#define ESS072 (ERRSS + 72) /* sm_msg.c: 854 */ +#define ESS073 (ERRSS + 73) /* sm_msg.c: 860 */ +#define ESS074 (ERRSS + 74) /* sm_msg.c:1011 */ +#define ESS075 (ERRSS + 75) /* sm_msg.c:1017 */ +#define ESS076 (ERRSS + 76) /* sm_msg.c:1023 */ +#define ESS077 (ERRSS + 77) /* sm_msg.c:1029 */ +#define ESS078 (ERRSS + 78) /* sm_msg.c:1192 */ +#define ESS079 (ERRSS + 79) /* sm_msg.c:1198 */ +#define ESS080 (ERRSS + 80) /* sm_msg.c:1203 */ +#define ESS081 (ERRSS + 81) /* sm_msg.c:1276 */ +#define ESS082 (ERRSS + 82) /* sm_msg.c:1282 */ +#define ESS083 (ERRSS + 83) /* sm_msg.c:1287 */ +#define ESS084 (ERRSS + 84) /* sm_msg.c:1378 */ +#define ESS085 (ERRSS + 85) /* sm_msg.c:1385 */ +#define ESS086 (ERRSS + 86) /* sm_msg.c:1393 */ +#define ESS087 (ERRSS + 87) /* sm_msg.c:1498 */ +#define ESS088 (ERRSS + 88) /* sm_msg.c:1505 */ +#define ESS089 (ERRSS + 89) /* sm_msg.c:1510 */ +#define ESS090 (ERRSS + 90) /* sm_msg.c:1625 */ +#define ESS091 (ERRSS + 91) /* sm_msg.c:1631 */ +#define ESS092 (ERRSS + 92) /* sm_msg.c:1637 */ +#define ESS093 (ERRSS + 93) /* sm_msg.c:1642 */ +#define ESS094 (ERRSS + 94) /* sm_msg.c:1705 */ +#define ESS095 (ERRSS + 95) /* sm_msg.c:1711 */ +#define ESS096 (ERRSS + 96) /* sm_msg.c:1716 */ +#define ESS097 (ERRSS + 97) /* sm_msg.c:1795 */ +#define ESS098 (ERRSS + 98) /* sm_msg.c:1801 */ +#define ESS099 (ERRSS + 99) /* sm_msg.c:1806 */ +#define ESS100 (ERRSS + 100) /* sm_msg.c:1811 */ +#define ESS101 (ERRSS + 101) /* sm_msg.c:1829 */ +#define ESS102 (ERRSS + 102) /* sm_msg.c:1999 */ +#define ESS103 (ERRSS + 103) /* sm_msg.c:2005 */ +#define ESS104 (ERRSS + 104) /* sm_msg.c:2011 */ +#define ESS105 (ERRSS + 105) /* sm_msg.c:2017 */ +#define ESS106 (ERRSS + 106) /* sm_msg.c:2022 */ +#define ESS107 (ERRSS + 107) /* sm_msg.c:2033 */ +#define ESS108 (ERRSS + 108) /* sm_msg.c:2048 */ +#define ESS109 (ERRSS + 109) /* sm_msg.c:2059 */ +#define ESS110 (ERRSS + 110) /* sm_msg.c:2155 */ +#define ESS111 (ERRSS + 111) /* sm_msg.c:2161 */ +#define ESS112 (ERRSS + 112) /* sm_msg.c:2166 */ +#define ESS113 (ERRSS + 113) /* sm_msg.c:2172 */ +#define ESS114 (ERRSS + 114) /* sm_msg.c:2177 */ +#define ESS115 (ERRSS + 115) /* sm_msg.c:2182 */ +#define ESS116 (ERRSS + 116) /* sm_msg.c:2300 */ +#define ESS117 (ERRSS + 117) /* sm_msg.c:2305 */ +#define ESS118 (ERRSS + 118) /* sm_msg.c:2312 */ +#define ESS119 (ERRSS + 119) /* sm_msg.c:2319 */ +#define ESS120 (ERRSS + 120) /* sm_msg.c:2333 */ +#define ESS121 (ERRSS + 121) /* sm_msg.c:2349 */ +#define ESS122 (ERRSS + 122) /* sm_msg.c:2355 */ +#define ESS123 (ERRSS + 123) /* sm_msg.c:2365 */ +#define ESS124 (ERRSS + 124) /* sm_msg.c:2377 */ +#define ESS125 (ERRSS + 125) /* sm_msg.c:2445 */ +#define ESS126 (ERRSS + 126) /* sm_msg.c:2530 */ +#define ESS127 (ERRSS + 127) /* sm_msg.c:2535 */ +#define ESS128 (ERRSS + 128) /* sm_msg.c:2545 */ +#define ESS129 (ERRSS + 129) /* sm_msg.c:2613 */ +#define ESS130 (ERRSS + 130) /* sm_msg.c:2680 */ +#define ESS131 (ERRSS + 131) /* sm_msg.c:2686 */ +#define ESS132 (ERRSS + 132) /* sm_msg.c:2704 */ +#define ESS133 (ERRSS + 133) /* sm_msg.c:2792 */ +#define ESS134 (ERRSS + 134) /* sm_msg.c:2797 */ +#define ESS135 (ERRSS + 135) /* sm_msg.c:2804 */ +#define ESS136 (ERRSS + 136) /* sm_msg.c:2817 */ +#define ESS137 (ERRSS + 137) /* sm_msg.c:2836 */ +#define ESS138 (ERRSS + 138) /* sm_msg.c:2842 */ +#define ESS139 (ERRSS + 139) /* sm_msg.c:2852 */ +#define ESS140 (ERRSS + 140) /* sm_msg.c:2865 */ +#define ESS141 (ERRSS + 141) /* sm_msg.c:2998 */ +#define ESS142 (ERRSS + 142) /* sm_msg.c:3004 */ +#define ESS143 (ERRSS + 143) /* sm_msg.c:3010 */ +#define ESS144 (ERRSS + 144) /* sm_msg.c:3016 */ +#define ESS145 (ERRSS + 145) /* sm_msg.c:3029 */ +#define ESS146 (ERRSS + 146) /* sm_msg.c:3120 */ +#define ESS147 (ERRSS + 147) /* sm_msg.c:3242 */ +#define ESS148 (ERRSS + 148) /* sm_msg.c:3305 */ +#define ESS149 (ERRSS + 149) /* sm_msg.c:3311 */ +#define ESS150 (ERRSS + 150) /* sm_msg.c:3318 */ +#define ESS151 (ERRSS + 151) /* sm_msg.c:3323 */ +#define ESS152 (ERRSS + 152) /* sm_msg.c:3329 */ +#define ESS153 (ERRSS + 153) /* sm_msg.c:3350 */ +#define ESS154 (ERRSS + 154) /* sm_msg.c:3395 */ +#define ESS155 (ERRSS + 155) /* sm_msg.c:3471 */ +#define ESS156 (ERRSS + 156) /* sm_msg.c:3476 */ +#define ESS157 (ERRSS + 157) /* sm_msg.c:3481 */ +#define ESS158 (ERRSS + 158) /* sm_msg.c:3507 */ +#define ESS159 (ERRSS + 159) /* sm_msg.c:3564 */ +#define ESS160 (ERRSS + 160) /* sm_msg.c:3569 */ +#define ESS161 (ERRSS + 161) /* sm_msg.c:3574 */ +#define ESS162 (ERRSS + 162) /* sm_msg.c:3580 */ +#define ESS163 (ERRSS + 163) /* sm_msg.c:3603 */ +#define ESS164 (ERRSS + 164) /* sm_msg.c:3665 */ +#define ESS165 (ERRSS + 165) /* sm_msg.c:3671 */ +#define ESS166 (ERRSS + 166) /* sm_msg.c:3739 */ +#define ESS167 (ERRSS + 167) /* sm_msg.c:3745 */ +#define ESS168 (ERRSS + 168) /* sm_msg.c:3814 */ +#define ESS169 (ERRSS + 169) /* sm_msg.c:3820 */ +#define ESS170 (ERRSS + 170) /* sm_msg.c:3825 */ +#define ESS171 (ERRSS + 171) /* sm_msg.c:3892 */ +#define ESS172 (ERRSS + 172) /* sm_msg.c:3898 */ +#define ESS173 (ERRSS + 173) /* sm_msg.c:3903 */ +#define ESS174 (ERRSS + 174) /* sm_msg.c:3962 */ +#define ESS175 (ERRSS + 175) /* sm_msg.c:3967 */ +#define ESS176 (ERRSS + 176) /* sm_msg.c:4015 */ +#define ESS177 (ERRSS + 177) /* sm_msg.c:4020 */ +#define ESS178 (ERRSS + 178) /* sm_msg.c:4025 */ +#define ESS179 (ERRSS + 179) /* sm_msg.c:4074 */ +#define ESS180 (ERRSS + 180) /* sm_msg.c:4079 */ +#define ESS181 (ERRSS + 181) /* sm_msg.c:4133 */ +#define ESS182 (ERRSS + 182) /* sm_msg.c:4138 */ +#define ESS183 (ERRSS + 183) /* sm_msg.c:4143 */ +#define ESS184 (ERRSS + 184) /* sm_msg.c:4148 */ +#define ESS185 (ERRSS + 185) /* sm_msg.c:4157 */ +#define ESS186 (ERRSS + 186) /* sm_msg.c:4170 */ +#define ESS187 (ERRSS + 187) /* sm_msg.c:4216 */ +#define ESS188 (ERRSS + 188) /* sm_msg.c:4221 */ +#define ESS189 (ERRSS + 189) /* sm_msg.c:4227 */ +#define ESS190 (ERRSS + 190) /* sm_msg.c:4232 */ +#define ESS191 (ERRSS + 191) /* sm_msg.c:4246 */ +#define ESS192 (ERRSS + 192) /* sm_msg.c:4292 */ +#define ESS193 (ERRSS + 193) /* sm_msg.c:4298 */ +#define ESS194 (ERRSS + 194) /* sm_msg.c:4304 */ +#define ESS195 (ERRSS + 195) /* sm_msg.c:4314 */ +#define ESS196 (ERRSS + 196) /* sm_msg.c:4370 */ +#define ESS197 (ERRSS + 197) /* sm_msg.c:4375 */ +#define ESS198 (ERRSS + 198) /* sm_msg.c:4391 */ +#define ESS199 (ERRSS + 199) /* sm_msg.c:4777 */ +#define ESS200 (ERRSS + 200) /* sm_msg.c:4783 */ +#define ESS201 (ERRSS + 201) /* sm_msg.c:4861 */ +#define ESS202 (ERRSS + 202) /* sm_msg.c:4867 */ +#define ESS203 (ERRSS + 203) /* sm_msg.c:4962 */ +#define ESS204 (ERRSS + 204) /* sm_msg.c:4969 */ +#define ESS205 (ERRSS + 205) /* sm_msg.c:5023 */ +#define ESS206 (ERRSS + 206) /* sm_msg.c:5030 */ +#define ESS207 (ERRSS + 207) /* sm_msg.c:5041 */ +#define ESS208 (ERRSS + 208) /* sm_msg.c:5056 */ +#define ESS209 (ERRSS + 209) /* sm_msg.c:5062 */ +#define ESS210 (ERRSS + 210) /* sm_msg.c:5070 */ +#define ESS211 (ERRSS + 211) /* sm_msg.c:5125 */ +#define ESS212 (ERRSS + 212) /* sm_msg.c:5132 */ +#define ESS213 (ERRSS + 213) /* sm_msg.c:5139 */ +#define ESS214 (ERRSS + 214) /* sm_msg.c:5147 */ +#define ESS215 (ERRSS + 215) /* sm_msg.c:5155 */ +#define ESS216 (ERRSS + 216) /* sm_msg.c:5168 */ +#define ESS217 (ERRSS + 217) /* sm_msg.c:5190 */ +#define ESS218 (ERRSS + 218) /* sm_msg.c:5197 */ +#define ESS219 (ERRSS + 219) /* sm_msg.c:5232 */ +#define ESS220 (ERRSS + 220) /* sm_msg.c:5294 */ +#define ESS221 (ERRSS + 221) /* sm_msg.c:5301 */ +#define ESS222 (ERRSS + 222) /* sm_msg.c:5308 */ +#define ESS223 (ERRSS + 223) /* sm_msg.c:5316 */ +#define ESS224 (ERRSS + 224) /* sm_msg.c:5324 */ +#define ESS225 (ERRSS + 225) /* sm_msg.c:5337 */ +#define ESS226 (ERRSS + 226) /* sm_msg.c:5358 */ +#define ESS227 (ERRSS + 227) /* sm_msg.c:5365 */ +#define ESS228 (ERRSS + 228) /* sm_msg.c:5385 */ +#define ESS229 (ERRSS + 229) /* sm_msg.c:5446 */ +#define ESS230 (ERRSS + 230) /* sm_msg.c:5453 */ +#define ESS231 (ERRSS + 231) /* sm_msg.c:5460 */ +#define ESS232 (ERRSS + 232) /* sm_msg.c:5473 */ +#define ESS233 (ERRSS + 233) /* sm_msg.c:5493 */ +#define ESS234 (ERRSS + 234) /* sm_msg.c:5500 */ +#define ESS235 (ERRSS + 235) /* sm_msg.c:5507 */ +#define ESS236 (ERRSS + 236) /* sm_msg.c:5529 */ +#define ESS237 (ERRSS + 237) /* sm_msg.c:5584 */ +#define ESS238 (ERRSS + 238) /* sm_msg.c:5590 */ +#define ESS239 (ERRSS + 239) /* sm_msg.c:5595 */ +#define ESS240 (ERRSS + 240) /* sm_msg.c:5601 */ +#define ESS241 (ERRSS + 241) /* sm_msg.c:5609 */ + +#define ESS242 (ERRSS + 242) /* sm_pack.c: 154 */ +#define ESS243 (ERRSS + 243) /* sm_pack.c: 194 */ +#define ESS244 (ERRSS + 244) /* sm_pack.c: 241 */ +#define ESS245 (ERRSS + 245) /* sm_pack.c: 289 */ +#define ESS246 (ERRSS + 246) /* sm_pack.c: 346 */ +#define ESS247 (ERRSS + 247) /* sm_pack.c: 403 */ +#define ESS248 (ERRSS + 248) /* sm_pack.c: 464 */ +#define ESS249 (ERRSS + 249) /* sm_pack.c: 524 */ +#define ESS250 (ERRSS + 250) /* sm_pack.c: 566 */ +#define ESS251 (ERRSS + 251) /* sm_pack.c: 574 */ +#define ESS252 (ERRSS + 252) /* sm_pack.c: 616 */ +#define ESS253 (ERRSS + 253) /* sm_pack.c: 624 */ +#define ESS254 (ERRSS + 254) /* sm_pack.c: 666 */ +#define ESS255 (ERRSS + 255) /* sm_pack.c: 674 */ +#define ESS256 (ERRSS + 256) /* sm_pack.c: 725 */ +#define ESS257 (ERRSS + 257) /* sm_pack.c: 733 */ +#define ESS258 (ERRSS + 258) /* sm_pack.c: 785 */ +#define ESS259 (ERRSS + 259) /* sm_pack.c: 793 */ +#define ESS260 (ERRSS + 260) /* sm_pack.c: 856 */ +#define ESS261 (ERRSS + 261) /* sm_pack.c: 864 */ +#define ESS262 (ERRSS + 262) /* sm_pack.c: 930 */ +#define ESS263 (ERRSS + 263) /* sm_pack.c: 938 */ +#define ESS264 (ERRSS + 264) /* sm_pack.c: 997 */ +#define ESS265 (ERRSS + 265) /* sm_pack.c:1005 */ + +#define ESS266 (ERRSS + 266) /* sm_queue.c: 157 */ +#define ESS267 (ERRSS + 267) /* sm_queue.c: 211 */ +#define ESS268 (ERRSS + 268) /* sm_queue.c: 280 */ +#define ESS269 (ERRSS + 269) /* sm_queue.c: 286 */ +#define ESS270 (ERRSS + 270) /* sm_queue.c: 292 */ +#define ESS271 (ERRSS + 271) /* sm_queue.c: 299 */ +#define ESS272 (ERRSS + 272) /* sm_queue.c: 391 */ +#define ESS273 (ERRSS + 273) /* sm_queue.c: 397 */ +#define ESS274 (ERRSS + 274) /* sm_queue.c: 453 */ +#define ESS275 (ERRSS + 275) /* sm_queue.c: 460 */ +#define ESS276 (ERRSS + 276) /* sm_queue.c: 467 */ +#define ESS277 (ERRSS + 277) /* sm_queue.c: 548 */ +#define ESS278 (ERRSS + 278) /* sm_queue.c: 554 */ +#define ESS279 (ERRSS + 279) /* sm_queue.c: 560 */ +#define ESS280 (ERRSS + 280) /* sm_queue.c: 566 */ +#define ESS281 (ERRSS + 281) /* sm_queue.c: 575 */ +#define ESS282 (ERRSS + 282) /* sm_queue.c: 584 */ +#define ESS283 (ERRSS + 283) /* sm_queue.c: 673 */ +#define ESS284 (ERRSS + 284) /* sm_queue.c: 680 */ +#define ESS285 (ERRSS + 285) /* sm_queue.c: 686 */ +#define ESS286 (ERRSS + 286) /* sm_queue.c: 852 */ +#define ESS287 (ERRSS + 287) /* sm_queue.c: 858 */ +#define ESS288 (ERRSS + 288) /* sm_queue.c: 908 */ +#define ESS289 (ERRSS + 289) /* sm_queue.c: 914 */ +#define ESS290 (ERRSS + 290) /* sm_queue.c: 961 */ +#define ESS291 (ERRSS + 291) /* sm_queue.c: 985 */ +#define ESS292 (ERRSS + 292) /* sm_queue.c:1006 */ +#define ESS293 (ERRSS + 293) /* sm_queue.c:1050 */ +#define ESS294 (ERRSS + 294) /* sm_queue.c:1066 */ +#define ESS295 (ERRSS + 295) /* sm_queue.c:1087 */ +#define ESS296 (ERRSS + 296) /* sm_queue.c:1145 */ +#define ESS297 (ERRSS + 297) /* sm_queue.c:1151 */ +#define ESS298 (ERRSS + 298) /* sm_queue.c:1157 */ +#define ESS299 (ERRSS + 299) /* sm_queue.c:1163 */ +#define ESS300 (ERRSS + 300) /* sm_queue.c:1181 */ +#define ESS301 (ERRSS + 301) /* sm_queue.c:1227 */ +#define ESS302 (ERRSS + 302) /* sm_queue.c:1259 */ +#define ESS303 (ERRSS + 303) /* sm_queue.c:1320 */ +#define ESS304 (ERRSS + 304) /* sm_queue.c:1326 */ +#define ESS305 (ERRSS + 305) /* sm_queue.c:1332 */ +#define ESS306 (ERRSS + 306) /* sm_queue.c:1343 */ +#define ESS307 (ERRSS + 307) /* sm_queue.c:1359 */ +#define ESS308 (ERRSS + 308) /* sm_queue.c:1377 */ +#define ESS309 (ERRSS + 309) /* sm_queue.c:1440 */ +#define ESS310 (ERRSS + 310) /* sm_queue.c:1489 */ +#define ESS311 (ERRSS + 311) /* sm_queue.c:1507 */ +#define ESS312 (ERRSS + 312) /* sm_queue.c:1523 */ +#define ESS313 (ERRSS + 313) /* sm_queue.c:1542 */ +#define ESS314 (ERRSS + 314) /* sm_queue.c:1560 */ +#define ESS315 (ERRSS + 315) /* sm_queue.c:1588 */ + +#define ESS316 (ERRSS + 316) /* sm_rtr.c: 167 */ +#define ESS317 (ERRSS + 317) /* sm_rtr.c: 175 */ +#define ESS318 (ERRSS + 318) /* sm_rtr.c: 185 */ +#define ESS319 (ERRSS + 319) /* sm_rtr.c: 198 */ +#define ESS320 (ERRSS + 320) /* sm_rtr.c: 264 */ +#define ESS321 (ERRSS + 321) /* sm_rtr.c: 271 */ +#define ESS322 (ERRSS + 322) /* sm_rtr.c: 286 */ +#define ESS323 (ERRSS + 323) /* sm_rtr.c: 299 */ +#define ESS324 (ERRSS + 324) /* sm_rtr.c: 309 */ + +#define ESS325 (ERRSS + 325) /* sm_strm.c: 226 */ +#define ESS326 (ERRSS + 326) /* sm_strm.c: 395 */ +#define ESS327 (ERRSS + 327) /* sm_strm.c: 410 */ +#define ESS328 (ERRSS + 328) /* sm_strm.c: 468 */ +#define ESS329 (ERRSS + 329) /* sm_strm.c: 479 */ +#define ESS330 (ERRSS + 330) /* sm_strm.c: 538 */ +#define ESS331 (ERRSS + 331) /* sm_strm.c: 549 */ +#define ESS332 (ERRSS + 332) /* sm_strm.c: 567 */ +#define ESS333 (ERRSS + 333) /* sm_strm.c: 622 */ +#define ESS334 (ERRSS + 334) /* sm_strm.c: 633 */ +#define ESS335 (ERRSS + 335) /* sm_strm.c: 669 */ +#define ESS336 (ERRSS + 336) /* sm_strm.c: 680 */ +#define ESS337 (ERRSS + 337) /* sm_strm.c: 728 */ +#define ESS338 (ERRSS + 338) /* sm_strm.c: 746 */ +#define ESS339 (ERRSS + 339) /* sm_strm.c: 806 */ +#define ESS340 (ERRSS + 340) /* sm_strm.c: 818 */ +#define ESS341 (ERRSS + 341) /* sm_strm.c: 872 */ +#define ESS342 (ERRSS + 342) /* sm_strm.c: 896 */ +#define ESS343 (ERRSS + 343) /* sm_strm.c: 908 */ +#define ESS344 (ERRSS + 344) /* sm_strm.c: 919 */ +#define ESS345 (ERRSS + 345) /* sm_strm.c:1056 */ +#define ESS346 (ERRSS + 346) /* sm_strm.c:1176 */ +#define ESS347 (ERRSS + 347) /* sm_strm.c:1182 */ +#define ESS348 (ERRSS + 348) /* sm_strm.c:1356 */ +#define ESS349 (ERRSS + 349) /* sm_strm.c:1483 */ + +#define ESS350 (ERRSS + 350) /* sm_task.c: 167 */ +#define ESS351 (ERRSS + 351) /* sm_task.c: 174 */ +#define ESS352 (ERRSS + 352) /* sm_task.c: 192 */ +#define ESS353 (ERRSS + 353) /* sm_task.c: 202 */ +#define ESS354 (ERRSS + 354) /* sm_task.c: 215 */ +#define ESS355 (ERRSS + 355) /* sm_task.c: 221 */ +#define ESS356 (ERRSS + 356) /* sm_task.c: 234 */ +#define ESS357 (ERRSS + 357) /* sm_task.c: 241 */ +#define ESS358 (ERRSS + 358) /* sm_task.c: 287 */ +#define ESS359 (ERRSS + 359) /* sm_task.c: 352 */ +#define ESS360 (ERRSS + 360) /* sm_task.c: 359 */ +#define ESS361 (ERRSS + 361) /* sm_task.c: 366 */ +#define ESS362 (ERRSS + 362) /* sm_task.c: 374 */ +#define ESS363 (ERRSS + 363) /* sm_task.c: 383 */ +#define ESS364 (ERRSS + 364) /* sm_task.c: 395 */ +#define ESS365 (ERRSS + 365) /* sm_task.c: 401 */ +#define ESS366 (ERRSS + 366) /* sm_task.c: 420 */ +#define ESS367 (ERRSS + 367) /* sm_task.c: 425 */ +#define ESS368 (ERRSS + 368) /* sm_task.c: 466 */ +#define ESS369 (ERRSS + 369) /* sm_task.c: 472 */ +#define ESS370 (ERRSS + 370) /* sm_task.c: 488 */ +#define ESS371 (ERRSS + 371) /* sm_task.c: 507 */ +#define ESS372 (ERRSS + 372) /* sm_task.c: 524 */ +#define ESS373 (ERRSS + 373) /* sm_task.c: 578 */ +#define ESS374 (ERRSS + 374) /* sm_task.c: 588 */ +#define ESS375 (ERRSS + 375) /* sm_task.c: 599 */ +#define ESS376 (ERRSS + 376) /* sm_task.c: 612 */ +#define ESS377 (ERRSS + 377) /* sm_task.c: 618 */ +#define ESS378 (ERRSS + 378) /* sm_task.c: 650 */ +#define ESS379 (ERRSS + 379) /* sm_task.c: 677 */ +#define ESS380 (ERRSS + 380) /* sm_task.c: 698 */ +#define ESS381 (ERRSS + 381) /* sm_task.c: 719 */ +#define ESS382 (ERRSS + 382) /* sm_task.c: 748 */ +#define ESS383 (ERRSS + 383) /* sm_task.c: 766 */ +#define ESS384 (ERRSS + 384) /* sm_task.c: 865 */ +#define ESS385 (ERRSS + 385) /* sm_task.c: 871 */ +#define ESS386 (ERRSS + 386) /* sm_task.c: 879 */ +#define ESS387 (ERRSS + 387) /* sm_task.c: 886 */ +#define ESS388 (ERRSS + 388) /* sm_task.c: 894 */ +#define ESS389 (ERRSS + 389) /* sm_task.c: 908 */ +#define ESS390 (ERRSS + 390) /* sm_task.c: 930 */ +#define ESS391 (ERRSS + 391) /* sm_task.c: 940 */ +#define ESS392 (ERRSS + 392) /* sm_task.c: 948 */ +#define ESS393 (ERRSS + 393) /* sm_task.c: 963 */ +#define ESS394 (ERRSS + 394) /* sm_task.c: 969 */ +#define ESS395 (ERRSS + 395) /* sm_task.c: 987 */ +#define ESS396 (ERRSS + 396) /* sm_task.c: 994 */ +#define ESS397 (ERRSS + 397) /* sm_task.c:1089 */ +#define ESS398 (ERRSS + 398) /* sm_task.c:1170 */ +#define ESS399 (ERRSS + 399) /* sm_task.c:1176 */ +#define ESS400 (ERRSS + 400) /* sm_task.c:1191 */ +#define ESS401 (ERRSS + 401) /* sm_task.c:1205 */ +#define ESS402 (ERRSS + 402) /* sm_task.c:1252 */ +#define ESS403 (ERRSS + 403) /* sm_task.c:1260 */ +#define ESS404 (ERRSS + 404) /* sm_task.c:1277 */ +#define ESS405 (ERRSS + 405) /* sm_task.c:1298 */ +#define ESS406 (ERRSS + 406) /* sm_task.c:1315 */ +#define ESS407 (ERRSS + 407) /* sm_task.c:1334 */ +#define ESS408 (ERRSS + 408) /* sm_task.c:1351 */ +#define ESS409 (ERRSS + 409) /* sm_task.c:1387 */ +#define ESS410 (ERRSS + 410) /* sm_task.c:1406 */ +#define ESS411 (ERRSS + 411) /* sm_task.c:1414 */ +#define ESS412 (ERRSS + 412) /* sm_task.c:1451 */ +#define ESS413 (ERRSS + 413) /* sm_task.c:1470 */ +#define ESS414 (ERRSS + 414) /* sm_task.c:1477 */ +#define ESS415 (ERRSS + 415) /* sm_task.c:1575 */ +#define ESS416 (ERRSS + 416) /* sm_task.c:1594 */ +#define ESS417 (ERRSS + 417) /* sm_task.c:1645 */ +#define ESS418 (ERRSS + 418) /* sm_task.c:1652 */ +#define ESS419 (ERRSS + 419) /* sm_task.c:1665 */ +#define ESS420 (ERRSS + 420) /* sm_task.c:1696 */ +#define ESS421 (ERRSS + 421) /* sm_task.c:1719 */ +#define ESS422 (ERRSS + 422) /* sm_task.c:1727 */ +#define ESS423 (ERRSS + 423) /* sm_task.c:1751 */ +#define ESS424 (ERRSS + 424) /* sm_task.c:1759 */ +#define ESS425 (ERRSS + 425) /* sm_task.c:1778 */ +#define ESS426 (ERRSS + 426) /* sm_task.c:1786 */ +#define ESS427 (ERRSS + 427) /* sm_task.c:1811 */ +#define ESS428 (ERRSS + 428) /* sm_task.c:1819 */ +#define ESS429 (ERRSS + 429) /* sm_task.c:1843 */ +#define ESS430 (ERRSS + 430) /* sm_task.c:1890 */ +#define ESS431 (ERRSS + 431) /* sm_task.c:1954 */ +#define ESS432 (ERRSS + 432) /* sm_task.c:2000 */ +#define ESS433 (ERRSS + 433) /* sm_task.c:2008 */ +#define ESS434 (ERRSS + 434) /* sm_task.c:2036 */ +#define ESS435 (ERRSS + 435) /* sm_task.c:2066 */ +#define ESS436 (ERRSS + 436) /* sm_task.c:2076 */ +#define ESS437 (ERRSS + 437) /* sm_task.c:2085 */ +#define ESS438 (ERRSS + 438) /* sm_task.c:2108 */ +#define ESS439 (ERRSS + 439) /* sm_task.c:2130 */ +#define ESS440 (ERRSS + 440) /* sm_task.c:2153 */ +#define ESS441 (ERRSS + 441) /* sm_task.c:2160 */ +#define ESS442 (ERRSS + 442) /* sm_task.c:2173 */ +#define ESS443 (ERRSS + 443) /* sm_task.c:2190 */ +#define ESS444 (ERRSS + 444) /* sm_task.c:2232 */ +#define ESS445 (ERRSS + 445) /* sm_task.c:2264 */ +#define ESS446 (ERRSS + 446) /* sm_task.c:2272 */ +#define ESS447 (ERRSS + 447) /* sm_task.c:2279 */ +#define ESS448 (ERRSS + 448) /* sm_task.c:2335 */ +#define ESS449 (ERRSS + 449) /* sm_task.c:2347 */ +#define ESS450 (ERRSS + 450) /* sm_task.c:2374 */ +#define ESS451 (ERRSS + 451) /* sm_task.c:2381 */ +#define ESS452 (ERRSS + 452) /* sm_task.c:2395 */ +#define ESS453 (ERRSS + 453) /* sm_task.c:2402 */ +#define ESS454 (ERRSS + 454) /* sm_task.c:2423 */ +#define ESS455 (ERRSS + 455) /* sm_task.c:2431 */ +#define ESS456 (ERRSS + 456) /* sm_task.c:2453 */ +#define ESS457 (ERRSS + 457) /* sm_task.c:2468 */ +#define ESS458 (ERRSS + 458) /* sm_task.c:2476 */ +#define ESS459 (ERRSS + 459) /* sm_task.c:2519 */ +#define ESS460 (ERRSS + 460) /* sm_task.c:2535 */ +#define ESS461 (ERRSS + 461) /* sm_task.c:2557 */ +#define ESS462 (ERRSS + 462) /* sm_task.c:2614 */ +#define ESS463 (ERRSS + 463) /* sm_task.c:2703 */ +#define ESS464 (ERRSS + 464) /* sm_task.c:2710 */ +#define ESS465 (ERRSS + 465) /* sm_task.c:2718 */ +#define ESS466 (ERRSS + 466) /* sm_task.c:2732 */ +#define ESS467 (ERRSS + 467) /* sm_task.c:2745 */ +#define ESS468 (ERRSS + 468) /* sm_task.c:2768 */ +#define ESS469 (ERRSS + 469) /* sm_task.c:2775 */ +#define ESS470 (ERRSS + 470) /* sm_task.c:2796 */ +#define ESS471 (ERRSS + 471) /* sm_task.c:2804 */ +#define ESS472 (ERRSS + 472) /* sm_task.c:2826 */ +#define ESS473 (ERRSS + 473) /* sm_task.c:2841 */ +#define ESS474 (ERRSS + 474) /* sm_task.c:2866 */ +#define ESS475 (ERRSS + 475) /* sm_task.c:2882 */ +#define ESS476 (ERRSS + 476) /* sm_task.c:2890 */ +#define ESS477 (ERRSS + 477) /* sm_task.c:2921 */ +#define ESS478 (ERRSS + 478) /* sm_task.c:2936 */ +#define ESS479 (ERRSS + 479) /* sm_task.c:2943 */ +#define ESS480 (ERRSS + 480) /* sm_task.c:2963 */ +#define ESS481 (ERRSS + 481) /* sm_task.c:2978 */ +#define ESS482 (ERRSS + 482) /* sm_task.c:3003 */ +#define ESS483 (ERRSS + 483) /* sm_task.c:3018 */ +#define ESS484 (ERRSS + 484) /* sm_task.c:3072 */ +#define ESS485 (ERRSS + 485) /* sm_task.c:3087 */ +#define ESS486 (ERRSS + 486) /* sm_task.c:3184 */ +#define ESS487 (ERRSS + 487) /* sm_task.c:3191 */ +#define ESS488 (ERRSS + 488) /* sm_task.c:3205 */ +#define ESS489 (ERRSS + 489) /* sm_task.c:3222 */ +#define ESS490 (ERRSS + 490) /* sm_task.c:3242 */ +#define ESS491 (ERRSS + 491) /* sm_task.c:3250 */ +#define ESS492 (ERRSS + 492) /* sm_task.c:3279 */ +#define ESS493 (ERRSS + 493) /* sm_task.c:3286 */ +#define ESS494 (ERRSS + 494) /* sm_task.c:3312 */ +#define ESS495 (ERRSS + 495) /* sm_task.c:3349 */ +#define ESS496 (ERRSS + 496) /* sm_task.c:3357 */ +#define ESS497 (ERRSS + 497) /* sm_task.c:3379 */ +#define ESS498 (ERRSS + 498) /* sm_task.c:3387 */ +#define ESS499 (ERRSS + 499) /* sm_task.c:3395 */ +#define ESS500 (ERRSS + 500) /* sm_task.c:3442 */ +#define ESS501 (ERRSS + 501) /* sm_task.c:3459 */ +#define ESS502 (ERRSS + 502) /* sm_task.c:3544 */ +#define ESS503 (ERRSS + 503) /* sm_task.c:3552 */ +#define ESS504 (ERRSS + 504) /* sm_task.c:3561 */ +#define ESS505 (ERRSS + 505) /* sm_task.c:3574 */ +#define ESS506 (ERRSS + 506) /* sm_task.c:3600 */ +#define ESS507 (ERRSS + 507) /* sm_task.c:3609 */ +#define ESS508 (ERRSS + 508) /* sm_task.c:3644 */ +#define ESS509 (ERRSS + 509) /* sm_task.c:3653 */ +#define ESS510 (ERRSS + 510) /* sm_task.c:3672 */ +#define ESS511 (ERRSS + 511) /* sm_task.c:3688 */ +#define ESS512 (ERRSS + 512) /* sm_task.c:3718 */ +#define ESS513 (ERRSS + 513) /* sm_task.c:3727 */ +#define ESS514 (ERRSS + 514) /* sm_task.c:3755 */ +#define ESS515 (ERRSS + 515) /* sm_task.c:3764 */ +#define ESS516 (ERRSS + 516) /* sm_task.c:3817 */ +#define ESS517 (ERRSS + 517) /* sm_task.c:3826 */ +#define ESS518 (ERRSS + 518) /* sm_task.c:3833 */ +#define ESS519 (ERRSS + 519) /* sm_task.c:3846 */ +#define ESS520 (ERRSS + 520) /* sm_task.c:3859 */ +#define ESS521 (ERRSS + 521) /* sm_task.c:3876 */ +#define ESS522 (ERRSS + 522) /* sm_task.c:3885 */ +#define ESS523 (ERRSS + 523) /* sm_task.c:3915 */ +#define ESS524 (ERRSS + 524) /* sm_task.c:3924 */ +#define ESS525 (ERRSS + 525) /* sm_task.c:3942 */ +#define ESS526 (ERRSS + 526) /* sm_task.c:3951 */ +#define ESS527 (ERRSS + 527) /* sm_task.c:3967 */ + +#define ESS528 (ERRSS + 528) /* sm_timer.c: 430 */ +#define ESS529 (ERRSS + 529) /* sm_timer.c: 436 */ +#define ESS530 (ERRSS + 530) /* sm_timer.c: 444 */ +#define ESS531 (ERRSS + 531) /* sm_timer.c: 451 */ +#define ESS532 (ERRSS + 532) /* sm_timer.c: 458 */ +#define ESS533 (ERRSS + 533) /* sm_timer.c: 468 */ +#define ESS534 (ERRSS + 534) /* sm_timer.c: 480 */ +#define ESS535 (ERRSS + 535) /* sm_timer.c: 494 */ +#define ESS536 (ERRSS + 536) /* sm_timer.c: 499 */ +#define ESS537 (ERRSS + 537) /* sm_timer.c: 505 */ +#define ESS538 (ERRSS + 538) /* sm_timer.c: 519 */ +#define ESS539 (ERRSS + 539) /* sm_timer.c: 532 */ +#define ESS540 (ERRSS + 540) /* sm_timer.c: 539 */ +#define ESS541 (ERRSS + 541) /* sm_timer.c: 577 */ +#define ESS542 (ERRSS + 542) /* sm_timer.c: 646 */ +#define ESS543 (ERRSS + 543) /* sm_timer.c: 890 */ +#define ESS544 (ERRSS + 544) /* sm_timer.c: 897 */ +#define ESS545 (ERRSS + 545) /* sm_timer.c: 904 */ +#define ESS546 (ERRSS + 546) /* sm_timer.c: 911 */ +#define ESS547 (ERRSS + 547) /* sm_timer.c: 918 */ +#define ESS548 (ERRSS + 548) /* sm_timer.c: 928 */ +#define ESS549 (ERRSS + 549) /* sm_timer.c: 939 */ +#define ESS550 (ERRSS + 550) /* sm_timer.c: 953 */ +#define ESS551 (ERRSS + 551) /* sm_timer.c: 958 */ +#define ESS552 (ERRSS + 552) /* sm_timer.c: 964 */ +#define ESS553 (ERRSS + 553) /* sm_timer.c: 978 */ +#define ESS554 (ERRSS + 554) /* sm_timer.c:1022 */ +#define ESS555 (ERRSS + 555) /* sm_timer.c:1029 */ +#define ESS556 (ERRSS + 556) /* sm_timer.c:1067 */ + +#define ESS557 (ERRSS + 557) /* ss_acc.c: 556 */ +#define ESS558 (ERRSS + 558) /* ss_acc.c: 607 */ +#define ESS559 (ERRSS + 559) /* ss_acc.c: 615 */ +#define ESS560 (ERRSS + 560) /* ss_acc.c: 623 */ +#define ESS561 (ERRSS + 561) /* ss_acc.c: 631 */ +#define ESS562 (ERRSS + 562) /* ss_acc.c: 670 */ +#define ESS563 (ERRSS + 563) /* ss_acc.c: 681 */ +#define ESS564 (ERRSS + 564) /* ss_acc.c: 690 */ +#define ESS565 (ERRSS + 565) /* ss_acc.c: 699 */ +#define ESS566 (ERRSS + 566) /* ss_acc.c: 708 */ +#define ESS567 (ERRSS + 567) /* ss_acc.c: 771 */ +#define ESS568 (ERRSS + 568) /* ss_acc.c: 781 */ +#define ESS569 (ERRSS + 569) /* ss_acc.c: 792 */ +#define ESS570 (ERRSS + 570) /* ss_acc.c: 813 */ +#define ESS571 (ERRSS + 571) /* ss_acc.c: 858 */ +#define ESS572 (ERRSS + 572) /* ss_acc.c: 868 */ +#define ESS573 (ERRSS + 573) /* ss_acc.c: 880 */ +#define ESS574 (ERRSS + 574) /* ss_acc.c: 901 */ +#define ESS575 (ERRSS + 575) /* ss_acc.c: 999 */ +#define ESS576 (ERRSS + 576) /* ss_acc.c:1282 */ +#define ESS577 (ERRSS + 577) /* ss_acc.c:1288 */ +#define ESS578 (ERRSS + 578) /* ss_acc.c:1291 */ +#define ESS579 (ERRSS + 579) /* ss_acc.c:1305 */ +#define ESS580 (ERRSS + 580) /* ss_acc.c:1356 */ +#define ESS581 (ERRSS + 581) /* ss_acc.c:1362 */ +#define ESS582 (ERRSS + 582) /* ss_acc.c:1365 */ +#define ESS583 (ERRSS + 583) /* ss_acc.c:1379 */ +#define ESS584 (ERRSS + 584) /* ss_acc.c:1420 */ +#define ESS585 (ERRSS + 585) /* ss_acc.c:1475 */ +#define ESS586 (ERRSS + 586) /* ss_acc.c:1486 */ +#define ESS587 (ERRSS + 587) /* ss_acc.c:1544 */ +#define ESS588 (ERRSS + 588) /* ss_acc.c:1699 */ +#define ESS589 (ERRSS + 589) /* ss_acc.c:1704 */ +#define ESS590 (ERRSS + 590) /* ss_acc.c:1712 */ +#define ESS591 (ERRSS + 591) /* ss_acc.c:1717 */ +#define ESS592 (ERRSS + 592) /* ss_acc.c:1722 */ +#define ESS593 (ERRSS + 593) /* ss_acc.c:1727 */ +#define ESS594 (ERRSS + 594) /* ss_acc.c:1739 */ +#define ESS595 (ERRSS + 595) /* ss_acc.c:1742 */ +#define ESS596 (ERRSS + 596) /* ss_acc.c:1746 */ +#define ESS597 (ERRSS + 597) /* ss_acc.c:1761 */ +#define ESS598 (ERRSS + 598) /* ss_acc.c:1768 */ +#define ESS599 (ERRSS + 599) /* ss_acc.c:1785 */ +#define ESS600 (ERRSS + 600) /* ss_acc.c:1792 */ +#define ESS601 (ERRSS + 601) /* ss_acc.c:1806 */ +#define ESS602 (ERRSS + 602) /* ss_acc.c:1824 */ +#define ESS603 (ERRSS + 603) /* ss_acc.c:1828 */ +#define ESS604 (ERRSS + 604) /* ss_acc.c:1851 */ +#define ESS605 (ERRSS + 605) /* ss_acc.c:1854 */ +#define ESS606 (ERRSS + 606) /* ss_acc.c:1857 */ +#define ESS607 (ERRSS + 607) /* ss_acc.c:1860 */ +#define ESS608 (ERRSS + 608) /* ss_acc.c:1868 */ +#define ESS609 (ERRSS + 609) /* ss_acc.c:1871 */ +#define ESS610 (ERRSS + 610) /* ss_acc.c:1874 */ +#define ESS611 (ERRSS + 611) /* ss_acc.c:1877 */ +#define ESS612 (ERRSS + 612) /* ss_acc.c:1898 */ +#define ESS613 (ERRSS + 613) /* ss_acc.c:1902 */ +#define ESS614 (ERRSS + 614) /* ss_acc.c:1919 */ +#define ESS615 (ERRSS + 615) /* ss_acc.c:1923 */ +#define ESS616 (ERRSS + 616) /* ss_acc.c:1936 */ +#define ESS617 (ERRSS + 617) /* ss_acc.c:1943 */ +#define ESS618 (ERRSS + 618) /* ss_acc.c:1957 */ +#define ESS619 (ERRSS + 619) /* ss_acc.c:1960 */ +#define ESS620 (ERRSS + 620) /* ss_acc.c:1964 */ +#define ESS621 (ERRSS + 621) /* ss_acc.c:1983 */ +#define ESS622 (ERRSS + 622) /* ss_acc.c:1986 */ +#define ESS623 (ERRSS + 623) /* ss_acc.c:1989 */ +#define ESS624 (ERRSS + 624) /* ss_acc.c:1992 */ +#define ESS625 (ERRSS + 625) /* ss_acc.c:1995 */ +#define ESS626 (ERRSS + 626) /* ss_acc.c:1998 */ +#define ESS627 (ERRSS + 627) /* ss_acc.c:2014 */ +#define ESS628 (ERRSS + 628) /* ss_acc.c:2023 */ +#define ESS629 (ERRSS + 629) /* ss_acc.c:2028 */ +#define ESS630 (ERRSS + 630) /* ss_acc.c:2035 */ +#define ESS631 (ERRSS + 631) /* ss_acc.c:2052 */ +#define ESS632 (ERRSS + 632) /* ss_acc.c:2060 */ +#define ESS633 (ERRSS + 633) /* ss_acc.c:2065 */ +#define ESS634 (ERRSS + 634) /* ss_acc.c:2071 */ +#define ESS635 (ERRSS + 635) /* ss_acc.c:2087 */ +#define ESS636 (ERRSS + 636) /* ss_acc.c:2091 */ +#define ESS637 (ERRSS + 637) /* ss_acc.c:2095 */ +#define ESS638 (ERRSS + 638) /* ss_acc.c:2120 */ +#define ESS639 (ERRSS + 639) /* ss_acc.c:2123 */ +#define ESS640 (ERRSS + 640) /* ss_acc.c:2127 */ +#define ESS641 (ERRSS + 641) /* ss_acc.c:2135 */ +#define ESS642 (ERRSS + 642) /* ss_acc.c:2138 */ +#define ESS643 (ERRSS + 643) /* ss_acc.c:2143 */ +#define ESS644 (ERRSS + 644) /* ss_acc.c:2168 */ +#define ESS645 (ERRSS + 645) /* ss_acc.c:2171 */ +#define ESS646 (ERRSS + 646) /* ss_acc.c:2179 */ +#define ESS647 (ERRSS + 647) /* ss_acc.c:2186 */ +#define ESS648 (ERRSS + 648) /* ss_acc.c:2191 */ +#define ESS649 (ERRSS + 649) /* ss_acc.c:2202 */ +#define ESS650 (ERRSS + 650) /* ss_acc.c:2207 */ +#define ESS651 (ERRSS + 651) /* ss_acc.c:2225 */ +#define ESS652 (ERRSS + 652) /* ss_acc.c:2231 */ +#define ESS653 (ERRSS + 653) /* ss_acc.c:2248 */ +#define ESS654 (ERRSS + 654) /* ss_acc.c:2254 */ +#define ESS655 (ERRSS + 655) /* ss_acc.c:2274 */ +#define ESS656 (ERRSS + 656) /* ss_acc.c:2294 */ +#define ESS657 (ERRSS + 657) /* ss_acc.c:2485 */ +#define ESS658 (ERRSS + 658) /* ss_acc.c:2498 */ +#define ESS659 (ERRSS + 659) /* ss_acc.c:2516 */ +#define ESS660 (ERRSS + 660) /* ss_acc.c:2528 */ +#define ESS661 (ERRSS + 661) /* ss_acc.c:2544 */ +#define ESS662 (ERRSS + 662) /* ss_acc.c:2567 */ +#define ESS663 (ERRSS + 663) /* ss_acc.c:2599 */ +#define ESS664 (ERRSS + 664) /* ss_acc.c:2628 */ +#define ESS665 (ERRSS + 665) /* ss_acc.c:2660 */ +#define ESS666 (ERRSS + 666) /* ss_acc.c:2676 */ +#define ESS667 (ERRSS + 667) /* ss_acc.c:2688 */ +#define ESS668 (ERRSS + 668) /* ss_acc.c:2702 */ +#define ESS669 (ERRSS + 669) /* ss_acc.c:2716 */ +#define ESS670 (ERRSS + 670) /* ss_acc.c:2745 */ +#define ESS671 (ERRSS + 671) /* ss_acc.c:2779 */ +#define ESS672 (ERRSS + 672) /* ss_acc.c:2781 */ +#define ESS673 (ERRSS + 673) /* ss_acc.c:2785 */ +#define ESS674 (ERRSS + 674) /* ss_acc.c:2787 */ +#define ESS675 (ERRSS + 675) /* ss_acc.c:2802 */ +#define ESS676 (ERRSS + 676) /* ss_acc.c:2804 */ +#define ESS677 (ERRSS + 677) /* ss_acc.c:2808 */ +#define ESS678 (ERRSS + 678) /* ss_acc.c:2810 */ +#define ESS679 (ERRSS + 679) /* ss_acc.c:2824 */ +#define ESS680 (ERRSS + 680) /* ss_acc.c:2833 */ +#define ESS681 (ERRSS + 681) /* ss_acc.c:2835 */ +#define ESS682 (ERRSS + 682) /* ss_acc.c:2850 */ +#define ESS683 (ERRSS + 683) /* ss_acc.c:2879 */ +#define ESS684 (ERRSS + 684) /* ss_acc.c:2881 */ +#define ESS685 (ERRSS + 685) /* ss_acc.c:2892 */ +#define ESS686 (ERRSS + 686) /* ss_acc.c:2911 */ +#define ESS687 (ERRSS + 687) /* ss_acc.c:2936 */ +#define ESS688 (ERRSS + 688) /* ss_acc.c:2948 */ +#define ESS689 (ERRSS + 689) /* ss_acc.c:2953 */ +#define ESS690 (ERRSS + 690) /* ss_acc.c:2960 */ +#define ESS691 (ERRSS + 691) /* ss_acc.c:2966 */ +#define ESS692 (ERRSS + 692) /* ss_acc.c:2986 */ +#define ESS693 (ERRSS + 693) /* ss_acc.c:2995 */ +#define ESS694 (ERRSS + 694) /* ss_acc.c:3000 */ +#define ESS695 (ERRSS + 695) /* ss_acc.c:3007 */ +#define ESS696 (ERRSS + 696) /* ss_acc.c:3030 */ +#define ESS697 (ERRSS + 697) /* ss_acc.c:3035 */ +#define ESS698 (ERRSS + 698) /* ss_acc.c:3041 */ +#define ESS699 (ERRSS + 699) /* ss_acc.c:3046 */ +#define ESS700 (ERRSS + 700) /* ss_acc.c:3094 */ +#define ESS701 (ERRSS + 701) /* ss_acc.c:3152 */ +#define ESS702 (ERRSS + 702) /* ss_acc.c:3185 */ +#define ESS703 (ERRSS + 703) /* ss_acc.c:3203 */ +#define ESS704 (ERRSS + 704) /* ss_acc.c:3215 */ +#define ESS705 (ERRSS + 705) /* ss_acc.c:3227 */ +#define ESS706 (ERRSS + 706) /* ss_acc.c:3240 */ +#define ESS707 (ERRSS + 707) /* ss_acc.c:3245 */ +#define ESS708 (ERRSS + 708) /* ss_acc.c:3251 */ +#define ESS709 (ERRSS + 709) /* ss_acc.c:3263 */ +#define ESS710 (ERRSS + 710) /* ss_acc.c:3276 */ +#define ESS711 (ERRSS + 711) /* ss_acc.c:3292 */ +#define ESS712 (ERRSS + 712) /* ss_acc.c:3296 */ +#define ESS713 (ERRSS + 713) /* ss_acc.c:3300 */ +#define ESS714 (ERRSS + 714) /* ss_acc.c:3304 */ +#define ESS715 (ERRSS + 715) /* ss_acc.c:3308 */ +#define ESS716 (ERRSS + 716) /* ss_acc.c:3325 */ +#define ESS717 (ERRSS + 717) /* ss_acc.c:3329 */ +#define ESS718 (ERRSS + 718) /* ss_acc.c:3333 */ +#define ESS719 (ERRSS + 719) /* ss_acc.c:3337 */ +#define ESS720 (ERRSS + 720) /* ss_acc.c:3341 */ +#define ESS721 (ERRSS + 721) /* ss_acc.c:3358 */ +#define ESS722 (ERRSS + 722) /* ss_acc.c:3362 */ +#define ESS723 (ERRSS + 723) /* ss_acc.c:3366 */ +#define ESS724 (ERRSS + 724) /* ss_acc.c:3370 */ +#define ESS725 (ERRSS + 725) /* ss_acc.c:3374 */ +#define ESS726 (ERRSS + 726) /* ss_acc.c:3378 */ +#define ESS727 (ERRSS + 727) /* ss_acc.c:3382 */ +#define ESS728 (ERRSS + 728) /* ss_acc.c:3398 */ +#define ESS729 (ERRSS + 729) /* ss_acc.c:3402 */ +#define ESS730 (ERRSS + 730) /* ss_acc.c:3406 */ +#define ESS731 (ERRSS + 731) /* ss_acc.c:3410 */ +#define ESS732 (ERRSS + 732) /* ss_acc.c:3430 */ +#define ESS733 (ERRSS + 733) /* ss_acc.c:3434 */ +#define ESS734 (ERRSS + 734) /* ss_acc.c:3438 */ +#define ESS735 (ERRSS + 735) /* ss_acc.c:3453 */ +#define ESS736 (ERRSS + 736) /* ss_acc.c:3457 */ +#define ESS737 (ERRSS + 737) /* ss_acc.c:3461 */ +#define ESS738 (ERRSS + 738) /* ss_acc.c:3477 */ +#define ESS739 (ERRSS + 739) /* ss_acc.c:3481 */ +#define ESS740 (ERRSS + 740) /* ss_acc.c:3485 */ +#define ESS741 (ERRSS + 741) /* ss_acc.c:3489 */ +#define ESS742 (ERRSS + 742) /* ss_acc.c:3493 */ +#define ESS743 (ERRSS + 743) /* ss_acc.c:3508 */ +#define ESS744 (ERRSS + 744) /* ss_acc.c:3512 */ +#define ESS745 (ERRSS + 745) /* ss_acc.c:3516 */ +#define ESS746 (ERRSS + 746) /* ss_acc.c:3531 */ +#define ESS747 (ERRSS + 747) /* ss_acc.c:3535 */ +#define ESS748 (ERRSS + 748) /* ss_acc.c:3539 */ +#define ESS749 (ERRSS + 749) /* ss_acc.c:3543 */ +#define ESS750 (ERRSS + 750) /* ss_acc.c:3547 */ +#define ESS751 (ERRSS + 751) /* ss_acc.c:3562 */ +#define ESS752 (ERRSS + 752) /* ss_acc.c:3566 */ +#define ESS753 (ERRSS + 753) /* ss_acc.c:3570 */ +#define ESS754 (ERRSS + 754) /* ss_acc.c:3574 */ +#define ESS755 (ERRSS + 755) /* ss_acc.c:3578 */ +#define ESS756 (ERRSS + 756) /* ss_acc.c:3593 */ +#define ESS757 (ERRSS + 757) /* ss_acc.c:3597 */ +#define ESS758 (ERRSS + 758) /* ss_acc.c:3601 */ +#define ESS759 (ERRSS + 759) /* ss_acc.c:3605 */ +#define ESS760 (ERRSS + 760) /* ss_acc.c:3609 */ +#define ESS761 (ERRSS + 761) /* ss_acc.c:3625 */ +#define ESS762 (ERRSS + 762) /* ss_acc.c:3629 */ +#define ESS763 (ERRSS + 763) /* ss_acc.c:3633 */ +#define ESS764 (ERRSS + 764) /* ss_acc.c:3637 */ +#define ESS765 (ERRSS + 765) /* ss_acc.c:3654 */ +#define ESS766 (ERRSS + 766) /* ss_acc.c:3658 */ +#define ESS767 (ERRSS + 767) /* ss_acc.c:3674 */ +#define ESS768 (ERRSS + 768) /* ss_acc.c:3680 */ +#define ESS769 (ERRSS + 769) /* ss_acc.c:3684 */ +#define ESS770 (ERRSS + 770) /* ss_acc.c:4059 */ +#define ESS771 (ERRSS + 771) /* ss_acc.c:4062 */ +#define ESS772 (ERRSS + 772) /* ss_acc.c:4066 */ +#define ESS773 (ERRSS + 773) /* ss_acc.c:4076 */ +#define ESS774 (ERRSS + 774) /* ss_acc.c:4083 */ +#define ESS775 (ERRSS + 775) /* ss_acc.c:4095 */ +#define ESS776 (ERRSS + 776) /* ss_acc.c:4102 */ +#define ESS777 (ERRSS + 777) /* ss_acc.c:4116 */ +#define ESS778 (ERRSS + 778) /* ss_acc.c:4130 */ +#define ESS779 (ERRSS + 779) /* ss_acc.c:4134 */ +#define ESS780 (ERRSS + 780) /* ss_acc.c:4154 */ +#define ESS781 (ERRSS + 781) /* ss_acc.c:4157 */ +#define ESS782 (ERRSS + 782) /* ss_acc.c:4160 */ +#define ESS783 (ERRSS + 783) /* ss_acc.c:4163 */ +#define ESS784 (ERRSS + 784) /* ss_acc.c:4171 */ +#define ESS785 (ERRSS + 785) /* ss_acc.c:4174 */ +#define ESS786 (ERRSS + 786) /* ss_acc.c:4177 */ +#define ESS787 (ERRSS + 787) /* ss_acc.c:4180 */ +#define ESS788 (ERRSS + 788) /* ss_acc.c:4197 */ +#define ESS789 (ERRSS + 789) /* ss_acc.c:4201 */ +#define ESS790 (ERRSS + 790) /* ss_acc.c:4214 */ +#define ESS791 (ERRSS + 791) /* ss_acc.c:4218 */ +#define ESS792 (ERRSS + 792) /* ss_acc.c:4231 */ +#define ESS793 (ERRSS + 793) /* ss_acc.c:4238 */ +#define ESS794 (ERRSS + 794) /* ss_acc.c:4302 */ +#define ESS795 (ERRSS + 795) /* ss_acc.c:4305 */ +#define ESS796 (ERRSS + 796) /* ss_acc.c:4309 */ +#define ESS797 (ERRSS + 797) /* ss_acc.c:4324 */ +#define ESS798 (ERRSS + 798) /* ss_acc.c:4327 */ +#define ESS799 (ERRSS + 799) /* ss_acc.c:4330 */ +#define ESS800 (ERRSS + 800) /* ss_acc.c:4333 */ +#define ESS801 (ERRSS + 801) /* ss_acc.c:4336 */ +#define ESS802 (ERRSS + 802) /* ss_acc.c:4339 */ +#define ESS803 (ERRSS + 803) /* ss_acc.c:4351 */ +#define ESS804 (ERRSS + 804) /* ss_acc.c:4360 */ +#define ESS805 (ERRSS + 805) /* ss_acc.c:4365 */ +#define ESS806 (ERRSS + 806) /* ss_acc.c:4372 */ +#define ESS807 (ERRSS + 807) /* ss_acc.c:4385 */ +#define ESS808 (ERRSS + 808) /* ss_acc.c:4393 */ +#define ESS809 (ERRSS + 809) /* ss_acc.c:4398 */ +#define ESS810 (ERRSS + 810) /* ss_acc.c:4404 */ +#define ESS811 (ERRSS + 811) /* ss_acc.c:4416 */ +#define ESS812 (ERRSS + 812) /* ss_acc.c:4420 */ +#define ESS813 (ERRSS + 813) /* ss_acc.c:4424 */ +#define ESS814 (ERRSS + 814) /* ss_acc.c:4445 */ +#define ESS815 (ERRSS + 815) /* ss_acc.c:4448 */ +#define ESS816 (ERRSS + 816) /* ss_acc.c:4453 */ +#define ESS817 (ERRSS + 817) /* ss_acc.c:4461 */ +#define ESS818 (ERRSS + 818) /* ss_acc.c:4464 */ +#define ESS819 (ERRSS + 819) /* ss_acc.c:4469 */ +#define ESS820 (ERRSS + 820) /* ss_acc.c:4487 */ +#define ESS821 (ERRSS + 821) /* ss_acc.c:4490 */ +#define ESS822 (ERRSS + 822) /* ss_acc.c:4498 */ +#define ESS823 (ERRSS + 823) /* ss_acc.c:4505 */ +#define ESS824 (ERRSS + 824) /* ss_acc.c:4510 */ +#define ESS825 (ERRSS + 825) /* ss_acc.c:4524 */ +#define ESS826 (ERRSS + 826) /* ss_acc.c:4529 */ +#define ESS827 (ERRSS + 827) /* ss_acc.c:4543 */ +#define ESS828 (ERRSS + 828) /* ss_acc.c:4549 */ +#define ESS829 (ERRSS + 829) /* ss_acc.c:4562 */ +#define ESS830 (ERRSS + 830) /* ss_acc.c:4568 */ +#define ESS831 (ERRSS + 831) /* ss_acc.c:4584 */ +#define ESS832 (ERRSS + 832) /* ss_acc.c:4645 */ +#define ESS833 (ERRSS + 833) /* ss_acc.c:4659 */ +#define ESS834 (ERRSS + 834) /* ss_acc.c:4666 */ +#define ESS835 (ERRSS + 835) /* ss_acc.c:4677 */ +#define ESS836 (ERRSS + 836) /* ss_acc.c:4738 */ +#define ESS837 (ERRSS + 837) /* ss_acc.c:4766 */ +#define ESS838 (ERRSS + 838) /* ss_acc.c:4791 */ +#define ESS839 (ERRSS + 839) /* ss_acc.c:4819 */ +#define ESS840 (ERRSS + 840) /* ss_acc.c:4872 */ +#define ESS841 (ERRSS + 841) /* ss_acc.c:4883 */ +#define ESS842 (ERRSS + 842) /* ss_acc.c:4955 */ +#define ESS843 (ERRSS + 843) /* ss_acc.c:4958 */ +#define ESS844 (ERRSS + 844) /* ss_acc.c:4961 */ +#define ESS845 (ERRSS + 845) /* ss_acc.c:4964 */ +#define ESS846 (ERRSS + 846) /* ss_acc.c:4972 */ +#define ESS847 (ERRSS + 847) /* ss_acc.c:4975 */ +#define ESS848 (ERRSS + 848) /* ss_acc.c:4978 */ +#define ESS849 (ERRSS + 849) /* ss_acc.c:4981 */ +#define ESS850 (ERRSS + 850) /* ss_acc.c:5041 */ +#define ESS851 (ERRSS + 851) /* ss_acc.c:5045 */ +#define ESS852 (ERRSS + 852) /* ss_acc.c:5104 */ +#define ESS853 (ERRSS + 853) /* ss_acc.c:5108 */ +#define ESS854 (ERRSS + 854) /* ss_acc.c:5121 */ +#define ESS855 (ERRSS + 855) /* ss_acc.c:5128 */ +#define ESS856 (ERRSS + 856) /* ss_acc.c:5276 */ +#define ESS857 (ERRSS + 857) /* ss_acc.c:5285 */ +#define ESS858 (ERRSS + 858) /* ss_acc.c:5305 */ +#define ESS859 (ERRSS + 859) /* ss_acc.c:5326 */ +#define ESS860 (ERRSS + 860) /* ss_acc.c:5336 */ +#define ESS861 (ERRSS + 861) /* ss_acc.c:5357 */ +#define ESS862 (ERRSS + 862) /* ss_acc.c:5378 */ +#define ESS863 (ERRSS + 863) /* ss_acc.c:5387 */ +#define ESS864 (ERRSS + 864) /* ss_acc.c:5408 */ +#define ESS865 (ERRSS + 865) /* ss_acc.c:5429 */ +#define ESS866 (ERRSS + 866) /* ss_acc.c:5438 */ +#define ESS867 (ERRSS + 867) /* ss_acc.c:5458 */ +#define ESS868 (ERRSS + 868) /* ss_acc.c:5479 */ +#define ESS869 (ERRSS + 869) /* ss_acc.c:5488 */ +#define ESS870 (ERRSS + 870) /* ss_acc.c:5508 */ +#define ESS871 (ERRSS + 871) /* ss_acc.c:5533 */ +#define ESS872 (ERRSS + 872) /* ss_acc.c:5549 */ +#define ESS873 (ERRSS + 873) /* ss_acc.c:5565 */ +#define ESS874 (ERRSS + 874) /* ss_acc.c:5581 */ +#define ESS875 (ERRSS + 875) /* ss_acc.c:5596 */ +#define ESS876 (ERRSS + 876) /* ss_acc.c:5646 */ +#define ESS877 (ERRSS + 877) /* ss_acc.c:5694 */ +#define ESS878 (ERRSS + 878) /* ss_acc.c:5742 */ +#define ESS879 (ERRSS + 879) /* ss_acc.c:5790 */ +#define ESS880 (ERRSS + 880) /* ss_acc.c:5838 */ +#define ESS881 (ERRSS + 881) /* ss_acc.c:6106 */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __SSERRH__ */ + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/mt/ss_gen.c b/src/mt/ss_gen.c new file mode 100644 index 000000000..1870b44aa --- /dev/null +++ b/src/mt/ss_gen.c @@ -0,0 +1,2279 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/********************************************************************20** + + Name: System Services -- general functions + + Type: C source file + + Desc: Source code for System Services startup and general + System Services. + + File: ss_gen.c + +*********************************************************************21*/ + + +/* header include files (.h) */ + +#include +#include +#include "envopt.h" /* environment options */ +#include "envdep.h" /* environment dependent */ +#include "envind.h" /* environment independent */ + +#include "gen.h" /* general layer */ +#include "ssi.h" /* system services */ + +#include "ss_err.h" /* errors */ +#include "ss_dep.h" /* implementation-specific */ +#include "ss_queue.h" /* queues */ +#include "ss_task.h" /* tasking */ +#include "ss_msg.h" /* messaging */ +#include "ss_mem.h" /* memory management interface */ +#include "ss_gen.h" /* general */ +/*ss013.301: Fixed Warnings for 32/64 bit compilation*/ +#ifdef SS_FBSED_TSK_REG +#include "cm_task.h" +#endif /* SS_FBSED_TSK_REG */ +#include "cm_llist.h" +#include "cm_hash.h" +/* ss001.301: additions */ +#include "cm_mem.h" /* memory management */ + +/* header/extern include files (.x) */ + +#include "gen.x" /* general layer */ +#include "ssi.x" /* system services */ + +#include "ss_dep.x" /* implementation-specific */ +#include "ss_queue.x" /* queues */ +#include "ss_task.x" /* tasking */ +#include "ss_timer.x" /* timers */ +#include "ss_strm.x" /* STREAMS */ +#include "ss_msg.x" /* messaging */ +#include "ss_mem.x" /* memory management interface */ +#include "ss_drvr.x" /* driver tasks */ +#ifdef SS_LOCKLESS_MEMORY +#include "cm_llist.x" +#include "cm_hash.x" +#include "cm_mem_wl.x" /* common memory manager */ +#else +#include "cm_mem.x" /* common memory manager */ +#endif /* SS_LOCKLESS_MEMORY */ +#include "ss_gen.x" /* general */ +/* ss001.301: additions */ +#ifdef SS_LOGGER_SUPPORT +#include "cm_lib.x" +#endif /* SS_LOGGER_SUPPORT */ +#ifdef SS_MULTICORE_SUPPORT +#include "cm_llist.x" +#include "cm_hash.x" +#include "cm_mem.h" +#include "cm_mem_wl.x" +#include "cm_lib.x" +#endif + +/* Cavium Changes:ss004.301 */ +#ifdef SS_SEUM_CAVIUM +#include "cvmx-config.h" +#include "cvmx.h" +#endif /* SS_SEUM_CAVIUM */ + +/*ss011.301 : RMIOS release related changes*/ +#ifdef SS_RMIOS +#include "mt_msgr.x" +#endif +/*ss013.301: Fixed Warnings for 32/64 bit compilation*/ +#ifdef SS_FBSED_TSK_REG +#include "cm_task.x" +#endif /* SS_FBSED_TSK_REG */ +#include + +/* public variable declarations */ + +/*ss014.301: SSI-4GMX related changes*/ +#ifdef SS_4GMX_LCORE +PUBLIC VOLATILE SsOs osCp; /* common OS control point */ +#else +PUBLIC SsOs osCp; /* common OS control point */ +#endif + + +EXTERN Cntr cfgNumRegs; +EXTERN SsRegCfg cfgRegInfo[SS_MAX_REGS]; + + +/* ss029.103: modification: multiple procId related changes */ +#ifdef SS_MULTIPLE_PROCS +/* PRIVATE functions */ +PRIVATE S16 SInsProcId ARGS((ProcId proc)); +PRIVATE S16 SRemProcId ARGS((ProcId proc)); +PRIVATE S16 SLockOsCp ARGS((Void)); +PRIVATE S16 SULockOsCp ARGS((Void)); +#endif /* SS_MULTIPLE_PROCS */ + +#ifdef SSI_STATIC_MEM_LEAK_DETECTION +PRIVATE void InitializeForStaticMemLeak ARGS((void)); +PRIVATE void InitializeStaticMemAllocInfo ARGS((StaticMemAllocInfo* memAllocInfo)); +PUBLIC U32 GetNextFreeIdx ARGS((StaticMemAllocInfo * memAllocInfo)); +PUBLIC void FreeIdx ARGS((U8* ptr, U32 idx, StaticMemAllocInfo* memAllocInfo,U32 size, char* + file, U32 line)); +PUBLIC void LogForStaticMemLeak ARGS((StaticMemAllocInfo* memAllocInfo, char* file, + U32 line, U32 size, void* ptr, U32 idx)); +PRIVATE void PrintStaticMemAllocInfo ARGS((StaticMemAllocInfo* memAllocInfo, FILE + *opFile)); +#endif +/* ss001.301: additions */ + +PUBLIC void DumpSSIDemandQDebugInformation() +{ + U32 i,j; + RTLIN_DUMP_DEBUG("Demand Q Information\n"); + RTLIN_DUMP_DEBUG("====================\n"); + for(i = 0; i < osCp.numSTsks; i++) + { + SsSTskEntry* tskEntry = &(osCp.sTskTbl[i]); + + for(j = 0; j < SS_MAX_NUM_DQ; j++) + { +#ifndef ALIGN_64BIT + RTLIN_DUMP_DEBUG("Task[%lu] Q[%lu] QSize = %lu region=%d\n", i, j, tskEntry->dQ.queue[j].crntSize,tskEntry->region); +#else + RTLIN_DUMP_DEBUG("Task[%u] Q[%u] QSize = %u region=%d\n", i, j, tskEntry->dQ.queue[j].crntSize,tskEntry->region); +#endif + } + } +} + +#ifdef TENB_T2K3K_SPECIFIC_CHANGES +pthread_mutex_t dumpingLock = PTHREAD_MUTEX_INITIALIZER; + +PUBLIC Void mtSigSegvHndlr() +{ + int i; + + printf("Backtrace for thread Id (%lu) total threads = %d\n", (unsigned long) pthread_self(), osCp.numSTsks); + ysPrntBkTrace(); + for(i = 0; i < osCp.numSTsks; i++) + { + SsSTskEntry* tskEntry = &(osCp.sTskTbl[i]); + if((tskEntry->dep.tId != pthread_self()) && (tskEntry->dep.tId != 0)) + { + pthread_kill(tskEntry->dep.tId, SIGUSR2); + } + } + + sleep(5); +} + +PUBLIC Void mtSigUsr2Hndlr() +{ + printf("Backtrace for thread Id (%lu) cause:SIGUSR2(%d)\n",(unsigned long) pthread_self(),SIGUSR2); + + pthread_mutex_lock(&dumpingLock); + ysPrntBkTrace(); + pthread_mutex_unlock(&dumpingLock); + + sleep(5); + + exit(0); +} + +#endif + + +/* +* +* Fun: System Services initialization function +* +* Desc: This is the general initialization function for +* all System Services implementations. It initializes +* all the common global data structures and calls the +* implementation-specific initialization and start +* functions. +* +* Ret: Void +* +* Notes: +* +* File: ss_gen.c +* +*/ +#ifdef ANSI +PUBLIC S16 SInit +( +void +) +#else +PUBLIC S16 SInit() +#endif +{ + S16 ret; + REG1 S16 i; + REG2 S16 j; + REG3 S16 k; + SsTTskEntry *tTsk; + SsSTskEntry *sTsk; + SsTmrEntry *tmr; + SsRegionEntry *reg; + /*ss012.301 : Fix log related issue to suite MT and NS implementations*/ + Txt prntBufLoc[1000]; +#ifdef SS_DRVR_SUPPORT + SsDrvrTskEntry *drvrTsk; +#endif +/* ss002.301 : Modications */ + TRC1(SInit); + + osCp.configFilePath = "/mnt/tmp/configFile"; + + /*ss012.301 : Fix log related issue to suite MT and NS implementations*/ + + /* ss019.103 - Modified for correct initialization of OS control point */ + /* start initializing OS control point */ +/* ss029.103: modification: multiple procId related changes */ +#ifndef SS_MULTIPLE_PROCS +/* ss004.301: Cavium changes */ +#ifdef SS_SEUM_CAVIUM + osCp.procId = cvmx_get_core_num(); +#else + osCp.procId = SS_PROC_ID; +#endif /* SS_SEUM_CAVIUM */ +#else /* SS_MULTIPLE_PROCS */ + for (i = 0; i < SS_MAX_PROCS; i++) + osCp.procLst.procId[i] = PROCNC; + + osCp.procLst.free = SS_MAX_PROCS; +#endif /* SS_MULTIPLE_PROCS */ + +#ifdef SS_THR_REG_MAP + cmMemset(osCp.threadMemoryRegionMap, SS_INVALID_THREAD_REG_MAP, + (sizeof(Region) * SS_MAX_THREAD_REGION_MAP)); + ssRegMainThread(); +#endif + + /* implementation specific general initialization */ + ret = ssdInitGen(); + if (ret != ROK) + { + /*ss012.301 : Fix log related issue to suite MT and NS implementations*/ + sprintf(prntBufLoc,"\n SInit(): ssdInitGen failed to initialize\ + implementation specific general information \n"); + SDisplay(1,prntBufLoc); + RETVALUE(RFAILED); + } + +#ifdef SSI_STATIC_MEM_LEAK_DETECTION + InitializeForStaticMemLeak(); +#endif + /* initialize memory information */ + osCp.numRegions = 0; + + for (i = 0; i < SS_MAX_REGS; i++) + { + reg = &osCp.regionTbl[i]; + + reg->used = FALSE; + + reg->start = NULLP; + reg->size = 0; + reg->regCb = NULLP; + reg->flags = 0; + reg->alloc = NULLP; + reg->free = NULLP; + reg->ctl = NULLP; + /* ss007.301 initializing the per region mBufRefLock */ + SInitLock(®->mBufRefLock, SS_LOCK_MUTEX); + + /* zero the pool information */ + reg->numPools = 0; + for (j = 0; j < SS_MAX_POOLS_PER_REG; j++) + reg->poolTbl[j].type = SS_POOL_UND; + + /* find this region ID in the region configuration structure */ + for (j = 0; j < cfgNumRegs; j++) + if (cfgRegInfo[j].region == i) + break; + + /* this region is not configured */ + if (j == cfgNumRegs) + continue; + + /* Load the configuration information into the region table. + * Note, the region still has to be registered, for it to + * be usable. + */ + for (k = 0; k < cfgRegInfo[j].numPools; k++) + { + reg->poolTbl[k].type = cfgRegInfo[j].pools[k].type; + if (reg->poolTbl[k].type == SS_POOL_DYNAMIC) + reg->poolTbl[k].u.dpool.size = cfgRegInfo[j].pools[k].size; + } + } + + /* Initialization of dynamic regions */ + for (i = 0; i < SS_MAX_REGS; i++) + { + reg = &osCp.dynRegionTbl[i]; + + reg->used = FALSE; + + reg->start = NULLP; + reg->size = 0; + reg->regCb = NULLP; + reg->flags = 0; + reg->alloc = NULLP; + reg->free = NULLP; + reg->ctl = NULLP; + /* ss007.301 initializing the per region mBufRefLock */ + SInitLock(®->mBufRefLock, SS_LOCK_MUTEX); + + /* zero the pool information */ + reg->numPools = 0; + for (j = 0; j < SS_MAX_POOLS_PER_REG; j++) + reg->poolTbl[j].type = SS_POOL_UND; + + /* find this region ID in the region configuration structure */ + for (j = 0; j < cfgNumRegs; j++) + if (cfgRegInfo[j].region == i) + break; + + /* this region is not configured */ + if (j == cfgNumRegs) + continue; + + /* Load the configuration information into the region table. + * Note, the region still has to be registered, for it to + * be usable. + */ + for (k = 0; k < cfgRegInfo[j].numPools; k++) + { + reg->poolTbl[k].type = cfgRegInfo[j].pools[k].type; + if (reg->poolTbl[k].type == SS_POOL_DYNAMIC) + reg->poolTbl[k].u.dpool.size = cfgRegInfo[j].pools[k].size; + } + } + + ret = ssInitSema(&osCp.regionTblSem, SS_MAX_STSKS); + if (ret != ROK) + { + /*ss012.301 : Fix log related issue to suite MT and NS implementations*/ + sprintf(prntBufLoc,"\n SInit(): Could not initialize the region Table Semaphore \n"); + SDisplay(1,prntBufLoc); + goto cleanup0; + } + + /* implementation specific memory initialization */ + ret = ssdInitMem(); + if (ret != ROK) + { + /*ss012.301 : Fix log related issue to suite MT and NS implementations*/ + sprintf(prntBufLoc,"\n SInit(): Memory initialization failed \n"); + SDisplay(1,prntBufLoc); + goto cleanup1; + } + + + /* initialize TAPA and system task information */ +/* ss029.103: modification: multiple procId related changes */ +#ifndef SS_MULTIPLE_PROCS + for (i = 0; i < SS_MAX_ENT; i++) + for (j = 0; j < SS_MAX_INST; j++) + osCp.tTskIds[i][j] = SS_TSKNC; +#else /* SS_MULTIPLE_PROCS */ + for (i = 0; i < SS_MAX_PROCS; i++) + for (j = 0; j < SS_MAX_ENT; j++) + for (k = 0; k < SS_MAX_INST; k++) + osCp.tTskIds[i][j][k] = SS_TSKNC; +#endif /* SS_MULTIPLE_PROCS */ + + for (i = 0; i < SS_MAX_TTSKS; i++) + { + tTsk = &osCp.tTskTbl[i]; + + tTsk->used = FALSE; + tTsk->ent = ENTNC; + tTsk->inst = INSTNC; + tTsk->tskType = TTUND; + tTsk->tskPrior = 0; + tTsk->initTsk = NULLP; + tTsk->actvTsk = NULLP; + tTsk->sTsk = NULLP; +/* ss029.103: addition: TAPA task control block added */ +#ifdef SS_MULTIPLE_PROCS + tTsk->xxCb = NULLP; +#endif /* SS_MULTIPLE_PROCS */ + + tTsk->nxt = i + 1; + } + + osCp.numTTsks = 0; + osCp.nxtTTskEntry = 0; + + ret = ssInitSema(&osCp.tTskTblSem, SS_MAX_STSKS); + if (ret != ROK) + { + /*ss012.301 : Fix log related issue to suite MT and NS implementations*/ + sprintf(prntBufLoc,"\n SInit(): Could not initialize the tTask table Semaphore \n"); + SDisplay(1,prntBufLoc); + goto cleanup2; + } + +#ifdef SS_MULTICORE_SUPPORT + /* check whether number of system tasks is + * equal to number of (regions-1). + * The last region is meant for timer task + * which under the current feature has as entry + * in system task table. + */ + if(SS_MAX_STSKS > SS_MAX_REGS) + { + /*ss012.301 : Fix log related issue to suite MT and NS implementations*/ + goto cleanup3; + } +#endif + + /* initialize system task information */ + for (i = 0; i < SS_MAX_STSKS; i++) + { + sTsk = &osCp.sTskTbl[i]; + + sTsk->used = FALSE; + sTsk->termPend = FALSE; + sTsk->tskPrior = 0; + for (j = 0; j < SS_MAX_TTSKS; j++) + sTsk->tTsks[j] = SS_INVALID_IDX; + sTsk->numTTsks = 0; + + sTsk->nxt = i + 1; +/* ss002.301 : Modifications */ +#ifdef SS_MULTICORE_SUPPORT + if(i == 0) + { + sTsk->region = (SS_MAX_REGS - 1); + } + else + { + sTsk->region = i-1; + } +#endif + } + + osCp.numSTsks = 0; + osCp.nxtSTskEntry = 0; + + ret = SInitLock(&osCp.sTskTblLock, SS_STSKTBL_LOCK); + if (ret != ROK) + { + /*ss012.301 : Fix log related issue to suite MT and NS implementations*/ + sprintf(prntBufLoc,"\n SInit(): Could not initialize the tTask table Semaphore \n"); + SDisplay(1,prntBufLoc); + goto cleanup3; + } + + /* ss028.103 - Addition of lock for mBuf reference count */ + /* ss007.301 moving the mBufRefLock from common to per region */ + /* SInitLock(&osCp.mBufRefLock, SS_LOCK_MUTEX);*/ + + /* implementation specific task initialization */ + ret = ssdInitTsk(); + if (ret != ROK) + { + /*ss012.301 : Fix log related issue to suite MT and NS implementations*/ + sprintf(prntBufLoc,"\n SInit(): implementation specific task initialization Failed \n"); + SDisplay(1,prntBufLoc); + goto cleanup4; + } + +#ifdef SS_DRVR_SUPPORT + /* initialize driver task information */ + for (i = 0; i < SS_MAX_DRVRTSKS; i++) + { + drvrTsk = &osCp.drvrTskTbl[i]; + + drvrTsk->used = FALSE; + + drvrTsk->channel = 0; + drvrTsk->actvTsk = NULLP; + drvrTsk->isTsk = NULLP; + drvrTsk->low = 0; + drvrTsk->high = 0; + } + + osCp.numDrvrTsks = 0; + + /* implementation specific driver initialization */ + ret = ssdInitDrvr(); + if (ret != ROK) + { + /*ss012.301 : Fix log related issue to suite MT and NS implementations*/ + sprintf(prntBufLoc,"\n SInit(): ssdInitDrvr failed \n"); + SDisplay(1,prntBufLoc); + goto cleanup5; + } +#endif + + /*ss004.301: Cavium Changes */ +#ifdef SS_SEUM_CAVIUM + ret = ssInitRcvWork(); + if (ret != ROK) + { + /*ss012.301 : Fix log related issue to suite MT and NS implementations*/ + goto cleanup6; + } +#endif /* SS_SEUM_CAVIUM */ + + + /* initialize the demand queue lookup table */ + osCp.dmndQLookupTbl[0] = 255; + osCp.dmndQLookupTbl[1] = 0; + osCp.dmndQLookupTbl[2] = 1; + osCp.dmndQLookupTbl[3] = 1; + for (i = 4; i < 256; i++) + { + if (i >= 128 && i <= 255) + osCp.dmndQLookupTbl[i] = 7; + if (i >= 64 && i <= 127) + osCp.dmndQLookupTbl[i] = 6; + if (i >= 32 && i <= 63) + osCp.dmndQLookupTbl[i] = 5; + if (i >= 16 && i <= 31) + osCp.dmndQLookupTbl[i] = 4; + if (i >= 8 && i <= 15) + osCp.dmndQLookupTbl[i] = 3; + if (i >= 4 && i <= 7) + osCp.dmndQLookupTbl[i] = 2; + } + + + /* initialize timer information */ + for (i = 0; i < SS_MAX_TMRS; i++) + { + tmr = &osCp.tmrTbl[i]; + + tmr->used = FALSE; + tmr->tmrId = 0; + tmr->ownerEnt = ENTNC; + tmr->ownerInst = INSTNC; + tmr->interval = 0; + /* + * ss015.301 - Modifed in initialization as timer activation + * functions enclosed in a union. Also initialized the mtFlag + * to FALSE + */ + tmr->ssTmrActvFn.actvFnc.tmrActvFn = NULLP; +#ifndef SS_MULTIPLE_PROCS +#ifdef SS_MT_TMR + tmr->ssTmrActvFn.mtFlag = FALSE; + tmr->ssTmrActvFn.actvFnc.tmrActvFnMt = NULLP; +#endif +#endif + tmr->nxt = i + 1; + } + + osCp.numTmrs = 0; + osCp.nxtTmrEntry = 0; + + ret = SInitLock(&osCp.tmrTblLock, SS_TMRTBL_LOCK); + if (ret != ROK) + { + /*ss012.301 : Fix log related issue to suite MT and NS implementations*/ + goto cleanup6; + } + + /* implementation specific timer initialization */ + ret = ssdInitTmr(); + if (ret != ROK) + { + /*ss012.301 : Fix log related issue to suite MT and NS implementations*/ + sprintf(prntBufLoc,"\n SInit(): Could not initialize the timer \n"); + SDisplay(1,prntBufLoc); + goto cleanup7; + } + + /*ss012.301 : Fix log related issue to suite MT and NS implementations*/ + /* ss005.201: Initialize logging streams */ + /* implementation specific logging initialization */ + ret = ssdInitLog(); + if (ret != ROK) + { + /*ss012.301 : Fix log related issue to suite MT and NS implementations*/ + sprintf(prntBufLoc,"\n SInit(): Could not initialize the Logging streams \n"); + SDisplay(1,prntBufLoc); + goto cleanup8; + } + +#ifdef SS_LOGGER_SUPPORT /* ss001.301: additions */ + /* Initialize the lock, return on failure */ + if( SInitLock(&(osCp.logger.bufLock),SS_LOCK_MUTEX) != ROK) + { + /*ss012.301 : Fix log related issue to suite MT and NS implementations*/ + sprintf(prntBufLoc,"\n SInit(): Could not initialize the Logger Buffer Lock \n"); + SDisplay(1,prntBufLoc); + goto cleanup9; + } /* if */ + + /* Initialize the logger configuration flag */ + osCp.logger.configured = FALSE; + /* Ss002.301 : Initialised */ + osCp.logger.started = FALSE; +#endif /* SS_LOGGER_SUPPORT */ +/* ss001.301: additions */ + +#ifdef SS_HISTOGRAM_SUPPORT + /* Here we are filling all the tapa entity Ids, which will be + * helpful to get the entity Id using file name. */ + ret = SFillEntIds(); +#endif /* SS_HISTOGRAM_SUPPORT */ + + +#ifdef SS_FBSED_TSK_REG + /* Configure task registration based on the configuration */ + /*ss013.301 : Fixed warnings for 32/64 bit compilation*/ + cmCfgrTskReg((U8 *)"task_info.t"); +#endif /* SS_FBSED_TSK_REG */ + +/*ss011.301 : RMIOS release related changes*/ +#ifdef SS_RMIOS + spInit(); +#endif + + /* call tst() function */ + ret = tst(); + if (ret != ROK) + { + /*ss012.301 : Fix log related issue to suite MT and NS implementations*/ + goto cleanup10; + } + + + /* call implementation-specific starter function */ + ssdStart(); + + + RETVALUE(ROK); + + +/* clean up code */ +/*ss012.301 : Fix log related issue to suite MT and NS implementations*/ +cleanup10: +#ifdef SS_LOGGER_SUPPORT + /* ss005.301: Deinitialize the logging at the end */ + SDestroyLock(&(osCp.logger.bufLock)); + /*ss013.301 : Fix for compile time warning*/ +cleanup9: +#endif /* SS_LOGGER_SUPPORT */ + ssdDeinitLog(); +cleanup8: + ssdDeinitTmr(); +cleanup7: + SDestroyLock(&osCp.tmrTblLock); + +cleanup6: +#ifdef SS_DRVR_SUPPORT + ssdDeinitDrvr(); +cleanup5: +#endif + ssdDeinitTsk(); +cleanup4: + SDestroyLock(&osCp.sTskTblLock); +cleanup3: + if ( (ssDestroySema(&osCp.tTskTblSem)) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS012, ERRZERO, + "Could not destroy the Semaphore"); + /* ss005.301: Changes, clean the threads and exit */ +#endif + } + +cleanup2: + ssdDeinitMem(); +cleanup1: + /* ss007.301 destroying the per region mBufRefLock */ + for (i= 0;i= osCp.logger.maxBufSiz) + { + SFlushBufToLog(osCp.logger.buffer); + osCp.logger.curBufSiz = 0; + cmMemset((U8 *)osCp.logger.buffer, '\0', osCp.logger.maxBufSiz); + sprintf(osCp.logger.buffer, "%s", buf); + osCp.logger.curBufSiz += bufSz; + } + else + { + strcat(osCp.logger.buffer,buf); + osCp.logger.curBufSiz += bufSz; + } + (Void)SUnlock(&(osCp.logger.bufLock)); + RETVALUE(ROK); +} +#endif /* SS_LOGGER_SUPPORT */ +/* +* +* Fun: SPrint +* +* Desc: Print a string. +* +* This function should be used for debugging only. +* +* Ret: ROK - ok +* +* Notes: Text buffer should be null terminated. +* +* SDisplay will replace SPrint. +* +* Typical usage consists of a call to sprintf to +* format the string into a buffer followed by a +* call to SPrint +* +* File: ss_gen.c +* +*/ +#ifdef ANSI +PUBLIC S16 SPrint +( +Txt *buf /* buffer */ +) +#else +PUBLIC S16 SPrint(buf) +Txt *buf; /* buffer */ +#endif +{ + TRC1(SPrint); + +/* ss001.301: additions */ + SDisplay(0, buf); +#ifdef SS_LOGGER_SUPPORT + SWrtLogBuf(buf); +#endif /* SS_LOGGER_SUPPORT */ + + RETVALUE(ROK); + +} /* end of SPrint */ + + +/* +* +* Fun: SError +* +* Desc: Invoked by layer when an unrecoverable +* software error is detected. This function should +* never return. +* +* Ret: None +* +* Notes: None +* +* File: ss_gen.c +* +*/ +#ifdef ANSI +PUBLIC S16 SError +( +Seq seq, /* sequence */ +Reason reason /* reason */ +) +#else +PUBLIC S16 SError(seq, reason) +Seq seq; /* sequence */ +Reason reason; /* reason */ +#endif +{ + S16 ret; + DateTime dt; + Txt errBuf[256]; + + + TRC1(SError); + + + SGetDateTime(&dt); + sprintf(errBuf, "\n\ndate: %02d/%02d/%04d time: %02d:%02d:%02d\n", + (int)dt.month,(int)dt.day,(int)dt.year + 1900, + (int)dt.hour,(int)dt.min,(int)dt.sec); + SPrint(errBuf); + + + ret = ssdError(seq, reason); + + + RETVALUE(ret); +} + + +/* +* +* Fun: SLogError +* +* Desc: Invoked by layer to log an error. +* +* Ret: None +* +* Notes: None +* +* File: ss_gen.c +* +*/ +#ifdef ANSI +PUBLIC Void SLogError +( +Ent ent, /* Calling layer's entity id */ +Inst inst, /* Calling layer's instance id */ +ProcId procId, /* Calling layer's processor id */ +Txt *file, /* file name where error occured */ +S32 line, /* line in file where error occured */ +ErrCls errCls, /* error class */ +ErrCode errCode, /* layer unique error code */ +ErrVal errVal, /* error value */ +Txt *errDesc /* description of error */ +) +#else +PUBLIC Void SLogError(ent, inst, procId, file, line, + errCls, errCode, errVal, errDesc) +Ent ent; /* Calling layer's entity id */ +Inst inst; /* Calling layer's instance id */ +ProcId procId; /* Calling layer's processor id */ +Txt *file; /* file name where error occured */ +S32 line; /* line in file where error occured */ +ErrCls errCls; /* error class */ +ErrCode errCode; /* layer unique error code */ +ErrVal errVal; /* error value */ +Txt *errDesc; /* description of error */ +#endif +{ + DateTime dt; + Txt errBuf[512]; + + + TRC1(SLogError); + +/*ss014.301: SSI-4GMX related changes*/ +#ifndef SS_4GMX_LCORE + SGetDateTime(&dt); + sprintf(errBuf, "\n\ndate: %02d/%02d/%04d time: %02d:%02d:%02d\n", + (int)dt.month,(int)dt.day,(int)dt.year + 1900, + (int)dt.hour,(int)dt.min,(int)dt.sec); + SDisplay(0,errBuf); +#endif + +/* ss001.301: additions */ +#ifdef SS_LOGGER_SUPPORT + SWrtLogBuf(errBuf); +#endif /* SS_LOGGER_SUPPORT */ + + ssdLogError(ent, inst, procId, file, line, + errCls, errCode, errVal, errDesc); + + + RETVOID; +} + +/* ss029.103: modification: + SFndProcId function is not supported with multiple procIds */ +#ifndef SS_MULTIPLE_PROCS + +/* +* +* Fun: SFndProcId +* +* Desc: This function finds the local processor ID. +* +* Ret: local processor id +* +* Notes: +* +* File: ss_gen.c +* +*/ +#ifdef ANSI +PUBLIC ProcId SFndProcId +( +void +) +#else +PUBLIC ProcId SFndProcId() +#endif +{ + TRC1(SFndProcId); + + RETVALUE(osCp.procId); +} /* end of SFndProcId */ + + +/* +* +* Fun: SSetProcId +* +* Desc: This function stores the local processor ID. +* +* Ret: Void +* +* Notes: +* +* File: ss_gen.c +* +*/ +#ifdef ANSI +PUBLIC Void SSetProcId +( +ProcId procId +) +#else +PUBLIC Void SSetProcId(procId) +ProcId procId; +#endif +{ + TRC1(SSetProcId); + + osCp.procId = procId; + + RETVOID; +} + +#endif /* SS_MULTIPLE_PROCS */ + +/* ss029.103: addition: New SSI functions with multiple proc support */ +#ifdef SS_MULTIPLE_PROCS + +/* +* +* Fun: SGetProcIdIdx +* +* Desc: This function finds index of procId in the process id table +* +* Ret: ROK/RFAILED +* +* Notes: +* +* File: ss_gen.c +* +*/ +#ifdef ANSI +PUBLIC U16 SGetProcIdIdx +( +ProcId proc +) +#else +PUBLIC U16 SGetProcIdIdx(proc) +ProcId proc; +#endif +{ + U16 i; + U16 idx; + + TRC1(SGetProcIdIdx); + + idx = SS_HASH_IDX(proc); + + for (i = idx; i < SS_MAX_PROCS; i++) + if (osCp.procLst.procId[i] == proc) + return i; + + /* search upto idx */ + for (i = 0; i < idx; i++) + if (osCp.procLst.procId[i] == proc) + return i; + + RETVALUE(SS_INV_PROCID_IDX); +} /* SGetProcIdIdx */ + + +/* +* +* Fun: SInsProcId +* +* Desc: This function inserts procId in the process id table +* +* Ret: ROK/RFAILED +* +* Notes: +* +* File: ss_gen.c +* +*/ +#ifdef ANSI +PRIVATE S16 SInsProcId +( +ProcId proc +) +#else +PRIVATE S16 SInsProcId(proc) +ProcId proc; +#endif +{ + U16 i; + U16 idx; + + TRC1(SInsProcId); + + idx = SS_HASH_IDX(proc); + + for (i = idx; i < SS_MAX_PROCS; i++) + if (osCp.procLst.procId[i] == SS_INV_PROCID) + { + osCp.procLst.procId[i] = proc; + osCp.procLst.free--; + RETVALUE(ROK); + } + + /* search for free entry upto idx */ + for (i = 0; i < idx; i++) + if (osCp.procLst.procId[i] == SS_INV_PROCID) + { + osCp.procLst.procId[i] = proc; + osCp.procLst.free--; + RETVALUE(ROK); + } + + RETVALUE(RFAILED); +} /* SInsProcId */ + + +/* +* +* Fun: SRemProcId +* +* Desc: This function inserts procId in the process id table +* +* Ret: ROK/RFAILED +* +* Notes: +* +* File: ss_gen.c +* +*/ +#ifdef ANSI +PRIVATE S16 SRemProcId +( +ProcId proc +) +#else +PRIVATE S16 SRemProcId(proc) +ProcId proc; +#endif +{ + U16 i; + U16 idx; + + TRC1(SRemProcId); + + idx = SS_HASH_IDX(proc); + + for (i = idx; i < SS_MAX_PROCS; i++) + if (osCp.procLst.procId[i] == proc) + { + osCp.procLst.procId[i] = SS_INV_PROCID; + osCp.procLst.free++; + RETVALUE(ROK); + } + + /* search upto idx */ + for (i = 0; i < idx; i++) + if (osCp.procLst.procId[i] == proc) + { + osCp.procLst.procId[i] = SS_INV_PROCID; + osCp.procLst.free++; + RETVALUE(ROK); + } + + RETVALUE(RFAILED); +} /* SRemProcId */ + + +/* +* +* Fun: SLockOsCp +* +* Desc: This function locks OsCp +* +* Ret: ROK/RFAILED +* +* Notes: +* +* File: ss_gen.c +* +*/ +#ifdef ANSI +PRIVATE S16 SLockOsCp +( +Void +) +#else +PRIVATE S16 SLockOsCp(Void) +#endif +{ + S16 ret; + + TRC1(SLockOsCp); + + ret = SLock(&osCp.sTskTblLock); + if (ret != ROK) + { + SSLOGERROR(ERRCLS_DEBUG, ESS016, ERRZERO, + "Could not lock system task table"); + RETVALUE(RFAILED); + } + + SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret); + if (ret != ROK) + { + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS017, ERRZERO, + "Could not lock TAPA task table"); +#endif + + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS018, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + + RETVALUE(RFAILED); + } + + RETVALUE(ROK); + +} /* SLockOsCp */ + + +/* +* +* Fun: SULockOsCp +* +* Desc: This function locks OsCp +* +* Ret: ROK/RFAILED +* +* Notes: +* +* File: ss_gen.c +* +*/ +#ifdef ANSI +PRIVATE S16 SULockOsCp +( +Void +) +#else +PRIVATE S16 SULockOsCp(Void) +#endif +{ + TRC1(SULockOsCp); + + /* unlock the table */ + SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem); + + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS019, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + + RETVALUE(ROK); + +} /* SULockOsCp */ + + + +/* +* +* Fun: SAddProcIdLst +* +* Desc: This function adds given proc ids to the list +* +* Ret: ROK/RFAILED +* +* Notes: +* +* File: ss_gen.c +* +*/ +#ifdef ANSI +PUBLIC S16 SAddProcIdLst +( +U16 numPIds, +ProcId *pIdLst +) +#else +PUBLIC S16 SAddProcIdLst(numPIds, pIdLst) +U16 numPIds; +ProcId *pIdLst; +#endif +{ + U16 i; + S16 ret; + + TRC1(SAddProcIdLst); + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* range check */ + if (numPIds > SS_MAX_PROCS) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS020, ERRZERO, "number of proc Ids exceeds\ + limit"); + RETVALUE(RFAILED); + } + + /* find if the entry exist in the table */ + for (i = 0; i < numPIds; i++) + { + if (pIdLst[i] == SS_INV_PROCID) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS021, ERRZERO, "Invalid proc Ids"); + RETVALUE(RFAILED); + } + } + +#endif + + if (SLockOsCp() != ROK) + RETVALUE(RFAILED); + +#if (ERRCLASS & ERRCLS_INT_PAR) + for (i = 0; i < numPIds; i++) + if (SGetProcIdIdx(pIdLst[i]) != SS_INV_PROCID_IDX) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS022, ERRZERO, "Duplicate proc id"); + (Void) SULockOsCp(); + RETVALUE(RFAILED); + } + + if (numPIds > osCp.procLst.free) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS023, ERRZERO, "Total number of proc id \ +exceeds"); + (Void) SULockOsCp(); + RETVALUE(RFAILED); + } +#endif + + /* insert the entries in the table */ + ret = ROK; + + for (i = 0; i < numPIds; i++) + { + if (SInsProcId(pIdLst[i]) == RFAILED) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS024, ERRZERO, + "Could not insert the proc id"); +#endif + (Void) SULockOsCp(); + RETVALUE(RFAILED); + } + } + + /* unlock the table */ + if (SULockOsCp() != ROK) + RETVALUE(RFAILED); + + RETVALUE(ret); +} /* SAddProcIdLst */ + + +/* +* +* Fun: SRemProcIdLst +* +* Desc: This function adds given proc ids to the list +* +* Ret: ROK/RFAILED +* +* Notes: +* +* File: ss_gen.c +* +*/ +#ifdef ANSI +PUBLIC S16 SRemProcIdLst +( +U16 numPIds, +ProcId *pIdLst +) +#else +PUBLIC S16 SRemProcIdLst(numPIds, pIdLst) +U16 numPIds; +ProcId *pIdLst; +#endif +{ + U16 i; + + TRC1(SRemProcIdLst); + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* range check */ + if (numPIds > SS_MAX_PROCS) + RETVALUE(RFAILED); +#endif + + if (SLockOsCp() != ROK) + RETVALUE(RFAILED); + + if (numPIds > (SS_MAX_PROCS - osCp.procLst.free)) + { + (Void) SULockOsCp(); + RETVALUE(RFAILED); + } + + /* find if the entry exist in the table */ + for (i = 0; i < numPIds; i++) + { + if (SGetProcIdIdx(pIdLst[i]) == SS_INV_PROCID_IDX) + { + (Void) SULockOsCp(); + RETVALUE(RFAILED); + } + } + + /* insert the entries in the table */ + for (i = 0; i < numPIds; i++) + SRemProcId(pIdLst[i]); + + if (SULockOsCp() != ROK) + RETVALUE(RFAILED); + + RETVALUE(ROK); +} /* SRemProcIdLst */ + + +/* +* +* Fun: SGetProcIdLst +* +* Desc: This function retrieves proc Id list +* +* Ret: ROK/RFAILED +* +* Notes: +* +* File: ss_gen.c +* +*/ +#ifdef ANSI +PUBLIC S16 SGetProcIdLst +( +U16 *numPIds, +ProcId *pIdLst +) +#else +PUBLIC S16 SGetProcIdLst(numPIds, pIdLst) +U16 *numPIds; +ProcId *pIdLst; +#endif +{ + U16 i; + U16 count = 0; + + TRC1(SGetProcIdLst); + +#if (ERRCLASS & ERRCLS_INT_PAR) + if ((numPIds == NULLP) || (pIdLst == NULLP)) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS025, ERRZERO, "Invalid numPIds/pIdLst"); + RETVALUE(RFAILED); + } +#endif + + if (SLockOsCp() != ROK) + RETVALUE(RFAILED); + + for (i = 0; i < SS_MAX_PROCS; i++) + { + if (osCp.procLst.procId[i] != PROCNC) + pIdLst[count++] = osCp.procLst.procId[i]; + } + + *numPIds = count; + + if (SULockOsCp() != ROK) + RETVALUE(RFAILED); + + if (count == 0) + RETVALUE(RFAILED); + + RETVALUE(ROK); +} /* SGetProcIdLst */ + + +/* +* +* Fun: SGetXxCb +* +* Desc: This function retrieves protocol layer control block for given proc, +* ent and inst IDs +* +* Ret: ROK/RFAILED +* +* Notes: +* +* File: ss_gen.c +* +*/ +#ifdef ANSI +PUBLIC S16 SGetXxCb +( +ProcId proc, +Ent ent, +Inst inst, +Void **xxCb +) +#else +PUBLIC S16 SGetXxCb(proc, ent, inst, xxCb) +ProcId proc; +Ent ent; +Inst inst; +Void **xxCb; +#endif +{ + U16 procIdIdx; + SsIdx idx; + + TRC1(SGetXxCb); + +#if (ERRCLASS & ERRCLS_INT_PAR) + if ((proc == SS_INV_PROCID) || (ent >= SS_MAX_ENT) || (inst >= SS_MAX_INST)) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS026, ERRZERO, "Invalid proc/entity/instance"); + RETVALUE(RFAILED); + } +#endif + + /* + * ss030.103: delete: locking/unlocking removed as it causes + * deadlock/blockage in some cases + */ + + procIdIdx = SGetProcIdIdx(proc); + + if (procIdIdx == SS_INV_PROCID_IDX) + { +#if (ERRCLASS & ERRCLS_INT_PAR) + SSLOGERROR(ERRCLS_INT_PAR, ESS027, ERRZERO, "Could not get proc table idx"); +#endif + RETVALUE(RFAILED); + } + + idx = osCp.tTskIds[procIdIdx][ent][inst]; + if (idx == SS_TSKNC) + { + RETVALUE(RFAILED); + } + + /* update the CB */ + *xxCb = osCp.tTskTbl[idx].xxCb; + /*ss032.103 added a check for NULLP */ + if (*xxCb == NULLP) + RETVALUE(RFAILED); + + RETVALUE(ROK); +} /* SGetXxCb */ + +#endif /* SS_MULTIPLE_PROCS */ + +/* ss001.301: additions */ +#ifdef SS_HISTOGRAM_SUPPORT +/* +* +* Fun: SFillEntIds +* +* Desc: It is static data base contains all entity Ids of tapa task. +* This Data base is used to find the entity id using two letter +* prifix product code. +* +* Ret: ROK/RFAILED +* +* Notes: +* +* File: ss_gen.c +* +*/ +#ifdef ANSI +PUBLIC S16 SFillEntIds +( +Void +) +#else +PUBLIC S16 SFillEntIds(Void) +#endif +{ + + U8 entInfo[26][26] = { + /* A B C D E F G H I J K * + L M N O P Q R S T U V * + W X Y Z */ + {ENTAA, ENTAB, ENTAC, ENTNC, ENTAE, ENTAF, ENTNC, ENTAH, ENTNC, ENTNC, ENTNC, + /* A */ ENTAL, ENTAM, ENTNC, ENTNC, ENTAP, ENTAQ, ENTAR, ENTAS, ENTNC, ENTAU, ENTNC, + ENTAW, ENTNC, ENTNC, ENTNC}, + + /* A B C D E F G H I J K * + L M N O P Q R S T U V * + W X Y Z */ + {ENTNC, ENTNC, ENTNC, ENTBD, ENTNC, ENTNC, ENTNC, ENTNC, ENTBI, ENTNC, ENTNC, + /* B */ ENTNC, ENTBM, ENTNC, ENTNC, ENTNC, ENTNC, ENTBR, ENTBS, ENTNC, ENTNC, ENTBV, + ENTBW, ENTNC, ENTNC, ENTNC}, + /* A B C D E F G H I J K * + L M N O P Q R S T U V * + W X Y Z */ + {ENTNC, ENTNC, ENTCC, ENTNC, ENTNC, ENTNC, ENTNC, ENTCH, ENTNC, ENTNC, ENTNC, + /* C */ ENTCL, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTCS, ENTNC, ENTCU, ENTCV, + ENTNC, ENTNC, ENTNC, ENTNC}, + /* A B C D E F G H I J K * + L M N O P Q R S T U V * + W X Y Z */ + {ENTNC, ENTDB, ENTNC, ENTNC, ENTNC, ENTNC, ENTDG, ENTNC, ENTDI, ENTNC, ENTDK, + /* D */ ENTNC, ENTDM, ENTDN, ENTNC, ENTDP, ENTNC, ENTNC, ENTNC, ENTDT, ENTDU, ENTDV, + ENTNC, ENTNC, ENTNC, ENTNC}, + /* A B C D E F G H I J K * + L M N O P Q R S T U V * + W X Y Z */ + {ENTNC, ENTNC, ENTNC, ENTNC, ENTEC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, + /* E */ ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTER, ENTES, ENTNC, ENTNC, ENTEV, + ENTNC, ENTNC, ENTNC, ENTNC}, + /* A B C D E F G H I J K * + L M N O P Q R S T U V * + W X Y Z */ + {ENTFA, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, + /* F */ ENTNC, ENTFM, ENTFN, ENTNC, ENTFP, ENTNC, ENTFR, ENTNC, ENTNC, ENTFU, ENTNC, + ENTFW, ENTNC, ENTNC, ENTNC}, + /* A B C D E F G H I J K * + L M N O P Q R S T U V * + W X Y Z */ + {ENTGA, ENTGB, ENTGC, ENTGD, ENTGE, ENTGF, ENTGG, ENTGH, ENTGI, ENTNC, ENTNC, + /* G */ ENTGL, ENTGM, ENTGN, ENTGO, ENTGP, ENTNC, ENTGR, ENTGS, ENTGT, ENTGU, ENTNC, + ENTGW, ENTGX, ENTGY, ENTGZ}, + /* A B C D E F G H I J K * + L M N O P Q R S T U V * + W X Y Z */ + {ENTNC, ENTNC, ENTHC, ENTNC, ENTHE, ENTNC, ENTHG, ENTNC, ENTHI, ENTNC, ENTNC, + /* H */ ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTHR, ENTHS, ENTNC, ENTHU, ENTNC, + ENTNC, ENTNC, ENTNC, ENTNC}, + /* A B C D E F G H I J K * + L M N O P Q R S T U V * + W X Y Z */ + {ENTIA, ENTIB, ENTNC, ENTID, ENTIE, ENTNC, ENTNC, ENTNC, ENTII, ENTNC, ENTNC, + /* I */ ENTNC, ENTIM, ENTIN, ENTNC, ENTNC, ENTIQ, ENTNC, ENTIS, ENTIT, ENTIU, ENTNC, + ENTIW, ENTIX, ENTNC, ENTNC}, + /* A B C D E F G H I J K * + L M N O P Q R S T U V * + W X Y Z */ + {ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, + /* J */ ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, + ENTNC, ENTNC, ENTNC, ENTNC}, + /* A B C D E F G H I J K * + L M N O P Q R S T U V * + W X Y Z */ + {ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, + /* K */ ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, + ENTKW, ENTNC, ENTNC, ENTNC}, + /* A B C D E F G H I J K * + L M N O P Q R S T U V * + W X Y Z */ + {ENTLA, ENTLB, ENTLC, ENTLD, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTLK, + /* L */ ENTNC, ENTLM, ENTLN, ENTNC, ENTNC, ENTNC, ENTLR, ENTNC, ENTLT, ENTLU, ENTLV, + ENTNC, ENTLX, ENTNC, ENTNC}, + /* A B C D E F G H I J K * + L M N O P Q R S T U V * + W X Y Z */ + {ENTMA, ENTNC, ENTMC, ENTMD, ENTME, ENTNC, ENTMG, ENTNC, ENTNC, ENTNC, ENTMK, + /* M */ ENTML, ENTMM, ENTNC, ENTNC, ENTNC, ENTNC, ENTMR, ENTMS, ENTMT, ENTMU, ENTMV, + ENTMW, ENTMX, ENTNC, ENTMZ}, + /* A B C D E F G H I J K * + L M N O P Q R S T U V * + W X Y Z */ + {ENTNC, ENTNC, ENTNC, ENTND, ENTNC, ENTNF, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, + /* N */ ENTNC, ENTNM, ENTNC, ENTNC, ENTNP, ENTNC, ENTNC, ENTNS, ENTNC, ENTNC, ENTNV, + ENTNW, ENTNC, ENTNC, ENTNC}, + /* A B C D E F G H I J K * + L M N O P Q R S T U V * + W X Y Z */ + {ENTNC, ENTNC, ENTNC, ENTOD, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, + /* O */ ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, + ENTNC, ENTNC, ENTNC, ENTNC}, + /* A B C D E F G H I J K * + L M N O P Q R S T U V * + W X Y Z */ + {ENTPA, ENTNC, ENTNC, ENTPD, ENTNC, ENTNC, ENTNC, ENTPH, ENTNC, ENTNC, ENTNC, + /* P */ ENTPL, ENTNC, ENTPN, ENTNC, ENTPN, ENTPQ, ENTPR, ENTNC, ENTNC, ENTPU, ENTPV, + ENTNC, ENTNC, ENTNC, ENTNC}, + /* A B C D E F G H I J K * + L M N O P Q R S T U V * + W X Y Z */ + {ENTNC, ENTNC, ENTQC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTQI, ENTNC, ENTNC, + /* Q */ ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, + ENTQW, ENTNC, ENTNC, ENTNC}, + /* A B C D E F G H I J K * + L M N O P Q R S T U V * + W X Y Z */ + {ENTRA, ENTNC, ENTNC, ENTRD, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, + /* R */ ENTRL, ENTRM, ENTRN, ENTNC, ENTRP, ENTNC, ENTRR, ENTNC, ENTRT, ENTRU, ENTNC, + ENTNC, ENTRX, ENTRY, ENTNC}, + /* A B C D E F G H I J K * + L M N O P Q R S T U V * + W X Y Z */ + {ENTSA, ENTSB, ENTSC, ENTSD, ENTSE, ENTSF, ENTSG, ENTSH, ENTSI, ENTNC, ENTNC, + /* S */ ENTNC, ENTSM, ENTSN, ENTSO, ENTSP, ENTNC, ENTSR, ENTSS, ENTST, ENTSU, ENTSV, + ENTNC, ENTNC, ENTNC, ENTSZ}, + /* A B C D E F G H I J K * + L M N O P Q R S T U V * + W X Y Z */ + {ENTNC, ENTNC, ENTTC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, + /* T */ ENTNC, ENTTM, ENTNC, ENTNC, ENTTP, ENTNC, ENTNC, ENTTS, ENTTT, ENTTU, ENTNC, + ENTNC, ENTNC, ENTNC, ENTNC}, + /* A B C D E F G H I J K * + L M N O P Q R S T U V * + W X Y Z */ + {ENTNC, ENTNC, ENTNC, ENTUD, ENTNC, ENTNC, ENTNC, ENTUH, ENTNC, ENTNC, ENTNC, + /* U */ ENTUL, ENTUM, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTUS, ENTNC, ENTNC, ENTNC, + ENTNC, ENTNC, ENTNC, ENTUZ}, + /* A B C D E F G H I J K * + L M N O P Q R S T U V * + W X Y Z */ + {ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTVF, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, + /* V */ ENTNC, ENTVM, ENTNC, ENTVO, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTVU, ENTNC, + ENTNC, ENTNC, ENTNC, ENTNC}, + /* A B C D E F G H I J K * + L M N O P Q R S T U V * + W X Y Z */ + {ENTNC, ENTNC, ENTWC, ENTWD, ENTNC, ENTNC, ENTNC, ENTNC, ENTWI, ENTNC, ENTNC, + /* W */ ENTNC, ENTNC, ENTWN, ENTNC, ENTNC, ENTNC, ENTNC, ENTWS, ENTNC, ENTWU, ENTNC, + ENTNC, ENTNC, ENTNC, ENTNC}, + /* A B C D E F G H I J K * + L M N O P Q R S T U V * + W X Y Z */ + {ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTXG, ENTNC, ENTXI, ENTNC, ENTNC, + /* X */ ENTNC, ENTXM, ENTXN, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTXU, ENTNC, + ENTNC, ENTXX, ENTXY, ENTNC}, + /* A B C D E F G H I J K * + L M N O P Q R S T U V * + W X Y Z */ + {ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, + /* Y */ ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, + ENTNC, ENTNC, ENTNC, ENTNC}, + /* A B C D E F G H I J K * + L M N O P Q R S T U V * + W X Y Z */ + {ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, + /* Z */ ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, ENTNC, + ENTNC, ENTNC, ENTNC, ENTNC} + }; + + /*ss013.301 :Adding TRC MACRO*/ + TRC2(SFillEntIds) + memcpy((U8*)osCp.entId, (U8*)entInfo, sizeof(entInfo)); + + RETVALUE(ROK); +} /* SFillEntIds */ + + +/* +* +* Fun: SGetEntInd +* +* Desc: This function gives the entity Id depending in the +* file name. This function uses the first two letter +* of file name to find the entity id. +* +* +* +* Ret: ROK OK +* RFAILED Region not registered +* +* +*/ +#ifdef ANSI +PUBLIC S16 SGetEntInd +( +Ent *entId, +U8 *fileName +) +#else +PUBLIC S16 SGetEntInd(entId, fileName) +Ent *entId; +U8 *fileName; +#endif +{ + + + U8 *letter = NULLP; + /* ss002.301 Additions */ + S8 *strippedName = NULLP; + U8 count = 0; + U8 tempIdx = 0; + U8 firstIdx = 0; + U8 secondIdx = 0; + + TRC1(SGetEntInd); + + /* ss002.301 Additions */ + if ((strippedName = strrchr((const char *)fileName, '/'))) + { + fileName = (U8 *)strippedName + 1; + } + + if(fileName[0] =='l' && fileName[3] == '.') + { + /* Usally layer manager interface files starts + * with l. so leave the first letter and take + * other two letter. + * Eg. Layer manger inteface file name for TUCL is lhi.c. + * so here we leave l and we take hi to get the entity Id. */ + letter = ++fileName; + } + else + { + letter = fileName; + /* Handle exceptional file names */ + switch(letter[0]) + { + case 'g': + if (letter[1] == 'g' && letter[2] == 'u') + { + *entId = ENTGT; + RETVALUE(ROK); + } + default: + break; + + } + } + + + /* here first two charactes of file name should be alphabets. + * if any one of the letter is non alphabet then we return ENTNC + * as an entity Id */ + /* Eg. In fileName l4_ptui.c, second letter is numeral. so we consider + * this file belogs to entity Id ENTNC. */ + for(count = 0; count < 2; count++) + { + /* ss002.301 - Optimizations */ + if(letter[count] < 'a' || letter[count] > 'z') + { + *entId = ENTNC; + RETVALUE(ROK); + } + else + { + tempIdx = letter[count] - 'a'; + } + if(count == 0) + { + firstIdx = tempIdx; + }/* End of if */ + else + { + secondIdx = tempIdx; + }/* End of else */ + } /* End of for */ + /* First two letter of file name are alphabets the get the + * entity id from the static data base which is loaded in sFillEntIds() */ + *entId = osCp.entId[firstIdx][secondIdx]; + RETVALUE(ROK); +} /* SGetEntInd */ + +#endif /* SS_HISTOGRAM_SUPPORT */ +#ifdef SS_LOCK_SUPPORT +/* ss002.301 Readwrite lock additions */ +/* +* +* Fun: SLockNew +* +* Desc: This function is used to aquire the read write lock +* +* Ret: ROK OK +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 SLockNew +( +SLockInfo *lockId, +U8 lockType + +) +#else +PUBLIC S16 SLockNew(lockId, lockType) +SLockInfo *lockId; +U8 lockType; +#endif +{ + S16 retVal = ROK; + + TRC1(SLockNew); + + if((retVal = ssdLockNew(lockId, lockType)) != ROK) + { + SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SLockNew(): Failed to aquire the lock\n"); + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + +/* +* +* Fun: SInitLockNew +* +* Desc: This function is used to aquire the read write lock +* +* Ret: ROK OK +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 SInitLockNew +( +SLockInfo *lockId, +U8 lockType +) +#else +PUBLIC S16 SInitLockNew(lockId, lockType) +SLockInfo *lockId; +U8 lockType; +#endif +{ + S16 retVal = ROK; + + TRC1(SInitLockNew); + + if((retVal = ssdInitLockNew(lockId, lockType)) != ROK) + { + SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SInitLockNew(): Initialization of lock Failed\n"); + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + +/* +* +* Fun: SUnlockNew +* +* Desc: This function is used to Unlock the read write lock +* +* Ret: ROK OK +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 SUnlockNew +( +SLockInfo *lockId, +U8 lockType +) +#else +PUBLIC S16 SUnlockNew(lockId, lockType) +SLockInfo *lockId; +U8 lockType; +#endif +{ + S16 retVal = ROK; + + TRC1(SUnlockNew); + + if((retVal = ssdUnlockNew(lockId, lockType)) != ROK) + { + SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SUnlockNew(): Failed to release the lock\n"); + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + +/* +* +* Fun: SDestroyLockNew +* +* Desc: This function is used to destroy the read write lock +* +* Ret: ROK OK +* +* Notes: +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 SDestroyLockNew +( +SLockInfo *lockId, +U8 lockType +) +#else +PUBLIC S16 SDestroyLockNew(lockId, lockType) +SLockInfo *lockId; +U8 lockType; +#endif +{ + S16 retVal = ROK; + + TRC1(SDestroyLockNew); + + if((retVal = ssdDestroyLockNew(lockId, lockType)) != ROK) + { + SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SDestroyLockNew(): Failed to destroy the lock\n"); + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} +#endif /* SS_LOCK_SUPPORT */ + +#ifdef SSI_STATIC_MEM_LEAK_DETECTION +/* Static memory leak detection changes */ +static U32 StaticMemLeakAge; +static U32 StaticMemLeakIntCount = 1; + +void PrintStaticMemAllocInfo(StaticMemAllocInfo* memAllocInfo, FILE *opFile) +{ + int i; + + fprintf(opFile, "Current Time = %ld\n",StaticMemLeakAge); + + for(i = 1; i < MAX_MEM_ALLOCATIONS; i++) + { + if(memAllocInfo->allocations[i].ptr) + { + fprintf(opFile, "p = %p f = %s l = %ld s = %ld a = %ld\n", + memAllocInfo->allocations[i].ptr, + memAllocInfo->allocations[i].file, + memAllocInfo->allocations[i].lineNo, + memAllocInfo->allocations[i].size, + memAllocInfo->allocations[i].age); + } + } + + fclose(opFile); +} + +void InitializeStaticMemAllocInfo(StaticMemAllocInfo* memAllocInfo) +{ + U32 i; + /* index 0 is not used; nextIdx as 0 means end of list */ + memAllocInfo->nextFreeIdx = 1; + + for(i = 1; i < MAX_MEM_ALLOCATIONS; i++) + { + memAllocInfo->allocations[i].listInfo.nextIdx = i + 1; + memAllocInfo->allocations[i].ptr = 0; + } + + /* override the last one to point to 0 meaning end of list */ + memAllocInfo->allocations[MAX_MEM_ALLOCATIONS - 1].listInfo.nextIdx = 0; +} + +U32 GetNextFreeIdx(StaticMemAllocInfo * memAllocInfo) +{ + U32 toBeReturned = memAllocInfo->nextFreeIdx; + + U32 newNextFreeIdx = memAllocInfo->allocations[memAllocInfo->nextFreeIdx].listInfo.nextIdx; + + if(newNextFreeIdx == 0 || newNextFreeIdx >= MAX_MEM_ALLOCATIONS) + { + printf("Something wrong in GetNextFreeIdx newNextIdx = %ld\n",newNextFreeIdx); + } + + memAllocInfo->nextFreeIdx = newNextFreeIdx; + + return toBeReturned; +} + +#define CRASH_ENB {int *p = 0; *p = 100;} +void FreeIdx(U8* ptr, U32 idx, StaticMemAllocInfo* memAllocInfo,U32 size, char* file, U32 line) +{ + if(idx == 0 || idx >= MAX_MEM_ALLOCATIONS) + { + printf("Something wrong in FreeIdx... idx = %ld called from %s:%ld\n",idx,file,line); + CRASH_ENB + } + /*printf("FreeIdx... idx = %d nexFree = %d\n",idx, memAllocInfo->nextFreeIdx);*/ + memAllocInfo->allocations[idx].listInfo.nextIdx = memAllocInfo->nextFreeIdx; + if((ptr != memAllocInfo->allocations[idx].ptr) || + (size != memAllocInfo->allocations[idx].size)) + { +#ifdef XEON_SPECIFIC_CHANGES +CRASH_ENB +#endif + + printf("Freeing wrong ptr stored = %p trying to free %p freeing size (%ld)" + "allocated size(%ld) from %s:%ld\n", + memAllocInfo->allocations[idx].ptr, + ptr, + size, + memAllocInfo->allocations[idx].size, + file, + line); + printf("Allocation was done from %s:%ld\n",memAllocInfo->allocations[idx].file, memAllocInfo->allocations[idx].lineNo); + printf("***********************************************************\n"); + CRASH_ENB + } + + memAllocInfo->allocations[idx].ptr = 0; + + memAllocInfo->nextFreeIdx = idx; +} + + +void LogForStaticMemLeak(StaticMemAllocInfo* memAllocInfo, char* file, U32 line, U32 size, void* ptr, U32 idx) +{ + + memAllocInfo->allocations[idx].file = file; + memAllocInfo->allocations[idx].lineNo = line; + memAllocInfo->allocations[idx].size = size; + memAllocInfo->allocations[idx].ptr = ptr; + memAllocInfo->allocations[idx].age = StaticMemLeakAge; + + if(StaticMemLeakIntCount++ % 256 == 0) + { + StaticMemLeakAge++; + } +} + +void InitializeForStaticMemLeak() +{ + int i; + + StaticMemLeakFileArr[0] = fopen("region0.log","w"); + StaticMemLeakFileArr[1] = fopen("region1.log","w"); + StaticMemLeakFileArr[2] = fopen("region2.log","w"); + StaticMemLeakFileArr[3] = fopen("region3.log","w"); + + if(StaticMemLeakFileArr[0] == NULL || + StaticMemLeakFileArr[1] == NULL || + StaticMemLeakFileArr[2] == NULL || + StaticMemLeakFileArr[3] == NULL) + { + int *p = 0; + printf("Could not open files for Static Mem Leak detection logging :( crashing...\n"); + *p = 100; + } + + for(i = 0; i < 4; i++) + { + InitializeStaticMemAllocInfo(&SMemLeakInfo[i]); + } +} + +PUBLIC void DumpStaticMemLeakFiles() +{ + int i; + + for(i = 0; i < 4; i++) + { + PrintStaticMemAllocInfo(&SMemLeakInfo[i], StaticMemLeakFileArr[i]); + } +} +/* Static memory leak detection changes */ +#endif + +/* + * + * Fun: ssRegMainThread + * + * Desc: This function is used to add the memory region + * mapping for the main thread. + * + * Ret: VOID (Always successful) + * + * Notes: + * + * File: mt_ss.c + * + */ +#ifdef ANSI +PUBLIC S16 SReInitTmr +( +void +) +#else +PUBLIC S16 SReInitTmr() +#endif +{ + U8 ret = ROK; + Txt prntBuf[PRNTSZE]; + + sprintf(prntBuf, "\n SReInitTmr(): ReStarting the Tmr\n"); + SDisplay(1,prntBuf); + ret = ssdReInitTmr(); + if (ret != ROK) + { + /*ss012.301 : Fix log related issue to suite MT and NS implementations*/ + SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SReInitTmr(): Failed to Restart the Tmr\n"); + RETVALUE(RFAILED); + } + RETVALUE(ROK); +} + +/* + * + * Fun: SGetConfigPath + * + * Desc: This function is used to Get config files path + * + * Ret: S8* config file Path + * + * Notes: + * + * File: ss_gen.c + * + */ +PUBLIC S8* SGetConfigPath(Void) +{ + return osCp.configFilePath; +} + +/********************************************************************** + End of file + **********************************************************************/ diff --git a/src/mt/ss_mem.c b/src/mt/ss_mem.c new file mode 100644 index 000000000..af2c6fce2 --- /dev/null +++ b/src/mt/ss_mem.c @@ -0,0 +1,1033 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/********************************************************************20** + + Name: System Services -- Memory management interface + + Type: C source file + + Desc: Implementation of the memory management interface. + + File: ss_mem.c + +*********************************************************************21*/ + + +/* header include files (.h) */ + +#include "envopt.h" /* environment options */ +#include "envdep.h" /* environment dependent */ +#include "envind.h" /* environment independent */ + +#include "gen.h" /* general layer */ +#include "ssi.h" /* system services */ + +#include "ss_err.h" /* errors */ +#include "ss_dep.h" /* implementation-specific */ +#include "ss_queue.h" /* queues */ +#include "ss_msg.h" /* messaging */ +#include "ss_mem.h" /* memory management interface */ +/*ss011.301 : RMI SSI specific includes*/ +#ifdef SS_RMIOS +#include "uc_gen.h" /* general */ +#else +#include "ss_gen.h" /* general */ +#endif + + +#include "cm_mem.h" /* common memory manager */ +#include "cm_llist.h" +#include "cm_hash.h" + +/* header/extern include files (.x) */ + +#include "gen.x" /* general layer */ +#include "ssi.x" /* system services */ + +#include "ss_dep.x" /* implementation-specific */ +#include "ss_queue.x" /* queues */ +/*ss011.301 : RMI SSI specific includes*/ +#ifdef SS_RMIOS +#include "uc_task.x" /* tasking */ +#include "uc_timer.x" /* timers */ +#else +#include "ss_task.x" /* tasking */ +#include "ss_timer.x" /* timers */ +#endif +#include "ss_strm.x" /* STREAMS */ +#include "ss_msg.x" /* messaging */ +#include "ss_mem.x" /* memory management interface */ +#include "ss_drvr.x" /* driver tasks */ +/*ss011.301 : RMI SSI specific includes*/ +#ifdef SS_LOCKLESS_MEMORY +#include "cm_llist.x" +#include "cm_hash.x" +#include "cm_mem_wl.x" /* common memory manager */ +#else +#include "cm_mem.x" /* common memory manager */ +#endif /* SS_LOCKLESS_MEMORY */ +#ifdef SS_RMIOS +#include "uc_gen.x" /* general */ +#else +#include "ss_gen.x" /* general */ +#endif +#include "cm_llist.x" +#include "cm_hash.x" + + + +/* +* Interface functions +*/ + + +/* +* +* Fun: SRegDynRegion +* +* Desc: Registers a memory region. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: +* +* File: ss_mem.c +* +*/ +#ifdef ANSI +PUBLIC S16 SRegDynRegion +( +Region region, /* region ID */ +SRegInfo *regInfo /* information about the region */ +) +#else +PUBLIC S16 SRegDynRegion(region, regInfo) +Region region; /* region ID */ +SRegInfo *regInfo; /* information about the region */ +#endif +{ + S16 ret; + + + TRC1(SRegDynRegion); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* validate region ID */ + if (region >= SS_MAX_REGS) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS028, region, "Invalid region"); + RETVALUE(RFAILED); + } + + /* validate region info pointer */ + if (regInfo == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS029, ERRZERO, "Null pointer"); + RETVALUE(RFAILED); + } +#endif + + + /* lock the region table */ + SS_ACQUIRE_ALL_SEMA(&osCp.regionTblSem, ret); + if (ret != ROK) + { + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS030, (ErrVal) ret, + "Could not lock region table"); +#endif + + RETVALUE(RFAILED); + } + + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* verify that this region is not registered */ + if (osCp.dynRegionTbl[region].used == TRUE) + { + SS_RELEASE_ALL_SEMA(&osCp.regionTblSem); + + SSLOGERROR(ERRCLS_INT_PAR, ESS031, ERRZERO, "Region ID used"); + RETVALUE(RFAILED); + } +#endif + + + /* fill in the region information */ + osCp.dynRegionTbl[region].used = TRUE; + osCp.dynRegionTbl[region].regCb = regInfo->regCb; + osCp.dynRegionTbl[region].flags = regInfo->flags; + osCp.dynRegionTbl[region].start = regInfo->start; + osCp.dynRegionTbl[region].size = regInfo->size; + osCp.dynRegionTbl[region].alloc = regInfo->alloc; + osCp.dynRegionTbl[region].free = regInfo->free; + osCp.dynRegionTbl[region].ctl = regInfo->ctl; + + osCp.numDynRegions++; + + + /* unlock the region table */ + SS_RELEASE_ALL_SEMA(&osCp.regionTblSem); + + + RETVALUE(ROK); +} + + + + +/* +* +* Fun: SRegRegion +* +* Desc: Registers a memory region. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: +* +* File: ss_mem.c +* +*/ +#ifdef ANSI +PUBLIC S16 SRegRegion +( +Region region, /* region ID */ +SRegInfo *regInfo /* information about the region */ +) +#else +PUBLIC S16 SRegRegion(region, regInfo) +Region region; /* region ID */ +SRegInfo *regInfo; /* information about the region */ +#endif +{ + S16 ret; + + + TRC1(SRegRegion); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* validate region ID */ + if (region >= SS_MAX_REGS) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS028, region, "Invalid region"); + RETVALUE(RFAILED); + } + + /* validate region info pointer */ + if (regInfo == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS029, ERRZERO, "Null pointer"); + RETVALUE(RFAILED); + } +#endif + + + /* lock the region table */ + SS_ACQUIRE_ALL_SEMA(&osCp.regionTblSem, ret); + if (ret != ROK) + { + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS030, (ErrVal) ret, + "Could not lock region table"); +#endif + + RETVALUE(RFAILED); + } + + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* verify that this region is not registered */ + if (osCp.regionTbl[region].used == TRUE) + { + SS_RELEASE_ALL_SEMA(&osCp.regionTblSem); + + SSLOGERROR(ERRCLS_INT_PAR, ESS031, ERRZERO, "Region ID used"); + RETVALUE(RFAILED); + } +#endif + + + /* fill in the region information */ + osCp.regionTbl[region].used = TRUE; + osCp.regionTbl[region].regCb = regInfo->regCb; + osCp.regionTbl[region].flags = regInfo->flags; + osCp.regionTbl[region].start = regInfo->start; + osCp.regionTbl[region].size = regInfo->size; + osCp.regionTbl[region].alloc = regInfo->alloc; + osCp.regionTbl[region].free = regInfo->free; + osCp.regionTbl[region].ctl = regInfo->ctl; + + osCp.numRegions++; + + + /* unlock the region table */ + SS_RELEASE_ALL_SEMA(&osCp.regionTblSem); + + + RETVALUE(ROK); +} + + +/* +* +* Fun: SDeregRegion +* +* Desc: Deregisters a memory region. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: +* +* File: ss_mem.c +* +*/ +#ifdef ANSI +PUBLIC S16 SDeregRegion +( +Region region /* region ID */ +) +#else +PUBLIC S16 SDeregRegion(region) +Region region; /* region ID */ +#endif +{ + S16 ret; + + + TRC1(SDeregRegion); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* validate region ID */ + if (region >= SS_MAX_REGS) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS032, region, "Invalid region"); + RETVALUE(RFAILED); + } +#endif + + + /* lock the region table */ + SS_ACQUIRE_ALL_SEMA(&osCp.regionTblSem, ret); + if (ret != ROK) + { + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS033, (ErrVal) ret, + "Could not lock region table"); +#endif + + RETVALUE(RFAILED); + } + + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check if this region is registered */ + if (osCp.regionTbl[region].used == FALSE) + { + SS_RELEASE_ALL_SEMA(&osCp.regionTblSem); + SSLOGERROR(ERRCLS_INT_PAR, ESS034, region, "Region not registered"); + RETVALUE(RFAILED); + } +#endif + + + /* empty the information about the region */ + osCp.regionTbl[region].used = FALSE; + osCp.regionTbl[region].start = NULLP; + osCp.regionTbl[region].size = 0; + osCp.regionTbl[region].regCb = NULLP; + osCp.regionTbl[region].flags = 0; + osCp.regionTbl[region].alloc = NULLP; + osCp.regionTbl[region].free = NULLP; + osCp.regionTbl[region].ctl = NULLP; + + osCp.numRegions--; + + + /* unlock the region table */ + SS_RELEASE_ALL_SEMA(&osCp.regionTblSem); + + + RETVALUE(ROK); +} + + +/* +* +* Fun: SAlloc +* +* Desc: Allocates a block of memory of at least the specified +* size. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: +* +* File: ss_mem.c +* +*/ +/*ss003.301-gaurded under flag SS_FAP*/ +#ifndef SS_FAP +/* ss001.301: Additions */ +#ifdef SS_HISTOGRAM_SUPPORT +#ifdef ANSI +PUBLIC S16 SAlloc +( +Region region, /* region ID */ +Size *size, /* size of block required/allocated */ +U32 flags, /* allocation flags */ +Data **ptr, /* filled with pointer to block */ +U32 line, +U8 *fileName, +U8 entId +) +#else +PUBLIC S16 SAlloc(region, size, flags, ptr, line, fileName, entId) +Region region; /* region ID */ +Size *size; /* size of block required/allocated */ +U32 flags; /* allocation flags */ +Data **ptr; /* filled with pointer to block */ +U32 line; +U8 *fileName; +U8 entId; +#endif +#else +#ifdef T2K_MEM_LEAK_DBG +PUBLIC S16 SAllocNew +( +Region region, /* region ID */ +Size *size, /* size of block required/allocated */ +U32 flags, /* allocation flags */ +Data **ptr, /* filled with pointer to block */ +char* file, +U32 line +) +#else +#ifdef ANSI +PUBLIC S16 SAlloc +( +Region region, /* region ID */ +Size *size, /* size of block required/allocated */ +U32 flags, /* allocation flags */ +Data **ptr /* filled with pointer to block */ +) +#else +PUBLIC S16 SAlloc(region, size, flags, ptr) +Region region; /* region ID */ +Size *size; /* size of block required/allocated */ +U32 flags; /* allocation flags */ +Data **ptr; /* filled with pointer to block */ +#endif +#endif +#endif +{ + S16 ret; +/* ss001.301: Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + Bool hstReg = FALSE; +#endif /* SS_HISTOGRAM_SUPPORT */ + + + TRC1(SAlloc); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* validate region ID */ + if (region >= SS_MAX_REGS) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS035, region, "Invalid region"); + RETVALUE(RFAILED); + } +#endif +#ifndef XEON_SPECIFIC_CHANGES + /* Get the region which is assgined with this thread. The region was + * stored in the osCp and is taken with respect to thread ID. This macro + * is used only when SS_LOCKLESS_MEMORY flag is used and it overwrites + * the region passed. + */ + region = SS_GET_THREAD_MEM_REGION(); +#endif +/* ss037.103 Removed the semaphore acquisition for performance enhancement */ +#ifndef SS_PERF + /* acquire one semaphore, to protect against deregistration */ + SS_ACQUIRE_SEMA(&osCp.regionTblSem, ret); + if (ret != ROK) + { + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS036, (ErrVal) ret, + "Could not lock region table"); +#endif + + RETVALUE(RFAILED); + } + +#endif +#if (ERRCLASS & ERRCLS_INT_PAR) + /* verify that this region is present */ + if (osCp.regionTbl[region].used == FALSE) + { +/* ss037.103 Removed the semaphore operation for performance enhancement */ +#ifndef SS_PERF +/* ss006.13: addition */ + if( SS_RELEASE_SEMA(&osCp.regionTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS037, ERRZERO, + "Could not release the semaphore"); + RETVALUE(RFAILED); +#endif + } +#endif + SSLOGERROR(ERRCLS_INT_PAR, ESS038, region, "Region not registered"); + RETVALUE(RFAILED); + } +#endif +/* ss001.301: Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + SGetHstGrmInfo(&entId, &hstReg); + /* call the memory manager, to allocate this memory */ + /* ss036.103 - addition for passing memType as dynamic */ +#ifdef SSI_DEBUG_LEVEL1 + ret = (osCp.regionTbl[region].alloc) + (osCp.regionTbl[region].regCb, size, flags, ptr, + SS_DYNAMIC_MEM_FLAG, line, fileName, entId, hstReg); +#else + ret = (osCp.regionTbl[region].alloc) + (osCp.regionTbl[region].regCb, size, flags, ptr, line, + fileName, entId, hstReg); +#endif /* SSI_DEBUG_LEVEL1 */ + +#else + + /* call the memory manager, to allocate this memory */ +/* ss036.103 - addition for passing memType as dynamic */ +#ifdef SSI_DEBUG_LEVEL1 + ret = (osCp.regionTbl[region].alloc) + (osCp.regionTbl[region].regCb, size, flags, ptr, SS_DYNAMIC_MEM_FLAG); +#else +#ifdef SS_LOCKLESS_MEMORY +#ifdef T2K_MEM_LEAK_DBG + ret = (osCp.dynRegionTbl[region].alloc) + (osCp.dynRegionTbl[region].regCb, size, flags, ptr,file,line); +#else + ret = (osCp.dynRegionTbl[region].alloc) + (osCp.dynRegionTbl[region].regCb, size, flags, ptr); +#endif +#else +#ifdef T2K_MEM_LEAK_DBG + ret = (osCp.regionTbl[region].alloc) + (osCp.regionTbl[region].regCb, size, flags, ptr,file,line); +#else + ret = (osCp.regionTbl[region].alloc) + (osCp.regionTbl[region].regCb, size, flags, ptr); +#endif +#endif /* SS_LOCKLESS_MEMORY */ +#endif /* SSI_DEBUG_LEVEL1 */ + +#endif /* SS_HISTOGRAM_SUPPORT */ + +/* ss037.103 Removed the semaphore operation for performance enhancement */ + +#ifndef SS_PERF + /* release the semaphore we took */ +/* ss006.13: addition */ + if( SS_RELEASE_SEMA(&osCp.regionTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS039, ERRZERO, + "Could not release the semaphore"); + RETVALUE(RFAILED); +#endif + } +#endif +/* ss036.103 - Addition to handle the memory trampling return value +* This in turn can call SRegMemErrHdlr +*/ +#ifdef SSI_DEBUG_LEVEL1 + if (ret == RTRAMPLINGNOK) + { + SRegMemErrHdlr( region, *ptr, ret); + } +#endif /* SSI_DEBUG_LEVEL1 */ + + RETVALUE(ret); +} + + +/* +* +* Fun: SFree +* +* Desc: Frees a block of memory previously allocated by SAlloc(). +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: +* +* File: ss_mem.c +* +*/ +/* ss001.301: Additions */ +#ifdef SS_HISTOGRAM_SUPPORT +#ifdef ANSI +PUBLIC S16 SFree +( +Region region, /* region ID */ +Data *ptr, /* pointer to the allocated block */ +Size size, /* size of block */ +U32 line, +U8 *fileName, +U8 entId +) +#else +PUBLIC S16 SFree(region, ptr, size, line, fileName, entId) +Region region; /* region ID */ +Data *ptr; /* pointer to the allocated block */ +Size size; /* size of block */ +U32 line; +U8 *fileName; +U8 entId; +#endif +#else +#ifdef ANSI +#ifdef T2K_MEM_LEAK_DBG +PUBLIC S16 SFreeNew +( +Region region, /* region ID */ +Data *ptr, /* pointer to the allocated block */ +Size size, /* size of block */ +char* file, +U32 line +) +#else +PUBLIC S16 SFree +( +Region region, /* region ID */ +Data *ptr, /* pointer to the allocated block */ +Size size /* size of block */ +) +#endif +#else +PUBLIC S16 SFree(region, ptr, size) +Region region; /* region ID */ +Data *ptr; /* pointer to the allocated block */ +Size size; /* size of block */ +#endif +#endif +{ + S16 ret; + +/* ss001.301: Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + Bool hstReg = FALSE; +#endif /* SS_HISTOGRAM_SUPPORT */ + + + TRC1(SFree); + + /* Get the region which is assgined with this thread. The region was + * stored in the osCp and is taken with respect to thread ID. This macro + * is used only when SS_LOCKLESS_MEMORY flag is used and it overwrites + * the region passed. + */ +#ifdef XEON_SPECIFIC_CHANGES + region = 0; +#else + region = SS_GET_THREAD_MEM_REGION(); +#endif + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* validate region ID */ + if (region >= SS_MAX_REGS) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS040, region, "Invalid region"); + RETVALUE(RFAILED); + } + +/* ss021.103 - Addition to validate size and ptr */ + if (size <= NULLD) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS041, region, "Invalid size"); + RETVALUE(RFAILED); + } + + /* validate ptr */ + if (ptr == (Data *)NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS042, region, "Invalid ptr"); + RETVALUE(RFAILED); + } + +#endif +/* ss037.103 Removed the semaphore operation for performance enhancement */ + +#ifndef SS_PERF + /* acquire one semaphore, to protect against deregistration */ + SS_ACQUIRE_SEMA(&osCp.regionTblSem, ret); + if (ret != ROK) + { + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS043, (ErrVal) ret, + "Could not lock region table"); +#endif + + RETVALUE(RFAILED); + } +#endif +#if (ERRCLASS & ERRCLS_INT_PAR) + /* verify that this region is around */ + if (osCp.regionTbl[region].used == FALSE) + { +#ifndef SS_PERF +/* ss006.13: addition */ + if( SS_RELEASE_SEMA(&osCp.regionTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS044, ERRZERO, + "Could not release the semaphore"); + RETVALUE(RFAILED); +#endif + } +#endif + SSLOGERROR(ERRCLS_INT_PAR, ESS045, region, "Region not registered"); + RETVALUE(RFAILED); + } +#endif + +/* ss001.301: Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + SGetHstGrmInfo(&entId, &hstReg); + + /* call the memory manager to free this memory */ + ret = (osCp.regionTbl[region].free) + (osCp.regionTbl[region].regCb, ptr, size, line, fileName, + entId, hstReg); + +#else + + /* call the memory manager to free this memory */ +#ifdef SS_LOCKLESS_MEMORY +#ifdef T2K_MEM_LEAK_DBG + ret = (osCp.dynRegionTbl[region].free)(osCp.dynRegionTbl[region].regCb, ptr, size,file,line); +#else + ret = (osCp.dynRegionTbl[region].free)(osCp.dynRegionTbl[region].regCb, ptr, size); +#endif +#else +#ifdef T2K_MEM_LEAK_DBG + ret = (osCp.regionTbl[region].free)(osCp.regionTbl[region].regCb, ptr, size,file,line); +#else + ret = (osCp.regionTbl[region].free)(osCp.regionTbl[region].regCb, ptr, size); +#endif +#endif /* SS_LOCKLESS_MEMORY */ + +#endif /* SS_HISTOGRAM_SUPPORT */ + +/* ss037.103 Removed the semaphore operation for performance enhancement */ + +#ifndef SS_PERF + /* release the semaphore we took */ +/* ss006.13: addition */ + if( SS_RELEASE_SEMA(&osCp.regionTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS046, ERRZERO, + "Could not release the semaphore"); + RETVALUE(RFAILED); +#endif + } +#endif +/* ss036.103 - changes to handle double free and trmapling return values +* This in turn may invoke SRegMemErrHdlr +*/ +#ifdef SSI_DEBUG_LEVEL1 + /* handle the double free error here by calling the OS specific error handling function */ + if ((ret == RDBLFREE) || (ret == RTRAMPLINGNOK)) + { + SRegMemErrHdlr( region, ptr, ret); + } +#endif /* SSI_DEBUG_LEVEL1 */ + + RETVALUE(ret); +} +#endif /* SS_FAP */ + +#ifndef SS_FAP +/* ss001.301: Additions */ +#ifdef SS_HISTOGRAM_SUPPORT + +/* +* +* Fun: SHstGrmInfoShow +* +* Desc: This function displays the memory usage information +* per Tapa task, which are registerd during initialization. +* +* +* Ret: +* +* +* Notes: A Sample Output from the function +* Memory Histogram for the Tapa task = (Entity Id)117 +* ------Region Id = 0------- +* -----------Bucket Id = 0----------- +* +* File Name| Line | Bucket Alloc | Bytes Allocated | Bytes Wasted | Buckets Freed|Bytes Freed| +* lhi.c | 413 | 4 | 512 | 224 | 0 | 0 | +* hi_acc1.c| 333 | 0 | 0 | 0 | 2 | 256 | +* hi_acc1.c| 209 | 13 | 1664 | 728 | 0 | 0 | +* +* File: mt_ss.c +* +*/ +#ifdef ANSI +PUBLIC S16 SHstGrmInfoShow +( +Ent *entId +) +#else +PUBLIC S16 SHstGrmInfoShow(entId) +Ent *entId; +#endif +{ + /*ss012.301 : Increased Buffer size to fix segmentation fault*/ + Txt prntBuf[511]; /* Buffer to print on the console */ + U16 ret = ROK; /* return value */ + Ent tapaTsk[SS_MAX_TTSKS]; /* List of tapa task */ + U32 tskCnt = 0; /* Tapa task Count */ + U32 regCnt = 0; /* Region count */ + U32 bktCnt = 0; /* Bucket count in each region */ + CmHstGrmHashListCp *hashListCp = NULLP; /* Hash List ponter of bucket */ + U32 binCnt = 0; + U32 entCnt = 0; + CmMemEntries *entry = NULLP; + U32 blkSize = 0; + + TRC1(SRegInfoShow); + + memset(tapaTsk, ENTNC, sizeof(tapaTsk)); + + if(entId == NULLP) + { + /* If user is not asking for specific entity id then, + * Take Tapa task entity id from the osCp structure and + * print the histogram for all tapa task */ + ret = SGetTapaTskEntIds(tapaTsk); + }/* End of if */ + else + { + /* If user asked for specific tapa task then print histogram + * for those tapa task */ + for(tskCnt = 0; entId[tskCnt]; tskCnt++) + { + tapaTsk[tskCnt] = entId[tskCnt]; + }/* end of for */ + } + for (tskCnt = 0; tapaTsk[tskCnt] != ENTNC; tskCnt++) + { + sprintf(prntBuf, "\n\nMemory Histogram for the Tapa task = (Entity Id)%d\n", tapaTsk[tskCnt]); + SPrint(prntBuf); + for (regCnt = 0; regCnt < osCp.numRegions; regCnt++) + { + + CmMmRegCb* regCb = (CmMmRegCb*)osCp.regionTbl[regCnt].regCb; + + sprintf(prntBuf, "------Region Id = %d-------\n", regCb->region); + SPrint(prntBuf); + for (bktCnt = 0; bktCnt < regCb->numBkts; bktCnt++) + { + /* ss002.301 - Compilation fixes */ + /*ss013.301 Fix for compilation warnings 32/64 bit */ +#ifdef ALIGN_64BIT + sprintf(prntBuf, "-----------Bucket Id = %u-----------\n\n", bktCnt); +#else + sprintf(prntBuf, "-----------Bucket Id = %lu-----------\n\n", bktCnt); +#endif + SPrint(prntBuf); + sprintf(prntBuf, "File Name | Line | Bucket Alloc | Bytes Allocated | Bytes Wasted | Buckets Freed|Bytes Freed|\n"); + SPrint(prntBuf); + hashListCp = &(regCb->bktTbl[bktCnt].hstGrmHashListCp); + blkSize = regCb->bktTbl[bktCnt].size; + for(binCnt = 0; binCnt < CMM_HIST_MAX_MEM_BIN; binCnt++) + { + for (entCnt = 0; entCnt < hashListCp->hashList[binCnt].numOfEntries; entCnt++) + { + entry = &(hashListCp->hashList[binCnt].entries[entCnt]); + if(entry->entId == tapaTsk[tskCnt]) + { + /* ss002.301 - Compilation fixes */ + /*ss013.301 Fix for compilation warnings 32/64 bit */ +#ifdef ALIGN_64BIT + sprintf(prntBuf, + "%-18s|%7u |%13u |%16u |%13u |%13u |%10u |\n", + entry->fileName, entry->line, entry->bucketAllocReq, + (blkSize*entry->bucketAllocReq), entry->wastedBytes, + entry->bucketFreeReq, (blkSize*entry->bucketFreeReq)); +#else + sprintf(prntBuf, + "%-18s|%7lu |%13lu |%16lu |%13lu |%13lu |%10lu |\n", + entry->fileName, entry->line, entry->bucketAllocReq, + (blkSize*entry->bucketAllocReq), entry->wastedBytes, + entry->bucketFreeReq, (blkSize*entry->bucketFreeReq)); +#endif + SPrint(prntBuf); + }/* End of If */ + }/* end of for. Entry count */ + } /* End of for. Hash bin count */ + } + + sprintf(prntBuf, "\n\n----------- Heap blocks -----------\n\n"); + SPrint(prntBuf); + sprintf(prntBuf, "File Name | Line | Heap Allocs | Bytes Allocated | Bytes Wasted | Heap Frees |Bytes Freed|\n"); + SPrint(prntBuf); + hashListCp = &(regCb->heapCb.heapHstGrmHashListCp); + for(binCnt = 0; binCnt < CMM_HIST_MAX_MEM_BIN; binCnt++) + { + for (entCnt = 0; entCnt < hashListCp->hashList[binCnt].numOfEntries; entCnt++) + { + entry = &(hashListCp->hashList[binCnt].entries[entCnt]); + if(entry->entId == tapaTsk[tskCnt]) + { + /* ss002.301 - Compilation fixes */ + /*ss013.301 Fix for compilation warnings 32/64 bit */ +#ifdef ALIGN_64BIT + sprintf(prntBuf, + "%-18s|%7u |%13u |%16u |%13u |%13u |%10u |\n", + entry->fileName, entry->line, entry->bucketAllocReq, + entry->allocBytes, entry->wastedBytes, + entry->bucketFreeReq, entry->freedBytes); +#else + sprintf(prntBuf, + "%-18s|%7lu |%13lu |%16lu |%13lu |%13lu |%10lu |\n", + entry->fileName, entry->line, entry->bucketAllocReq, + entry->allocBytes, entry->wastedBytes, + entry->bucketFreeReq, entry->freedBytes); +#endif + SPrint(prntBuf); + }/* End of If */ + }/* end of for. Entry count */ + } /* End of for. Hash bin count */ + }/* End of for. Region Count */ + } /* End of for (Tapa task)*/ + + + /* Print the memory information used at common, sample and ssi files. + we considerd common Sample file as invalid entity id. */ + sprintf(prntBuf, "\n\nMemory Histogram for the Tapa task = (Entity Id = ENTNC)%d\n", ENTNC); + SPrint(prntBuf); + for (regCnt = 0; regCnt < osCp.numRegions; regCnt++) + { + CmMmRegCb* regCb = (CmMmRegCb*)osCp.regionTbl[regCnt].regCb; + + sprintf(prntBuf, "------Region Id = %d-------\n", regCb->region); + SPrint(prntBuf); + for (bktCnt = 0; bktCnt < regCb->numBkts; bktCnt++) + { + /* ss002.301 - Compilation fixes */ + /*ss013.301 Fix for compilation warnings 32/64 bit */ +#ifdef ALIGN_64BIT + sprintf(prntBuf, "-----------Bucket Id = %u-----------\n\n", bktCnt); +#else + sprintf(prntBuf, "-----------Bucket Id = %lu-----------\n\n", bktCnt); +#endif + SPrint(prntBuf); + sprintf(prntBuf, "File Name | Line | Bucket Alloc | Bytes Allocated | Bytes Wasted | Buckets Freed|Bytes Freed|\n"); + SPrint(prntBuf); + hashListCp = &(regCb->bktTbl[bktCnt].hstGrmHashListCp); + blkSize = regCb->bktTbl[bktCnt].size; + for(binCnt = 0; binCnt < CMM_HIST_MAX_MEM_BIN; binCnt++) + { + for (entCnt = 0; entCnt < hashListCp->hashList[binCnt].numOfEntries; entCnt++) + { + entry = &(hashListCp->hashList[binCnt].entries[entCnt]); + if(entry->entId == tapaTsk[tskCnt]) + { + /* ss002.301 - Compilation fixes */ + /*ss013.301 Fix for compilation warnings 32/64 bit */ +#ifdef ALIGN_64BIT + sprintf(prntBuf, "%-18s|%7u |%13u |%16u |%13u |%13u |%10u |\n", + entry->fileName, entry->line, entry->bucketAllocReq, (blkSize*entry->bucketAllocReq), + entry->wastedBytes, entry->bucketFreeReq, (blkSize*entry->bucketFreeReq)); +#else + sprintf(prntBuf, "%-18s|%7lu |%13lu |%16lu |%13lu |%13lu |%10lu |\n", + entry->fileName, entry->line, entry->bucketAllocReq, (blkSize*entry->bucketAllocReq), + entry->wastedBytes, entry->bucketFreeReq, (blkSize*entry->bucketFreeReq)); +#endif + SPrint(prntBuf); + }/* End of If */ + }/* end of for. Entry count */ + } /* End of for. Hash bin count */ + + }/* End of for. Bucket Count */ + + sprintf(prntBuf, "\n\n----------- Heap blocks -----------\n\n"); + SPrint(prntBuf); + sprintf(prntBuf, "File Name | Line | Heap Allocs | Bytes Allocated | Bytes Wasted | Heap Frees |Bytes Freed|\n"); + SPrint(prntBuf); + hashListCp = &(regCb->heapCb.heapHstGrmHashListCp); + for(binCnt = 0; binCnt < CMM_HIST_MAX_MEM_BIN; binCnt++) + { + for (entCnt = 0; entCnt < hashListCp->hashList[binCnt].numOfEntries; entCnt++) + { + entry = &(hashListCp->hashList[binCnt].entries[entCnt]); + if(entry->entId == tapaTsk[tskCnt]) + { + /* ss002.301 - Compilation fixes */ + /*ss013.301 Fix for compilation warnings 32/64 bit */ +#ifdef ALIGN_64BIT + sprintf(prntBuf, + "%-18s|%7u |%13u |%16u |%13u |%13u |%10u |\n", + entry->fileName, entry->line, entry->bucketAllocReq, + entry->allocBytes, entry->wastedBytes, + entry->bucketFreeReq, entry->freedBytes); +#else + sprintf(prntBuf, + "%-18s|%7lu |%13lu |%16lu |%13lu |%13lu |%10lu |\n", + entry->fileName, entry->line, entry->bucketAllocReq, + entry->allocBytes, entry->wastedBytes, + entry->bucketFreeReq, entry->freedBytes); +#endif + SPrint(prntBuf); + }/* End of If */ + }/* end of for. Entry count */ + } /* End of for. Hash bin count */ + + }/* End of for. Region Count */ + + RETVALUE(ROK); +} + +#endif /* SS_HISTOGRAM_SUPPORT */ +#endif /* SS_FAP */ + +/********************************************************************** + End of file + **********************************************************************/ diff --git a/src/mt/ss_msg.c b/src/mt/ss_msg.c new file mode 100644 index 000000000..15cc55d86 --- /dev/null +++ b/src/mt/ss_msg.c @@ -0,0 +1,8733 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/********************************************************************20** + + Name: System Services -- Message manipulation functions + + Type: C source file + + Desc: Source Code for message related functions. + + File: ss_msg.c + +*********************************************************************21*/ + + + +/* header include files (.h) */ + +#include "envopt.h" /* environment options */ +#include "envdep.h" /* environment dependent */ +#include "envind.h" /* environment independent */ + +#include "gen.h" /* general layer */ +#include "ssi.h" /* system services */ + +#include "ss_err.h" /* errors */ +#include "ss_dep.h" /* implementation-specific */ +#include "ss_queue.h" /* queues */ +#include "ss_strm.h" /* STREAMS */ +#include "ss_msg.h" /* messaging */ +#include "ss_mem.h" /* memory management interface */ +#include "ss_gen.h" /* general */ +#include "cm_mem.h" +#include "cm_llist.h" + +#ifdef RGL_SPECIFIC_CHANGES +#ifdef TENB_DPDK_BUF +#include "ntl_lib.h" +#endif +#endif + + +/* header/extern include files (.x) */ + +#include "gen.x" /* general layer */ +#include "ssi.x" /* system services */ + +#include "ss_dep.x" /* implementation-specific */ +#include "ss_queue.x" /* queues */ +#include "ss_task.x" /* tasking */ +#include "ss_timer.x" /* timers */ +#include "ss_strm.x" /* STREAMS */ +#include "ss_msg.x" /* messaging */ +#include "ss_mem.x" /* memory management interface */ +#include "ss_drvr.x" /* driver tasks */ +#ifdef SS_LOCKLESS_MEMORY +#include "cm_llist.x" +#include "cm_hash.x" +#include "cm_mem_wl.x" /* common memory manager */ +#else +#include "cm_mem.x" /* common memory manager */ +#endif /* SS_LOCKLESS_MEMORY */ +#include "ss_gen.x" /* general */ + +/*ss004.301: Cavium changes */ +#ifdef SS_SEUM_CAVIUM +/* cvmx includes files */ +#include "cvmx-config.h" +#include "cvmx.h" +#include "cvmx-pow.h" +#include "cvmx-tim.h" +#include "cvmx-fpa.h" +#include "cvmx-helper-fpa.h" +#include "cvmx-malloc.h" +#endif /* SS_SEUM_CAVIUM */ +#include +#ifdef XEON_SPECIFIC_CHANGES +U32 startMemLeak=0; +extern pthread_mutex_t memLock; +#endif + +#if (defined (MAC_FREE_RING_BUF) || defined (RLC_FREE_RING_BUF)) +#include "ss_rbuf.h" +#include "ss_rbuf.x" +#endif +#ifdef L2_L3_SPLIT +#include "mt_plat_t33.h" +#include "mt_plat_t33.x" +#endif +/* forward declarations */ +PUBLIC S16 ssGetDBufOfSize ARGS((Region region, Size size, Buffer **dBuf)); +PUBLIC S16 SIncMsgRef(Buffer *srcBuf,Region dstRegion, Pool dstPool,Buffer **dstBuf); +#ifdef SSI_STATIC_MEM_LEAK_DETECTION +EXTERN PUBLIC U32 GetNextFreeIdx ARGS((StaticMemAllocInfo * memAllocInfo)); +EXTERN PUBLIC void LogForStaticMemLeak ARGS((StaticMemAllocInfo* memAllocInfo, char* + file, U32 line, U32 size, void* ptr, U32 idx)); +EXTERN PUBLIC void FreeIdx ARGS((U8* ptr, U32 idx, StaticMemAllocInfo* + memAllocInfo,U32 size, char* file, U32 line)); +#endif + +#ifdef SS_USE_ZBC_MEMORY +#ifdef T2K_MEM_LEAK_DBG +PRIVATE S16 SPutZbcDBufNew ARGS((Region region, Buffer *buf,char*,U32)); + +#else +PRIVATE S16 SPutZbcDBuf ARGS((Region region, Buffer *buf)); +PUBLIC S16 SAttachPtrToBuf ARGS(( Region region, Pool pool, Data *ptr, + MsgLen totalLen, Buffer** mBuf)); +#endif +#endif + +/* ss012.13: Addition */ +#ifdef SS_M_PROTO_REGION +#ifdef T2K_MEM_LEAK_DBG +#define DupMsg(region,buffer) DupMsgNew(region,buffer,file,line) +PRIVATE Buffer *DupMsgNew ARGS((Region region, Buffer *buffer,char*,U32)); +#else +#ifdef INTEL_WLS +#ifdef T2K_MEM_LEAK_DBG +PUBLIC S16 SAttachPtrToMBuf1 ARGS(( Region region, Pool pool, Data *ptr, MsgLen totalLen, + MsgLen ptrLen, Buffer** mBuf, char* file, U32 line)); +#else +PUBLIC S16 SAttachPtrToMBuf ARGS(( Region region, Pool pool, Data *ptr, MsgLen totalLen, + MsgLen ptrLen, Buffer** mBuf)); +#endif +#ifdef T2K_MEM_LEAK_DBG +PUBLIC S16 SAttachWlsPtrToMBuf1 ARGS(( Region region, Pool pool, Data *ptr, + Data *readPtr, MsgLen totalLen, + MsgLen ptrLen, Buffer** mBuf, char* file, U32 line)); + +PUBLIC S16 SAttachWlsPtrToMBuf ARGS(( Region region, Pool pool, Data *ptr, + Data *readPtr, MsgLen totalLen, + MsgLen ptrLen, Buffer** mBuf)); +#endif +#ifdef TENB_DPDK_BUF +PUBLIC S16 SDetachDpdkPtrFrmMBuf ARGS((Buffer *mBuf, Data **ptr)); +PUBLIC S16 SDetachDpdkPtrFrmDBuf ARGS((Buffer *mBuf, Data **ptr)); +PUBLIC S16 SPutSBufDpdk ARGS(( Data *ptr)); +#endif /* TENB_DPDK_BUF */ + + +#endif /* INTEL_WLS */ + +PRIVATE Buffer *DupMsg ARGS((Region region, Buffer *buffer)); +#endif +#endif /* SS_M_PROTO_REGION */ + +/* local defines */ +#define MBSIZE (sizeof(SsMblk)) +#define MDBSIZE (sizeof(SsDblk) + sizeof(SsMblk)) +#define MSGSIZE (MDBSIZE + sizeof(SsMsgInfo)) + +/*ss014.301 SSI-4GMX specific changes*/ +#if (defined(SS_4GMX_LCORE) && defined (RB_HEAD_ROOM)) +#define INITMBLK(mp, dp, dat) {\ + mp->b_next = NULLP;\ + mp->b_prev = NULLP;\ + mp->b_cont = NULLP;\ + mp->b_rptr = (dat + RB_MSG_HEAD_ROOM);\ + mp->b_wptr = (dat + RB_MSG_HEAD_ROOM);\ + mp->b_datap = dp;\ +} +#else +#define INITMBLK(mp, dp, dat) {\ + mp->b_next = NULLP;\ + mp->b_prev = NULLP;\ + mp->b_cont = NULLP;\ + mp->b_rptr = dat;\ + mp->b_wptr = dat;\ + mp->b_datap = dp;\ +} +#endif + +/* ss008.301 */ +#ifdef SS_DBLK_FREE_RTN +#define INITDBLK(dp, dat, size, frtn) {\ + dp->db_frtnp = frtn;\ + dp->db_base = dat;\ + dp->db_lim = (dat == NULLP ? dat : (dat + size));\ + dp->db_ref = 1;\ + dp->shared = FALSE; \ + dp->db_type = SS_M_DATA;\ +} +#else +#define INITDBLK(dp, dat, size, frtn) {\ + dp->db_base = dat;\ + dp->db_lim = (dat == NULLP ? dat : (dat + size));\ + dp->db_ref = 1;\ + dp->shared = FALSE; \ + dp->db_type = SS_M_DATA;\ +} +#endif /* SS_DBLK_FREE_RTN */ + +#define INITB(mp, dp, dat, size, frtn) {\ + INITMBLK(mp, dp, dat)\ + INITDBLK(dp, dat, size, frtn)\ +} + + +EXTERN pthread_t tmpRegTidMap[20]; +#define CM_MEM_GET_REGION(_region) \ +{ \ + U8 _regCnt; \ + _region = 0xFF; \ + \ + for(_regCnt = 0; _regCnt < 12; _regCnt++) \ + { \ + if(tmpRegTidMap[_regCnt] == pthread_self()) \ + { \ + _region = _regCnt; \ + break; \ + } \ + } \ +} + +#if (defined (MAC_FREE_RING_BUF) || defined (RLC_FREE_RING_BUF) || defined(L2_OPTMZ)) +extern S32 clusterMode; +#endif +/* +* +* Fun: ssGetDBufOfSize +* +* Desc: This function gets a message buffer from specified region and +* size +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: message is created. message is returned via message buffer +* pointer. Buffer type is SS_M_DATA. +* return is ok. +* +* File: ss_msg.c +* +*/ +#ifdef T2K_MEM_LEAK_DBG +PUBLIC S16 ssGetDBufOfSizeNew +( +Region region, +Size size, +Buffer **dBuf, +char* file, +U32 line +) +#else +#ifdef ANSI +PUBLIC S16 ssGetDBufOfSize +( +Region region, +Size size, +Buffer **dBuf +) +#else +PUBLIC S16 ssGetDBufOfSize(region, size, dBuf) +Region region; +Size size; +Buffer **dBuf; +#endif +#endif +{ + Size mdsize; + Data *data; + SsDblk *dptr; + + TRC1(ssGetDBufOfSize) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check buffer pointer */ + if (!dBuf) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS047, ERRZERO, "ssGetDBufOfSize : Null\ + Buffer"); + RETVALUE(RFAILED); + } + if (region >= SS_MAX_REGS) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS048, ERRZERO, "ssGetDBufOfSize : Invalid\ + region id"); + RETVALUE(RFAILED); + } + + if (size <= 0) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS049, ERRZERO, "ssGetDBufOfSize : Invalid\ + size"); + RETVALUE(RFAILED); + } +#endif + + /* ss006.301 : optmized this function */ + mdsize = MDBSIZE + size; +#ifdef SS_HISTOGRAM_SUPPORT + if (SAlloc(region, &mdsize, 0, (Data **) dBuf, __LINE__, (U8*) __FILE__, ENTNC) != ROK) +#else + if (SAlloc(region, &mdsize, 0, (Data **) dBuf) != ROK) +#endif /* SS_HISTOGRAM_SUPPORT */ + { + RETVALUE(ROUTRES); + } + data = (Data *) (*dBuf) + MDBSIZE; + size = mdsize - MDBSIZE; + + dptr = (SsDblk*) (((Data *) (*dBuf)) + MBSIZE); + + INITB((*dBuf), dptr, data, size, NULLP) +#ifndef SS_DBUF_REFLOCK_DISABLE + if((SInitLock (&(dptr->dBufLock), SS_LOCK_MUTEX)) != 0) + { + SSLOGERROR(ERRCLS_DEBUG, ESS056, ERRZERO,"Falied to initalize lock"); + } +#endif + + RETVALUE(ROK); +} /* ssGetDBufOfSize */ + + +/* +* +* Fun: SGetMsgNew +* +* Desc: This function gets a message +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: message is created. message is set to type SS_M_PROTO. +* message is returned via message buffer pointer. +* return is ok. +* +* File: ss_msg.c +* +*/ +/* ss001.301: additions */ +#ifdef SS_HISTOGRAM_SUPPORT +#ifdef ANSI +PUBLIC S16 SGetMsgNew +( +Region region, /* region id */ +Pool pool, /* pool id */ +Buffer **mBuf, /* pointer to message buffer */ +U32 line, +U8 *fileName +) +#else +PUBLIC S16 SGetMsgNew(region, pool, mBuf, line, fileName) +Region region; /* region id */ +Pool pool; /* pool id */ +Buffer **mBuf; /* pointer to message buffer */ +U32 line; +U8 *fileName; +#endif +#else /* SS_HISTOGRAM_SUPPORT */ +#ifdef T2K_MEM_LEAK_DBG +PUBLIC S16 SGetMsgNew +( +Region region, /* region id */ +Pool pool, /* pool id */ +Buffer **mBuf, /* pointer to message buffer */ +char* file, +U32 line +) +#else +#ifdef ANSI +PUBLIC S16 SGetMsg +( +Region region, /* region id */ +Pool pool, /* pool id */ +Buffer **mBuf /* pointer to message buffer */ +) +#else +PUBLIC S16 SGetMsg(region, pool, mBuf) +Region region; /* region id */ +Pool pool; /* pool id */ +Buffer **mBuf; /* pointer to message buffer */ +#endif +#endif +#endif /* SS_HISTOGRAM_SUPPORT */ +{ + SsMsgInfo *minfo; + Size size = MSGSIZE; + SsDblk *dptr; + Data *data; +/* ss001.301: additions */ +#ifdef SS_HISTOGRAM_SUPPORT + Ent entId = 0; +#endif /* SS_HISTOGRAM_SUPPORT */ + + /* ss021.103 - Addition of return value */ +#ifndef SS_PERF +#if (ERRCLASS & ERRCLS_INT_PAR) + S16 ret; +#endif +#endif + + + TRC1(SGetMsgNew) + +#ifdef XEON_SPECIFIC_CHANGES + region = 0; + pool = 0; +#endif + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check buffer pointer */ + if (!mBuf) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS050, ERRZERO, "SGetMsg : Null Buffer"); + RETVALUE(RFAILED); + } + if (region >= SS_MAX_REGS) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS051, ERRZERO, "SGetMsg : Invalid region\ + id"); + RETVALUE(RFAILED); + } + + if (pool >= SS_MAX_POOLS_PER_REG) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS052, ERRZERO, "SGetMsg : Invalid pool id"); + RETVALUE(RFAILED); + } + +/* ss037.103 Removed the semaphore operation for performance enhancement */ + +#ifndef SS_PERF + /* ss021.103 - Addition to check if region is registered */ + /* acquire one semaphore, to protect against deregistration */ + SS_ACQUIRE_SEMA(&osCp.regionTblSem, ret); + if (ret != ROK) + { + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS053, (ErrVal) ret, + "Could not lock region table"); +#endif + + RETVALUE(RFAILED); + } +#endif +#endif +#if (ERRCLASS & ERRCLS_INT_PAR) + /* verify that this region is present */ + if (osCp.regionTbl[region].used == FALSE) + { +/* ss037.103 Removed the semaphore operation for performance enhancement */ + +#ifndef SS_PERF + if( SS_RELEASE_SEMA(&osCp.regionTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS054, ERRZERO, + "Could not release semaphore"); + RETVALUE(RFAILED); +#endif + } +#endif + SSLOGERROR(ERRCLS_INT_PAR, ESS055, region, "Region not registered"); + RETVALUE(RFAILED); + } +/* ss037.103 Removed the semaphore operation for performance enhancement */ + +#ifndef SS_PERF + if( SS_RELEASE_SEMA(&osCp.regionTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS056, ERRZERO, + "Could not release semaphore"); + RETVALUE(RFAILED); +#endif + } +#endif +#endif + +/* ss001.301: additions */ +#ifdef SS_HISTOGRAM_SUPPORT + SGetEntInd(&entId, fileName); +#endif /* SS_HISTOGRAM_SUPPORT */ + +/* ss012.13: Addition */ +#ifdef SS_M_PROTO_REGION +/* ss001.301: additions */ +#ifdef SS_HISTOGRAM_SUPPORT + if (SAlloc(region, &size, 0, (Data**) mBuf, line, fileName, entId) != ROK) +#else + if (SAlloc(region, &size, 0, (Data**) mBuf) != ROK) +#endif /* SS_HISTOGRAM_SUPPORT */ + { + SSLOGERROR(ERRCLS_DEBUG, ESS058, ERRZERO, "SGetMsg:Failed in SAlloc"); + RETVALUE(ROUTRES); + } +#else /* SS_M_PROTO_REGION */ +/* ss001.301: additions */ +#ifdef SS_HISTOGRAM_SUPPORT + if (SAlloc(SS_DFLT_REGION, &size, 0, (Data**) mBuf, line, fileName, entId) != ROK) +#else + if (SAlloc(region, &size, 0, (Data**) mBuf) != ROK) +#endif /* SS_HISTOGRAM_SUPPORT */ + { + SSLOGERROR(ERRCLS_DEBUG, ESS059, ERRZERO, "SGetMsg:Failed in SAlloc"); + RETVALUE(ROUTRES); + } +#endif /* SS_M_PROTO_REGION */ + + dptr = (SsDblk*) (((Data *) (*mBuf)) + MBSIZE); + data = (Data*) (((Data *) (*mBuf)) + MDBSIZE); + + /* INITB initialises and sets up the message blk */ + INITB((*mBuf), dptr, data, sizeof(SsMsgInfo), NULLP) + + (*mBuf)->b_datap->db_type = SS_M_PROTO; + (*mBuf)->b_wptr = (*mBuf)->b_rptr + sizeof(SsMsgInfo); + + /* initialise message info of mBuf */ + minfo = (SsMsgInfo*) (*mBuf)->b_rptr; + + minfo->region = region; + minfo->pool = pool; + minfo->len = 0; + minfo->endptr = NULLP; + minfo->eventInfo.event = SS_EVNT_DATA; + /* ss021.103 - Addition to initialize next and route */ + minfo->next = NULLP; +#ifdef L2_OPTMZ + { + if(clusterMode == RADIO_CLUSTER_MODE) + { + (*mBuf)->refCnt = 1; + } + } +#endif + RETVALUE(ROK); +} + +#ifdef RGL_SPECIFIC_CHANGES +S16 SSetMBufPool(Buffer *mBuf, Pool pool) +{ + + SsMsgInfo *minfo; + + minfo = (SsMsgInfo*) mBuf->b_rptr; + minfo->pool = pool; + + RETVALUE(ROK); +} +#endif + +/* #ifdef SS_LOCKLESS_MEMORY */ + +/* +* +* Fun: SPutMsgNew +* +* Desc: This function deallocates a message back. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: all data attached to message is returned to memory. +* message is returned to memory. return is ok. +* +* File: ss_msg.c +* +*/ +/* ss001.301: additions */ +#ifdef SS_HISTOGRAM_SUPPORT +#ifdef ANSI +PUBLIC S16 SPutMsgNew +( +Buffer *mBuf, +U32 line, +U8 *fileName +) +#else +PUBLIC S16 SPutMsgNew(mBuf, line, fileName) +Buffer *mBuf; +U32 line; +U8 *fileName; +#endif +#else /* SS_HISTOGRAM_SUPPORT */ +#ifdef T2K_MEM_LEAK_DBG +PUBLIC S16 SPutMsgNew +( +Buffer *mBuf, +char* file, +U32 line +) +#else +#ifdef ANSI +PUBLIC S16 SPutMsg +( +Buffer *mBuf +) +#else +PUBLIC S16 SPutMsg(mBuf) +Buffer *mBuf; +#endif +#endif +#endif /* SS_HISTOGRAM_SUPPORT */ +{ + Buffer *tmp; + SsMsgInfo *minfo; +#ifdef SS_MEM_WL_DEBUG + U8 tmpThrReg; +#endif + +/* ss001.301: additions */ +#ifdef SS_HISTOGRAM_SUPPORT + Ent entId = 0; +#endif /* SS_HISTOGRAM_SUPPORT */ + + TRC1(SPutMsgNew) + +#ifdef L2_OPTMZ +//#ifdef RADIO_CLUSTER + if(clusterMode == RADIO_CLUSTER_MODE) + { + if(mBuf->refCnt) + { + mBuf->refCnt -= 1; + } + if (mBuf->refCnt > 0) + { + RETVALUE(ROK); + } + } +#endif +#if (defined (MAC_FREE_RING_BUF) || defined (RLC_FREE_RING_BUF)) + { + extern pthread_t gMacTId,gRlcTId; + extern S32 clusterMode; + if(clusterMode == RADIO_CLUSTER_MODE) + { + +#ifdef MAC_FREE_RING_BUF + if(pthread_self() == gMacTId) + //if(pthread_equal(pthread_self(),gMacTId)) + { +#if 0 +#else + if(ROK == mtAddBufToRing(SS_RNG_BUF_MAC_FREE_RING,(Void *)mBuf,0)) +#endif + { + RETVALUE(ROK); + } + } +#endif +#ifdef RLC_FREE_RING_BUF + else if(pthread_self() == gRlcTId) + { +#if 0 +#else + if(ROK == mtAddBufToRing(SS_RNG_BUF_RLC_FREE_RING,(Void *)mBuf,0)) +#endif + { + RETVALUE(ROK); + } + } +#endif + } + } +#endif + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (mBuf == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS060, ERRZERO, "SPutMsg: Null Buffer"); + RETVALUE(RFAILED); + } + if (mBuf->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS061, ERRZERO, "SPutMsg: Incorrect buffer\ + type"); + RETVALUE(RFAILED); + } +#endif + +#ifdef SS_MEM_WL_DEBUG + CM_MEM_GET_REGION(tmpThrReg) + if(tmpThrReg == 0xFF) + { + printf("\n Not able to get region \n"); + RETVALUE(RFAILED); + } +#endif + + /* get the message info */ + minfo = (SsMsgInfo *) mBuf->b_rptr; + + while ((tmp = mBuf->b_cont)) + { + /* set b_cont of mBuf to point to the b_cont of tmp */ + mBuf->b_cont = tmp->b_cont; +#ifdef SS_MEM_WL_DEBUG + (Void) SPutDBuf(tmpThrReg, minfo->pool, tmp); +#else + (Void) SPutDBuf(minfo->region, minfo->pool, tmp); +#endif + } + +/* ss001.301: additions */ +#ifdef SS_HISTOGRAM_SUPPORT + SGetEntInd(&entId, fileName); +#endif /* SS_HISTOGRAM_SUPPORT */ + +/* ss012.13: Addition */ +#ifdef SS_M_PROTO_REGION + /* ss021.103 - Addition to check return value of SFree */ +#ifdef SS_HISTOGRAM_SUPPORT + if (SFree(minfo->region, (Data *) mBuf, MSGSIZE, line, fileName, entId) == RFAILED) +#else +#ifdef SS_MEM_WL_DEBUG + if (SFree(tmpThrReg, (Data *) mBuf, MSGSIZE) == RFAILED) +#else + if (SFree(minfo->region, (Data *) mBuf, MSGSIZE) == RFAILED) +#endif +#endif /* SS_HISTOGRAM_SUPPORT */ + RETVALUE(RFAILED); +#else /* SS_M_PROTO_REGION */ + /* ss021.103 - Addition to check return value of SFree */ +#ifdef SS_HISTOGRAM_SUPPORT + if (SFree(SS_DFLT_REGION, (Data *) mBuf, MSGSIZE, line, fileName, entId) == RFAILED) +#else + if (SFree(minfo->region, (Data *) mBuf, MSGSIZE) == RFAILED) +#endif /* SS_HISTOGRAM_SUPPORT */ + RETVALUE(RFAILED); +#endif /* SS_M_PROTO_REGION */ + + RETVALUE(ROK); +} + +#ifdef SS_LOCKLESS_MEMORY +/* +* +* Fun: SPutStaticBuffer +* +* Desc: Returns a buffer to the specified static pool in the +* specified memory region. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: +* +* File: ss_msg.c +* +*/ +/* ss001.301: additions */ +#ifdef T2K_MEM_LEAK_DBG +PUBLIC S16 SPutStaticBufferNew +( +Region region, /* region ID */ +Pool pool, /* pool ID */ +Data *ptr, /* pointer to buffer */ +Size size, /* size */ +U8 memType, /* memory type used if shareable or not */ +char* file, +U32 line +) +#else +#ifdef ANSI +PUBLIC S16 SPutStaticBuffer +( +Region region, /* region ID */ +Pool pool, /* pool ID */ +Data *ptr, /* pointer to buffer */ +Size size, /* size */ +U8 memType /* memory type used if shareable or not */ +) +#else +PUBLIC S16 SPutStaticBuffer(region, pool, ptr, size) +Region region; /* region ID */ +Pool pool; /* pool ID */ +Data *ptr; /* pointer to buffer */ +Size size; /* size */ +U8 memType; /* memory type used if shareable or not */ +#endif +#endif +{ + S16 ret = RFAILED; + + TRC1(SPutStaticBuffer); + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* validate region ID */ + if (region >= SS_MAX_REGS) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS220, region, "Invalid region"); + RETVALUE(RFAILED); + } + + /* validate pool ID */ + if (pool >= SS_MAX_POOLS_PER_REG) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS221, pool, "Invalid pool"); + RETVALUE(RFAILED); + } + /* validate data pointer */ + if (ptr == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS223, (ErrVal)0, "NULL data pointe"); + RETVALUE(RFAILED); + } + + /* validate size */ + if (size <= 0) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS224, size, "Invalid size"); + RETVALUE(RFAILED); + } +#endif +#if (defined (MAC_FREE_RING_BUF) || defined (RLC_FREE_RING_BUF)) + { + extern pthread_t gMacTId,gRlcTId; + + if(clusterMode == RADIO_CLUSTER_MODE) + { +#ifdef MAC_FREE_RING_BUF + if(pthread_self() == gMacTId) + //if(pthread_equal(pthread_self(),gMacTId)) + { +#if 0 +#else + if(ROK == mtAddBufToRing(SS_RNG_BUF_MAC_FREE_RING,(Void *)ptr,1)) +#endif + { + RETVALUE(ROK); + } + } +#endif +#ifdef RLC_FREE_RING_BUF + else if(pthread_self() == gRlcTId) + { +#if 0 +#else + if(ROK == mtAddBufToRing(SS_RNG_BUF_RLC_FREE_RING,(Void *)ptr,1)) +#endif + { + RETVALUE(ROK); + } + } + } + } +#endif +#endif + region = SS_GET_THREAD_MEM_REGION(); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* verify that this region is present */ + if (((memType == SS_NON_SHARABLE_MEMORY) && + (osCp.regionTbl[region].used == FALSE)) || + ((memType == SS_SHARABLE_MEMORY) && + (osCp.dynRegionTbl[region].used == FALSE))) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS218, region, "Region not registered"); + RETVALUE(ret); + } +#endif + + /* call the memory manager, to allocate this memory */ +#ifndef SS_DBUF_REFLOCK_DISABLE + if(memType == SS_NON_SHARABLE_MEMORY) + { + #ifndef T2K_MEM_LEAK_DBG + ret = (osCp.regionTbl[region].free) + (osCp.regionTbl[region].regCb, ptr, size); + #else + ret = (osCp.regionTbl[region].free) + (osCp.regionTbl[region].regCb, ptr, size, file, line); + + #endif + } + else if(memType == SS_SHARABLE_MEMORY) + { +#endif + +#ifndef T2K_MEM_LEAK_DBG + ret = (osCp.dynRegionTbl[region].free) + (osCp.dynRegionTbl[region].regCb, ptr, size); +#else + ret = (osCp.dynRegionTbl[region].free) + (osCp.dynRegionTbl[region].regCb, ptr, size,file,line); +#endif +#ifndef SS_DBUF_REFLOCK_DISABLE + } +#endif + + RETVALUE(ret); +} + +/* +* +* Fun: SGetStaticBuffer +* +* Desc: Allocates a buffer from the specified static memory pool +* in the specified region. Depending on the type wheather +* the buffer is sharable or non-sharable indicated by the +* memType prameter allocation region is choosen +* done +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: +* +* File: ss_msg.c +* +*/ +#ifdef T2K_MEM_LEAK_DBG +PUBLIC S16 SGetStaticBufferNew +( +Region region, /* region ID */ +Pool pool, /* pool ID */ +Data **ptr, /* pointer to buffer */ +Size size, /* size requested */ +U8 memType, /* memory type used if shareable or not */ +char* file, +U32 line +) +#else +#ifdef ANSI +PUBLIC S16 SGetStaticBuffer +( +Region region, /* region ID */ +Pool pool, /* pool ID */ +Data **ptr, /* pointer to buffer */ +Size size, /* size requested */ +U8 memType /* memory type used if shareable or not */ +) +#else +PUBLIC S16 SGetStaticBuffer(region, pool, ptr, size) +Region region; /* region ID */ +Pool pool; /* pool ID */ +Data **ptr; /* pointer to buffer */ +Size size; /* size requested */ +U8 memType; /* memory type used if shareable or not */ +#endif +#endif +{ + S16 ret = RFAILED; + U32 flags; + + TRC1(SGetStaticBuffer); + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* validate region ID */ + if (region >= SS_MAX_REGS) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS211, region, "Invalid region"); + RETVALUE(ret); + } + + /* validate pool ID */ + if (pool >= SS_MAX_POOLS_PER_REG) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS212, pool, "Invalid pool"); + RETVALUE(ret); + } + /* validate data pointer */ + if (ptr == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS214, (ErrVal)0 , "NULL data pointer"); + RETVALUE(ret); + } + + /* validate size */ + if (size <= 0) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS215, size, "Invalid size"); + RETVALUE(ret); + } +#endif + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* verify that this region is present */ + if (((memType == SS_NON_SHARABLE_MEMORY) && + (osCp.regionTbl[region].used == FALSE)) || + ((memType == SS_SHARABLE_MEMORY) && + (osCp.dynRegionTbl[region].used == FALSE))) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS218, region, "Region not registered"); + RETVALUE(ret); + } +#endif + + flags = 0; + + region = SS_GET_THREAD_MEM_REGION(); +#ifdef USE_MEMCAL + if (region == SS_STATIC_REGION) + flags = 1; +#endif + + /* call the memory manager, to allocate this memory */ +#ifndef SS_DBUF_REFLOCK_DISABLE + if(memType == SS_NON_SHARABLE_MEMORY) + { +#ifndef T2K_MEM_LEAK_DBG + ret = (osCp.regionTbl[region].alloc) + (osCp.regionTbl[region].regCb, &size, flags, ptr); +#else + ret = (osCp.regionTbl[region].alloc) + (osCp.regionTbl[region].regCb, &size, flags, ptr, file,line); +#endif + } + else if(memType == SS_SHARABLE_MEMORY) + { +#endif +#ifndef T2K_MEM_LEAK_DBG + ret = (osCp.dynRegionTbl[region].alloc) + (osCp.dynRegionTbl[region].regCb, &size, flags, ptr); +#else + ret = (osCp.dynRegionTbl[region].alloc) + (osCp.dynRegionTbl[region].regCb, &size, flags, ptr,file,line); +#endif +#ifndef SS_DBUF_REFLOCK_DISABLE + } +#endif + + RETVALUE(ret); +} +#endif /* SS_LOCKLESS_MEMORY */ + +#ifdef INTEL_WLS +#ifndef SS_LOCKLESS_MEMORY +#ifdef ANSI +PUBLIC S16 SGetStaticBuffer +( +Region region, /* region ID */ +Pool pool, /* pool ID */ +Data **ptr, /* pointer to buffer */ +Size size, /* size requested */ +U8 memType /* memory type used if shareable or not */ +) +#else +PUBLIC S16 SGetStaticBuffer(region, pool, ptr, size) +Region region; /* region ID */ +Pool pool; /* pool ID */ +Data **ptr; /* pointer to buffer */ +Size size; /* size requested */ +U8 memType; /* memory type used if shareable or not */ +#endif +{ + S16 ret; + + ret = SGetSBuf(region, pool, ptr, size); + + RETVALUE(ret); +} + + +#ifdef ANSI +PUBLIC S16 SPutStaticBuffer +( +Region region, /* region ID */ +Pool pool, /* pool ID */ +Data *ptr, /* pointer to buffer */ +Size size, /* size */ +U8 memType /* memory type used if shareable or not */ +) +#else +PUBLIC S16 SPutStaticBuffer(region, pool, ptr, size) +Region region; /* region ID */ +Pool pool; /* pool ID */ +Data *ptr; /* pointer to buffer */ +Size size; /* size */ +U8 memType; /* memory type used if shareable or not */ +#endif +{ + + S16 ret; + + ret = SPutSBuf(region, pool, ptr, size); + + RETVALUE(ret); + +} +#endif +#ifdef T2K_MEM_LEAK_DBG +PUBLIC S16 SGetSBufWls1 +( +Region region, /* region ID */ +Pool pool, /* pool ID */ +Data **ptr, /* pointer to buffer */ +Size size, /* size requested */ +char* file, +U32 line +) +#else +PUBLIC S16 SGetSBufWls +( +Region region, /* region ID */ +Pool pool, /* pool ID */ +Data **ptr, /* pointer to buffer */ +Size size /* size requested */ +) +#endif +{ + S16 ret; + U32 flags = 0; + +#ifdef SS_LOCKLESS_MEMORY + region = SS_GET_THREAD_MEM_REGION(); + ret = SAlloc(region, &size, 0, ptr); +#else + region = 0; +#ifdef T2K_MEM_LEAK_DBG + ret = (osCp.regionTbl[region].alloc) + (osCp.regionTbl[region].regCb, &size, flags, ptr,file,line); +#else + ret = (osCp.regionTbl[region].alloc) + (osCp.regionTbl[region].regCb, &size, flags, ptr); +#endif +#endif + + RETVALUE(ret); +} + +#ifdef T2K_MEM_LEAK_DBG +PUBLIC S16 SPutSBufWls1 +( +Region region, /* region ID */ +Pool pool, /* pool ID */ +Data *ptr, /* pointer to buffer */ +Size size, /* size */ +char* file, +U32 line +) +#else +PUBLIC S16 SPutSBufWls +( +Region region, /* region ID */ +Pool pool, /* pool ID */ +Data *ptr, /* pointer to buffer */ +Size size /* size */ +) +#endif +{ + S16 ret; + +#ifdef SS_LOCKLESS_MEMORY + region = SS_GET_THREAD_MEM_REGION(); + ret = SFree(region, ptr, size); +#else + region = 0; +#ifdef T2K_MEM_LEAK_DBG + ret = (osCp.regionTbl[region].free)(osCp.regionTbl[region].regCb, ptr, size,file,line); +#else + ret = (osCp.regionTbl[region].free)(osCp.regionTbl[region].regCb, ptr, size); +#endif +#endif + + RETVALUE(ret); +} + +#endif /* INTEL_WLS */ + + +/* +* +* Fun: SGetSBufNew +* +* Desc: Allocates a buffer from the specified static memory pool +* in the specified region. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: The new memory management scheme eliminates the concept +* of pools. This call maps directly to a call to the memory +* manager. +* +* File: ss_msg.c +* +*/ +/* ss001.301: additions */ +#ifdef SS_HISTOGRAM_SUPPORT +#ifdef ANSI +PUBLIC S16 SGetSBufNew +( +Region region, /* region ID */ +Pool pool, /* pool ID */ +Data **ptr, /* pointer to buffer */ +Size size, /* size requested */ +U32 line, +U8 *fileName +) +#else +PUBLIC S16 SGetSBufNew(region, pool, ptr, size, line, fileName) +Region region; /* region ID */ +Pool pool; /* pool ID */ +Data **ptr; /* pointer to buffer */ +Size size; /* size requested */ +U32 line; +U8 *fileName; +#endif +#else /* SS_HISTOGRAM_SUPPORT */ +#if (defined(SSI_STATIC_MEM_LEAK_DETECTION) || defined(T2K_MEM_LEAK_DBG)) +#ifdef ANSI +PUBLIC S16 SGetSBuf1 +( +Region region, /* region ID */ +Pool pool, /* pool ID */ +Data **ptr, /* pointer to buffer */ +Size size, /* size requested */ +char* file, +U32 line +) +#else +PUBLIC S16 SGetSBuf1(region, pool, ptr, size, file, line) +Region region; /* region ID */ +Pool pool; /* pool ID */ +Data **ptr; /* pointer to buffer */ +Size size; /* size requested */ +char* file; +U32 line; +#endif +#else +#ifdef ANSI +PUBLIC S16 SGetSBuf +( +Region region, /* region ID */ +Pool pool, /* pool ID */ +Data **ptr, /* pointer to buffer */ +Size size /* size requested */ +) +#else +PUBLIC S16 SGetSBuf(region, pool, ptr, size) +Region region; /* region ID */ +Pool pool; /* pool ID */ +Data **ptr; /* pointer to buffer */ +Size size; /* size requested */ +#endif +#endif +#endif /* SS_HISTOGRAM_SUPPORT */ +{ + S16 ret; + U32 flags; +#ifdef SSI_STATIC_MEM_LEAK_DETECTION + Size tmpSize; +#endif + +#ifdef SS_HISTOGRAM_SUPPORT + Ent entId = 0; + Bool hstReg = FALSE; +#endif /* SS_HISTOGRAM_SUPPORT */ + + TRC1(SGetSBufNew); + + region = SS_GET_THREAD_MEM_REGION(); +#ifdef INTEL_WLS + region = 1; +#endif /* INTEL_WLS */ + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* validate region ID */ + if (region >= SS_MAX_REGS) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS211, region, "Invalid region"); + RETVALUE(RFAILED); + } + + /* validate pool ID */ + if (pool >= SS_MAX_POOLS_PER_REG) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS212, pool, "Invalid pool"); + RETVALUE(RFAILED); + } +/* ss008.13: addition */ + /* validate data pointer */ + if (ptr == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS214, (ErrVal)0 , "NULL data pointer"); + RETVALUE(RFAILED); + } + + /* validate size */ + if (size <= 0) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS215, size, "Invalid size"); + RETVALUE(RFAILED); + } +#endif +/* ss037.103 Removed the semaphore operation for performance enhancement */ + +#ifndef RGL_SPECIFIC_CHANGES + region = SS_GET_THREAD_MEM_REGION(); +#endif +#ifndef SS_PERF + /* acquire one semaphore, to protect against deregistration */ + SS_ACQUIRE_SEMA(&osCp.regionTblSem, ret); + if (ret != ROK) + { + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS216, (ErrVal) ret, + "Could not lock region table"); +#endif + + RETVALUE(RFAILED); + } + +#endif + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* verify that this region is present */ + if (osCp.regionTbl[region].used == FALSE) + { + +#ifndef SS_PERF +/* ss006.13: addition */ + if( SS_RELEASE_SEMA(&osCp.regionTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS217, ERRZERO, + "Could not release semaphore"); + RETVALUE(RFAILED); +#endif + } + + SSLOGERROR(ERRCLS_INT_PAR, ESS218, region, "Region not registered"); + RETVALUE(RFAILED); +#endif + } +#endif + + + flags = 0; + + /* ss024.103 - Addition for memory calculator tool */ +#ifdef USE_MEMCAL + if (region == SS_STATIC_REGION) + flags = 1; +#endif + +/* ss001.301: additions */ +#ifdef SS_HISTOGRAM_SUPPORT + + SGetEntInd(&entId, fileName); + /* Get the Information from the oscp that the tapa task with the entity + id (entid) is registed for histogram or not */ + SGetHstGrmInfo(&entId, &hstReg); + /* call the memory manager, to allocate this memory */ +#ifdef SSI_DEBUG_LEVEL1 + ret = (osCp.regionTbl[region].alloc) + (osCp.regionTbl[region].regCb, &size, flags, ptr, + SS_STATIC_MEM_FLAG, line, fileName, entId, hstReg); +#else + ret = (osCp.regionTbl[region].alloc) + (osCp.regionTbl[region].regCb, &size, flags, ptr, + line, fileName, entId, hstReg); +#endif /* SSI_DEBUG_LEVEL1 */ + +#else + + /* call the memory manager, to allocate this memory */ +/* ss036.103 - addition for passing additional parameter memType as static */ +#ifdef SSI_DEBUG_LEVEL1 + ret = (osCp.regionTbl[region].alloc) + (osCp.regionTbl[region].regCb, &size, flags, ptr, SS_STATIC_MEM_FLAG); +#else +#ifdef SSI_STATIC_MEM_LEAK_DETECTION + /* Static mem leak detection changes */ + tmpSize = size + 4; +#ifdef T2K_MEM_LEAK_DBG + ret = (osCp.regionTbl[region].alloc) + (osCp.regionTbl[region].regCb, &tmpSize, flags, ptr, file, line); +#else + ret = (osCp.regionTbl[region].alloc) + (osCp.regionTbl[region].regCb, &tmpSize, flags, ptr); +#endif + /*size = tmpSize - 4;*/ + { + /*printf("ptr = %p *ptr = %p\n",ptr,*ptr);*/ +#ifdef XEON_SPECIFIC_CHANGES + pthread_mutex_lock(&(memLock)); +#endif + U32 idx = GetNextFreeIdx(&SMemLeakInfo[region]); + U8* allocatedPtr = *ptr; + void* actualPtr = allocatedPtr + 4; + *ptr = actualPtr; + /* store the index in the memory allocated itself */ + /**((U32*)*((U32*)allocatedPtr)) = idx;*/ + *((U32*)allocatedPtr) = idx; + /*printf("region = %d idx = %d ptr = %p *ptr = %p actual = %p allocated = %p content = %d\n",region, idx, ptr, *ptr, actualPtr, allocatedPtr, *((U32*)allocatedPtr));*/ + + LogForStaticMemLeak(&SMemLeakInfo[region], + file, + line, + size, + *ptr, + idx); +#ifdef XEON_SPECIFIC_CHANGES + pthread_mutex_unlock(&(memLock)); +#endif + } +#else +#ifndef T2K_MEM_LEAK_DBG + ret = (osCp.regionTbl[region].alloc) + (osCp.regionTbl[region].regCb, &size, flags, ptr); +#else + ret = (osCp.regionTbl[region].alloc) + (osCp.regionTbl[region].regCb, &size, flags, ptr, file, line); +#endif + +#endif +#endif /* SSI_DEBUG_LEVEL1 */ + +#endif /* SS_HISTOGRAM_SUPPORT */ + + /* release the semaphore we took */ + +#ifndef SS_PERF +/* ss006.13: addition */ + if( SS_RELEASE_SEMA(&osCp.regionTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS219, ERRZERO, + "Could not release semaphore"); + RETVALUE(RFAILED); +#endif + } +#endif +/* ss036.103 - Addition to handle the memory trampling return value +* This in turn might invoke SRegMemErrHdlr +*/ +#ifdef SSI_DEBUG_LEVEL1 + if (ret == RTRAMPLINGNOK) + { + SRegMemErrHdlr( region, *ptr, ret); + } +#endif /* SSI_DEBUG_LEVEL1 */ + + RETVALUE(ret); +} + + +/* +* +* Fun: SPutSBufNew +* +* Desc: Returns a buffer to the specified static pool in the +* specified memory region. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: +* +* File: ss_msg.c +* +*/ +/* ss001.301: additions */ +#ifdef SS_HISTOGRAM_SUPPORT +#ifdef ANSI +PUBLIC S16 SPutSBufNew +( +Region region, /* region ID */ +Pool pool, /* pool ID */ +Data *ptr, /* pointer to buffer */ +Size size, /* size */ +U32 line, +U8 *fileName +) +#else +PUBLIC S16 SPutSBufNew(region, pool, ptr, size, line, fileName) +Region region; /* region ID */ +Pool pool; /* pool ID */ +Data *ptr; /* pointer to buffer */ +Size size; /* size */ +U32 line; +U8 *fileName; +#endif +#else /* SS_HISTOGRAM_SUPPORT */ +#if (defined(SSI_STATIC_MEM_LEAK_DETECTION) || defined(T2K_MEM_LEAK_DBG)) +#ifdef ANSI +PUBLIC S16 SPutSBuf1 +( +Region region, /* region ID */ +Pool pool, /* pool ID */ +Data *ptr, /* pointer to buffer */ +Size size, /* size */ +char* file, +U32 line +) +#else +PUBLIC S16 SPutSBuf1(region, pool, ptr, size, file, line) +Region region; /* region ID */ +Pool pool; /* pool ID */ +Data *ptr; /* pointer to buffer */ +Size size; /* size */ +char* file; +U32 line; +#endif +#else +#ifdef ANSI +PUBLIC S16 SPutSBuf +( +Region region, /* region ID */ +Pool pool, /* pool ID */ +Data *ptr, /* pointer to buffer */ +Size size /* size */ +) +#else +PUBLIC S16 SPutSBuf(region, pool, ptr, size) +Region region; /* region ID */ +Pool pool; /* pool ID */ +Data *ptr; /* pointer to buffer */ +Size size; /* size */ +#endif +#endif +#endif /* SS_HISTOGRAM_SUPPORT */ +{ + S16 ret; + +#ifdef SS_HISTOGRAM_SUPPORT + Ent entId = 0; + Bool hstReg = FALSE; +#endif /* SS_HISTOGRAM_SUPPORT */ + + TRC1(SPutSBufNew); + + + region = SS_GET_THREAD_MEM_REGION(); +#if (!defined(SS_LOCKLESS_MEMORY) && defined(INTEL_WLS)) + region = 1; +#endif /* INTEL_WLS */ + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* validate region ID */ + if (region >= SS_MAX_REGS) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS220, region, "Invalid region"); + RETVALUE(RFAILED); + } + + /* validate pool ID */ + if (pool >= SS_MAX_POOLS_PER_REG) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS221, pool, "Invalid pool"); + RETVALUE(RFAILED); + } +/* ss008.13: addition */ + /* validate data pointer */ + if (ptr == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS223, (ErrVal)0, "NULL data pointe"); + RETVALUE(RFAILED); + } + + /* validate size */ + if (size <= 0) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS224, size, "Invalid size"); + RETVALUE(RFAILED); + } +#endif +/* ss037.103 Removed the semaphore operation for performance enhancement */ +#ifndef RGL_SPECIFIC_CHANGES + region = SS_GET_THREAD_MEM_REGION(); +#endif +#ifndef SS_PERF + /* acquire one semaphore, to protect against deregistration */ + SS_ACQUIRE_SEMA(&osCp.regionTblSem, ret); + if (ret != ROK) + { + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS225, (ErrVal) ret, + "Could not lock region table"); +#endif + + RETVALUE(RFAILED); + } +#endif + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* verify that this region is around */ + if (osCp.regionTbl[region].used == FALSE) + { +#ifndef SS_PERF + +/* ss006.13: addition */ + if( SS_RELEASE_SEMA(&osCp.regionTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS226, ERRZERO, + "Could not release semaphore"); + RETVALUE(RFAILED); +#endif + } +#endif + SSLOGERROR(ERRCLS_INT_PAR, ESS227, region, "Region not registered"); + RETVALUE(RFAILED); + } +#endif + +#ifdef SSI_STATIC_MEM_LEAK_DETECTION +/* Static mem leak detection changes */ + { +#ifdef XEON_SPECIFIC_CHANGES + pthread_mutex_lock(&(memLock)); +#endif + U32 idx = *((U32*)((U8 *)ptr - 4)); + FreeIdx(ptr,idx,&SMemLeakInfo[region],size,file,line); +#ifdef XEON_SPECIFIC_CHANGES + pthread_mutex_unlock(&(memLock)); +#endif + } +/* Static mem leak detection changes */ +#endif + +/* ss001.301: additions */ +#ifdef SS_HISTOGRAM_SUPPORT + SGetEntInd(&entId, fileName); + /* Get the Information from the oscp that the tapa task with the entity + id (entid) is registed for histogram or not */ + SGetHstGrmInfo(&entId, &hstReg); + + /* call the memory manager to free this memory */ + ret = (osCp.regionTbl[region].free)(osCp.regionTbl[region].regCb, ptr, size, + line, fileName, entId, hstReg); +#else + /* call the memory manager to free this memory */ +#ifdef SSI_STATIC_MEM_LEAK_DETECTION +#ifdef T2K_MEM_LEAK_DBG + ret = (osCp.regionTbl[region].free)(osCp.regionTbl[region].regCb, ptr - 4, size + 4, file, line); +#else + ret = (osCp.regionTbl[region].free)(osCp.regionTbl[region].regCb, ptr - 4, size + 4); +#endif +#else +#ifndef T2K_MEM_LEAK_DBG + ret = (osCp.regionTbl[region].free)(osCp.regionTbl[region].regCb, ptr, size); +#else + ret = (osCp.regionTbl[region].free)(osCp.regionTbl[region].regCb, ptr, size, file, line); +#endif +#endif +#endif /* SS_HISTOGRAM_SUPPORT */ +/* ss037.103 Removed the semaphore operation for performance enhancement */ + +#ifndef SS_PERF + /* release the semaphore we took */ + +/* ss006.13: addition */ + if( SS_RELEASE_SEMA(&osCp.regionTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS228, ERRZERO, + "Could not release semaphore"); + RETVALUE(RFAILED); +#endif + } +#endif +/* ss036.103 - addition to handle double free and trampling return values +* This might invoke SRegMemErrHdlr +*/ +#ifdef SSI_DEBUG_LEVEL1 + /* handle the double free error here by calling the OS specific error handling function */ + if ((ret == RDBLFREE) || (ret == RTRAMPLINGNOK)) + { + SRegMemErrHdlr( region, ptr, ret); + } +#endif /* SSI_DEBUG_LEVEL1 */ + + RETVALUE(ret); +} + + +/* +* +* Fun: SInitMsg +* +* Desc: This function deallocates a message back and then +* reinitializes the message. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: all data attached to message is returned to memory. +* message is set to empty. message is not returned to +* memory. return is ok. +* +* File: ss_msg.c +* +*/ + +#ifdef ANSI +PUBLIC S16 SInitMsg +( +Buffer *mBuf +) +#else +PUBLIC S16 SInitMsg(mBuf) +Buffer *mBuf; +#endif +{ + SsMsgInfo *minfo; + Buffer *tmp; + U8 tmpRegId; + + TRC1(SInitMsg) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check message buffer */ + if (mBuf == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS062, ERRZERO, "SInitMsg: Null Buffer"); + RETVALUE(RFAILED); + } + if (mBuf->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS063, ERRZERO, "SInitMsg: Incorrect buffer\ + type"); + RETVALUE(RFAILED); + } +#endif + + /* get the message info */ +#ifdef YYYY +#else + CM_MEM_GET_REGION(tmpRegId); + if(tmpRegId == 0xFF) + { + RETVALUE(RFAILED); + } +#endif + minfo = (SsMsgInfo*) mBuf->b_rptr; + + /* free all SS_M_DATA blks */ + while ((tmp = mBuf->b_cont)) + { + mBuf->b_cont = tmp->b_cont; +/* #ifdef YYYY */ +#if 1 +#ifdef T2K_MEM_LEAK_DBG + char * file = __FILE__; + U32 line = __LINE__; +#endif + + (Void) SPutDBuf(tmpRegId, minfo->pool, tmp); +#else + (Void) SPutDBuf(minfo->region, minfo->pool, tmp); +#endif + } + /* initialise the length and endptr variables of mBuf */ + + minfo->len = 0; + minfo->endptr = NULLP; + minfo->next = NULLP; + + RETVALUE(ROK); +} + +/* ss016.301 - Added a new API - SAddPreMsgMultInOrder. This preserves the + * byte order while adding the data bytes to the beginning of the message. + */ +/* +* +* Fun: SAddPreMsgMultInOrder +* +* Desc: This function copies consecutive bytes of data to the +* beginning of a message and keeps the bytes order preserved. +* +* Ret: ROK - Appended the bytes to the beginning of the message. +* RFAILED - Failed to append the bytes. +* ROUTRES - Out of resources - Possibly insufficient memory. +* +* Notes: If the message is empty,data is placed in the message. Message +* length is incremented. Return is ROK. +* +* If the message is not empty,data is read by source pointer +* and appended at the beginning of the message. +* Message length is incremented. Return is ROK. +* +* File: ss_msg.c +* +*/ +#ifdef ANSI +PUBLIC S16 SAddPreMsgMultInOrder +( + Data *src, + MsgLen cnt, + Buffer *mBuf + ) +#else +PUBLIC S16 SAddPreMsgMultInOrder(src, cnt, mBuf) + Data *src; + MsgLen cnt; + Buffer *mBuf; +#endif +{ + SsMsgInfo *minfo; /* Message info */ + Buffer *tmp; + Buffer *curblk=NULLP; + Buffer *newblk; + Buffer *prevblk; + MsgLen numBytes; /* no. of bytes to be copied */ + MsgLen len; + MsgLen offset; + Data *rptr; + Data *revSrc; + TRC1(SAddPreMsgMultInOrder) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check message buffer */ + if (mBuf == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS070, ERRZERO, "SAddPreMsgMultInOrder:\ + Null Buffer"); + RETVALUE(RFAILED); + } + /* check source */ + if (src == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS071, ERRZERO, "SAddPreMsgMultInOrder:\ + Null Buffer"); + RETVALUE(RFAILED); + } + /* check count */ + if (cnt <= 0) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS072, ERRZERO, "SAddPreMsgMultInOrder:\ + Invalid count"); + RETVALUE(RFAILED); + } + if (mBuf->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS073, ERRZERO, "SAddPreMsgMultInOrder:\ + Incorrect buffer type"); + RETVALUE(RFAILED); + } +#endif + + /* get the SsMsgInfo of mBuf */ + minfo = (SsMsgInfo*) mBuf->b_rptr; +#ifdef RGL_SPECIFIC_CHANGES + minfo->region = 0; +#endif + + /* store cnt in length */ + len = cnt; + offset = 0; + revSrc = NULL; + + /* point to the end of the source buffer */ + revSrc = src + cnt ; + + if ((tmp = mBuf->b_cont) && (tmp->b_datap->db_ref == 1) && + (tmp->b_datap->db_base < tmp->b_rptr)) + { + /* store the offset of the read pointer of tmp */ + offset = tmp->b_rptr - tmp->b_datap->db_base; + + /* determine the number of bytes to copy */ + numBytes = MIN(cnt, offset); + + /* traverse back from the end of the source buffer*/ + revSrc -= numBytes; + + /* derement cnt */ + cnt -= numBytes; + + /* move the read pointer towards the left */ + tmp->b_rptr -= numBytes ; + SMemCpy((Void *)(tmp->b_rptr ), (Void *) revSrc, (size_t) numBytes); + + if (!cnt) + { + minfo->len += len; + RETVALUE(ROK); + } + } + newblk = prevblk = NULLP; + while (cnt) + { + /* allocate a message blk */ + if (SGetDBuf(minfo->region, minfo->pool, &curblk) != ROK) + { + while ((curblk = prevblk)) + { + prevblk = prevblk->b_cont; +#ifdef T2K_MEM_LEAK_DBG + char * file = __FILE__; + U32 line = __LINE__; +#endif + + (Void) SPutDBuf(minfo->region, minfo->pool, curblk); + } + + if (tmp) + { + tmp->b_rptr = tmp->b_datap->db_base + offset; + } + + RETVALUE(ROUTRES); + } + /* attach curblk in the newblk chain */ + if (prevblk) + { + curblk->b_cont = prevblk; /* stack them up */ + } + else + { + newblk = curblk; + } + prevblk = curblk; + + /* set the read and write pointers to the end of the data buffer */ + /* subsequent prepends have all the buffer to insert data into */ + curblk->b_wptr = curblk->b_datap->db_lim; + rptr = curblk->b_datap->db_lim; + + /* copy data */ + numBytes = MIN(cnt, (rptr - curblk->b_datap->db_base)); + + /* decrement cnt */ + cnt -= numBytes; + + /* move the read pointer towards the left */ + rptr -= numBytes; + + /* traverse back the source buffer */ + revSrc -= numBytes; + + SMemCpy((Void *)(rptr), (Void *) revSrc, (size_t) numBytes); + + curblk->b_rptr = rptr; + } + + /* attach the newblk chain into mBuf */ + newblk->b_cont = tmp; + mBuf->b_cont = curblk; + + /* update endptr of mBuf */ + if (!tmp) + { + minfo->endptr = newblk; + } + /* update length of message */ + minfo->len += len; + + RETVALUE(ROK); +} +/* +* +* Fun: SAddPreMsg +* +* Desc: This function copies one byte of data to the +* beginning of a message. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: if message is empty: data is placed in the message. message +* length is incremented. return is ok. +* +* if message is not empty: data is placed in front of all +* other data in message. message length is incremented. +* return is ok. +* +* File: ss_msg.c +* +*/ + + +#ifdef ANSI +PUBLIC S16 SAddPreMsg +( +Data data, +Buffer *mBuf +) +#else +PUBLIC S16 SAddPreMsg (data, mBuf) +Data data; +Buffer *mBuf; +#endif +{ + SsMsgInfo *minfo; + Buffer *tmp; + Buffer *newb; + + TRC1(SAddPreMsg) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check message buffer */ + if (!mBuf) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS064, ERRZERO, "SAddPreMsg: Null Buffer"); + RETVALUE(RFAILED); + } + if (mBuf->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS065, ERRZERO, "SAddPreMsg: Incorrect\ + buffer type"); + RETVALUE(RFAILED); + } +#endif + + minfo = (SsMsgInfo *) mBuf->b_rptr; + + /* ss021.103 - Addition to check if exceeding maximum message length */ +#ifdef LONG_MSG + if (minfo->len == 0x7FFFFFFF) +#else + if (minfo->len == 0x7FFF) +#endif + { + RETVALUE(ROUTRES); + } + + /* + * allocate a message blk using SGetDBuf(), if there are no data blks in the + * message, mBuf, or if the reference count of the first data blk is greater + * than 1, or if there is no space to append databytes in front of the read + * pointer of the first data blk + */ + if (!(tmp = mBuf->b_cont) || (tmp->b_datap->db_ref > 1) || + (tmp->b_rptr == tmp->b_datap->db_base)) + { + if (SGetDBuf(minfo->region, minfo->pool, &newb) != ROK) + { + SSLOGERROR(ERRCLS_DEBUG, ESS066, ERRZERO, "SAddPreMsg:Failed in\ + SGetDBuf"); + RETVALUE(ROUTRES); + } + /* set the read and write pointers to end of data buffer */ + /* subsequent prepends have all the buffer to insert data into */ + newb->b_wptr = newb->b_datap->db_lim; + newb->b_rptr = newb->b_datap->db_lim; + + /* insert newb before tmp */ + newb -> b_cont = tmp; + mBuf->b_cont = newb; + + /* if endptr of mBuf is NULLP, set it to newb */ + if (tmp == NULLP) + minfo->endptr = newb; + tmp = newb; + } + /* insert data, increment length */ + *--tmp->b_rptr = data; + minfo->len++; + + RETVALUE(ROK); +} + +/* +* +* Fun: SAddPstMsg +* +* Desc: This function copies one byte of data to the +* end of a message. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: if message is empty: data is placed in the message. message +* length is incremented. return is ok. +* +* if message is not empty: data is placed in back of all +* other data in message. message length is incremented. +* return is ok. +* +* File: ss_msg.c +* +*/ + + +#ifdef ANSI +PUBLIC S16 SAddPstMsg +( +Data data, +Buffer *mBuf +) +#else +PUBLIC S16 SAddPstMsg (data, mBuf) +Data data; +Buffer *mBuf; +#endif +{ + SsMsgInfo *minfo; + Buffer *tmp; + Buffer *newb; + + TRC1(SAddPstMsg) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check message buffer */ + if (!mBuf) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS067, ERRZERO, "SAddPstMsg: Null Buffer"); + RETVALUE(RFAILED); + } + if (mBuf->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS068, ERRZERO, "SAddPstMsg: Incorrect\ + buffer type"); + RETVALUE(RFAILED); + } +#endif + + /* get the message info */ + minfo = (SsMsgInfo *) mBuf->b_rptr; + + if (!(tmp = minfo->endptr) || (tmp->b_datap->db_ref > 1) || + (tmp->b_wptr == tmp->b_datap->db_lim)) + { + if (SGetDBuf(minfo->region, minfo->pool, &newb) != ROK) + { + SSLOGERROR(ERRCLS_DEBUG, ESS069, ERRZERO, "SAddPstMsg: Failed in\ + SGetDBuf()"); + RETVALUE(ROUTRES); + } + + /* append newb to the end of the mBuf chain */ + if (tmp) + tmp->b_cont = newb; + else + mBuf->b_cont = newb; + + /* set the endptr of mBuf to newb */ + minfo->endptr = newb; + + tmp = newb; + } + /* insert data, increment length */ + *tmp->b_wptr++ = data; + minfo->len++; + + RETVALUE(ROK); +} + +/* +* +* Fun: SAddPreMsgMult +* +* Desc: This function copies consecutive bytes of data to the +* beginning of a message. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: if message is empty: data is placed in the message. message +* length is incremented. return is ok. +* +* if message is not empty: data is read by source pointer, +* data is placed in front of all other data in message. +* message length is incremented. return is ok. +* +* the first byte of data pointed to by the source pointer will +* be placed at the front of the message first, the last byte of +* data pointed to by the source pointer will be placed at the +* front of the message last (i.e. it will become the first +* byte of the message). +* +* File: ss_msg.c +* +*/ + +#ifdef T2K_MEM_LEAK_DBG +PUBLIC S16 SAddPreMsgMult1 +( +Data *src, +MsgLen cnt, +Buffer *mBuf, +char *file, +U32 line +) + +#else +#ifdef ANSI +PUBLIC S16 SAddPreMsgMult +( +Data *src, +MsgLen cnt, +Buffer *mBuf +) +#else +PUBLIC S16 SAddPreMsgMult(src, cnt, mBuf) +Data *src; +MsgLen cnt; +Buffer *mBuf; +#endif +#endif +{ + SsMsgInfo *minfo; /* Message info */ + Buffer *tmp; + Buffer *curblk=NULLP; + Buffer *newblk; + Buffer *prevblk; + MsgLen numBytes; /* no. of bytes to be copied */ + MsgLen len; + MsgLen offset; + Data *rptr; + + TRC1(SAddPreMsgMult) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check message buffer */ + if (mBuf == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS070, ERRZERO, "SAddPreMsgMult:Null Buffer"); + RETVALUE(RFAILED); + } + /* check source */ + if (src == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS071, ERRZERO, "SAddPreMsgMult:Null Buffer"); + RETVALUE(RFAILED); + } + /* check count */ + if (cnt <= 0) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS072, ERRZERO, "SAddPreMsgMult: Invalid\ + count"); + RETVALUE(RFAILED); + } + if (mBuf->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS073, ERRZERO, "SAddPreMsgMult: Incorrect\ + buffer type"); + RETVALUE(RFAILED); + } +#endif + + /* get the SsMsgInfo of mBuf */ + minfo = (SsMsgInfo*) mBuf->b_rptr; + + /* store cnt in length */ + len = cnt; +/* ss014.13: Addition */ + offset = 0; + + if ((tmp = mBuf->b_cont) && (tmp->b_datap->db_ref == 1) && + (tmp->b_datap->db_base < tmp->b_rptr)) + { + /* store the offset of the read pointer of tmp */ + offset = tmp->b_rptr - tmp->b_datap->db_base; + + /* determine the number of bytes to copy */ + numBytes = MIN(cnt, offset); + + /* decrement cnt */ + cnt -= numBytes; + + /* copy data */ + while (numBytes--) + *--tmp->b_rptr = *src++; + if (!cnt) + { + minfo->len += len; + RETVALUE(ROK); + } + } + newblk = prevblk = NULLP; + while (cnt) + { + /* allocate a message blk */ + if (SGetDBuf(minfo->region, minfo->pool, &curblk) != ROK) + { + while ((curblk = prevblk)) + { + prevblk = prevblk->b_cont; + (Void) SPutDBuf(minfo->region, minfo->pool, curblk); + } + + if (tmp) + { + tmp->b_rptr = tmp->b_datap->db_base + offset; + } + + RETVALUE(ROUTRES); + } + /* attach curblk in the newblk chain */ + if (prevblk) + curblk->b_cont = prevblk; /* stack them up */ + else + newblk = curblk; + prevblk = curblk; + + /* set the read and write pointers to the end of the data buffer */ + /* subsequent prepends have all the buffer to insert data into */ + curblk->b_wptr = curblk->b_datap->db_lim; + rptr = curblk->b_datap->db_lim; + + /* copy data */ + numBytes = MIN(cnt, (rptr - curblk->b_datap->db_base)); + + /* decrement cnt */ + cnt -= numBytes; + + while (numBytes--) + *--rptr = *src++; + curblk->b_rptr = rptr; + } + + /* attach the newblk chain into mBuf */ + newblk -> b_cont = tmp; + mBuf -> b_cont = curblk; + + /* update endptr of mBuf */ + if (!tmp) + minfo -> endptr = newblk; + + /* update length of message */ + minfo->len += len; + + RETVALUE(ROK); +} + +/* +* +* Fun: SAddPstMsgMult +* +* Desc: This function copies consecutive bytes of data to the +* end of a message. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: if message is empty: data is placed in the message. message +* length is incremented. return is ok. +* +* if message is not empty: data is read by source pointer, +* data is placed in back of all other data in message. +* message length is incremented. return is ok. +* +* the first byte of data pointed to by the source pointer will +* be placed at the back of the message first, the last byte of +* data pointed to by the source pointer will be placed at the +* back of the message last (i.e. it will become the last +* byte of the message). +* +* File: ss_msg.c +* +*/ + +#ifdef T2K_MEM_LEAK_DBG +PUBLIC S16 SAddPstMsgMult1 +( +Data *src, +MsgLen cnt, +Buffer *mBuf, +char *file, +U32 line +) +#else +#ifdef ANSI +PUBLIC S16 SAddPstMsgMult +( +Data *src, +MsgLen cnt, +Buffer *mBuf +) +#else +PUBLIC S16 SAddPstMsgMult(src, cnt, mBuf) +Data *src; +MsgLen cnt; +Buffer *mBuf; +#endif +#endif +{ + SsMsgInfo *minfo; + Buffer *tmp; + Buffer *newblk; + Buffer *curblk=NULLP; + Buffer *prevblk; + MsgLen len; + MsgLen offset; + MsgLen numBytes; + Data *wptr; + + TRC1(SAddPstMsgMult) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check message buffer */ + if (mBuf == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS074, ERRZERO, "SAddPstMsgMult:Null Buffer"); + RETVALUE(RFAILED); + } + /* check source */ + if (src == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS075, ERRZERO, "SAddPstMsgMult:Null Buffer"); + RETVALUE(RFAILED); + } + /* check count */ + if (cnt <= 0) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS076, ERRZERO, "SAddPstMsgMult:Invalid\ + count"); + RETVALUE(RFAILED); + } + if (mBuf->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS077, ERRZERO, "SAddPstMsgMult: Incorrect\ + buffer type"); + RETVALUE(RFAILED); + } +#endif + + /* get the SsMsgInfo of mBuf */ + minfo = (SsMsgInfo*) mBuf->b_rptr; + + /* store cnt in len */ + len = cnt; + +/* ss014.13: Addition */ + offset = 0; + + if ((tmp = minfo->endptr) && (tmp->b_datap->db_ref == 1) && + (tmp->b_datap->db_lim > tmp->b_wptr)) + { + /* store offset of the write pointer */ + /* incase subsequent allocations fail, offset is read reset to original */ + offset = tmp->b_datap->db_lim - tmp->b_wptr; + + /* determine the number of bytes to copy */ + numBytes = MIN(cnt, offset); + + /* decrement cnt */ + cnt -= numBytes; + + +/* ss002.13: addition */ + + /* ss004.13: addition */ + SMemCpy((Void *) tmp->b_wptr, (Void *) src, (size_t) numBytes); + + tmp->b_wptr += numBytes; + src += numBytes; + + if (!cnt) + { + minfo->len += len; + RETVALUE(ROK); + } + } + + newblk = prevblk = NULLP; + + while (cnt) + { + /* allocate a message blk */ + if (SGetDBuf(minfo->region, minfo->pool, &curblk) != ROK) + { + while ((curblk = newblk)) + { + newblk = newblk->b_cont; + (Void) SPutDBuf(minfo->region, minfo->pool, curblk); + } + + if (tmp) + { + tmp->b_wptr = tmp->b_datap->db_lim - offset; + } + + RETVALUE(ROUTRES); + } + + /* insert curblk in the newblk chain */ + if (prevblk) + prevblk->b_cont = curblk; /* stack them down */ + else + newblk = curblk; + prevblk = curblk; + + /* copy data */ + wptr = curblk->b_wptr; + numBytes = MIN(cnt, curblk->b_datap->db_lim - wptr); + + /* decrement cnt */ + cnt -= numBytes; + + +/* ss002.13: addition */ +/* ss003.13: addition */ + SMemCpy( (Void *) wptr, (Void *) src, (size_t) numBytes); + + src = src + numBytes; + + curblk->b_wptr += numBytes; + } + /* insert newblk chain into mBuf */ + if (tmp) + tmp->b_cont = newblk; + else + mBuf->b_cont = newblk; + minfo->endptr = curblk; + + /* update length */ + minfo->len += len; + + RETVALUE(ROK); +} + +/* #ifdef SS_LOCKLESS_MEMORY */ + + + +/* +* +* Fun: SRemPreMsg +* +* Desc: This function copies and then removes one byte of +* data from the beginning of a message. +* +* Ret: ROK - ok +* ROKDNA - ok, data not available +* RFAILED - failed, general (optional) +* +* Notes: if message is empty: message is unchanged. return is ok, +* data not available. +* +* if message is not empty: data is removed from front of +* message, data is returned via pointer to data. message +* length is decremented. return is ok. +* +* File: ss_msg.c +* +*/ + + +#ifdef ANSI +PUBLIC S16 SRemPreMsg +( +Data *dataPtr, +Buffer *mBuf +) +#else +PUBLIC S16 SRemPreMsg(dataPtr, mBuf) +Data *dataPtr; +Buffer *mBuf; +#endif +{ + SsMsgInfo *minfo; + Buffer *tmp; +#ifdef T2K_MEM_LEAK_DBG + char* file = __FILE__; + U32 line = __LINE__; +#endif + + TRC1(SRemPreMsg) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check data pointer */ + if (!dataPtr) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS078, ERRZERO, "SRemPreMsg : Null Buffer"); + RETVALUE(RFAILED); + } + /* check message buffer */ + if (!mBuf) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS079, ERRZERO, "SRemPreMsg : Null Buffer"); + RETVALUE(RFAILED); + } + if (mBuf->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS080, ERRZERO, "SRemPreMsg : Incorrect\ + buffer type"); + RETVALUE(RFAILED); + } +#endif + + if (!(tmp = mBuf->b_cont)) + RETVALUE(ROKDNA); + + /* get SsMsgInfo of mBuf */ + minfo = (SsMsgInfo *) mBuf->b_rptr; + + /* read databyte into dataPtr and incrment read ptr */ + *dataPtr = *tmp->b_rptr++; + + /* if all data is exhausted, release the blk */ + if (tmp->b_rptr == tmp->b_wptr) + { + mBuf->b_cont = tmp->b_cont; + (Void) SPutDBuf(minfo->region, minfo->pool, tmp); + } + /* update SsMsgInfo */ + if (!--minfo->len) + minfo->endptr = NULLP; + + RETVALUE(ROK); +} + +/* +* +* Fun: SRemPstMsg +* +* Desc: This function copies and then removes one byte of +* data from the end of a message. +* +* Ret: ROK - ok +* ROKDNA - ok, data not available +* RFAILED - failed, general (optional) +* +* Notes: if message is empty: message is unchanged. return is ok, +* data not available. +* +* if message is not empty: data is removed from back of +* message, data is returned via pointer to data. message +* length is decremented. return is ok. +* +* File: ss_msg.c +* +*/ + + +#ifdef ANSI +PUBLIC S16 SRemPstMsg +( +Data *dataPtr, /* pointer to data */ +Buffer *mBuf +) +#else +PUBLIC S16 SRemPstMsg(dataPtr, mBuf) +Data *dataPtr; /* pointer to data */ +Buffer *mBuf; /* message buffer */ +#endif +{ + SsMsgInfo *minfo; + Buffer *tmp; + Buffer *last; +#ifdef T2K_MEM_LEAK_DBG + char* file = __FILE__; + U32 line = __LINE__; +#endif + + TRC1(SRemPstMsg) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check data pointer */ + if (dataPtr == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS081, ERRZERO, "SRemPstMsg : Null Buffer"); + RETVALUE(RFAILED); + } + /* check message buffer */ + if (mBuf == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS082, ERRZERO, "SRemPstMsg : Null Buffer"); + RETVALUE(RFAILED); + } + if (mBuf->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS083, ERRZERO, "SRemPstMsg : Incorrect\ + buffer type"); + RETVALUE(RFAILED); + } +#endif + + /* get the SsMsgInfo */ + minfo = (SsMsgInfo*) mBuf->b_rptr; + + if (!(last = minfo->endptr)) + RETVALUE(ROKDNA); + + /* read databyte into dataPtr and decrement write ptr */ + *dataPtr = *--last->b_wptr; + + /* if all data is exhausted, release the blk */ + if (last->b_rptr == last->b_wptr) + { + for (tmp = mBuf; tmp->b_cont != last;) + tmp = tmp->b_cont; + tmp->b_cont = NULLP; + (Void) SPutDBuf(minfo->region, minfo->pool, last); + + /* update endptr */ + if (mBuf->b_cont) + minfo->endptr = tmp; + else + minfo->endptr = NULLP; + } + /* update SsMsgInfo */ + minfo->len--; + + RETVALUE(ROK); +} + + +/* +* +* Fun: SRemPreMsgMult +* +* Desc: This function copies and then removes consecutive bytes of +* data from the beginning of a message. +* +* Ret: ROK - ok +* ROKDNA - ok, data not available +* RFAILED - failed, general (optional) +* +* Notes: if message is empty: message is unchanged. return is ok, +* data not available. +* +* if the destination buffer is NULL, data is not copied. +* +* if message is not empty: data is removed from front of +* message, data is returned by destination pointer. message +* length is decremented. return is ok. +* +* the first byte of data read from the message will be placed +* in the destination buffer first (i.e. this was the first byte +* of the message), the last byte of data read from the message +* will be placed in the destination buffer last. +* +* File: ss_msg.c +* +*/ + +#ifdef ANSI +PUBLIC S16 SRemPreMsgMult +( +Data *dst, /* destination */ +MsgLen cnt, /* count */ +Buffer *mBuf +) +#else +PUBLIC S16 SRemPreMsgMult(dst, cnt, mBuf) +Data *dst; /* destination */ +MsgLen cnt; /* count */ +Buffer *mBuf; /* message buffer */ +#endif +{ + SsMsgInfo *minfo; + Buffer *tmp; + MsgLen numBytes; +#ifdef T2K_MEM_LEAK_DBG + char* file = __FILE__; + U32 line = __LINE__; +#endif + + TRC1(SRemPreMsgMult) + + /* ss023.103 - Modification of SRemPreMsgMult for bug fix */ + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check count */ + if (cnt <= 0) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS084, ERRZERO, "SRemPreMsgMult:Invalid\ + count"); + RETVALUE(RFAILED); + } + /* check message buffer */ + if (!mBuf) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS085, ERRZERO, "SRemPreMsgMult:Null Buffer"); + RETVALUE(RFAILED); + } + /* ss021.103 - Addition to check for NULL pointer */ + /* check data pointer */ + /* ss022.103 - Removed check for NULL pointer */ + if (mBuf->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS086, ERRZERO, "SRemPreMsgMult : Incorrect\ + buffer type"); + RETVALUE(RFAILED); + } +#endif + + /* get the SsMsgInfo */ + minfo = (SsMsgInfo*) mBuf->b_rptr; + + /* check if data present */ + if (minfo->len < cnt) + RETVALUE(ROKDNA); + else + minfo->len -= cnt; + + while (cnt) + { + /* get the first SS_M_DATA blk */ + tmp = mBuf->b_cont; + + /* determine the number of bytes to be copy */ + numBytes = MIN(cnt, tmp->b_wptr - tmp->b_rptr); + + /* decrement cnt */ + cnt -= numBytes; + + /* move data into dst */ + if (dst != NULLP) + { + + SMemCpy( (Void *) dst, (Void *) tmp->b_rptr, (size_t) numBytes); + dst += numBytes; + } + + tmp->b_rptr += numBytes; + + if (tmp->b_rptr == tmp->b_wptr) + { + mBuf->b_cont = tmp->b_cont; + (Void) SPutDBuf(minfo->region, minfo->pool, tmp); + } + } + /* update SsMsgInfo */ + if (!minfo->len) + minfo->endptr = NULLP; + + RETVALUE(ROK); +} + +/* +* +* Fun: SRemPstMsgMult +* +* Desc: This function copies and then removes consecutive bytes of +* data from the end of a message. +* +* Ret: ROK - ok +* ROKDNA - ok, data not available +* RFAILED - failed, general (optional) +* +* Notes: if message is empty: message is unchanged. return is ok, +* data not available. +* +* if the destination buffer is NULL, data is not copied. +* +* if message is not empty: data is removed from front of +* message, data is returned by destination pointer. message +* length is decremented. return is ok. +* +* the first byte of data read from the message will be placed +* in the destination buffer first (i.e. this was the last byte +* of the message), the last byte of data read from the message +* will be placed in the destination buffer last. +* +* File: ss_msg.c +* +*/ + +#ifdef ANSI +PUBLIC S16 SRemPstMsgMult +( +Data *dst, /* destination */ +MsgLen cnt, /* count */ +Buffer *mBuf +) +#else +PUBLIC S16 SRemPstMsgMult(dst, cnt, mBuf) +Data *dst; /* destination */ +MsgLen cnt; /* count */ +Buffer *mBuf; /* message buffer */ +#endif +{ + SsMsgInfo *minfo; + Buffer *tmp; + Buffer *prev; + MsgLen count; + MsgLen numBytes; + Data *cptr; +#ifdef T2K_MEM_LEAK_DBG + char* file = __FILE__; + U32 line = __LINE__; +#endif + + TRC1(SRemPstMsgMult) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check count */ + if (cnt <= 0) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS087, ERRZERO, "SRemPstMsgMult:Invalid\ + count"); + RETVALUE(RFAILED); + } + /* check message buffer */ + if (mBuf == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS088, ERRZERO, "SRemPstMsgMult:Null Buffer"); + RETVALUE(RFAILED); + } + if (mBuf->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS089, ERRZERO, "SRemPstMsgMult : Incorrect\ + buffer type"); + RETVALUE(RFAILED); + } + /* ss021.103 - Addition to check dst data pointer */ + /* check data pointer */ + /* ss022.103 - Removed check for NULL destination pointer */ +#endif + + /* get the SsMsgInfo */ + minfo = (SsMsgInfo*) mBuf->b_rptr; + + /* check if data present */ + if (minfo->len < cnt) + RETVALUE(ROKDNA); + else + { + minfo->len -= cnt; + count = minfo->len; + prev = mBuf; + tmp = mBuf->b_cont; + } + + /* determine blk containing offset, and prev node */ + FIND_OFFSET_AND_PREV(prev, tmp, count) + + if (dst != NULLP) + dst += cnt; + + while (cnt) + { + numBytes = MIN(cnt, (tmp->b_wptr - tmp->b_rptr - count)); + + tmp->b_wptr -= numBytes; + + cnt -= numBytes; + + /* copy data */ + cptr = tmp->b_wptr; + if (dst != NULLP) + { + while (numBytes--) + *--dst = *cptr++; + } + + if (tmp->b_rptr == tmp->b_wptr) + { + prev->b_cont = tmp->b_cont; + (Void) SPutDBuf(minfo->region, minfo->pool, tmp); + tmp = prev; + } + prev = tmp; + tmp = tmp->b_cont; + + count = 0; + } + if (mBuf == prev) + minfo->endptr = NULLP; + else + minfo->endptr = prev; + + RETVALUE(ROK); +} + +/* +* +* Fun: SExamMsg +* +* Desc: This function copies one byte of data from a message +* without modifying the message. +* +* Ret: ROK - ok +* ROKDNA - ok, data not available +* RFAILED - failed, general (optional) +* +* Notes: index is 0 based and indicates location in message +* +* if index is less than the length of the message: +* message is unchanged and data is examined at specified +* index and returned via pointer to data. message length +* is unchanged. return is ok. +* +* if index is greater than or equal to +* the length of the message: message is unchanged and 0 +* is returned via pointer to data. return is ok, data +* not available. +* +* File: ss_msg.c +* +*/ + + +#ifdef ANSI +PUBLIC S16 SExamMsg +( +Data *dataPtr, /* pointer to data */ +Buffer *mBuf, /* message buffer */ +MsgLen idx +) +#else +PUBLIC S16 SExamMsg(dataPtr, mBuf, idx) +Data *dataPtr; /* pointer to data */ +Buffer *mBuf; /* message buffer */ +MsgLen idx; /* index */ +#endif +{ + SsMsgInfo *minfo; + Buffer *tmp; + + TRC1(SExamMsg) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check data pointer */ + if (!dataPtr) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS090, ERRZERO, "SExamMsg : Null Buffer"); + RETVALUE(RFAILED); + } + /* check message buffer */ + if (!mBuf) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS091, ERRZERO, "SExamMsg : Null Buffer"); + RETVALUE(RFAILED); + } + /* check index */ + if (idx < 0) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS092, ERRZERO, "SExamMsg : Invalid Index"); + RETVALUE(RFAILED); + } + if (mBuf->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS093, ERRZERO, "SExamMsg : Incorrect buffer\ + type"); + RETVALUE(RFAILED); + } +#endif + + /* get the SsMsgInfo */ + minfo = (SsMsgInfo*) mBuf->b_rptr; + + if (minfo->len <= idx) + { + RETVALUE(ROKDNA); + } + + /* get the first SS_M_DATA blk */ + tmp = mBuf->b_cont; + + /* determine offset */ + FIND_OFFSET(tmp, idx) + + *dataPtr = *(tmp->b_rptr + idx); + + RETVALUE(ROK); +} + + +/* s002.301 */ +/* +* +* Fun: SGetDataFrmMsg +* +* Desc: This function copies requested byte of data from a message +* without modifying the message. +* +* Ret: ROK - ok +* ROKDNA - ok, data not available +* RFAILED - failed, general (optional) +* +* Notes: index is 0 based and indicates location in message +* +* if index is less than the length of the message: +* message is unchanged and data is examined at specified +* index and returned via pointer to data. message length +* is unchanged. return is ok. +* +* if index is greater than or equal to +* the length of the message: message is unchanged and 0 +* is returned via pointer to data. return is ok, data +* not available. +* +* File: sm_msg.c +* +*/ + + +#ifdef ANSI +PUBLIC S16 SGetDataFrmMsg +( +Buffer *mBuf, /* message buffer */ +Data *dataPtr, /* pointer to data */ +MsgLen idx, +MsgLen dataLen +) +#else +PUBLIC S16 SGetDataFrmMsg(mBuf, dataPtr, idx, dataLen) +Buffer *mBuf; /* message buffer */ +Data *dataPtr; /* pointer to data */ +MsgLen idx; /* index */ +MsgLen dataLen; +#endif +{ + SsMsgInfo *minfo; + Buffer *tmp; + MsgLen offSetLen; + Data *tmpDataPtr = dataPtr; + + TRC1(SGetDataFrmMsg) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check data pointer */ + if (!dataPtr) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS090, ERRZERO, "SGetDataFrmMsg: Null Buffer"); + RETVALUE(RFAILED); + } + /* check message buffer */ + if (!mBuf) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS091, ERRZERO, "SGetDataFrmMsg: Null Buffer"); + RETVALUE(RFAILED); + } + /* check index */ + if (idx < 0) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS092, ERRZERO, "SGetDataFrmMsg: Invalid Index"); + RETVALUE(RFAILED); + } + if (mBuf->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS093, ERRZERO, "SGetDataFrmMsg: Incorrect buffer\ + type"); + RETVALUE(RFAILED); + } +#endif + + /* get the SsMsgInfo */ + minfo = (SsMsgInfo*) mBuf->b_rptr; + + if (minfo->len <= (idx + dataLen) ) + { + RETVALUE(ROKDNA); + } + + /* get the first SS_M_DATA blk */ + tmp = mBuf->b_cont; + + /* determine offset */ + if(tmp == NULLP) + { + RETVALUE(ROKDNA); + } + else + { + FIND_OFFSET(tmp, idx) + offSetLen = ((tmp->b_wptr - (tmp->b_rptr + idx))); + + for(;(offSetLen < dataLen && tmp != NULLP);) + { + SMemCpy((Void *)tmpDataPtr, (Void *)(tmp->b_rptr + idx), (size_t)offSetLen); + dataLen = dataLen - offSetLen; + tmp = tmp->b_cont; + idx = 0; + tmpDataPtr = tmpDataPtr + offSetLen; + offSetLen = tmp->b_wptr - tmp->b_rptr; + } + if( tmp == NULLP ) + { + RETVALUE(ROKDNA); + } + SMemCpy((Void *)tmpDataPtr, (Void *)(tmp->b_rptr + idx), (size_t)dataLen); + } + + RETVALUE(ROK); +} /* End of SGetDataFrmMsg() */ + +/* +* +* Fun: SFndLenMsg +* +* Desc: This function determines the length of data within +* a message. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: length of message is determined, message is unchanged +* and length is returned via pointer to length. return is ok. +* +* File: ss_msg.c +* +*/ + + +#ifdef ANSI +PUBLIC S16 SFndLenMsg +( +REG1 Buffer *mBuf, /* message buffer */ +MsgLen *lngPtr +) +#else +PUBLIC S16 SFndLenMsg(mBuf, lngPtr) +REG1 Buffer *mBuf; /* message buffer */ +MsgLen *lngPtr; /* pointer to length */ +#endif +{ + SsMsgInfo *minfo; + + TRC1(SFndLenMsg) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check message buffer */ + if (mBuf == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS094, ERRZERO, "SFndLenMsg : Null Buffer"); + RETVALUE(RFAILED); + } + /* check length pointer */ + if (lngPtr == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS095, ERRZERO, "SFndLenMsg : Null Buffer"); + RETVALUE(RFAILED); + } + if (mBuf->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS096, ERRZERO, "SFndLenMsg : Incorrect\ + buffer type"); + RETVALUE(RFAILED); + } +#endif + + /* get the SsMsgInfo */ + minfo = (SsMsgInfo*) mBuf->b_rptr; + + /* read length */ + *lngPtr = minfo->len; + + RETVALUE(ROK); +} + + +/* #ifdef SS_LOCKLESS_MEMORY */ + +/* +* +* Fun: SSegMsg +* +* Desc: This function will segment one specified message into two +* messages. +* +* Ret: ROK - ok +* ROKDNA - ok, data not available +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: message 1 is the original message. +* +* message 2 is the new message. +* +* index is 0 based and indicates location in message 1 +* from which message 2 will be created. +* +* if index is equal to 0: message 2 is created and all data +* attached to message 1 is moved to message 2. message 1 +* is not returned to memory. return is ok. +* +* if index is not equal to 0 and less than the length of +* the message minus 1: message 2 is created, all data +* attached to message 1 from index (inclusive) is moved to +* message 2. message 1 contains data from index 0 to index +* minus 1. return is ok. +* +* if index is not equal to 0 and greater than or equal to +* the length of the message minus 1: message 1 is unchanged. +* message 2 is set to null. return is ok, data not available. +* +* File: ss_msg.c +* +*/ +#ifdef T2K_MEM_LEAK_DBG +PUBLIC S16 SSegMsgNew +( +Buffer *mBuf1, /* message 1 */ +MsgLen idx, /* index */ +Buffer **mBuf2, +char* file, +U32 line +) +#else +#ifdef ANSI +PUBLIC S16 SSegMsg +( +Buffer *mBuf1, /* message 1 */ +MsgLen idx, /* index */ +Buffer **mBuf2 +) +#else +PUBLIC S16 SSegMsg(mBuf1, idx, mBuf2) +Buffer *mBuf1; /* message 1 */ +MsgLen idx; /* index */ +Buffer **mBuf2; /* message 2 */ +#endif +#endif +{ + SsMsgInfo *minfo1; + SsMsgInfo *minfo2; + Buffer *tmp; + Buffer *prev; + Buffer *next; + + TRC1(SSegMsg) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check message buffer 1 */ + if (mBuf1 == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS097, ERRZERO, "SSegMsg : Null Buffer"); + RETVALUE(RFAILED); + } + /* check message buffer 2 */ + if (mBuf2 == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS098, ERRZERO, "SSegMsg : Null Buffer"); + RETVALUE(RFAILED); + } + if (idx < 0) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS099, ERRZERO, "SSegMsg : Invalid index"); + RETVALUE(RFAILED); + } + if (mBuf1->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS100, ERRZERO, "SSegMsg : Incorrect buffer\ + type"); + RETVALUE(RFAILED); + } +#endif + + /* get the SsMsgInfo of mBuf1 */ + minfo1 = (SsMsgInfo*) mBuf1->b_rptr; +#ifdef RGL_SPECIFIC_CHANGES + minfo1->region = 0; +#endif + + /* if index > length of mBuf, return */ + if (idx >= minfo1->len) + { + *mBuf2 = NULLP; + RETVALUE(ROKDNA); + } + /* allocate message buffer */ + if (SGetMsg(minfo1->region, minfo1->pool, mBuf2) != ROK) + { + SSLOGERROR(ERRCLS_DEBUG, ESS101, ERRZERO, "SSegMsg : SGetMsg failed"); + RETVALUE(RFAILED); + } + + /* get the SsMsgInfo of mBuf2 */ + minfo2 = (SsMsgInfo*) (*mBuf2)->b_rptr; + + /* adjust the lengths of mBuf1, mBuf2 */ + minfo2->len = minfo1->len - idx; + minfo1->len = idx; + + /* set the endptr of mBuf2 to mBuf1 */ + minfo2->endptr = minfo1->endptr; + + /* if index is zero ... */ + if (!idx) + { + (*mBuf2)->b_cont = mBuf1->b_cont; + + /* set the endptr and b_cont of mBuf1 to NULLP */ + minfo1->endptr = NULLP; + mBuf1->b_cont = NULLP; + + RETVALUE(ROK); + } + + /* get the first SS_M_DATA blk */ + tmp = mBuf1->b_cont; + prev = mBuf1; + + FIND_OFFSET_AND_PREV(prev, tmp, idx) + + /* segmented at the start of a blk */ + if (!idx) + { + (*mBuf2)->b_cont = tmp; + prev->b_cont = NULLP; + minfo1->endptr = prev; + } + else + { +#ifndef SS_MULTICORE_SUPPORT + /* allocate a message blk without a data blk */ + /* ssDupB internally increments the reference count */ +#ifdef SS_M_PROTO_REGION + if (!(next = DupMsg(minfo1->region, tmp))) +#else + if (!(next = ssDupB(tmp))) +#endif /* SS_M_PROTO_REGION */ + { + /* reset length */ + minfo1->len += minfo2->len; + (Void) SPutMsg(*mBuf2); + RETVALUE(ROUTRES); + } + + (*mBuf2)->b_cont = next; + + tmp->b_cont = NULLP; + + tmp->b_wptr = tmp->b_rptr + idx; + next->b_rptr = tmp->b_wptr; + + /* If the index was in the last mblk of the message, the + * end pointer of the new message needs to be set to the + * dup'ped mblk. Otherwise, the end pointer of the first + * message will be set to the mblk in which the index + * was found, and the end pointer of the new message can + * remain where it is. + */ + if (minfo1->endptr == tmp) + { + minfo2->endptr = next; + } + else + { + minfo1->endptr = tmp; + } +#else /*SS_MULTICORE_SUPPORT*/ +/* + * SDeRegTTsk patch + */ +#ifdef SS_M_PROTO_REGION + if (!(next = DupMsg(minfo1->region, tmp))) +#else + if (!(next = ssDupB(tmp))) +#endif /* SS_M_PROTO_REGION */ + { + /* reset length */ + minfo1->len += minfo2->len; + (Void) SPutMsg(*mBuf2); + RETVALUE(ROUTRES); + } + (*mBuf2)->b_cont = next; + tmp->b_wptr = tmp->b_rptr + idx; + next->b_rptr += idx; + prev = tmp; + tmp = tmp->b_cont; + /* copy rest of the blocks */ + if(tmp) + { + next->b_cont = tmp; + prev->b_cont = NULLP; + minfo2->endptr = minfo1->endptr; + minfo1->endptr = prev; + } + else + { + next->b_cont = NULLP; + minfo2->endptr = next; + } + +#endif /*SS_MULTICORE_SUPPORT*/ + } + + RETVALUE(ROK); +} + +/* +* +* Fun: SCpyFixMsg +* +* Desc: This function copies data from a fixed buffer to a +* message. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: None +* +* File: ss_msg.c +* +*/ + +#ifdef ANSI +PUBLIC S16 SCpyFixMsg +( +Data *srcBuf, /* source buffer */ +Buffer *dstMbuf, /* destination message buffer */ +MsgLen dstIdx, /* destination index */ +MsgLen cnt, /* count */ +MsgLen *cCnt +) +#else +PUBLIC S16 SCpyFixMsg(srcBuf, dstMbuf, dstIdx, cnt, cCnt) +Data *srcBuf; /* source buffer */ +Buffer *dstMbuf; /* destination message buffer */ +MsgLen dstIdx; /* destination index */ +MsgLen cnt; /* count */ +MsgLen *cCnt; /* copied count */ +#endif +{ + S16 ret; + SsMsgInfo *minfo; + Buffer *right; + + TRC1(SCpyFixMsg) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check source message buffer */ + if (srcBuf == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS102, ERRZERO, "SCpyFixMsg : Null Buffer"); + RETVALUE(RFAILED); + } + /* check destination message buffer */ + if (dstMbuf == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS103, ERRZERO, "SCpyFixMsg : Null Buffer"); + RETVALUE(RFAILED); + } + /* check copied count buffer */ + if (cCnt == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS104, ERRZERO, "SCpyFixMsg : Null Buffer"); + RETVALUE(RFAILED); + } + /* check copy count */ + if (cnt <= 0) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS105, ERRZERO, "SCpyFixMsg : Invalid count"); + RETVALUE(RFAILED); + } + if (dstMbuf->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS106, ERRZERO, "SCpyFixMsg : Incorrect\ + buffer type"); + RETVALUE(RFAILED); + } +#endif + + minfo = (SsMsgInfo*) dstMbuf->b_rptr; + + if (minfo->len < dstIdx) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS107, ERRZERO, "SCpyFixMsg : Invalid Index"); +#endif + RETVALUE(RFAILED); + } + +/* ss021.103 - Addition test if message length will exceed max msg length */ +#if (ERRCLASS & ERRCLS_INT_PAR) +#ifdef LONG_MSG + if (minfo->len > 0x7FFFFFFF - cnt) +#else + if (minfo->len > 0x7FFF - cnt) +#endif + { + *cCnt = 0; + + SSLOGERROR(ERRCLS_INT_PAR, ESS108, ERRZERO, "SCpyFixMsg : msgLen + cnt > maxS16"); + RETVALUE(ROUTRES); + } +#endif + + /* add data at the start of dst buffer */ + if (!dstIdx) + { + if ((ret = SAddPreMsgMult(srcBuf, cnt, dstMbuf)) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS109, ERRZERO, "SCpyFixMsg : Failed in\ + SAddPreMsgMult"); +#endif + RETVALUE(ret); + } + *cCnt = cnt; + + RETVALUE(ROK); + } + + /* add data at the end of the dst buffer */ + if (minfo->len == dstIdx) + { + if ((ret = SAddPstMsgMult(srcBuf, cnt, dstMbuf)) != ROK) + { + RETVALUE(ret); + } + *cCnt = cnt; + + RETVALUE(ROK); + } + + /* segment the message into dstMbuf and right */ + if ((ret = SSegMsg(dstMbuf, dstIdx, &right)) != ROK) + { + RETVALUE(ret); + } + + /* append data at the end of dstMbuf */ + if ((ret = SAddPstMsgMult(srcBuf, cnt, dstMbuf)) != ROK) + { + /* ss020.103 - Addition for cleanup */ + (Void) SPutMsg(right); + RETVALUE(ret); + } + + /* cancatenate dstMbuf and right */ + if ((ret = SCatMsg(dstMbuf, right, M1M2)) != ROK) + { + /* ss020.103 - Addition for cleanup */ + (Void) SPutMsg(right); + RETVALUE(ret); + } + + *cCnt = cnt; + + (Void) SPutMsg(right); + + RETVALUE(ROK); +} + +/* +* +* Fun: SCpyMsgFix +* +* Desc: This function copies data from a message +* into a fixed buffer. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: None +* +* File: ss_msg.c +* +*/ + +#ifdef ANSI +PUBLIC S16 SCpyMsgFix +( +Buffer *srcMbuf, /* source message buffer */ +MsgLen srcIdx, /* source index */ +MsgLen cnt, /* count */ +Data *dstBuf, /* destination buffer */ +MsgLen *cCnt +) +#else +PUBLIC S16 SCpyMsgFix(srcMbuf, srcIdx, cnt, dstBuf, cCnt) +Buffer *srcMbuf; /* source message buffer */ +MsgLen srcIdx; /* source index */ +MsgLen cnt; /* count */ +Data *dstBuf; /* destination buffer */ +MsgLen *cCnt; /* copied count */ +#endif +{ + Data *cptr; + Buffer *tmp; + SsMsgInfo *minfo; + MsgLen numBytes; + + TRC1(SCpyMsgFix) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check source message buffer */ + if (srcMbuf == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS110, ERRZERO, "SCpyMsgFix : Null Buffer"); + RETVALUE(RFAILED); + } + /* check destination message buffer */ + if (dstBuf == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS111, ERRZERO, "SCpyMsgFix : Null Buffer"); + RETVALUE(RFAILED); + } + if (cnt <= 0) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS112, ERRZERO, "SCpyMsgFix : Invalid Index"); + RETVALUE(RFAILED); + } + + if (srcIdx < 0) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS113, ERRZERO, "SCpyMsgFix : Invalid Index"); + RETVALUE(RFAILED); + } + if (!cCnt) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS114, ERRZERO, "SCpyMsgFix : Null Buffer"); + RETVALUE(RFAILED); + } + if (srcMbuf->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS115, ERRZERO, "SCpyMsgFix : Incorrect\ + buffer type"); + RETVALUE(RFAILED); + } +#endif + + /* get SsMsgInfo */ + minfo = (SsMsgInfo*) srcMbuf->b_rptr; + + if ((srcIdx + cnt) > minfo->len) + { + *cCnt = 0; + RETVALUE(ROKDNA); + } + + /* get the first SS_M_DATA blk */ + tmp = srcMbuf->b_cont; + + /* get to the srcIdx-th offset */ + FIND_OFFSET(tmp, srcIdx) + + *cCnt = cnt; + + /* set cptr to the read ptr of tmp + offset */ + cptr = tmp->b_rptr + srcIdx; + + while (cnt) + { + /* determine the number of bytes to be copied */ + numBytes = MIN(cnt, (tmp->b_wptr - cptr)); + + /* decrement cnt */ + cnt -= numBytes; + + /* copy data */ + +/* ss002.13 addition */ + + /* ss003.13 addition */ + SMemCpy((Void *) dstBuf, (Void *) cptr, (size_t) numBytes); + + cptr += numBytes; + dstBuf += numBytes; + + + /* get the next blk */ + if ((tmp = tmp->b_cont)) + /* set cptr to the read ptr of tmp */ + cptr = tmp->b_rptr; + else + break; + } + + RETVALUE(ROK); +} + +/* +* +* Fun: SCpyMsgMsg +* +* Desc: This function is used to copy a message into +* a new region and or pool of memory. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: None +* +* File: ss_msg.c +* +*/ + +#ifdef T2K_MEM_LEAK_DBG +PUBLIC S16 SCpyMsgMsgNew +( +Buffer *srcBuf, +Region dstRegion, +Pool dstPool, +Buffer **dstBuf, +char* file, +U32 line +) +#else +#ifdef ANSI +PUBLIC S16 SCpyMsgMsg +( +Buffer *srcBuf, +Region dstRegion, +Pool dstPool, +Buffer **dstBuf +) +#else +PUBLIC S16 SCpyMsgMsg(srcBuf, dstRegion, dstPool, dstBuf) +Buffer *srcBuf; +Region dstRegion; +Pool dstPool; +Buffer **dstBuf; +#endif +#endif +{ + SsMsgInfo *minfo1; + SsMsgInfo *minfo2; + Buffer *tmp; + Buffer *curblk; + Buffer *newblk; + Buffer *prevblk; + + /* ss021.103 - Addition of return value */ +#ifndef SS_PERF +#if (ERRCLASS & ERRCLS_INT_PAR) + S16 ret; +#endif +#endif + + TRC1(SCpyMsgMsg) + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (!srcBuf) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS116, ERRZERO, "SCpyMsgMsg : Null Buffer"); + RETVALUE(RFAILED); + } + if (srcBuf->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS117, ERRZERO, "SCpyMsgMsg : Incorrect\ + buffer type"); + RETVALUE(RFAILED); + } + /* ss021.103 - Addition to validate region and pool */ + if (dstRegion >= SS_MAX_REGS) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS118, ERRZERO, + "SCpyMsgMsg : Invalid region id"); + RETVALUE(RFAILED); + } + + if (dstPool >= SS_MAX_POOLS_PER_REG) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS119, ERRZERO, + "SCpyMsgMsg : Invalid pool id"); + RETVALUE(RFAILED); + } +/* ss037.103 Removed the semaphore operation for performance enhancement */ + +#ifndef SS_PERF + /* ss021.103 - Addition to check if region is valid */ + /* acquire one semaphore, to protect against deregistration */ + SS_ACQUIRE_SEMA(&osCp.regionTblSem, ret); + if (ret != ROK) + { + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS120, (ErrVal) ret, + "Could not lock region table"); +#endif + + RETVALUE(RFAILED); + } +#endif + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* verify that this region is present */ + if (osCp.regionTbl[dstRegion].used == FALSE) + { +#ifndef SS_PERF + if( SS_RELEASE_SEMA(&osCp.regionTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS121, ERRZERO, + "Could not release semaphore"); + RETVALUE(RFAILED); +#endif + } +#endif + SSLOGERROR(ERRCLS_INT_PAR, ESS122, dstRegion, "Region not registered"); + RETVALUE(RFAILED); + } +#endif +/* ss037.103 Removed the semaphore operation for performance enhancement */ + +#ifndef SS_PERF + if( SS_RELEASE_SEMA(&osCp.regionTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS123, ERRZERO, + "Could not release semaphore"); + RETVALUE(RFAILED); +#endif + } +#endif +#endif + +#ifdef XEON_SPECIFIC_CHANGES + dstRegion = 0; + dstPool = 0; +#endif + /* allocate a message buffer */ + if (SGetMsg(dstRegion, dstPool, dstBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS124, ERRZERO, "SCpyMsgMsg : SGetMsg failed"); +#endif + RETVALUE(RFAILED); + } + /* get the SsMsgInfo from srcBuf */ + minfo1 = (SsMsgInfo*) srcBuf->b_rptr; + + /* get the SsMsgInfo from srcBuf */ + minfo2 = (SsMsgInfo*) (*dstBuf)->b_rptr; + + /* get the first SS_M_DATA blk of srcBuf */ + tmp = srcBuf->b_cont; + + /* if srcBuf and dstBuf belong to the same region, increment the reference + * count + */ + newblk = NULLP; + curblk = NULLP; + prevblk = NULLP; + + while (tmp) + { +#ifdef SS_M_PROTO_REGION + if ((curblk = DupMsg(dstRegion,tmp)) == NULLP) +#else + if ((curblk = ssDupB(tmp)) == NULLP) +#endif /* SS_M_PROTO_REGION */ + { + while (newblk) + { + curblk = newblk->b_cont; + (Void) SPutDBuf(minfo1->region, minfo1->pool, newblk); + newblk = curblk; + } + printf("Failed to get the buffer of size %s %d\n", __FILE__, __LINE__); + (Void) SPutMsg(*dstBuf); + RETVALUE(ROUTRES); + } + + if (!prevblk) + newblk = curblk; + else + prevblk->b_cont = curblk; + prevblk = curblk; + + tmp = tmp->b_cont; + } + if (curblk) + curblk->b_cont = NULLP; + + minfo2->len = minfo1->len; + minfo2->endptr = curblk; + (*dstBuf)->b_cont = newblk; + + RETVALUE(ROK); +} + + + +/* +* +* Fun: SAddMsgRef +* +* Desc: This function is used to copy a message into +* a new region and or pool of memory. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: None +* +* File: ss_msg.c +* +*/ +#ifdef T2K_MEM_LEAK_DBG +PUBLIC S16 SAddMsgRefNew +( +Buffer *srcBuf, +Region dstRegion, +Pool dstPool, +Buffer **dstBuf, +char* file, +U32 line +) +#else +#ifdef ANSI +PUBLIC S16 SAddMsgRef +( +Buffer *srcBuf, +Region dstRegion, +Pool dstPool, +Buffer **dstBuf +) +#else +PUBLIC S16 SAddMsgRef(srcBuf, dstRegion, dstPool, dstBuf) +Buffer *srcBuf; +Region dstRegion; +Pool dstPool; +Buffer **dstBuf; +#endif +#endif +{ + SsMsgInfo *minfo1; + SsMsgInfo *minfo2; + Buffer *tmp; + Buffer *dBuf; + Buffer *curblk; + Buffer *newblk; + Buffer *prevblk; + Data *cptr; + MsgLen numBytes; + + TRC1(SAddMsgRef) + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (!srcBuf) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS126, ERRZERO, "SAddMsgRef : Null Buffer"); + RETVALUE(RFAILED); + } + if (srcBuf->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS127, ERRZERO, "SAddMsgRef : Incorrect\ + buffer type"); + RETVALUE(RFAILED); + } +#endif +#ifdef XEON_SPECIFIC_CHANGES + dstRegion = 0; + dstPool = 0; +#endif + + /* allocate a message buffer */ + if (SGetMsg(dstRegion, dstPool, dstBuf) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS128, ERRZERO, "SAddMsgRef : SGetMsg failed"); +#endif + RETVALUE(RFAILED); + } + /* get the SsMsgInfo from srcBuf */ + minfo1 = (SsMsgInfo*) srcBuf->b_rptr; + + /* get the SsMsgInfo from srcBuf */ + minfo2 = (SsMsgInfo*) (*dstBuf)->b_rptr; + + /* get the first SS_M_DATA blk of srcBuf */ + tmp = srcBuf->b_cont; + + /* if srcBuf and dstBuf belong to the same region, increment the reference + * count + */ + if (dstRegion == minfo1->region) + { + newblk = NULLP; + curblk = NULLP; + prevblk = NULLP; + + while (tmp) + { +#ifdef SS_M_PROTO_REGION + if ((curblk = DupMsg(dstRegion, tmp)) == NULLP) +#else + if ((curblk = ssDupB(tmp)) == NULLP) +#endif /* SS_M_PROTO_REGION */ + { + while (newblk) + { + curblk = newblk->b_cont; + (Void) SPutDBuf(minfo1->region, minfo1->pool, newblk); + newblk = curblk; + } + (Void) SPutMsg(*dstBuf); + RETVALUE(ROUTRES); + } + + if (!prevblk) + newblk = curblk; + else + prevblk->b_cont = curblk; + prevblk = curblk; + + tmp = tmp->b_cont; + } + if (curblk) + curblk->b_cont = NULLP; + + minfo2->len = minfo1->len; + minfo2->endptr = curblk; + (*dstBuf)->b_cont = newblk; + + RETVALUE(ROK); + } + + /* allocate a data buffer */ + if (ssGetDBufOfSize(dstRegion, minfo1->len, &dBuf) != ROK) + { +/* ss016.13: addition */ + (Void) SPutMsg(*dstBuf); + SSLOGERROR(ERRCLS_DEBUG, ESS129, ERRZERO, "SAddMsgRef : ssGetDBufOfSize\ + failed"); + RETVALUE(ROUTRES); + } + dBuf->b_datap->db_type = SS_M_DATA; + + while (tmp) + { + numBytes = tmp->b_wptr - tmp->b_rptr; + cptr = tmp->b_rptr; + while (numBytes--) + *dBuf->b_wptr++ = *cptr++; + tmp = tmp->b_cont; + } + minfo2->len = minfo1->len; + /* set the endptr and b_cont of dstBuf to point to dBuf */ + minfo2->endptr = dBuf; + (*dstBuf)->b_cont = dBuf; + + RETVALUE(ROK); +} +/* ss012.13: Addition */ +#ifdef SS_M_PROTO_REGION +/* +* +* Fun: DupMsg +* +* Desc: Duplicates the specified message block, copying it +* into a newly-allocated message block. Increments +* the reference count of the data block that is pointed +* at by the original message block descriptor. +* +* Ret: non-NULL - ok +* NULL - failure +* +* Notes: +* +* File: ss_msg.c +* +*/ +#ifdef T2K_MEM_LEAK_DBG +PRIVATE Buffer *DupMsgNew +( +Region region, /* region id */ +Buffer *mp, /* message block */ +char* file, +U32 line +) +#else +#ifdef ANSI +PRIVATE Buffer *DupMsg +( +Region region, /* region id */ +Buffer *mp /* message block */ +) +#else +PRIVATE Buffer *DupMsg(region, mp) +Region region; /* region id */ +Buffer *mp; /* message block */ +#endif +#endif +{ + Buffer *bp; /* mblk for iteration */ + S16 r; /* return value */ + Size m; /* temporary */ + + TRC1(DupMsg); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (mp == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS130, ERRZERO, "Null pointer"); + RETVALUE(NULLP); + } + + if (region >= SS_MAX_REGS) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS131, ERRZERO, "DupMsg : Invalid region\ + id"); + RETVALUE(NULLP); + } +#endif + + +/* allocate a single block for the mblock and the dblock */ +#if 1 + m = (sizeof(SsMblk) + sizeof(SsDblk)); +#else + numBytes = mp->b_wptr - mp->b_rptr; + m = MDBSIZE + numBytes; +#endif /* SS_MULTICORE_SUPPORT */ +/* ss001.301: additions */ +#ifdef SS_HISTOGRAM_SUPPORT + r = SAlloc(region, &m, 0, (Data **)&bp, __LINE__, (U8*) __FILE__, ENTNC); +#else + r = SAlloc(region, &m, 0, (Data **)&bp); +#endif /* SS_HISTOGRAM_SUPPORT */ + if (r != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SSLOGERROR(ERRCLS_ADD_RES, ESS132, (ErrVal) r, "SAlloc() failed"); +#endif + + RETVALUE(NULLP); + } +/* generic set-up-message function */ +#if 1 +#ifndef SS_DBUF_REFLOCK_DISABLE + SS_STRM_INITB(bp, (SsDblk *)(((U8 *)bp) + sizeof(SsMblk)), NULLP, 0, NULLP); +#endif +#else + data = (Data *) (bp) + MDBSIZE; + SS_STRM_INITB(bp,(SsDblk *)(((U8 *)bp) + sizeof(SsMblk)), data, numBytes, NULLP); +#endif /* SS_MULTICORE_SUPPORT */ + + + /* make the new message block identical to the one to be dup'ed. + * notice that an mblk/dblk pair is allocated but only the mblk + * is used,, this is for optimum performance in the average case. + */ + SMemCpy( (Void *)bp, (Void *)mp, (size_t)sizeof(SsMblk)); + + /* ss006.301 - added the Lock */ +#ifndef SS_DBUF_REFLOCK_DISABLE + if((SLock(&(mp->b_datap->dBufLock))) != ROK) + { + SSLOGERROR(ERRCLS_DEBUG, ESS335, ERRZERO, + "Could not lock the mBuf Ref Lock"); + RETVALUE(NULLP); + } +#endif + /* increment the reference count of the dblock */ + /* increment the reference count of the dblock */ + mp->b_datap->db_ref++; + mp->b_datap->shared = TRUE; +#ifndef SS_DBUF_REFLOCK_DISABLE + if((SUnlock(&(mp->b_datap->dBufLock))) != ROK) + { + SSLOGERROR(ERRCLS_DEBUG, ESS335, ERRZERO, + "Could not lock the mBuf Ref Lock"); + RETVALUE(NULLP); + } +#endif + + + RETVALUE(bp); +} /* DupMsg */ +#endif /* SS_M_PROTO_REGION */ + +/* +* +* Fun: SGetDBuf +* +* Desc: This function allocates a buffer from the dynamic +* memory pool indicated by the caller. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: The dynamic memory pools are used to create and +* manipulate messages. +* +* SGetDBuf is never called by a protocol layer. +* +* SGetDBuf assumes that interrupts are already disabled. +* +* File: ss_msg.c +* +*/ + +#ifdef T2K_MEM_LEAK_DBG +PUBLIC S16 SGetDBufNew +( +Region region, /* region id */ +Pool pool, /* pool id */ +Buffer **bufPtr, +char* file, +U32 line +) +#else +#ifdef ANSI +PUBLIC S16 SGetDBuf +( +Region region, /* region id */ +Pool pool, /* pool id */ +Buffer **bufPtr +) +#else +PUBLIC S16 SGetDBuf(region, pool, bufPtr) +Region region; /* region id */ +Pool pool; /* pool id */ +Buffer **bufPtr; /* pointer to buffer */ +#endif +#endif +{ + Size size; + Size mdsize; + Data *data; + SsDblk *dptr; +#ifdef SS_LOCKLESS_MEMORY +#ifdef SS_USE_ICC_MEMORY + CmMmDynRegCb *regCb; +#else + CmMmGlobRegCb *regCb; +#endif +#else + SsRegionEntry *regp; +#endif /* SS_LOCKLESS_MEMORY */ + /* ss021.103 - Addition of return value */ +#ifndef SS_PERF +#if (ERRCLASS & ERRCLS_INT_PAR) + S16 ret; +#endif +#endif + + TRC1(SGetDBuf) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check buffer pointer */ + if (!bufPtr) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS133, ERRZERO, "SGetDBuf : Null Buffer"); + RETVALUE(RFAILED); + } + if (region >= SS_MAX_REGS) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS134, ERRZERO, "SGetDBuf : Invalid region\ + id"); + RETVALUE(RFAILED); + } + + if (pool >= SS_MAX_POOLS_PER_REG) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS135, ERRZERO, "SGetDBuf : Invalid pool id"); + RETVALUE(RFAILED); + } +/* ss037.103 Removed the semaphore operation for performance enhancement */ + +#ifndef SS_PERF + /* ss021.103 - Addition to check if region is registered */ + /* acquire one semaphore, to protect against deregistration */ + SS_ACQUIRE_SEMA(&osCp.regionTblSem, ret); + if (ret != ROK) + { + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS136, (ErrVal) ret, + "Could not lock region table"); +#endif + + RETVALUE(RFAILED); + } + +#endif + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* verify that this region is present */ + if (osCp.regionTbl[region].used == FALSE) + { +/* ss037.103 Removed the semaphore operation for performance enhancement */ + +#ifndef SS_PERF + if( SS_RELEASE_SEMA(&osCp.regionTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS137, ERRZERO, + "Could not release semaphore"); + RETVALUE(RFAILED); +#endif + } +#endif + SSLOGERROR(ERRCLS_INT_PAR, ESS138, region, "Region not registered"); + RETVALUE(RFAILED); + } +#endif +/* ss037.103 Removed the semaphore operation for performance enhancement */ + +#ifndef SS_PERF + if( SS_RELEASE_SEMA(&osCp.regionTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS139, ERRZERO, + "Could not release semaphore"); + RETVALUE(RFAILED); +#endif + } +#endif +#endif + +#ifdef SS_LOCKLESS_MEMORY +#ifdef SS_USE_ICC_MEMORY + regCb = (CmMmDynRegCb *)(osCp.dynRegionTbl[region].regCb); + mdsize = regCb->bktSize[pool]; +#else /* SS_USE_ICC_MEMORY */ + regCb = osCp.globRegCb; +#ifdef SS_MEM_WL_DEBUG + mdsize = regCb->bktTbl[pool].size - 4; +#else /* SS_MEM_WL_DEBUG */ + mdsize = regCb->bktTbl[pool].size; +#endif /* SS_MEM_WL_DEBUG */ +#endif /* SS_USE_ICC_MEMORY */ +#else + regp = &osCp.regionTbl[region]; + size = regp->poolTbl[pool].u.dpool.size; + /* ss006.301 : optimized this function */ + mdsize = MDBSIZE + size; +#endif /* SS_LOCKLESS_MEMORY */ + + /* ss006.301 : optimized this function */ +/* ss001.301: additions */ +#ifdef SS_HISTOGRAM_SUPPORT + if (SAlloc(region, &mdsize, 0, (Data **) bufPtr, __LINE__, (U8*) __FILE__, ENTNC) != ROK) +#else + if (SAlloc(region, &mdsize, 0, (Data **) bufPtr) != ROK) +#endif /* SS_HISTOGRAM_SUPPORT */ + { + RETVALUE(ROUTRES); + } + data = (Data *) (*bufPtr) + MDBSIZE; + size = mdsize - MDBSIZE; + + dptr = (SsDblk*) (((Data *) (*bufPtr)) + MBSIZE); + + INITB((*bufPtr), dptr, data, size, NULLP) +#ifndef SS_DBUF_REFLOCK_DISABLE + if((SInitLock (&(dptr->dBufLock), SS_LOCK_MUTEX)) != 0) + { + printf("Falied to destroy lock\n"); + } +#endif + + RETVALUE(ROK); +} + +/* +* +* Fun: SPutDBuf +* +* Desc: This function deallocates a buffer back to the +* dynamic memory pool indicated by the caller. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: The dynamic memory pools are used to create and +* manipulate messages. +* +* SPutDBuf is never called by a protocol layer. +* +* SPutDBuf assumes that interrupts are already disabled. +* +* File: ss_msg.c +* +*/ + +#ifdef T2K_MEM_LEAK_DBG +PUBLIC S16 SPutDBufNew +( +Region region, +Pool pool, +Buffer *buf, +char* file, +U32 line +) +#else +#ifdef ANSI +PUBLIC S16 SPutDBuf +( +Region region, +Pool pool, +Buffer *buf +) +#else +PUBLIC S16 SPutDBuf(region, pool, buf) +Region region; +Pool pool; +Buffer *buf; +#endif +#endif +{ + register SsDblk *dptr; + /* ss021.103 - Addition to check return value of SFree */ + S16 ret; +#if (defined(SS_USE_ZBC_MEMORY) && defined (TENB_DPDK_BUF)) + Data *dpdkBuf; +#endif + + TRC2(SPutDBuf); + + /* ss021.103 - Addition of ret initialization */ + ret = ROK; + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (region >= SS_MAX_REGS) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS141, ERRZERO, "SPutDBuf:Invalid region"); + RETVALUE(RFAILED); + } + + if (pool >= SS_MAX_POOLS_PER_REG) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS142, ERRZERO, "SPutDBuf:Invalid pool"); + RETVALUE(RFAILED); + } + + if (buf == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS143, ERRZERO, "SPutDBuf:Null pointer"); + RETVALUE(RFAILED); + } + + if ( (buf->b_datap->db_type != SS_M_DATA) && (buf->b_datap->db_type != SS_M_PROTO)) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS144, ERRZERO, "SPutDBuf:Incorrect\ + buffer type"); + RETVALUE(RFAILED); + } +#endif +/* ss016.13: Addition */ + dptr = buf->b_datap; + +#ifdef SS_USE_ZBC_MEMORY + if(dptr->db_type == SS_MEM_TYPE_SSI_ZBC) + { + ret = SPutZbcDBuf(region, buf); + RETVALUE(ret); + } + +#ifdef TENB_DPDK_BUF + if(dptr->db_type == SS_MEM_TYPE_DPDK_ZBC) + { + /* Not considering referances for DPDK buffer for now */ + SDetachDpdkPtrFrmDBuf(buf, &dpdkBuf); + SPutSBufDpdk(dpdkBuf); + ret = SFree(region, (Data *) buf, MDBSIZE); + RETVALUE(ret); + } +#endif /* TENB_DPDK_BUF */ +#endif /* SS_USE_ZBC_MEMORY */ + + /* ss028.103 - Addition of lock for mBuf reference count */ + /* ss006.301 : optimized this funciton */ +#if 1 + if(!dptr->shared) + { +#ifndef SS_DBUF_REFLOCK_DISABLE + SDestroyLock(&dptr->dBufLock); +#endif + /* if the data block is not shared, free the buffer, checks not reqd */ +#ifdef SS_HISTOGRAM_SUPPORT + ret = SFree(region, (Data *) buf, MDBSIZE + dptr->db_lim - dptr->db_base + , __LINE__, (U8*) __FILE__, ENTNC); +#else + ret = SFree(region, (Data *) buf, MDBSIZE + dptr->db_lim - dptr->db_base); +#endif /* SS_HISTOGRAM_SUPPORT */ + } + else + { +#ifndef SS_DBUF_REFLOCK_DISABLE + if((ret=SLock(&dptr->dBufLock))) + { + SSLOGERROR(ERRCLS_DEBUG, ESSXXX, ERRZERO, + "Could not lock the mBuf Ref Lock"); + RETVALUE(RFAILED); + } +#endif + --dptr->db_ref; + /* if buffer's message blk is obtained during dupb */ + if (buf != (SsMblk *) (((Data*) dptr) - MBSIZE)) + { + + SsDblk* dupdptr = (SsDblk *)((U8 *)buf + MBSIZE); + dupdptr->db_ref--; + if(dupdptr->db_ref == 0) + { + +#ifdef SS_HISTOGRAM_SUPPORT + ret = SFree(region, (Data *) buf, MDBSIZE, __LINE__, (U8*) __FILE__, ENTNC); +#else + ret = SFree(region, (Data *) buf, MDBSIZE); + +#endif /* SS_HISTOGRAM_SUPPORT */ + } + buf = (SsMblk *) (((Data*) dptr) - MBSIZE); + } + /* if reference count falls to zero */ + if (!dptr->db_ref) + { +#ifndef SS_DBUF_REFLOCK_DISABLE + ret = SUnlock(&dptr->dBufLock) ; + if((SDestroyLock(&dptr->dBufLock)) != 0) + { + printf("Falied to destroy lock\n"); + } +#endif + /* free buffer to region */ +#ifdef SS_HISTOGRAM_SUPPORT + ret = SFree(region, (Data *) buf, MDBSIZE + dptr->db_lim - dptr->db_base + , __LINE__, (U8*) __FILE__, ENTNC); +#else + ret = SFree(region, (Data *) buf, MDBSIZE + dptr->db_lim - dptr->db_base); +#endif /* SS_HISTOGRAM_SUPPORT */ + RETVALUE(ret); + } +#ifndef SS_DBUF_REFLOCK_DISABLE + ret = SUnlock(&(dptr->dBufLock)); +#endif + } +#else /* SS_MULTICORE_SUPPORT */ + /* If MultiCore Support enabled, Dblk never be shared */ +#ifdef SS_HISTOGRAM_SUPPORT + ret = SFree(region, (Data *) buf, MDBSIZE + dptr->db_lim - dptr->db_base + , __LINE__, (U8*) __FILE__, ENTNC); +#else + ret = SFree(region, (Data *) buf, MDBSIZE + dptr->db_lim - dptr->db_base); +#endif /* SS_HISTOGRAM_SUPPORT */ +#endif /* SS_MULTICORE_SUPPORT */ + RETVALUE(ret); +} + + +/* #ifdef SS_LOCKLESS_MEMORY */ + + +/* +* +* Fun: SCatMsg +* +* Desc: This function will concatenate the two specified messages +* into one message. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: if order equal M1M2: all data attached to message 2 is +* moved to the end of message 1. message 2 is set to empty. +* message 1 length is increased by length of message 2. +* message 2 length is set to zero. message 2 is not returned +* to memory. return is ok. +* +* if order equal M2M1: all data attached to message 2 is +* moved to the front of message 1. message 2 is set to empty. +* message 1 length is increased by length of message 2. +* message 2 length is set to zero. message 2 is not returned +* to memory. return is ok. +* +* File: ss_msg.c +* +*/ + + +#ifdef ANSI +PUBLIC S16 SCatMsg +( +Buffer *mBuf1, /* message 1 */ +Buffer *mBuf2, /* message 2 */ +Order order +) +#else +PUBLIC S16 SCatMsg(mBuf1, mBuf2, order) +Buffer *mBuf1; /* message 1 */ +Buffer *mBuf2; /* message 2 */ +Order order; /* order */ +#endif +{ + SsMsgInfo *minfo1; + SsMsgInfo *minfo2; + Buffer *tmp; + Buffer *newb; + + TRC1(SCatMsg) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check message buffer 1 */ + if (mBuf1 == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS148, ERRZERO, "SCatMsg : Null Buffer"); + RETVALUE(RFAILED); + } + /* check message buffer 2 */ + if (mBuf2 == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS149, ERRZERO, "SCatMsg : Null Buffer"); + RETVALUE(RFAILED); + } + /* ss021.103 - Addition to test if same buffer */ + /* check message buffer 1 and 2 not same buffer */ + if (mBuf1 == mBuf2) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS150, ERRZERO, "SCatMsg : mBuf1 == mBuf2"); + RETVALUE(RFAILED); + } + if ((order != M1M2) && (order != M2M1)) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS151, ERRZERO, "SCatMsg : Invalid Order"); + RETVALUE(RFAILED); + } + if ((mBuf1->b_datap->db_type != SS_M_PROTO) || + (mBuf2->b_datap->db_type != SS_M_PROTO)) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS152, ERRZERO, + "SCatMsg : Incorrect buffer type"); + RETVALUE(RFAILED); + } +#endif + + /* no data to append or prepend */ + if (!mBuf2->b_cont) + RETVALUE(ROK); + + minfo1 = (SsMsgInfo*) mBuf1->b_rptr; + minfo2 = (SsMsgInfo*) mBuf2->b_rptr; + +/* ss021.103 - Addition to test max length of message is not exceeded */ +#if (ERRCLASS & ERRCLS_INT_PAR) +#ifdef LONG_MSG + if (minfo1->len > 0x7FFFFFFF - minfo2->len) +#else + if (minfo1->len > 0x7FFF - minfo2->len) +#endif + { + SSLOGERROR(ERRCLS_INT_PAR, ESS153, ERRZERO, "SCpyFixMsg : messages too big"); + RETVALUE(ROUTRES); + } +#endif + + if (minfo1->region != minfo2->region) + { + /* duplicate mBuf2 from the region/pool of mBuf1, initialise mBuf2 */ +/*ss015.13: addition */ + if (SCpyMsgMsg(mBuf2, minfo1->region, minfo1->pool, &newb) != ROK) + RETVALUE(RFAILED); + + minfo2 = (SsMsgInfo*) newb->b_rptr; + } + else + newb = mBuf2; + + if ((tmp = mBuf1->b_cont) == NULLP) + { + mBuf1->b_cont = newb->b_cont; + minfo1->endptr = minfo2->endptr; + } + else + { + if (order == M1M2) + /* attach newb after mBuf1 */ + { + minfo1->endptr->b_cont = newb->b_cont; + minfo1->endptr = minfo2->endptr; + } + else + { + if (order == M2M1) + /* attach newb before mBuf1 */ + { + minfo2->endptr->b_cont = mBuf1->b_cont; + mBuf1->b_cont = newb->b_cont; + } + else /* invalid order */ + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS154, ERRZERO, "SCatMsg:Invalid order"); +#endif + if (newb && (newb != mBuf2)) + (Void) SPutMsg(newb); + RETVALUE(RFAILED); + } + } + } + minfo1->len += minfo2->len; + + + minfo2->endptr = NULLP; + minfo2->len = 0; + + newb->b_cont = NULLP; + + if (newb != mBuf2) + { + (Void) SPutMsg(newb); + (Void) SInitMsg(mBuf2); + } + + RETVALUE(ROK); +} + +/* +* +* Fun: SRepMsg +* +* Desc: This function replaces one byte of data in a message. +* +* Ret: ROK - ok +* ROKDNA - ok, data not available +* RFAILED - failed, general (optional) +* +* Notes: index is 0 based and indicates location in message +* +* if index is less than the length of the message: +* data is replaced at specified index. message length +* is unchanged. return is ok. +* +* if index is greater than or equal to +* the length of the message: message is unchanged. +* return is ok, data not available. +* +* File: ss_msg.c +* +*/ + + +#ifdef ANSI +PUBLIC S16 SRepMsg +( +Data data, /* data */ +Buffer *mBuf, /* message buffer */ +MsgLen idx +) +#else +PUBLIC S16 SRepMsg(data, mBuf, idx) +Data data; /* data */ +Buffer *mBuf; /* message buffer */ +MsgLen idx; /* index */ +#endif +{ + SsMsgInfo *minfo; + Buffer *tmp; + Buffer *newb; + Buffer *prev; + MsgLen numBytes; + + TRC1(SRepMsg) + +#ifdef T2K_MEM_LEAK_DBG + char* file = __FILE__; + U32 line = __LINE__; +#endif +#if ( ERRCLASS & ERRCLS_INT_PAR) + /* check message buffer */ + if (mBuf == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS155, ERRZERO, "SRepMsg : Null Buffer"); + RETVALUE(RFAILED); + } + if (idx < 0) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS156, ERRZERO, "SRepMsg : Invalid index"); + RETVALUE(RFAILED); + } + if (mBuf->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS157, ERRZERO, "SRepMsg : Incorrect buffer\ + type"); + RETVALUE(RFAILED); + } +#endif + + minfo = (SsMsgInfo*) (mBuf)->b_rptr; + + /* if index > length of the buffer */ + if (minfo->len <= idx) + { + RETVALUE(ROKDNA); + } + + tmp = mBuf->b_cont; /* get the first SS_M_DATA blk */ + prev = mBuf; /* parent */ + + FIND_OFFSET_AND_PREV(prev, tmp, idx) + + /* if ref cnt is greater than 1, duplicate tmp */ + if (tmp->b_datap->db_ref > 1) + { + /* allocate a message blk of message size of tmp */ + numBytes = tmp->b_wptr - tmp->b_rptr; + if (ssGetDBufOfSize(minfo->region, numBytes, &newb) != ROK) + { + SSLOGERROR(ERRCLS_DEBUG, ESS158, ERRZERO, "SRepMsg : ssGetDBufOfSize\ + failed"); + RETVALUE(RFAILED); + } + while (numBytes--) + *newb->b_wptr++ = *tmp->b_rptr++; + + newb->b_cont = tmp->b_cont; + prev->b_cont = newb; + if (minfo->endptr == tmp) + minfo->endptr = newb; + + /* free tmp */ + (Void) SPutDBuf(minfo->region, minfo->pool, tmp); + tmp = newb; + } + *(tmp->b_rptr + idx) = data; + + RETVALUE(ROK); +} + +/* +* +* Fun: SUpdMsg +* +* Desc: Update a message with a new dBuf +* +* Ret: ROK/RFAILED +* +* Notes: +* +* File: ss_msg.c +* +*/ + + +#ifdef ANSI +PUBLIC S16 SUpdMsg +( +Buffer *mBuf, /* message buffer */ +Buffer *dBuf, /* data buffer */ +MsgLen dLen +) +#else +PUBLIC S16 SUpdMsg(mBuf, dBuf, dLen) +Buffer *mBuf; /* message buffer */ +Buffer *dBuf; /* data buffer */ +MsgLen dLen; /* data length */ +#endif +{ + SsMsgInfo *minfo; + + TRC1(SUpdMsg) + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (!mBuf) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS159, ERRZERO, "SUpdMsg : Null Buffer"); + RETVALUE(RFAILED); + } + if (!dBuf) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS160, ERRZERO, "SUpdMsg : Null Buffer"); + RETVALUE(RFAILED); + } + if (dLen < 0) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS161, ERRZERO, "SUpdMsg : Invalid length"); + RETVALUE(RFAILED); + } + if ((mBuf->b_datap->db_type != SS_M_PROTO) || + (dBuf->b_datap->db_type != SS_M_DATA)) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS162, ERRZERO, "SUpdMsg : Incorrect buffer\ + type"); + RETVALUE(RFAILED); + } +#endif + + /* get the message info of mBuf */ + minfo = (SsMsgInfo*) (mBuf)->b_rptr; + + /* accept zero length data */ + + /* buffer offset out of bounds */ + if ((dBuf->b_rptr + dLen) > dBuf->b_datap->db_lim) + { + SSLOGERROR(ERRCLS_DEBUG, ESS163, ERRZERO, "SUpdMsg:Offset out of bounds"); + RETVALUE(RFAILED); + } + + /* offset write ptr from read ptr by dLen */ + dBuf->b_wptr = dBuf->b_rptr + dLen; + + /* attach dBuf at the end of mBuf */ + if (minfo->endptr) + minfo->endptr->b_cont = dBuf; + else + mBuf->b_cont = dBuf; + + /* update SsMsgInfo */ + minfo->endptr = dBuf; + + minfo->len += dLen; + + RETVALUE(ROK); +} + +/* +* +* Fun: SAddDBufPst +* +* Desc: This function queues a data buffer to the +* back of the specified message buffer . +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: if queue is empty: buffer is placed in the queue. +* queue length is incremented. +* +* if queue is not empty: buffer is placed behind all +* other buffers in queue. queue length is incremented. +* +* File: ss_msg.c +* +*/ + + +#ifdef ANSI +PUBLIC S16 SAddDBufPst +( +Buffer *mBuf, /* message buffer */ +Buffer *dBuf +) +#else +PUBLIC S16 SAddDBufPst(mBuf, dBuf) +Buffer *mBuf; /* message buffer */ +Buffer *dBuf; /* data buffer */ +#endif +{ + SsMsgInfo *minfo; + + TRC1(SAddDBufPst) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check buffer queue */ + if (!mBuf || !dBuf) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS164, ERRZERO, "SAddDBufPst : Null Buffer"); + RETVALUE(RFAILED); + } + if ((mBuf->b_datap->db_type != SS_M_PROTO) || + (dBuf->b_datap->db_type != SS_M_DATA)) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS165, ERRZERO, "SAddDBufPst : Incorrect\ + buffer type"); + RETVALUE(RFAILED); + } +#endif + + /* no data, return */ + if (dBuf->b_wptr == dBuf->b_rptr) + RETVALUE(ROK); + + minfo = (SsMsgInfo*) (mBuf)->b_rptr; + + /* attach dBuf at the end of mBuf */ + if (minfo->endptr) + minfo->endptr->b_cont = dBuf; + else + mBuf->b_cont = dBuf; + + /* update SsMsgInfo */ + minfo->endptr = dBuf; + + minfo->len += dBuf->b_wptr - dBuf->b_rptr; + + RETVALUE(ROK); +} + +/* +* +* Fun: SAddDBufPre +* +* Desc: This function queues a data buffer to the +* front of the specified message buffer. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: if buffer queue is empty: buffer is placed in the queue. queue +* length is incremented. +* +* if buffer queue is not empty: buffer is placed in front of all +* other buffers in queue. queue length is incremented. +* +* File: ss_msg.c +* +*/ + + +#ifdef ANSI +PUBLIC S16 SAddDBufPre +( +Buffer *mBuf, /* message buffer */ +Buffer *dBuf +) +#else +PUBLIC S16 SAddDBufPre(mBuf, dBuf) +Buffer *mBuf; /* message buffer */ +Buffer *dBuf; /* data buffer */ +#endif +{ + SsMsgInfo *minfo; + Buffer *tmp; + + TRC1(SAddDBufPre) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check buffer queue */ + if (!mBuf || !dBuf) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS166, ERRZERO, "SAddDBufPre : Null Buffer"); + RETVALUE(RFAILED); + } + if ((mBuf->b_datap->db_type != SS_M_PROTO) || + (dBuf->b_datap->db_type != SS_M_DATA)) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS167, ERRZERO, "SAddDBufPre : Incorrect\ + buffer type"); + RETVALUE(RFAILED); + } +#endif + + /* no data, return */ + if (dBuf->b_wptr == dBuf->b_rptr) + RETVALUE(ROK); + + minfo = (SsMsgInfo*) (mBuf)->b_rptr; + + tmp = mBuf->b_cont; + + /* attach dBuf at the start of mBuf */ + mBuf->b_cont = dBuf; + dBuf->b_cont = tmp; + + minfo->len += dBuf->b_wptr - dBuf->b_rptr; + + if (!tmp) + minfo->endptr = dBuf; + + RETVALUE(ROK); +} + +/* +* +* Fun: SRemDBufPre +* +* Desc: This function dequeues a data buffer from +* the front of the specified message buffer. +* +* Ret: ROK - ok +* ROKDNA - ok, data not available +* RFAILED - failed, general (optional) +* +* Notes: if queue is empty: pointer to buffer is set to null and +* return is ok, data not available. queue length is unchanged. +* +* if queue is not empty: pointer to buffer is set to first +* buffer in queue, first buffer in queue is removed and +* return is ok. queue length is decremented. +* +* File: ss_msg.c +* +*/ + + +#ifdef ANSI +PUBLIC S16 SRemDBufPre +( +Buffer *mBuf, /* message buffer */ +Buffer **dBufPtr +) +#else +PUBLIC S16 SRemDBufPre(mBuf, dBufPtr) +Buffer *mBuf; /* message buffer */ +Buffer **dBufPtr; /* pointer to data buffer */ +#endif +{ + SsMsgInfo *minfo; + + TRC1(SRemDBufPre) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check buffer pointer */ + if (dBufPtr == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS168, ERRZERO, "SRemDBufPre : Null Buffer"); + RETVALUE(RFAILED); + } + /* check queue */ + if (mBuf == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS169, ERRZERO, "SRemDBufPre : Null Buffer"); + RETVALUE(RFAILED); + } + if (mBuf->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS170, ERRZERO, "SRemDBufPre : Incorrect\ + buffer type"); + RETVALUE(RFAILED); + } +#endif + + /* no data blk, return */ + if ((*dBufPtr = mBuf->b_cont) == NULLP) + { + return ROKDNA; + } + minfo = (SsMsgInfo*) (mBuf)->b_rptr; + + mBuf->b_cont = (*dBufPtr)->b_cont; + (*dBufPtr)->b_cont = NULLP; + + /* update SsMsgInfo */ + if (!(minfo->len -= (*dBufPtr)->b_wptr - (*dBufPtr)->b_rptr)) + minfo->endptr = NULLP; + + RETVALUE(ROK); +} + +/* +* +* Fun: SRemDBufPst +* +* Desc: This function dequeues a data or message buffer from the +* back of the specified message buffer. +* +* Ret: ROK - ok +* ROKDNA - ok, data not available +* RFAILED - failed, general (optional) +* +* Notes: if queue is empty: pointer to buffer is set to null and +* return is ok, data not available. queue length is unchanged. +* +* if queue is not empty: pointer to buffer is set to last +* buffer in queue, last buffer in queue is removed and +* return is ok. queue length is decremented. +* +* File: ss_msg.c +* +*/ + + +#ifdef ANSI +PUBLIC S16 SRemDBufPst +( +Buffer *mBuf, /* message buffer */ +Buffer **dBufPtr +) +#else +PUBLIC S16 SRemDBufPst(mBuf, dBufPtr) +Buffer *mBuf; /* message buffer */ +Buffer **dBufPtr; /* pointer to data buffer */ +#endif +{ + SsMsgInfo *minfo; + Buffer *tmp; + + TRC1(SRemDBufPst) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check buffer pointer */ + if (!dBufPtr) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS171, ERRZERO, "SRemDBufPst : Null Buffer"); + RETVALUE(RFAILED); + } + /* check message */ + if (!mBuf) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS172, ERRZERO, "SRemDBufPst : Null Buffer"); + RETVALUE(RFAILED); + } + if (mBuf->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS173, ERRZERO, "SRemDBufPst : Incorrect\ + buffer type"); + RETVALUE(RFAILED); + } +#endif + + minfo = (SsMsgInfo*) (mBuf)->b_rptr; + + /* no data blk, return */ + if ((*dBufPtr = minfo->endptr) == NULLP) + { + return ROKDNA; + } + for (tmp = mBuf; tmp->b_cont != (*dBufPtr); ) + tmp = tmp->b_cont; + + tmp->b_cont = NULLP; + + /* update SsMsgInfo */ + if (!(minfo->len -= (*dBufPtr)->b_wptr - (*dBufPtr)->b_rptr)) + minfo->endptr = NULLP; + else + minfo->endptr = tmp; + + RETVALUE(ROK); +} + +/* +* +* Fun: SInitNxtDBuf +* +* Desc: Initialize next Data Buffer Id +* +* Ret: ROK/RFAILED +* +* Notes: Must be called prior to SGetNxtDBuf +* +* File: ss_msg.c +* +*/ + + +#ifdef ANSI +PUBLIC S16 SInitNxtDBuf +( +Buffer *mBuf +) +#else +PUBLIC S16 SInitNxtDBuf(mBuf) +Buffer *mBuf; /* message buffer */ +#endif +{ + SsMsgInfo *minfo; + + TRC1(SInitNxtDBuf) + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (!mBuf) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS174, ERRZERO, "SInitNxtDBuf : Null Buffer"); + RETVALUE(RFAILED); + } + if (mBuf->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS175, ERRZERO, "SInitNxtDBuf : Incorrect\ + buffer type"); + RETVALUE(RFAILED); + } +#endif + + minfo = (SsMsgInfo*) mBuf->b_rptr; + + /* set the next ptr of mBuf to point to the first SS_M_DATA blk */ + minfo->next = mBuf->b_cont; + + RETVALUE(ROK); +} + +/* +* +* Fun: SGetNxtDBuf +* +* Desc: Get next dBuf in message chain +* +* Ret: ROK/RFAILED +* +* Notes: Must be called after SInitNxtDBuf +* +* File: ss_msg.c +* +*/ + + +#ifdef ANSI +PUBLIC S16 SGetNxtDBuf +( +Buffer *mBuf, /* message buffer */ +Buffer **dBuf +) +#else +PUBLIC S16 SGetNxtDBuf(mBuf, dBuf) +Buffer *mBuf; /* message buffer */ +Buffer **dBuf; /* data buffer return */ +#endif +{ + SsMsgInfo *minfo; + + TRC1(SGetNxtDBuf) + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (!mBuf) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS176, ERRZERO, "SGetNxtDBuf : Null Buffer"); + RETVALUE(RFAILED); + } + if (!dBuf) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS177, ERRZERO, "SGetNxtDBuf : Null Buffer"); + RETVALUE(RFAILED); + } + if (mBuf->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS178, ERRZERO, "SGetNxtDBuf : Incorrect\ + buffer type"); + RETVALUE(RFAILED); + } +#endif + + minfo = (SsMsgInfo*) (mBuf)->b_rptr; + + /* if next ptr of mBuf is NULLP, return */ + if ((*dBuf = minfo->next) == NULLP) + RETVALUE(ROKDNA); + + /* update next */ + minfo->next = (*dBuf)->b_cont; + + RETVALUE(ROK); +} + +/* +* +* Fun: SChkNxtDBuf +* +* Desc: check if next data buffer exists. +* +* Ret: ROK/ROKDNA/RFAILED +* +* Notes: doesn't modify nxtDBuf +* +* File: ss_msg.c +* +*/ + +#ifdef ANSI +PUBLIC S16 SChkNxtDBuf +( +Buffer *mBuf +) +#else +PUBLIC S16 SChkNxtDBuf(mBuf) +Buffer *mBuf; /* message buffer */ +#endif +{ + SsMsgInfo *minfo; + + TRC1(SChkNxtDBuf) + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (!mBuf) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS179, ERRZERO, "SChkNxtDBuf : Null Buffer"); + RETVALUE(RFAILED); + } + if (mBuf->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS180, ERRZERO, "SChkNxtDBuf : Incorrect\ + buffer type"); + RETVALUE(RFAILED); + } +#endif /* ERRCLASS */ + + minfo = (SsMsgInfo*) (mBuf)->b_rptr; + + /* if next is valid, return ROK */ + if (minfo->next) + RETVALUE(ROK); + else + RETVALUE(ROKDNA); +} + +/* +* +* Fun: SGetDataRx +* +* Desc: Given a data buffer, return a pointer to the +* data payload, and the length of the payload +* +* +* Ret: ROK ok +* RFAILED error +* +* Notes: This assumes an uninitialized dBuf +* +* File: ss_msg.c +* +*/ + + +#ifdef ANSI +PUBLIC S16 SGetDataRx +( +Buffer *dBuf, /* data buffer */ +MsgLen pad, /* pad */ +Data **retDatPtr, /* return data pointer */ +MsgLen *retDatLen +) +#else +PUBLIC S16 SGetDataRx(dBuf, pad, retDatPtr, retDatLen) +Buffer *dBuf; /* data buffer */ +MsgLen pad; /* pad */ +Data **retDatPtr; /* return data pointer */ +MsgLen *retDatLen; /* return data length */ +#endif +{ + TRC1(SGetDataRx) + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (!dBuf) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS181, ERRZERO, "SGetDataRx : Null Buffer"); + RETVALUE(RFAILED); + } + if (!retDatLen || (pad < 0)) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS182, ERRZERO, "SGetDataRx : Null Buffer"); + RETVALUE(RFAILED); + } + if (!retDatPtr) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS183, ERRZERO, "SGetDataRx : Null Buffer"); + RETVALUE(RFAILED); + } + if (dBuf->b_datap->db_type != SS_M_DATA) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS184, ERRZERO, "SGetDataRx : Incorrect\ + buffer type"); + RETVALUE(RFAILED); + } +#endif /* ERRCLASS */ + + if (dBuf->b_datap->db_ref > 1) /* cannot write to a shared buffer */ + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS185, ERRZERO, "SGetDataRx : Reference\ + count > 1"); +#endif + RETVALUE(RFAILED); + } + + /* return the write ptr loc(with padding) if there is data to write to */ + if ((*retDatLen = (dBuf->b_datap->db_lim - dBuf->b_wptr - pad)) > 0) + *retDatPtr = dBuf->b_wptr + pad; + else + { + *retDatPtr = NULLP; +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS186, ERRZERO, "SGetDataRx:No data available"); +#endif + RETVALUE(RFAILED); + } + + RETVALUE(ROK); +} + +/* +* +* Fun: SGetDataTx +* +* Desc: Given a data buffer, return a pointer to the +* data payload, and the length of the payload +* +* +* Ret: ROK ok +* RFAILED error +* +* Notes: This assumes an initialized dBuf +* +* File: ss_msg.c +* +*/ + + +#ifdef ANSI +PUBLIC S16 SGetDataTx +( +Buffer *dBuf, /* data buffer */ +Data **retDatPtr, /* return data pointer */ +MsgLen *retDatLen /* return data length */ +) +#else +PUBLIC S16 SGetDataTx(dBuf, retDatPtr, retDatLen) +Buffer *dBuf; /* data buffer */ +Data **retDatPtr; /* return data pointer */ +MsgLen *retDatLen; /* return data length */ +#endif +{ + TRC1(SGetDataTx) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* ss021.103 - Modification to check parameters */ + if (!retDatPtr) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS187, ERRZERO, "SGetDataTx : Null Buffer"); + RETVALUE(RFAILED); + } + if (!dBuf) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS188, ERRZERO, "SGetDataTx : Null Buffer"); + *retDatPtr = (Data *)NULLP; + RETVALUE(RFAILED); + } + if (!retDatLen) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS189, ERRZERO, "SGetDataTx : Null Buffer"); + RETVALUE(RFAILED); + } + if (dBuf->b_datap->db_type != SS_M_DATA) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS190, ERRZERO, "SGetDataTx : Incorrect\ + buffer type"); + *retDatPtr = (Data *)NULLP; + RETVALUE(RFAILED); + } +#endif /* ERRCLASS */ + + /* if there is data, return read ptr */ + if ((*retDatLen = dBuf->b_wptr - dBuf->b_rptr)) + *retDatPtr = dBuf->b_rptr; + else + { + *retDatPtr = NULLP; +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS191, ERRZERO, "SGetDataTx : Buffer empty"); +#endif + RETVALUE(RFAILED); + } + + RETVALUE(ROK); +} + +#ifndef SS_ENABLE_MACROS + +/* +* +* Fun: SGetBufRegionPool +* +* Desc: returns the region and pool of the message buffer +* +* Ret: ROK on success +* RFAILED on error +* +* Notes: None +* +* File: ss_msg.c +* +*/ +#ifdef ANSI +PUBLIC S16 SGetBufRegionPool +( +Buffer *mBuf, /* message buffer */ +Region *region, /* region */ +Pool *pool /* pool */ +) +#else +PUBLIC S16 SGetBufRegionPool(mBuf, region, pool) +Buffer *mBuf; /* message buffer */ +Region *region; /* region */ +Pool *pool; /* pool */ +#endif +{ + SsMsgInfo *mInfo; /* message info pointer */ + + TRC1(SGetBufRegionPool) + +#if (ERRCLASS & ERRCLS_INT_PAR) + + if (mBuf == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS192, ERRZERO, + "SGetBufRegionPool : Null Buffer"); + RETVALUE(RFAILED); + } + if ((region == NULLP) && (pool == NULLP)) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS193, ERRZERO, + "SGetBufRegionPool : Null region and pool pointers"); + RETVALUE(RFAILED); + } + if (mBuf->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS194, ERRZERO, + "SUpdMsg : Incorrect buffer type"); + RETVALUE(RFAILED); + } +#endif /* (ERRCLASS & ERRCLS_INT_PAR */ + + /* get message info of mBuf */ + if ((mInfo = (SsMsgInfo *) mBuf->b_rptr) == NULLP) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS195, ERRZERO, + "SGetBufRegionPool : mBuf's control data is null"); +#endif + RETVALUE(RFAILED); + } + + if (region != NULLP) + *region = mInfo->region; + if (pool != NULLP) + *pool = mInfo->pool; + + RETVALUE(ROK); +} /* end of SGetBufRegionPool */ + +#endif /* SS_ENABLE_MACROS */ + +/* +* +* Fun: SCompressMsg +* +* Desc: This function is used to compress a message into +* the minimum number of data buffers needed. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: None +* +* File: ss_msg.c +* +*/ + + +#ifdef ANSI +PUBLIC S16 SCompressMsg +( +Buffer *mBuf +) +#else +PUBLIC S16 SCompressMsg(mBuf) +Buffer *mBuf; /* message buffer */ +#endif +{ + SsMsgInfo *minfo; + MsgLen numBytes; + Buffer *dBuf; + Buffer *tmp; + Buffer *next; + S16 ret; + +#ifdef T2K_MEM_LEAK_DBG + char* file = __FILE__; + U32 line = __LINE__; +#endif + TRC1(SCompressMsg) + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (!mBuf) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS196, ERRZERO, "SCompressMsg : Null Buffer"); + RETVALUE(RFAILED); + } + if (mBuf->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS197, ERRZERO, "SCompressMsg : Incorrect\ + buffer type"); + RETVALUE(RFAILED); + } +#endif + + minfo = (SsMsgInfo*) (mBuf)->b_rptr; + + if ((tmp = mBuf->b_cont) == minfo->endptr) + { + RETVALUE(ROK); + } + + /* allocate a data buffer of size bytes*/ + if ((ret = ssGetDBufOfSize(minfo->region, minfo->len, &dBuf)) != ROK) + { + SSLOGERROR(ERRCLS_DEBUG, ESS198, ERRZERO, "SAddMsgRef : ssGetDBufOfSize\ + failed"); + RETVALUE(RFAILED); + } + dBuf->b_datap->db_type = SS_M_DATA; + + while (tmp) + { + /* determine number of bytes to be copied */ + numBytes = tmp->b_wptr - tmp->b_rptr; + + /* copy data */ + +/* ss002.13: addition */ + /* ss003.13: addition */ + SMemCpy( (Void *)dBuf->b_wptr, (Void *)tmp->b_rptr, (size_t)numBytes); + + dBuf->b_wptr += numBytes; + tmp->b_rptr += numBytes; + + + next = tmp->b_cont; + (Void) SPutDBuf(minfo->region, minfo->pool, tmp); + tmp = next; + } + /* update mBuf and SsMsgInfo */ + mBuf->b_cont = dBuf; + minfo->endptr = dBuf; + + RETVALUE(ROK); +} + +/* +* +* Fun: SPrntMsg +* +* Desc: This function prints the contents of a message. The +* following information is printed: queue length, +* message length, direction, hexadecimal and ASCII +* (if appropriate) values of all bytes in the message. +* +* This function should be used for debugging only. +* +* Ret: ROK - ok +* +* Notes: None +* +* File: ss_msg.c +* +*/ + +#ifdef ANSI +PUBLIC S16 SPrntMsg +( +Buffer *mBuf, /* message buffer */ +S16 src, /* source id */ +S16 dst /* destination id */ +) +#else +PUBLIC S16 SPrntMsg(mBuf, src, dst) +Buffer *mBuf; /* message buffer */ +S16 src; /* source id */ +S16 dst; /* destination id */ +#endif +{ + QLen qlen; /* queue length */ + MsgLen mlen; /* message length */ +/* + * SDeRegTTsk patch + */ + /* ss038.103 : 102061 Changed to MsgLen from S16 */ + MsgLen i; /* counter */ + S16 j; /* counter */ + S16 k; /* counter */ + U8 data; /* data */ + U8 tdata[16] = {0}; /* temporary data */ + S8 prntBuf[256]; /* print buffer */ + Buffer *tmp; /* buffer ptr */ + Data *cptr; +/* ss012.13: Addition */ + Data reg; + + + TRC1(SPrntMsg) + + if (mBuf == NULLP) + { + sprintf(prntBuf,"\nmsg: empty\n"); + SPrint(prntBuf); + SPrint( (S8*)"\n\n"); + RETVALUE(ROK); + } + + for (qlen = 0, tmp = mBuf->b_cont; tmp; qlen++) + tmp = tmp->b_cont; + mlen = ((SsMsgInfo*)(mBuf->b_rptr))->len; + reg = ((SsMsgInfo*)(mBuf->b_rptr))->region; + /*ss013.301: Fixed Warnings for 32/64 bit compilation*/ + sprintf(prntBuf,"\nmsg: qlen: %04d mlen: %04d %02d-->%02d region: %02d\n", + (U16)qlen,(U16)mlen,src,dst,reg); + SPrint( prntBuf); +#ifdef XEON_SPECIFIC_CHANGES + printf("%s\n", prntBuf); +#endif + SPrint((S8*) "dat: "); +#ifdef XEON_SPECIFIC_CHANGES + printf("\ndat: "); +#endif + + if (mlen == 0) + { + sprintf(prntBuf," empty\n"); + SPrint(prntBuf); + SPrint( (S8*)"\n\n"); + RETVALUE(ROK); + } + tmp = mBuf->b_cont; + cptr = tmp->b_rptr; + data= *cptr++; + i = 0; + while( i < mlen ) + { + j = 0; + for( j = 0; j < 16; j++) + { + if( i < mlen ) + { + /* print hex */ + tdata[j]=data; + sprintf( prntBuf,"%02x ",(U16) data); + SPrint( prntBuf); +#ifdef XEON_SPECIFIC_CHANGES + printf("%s\n", prntBuf); +#endif + if (cptr == tmp->b_wptr) + { + tmp = tmp->b_cont; + if (tmp) + cptr = tmp->b_rptr; + } + /* ss024.103 - Modification to fix bug */ + i++; + if ( i < mlen ) + data = *cptr++; + } + else + { + sprintf( prntBuf," "); + SPrint( prntBuf ); +#ifdef XEON_SPECIFIC_CHANGES + printf("%s\n", prntBuf); +#endif + } + } + for (k = 0; k < 16; k++) + { + if( (i >= mlen) && (k>=(mlen%16)) && mlen%16 != 0) + break; + if (AIsAscii(tdata[k])) + { + /* print character if printable */ + sprintf(prntBuf,"%c",tdata[k]); + SPrint( prntBuf); +#ifdef XEON_SPECIFIC_CHANGES + printf("%s\n", prntBuf); +#endif + } + else + { + /* print . if non printable */ + SPrint((S8*) "."); +#ifdef XEON_SPECIFIC_CHANGES + printf("."); +#endif + } + } + sprintf(prntBuf,"\n "); + SPrint(prntBuf); +#ifdef XEON_SPECIFIC_CHANGES + printf("%s\n", prntBuf); +#endif + } + RETVALUE(ROK); + +} /* end of SPrntMsg */ + + + +/* +* +* Fun: SGetPstMsgMult +* +* Desc: This function allocates consecutive bytes of data at the +* end of a message. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: if message is empty: message length is incremented. +* return is ok. +* +* if message is not empty: space is allocated in back of +* all other data in message. message length is incremented. +* return is ok. +* +* File: ss_msg.c +* +*/ +#ifdef ANSI +PUBLIC S16 SGetPstMsgMult +( +MsgLen cnt, /* count */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 SGetPstMsgMult(cnt, mBuf) +MsgLen cnt; /* count */ +Buffer *mBuf; /* message buffer */ +#endif +{ + Buffer *tmp; + Buffer *newb; + SsMsgInfo *minfo; + MsgLen numBytes; + MsgLen avail; + +#if 0 + char* file = __FILE__; + U32 line = __LINE__; +#endif + TRC1(SGetPstMsgMult) + +#if ( ERRCLASS & ERRCLS_INT_PAR ) + /* check message buffer */ + if (mBuf == NULLP) + { + RETVALUE(RFAILED); + } + /* check count */ + if (cnt <= 0) + { + RETVALUE(RFAILED); + } + if (mBuf->b_datap->db_type != SS_M_PROTO) + { + RETVALUE(RFAILED); + } +#endif + /* get the message info */ + minfo = (SsMsgInfo *) (mBuf->b_rptr); + + /* init avail */ + avail = 0; + + if ((tmp = minfo->endptr) && (tmp->b_datap->db_ref == 1) && + ((avail = tmp->b_datap->db_lim - tmp->b_wptr))) + { + numBytes = MIN(cnt, avail); + + cnt -= numBytes; + minfo->len += numBytes; + + +/* ss002.13 addition */ +/* ss003.13 addition */ + SMemSet( (Void *)tmp->b_wptr, (Data)'\0', (size_t)numBytes); + + tmp->b_wptr += numBytes; + if (!cnt) + RETVALUE(ROK); + } + if (ssGetDBufOfSize(minfo->region, cnt, &newb) != ROK) + { + /* ss027.103 - Modification to fix bug in SGetPstMsgMult */ + if ((avail) && (tmp)) + tmp->b_wptr = tmp->b_datap->db_lim - avail; + minfo->len -= avail; + RETVALUE(ROUTRES); + } + + minfo->len += cnt; + + +/* ss002.13: addition */ + /* ss003.13: addition */ + SMemSet( (Void *)newb->b_wptr, (Data)'\0', (size_t)cnt); + + newb->b_wptr += cnt; + + + if (tmp) + tmp->b_cont = newb; + else + mBuf->b_cont = newb; + + minfo->endptr = newb; + + RETVALUE(ROK); +} + +/* +* +* Fun: SChkMsg +* +* Desc: Check Message +* +* Ret: ROK on success +* RFAILED on error +* +* Notes: Check that the first buffer in a message +* contains at least two bytes. This check is required +* by 68302/68360 processors to insure accurate fisu +* generation. +* +* File: ss_msg.c +* +*/ +#ifdef ANSI +PUBLIC S16 SChkMsg +( +Buffer *mBuf +) +#else +PUBLIC S16 SChkMsg(mBuf) +Buffer *mBuf; +#endif +{ + SsMsgInfo *minfo; + Buffer *tmp; + + TRC1(SChkMsg) + +#if ( ERRCLASS & ERRCLS_INT_PAR ) + /* check message buffer */ + if (mBuf == NULLP) + { + RETVALUE(RFAILED); + } + if (mBuf->b_datap->db_type != SS_M_PROTO) + { + RETVALUE(RFAILED); + } +#endif + /* get the message info */ + minfo = (SsMsgInfo *) (mBuf->b_rptr); + + if (minfo->len < 2) + RETVALUE(RFAILED); + + /* get the first M_DATA blk*/ + tmp = mBuf->b_cont; + + if (((tmp->b_rptr + 2) <= tmp->b_wptr) || (SCompressMsg(mBuf) == ROK)) + RETVALUE(ROK); + + RETVALUE(RFAILED); +} + +/* +* +* Fun: SAlignDBufEven +* +* Desc: align data portion of a data buffer on an even +* byte boundary. +* +* Ret: ROK/RFAILED +* +* Notes: required for SS7 microcode on the 68302 +* +* File: ss_msg.c +* +*/ +#ifdef ANSI +PUBLIC S16 SAlignDBufEven +( +Buffer *dBuf /* data buffer */ +) +#else +PUBLIC S16 SAlignDBufEven(dBuf) +Buffer *dBuf; /* data buffer */ +#endif +{ + MsgLen len; + Data *src; + + TRC1(SAlignDBufEven) + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (!dBuf) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS199, ERRZERO, "SAlignDBufEven : Null\ + Buffer"); + RETVALUE(RFAILED); + } + if (dBuf->b_datap->db_type != SS_M_DATA) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS200, ERRZERO, "SAlignDBufEven : Incorrect\ + buffer type"); + RETVALUE(RFAILED); + } +#endif + + src = dBuf->b_rptr; +/* ss008.13: addition */ + if (!((PTR)src % (PTR)2)) + RETVALUE(ROK); + + if (dBuf->b_datap->db_ref > 1) + RETVALUE(RFAILED); + + len = dBuf->b_wptr - dBuf->b_rptr; + + if (dBuf->b_datap->db_base < dBuf->b_rptr) + { + dBuf->b_wptr = --dBuf->b_rptr; + while (len--) + *dBuf->b_wptr++ = *src++; + } + else + if (dBuf->b_datap->db_lim > dBuf->b_wptr) + { + src = dBuf->b_wptr - 1; + dBuf->b_rptr = ++dBuf->b_wptr; + while (len--) + *--dBuf->b_rptr = *src--; + } + else + RETVALUE(RFAILED); + + RETVALUE(ROK); +} + +/* ss004.13: addition */ +/* +* +* Fun: SAlignDBuf +* +* Desc: Align data portion of a data buffer on the specified +* boundary. No restriction is imposed on the alignment. +* +* Ret: ROK/RFAILED +* +* Notes: required by drivers (68360, 860) +* +* File: ss_msg.c +* +*/ +#ifdef ANSI +PUBLIC S16 SAlignDBuf +( +Buffer *dBuf, /* data buffer */ +U32 align /* alignemnt required */ +) +#else +PUBLIC S16 SAlignDBuf(dBuf, align) +Buffer *dBuf; /* data buffer */ +U32 align; /* alignemnt required */ +#endif +{ + MsgLen len; + Data *src; + U32 upShift; /* no. of bytes to be shifted up */ + U32 downShift; /* no. of bytes to be shifted down */ + + TRC1(SAlignDBuf) + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (!dBuf) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS201, ERRZERO, "SAlignDBuf: Null\ + Buffer"); + RETVALUE(RFAILED); + } + if (dBuf->b_datap->db_type != SS_M_DATA) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS202, ERRZERO, "SAlignDBuf: Incorrect\ + buffer type"); + RETVALUE(RFAILED); + } +#endif + + src = dBuf->b_rptr; +/* ss008.13: addition */ + upShift = (PTR)src % (PTR)align; /* no. of bytes by which to shift up + * the read and write pointers */ + + if (!upShift) + RETVALUE(ROK); + + if (dBuf->b_datap->db_ref > 1) + RETVALUE(RFAILED); + + downShift = align - upShift; /* no of bytes by which to shift down + * the read and write pointers */ + len = dBuf->b_wptr - dBuf->b_rptr; + + if (dBuf->b_datap->db_base <= (dBuf->b_rptr - upShift)) + { + /* there is space to shift up the read and write pointers */ + + dBuf->b_rptr -= upShift; /* align the read pointer */ + dBuf->b_wptr = dBuf->b_rptr; + SMemCpy( (Void *) dBuf->b_wptr, (Void *) src, (size_t) len); + dBuf->b_wptr = dBuf->b_wptr + len; + } + else + { + if (dBuf->b_datap->db_lim > dBuf->b_wptr + downShift) + { + src = dBuf->b_wptr - 1; + dBuf->b_wptr = dBuf->b_wptr + downShift; + dBuf->b_rptr = dBuf->b_wptr; + while (len--) + *--dBuf->b_rptr = *src--; + } + else + RETVALUE(RFAILED); + } + + RETVALUE(ROK); +} + + +/* +* +* Fun: SGetSMem +* +* Desc: Allocates a static buffer pool within the specified +* memory region. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: The new memory management scheme makes this function +* meaningless. It merely sets the pool ID to zero and +* returns. +* +* File: ss_msg.c +* +*/ +#ifdef ANSI +PUBLIC S16 SGetSMem +( +Region region, /* region ID */ +Size size, /* size */ +Pool *pool /* pointer to pool ID */ +) +#else +PUBLIC S16 SGetSMem(region, size, pool) +Region region; /* region ID */ +Size size; /* size */ +Pool *pool; /* pointer to pool ID */ +#endif +{ + TRC1(SGetSMem); + + + UNUSED(size); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* validate region ID */ + if (region >= SS_MAX_REGS) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS203, region, "Invalid region"); + RETVALUE(RFAILED); + } + + /* validate pointer to pool ID */ + if (pool == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS204, region, "Null pointer"); + RETVALUE(RFAILED); + } +#endif + + + /* set the pool ID to zero and return success */ + *pool = 0; + + + RETVALUE(ROK); +} + + +/* +* +* Fun: SPutSMem +* +* Desc: Deallocates a static buffer pool within the specified +* memory region. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: The new memory management scheme makes this function +* meaningless. It does nothing. +* +* File: ss_msg.c +* +*/ +#ifdef ANSI +PUBLIC S16 SPutSMem +( +Region region, /* region ID */ +Pool pool /* pool ID */ +) +#else +PUBLIC S16 SPutSMem(region, pool) +Region region; /* region ID */ +Pool pool; /* pool ID */ +#endif +{ + /* ss021.103 - Addition of return value */ +#if (ERRCLASS & ERRCLS_INT_PAR) + S16 ret; +#endif + + TRC1(SPutSMem); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* validate region ID */ + if (region >= SS_MAX_REGS) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS205, region, "Invalid region"); + RETVALUE(RFAILED); + } + + /* validate pool ID */ + if (pool >= SS_MAX_POOLS_PER_REG) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS206, region, "Invalid pool"); + RETVALUE(RFAILED); + } + + /* ss021.103 - Addition to check if region is registered */ + /* acquire one semaphore, to protect against deregistration */ + SS_ACQUIRE_SEMA(&osCp.regionTblSem, ret); + if (ret != ROK) + { + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS207, (ErrVal) ret, + "Could not lock region table"); +#endif + + RETVALUE(RFAILED); + } + + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* verify that this region is present */ + if (osCp.regionTbl[region].used == FALSE) + { + if( SS_RELEASE_SEMA(&osCp.regionTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS208, ERRZERO, + "Could not release semaphore"); + RETVALUE(RFAILED); +#endif + } + + SSLOGERROR(ERRCLS_INT_PAR, ESS209, region, "Region not registered"); + RETVALUE(RFAILED); + } +#endif + + if( SS_RELEASE_SEMA(&osCp.regionTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS210, ERRZERO, + "Could not release semaphore"); + RETVALUE(RFAILED); +#endif + } +#endif + + RETVALUE(ROK); +} + + +/* +* +* Fun: SChkRes +* +* Desc: Checks the available system resources (memory). +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: +* +* File: ss_msg.c +* +*/ +#ifdef ANSI +PUBLIC S16 SChkRes +( +Region region, /* region ID */ +Pool pool, /* pool ID */ +Status *status /* pointer to status */ +) +#else +PUBLIC S16 SChkRes(region, pool, status) +Region region; /* region ID */ +Pool pool; /* pool ID */ +Status *status; /* pointer to status */ +#endif +{ + S16 ret; + SMemCtl mctl; + + + TRC1(SChkRes); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* validate region ID */ + if (region >= SS_MAX_REGS) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS229, region, "Invalid region"); + RETVALUE(RFAILED); + } + + /* validate pool ID */ + if (pool >= SS_MAX_POOLS_PER_REG) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS230, region, "Invalid pool"); + RETVALUE(RFAILED); + } + + /* validate status pointer */ + if (status == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS231, ERRZERO, "Null pointer"); + RETVALUE(RFAILED); + } +#endif +/* ss037.103 Removed the semaphore operation for performance enhancement */ + +#ifndef SS_PERF + /* acquire one semaphore, to protect against deregistration */ + SS_ACQUIRE_SEMA(&osCp.regionTblSem, ret); + if (ret != ROK) + { + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS232, (ErrVal) ret, + "Could not lock region table"); +#endif + + RETVALUE(RFAILED); + } + + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* verify that this region is around */ + if (osCp.regionTbl[region].used == FALSE) + { + +/* ss006.13: addition */ + if( SS_RELEASE_SEMA(&osCp.regionTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS233, ERRZERO, + "Could not release semaphore"); + RETVALUE(RFAILED); +#endif + } + + SSLOGERROR(ERRCLS_INT_PAR, ESS234, region, "Region not registered"); + RETVALUE(RFAILED); + } + + /* verify that this is a valid pool */ + if (osCp.regionTbl[region].poolTbl[pool].type != SS_POOL_DYNAMIC) + { + SSLOGERROR(ERRCLS_DEBUG, ESS235, ERRZERO, "Invalid pool"); + RETVALUE(RFAILED); + } +#endif +#endif + + /* call the memory manager to check resources */ + mctl.op = SS_MEM_CHK_RES; + mctl.u.chkres.size = osCp.regionTbl[region].poolTbl[pool].u.dpool.size; + mctl.u.chkres.status = status; + ret = (osCp.regionTbl[region].ctl) + (osCp.regionTbl[region].regCb, SS_MEM_CHK_RES, &mctl); +#ifndef SS_PERF + /* release the semaphore we took */ + +/* ss006.13: addition */ + if( SS_RELEASE_SEMA(&osCp.regionTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS236, ERRZERO, + "Could not release semaphore"); + RETVALUE(RFAILED); +#endif + } +#endif + + RETVALUE(ret); +} + +/* +* +* Fun: SSwapMsg +* +* Desc: This function will swap two message data contents. +* The original mBuf pointers are unchanged. +* +* Ret: ROK - ok +* RFAILED - failed +* +* Notes: +* +* File: ss_msg.c +* +*/ + + +#ifdef ANSI +PUBLIC S16 SSwapMsg +( +Buffer *mBuf1, /* message 1 */ +Buffer *mBuf2 /* message 2 */ +) +#else +PUBLIC S16 SSwapMsg(mBuf1, mBuf2) +Buffer *mBuf1; /* message 1 */ +Buffer *mBuf2; /* message 2 */ +#endif +{ + SsMsgInfo *minfop; + SsMsgInfo minfo; +#if (ERRCLASS & ERRCLS_INT_PAR) + SsMsgInfo *minfo1; + SsMsgInfo *minfo2; +#endif + Buffer *tmp; + U8 tmp2; + + TRC1(SSwapMsg) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check message buffer 1 */ + if (mBuf1 == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS237, ERRZERO, "SSwapMsg : Null Buffer"); + RETVALUE(RFAILED); + } + /* check message buffer 2 */ + if (mBuf2 == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS238, ERRZERO, "SSwapMsg : Null Buffer"); + RETVALUE(RFAILED); + } + if (mBuf1->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS239, ERRZERO, "SSwapMsg: Incorrect buffer\ + type"); + RETVALUE(RFAILED); + } + if (mBuf2->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS240, ERRZERO, "SSwapMsg: Incorrect buffer\ + type"); + RETVALUE(RFAILED); + } + minfo1 = (SsMsgInfo*) mBuf1->b_rptr; + minfo2 = (SsMsgInfo*) mBuf2->b_rptr; + if (minfo1->region != minfo2->region) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS241, ERRZERO, "SSwapMsg: differnt regions\ + for messages"); + RETVALUE(RFAILED); + } +#endif + + + tmp = mBuf1->b_next; + mBuf1->b_next = mBuf2->b_next; + mBuf2->b_next = tmp; + + tmp = mBuf1->b_prev; + mBuf1->b_prev = mBuf2->b_prev; + mBuf2->b_prev = tmp; + + tmp = mBuf1->b_cont; + mBuf1->b_cont = mBuf2->b_cont; + mBuf2->b_cont = tmp; + +/* ss008.301 */ +#ifdef SS_DBLK_FREE_RTN + tmp = (Buffer *) mBuf1->b_datap->db_frtnp; + mBuf1->b_datap->db_frtnp = mBuf2->b_datap->db_frtnp; + mBuf2->b_datap->db_frtnp = (struct ssfree_rtn *) tmp; +#endif + + tmp2 = mBuf1->b_datap->db_ref; + mBuf1->b_datap->db_ref = mBuf2->b_datap->db_ref; + mBuf2->b_datap->db_ref = tmp2; + + + minfop = & minfo; + + SMemCpy((Void *) minfop, (Void *) (mBuf1->b_datap->db_base), (size_t)(sizeof(SsMsgInfo))); + SMemCpy((Void *) (mBuf1->b_datap->db_base), (Void *) (mBuf2->b_datap->db_base), (size_t)(sizeof(SsMsgInfo))); + SMemCpy((Void *) (mBuf2->b_datap->db_base), (Void *) minfop, (size_t)(sizeof(SsMsgInfo))); + + RETVALUE(ROK); +} +/* ss004.301 : Cavium changes */ +#ifdef SS_SEUM_CAVIUM + +/* + * + * Fun: SConvPtrPhy + * + * Desc: This function will converts the pointer to + * physical address. + * + * Ret: ROK - ok + * RFAILED - failed, general (optional) + * + * Notes: Function to convert the Pointer (Virtual address) to + * Physical Address. This will take the Buffer type as + * input and will convert all pointer associated with + * that to Physical Address + * + * File: ss_msg.c + * + */ +#ifdef ANSI +PUBLIC S16 SConvPtrPhy +( + Buffer **mBuf +) +#else +PUBLIC S16 SConvPtrPhy (mBuf) + Buffer **mBuf; +#endif +{ + + Buffer *curPtr; + Buffer *nextPtr; + SsMsgInfo *minfoPtr; + SsDblk *dblkPtr; + SsFrtn *frtnPtr; + + TRC1(SConvPtrPhy); + + + /* check mBuf for NULLP */ + if ( (mBuf == NULLP) || (*mBuf == NULLP ) ) + { + RETVALUE(RFAILED); + } + + /* first block in Buffer is head */ + curPtr = *mBuf; + nextPtr = curPtr->b_cont; + + /* Get the physical address of the Pointer */ + if(curPtr->b_cont) + { + curPtr->b_cont = (Buffer*)cvmx_ptr_to_phys (curPtr->b_cont); + } + + if(curPtr->b_next) + { + curPtr->b_next = (Buffer*)cvmx_ptr_to_phys (curPtr->b_next); + } + + if(curPtr->b_prev) + { + curPtr->b_prev = (Buffer*)cvmx_ptr_to_phys (curPtr->b_prev); + } + + /* Convert the pointers of Minfo to Physical addr */ + minfoPtr = (SsMsgInfo*)curPtr->b_rptr; + + if (minfoPtr->endptr) + { + minfoPtr->endptr = (Buffer*)cvmx_ptr_to_phys (minfoPtr->endptr); + } + if (minfoPtr->next) + { + minfoPtr->next = (Buffer*)cvmx_ptr_to_phys (minfoPtr->next); + } + + curPtr->b_rptr = (U8*)cvmx_ptr_to_phys (curPtr->b_rptr); + + curPtr->b_wptr = (U8*)cvmx_ptr_to_phys (curPtr->b_wptr); + + /* Convert the pointers of Dblock to Physical addr */ + dblkPtr = (SsDblk*)curPtr->b_datap; + +/* ss008.301 */ +#ifdef SS_DBLK_FREE_RTN + frtnPtr = dblkPtr->db_frtnp; + if( frtnPtr != NULLP) + { + if (frtnPtr->free_func) + { + frtnPtr->free_func = (Void*)cvmx_ptr_to_phys (frtnPtr->free_func); + } + if (frtnPtr->free_arg) + { + frtnPtr->free_arg = (S8*)cvmx_ptr_to_phys (frtnPtr->free_arg); + } + + dblkPtr->db_frtnp = (SsFrtn*)cvmx_ptr_to_phys (dblkPtr->db_frtnp); + } +#endif + + dblkPtr->db_base = (U8*)cvmx_ptr_to_phys (dblkPtr->db_base); + dblkPtr->db_lim = (U8*)cvmx_ptr_to_phys (dblkPtr->db_lim); + + curPtr->b_datap = (SsDblk*)cvmx_ptr_to_phys (curPtr->b_datap); + + /* second block onwards is dblk */ + curPtr = nextPtr; + + while(curPtr) + { + nextPtr = curPtr->b_cont; + + /* Get the physical address of the Pointer */ + if(curPtr->b_cont) + { + curPtr->b_cont = (Buffer*)cvmx_ptr_to_phys (curPtr->b_cont); + } + + curPtr->b_rptr = (U8*)cvmx_ptr_to_phys (curPtr->b_rptr); + curPtr->b_wptr = (U8*)cvmx_ptr_to_phys (curPtr->b_wptr); + + /* Convert the pointers of Dblock to Physical addr */ + dblkPtr = (SsDblk*)curPtr->b_datap; + +/* ss008.301 */ +#ifdef SS_DBLK_FREE_RTN + frtnPtr = dblkPtr->db_frtnp; + if( frtnPtr != NULLP) + { + if (frtnPtr->free_func) + { + frtnPtr->free_func = (Void*)cvmx_ptr_to_phys (frtnPtr->free_func); + } + if (frtnPtr->free_arg) + { + frtnPtr->free_arg = (S8*)cvmx_ptr_to_phys (frtnPtr->free_arg); + } + + dblkPtr->db_frtnp = (SsFrtn*)cvmx_ptr_to_phys (dblkPtr->db_frtnp); + } +#endif + + dblkPtr->db_base = (U8*)cvmx_ptr_to_phys (dblkPtr->db_base); + dblkPtr->db_lim = (U8*)cvmx_ptr_to_phys (dblkPtr->db_lim); + + curPtr->b_datap = (SsDblk*)cvmx_ptr_to_phys (curPtr->b_datap); + + curPtr = nextPtr; + + } + + *mBuf = (Buffer*)cvmx_ptr_to_phys (*mBuf); + + RETVALUE(ROK); + +} /* SConvPtrPhy */ + +/* + * + * Fun: SConvPhyPtr + * + * Desc: This function will converts the physical address + * into pointers. + * + * Ret: On Success - Pointer to converted buffer + * On Failuer - Returns NULL + * + * Notes: Function to Convert the Physical address to Pointer + * (Virtual address) This will take work buffer as input + * and will convert all address associated with that to + * Pointers. + * + * File: ss_msg.c + * + */ +#ifdef ANSI +PUBLIC S16 SConvPhyPtr +( + Buffer **workPtr + ) +#else +PUBLIC S16 SConvPhyPtr (workPtr) + Buffer **workPtr; +#endif +{ + + Buffer *curPtr; + Buffer *mBuf; + SsMsgInfo *minfoPtr; + SsDblk *dblkPtr; + SsFrtn *frtnPtr; + + TRC1(SConvPhyPtr); + + + /* check workPtr for NULLP */ + if ( (workPtr == NULLP) || (*workPtr == NULLP) ) + { + RETVALUE(RFAILED); + } + + /* Convert the buffer address to pointer */ + mBuf = (Buffer*)cvmx_phys_to_ptr ((U64)(*workPtr)); + + curPtr = mBuf; + + /* first block is mblk */ + if (curPtr->b_next) + { + curPtr->b_next = (Buffer*)cvmx_phys_to_ptr ((U64)curPtr->b_next); + } + + if (curPtr->b_prev) + { + curPtr->b_prev = (Buffer*)cvmx_phys_to_ptr ((U64)curPtr->b_prev); + } + + if(curPtr->b_cont) + { + curPtr->b_cont = (Buffer*)cvmx_phys_to_ptr ((U64)curPtr->b_cont); + } + + curPtr->b_rptr = (U8*)cvmx_phys_to_ptr ((U64)curPtr->b_rptr); + + /* Get the pointer for minfo */ + minfoPtr = (SsMsgInfo*)curPtr->b_rptr; + + if (minfoPtr->endptr) + { + minfoPtr->endptr = (Buffer*)cvmx_phys_to_ptr ((U64)minfoPtr->endptr); + } + if (minfoPtr->next) + { + minfoPtr->next = (Buffer*)cvmx_phys_to_ptr ((U64)minfoPtr->next); + } + + curPtr->b_wptr = (U8*)cvmx_phys_to_ptr ((U64)curPtr->b_wptr); + + curPtr->b_datap = (SsDblk*)cvmx_phys_to_ptr ((U64)curPtr->b_datap); + + /* Get the Dblock pointers */ + dblkPtr = (SsDblk*)curPtr->b_datap; + +/* ss008.301 */ +#ifdef SS_DBLK_FREE_RTN + if (dblkPtr->db_frtnp) + { + dblkPtr->db_frtnp = (SsFrtn*)cvmx_phys_to_ptr ((U64)dblkPtr->db_frtnp); + frtnPtr = dblkPtr->db_frtnp; + + if (frtnPtr->free_func) + { + frtnPtr->free_func = cvmx_phys_to_ptr ((U64)frtnPtr->free_func); + } + if (frtnPtr->free_arg) + { + frtnPtr->free_arg = (S8*)cvmx_phys_to_ptr ((U64)frtnPtr->free_arg); + } + } +#endif + + dblkPtr->db_base = (U8*)cvmx_phys_to_ptr ((U64)dblkPtr->db_base); + dblkPtr->db_lim = (U8*)cvmx_phys_to_ptr ((U64)dblkPtr->db_lim); + + curPtr = curPtr->b_cont; + + /* after the first block is dblk */ + while(curPtr) + { + if(curPtr->b_cont) + { + curPtr->b_cont = (Buffer*)cvmx_phys_to_ptr ((U64)curPtr->b_cont); + } + + curPtr->b_rptr = (U8*)cvmx_phys_to_ptr ((U64)curPtr->b_rptr); + + curPtr->b_wptr = (U8*)cvmx_phys_to_ptr ((U64)curPtr->b_wptr); + + curPtr->b_datap = (SsDblk*)cvmx_phys_to_ptr ((U64)curPtr->b_datap); + + /* Get the Dblock pointers */ + dblkPtr = (SsDblk*)curPtr->b_datap; + +/* ss008.301 */ +#ifdef SS_DBLK_FREE_RTN + if (dblkPtr->db_frtnp) + { + dblkPtr->db_frtnp = (SsFrtn*)cvmx_phys_to_ptr ((U64)dblkPtr->db_frtnp); + + frtnPtr = dblkPtr->db_frtnp; + + if (frtnPtr->free_func) + { + frtnPtr->free_func = cvmx_phys_to_ptr ((U64)frtnPtr->free_func); + } + if (frtnPtr->free_arg) + { + frtnPtr->free_arg = (S8*)cvmx_phys_to_ptr ((U64)frtnPtr->free_arg); + } + } +#endif + + dblkPtr->db_base = (U8*)cvmx_phys_to_ptr ((U64)dblkPtr->db_base); + dblkPtr->db_lim = (U8*)cvmx_phys_to_ptr ((U64)dblkPtr->db_lim); + + curPtr = curPtr->b_cont; + } + + /* Place the converted buffer */ + *workPtr = mBuf; + + RETVALUE(ROK); + +} /* SConvPhyPtr */ + +/* + * + * Fun: SCpyFpaMsg + * + * Desc: This function will copy the message from FPA region + * to other region + * + * Ret: On Success - ROK + * On Failuer - RFAILED + * + * Notes: Function to copy the message from FPA region to + * other region. This will internally allocates the + * memory for the destination buffer and copies the + * message in the same chain list + * + * File: + * + */ +#ifdef ANSI +PUBLIC S16 SCpyFpaMsg +( + Buffer *srcBuf, + Region dstRegion, + Pool dstPool, + Buffer **dstBuf + ) +#else +PUBLIC S16 SCpyFpaMsg (srcBuf, dstRegion, dstPool, dstBuf) + Buffer *srcBuf; + Region dstRegion; + Pool dstPool; + Buffer **dstBuf; +#endif +{ + + Size numBytes; + Size size; + S16 ret; + Buffer *curPtr = NULLP; + Data *dat = NULLP; + Buffer *tmpblk = NULLP; + Buffer *newblk = NULLP; + Buffer *prevblk = NULLP; + SsMsgInfo *minfoSrc = NULLP; + SsMsgInfo *minfoDst = NULLP; + SsDblk *dblkPtr = NULLP; + SsDblk *dptr = NULLP; + + TRC1(SCpyFpaMsg); + + + if ( srcBuf == (Buffer*)NULLP ) + { + RETVALUE(RFAILED); + } + + if ((dstRegion >= SS_MAX_REGS) || (dstPool >= SS_MAX_POOLS_PER_REG)) + { + /* Free the source buffer and return failure */ + SPutFpaMsg(srcBuf); + RETVALUE(RFAILED); + } + + /* Allocate memory for destination buffer */ + if(SGetMsg(dstRegion, dstPool, dstBuf) != ROK) + { + /* Free the source buffer and return failure */ + SPutFpaMsg(srcBuf); + RETVALUE(ROUTRES); + } + + /* get the minfo of dest and src buffers */ + minfoSrc = (SsMsgInfo*) srcBuf->b_rptr; + minfoDst = (SsMsgInfo*) (*dstBuf)->b_rptr; + + curPtr = srcBuf->b_cont; + + /* Copy all the blocks associated with this Buffer */ + while(curPtr) + { + /* Allocate the memeory for dblock */ + + dblkPtr = (SsDblk*)curPtr->b_datap; + numBytes = dblkPtr->db_lim - dblkPtr->db_base; + size = numBytes + MDBSIZE; + + ret = SAlloc( dstRegion, &size, 0, (Data**)&tmpblk); + + if(ret != ROK) + { + /* Free all allocated buffers before returning */ + while (newblk) + { + tmpblk = newblk->b_cont; + (Void) SPutDBuf(dstRegion, dstPool, newblk); + newblk = tmpblk; + } + (Void) SPutMsg(*dstBuf); + /* Free the source buffer and return failure */ + SPutFpaMsg(srcBuf); + RETVALUE(ROUTRES); + } + + dat = (Data *)tmpblk + MDBSIZE; + dptr = (SsDblk*) (((Data *) tmpblk) + MBSIZE); + size -= MDBSIZE; + + /* Initialize the pointer and copy the data */ + INITB( tmpblk, dptr, dat, size, NULLP ); +#ifndef SS_DBUF_REFLOCK_DISABLE + SInitLock (&(dptr->dBufLock), SS_LOCK_MUTEX); +#endif + numBytes = curPtr->b_wptr - curPtr->b_rptr; + /* Copy the data part if its present */ + if (numBytes > 0 ) + { + SMemCpy( (Void *) tmpblk->b_wptr, (Void *) curPtr->b_rptr, numBytes); + tmpblk->b_wptr += numBytes; + } + + if (!prevblk) + { + newblk = tmpblk; + } + else + { + prevblk->b_cont = tmpblk; + } + + prevblk = tmpblk; + curPtr = curPtr->b_cont; + } + + if (tmpblk) + { + tmpblk->b_cont = NULLP; + } + + *minfoDst = *minfoSrc; + minfoDst->region = 0; + minfoDst->pool = 0; + minfoDst->len = minfoSrc->len; + minfoDst->endptr = tmpblk; + minfoDst->next = NULLP; + + (*dstBuf)->b_cont = newblk; + + /* Free the source buffer after copying it */ + SPutFpaMsg(srcBuf); + + RETVALUE(ROK); + +} /* SCpyFpaMsg */ + +/* + * + * Fun: SCpyMsgFpa + * + * Desc: This function will copy the message from any region + * to FPA region + * + * Ret: On Success - ROK + * On Failuer - RFAILED + * + * Notes: Function will copy the mbuf from msg to FPA. + * This function allocates the memory internally + * and copies the message to newly allocated mBuf. + * The size of mBuf should be either of one + * pre-difined sizes otherwise mBuf is dopped. + * + * File: + * + */ +#ifdef ANSI +PUBLIC S16 SCpyMsgFpa +( + Buffer *srcBuf, + Buffer **dstBuf + ) +#else +PUBLIC S16 SCpyMsgFpa (srcBuf, dstBuf) + Buffer *srcBuf; + Buffer **dstBuf; +#endif +{ + + Buffer *curPtr = NULLP; + Data *dat = NULLP; + Buffer *tmpblk = NULLP; + Buffer *prevblk = NULLP; + Buffer *newblk = NULLP; + SsMsgInfo *minfoSrc = NULLP; + SsMsgInfo *minfoDst = NULLP; + SsDblk *dblkPtr = NULLP; + SsDblk *dptr = NULLP; + U32 numBytes; + Pool pool; + + TRC1(SCpyMsgFpa); + + + if (srcBuf == (Buffer*)NULLP) + { + RETVALUE(RFAILED); + } + + *dstBuf = (Buffer*)cvmx_fpa_alloc(SS_CVMX_POOL_0); + + if ( *dstBuf == NULLP ) + { + /* Free the source buffer before returning */ + SPutMsg(srcBuf); + RETVALUE(ROUTRES); + } + + dat = (Data *)(*dstBuf) + MDBSIZE; + dptr = (SsDblk*) ((Data *)(*dstBuf) + MBSIZE); + numBytes = SS_CVMX_POOL_0_SIZE - MDBSIZE; + + /* Initialize the pointers of new block */ + INITB((*dstBuf), dptr, dat, numBytes, NULLP); + + (*dstBuf)->b_datap->db_type = SS_M_PROTO; + (*dstBuf)->b_wptr = (*dstBuf)->b_rptr + sizeof(SsMsgInfo); + + minfoSrc = (SsMsgInfo*) srcBuf->b_rptr; + minfoDst = (SsMsgInfo*) (*dstBuf)->b_rptr; + curPtr = srcBuf->b_cont; + + while(curPtr) + { + dblkPtr = (SsDblk*)curPtr->b_datap; + + /* Get the size required which is to be allocated */ + numBytes = dblkPtr->db_lim - dblkPtr->db_base; + numBytes += MDBSIZE; + + /* get the pool depending on the size need to be allocated */ + switch(numBytes) + { + case SS_CVMX_POOL_0_SIZE: + + pool = SS_CVMX_POOL_0; + break; + + case SS_CVMX_POOL_1_SIZE: + + pool = SS_CVMX_POOL_1; + break; + + case SS_CVMX_POOL_2_SIZE: + + pool = SS_CVMX_POOL_2; + break; + + case SS_CVMX_POOL_3_SIZE: + + pool = SS_CVMX_POOL_3; + break; + + default: + /* size doesn't match, drop the mBuf and returning + * RFAILED */ + SSLOGERROR(ERRCLS_INT_PAR, ESS048, ERRZERO, "SCpyMsgFpa: Invalid\ + buffer size, dropping the message"); + + (*dstBuf)->b_cont = newblk; + SPutFpaMsg(*dstBuf); + /* Free the source buffer before returning */ + SPutMsg(srcBuf); + RETVALUE(RFAILED); + } + + /* Allocate for mBuf and copy both the header and contents */ + tmpblk = (Buffer*)cvmx_fpa_alloc(pool); + + if ( tmpblk == NULLP ) + { + /* Return error if fails to allocate memory */ + + (*dstBuf)->b_cont = newblk; + SPutFpaMsg(*dstBuf); + /* Free the source buffer before returning */ + SPutMsg(srcBuf); + RETVALUE(ROUTRES); + } + + dat = (Data *)tmpblk + MDBSIZE; + dptr = (SsDblk*) (((Data *) tmpblk) + MBSIZE); + numBytes -= MDBSIZE; + + /* Initialize the pointers of new block */ + INITB( tmpblk, dptr, dat, numBytes, NULLP ); + + numBytes = curPtr->b_wptr - curPtr->b_rptr; + /* Copy the message contents */ + if (numBytes > 0 ) + { + SMemCpy( (Void *) tmpblk->b_wptr, (Void *) curPtr->b_rptr, numBytes); + tmpblk->b_wptr += numBytes; + } + + /* Add the mew mBuf to the Buffer chain */ + if (!prevblk) + { + newblk = tmpblk; + } + else + { + prevblk->b_cont = tmpblk; + } + + prevblk = tmpblk; + /* Get the next block */ + curPtr = curPtr->b_cont; + } + + /* Initialize the last mBuf */ + if (tmpblk) + { + tmpblk->b_cont = NULLP; + } + + *minfoDst = *minfoSrc; + minfoDst->region = 0; + minfoDst->pool = 0; + minfoDst->len = minfoSrc->len; + minfoDst->endptr = tmpblk; + minfoDst->next = NULLP; + + (*dstBuf)->b_cont = newblk; + + /* Free the source buffer after copying it */ + SPutMsg(srcBuf); + + RETVALUE(ROK); + +} /* SCpyMsgFpa */ + +/* + * + * Fun: SPutFpaMsg + * + * Desc: This function will free the Buffer associated with + * FPA pool. + * + * Ret: On Success - ROK + * On Failuer - RFAILED + * + * Notes: Function free the all buffer associated with wqBuf + * This will get the pool id by the size of the buffer + * and same will be used to free the buffer. + * + * File: + * + */ +#ifdef ANSI +PUBLIC S16 SPutFpaMsg +( + Buffer *fpaBuf +) +#else +PUBLIC S16 SPutFpaMsg(fpaBuf) +Buffer *fpaBuf; +#endif +{ + U16 size; + Buffer *curBlk; + Buffer *nextBlk; + SsDblk *dblkPtr; + + TRC1(SPutFpaMsg); + + if( fpaBuf == NULLP ) + { + RETVALUE(ROK); + } + + curBlk = fpaBuf->b_cont; + + while(curBlk) + { + nextBlk = curBlk->b_cont; + + dblkPtr = (SsDblk*)curBlk->b_datap; + + size = dblkPtr->db_lim - dblkPtr->db_base + MDBSIZE; + + /* Free the dblock according to its size */ + switch(size) + { + case SS_CVMX_POOL_0_SIZE: + cvmx_fpa_free(curBlk, SS_CVMX_POOL_0, 0); + break; + + case SS_CVMX_POOL_1_SIZE: + cvmx_fpa_free(curBlk, SS_CVMX_POOL_1, 0); + break; + + case SS_CVMX_POOL_2_SIZE: + cvmx_fpa_free(curBlk, SS_CVMX_POOL_2, 0); + break; + + case SS_CVMX_POOL_3_SIZE: + cvmx_fpa_free(curBlk, SS_CVMX_POOL_3, 0); + break; + + default: + SSLOGERROR(ERRCLS_INT_PAR, ESS048, ERRZERO, "SPutFpaMsg: Invalid\ + buffer size, dropping the message"); + break; + } + + curBlk = nextBlk; + } + + cvmx_fpa_free(fpaBuf, SS_CVMX_POOL_0, 0); + + RETVALUE(ROK); + +} /* SPutFpaMsg */ + +#endif /* SS_SEUM_CAVIUM */ + +/* ss006.301 : new buffer management APIs, start */ +/* +* +* Fun: SCpyPartMsg +* +* Desc: This function is used to copy a portion of message(srcBuf) into +* another msg(dstBuf) +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) - In this case +* caller shall reclaim the resources allocated for dstBuf. +* +* Notes: None +* +* File: ss_msg.c +* +*/ + +#ifdef ANSI +PUBLIC S16 SCpyPartMsg +( +Buffer *srcBuf, +MsgLen idx, +MsgLen cnt, +Buffer *dstBuf +) +#else +PUBLIC S16 SCpyPartMsg(srcBuf, idx, cnt, dstBuf) +Buffer *srcBuf; +MsgLen idx; +MsgLen cnt; +Buffer *dstBuf; +#endif +{ + SsMsgInfo *sMinfo; + SsMsgInfo *dMinfo; + Buffer *dBuf; + Buffer *sBuf; + Buffer *dPrev; + MsgLen sCnt; + MsgLen dCnt; + MsgLen numCpd; + + TRC1(SCpyPartMsg) + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (!srcBuf) + { + SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SCpyPartMsg : Null src Buffer"); + RETVALUE(RFAILED); + } + if (srcBuf->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SCpyPartMsg : Incorrect\ + src buffer type"); + RETVALUE(RFAILED); + } + if(!dstBuf) + { + SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SCpyPartMsg : Null dst Buffer"); + RETVALUE(RFAILED); + } + if (dstBuf->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SCpyPartMsg : Incorrect\ + dst buffer type"); + RETVALUE(RFAILED); + } +#endif /* (ERRCLASS & ERRCLS_INT_PAR) */ + + /* if index > length of mBuf, return */ + sMinfo = (SsMsgInfo*)srcBuf->b_rptr; + dMinfo = (SsMsgInfo*)dstBuf->b_rptr; + + if (idx >= sMinfo->len) + { + SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SCpyPartMsg : Incorrect\ + idx value "); + RETVALUE(RFAILED); + } + + sBuf = srcBuf->b_cont; + FIND_OFFSET(sBuf, idx) + + dPrev = dstBuf; +/*-- ss008.301 */ + dBuf = (dMinfo->endptr) ? (dMinfo->endptr) : (dstBuf->b_cont); + if(dMinfo->endptr) + { + Buffer *crnt; + crnt = dPrev->b_cont; + while(crnt) + { + dPrev = crnt; + crnt = crnt->b_cont; + } + } + dCnt = 0; + numCpd = 0; + while(cnt && sBuf) + { + sCnt = sBuf->b_wptr - (sBuf->b_rptr + idx); + if(dBuf) + { + dCnt = dBuf->b_datap->db_lim - dBuf->b_wptr; + } + else + { + /* allocate a data buffer */ + if (SGetDBuf(dMinfo->region, dMinfo->pool, &dBuf) != ROK) + { + SSLOGERROR(ERRCLS_DEBUG, ESS125, ERRZERO, "SCpyPartMsg : SGetDBuf\ + failed"); + RETVALUE(ROUTRES); + } + dCnt = MIN(cnt, (dBuf->b_datap->db_lim - dBuf->b_datap->db_base)); + dPrev->b_cont = dBuf; + dPrev = dBuf; + } + if(sCnt > cnt) /* src Dblk has enough data to copy */ + { + if(dCnt < cnt) + { + SMemCpy((void*)dBuf->b_wptr, (void*)(sBuf->b_rptr + idx), dCnt); + cnt -= dCnt; + dBuf->b_wptr += dCnt; + dBuf = dBuf->b_cont; + idx += dCnt; + numCpd += dCnt; + } + else + { + SMemCpy((void*)dBuf->b_wptr, (void*)(sBuf->b_rptr + idx), cnt); + dBuf->b_wptr += cnt; + dBuf->b_cont = NULLP; + numCpd += cnt; + cnt = 0; + break; + } + } + else /* src dBlk has partial data to be copied */ + { + if(dCnt < sCnt) + { + SMemCpy((void*)dBuf->b_wptr, (void*)(sBuf->b_rptr + idx), dCnt); + dBuf->b_wptr += dCnt; + dBuf = dBuf->b_cont; + cnt -= dCnt; + idx += dCnt; + numCpd += dCnt; + } + else + { + SMemCpy((void*)dBuf->b_wptr, (void*)(sBuf->b_rptr + idx), sCnt); + dBuf->b_wptr += sCnt; + cnt -= sCnt; + sBuf = sBuf->b_cont; + numCpd += sCnt; + idx = 0; + } + } + } + /* update the msgLen in dstBuf */ + dMinfo->len += numCpd; + dMinfo->endptr = dBuf; + + RETVALUE(ROK); +} + +/* +* +* Fun: SRepPartMsg +* +* Desc: This function is used to replace a portion of message(mBuf) with the +* given data +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: None +* +* File: ss_msg.c +* +*/ + +#ifdef ANSI +PUBLIC S16 SRepPartMsg +( +Buffer *srcBuf, +MsgLen idx, +MsgLen cnt, +Buffer *dstBuf +) +#else +PUBLIC S16 SRepPartMsg(srcBuf, idx, cnt, dstBuf) +Buffer *srcBuf; +MsgLen idx; +MsgLen cnt; +Buffer *dstBuf; +#endif +{ + SsMsgInfo *sMinfo; + SsMsgInfo *dMinfo; + Buffer *dBuf; + Buffer *sBuf; + MsgLen dCnt; + MsgLen sCnt; + MsgLen sIdx; + MsgLen cpBytes; + + TRC1(SRepPartMsg) + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (!dstBuf) + { + SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SRepPartMsg : Null dstBuf"); + RETVALUE(RFAILED); + } + if (dstBuf->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SRepPartMsg : Incorrect\ + dstBuf buffer type"); + RETVALUE(RFAILED); + } + if(!srcBuf) + { + SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SRepPartMsg : Null Src Buffer "); + RETVALUE(RFAILED); + } + if (srcBuf->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SRepPartMsg : Incorrect\ + sBuf buffer type"); + RETVALUE(RFAILED); + } +#endif /* (ERRCLASS & ERRCLS_INT_PAR) */ + + dMinfo = (SsMsgInfo*)dstBuf->b_rptr; + sMinfo = (SsMsgInfo*)srcBuf->b_rptr; + + if(((idx + cnt) > dMinfo->len) || (cnt < sMinfo->len)) + { + SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SRepPartMsg : Incorrect\ + cnt value "); + RETVALUE(RFAILED); + } + + dBuf = dstBuf->b_cont; + FIND_OFFSET(dBuf, idx) + sBuf = srcBuf->b_cont; + sIdx = 0; + while(cnt && dBuf && sBuf) + { + dCnt = (dBuf->b_wptr - (dBuf->b_rptr + idx)); + sCnt = sBuf->b_wptr - (sBuf->b_rptr + sIdx); + cpBytes = MIN(cnt, sCnt); + cpBytes = MIN(cpBytes, dCnt); + SMemCpy((void*)(dBuf->b_rptr + idx), (void*)(sBuf->b_rptr + sIdx), cpBytes); + + if(cpBytes < cnt) + { + if(cpBytes == sCnt) + { + /* move to next DBlk in srcBuf */ + sBuf = sBuf->b_cont; + idx += cpBytes; + sIdx = 0; + } + else /* cpBytes equals dCnt */ + { + /* move to the next DBlk in dstBuf */ + dBuf = dBuf->b_cont; + idx = 0; + sIdx += cpBytes; + } + cnt -= cpBytes; + } + else + { + cnt = 0; + break; + } + } + if(cnt) + { + SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SRepPartMsg : unable to replace\ + some bytes "); + RETVALUE(RFAILED); + } + + RETVALUE(ROK); +} + +/* +* +* Fun: SMovPartMsg +* +* Desc: This function will move a portion of the first msg to second msg +* +* Ret: ROK - ok +* ROKDNA - ok, data not available +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: message 1 is the message from which the segment will be copied +* +* message 2 is the updated message. +* +* index is 0 based and indicates location in message 1 +* up to which the data will be copied to message 2 +* +* if index is equal to 0, message 1 will not be changed and no data + shall be copied to message 2. +* message 1 is not returned to memory. return is ok. +* +* if index is not equal to 0 and less than the length of +* the message minus 1: data upto index, shall be copied to message 2 +* and read/write pointers of message 1 will be updated accordingly +* +* if index is not equal to 0 and greater than or equal to +* the length of the message minus 1: all of the message 1 data. +* shall be copied to message 2. return is ok. +* +* File: ss_msg.c +* +*/ + + +#ifdef ANSI +PUBLIC S16 SMovPartMsg +( +Buffer *srcBuf, /* message 1 */ +MsgLen idx, /* index */ +Buffer *dstBuf /* message 2 */ +) +#else +PUBLIC S16 SMovPartMsg(srcBuf, idx, dstBuf) +Buffer *srcBuf; /* message 1 */ +MsgLen idx; /* index */ +Buffer *dstBuf; /* message 2 */ +#endif +{ + MsgLen dCnt; + MsgLen sCnt; + Buffer *dPrev; + Buffer *sBuf; + Buffer *dBuf; + SsMsgInfo *sMinfo; + SsMsgInfo *dMinfo; +#ifdef T2K_MEM_LEAK_DBG + char* file = __FILE__; + U32 line = __LINE__; +#endif + + TRC1(SMovPartMsg) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check message buffer 1 */ + if ((!srcBuf) || (!dstBuf )) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS097, ERRZERO, "SMovPartMsg : Null Buffer (src or Dst)"); + RETVALUE(RFAILED); + } + if (idx < 0) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS099, ERRZERO, "SMovPartMsg : Invalid index"); + RETVALUE(RFAILED); + } + if ((srcBuf->b_datap->db_type != SS_M_PROTO) || (dstBuf->b_datap->db_type != SS_M_PROTO)) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS100, ERRZERO, "SMovPartMsg : Incorrect buffer\ + type"); + RETVALUE(RFAILED); + } +#endif + + /* get the SsMsgInfo of srcBuf */ + sMinfo = (SsMsgInfo*) srcBuf->b_rptr; + + /* get the SsMsgInfo of dstBuf */ + dMinfo = (SsMsgInfo*) dstBuf->b_rptr; + + /* if index > length of mBuf, return */ + /*-- ss008.301 */ + if (idx > sMinfo->len) + { + RETVALUE(ROKDNA); + } + + /* one block might not sufficient - Check for generic implementation */ + sBuf = srcBuf->b_cont; + /* dBuf = dMinfo->endptr; */ + dPrev = (dBuf = dMinfo->endptr) ? dBuf : dstBuf; + + /* adjust the lengths of srcBuf, dstBuf */ + sMinfo->len -= idx; + dMinfo->len += idx; + + while(idx && sBuf) + { + sCnt = sBuf->b_wptr - sBuf->b_rptr; + if(!dBuf) + { + /* allocate a data buffer */ + if (SGetDBuf(dMinfo->region, dMinfo->pool, &dBuf) != ROK) + { + SSLOGERROR(ERRCLS_DEBUG, ESS125, ERRZERO, "SCpyMsgPartMsg : SGetDBuf\ + failed"); + RETVALUE(ROUTRES); + } + dCnt = MIN(idx, (dBuf->b_datap->db_lim - dBuf->b_datap->db_base)); + dPrev->b_cont = dBuf; + dPrev = dBuf; + } + else + { + dCnt = dBuf->b_datap->db_lim - dBuf->b_wptr; + } + if(sCnt > idx) /* src Dblk has enough data to copy */ + { + if(dCnt < idx) + { + SMemCpy((void*)dBuf->b_wptr, (void*)(sBuf->b_rptr), dCnt); + dBuf->b_wptr += dCnt; + dBuf = dBuf->b_cont; + idx -= dCnt; + sBuf->b_rptr += dCnt; + } + else + { + SMemCpy((void*)dBuf->b_wptr, (void*)(sBuf->b_rptr), idx); + dBuf->b_wptr += idx; + dBuf->b_cont = NULLP; + sBuf->b_rptr += idx; + idx = 0; + break; + } + } + else /* src dBlk has partial data to be copied */ + { + if(dCnt < sCnt) + { + SMemCpy((void*)dBuf->b_wptr, (void*)(sBuf->b_rptr), dCnt); + dBuf->b_wptr += dCnt; + dBuf = dBuf->b_cont; + idx -= dCnt; + sBuf->b_rptr += dCnt; + } + else + { + Buffer *tmp; + SMemCpy((void*)dBuf->b_wptr, (void*)(sBuf->b_rptr), sCnt); + dBuf->b_wptr += sCnt; + idx -= sCnt; + /* deallocate the sBuf here */ + tmp = sBuf->b_cont; + /* printf("SMovPartMsg() sBuf is completely copied sBuf->b_cont(%p)\n", sBuf->b_cont); */ + (Void)SPutDBuf(sMinfo->region, sMinfo->pool, sBuf); + srcBuf->b_cont = sBuf = tmp; + } + } + } + dMinfo->endptr = dBuf; + if(idx) + { + sMinfo->len += idx; + dMinfo->len -= idx; + SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SMovPartMsg : unable to copy\ + some bytes "); + RETVALUE(RFAILED); + } + + RETVALUE(ROK); +} + +/* +* +* Fun: SPkMsgMult +* +* Desc: This function copies consecutive bytes of data to the +* beginning of a message. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: if message is empty: data is placed in the message. message +* length is incremented. return is ok. +* +* if message is not empty: data is read by source pointer, +* data is placed in front of all other data in message. +* message length is incremented. return is ok. +* +* the first byte of data pointed to by the source pointer +* will be placed at the front of the message first (i.e. it +* will become the first byte of the message) and the last +* byte will be placed in front of the existing msg contents, +* i.e. order of the source is preserved. +* +* File: ss_msg.c +* +*/ + +#ifdef ANSI +PUBLIC S16 SPkMsgMult +( +Data *src, +MsgLen cnt, +Buffer *mBuf +) +#else +PUBLIC S16 SPkMsgMult(src, cnt, mBuf) +Data *src; +MsgLen cnt; +Buffer *mBuf; +#endif +{ + SsMsgInfo *minfo; /* Message info */ + Buffer *tmp; + Buffer *newblk; + MsgLen numBytes; /* no. of bytes to be copied */ + MsgLen offset; + + TRC1(SPkMsgMult) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check message buffer */ + if (mBuf == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS070, ERRZERO, "SPkMsgMult:Null Buffer"); + RETVALUE(RFAILED); + } + /* check source */ + if (src == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS071, ERRZERO, "SPkMsgMult:Null Buffer"); + RETVALUE(RFAILED); + } + /* check count */ + if (cnt <= 0) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS072, ERRZERO, "SPkMsgMult: Invalid\ + count"); + RETVALUE(RFAILED); + } + if (mBuf->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS073, ERRZERO, "SPkMsgMult: Incorrect\ + buffer type"); + RETVALUE(RFAILED); + } +#endif + + /* get the SsMsgInfo of mBuf */ + minfo = (SsMsgInfo*) mBuf->b_rptr; + +/* ss014.13: Addition */ + offset = 0; + + if ((tmp = mBuf->b_cont) && (tmp->b_datap->db_ref == 1) && + (tmp->b_datap->db_base < tmp->b_rptr)) + { + /* store the offset of the read pointer of tmp */ + offset = tmp->b_rptr - tmp->b_datap->db_base; + + /* determine the number of bytes to copy */ + numBytes = MIN(cnt, offset); + + /* decrement cnt */ + cnt -= numBytes; + + /* update the read ptr */ + tmp->b_rptr -= numBytes; + /* copy data */ + memcpy((U8*)tmp->b_rptr, (src + cnt), numBytes); + minfo->len += numBytes; + if (!cnt) + { + RETVALUE(ROK); + } + } + +#if 0 + char * file = __FILE__; + U32 line = __LINE__; +#endif + + /* allocate a DBlk minimum of size Cnt to pack the data */ + newblk = NULLP; + if (ssGetDBufOfSize(minfo->region, cnt, &newblk) != ROK) + { + RETVALUE(ROUTRES); + } + newblk->b_datap->db_type = SS_M_DATA; + newblk->b_rptr = newblk->b_datap->db_lim - cnt; + newblk->b_wptr = newblk->b_datap->db_lim; + memcpy((U8*)newblk->b_rptr, src, cnt); + /* attach the newblk chain into mBuf */ + newblk->b_cont = tmp; + mBuf->b_cont = newblk; + minfo->len += cnt; + minfo->endptr = newblk; + + RETVALUE(ROK); +} +/* ss006.301 : new buffer management APIs, end */ +/* +* +* Fun: SGetReadPtr +* +* Desc: This function retunrs the pointer to the read the message from mBuf +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: +* +* File: ss_msg.c +* +*/ +#ifdef ANSI +PUBLIC S16 SGetReadPtr +( + Buffer *mBuf, + U8** data, + MsgLen *len +) +#else +PUBLIC S16 SGetReadPtr (mBuf, data, len) +Buffer *mBuf; +U8** data; +MsgLen *len; +#endif +{ +/* Buffer *tmp; */ + + if (mBuf && mBuf->b_cont) + { + *data = mBuf->b_cont->b_rptr; + *len = ((SsMsgInfo*)(mBuf->b_rptr))->len; + } + else + { + *data = NULLP; + *len = 0; + } + + RETVALUE(ROK); +} +#ifdef SS_USE_ZBC_MEMORY +/* +* +* Fun: SAttachPtrToBuf +* +* Desc: This function attaches the Pointer provided into a new +* message buffer after allocating the same. It allocates +* header (M-Block) and an additional dBuf (D-Block) and attaches +* the provided pointer to it. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: +* +* File: ss_msg.c +* +*/ + +#ifdef T2K_MEM_LEAK_DBG +PUBLIC S16 SAttachPtrToBufNew +( +Region region, +Pool pool, +Data *ptr, +MsgLen totalLen, +Buffer** mBuf, +char* file, +U32 line +) +#else +#ifdef ANSI +PUBLIC S16 SAttachPtrToBuf +( +Region region, +Pool pool, +Data *ptr, +MsgLen totalLen, +Buffer** mBuf +) +#else +PUBLIC S16 SAttachPtrToBuf(region, pool, ptr, totalLen, mBuf) +Region region; +Pool pool; +Data *ptr; +MsgLen totalLen; +Buffer** mBuf; +#endif +#endif +{ + SsMsgInfo *minfo; /* Message info */ + Size mdsize; + SsDblk *dptr; + Buffer *newblk; + /* Void *iccHdlr; */ + + TRC1(SAttachPtrToBuf) + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (ptr == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SAttachPtrToBuf: Null PTR"); + RETVALUE(RFAILED); + } +#endif + +#ifdef XEON_SPECIFIC_CHANGES + region = 0; +#endif + if(SGetMsg(region, pool, mBuf) != ROK) + { + SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SAttachPtrToBuf: SGetMsg Failed"); + RETVALUE(ROUTRES); + } + + mdsize = MDBSIZE; + +#ifdef SS_HISTOGRAM_SUPPORT + if (SAlloc(region, &mdsize, 0, (Data **) &newblk, __LINE__, (U8*) __FILE__, ENTNC) != ROK) +#else + if (SAlloc(region, &mdsize, 0, (Data **) &newblk) != ROK) +#endif /* SS_HISTOGRAM_SUPPORT */ + { + SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SAttachPtrToBuf: SAlloc Failed"); + SPutMsg(*mBuf); + RETVALUE(ROUTRES); + } + + (*mBuf)->b_cont = newblk; + + dptr = (SsDblk*) (((Data *) (newblk)) + MBSIZE); + + INITB((newblk), dptr, (Data*) NULL, 0, NULLP) + + + newblk->b_datap->db_base = ptr; + newblk->b_datap->db_lim = ptr + totalLen; + newblk->b_rptr = newblk->b_datap->db_base; + newblk->b_wptr = newblk->b_rptr + totalLen; + +#ifndef SS_DBUF_REFLOCK_DISABLE + if((SInitLock (&(dptr->dBufLock), SS_LOCK_MUTEX)) != 0) + { + printf("Falied to destroy lock\n"); + } +#endif + + dptr->db_type = SS_MEM_TYPE_SSI_ZBC; + + /* get the SsMsgInfo of mBuf */ + minfo = (SsMsgInfo*) (*mBuf)->b_rptr; + minfo->len = totalLen; + minfo->endptr = newblk; + + RETVALUE(ROK); +} + +/* +* +* Fun: SPutZbcDBuf +* +* Desc: This function deallocates a buffer back to the +* dynamic memory pool which is allocated for ZBC +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: +* +* File: ss_msg.c +* +*/ + +#ifdef T2K_MEM_LEAK_DBG +PRIVATE S16 SPutZbcDBufNew +( +Region region, +Buffer *buf, +char* file, +U32 line +) +#else +#ifdef ANSI +PRIVATE S16 SPutZbcDBuf +( +Region region, +Buffer *buf +) +#else +PRIVATE S16 SPutZbcDBuf(region, buf) +Region region; +Buffer *buf; +#endif +#endif +{ + register SsDblk *dptr; + MsgLen bufLen; + S16 ret = ROK; + + TRC2(SPutZbcDBuf); + + dptr = buf->b_datap; + /* Get the length of the buffer */ + bufLen = buf->b_datap->db_lim - buf->b_datap->db_base; + + /* If the buffer is not shared, free the buffer */ + if(!dptr->shared) + { +#ifndef SS_DBUF_REFLOCK_DISABLE + SDestroyLock(&dptr->dBufLock); +#endif + + /* Free the ZBC buffer first and then free the block allocated for the + * D-Block */ + +#ifdef SS_HISTOGRAM_SUPPORT + ret = SFree(region, (Data *) buf->b_datap->db_base, bufLen, __LINE__, + (U8*) __FILE__, ENTNC); +#else + ret = SFree(region, (Data *) buf->b_datap->db_base, bufLen); +#endif /* SS_HISTOGRAM_SUPPORT */ + + /* if the data block is not shared, free the buffer, checks not reqd */ +#ifdef SS_HISTOGRAM_SUPPORT + ret = SFree(region, (Data *) buf, MDBSIZE, __LINE__, (U8*) __FILE__, + ENTNC); +#else + ret = SFree(region, (Data *) buf, MDBSIZE); +#endif /* SS_HISTOGRAM_SUPPORT */ + } + /* If the buffer is shared, reduce the refernce count and free the buffer + * if reference count falls to zero */ + else + { +#ifndef SS_DBUF_REFLOCK_DISABLE + if((ret=SLock(&dptr->dBufLock))) + { + SSLOGERROR(ERRCLS_DEBUG, ESSXXX, ERRZERO, + "Could not lock the mBuf Ref Lock"); + RETVALUE(RFAILED); + } +#endif + --dptr->db_ref; + /* if buffer's message blk is obtained during dupb */ + if (buf != (SsMblk *) (((Data*) dptr) - MBSIZE)) + { +#ifdef SS_HISTOGRAM_SUPPORT + ret = SFree(region, (Data *) buf, MDBSIZE, __LINE__, (U8*) __FILE__, ENTNC); +#else + ret = SFree(region, (Data *) buf, MDBSIZE); +#endif /* SS_HISTOGRAM_SUPPORT */ + buf = (SsMblk *) (((Data*) dptr) - MBSIZE); + } + /* if reference count falls to zero */ + if (!dptr->db_ref) + { +#ifndef SS_DBUF_REFLOCK_DISABLE + ret = SUnlock(&dptr->dBufLock) ; + if((SDestroyLock(&dptr->dBufLock)) != 0) + { + printf("Falied to destroy lock\n"); + } +#endif +#ifdef SS_HISTOGRAM_SUPPORT + ret = SFree(region, (Data *) buf->b_datap->db_base, bufLen, __LINE__, + (U8*) __FILE__, ENTNC); +#else + ret = SFree(region, (Data *) buf->b_datap->db_base, bufLen); +#endif /* SS_HISTOGRAM_SUPPORT */ + +#ifdef SS_HISTOGRAM_SUPPORT + ret = SFree(region, (Data *) buf, MDBSIZE, __LINE__, (U8*) __FILE__, + ENTNC); +#else + ret = SFree(region, (Data *) buf, MDBSIZE); +#endif /* SS_HISTOGRAM_SUPPORT */ + RETVALUE(ret); + } +#ifndef SS_DBUF_REFLOCK_DISABLE + ret = SUnlock(&(dptr->dBufLock)); +#endif + } + + RETVALUE(ret); +} +#endif /* SS_USE_ZBC_MEMORY */ + +#ifdef INTEL_WLS + +/* +* +* Fun: SAttachPtrToMBuf +* +* Desc: This function attaches the Pointer provided into a new +* message buffer after allocating the same. It allocates +* header (M-Block) and an additional dBuf (D-Block) and attaches +* the provided pointer to it. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: +* +* File: ss_msg.c +* +*/ +#ifdef T2K_MEM_LEAK_DBG +PUBLIC S16 SAttachPtrToMBuf1 +( +Region region, +Pool pool, +Data *ptr, +MsgLen totalLen, +MsgLen ptrLen, +Buffer** mBuf, +char* file, +U32 line +) +#else +#ifdef ANSI +PUBLIC S16 SAttachPtrToMBuf +( +Region region, +Pool pool, +Data *ptr, +MsgLen totalLen, +MsgLen ptrLen, +Buffer** mBuf +) +#else +PUBLIC S16 SAttachPtrToMBuf(region, pool, ptr, totalLen, ptrLen, mBuf) +Region region; +Pool pool; +Data *ptr; +MsgLen totalLen; +MsgLen ptrLen; +Buffer** mBuf; +#endif +#endif +{ + SsMsgInfo *minfo; /* Message info */ + Size mdsize; + SsDblk *dptr; + Buffer *newblk; + /* Void *iccHdlr; */ + + TRC1(SAttachPtrToMBuf) + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (ptr == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SAttachPtrToBuf: Null PTR"); + RETVALUE(RFAILED); + } +#endif + + if(SGetMsg(region, pool, mBuf) != ROK) + { + SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SAttachPtrToBuf: SGetMsg Failed"); + RETVALUE(ROUTRES); + } + + region = 0; + mdsize = MDBSIZE; + +#ifdef SS_HISTOGRAM_SUPPORT + if (SAlloc(region, &mdsize, 0, (Data **) &newblk, __LINE__, (U8*) __FILE__, ENTNC) != ROK) +#else + if (SAlloc(region, &mdsize, 0, (Data **) &newblk) != ROK) +#endif /* SS_HISTOGRAM_SUPPORT */ + { + SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SAttachPtrToBuf: SAlloc Failed"); + SPutMsg(*mBuf); + RETVALUE(ROUTRES); + } + + (*mBuf)->b_cont = newblk; + + dptr = (SsDblk*) (((Data *) (newblk)) + MBSIZE); + + INITB((newblk), dptr, (Data*) NULL, 0, NULLP) + + + newblk->b_datap->db_base = ptr; + newblk->b_datap->db_lim = ptr + ptrLen; + newblk->b_rptr = newblk->b_datap->db_base; + newblk->b_wptr = newblk->b_rptr + totalLen; + +#ifndef SS_DBUF_REFLOCK_DISABLE + if((SInitLock (&(dptr->dBufLock), SS_LOCK_MUTEX)) != 0) + { + printf("Falied to destroy lock\n"); + } +#endif + + dptr->db_type = SS_MEM_TYPE_SSI_ZBC; + + /* get the SsMsgInfo of mBuf */ + minfo = (SsMsgInfo*) (*mBuf)->b_rptr; + minfo->len = totalLen; + minfo->endptr = newblk; + + //printf("Mbuf PTR = %x, DBlk PTR = %x, PTR = %x\n", *mBuf, newblk, ptr); + RETVALUE(ROK); +} +#endif /* INTEL_WLS */ +PUBLIC S16 SIncMsgRef(Buffer *srcBuf,Region dstRegion, Pool dstPool,Buffer **dstBuf) +{ +#ifndef L2_OPTMZ + RETVALUE(SAddMsgRef(srcBuf,dstRegion, dstPool,dstBuf)); +#else + *dstBuf = srcBuf; +#endif + RETVALUE(ROK); +} +#ifdef L2_OPTMZ +PUBLIC Void SResetMBuf(Buffer *mbuf) +{ + SsMsgInfo *minfo; + Buffer *tmp; +#if 1 + + minfo = (SsMsgInfo *) mbuf->b_rptr; + //tmp = minfo->endptr; + tmp = mbuf->b_cont; + + minfo->len = 0; + if(tmp) + { + + // printf("SResetMBuf The write & read ptr is %p %p %p %p \n", tmp->b_wptr, tmp->b_rptr, tmp->b_datap->db_base, tmp->b_datap->db_lim ); +// tmp->b_wptr = tmp->b_rptr = tmp->b_datap->db_base; + tmp->b_wptr = tmp->b_rptr = (tmp->b_datap->db_base + 5); + tmp->b_datap->db_ref = 1; + tmp->b_datap->shared = 0; + } +#endif + + + RETVOID; +} +#endif + +#ifdef INTEL_WLS +/* +* +* Fun: SAttachWlsPtrToMBuf +* +* Desc: This function attaches the Pointer provided into a new +* message buffer after allocating the same. It allocates +* header (M-Block) and an additional dBuf (D-Block) and attaches +* the provided pointer to it. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: +* +* File: ss_msg.c +* +*/ +#ifdef T2K_MEM_LEAK_DBG +PUBLIC S16 SAttachWlsPtrToMBuf1 +( +Region region, +Pool pool, +Data *ptr, +Data *readPtr, +MsgLen totalLen, +MsgLen ptrLen, +Buffer** mBuf, +char* file, +U32 line +) +#else +#ifdef ANSI +PUBLIC S16 SAttachWlsPtrToMBuf +( +Region region, +Pool pool, +Data *ptr, +Data *readPtr, +MsgLen totalLen, +MsgLen ptrLen, +Buffer** mBuf +) +#else +PUBLIC S16 SAttachWlsPtrToMBuf(region, pool, ptr, readPtr, totalLen, ptrLen, mBuf) +Region region; +Pool pool; +Data *ptr; +Data *readPtr; +MsgLen totalLen; +MsgLen ptrLen; +Buffer** mBuf; +#endif +#endif +{ + SsMsgInfo *minfo; /* Message info */ + Size mdsize; + SsDblk *dptr; + Buffer *newblk; + /* Void *iccHdlr; */ + + TRC1(SAttachWlsPtrToMBuf) + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (ptr == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SAttachPtrToBuf: Null PTR"); + RETVALUE(RFAILED); + } +#endif + + region = 0; + if(SGetMsg(region, pool, mBuf) != ROK) + { + SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SAttachPtrToBuf: SGetMsg Failed"); + RETVALUE(ROUTRES); + } + + mdsize = MDBSIZE; + +#ifdef SS_HISTOGRAM_SUPPORT + if (SAlloc(region, &mdsize, 0, (Data **) &newblk, __LINE__, (U8*) __FILE__, ENTNC) != ROK) +#else + if (SAlloc(region, &mdsize, 0, (Data **) &newblk) != ROK) +#endif /* SS_HISTOGRAM_SUPPORT */ + { + SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SAttachPtrToBuf: SAlloc Failed"); + SPutMsg(*mBuf); + RETVALUE(ROUTRES); + } + + (*mBuf)->b_cont = newblk; + + dptr = (SsDblk*) (((Data *) (newblk)) + MBSIZE); + + INITB((newblk), dptr, (Data*) NULL, 0, NULLP) + + + newblk->b_datap->db_base = ptr; + newblk->b_datap->db_lim = ptr + ptrLen; + newblk->b_rptr = readPtr; + newblk->b_wptr = newblk->b_rptr + totalLen; + +#ifndef SS_DBUF_REFLOCK_DISABLE + if((SInitLock (&(dptr->dBufLock), SS_LOCK_MUTEX)) != 0) + { + printf("Falied to destroy lock\n"); + } +#endif + + dptr->db_type = SS_MEM_TYPE_SSI_ZBC; + + /* get the SsMsgInfo of mBuf */ + minfo = (SsMsgInfo*) (*mBuf)->b_rptr; + minfo->len = totalLen; + minfo->endptr = newblk; + + //printf("Mbuf PTR = %x, DBlk PTR = %x, PTR = %x\n", *mBuf, newblk, ptr); + RETVALUE(ROK); +} + +#ifdef TENB_DPDK_BUF + +extern U32 numeTti; + +PUBLIC S16 SGetSBufDpdk +( +Data **ptr, /* pointer to buffer */ +Size size /* size requested */ +) +{ + S16 ret=ROK; + + *ptr = ntl_alloc(mtGetNtlHdl(), size); + + RETVALUE(ret); +} + +PUBLIC S16 SPutSBufDpdk +( +Data *ptr /* pointer to buffer */ +) +{ + S16 ret; + U32 flags = 0; + + ntl_free(mtGetNtlHdl(), ptr); + + RETVALUE(ret); +} + +PUBLIC S16 SDetachDpdkPtrFrmDBuf +( +Buffer *mBuf, +Data **ptr +) +{ + + Buffer *msgBlk; + SsMsgInfo *minfo; + + //msgBlk = mBuf->b_cont; + //*ptr = msgBlk->b_rptr;; + *ptr = mBuf->b_datap->db_base;; + + mBuf->b_cont = NULL; + + //minfo = (SsMsgInfo*) mBuf->b_rptr; + //minfo->len = 0; + + + RETVALUE(ROK); +} + + +PUBLIC S16 SDetachDpdkPtrFrmMBuf +( + Buffer *mBuf, + Data **ptr + ) +{ + + Buffer *msgBlk; + SsMsgInfo *minfo; + register SsDblk *dptr; + + + + msgBlk = mBuf->b_cont; + if(msgBlk == NULLP) + { + *ptr = NULLP; + RETVALUE(RFAILED); + } + + dptr = msgBlk->b_datap; + if(dptr->db_type != SS_MEM_TYPE_DPDK_ZBC) + { + *ptr = NULLP; + RETVALUE(RFAILED); + } + + *ptr = msgBlk->b_rptr;; + + mBuf->b_cont = NULL; + + minfo = (SsMsgInfo*) mBuf->b_rptr; + minfo->len = 0; + + RETVALUE(ROK); +} + + +#ifdef ANSI +PUBLIC S16 SAttachDpdkPtrToMBuf +( +Region region, +Pool pool, +Data *ptr, +Data *readPtr, +MsgLen msgLen, +MsgLen totalLen, +Buffer** mBuf +) +#else +PUBLIC S16 SAttachDpdkPtrToMBuf(region, pool, ptr, readPtr, msgLen, totalLen, mBuf) +Region region; +Pool pool; +Data *ptr; +Data *readPtr; +MsgLen msgLen; +MsgLen totalLen; +Buffer** mBuf; +#endif +{ + + SsDblk *dptr; + + if(0 == msgLen) + RETVALUE(RFAILED); + + SAttachWlsPtrToMBuf(region, pool, ptr, readPtr, msgLen, totalLen, mBuf); + dptr = (SsDblk*) (((Data *) ((*mBuf)->b_cont)) + MBSIZE); + + dptr->db_type = SS_MEM_TYPE_DPDK_ZBC; + + RETVALUE(ROK); +} + +#endif /* TENB_DPDK_BUF */ + +#endif /* INTEL_WLS */ + +/********************************************************************** + End of file +**********************************************************************/ + diff --git a/src/mt/ss_pack.c b/src/mt/ss_pack.c new file mode 100644 index 000000000..7441a6c75 --- /dev/null +++ b/src/mt/ss_pack.c @@ -0,0 +1,980 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/********************************************************************20** + + Name: System Services -- packing + + Type: C source file + + Desc: Source code for System Services packing functions. + + File: ss_pack.c + +*********************************************************************21*/ + + +/* header include files (.h) */ + +#include "envopt.h" /* environment options */ +#include "envdep.h" /* environment dependent */ +#include "envind.h" /* environment independent */ + +#include "gen.h" /* general layer */ +#include "ssi.h" /* system services */ + +#include "ss_err.h" /* errors */ +#include "ss_dep.h" /* implementation-specific */ +#include "ss_queue.h" /* queues */ +#include "ss_msg.h" /* messaging */ +#include "ss_mem.h" /* memory management interface */ +#include "ss_gen.h" /* general */ +#include "cm_mem.h" /* memory management */ + + + +/* header/extern include files (.x) */ + +#include "gen.x" /* general layer */ +#include "ssi.x" /* system services */ + +#include "ss_dep.x" /* implementation-specific */ +#include "ss_queue.x" /* queues */ +#include "ss_task.x" /* tasking */ +#include "ss_timer.x" /* timers */ +#include "ss_strm.x" /* STREAMS */ +#include "ss_msg.x" /* messaging */ +#include "ss_mem.x" /* memory management interface */ +#include "ss_drvr.x" /* driver tasks */ +#ifdef SS_LOCKLESS_MEMORY +#include "cm_llist.x" +#include "cm_hash.x" +#include "cm_mem_wl.x" /* common memory manager */ +#else +#include "cm_mem.x" /* common memory manager */ +#endif /* SS_LOCKLESS_MEMORY */ +#include "ss_gen.x" /* general */ + + + +/* +* +* Fun: SPkS8 +* +* Desc: This function packs a signed 8 bit value into a message. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: None +* +* File: ss_pack.c +* +*/ + +#ifdef ANSI +PUBLIC S16 SPkS8 +( +S8 val, /* value */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 SPkS8(val, mBuf) +S8 val; /* value */ +Buffer *mBuf; /* message buffer */ +#endif +{ + S16 ret; /* return code */ + TRC1(SPkS8) + ret = SAddPreMsg((Data) val, mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + if (ret != ROK) + SSLOGERROR(ERRCLS_ADD_RES, ESS242, (ErrVal)ret, "SAddPreMsg() failed"); +#endif + RETVALUE(ret); +} /* end of SPkS8 */ + + + +/* +* +* Fun: SPkU8 +* +* Desc: This function packs an unsigned 8 bit value into a message. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: None +* +* File: ss_pack.c +* +*/ + +#ifdef ANSI +PUBLIC S16 SPkU8 +( +U8 val, /* value */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 SPkU8(val, mBuf) +U8 val; /* value */ +Buffer *mBuf; /* message buffer */ +#endif +{ + S16 ret; /* return code */ + TRC1(SPkU8) + ret = SAddPreMsg((Data) val, mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + if (ret != ROK) + SSLOGERROR(ERRCLS_ADD_RES, ESS243, (ErrVal)ret, "SAddPreMsg() failed"); +#endif + RETVALUE(ret); +} /* end of SPkU8 */ + +/* +* +* Fun: SPkS16 +* +* Desc: This function packs a signed 16 bit value into a message. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: None +* +* File: ss_pack.c +* +*/ + +#ifdef ANSI +PUBLIC S16 SPkS16 +( +S16 val, /* value */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 SPkS16(val, mBuf) +S16 val; /* value */ +Buffer *mBuf; /* message buffer */ +#endif +{ + Data pkArray[2]; /* array for packing */ + S16 ret; /* return code */ + + TRC1(SPkS16) +#ifndef FCSPKINT /* backward compatibility, packing order */ + pkArray[0] = (Data) GetHiByte(val); + pkArray[1] = (Data) GetLoByte(val); +#else /* forward compatibility, packing order */ + pkArray[1] = (Data) GetHiByte(val); + pkArray[0] = (Data) GetLoByte(val); +#endif + ret = SAddPreMsgMult(pkArray, (MsgLen) 2, mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + if (ret != ROK) + SSLOGERROR(ERRCLS_ADD_RES, ESS244, (ErrVal)ret, "SAddPreMsgMult() failed"); +#endif + RETVALUE(ret); +} /* end of SPkS16 */ + + +/* +* +* Fun: SPkU16 +* +* Desc: This function packs an unsigned 16 bit value into a message. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: None +* +* File: ss_pack.c +* +*/ + +#ifdef ANSI +PUBLIC S16 SPkU16 +( +U16 val, /* value */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 SPkU16(val, mBuf) +U16 val; /* value */ +Buffer *mBuf; /* message buffer */ +#endif +{ + Data pkArray[2]; /* array for packing */ + S16 ret; /* return code */ + + TRC1(SPkU16) +#ifndef FCSPKINT /* backward compatibility, packing order */ + pkArray[0] = (Data) GetHiByte(val); + pkArray[1] = (Data) GetLoByte(val); +#else /* forward compatibility, packing order */ + pkArray[1] = (Data) GetHiByte(val); + pkArray[0] = (Data) GetLoByte(val); +#endif + ret = SAddPreMsgMult(pkArray, (MsgLen) 2, mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + if (ret != ROK) + SSLOGERROR(ERRCLS_ADD_RES, ESS245, (ErrVal)ret, "SAddPreMsgMult() failed"); +#endif + RETVALUE(ret); +} /* end of SPkU16 */ + + +/* +* +* Fun: SPkS32 +* +* Desc: This function packs a signed 32 bit value into a message. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: None +* +* File: ss_pack.c +* +*/ + +#ifdef ANSI +PUBLIC S16 SPkS32 +( +S32 val, /* value */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 SPkS32(val, mBuf) +S32 val; /* value */ +Buffer *mBuf; /* message buffer */ +#endif +{ + U16 tmp; /* temporary value */ + Data pkArray[4]; /* packing array */ + S16 ret; /* return code */ + + TRC1(SPkS32) +#ifndef FCSPKINT /* backward compatibility, packing order */ + tmp = (U16) GetHiWord(val); + pkArray[0] = (Data) GetHiByte(tmp); + pkArray[1] = (Data) GetLoByte(tmp); + tmp = (U16) GetLoWord(val); + pkArray[2] = (Data) GetHiByte(tmp); + pkArray[3] = (Data) GetLoByte(tmp); +#else /* forward compatibility, packing order */ + tmp = (U16) GetHiWord(val); + pkArray[3] = (Data) GetHiByte(tmp); + pkArray[2] = (Data) GetLoByte(tmp); + tmp = (U16) GetLoWord(val); + pkArray[1] = (Data) GetHiByte(tmp); + pkArray[0] = (Data) GetLoByte(tmp); +#endif + ret = SAddPreMsgMult(pkArray, (MsgLen) 4, mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + if (ret != ROK) + SSLOGERROR(ERRCLS_ADD_RES, ESS246, (ErrVal)ret, "SAddPreMsgMult() failed"); +#endif + RETVALUE(ret); +} /* end of SPkS32 */ + + +/* +* +* Fun: SPkU32 +* +* Desc: This function packs an unsigned 32 bit value into a message. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: None +* +* File: ss_pack.c +* +*/ + +#ifdef ANSI +PUBLIC S16 SPkU32 +( +U32 val, /* value */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 SPkU32(val, mBuf) +U32 val; /* value */ +Buffer *mBuf; /* message buffer */ +#endif +{ + U16 tmp; /* temporary value */ + Data pkArray[4]; /* packing array */ + S16 ret; /* return code */ + + TRC1(SPkU32) +#ifndef FCSPKINT /* backward compatibility, packing order */ + tmp = (U16) GetHiWord(val); + pkArray[0] = (Data) GetHiByte(tmp); + pkArray[1] = (Data) GetLoByte(tmp); + tmp = (U16) GetLoWord(val); + pkArray[2] = (Data) GetHiByte(tmp); + pkArray[3] = (Data) GetLoByte(tmp); +#else /* forward compatibility, packing order */ + tmp = (U16) GetHiWord(val); + pkArray[3] = (Data) GetHiByte(tmp); + pkArray[2] = (Data) GetLoByte(tmp); + tmp = (U16) GetLoWord(val); + pkArray[1] = (Data) GetHiByte(tmp); + pkArray[0] = (Data) GetLoByte(tmp); +#endif + ret = SAddPreMsgMult(pkArray, (MsgLen) 4, mBuf); +#if (ERRCLASS & ERRCLS_ADD_RES) + if (ret != ROK) + SSLOGERROR(ERRCLS_ADD_RES, ESS247, (ErrVal)ret, "SAddPreMsgMult() failed"); +#endif + RETVALUE(ret); +} /* end of SPkU32 */ + +/*ss038.103 1. Added Floating point support*/ +#ifdef SS_FLOAT +/* +* +* Fun: SPkF32 +* +* Desc: This function packs an 32 bit ieee-754 format float value into a message. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: None +* +* File: ss_pack.c +* +*/ + +#ifdef ANSI +PUBLIC S16 SPkF32 +( +F32 val, /* value */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 SPkF32(val, mBuf) +F32 val; /* value */ +Buffer *mBuf; /* message buffer */ +#endif +{ + S16 ret; /* return code */ + S8 tmpArray[15]; /* temporary array */ +#ifdef FCSPKINT /* backward compatibility, packing order */ + S32 tIdx = 14; /* counters */ + S32 kIdx = 0; /* counters */ + S8 pkArray[15]; /* packing array */ +#endif /*FCSPKINT*/ + + TRC1(SPkF32) + + sprintf(tmpArray, "%.7e", val); + +#ifndef FCSPKINT /* backward compatibility, packing order */ + ret = SAddPreMsgMult((Data*)tmpArray, (MsgLen) 15, mBuf); +#else + while(tIdx >= 0) + { + pkArray[kIdx] = tmpArray[tIdx]; + tIdx--; kIdx++; + } + ret = SAddPreMsgMult((Data*)pkArray, (MsgLen) 15, mBuf); +#endif + + +#if (ERRCLASS & ERRCLS_ADD_RES) + if (ret != ROK) + SSLOGERROR(ERRCLS_ADD_RES, ESS248, (ErrVal)ret, "SAddPreMsgMult() failed"); +#endif + RETVALUE(ret); +} /* end of SPkF32 */ + +/* +* +* Fun: SPkF64 +* +* Desc: This function packs an 64 bit ieee-754 format float value into a message. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: None +* +* File: ss_pack.c +* +*/ + +#ifdef ANSI +PUBLIC S16 SPkF64 +( +F64 val, /* value */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 SPkF64(val, mBuf) +F64 val; /* value */ +Buffer *mBuf; /* message buffer */ +#endif +{ + + S16 ret; /* return code */ + S8 tmpArray[25]; /* temporary array */ +#ifdef FCSPKINT /* backward compatibility, packing order */ + S32 tIdx = 24; /* counters */ + S32 kIdx = 0; /* counters */ + S8 pkArray[25]; /* packing array */ +#endif /*FCSPKINT*/ + + TRC1(SPkF64) + + sprintf(tmpArray, "%.16le", val); + +#ifndef FCSPKINT /* backward compatibility, packing order */ + ret = SAddPreMsgMult((Data*)tmpArray, (MsgLen) 25, mBuf); +#else + while(tIdx >= 0) + { + pkArray[kIdx] = tmpArray[tIdx]; + tIdx--; kIdx++; + } + ret = SAddPreMsgMult((Data*)pkArray, (MsgLen) 25, mBuf); +#endif + + +#if (ERRCLASS & ERRCLS_ADD_RES) + if (ret != ROK) + SSLOGERROR(ERRCLS_ADD_RES, ESS249, (ErrVal)ret, "SAddPreMsgMult() failed"); +#endif + RETVALUE(ret); + +} /* end of SPkF64 */ +#endif /* SS_FLOAT */ + +/* +* +* Fun: SUnpkS8 +* +* Desc: This function unpacks a signed 8 bit value from a message. +* +* Ret: ROK - ok +* +* Notes: None +* +* File: ss_pack.c +* +*/ + +#ifdef ANSI +PUBLIC S16 SUnpkS8 +( +S8 *val, /* pointer to value */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 SUnpkS8(val, mBuf) +S8 *val; /* pointer to value */ +Buffer *mBuf; /* message buffer */ +#endif +{ + Data tmp; /* temporary value */ + S16 ret; /* return code */ + TRC1(SUnpkS8) + +/* ss021.103 - Addition of data pointer check */ +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check data pointer */ + if (!val) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS250, ERRZERO, "SUnpkS8 : Null value"); + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + ret = SRemPreMsg(&tmp, mBuf); +#if (ERRCLASS & ERRCLS_DEBUG) + if (ret != ROK) + SSLOGERROR(ERRCLS_DEBUG, ESS251, (ErrVal)ret, "SRemPreMsg() failed"); +#endif + *val = (S8) tmp; + RETVALUE(ret); +} /* end of SUnpkS8 */ + + +/* +* +* Fun: SUnpkU8 +* +* Desc: This function unpacks an unsigned 8 bit value from a message. +* +* Ret: ROK - ok +* +* Notes: None +* +* File: ss_pack.c +* +*/ + +#ifdef ANSI +PUBLIC S16 SUnpkU8 +( +U8 *val, /* pointer to value */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 SUnpkU8(val, mBuf) +U8 *val; /* pointer to value */ +Buffer *mBuf; /* message buffer */ +#endif +{ + Data tmp; /* temporary value */ + S16 ret; /* return code */ + TRC1(SUnpkU8) + +/* ss021.103 - Addition of data pointer check */ +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check data pointer */ + if (!val) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS252, ERRZERO, "SUnpkU8 : Null value"); + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + ret = SRemPreMsg(&tmp, mBuf); +#if (ERRCLASS & ERRCLS_DEBUG) + if (ret != ROK) + SSLOGERROR(ERRCLS_DEBUG, ESS253, (ErrVal)ret, "SRemPreMsg() failed"); +#endif + *val = (U8) tmp; + RETVALUE(ret); +} /* end of SUnpkU8 */ + +/* +* +* Fun: SUnpkS16 +* +* Desc: This function unpacks a signed 16 bit value from a message. +* +* Ret: ROK - ok +* +* Notes: None +* +* File: ss_pack.c +* +*/ + +#ifdef ANSI +PUBLIC S16 SUnpkS16 +( +S16 *val, /* pointer to value */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 SUnpkS16(val, mBuf) +S16 *val; /* pointer to value */ +Buffer *mBuf; /* message buffer */ +#endif +{ + U16 tmp16; /* temporary value */ + Data unpkArray[2]; /* unpacking array */ + S16 ret; /* return code */ + TRC1(SUnpkS16) + +/* ss021.103 - Addition of data pointer check */ +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check data pointer */ + if (!val) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS254, ERRZERO, "SUnpkS16 : Null value"); + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + ret = SRemPreMsgMult(unpkArray, (MsgLen) 2, mBuf); +#if (ERRCLASS & ERRCLS_DEBUG) + if (ret != ROK) + SSLOGERROR(ERRCLS_DEBUG, ESS255, (ErrVal)ret, "SRemPreMsgMult() failed"); +#endif + tmp16 = 0; +#ifndef FCSPKINT /* backward compatibility, packing order */ + tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[1]); + tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[0]); +#else /* forward compatibility, packing order */ + tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[0]); + tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[1]); +#endif + *val = (S16) tmp16; + RETVALUE(ret); +} /* end of SUnpkS16 */ + + +/* +* +* Fun: SUnpkU16 +* +* Desc: This function unpacks an unsigned 16 bit value from a message. +* +* Ret: ROK - ok +* +* Notes: None +* +* File: ss_pack.c +* +*/ + +#ifdef ANSI +PUBLIC S16 SUnpkU16 +( +U16 *val, /* pointer to value */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 SUnpkU16(val, mBuf) +U16 *val; /* pointer to value */ +Buffer *mBuf; /* message buffer */ +#endif +{ + U16 tmp16; /* temporary value */ + Data unpkArray[2]; /* unpacking array */ + S16 ret; /* return code */ + TRC1(SUnpkU16) + +/* ss021.103 - Addition of data pointer check */ +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check data pointer */ + if (!val) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS256, ERRZERO, "SUnpkU16 : Null value"); + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + ret = SRemPreMsgMult(unpkArray, (MsgLen) 2, mBuf); +#if (ERRCLASS & ERRCLS_DEBUG) + if (ret != ROK) + SSLOGERROR(ERRCLS_DEBUG, ESS257, (ErrVal)ret, "SRemPreMsgMult failed"); +#endif + tmp16 = 0; +#ifndef FCSPKINT /* backward compatibility, packing order */ + tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[1]); + tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[0]); +#else /* forward compatibility, packing order */ + tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[0]); + tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[1]); +#endif + *val = tmp16; + RETVALUE(ret); +} /* end of SUnpkU16 */ + + +/* +* +* Fun: SUnpkS32 +* +* Desc: This function unpacks a signed 32 bit value from a message. +* +* Ret: ROK - ok +* +* Notes: None +* +* File: ss_pack.c +* +*/ + +#ifdef ANSI +PUBLIC S16 SUnpkS32 +( +S32 *val, /* pointer to value */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 SUnpkS32(val, mBuf) +S32 *val; /* pointer to value */ +Buffer *mBuf; /* message buffer */ +#endif +{ + U16 tmp16; /* temporary value */ + U32 tmp32; /* temporary value */ + Data unpkArray[4]; /* unpacking array */ + S16 ret; /* return code */ + TRC1(SUnpkS32) + +/* ss021.103 - Addition of data pointer check */ +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check data pointer */ + if (!val) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS258, ERRZERO, "SUnpkS32 : Null value"); + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + ret = SRemPreMsgMult(unpkArray, (MsgLen) 4, mBuf); +#if (ERRCLASS & ERRCLS_DEBUG) + if (ret != ROK) + SSLOGERROR(ERRCLS_DEBUG, ESS259, (ErrVal)ret, "SRemPreMsgMult() failed"); +#endif + tmp16 = 0; + tmp32 = 0; +#ifndef FCSPKINT /* backward compatibility, packing order */ + tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[3]); + tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[2]); + tmp32 = (U32) PutHiWord(tmp32, (U16) tmp16); + tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[1]); + tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[0]); + tmp32 = (U32) PutLoWord(tmp32, (U16) tmp16); +#else /* forward compatibility, packing order */ + tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[0]); + tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[1]); + tmp32 = (U32) PutHiWord(tmp32, (U16) tmp16); + tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[2]); + tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[3]); + tmp32 = (U32) PutLoWord(tmp32, (U16) tmp16); +#endif + *val = (S32) tmp32; + RETVALUE(ret); +} /* end of SUnpkS32 */ + + +/* +* +* Fun: SUnpkU32 +* +* Desc: This function unpacks an unsigned 32 bit value from a message. +* +* Ret: ROK - ok +* +* Notes: None +* +* File: ss_pack.c +* +*/ + +#ifdef ANSI +PUBLIC S16 SUnpkU32 +( +U32 *val, /* pointer to value */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 SUnpkU32(val, mBuf) +U32 *val; /* pointer to value */ +Buffer *mBuf; /* message buffer */ +#endif +{ + U16 tmp16; /* temporary value */ + U32 tmp32; /* temporary value */ + Data unpkArray[4]; /* unpacking array */ +#ifdef ERRCLASS + S16 ret; /* return code */ +#endif /* ERRCLASS */ + TRC1(SUnpkU32) + +/* ss021.103 - Addition of data pointer check */ +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check data pointer */ + if (!val) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS260, ERRZERO, "SUnpkU32 : Null value"); + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + ret = SRemPreMsgMult(unpkArray, (MsgLen) 4, mBuf); +#if (ERRCLASS & ERRCLS_DEBUG) + if (ret != ROK) + SSLOGERROR(ERRCLS_DEBUG, ESS261, (ErrVal)ret, "SRemPreMsgMult() failed"); +#endif + + tmp16 = 0; + tmp32 = 0; +#ifndef FCSPKINT /* backward compatibility, packing order */ + tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[3]); + tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[2]); + tmp32 = (U32) PutHiWord(tmp32, (U16) tmp16); + tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[1]); + tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[0]); + tmp32 = (U32) PutLoWord(tmp32, (U16) tmp16); +#else /* forward compatibility, packing order */ + tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[0]); + tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[1]); + tmp32 = (U32) PutHiWord(tmp32, (U16) tmp16); + tmp16 = (U16) PutHiByte(tmp16, (U8) unpkArray[2]); + tmp16 = (U16) PutLoByte(tmp16, (U8) unpkArray[3]); + tmp32 = (U32) PutLoWord(tmp32, (U16) tmp16); +#endif + *val = tmp32; + RETVALUE(ret); +} /* end of SUnpkU32 */ + +/*ss038.103 1. Added Floating point support*/ +#ifdef SS_FLOAT +/* +* +* Fun: SUnpkF32 +* +* Desc: This function unpacks an 32 bit ieee-754 format float value from a message. +* +* Ret: ROK - ok +* +* Notes: None +* +* File: ss_pack.c +* +*/ + +#ifdef ANSI +PUBLIC S16 SUnpkF32 +( +F32 *val, /* pointer to value */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 SUnpkF32(val, mBuf) +F32 *val; /* pointer to value */ +Buffer *mBuf; /* message buffer */ +#endif +{ + S16 ret; /* return code */ + S8 tmpArray[15]; /* temporary array */ +#ifndef FCSPKINT /* backward compatibility, packing order */ + S32 tIdx = 14; /* temparory array index */ + S32 kIdx = 0; /* unpacking array index */ + S8 unpkArray[15]; /* unpacking array */ +#endif /* FCSPKINT */ + + TRC1(SUnpkF32) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check data pointer */ + if (!val) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS262, ERRZERO, "SUnpkF32 : Null value"); + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + ret = SRemPreMsgMult((Data*)tmpArray, (MsgLen) 15, mBuf); +#if (ERRCLASS & ERRCLS_DEBUG) + if (ret != ROK) + SSLOGERROR(ERRCLS_DEBUG, ESS263, (ErrVal)ret, "SRemPreMsgMult() failed"); +#endif + +#ifndef FCSPKINT /* backward compatibility, packing order */ + while(tIdx >= 0) + { + unpkArray[kIdx] = tmpArray[tIdx]; + tIdx--; kIdx++; + } + sscanf(unpkArray, "%f", val); +#else + sscanf(tmpArray, "%f", val); +#endif + + RETVALUE(ret); + +} /* end of SUnpkF32 */ + +/* +* +* Fun: SUnpkF64 +* +* Desc: This function unpacks an 64 bit ieee-754 format float value from a message. +* +* Ret: ROK - ok +* +* Notes: None +* +* File: ss_pack.c +* +*/ + +#ifdef ANSI +PUBLIC S16 SUnpkF64 +( +F64 *val, /* pointer to value */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 SUnpkF64(val, mBuf) +F64 *val; /* pointer to value */ +Buffer *mBuf; /* message buffer */ +#endif +{ + + S16 ret; /* return code */ + S8 tmpArray[25]; /* temporary array */ +#ifndef FCSPKINT /* backward compatibility, packing order */ + S32 tIdx = 24; /* temparory array index */ + S32 kIdx = 0; /* unpacking array index */ + S8 unpkArray[25]; /* unpacking array */ +#endif /* FCSPKINT */ + + TRC1(SUnpkF64) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check data pointer */ + if (!val) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS264, ERRZERO, "SUnpkF64 : Null value"); + RETVALUE(RFAILED); + } +#endif /* ERRCLASS & ERRCLS_INT_PAR */ + + ret = SRemPreMsgMult((Data*)tmpArray, (MsgLen) 25, mBuf); +#if (ERRCLASS & ERRCLS_DEBUG) + if (ret != ROK) + SSLOGERROR(ERRCLS_DEBUG, ESS265, (ErrVal)ret, "SRemPreMsgMult() failed"); +#endif + +#ifndef FCSPKINT /* backward compatibility, packing order */ + while(tIdx >= 0) + { + unpkArray[kIdx] = tmpArray[tIdx]; + tIdx--; kIdx++; + } + sscanf(unpkArray, "%lf", val); +#else + sscanf(tmpArray, "%lf", val); +#endif + + RETVALUE(ret); + +} /* end of SUnpkF64 */ +#endif /* SS_FLOAT */ + +/********************************************************************** + End of file + **********************************************************************/ diff --git a/src/mt/ss_queue.c b/src/mt/ss_queue.c new file mode 100644 index 000000000..53397ead3 --- /dev/null +++ b/src/mt/ss_queue.c @@ -0,0 +1,1667 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/********************************************************************20** + + Name: System Services -- Queueing + + Type: C source file + + Desc: Source code for System Services queuing functions. + + File: ss_queue.c + +*********************************************************************21*/ + + + +/* header include files (.h) */ + +#include "envopt.h" /* environment options */ +#include "envdep.h" /* environment dependent */ +#include "envind.h" /* environment independent */ + +#include "gen.h" /* general layer */ +#include "ssi.h" /* system services */ + +#include "ss_err.h" /* errors */ +#include "ss_dep.h" /* implementation-specific */ +#include "ss_queue.h" /* queues */ +#include "ss_task.h" /* tasking */ +#include "ss_strm.h" /* STREAMS */ +#include "ss_msg.h" /* messaging */ +#include "ss_mem.h" /* memory management interface */ +#include "ss_gen.h" /* general */ +#include "cm_mem.h" /* memory management */ +/* ss040.103: addition */ +#include + +/* header/extern include files (.x) */ + +#include "gen.x" /* general layer */ +#include "ssi.x" /* system services */ + +#include "ss_dep.x" /* implementation-specific */ +#include "ss_queue.x" /* queues */ +#include "ss_task.x" /* tasking */ +#include "ss_timer.x" /* timers */ +#include "ss_strm.x" /* STREAMS */ +#include "ss_msg.x" /* messaging */ +#include "ss_mem.x" /* memory management interface */ +#include "ss_drvr.x" /* driver tasks */ +#ifdef SS_LOCKLESS_MEMORY +#include "cm_llist.x" +#include "cm_hash.x" +#include "cm_mem_wl.x" /* common memory manager */ +#else +#include "cm_mem.x" /* common memory manager */ +#endif /* SS_LOCKLESS_MEMORY */ +#include "ss_gen.x" /* general */ + + + +/* +* +* Fun: SInitQueue +* +* Desc: This function initializes a queue. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: no assumptions are made about the previous state +* of the queue. +* +* queue size is set to zero. +* +* File: ss_queue.c +* +*/ +#ifdef ANSI +PUBLIC S16 SInitQueue +( +Queue *q /* queue */ +) +#else +PUBLIC S16 SInitQueue(q) +Queue *q; /* queue */ +#endif +{ + TRC1(SInitQueue) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check queue pointer */ + if (q == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS266, ERRZERO, "Null Ptr"); + RETVALUE(RFAILED); + } +#endif + q->head = NULLP; + q->tail = NULLP; + q->crntSize = 0; + + RETVALUE(ROK); + +} /* end of SInitQueue */ + + +/* +* +* Fun: SFlushQueue +* +* Desc: This function will release all of the data or message +* buffers on the specified queue. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: if queue is empty: no action is taken. +* +* if queue is not empty: all buffers in queue are returned +* to memory. queue length is set to zero. +* +* if dequeud buffer is a message buffer, all data buffers +* associated with the message buffer are returned to memory +* +* File: ss_queue.c +* +*/ +#ifdef ANSI +PUBLIC S16 SFlushQueue +( +Queue *q /* queue */ +) +#else +PUBLIC S16 SFlushQueue(q) +Queue *q; /* queue */ +#endif +{ + Buffer *tBuf; + Buffer *mBuf; + SsMsgInfo *minfo; + +#ifdef T2K_MEM_LEAK_DBG + char* file = __FILE__; + U32 line = __LINE__; +#endif + + TRC1(SFlushQueue) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check queue */ + if (q == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS267, ERRZERO, "Null Q Ptr"); + RETVALUE(RFAILED); + } +#endif + + tBuf = q->head; + while (tBuf != NULLP) + { + mBuf = tBuf->b_next; + if (tBuf->b_datap->db_type == SS_M_PROTO) + SPutMsg(tBuf); + else + { + minfo = (SsMsgInfo *) tBuf->b_rptr; + SPutDBuf(minfo->region, minfo->pool, tBuf); + } + tBuf = mBuf; + } + q->crntSize = 0; + q->head = NULLP; + q->tail = NULLP; + + RETVALUE(ROK); + +} /* end of SFlushQueue */ + + +/* +* +* Fun: SCatQueue +* +* Desc: This function will concatenate the two specified queues +* into one queue. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: if order equals Q1Q2: all buffers attached to queue 2 are +* moved to the end of queue 1. queue 2 is set to empty. +* queue 1 length is increased by length of queue 2. queue +* 2 length is set to zero. return is ok. +* +* if order equals Q2Q1: all buffers attached to queue 2 are +* moved to the front of queue 1. queue 2 is set to empty. +* queue 1 length is increased by length of queue 2. queue +* 2 length is set to zero. return is ok. +* +* File: ss_queue.c +* +*/ +#ifdef ANSI +PUBLIC S16 SCatQueue +( +Queue *q1, /* queue 1 */ +Queue *q2, /* queue 2 */ +Order order /* order */ +) +#else +PUBLIC S16 SCatQueue(q1, q2, order) +Queue *q1; /* queue 1 */ +Queue *q2; /* queue 2 */ +Order order; /* order */ +#endif +{ + TRC1(SCatQueue) + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (q1 == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS268, ERRZERO, "Null Q1 Ptr"); + RETVALUE(RFAILED); + } + + if (q2 == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS269, ERRZERO, "Null Q2 Ptr"); + RETVALUE(RFAILED); + } + + if ((order != Q1Q2) && (order != Q2Q1)) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS270, ERRZERO, "Invalid queue order"); + RETVALUE(RFAILED); + } + + /* ss021.103 - Addition if Q1 is Q2 */ + if (q2 == q1) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS271, ERRZERO, "Q1 == Q2"); + RETVALUE(RFAILED); + } + +#endif /* ERRCLASS */ + + if (q1->crntSize == 0) + { + q1->head = q2->head; + q1->tail = q2->tail; + q1->crntSize = q2->crntSize; + + q2->head = NULLP; + q2->tail = NULLP; + q2->crntSize = 0; + + RETVALUE(ROK); + } + + if (q2->crntSize == 0) + { + RETVALUE(ROK); + } + + switch (order) + { + case Q1Q2: + { + q1->tail->b_next = q2->head; + q2->head->b_prev = q1->tail; + q1->tail = q2->tail; + + break; + } + + case Q2Q1: + { + q2->tail->b_next = q1->head; + q1->head->b_prev = q2->tail; + q1->head = q2->head; + + break; + } + default: + RETVALUE(RFAILED); + } + + q1->crntSize += q2->crntSize; + + q2->head = NULLP; + q2->tail = NULLP; + q2->crntSize = 0; + + RETVALUE(ROK); + +} /* end of SCatQueue */ + + + +/* +* +* Fun: SFndLenQueue +* +* Desc: This function determines the length of a queue. +* +* Ret: ROK - ok +* RFAILED - failed +* +* Notes: length of queue is determined, queue is unchanged +* and length is returned via pointer to length. +* +* File: ss_queue.c +* +*/ +#ifdef ANSI +PUBLIC S16 SFndLenQueue +( +Queue *q, /* queue */ +QLen *lngPtr /* pointer to length */ +) +#else +PUBLIC S16 SFndLenQueue(q, lngPtr) +Queue *q; /* queue */ +QLen *lngPtr; /* pointer to length */ +#endif +{ + TRC1(SFndLenQueue) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check queue */ + if (q == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS272, ERRZERO, "Null Q Ptr"); + RETVALUE(RFAILED); + } + /* check length */ + if (lngPtr == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS273, ERRZERO, "Null Q Len Ptr"); + RETVALUE(RFAILED); + } +#endif + + *lngPtr = q->crntSize; + + RETVALUE(ROK); + +} /* end of SFndLenQueue */ + + +/* +* +* Fun: SExamQueue +* +* Desc: This function examines the queue at the desired index. +* +* Ret: ROK - ok +* ROKDNA - ok, data not available +* RFAILED - failed +* +* Notes: index is 0 based and indicates location in queue. +* +* if queue is empty: pointer to buffer is set to null and +* return is ok, data not available. queue length is unchanged. +* +* if queue is not empty: pointer to buffer is set to indexed +* buffer in queue. return is ok. queue length is unchanged. +* +* File: ss_queue.c +* +*/ +#ifdef ANSI +PUBLIC S16 SExamQueue +( +Buffer **bufPtr, /* pointer to buffer */ +Queue *q, /* queue */ +QLen idx /* index */ +) +#else +PUBLIC S16 SExamQueue(bufPtr, q, idx) +Buffer **bufPtr; /* pointer to buffer */ +Queue *q; /* queue */ +QLen idx; /* index */ +#endif +{ + Buffer *tmpBuf; + QLen i; + + TRC1(SExamQueue) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check buffer pointer */ + if (bufPtr == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS274, ERRZERO, "Null Buf Ptr"); + RETVALUE(RFAILED); + } + + /* check index */ + if ((S32)idx < 0) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS275, ERRZERO, "-ve index "); + RETVALUE(RFAILED); + } + + /* check queue */ + if (q == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS276, ERRZERO, "Null Q Ptr"); + RETVALUE(RFAILED); + } +#endif /* ERRCLASS */ + + if (idx >= q->crntSize) + { + *bufPtr = NULLP; + RETVALUE(ROKDNA); + } + + if (idx == 0) + { + *bufPtr = q->head; + } + else if (idx == q->crntSize -1) + { + *bufPtr = q->tail; + } + else + { + tmpBuf = q->head; + for (i = 0; i < idx; i++) + { + tmpBuf = tmpBuf->b_next; + } + *bufPtr = tmpBuf; + } + + RETVALUE(ROK); + +} /* end of SExamQueue */ + + +/* +* +* Fun: SAddQueue +* +* Desc: This function inserts a bufer into the queue before +* the desired index. +* +* Ret: ROK - ok +* RFAILED - failed +* ROKDNA - failed - specified index not available +* +* Notes: index is 0 based and indicates location in queue. +* +* if queue is empty: buffer is placed in the queue. +* queue length is incremented. +* +* if queue is not empty: if index is less than the queue length, +* buffer is inserted before the desired index; +* otherwise, buffer is placed behind all other buffers in queue. +* queue length is incremented. +* +* File: ss_queue.c +* +*/ +#ifdef ANSI +PUBLIC S16 SAddQueue +( +Buffer *mBuf, /* buffer */ +Queue *q, /* queue */ +QLen idx /* index */ +) +#else +PUBLIC S16 SAddQueue(mBuf, q, idx) +Buffer *mBuf; /* buffer */ +Queue *q; /* queue */ +QLen idx; /* index */ +#endif +{ + Buffer *tBuf; + QLen i; + + TRC1(SAddQueue) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check queue */ + if (q == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS277, ERRZERO, "Null Q Ptr"); + RETVALUE(RFAILED); + } + + if (mBuf == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS278, ERRZERO, "Null Buf Ptr"); + RETVALUE(RFAILED); + } + + if ((S32)idx < 0) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS279, ERRZERO, "-ve index"); + RETVALUE(RFAILED); + } + /* ss021.103 - Addition to check buffer type and if duplicate message */ + if (mBuf->b_datap->db_type != SS_M_PROTO) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS280, ERRZERO, + "Incorrect buffer type"); + RETVALUE(RFAILED); + } + tBuf = q->head; + while (tBuf != (Buffer *)NULLP) + { + if (tBuf == mBuf) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS281, ERRZERO, "Duplicate queued mBuf"); + RETVALUE(RFAILED); + } + tBuf = tBuf->b_next; + } +#endif /* ERRCLASS */ + + if (idx > q->crntSize) + { + SSLOGERROR(ERRCLS_DEBUG, ESS282, ERRZERO, "Invalid index"); + RETVALUE(ROKDNA); + } + else if (q->crntSize == 0) + { + q->head = mBuf; + q->tail = mBuf; + + mBuf->b_next = NULLP; + mBuf->b_prev = NULLP; + } + else if (idx == 0) + { + mBuf->b_next = q->head; + mBuf->b_prev = NULLP; + q->head->b_prev = mBuf; + q->head = mBuf; + } + else if (idx == q->crntSize) + { + mBuf->b_prev = q->tail; + mBuf->b_next = NULLP; + q->tail->b_next = mBuf; + q->tail = mBuf; + } + else + { + tBuf = q->head; + for (i = 0; i < idx; i++) + { + tBuf = tBuf->b_next; + } + + tBuf->b_prev->b_next = mBuf; + mBuf->b_prev = tBuf->b_prev; + mBuf->b_next = tBuf; + tBuf->b_prev = mBuf; + } + q->crntSize++; + RETVALUE(ROK); + +} /* end of SAddQueue */ + + +/* +* +* Fun: SRemQueue +* +* Desc: This function removes a buffer from the queue at +* the desired index. +* +* Ret: ROK - ok +* ROKDNA - ok, data not available +* RFAILED - failed +* +* Notes: index is 0 based and indicates location in queue. +* +* if queue is empty: pointer to buffer is set to null and +* return is ok, data not available. queue length is unchanged. +* +* if queue is not empty: pointer to buffer is set to indexed +* buffer in queue. return is ok. queue length is decremented. +* +* File: ss_queue.c +* +*/ +#ifdef ANSI +PUBLIC S16 SRemQueue +( +Buffer **bufPtr, /* pointer to buffer */ +Queue *q, /* queue */ +QLen idx /* index */ +) +#else +PUBLIC S16 SRemQueue(bufPtr, q, idx) +Buffer **bufPtr; /* pointer to buffer */ +Queue *q; /* queue */ +QLen idx; /* index */ +#endif +{ + Buffer *tBuf; + QLen i; + + TRC1(SRemQueue) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check buffer pointer */ + if (bufPtr == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS283, ERRZERO, "Null Buf Ptr"); + RETVALUE(RFAILED); + } + + /* check queue */ + if (q == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS284, ERRZERO, "Null Q Ptr"); + RETVALUE(RFAILED); + } + + if ((S32)idx < 0) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS285, ERRZERO, "-ve Index"); + RETVALUE(RFAILED); + } +#endif /* ERRCLASS */ + + if (idx >= q->crntSize) + { + *bufPtr = NULLP; + RETVALUE(ROKDNA); + } + if (idx == 0) + { + *bufPtr = q->head; + if (q->crntSize == 1) + { + q->head = NULLP; + q->tail = NULLP; + } + else + { + q->head = q->head->b_next; + q->head->b_prev = NULLP; + } + } + else if (idx == q->crntSize -1) + { + *bufPtr = q->tail; + q->tail = q->tail->b_prev; + q->tail->b_next = NULLP; + } + else + { + tBuf = q->head; + + for (i = 0; i < idx; i++) + { + tBuf = tBuf->b_next; + } + *bufPtr = tBuf; + + tBuf->b_prev->b_next = tBuf->b_next; + tBuf->b_next->b_prev = tBuf->b_prev; + } + q->crntSize--; + + RETVALUE(ROK); + +} /* end of SRemQueue */ + + +#ifndef SS_ENABLE_MACROS + + +/* +* +* Fun: SQueueFirst +* +* Desc: This function queues a data or message buffer to the +* front of the specified queue. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: if queue is empty: buffer is placed in the queue. queue +* length is incremented. +* +* if queue is not empty: buffer is placed in front of all +* other buffers in queue. queue length is incremented. +* +* File: ss_queue.c +* +*/ +#ifdef ANSI +PUBLIC INLINE S16 SQueueFirst +( +Buffer *buf, /* buffer */ +Queue *q /* queue */ +) +#else +PUBLIC INLINE S16 SQueueFirst(buf, q) +Buffer *buf; /* buffer */ +Queue *q; /* queue */ +#endif +{ + TRC1(SQueueFirst) + + RETVALUE(SAddQueue(buf, q, 0)); +} /* end of SQueueFirst */ + + +/* +* +* Fun: SDequeueFirst +* +* Desc: This function dequeues a data or message buffer from +* the front of the specified queue. +* +* Ret: ROK - ok +* ROKDNA - ok, data not available +* RFAILED - failed, general (optional) +* +* Notes: if queue is empty: pointer to buffer is set to null and +* return is ok, data not available. queue length is unchanged. +* +* if queue is not empty: pointer to buffer is set to first +* buffer in queue, first buffer in queue is removed and +* return is ok. queue length is decremented. +* +* File: ss_queue.c +* +*/ +#ifdef ANSI +PUBLIC INLINE S16 SDequeueFirst +( +Buffer **bufPtr, /* pointer to buffer */ +Queue *q /* queue */ +) +#else +PUBLIC INLINE S16 SDequeueFirst(bufPtr, q) +Buffer **bufPtr; /* pointer to buffer */ +Queue *q; /* queue */ +#endif +{ + TRC2(SDequeueFirst) + + RETVALUE(SRemQueue(bufPtr, q, 0)); +} /* end of SDequeueFirst */ + + +/* +* +* Fun: SQueueLast +* +* Desc: This function queues a data or message buffer to the +* back of the specified queue. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: if queue is empty: buffer is placed in the queue. +* queue length is incremented. +* +* if queue is not empty: buffer is placed behind all +* other buffers in queue. queue length is incremented. +* +* File: ss_queue.c +* +*/ +#ifdef ANSI +PUBLIC S16 SQueueLast +( +Buffer *buf, /* buffer */ +Queue *q /* queue */ +) +#else +PUBLIC S16 SQueueLast(buf, q) +Buffer *buf; /* buffer */ +Queue *q; /* queue */ +#endif +{ + TRC1(SQueueLast) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check queue */ + if (q == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS286, ERRZERO, "Null Q Ptr"); + RETVALUE(RFAILED); + } + /* check queue */ + if (buf == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS287, ERRZERO, "Null Buf Ptr"); + RETVALUE(RFAILED); + } +#endif + RETVALUE(SAddQueue(buf, (q), ((q)->crntSize))); +} + + + +/* +* +* Fun: SDequeueLast +* +* Desc: This function dequeues a data or message buffer from the +* back of the specified queue. +* +* Ret: ROK - ok +* ROKDNA - ok, data not available +* RFAILED - failed, general (optional) +* +* Notes: if queue is empty: pointer to buffer is set to null and +* return is ok, data not available. queue length is unchanged. +* +* if queue is not empty: pointer to buffer is set to last +* buffer in queue, last buffer in queue is removed and +* return is ok. queue length is decremented. +* +* File: ss_queue.c +* +*/ +#ifdef ANSI +PUBLIC S16 SDequeueLast +( +Buffer **bufPtr, /* pointer to buffer */ +Queue *q /* queue */ +) +#else +PUBLIC S16 SDequeueLast(bufPtr, q) +Buffer **bufPtr; /* pointer to buffer */ +Queue *q; /* queue */ +#endif +{ + S16 ret; + + TRC1(SDequeueLast) + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check buffer pointer */ + if (!bufPtr) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS288, ERRZERO, "Null Buf Ptr"); + RETVALUE(RFAILED); + } + /* check queue */ + if (!q) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS289, ERRZERO, "Null Q Ptr"); + RETVALUE(RFAILED); + } +#endif + if(q->crntSize > 0) + ret = SRemQueue(bufPtr, q, q->crntSize-1); + else + ret = SRemQueue(bufPtr, q, q->crntSize); + + RETVALUE(ret); +} + +#endif /* SS_ENABLE_MACROS */ + + +/* +* +* Fun: ssInitDmndQ +* +* Desc: This function initializes a Demand Queue +* +* Ret: ROK - ok +* RFAILED - failed +* +* Notes: +* +* File: ss_queue.c +* +*/ +#ifdef ANSI +PUBLIC S16 ssInitDmndQ +( +SsDmndQ *dQueue /* Demand Queue */ +) +#else +PUBLIC S16 ssInitDmndQ(dQueue) +SsDmndQ *dQueue; /* Demand Queue */ +#endif +{ + U8 i; + S16 ret; + + TRC0(ssInitDmnddQ) + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (dQueue == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS290, ERRZERO, "NULL DQ Pointer"); + RETVALUE(RFAILED); + } +#endif + + for (i = 0; i < SS_MAX_NUM_DQ; i++) + { + dQueue->queue[i].head = NULLP; + dQueue->queue[i].tail = NULLP; + dQueue->queue[i].crntSize = 0; + } + +#ifndef TENB_RTLIN_CHANGES + for (i = 0; i < SS_DQ_BIT_MASK_LEN; i++) +#else + for (i = 0; i < SS_MAX_NUM_DQ; i++) +#endif + { +#ifndef TENB_RTLIN_CHANGES + dQueue->bitMask[i] = 0; +#endif + /* ss039.103 : Replaced SInitLock with WTInitLock */ +#ifdef SS_WIN + ret = WTInitLock(&dQueue->dmndQLock[i], SS_DMNDQ_LOCK); +#else + ret = SInitLock(&dQueue->dmndQLock[i], SS_DMNDQ_LOCK); +#endif + if (ret != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS291, (ErrVal)ret, + "Failed to initialize lock"); +#endif + RETVALUE(RFAILED); + } + } + + /* initialize the semaphore */ + ret = ssInitSema(&dQueue->dmndQSema, 0); + if (ret != ROK) + { +#ifndef TENB_RTLIN_CHANGES + for (i = 0; i < SS_DQ_BIT_MASK_LEN; i++) +#else + for (i = 0; i < SS_MAX_NUM_DQ; i++) +#endif + { + /* ss039.103 : Replaced SDestroyLock with WTDestroyLock */ +#ifdef SS_WIN + WTDestroyLock(&dQueue->dmndQLock[i]); +#else + SDestroyLock(&dQueue->dmndQLock[i]); +#endif + } +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS292, (ErrVal)ret, + "Failed to init semaphore"); +#endif + RETVALUE(RFAILED); + } + RETVALUE (ROK); + +} /* End of ssInitDmndQ */ + + +/* +* +* Fun: ssDestroyDmndQ +* +* Desc: This function destroys a Demand Queue by releasing all the +* queued messages and detroying all the associated locks +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: +* +* File: ss_queue.c +* +*/ +#ifdef ANSI +PUBLIC S16 ssDestroyDmndQ +( +SsDmndQ *dQueue /* demand Queue */ +) +#else +PUBLIC S16 ssDestroyDmndQ(dQueue) +SsDmndQ *dQueue; /* demand Queue */ +#endif +{ + U8 i; + Buffer *tBuf; + S16 ret; + + TRC0(ssDestroyDmndQ) + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (dQueue == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS293, ERRZERO, "NULL DQ Pointer"); + RETVALUE(RFAILED); + } +#endif + +#ifndef TENB_RTLIN_CHANGES + for (i = 0; i < SS_DQ_BIT_MASK_LEN; i++) +#else + for (i = 0; i < SS_MAX_NUM_DQ; i++) +#endif + { + /* ss039.103 : Replaced SDestroyLock with WTDestroyLock */ +#ifdef SS_WIN + ret = WTDestroyLock(&dQueue->dmndQLock[i]); +#else + ret = SDestroyLock(&dQueue->dmndQLock[i]); +#endif + if (ret != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS294, (ErrVal)ret, "Failed to destroy lock"); +#endif + RETVALUE(RFAILED); + } + } + for (i = 0; i < SS_MAX_NUM_DQ; i++) + { + while (dQueue->queue[i].head != NULLP) + { + tBuf = dQueue->queue[i].head; + dQueue->queue[i].head = dQueue->queue[i].head->b_next; + SPutMsg(tBuf); + } + } + +/* ss06.13:addition */ + if( ssDestroySema(&dQueue->dmndQSema) != ROK) + { + SSLOGERROR(ERRCLS_DEBUG, ESS295, ERRZERO, + "Could not delete the Semaphore"); + RETVALUE(RFAILED); + + } + RETVALUE (ROK); + +} /* end of ssDestroyDmndQ */ + + +/* +* +* Fun: ssDmndQPut +* +* Desc: This function adds a message to the head or tail of the +* priority queue specified. The priority specified is the +* destination Q index i.e +* ((dst_Tsk_pri * SS_MAX_MSG_PRI) + msg_pri) +* +* Ret: ROK - ok +* RFAILED - failed +* +* Notes: +* +* File: ss_queue.c +* +*/ +#ifdef ANSI +PUBLIC S16 ssDmndQPut +( +SsDmndQ *dQueue, /* demand Queue */ +Buffer *mBuf, /* message buffer */ +Prior priority, /* priority */ +Order order /* position */ +) +#else +PUBLIC S16 ssDmndQPut(dQueue, mBuf, priority, order) +SsDmndQ *dQueue; /* demand Queue */ +Buffer *mBuf; /* message buffer */ +Prior priority; /* priority */ +Order order; /* position */ +#endif +{ +#ifndef TENB_RTLIN_CHANGES + U8 maskIndex; /* mask Index */ + U8 bitPosition; /* bit position in index */ +#else + U8 qIndex; +#endif + Queue *queue; /* queue in demand queue */ + S16 ret; /* return value */ +#ifdef SS_PERF + int value; + U32 size; +#endif +#ifdef MSPD_MLOG_NEW + U32 t = MacGetTick(); +#endif + + TRC0(ssDmndQPut) + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (dQueue == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS296, ERRZERO, "NULL DQ Pointer"); + RETVALUE(RFAILED); + } + + if (mBuf == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS297, ERRZERO, "NULL mBuf Pointer"); + RETVALUE(RFAILED); + } + + if ((priority == PRIORNC) || (priority > SS_MAX_DQ_PRIOR)) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS298, ERRZERO, "invalid priority "); + RETVALUE(RFAILED); + } + + if ((order != SS_DQ_FIRST) && (order != SS_DQ_LAST)) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS299, ERRZERO, "invalid order "); + RETVALUE(RFAILED); + } +#endif + +#ifndef TENB_RTLIN_CHANGES + maskIndex = priority >> 3; + bitPosition = 7 - (priority % 8); + queue = &dQueue->queue[priority]; +#else + qIndex = priority; + queue = &dQueue->queue[qIndex]; +#endif + + /* ss039.103 : Replaced SLock with WTLock */ +#ifdef SS_WIN +#ifndef TENB_RTLIN_CHANGES + ret = WTLock(&dQueue->dmndQLock[maskIndex]); +#else + ret = WTLock(&dQueue->dmndQLock[qIndex]); +#endif +#else +#ifndef TENB_RTLIN_CHANGES + ret = SLock(&dQueue->dmndQLock[maskIndex]); +#else + ret = SLock(&dQueue->dmndQLock[qIndex]); +#endif +#endif + if (ret != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS300, (ErrVal)ret, "Failed to get lock"); +#endif + RETVALUE (RFAILED); + } + + if (queue->crntSize == 0) + { + queue->head = mBuf; + queue->tail = mBuf; + mBuf->b_next = NULLP; + mBuf->b_prev = NULLP; + +#ifndef TENB_RTLIN_CHANGES + /* Set the corresponding bit in bit mask */ + dQueue->bitMask[maskIndex] |= (1 << bitPosition); +#endif + } + else + { + if (order == SS_DQ_LAST) + { + mBuf->b_prev = queue->tail; + mBuf->b_next = NULLP; + queue->tail->b_next = mBuf; + queue->tail = mBuf; + } + else + { + mBuf->b_next = queue->head; + mBuf->b_prev = NULLP; + queue->head->b_prev = mBuf; + queue->head = mBuf; + } + } + queue->crntSize++; +#ifdef SS_PERF + size = queue->crntSize; +#endif + + /* ss039.103 : Replaced SUnlock with WTUnlock */ +#ifdef SS_WIN +#ifndef TENB_RTLIN_CHANGES + ret = WTUnlock(&dQueue->dmndQLock[maskIndex]); +#else + ret = WTUnlock(&dQueue->dmndQLock[qIndex]); +#endif +#else +#ifndef TENB_RTLIN_CHANGES + ret = SUnlock(&dQueue->dmndQLock[maskIndex]); +#else + ret = SUnlock(&dQueue->dmndQLock[qIndex]); +#endif +#endif + if (ret != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS301, (ErrVal)ret, "Failed to release lock"); +#endif + /* ss035.103 */ + if (order == SS_DQ_LAST) + { + SDequeueLast(&mBuf, queue); + } + else + { + SDequeueFirst(&mBuf, queue); + } + RETVALUE (RFAILED); + } + + /* increment the counting semaphore */ + /* ss006.13: addition */ + +/* ss037.103 for Performance enhancement : this is to ensure that semaphore is posted every time the first message is posted to the queue so that permanent tick is picked */ +#ifdef SS_PERF + if (size > 1) + { + sem_getvalue(&dQueue->dmndQSema, &value); + if (value > 0) + RETVALUE(ROK); + } +#endif + if (ssPostSema(&dQueue->dmndQSema) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS302, ERRZERO, + "Could not unlock the Semaphore"); + /* ss035.103 */ + if (order == SS_DQ_LAST) + { + SDequeueLast(&mBuf, queue); + } + else + { + SDequeueFirst(&mBuf, queue); + } + RETVALUE(RFAILED); +#endif + } + RETVALUE(ROK); + +} /* End of ssDmndQPut */ + + +/* +* +* Fun: ssDmndQWait +* +* Desc: This function removes a message from head or tail of the +* highest non-empty priority queue message. +* +* Ret: ROK - ok +* RFAILED - failed +* ROKDNA - ok, no data available in queue +* +* Notes: This is a blocking call +* +* File: ss_queue.c +* +*/ +#ifdef ANSI +PUBLIC S16 ssDmndQWait +( +SsDmndQ *dQueue /* demand queue */ +) +#else +PUBLIC S16 ssDmndQWait(dQueue) +SsDmndQ *dQueue; /* demand queue */ +#endif +{ + S16 ret; + + TRC0(ssDmndQWait) + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (dQueue == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS303, ERRZERO, "NULL DQ Pointer"); + RETVALUE(RFAILED); + } + +#endif + + /* ss040.103 updating for possible non-fatal retur from sem_wait */ + while ((ret = ssWaitSema(&dQueue->dmndQSema) != ROK) && (errno == EINTR)) + continue; + if (ret != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS306, (ErrVal)ret, "Failed to get semaphore"); +#endif + RETVALUE (RFAILED); + } + + RETVALUE (ROK); +} /* End of ssDmndQWait */ + + + +/* +* +* Fun: ssDmndQGet +* +* Desc: This function removes a message from head or tail of the +* highest non-empty priority queue message. +* +* Ret: ROK - ok +* RFAILED - failed +* ROKDNA - ok, no data available in queue +* +* Notes: This is a blocking call +* +* File: ss_queue.c +* +*/ +#ifdef ANSI +PUBLIC S16 ssDmndQGet +( +SsDmndQ *dQueue, /* demand queue */ +Buffer **mBuf, /* message buffer */ +Order order /* position */ +) +#else +PUBLIC S16 ssDmndQGet(dQueue, mBuf, order) +SsDmndQ *dQueue; /* demand queue */ +Buffer **mBuf; /* message buffer */ +Order order; /* position */ +#endif +{ + Queue *queue; + S16 ret; + S16 i; +#ifndef TENB_RTLIN_CHANGES + U8 bitPosition; + U8 qIndex; +#endif + + TRC0(ssDmndQGet) + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (mBuf == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS304, ERRZERO, "NULL mBuf Pointer"); + RETVALUE(RFAILED); + } + + if ((order != SS_DQ_FIRST) && (order != SS_DQ_LAST)) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS305, ERRZERO, "invalid order "); + RETVALUE(RFAILED); + } +#endif + +#ifndef TENB_RTLIN_CHANGES + for (i = 0; i < SS_DQ_BIT_MASK_LEN; i++) + { + /* ss039.103 : Replaced SLock with WTLock */ +#ifdef SS_WIN + ret = WTLock(&dQueue->dmndQLock[i]); +#else + ret = SLock(&dQueue->dmndQLock[i]); +#endif + if (ret != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS307, (ErrVal)ret, "Failed to get lock"); +#endif + RETVALUE (RFAILED); + } + + bitPosition = osCp.dmndQLookupTbl[dQueue->bitMask[i]]; + if (bitPosition != 255) + break; + + /* ss039.103 : Replaced SUnlock with WTUnlock */ +#ifdef SS_WIN + ret = WTUnlock(&dQueue->dmndQLock[i]); +#else + ret = SUnlock(&dQueue->dmndQLock[i]); +#endif + if (ret != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS308, ret, "Failed to release lock"); +#endif + RETVALUE (RFAILED); + } + } + if (i >= SS_DQ_BIT_MASK_LEN) + { + /* Demand Queue is empty */ + *mBuf = NULLP; + RETVALUE (ROKDNA); + } + + qIndex = (i * 8) + (7 - bitPosition); + queue = &dQueue->queue[qIndex]; + +#else + for (i = 0; i < SS_MAX_NUM_DQ; i++) + { + queue = &dQueue->queue[i]; + if (queue->crntSize) + break; + } + + if (i >= SS_MAX_NUM_DQ) + { + /* Demand Queue is empty */ + *mBuf = NULLP; + RETVALUE (ROKDNA); + } + + /* ss039.103 : Replaced SLock with WTLock */ +#ifdef SS_WIN + ret = WTLock(&dQueue->dmndQLock[i]); +#else + ret = SLock(&dQueue->dmndQLock[i]); +#endif + if (ret != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS307, (ErrVal)ret, "Failed to get lock"); +#endif + RETVALUE (RFAILED); + } + +#endif +/* ss037.103 For performance enhancement replace the check sequence with simple +setting the crntSize to 0 and removing the message */ +#ifndef SS_PERF + if (queue->crntSize == 1) + { + *mBuf = queue->head; + queue->head = NULLP; + queue->tail = NULLP; + + /* Reset the corresponding bit in bit mask */ + dQueue->bitMask[i] &= (~( 1 << (bitPosition))); + } + else + { + if (order == SS_DQ_FIRST) + { + *mBuf = queue->head; + queue->head = queue->head->b_next; + queue->head->b_prev = NULLP; + } + else + { + *mBuf = queue->tail; + queue->tail = queue->tail->b_prev; + queue->tail->b_next = NULLP; + } + } + queue->crntSize--; +#else + queue->crntSize = 0; + *mBuf = queue->head; + queue->head = NULLP; + queue->tail = NULLP; + +#endif + + /* ss039.103 : Replaced SUnlock with WTUnlock */ +#ifdef SS_WIN + ret = WTUnlock(&dQueue->dmndQLock[i]); +#else + ret = SUnlock(&dQueue->dmndQLock[i]); +#endif + if (ret != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS309, (ErrVal)ret, "Failed to release lock"); +#endif + RETVALUE (RFAILED); + } + + RETVALUE (ROK); + +} /* End of ssDmndQGet */ + + +/* +* +* Fun: ssFndLenDmndQ +* +* Desc: This function returns the number of messages in a queue +* If priority is specified, length of the associated Q is +* returned otherwise total length of all Qs is returned. +* +* Ret: ROK - ok +* RFAILED - failed +* +* Notes: +* +* File: ss_queue.c +* +*/ +#ifdef ANSI +PUBLIC S16 ssFndLenDmndQ +( +SsDmndQ *dQueue, /* demand queue */ +Prior priority, /* priority */ +QLen *len /* queue length */ +) +#else +PUBLIC S16 ssFndLenDmndQ(dQueue, priority, len) +SsDmndQ *dQueue; /* demand queue */ +Prior priority; /* priority */ +QLen *len; /* queue length */ +#endif +{ + + S16 ret; /* return value */ + U8 i; + + TRC0(ssFndLenDmndQ) + +#if (ERRCLASS & ERRCLS_INT_PAR) + if ((dQueue == NULLP) || (len == NULLP)) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS310, ERRZERO, "NULL Pointer"); + RETVALUE(RFAILED); + } +#endif + + *len = 0; + if (priority != PRIORNC) + { + i = priority >> 3; + /* ss039.103 : Replaced SLock with WTLock */ +#ifdef SS_WIN + ret = WTLock(&dQueue->dmndQLock[i]); +#else + ret = SLock(&dQueue->dmndQLock[i]); +#endif + if (ret != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS311, (ErrVal)ret, "Failed to get lock"); +#endif + RETVALUE (RFAILED); + } + + *len = dQueue->queue[priority].crntSize; + + /* ss039.103 : Replaced SUnlock with WTUnlock */ +#ifdef SS_WIN + ret = WTUnlock(&dQueue->dmndQLock[i]); +#else + ret = SUnlock(&dQueue->dmndQLock[i]); +#endif + if (ret != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS312, (ErrVal)ret, \ + "Failed to release lock"); +#endif + RETVALUE (RFAILED); + } + } + else + { +#ifndef TENB_RTLIN_CHANGES + for (i = 0; i < SS_DQ_BIT_MASK_LEN; i++) +#else + for (i = 0; i < SS_MAX_NUM_DQ; i++) +#endif + { + /* ss039.103 : Replaced SLock with WTLock */ +#ifdef SS_WIN + ret = WTLock(&dQueue->dmndQLock[i]); +#else + ret = SLock(&dQueue->dmndQLock[i]); +#endif + if (ret != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS313, (ErrVal)ret, "Failed to get lock"); +#endif + /* Release all the locks aquired */ + while (i > 0) + { + +/* ss006.13: addition */ + /* ss039.103 : Replaced SUnlock with WTUnlock */ +#ifdef SS_WIN + if( WTUnlock(&dQueue->dmndQLock[i-1]) != ROK) +#else + if( SUnlock(&dQueue->dmndQLock[i-1]) != ROK) +#endif + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS314, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + + i--; + } + + RETVALUE (RFAILED); + } + } + + for (i = 0; i < SS_MAX_NUM_DQ; i++) + *len += dQueue->queue[i].crntSize; + +#ifndef TENB_RTLIN_CHANGES + for (i = 0; i < SS_DQ_BIT_MASK_LEN; i++) +#else + for ( i = 0; i < SS_MAX_NUM_DQ; i++) +#endif + { + /* ss039.103 : Replaced SUnlock with WTUnlock */ +#ifdef SS_WIN + ret = WTUnlock(&dQueue->dmndQLock[i]); +#else + ret = SUnlock(&dQueue->dmndQLock[i]); +#endif + if (ret != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS315, (ErrVal)ret, "Failed to get lock"); +#endif + RETVALUE (RFAILED); + } + } + } + RETVALUE(ROK); + +} /* End of ssFndLenDmndQ */ + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/mt/ss_rbuf.c b/src/mt/ss_rbuf.c new file mode 100755 index 000000000..e0ef97c1c --- /dev/null +++ b/src/mt/ss_rbuf.c @@ -0,0 +1,615 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/* + Steps to Add a new Ring Buffer + +1. Add Buffer Id to enum in ss_rbuf.h +2. Update Static SsRngCfgTbl below for ring and element size. Add a macro in ss_rbuf.h +3. typedef a structure for element type if not available in ss_rbuf.h +4. Call SCreateSRngBuf for new Buffer id from bcInitRingBuffers() in bc_cpu_init.c +5. Call SAttachSRngBuf from producer and consumer ActvInit +6. Call SEnqSRngBuf and SDeqSRngBuf from producer and consumer respectively + +*/ +#include "envopt.h" /* environment options */ +#include "envdep.h" /* environment dependent */ +#include "envind.h" /* environment independent */ +#include "gen.h" /* general */ +#include "ssi.h" /* system services */ +#include "cm_err.h" +#include +#include "gen.x" /* general layer */ +#include "ssi.x" /* system services */ +#include "ss_rbuf.h" +#include "ss_rbuf.x" + +U32 ssRngBufStatus = 0; + +/* Global Ring Loop Up Table */ +SsRngBufTbl SsRngInfoTbl[SS_RNG_BUF_MAX]; + + +PUBLIC Void SsRngBufEnable(Void) +{ + ssRngBufStatus = TRUE; +} + + +PUBLIC Void SsRngBufDisable(Void) +{ + ssRngBufStatus = FALSE; + +} +/* +Func: SCreateSRngBuf +Desc: Creates Ring Buffer for the given Id. + Ring Structure is allocated from given + Region and Pool +*/ +#ifdef ANSI +PUBLIC S16 SCreateSRngBuf +( +U32 id, +Region region, +Pool pool, +U32 elmSize, +U32 rngSize +) +#else +PUBLIC S16 SCreateSRngBuf (id, region, pool, elmSize, rngSize) +U32 id; +Region region; +Pool pool; +U32 elmSize; +U32 rngSize; +#endif +{ + SsRngBuf* ring; + + /* Validate Id */ + if(id >= SS_RNG_BUF_MAX) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESSXXX, id, "Invalid RBUF ID"); +#endif + RETVALUE(RFAILED); + } + if(SsRngInfoTbl[id].r_addr != 0) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESSXXX, id, + "Failed to Create Ring Buffer Id Ring already exist"); +#endif + RETVALUE(RFAILED); + } + /* Get Element Size */ + + /* Get Ring Size */ + /* Allocate memory for Ring structure */ + ring = (SsRngBuf* )malloc(sizeof(SsRngBuf)); + if(ring == NULLP) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "Allocating Ring Failed!!!") +#endif + RETVALUE(RFAILED); + } +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESSXXX, ring, + "Failed to Create Ring Buffer Id Ring already exist"); +#endif + + ring->size = rngSize; /* No empty elem */ + ring->read = 0; + ring->write = 0; + ring->type = elmSize; + + /* Allocate elements memory */ + ring->elem = calloc(ring->size, ring->type); + if(ring->elem == NULLP) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "Allocating Ring Failed!!!") +#endif + free(ring); + RETVALUE(RFAILED); + } + /* Update Buffer Id Table */ + SsRngInfoTbl[id].r_addr = ring; + SsRngInfoTbl[id].rngState = SS_RNG_CREATED; + SsRngInfoTbl[id].n_write = 0; + SsRngInfoTbl[id].n_read = 0; + +#ifndef ALIGN_64BIT + printf("Ring Buffer Created with id =%ld rSize:%ld eSize:%ld %lx\n",id,ring->size,ring->type,(PTR)ring); +#else + printf("Ring Buffer Created with id =%d rSize:%d eSize:%d %lx\n",id,ring->size,ring->type,(PTR)ring); +#endif + RETVALUE(ROK); +} + +/* +Func: SAttachSRngBuf +Desc: Attach the calling Entity to a ring buffer + as consumer(Rx) or producer (Tx) +*/ +#ifdef ANSI +PUBLIC S16 SAttachSRngBuf +( +U32 id, +U32 ent, +U32 txRx +) +#else +PUBLIC S16 SAttachSRngBuf (id, ent, txRx) +U32 id; +U32 ent; +U32 txRx; +#endif +{ + /* Retrive Buffer from Global Info Table */ + if( id >= SS_RNG_BUF_MAX) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESSXXX, id, "Invalid RBUF ID"); +#endif + RETVALUE(RFAILED); + } + if(SsRngInfoTbl[id].rngState < SS_RNG_CREATED) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESSXXX, id, + "Attach Request in Invalid Ring ID"); +#endif +#ifndef ALIGN_64BIT + printf("Attach Request in Invalid Ring State %ld id%ld \n", + SsRngInfoTbl[id].rngState,id); +#else + printf("Attach Request in Invalid Ring State %d id%d \n", + SsRngInfoTbl[id].rngState,id); +#endif + RETVALUE(RFAILED); + } + if(txRx == SS_RNG_TX) + { + SsRngInfoTbl[id].txEnt = ent; + SsRngInfoTbl[id].rngState = SS_RNG_TX_ATTACHED; + } + else if(txRx == SS_RNG_RX) + { + SsRngInfoTbl[id].rxEnt = ent; + SsRngInfoTbl[id].rngState = SS_RNG_RX_ATTACHED; + } + RETVALUE(ROK); +} +/* +Func: SConnectSRngBuf +Desc: Establish a pipe between producer and consumer + +*/ +#ifdef ANSI +PUBLIC S16 SConnectSRngBuf +( +U32 id, +U32 rxEnt +) +#else +PUBLIC S16 SConnectSRngBuf (id, rxEnt) +U32 id; +U32 rxEnt; +#endif +{ + /* Send to Reciever ENT*/ + RETVALUE(ROK); +} + +/* +Func: IsFull +Desc: Checks if Ring is full +*/ +inline static S16 IsFull(SsRngBuf* rBuf) +{ +#if 0 + /* write+1 == read implies ring is full */ + return ((((rBuf->write + 1)> rBuf->size)?0:(rBuf->write+1))==rBuf->read); +#endif +#if 1 + if((rBuf->write+1) == rBuf->read) + { + return 1; + } + if((rBuf->write+1) == (rBuf->read + rBuf->size)) + { + return 1; + } + if((rBuf->write + 1) > rBuf->size ) + { + return 1; + } + return 0; +#endif +} +/* +Func: IsEmpty +Desc: Checks if ring is empty +*/ +inline static S16 IsEmpty(SsRngBuf* rBuf) +{ + /* write == read implies Buffer is empty*/ + return (rBuf->write == rBuf->read); +} + +PUBLIC S16 isRngEmpty(U32 id) +{ + return (IsEmpty(SsRngInfoTbl[id].r_addr)); +} +/* +Func: SEnqSRngBuf +Desc: Perform Queue operation on Ring bufer +*/ +#ifdef ANSI +PUBLIC S16 SEnqSRngBuf +( +U32 id, +Void* elem +) +#else +PUBLIC S16 SEnqSRngBuf(id,elem) +U32 id; +Void* elem; +#endif +{ + U8* w_ptr; + U8 i=0; + U8 *element = (U8 *)elem; + U32 wrIndex; + /* TBD To replace id with ring addr when SAttachSRngBuf is used*/ + /* Retrive Buffer from Id */ + SsRngBuf* ring = SsRngInfoTbl[id].r_addr; + if (IsFull(ring)) + { + SsRngInfoTbl[id].nWriteFail++; + RETVALUE(RFAILED); + } + /* TBD Avoid multiplication for optimisation */ + w_ptr = (U8*)ring->elem + (ring->write * ring->type); + /* TBD Avoid for loop - use memcpy */ + for( i=0; i < ring->type; i++) + { + *(U8*)w_ptr = *(U8*)element; + w_ptr++; + (U8*)element++; + } + /* Increment write index */ + wrIndex = ring->write + 1 ; + ring->write = (wrIndex == ring->size)?0: wrIndex; + /* Update Statistics */ + SsRngInfoTbl[id].n_write++; + RETVALUE(ROK); +} + +#ifdef ANSI +PUBLIC S16 SGetNumElemInRng +( +U32 id +) +#else +PUBLIC S16 SGetNumElemInRng (id) +U32 id; +#endif +{ + + S16 freeDist = (SsRngInfoTbl[id].n_write- SsRngInfoTbl[id].n_read); + + RETVALUE(freeDist); +} +/* +Func: SDeqSRngBuf +Desc: Perform DeQueue operation on Ring bufer +*/ +#ifdef ANSI +PUBLIC S16 SDeqSRngBuf +( +U32 id, +Void *elem +) +#else +PUBLIC S16 SDeqSRngBuf (id,elem) +U8 id; +Void *elem; +#endif +{ + U8* r_ptr; + U8 i=0; + U8 *element = (U8 *)elem; + U32 rdIndex; + /* Retrive Buffer from Id*/ + SsRngBuf* ring = SsRngInfoTbl[id].r_addr; + if(IsEmpty(ring)) + { + SsRngInfoTbl[id].nReadFail++; + RETVALUE(RFAILED); + } + r_ptr = (U8*)ring->elem + (ring->read * ring->type); + for(i=0; itype; i++) + { + *(U8*)element = *r_ptr; + (U8*)element++; + r_ptr++; + } + // Avoiding % operation for wrap around + rdIndex= ring->read + 1; + ring->read = (rdIndex == ring->size)?0:rdIndex; + SsRngInfoTbl[id].n_read++; + RETVALUE(ROK); +} + +#ifdef ANSI +PUBLIC S16 SDestroySRngBuf +( +U32 id, +Region region, +Pool pool +) +#else +PUBLIC S16 SDestroySRngBuf(id, region, pool) +U32 id; +Region region; +Pool pool; +#endif +{ + /* Retrive Buffer from Id */ + SsRngBuf* ring = SsRngInfoTbl[id].r_addr; + if(ring) + { + //SPutSBuf(region, pool, (Data *)ring->elem, (ring->size * ring->type)); + //SPutSBuf(region, pool, (Data *)ring, sizeof(SsRngBuf)); + + free(ring->elem); /* OK if null */ + free(ring); /* OK if null */ + + /* Update Global Info table */ + SsRngInfoTbl[id].rngState = SS_RNG_DESTROYED; + SsRngInfoTbl[id].r_addr = 0; + } + RETVALUE(ROK); +} + +#ifdef ANSI +PUBLIC S16 SPrintSRngStats +( +Void +) +#else +PUBLIC S16 SPrintSRngStats () +Void; +#endif +{ +U32 i; + + Txt prntBuf[100]; + +#ifdef RGL_SPECIFIC_CHANGES + RETVALUE(ROK); +#endif + for(i=0; i< SS_RNG_BUF_MAX;i++) + { + if(SsRngInfoTbl[i].r_addr != 0 ) + { +#ifndef ALIGN_64BIT + sprintf(prntBuf,"\n=======Ring %ld Stats========\n",i); + SDisplay(0, prntBuf); + sprintf(prntBuf,"r_addr = %lx\n", (PTR)SsRngInfoTbl[i].r_addr); + SDisplay(0, prntBuf); + sprintf(prntBuf,"txEnt = %lx\n", (PTR)SsRngInfoTbl[i].txEnt); + SDisplay(0, prntBuf); + sprintf(prntBuf,"rxEnt = %lx\n", (PTR)SsRngInfoTbl[i].rxEnt); + SDisplay(0, prntBuf); + sprintf(prntBuf,"n_write = %lu\n", SsRngInfoTbl[i].n_write); + SDisplay(0, prntBuf); + sprintf(prntBuf,"n_read = %lu\n", SsRngInfoTbl[i].n_read); + SDisplay(0, prntBuf); + sprintf(prntBuf,"nWriteFail = %lu\n", SsRngInfoTbl[i].nWriteFail); + SDisplay(0, prntBuf); + sprintf(prntBuf,"nReadFail = %lu\n", SsRngInfoTbl[i].nReadFail); + SDisplay(0, prntBuf); + sprintf(prntBuf,"pktDrop = %lu\n", SsRngInfoTbl[i].pktDrop); + SDisplay(0, prntBuf); + sprintf(prntBuf,"State = %lu\n\n", SsRngInfoTbl[i].rngState); + SDisplay(0, prntBuf); + sprintf(prntBuf,"nPktProc = %lu\n\n", SsRngInfoTbl[i].nPktProc); + SDisplay(0, prntBuf); +#else + sprintf(prntBuf,"\n=======Ring %d Stats========\n",i); + SDisplay(0, prntBuf); + sprintf(prntBuf,"r_addr = %lx\n", (PTR)SsRngInfoTbl[i].r_addr); + SDisplay(0, prntBuf); + sprintf(prntBuf,"txEnt = %lx\n", (PTR)SsRngInfoTbl[i].txEnt); + SDisplay(0, prntBuf); + sprintf(prntBuf,"rxEnt = %lx\n", (PTR)SsRngInfoTbl[i].rxEnt); + SDisplay(0, prntBuf); + sprintf(prntBuf,"n_write = %u\n", SsRngInfoTbl[i].n_write); + SDisplay(0, prntBuf); + sprintf(prntBuf,"n_read = %u\n", SsRngInfoTbl[i].n_read); + SDisplay(0, prntBuf); + sprintf(prntBuf,"nWriteFail = %u\n", SsRngInfoTbl[i].nWriteFail); + SDisplay(0, prntBuf); + sprintf(prntBuf,"nReadFail = %u\n", SsRngInfoTbl[i].nReadFail); + SDisplay(0, prntBuf); + sprintf(prntBuf,"pktDrop = %u\n", SsRngInfoTbl[i].pktDrop); + SDisplay(0, prntBuf); + sprintf(prntBuf,"State = %u\n\n", SsRngInfoTbl[i].rngState); + SDisplay(0, prntBuf); + sprintf(prntBuf,"nPktProc = %u\n\n", SsRngInfoTbl[i].nPktProc); + SDisplay(0, prntBuf); + +#endif + } + } + RETVALUE(ROK); +} + +#ifdef ANSI +PUBLIC Void* SRngGetWIndx +( +U32 rngId +) +#else +PUBLIC Void* SRngGetWIndx (rngId) +U32 rngId; +#endif +{ + /* Retrive Buffer from Id*/ + SsRngBuf* ring = SsRngInfoTbl[rngId].r_addr; + if (IsFull(ring)) + { + SsRngInfoTbl[rngId].nWriteFail++; + RETVALUE(NULLP); + } + else + { + RETVALUE(((U8 *)ring->elem) + (ring->type * ring->write)); + } +} + +#ifdef ANSI +PUBLIC Void* SRngGetRIndx +( +U32 rngId +) +#else +PUBLIC Void* SRngGetRIndx (rngId) +U32 rngId; +#endif +{ + /* Retrive Buffer from Id*/ + SsRngBuf* ring = SsRngInfoTbl[rngId].r_addr; + if(IsEmpty(ring)) + { + SsRngInfoTbl[rngId].nReadFail++; + RETVALUE(NULLP); + } + else + { + RETVALUE(((U8 *)ring->elem) + (ring->type * ring->read)); + } +} + +#ifdef ANSI +PUBLIC Void SRngIncrWIndx +( +U32 rngId +) +#else +PUBLIC Void SRngIncrWIndx (rngId) +U32 rngId; +#endif +{ + U32 wrIndex; + /* Retrive Buffer from Id*/ + SsRngBuf* ring = SsRngInfoTbl[rngId].r_addr; + wrIndex = ring->write + 1; + ring->write = (wrIndex == ring->size)?0:wrIndex; + /* Update Statistics */ + SsRngInfoTbl[rngId].n_write++; +} + +#ifdef ANSI +PUBLIC Void SRngIncrRIndx +( +U32 rngId +) +#else +PUBLIC Void SRngIncrRIndx (rngId) +U32 rngId; +#endif +{ + U32 rdIndex; + /* Retrive Buffer from Id*/ + SsRngBuf* ring = SsRngInfoTbl[rngId].r_addr; + rdIndex = ring->read + 1; + ring->read = (rdIndex == ring->size)?0:rdIndex; + /* Update Statistics */ + SsRngInfoTbl[rngId].n_read++; +} +#ifdef XEON_SPECIFIC_CHANGES +#if (defined (MAC_FREE_RING_BUF) || defined (RLC_FREE_RING_BUF)) +S16 mtAddBufToRing(SsRngBufId ringId,void *bufPtr,U8 freeType) +{ + S16 ret1 = ROK; + + Void *elem = NULLP; + + RgKwFreeInfo *bufFreeInfo = NULLP; + elem = SRngGetWIndx(ringId); + + if (NULLP != elem) + { + bufFreeInfo = (RgKwFreeInfo *) elem; + + bufFreeInfo->bufToFree = bufPtr; + bufFreeInfo->freeType = freeType; + + SRngIncrWIndx(ringId); + + SsRngInfoTbl[ringId].pktRate++; + } + else + { + printf("Free Ring FULL id %d!!! \n",ringId); + SsRngInfoTbl[ringId].pktDrop++; + ret1 = RFAILED; + } + RETVALUE(ret1); +} +#endif +#endif + + + +#if 0 +int main(int argc, char **argv) +{ + SCreateSRngBuf(1,sizeof(SsRngBuf), 10); + rngElem* buf; + /* Fill buffer with test elements 3 times */ + buf = (SsRngBuf*)malloc(sizeof(rngBuf)); + buf->ptr = 1; + SEnqSRngBuf(1, buf); + buf = (SsRngBuf*)malloc(sizeof(rngBuf)); + buf->ptr = 2; + SEnqSRngBuf(1, buf); + buf = (SsRngBuf*)malloc(sizeof(rngBuf)); + buf->ptr = 3; + SEnqSRngBuf(1, buf); + + SDeqSRngBuf(1,buf); + printf("buf 1 = %d",buf->ptr); + SDeqSRngBuf(1,buf); + printf("buf 2 = %d",buf->ptr); + SDeqSRngBuf(1,buf); + printf("buf 3 = %d",buf->ptr); + + return 0; +} +#endif + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/mt/ss_strm.c b/src/mt/ss_strm.c new file mode 100644 index 000000000..2fe524bf1 --- /dev/null +++ b/src/mt/ss_strm.c @@ -0,0 +1,1529 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/********************************************************************20** + + Name: System Services -- STREAMS + + Type: C source file + + Desc: Implementation of STREAMS messaging functions. + + File: ss_strm.c + +*********************************************************************21*/ + + +/* header include files (.h) */ + +#include "envopt.h" /* environment options */ +#include "envdep.h" /* environment dependent */ +#include "envind.h" /* environment independent */ + +#include "gen.h" /* general layer */ +#include "ssi.h" /* system services */ + +#include "ss_err.h" /* errors */ +#include "ss_dep.h" /* implementation-specific */ +#include "ss_queue.h" /* queues */ +#include "ss_strm.h" /* STREAMS */ +#include "ss_msg.h" /* messaging */ +#include "ss_mem.h" /* memory management interface */ +#include "ss_gen.h" /* general */ +#include "cm_mem.h" /* memory management */ + + + +/* header/extern include files (.x) */ + +#include "gen.x" /* general layer */ +#include "ssi.x" /* system services */ + + +#include "ss_dep.x" /* implementation-specific */ +#include "ss_queue.x" /* queues */ +#include "ss_task.x" /* tasking */ +#include "ss_timer.x" /* timers */ +#include "ss_strm.x" /* STREAMS */ +#include "ss_msg.x" /* messaging */ +#include "ss_mem.x" /* memory management interface */ +#include "ss_drvr.x" /* driver tasks */ +#ifdef SS_LOCKLESS_MEMORY +#include "cm_llist.x" +#include "cm_hash.x" +#include "cm_mem_wl.x" /* common memory manager */ +#else +#include "cm_mem.x" /* common memory manager */ +#endif /* SS_LOCKLESS_MEMORY */ +#include "ss_gen.x" /* general */ + + + +/* private variable declarations */ + +PRIVATE struct +{ + Region mdRegion; /* region for message and data blocks */ + Region datRegion; /* region for data buffers */ +} strmCfg; + + + + +/* +* Interface functions (System Services--non-STREAMS interface) +*/ + + +/* +* +* Fun: ssStrmCfg +* +* Desc: Configures the STREAMS system. +* +* Ret: ROK - ok +* +* Notes: +* +* File: ss_strm.c +* +*/ +#ifdef ANSI +PUBLIC S16 ssStrmCfg +( +Region mdRegId, /* region for message and data blocks */ +Region datRegId /* region for data buffers */ +) +#else +PUBLIC S16 ssStrmCfg(mdRegId, datRegId) +Region mdRegId; /* region for message and data blocks */ +Region datRegId; /* region for data buffers */ +#endif +{ + TRC1(ssStrmCfg); + + + strmCfg.mdRegion = mdRegId; + strmCfg.datRegion = datRegId; + + + RETVALUE(ROK); +} + + +/* +* STREAMS interface functions +* +* All these assume that ssStrmCfg() has been called first, with +* valid parameters. +*/ + + +/* +* +* Fun: ssAdjMsg +* +* Desc: Trim abs(len) bytes from a message. If len is less than +* 0, trim from the tail, otherwise from the head. Operates +* only on blocks of the same type. Does not remove emptied +* message blocks. +* +* +* Ret: 1 - ok +* 0 - failure +* +* Notes: +* +* File: ss_strm.c +* +*/ +#ifdef ANSI +PUBLIC S32 ssAdjMsg +( +SsMblk *mp, /* message */ +S32 len /* bytes to remove */ +) +#else +PUBLIC S32 ssAdjMsg(mp, len) +SsMblk *mp; /* message */ +S32 len; /* bytes to remove */ +#endif +{ + S32 n; /* counter */ + S32 size; /* size of mblks of same type as head/tail */ + U8 type; /* message type */ + SsMblk *bp; /* mblk for iteration */ + SsMblk *first; /* first mblk to be adjusted */ + + + TRC1(ssAdjMsg); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (mp == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS325, ERRZERO, "Null pointer"); + RETVALUE(0); + } +#endif + + + if (len == 0) /* nothing to do */ + { + RETVALUE(1); + } + + + if (len > 0) /* trim from the head */ + { + /* figure out the size of all blocks of the same type as the head */ + bp = mp; + size = 0; + type = bp->b_datap->db_type; + while (bp && bp->b_datap->db_type == type) + { + n = bp->b_wptr - bp->b_rptr; + if (n > 0) + { + size += n; + } + + bp = bp->b_cont; + } + + + /* if we can't trim len bytes, fail */ + if (len > size) + { + RETVALUE(0); + } + + + /* do the trimming */ + bp = mp; + for (; ;) + { + n = bp->b_wptr - bp->b_rptr; + + if (n >= len) + { + bp->b_rptr += len; + break; + } + else if (n > 0) + { + bp->b_rptr += len; + len -= n; + } + + bp = bp->b_cont; + } + } + else /* trim from the tail */ + { + /* figure out the size of all blocks of the same type as the tail */ + bp = mp; + first = bp; + size = 0; + type = bp->b_datap->db_type; + while (bp) + { + if (bp->b_datap->db_type == type) + { + n = bp->b_wptr - bp->b_rptr; + if (n > 0) + { + size += n; + } + } + else + { + type = bp->b_datap->db_type; + first = bp; + size = 0; + } + + bp = bp->b_cont; + } + + + /* if we can't trim len bytes, fail */ + size += len; + if (size < 0) + { + RETVALUE(0); + } + + + /* do the trimming */ + while (first) + { + n = first->b_wptr - first->b_rptr; + + if (size <= 0) + { + first->b_rptr = first->b_wptr; + } + else if (n > 0) + { + if (n > size) + { + first->b_wptr = first->b_rptr + size; + } + + size -= n; + } + + first = first->b_cont; + } + } + + + RETVALUE(1); +} /* ssAdjMsg */ + + +/* +* +* Fun: ssAllocB +* +* Desc: Returns a pointer to a message block of type M_DATA +* in which the data buffer is of at least the specified +* size. +* +* +* Ret: non-NULL - success +* NULL - failure +* +* Notes: The parameter pri is unused. +* +* File: ss_strm.c +* +*/ +#ifdef ANSI +PUBLIC SsMblk *ssAllocB +( +S32 size, /* required size */ +U32 pri /* message priority */ +) +#else +PUBLIC SsMblk *ssAllocB(size, pri) +S32 size; /* required size */ +U32 pri; /* message priority */ +#endif +{ + SsMblk *bp; /* mblk for iteration */ + Data *dat; /* pointer to data buffer */ + Size m; /* temporary */ + Size n; /* temporary */ + S16 r; /* return value */ + + +#ifdef T2K_MEM_LEAK_DBG + char* file = __FILE__; + U32 line = __LINE__; +#endif + TRC1(ssAllocB); + + + UNUSED(pri); + + + /* allocate a single block for the mblock and the dblock */ + m = (sizeof(SsMblk) + sizeof(SsDblk)); +/* ss001.301: additions */ +#ifdef SS_HISTOGRAM_SUPPORT + r = SAlloc(strmCfg.mdRegion, &m, 0, (Data **)&bp, __LINE__, (U8*)__FILE__, ENTNC); +#else + r = SAlloc(strmCfg.mdRegion, &m, 0, (Data **)&bp); +#endif /* SS_HISTOGRAM_SUPPORT */ + if (r != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SSLOGERROR(ERRCLS_ADD_RES, ESS326, (ErrVal) r, "SAlloc() failed"); +#endif + + RETVALUE(NULLP); + } + + + /* allocate space for the data block */ + if (size > 0) + { + n = size; +/* ss001.301: additions */ +#ifdef SS_HISTOGRAM_SUPPORT + r = SAlloc(strmCfg.datRegion, &n, 0, &dat, __LINE__, (U8*)__FILE__, ENTNC); +#else + r = SAlloc(strmCfg.datRegion, &n, 0, &dat); +#endif /* SS_HISTOGRAM_SUPPORT */ + if (r != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SSLOGERROR(ERRCLS_ADD_RES, ESS327, (ErrVal) r, "SAlloc() failed"); +#endif + +/* ss001.301: additions */ +#ifdef SS_HISTOGRAM_SUPPORT + SFree(strmCfg.mdRegion, (Data *)bp, m, __LINE__, (U8*)__FILE__, ENTNC); +#else + SFree(strmCfg.mdRegion, (Data *)bp, m); +#endif /* SS_HISTOGRAM_SUPPORT */ + RETVALUE(NULLP); + } + } + /* we _can_ allocate a message with an empty data block */ + else + { + dat = NULLP; + } + + /* generic set-up-message function */ + SS_STRM_INITB(bp, (SsDblk *)(((U8 *)bp) + sizeof(SsMblk)), dat, size, NULLP); + + + RETVALUE(bp); +} /* ssAllocB */ + + +/* +* +* Fun: ssCopyB +* +* Desc: Copies the contents of the specified message block +* into a newly-allocated message block of at least +* the same size. Calls ssAllocB(). +* +* Ret: non-NULL - ok +* NULL - failure +* +* Notes: +* +* File: ss_strm.c +* +*/ +#ifdef ANSI +PUBLIC SsMblk *ssCopyB +( +SsMblk *mp /* message block */ +) +#else +PUBLIC SsMblk *ssCopyB(mp) +SsMblk *mp; /* message block */ +#endif +{ + SsMblk *bp; /* mblk for iteration */ + U8 *ptr; /* pointer to data */ + U32 size; /* size of data content */ + + + TRC1(ssCopyB); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (mp == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS328, ERRZERO, "Null pointer"); + RETVALUE(NULLP); + } +#endif + + + /* allocate another message */ + bp = ssAllocB((mp->b_datap->db_lim - mp->b_datap->db_base), 0); + if (bp == NULLP) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SSLOGERROR(ERRCLS_ADD_RES, ESS329, ERRZERO, "ssAllocB() failed"); +#endif + + RETVALUE(NULLP); + } + + + /* copy the contents, if any */ + size = (mp->b_wptr - mp->b_rptr); + if (size > 0) + { + ptr = mp->b_rptr; + while (ptr != mp->b_wptr) + { + *bp->b_wptr++ = *ptr++; + } + } + + + RETVALUE(bp); +} /* ssCopyB */ + + +/* +* +* Fun: ssCopyMsg +* +* Desc: Uses ssCopyB to copy the message blocks contained in +* the specified message to newly allocated blocks and +* links those blocks into a new message. +* +* Ret: non-NULL - ok +* NULL - failure +* +* Notes: +* +* File: ss_strm.c +* +*/ +#ifdef ANSI +PUBLIC SsMblk *ssCopyMsg +( +SsMblk *mp /* message block */ +) +#else +PUBLIC SsMblk *ssCopyMsg(mp) +SsMblk *mp; /* message block */ +#endif +{ + SsMblk *first; /* first mblk in message */ + SsMblk *bp; /* mblk for iteration */ + + + TRC1(ssCopyMsg); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (mp == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS330, ERRZERO, "Null pointer"); + RETVALUE(NULLP); + } +#endif + + + /* copy the first mblock */ + first = bp = ssCopyB(mp); + if (bp == NULLP) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SSLOGERROR(ERRCLS_ADD_RES, ESS331, ERRZERO, "ssCopyB() failed"); +#endif + + RETVALUE(NULLP); + } + + + /* copy all the rest, linking the new ones at the same time */ + while (mp->b_cont) + { + mp = mp->b_cont; + + bp->b_cont = ssCopyB(mp); + + /* if any copy fails, free whatever exists of the new message */ + if (bp->b_cont == NULLP) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SSLOGERROR(ERRCLS_ADD_RES, ESS332, ERRZERO, "ssCopyB() failed"); +#endif + + ssFreeMsg(first); + RETVALUE(NULLP); + } + + bp = bp->b_cont; + } + + + RETVALUE(first); +} /* ssCopyMsg */ + + +/* +* +* Fun: ssDupB +* +* Desc: Duplicates the specified message block, copying it +* into a newly-allocated message block. Increments +* the reference count of the data block that is pointed +* at by the original message block descriptor. +* +* Ret: non-NULL - ok +* NULL - failure +* +* Notes: +* +* File: ss_strm.c +* +*/ +#ifdef ANSI +PUBLIC SsMblk *ssDupB +( +SsMblk *mp /* message block */ +) +#else +PUBLIC SsMblk *ssDupB(mp) +SsMblk *mp; /* message block */ +#endif +{ + SsMblk *bp; /* mblk for iteration */ + /* ss028.103 - Addition of lock for mBuf reference count */ + + TRC1(ssDupB); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (mp == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS333, ERRZERO, "Null pointer"); + RETVALUE(NULLP); + } +#endif + + + /* allocate a message with no data buffer */ + bp = ssAllocB(0, 0); + if (bp == NULLP) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SSLOGERROR(ERRCLS_ADD_RES, ESS334, ERRZERO, "ssAllocB() failed"); +#endif + + RETVALUE(NULLP); + } + + + /* make the new message block identical to the one to be dup'ed. + * notice that an mblk/dblk pair is allocated but only the mblk + * is used,, this is for optimum performance in the average case. + */ + + + + /* ss002.13: addition */ + + + /* ss003.13: addition */ + SMemCpy( (Void *)bp, (Void *)mp, (size_t)sizeof(SsMblk)); + + + /* ss028.103 - Addition of lock for mBuf reference count */ + /* ss006.301 - use the mBufRefLock for the DFLT_REGION */ +#ifndef SS_DBUF_REFLOCK_DISABLE + if(SLock(&mp->b_datap->dBufLock) != ROK) + { + SSLOGERROR(ERRCLS_DEBUG, ESS335, ERRZERO, + "Could not lock the mBuf Ref Lock"); + RETVALUE(NULLP); + } +#endif + + /* increment the reference count of the dblock */ + mp->b_datap->db_ref++; + mp->b_datap->shared = TRUE; + + /* ss006.301 - use the mBufRefLock for the DFLT_REGION */ +#ifndef SS_DBUF_REFLOCK_DISABLE + if ( SUnlock(&mp->b_datap->dBufLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS336, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(NULLP); +#endif + } +#endif + + RETVALUE(bp); +} /* ssDupB */ + + +/* +* +* Fun: ssDupMsg +* +* Desc: Calls ssDupB to duplicate the specified message by +* copying all message block descriptors and then linking +* the new message blocks together to form a new message. +* +* Ret: non-NULL - ok +* NULL - failure +* +* Notes: +* +* File: ss_strm.c +* +*/ +#ifdef ANSI +PUBLIC SsMblk *ssDupMsg +( +SsMblk *mp /* message block */ +) +#else +PUBLIC SsMblk *ssDupMsg(mp) +SsMblk *mp; /* message block */ +#endif +{ + SsMblk *first; /* first mblk in message */ + SsMblk *bp; /* mblk for iteration */ + + + TRC1(ssDupMsg); + + + /* dup the first mblock */ + first = bp = ssDupB(mp); + if (bp == NULLP) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SSLOGERROR(ERRCLS_ADD_RES, ESS337, ERRZERO, "ssDupB() failed"); +#endif + + RETVALUE(NULLP); + } + + + /* dup all the rest, linking the new ones at the same time */ + while (mp->b_cont) + { + mp = mp->b_cont; + + bp->b_cont = ssDupB(mp); + + /* if any dup fails, free whatever exists of the new message */ + if (bp->b_cont == NULLP) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SSLOGERROR(ERRCLS_ADD_RES, ESS338, ERRZERO, "ssDupB() failed"); +#endif + + ssFreeMsg(first); + RETVALUE(NULLP); + } + + bp = bp->b_cont; + } + + + RETVALUE(first); +} /* ssDupMsg */ + + +/* +* +* Fun: ssESBAlloc +* +* Desc: Allocates message and data blocks that point directly +* at a client-supplied buffer. +* +* Ret: non-NULL - ok +* NULL - failure +* +* Notes: +* +* File: ss_strm.c +* +*/ +#ifdef ANSI +PUBLIC SsMblk *ssESBAlloc +( +U8 *base, /* client supplied data buffer */ +S32 size, /* size of data buffer */ +S32 pri, /* message priority */ +SsFrtn *fr_rtn /* free routine */ +) +#else +PUBLIC SsMblk *ssESBAlloc(base, size, pri, fr_rtn) +U8 *base; /* client supplied data buffer */ +S32 size; /* size of data buffer */ +S32 pri; /* message priority */ +SsFrtn *fr_rtn; /* free routine */ +#endif +{ + SsMblk *bp; /* mblk for iteration */ + Size m; /* mblk + dblk */ + S16 r; /* return value */ + + + TRC1(ssESBAlloc); + + + UNUSED(pri); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (base == NULLP || fr_rtn == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS339, ERRZERO, "Null pointer"); + RETVALUE(NULLP); + } +#endif + + + /* allocate space for an mblock and a dblock */ + m = (sizeof(SsMblk) + sizeof(SsDblk)); +/* ss001.301: additions */ +#ifdef SS_HISTOGRAM_SUPPORT + r = SAlloc(strmCfg.mdRegion, &m, 0, (Data **)&bp, __LINE__, (U8*)__FILE__, ENTNC); +#else +#ifdef T2K_MEM_LEAK_DBG + char* file = __FILE__; + U32 line = __LINE__; +#endif + r = SAlloc(strmCfg.mdRegion, &m, 0, (Data **)&bp); +#endif /* SS_HISTOGRAM_SUPPORT */ + if (r != ROK) + { +#if (ERRCLASS & ERRCLS_ADD_RES) + SSLOGERROR(ERRCLS_ADD_RES, ESS340, (ErrVal) r, "SAlloc() failed"); +#endif + + RETVALUE(NULLP); + } + + + /* use the generic set-up-message function to initialize everything */ + SS_STRM_INITB(bp, (SsDblk *)(((U8 *)bp) + sizeof(SsMblk)), + base, size, fr_rtn); + + + RETVALUE(bp); +} /* ssESBAlloc */ + + +/* +* +* Fun: ssFreeB +* +* Desc: Deallocates the specified message block descriptor +* and frees the corresponding data block if the +* reference count is equal to 1. If not, the reference +* count is decremented. +* +* Ret: Void +* +* Notes: +* +* File: ss_strm.c +* +*/ +#ifdef ANSI +PUBLIC Void ssFreeB +( +SsMblk *mp /* message block */ +) +#else +PUBLIC Void ssFreeB(mp) +SsMblk *mp; /* message block */ +#endif +{ + SsMblk *bp; /* mblk for iteration */ + Size size; /* mblk + dblk */ + /* ss028.103 - Addition of lock for mBuf reference count */ + +#ifdef T2K_MEM_LEAK_DBG + char* file = __FILE__; + U32 line = __LINE__; +#endif + + TRC1(ssFreeB); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (mp == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS341, ERRZERO, "Null pointer"); + RETVOID; + } +#endif + + + size = sizeof(SsMblk) + sizeof(SsDblk); + + + /* this mblock has already been freed, and still exists only + * because there is a reference to its dblock. it will be + * freed when the referring mblock is freed. + */ + + if (mp->b_datap == NULLP) + { + RETVOID; + } + + + /* ?? this should never happen ?? */ + if (mp->b_datap->db_ref == 0) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS342, ERRZERO, + "Zero reference count in ssFreeB; logic failure"); +#endif + +/* ss001.301: additions */ +#ifdef SS_HISTOGRAM_SUPPORT + SFree(strmCfg.mdRegion, (Data *)mp, size, __LINE__, (U8*)__FILE__, ENTNC); +#else +#ifdef T2K_MEM_LEAK_DBG + SFree(strmCfg.mdRegion, (Data *)mp, size); +#else + SFree(strmCfg.mdRegion, (Data *)mp, size); +#endif +#endif /* SS_HISTOGRAM_SUPPORT */ + RETVOID; + } + + /* ss028.103 - Addition of lock for mBuf reference count */ + /* ss006.301 - use the mBufRefLock for the DFLT_REGION */ +#ifndef SS_DBUF_REFLOCK_DISABLE + if(SLock(&mp->b_datap->dBufLock) != ROK) + { + SSLOGERROR(ERRCLS_DEBUG, ESS343, ERRZERO, + "Could not lock the mBuf Ref Lock"); + RETVOID; + } +#endif + + /* decrement reference count of the dblock */ + mp->b_datap->db_ref--; + + /* ss006.301 - use the mBufRefLock for the DFLT_REGION */ +#ifndef SS_DBUF_REFLOCK_DISABLE + if ( SUnlock(&mp->b_datap->dBufLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS344, ERRZERO, + "Could not give the Semaphore"); + RETVOID; +#endif + } +#endif + + /* if we have no more references to this dblock, we can free + * the data buffer and the header. + */ + + if (mp->b_datap->db_ref == 0) + { + /* if there is a free routine, we call it for the data buffer; + * otherwise, we've allocated the data buffer and so we free it. + */ +#ifndef SS_DBUF_REFLOCK_DISABLE + SDestroyLock(&mp->b_datap->dBufLock); +#endif +/* ss008.301 */ +#ifdef SS_DBLK_FREE_RTN + if (mp->b_datap->db_frtnp) + { + (*(mp->b_datap->db_frtnp->free_func))(mp->b_datap->db_frtnp->free_arg); + } + else +#endif + if (mp->b_datap->db_base != NULLP) + { +/* ss001.301: additions */ +#ifdef SS_HISTOGRAM_SUPPORT + SFree(strmCfg.datRegion, mp->b_datap->db_base, + (Size)(mp->b_datap->db_lim - mp->b_datap->db_base), + __LINE__, (U8*)__FILE__, ENTNC); +#else + SFree(strmCfg.datRegion, mp->b_datap->db_base, + (Size)(mp->b_datap->db_lim - mp->b_datap->db_base)); +#endif /* SS_HISTOGRAM_SUPPORT */ + } + + + /* if the dblock is in this header, we free this header + * and we're done. if the dblock is in another header, + * we have to free that header too. + */ + + if (mp->b_datap != ((SsDblk *)(mp + sizeof(SsMblk)))) + { + bp = (SsMblk *)(mp->b_datap - sizeof (SsMblk)); +/* ss001.301: additions */ +#ifdef SS_HISTOGRAM_SUPPORT + SFree(strmCfg.mdRegion, (Data *)bp, size, __LINE__, (U8*)__FILE__, ENTNC); +#else + SFree(strmCfg.mdRegion, (Data *)bp, size); +#endif /* SS_HISTOGRAM_SUPPORT */ + } + +/* ss001.301: additions */ +#ifdef SS_HISTOGRAM_SUPPORT + SFree(strmCfg.mdRegion, (Data *)mp, size, __LINE__, (U8*)__FILE__, ENTNC); +#else + SFree(strmCfg.mdRegion, (Data *)mp, size); +#endif /* SS_HISTOGRAM_SUPPORT */ + } + else + { + /* reference count is non-zero; if it is this header's + * dblock, we don't free the header, we just mark the + * dblock pointer empty so we know about it. if it is + * another header's dblock, we can free this header. + */ + + if (mp->b_datap == (SsDblk *)(mp + sizeof(SsMblk))) + { + mp->b_datap = NULLP; + } + else + { +/* ss001.301: additions */ +#ifdef SS_HISTOGRAM_SUPPORT + SFree(strmCfg.mdRegion, (Data *)mp, size, __LINE__, (U8*)__FILE__, ENTNC); +#else + SFree(strmCfg.mdRegion, (Data *)mp, size); +#endif /* SS_HISTOGRAM_SUPPORT */ + } + } + + RETVOID; +} /* ssFreeB */ + + +/* +* +* Fun: ssFreeMsg +* +* Desc: Calls ssFreeB to free all message blocks and their +* corresponding data blocks for the specified +* message. +* +* Ret: Void +* +* Notes: +* +* File: ss_strm.c +* +*/ +#ifdef ANSI +PUBLIC Void ssFreeMsg +( +SsMblk *mp /* message block */ +) +#else +PUBLIC Void ssFreeMsg(mp) +SsMblk *mp; /* message block */ +#endif +{ + SsMblk *bp; /* mblk for iteration */ + + + TRC1(ssFreeMsg); + + + /* free all the message blocks in the message */ + while (mp) + { + bp = mp; + mp = mp->b_cont; + ssFreeB(bp); + } + + RETVOID; +} /* ssFreeMsg */ + + +/* +* +* Fun: ssLinkB +* +* Desc: Puts the second specified message at the tail of +* the first specified message. +* +* Ret: Void +* +* Notes: +* +* File: ss_strm.c +* +*/ +#ifdef ANSI +PUBLIC Void ssLinkB +( +SsMblk *mp, /* first message block */ +SsMblk *bp /* second message block */ +) +#else +PUBLIC Void ssLinkB(mp, bp) +SsMblk *mp; /* first message block */ +SsMblk *bp; /* second message block */ +#endif +{ + TRC1(ssLinkB); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (mp == NULLP || bp == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS345, ERRZERO, "Null pointer"); + RETVOID; + } +#endif + + + /* run down to the end of the message */ + while (mp->b_cont) + { + mp = mp->b_cont; + } + + + /* link in the passed mblock */ + mp->b_cont = bp; + + RETVOID; +} /* ssLinkB */ + + +/* +* +* Fun: ssMsgDSize +* +* Desc: Returns the number of bytes of data in the +* specified message. +* +* Ret: S32 - number of bytes +* +* Notes: +* +* File: ss_strm.c +* +*/ +#ifdef ANSI +PUBLIC S32 ssMsgDSize +( +SsMblk *mp /* message block */ +) +#else +PUBLIC S32 ssMsgDSize(mp) +SsMblk *mp; /* message block */ +#endif +{ + S32 n; /* temporary */ + S32 size; /* size of data */ + + + TRC1(ssMsgDSize); + + + /* for all blocks that are of type data, count the bytes */ + size = 0; + while (mp) + { + if (mp->b_datap->db_type == SS_M_DATA) + { + n = mp->b_wptr - mp->b_rptr; + if (n > 0) + { + size += n; + } + } + + mp = mp->b_cont; + } + + + RETVALUE(size); +} /* ssMsgDSize */ + + +/* +* +* Fun: ssPullupMsg +* +* Desc: Concatenates and aligns the first 'len' bytes +* of the specified message into a single, contiguous +* message block. +* +* Ret: 1 - success +* 0 - failure +* +* Notes: +* +* File: ss_strm.c +* +*/ +#ifdef ANSI +PUBLIC S32 ssPullupMsg +( +SsMblk *mp, /* message block */ +S32 len /* number of bytes to align */ +) +#else +PUBLIC S32 ssPullupMsg(mp, len) +SsMblk *mp; /* message block */ +S32 len; /* number of bytes to align */ +#endif +{ + SsMblk *bp; /* mblk for iteration */ + SsMblk *newbp; /* the new mblk */ + SsMblk *prev; /* mblk of same type */ + U8 *base; /* for swapping data buffers */ + U8 *lim; /* for swapping data buffers */ + U8 *rptr; /* for swapping data buffers */ + U8 *wptr; /* for swapping data buffers */ + /* ss008.301 */ +#ifdef SS_DBLK_FREE_RTN + SsFrtn *frtn; /* for swapping data buffers */ +#endif + S32 mLen; /* number of bytes in all blocks of same type */ + S32 m; /* temporary */ + S32 n; /* temporary */ + U8 type; /* message type */ + + + TRC1(ssPullupMsg); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (mp == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS346, ERRZERO, "Null pointer"); + RETVALUE(0); + } + + if (len < -1) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS347, len, "Invalid length"); + RETVALUE(0); + } +#endif + + + /* count the number of bytes in all blocks of the same type */ + bp = mp; + mLen = 0; + type = bp->b_datap->db_type; + while (bp && bp->b_datap->db_type == type) + { + n = bp->b_wptr - bp->b_rptr; + if (n > 0) + { + mLen += n; + } + + bp = bp->b_cont; + } + + /* if -1 has been passed, we want to pull up all bytes */ + if (len == -1) + { + len = mLen; + } + + if (len == 0) + { + RETVALUE(1); + } + + + /* do we have enough bytes to pull up? */ + if (len < 0 || len > mLen) + { + RETVALUE(0); + } + + + /* allocate a new message of the required size */ + newbp = ssAllocB(len, 0); + if (newbp == NULLP) + { + RETVALUE(0); + } + + newbp->b_datap->db_type = mp->b_datap->db_type; + + + /* now we copy all the data in the blocks of the same type into + * this new message + */ + + prev = NULLP; + bp = mp; + while (bp != NULLP) + { + /* if this buffer is of a different type, we just skip over it */ + if (bp->b_datap->db_type != newbp->b_datap->db_type) + { + prev = bp; + bp = bp->b_cont; + continue; + } + + + /* we have to copy this buffer */ + n = bp->b_wptr - bp->b_rptr; + if (n > 0) + { + n = m = MIN(n, len); + while (m > 0) + { + *newbp->b_wptr++ = *bp->b_rptr++; + m--; + } + + len -= n; + } + + + /* the buffer is copied, now--can we free it? if this the + * first buffer, we don't free it. also, if this buffer has + * something in it, we don't free it. otherwise, we link + * around this buffer, from the previous one to the next, + * and free this buffer. + */ + + if (prev != NULLP && bp->b_rptr == bp->b_wptr) + { + prev->b_cont = bp->b_cont; + bp->b_cont = NULLP; + ssFreeB(bp); + bp = prev->b_cont; + } + else + { + prev = bp; + } + } + + + /* now we have to make the passed mblock point at the new data + * buffer we've just filled. then, we have to free the new + * mblock we created. also, we have to free the data buffer of + * the old mblock, we left it in there. we do this by basically + * swapping the data buffers of the passed mblock and the new + * mblock, and then freeing the new mblock. + */ + + rptr = mp->b_rptr; + wptr = mp->b_wptr; + base = mp->b_datap->db_base; + lim = mp->b_datap->db_lim; +/* ss008.301 */ +#ifdef SS_DBLK_FREE_RTN + frtn = mp->b_datap->db_frtnp; +#endif + + mp->b_rptr = newbp->b_rptr; + mp->b_wptr = newbp->b_wptr; + mp->b_datap->db_base = newbp->b_datap->db_base; + mp->b_datap->db_lim = newbp->b_datap->db_lim; +/* ss008.301 */ +#ifdef SS_DBLK_FREE_RTN + mp->b_datap->db_frtnp = NULLP; +#endif + + newbp->b_rptr = rptr; + newbp->b_wptr = wptr; + newbp->b_datap->db_base = base; + newbp->b_datap->db_lim = lim; +/* ss008.301 */ +#ifdef SS_DBLK_FREE_RTN + newbp->b_datap->db_frtnp = frtn; +#endif + + ssFreeB(newbp); + + + RETVALUE(1); +} /* ssPullupMsg */ + + +/* +* +* Fun: ssRmvB +* +* Desc: Removes the specified message block from the +* specified message and restores the linkage of +* the remaining blocks in the message. +* +* Ret: non-NULL - pointer to the head of the new message +* -1 - specified message block not found in message +* NULL - failure +* +* Notes: The block removed is not freed. +* +* File: ss_strm.c +* +*/ +#ifdef ANSI +PUBLIC SsMblk *ssRmvB +( +SsMblk *mp, /* message */ +SsMblk *bp /* message block */ +) +#else +PUBLIC SsMblk *ssRmvB(mp, bp) +SsMblk *mp; /* message */ +SsMblk *bp; /* message block */ +#endif +{ + SsMblk *rp; /* mblk that will be returned */ + + + TRC1(ssRmvB); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (mp == NULLP || bp == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS348, ERRZERO, "Null pointer"); + RETVALUE(NULLP); + } +#endif + + + /* we will return rp */ + rp = mp; + + + /* if the block to be removed is the first one, its easy */ + if (mp == bp) + { + rp = mp->b_cont; + } + /* otherwise we run through the message, hunting */ + else + { + for (; ;) + { + if (mp == NULLP) + { + RETVALUE((SsMblk *)-1); + } + else if (mp->b_cont == bp) + { + mp->b_cont = bp->b_cont; + break; + } + else + { + mp = mp->b_cont; + } + } + } + + + /* we've removed bp from the message, clear its next pointer */ + bp->b_cont = NULLP; + + + RETVALUE(rp); +} /* ssRmvB */ + + +/* +* +* Fun: ssTestB +* +* Desc: Checks for the availability of a message buffer +* of the specified size without actually retrieving +* the buffer. +* +* Ret: 1 - buffer is available +* 0 - not available +* +* Notes: Is currently a hack that allocates a message and +* frees it. +* +* File: ss_strm.c +* +*/ +#ifdef ANSI +PUBLIC S32 ssTestB +( +S32 size, /* size required */ +U32 pri /* priority of the message buffer */ +) +#else +PUBLIC S32 ssTestB(size, pri) +S32 size; /* size required */ +U32 pri; /* priority of the message buffer */ +#endif +{ + SsMblk *bp; /* mblk for iteration */ + + + TRC1(ssTestB); + + + bp = ssAllocB(size, pri); + if (bp) + { + ssFreeB(bp); + RETVALUE(1); + } + + + RETVALUE(0); +} /* ssTestB */ + + +/* +* +* Fun: ssUnlinkB +* +* Desc: Removes the first message block pointed at +* by the specified message and returns a pointer +* to the head of the resultant message. +* +* Ret: non-NULL - head of the new message +* NULL - failure +* +* Notes: +* +* File: ss_strm.c +* +*/ +#ifdef ANSI +PUBLIC SsMblk *ssUnlinkB +( +SsMblk *mp /* message */ +) +#else +PUBLIC SsMblk *ssUnlinkB(mp) +SsMblk *mp; /* message */ +#endif +{ + SsMblk *bp; /* mblk for iteration */ + + + TRC1(ssUnlinkB); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (mp == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS349, ERRZERO, "Null pointer"); + RETVALUE(NULLP); + } +#endif + + + /* does this need a comment? ;) */ + bp = mp->b_cont; + mp->b_cont = NULLP; + + + RETVALUE(bp); +} /* ssUnlinkB */ + +/********************************************************************** + End of file + **********************************************************************/ diff --git a/src/mt/ss_strm.h b/src/mt/ss_strm.h new file mode 100755 index 000000000..48b69bcf6 --- /dev/null +++ b/src/mt/ss_strm.h @@ -0,0 +1,95 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/********************************************************************20** + + Name: System Services -- STREAMS + + Type: C include file + + Desc: Various macro definitions required for STREAMS. + + File: ss_strm.h + +*********************************************************************21*/ + + +#ifndef __SSSTRMH__ +#define __SSSTRMH__ + +#ifdef __cplusplus +extern "C" { +#endif + + + +/* STREAMS message types */ +#define SS_M_DATA 0 +#define SS_M_PROTO 1 +#define SS_M_BREAK 2 +#define SS_M_CTL 3 +#define SS_M_DELAY 4 +#define SS_M_IOCTL 5 +#define SS_M_PASSFP 6 +#define SS_M_RSE 7 +#define SS_M_SETOPTS 8 +#define SS_M_SIG 9 + + +/* message initialization macro */ +/* ss008.301 */ +#ifdef SS_DBLK_FREE_RTN +#define SS_STRM_INITB(mp, dp, dat, size, frtn) \ + (mp)->b_next = NULLP; \ + (mp)->b_prev = NULLP; \ + (mp)->b_cont = NULLP; \ + (mp)->b_rptr = (dat); \ + (mp)->b_wptr = (dat); \ + (mp)->b_datap = (dp); \ + (dp)->db_frtnp = (frtn); \ + (dp)->db_base = (dat); \ + (dp)->db_lim = (dat) == NULLP ? (dat) : ((dat) + (size)); \ + (dp)->db_ref = 1; \ + (dp)->db_type = SS_M_DATA; \ + (dp)->shared = FALSE; + +#else +#define SS_STRM_INITB(mp, dp, dat, size, frtn) \ + (mp)->b_next = NULLP; \ + (mp)->b_prev = NULLP; \ + (mp)->b_cont = NULLP; \ + (mp)->b_rptr = (dat); \ + (mp)->b_wptr = (dat); \ + (mp)->b_datap = (dp); \ + (dp)->db_base = (dat); \ + (dp)->db_lim = (dat) == NULLP ? (dat) : ((dat) + (size)); \ + (dp)->db_ref = 1; \ + (dp)->db_type = SS_M_DATA; \ + (dp)->shared = FALSE; +#endif /* SS_DBLK_FREE_RTN */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __SSSTRMH__ */ + +/********************************************************************** + End of file + **********************************************************************/ diff --git a/src/mt/ss_strm.x b/src/mt/ss_strm.x new file mode 100755 index 000000000..7f36e1dd3 --- /dev/null +++ b/src/mt/ss_strm.x @@ -0,0 +1,106 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + + +/********************************************************************20** + + Name: System Services -- STREAMS + + Type: C include file + + Desc: Data structure definitions for STREAMS messages. + + File: ss_strm.x + +*********************************************************************21*/ + + +#ifndef __SSSTRMX__ +#define __SSSTRMX__ + +#ifdef __cplusplus +extern "C" { +#endif + + +/* message block is defined in ssi.x */ +typedef struct ssmsgb SsMblk; + + + +/* data block */ +struct ssdatab +{ + U8 db_ref; /* reference count */ + U8 db_type; /* type of data block */ + /* ss006.301 */ + Bool shared; /* is this data block shared ? */ +#ifndef SS_DBUF_REFLOCK_DISABLE + SLockId dBufLock; /* Lock per Dbuf */ +#endif + U8 *db_base; /* base of data buffer */ + U8 *db_lim; /* limit of data buffer */ + /* ss008.301 - deprecating for normal OS, useful for Cavium/RMI OS*/ +#ifdef SS_DBLK_FREE_RTN + struct ssfree_rtn *db_frtnp; /* free routine */ +#endif /* SS_DBLK_FREE_RTN */ +}; + +typedef struct ssdatab SsDblk; + + + +/* to free memory used with esballoc() */ +struct ssfree_rtn +{ + void (*free_func)(char *); /* free function */ + char *free_arg; /* argument to function */ +}; + +typedef struct ssfree_rtn SsFrtn; + + + +/* STREAMS functions prototypes */ +PUBLIC S16 ssStrmCfg ARGS((Region, Region)); +PUBLIC S32 ssAdjMsg ARGS((SsMblk *, S32)); +PUBLIC SsMblk *ssAllocB ARGS((S32, U32)); +PUBLIC SsMblk *ssCopyB ARGS((SsMblk *)); +PUBLIC SsMblk *ssCopyMsg ARGS((SsMblk *)); +PUBLIC SsMblk *ssDupB ARGS((SsMblk *)); +PUBLIC SsMblk *ssDupMsg ARGS((SsMblk *)); +PUBLIC SsMblk *ssESBAlloc ARGS((U8 *, S32, S32, SsFrtn *)); +PUBLIC void ssFreeB ARGS((SsMblk *)); +PUBLIC void ssFreeMsg ARGS((SsMblk *)); +PUBLIC void ssLinkB ARGS((SsMblk *, SsMblk *)); +PUBLIC S32 ssMsgDSize ARGS((SsMblk *)); +PUBLIC S32 ssPullupMsg ARGS((SsMblk *, S32)); +PUBLIC SsMblk *ssRmvB ARGS((SsMblk *, SsMblk *)); +PUBLIC S32 ssTestB ARGS((S32, U32)); +PUBLIC SsMblk *ssUnlinkB ARGS((SsMblk *)); + + +#ifdef __cplusplus +} +#endif + +#endif /* __SSSTRMX__ */ + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/mt/ss_task.c b/src/mt/ss_task.c new file mode 100644 index 000000000..73f9037d8 --- /dev/null +++ b/src/mt/ss_task.c @@ -0,0 +1,4976 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/********************************************************************20** + + Name: System Services -- Task Management + + Type: C source file + + Desc: Source code for System Services functions for task mgmt. + + File: ss_task.c + +*********************************************************************21*/ + + +/* header include files (.h) */ + +#include "envopt.h" /* environment options */ +#include "envdep.h" /* environment dependent */ +#include "envind.h" /* environment independent */ + +#include "gen.h" /* general layer */ +#include "ssi.h" /* system services */ + +#include "ss_err.h" /* errors */ +#include "ss_dep.h" /* implementation-specific */ +#include "ss_queue.h" /* queues */ +#include "ss_task.h" /* tasking */ +#include "ss_msg.h" /* messaging */ +#include "ss_mem.h" /* memory management interface */ +#include "ss_gen.h" /* general */ +#include "cm_mem.h" /* memory management */ +#ifdef SPLIT_RLC_DL_TASK +#include "rgu.h" +#endif +#ifdef SS_FBSED_TSK_REG +#include "cm_task.h" +#endif /* SS_FBSED_TSK_REG */ + +/* header/extern include files (.x) */ + +#include "gen.x" /* general layer */ +#include "ssi.x" /* system services */ + +#include "ss_dep.x" /* implementation-specific */ +#include "ss_queue.x" /* queues */ +#include "ss_task.x" /* tasking */ +#include "ss_timer.x" /* timers */ +#include "ss_strm.x" /* STREAMS */ +#include "ss_msg.x" /* messaging */ +#include "ss_mem.x" /* memory management interface */ +#include "ss_drvr.x" /* driver tasks */ +#ifdef SS_LOCKLESS_MEMORY +#include "cm_llist.x" +#include "cm_hash.x" +#include "cm_mem_wl.x" /* common memory manager */ +#else +#include "cm_mem.x" /* common memory manager */ +#endif /* SS_LOCKLESS_MEMORY */ +#include "ss_gen.x" /* general */ +#include "cm_lib.x" /* general */ + +/* ss001.301: additions */ +#ifdef SS_LOGGER_SUPPORT +/* ss002.301: Fixed warings */ +#ifdef SS_MT +#include +#include +#include +#include +#include +#endif /* SS_MT */ +#ifdef WIN32 +#include +#include "winsock2.h" +#include "ws2tcpip.h" +#endif /* WIN32 */ +#endif /* SS_LOGGER_SUPPORT */ + +/* ss001.301: additions */ +#ifdef SS_WATCHDOG +#include +#ifdef SS_MT +#include +#include +#include +#include +#include +#include +#include +#include +#include +#elif WIN32 +#include "winsock2.h" +#include "ws2tcpip.h" +#endif /* WIN32 */ +#endif /* SS_WATCHDOG */ + +/* ss001.301: additions */ +#ifdef SS_FBSED_TSK_REG +#include "cm_task.x" +#endif /* SS_FBSED_TSK_REG */ +/* ss004.301 : Cavium changes */ +#ifdef SS_SEUM_CAVIUM +/* cvmx includes files */ +#include "cvmx-config.h" +#include "cvmx.h" +#include "cvmx-pow.h" +#include "cvmx-tim.h" +#include "cvmx-fpa.h" +#include "cvmx-helper-fpa.h" +#include "cvmx-malloc.h" +#endif /* SS_SEUM_CAVIUM */ +#ifdef L2_L3_SPLIT +#include "signal.h" +#include "mt_plat_t33.h" +#include "mt_4gmx.x" +EXTERN S32 clusterMode; +#endif + +PUBLIC pthread_t tmpRegTidMap[20]; + +#ifdef TENB_T2K3K_SPECIFIC_CHANGES +EXTERN unsigned int tlPost(void *handle); +#ifdef XEON_SPECIFIC_CHANGES +EXTERN int WLS_WakeUp(void* h); +#endif +#endif + +/* ss029.103: modification: + Old SSI functions are not supported with multiple procIds */ +#ifndef SS_MULTIPLE_PROCS + +/* +* +* Fun: SRegInit +* +* Desc: This function is used to register an initialization function +* for the layer. The system services will invoke the function +* passed to it one time. The initialization function will be +* used by the layer to initilize the layer. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: +* +* File: ss_task.c +* +*/ + +#ifdef ANSI +PUBLIC S16 SRegInit +( +Ent ent, /* entity */ +Inst inst, /* instance */ +PAIFS16 initFnct /* initialization function */ +) +#else +PUBLIC S16 SRegInit(ent, inst, initFnct) +Ent ent; /* entity */ +Inst inst; /* instance */ +PAIFS16 initFnct; /* initialization function */ +#endif +{ + /* ss021.103 - Addition for return value and pointer */ + S16 ret; /* return value */ + SsTTskEntry *tTsk; + + TRC1(SRegInit); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check entity and instance ranges */ + if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS350, ERRZERO, "Invalid entity/instance"); + RETVALUE(RFAILED); + } + + /* check initialization function */ + if (initFnct == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS351, ERRZERO, "Null pointer"); + RETVALUE(RFAILED); + } +#endif + + /* ss021.103 - Modification to store initialization function */ + /* Acquire the counting semaphore for all other system + * tasks (this call is either running in one system task's + * context, or in SInit()'s context). Once we have all of + * them, SPstTsk() cannot run, so we can do things to the + * TAPA task table. + */ + + /* ss025.103 - Addition of lock around counting semaphore */ + /* lock system task table */ + ret = SLock(&osCp.sTskTblLock); + if (ret != ROK) + { + SSLOGERROR(ERRCLS_DEBUG, ESS352, ERRZERO, + "Could not lock system task table"); + RETVALUE(RFAILED); + } + + SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret); + if (ret != ROK) + { + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS353, ERRZERO, + "Could not lock TAPA task table"); +#endif + + RETVALUE(RFAILED); + } + + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check count of tasks */ + if (osCp.numTTsks == SS_MAX_TTSKS) + { + SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem); + SSLOGERROR(ERRCLS_INT_PAR, ESS354, ERRZERO, "Too many tasks"); + + /* ss025.103 - Addition of unlock around counting semephore */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS355, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + + RETVALUE(ROUTRES); + } + + /* check if entity and instance already registered */ + if (osCp.tTskIds[ent][inst] != SS_TSKNC) + { + SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem); + SSLOGERROR(ERRCLS_INT_PAR, ESS356, ERRZERO, + "Entity and instance already registered"); + + /* ss025.103 - Addition of unlock around counting semaphore */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS357, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + + RETVALUE(RFAILED); + } +#endif + + tTsk = &osCp.tTskTbl[osCp.nxtTTskEntry]; + + tTsk->used = TRUE; + tTsk->ent = ent; + tTsk->inst = inst; + tTsk->tskType = (Ttype)NULLD; + tTsk->tskPrior = (Prior)NULLD; + tTsk->initTsk = initFnct; + tTsk->actvTsk = (ActvTsk)NULLP; + tTsk->sTsk = NULLP; + + osCp.tTskIds[ent][inst] = osCp.nxtTTskEntry; + osCp.nxtTTskEntry = tTsk->nxt; + osCp.numTTsks++; + + /* Activate initialization function, if present. Like + * SRegInit(), we use hard-coded parameters. Note: we + * assume that the initialization function is not + * going to call SRegTTsk() or SPstTsk(). If it does, + * this thread will freeze up as we are holding the + * TAPA task table counting semaphore. + */ + /* ss024.103 - Modification for memory calculator tool */ +#ifndef USE_MEMCAL + (Void)(*initFnct)(ent, inst, DFLT_REGION, PWR_UP); +#else + (Void)(*initFnct)(ent, inst, SS_STATIC_REGION, PWR_UP); +#endif /* USE_MEMCAL */ + + /* unlock the table */ + SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem); + + /* ss025.103 - Addition of unlock around counting semaphore */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS358, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + + RETVALUE(ROK); +} /* SRegInit */ + + + +/* +* +* Fun: SRegActvTsk +* +* Desc: This function is used to register an activation function +* for the layer. The system services will invoke the +* function passed to it whenever a task buffer is received. +* The activation function will be used by the layer to receive +* messages from other entities. It allows a priority to be +* associated with the task so that it can be preempted if +* necessary. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: We pass NULLP for the initialization function, because +* it is assumed that whoever is using this call will also +* be calling SRegInit(). +* +* File: ss_task.c +* +*/ +#ifdef ANSI +PUBLIC S16 SRegActvTsk +( +Ent ent, /* entity */ +Inst inst, /* instance */ +Ttype ttype, /* task type */ +Prior prior, /* task priority */ +ActvTsk actvTsk /* activate task function */ +) +#else +PUBLIC S16 SRegActvTsk(ent, inst, ttype, prior, actvTsk) +Ent ent; /* entity */ +Inst inst; /* instance */ +Ttype ttype; /* task type */ +Prior prior; /* task priority */ +ActvTsk actvTsk; /* activate task function */ +#endif +{ + S16 ret; + SSTskId sTskId; + Prior spri; + /* ss021.103 - Addition for pointer */ + SsTTskEntry *tTsk; + + TRC1(SRegActvTsk); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check entity and instance ranges */ + if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS359, ERRZERO, "Invalid entity/instance"); + RETVALUE(RFAILED); + } + + /* check activation function */ + if (actvTsk == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS360, ERRZERO, "Null pointer"); + RETVALUE(RFAILED); + } + + /* check task type */ + if (ttype != TTNORM && ttype != TTPERM) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS361, ERRZERO, "Invalid task type"); + /* ss021.103 - Addition of return fail for invalid task type */ + RETVALUE(RFAILED); + } + + /* check task priority */ + if (prior > PRIOR3) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS362, ERRZERO, "Invalid task priority"); + RETVALUE(RFAILED); + } +#endif + + /* lock system task table */ + ret = SLock(&osCp.sTskTblLock); + if (ret != ROK) + { + SSLOGERROR(ERRCLS_DEBUG, ESS363, ERRZERO, + "Could not lock system task table"); + RETVALUE(RFAILED); + } + + /* lock TAPA task table */ + SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret); + if (ret != ROK) + { + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS364, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + + SSLOGERROR(ERRCLS_DEBUG, ESS365, ERRZERO, + "Could not lock TAPA task table"); + RETVALUE(RFAILED); + } + /* ss021.103 - Modification for SRegInit not called yet */ + /* check if entity and instance already registered */ + if (osCp.tTskIds[ent][inst] == SS_TSKNC) + { + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check count of tasks */ + if (osCp.numTTsks == SS_MAX_TTSKS) + { + SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem); + + /* ss025.103 - Addition of unlock around counting semaphore */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS366, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + SSLOGERROR(ERRCLS_INT_PAR, ESS367, ERRZERO, "Too many tasks"); + RETVALUE(ROUTRES); + } +#endif + + tTsk = &osCp.tTskTbl[osCp.nxtTTskEntry]; + tTsk->used = TRUE; + tTsk->ent = ent; + tTsk->inst = inst; + tTsk->initTsk = (PAIFS16)NULLP; + tTsk->actvTsk = (ActvTsk)NULLP; + tTsk->sTsk = NULLP; + + osCp.tTskIds[ent][inst] = osCp.nxtTTskEntry; + osCp.nxtTTskEntry = tTsk->nxt; + osCp.numTTsks++; + } + + + /* check and bump the priority if it is a permanent task */ + if(ttype == TTPERM) + { + prior = PRIOR3; + } + + /* ss021.103 - Modification to register task information */ + /* We fill up the current available slot with all the + * information we've been given. Update table information, + * and the task is registered. + */ + + tTsk = &osCp.tTskTbl[osCp.tTskIds[ent][inst]]; + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (tTsk->actvTsk != (ActvTsk)NULLP) + { + SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem); + + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS368, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + + SSLOGERROR(ERRCLS_INT_PAR, ESS369, ERRZERO, + "ActvTask already registered"); + RETVALUE(RFAILED); + } +#endif + + tTsk->tskType = ttype; + tTsk->tskPrior = prior; + tTsk->actvTsk = actvTsk; + + /* unlock the table */ + SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem); + + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS370, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + + /* Now we create a system task--one per TAPA task is the + * semantics of SRegActvTsk(). + */ + if (ttype == TTNORM) + spri = SS_NORM_TSK_PRI; + else + spri = SS_PERM_TSK_PRI; + + ret = SCreateSTsk(spri, &sTskId); + if (ret != ROK) + { + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS371, (ErrVal) ret, + "Could not create system task"); +#endif + + SDeregTTsk(ent, inst); + RETVALUE(ret); + } + + + /* Attach the TAPA task we just registered, to the system + * task we just created. + */ + ret = SAttachTTsk(ent, inst, sTskId); + if (ret != ROK) + { + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS372, (ErrVal) ret, + "Could not attach TAPA task to system task"); +#endif + SDestroySTsk(sTskId); + SDeregTTsk(ent, inst); + } + + + RETVALUE(ret); + +} /* SRegActvTsk */ + + +/* +* +* Fun: Deregister Initialize, task buffer and timer +* +* Desc: This function is used to deregister the initialization, +* activation and timer functions for a task. +* +* Ret: ROK - ok +* +* Notes: None. +* +* File: ss_task.c +* +*/ +#ifdef ANSI +PUBLIC S16 SDeregInitTskTmr +( +Ent ent, /* entity */ +Inst inst /* instance */ +) +#else +PUBLIC S16 SDeregInitTskTmr(ent, inst) +Ent ent; /* entity */ +Inst inst; /* instance */ +#endif +{ + SsTTskEntry *tTsk; + SsSTskEntry *sTsk; + S16 ret; + SSTskId sTskId; + SsIdx idx; + Bool destroySTsk; + + + TRC1(SDeregInitTskTmr); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check entity and instance ranges */ + if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS373, ERRZERO, "Invalid entity/instance"); + RETVALUE(RFAILED); + } +#endif + + /* ss025.103 - Addition of lock around counting semaphore */ + /* lock system task table */ + ret = SLock(&osCp.sTskTblLock); + if (ret != ROK) + { + SSLOGERROR(ERRCLS_DEBUG, ESS374, ERRZERO, + "Could not lock system task table"); + RETVALUE(RFAILED); + } + + /* lock the TAPA task table */ + SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret); + if (ret != ROK) + { + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS375, ERRZERO, + "Could not lock TAPA task table"); +#endif + + RETVALUE(RFAILED); + } + + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check whether this entity is registered */ + if (osCp.tTskIds[ent][inst] == SS_TSKNC) + { + SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem); + SSLOGERROR(ERRCLS_INT_PAR, ESS376, ERRZERO, "Unknown task"); + + /* ss025.103 - Addition of unlock around counting semaphore */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS377, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + + RETVALUE(RFAILED); + } +#endif + + + /* get out the TAPA task entry */ + tTsk = &osCp.tTskTbl[osCp.tTskIds[ent][inst]]; + + /* get out the system task that's running this TAPA task */ + sTsk = tTsk->sTsk; + + /* get out the ID of this system task */ + if (sTsk != NULLP) + { + sTskId = sTsk->tskId; + } + else + sTskId = 0; + + /* unlock the TAPA task table */ + SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem); + + /* ss025.103 - Addition of unlock around counting semaphore */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS378, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + + + /* deregister the TAPA task */ + if (SDeregTTsk(ent, inst) != ROK) + { + RETVALUE(RFAILED); + } + + + /* Now, if the TAPA task was attached, and nobody else is using that + * system task, we should destroy it. + */ + if (sTsk != NULLP) + { + destroySTsk = FALSE; + + /* lock the system task table */ + ret = SLock(&osCp.sTskTblLock); + if (ret != ROK) + { + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS379, (ErrVal) ret, + "Could not lock system task table"); +#endif + + RETVALUE(RFAILED); + } + + idx = (SsIdx) sTskId; + sTsk = &osCp.sTskTbl[idx]; + + /* check if the system task is still around */ + if (sTsk->used != TRUE) + { + +/* ss006.13: addition */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS380, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + + RETVALUE(ROK); + } + + /* check if the system task is dying already */ + if (sTsk->termPend) + { + + /* ss006.13: addition */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS381, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + RETVALUE(ROK); + } + + + /* If this system task entry has no more TAPA tasks attached, + * we destroy it, otherwise we do nothing. + */ + if (sTsk->numTTsks == 0) + { + sTsk->termPend = TRUE; + destroySTsk = TRUE; + } + + + /* unlock */ + + /* ss006.13: addition */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS382, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + + /* If we're destroying the system task, ask the implementation + * to do it. + */ + if (destroySTsk) + { + ret = ssdDestroySTsk(sTsk); + if (ret != ROK) + { + /* oops? */ + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS383, (ErrVal) ret, + "Could not destroy system task"); +#endif + + RETVALUE(RFAILED); + } + } + } + + + RETVALUE(ROK); +} /* SDeregInitTskTmr */ + +#endif /* SS_MULTIPLE_PROCS */ + + +/* +* +* Fun: Register a TAPA task +* +* Desc: This function is used to register a TAPA task, +* and its initialization and activation functions. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: +* +* File: ss_task.c +* +*/ +/* ss029.103: modification: procId added */ +#ifndef SS_MULTIPLE_PROCS + +#ifdef ANSI +PUBLIC S16 SRegTTsk +( +Ent ent, /* entity */ +Inst inst, /* instance */ +Ttype type, /* task type */ +Prior prior, /* task priority */ +PAIFS16 initTsk, /* initialization function */ +ActvTsk actvTsk /* activation function */ +) +#else +PUBLIC S16 SRegTTsk(ent, inst, type, prior, initTsk, actvTsk) +Ent ent; /* entity */ +Inst inst; /* instance */ +Ttype type; /* task type */ +Prior prior; /* task priority */ +PAIFS16 initTsk; /* initialization function */ +ActvTsk actvTsk; /* activation function */ +#endif + +#else /* SS_MULTIPLE_PROCS */ + +#ifdef ANSI +PUBLIC S16 SRegTTsk +( +ProcId proc, /* processor */ +Ent ent, /* entity */ +Inst inst, /* instance */ +Ttype type, /* task type */ +Prior prior, /* task priority */ +PAIFS16 initTsk, /* initialization function */ +ActvTsk actvTsk /* activation function */ +) +#else +PUBLIC S16 SRegTTsk(proc, ent, inst, type, prior, initTsk, actvTsk) +ProcId proc; /* processor */ +Ent ent; /* entity */ +Inst inst; /* instance */ +Ttype type; /* task type */ +Prior prior; /* task priority */ +PAIFS16 initTsk; /* initialization function */ +ActvTsk actvTsk; /* activation function */ +#endif + +#endif /* SS_MULTIPLE_PROCS */ + +{ + S16 ret = ROK; + SsTTskEntry *tTsk; +/* ss029.103: addition: multiple procIds related changes */ +#ifdef SS_MULTIPLE_PROCS + U16 procIdIdx; +#endif + + TRC1(SRegTTsk); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + + /* check entity and instance ranges */ +/* ss029.103: addition: multiple procIds related changes */ +#ifdef SS_MULTIPLE_PROCS + if ((proc == SS_INV_PROCID) || (ent >= SS_MAX_ENT) || (inst >= SS_MAX_INST)) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS384, ERRZERO, "Invalid proc/entity/instance"); + RETVALUE(RFAILED); + } +#else /* SS_MULTIPLE_PROCS */ + if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS385, ERRZERO, "Invalid entity/instance"); + RETVALUE(RFAILED); + } +#endif /* SS_MULTIPLE_PROCS */ + + /* check activation function */ + if (actvTsk == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS386, ERRZERO, "Null pointer"); + RETVALUE(RFAILED); + } + + /* check task type */ + if (type != TTNORM && type != TTPERM) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS387, ERRZERO, "Invalid task type"); + /* ss021.103 - Addition of return fail for invalid task type */ + RETVALUE(RFAILED); + } + + /* check task priority */ + if (prior > PRIOR3) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS388, ERRZERO, "Invalid task priority"); + RETVALUE(RFAILED); + } +#endif + +/* ss029.103: addition: multiple procIds related changes */ +#ifdef SS_MULTIPLE_PROCS + /* retrieve proc id index in the proc id table */ + procIdIdx = SGetProcIdIdx(proc); + + /* Check whether the proc id exist in the proc id table */ + if (procIdIdx == SS_INV_PROCID_IDX) + { +#if (ERRCLASS & ERRCLS_INT_PAR) + SSLOGERROR(ERRCLS_INT_PAR, ESS389, ERRZERO, + "Could not find proc table index"); +#endif + + RETVALUE(RFAILED); + } +#endif /* SS_MULTIPLE_PROCS */ + + + + /* Acquire the counting semaphore for all other system + * tasks (this call is either running in one system task's + * context, or in SInit()'s context). Once we have all of + * them, SPstTsk() cannot run, so we can do things to the + * TAPA task table. + */ + + /* ss025.103 - Addition of lock around counting semaphore */ + /* lock system task table */ + ret = SLock(&osCp.sTskTblLock); + if (ret != ROK) + { + SSLOGERROR(ERRCLS_DEBUG, ESS390, ERRZERO, + "Could not lock system task table"); + RETVALUE(RFAILED); + } + + SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret); + if (ret != ROK) + { + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS391, ERRZERO, + "Could not lock TAPA task table"); +#endif + + /* ss025.103 - Addition of unlock around counting semaphore */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS392, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + + RETVALUE(RFAILED); + } + + +#if (ERRCLASS & ERRCLS_DEBUG) + /* check count of tasks */ + if (osCp.numTTsks == SS_MAX_TTSKS) + { + SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem); + SSLOGERROR(ERRCLS_DEBUG, ESS393, ERRZERO, "Too many tasks"); + + /* ss025.103 - Addition of unlock around counting semaphore */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS394, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + + RETVALUE(ROUTRES); + } + + /* check if entity and instance already registered */ +/* ss029.103: addition: multiple procIds related changes */ +#ifdef SS_MULTIPLE_PROCS + if (osCp.tTskIds[procIdIdx][ent][inst] != SS_TSKNC) +#else + if (osCp.tTskIds[ent][inst] != SS_TSKNC) +#endif /* SS_MULTIPLE_PROCS */ + { + SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem); + SSLOGERROR(ERRCLS_DEBUG, ESS395, ERRZERO, + "Entity and instance already registered"); + + /* ss025.103 - Addition of unlock around counting semaphore */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS396, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + + RETVALUE(RFAILED); + } +#endif + + + /* We fill up the current available slot with all the + * information we've been given. Update table information, + * and the task is registered. + */ + tTsk = &osCp.tTskTbl[osCp.nxtTTskEntry]; + tTsk->used = TRUE; +/* ss029.103: addition: procId added */ +#ifdef SS_MULTIPLE_PROCS + tTsk->proc = proc; +#endif /* SS_MULTIPLE_PROCS */ + tTsk->ent = ent; + tTsk->inst = inst; + tTsk->tskType = type; + tTsk->tskPrior = prior; + tTsk->initTsk = initTsk; + tTsk->actvTsk = actvTsk; + tTsk->sTsk = NULLP; + +/* ss001.301: additions */ +#ifdef SS_HISTOGRAM_SUPPORT + tTsk->hstReg = 0; +#endif /* SS_HISTOGRAM_SUPPORT */ + +/* ss029.103: addition: multiple procIds related changes */ +#ifdef SS_MULTIPLE_PROCS + osCp.tTskIds[procIdIdx][ent][inst] = osCp.nxtTTskEntry; +#else + osCp.tTskIds[ent][inst] = osCp.nxtTTskEntry; +#endif /* SS_MULTIPLE_PROCS */ + osCp.nxtTTskEntry = tTsk->nxt; + osCp.numTTsks++; + + + /* Activate initialization function, if present. Like + * SRegInit(), we use hard-coded parameters. Note: we + * assume that the initialization function is not + * going to call SRegTTsk() or SPstTsk(). If it does, + * this thread will freeze up as we are holding the + * TAPA task table counting semaphore. + */ + /* ss024.103 - Modification for memory calculator tool */ + if (initTsk != NULLP) + { +/* ss029.103: addition: multiple procIds related changes */ +#ifdef SS_MULTIPLE_PROCS + SsIdx idx; + Void *xxCb = NULLP; +#endif /* SS_MULTIPLE_PROCS */ + +/* ss029.103: addition: multiple procIds related changes */ +#ifndef SS_MULTIPLE_PROCS + +#ifndef USE_MEMCAL +#ifndef SS_MULTICORE_SUPPORT + (Void)(*initTsk)(ent, inst, DFLT_REGION, PWR_UP); +#endif +#else + (Void)(*initTsk)(ent, inst, SS_STATIC_REGION, PWR_UP); +#endif /* USE_MEMCAL */ + +#else /* SS_MULTIPLE_PROCS */ + +#ifndef USE_MEMCAL +#ifndef SS_MULTICORE_SUPPORT + (Void)(*initTsk)(proc, ent, inst, DFLT_REGION, PWR_UP, &xxCb); +#endif /* SS_MULTICORE_SUPPORT */ +#else + (Void)(*initTsk)(proc, ent, inst, SS_STATIC_REGION, PWR_UP, &xxCb); +#endif /* USE_MEMCAL */ + + /* + * store the control block. The control block may be NULL in some cases + */ + idx = osCp.tTskIds[procIdIdx][ent][inst]; + + osCp.tTskTbl[idx].xxCb = xxCb; + + /* ss032.103 do a debug print if xxCb is NULLP */ + if (xxCb == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ERRZERO, ERRZERO, "Null pointer"); + } +#endif /* SS_MULTIPLE_PROCS */ + } + + /* unlock the table */ + SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem); + + /* ss025.103 - Addition of unlock around counting semaphore */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS397, ERRZERO, + "Could not give the Semaphore"); +#endif + RETVALUE(RFAILED); + } + + RETVALUE(ROK); +} /* SRegTTsk */ + /* ss002.301 Additions */ +/* +* +* Fun: Register a call back function with SSI +* +* Desc: This function is used to register a callback function +* +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: +* +* File: sm_task.c +* +**/ +#ifndef SS_MULTIPLE_PROCS +#ifdef ANSI +PUBLIC S16 SRegCbTsk +( +Ent ent, /* entity */ +Inst inst, /* instance */ +ActvTsk cbTsk /* Callback Function */ +) +#else +PUBLIC S16 SRegCbTsk(ent, inst, cbTsk) +Ent ent; /* entity */ +Inst inst; /* instance */ +ActvTsk cbTsk; +#endif + +#else /* SS_MULTIPLE_PROCS */ + +#ifdef ANSI +PUBLIC S16 SRegCbTsk +( +ProcId proc, /* processor */ +Ent ent, /* entity */ +Inst inst, /* instance */ +ActvTsk cbTsk +) +#else +PUBLIC S16 SRegCbTsk(proc, ent, inst, cbTsk) +ProcId proc; /* processor */ +Ent ent; /* entity */ +Inst inst; /* instance */ +ActvTsk cbTsk; +#endif +#endif /* SS_MULTIPLE_PROCS */ +{ + SsTTskEntry *tTsk; + SsIdx idx; + S16 ret = ROK; +#ifdef SS_MULTIPLE_PROCS + U16 procIdIdx; +#endif /* SS_MULTIPLE_PROCS */ + + TRC1(SRegCbTsk); + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST) + { + SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SRegCbTsk() : Invalid entity/instance"); + RETVALUE(RFAILED); + } + + if (cbTsk == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, " SRegCbTsk() : Null pointer"); + RETVALUE(RFAILED); + } +#endif + +#ifdef SS_MULTIPLE_PROCS + /* retrieve proc id index in the proc id table */ + procIdIdx = SGetProcIdIdx(proc); + + /* Check whether the proc id exist in the proc id table */ + if (procIdIdx == SS_INV_PROCID_IDX) + { +#if (ERRCLASS & ERRCLS_INT_PAR) + SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, + " SRegCbTsk() : Could not find proc table index"); +#endif + + RETVALUE(RFAILED); + } +#endif /* SS_MULTIPLE_PROCS */ + + SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret); + if (ret != ROK) + { + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESSXXX, ERRZERO, + "SRegCbTsk() : Could not lock TAPA task table"); +#endif + RETVALUE(RFAILED); + } + +#ifdef SS_MULTIPLE_PROCS + idx = osCp.tTskIds[procIdIdx][ent][inst]; +#else /* SS_MULTIPLE_PROCS */ + idx = osCp.tTskIds[ent][inst]; +#endif /* SS_MULTIPLE_PROCS */ + +#if (ERRCLASS & ERRCLS_INT_PAR) + if (idx == SS_TSKNC) + { + SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem); + SSLOGERROR(ERRCLS_INT_PAR, ESSXXX, ERRZERO, "SRegCbTsk() : Unknown task"); + RETVALUE(RFAILED); + } +#endif + tTsk = &osCp.tTskTbl[idx]; + tTsk->cbTsk = cbTsk; + + /* unlock the table */ + SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem); + RETVALUE(ROK); +} + + +/* +* +* Fun: Deregister TAPA task +* +* Desc: This function is used to deregister a TAPA task. +* All information about the task is removed from the +* task table. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: +* +* File: ss_task.c +* +*/ +/* ss029.103: addition: procId added */ +#ifndef SS_MULTIPLE_PROCS + +#ifdef ANSI +PUBLIC S16 SDeregTTsk +( +Ent ent, /* entity */ +Inst inst /* instance */ +) +#else +PUBLIC S16 SDeregTTsk(ent, inst) +Ent ent; /* entity */ +Inst inst; /* instance */ +#endif + +#else /* SS_MULTIPLE_PROCS */ + +#ifdef ANSI +PUBLIC S16 SDeregTTsk +( +ProcId proc, /* processor */ +Ent ent, /* entity */ +Inst inst /* instance */ +) +#else +PUBLIC S16 SDeregTTsk(proc, ent, inst) +ProcId proc; /* processor */ +Ent ent; /* entity */ +Inst inst; /* instance */ +#endif +#endif /* SS_MULTIPLE_PROCS */ +{ + S16 ret; + /* ss029.103: modification: The subscript should be consistent type */ + SsIdx idx; + SsTTskEntry *tTsk; + SsTmrEntry *tmr; +/* ss029.103: addition: multiple procIds related changes */ +#ifdef SS_MULTIPLE_PROCS + U16 procIdIdx; +#endif /* SS_MULTIPLE_PROCS */ + /* ss002.301 Additions */ + Buffer *mBuf; + SsMsgInfo *mInfo; + + TRC1(SDeregTTsk); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check entity and instance ranges */ +/* ss029.103: addition: multiple procIds related changes */ +#ifdef SS_MULTIPLE_PROCS + if ((proc == SS_INV_PROCID) || (ent >= SS_MAX_ENT) || (inst >= SS_MAX_INST)) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS398, ERRZERO, "Invalid processor/entity/instance"); + RETVALUE(RFAILED); + } +#else /* SS_MULTIPLE_PROCS */ + if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS399, ERRZERO, "Invalid entity/instance"); + RETVALUE(RFAILED); + } +#endif /* SS_MULTIPLE_PROCS */ + +#endif + +/* ss029.103: addition: multiple procIds related changes */ +#ifdef SS_MULTIPLE_PROCS + /* Find the proc table index */ + procIdIdx = SGetProcIdIdx(proc); + + if (procIdIdx == SS_INV_PROCID) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS400, ERRZERO, + "Could not find proc id index"); +#endif + RETVALUE(RFAILED); + } +#endif /* SS_MULTIPLE_PROCS */ + + /* We deregister all timers for this TAPA task, since it's going + * away now. Lock the timer table and iterate through it, removing + * all timers owned by this task. + */ + if (SLock(&osCp.tmrTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS401, ERRZERO, + "Could not lock timer table"); +#endif + RETVALUE(RFAILED); + } + + for (idx = 0; idx < SS_MAX_TMRS; idx++) + { +/* ss029.103: addition: multiple procIds related changes */ +#ifdef SS_MULTIPLE_PROCS + if ((osCp.tmrTbl[idx].ownerProc == proc) && + (osCp.tmrTbl[idx].ownerEnt == ent) && + (osCp.tmrTbl[idx].ownerInst == inst)) +#else /* SS_MULTIPLE_PROCS */ + if ((osCp.tmrTbl[idx].ownerEnt == ent) && + (osCp.tmrTbl[idx].ownerInst == inst)) +#endif /* SS_MULTIPLE_PROCS */ + { + /* shut down this timer */ + tmr = &osCp.tmrTbl[idx]; + if (ssdDeregTmr(tmr) == ROK) + { + tmr->used = FALSE; + tmr->tmrId = 0; +/* ss029.103: addition: multiple procIds related changes */ +#ifdef SS_MULTIPLE_PROCS + tmr->ownerProc = PROCNC; + /* + * ss015.301 - Modifed in initialization as timer activation + * functions enclosed in a union. Also initialized the mtFlag + * to FALSE + */ +#endif /* SS_MULTIPLE_PROCS */ + tmr->ownerEnt = ENTNC; + tmr->ownerInst = INSTNC; + tmr->interval = 0; + tmr->ssTmrActvFn.actvFnc.tmrActvFn = NULLP; +#ifndef SS_MULTIPLE_PROCS +#ifdef SS_MT_TMR + tmr->ssTmrActvFn.mtFlag = FALSE; + tmr->ssTmrActvFn.actvFnc.tmrActvFnMt = NULLP; +#endif +#endif + tmr->nxt = osCp.nxtTmrEntry; + osCp.nxtTmrEntry = (SsIdx)idx; + osCp.numTmrs--; + } + else + { + + /* ss006.13: addition */ + if ( SUnlock(&osCp.tmrTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS402, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS403, ERRZERO, + "Could not deregister task's timer(s)"); +#endif + RETVALUE(RFAILED); + + } + } + } + + + /* ss006.13: addition */ + if ( SUnlock(&osCp.tmrTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS404, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + /* ss002.301 Additions */ + /* Acquire the counting semaphore for all TAPA tasks. Once + * we have all of them, both SPstTsk() and SRegTTsk() cannot + * run, so we can do things to the TAPA task table. + */ + SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret); + if (ret != ROK) + { + /* ss002.301 Additions */ + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS411, ERRZERO, + "Could not lock TAPA task table"); +#endif + + RETVALUE(RFAILED); + } + + + /* get out the TAPA task entry */ +/* ss029.103: addition: multiple procIds related changes */ +#ifdef SS_MULTIPLE_PROCS + idx = osCp.tTskIds[procIdIdx][ent][inst]; +#else /* SS_MULTIPLE_PROCS */ + idx = osCp.tTskIds[ent][inst]; +#endif /* SS_MULTIPLE_PROCS */ + + + /* make sure this TAPA task exists */ + if (idx == SS_TSKNC) + { + SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem); + + SSLOGERROR(ERRCLS_INT_PAR, ESS412, ERRZERO, "Unknown task"); + /* ss002.301 Additions */ + RETVALUE(RFAILED); + } + + tTsk = &osCp.tTskTbl[idx]; + + /* unlock the TAPA task table */ + SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem); + + /*Check whether the thread calling this funtion is the same as the system task to which the + TAPA task detremined by passed entity and instance is attached*/ + /* 100178 */ + +/*ss014.301 SSI-4GMX specific changes*/ +#ifndef SS_4GMX_LCORE + if((tTsk->sTsk == NULLP) || (SS_CHECK_CUR_STSK(tTsk->sTsk))) + { +#ifdef SS_MULTIPLE_PROCS + ssdProcTTskTerm(procIdIdx, tTsk, idx); +#else + ssdProcTTskTerm(tTsk, idx); +#endif + + } + else + { + /*Allocate memory*/ + if (SGetMsg(SS_DFLT_REGION, SS_DFLT_POOL, &mBuf) != ROK) + { + +#if (ERRCLASS & ERRCLASS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS415, ERRZERO, "Could not get a message"); +#endif + + RETVALUE(RFAILED); + } + + /* Update message*/ + mInfo = (SsMsgInfo *)mBuf->b_rptr; + mInfo->eventInfo.event = SS_EVNT_TTSK_TERM; + + mInfo->pst.dstEnt = ent; + mInfo->pst.dstInst = inst; + + /* we dont care who is calling SDeregTTsk() + so we dont fill srcEnt and dstInst in mInfo->pst */ + + /* mt028.201: modification: multiple procs support related changes */ + /* source proc id is not needed so we dont fill it */ +#ifndef SS_MULTIPLE_PROCS + mInfo->pst.dstProcId = SFndProcId(); +#else /* SS_MULTIPLE_PROCS */ + mInfo->pst.dstProcId = proc; +#endif /* SS_MULTIPLE_PROCS */ + /* ss002.301 Additions */ + mInfo->pst.selector = SEL_LC_NEW; + mInfo->pst.region = DFLT_REGION; + mInfo->pst.pool = DFLT_POOL; + mInfo->pst.prior = PRIOR0; + mInfo->pst.route = RTESPEC; + mInfo->pst.event = 0; + /* write the timer message to the queue of the destination task */ + if (ssDmndQPutLast(&tTsk->sTsk->dQ, mBuf, + (tTsk->tskPrior * SS_MAX_MSG_PRI) + PRIOR0) != ROK) + { + SS_RELEASE_SEMA(&osCp.tTskTblSem); + SPutMsg(mBuf); +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_INT_PAR, ESS416, ERRZERO, "Could not write to demand queue"); +#endif + RETVALUE(RFAILED); + } + } +#endif + + RETVALUE(ROK); +} /* SDeregTTsk */ + + +/* +* +* Fun: Create system task +* +* Desc: This function is used to create a system task. An +* entry is located in the system task table and the +* implementation-specific function is called. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: +* +* File: ss_task.c +* +*/ +#ifdef ANSI +PUBLIC S16 SCreateSTsk +( +SSTskPrior tskPrior, /* task priority */ +SSTskId *tskId /* filled in with system task ID */ +) +#else +PUBLIC S16 SCreateSTsk(tskPrior, tskId) +SSTskPrior tskPrior; /* task priority */ +SSTskId *tskId; /* filled in with system task ID */ +#endif +{ + S16 ret; + SsSTskEntry *sTsk; + + + TRC1(SCreateSTsk); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check task ID pointer */ + if (tskId == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS417, ERRZERO, "Null pointer"); + RETVALUE(RFAILED); + } + + /* check system task priority */ + if (tskPrior > SS_LOWEST_STSK_PRIOR) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS418, ERRZERO, + "Invalid system task priority"); + RETVALUE(RFAILED); + } +#endif + + + /* lock the system task table */ + ret = SLock(&osCp.sTskTblLock); + if (ret != ROK) + { + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS419, (ErrVal) ret, + "Could not lock system task table"); +#endif + + RETVALUE(RFAILED); + } + + +#ifdef SS_SINGLE_THREADED + /* When singlethreaded, we only need to create one... */ +/* ss001.301: additions */ +#ifndef SS_WATCHDOG +#ifndef SS_MULTICORE_SUPPORT + if (osCp.numSTsks == 1) +#else + if (osCp.numSTsks == 2) +#endif /* SS_MULTICORE_SUPPORT */ +#else +#ifndef SS_MULTICORE_SUPPORT + if (osCp.numSTsks == 3) +#else + if (osCp.numSTsks == 4) +#endif /* SS_MULTICORE_SUPPORT */ +#endif /* SS_WATCHDOG */ + { +/* ss001.301: additions */ +#ifndef SS_WATCHDOG +#ifndef SS_MULTICORE_SUPPORT + *tskId = 0; + osCp.sTskTbl[0].termPend = FALSE; +#else + *tskId = 1; + osCp.sTskTbl[1].termPend = FALSE; +#endif /* SS_MULTICORE_SUPPORT */ +#else +#ifndef SS_MULTICORE_SUPPORT + *tskId = 2; + osCp.sTskTbl[2].termPend = FALSE; +#else + *tskId = 3; + osCp.sTskTbl[3].termPend = FALSE; +#endif /* SS_MULTICORE_SUPPORT */ +#endif /* SS_WATCHDOG */ + + /* ss006.13: addition */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS420, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + RETVALUE(ROK); + } +#endif /* SS_SINGLE_THREADED */ + + + /* check count of system tasks */ + if (osCp.numSTsks == SS_MAX_STSKS) + { + + /* ss006.13: addition */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS421, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + +#if (ERRCLASS & ERRCLS_ADD_RES) + SSLOGERROR(ERRCLS_ADD_RES, ESS422, ERRZERO, "Too many system tasks"); +#endif + + RETVALUE(ROUTRES); + } + + + /* initialize the system task entry with the information we have */ + sTsk = &osCp.sTskTbl[osCp.nxtSTskEntry]; + + /* store the system task priority */ + sTsk->tskPrior = tskPrior; + +/*ss014.301 SSI-4GMX specific changes*/ +#ifndef SS_4GMX_LCORE + /* initialize the demand queue */ + if (ssInitDmndQ(&sTsk->dQ) != ROK) + { + + /* ss006.13: addition */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS423, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS424, (ErrVal) ret, + "Could not initialize demand queue"); +#endif + + RETVALUE(RFAILED); + } + + /* initialize the system task entry lock */ + if (SInitLock(&sTsk->lock, SS_STSKENTRY_LOCK) != ROK) + { + ssDestroyDmndQ(&sTsk->dQ); + + /* ss006.13: addition */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS425, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS426, (ErrVal) ret, + "Could not initialize system task entry lock"); +#endif + + RETVALUE(RFAILED); + } +#endif + + /* we ask the implementation to start this system task */ + ret = ssdCreateSTsk(sTsk); + if (ret != ROK) + { + /* failed, clean up */ + SDestroyLock(&sTsk->lock); +/*ss014.301 SSI-4GMX specific changes*/ +#ifndef SS_4GMX_LCORE + ssDestroyDmndQ(&sTsk->dQ); +#endif + sTsk->tskPrior = 0; + + + /* ss006.13: addition */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS427, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS428, (ErrVal) ret, + "Could not create system task"); +#endif + + RETVALUE(RFAILED); + } + + /* success, update the table */ + *tskId = osCp.nxtSTskEntry; + sTsk->tskId = osCp.nxtSTskEntry; + sTsk->used = TRUE; + sTsk->termPend = FALSE; + osCp.nxtSTskEntry = sTsk->nxt; + osCp.numSTsks++; + +#ifdef SS_LOCKLESS_MEMORY + tmpRegTidMap[sTsk->region] = sTsk->dep.tId; +#endif /* SS_LOCKLESS_MEMORY */ + /* unlock the system task table */ + + /* ss006.13: addition */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS429, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + + RETVALUE(ROK); + +} /* SCreateSTsk */ + +/* ss001.301: additions */ +#ifdef SS_LOGGER_SUPPORT +/* +* +* Fun: Register logger configuration +* +* Desc: This function is used to configure the config information +* of the logger.The log file name, path and the size limits +* of the log file are updated in the SSI control block. +* +* +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: +* +* File: ss_task.c +* +*/ +#ifdef ANSI +PUBLIC S16 SRegLogCfg +( +U8 mode, +S8 *path, +U32 size, +S8 *IPA, +U16 port +) +#else +PUBLIC S16 SRegLogCfg(mode, path, size, IPA, port) +U8 mode; +S8 *path; +U32 size; +S8 *IPA; +U16 port +#endif +{ + +#ifdef WIN32 + WSADATA wsaData; + U32 iRes; +#endif + + /*ss013.301: Fixed Warnings for 32/64 bit compilation*/ + struct sockaddr_in localAddr={0}; + struct sockaddr_in remoteAddr ={0}; + + TRC1(SRegLogCfg); + +#if (ERRCLASS & ERRCLS_INT_PAR) +#endif + + /* Initialize the lock, return on failure */ + if( SInitLock(&(osCp.logger.bufLock),SS_LOCK_MUTEX) != ROK) + { + RETVALUE(RFAILED); + } /* if */ + + SLock(&osCp.logger.bufLock); + + /* Initialize the logger configuration flag */ + osCp.logger.configured = FALSE; + + if( osCp.logger.started == TRUE) + { + (Void)SUnlock(&(osCp.logger.bufLock)); + RETVALUE(RFAILED); + } + + /* set the mode of the logging */ + switch (mode) + { + case SS_LOG_TO_FILE: + osCp.logger.opt |= 0x01; + break; + case SS_LOG_TO_SOCKET: + osCp.logger.opt |= 0x02; + break; + case SS_LOG_ALL: + default: + osCp.logger.opt |= 0x03; break; + } + + /*Open log file*/ + if (osCp.logger.opt & 0x01) + { + osCp.logger.filep = fopen(path, "wb"); + if(osCp.logger.filep == NULLP) + { + SDisplay(0,"Error Opening Log File \n"); + (Void)SUnlock(&(osCp.logger.bufLock)); + RETVALUE(RFAILED); + } + strcpy(osCp.logger.filePath,path); + } + + /*Open socket */ + if (osCp.logger.opt & 0x02) + { +#ifdef WIN32 + if ((iRes = WSAStartup(MAKEWORD(2,2), &wsaData)) != NO_ERROR) + { + SDisplay(0, "Error at WSAStartup!\n"); + (Void)SUnlock(&(osCp.logger.bufLock)); + RETVALUE(RFAILED); + } +#endif + osCp.logger.socketdes = socket(AF_INET, SOCK_DGRAM, 0); + if(osCp.logger.socketdes == -1) + { + SDisplay(0,"Error Opening Log Socket \n"); +#ifdef WIN32 + WSACleanup(); +#endif + (Void)SUnlock(&(osCp.logger.bufLock)); + RETVALUE(RFAILED); + } + /* bind to local address */ + localAddr.sin_family = AF_INET; + localAddr.sin_port = port; + localAddr.sin_addr.s_addr = INADDR_ANY; + if (bind(osCp.logger.socketdes, (struct sockaddr*)&localAddr, sizeof(struct sockaddr)) < 0) + { + SDisplay(0,"Error binding to local port \n"); +#ifdef WIN32 + closesocket(osCp.logger.socketdes); + WSACleanup(); +#else + close(osCp.logger.socketdes); +#endif + (Void)SUnlock(&(osCp.logger.bufLock)); + RETVALUE(RFAILED); + } + /* remote address */ + remoteAddr.sin_family = AF_INET; + remoteAddr.sin_port = htons(port); + if (!IPA) + { + SDisplay(0,"Invalid remote IP Address \n"); +#ifdef WIN32 + closesocket(osCp.logger.socketdes); + WSACleanup(); +#else + close(osCp.logger.socketdes); +#endif + (Void)SUnlock(&(osCp.logger.bufLock)); + RETVALUE(RFAILED); + } + remoteAddr.sin_addr.s_addr = inet_addr(IPA); + osCp.logger.remoteAddr = remoteAddr; + + } + + cmMemset((U8*)osCp.logger.buffer, '\0', sizeof(osCp.logger.buffer)); + + osCp.logger.maxBufSiz = SS_MAX_LOGBUF_SIZE; + osCp.logger.curBufSiz = 0; + + osCp.logger.maxNumFlush = size/osCp.logger.maxBufSiz; + osCp.logger.curNumFlush = 0; + + + osCp.logger.started = FALSE; + osCp.logger.configured = TRUE; + + (Void)SUnlock(&(osCp.logger.bufLock)); + + RETVALUE(ROK); +} /* SRegLogCfg */ + +/* +* +* Fun: SFlushBufToLog +* +* Desc: This function is used flush the buffer to file/socket. +* +* Ret: ROK +* +* Notes: +* +* File: ss_task.c +* +--*/ +#ifdef ANSI +PUBLIC S16 SFlushBufToLog +( +S8 *logBuf +) +#else +PUBLIC S16 SFlushBufToLog(logBuf) +S8 *logBuf +#endif +{ + S8 *buffer; + PRIVATE U16 logFileCnt = 0; + S8 newFileName[SS_MAX_PATH]; +#ifdef WIN32 + size_t writeNum; +#else + ssize_t writeNum; +#endif + FILE* oldFileP; + /*ss013.301 :Fix for TRACE5 feature crash due to missing TRC MACRO*/ + TRC1(SFlushBufToLog) + + buffer = logBuf; + + if (osCp.logger.opt & 0x01) + { + writeNum = fwrite(buffer, sizeof(U8), cmStrlen((U8 *)buffer), + osCp.logger.filep); + } + if (osCp.logger.opt & 0x02) + { + writeNum = sendto(osCp.logger.socketdes, buffer, cmStrlen((U8 *)buffer), 0, (struct sockaddr*)&osCp.logger.remoteAddr, sizeof(osCp.logger.remoteAddr)); + /*ss013.301 : Returned after sending to socket*/ + RETVALUE(ROK); + } + osCp.logger.curNumFlush++; + if(osCp.logger.curNumFlush == osCp.logger.maxNumFlush) + { + cmMemset((U8 *)newFileName,'\0',sizeof(newFileName)); + /*Store the current File*/ + oldFileP = osCp.logger.filep; + /*Open a new file and use it as a new log file*/ + osCp.logger.curNumFlush = 0; + logFileCnt++; + sprintf(newFileName, "%s%d", osCp.logger.filePath, logFileCnt); + osCp.logger.filep = fopen(newFileName, "wb"); + if(osCp.logger.filep == NULLP) + { + /*MTLOGERROR(ERRCLS_DEBUG, EMTXXX, ERRZERO, "Error Opening Log File. \n");*/ + } + + fclose(oldFileP); + } + /*SPutSBuf(DFLT_REGION,DFLT_POOL, + (Data *)buffer, (Size)(osCp.logger.maxBufSiz * sizeof(S8)));*/ + + RETVALUE(ROK); +} /* SFlushBufToLog */ + +/* +* +* Fun: SCleanUp +* +* Desc: This function is used to clean up the logger info. +* +* Ret: task id +* +* Notes: +* +* File: ss_task.c +* +--*/ +#ifdef ANSI +PUBLIC S16 SCleanUp +( +Void +) +#else +PUBLIC S16 SCleanUp() +#endif +{ + + TRC1(SCleanUp); + /*Flush the remaining data in the log file*/ + SLock(&osCp.logger.bufLock); + if(osCp.logger.started == FALSE) + { + (Void)SUnlock(&(osCp.logger.bufLock)); + RETVALUE(ROK); + } + if(osCp.logger.curBufSiz) + { + SFlushBufToLog(osCp.logger.buffer); + osCp.logger.curBufSiz = 0; + + } + if (osCp.logger.opt & 0x01) + { + fclose(osCp.logger.filep); + } + if (osCp.logger.opt & 0x02) + { +#ifdef WIN32 + closesocket(osCp.logger.socketdes); +#else + close(osCp.logger.socketdes); +#endif + } + osCp.logger.started = FALSE; + + (Void)SUnlock(&(osCp.logger.bufLock)); +#ifdef L2_L3_SPLIT + signal(SIGINT, App_SigExitCallBack); +#endif + + RETVALUE(ROK); + +} /* end of SCleanUp */ + +/* +* +* Fun: Unregister the logger. +* +* Desc: This function is used to deregister a logger task. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: +* +* File: ss_task.c +* +*/ +#ifdef ANSI +PUBLIC S16 SDeregLogCfg +( +) +#else +PUBLIC S16 SDeregLogCfg() +#endif +{ + + + TRC1(SDeregLogCfg); + + SCleanUp(); + + RETVALUE(ROK); + +} /* SDeregLogCfg */ + +/* +* +* Fun: SStartLogger +* +* Desc: To start logger. +* +* Ret: Void +* +* Notes: +* +* File: ss_task.c +* +*/ +#ifdef ANSI +PUBLIC Void SStartLogger +( +void +) +#else +PUBLIC Void SStartLogger() +#endif +{ + if (osCp.logger.configured == TRUE) + { + osCp.logger.started = TRUE; + } +} + + +/* +* +* Fun: SStopLogger +* +* Desc: To stop logging to file/socket. +* +* Ret: Void +* +* Notes: +* +* File: ss_task.c +* +*/ +#ifdef ANSI +PUBLIC Void SStopLogger +( +void +) +#else +PUBLIC Void SStopLogger() +#endif +{ + osCp.logger.started = FALSE; +} +#endif /* SS_LOGGER_SUPPORT */ + +/** for multi-core support **/ +/*ss013.301 : changes related to SS_AFFINITY_SUPPORT*/ +#if defined(SS_MULTICORE_SUPPORT) || defined(SS_AFFINITY_SUPPORT) + +/* +* +* Fun: Register the CPU information +* +* Desc: This function is used to register the number of cores +* present and the number of threads which can be run on +* each core. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: +* +* File: ss_task.c +* +*/ +#ifdef ANSI +PUBLIC S16 SRegCpuInfo +( +SCpuInfo *cpuInfo /* Information about the cores/threads per core */ +) +#else +PUBLIC S16 SRegCpuInfo (cpuInfo) +SCpuInfo *cpuInfo; /* Information about the cores/threads per core */ +#endif +{ + U32 coreCount = 0; + + /*ss013.301 :Fix for TRACE5 feature crash due to missing TRC MACRO*/ + TRC1(SRegCpuInfo) + /* check the number of cores */ + if ( cpuInfo->numCores > SS_MAX_CORES || + cpuInfo->threadsPerCore > SS_MAX_THREADS_PER_CORE || + cpuInfo->numCores < 1 || cpuInfo->threadsPerCore < 1 ) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS430, ERRZERO, "Invalid number of cores\n"); + RETVALUE(RFAILED); + } + + /* lock mCInfo */ + SLock(&osCp.mCILock); + osCp.mCInfo.cpuInfo.numCores = cpuInfo->numCores; + osCp.mCInfo.cpuInfo.threadsPerCore = cpuInfo->threadsPerCore; + /* if the cpu register is supplied then use it */ + for (; coreCount < cpuInfo->numCores; coreCount++) + { + U32 thrCnt = 0; + for (;thrCnt < SS_MAX_THREADS_PER_CORE;thrCnt++) + { + osCp.mCInfo.coreInfo[coreCount].tskPerCoreLst[thrCnt] = -1; + } /* for */ + osCp.mCInfo.coreInfo[coreCount].exclusive = FALSE; + osCp.mCInfo.coreInfo[coreCount].thrs = osCp.mCInfo.cpuInfo.threadRegister[coreCount] + = cpuInfo->threadRegister[coreCount]; + } + /* unlock mCInfo */ + SUnlock(&osCp.mCILock); + + RETVALUE(ROK); + +} /* SRegCpuInfo */ + + + +/* +* +* Fun: Get the current core/cpu affinity for a thread/lwp +* +* Desc: This function is used to get the current processor/core +* affinity for a a system task (thread/lwp). It sets the +* affinity based on the mode supplied by the caller. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: +* +* File: ss_task.c +* +*/ +#ifdef ANSI +PUBLIC S16 SGetAffinity +( +SSTskId *tskId, /* filled in with system task ID */ +U32 *coreId /* the core/processor id to which the affinity is set */ +) +#else +PUBLIC S16 SGetAffinity(tskId, coreId) +SSTskId *tskId; /* filled in with system task ID */ +U32 *coreId; /* the core/processor id to which the affinity is set */ +#endif +{ + S16 ret; + + /*ss013.301 :Fix for TRACE5 feature crash due to missing TRC MACRO*/ + TRC1(SGetAffinity) + /* implementation specific */ + ret = ssdGetAffinity(tskId, coreId); + + if (ret != ROK) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS431, ERRZERO, "Failed to get affinity\n"); + RETVALUE(RFAILED); + } /* end if */ + + RETVALUE(ROK); +} /* SGetAffinity */ + + +/* +* +* Fun: Set the core/cpu affinity for a thread/lwp +* +* Desc: This function is used to set processor/core affinity for a +* a system task (thread/lwp). It sets the affinity based on the +* mode supplied by the caller. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: +* +* File: ss_task.c +* +*/ +#ifdef ANSI +PUBLIC S16 SSetAffinity +( +SSTskId *tskId, /* filled in with system task ID */ +SsAffinityMode mode, /* the mode according to which the affinty is set */ +U32 coreId, /* the core/processor id to which the affinity has to be set */ +SSTskId *tskAssociatedTskId /* filled in with system task ID of the associated layer */ +) +#else +PUBLIC S16 SSetAffinity(tskId, mode, coreId, tskAssociatedTskId) +SSTskId *tskId; /* filled in with system task ID */ +SsAffinityMode mode; /* the mode according to which the affinty is set */ +U32 coreId; /* the core/processor id to which the affinity has to be set */ +SSTskId *tskAssociatedTskId; /* filled in with system task ID of the associated layer */ +#endif +{ + S16 ret; + + /*ss013.301 :Fix for TRACE5 feature crash due to missing TRC MACRO*/ + TRC1(SSetAffinity) + /* validate the mode */ + if (mode < SS_AFFINITY_MODE_DEFAULT || + mode > SS_AFFINITY_MODE_EXCL) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS432, ERRZERO, "Invalid mode for setting core affinity\n"); + RETVALUE(RFAILED); + } /* end if */ + + /* check the value of core id */ + if (SS_AFFINITY_MODE_SPECIFIC == mode && + (coreId > osCp.mCInfo.cpuInfo.numCores || coreId < 0)) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS433, ERRZERO, "Invalid core id\n"); + RETVALUE(RFAILED); + } /* end if */ + + /* set affinity according to the mode supplied */ + switch (mode) + { + case SS_AFFINITY_MODE_DEFAULT: + { + U32 coreCounter = 0, coreIndex = 0; + S8 repeatFlag = 1; + SEARCH_FOR_CORE: + /*ss013.301: Fixed Warnings for 32/64 bit compilation*/ + for (coreIndex = osCp.mCInfo.currentCore; + coreCounter < osCp.mCInfo.cpuInfo.numCores; + coreCounter++ ) + { + /* again start from core 0 */ + ++coreIndex; + coreIndex = (coreIndex)%osCp.mCInfo.cpuInfo.numCores; + if (!osCp.mCInfo.coreInfo[coreIndex].exclusive + && osCp.mCInfo.cpuInfo.threadRegister[coreIndex]) + { + if (osCp.mCInfo.coreInfo[coreIndex].thrs || !repeatFlag) + { + /* call the implementation specific affinity function */ + ret = ssdSetAffinity(tskId, coreIndex); + + if (ret != ROK) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS434, ERRZERO, \ + "Failed to set core affinity\n"); + RETVALUE(RFAILED); + } /* end if */ + + /* lock mCInfo */ + SLock(&osCp.mCILock); + + /* move the current core index */ + osCp.mCInfo.currentCore = (coreIndex+1)%osCp.mCInfo.cpuInfo.numCores; + + /* save the tskId in tskList */ + osCp.mCInfo.coreInfo[coreIndex].tskPerCoreLst[ + osCp.mCInfo.cpuInfo.threadRegister[coreIndex] - + osCp.mCInfo.coreInfo[coreIndex].thrs] = *tskId; + + /* decrement the available thread count in the thread register */ + osCp.mCInfo.coreInfo[coreIndex].thrs--; + + /* unlock mCInfo */ + SUnlock(&osCp.mCILock); + + break; + } /* end if there are threads available in the core */ + } /* end if the core is not exclusive flagged and + the core has threads for SSI use */ + } /* end for */ + if (coreCounter == osCp.mCInfo.cpuInfo.numCores && repeatFlag) + { + repeatFlag = 0; + SSLOGERROR(ERRCLS_INT_PAR, ESS435, ERRZERO, "Overloading of threads per core!!\n"); + goto SEARCH_FOR_CORE; + } /* end if no thrs on cores available and overallocation is needed */ + break; + } /* end case SS_AFFINITY_MODE_DEFAULT */ + case SS_AFFINITY_MODE_SPECIFIC: + { + /* check if the core is used exclusively for any task */ + if (osCp.mCInfo.coreInfo[coreId].exclusive) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS436, ERRZERO,\ + "Can not set core affinity, core is exclusively used for other task\n"); + RETVALUE(RFAILED); + } /* end if */ + /* call the implementation specific affinity function with the core id supplied by caller */ + ret = ssdSetAffinity(tskId, coreId); + + if (ret != ROK) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS437, ERRZERO, "Failed to set core affinity\n"); + RETVALUE(RFAILED); + } /* end if */ + + /* lock mCInfo */ + SLock(&osCp.mCILock); + + /* move the current core index */ + osCp.mCInfo.currentCore = (coreId+1)%osCp.mCInfo.cpuInfo.numCores; + + /* save the tskId in tskList */ + osCp.mCInfo.coreInfo[coreId].tskPerCoreLst[ + osCp.mCInfo.cpuInfo.threadRegister[coreId] - + osCp.mCInfo.coreInfo[coreId].thrs] = *tskId; + + /* decrement the available thread count in the thread register */ + osCp.mCInfo.coreInfo[coreId].thrs--; + + /* unlock mCInfo */ + SUnlock(&osCp.mCILock); + + if (osCp.mCInfo.coreInfo[coreId].thrs < 0) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS438, ERRZERO, "Overloading of threads per core!!\n"); + } /* end else */ + + break; + } /* end case SS_AFFINITY_MODE_SPECIFIC */ + case SS_AFFINITY_MODE_ASSOC: + { + /* search for the associated tsk id in osCp */ + U32 coreIndex = 0, threadIndex = 0; + Bool tskNotFound = TRUE; + for (;tskNotFound && coreIndex < SS_MAX_CORES; coreIndex++) + { + for (threadIndex = 0; threadIndex < SS_MAX_THREADS_PER_CORE; threadIndex++) + { + if (osCp.mCInfo.coreInfo[coreIndex].tskPerCoreLst[threadIndex] == *tskAssociatedTskId) + { + if (!osCp.mCInfo.coreInfo[coreIndex].exclusive) + { + /* set the affinity for the given task on to the core coreIndex */ + ret = ssdSetAffinity(tskId, coreIndex); + if (ret != ROK) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS439, ERRZERO, "Failed to set core affinity\n"); + RETVALUE(RFAILED); + } /* end if */ + + /* lock mCInfo */ + SLock(&osCp.mCILock); + + /* move the current core index */ + osCp.mCInfo.currentCore = (coreIndex+1)%osCp.mCInfo.cpuInfo.numCores; + + /* save the tskId in tskList */ + osCp.mCInfo.coreInfo[coreIndex].tskPerCoreLst[ + osCp.mCInfo.cpuInfo.threadRegister[coreIndex] - + osCp.mCInfo.coreInfo[coreIndex].thrs] = *tskId; + + /* decrement the available thread count in the thread register */ + osCp.mCInfo.coreInfo[coreIndex].thrs--; + + /* unlock mCInfo */ + SUnlock(&osCp.mCILock); + + if (osCp.mCInfo.coreInfo[coreIndex].thrs < 0) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS440, ERRZERO, + "Overloading of threads per core!!\n"); + } /* end if */ + + } /* end if */ + else + { + SSLOGERROR(ERRCLS_INT_PAR, ESS441, ERRZERO, + "Can not set core affinity, core is exclusively used for other task\n"); + RETVALUE(RFAILED); + } /* end else */ + tskNotFound = FALSE; + break; + } /* end if */ + } /* end inner for */ + } /* end for */ + + /* check if tskAssociatedTskId is valid or not */ + if (coreIndex == SS_MAX_CORES) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS442, ERRZERO, "Invalid core id\n"); + RETVALUE(RFAILED); + } /* if */ + break; + } /* end case SS_AFFINITY_MODE_ASSOC */ + case SS_AFFINITY_MODE_EXCL: + { + /* check if any thread is already running on the core */ + if (coreId != SS_DEFAULT_CORE && + osCp.mCInfo.coreInfo[coreId].thrs == osCp.mCInfo.cpuInfo.threadRegister[coreId] && + !osCp.mCInfo.coreInfo[coreId].exclusive) + { + /* call the implementation specific affinity function */ + ret = ssdSetAffinity(tskId, coreId); + + if (ret != ROK) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS443, ERRZERO, "Failed to set core affinity\n"); + RETVALUE(RFAILED); + } /* end if */ + + /* lock mCInfo */ + SLock(&osCp.mCILock); + + /* set the exclusive flag so that the core will not be used for other system tasks */ + osCp.mCInfo.coreInfo[coreId].exclusive = TRUE; + + /* save the tskId in tskList */ + osCp.mCInfo.coreInfo[coreId].tskPerCoreLst[osCp.mCInfo.cpuInfo.threadRegister[coreId] - + osCp.mCInfo.coreInfo[coreId].thrs] = *tskId; + + /* decrement the available thread count in the thread register */ + osCp.mCInfo.coreInfo[coreId].thrs--; + + /* unlock mCInfo */ + SUnlock(&osCp.mCILock); + + } /* end if */ + else if (coreId == SS_DEFAULT_CORE) + { + U32 coreCounter = 0; + U32 coreIndex = 0; + /*ss013.301: Fixed Warnings for 32/64 bit compilation*/ + for (coreIndex = osCp.mCInfo.currentCore; + coreCounter < osCp.mCInfo.cpuInfo.numCores; + coreCounter++) + { + ++coreIndex; + coreIndex = (coreIndex)%osCp.mCInfo.cpuInfo.numCores; + if (!osCp.mCInfo.coreInfo[coreIndex].exclusive + && osCp.mCInfo.cpuInfo.threadRegister[coreIndex]) + { + if ( osCp.mCInfo.coreInfo[coreIndex].thrs == + osCp.mCInfo.cpuInfo.threadRegister[coreIndex] && + osCp.mCInfo.coreInfo[coreIndex].thrs) + { + /* call the implementation specific affinity function */ + ret = ssdSetAffinity(tskId, coreIndex); + + if (ret != ROK) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS444, ERRZERO, "Failed to set core affinity\n"); + RETVALUE(RFAILED); + } /* end if */ + + /* lock mCInfo */ + SLock(&osCp.mCILock); + + /* move the current core index */ + osCp.mCInfo.currentCore = (coreIndex+1)%osCp.mCInfo.cpuInfo.numCores; + + /* save the tskId in tskList */ + osCp.mCInfo.coreInfo[coreIndex].tskPerCoreLst[ + osCp.mCInfo.cpuInfo.threadRegister[coreIndex] - + osCp.mCInfo.coreInfo[coreIndex].thrs] = *tskId; + + /* decrement the available thread count in the thread register */ + osCp.mCInfo.coreInfo[coreIndex].thrs--; + + /* set the exclusive flag so that the core will not + be used for other system tasks */ + osCp.mCInfo.coreInfo[coreIndex].exclusive = TRUE; + + /* unlock mCInfo */ + SUnlock(&osCp.mCILock); + + break; + } /* end if there are threads available in the core */ + } /* end if the core is not exclusive flagged and + the core has threads for SSI use */ + } /* end for */ + if (coreCounter == osCp.mCInfo.cpuInfo.numCores) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS445, ERRZERO, + "Failed to set core affinity, no threads on cores available\n"); + RETVALUE(RFAILED); + } /* end if no thrs on cores available */ + + } /* else if */ + else + { + SSLOGERROR(ERRCLS_INT_PAR, ESS446, ERRZERO, "Can not set exclusive affinity for the core\n"); + RETVALUE(RFAILED); + } /* end else */ + break; + } /* end case SS_AFFINITY_MODE_EXCL */ + default: + { + SSLOGERROR(ERRCLS_INT_PAR, ESS447, ERRZERO, "Invalid mode for setting core affinity\n"); + RETVALUE(RFAILED); + } /* end default case */ + } /* end of switch */ + + RETVALUE(ROK); + + +} /* SSetAffinity */ + +#endif /* SS_MULTICORE_SUPPORT || SS_AFFINITY_SUPPORT*/ + +/** end multi-core support **/ + + +/* +* +* Fun: Destroy system task +* +* Desc: This function is used to destroy a system task. The +* entry is located in the system task table and the +* implementation-specific function is called. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: +* +* File: ss_task.c +* +*/ +#ifdef ANSI +PUBLIC S16 SDestroySTsk +( +SSTskId tskId /* system task to be destroyed */ +) +#else +PUBLIC S16 SDestroySTsk(tskId) +SSTskId tskId; /* system task to be destroyed */ +#endif +{ + S16 ret; + /* ss029.103: modification: the subscript should be of same type */ + SsIdx i; + SsIdx idx; + SsSTskEntry *sTsk; + /* ss002.301 Additions */ +/*ss013.301 : changes related to SS_AFFINITY_SUPPORT*/ +#if defined(SS_MULTICORE_SUPPORT) || defined(SS_AFFINITY_SUPPORT) + U32 tskInd = 0; +#endif /* SS_MULTICORE_SUPPORT || SS_AFFINITY_SUPPORT*/ + + + TRC1(SDestroySTsk); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* validate the system task ID */ + if (tskId >= SS_MAX_STSKS) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS448, (ErrVal) tskId, "Invalid task ID"); + RETVALUE(RFAILED); + } +#endif + + + /* lock the system task table */ + ret = SLock(&osCp.sTskTblLock); + if (ret != ROK) + { + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS449, (ErrVal) ret, + "Could not lock system task table"); +#endif + + RETVALUE(RFAILED); + } + + + idx = (SsIdx) tskId; + sTsk = &osCp.sTskTbl[idx]; + + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* + * check to see this system task exists and it is not already scheduled + * for termination + */ + if (sTsk->used != TRUE) + { + + /* ss006.13: addition */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS450, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + + SSLOGERROR(ERRCLS_INT_PAR, ESS451, (ErrVal) idx, + "Invalid system task ID"); + RETVALUE(RFAILED); + } + else if (sTsk->termPend != FALSE) + { + + /* ss006.13: addition */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS452, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + + SSLOGERROR(ERRCLS_INT_PAR, ESS453, (ErrVal) idx, + "Invalid system task ID"); + RETVALUE(RFAILED); + } +#endif + + + /* lock this system task entry */ + if (!SS_CHECK_CUR_STSK(sTsk)) + { + ret = SLock(&sTsk->lock); + if (ret != ROK) + { + + /* ss006.13: addition */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS454, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS455, (ErrVal) ret, + "Could not lock system task entry"); +#endif + + RETVALUE(RFAILED); + } + } + + /* lock the TAPA task table */ + SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret); + if (ret != ROK) + { + if (!SS_CHECK_CUR_STSK(sTsk)) + { + + /* ss006.13: addition */ + if ( SUnlock(&sTsk->lock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS456, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + } + + /* ss006.13: addition */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS457, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS458, ERRZERO, + "Could not lock TAPA task table"); +#endif + + RETVALUE(RFAILED); + } + + + /* If this system task entry has any TAPA tasks attached, + * we have to detach them + */ + if (sTsk->numTTsks) + { + /* detach all TAPA tasks that are attached here */ + for (i = 0; i < SS_MAX_TTSKS; i++) + { + if (sTsk->tTsks[i] == SS_INVALID_IDX) + continue; + + osCp.tTskTbl[sTsk->tTsks[i]].sTsk = NULLP; + sTsk->tTsks[i] = SS_INVALID_IDX; + sTsk->numTTsks--; + } + } + + + /* set the termination pending flag to TRUE */ + sTsk->termPend = TRUE; + + + /* unlock everything */ + SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem); + + if (!SS_CHECK_CUR_STSK(sTsk)) + { + + /* ss006.13: addition */ + if ( SUnlock(&sTsk->lock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS459, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + } + + + /* ss006.13: addition */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS460, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + + + /* We call this after unlocking because it is possible that the + * caller is this very system task and we need to take care of + * that. The actual mechanism of notifying the thread that it + * has to die, or actually killing the thread is left to the + * implementation. + */ + ret = ssdDestroySTsk(sTsk); + if (ret != ROK) + { + /* Here, we're a little messed up. We've pretty much made this + * system task unusable, but now, its not going to die. So..?? + */ + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS461, (ErrVal) ret, + "Could not destroy system task"); +#endif + + RETVALUE(RFAILED); + } + + /* multi-core support */ +/*ss013.301 : changes related to SS_AFFINITY_SUPPORT*/ +#if defined(SS_MULTICORE_SUPPORT) || defined(SS_AFFINITY_SUPPORT) + + /* Remove CPU affinity if any */ + for (tskInd = 0; tskInd < SS_MAX_STSKS; tskInd++) + { + if (osCp.sTskTbl[tskInd].tskId == sTsk->tskId) + { + /* search for the tskId in coreInfo */ + U32 coreId = 0; + for (coreId = 0; coreId < SS_MAX_CORES; coreId++) + { + U32 thrId = 0; + for (thrId = 0; thrId < SS_MAX_THREADS_PER_CORE; thrId++) + { + if (sTsk->tskId == osCp.mCInfo.coreInfo[coreId].tskPerCoreLst[thrId]) + { + /* lock mCInfo */ + SLock(&osCp.mCILock); + + /* increment the available threads */ + osCp.mCInfo.coreInfo[coreId].thrs++; + + /* reset the thread id */ + osCp.mCInfo.coreInfo[coreId].tskPerCoreLst[thrId] = 0; + + /* if exclusive flag is set then remove it */ + if (osCp.mCInfo.coreInfo[coreId].exclusive) + { + osCp.mCInfo.coreInfo[coreId].exclusive = FALSE; + } /* end if excl set */ + + /* unlock mCInfo */ + SUnlock(&osCp.mCILock); + + break; + } /* end if sTsk matched a thread */ + } /* end for loop of thread Ids */ + } /* for */ + break; + } /* end if */ + } /* end for */ + +#endif /* SS_MULTICORE_SUPPORT || SS_AFFINITY_SUPPORT*/ +/* end multi-core support */ + + /* ss019.103 - added to release semaphore for system task */ +#ifndef NS + if (ssPostSema(&osCp.dep.ssStarted) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS462, ERRZERO, + "Could not unlock the Semaphore"); + RETVALUE(RFAILED); +#endif + } +#endif + + RETVALUE(ROK); +} /* SDestroySTsk */ + + + +/* +* +* Fun: Attach TAPA task +* +* Desc: This function is used to attach a TAPA task to a +* system task. The system task will begin to execute +* the TAPA task. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: +* +* File: ss_task.c +* +*/ +/* ss029.103: addition: procId added */ +#ifndef SS_MULTIPLE_PROCS + +#ifdef ANSI +PUBLIC S16 SAttachTTsk +( +Ent ent, /* entity ID of the task */ +Inst inst, /* instance ID of the task */ +SSTskId sTskId /* system task to use */ +) +#else +PUBLIC S16 SAttachTTsk(ent, inst, sTskId) +Ent ent; /* entity ID of the task */ +Inst inst; /* instance ID of the task */ +SSTskId sTskId; /* system task to use */ +#endif + +#else /* SS_MULTIPLE_PROCS */ + +#ifdef ANSI +PUBLIC S16 SAttachTTsk +( +ProcId proc, /* processor ID of the task */ +Ent ent, /* entity ID of the task */ +Inst inst, /* instance ID of the task */ +SSTskId sTskId /* system task to use */ +) +#else +PUBLIC S16 SAttachTTsk(proc, ent, inst, sTskId) +ProcId proc; /* processor ID of the task */ +Ent ent; /* entity ID of the task */ +Inst inst; /* instance ID of the task */ +SSTskId sTskId; /* system task to use */ +#endif + +#endif /* SS_MULTIPLE_PROCS */ + +{ + S16 ret; + S16 i; + SsIdx idx; + SsSTskEntry *sTsk; +/* ss029.103: addition: multiple procIds related changes */ +#ifdef SS_MULTIPLE_PROCS + U16 procIdIdx; +#endif /* SS_MULTIPLE_PROCS */ +#ifdef SS_MULTICORE_SUPPORT + SsTTskEntry *tTsk; +#ifdef SS_MULTIPLE_PROCS + void *xxCb; +#endif /* SS_MULTIPLE_PROCS */ +#endif + + + TRC1(SAttachTTsk); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check entity and instance range */ +/* ss029.103: addition: multiple procIds related changes */ +#ifdef SS_MULTIPLE_PROCS + /* check proc, entity and instance range */ + if ((proc == SS_INV_PROCID) || (ent >= SS_MAX_ENT) || (inst >= SS_MAX_INST)) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS463, ERRZERO, "Invalid processor/entity/instance"); + RETVALUE(RFAILED); + } +#else /* SS_MULTIPLE_PROCS */ + /* check entity and instance range */ + if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS464, ERRZERO, "Invalid entity/instance"); + RETVALUE(RFAILED); + } +#endif /* SS_MULTIPLE_PROCS */ + + /* check the system task index */ + if ((SsIdx)sTskId >= SS_MAX_STSKS) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS465, (ErrVal) sTskId, + "Invalid system task ID"); + RETVALUE(RFAILED); + } +#endif + +/* ss029.103: addition: multiple procIds related changes */ +#ifdef SS_MULTIPLE_PROCS + /* get the proc id idx */ + procIdIdx = SGetProcIdIdx(proc); + + if (procIdIdx == SS_INV_PROCID) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS466, ERRZERO, + "Could not find proc id index"); +#endif + RETVALUE(RFAILED); + } +#endif /* SS_MULTIPLE_PROCS */ + + /* lock the system task table */ + ret = SLock(&osCp.sTskTblLock); + if (ret != ROK) + { + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS467, (ErrVal) ret, + "Could not lock system task table"); +#endif + + RETVALUE(RFAILED); + } + + + sTsk = &osCp.sTskTbl[(SsIdx)sTskId]; + + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* verify that this system task exists */ + if (sTsk->used == FALSE) + { + + /* ss006.13: addition */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS468, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + + SSLOGERROR(ERRCLS_INT_PAR, ESS469, (ErrVal) sTskId, + "Unknown system task ID"); + RETVALUE(RFAILED); + } +#endif + + + /* lock the system task entry */ + if (!SS_CHECK_CUR_STSK(sTsk)) + { + ret = SLock(&sTsk->lock); + if (ret != ROK) + { + + /* ss006.13: addition */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS470, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS471, (ErrVal) ret, + "Could not lock system task entry"); +#endif + + RETVALUE(RFAILED); + } + } + + + /* if this system task is about to die, we don't attach */ + if (sTsk->termPend == TRUE) + { + if (!SS_CHECK_CUR_STSK(sTsk)) + { + + /* ss006.13: addition */ + if ( SUnlock(&sTsk->lock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS472, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + } + + /* ss006.13: addition */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS473, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + + RETVALUE(RFAILED); + } + + + /* lock the TAPA task table */ + SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret); + if (ret != ROK) + { + if (!SS_CHECK_CUR_STSK(sTsk)) + { + + /* ss006.13: addition */ + if ( SUnlock(&sTsk->lock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS474, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + } + + + /* ss006.13: addition */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS475, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS476, ERRZERO, + "Could not lock TAPA task table"); +#endif + + RETVALUE(RFAILED); + } + + + /* get the index of the TAPA task entry in the table */ +/* ss029.103: addition: multiple procIds related changes */ +#ifdef SS_MULTIPLE_PROCS + idx = osCp.tTskIds[procIdIdx][ent][inst]; +#else /* SS_MULTIPLE_PROCS */ + idx = osCp.tTskIds[ent][inst]; +#endif /* SS_MULTIPLE_PROCS */ + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check out the TAPA task ID */ + if (idx == SS_TSKNC) + { + SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem); + if (!SS_CHECK_CUR_STSK(sTsk)) + { + + /* ss006.13: addition */ + if ( SUnlock(&sTsk->lock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS477, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + } + + /* ss006.13: addition */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS478, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + + SSLOGERROR(ERRCLS_INT_PAR, ESS479, ERRZERO, "Unknown task"); + RETVALUE(RFAILED); + } +#endif + + + /* verify that this TAPA task is not already attached */ + if (osCp.tTskTbl[idx].sTsk != NULLP) + { + SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem); + if (!SS_CHECK_CUR_STSK(sTsk)) + { + + /* ss006.13: addition */ + if ( SUnlock(&sTsk->lock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS480, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + } + + /* ss006.13: addition */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS481, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + + RETVALUE(RFAILED); + } + + + /* verify that there is space for another TAPA task */ + if (sTsk->numTTsks == SS_MAX_TTSKS) + { + SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem); + if (!SS_CHECK_CUR_STSK(sTsk)) + { + + /* ss006.13: addition */ + if ( SUnlock(&sTsk->lock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS482, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + } + + /* ss006.13: addition */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS483, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + + RETVALUE(ROUTRES); + } + + + /* Find place for this TAPA task in the system task's list + * of TAPA tasks to run. Plug in this TAPA task. + */ + for (i = 0; i < SS_MAX_TTSKS; i++) + { + if (sTsk->tTsks[i] == SS_INVALID_IDX) + { + sTsk->tTsks[i] = idx; + sTsk->numTTsks++; + break; + } + } + + + /* Fill in the system task info in the TAPA task entry, so + * the TAPA task knows who's running it. + */ + osCp.tTskTbl[idx].sTsk = sTsk; +#ifdef SS_MULTICORE_SUPPORT + tTsk = &osCp.tTskTbl[idx]; + if(tTsk->initTsk != NULLP) + { +#ifndef SS_MULTIPLE_PROCS + (Void)(tTsk->initTsk)(tTsk->ent, tTsk->inst, sTsk->region, PWR_UP); +#else + /* retrieve proc id index in the proc id table */ + procIdIdx = SGetProcIdIdx(tTsk->proc); + + /* Check whether the proc id exist in the proc id table */ + if (procIdIdx == SS_INV_PROCID_IDX) + { +#if (ERRCLASS & ERRCLS_INT_PAR) + SSLOGERROR(ERRCLS_INT_PAR, ESS389, ERRZERO, + "Could not find proc table index"); +#endif + + RETVALUE(RFAILED); + } + (Void)(tTsk->initTsk)(tTsk->proc, tTsk->ent, tTsk->inst, sTsk->region, PWR_UP, &xxCb); + /* + * store the control block. The control block may be NULL in some cases + */ + idx = osCp.tTskIds[procIdIdx][tTsk->ent][tTsk->inst]; +#if (ERRCLASS & ERRCLS_INT_PAR) + if ( xxCb == NULLP ) + { + SSLOGERROR(ERRCLS_INT_PAR, ERRZERO, ERRZERO, + "Null pointer"); + } +#endif + osCp.tTskTbl[idx].xxCb = xxCb; +#endif /* SS_MULTIPLE_PROCS */ + } +#endif /* SS_MULTICORE_SUPPORT */ + + + /* call the implementation to do anything implementation-specific */ + ret = ssdAttachTTsk(&osCp.tTskTbl[idx]); + + + /* unlock the tables; we're done */ + SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem); + if (!SS_CHECK_CUR_STSK(sTsk)) + { + + /* ss006.13: addition */ + if ( SUnlock(&sTsk->lock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS484, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + } + + /* ss006.13: addition */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS485, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + + + /* If the implementation didn't succeed, we have to undo everything. + * We call SDetachTTsk, to make it easier. + */ + if (ret != ROK) + { +/* ss029.103: addition: multiple procIds related changes */ +#ifdef SS_MULTIPLE_PROCS + SDetachTTsk(proc, ent, inst); +#else /* SS_MULTIPLE_PROCS */ + SDetachTTsk(ent, inst); +#endif /* SS_MULTIPLE_PROCS */ + RETVALUE(RFAILED); + } + + + RETVALUE(ROK); +} /* SAttachTTsk */ + + +/* +* +* Fun: Detach TAPA task +* +* Desc: This function is used to detach a TAPA task from a +* system task. The system task will stop executing +* the TAPA task. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: +* +* File: ss_task.c +* +*/ +/* ss029.103: addition: procId added */ +#ifndef SS_MULTIPLE_PROCS + +#ifdef ANSI +PUBLIC S16 SDetachTTsk +( +Ent ent, /* entity ID of the task */ +Inst inst /* instance ID of the task */ +) +#else +PUBLIC S16 SDetachTTsk(ent, inst) +Ent ent; /* entity ID of the task */ +Inst inst; /* instance ID of the task */ +#endif + +#else /* SS_MULTIPLE_PROCS */ + +#ifdef ANSI +PUBLIC S16 SDetachTTsk +( +ProcId proc, /* processor ID of the task */ +Ent ent, /* entity ID of the task */ +Inst inst /* instance ID of the task */ +) +#else +PUBLIC S16 SDetachTTsk(proc, ent, inst) +ProcId proc; /* processor ID of the task */ +Ent ent; /* entity ID of the task */ +Inst inst; /* instance ID of the task */ +#endif + +#endif /* SS_MULTIPLE_PROCS */ + +{ + S16 ret; + S16 i; + SsIdx idx; + SsTTskEntry *tTsk; + SsSTskEntry *sTsk; +/* ss029.103: addition: multiple procIds related changes */ +#ifdef SS_MULTIPLE_PROCS + U16 procIdIdx; +#endif /* SS_MULTIPLE_PROCS */ + + TRC1(SDetachTTsk); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check entity and instance ranges */ +/* ss029.103: addition: multiple procIds related changes */ +#ifdef SS_MULTIPLE_PROCS + /* check entity and instance ranges */ + if ((proc == SS_INV_PROCID) || (ent >= SS_MAX_ENT) || (inst >= SS_MAX_INST)) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS486, ERRZERO, "Invalid processor/entity/instance"); + RETVALUE(RFAILED); + } +#else /* SS_MULTIPLE_PROCS */ + /* check entity and instance ranges */ + if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS487, ERRZERO, "Invalid entity/instance"); + RETVALUE(RFAILED); + } +#endif /* SS_MULTIPLE_PROCS */ +#endif + +/* ss029.103: addition: multiple procIds related changes */ +#ifdef SS_MULTIPLE_PROCS + /* get the proc id idx */ + procIdIdx = SGetProcIdIdx(proc); + + if (procIdIdx == SS_INV_PROCID) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS488, ERRZERO, + "Could not find proc id index"); +#endif + RETVALUE(RFAILED); + } +#endif /* SS_MULTIPLE_PROCS */ + + + /* Lock the system task table. We do this to prevent + * the system task from being destroyed and confusing + * matters before we detach. + */ + ret = SLock(&osCp.sTskTblLock); + if (ret != ROK) + { + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS489, (ErrVal) ret, + "Could not lock system task table"); +#endif + + RETVALUE(RFAILED); + } + + + /* lock the TAPA task table */ + SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret); + if (ret != ROK) + { + + /* ss006.13: addition */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS490, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS491, ERRZERO, + "Could not lock TAPA task table"); +#endif + + RETVALUE(RFAILED); + } + + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* Check this TAPA task. We do this with the TAPA task table + * locked, coz we don't want the task to be found, but then + * be deregistered before we lock + */ +/* ss029.103: addition: multiple procIds related changes */ +#ifdef SS_MULTIPLE_PROCS + if (osCp.tTskIds[procIdIdx][ent][inst] == SS_TSKNC) +#else /* SS_MULTIPLE_PROCS */ + if (osCp.tTskIds[ent][inst] == SS_TSKNC) +#endif /* SS_MULTIPLE_PROCS */ + { + SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem); + + /* ss006.13: addition */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS492, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + + SSLOGERROR(ERRCLS_INT_PAR, ESS493, ERRZERO, "Unknown task"); + RETVALUE(RFAILED); + } +#endif + +/* ss029.103: addition: multiple procIds related changes */ +#ifdef SS_MULTIPLE_PROCS + idx = osCp.tTskIds[procIdIdx][ent][inst]; +#else /* SS_MULTIPLE_PROCS */ + idx = osCp.tTskIds[ent][inst]; +#endif /* SS_MULTIPLE_PROCS */ + + tTsk = &osCp.tTskTbl[idx]; + + /* check if this TAPA task is attached to anyone */ + if (tTsk->sTsk == NULLP) + { + SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem); + + /* ss006.13: addition */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS494, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + RETVALUE(ROK); + } + + + /* we get the system task entry out */ + sTsk = tTsk->sTsk; + + + /* We unlock the TAPA task table here, and then re-lock it later + * because of lock sequencing--we have to lock the system task + * entry first, and then the TAPA task table. Note, the system + * task table is locked, so nobody can sneak in and destroy the + * system task while we're doing this. + */ + SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem); + + + /* lock the system task entry */ + if (!SS_CHECK_CUR_STSK(sTsk)) + { + ret = SLock(&sTsk->lock); + if (ret != ROK) + { + + /* ss006.13: addition */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS495, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS496, (ErrVal) ret, + "Could not lock system task entry"); +#endif + + RETVALUE(RFAILED); + } + } + + + /* now we lock the TAPA task table */ + SS_ACQUIRE_ALL_SEMA(&osCp.tTskTblSem, ret); + if (ret != ROK) + { + + /* ss006.13: addition */ + if ( SUnlock(&sTsk->lock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS497, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS498, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS499, ERRZERO, + "Could not lock TAPA task table"); +#endif + + RETVALUE(RFAILED); + } + + + /* Now, we can safely update both the system task entry + * and the TAPA task entry. First, we update the TAPA + * task entry--nobody is running it now. + */ + tTsk->sTsk = NULLP; + + + /* Remove this TAPA task from the system task's list of + * TAPA tasks to run. + */ + for (i = 0; i < SS_MAX_TTSKS; i++) + { + if (sTsk->tTsks[i] == idx) + { + sTsk->tTsks[i] = SS_INVALID_IDX; + sTsk->numTTsks--; + break; + } + } + + + /* call the implementation to do anything it needs to */ + ret = ssdDetachTTsk(tTsk); + + + /* unlock the TAPA task table */ + SS_RELEASE_ALL_SEMA(&osCp.tTskTblSem); + + /* unlock the system task entry */ + if (!SS_CHECK_CUR_STSK(sTsk)) + { + + /* ss006.13: addition */ + if ( SUnlock(&sTsk->lock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS500, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + } + + /* unlock the system task table */ + + /* ss006.13: addition */ + if ( SUnlock(&osCp.sTskTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS501, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + + + /* If the implementation couldn't detach the task, we just + * return an error, nothing else we can do. + */ + if (ret != ROK) + { + RETVALUE(RFAILED); + } + + + RETVALUE(ROK); +} /* SDetachTTsk */ + + +/* +* +* Fun: Post a message to a task +* +* Desc: This function is used to post a message to a TAPA +* task. The message is delivered to the demand queue +* of the system task that is running the specified +* destination task. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: +* +* File: ss_task.c +* +*/ +#ifdef ANSI +PUBLIC S16 SPstTsk +( +Pst *pst, /* post information */ +Buffer *mBuf /* message to post */ +) +#else +PUBLIC S16 SPstTsk(pst, mBuf) +Pst *pst; /* post information */ +Buffer *mBuf; /* message to post */ +#endif +{ + S16 r; + S16 i; +#if (defined(SS_DRVR_SUPPORT)) + S16 j; +#endif + SsIdx dstIdx; + SsIdx srcIdx; + Prior prior; + SsTTskEntry *tTsk; + SsMsgInfo *msgInfo; +#if (defined(SS_DRVR_SUPPORT) || defined(SS_RTR_SUPPORT)) + Pst nPst; +#endif +#ifdef SS_DRVR_SUPPORT + Bool nPstUsed = FALSE; +#endif +#if (defined(SS_RTR_SUPPORT)) + Route rte; +#endif +/* ss029.103: addition: multiple procIds related changes */ +#ifdef SS_MULTIPLE_PROCS + U16 srcProcIdIdx; + U16 dstProcIdIdx; +#endif /* SS_MULTIPLE_PROCS */ +/*ss004.301: Cavium changes */ +#ifdef SS_SEUM_CAVIUM + Buffer *wqBuf; + S16 ret; + cvmx_wqe_t *workPtr; +#endif /* SS_SEUM_CAVIUM */ + + S16 retValue = 0; + Pst tempPst; + +#ifdef MSPD_MLOG_NEW + U32 t = MacGetTick(); +#endif + + TRC1(SPstTsk); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check the message buffer */ + if (mBuf == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS502, ERRZERO, "Invalid message buffer"); + RETVALUE(RFAILED); + } + + /* check the pst structure */ + if (pst == NULLP) + { + SPutMsg(mBuf); + SSLOGERROR(ERRCLS_INT_PAR, ESS503, ERRZERO, "Null pointer"); + RETVALUE(RFAILED); + } + /* ss021.103 - Addition to check for valid route */ + /* ss023.103 - Modification to fix bug in route validation */ + /* check the route */ + if (pst->route == RTENC) + { + SPutMsg(mBuf); + SSLOGERROR(ERRCLS_INT_PAR, ESS504, ERRZERO, "No route defined"); + RETVALUE(RFAILED); + } +#endif + +#ifndef TENB_RTLIN_CHANGES + /* lock the TAPA task table */ + SS_ACQUIRE_SEMA(&osCp.tTskTblSem, r); + if (r != ROK) + { + SPutMsg(mBuf); + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS505, ERRZERO, + "Could not lock TAPA task table"); +#endif + + RETVALUE(RFAILED); + } +#endif + +#if (ERRCLASS & ERRCLS_INT_PAR) +/* ss029.103: addition: multiple procIds related changes */ +#ifdef SS_MULTIPLE_PROCS + if (pst->srcProcId == SS_INV_PROCID || pst->srcEnt >= SS_MAX_ENT || + pst->srcInst >= SS_MAX_INST || pst->dstProcId == SS_INV_PROCID || + pst->dstEnt >= SS_MAX_ENT || pst->dstInst >= SS_MAX_INST) +#else /* SS_MULTIPLE_PROCS */ + if (pst->srcEnt >= SS_MAX_ENT || pst->srcInst >= SS_MAX_INST || + pst->dstEnt >= SS_MAX_ENT || pst->dstInst >= SS_MAX_INST) +#endif /* SS_MULTIPLE_PROCS */ + { +#ifndef TENB_RTLIN_CHANGES + /* ss006.13: addition */ + if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS506, ERRZERO, + "Could not release the semaphore"); + RETVALUE(RFAILED); +#endif + } +#endif + + SPutMsg(mBuf); + + SSLOGERROR(ERRCLS_INT_PAR, ESS507, ERRZERO, + "Invalid source/destination entity/instance"); + + RETVALUE(RFAILED); + } +#endif + + /* ss019.103 - modified for use with message router in virtual/physical + * configuration */ + +#ifdef SS_RTR_SUPPORT + /* check if we have a router task registered for this route */ + if (pst->route < RTENC && osCp.rtrTskTbl[pst->route] != NULLP) + { + /* copy the Pst structure into a local duplicate */ + for (i = 0; i < (S16)sizeof(Pst); i++) + { + *(((U8 *)(&nPst)) + i) = *(((U8 *) pst) + i); + } + pst = &nPst; +#ifdef SS_DRVR_SUPPORT + nPstUsed = TRUE; +#endif + + /* lock the router task entry */ + rte = pst->route; + r = SLock(&osCp.rtrTskLocks[rte]); + if (r != ROK) + { + /* ss006.13: addition */ +#ifndef TENB_RTLIN_CHANGES + if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS508, ERRZERO, + "Could not release the semaphore"); + RETVALUE(RFAILED); +#endif + } +#endif + SPutMsg(mBuf); + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS509, ERRZERO, + "Could not lock router task entry"); +#endif + + RETVALUE(RFAILED); + } + + /* call the router activation function */ + r = (*osCp.rtrTskTbl[rte])(pst, mBuf); + + /* unlock the router task entry */ + + /* ss006.13: addition */ + if ( SUnlock(&osCp.rtrTskLocks[rte]) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS510, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } + + if (r == RFAILED || r == ROKIGNORE) + { + /* ss006.13: addition */ +#ifndef TENB_RTLIN_CHANGES + if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS511, ERRZERO, + "Could not release the semaphore"); + RETVALUE(RFAILED); +#endif + } +#endif + RETVALUE((r == RFAILED) ? RFAILED : ROK); + } + } +#endif /* SS_RTR_SUPPORT */ + +/* ss029.103: addition: multiple procIds related changes */ +#ifdef SS_MULTIPLE_PROCS + + /* get proc id index */ + srcProcIdIdx = SGetProcIdIdx(pst->srcProcId); + dstProcIdIdx = SGetProcIdIdx(pst->dstProcId); + + if (srcProcIdIdx != SS_INV_PROCID_IDX) + srcIdx = osCp.tTskIds[srcProcIdIdx][pst->srcEnt][pst->srcInst]; + + if (dstProcIdIdx != SS_INV_PROCID_IDX) + dstIdx = osCp.tTskIds[dstProcIdIdx][pst->dstEnt][pst->dstInst]; + + if (((srcProcIdIdx != SS_INV_PROCID_IDX) && (srcIdx == SS_TSKNC)) || + ((dstProcIdIdx != SS_INV_PROCID_IDX) && (dstIdx == SS_TSKNC))) + { +#ifndef TENB_RTLIN_CHANGES + if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS512, ERRZERO, + "Could not release the semaphore"); + RETVALUE(RFAILED); +#endif + } +#endif + + SPutMsg(mBuf); + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS513, ERRZERO, "Unknown task"); +#endif + + RETVALUE(RFAILED); + } + +#else /* SS_MULTIPLE_PROCS */ + /* ss019.103 - modified for use with message router in virtual/physical + * configuration */ + + /* get the src and destination task */ + srcIdx = osCp.tTskIds[pst->srcEnt][pst->srcInst]; + dstIdx = osCp.tTskIds[pst->dstEnt][pst->dstInst]; + + + /* If the source/destination processor ID is local, the + * source/destination TAPA task must be local. + */ + if ((pst->srcProcId == osCp.procId && srcIdx == SS_TSKNC) + || (pst->dstProcId == osCp.procId && dstIdx == SS_TSKNC)) + { + /* ss006.13: addition */ +#ifndef TENB_RTLIN_CHANGES + if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS514, ERRZERO, + "Could not release the semaphore"); + RETVALUE(RFAILED); +#endif + } +#endif + SPutMsg(mBuf); + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS515, ERRZERO, "Unknown task"); +#endif + + RETVALUE(RFAILED); + } + +#endif /* SS_MULTIPLE_PROCS */ + +#ifdef SS_DRVR_SUPPORT + /* Check for the destination procId. If it is non-local, + * we need to find the driver task that will handle this + * message. + */ +/* ss029.103: addition: multiple procIds related changes */ +#ifdef SS_MULTIPLE_PROCS + if (dstProcIdIdx == SS_INV_PROCID_IDX) +#else /* SS_MULTIPLE_PROCS */ + if (pst->dstProcId != osCp.procId) +#endif /* SS_MULTIPLE_PROCS */ + { + /* Need to optimize this search. + */ + for (i = 0; i < SS_MAX_DRVRTSKS; i++) + { + if (osCp.drvrTskTbl[i].used + && pst->dstProcId >= osCp.drvrTskTbl[i].low + && pst->dstProcId <= osCp.drvrTskTbl[i].high) + { + /* Copy the Pst structure into a local duplicate if not + * already done. + */ + if (!nPstUsed) + { + for (j = 0; j < (S16)sizeof(Pst); j++) + { + *(((U8 *)(&nPst)) + j) = *(((U8 *) pst) + j); + } + pst = &nPst; + nPstUsed = TRUE; + } + + +#ifdef L2_L3_SPLIT +//if (clusterMode == NET_CLUSTER_MODE) +{ +#endif + /* lock the driver task entry */ + r = SLock(&osCp.drvrTskTbl[i].lock); + if (r != ROK) + { + /* ss006.13: addition */ +#ifndef TENB_RTLIN_CHANGES + if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS516, ERRZERO, + "Could not release the semaphore"); + RETVALUE(RFAILED); +#endif + } +#endif + SPutMsg(mBuf); + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS517, ERRZERO, + "Could not lock driver task entry"); +#endif + + RETVALUE(RFAILED); + } +#ifdef L2_L3_SPLIT +} +#endif +/*ss014.301 SSI-4GMX specific change*/ +#ifndef SS_4GMX_LCORE + CMCHKPKLOG(cmPkInst, osCp.drvrTskTbl[i].channel, mBuf, ESS518, pst); +#endif + + (osCp.drvrTskTbl[i].actvTsk)(pst, mBuf); + + /* unlock */ +#ifdef L2_L3_SPLIT +//if (clusterMode == NET_CLUSTER_MODE) +{ +#endif + /* ss006.13: addition */ + if ( SUnlock(&osCp.drvrTskTbl[i].lock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS519, ERRZERO, + "Could not give the Semaphore"); + RETVALUE(RFAILED); +#endif + } +#ifdef L2_L3_SPLIT +} +#endif + + /* ss006.13: addition */ +#ifndef TENB_RTLIN_CHANGES + if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS520, ERRZERO, + "Could not release the semaphore"); + RETVALUE(RFAILED); +#endif + } +#endif + RETVALUE(ROK); + } + } + + /* ss006.13: addition */ +#ifndef TENB_RTLIN_CHANGES + if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS521, ERRZERO, + "Could not release the semaphore"); + RETVALUE(RFAILED); +#endif + } +#endif + SPutMsg(mBuf); + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS522, ERRZERO, + "Could not find a driver task to handle this proc ID"); +#endif + + RETVALUE(RFAILED); + } +#endif /* SS_DRVR_SUPPORT */ + /* ss002.301 Modifications */ + /* Write the message to the demand queue of the system + * task which is running the destination task + */ + tTsk = &osCp.tTskTbl[dstIdx]; + + cmMemcpy((U8*)&tempPst, (U8*)pst, sizeof(Pst)); + if(tTsk->cbTsk != NULLP) + { + retValue = tTsk->cbTsk(&tempPst,mBuf); + if(retValue != ROK) + { +#ifndef TENB_RTLIN_CHANGES + if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS512, ERRZERO, + "Could not release the semaphore"); + RETVALUE(RFAILED); +#endif + } +#endif + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS513, ERRZERO, "call back function failed\n"); +#endif + RETVALUE(ROK); + } +#ifdef SS_MULTIPLE_PROCS + dstIdx = osCp.tTskIds[dstProcIdIdx][tempPst.dstEnt][tempPst.dstInst]; +#else + dstIdx = osCp.tTskIds[tempPst.dstEnt][tempPst.dstInst]; +#endif + tTsk = &osCp.tTskTbl[dstIdx]; + } + + /* plug the Pst structure into the message information portion */ + msgInfo = (SsMsgInfo *) (mBuf->b_rptr); + for (i = 0; i < (S16 )sizeof(Pst); i++) + *(((U8 *)(&msgInfo->pst)) + i) = *(((U8 *) &(tempPst)) + i); + +/* ss004.301 : Cavium cahnges */ +#ifdef SS_SEUM_CAVIUM + if (pst->dstProcId != osCp.procId) + { + if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS527, ERRZERO, + "Could not release the semaphore"); + RETVALUE(RFAILED); +#endif + } + + /* Copy the message to the FPA region */ + ret = SCpyMsgFpa(mBuf, &wqBuf); + if( ret != ROK ) + { + /* No need to free the buffer, its already done in called fun */ + RETVALUE(RFAILED); + } + + /* Allocate for the mBuf */ + /* ss010.301: Cavium 32 bit changes */ + workPtr = cvmx_fpa_alloc(SS_CVMX_WQE_POOL); + if( workPtr == NULLP ) + { + SPutFpaMsg(wqBuf); + RETVALUE(RFAILED); + } + + /* Convert the pointers to physical address */ + ret = SConvPtrPhy(&wqBuf); + if( ret != ROK ) + { + SPutFpaMsg(wqBuf); + RETVALUE(RFAILED); + } + + /* Assign the values for work ptr */ + workPtr->qos = 0; + workPtr->grp = pst->dstProcId; + workPtr->tag_type = CVMX_POW_TAG_TYPE_NULL; + workPtr->tag = SS_CVMX_MBUF_TAG; + + workPtr->packet_ptr.ptr = (Void*)wqBuf; + + cvmx_pow_work_submit(workPtr, workPtr->tag, workPtr->tag_type, \ + workPtr->qos, workPtr->grp); + + RETVALUE(ROK); + } +#endif /* SS_SEUM_CAVIUM */ + + + /* Write the message to the demand queue of the system + * task which is running the destination task + */ + tTsk = &osCp.tTskTbl[dstIdx]; + prior = tTsk->tskPrior; + + if (tTsk->sTsk == NULLP) + { + /* ss006.13: addition */ +#ifndef TENB_RTLIN_CHANGES + if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS523, ERRZERO, + "Could not release the semaphore"); + RETVALUE(RFAILED); +#endif + } +#endif + SPutMsg(mBuf); + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS524, (ErrVal) 0, + "Destination TAPA task is not attached"); +#endif + + RETVALUE(RFAILED); + } + +#ifdef SS_LOCKLESS_MEMORY + msgInfo->region = tTsk->sTsk->region; + msgInfo->pst.region = tTsk->sTsk->region; +#endif /* SS_LOCKLESS_MEMORY */ + +/*ss014.301 SSI-4GMX specific changes*/ +#ifndef SS_4GMX_LCORE + r = ssDmndQPutLast(&tTsk->sTsk->dQ, mBuf, + ((prior * SS_MAX_MSG_PRI) + tempPst.prior)); +#ifdef TENB_T2K3K_SPECIFIC_CHANGES + { + extern Bool g_usettitmr; + if (g_usettitmr) + { + if (tTsk->sTsk->tskPrior == PRIOR0) + { + SsTTskEntry *srctTsk; + srctTsk = &osCp.tTskTbl[srcIdx]; + if ((srctTsk->sTsk == tTsk->sTsk) +#if defined(SPLIT_RLC_DL_TASK) && !defined(RLC_MAC_DAT_REQ_RBUF) + || + ((pst->dstEnt == ENTRG) && + (pst->srcEnt == ENTKW) && + (pst->event == EVTRGUDDATREQ)) +#endif + ) +#ifdef RGL_SPECIFIC_CHANGES + WLS_WakeUp(mtGetWlsHdl()); +#else + tlPost(NULLP); +#endif + } + } + else if (tTsk->sTsk->tskPrior == PRIOR0) +#ifdef RGL_SPECIFIC_CHANGES + WLS_WakeUp(mtGetWlsHdl()); +#else + tlPost(NULLP); +#endif + } +#endif +#else + if(tTsk->actvTsk != NULLP) + { + if(tTsk->cbTsk != NULLP) + { + r = rbICorePstTsk(&tempPst, mBuf, tTsk); + } + else + { + r = rbICorePstTsk(pst, mBuf, tTsk); + } + } + else + { + r = RFAILED; + } +#endif + if (r != ROK) + { + /* ss006.13: addition */ +#ifndef TENB_RTLIN_CHANGES + if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS525, ERRZERO, + "Could not release the semaphore"); + RETVALUE(RFAILED); +#endif + } +#endif + SPutMsg(mBuf); + +#if (ERRCLASS & ERRCLS_ADD_RES) + SSLOGERROR(ERRCLS_ADD_RES, ESS526, (ErrVal) r, + "Could not write to demand queue"); +#endif + + RETVALUE(RFAILED); + } + + + /* unlock, we're done */ + /* ss006.13: addition */ +#ifndef TENB_RTLIN_CHANGES + if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS527, ERRZERO, + "Could not release the semaphore"); + RETVALUE(RFAILED); +#endif + } +#endif + + + /* If the implementation has anything to do... note that + * we call it unlocked at this time. + */ + ssdPstTsk(tempPst, mBuf, tTsk); + + RETVALUE(ROK); +} /* SPstTsk */ + +/* ss001.301: additions */ +#ifdef SS_HISTOGRAM_SUPPORT +/* +* +* fun : SGetTapaTskEntIds +* +* Desc: Get the tapa task entity id, which are registerd for SSI. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: +* +* File: ss_task.c +* +*/ +/* ss029.103: modification: procId added */ + +#ifdef ANSI +PUBLIC S16 SGetTapaTskEntIds +( +Ent *ent /* entity */ +) +#else +PUBLIC S16 SGetTapaTskEntIds(ent) +Ent *ent; /* entity */ +#endif +{ + + U32 tskCnt = 0; + + TRC1(SGetTapaTskEntIds); + /* Get the tapa task entity Ids from the osCp structure */ + for(tskCnt = 0; tskCnt < osCp.numTTsks; tskCnt++) + { + ent[tskCnt] = osCp.tTskTbl[tskCnt].ent; + } + + RETVALUE(ROK); +} /* SGetTapaTskEntIds */ + +/* +* +* Fun: SRegForHstGrm +* +* Desc: This function is used to register a TAPA task, +* for histogram facilty. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: +* +* File: ss_task.c +* +*/ +/* ss029.103: modification: procId added */ + +#ifdef ANSI +PUBLIC S16 SRegForHstGrm +( +Ent ent /* entity */ +) +#else +PUBLIC S16 SRegForHstGrm(ent) +Ent ent; /* entity */ +#endif +{ + + U32 tskCnt = 0; + S16 r = 0; + + TRC1(SRegForHstGrm); + + SS_ACQUIRE_SEMA(&osCp.tTskTblSem, r); + if (r != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS623, ERRZERO, + "Could not lock TAPA task table"); +#endif + + RETVALUE(RFAILED); + } + + for(tskCnt = 0; tskCnt < osCp.numTTsks; tskCnt++) + { + if(osCp.tTskTbl[tskCnt].ent == ent) + { + osCp.tTskTbl[tskCnt].hstReg = TRUE; + break; + } + } + + if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS639, ERRZERO, + "Could not release the semaphore"); + RETVALUE(RFAILED); +#endif + } + + RETVALUE(ROK); +} /* SGetTapaTskEntIds */ + +/* +* +* Fun: SGetHstGrmInfo +* +* Desc : Get the Histogram registration for TAPA task +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: +* +* File: ss_task.c +* +*/ +#ifdef ANSI +PUBLIC S16 SGetHstGrmInfo +( +Ent *entId, +Bool *hstReg /* entity */ +) +#else +PUBLIC S16 SGetHstGrmInfo(entId, hstReg) +Ent *entId; +Bool *hstReg; /* entity */ +#endif +{ + + U32 tskCnt = 0; + Bool found = FALSE; + *hstReg = 0; + + TRC1(SGetHstGrmInfo); + for(tskCnt = 0; tskCnt < osCp.numTTsks; tskCnt++) + { + if( *entId == osCp.tTskTbl[tskCnt].ent) + { + *hstReg = osCp.tTskTbl[tskCnt].hstReg; + found = TRUE; + break; + } + } + + if(!found) + { + *entId = ENTNC; + *hstReg = TRUE; + } + + RETVALUE(ROK); +} /* SGetTapaTskEntIds */ + +#endif /* SS_HISTOGRAM_SUPPORT */ + +#ifdef SS_WATCHDOG +#ifdef ANSI +PUBLIC S16 SInitWatchdog +( +U16 port +) +#else +PUBLIC S16 SInitWatchdog(port) +U16 port; +#endif +{ + return ssdInitWatchDog(port); +} + +#ifdef ANSI +PUBLIC S16 SRegCfgWd +( +U32 numNodes, +U8 *addr[], +U16 port[], +U32 timeout, +WdUserCallback callback, +void *data +) +#else +PUBLIC S16 SRegCfgWd(numNodes, addr, port, timeout, callback, data) +U32 numNodes; +U8 *addr[]; +U16 port[]; +U32 timeout; +WdUserCallback callback; +void *data; +#endif +{ + Txt prntBuf[PRNTSZE]; + int i = 0; + + /*ss013.301 :Fix for TRACE5 feature crash due to missing TRC MACRO*/ + TRC1(SRegCfgWd) + + osCp.wdCp.globWd.timeout = timeout; + osCp.wdCp.globWd.callback = callback; + osCp.wdCp.globWd.data = data; + osCp.wdCp.globWd.numNodes = numNodes; + + SLock(&osCp.wdCp.wdLock); + for(i = 0; i < SS_MAX_WD_NODES && i < numNodes; i++) + { +#ifdef SS_WATCHDOG_IPV6 + /* ss002.301 Modifications */ + inet_pton(AF_INET6,(const char *)addr[i],osCp.wdCp.globWd.wdsta[i].addr); +#else + osCp.wdCp.globWd.wdsta[i].addr.s_addr = inet_addr((const char *)addr[i]); +#endif /* SS_WATCHDOG_IPV6 */ + osCp.wdCp.globWd.wdsta[i].port = htons(port[i]); + sprintf(prntBuf, "Configured [%s:%d] for watchdog\n", addr[i], port[i]); + SPrint(prntBuf); + } + SUnlock(&osCp.wdCp.wdLock); + /* ss002.301 Compilation fixes */ + /*ss013.301: Fixed Warnings for 32/64 bit compilation*/ +#ifdef ALIGN_64BIT + sprintf(prntBuf, "Configured %d nodes with timeout %u for Watchdog\n", osCp.wdCp.globWd.numNodes, osCp.wdCp.globWd.timeout); +#else + sprintf(prntBuf, "Configured %d nodes with timeout %lu for Watchdog\n", osCp.wdCp.globWd.numNodes, osCp.wdCp.globWd.timeout); +#endif + SPrint(prntBuf); + + RETVALUE(ROK); +} + +#ifdef ANSI +PUBLIC S16 SDeregCfgWd +( +void +) +#else +PUBLIC S16 SDeregCfgWd(void) +void; +#endif +{ + Txt prntBuf[PRNTSZE]; + int i = 0; + + /*ss013.301 :Fix for TRACE5 feature crash due to missing TRC MACRO*/ + TRC1(SDeregCfgWd) + + osCp.wdCp.globWd.timeout = 0; + osCp.wdCp.globWd.callback = 0; + osCp.wdCp.globWd.data = 0; + osCp.wdCp.globWd.numNodes = 0; + + SLock(&osCp.wdCp.wdLock); + for(i = 0; i < SS_MAX_WD_NODES; i++) + { + /* ss002.301 Modifications */ + sprintf(prntBuf, "Deregister [%s:%d] for watchdog\n", inet_ntoa(osCp.wdCp.globWd.wdsta[i +].addr), osCp.wdCp.globWd.wdsta[i].port); + osCp.wdCp.globWd.wdsta[i].addr.s_addr = 0; + osCp.wdCp.globWd.wdsta[i].port = 0; + SPrint(prntBuf); + } + SUnlock(&osCp.wdCp.wdLock); + + /* Implicit watchdog stop during dereg */ + SStopHrtBt(); + + RETVALUE(ROK); +} + +#ifdef ANSI +PUBLIC S16 SStartHrtBt +( +U8 timeInterval /* time interval */ +) +#else +PUBLIC S16 SStartHrtBt(timeInterval) +U8 timeInterval; +#endif +{ + TRC1(SStartHrtBt); + + ssdStartWatchDgTmr(NULLP, SS_TMR_HRTBT, timeInterval); + ssdSndHrtBtMsg(TRUE, SS_WD_HB_REQ); + + RETVALUE(ROK); +} + +#ifdef ANSI +PUBLIC S16 SStopHrtBt +( +void +) +#else +PUBLIC S16 SStopHrtBt() +void +#endif +{ + TRC1(SStopHrtBt); + + osCp.wdCp.globWd.watchdogStop = 1; + + RETVALUE(ROK); +} + +#ifdef ANSI +PUBLIC S16 watchDgActvTsk +( +Pst *pst, /* post */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 watchDgActvTsk(pst, mBuf) +Pst *pst; /* post */ +Buffer *mBuf; /* message buffer */ +#endif +{ +/* ss002.301 Fixed warnings */ +#ifdef DEBUGP + DateTime dt; + Txt prntBuf[PRNTSZE]; +#endif /* DEBUGP */ + + TRC3(watchDgActvTsk) +#ifdef DEBUGP + SGetDateTime(&dt); + sprintf(prntBuf,"watchDgActvTsk: Time: %02d:%02d:%02d\n",dt.hour,dt.min, dt.sec +); + SPrint(prntBuf); +#endif /* DEBUGP */ + RETVALUE(ROK); +} + +#ifdef ANSI +PUBLIC S16 watchDgRcvrActvTsk +( +Pst *pst, /* post */ +Buffer *mBuf /* message buffer */ +) +#else +PUBLIC S16 watchDgRcvrActvTsk(pst, mBuf) +Pst *pst; /* post */ +Buffer *mBuf; /* message buffer */ +#endif +{ +#ifdef DEBUGP + DateTime dt; +#endif /* DEBUGP */ + Txt prntBuf[PRNTSZE]; + U16 n; + S16 err; + struct sockaddr_in tmpaddr; + Txt hbMsg[SS_WD_HB_MSG_SIZE]; + /* ss002.301 Modifications */ +#ifdef SS_LINUX + socklen_t socklen = sizeof(struct sockaddr); +#else + int socklen = sizeof(struct sockaddr); +#endif + + TRC3(watchDgActvTsk) + +#ifdef DEBUGP + SGetDateTime(&dt); + sprintf(prntBuf,"watchDgRcvrActvTsk: Time: %02d:%02d:%02d\n",dt.hour, dt.min, dt.sec); + SPrint(prntBuf); +#endif /* DEBUGP */ + + while(!osCp.wdCp.globWd.watchdogStop) + { + err = recvfrom(osCp.wdCp.globWd.sock, hbMsg, SS_WD_HB_MSG_SIZE, 0, (struct sockaddr *)&tmpaddr, &socklen); + if(err == -1) + { + sprintf(prntBuf,"watchDgRcvrActvTsk: recvfrom failed, errno %d\n", errno); + SPrint(prntBuf); + continue; + } + + if(strcmp(hbMsg, "REQ") == 0) + { + /* Send back the reply */ +#ifdef DEBUGP + sprintf(prntBuf,"watchDgRcvrActvTsk: Recvd HB REQ message from [%s:%d]\n", inet_ntoa(tmpaddr.sin_addr), ntohs(tmpaddr.sin_port)); + SPrint(prntBuf); +#endif /* DEBUGP */ + + strcpy(hbMsg, "RSP"); + sendto(osCp.wdCp.globWd.sock, hbMsg, strlen(hbMsg), 0, (struct sockaddr *)&tmpaddr, sizeof(tmpaddr)); + } + else if(strcmp(hbMsg, "RSP") == 0) + { + /* Got a HB RSP, set the status for the correcponding node */ +#ifdef DEBUGP + sprintf(prntBuf,"watchDgRcvrActvTsk: Recvd HB RSP message from [%s:%d]\n", inet_ntoa(tmpaddr.sin_addr), ntohs(tmpaddr.sin_port)); + SPrint(prntBuf); +#endif /* DEBUGP */ + + SLock(&osCp.wdCp.wdLock); + for(n = 0; n < osCp.wdCp.globWd.numNodes; n++) + { + if(osCp.wdCp.globWd.wdsta[n].addr.s_addr == tmpaddr.sin_addr.s_addr) + { + osCp.wdCp.globWd.wdsta[n].status = 1; + } + } + SUnlock(&osCp.wdCp.wdLock); + } + else + { +#ifdef DEBUGP + sprintf(prntBuf,"watchDgRcvrActvTsk: Rcvd invalid message\n"); + SPrint(prntBuf); +#endif /* DEBUGP */ + } + } + RETVALUE(ROK); +} + +#endif /* SS_WATCHDOG */ + +/* ss002.301 Modifications */ +#ifdef SS_THREAD_PROFILE +/* +* +* Fun: SGetThrdProf +* +* Desc: This function gets the current profile of a system task +* The function sets the Entity, Instance, Event and time taken +* for that thread to execurte the activate function of +* that entity. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: This function may be called by the OS or Layer 1 +* hardware drivers. +* +* File: mt_ss.c +* +*/ +#ifdef SS_MULTIPLE_PROCS +#ifdef ANSI +PUBLIC S16 SGetThrdProf +( +SSTskId *sTskId, +ProcId procId, +Ent ent, /* entity */ +Inst inst, +Event *curEvent, +U32 *curEvtTime, +U64 *totTime +) +#else +PUBLIC S16 SGetThrdProf(sTskId, procId, ent, inst, evnt, curEvent, curEvtTime, totTime) +SSTskId *sTskId; +ProcId procId; +Ent ent; /* entity */ +Inst inst; +Event *curEvent; +U32 *curEvtTime; +U64 *totTime; +#endif +#else +#ifdef ANSI +PUBLIC S16 SGetThrdProf +( +SSTskId *sTskId, +Ent ent, /* entity */ +Inst inst, +Event *curEvent, +U32 *curEvtTime, +U64 *totTime +) +#else +PUBLIC S16 SGetThrdProf(sTskId, ent, inst, curEvent,curEvtTime, totTime) +SSTskId *sTskId; +Ent ent; /* entity */ +Inst inst; +Event *curEvent; +U32 *curEvtTime; +U64 *totTime; +#endif +#endif /* SS_MULTIPLE_PROCS */ +{ + S16 ret; + SsIdx idx; + SsTTskEntry *tTsk; +#ifdef SS_MULTIPLE_PROCS + U16 procIdIdx; +#endif + + + TRC1(SGetThrdProf); + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check entity and instance range */ +#ifdef SS_MULTIPLE_PROCS + /* check proc, entity and instance range */ + if ((procId == SS_INV_PROCID) || (ent >= SS_MAX_ENT) || (inst >= SS_MAX_INST)) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS463, ERRZERO, "Invalid processor/entity/instance"); + RETVALUE(RFAILED); + } +#else /* SS_MULTIPLE_PROCS */ + /* check entity and instance range */ + if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS464, ERRZERO, "Invalid entity/instance"); + RETVALUE(RFAILED); + } +#endif /* SS_MULTIPLE_PROCS */ +#endif + + + ret = SLock(&osCp.sTskTblLock); + if (ret != ROK) + { + RETVALUE(RFAILED); + } + + +#ifdef SS_MULTIPLE_PROCS + procIdIdx = SGetProcIdIdx(procId); + + if (procIdIdx == SS_INV_PROCID_IDX) + { + RETVALUE(RFAILED); + } + + idx = osCp.tTskIds[procIdIdx][ent][inst]; +#else /* SS_MULTIPLE_PROCS */ + idx = osCp.tTskIds[ent][inst]; +#endif /* SS_MULTIPLE_PROCS */ + + tTsk = &osCp.tTskTbl[idx]; + if(tTsk == NULLP ) + { + SUnlock(&osCp.sTskTblLock); + RETVALUE(RFAILED); + } + *curEvent = osCp.tTskTbl[idx].curEvent; + *curEvtTime = osCp.tTskTbl[idx].curEvtTime; + *totTime = osCp.tTskTbl[idx].totTime; + *sTskId = osCp.tTskTbl[idx].sTsk->tskId; + + SUnlock(&osCp.sTskTblLock); + RETVALUE(ROK); +} +#endif /* SS_THREAD_PROFILE */ + +#ifdef SS_FBSED_TSK_REG +/* +* +* Fun: SRegTskInfo +* +* Desc: This function is used to register tasks based on cfg file. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* +* File: ss_task.c +* +*/ +#ifdef ANSI +PUBLIC S16 SRegTskInfo +( +U8 *cfgFile +) +#else +PUBLIC S16 SRegTskInfo(cfgFile) +U8 *cfgFile; +#endif +{ + return cmCfgrTskReg(cfgFile); +} +#endif /* SS_FBSED_TSK_REG */ + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/mt/ss_timer.c b/src/mt/ss_timer.c new file mode 100644 index 000000000..aa9e71f59 --- /dev/null +++ b/src/mt/ss_timer.c @@ -0,0 +1,1054 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/********************************************************************20** + + Name: System Services -- Timing + + Type: C source file + + Desc: Source code for System Services related to timing. + + File: ss_timer.c + +*********************************************************************21*/ + + +/* header include files (.h) */ + +#include "envopt.h" /* environment options */ +#include "envdep.h" /* environment dependent */ +#include "envind.h" /* environment independent */ + +#include "gen.h" /* general layer */ +#include "ssi.h" /* system services */ + +#include "ss_err.h" /* errors */ +#include "ss_dep.h" /* implementation-specific */ +#include "ss_queue.h" /* queues */ +#include "ss_msg.h" /* messaging */ +#include "ss_mem.h" /* memory management interface */ +#include "ss_gen.h" /* general */ +#include "cm_mem.h" /* memory management */ + + + +/* header/extern include files (.x) */ + +#include "gen.x" /* general layer */ +#include "ssi.x" /* system services */ + +#include "ss_dep.x" /* implementation-specific */ +#include "ss_queue.x" /* queues */ +#include "ss_task.x" /* tasking */ +#include "ss_timer.x" /* timers */ +#include "ss_strm.x" /* STREAMS */ +#include "ss_msg.x" /* messaging */ +#include "ss_mem.x" /* memory management interface */ +#include "ss_drvr.x" /* driver tasks */ +#ifdef SS_LOCKLESS_MEMORY +#include "cm_llist.x" +#include "cm_hash.x" +#include "cm_mem_wl.x" /* common memory manager */ +#else +#include "cm_mem.x" /* common memory manager */ +#endif /* SS_LOCKLESS_MEMORY */ +#include "ss_gen.x" /* general */ + + +/* Forward declarations */ + +/* ss041.103 Declaration for STmrRegHndlr */ +/* ss015.301 Changed the timer activation function type as all timer activation + * functions are enclosed in a union. + */ +#ifndef SS_MULTIPLE_PROCS +PRIVATE S16 STmrRegHndlr ARGS(( + Ent ent, + Inst inst, + S16 period, + S16 units, + SsTmrActvFn ssTmrActvFn + )); +/* ss015.301: Removed the timer handler prototypes guarded under SS_MT_TMR and + * handled mtFlag in existing timer handlers. + */ +#else /* SS_MULTIPLE_PROCS */ +PRIVATE S16 STmrRegHndlr ARGS(( + ProcId proc, + Ent ent, + Inst inst, + S16 period, + S16 units, + SsTmrActvFn ssTmrActvFn + )); +#endif /* SS_MULTIPLE_PROCS */ + +/* ss041.103 Declaration for STmrDeregHndlr */ +#ifndef SS_MULTIPLE_PROCS +PRIVATE S16 STmrDeregHndlr ARGS(( + Ent ent, + Inst inst, + S16 period, + S16 units, + SsTmrActvFn ssTmrActvFn + )); +/* ss015.301 Removed the timer handler prototypes guarded under SS_MT_TMR and + * handled mtFlag in existing timer handlers. + */ +#else /* SS_MULTIPLE_PROCS */ +PRIVATE S16 STmrDeregHndlr ARGS(( + ProcId proc, + Ent ent, + Inst inst, + S16 period, + S16 units, + SsTmrActvFn ssTmrActvFn + )); +#endif /* SS_MULTIPLE_PROCS */ + + + +/* ss028.103 - Modification for SRegCfgTmr Support */ +/* +* +* Fun: Register Configurable Timer Task - timer +* +* Desc: This function is used to register a timer function for the +* layer. The system services will periodically invoke the +* function passed to it. The timer function will be used by the +* layer to manage the layers internal protocol timers. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: +* +* File: ss_timer.c +* +*/ +/* ss029.103: addition: procId added and timer function type modified */ +#ifndef SS_MULTIPLE_PROCS +#ifdef ANSI +PUBLIC S16 SRegCfgTmr +( +Ent ent, /* entity */ +Inst inst, /* instance */ +S16 period, /* period */ +S16 units, /* period units */ +PFS16 tmrFnct /* timer function, typically SActvTmr */ +) +#else +PUBLIC S16 SRegCfgTmr(ent, inst, period, units, tmrFnct) +Ent ent; /* entity */ +Inst inst; /* instance */ +S16 period; /* period */ +S16 units; /* period units*/ +PFS16 tmrFnct; /* timer function, typically SActvTmr */ +#endif +{ + S16 ret; + /* ss015.301 - Enclosed all timer activation functions in a union. */ + SsTmrActvFn ssTmrActvFn; + /* ss041.103 - Moved handling to STmrRegHndlr */ + + TRC1(SRegCfgTmr); + + ssTmrActvFn.mtFlag = FALSE; + ssTmrActvFn.actvFnc.tmrActvFn = tmrFnct; + ret = STmrRegHndlr(ent, inst, period, units, ssTmrActvFn); + + RETVALUE(ret); +} + +#else /* SS_MULTIPLE_PROCS */ + +#ifdef ANSI +PUBLIC S16 SRegCfgTmr +( +ProcId proc, /* processor */ +Ent ent, /* entity */ +Inst inst, /* instance */ +S16 period, /* period */ +S16 units, /* period units */ +PAIFTMRS16 tmrFnct /* timer function, typically SActvTmr */ +) +#else +PUBLIC S16 SRegCfgTmr(proc, ent, inst, period, units, tmrFnct) +ProcId proc; /* processor */ +Ent ent; /* entity */ +Inst inst; /* instance */ +S16 period; /* period */ +S16 units; /* period units*/ +PAIFTMRS16 tmrFnct; /* timer function, typically SActvTmr */ +#endif + +{ + S16 ret; + /* ss015.301 - Enclosed all timer activation functions in a union. */ + SsTmrActvFn ssTmrActvFn; + /* ss041.103 - Moved handling to STmrRegHndlr */ + + TRC1(SRegCfgTmr); + + ssTmrActvFn.mtFlag = FALSE; + ssTmrActvFn.actvFnc.tmrActvFn = tmrFnct; + ret = STmrRegHndlr(proc, ent, inst, period, units, ssTmrActvFn); + + RETVALUE(ret); +} + +#endif /* SS_MULTIPLE_PROCS */ + + +#ifndef SS_MULTIPLE_PROCS +/* ss041.103 - New function for MT timer reg */ +#ifdef SS_MT_TMR +/* +* +* Fun: Register Configurable Timer Task - timer +* +* Desc: This function is used to register a timer function for the +* layer. The system services will periodically invoke the +* function passed to it. The timer function will be used by the +* layer to manage the layers internal protocol timers. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: By invoking this function, Ent and Inst are passed in the +* timer activation function. +* +* File: ss_timer.c +* +*/ +#ifdef ANSI +PUBLIC S16 SRegCfgTmrMt +( +Ent ent, /* entity */ +Inst inst, /* instance */ +S16 period, /* period */ +S16 units, /* period units */ +PAIFTMRS16 tmrFnctMt /* timer function, typically SActvTmr */ +) +#else +PUBLIC S16 SRegCfgTmrMt(ent, inst, period, units, tmrFnctMt) +Ent ent; /* entity */ +Inst inst; /* instance */ +S16 period; /* period */ +S16 units; /* period units*/ +PAIFTMRS16 tmrFnctMt; /* timer function, typically SActvTmr */ +#endif +{ + S16 ret; + /* ss015.301 - Enclosed all timer activation functions in a union. */ + SsTmrActvFn ssTmrActvFn; + + TRC1(SRegCfgTmrMt); + + ssTmrActvFn.actvFnc.tmrActvFnMt = tmrFnctMt; + ssTmrActvFn.mtFlag = TRUE; + ret = STmrRegHndlr(ent, inst, period, units, ssTmrActvFn); + + RETVALUE(ret); +} +#endif /* SS_MT_TMR */ +#endif /* not SS_MULTIPLE_PROCS */ + +/* ss041.103 - Function for timer registration handling */ +/* +* +* Fun: Timer registration handler function +* +* Desc: This function is called by the timer registration interface +* functions, and does the actual handling for timer +* registration. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* ROUTRES - failed, out of resources (optional) +* +* Notes: +* +* File: ss_timer.c +* +*/ + +/* ss015.301 Changed the timer activation function type as all timer activation + * functions are enclosed in a union. + */ + +#ifndef SS_MULTIPLE_PROCS + +#ifdef ANSI +PRIVATE S16 STmrRegHndlr +( +Ent ent, /* entity */ +Inst inst, /* instance */ +S16 period, /* period */ +S16 units, /* period units */ +SsTmrActvFn ssTmrActvFn /* timer function, typically SActvTmr */ +) +#else +PRIVATE S16 STmrRegHndlr(ent, inst, period, units, ssTmrActvFn) +Ent ent; /* entity */ +Inst inst; /* instance */ +S16 period; /* period */ +S16 units; /* period units*/ +SsTmrActvFn ssTmrActvFn; /* timer function, typically SActvTmr */ +#endif +/* ss015.301: Removed the timer handler prototypes guarded + * under SS_MT_TMR and handled mtFlag in existing timer handlers. + */ + +#else /* SS_MULTIPLE_PROCS */ + +#ifdef ANSI +PRIVATE S16 STmrRegHndlr +( +ProcId proc, /* processor */ +Ent ent, /* entity */ +Inst inst, /* instance */ +S16 period, /* period */ +S16 units, /* period units */ +SsTmrActvFn ssTmrActvFn /* timer function */ +) +#else +PRIVATE S16 STmrRegHndlr(proc, ent, inst, period, units, ssTmrActvFn) +ProcId proc; /* processor */ +Ent ent; /* entity */ +Inst inst; /* instance */ +S16 period; /* period */ +S16 units; /* period units*/ +SsTmrActvFn ssTmrActvFn; /* timer function */ +#endif + +#endif /* SS_MULTIPLE_PROCS */ +{ +#if (ERRCLASS & ERRCLS_INT_PAR) + U8 i; +#endif + S16 ret; + SsTmrEntry *tmr; +#ifdef SS_MULTIPLE_PROCS +#if (ERRCLASS & ERRCLS_INT_PAR) + U16 procIdIdx; +#endif /* ERRCLASS & ERRCLS_INT_PAR */ +#endif /* SS_MULTPLE_PROCS */ + + TRC1(STmrRegHndlr); + +#if (ERRCLASS & ERRCLS_INT_PAR) + +#ifdef SS_MULTIPLE_PROCS + if ((proc == SS_INV_PROCID) || (ent >= SS_MAX_ENT) || (inst >= SS_MAX_INST)) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS528, ERRZERO, "Invalid processor/entity/instance"); + RETVALUE(RFAILED); + } +#else /* SS_MULTIPLE_PROCS */ + if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS529, ERRZERO, "Invalid entity/instance"); + RETVALUE(RFAILED); + } +#endif /* SS_MULTIPLE_PROCS */ + + /* check period */ + if (period <= 0) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS530, ERRZERO, "Invalid period"); + RETVALUE(RFAILED); + } + + /* check period units*/ + if ((units < 1) || (units > SS_TICKS_SEC)) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS531, ERRZERO, "Invalid period units"); + RETVALUE(RFAILED); + } + + if(ssTmrActvFn.mtFlag == TRUE) + { + /* ss015.301 Enclosed all timer activation functions in a union. */ +#ifndef SS_MULTIPLE_PROCS +#ifdef SS_MT_TMR + if (ssTmrActvFn.actvFnc.tmrActvFnMt == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS532, ERRZERO, "Null pointer"); + RETVALUE(RFAILED); + } +#else + RETVALUE(RFAILED); +#endif +#else + RETVALUE(RFAILED); +#endif + } + else + { + if (ssTmrActvFn.actvFnc.tmrActvFn == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS532, ERRZERO, "Null pointer"); + RETVALUE(RFAILED); + } + } + +#ifdef SS_MULTIPLE_PROCS + /* check if the procId has been registered with SSI */ + procIdIdx = SGetProcIdIdx(proc); + + if (procIdIdx == SS_INV_PROCID_IDX) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS533, ERRZERO, + "Could not find proc id index"); + RETVALUE(RFAILED); + } +#endif /* SS_MULTIPLE_PROCS */ + + + /* check task ID */ + /* lock TAPA task table */ + SS_ACQUIRE_SEMA(&osCp.tTskTblSem, ret); + if (ret != ROK) + { + SSLOGERROR(ERRCLS_DEBUG, ESS534, ERRZERO, + "Could not lock TAPA task table"); + RETVALUE(RFAILED); + } + +#ifdef SS_MULTIPLE_PROCS + if (osCp.tTskIds[procIdIdx][ent][inst] == SS_TSKNC) +#else /* SS_MULTIPLE_PROCS */ + if (osCp.tTskIds[ent][inst] == SS_TSKNC) +#endif /* SS_MULTIPLE_PROCS */ + { + if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS535, ERRZERO, + "Could not release the semaphore"); + RETVALUE(RFAILED); +#endif + } + SSLOGERROR(ERRCLS_INT_PAR, ESS536, ERRZERO, "Unknown task"); + RETVALUE(RFAILED); + } + if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS537, ERRZERO, + "Could not release the semaphore"); + RETVALUE(RFAILED); +#endif + } + +#endif + + /* lock the timer table */ + ret = SLock(&osCp.tmrTblLock); + if (ret != ROK) + { + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS538, (ErrVal) ret, + "Could not lock timer table"); +#endif + RETVALUE(ret); + } + + + /* check if we've got room for another timer */ + if (osCp.numTmrs == SS_MAX_TMRS) + { + if ( SUnlock(&osCp.tmrTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS539, ERRZERO, + "Could not unlock the semaphore"); + RETVALUE(RFAILED); +#endif + } + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS540, ERRZERO, "Too many timers"); +#endif + + RETVALUE(ROUTRES); + } + +#if (ERRCLASS & ERRCLS_INT_PAR) + /* check through the timer table for a matching timer entry */ + for (i = 0; i < SS_MAX_TMRS; i++) + { + if ((osCp.tmrTbl[i].ownerEnt == ent) +#ifdef SS_MULTIPLE_PROCS + && (osCp.tmrTbl[i].ownerProc == proc) +#endif /* SS_MULTIPLE_PROCS */ + && (osCp.tmrTbl[i].ownerInst == inst) + /* ss041.103 - Added mtFlag check */ + /* ss015.301 Enclosed all timer activation functions in a union. */ +#ifndef SS_MULTIPLE_PROCS +#ifdef SS_MT_TMR + && (osCp.tmrTbl[i].ssTmrActvFn.mtFlag == ssTmrActvFn.mtFlag) + && ((ssTmrActvFn.mtFlag == FALSE + && osCp.tmrTbl[i].ssTmrActvFn.actvFnc.tmrActvFn == ssTmrActvFn.actvFnc.tmrActvFn) + || osCp.tmrTbl[i].ssTmrActvFn.actvFnc.tmrActvFnMt == ssTmrActvFn.actvFnc.tmrActvFnMt) +#else + && (osCp.tmrTbl[i].ssTmrActvFn.actvFnc.tmrActvFn == ssTmrActvFn.actvFnc.tmrActvFn) +#endif +#else + && (osCp.tmrTbl[i].ssTmrActvFn.actvFnc.tmrActvFn == ssTmrActvFn.actvFnc.tmrActvFn) +#endif + && (osCp.tmrTbl[i].interval == (U32) ((period * SS_TICKS_SEC) / units))) + { + /* is this timer in use ? (unexpired) */ + if (osCp.tmrTbl[i].used == TRUE) + { + /* to prevent the same timer to be registered with SS UNLOCK and */ + /* then RFAIL */ + if (SUnlock(&osCp.tmrTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS541, ERRZERO, "Could not unlock the semaphore"); + RETVALUE(RFAILED); +#endif + } + RETVALUE(RFAILED); + } + } + } +#endif + + /* fill in the information we have into the timer entry */ + tmr = &osCp.tmrTbl[osCp.nxtTmrEntry]; + tmr->tmrId = osCp.nxtTmrEntry; +#ifdef SS_MULTIPLE_PROCS + tmr->ownerProc = proc; +#endif /* SS_MULTIPLE_PROCS */ + tmr->ownerEnt = ent; + tmr->ownerInst = inst; + tmr->interval = (U32) ((period * SS_TICKS_SEC) / units); + tmr->ssTmrActvFn.mtFlag = ssTmrActvFn.mtFlag; + + /* ss041.103 */ + /* ss015.301 Enclosed all timer activation functions in a union. */ +#ifndef SS_MULTIPLE_PROCS +#ifdef SS_MT_TMR + if (ssTmrActvFn.mtFlag == TRUE) + { + tmr->ssTmrActvFn.actvFnc.tmrActvFnMt = ssTmrActvFn.actvFnc.tmrActvFnMt; + } + else +#endif +#endif + { + tmr->ssTmrActvFn.actvFnc.tmrActvFn = ssTmrActvFn.actvFnc.tmrActvFn; + } + + + /* ask the implementation to start the timer */ + ret = ssdRegTmr(tmr); + if (ret != ROK) + { + tmr->tmrId = 0; +#ifdef SS_MULTIPLE_PROCS + tmr->ownerProc = PROCNC; +#endif /* SS_MULTIPLE_PROCS */ + tmr->ownerEnt = ENTNC; + tmr->ownerInst = INSTNC; + tmr->interval = 0; + /* ss015.301 Enclosed all timer activation functions in a union. */ + tmr->ssTmrActvFn.mtFlag = FALSE; + tmr->ssTmrActvFn.actvFnc.tmrActvFn = NULLP; +#ifndef SS_MULTIPLE_PROCS +#ifdef SS_MT_TMR + tmr->ssTmrActvFn.actvFnc.tmrActvFnMt = NULLP; +#endif +#endif + } + else + { + tmr->used = TRUE; + osCp.nxtTmrEntry = tmr->nxt; + osCp.numTmrs++; + } + + + /* unlock the timer table */ + if ( SUnlock(&osCp.tmrTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS542, ERRZERO, + "Could not unlock the semaphore"); + RETVALUE(RFAILED); +#endif + } + + RETVALUE(ret); +} + + + +/* +* +* Fun: SDeregCfgTmr +* +* Desc: This function is used to deregister a timer function. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: +* +* File: ss_timer.c +* +*/ +/* ss029.103: addition: procId added and timer function type modified */ +#ifndef SS_MULTIPLE_PROCS + +#ifdef ANSI +PUBLIC S16 SDeregCfgTmr +( +Ent ent, /* entity */ +Inst inst, /* instance */ +S16 period, /* period */ +S16 units, /* period units */ +PFS16 tmrFnct /* timer function */ +) +#else +PUBLIC S16 SDeregCfgTmr(ent, inst, period, units, tmrFnct) +Ent ent; /* entity */ +Inst inst; /* instance */ +S16 period; /* period */ +S16 units; /* period units*/ +PFS16 tmrFnct; /* timer function */ +#endif +{ + S16 ret; + /* ss015.301 Enclosed all timer activation functions in a union. */ + SsTmrActvFn ssTmrActvFn; + /* ss041.103 - Moved handling to STmrDeregHndlr */ + + TRC1(SDeregCfgTmr); + + ssTmrActvFn.mtFlag = FALSE; + ssTmrActvFn.actvFnc.tmrActvFn = tmrFnct; + ret = STmrDeregHndlr(ent, inst, period, units, ssTmrActvFn); + + RETVALUE(ret); +} + +#else /* SS_MULTIPLE_PROCS */ + +#ifdef ANSI +PUBLIC S16 SDeregCfgTmr +( +ProcId proc, /* processor */ +Ent ent, /* entity */ +Inst inst, /* instance */ +S16 period, /* period */ +S16 units, /* period units */ +PAIFTMRS16 tmrFnct /* timer function */ +) +#else +PUBLIC S16 SDeregCfgTmr(proc, ent, inst, period, units, tmrFnct) +ProcId proc; /* processor */ +Ent ent; /* entity */ +Inst inst; /* instance */ +S16 period; /* period */ +S16 units; /* period units*/ +PAIFTMRS16 tmrFnct; /* timer function */ +#endif +{ + S16 ret; + /* ss015.301 Enclosed all timer activation functions in a union. */ + SsTmrActvFn ssTmrActvFn; + + /* ss041.103 - Moved handling to STmrDeregHndlr */ + + TRC1(SDeregCfgTmr); + + ssTmrActvFn.mtFlag = FALSE; + ssTmrActvFn.actvFnc.tmrActvFn = tmrFnct; + ret = STmrDeregHndlr(proc, ent, inst, period, units, ssTmrActvFn); + + RETVALUE(ret); +} + +#endif /* SS_MULTIPLE_PROCS */ + + +/* ss041.103 - Addition to support MT timer dereg */ +#ifndef SS_MULTIPLE_PROCS +#ifdef SS_MT_TMR +/* +* +* Fun: SDeregCfgTmrMt +* +* Desc: This function is used to deregister an MT timer function. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: +* +* File: ss_timer.c +* +*/ +#ifdef ANSI +PUBLIC S16 SDeregCfgTmrMt +( +Ent ent, /* entity */ +Inst inst, /* instance */ +S16 period, /* period */ +S16 units, /* period units */ +PAIFTMRS16 tmrFnctMt /* timer function */ +) +#else +PUBLIC S16 SDeregCfgTmrMt(ent, inst, period, units, tmrFnctMt) +Ent ent; /* entity */ +Inst inst; /* instance */ +S16 period; /* period */ +S16 units; /* period units*/ +PAIFTMRS16 tmrFnctMt; /* timer function */ +#endif +{ + S16 ret; + /* ss015.301 Enclosed all timer activation functions in a union. */ + SsTmrActvFn ssTmrActvFn; + + TRC1(SDeregCfgTmrMt); + + ssTmrActvFn.actvFnc.tmrActvFnMt = tmrFnctMt; + ssTmrActvFn.mtFlag = TRUE; + + ret = STmrDeregHndlr(ent, inst, period, units, ssTmrActvFn); + + RETVALUE(ret); +} +#endif /* SS_MT_TMR */ +#endif /* not SS_MULTIPLE_PROCS */ + + +/* ss041.103 - Addition of STmrDeregHndlr */ +/* +* +* Fun: STmrDeregHndlr +* +* Desc: This function is used to deregister a timer function. +* +* Ret: ROK - ok +* RFAILED - failed, general (optional) +* +* Notes: +* +* File: ss_timer.c +* +*/ +/* ss029.103: addition: procId added and timer function type modified */ + +/* ss015.301 Changed the timer activation function type as all timer activation + * functions are enclosed in a union. + */ +#ifndef SS_MULTIPLE_PROCS +#ifdef ANSI +PRIVATE S16 STmrDeregHndlr +( +Ent ent, /* entity */ +Inst inst, /* instance */ +S16 period, /* period */ +S16 units, /* period units */ +SsTmrActvFn ssTmrActvFn /* timer function */ +) +#else +/* ss017.301: Modified the prototype of STmrDeregHndlr for Non-ANSI + * compilation. + */ +PRIVATE S16 STmrDeregHndlr(ent, inst, period, units, ssTmrActvFn) +Ent ent; /* entity */ +Inst inst; /* instance */ +S16 period; /* period */ +S16 units; /* period units*/ +SsTmrActvFn ssTmrActvFn; /* timer function */ +#endif +/* ss015.301: Removed the timer handler prototypes guarded under SS_MT_TMR + * and handled mtFlag in existing timer handlers. + */ + +#else /* SS_MULTIPLE_PROCS */ + +#ifdef ANSI +PRIVATE S16 STmrDeregHndlr +( +ProcId proc, /* processor */ +Ent ent, /* entity */ +Inst inst, /* instance */ +S16 period, /* period */ +S16 units, /* period units */ +SsTmrActvFn ssTmrActvFn /* timer function */ +) +#else +PRIVATE S16 STmrDeregHndlr(proc, ent, inst, period, units, ssTmrActvFn) +ProcId proc; /* processor */ +Ent ent; /* entity */ +Inst inst; /* instance */ +S16 period; /* period */ +S16 units; /* period units*/ +SsTmrActvFn ssTmrActvFn; /* timer function */ +#endif + +#endif /* SS_MULTIPLE_PROCS */ +{ + S16 ret; + S16 idx; + SsTmrEntry *tmr; +#ifdef SS_MULTIPLE_PROCS +#if (ERRCLASS & ERRCLS_INT_PAR) + U16 procIdIdx; +#endif /* ERRCLASS & ERRCLS_INT_PAR */ +#endif /* SS_MULTIPLE_PROCS */ + + + TRC1(STmrDeregHndlr); + + +#if (ERRCLASS & ERRCLS_INT_PAR) + +#ifdef SS_MULTIPLE_PROCS + if ((proc == SS_INV_PROCID) || (ent >= SS_MAX_ENT) || (inst >= SS_MAX_INST)) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS543, ERRZERO, "Invalid processor/entity/instance"); + RETVALUE(RFAILED); + } + +#else /* SS_MULTIPLE_PROCS */ + if (ent >= SS_MAX_ENT || inst >= SS_MAX_INST) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS544, ERRZERO, "Invalid entity/instance"); + RETVALUE(RFAILED); + } +#endif /* SS_MULTIPLE_PROCS */ + /* check period */ + if (period <= 0) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS545, ERRZERO, "Invalid period"); + RETVALUE(RFAILED); + } + + /* check period units */ + if ((units < 1) || (units > SS_TICKS_SEC)) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS546, ERRZERO, "Invalid period units"); + RETVALUE(RFAILED); + } + + /* check timer function */ + if(ssTmrActvFn.mtFlag == TRUE) + { +#ifndef SS_MULTIPLE_PROCS +#ifdef SS_MT_TMR + if (ssTmrActvFn.actvFnc.tmrActvFnMt == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS547, ERRZERO, "Null pointer"); + RETVALUE(RFAILED); + } +#else + RETVALUE(RFAILED); +#endif +#else + RETVALUE(RFAILED); +#endif + + } + else + { + if (ssTmrActvFn.actvFnc.tmrActvFn == NULLP) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS547, ERRZERO, "Null pointer"); + RETVALUE(RFAILED); + } + } + +#ifdef SS_MULTIPLE_PROCS + /* check if the procId has been registered with SSI */ + procIdIdx = SGetProcIdIdx(proc); + + if (procIdIdx == SS_INV_PROCID_IDX) + { + SSLOGERROR(ERRCLS_INT_PAR, ESS548, ERRZERO, + "Could not find proc id index"); + RETVALUE(RFAILED); + } +#endif /* SS_MULTIPLE_PROCS */ + + /* check task ID */ + /* lock TAPA task table */ + SS_ACQUIRE_SEMA(&osCp.tTskTblSem, ret); + if (ret != ROK) + { + SSLOGERROR(ERRCLS_DEBUG, ESS549, ERRZERO, + "Could not lock TAPA task table"); + RETVALUE(RFAILED); + } + +#ifdef SS_MULTIPLE_PROCS + if (osCp.tTskIds[procIdIdx][ent][inst] == SS_TSKNC) +#else /* SS_MULTIPLE_PROCS */ + if (osCp.tTskIds[ent][inst] == SS_TSKNC) +#endif /* SS_MULTIPLE_PROCS */ + { + if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS550, ERRZERO, + "Could not release the semaphore"); + RETVALUE(RFAILED); +#endif + } + SSLOGERROR(ERRCLS_INT_PAR, ESS551, ERRZERO, "Unknown task"); + RETVALUE(RFAILED); + } + if ( SS_RELEASE_SEMA(&osCp.tTskTblSem) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS552, ERRZERO, + "Could not release the semaphore"); + RETVALUE(RFAILED); +#endif + } + +#endif + + /* lock the timer table */ + ret = SLock(&osCp.tmrTblLock); + if (ret != ROK) + { + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS553, (ErrVal) ret, + "Could not lock timer table"); +#endif + RETVALUE(ret); + } + + + /* Note: Right now, we're using ent, inst and tmrActvFn to locate + * the timer,, this will change to using tmrId, some day. + */ + + /* locate the timer to delete in the timer table */ + for (idx = 0; idx < SS_MAX_TMRS; idx++) + { + /* ss021.103 - Modification find timer by ent, inst, func, and period */ + /* ss029.103: addition: multiple procId related changes */ + if (osCp.tmrTbl[idx].ownerEnt == ent +#ifdef SS_MULTIPLE_PROCS + && osCp.tmrTbl[idx].ownerProc == proc +#endif /* SS_MULTIPLE_PROCS */ + && osCp.tmrTbl[idx].ownerInst == inst +#ifndef SS_MULTIPLE_PROCS +#ifdef SS_MT_TMR + /* + * ss015.301 - Modifed as timer activation functions + * enclosed in a union. + */ + && osCp.tmrTbl[idx].ssTmrActvFn.mtFlag == ssTmrActvFn.mtFlag + && ((ssTmrActvFn.mtFlag == FALSE + && osCp.tmrTbl[idx].ssTmrActvFn.actvFnc.tmrActvFn == ssTmrActvFn.actvFnc.tmrActvFn) + || osCp.tmrTbl[idx].ssTmrActvFn.actvFnc.tmrActvFnMt == ssTmrActvFn.actvFnc.tmrActvFnMt) +#else + && osCp.tmrTbl[idx].ssTmrActvFn.actvFnc.tmrActvFn == ssTmrActvFn.actvFnc.tmrActvFn +#endif +#else + && osCp.tmrTbl[idx].ssTmrActvFn.actvFnc.tmrActvFn == ssTmrActvFn.actvFnc.tmrActvFn +#endif + && osCp.tmrTbl[idx].interval == (U32) ((period * SS_TICKS_SEC) / units)) + { + break; + } + } + + if (idx == SS_MAX_TMRS) + { + if ( SUnlock(&osCp.tmrTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS554, ERRZERO, + "Could not unlock the semaphore"); + RETVALUE(RFAILED); +#endif + } + +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS555, ERRZERO, "Could not locate timer"); +#endif + + RETVALUE(RFAILED); + } + + + /* ask the implementation to shut down this timer */ + tmr = &osCp.tmrTbl[idx]; + ret = ssdDeregTmr(tmr); + if (ret == ROK) + { + tmr->used = FALSE; + tmr->tmrId = 0; +#ifdef SS_MULTIPLE_PROCS + tmr->ownerProc = PROCNC; +#endif /* SS_MULTIPLE_PROCS */ + tmr->ownerEnt = ENTNC; + tmr->ownerInst = INSTNC; + tmr->interval = 0; + /* + * ss015.301: Modifed as timer activation functions enclosed in a union. + */ + tmr->ssTmrActvFn.mtFlag = FALSE; + tmr->ssTmrActvFn.actvFnc.tmrActvFn = NULLP; +#ifndef SS_MULTIPLE_PROCS +#ifdef SS_MT_TMR + tmr->ssTmrActvFn.actvFnc.tmrActvFnMt = NULLP; +#endif +#endif + + tmr->nxt = osCp.nxtTmrEntry; + osCp.nxtTmrEntry = (SsIdx)idx; + osCp.numTmrs--; + } + + + /* unlock the timer table */ + if ( SUnlock(&osCp.tmrTblLock) != ROK) + { +#if (ERRCLASS & ERRCLS_DEBUG) + SSLOGERROR(ERRCLS_DEBUG, ESS556, ERRZERO, + "Could not unlock the semaphore"); + RETVALUE(RFAILED); +#endif + } + + + RETVALUE(ret); +} + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/phy_stub/.l1_bdy1.c.swo b/src/phy_stub/.l1_bdy1.c.swo new file mode 100644 index 0000000000000000000000000000000000000000..8fee77f52098ad9bebe3f56e5338abdd29de5aa0 GIT binary patch literal 12288 zcmeI2&1(}u7>B1lTNV8WrYXXvq)E0?6-A*RX&Ox1n2%zqW!daZHjA6tbU&i8*j_yg z7D4cT5ft(0$&+~SqF0Yz^tYR|DORxO`VM)r%)2}9yzeu&WSjYo(kj26%`=RPjERG1 z+i$--ANyQjtnHd^9RAk`rE1PJU6I$bzA2obA7m}Bb8^*QoG>?6T&o&OvS(PHkhwWq z`G(h(D)1uTlDWXQl32Ih55lOKb9JLB`g+znnT{f4fDD}0KoquSZcH?;&g%K8)Fi)r zsd3ts^c)!=17v^U2WPl8i0Wv@a$N(82 z17v^7a02n-h+4G4cG^JpaZtRCb$nWU>f{9 z&)6sM5xfR3!2x&yEMS5)Py%T%4t`+IuizEf2TwpB*dVFrj5ww?$N(8217v^T-cWt{VBp}sL+ZWOfY`rY&`7Kf5Jt{9`c%k!mjVF^zp@%XFjJ1T5xsRyd0 zdZz0L-jP9I+LDL;uH3rvc$@pul1@(wZic+FvYE>8PGHw@_b88$Ei-b%o1?T%Uz!h( zZR6@IO1O)jYB_dQ?r6wRmMY0~l*KXw$yaMdqrO=w7>ny`%cY`GE!<1e?#8);M^0$9 zmb3TsVF^BInhwq%ATpH4#r xCS|=mdvqd$=**qA@UsJJgMLw34OUM!dtB+1qbxTPlBayzuv`N#*k{`*_8U091r-1Q literal 0 HcmV?d00001 diff --git a/src/phy_stub/.l1_bdy1.c.swp b/src/phy_stub/.l1_bdy1.c.swp new file mode 100644 index 0000000000000000000000000000000000000000..092d2521f5f4c61a5c9044af881b6eb1e8710f0c GIT binary patch literal 12288 zcmeI2&1=*^7>B2VC#{MeyiQY;t+cxvrBxIU{n&07`>`gwg`zcPGm~s^I!W`fx|DkG zq6eiQh=?b>>%smDiYS8MS@5cVgy@^;cDGnjdM)q3vmuk@H}Cu8lua7N#mXE#pDz*^ z#|XK<@nHGwx5s^74-?W9w#cUcHxe!zBMrfddOot5AGhPY6RhmM>TVWT7%k5m))a49 zPQZ9!)RU1Fgj~i!8accWM~<2co9%+otp;oBd1rSN&Y%G_uonYq;*MPCub(@s7YDTg zdg6F}FIVHaXaEhM0W^RH&;S}h184vZ>;nTy*hhXr9|r&p=<5I*9B2RypaC?12G9T+ zKm%w14WI!ufCkXOJ~3c3LVm)#{%8Hr5WN4-{sZ`Nl#uVhd*B_g3A_Pb0xy6K;1Tc; zxCz_<^1vbBAn@e~A)kPczz5(d@C3LAtOLuy7;qXm34DgNH-Xo{E8sbx>e(lbu?;kU z2G9T+Km%w14WI!ufCkXOKMkxCN~uw*EsoFDOF3iV%Frc}O{sagC zRk3SXc6{4UoMv{hTAr+tR*+R}JGG$NZ0G9w*miBh6h2|icGNQJv@@_b1W%T#%C4TC zfN9$o(51;G^QA`}RV;KLhk=Z_)~Qn!LVY(U^a;VnB{L$g zYzy3qOd~t-0}08iDUXvZxYNj=mOB0Xy@lRg?cQ^!$}IE5oJd`06oi@8RPANT)G{U* b+FkfgJ%hecarrierId; + SPutSBuf(0, 0, (Data *)msg, FAPIConfigReq->hdr.msgLen); + + if(SGetSBuf(0, 0, (Data **)&FAPIConfigRsp, sizeof(L1L2ConfigRsp)) != ROK) + { + printf("\nMemory allocation failed for PHY Config Response"); + RETVALUE(RFAILED); + } + + FAPIConfigRsp->hdr.nMsg = 1; + FAPIConfigRsp->hdr.msgType = MSG_TYPE_CONFIG_RSP; + FAPIConfigRsp->hdr.msgLen = sizeof(L1L2ConfigRsp); + + FAPIConfigRsp->carrierId = cci; + FAPIConfigRsp->status = MSG_OK; + FAPIConfigRsp->numUnsuppTlv = 0; + FAPIConfigRsp->unsuppTlvLst = NULLP; + FAPIConfigRsp->numInvTlvForPhySta = 0; + FAPIConfigRsp->phyIdleCfgTlvLst = NULLP; + FAPIConfigRsp->phyRunCfgTlvLst = NULLP; + FAPIConfigRsp->numMissingTlv = 0; + FAPIConfigRsp->missingTlvLst = NULLP; + + phyToMac(MSG_TYPE_CONFIG_RSP, sizeof(L1L2ConfigRsp), FAPIConfigRsp); + + RETVALUE(ROK); +} + +/******************************************************************* + * + * @brief Handles config request received from MAC + * + * @details + * + * Function : l1HndlConfigReq + * + * Functionality: + * -Handles config request received from MAC + * + * @params[in] Message length + * Config request message pointer + * + * @return void + * + * ****************************************************************/ + +void l1HndlConfigReq(U16 msgLen, void *msg) +{ + printf("\nReceived configuration request"); + + /* TO DO : validate all received TLVs and send back any unsupported/missing TLV */ + + if(l1BldAndSndCfgRsp(msg) != ROK) + { + printf("\nFailed Sending config response"); + } +} + +/******************************************************************* + * + * @brief Receives message from MAC + * + * @details + * + * Function : macToPhy + * + * Functionality: + * - Receives message from MAC and calls handler + * + * @params[in] Message type + * Message length + * Message pointer + * + * @return void + * + * ****************************************************************/ + +void macToPhy(U16 msgType, U32 msgLen, void *msg) +{ + switch(msgType) + { + case MSG_TYPE_CONFIG_REQ: + l1HndlConfigReq(msgLen, msg); + break; + default: + printf("\nInvalid message type[%x] received at PHY", msgType); + } + +} + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/rlog/rl_common.c b/src/rlog/rl_common.c new file mode 100644 index 000000000..6e1c530f0 --- /dev/null +++ b/src/rlog/rl_common.c @@ -0,0 +1,70 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/********************************************************************20** + + Name: Radisys Logging Framework + Type: C source file + Desc: This file contains logging framework implementation. + File: rl_common.c + +*********************************************************************21*/ +/**************************************************************************** +@ description: This is common source file for postprocessor and log library. +*****************************************************************************/ + +#include +#include "rl_common.h" + +/* String representation of Log Levels */ +const char* g_logStr[L_MAX_LOG_LEVEL] = +{ + "ALWAYS", + "FATAL", + "ERROR", + "WARNING", + "EVENT", + "INFO", + "DEBUG" +}; + +const char* g_splStr[DBG_MAX_IDs] = +{ + "CELLID", + "PEERID", + "ENBID", + "MME", + "CRNTI", + "UEIDX", + "UEID", + "RBID", + "LCID", + "LCGID", + "TRNSID" +}; + +void hextostr(char* p, PSTR h, int hexlen) +{ + int i; + for(i=0; i extern FILE* g_fp; void logLev0(PSTR strLogLevel, PSTR modName, PSTR file, int lineno, PSTR fmtStr, ...); @@ -91,6 +92,17 @@ void logLevE(PSTR strLogLevel, PSTR modName, PSTR file, int lineno, PSTR fmtStr, U32 splVal, U32 arg1, U32 arg2, U32 arg3, U32 arg4, ...); void logLevH(PSTR strLogLevel, PSTR modName, PSTR file, int lineno, PSTR fmtStr, PSTR hexdump, int hexlen, ...); void logLevS(PSTR strLogLevel, PSTR modName, PSTR file, int lineno, PSTR fmtStr, PSTR str, ...); +#else +void logLevH( LOGID logId, R_LOG_LEVEL logLevel, PSTR hex, int hexlen, ...); +void logLev0( LOGID logId, R_LOG_LEVEL logLevel, ...); +void logLev1( LOGID logId, R_LOG_LEVEL logLevel, U32 arg1, ...); +void logLev2( LOGID logId, R_LOG_LEVEL logLevel, U32 arg1, U32 arg2, ...); +void logLev3( LOGID logId, R_LOG_LEVEL logLevel, U32 arg1, U32 arg2, U32 arg3, ...); +void logLev4( LOGID logId, R_LOG_LEVEL logLevel, U32 arg1, U32 arg2, U32 arg3, U32 arg4, ...); +void logLevE(LOGID logId, R_LOG_LEVEL logLevel, R_SPL_ARG splType, U32 splVal, +U32 arg1, U32 arg2, U32 arg3, U32 arg4, ...); +void logLevS( LOGID logId, R_LOG_LEVEL logLevel, const char* str, ...); +#endif void hextostr(char* p, PSTR h, int hexlen); diff --git a/src/rlog/rl_interface.h b/src/rlog/rl_interface.h index 925ab5f23..54ae4a5a9 100755 --- a/src/rlog/rl_interface.h +++ b/src/rlog/rl_interface.h @@ -132,6 +132,8 @@ extern void rlStopLogCountLimit(void); #else +#if defined(RLOG_ENABLE_TEXT_LOGGING) + #define FMTSTR "[%d-%d-%d %d:%d:%d.%03d][%s]%s:%d\n%s:" #define FMTSTR_S "[%d-%d-%d %d:%d:%d.%03d][%s]%s:%d\n%s:%s:%ld:" @@ -165,6 +167,33 @@ if( _level < g_logLevel || g_modMask & RLOG_MODULE_ID)\ #define RLOG3(_level, _lstr, _arg1, _arg2, _arg3) LOG_ARGN(3, _level, _lstr, _arg1, _arg2, _arg3) #define RLOG4(_level, _lstr, _arg1, _arg2, _arg3, _arg4)LOG_ARGN(4, _level, _lstr, _arg1, _arg2, _arg3, _arg4) +#else /* BINARY LOGGING */ + +#define LOG_ARG0(_level, _fmtStr) \ +if( _level < g_logLevel || g_modMask & RLOG_MODULE_ID)\ +{ \ + logLev0(_LOGID, _level, __FILE__,__LINE__, _fmtStr, RLOG_FILE_ID, RLOG_MODULE_NAME); \ +} + +#define LOG_ARGN(_N, _level, _fmtStr, ...) \ +if( _level < g_logLevel || g_modMask & RLOG_MODULE_ID)\ +{ \ + logLev##_N(_LOGID, _level, ##__VA_ARGS__, __FILE__,__LINE__, _fmtStr, RLOG_FILE_ID, RLOG_MODULE_NAME); \ +} + +#define LOG_SPL(_level, _splenum, _splArg, _fmtStr, ...) \ +if( _level < g_logLevel || g_modMask & RLOG_MODULE_ID)\ +{ \ + logLevE(_LOGID,_level,_splenum, _splArg, ##__VA_ARGS__, __FILE__,__LINE__, _fmtStr, RLOG_FILE_ID, RLOG_MODULE_NAME); \ +} + +#define RLOG0(_level, _lstr) LOG_ARG0(_level, _lstr) +#define RLOG1(_level, _lstr, _arg1) LOG_ARGN(1, _level, _lstr, _arg1) +#define RLOG2(_level, _lstr, _arg1, _arg2) LOG_ARGN(2, _level, _lstr, _arg1, _arg2) +#define RLOG3(_level, _lstr, _arg1, _arg2, _arg3) LOG_ARGN(3, _level, _lstr, _arg1, _arg2, _arg3) +#define RLOG4(_level, _lstr, _arg1, _arg2, _arg3, _arg4)LOG_ARGN(4, _level, _lstr, _arg1, _arg2, _arg3, _arg4) + +#endif /* if defined(RLOG_ENABLE_TEXT_LOGGING) */ #define RLOG_STR(_level, _lstr, _strarg) LOG_ARGN(S, _level, _lstr, _strarg) #define RLOG_HEX(_level, _lstr, _hexdata, _hexlen) LOG_ARGN(H, _level, _lstr, _hexdata, _hexlen) diff --git a/src/rlog/rl_platform.c b/src/rlog/rl_platform.c new file mode 100644 index 000000000..3c8bcf280 --- /dev/null +++ b/src/rlog/rl_platform.c @@ -0,0 +1,126 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/********************************************************************20** + + Name: Radisys Logging Framework + Type: C source file + Desc: This file contains logging framework implementation. + File: rl_rlog.c + +*********************************************************************21*/ +/************************************************************************** +@ description: This is source file which has implementaion of logging +framework. +****************************************************************************/ + +#include "rl_interface.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "rl_rlog.h" +#include "rl_platform.h" + +/* VARIABLE DECLARATION SECTION */ + +/* Thread-specific data key visible to all threads */ +static pthread_key_t g_threadkey; + +extern pthread_mutex_t g_logmutex; +extern THREAD_DATA* g_pCirList[RLOG_MAX_THREADS]; +void* rlAlloc(size_t mem_size) +{ + return malloc(mem_size); +} + +void rlFree(void* pMem) +{ + free(pMem); +} + +void* rlCalloc(size_t mem_size) +{ + return calloc(mem_size, 1); +} + +void rlSetThreadSpecificData(const void *pThrData) +{ + int retVal = pthread_setspecific(g_threadkey, pThrData); + + if( retVal!=0 ) { + fprintf(stderr, "Failed to associate the value with the key or invalid key"); + _exit(0); + } +} + +#ifdef RLOG_USE_CIRCULAR_BUFFER +/******************************************************************************************* +@param[in] pThreadData - Thread specific data +@brief This function is called whenever thread is being destroyed. This function will delete +thread specific data allocated during thread registration. +********************************************************************************************/ +void deInitThread(void* pThreadData) +{ + + THREAD_DATA* pThrData = (THREAD_DATA*)(pThreadData); + + if( pThreadData == NULL ) + return; + + /* lock the mutex, to make sure no one is accessing this buffer */ + pthread_mutex_lock(&g_logmutex); + + g_pCirList[pThrData->listIndex] = NULL; + + if( pThrData->logBuff != NULL ) + rlFree(pThrData->logBuff); + + rlFree(pThreadData); + + /* unlock the mutex */ + pthread_mutex_unlock(&g_logmutex); +} +#endif + +void* rlGetThreadSpecData(void) +{ + return (void*) pthread_getspecific(g_threadkey); +} + +void rlInitPlatformSpecific(void) +{ +#ifdef RLOG_USE_CIRCULAR_BUFFER + pthread_key_create(&g_threadkey, &deInitThread); +#endif +} + +/********************************************************************** + End of file + **********************************************************************/ diff --git a/src/5gnrpdcp/pj_ptsec.x b/src/rlog/rl_platform.h similarity index 70% rename from src/5gnrpdcp/pj_ptsec.x rename to src/rlog/rl_platform.h index b47bee504..f90f4c582 100755 --- a/src/5gnrpdcp/pj_ptsec.x +++ b/src/rlog/rl_platform.h @@ -17,37 +17,30 @@ *******************************************************************************/ /********************************************************************20** - - Name: LTE PDCP-PAL Interface file - - Type: C include file - - Desc: This file contains all the data structures and - prototypes for LTE PDCP. - - File: pj_ptsec.x - + + Name: Radisys Logging Framework + Type: C include file + Desc: This file contains logging framework include file. + File: rl_interface.h + *********************************************************************21*/ -/** @file pj_ptsec.x -@brief PDCP Product Structures, prototypes -*/ +/*************************************************************************** +@ description: This is header file is used for platform specific +implementaion. +****************************************************************************/ -#ifndef __PJPTSECPALX__ -#define __PJPTSECPALX__ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ +#ifndef __RL_PLATFORME_H__ -EXTERN S16 pjUtlChekTxEnqReq ARGS ((PjCb *gCb, PjDlRbCb *pjRbCb, PjTxEnt *txEnt)); -#ifdef __cplusplus -} -#endif /* __cplusplus */ +void* rlAlloc(size_t memSize); +void rlFree(void* pMem); +void* rlCalloc(size_t memSize); +void deInitThread(void* pThreadData); +void* rlGetThreadSpecData(void); +void rlSetThreadSpecificData(const void *pThrData); +void rlInitPlatformSpecific(void); -#endif /* __PJPTSECPALX__ */ +#endif /* __RL_PLATFORME_H__ */ - -/********************************************************************30** - +/********************************************************************** End of file **********************************************************************/ diff --git a/src/rlog/rl_postproc.cpp b/src/rlog/rl_postproc.cpp new file mode 100644 index 000000000..2410d11c6 --- /dev/null +++ b/src/rlog/rl_postproc.cpp @@ -0,0 +1,747 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/********************************************************************20** + + Name: Radisys Logging Framework + Type: C++ source file + Desc: This file contains logging framework implementation. + File: postproc.cpp + +*********************************************************************21*/ +/////////////////////////////////////////////////////////////////////////////// +// @ description: This is source file contains the implementaion of binary log +// postprocessor and has ability to connect to remote node and print live logs. +/////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "rl_interface.h" +#include "rl_rlog.h" + +#define TEST_MODE + +namespace cmdlinearg { +int g_port = 0; +std::string g_sFileDb; /* File DB */ +std::string g_sLogDb; /* Log DB */ +std::string g_sOutFile; /* Output file */ +std::string g_sBinLogFile; /* Input binary log file */ +std::string g_ipAddr; +} + +typedef struct +{ + int lineno; + std::string modName; + std::string file; + std::string logStr; + +} LOG_INFO; + +static struct option long_options[] = +{ + {"port", required_argument, 0, 'p'}, + {"logdb", required_argument, 0, 'l'}, + {"ofile", required_argument, 0, 'o'}, + {"blog", required_argument, 0, 'b'}, + {"ipaddr", required_argument, 0, 'i'}, + {0, 0, 0, 0} +}; + +std::map g_mFileInfo; +std::map g_mLogInfo; +FILE* g_fp=stderr; +U32 g_ttiCount = 0; +time_t g_basetimeSec; + +void readCmdLineArgs(int argc,char **argv); +void printLogTime(LOGTIME & ltime); +void loadLogDb(); +void printUsage(); +void logHexDump(ARGDATA & log); +bool invalidLogId(LOGID logId); +void openLogFile(const char* file); +void logLevN(LOGDATA & log, LOG_INFO & logInfo, const char* fmtStr, ...); +void logLevS(LOGDATA & log, LOG_INFO & logInfo, const char* fmtStr, const char *logStr); +void logString(ARGDATA & log); +void logIntArg(ARG4DATA* log); +void logArgSpl(SPL_ARGDATA* log); +void processLogs(int fd, bool (*fpReadLog)(int, ARGDATA &)); + +bool readRemoteLogs(int sockfd, ARGDATA & log); +bool readFileLogs(int fd, ARGDATA & log); +int openBinLogFile(); +int connectToLogServer(); + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// @arg[in] argc - Number of arguments +// @arg[in] argv - Command line arguments +// This is main functions, which calls a function to parse command line arguments. Then it loads +// log metadata into memory. And then based on if its remote logging or binary log file parsing +// passes apropriate function pointer to read and convert logs. +/////////////////////////////////////////////////////////////////////////////////////////////////// +int main(int argc, char* argv[]) +{ + readCmdLineArgs(argc, argv); + loadLogDb(); + + if( !cmdlinearg::g_sBinLogFile.empty() ) + { + if( !cmdlinearg::g_sOutFile.empty() ) + { + openLogFile(cmdlinearg::g_sOutFile.c_str()); + + processLogs(openBinLogFile(), readFileLogs); + fclose(g_fp); + } + } + + if( cmdlinearg::g_port != 0 ) { + + if( !cmdlinearg::g_sOutFile.empty() ) { + openLogFile(cmdlinearg::g_sOutFile.c_str()); + } + + + processLogs(connectToLogServer(), readRemoteLogs); + + fclose(g_fp); + } + return 0; +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// @param[in] file - Input log file name +// This function opens the log file in write mode. +/////////////////////////////////////////////////////////////////////////////////////////////////// +void openLogFile(const char* file) +{ + g_fp = fopen(file, "w+"); + + if( g_fp == NULL ) + { + fprintf(stderr, "Failed to open log file %s\n", file); + _exit(0); + } + + fprintf(stderr, "Log Output will be written in %s\n", file); +} + +uint32_t swap_uint32( uint32_t val ) +{ + val = ((val << 8) & 0xFF00FF00 ) | ((val >> 8) & 0xFF00FF ); + return (val << 16) | (val >> 16); +} + + +unsigned long EndianSwap32(unsigned long x) +{ + unsigned long y=0; + y += (x & 0x000000FF)<<24; + y += (x & 0xFF000000)>>24; + y += (x & 0x0000FF00)<<8; + y += (x & 0x00FF0000)>>8; + return y; +} + +void print_hex(const char* str, const U8 *p, int len) +{ + fprintf(stderr, "%s HEX \n", str); + for(int i=0; iai_family, res->ai_addr->sa_data, addrstr, 100); + + switch(res->ai_family) + { + case AF_INET: + ptr = &((struct sockaddr_in *) res->ai_addr)->sin_addr; + serv_addr.sin_addr = ((struct sockaddr_in *) res->ai_addr)->sin_addr; + sockServAddr = &serv_addr; + ai_family = res->ai_family; + serv_addr.sin_family = res->ai_family; + serv_addr.sin_port = htons(cmdlinearg::g_port); + size = sizeof(serv_addr); + break; + case AF_INET6: + ptr = &((struct sockaddr_in6 *) res->ai_addr)->sin6_addr; + sockServAddr = &serv_addr6; + /* Copy IPv6 address(16bytes) into the destination */ + memcpy((unsigned char*)serv_addr6.sin6_addr.s6_addr, (unsigned char *) + &((struct sockaddr_in6 *) res->ai_addr)->sin6_addr, 16); + ai_family = res->ai_family; + serv_addr6.sin6_family = res->ai_family; + serv_addr6.sin6_port = htons(cmdlinearg::g_port); + size = sizeof(serv_addr6); + break; + default: + sockServAddr = NULL; + break; + } + + if(ptr != NULL) + { + inet_ntop(res->ai_family, ptr, addrstr, 100); + printf ("IPv%d address: %s (%s)\n", res->ai_family == PF_INET6 ? 6 : 4, + addrstr, res->ai_canonname); + } + res = res->ai_next; + } + + if(sockServAddr == NULL || size == 0) + { + fprintf(stderr, "Not able to parse server address\n"); + _exit(0); + } + + if( (sockfd = socket(ai_family, SOCK_STREAM,0)) < 0 ) { + fprintf(stderr, "Failed to create socket\n"); + _exit(0); + } + + if( connect(sockfd, (const sockaddr*)sockServAddr, size) < 0 ) { + perror("ERROR Connecting"); + _exit(0); + } + + if(result != NULL) + { + freeaddrinfo(result); + } + return sockfd; +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// @param[in] sockfd - Socket file descriptor +// @paramp[in] log - Log data buffer +// This function reads the log header and remaining log from socket descriptor. Will return false +// if socket operation fails. +/////////////////////////////////////////////////////////////////////////////////////////////////// +bool readRemoteLogs(int sockfd, ARGDATA & log) +{ + int len; + + while( (len = recv(sockfd, (void*)&log.logData, RLOG_FIXED_LENGTH_BUFFER_SIZE, MSG_WAITALL)) == 0 ); + if( len < 0 ) { + return false; + } + + + return true; +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// @param[in] fd - input file descriptor +// @param[out] log - Log header +// This function will read the log header and returns success if able to read. +/////////////////////////////////////////////////////////////////////////////////////////////////// +bool readFileLogs(int fd, ARGDATA & log) +{ + int len = read(fd, (void*)&log.logData, sizeof(LOGDATA)); + + if( len <= 0 ) { + return false; + } + +#ifdef RLOG_MULTI_CIRCULAR_BUFFER + if( log.logData.len && read(fd, (void*)log.buf, log.logData.len) <= 0 ) { + return false; + } +#else + U16 size = RLOG_FIXED_LENGTH_BUFFER_SIZE - sizeof(LOGDATA); +// if( log.logData.len && read(fd, (void*)log.buf, size) <= 0 ) { + if( read(fd, (void*)log.buf, size) <= 0 ) { + return false; + } +#endif + + return true; +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// @param[in] log1 - LOG +// @param[in] log2 - Second Log +// This function compares the TTI of two consecutive logs. +/////////////////////////////////////////////////////////////////////////////////////////////////// +bool cmp_tti(ARGDATA & log1, ARGDATA & log2) +{ + return log2.logData.logTime.ms_tti > log1.logData.logTime.ms_tti ? true : false; +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// @param[in] log - Log data +// This function calculates the time based on TTI & time reference associated with it. And thne +// calls the function to print logs in aprpriate text format. +/////////////////////////////////////////////////////////////////////////////////////////////////// +void printLog(ARGDATA & log) +{ + + if( invalidLogId(log.logData.logId) ) + return; + + switch( log.logData.argType ) + { + case LOG_ARG_INT: + logIntArg((ARG4DATA*)&log); + break; + + case LOG_ARG_STR: + logString(log); + break; + + case LOG_ARG_HEX: + logHexDump(log); + break; + + case LOG_ARG_SPL: + logArgSpl((SPL_ARGDATA*)&log); + break; + } +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// @param[in] fd - File or socket descriptor +// @param[in] fpReadLog - Function pointer which reads either file or socket based log +// This function reads the binary log file and does sorting of logs based on TTI and then calls the +// function to print it +/////////////////////////////////////////////////////////////////////////////////////////////////// +void processLogs(int fd, bool (*fpReadLog)(int, ARGDATA &)) +{ + ARGDATA log; + bool bSortingRequired = false, bStartBuffering = false; + std::list logList; + + while((*fpReadLog)(fd, log)) + { + if( log.logData.logId == L_TIME_DELIMITER ) + { + bStartBuffering = (bStartBuffering == false) ? true : false; + if( bStartBuffering == true ) { + bSortingRequired = true; + continue; + } + } + + if( bStartBuffering ) { + logList.push_back(log); + continue; + } + + if( bSortingRequired ) { + logList.sort(cmp_tti); + std::for_each(logList.begin(), logList.end(), printLog); + logList.clear(); + bSortingRequired = false; + bStartBuffering = false; + continue; + } + + printLog(log); + } + + /* connection was closed due to some error, but we still have some logs */ + if( bStartBuffering && !logList.empty() ) + { + logList.sort(cmp_tti); + std::for_each(logList.begin(), logList.end(), printLog); + } + + close(fd); +} + + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// @param[in] log - LOG Data +// This function convert binary log with integer data type into text format. +/////////////////////////////////////////////////////////////////////////////////////////////////// +void logIntArg(ARG4DATA* log) +{ +#ifdef TEST_MODE +// printf("LOG ARG: INT, LEVEL: %s\n", g_logStr[log->logData.logLevel]); +#endif + + LOG_INFO & logInfo = g_mLogInfo[log->logData.logId]; + logLevN(log->logData,logInfo,logInfo.logStr.c_str(),log->arg1,log->arg2,log->arg3,log->arg4); +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// @param[in] log - LOG Data +// This function converts binary log containg string into text format. +/////////////////////////////////////////////////////////////////////////////////////////////////// +void logString(ARGDATA & log) +{ +#ifdef TEST_MODE +// printf("LOG ID %ld LOG ARG STRING, LEVEL: %s\n", log.logData.logId, g_logStr[log.logData.logLevel]); +#endif + + LOG_INFO & logInfo = g_mLogInfo[log.logData.logId]; + logLevS(log.logData, logInfo, logInfo.logStr.c_str(), log.buf); +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// @param[in] log - LOG Data +// This function converts binary log containg hex dump into readable text format. +/////////////////////////////////////////////////////////////////////////////////////////////////// +void logHexDump(ARGDATA & log) +{ +#ifdef TEST_MODE +// printf("LOG ARG HEX, LEVEL: %s\n", g_logStr[log.logData.logLevel]); +#endif + + LOG_INFO & logInfo = g_mLogInfo[log.logData.logId]; + + char szHex[MAX_LOG_BUF_SIZE*3]; + hextostr(szHex, log.buf, log.logData.len); + + logLevN(log.logData, logInfo, logInfo.logStr.c_str(), szHex); +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// @param[in] log - LOG Data +// @param[in] logInfo - Log information structure reference +// @param[in] fmtStr - Formatted string +// This function prints log into console or log file. +/////////////////////////////////////////////////////////////////////////////////////////////////// +void logLevN(LOGDATA & log, LOG_INFO & logInfo, const char* fmtStr, ...) +{ + va_list argList; + const char* file = logInfo.file.c_str(); + + printLogTime(log.logTime); + fprintf(g_fp, "[%s]%s:%d\n%s:", logInfo.modName.c_str(), file, logInfo.lineno, g_logStr[log.logLevel]); + + va_start(argList,fmtStr); + vfprintf(g_fp, fmtStr, argList); + va_end(argList); +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// @param[in] log - LOG Data +// @param[in] logInfo - Log information structure reference +// @param[in] fmtStr - Formatted string +// This function prints string log into console or log file. +/////////////////////////////////////////////////////////////////////////////////////////////////// +void logLevS(LOGDATA & log, LOG_INFO & logInfo, const char* fmtStr, const char* logStr) +{ + const char* file = logInfo.file.c_str(); + std::string argStr(logStr, log.len); + printLogTime(log.logTime); + fprintf(g_fp, "[%s]%s:%d\n%s:", logInfo.modName.c_str(), file, logInfo.lineno, g_logStr[log.logLevel]); + fprintf(g_fp, fmtStr, argStr.c_str()); +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// @param[in] log - LOG Data +// @param[in] logInfo - Log information structure reference +// @param[in] fmtStr - Formatted string +// This function prints log into console or log file. +/////////////////////////////////////////////////////////////////////////////////////////////////// +void logLevSpl(SPL_ARGDATA* log, LOG_INFO & logInfo, const char* fmtStr, ...) +{ + va_list argList; + const char* file = logInfo.file.c_str(); + + printLogTime(log->logData.logTime); + fprintf(g_fp, "[%s]%s:%d\n%s:%s:%d:", logInfo.modName.c_str(), file, logInfo.lineno, g_logStr[log->logData.logLevel], g_splStr[log->splEnum], log->splArg); + + va_start(argList,fmtStr); + vfprintf(g_fp, fmtStr, argList); + va_end(argList); +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// @param[in] log - LOG Data +// This function converts binary log with special arguments into text format. +/////////////////////////////////////////////////////////////////////////////////////////////////// +void logArgSpl(SPL_ARGDATA* log) +{ +#ifdef TEST_MODE +// printf("LOG ARG SPL, LEVEL: %s\n", g_logStr[log->logData.logLevel]); +#endif + LOG_INFO & logInfo = g_mLogInfo[log->logData.logId]; + const char* file = logInfo.file.c_str(); + + logLevSpl(log, logInfo, logInfo.logStr.c_str(),log->arg1, log->arg2, log->arg3, log->arg4); +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// @param[in] ltime - Log time +// This function prints log time using standard c formating function fprintf +/////////////////////////////////////////////////////////////////////////////////////////////////// +void printLogTime(LOGTIME & ltime) +{ + struct tm* tm; + time_t curTimeSec; + U32 secElapsedFromBeg; + U32 ttiNum; + U32 miliseconds; + + ttiNum = ltime.ms_tti; + secElapsedFromBeg = ttiNum/1000; + miliseconds = ttiNum%1000; + curTimeSec = g_basetimeSec + secElapsedFromBeg; + + /* Obtain the time of day, and convert it to a tm struct. --*/ + tm = localtime (&curTimeSec); + + if(NULL != tm) + { + fprintf(g_fp,"[%d-%d-%d %d:%d:%d.%03d]", tm->tm_mday, tm->tm_mon+1, tm->tm_year+1900, + tm->tm_hour, tm->tm_min,tm->tm_sec,miliseconds); + } +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// @param[in] logId - Log id which is unique to each log +// This function checks if the given log id is valid based on the logdb information loaded into +// memory. +/////////////////////////////////////////////////////////////////////////////////////////////////// +bool invalidLogId(LOGID logId) +{ + /* if this is a time reference this is valid log */ + if( g_mLogInfo.find(logId) == g_mLogInfo.end() ) + { + if(logId != L_TIME_REFERENCE) + { + fprintf(stderr, "Invalid log id %d\n",logId); + } + return true; + } + return false; +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// This function parse and reads the logdb file. Extracts the information and stores into map data +// structure. +/////////////////////////////////////////////////////////////////////////////////////////////////// +void loadLogDb() +{ + std::ifstream logdb(cmdlinearg::g_sLogDb.c_str()); + + if(logdb.is_open() == false) { + fprintf(stderr, "Failed to open file %s\n", cmdlinearg::g_sLogDb.c_str()); + _exit(0); + } + + LOGID logId; LOG_INFO logInfo; + std::string line; + std::string & lstr = logInfo.logStr; + + while( getline(logdb, line) ) + { + std::istringstream iss(line); + int pos = 0, newpos=0; + + logId = atol( line.substr(pos, newpos=line.find(';', pos)).c_str() ); + + pos = newpos+1; + logInfo.lineno = atol( line.substr(pos, (newpos=line.find(';', pos)) - pos).c_str() ); + + pos = newpos+1; + logInfo.modName = line.substr(pos, (newpos=line.find(';', pos)) - pos); + + pos = newpos+3; + logInfo.file = line.substr(pos, (newpos=line.find('\"', pos)) - pos); + + pos=line.find('\"',newpos+1) + 1; + logInfo.logStr = line.substr(pos, (newpos=line.find_last_of("\"", pos)) - pos); + lstr.erase(std::remove(lstr.begin(),lstr.end(),'\"')++,lstr.end()); + + +#ifdef TEST_MODE_0 + std::cout << "LOG Id:" << logId << " FILE:" << logInfo.file << " lineno:" << logInfo.lineno; + std::cout << " MOD Name: " << logInfo.modName << std::endl; + std::cout << "LOG STR:[" << logInfo.logStr << "]" << std::endl; +#endif + + logInfo.logStr+= "\n\n"; + + g_mLogInfo[logId] = logInfo; + } + + logdb.close(); + + logInfo.file = "NULL"; + logInfo.lineno = 0; + logInfo.modName = "RLOG"; + logInfo.logStr = RLOG_SEGFAULT_STR; + g_mLogInfo[L_SIGSEGV] = logInfo; + +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// @arg[in] argc - Number of arguments +// @arg[in] argv - Command line arguments +// This function parses the command line input parameters. +/////////////////////////////////////////////////////////////////////////////////////////////////// +void readCmdLineArgs(int argc,char **argv) +{ + using namespace cmdlinearg; + /* getopt_long stores the option index here */ + int c, option_index = 0; + + while( (c = getopt_long(argc, argv, "p:f:l:o:b:i:", long_options,&option_index)) != -1 ) + { + switch(c) + { + case 'p': + std::cout<<"option -p with value = " << optarg << std::endl; + cmdlinearg::g_port = atoi(optarg); + break; + case 'f': + std::cout<<"option -f with value = "<< optarg << std::endl; + cmdlinearg::g_sFileDb = optarg; + break; + case 'l': + std::cout<<"option -l with value = "<< optarg << std::endl; + cmdlinearg::g_sLogDb = optarg; + break; + case 'o': + std::cout<<"option -o with value = " << optarg << std::endl; + cmdlinearg::g_sOutFile = optarg; + break; + case 'b': + std::cout<<"option -b with value = " << optarg << std::endl; + cmdlinearg::g_sBinLogFile = optarg; + break; + case 'i': + std::cout<<"option -i with value = " << optarg << std::endl; + cmdlinearg::g_ipAddr = optarg; + break; + defult: + std::cout << "Invalid arguments" << std::endl; + exit(0); + } + } + +// if( g_port == 0 && g_sBinLogFile.empty() ) +// printUsage(); + +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// This functin prints the binary log application usage. +/////////////////////////////////////////////////////////////////////////////////////////////////// +void printUsage() +{ + printf("Usage: postproc [-f ] [-l ] [-b | -p ] [-o ] \n"); + printf("\t[--filedb | -p ]\n"); + printf("\t[--logdb | -l ]\n"); + printf("\t[--binlog | -b ]\n"); + printf("\t[--ofile | -o ]\n"); + printf("\t[--port | -p ]\n"); + _exit(0); +} + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/rlog/rl_rlog.c b/src/rlog/rl_rlog.c new file mode 100644 index 000000000..cb44af511 --- /dev/null +++ b/src/rlog/rl_rlog.c @@ -0,0 +1,1938 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/********************************************************************20** + + Name: Radisys Logging Framework + Type: C source file + Desc: This file contains logging framework implementation. + File: rl_rlog.c + +*********************************************************************21*/ +/********************************************************************** + @ description: This is source file which has implementaion of logging + framework. +************************************************************************/ + +#include "envopt.h" +#include "envdep.h" +#include "rl_interface.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "rl_rlog.h" +#include "rl_platform.h" +#include "gen.h" +#include "ssi.h" +#include "ss_msg.h" +#include "ss_task.h" + +#include "gen.x" +#include "ssi.x" + +#include "ss_queue.h" +#include "ss_queue.x" +#include "ss_task.x" +#include "ss_msg.x" +#include "cm_inet.h" +#include "cm_inet.x" + +#include "rl_interface.h" +#include "rl_soc.h" +char g_fileName[MAX_FILENAME_LEN]; +char g_logDir[MAX_FILENAME_LEN]; +char g_fileList[RLOG_MAX_FILES][MAX_FILENAME_LEN]; +#ifdef RLOG_USE_CIRCULAR_BUFFER +static THREAD_DATA *g_pSingCirBuff = NULL; +static U16 g_prevLogOffset=0; +#endif +#ifndef RLOG_ENABLE_TEXT_LOGGING +static volatile U32 g_rlogPositionIndex=0; +U32 gIpType = CM_IPV4ADDR_TYPE; +#endif + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Default variable initilization +/////////////////////////////////////////////////////////////////////////////////////////////////// + +/* global file pointer */ +FILE* g_fp = NULL; + +/* L2 Logging */ +#ifndef RLOG_ENABLE_TEXT_LOGGING + +Data *g_l2rlogBuf = NULLP; +Data *g_l2LogBufStartPtr = NULLP; +Data *g_l2LogBufBasePtr = NULLP; +Data *g_logBufRcvdFromL2 = NULLP; +Data *g_l2LogBaseBuff = NULLP; +U32 g_logBufLenRcvdFromL2 = 0; +U32 g_l2LogBufLen = 0; +U32 startL2Logging = 0; +U32 g_l2logBuffPos = 0; +/* end */ +#endif /* Binary Logging */ + +/* number of times log function is called */ +int g_nWrites = 0; + +/* Socke descriptor if remote client is connected */ +int g_nCliSocket = 0; + +/* Default log level Error */ +#ifdef DISABLE_RLOG +int g_logLevel = 1; +#else +int g_logLevel = L_MAX_LOG_LEVEL; +#endif +/* MAX Log Files 1 */ +U8 g_nMaxLogFiles = 1; + +/* Max File Size limit for each log file */ +U32 g_uiMaxFileSizeLimit = MAX_FILE_SIZE; + +/* Default circular buffer size 100Kb*/ +U32 g_cirMaxBufferSize = RLOG_MAX_CIRBUF_SIZE; + +/* Default mask for each module is disabled */ +U32 g_modMask = 0; + +/* Remote Logging port */ +static U32 g_nLogPort = RLOG_REMOTE_LOGGING_PORT; + +/* Current File Number index */ +int g_nCurrFileIdx = 0; + +/* Remote logging flag */ +static U8 g_bRemoteLoggingDisabled=1; + +/* Global file descriptor for L2 & L3 */ +static int g_fd; + +/* L2 Buffer */ +char g_l2Buf[RLOG_MAX_CIRBUF_SIZE]; + +#ifdef RLOG_USE_CIRCULAR_BUFFER +/* List of thread data pointers */ +THREAD_DATA* g_pCirList[RLOG_MAX_THREADS]; + +/* Number of threads registered */ +static int g_nThreadsRegistered; + +/* Mutex to protect circular buffers */ +pthread_mutex_t g_logmutex, g_condmutex; +pthread_cond_t g_cond; + +U8 g_writeCirBuf = 0; + +static int thread_signalled; +#endif + +/* TTI Count */ +static U32 numTtiTicks; +/* Console input handling parameters */ +static int g_kIdx, g_action, g_storeKeys; +static char g_keyBuf[32]; + +/* Standard C library, timezone */ +extern char *tzname[2]; +/////////////////////////////////////////////////////////////////////////////// +// FUNCTION DECLARATIONS // +/////////////////////////////////////////////////////////////////////////////// +#if defined(RLOG_ENABLE_TEXT_LOGGING) +static struct tm* getTime(int* microseconds); +static void getLogTimeStr(char* ts); +#else +#endif +void initGlbDataAtL2(void); +void createNewLogFile(void); +void createL2LogFile(void); +void* rLogServer(void* arg); +void closeConnection(int sockfd); +void storeTimeDelimeter(FILE* fp); +void rlCatchSegViolation(int sig); +void flushData(int sig); +void* cirBufReaderThread(void* arg); +void readCircularBuffers(void); +void userAction(void); +void handleSigIO(int sig); +void rlPrintConfiguration(void); +THREAD_DATA* rlRegisterThread(const char* taskName); +extern void (*rlSigHandler)(int); +/* L2 Logging */ +void rlInitL2Log(void); +U32 g_rlogWriteCount = 0; +U32 g_maxRlogCount = 50; +U32 g_logsDropCnt = 0; +RLLogCntLmt g_rlLogCntLimit = RL_LOG_COUNT_LIMIT_STOP; + +#ifndef RLOG_ENABLE_TEXT_LOGGING +void readL2LogBuff(void); +S16 rlValidateL2LogBuf(void); +void rlSetL2LogBuf(U8 *l2LogBuf,U32 l2logLen); +void rlResetL2LogBuf(void); +#endif + + +#ifndef RLOG_ENABLE_TEXT_LOGGING +EndianType getCPU_Endian(Void); +void storeFileHeader(FILE* fp); +void saveLogDataFromCpul(const void* buf, U16 len); +void saveLogData(const void* buf, U16 len, U32 g_rlogWritePosIndex); +void sendToPostProcessor(const void* buf, U16 len); +void getLogTimeStr(char* ts); +#endif +/////////////////////////////////////////////////////////////////////////////////////////////////// +// @param[in] modMask - bit mask for any particular module. +// Sets or clears bit for the particular module. If mask value is zero all bits are cleared. +/////////////////////////////////////////////////////////////////////////////////////////////////// +void rlSetModuleMask(U32 modMask) +{ + g_modMask = (modMask == 0 ) ? 0 : (g_modMask ^ modMask); +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// @param[in] - maxFileSize - Maximum file size in MB. +// @brief This function sets the limit to log file size. +/////////////////////////////////////////////////////////////////////////////////////////////////// +void rlSetLogFileSizeLimit(U32 maxFileSize) +{ + g_uiMaxFileSizeLimit = (maxFileSize == 0) ? MAX_FILE_SIZE : maxFileSize*1048576; +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// +// +/////////////////////////////////////////////////////////////////////////////////////////////////// +void rlSetNumOfLogFiles(U8 nMaxFiles) +{ + if( nMaxFiles > RLOG_MAX_FILES || nMaxFiles == 0 ) { + g_nMaxLogFiles = RLOG_MAX_FILES; + return; + } + + g_nMaxLogFiles = nMaxFiles; +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// +// @brief 1-> enable remote logging, 0-> disable remote logging +/////////////////////////////////////////////////////////////////////////////////////////////////// +void rlSetRemoteLoggingFlag(S32 flag) +{ + g_bRemoteLoggingDisabled = !flag; +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// @param[in] port - Server port +// @brief Use this API to configure port for remote logging application. +/////////////////////////////////////////////////////////////////////////////////////////////////// +void rlSetLogPort(U32 port) +{ + g_nLogPort = port; +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// @param[in] enable_core - 1 Enables core file generation 0 - disable +// This enables or disables core file generation +/////////////////////////////////////////////////////////////////////////////////////////////////// +void rlEnableDisableCore(S32 enable_core) +{ + struct rlimit core_limits; + core_limits.rlim_cur = core_limits.rlim_max = enable_core ? RLIM_INFINITY : 0; + setrlimit(RLIMIT_CORE, &core_limits); +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// +// +/////////////////////////////////////////////////////////////////////////////////////////////////// +void rlSetLogPath(const char* logDir) +{ + strncpy(g_logDir, logDir, MAX_FILENAME_LEN); +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// +// +/////////////////////////////////////////////////////////////////////////////////////////////////// +void rlSetLogFile(const char* fileName) +{ + strncpy(g_fileName, fileName, MAX_FILENAME_LEN); +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// +// +/////////////////////////////////////////////////////////////////////////////////////////////////// +void rlSetLogLevel(R_LOG_LEVEL logLevel) +{ + g_logLevel = logLevel + 1; +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// @param[in] bufSize - Circulaer buffer size in multiples of 1Kb or 1024 bytes. +// This function is called to set circular buffer size for each thread. +/////////////////////////////////////////////////////////////////////////////////////////////////// +void rlSetCircularBufferSize(U32 bufSize) +{ + g_cirMaxBufferSize = bufSize*1024; + g_cirMaxBufferSize = (g_cirMaxBufferSize/50) * 50; +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// +// +/////////////////////////////////////////////////////////////////////////////////////////////////// +void rlPrintConfiguration(void) +{ + fprintf(stderr, "Log File:\t\t[%s]\n", g_fileName); + fprintf(stderr, "Log level:\t\t[%s]\n", g_logStr[g_logLevel-1]); +#ifndef ALIGN_64BIT + fprintf(stderr, "Module Mask:\t\t[%ld]\n", g_modMask); + fprintf(stderr, "File Size Limit:\t[%ld]\n", g_uiMaxFileSizeLimit); +#else + fprintf(stderr, "Module Mask:\t\t[%d]\n", g_modMask); + fprintf(stderr, "File Size Limit:\t[%d]\n", g_uiMaxFileSizeLimit); +#endif + fprintf(stderr, "Maximum Log Files:\t[%d]\n", g_nMaxLogFiles); + fprintf(stderr, "Time Zone:\t\t[%s]\n", tzname[0]); + +#ifdef RLOG_ENABLE_TEXT_LOGGING + fprintf(stderr, "Binary Logging:\t\t[Disabled]\n"); + fprintf(stderr, "Remote Logging:\t\t[Disabled]\n"); + fprintf(stderr, "Console Logging:\t[%s]\n", (g_fp==stderr) ? "Enabled" : "Disabled" ); +#else + fprintf(stderr, "Console Logging:\t[Disabled]\n"); + fprintf(stderr, "Binary Logging:\t\t[Enabled]\n"); + fprintf(stderr, "Remote Logging:\t\t[%s]\n", g_bRemoteLoggingDisabled ? "Disabled" : "Enabled"); +#ifndef ALIGN_64BIT + fprintf(stderr, "Remote Logging Port:\t[%ld]\n", g_nLogPort); +#else + fprintf(stderr, "Remote Logging Port:\t[%d]\n", g_nLogPort); +#endif +#ifdef RLOG_USE_CIRCULAR_BUFFER + fprintf(stderr, "Circular Buffer:\t[Enabled]\n"); +#ifndef ALIGN_64BIT + fprintf(stderr, "Circular BufferSize:\t[Actual:%ld][Derived:%ld]\n", + g_cirMaxBufferSize/1024, g_cirMaxBufferSize); +#else + fprintf(stderr, "Circular BufferSize:\t[Actual:%d][Derived:%d]\n", + g_cirMaxBufferSize/1024, g_cirMaxBufferSize); +#endif +#else + fprintf(stderr, "Circular Buffer:\t[Disabled]\n"); +#endif /* RLOG_USE_CIRCULAR_BUFFER */ +#endif /* RLOG_ENABLE_TEXT_LOGGING */ + +} + +#ifdef RLOG_USE_CIRCULAR_BUFFER + +#ifdef RLOG_USE_TTI_LOGGING +#define CHECK_FILE_SIZE if( ++g_nWrites == 200 ) \ +{ \ + g_nWrites = 0; \ + logLev1(L_TIME_REFERENCE, L_ALWAYS, (U32)time(NULL));\ +} +#else +#define CHECK_FILE_SIZE +#endif /* RLOG_USE_TTI_LOGGING */ + +#else /* RLOG_USE_CIRCULAR_BUFFER */ + +#ifdef RLOG_USE_TTI_LOGGING +#define CHECK_FILE_SIZE if( ++g_nWrites == 200 ) \ +{ \ + if( g_fp && ftell(g_fp) > g_uiMaxFileSizeLimit ) { \ + createNewLogFile(); \ + }\ + g_nWrites = 0; \ + logLev1(L_TIME_REFERENCE, L_ALWAYS, (U32)time(NULL));\ +} +#else +#define CHECK_FILE_SIZE if( ++g_nWrites == 200 ) \ +{ \ + if( g_fp && ( (U32)(ftell(g_fp)) > g_uiMaxFileSizeLimit) ) { \ + createNewLogFile(); \ + }\ + g_nWrites = 0; \ +} +#endif /* RLOG_USE_TTI_LOGGING */ +#endif /* RLOG_USE_CIRCULAR_BUFFER */ + + +#ifdef RLOG_USE_CIRCULAR_BUFFER + +#define CHECK_CIRFILE_SIZE if( g_fp && ftell(g_fp) > g_uiMaxFileSizeLimit ) \ + createNewLogFile(); + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// @param[in] tasName - Name of registering thread / task +// This function registers the thread for writing logs. It creates thread specific buffers. +/////////////////////////////////////////////////////////////////////////////////////////////////// +THREAD_DATA* rlRegisterThread(const char* taskName) +{ + THREAD_DATA* pThrData = (THREAD_DATA*) rlCalloc(sizeof(THREAD_DATA)); + + if( pThrData == NULL ) { + fprintf(stderr, "Failed to allocate memory for thread %s\n", taskName); + _exit(0); + } + + pthread_mutex_lock(&g_logmutex); + + /* Allocate circular buffer */ + pThrData->logBuff = (U8*) rlAlloc(g_cirMaxBufferSize); + + if( pThrData->logBuff == NULL ) { +#ifndef ALIGN_64BIT + fprintf(stderr, "Failed to allocate memory [%ld] for thread %s\n",g_cirMaxBufferSize, taskName); +#else + fprintf(stderr, "Failed to allocate memory [%d] for thread %s\n",g_cirMaxBufferSize, taskName); +#endif + _exit(0); + } + + /* store task name */ + strcpy(pThrData->szTaskName, taskName); + + //rlSetThreadSpecificData(pThrData); + + pThrData->listIndex = g_nThreadsRegistered++; + + /* Store this pointerin global list, to access it later */ + g_pCirList[pThrData->listIndex] = pThrData; + + pthread_mutex_unlock(&g_logmutex); + +#ifdef RLOG_DEBUG_MODE +#ifndef ALIGN_64BIT + fprintf(stderr, "rlRegisterThread: allocated CIRCULAR BUFFER of size [%ld]\n", g_cirMaxBufferSize); +#else + fprintf(stderr, "rlRegisterThread: allocated CIRCULAR BUFFER of size [%d]\n", g_cirMaxBufferSize); +#endif + fprintf(stderr, "rlRegisterThread: Total registered threads [%d]\n", g_nThreadsRegistered); +#endif + + return pThrData; +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// @param[in] arg - Thread argument +// This thread wakes up periodically and transfer logs from thread specific buffer into file system. +// If buffer is going to be full, this thread is signalled asynchrounously to read buffered logs. +/////////////////////////////////////////////////////////////////////////////////////////////////// +void* cirBufReaderThread(void* arg) +{ + struct timespec timeout; + int retCode; + +#ifdef RLOG_DEBUG_MODE + fprintf(stderr, "Circular Buffer Reader thread started\n"); +#endif + + while(1) + { + /*this thread is not active and waiting to timeout */ + thread_signalled = 0; + + /* set the thread timeout */ + timeout.tv_sec = time(NULL) + RLOG_CIRBUF_READ_INTERVAL; + timeout.tv_nsec = 0; + + /* wait for 120 seconds time interval to read buffer */ + retCode = pthread_cond_timedwait(&g_cond, &g_condmutex, &timeout); + + /* this means, this thread is already active, no need to give any other signal to wake up */ + thread_signalled = 1; + +#ifdef RLOG_DEBUG_MODE + //if(retCode == 0) fprintf(stderr, "cirBufReaderThread: I am signalled to read data\n"); +#endif + + /* If someone has given signal or there is timeout */ + if( retCode == 0 || retCode == ETIMEDOUT ){ + readCircularBuffers(); + continue; + } + + readCircularBuffers(); + +#ifdef RLOG_DEBUG_MODE + fprintf(stderr, "System is exiting ??"); + perror("cirBufReaderThread"); +#endif + break; + } + + return NULL; +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// +// +/////////////////////////////////////////////////////////////////////////////////////////////////// +void readCircularBuffers() +{ + U32 i, writerPos; + + /* Check if process is L2. If L2 then return from here */ + if (SFndProcId() == TENB_L2_PROC_ID) + { + return; + } + + g_writeCirBuf = 1; + /* Before reading circular buffers, store delimiter */ + //storeTimeDelimeter(g_fp); + + /* lock the mutex */ + pthread_mutex_lock(&g_logmutex); + + for(i=0; i < g_nThreadsRegistered; i++) + { + THREAD_DATA* pThrData = g_pCirList[i]; + + if( pThrData == NULL ) + continue; + + writerPos = pThrData->logBufLen; + +#ifdef RLOG_DEBUG_MODE + //fprintf(stderr, "Thread [%ld] WritePos:[%ld] ReadPos:[%ld]\n", i+1, writerPos, pThrData->logReadPos); +#endif + + if( pThrData->logReadPos < writerPos ) + { + /* Calculate the delta data to be read from buffer */ + int dataLen = writerPos - pThrData->logReadPos; + + /* Write the data into file */ + if( fwrite(pThrData->logBuff+pThrData->logReadPos,1, dataLen, g_fp) == -1 ) + { +#ifdef RLOG_DEBUG_MODE + fprintf(stderr, "Failed to write data len %d\n", dataLen); +#endif + createNewLogFile(); + continue; + } + /* reset log read position to last known position */ + pThrData->logReadPos = writerPos; + } + else if ( pThrData->logReadPos > writerPos ) + { + /* Calculate the remaining data left in the buffer */ + int dataLen = g_cirMaxBufferSize - pThrData->logReadPos; + + /* Write from last know position till end */ + if( fwrite(pThrData->logBuff+pThrData->logReadPos, 1, dataLen, g_fp) == -1 ) + { +#ifdef RLOG_DEBUG_MODE + fprintf(stderr, "Failed to write data len %d\n", dataLen); +#endif + createNewLogFile(); + continue; + } + + /* Write from 0 to len position */ + if( fwrite(pThrData->logBuff, 1, writerPos, g_fp) == -1 ) + { +#ifdef RLOG_DEBUG_MODE + fprintf(stderr, "Failed to write data len %d\n", dataLen); +#endif + createNewLogFile(); + continue; + } + + /* reset log read position to last known position */ + pThrData->logReadPos = writerPos; + } + } + + /* unlock the mutex */ + pthread_mutex_unlock(&g_logmutex); + + /* after reading circular buffers also store delimiter */ + //storeTimeDelimeter(g_fp); + + CHECK_CIRFILE_SIZE + + g_writeCirBuf = 0; +} + +#endif + +#ifndef RLOG_ENABLE_TEXT_LOGGING +/////////////////////////////////////////////////////////////////////////////////////////////////// +// +// +/////////////////////////////////////////////////////////////////////////////////////////////////// +EndianType getCPU_Endian(Void) +{ + unsigned short x; + unsigned char c; + + x = 0x0001;; + c = *(unsigned char *)(&x); + + return ( c == 0x01 ) ? little_endian : big_endian; +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// +// +/////////////////////////////////////////////////////////////////////////////////////////////////// +void storeFileHeader(FILE* fp) +{ + FILE_HEADER fileHdr; + + memset(&fileHdr, 0, sizeof(FILE_HEADER)); + + fileHdr.endianType = getCPU_Endian(); + fileHdr.dummy32 = 2818049; + fileHdr.END_MARKER = 0xFFFF; + strncpy(fileHdr.szTimeZone, tzname[0], RLOG_TIME_ZONE_LEN); + + fileHdr.time_sec = time(NULL); + if( fwrite((const void*)&fileHdr, 1, sizeof(FILE_HEADER), fp) == -1 ) + { +#ifdef RLOG_DEBUG_MODE + fprintf(stderr, "Failed to write file header\n"); +#endif + createNewLogFile(); + } +} +#endif + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// @param[in] fileName - Log File Name +// @brief This function creates a log file. If log file name is stdout & text logging is enabled, +// file pointer is initialized to standard output. This function also creates thread on which +// remote application can connect & receive binary logs. If circular buffer is enabled, it creates +// thread key, which is used to store & retrieve thread specific buffers and data. +/////////////////////////////////////////////////////////////////////////////////////////////////// +void rlInitLog(U8 type) +{ +#ifdef SS_RBUF + /* Initilize the signal handler */ + rlSigHandler = &rlCatchSegViolation; +#else + signal(SIGSEGV, rlCatchSegViolation); + signal(SIGBUS, rlCatchSegViolation); + signal(SIGINT, flushData); +#endif +/* set rate limit count for L3 Logs */ + g_maxRlogCount = RLOG_LIMIT_L3_COUNT; + +#ifdef RLOG_DEBUG_MODE + rlPrintConfiguration(); +#endif /* RLOG_DEBUG_MODE */ + +#if RLOG_ALLOW_CONSOLE_LOGS + if( !strcmp(g_fileName, "stdout")) { + g_fp = stderr; + return; + } +#endif + +#ifndef RLOG_ENABLE_TEXT_LOGGING + { + printf("\n IP Type before reader thread spawn [%d]\n",type); + /* Allocate circular buffer */ + gIpType = type; + pthread_t tid; + if( pthread_create(&tid, NULL, &rLogServer, NULL) != 0 ) { + fprintf(stderr, "Failed to initialize log server thread\n"); + _exit(0); + } + } + + rlInitPlatformSpecific(); + +#ifdef RLOG_USE_CIRCULAR_BUFFER + { + pthread_t tid; + pthread_mutex_init(&g_logmutex, NULL); + if( pthread_create(&tid, NULL, &cirBufReaderThread, NULL) != 0 ) { + fprintf(stderr, "Failed to initialize log server thread\n"); + _exit(0); + } +/* Initialize single circular buffer for all threads */ + g_pSingCirBuff = rlRegisterThread("DUMMY"); +} + +#endif +#endif + + createNewLogFile(); +} + + +////////////////////////////////////////////////////////////////////////// +// @Function : rlInitL2Log +// @Discription : This will be trigigered from cl init function to +// allocate buffer from shared memory and to intialize +// the buffer +// @in : void +// @out : void +////////////////////////////////////////////////////////////////////////// +void rlInitL2Log(void) +{ + +/* set rate limit count for L3 Logs */ + g_maxRlogCount = RLOG_LIMIT_L2_COUNT; + +#ifndef RLOG_ENABLE_TEXT_LOGGING +/* Initialise memory to write logs in L2. This is soc specific + function present in soc file. */ + rlInitL2SocSpecific(); + +#else + +/* This is used to initialize global variable at L2 */ + initGlbDataAtL2(); + createL2LogFile(); + +#endif /* Binary Logging */ +} + + +#ifndef RLOG_ENABLE_TEXT_LOGGING +/////////////////////////////////////////////////////////////////////////////////////////////////// +// @param[in] arg - Input thread argument - IP Address type. +// @brief This is log server thread which listens on configred port. This allows user to connect to +// log server and view log data live. +/////////////////////////////////////////////////////////////////////////////////////////////////// +void* rLogServer(void* arg) +{ + CmInetCmnSockAddr serv_addr; + CmInetCmnSockAddr cli_addr; + int sockfd; + int newsockfd; + int clilen = 0; + int domain = AF_INET; + memset((void*)&serv_addr, 0, sizeof(serv_addr)); + + + if(gIpType == CM_IPV4ADDR_TYPE) + { +#ifndef ALIGN_64BIT + printf("Initializing RLOG for IPV4- %ld\n",gIpType); +#else + printf("Initializing RLOG for IPV4- %d\n",gIpType); +#endif + clilen = serv_addr.len = sizeof(struct sockaddr_in); + domain = AF_INET; + serv_addr.type = CM_IPV4ADDR_TYPE; + serv_addr.u.addr.sin_family = AF_INET; + serv_addr.u.addr.sin_addr.s_addr = INADDR_ANY; + serv_addr.u.addr.sin_port = htons(g_nLogPort); + } + else + { +#ifndef ALIGN_64BIT + printf("Initializing RLOG for IPV6 - %ld\n",gIpType); +#else + printf("Initializing RLOG for IPV6 - %d\n",gIpType); +#endif +#ifdef IPV6_SUPPORTED + if(gIpType == CM_IPV6ADDR_TYPE) + { + clilen = serv_addr.len = sizeof(struct sockaddr_in6); + domain = AF_INET6; + serv_addr.type = CM_IPV6ADDR_TYPE; + serv_addr.u.addr6.sin6_family = AF_INET6; + serv_addr.u.addr6.sin6_addr = in6addr_any; + serv_addr.u.addr6.sin6_port = htons(g_nLogPort); + } +#endif + } + if( (sockfd = socket(domain, SOCK_STREAM, 0)) < 0 ) { + fprintf(stderr, "RLOG: Failed to create socket\n"); + _exit(0); + } + + if( bind(sockfd, (struct sockaddr*)&(serv_addr.u),serv_addr.len) < 0 ) { + fprintf(stderr, "RLOG: Error in Binding\n"); + perror("RLOG"); + _exit(0); + } + + listen(sockfd, 5); + + while(1) + { + newsockfd = accept(sockfd, (struct sockaddr*)&(cli_addr.u), (socklen_t *) &clilen); + if( newsockfd < 0 ) { + fprintf(stderr, "RLOG: Error on accept\n"); + perror("RLOG"); + return 0; + } + + /* If remote logging is disabled or there is already 1 client connected */ + if( g_bRemoteLoggingDisabled || g_nCliSocket ) { + /* close the new connection and proceed */ + closeConnection(newsockfd); + continue; + } + + g_nCliSocket = newsockfd; + } + + return 0; +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// +// +/////////////////////////////////////////////////////////////////////////////////////////////////// +void closeConnection(int sockfd) +{ + shutdown(sockfd, SHUT_RDWR); + close(sockfd); +} + +#endif + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// +// +/////////////////////////////////////////////////////////////////////////////////////////////////// +void handleSigIO(int sig) +{ + char ch; + + if( read(0, &ch, 1) <= 0 ) + return; + + rlHandleConInput(ch); +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// +// +/////////////////////////////////////////////////////////////////////////////////////////////////// +int rlHandleConInput(char ch) +{ + if( ch == RLOG_CTRL_L ) { + g_storeKeys = 1; + g_action = RLOG_SET_LOGLEVEL; + fprintf(stderr, "\nEnter new log level:"); + return 1; + } + + if( ch == RLOG_CTRL_Y ) { + g_storeKeys = 1; + g_action = RLOG_SET_MODMASK; + fprintf(stderr, "\nEnter module number:"); + return 1; + } + + if( ch == RLOG_ENTER_KEY && g_action ) { + g_keyBuf[g_kIdx] = '\0'; + userAction(); + return 1; + } + + if( g_storeKeys ) { + g_keyBuf[g_kIdx] = ch; + g_kIdx +=1; + } + + return 0; +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// +// +/////////////////////////////////////////////////////////////////////////////////////////////////// +void userAction() +{ + unsigned int val = atol(g_keyBuf); + + switch( g_action ) + { + case RLOG_SET_LOGLEVEL: + { + if( val >= L_MAX_LOG_LEVEL ) + fprintf(stderr, "Invalid log level\n"); + else + { + if( val > L_FATAL ) + { + rlSetLogLevel((R_LOG_LEVEL)val); + fprintf(stderr, "New Log level is %s\n", g_logStr[val]); + } + else + fprintf(stderr, "Log level below L_ERROR is not allowed\n"); + } + } + break; + + case RLOG_SET_MODMASK: + { + rlSetModuleMask(val); + fprintf(stderr, "Toggled log mask %d\n", val); + } + break; + } + + g_action = 0; + g_kIdx= 0; + g_storeKeys = 0; +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// +// +/////////////////////////////////////////////////////////////////////////////////////////////////// +void rlCatchSegViolation(int sig) +{ + int i, nStrLen, nDepth; + + void *stackTraceBuf[RLOG_MAX_STACK_DEPTH]; + const char* sFileNames[RLOG_MAX_STACK_DEPTH]; + const char* sFunctions[RLOG_MAX_STACK_DEPTH]; + + char **strings; char buf[RLOG_MAX_STACK_DEPTH*128]={0}; +#ifdef T2K_MEM_LEAK_DBG + DumpT2kMemLeakInfoToFile(); +#endif +#ifdef SSI_STATIC_MEM_LEAK_DETECTION + DumpStaticMemLeakFiles(); +#endif + + nDepth = backtrace(stackTraceBuf, RLOG_MAX_STACK_DEPTH); + + + strings = (char**) backtrace_symbols(stackTraceBuf, nDepth); + + for(i = 0, nStrLen=0; i < nDepth; i++) + { + sFunctions[i] = (strings[i]); + sFileNames[i] = "unknown file"; + +#ifndef RLOG_ENABLE_TEXT_LOGGING + logLevS(L_SIGSEGV, L_FATAL, strings[i]); +#endif + printf("BT[%d] : len [%ld]: %s\n",i, (PTR)strlen(sFunctions[i]),strings[i]); + sprintf(buf+nStrLen, " in Function %s (from %s)\n", sFunctions[i], sFileNames[i]); + nStrLen += strlen(sFunctions[i]) + strlen(sFileNames[i]) + 15; + } + +#ifdef RLOG_ENABLE_TEXT_LOGGING + logLevS(g_logStr[L_FATAL], "RLOG", "NULL", 0, FMTSTR RLOG_SEGFAULT_STR, buf); + fflush(g_fp); +#else + logLevS(L_SIGSEGV, L_FATAL, buf); +#endif + + flushData(SIGSEGV); +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// +// +/////////////////////////////////////////////////////////////////////////////////////////////////// +void flushData(int sig) +{ +#ifdef RLOG_USE_CIRCULAR_BUFFER + readCircularBuffers(); +#endif + g_rlogWriteCount = 0; + + fclose(g_fp); + + if(SIGSEGV == sig) + { + signal(sig, SIG_DFL); + kill(getpid(), sig); + } + else + { + exit(0); + } + + return; +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// +// +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef RLOG_ENABLE_TEXT_LOGGING + +#define TIME_PARAMS tm->tm_mday, tm->tm_mon+1, tm->tm_year+1900,tm->tm_hour, tm->tm_min,tm->tm_sec,microseconds + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// +// +/////////////////////////////////////////////////////////////////////////////////////////////////// +void logLevS(PSTR strLogLevel, PSTR modName, PSTR file, int lineno, PSTR fmtStr, PSTR str, ...) +{ + int microseconds=0; + + struct tm* tm = getTime(µseconds); + if (tm) fprintf(g_fp, fmtStr, TIME_PARAMS, modName, file, lineno, strLogLevel, str); + + CHECK_FILE_SIZE +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// +// +/////////////////////////////////////////////////////////////////////////////////////////////////// +void logLevH(PSTR strLogLevel, PSTR modName, PSTR file, int lineno, PSTR fmtStr, PSTR hexdump, int hexlen, ...) +{ + int microseconds=0; + char szHex[MAX_LOG_BUF_SIZE*3]; + + struct tm* tm = getTime(µseconds); + hextostr(szHex, hexdump, hexlen); + if (tm) fprintf(g_fp, fmtStr, TIME_PARAMS, modName, file, lineno, strLogLevel, szHex); + + CHECK_FILE_SIZE +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// +// +/////////////////////////////////////////////////////////////////////////////////////////////////// +void logLevE(PSTR strLogLevel, PSTR modName, PSTR file, int lineno, PSTR fmtStr, R_SPL_ARG splType, + U32 splVal, U32 arg1, U32 arg2, U32 arg3, U32 arg4, ...) +{ + int microseconds=0; + + struct tm* tm = getTime(µseconds); + if (tm) fprintf(g_fp, fmtStr, TIME_PARAMS, modName, file, lineno, strLogLevel, g_splStr[splType], splVal, + arg1, arg2, arg3, arg4); + + CHECK_FILE_SIZE +} +/////////////////////////////////////////////////////////////////////////////////////////////////// +// +// +/////////////////////////////////////////////////////////////////////////////////////////////////// +void logLev0(PSTR strLogLevel, PSTR modName, PSTR file, int lineno, PSTR fmtStr, ...) +{ + int microseconds=0; + + struct tm* tm = getTime(µseconds); + if (tm) fprintf(g_fp, fmtStr, TIME_PARAMS, modName, file, lineno, strLogLevel); + + CHECK_FILE_SIZE +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// +// +/////////////////////////////////////////////////////////////////////////////////////////////////// +void logLev1(PSTR strLogLevel, PSTR modName, PSTR file, int lineno, PSTR fmtStr, U32 arg1, ...) +{ + int microseconds=0; + + struct tm* tm = getTime(µseconds); + if (tm) fprintf(g_fp, fmtStr, TIME_PARAMS, modName, file, lineno, strLogLevel, arg1); + + CHECK_FILE_SIZE +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// +// +/////////////////////////////////////////////////////////////////////////////////////////////////// +void logLev2(PSTR strLogLevel, PSTR modName, PSTR file, int lineno, PSTR fmtStr, U32 arg1, U32 arg2, ...) +{ + int microseconds=0; + + struct tm* tm = getTime(µseconds); + if (tm) fprintf(g_fp, fmtStr, TIME_PARAMS, modName, file, lineno, strLogLevel, arg1, arg2); + + CHECK_FILE_SIZE +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// +// +/////////////////////////////////////////////////////////////////////////////////////////////////// +void logLev3(PSTR strLogLevel, PSTR modName, PSTR file, int lineno, PSTR fmtStr, + U32 arg1, U32 arg2, U32 arg3, ...) +{ + int microseconds=0; + + struct tm* tm = getTime(µseconds); + if (tm) fprintf(g_fp, fmtStr, TIME_PARAMS, modName, file, lineno, strLogLevel, arg1, arg2, arg3); + + CHECK_FILE_SIZE +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// +// +/////////////////////////////////////////////////////////////////////////////////////////////////// +void logLev4(PSTR strLogLevel, PSTR modName, PSTR file, int lineno, PSTR fmtStr, + U32 arg1, U32 arg2, U32 arg3, U32 arg4, ...) +{ + int microseconds=0; + + struct tm* tm = getTime(µseconds); + if (tm) fprintf(g_fp, fmtStr, TIME_PARAMS, modName, file, lineno, strLogLevel, arg1, arg2, arg3, arg4); + + CHECK_FILE_SIZE +} + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// +// +/////////////////////////////////////////////////////////////////////////////////////////////////// +void logLevN(int logLevel, const char* modName, const char* file, int lineno, const char* fmtStr, ...) +{ + va_list argList; + char szTime[RLOG_MAX_TIME_STAMP]; + char szLog1[MAX_LOG_LEN], szLog2[MAX_LOG_LEN]; + + getLogTimeStr(szTime); + snprintf(szLog1, MAX_LOG_LEN, "[%s][%s]%s:%d\n%s:", szTime, modName, file, lineno, g_logStr[logLevel]); + + va_start(argList,fmtStr); + vsnprintf(szLog2, MAX_LOG_LEN, fmtStr, argList); + va_end(argList); + + fprintf(g_fp, "%s%s",szLog1, szLog2); + + CHECK_FILE_SIZE +} +#else /* BINARY LOGGING */ + +#define RLOG_SAVE_TIME(_logTime) _logTime.ms_tti=numTtiTicks; + +void saveLogDataFromCpul(const void* buf, U16 len) +{ +#ifdef RLOG_USE_CIRCULAR_BUFFER + THREAD_DATA* p = (THREAD_DATA*) g_pSingCirBuff; + + if( (p->logBufLen+len) > g_cirMaxBufferSize ) + { + S32 tempLen = g_cirMaxBufferSize - p->logBufLen; + S32 remlen = len-tempLen; + if ((tempLen < 0) || (remlen < 0)) + { + RETVOID; + } + if(remlen == 0) + { + g_rlogPositionIndex = 0; + g_prevLogOffset = 0; + } + else + { + g_rlogPositionIndex = remlen/50; + } + + /* we are unlikely to hit this condition, but to prevent corruption of binary logs */ + /* we cannot write the data, if we write, data will be corrected forever */ + if( remlen > p->logReadPos ) + { + fprintf(stderr, "cannot write data.retune buffer parameters\n"); + return; + } + if( (p->logReadPos - remlen) < RLOG_READ_POS_THRESHOLD && !thread_signalled ) + { + pthread_cond_signal(&g_cond); /* this will wakeup thread */ + } + + + /* Copy data till end of the buffer */ + memcpy(p->logBuff+p->logBufLen, buf, tempLen); + /* Copy remaining data from the start of buffer */ + memcpy(p->logBuff, ((const U8 *)buf)+tempLen, remlen); + /* Store buffer length position */ + p->logBufLen = len-tempLen; + } + else + { + /* if reader is far behind and writer is reaching reader position, diff < 5Kb */ + /* its time to wakeup thread if reader has not read much of data */ + if( p->logReadPos > p->logBufLen && (p->logReadPos - p->logBufLen) < RLOG_READ_POS_THRESHOLD && !thread_signalled ) + pthread_cond_signal(&g_cond); /* this will wakeup thread */ + + g_rlogPositionIndex += (len/50); + memcpy(p->logBuff+p->logBufLen, buf, len); + p->logBufLen += len; + } +#else + /* Directly write received buffer in cpuh log file */ + if( fwrite((const void*)buf, 1, len, g_fp) == -1 ) + { +#ifdef RLOG_DEBUG_MODE + fprintf(stderr, "Failed to write log data in file\n"); + perror("LOG"); +#endif + createNewLogFile(); + } +#endif + +} + +void saveLogData(const void* buf, U16 len, U32 g_rlogWritePosIndex) +{ + + ++g_rlogWriteCount ; + + if((1 == g_writeCirBuf) || + ((g_rlLogCntLimit == RL_LOG_COUNT_LIMIT_START) && + (g_rlogWriteCount > g_maxRlogCount)) || + (len > RLOG_FIXED_LENGTH_BUFFER_SIZE)) + { + g_rlogPositionIndex --; + g_logsDropCnt++; + return; + } + + /* check for if L2 is going to store logs */ + if (SFndProcId() == TENB_L2_PROC_ID) + { + if((g_l2LogBufLen + RLOG_FIXED_LENGTH_BUFFER_SIZE) < L2LOG_BUFF_BLOCK_SIZE - sizeof(g_l2LogBufLen) ) + { + /* copying logs in shared buffer */ + memcpy(g_l2LogBufStartPtr, buf, len); + + g_l2LogBufStartPtr += RLOG_FIXED_LENGTH_BUFFER_SIZE; + /* increasing total log length with L2 log length */ + g_l2LogBufLen += RLOG_FIXED_LENGTH_BUFFER_SIZE; + } + return; + } +#ifdef RLOG_USE_CIRCULAR_BUFFER + U32 logWritePointerPosition; + THREAD_DATA* p = (THREAD_DATA*) g_pSingCirBuff; + + /* if buffer is about to full, write till end and continue writing from begining */ + if( ((g_rlogWritePosIndex+1) * RLOG_FIXED_LENGTH_BUFFER_SIZE) > g_cirMaxBufferSize ) + { + /* setting this flag to 1 to avoid other threads + to write in same circular buffer */ + g_writeCirBuf = 1; + /* Start globalPositionIndex again */ + g_rlogPositionIndex = 0; + + /* if reader has not read initial data, minmum buffer size should be 100Kb */ + if( p->logReadPos < RLOG_READ_POS_THRESHOLD && !thread_signalled ) { + pthread_cond_signal(&g_cond); /* this will wakeup thread */ + } + + /* we are unlikely to hit this condition, but to prevent corruption of binary logs */ + /* we cannot write the data, if we write, data will be corrected forever */ + if( RLOG_FIXED_LENGTH_BUFFER_SIZE > p->logReadPos ) { + fprintf(stderr, "cannot write data.retune buffer parameters\n"); + return; + } + + /* Copy data from the start of buffer */ + memcpy(p->logBuff, buf, len); + /* Store buffer length position */ + p->logBufLen = RLOG_FIXED_LENGTH_BUFFER_SIZE; + g_prevLogOffset = 0; + /* setting this flag to 0 so that other threads + will start writing in circular buffer */ + g_writeCirBuf = 0; + } + else + { + /* if reader is far behind and writer is reaching reader position, diff < 5Kb */ + /* its time to wakeup thread if reader has not read much of data */ + if( p->logReadPos > p->logBufLen && (p->logReadPos - p->logBufLen) < RLOG_READ_POS_THRESHOLD ) + pthread_cond_signal(&g_cond); /* this will wakeup thread */ + + logWritePointerPosition = (g_rlogWritePosIndex * RLOG_FIXED_LENGTH_BUFFER_SIZE) + g_prevLogOffset; + + memcpy(p->logBuff+logWritePointerPosition, buf, len); + p->logBufLen += RLOG_FIXED_LENGTH_BUFFER_SIZE; + } +#else /* !RLOG_USE_CIRCULAR_BUFFER */ + if( fwrite((const void*)buf, 1, RLOG_FIXED_LENGTH_BUFFER_SIZE, g_fp) == -1 ) + { +#ifdef RLOG_DEBUG_MODE + fprintf(stderr, "Failed to write log data in file\n"); + perror("LOG"); +#endif + createNewLogFile(); + } +#endif /* RLOG_USE_CIRCULAR_BUFFER */ + + CHECK_FILE_SIZE + + /* If post processor connected send logs */ + if( g_nCliSocket && send(g_nCliSocket, buf, RLOG_FIXED_LENGTH_BUFFER_SIZE, 0 ) == -1 ) { + closeConnection(g_nCliSocket); + g_nCliSocket = 0; + } + +#ifdef RLOG_DEBUG_MODE_2 + { + static int maxlen = 0; + if(len > maxlen) { + maxlen = len; + fprintf(stderr, "MAX BUFFER SIZE is binary mode is [%d]\n", maxlen); + } + } +#endif + +} + +#if 0 +void storeTimeDelimeter(FILE* fp) +{ + LOGDATA logData; + logData.logId = L_TIME_DELIMITER; + logData.argType = 0; + logData.logLevel = 0; + logData.numOfArgs = 0; + logData.len = 0; +} +#endif +void sendToPostProcessor(const void* buf, U16 len) +{ + if( send(g_nCliSocket, buf, len, 0 ) == -1 ) { + perror("ERROR Sending"); + closeConnection(g_nCliSocket); + g_nCliSocket = 0; + } +} +void logLevS( LOGID logId, R_LOG_LEVEL logLevel, const char* str, ...) +{ + ARGDATA arg; U16 bufsize; + + + RLOG_SAVE_TIME(arg.logData.logTime); + + arg.logData.logId = logId; + arg.logData.argType = LOG_ARG_STR; + arg.logData.logLevel = logLevel; + arg.logData.numOfArgs = 1; + arg.logData.len = strlen(str); + + memcpy(arg.buf, (const void*)str, arg.logData.len); + bufsize = sizeof(LOGDATA)+arg.logData.len; + + saveLogData((const void*)&arg, bufsize,g_rlogPositionIndex++); +} + +void logLevH( LOGID logId, R_LOG_LEVEL logLevel, PSTR hex, int hexlen, ...) +{ + ARGDATA arg; + int bufsize; + + RLOG_SAVE_TIME(arg.logData.logTime); + + arg.logData.logId = logId; + arg.logData.argType = LOG_ARG_HEX; + arg.logData.logLevel = logLevel; + arg.logData.numOfArgs = 1; + arg.logData.len = hexlen; + + memcpy(arg.buf, (const void*)hex, hexlen); + bufsize = sizeof(LOGDATA)+arg.logData.len; + + saveLogData((const void*)&arg, bufsize,g_rlogPositionIndex++); +} +void logLevE(LOGID logId, R_LOG_LEVEL logLevel, R_SPL_ARG splType, U32 splVal, U32 arg1, U32 arg2, + U32 arg3, U32 arg4, ...) +{ + SPL_ARGDATA arg; + int bufsize; + + RLOG_SAVE_TIME(arg.logData.logTime); + + arg.logData.logId = logId; + arg.logData.argType = LOG_ARG_SPL; + arg.logData.logLevel = logLevel; + if( arg1 ) { + arg.logData.numOfArgs = (arg2 == 0 ) ? 1 : (arg3==0 ? 2 : (arg4==0 ? 3 : 4)); + } else { + arg.logData.numOfArgs = 0; + } + + arg.logData.len = sizeof(u_int8_t) + sizeof(U32) + (sizeof(U32)*arg.logData.numOfArgs); + + arg.splEnum = splType; + arg.splArg = splVal; + arg.arg1 = arg1; + arg.arg2 = arg2; + arg.arg3 = arg3; + arg.arg4 = arg4; + + bufsize = sizeof(LOGDATA)+arg.logData.len; + + saveLogData((const void*)&arg, bufsize,g_rlogPositionIndex++); +} + +void logLev0( LOGID logId, R_LOG_LEVEL logLevel, ...) +{ + //LOGDATA logData; + ARG4DATA arg; + + RLOG_SAVE_TIME(arg.logData.logTime); + + arg.logData.logId = logId; + arg.logData.argType = LOG_ARG_STR; + arg.logData.logLevel = logLevel; + arg.logData.numOfArgs = 0; + arg.logData.len = 0; + + saveLogData((const void*)&arg, sizeof(LOGDATA),g_rlogPositionIndex++); +} + +void logLev1( LOGID logId, R_LOG_LEVEL logLevel, U32 arg1, ...) +{ + ARG4DATA arg; + int bufsize; + + RLOG_SAVE_TIME(arg.logData.logTime); + + arg.logData.logId = logId; + arg.logData.argType = LOG_ARG_INT; + arg.logData.logLevel = logLevel; + arg.logData.numOfArgs = 1; + arg.logData.len = sizeof(U32); + + arg.arg1 = arg1; + bufsize = sizeof(LOGDATA)+arg.logData.len; + + saveLogData((const void*)&arg, bufsize,g_rlogPositionIndex++); +} +void logLev2( LOGID logId, R_LOG_LEVEL logLevel, U32 arg1, U32 arg2, ...) +{ + ARG4DATA arg; + int bufsize; + + RLOG_SAVE_TIME(arg.logData.logTime); + + arg.logData.logId = logId; + arg.logData.argType = LOG_ARG_INT; + arg.logData.logLevel = logLevel; + arg.logData.numOfArgs = 2; + arg.logData.len = 2 * sizeof(U32); + + arg.arg1 = arg1; + arg.arg2 = arg2; + + bufsize = sizeof(LOGDATA)+arg.logData.len; + + saveLogData((const void*)&arg, bufsize,g_rlogPositionIndex++); +} +void logLev3( LOGID logId, R_LOG_LEVEL logLevel, U32 arg1, U32 arg2, U32 arg3, ...) +{ + ARG4DATA arg; + int bufsize; + + RLOG_SAVE_TIME(arg.logData.logTime); + + arg.logData.logId = logId; + arg.logData.argType = LOG_ARG_INT; + arg.logData.logLevel = logLevel; + arg.logData.numOfArgs = 3; + arg.logData.len = 3 * sizeof(U32); + + arg.arg1 = arg1; + arg.arg2 = arg2; + arg.arg3 = arg3; + + bufsize = sizeof(LOGDATA)+arg.logData.len; + + saveLogData((const void*)&arg, bufsize,g_rlogPositionIndex++); +} +void logLev4( LOGID logId, R_LOG_LEVEL logLevel, U32 arg1, U32 arg2, U32 arg3, U32 arg4, ...) +{ + ARG4DATA arg; + + RLOG_SAVE_TIME(arg.logData.logTime); + + arg.logData.logId = logId; + arg.logData.argType = LOG_ARG_INT; + arg.logData.logLevel = logLevel; + arg.logData.numOfArgs = 4; + arg.logData.len = 4 * sizeof(U32); + + arg.arg1 = arg1; + arg.arg2 = arg2; + arg.arg3 = arg3; + arg.arg4 = arg4; + + saveLogData((const void*)&arg, sizeof(ARG4DATA),g_rlogPositionIndex++); +} + +#endif /* BINARY LOGGING */ + +#if defined(RLOG_ENABLE_TEXT_LOGGING) +struct tm* getTime(int* microseconds) +{ +#ifndef SS_LINUX + struct timespec ptime; +#else + struct timeval ptime; +#endif + +#ifndef SS_LINUX + clock_gettime(CLOCK_REALTIME, &ptime); + *microseconds = ptime.tv_nsec / 1000; +#else + gettimeofday(&ptime, NULL); + *microseconds = ptime.tv_usec; +#endif + + /* Obtain the time of day, and convert it to a tm struct. --*/ + return localtime (&ptime.tv_sec); +} +#elif !defined(RLOG_USE_TTI_LOGGING) +static void getLogTime(LOGTIME* logTime) +{ +#ifndef SS_LINUX + struct timespec ptime; +#else + struct timeval ptime; +#endif + +#ifndef SS_LINUX + clock_gettime(CLOCK_REALTIME, &ptime); + logTime->ms_tti = ptime.tv_nsec / 1000; +#else + gettimeofday(&ptime, NULL); + logTime->ms_tti = ptime.tv_usec/1000; +#endif + + logTime->tv_sec = ptime.tv_sec; +} + +#endif + +void getLogTimeStr(char* ts) +{ +#ifndef SS_LINUX + struct timespec ptime; +#else + struct timeval ptime; +#endif + struct tm* tm; + int microseconds; + +#ifndef SS_LINUX + clock_gettime(CLOCK_REALTIME, &ptime); + microseconds = ptime.tv_nsec / 1000; +#else + gettimeofday(&ptime, NULL); + microseconds = ptime.tv_usec/1000; +#endif + + /* Obtain the time of day, and convert it to a tm struct. --*/ + tm = localtime (&ptime.tv_sec); + + if (tm) sprintf(ts,"%d_%d_%d_%d_%d_%d.%03d", tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, + tm->tm_hour, tm->tm_min,tm->tm_sec,microseconds); +} +/////////////////////////////////////////////////////////////////////////////////////////////////// +// +// +/////////////////////////////////////////////////////////////////////////////////////////////////// + +void rlEnaBleBufferedIO(void) +{ + setvbuf (g_fp, NULL, _IOFBF, 1024 ); +} + +void createNewLogFile() +{ + FILE *fp, *prev_fp = g_fp; + char curTime[RLOG_MAX_TIME_STAMP]; int fd; + char *temptr; + /* Fix for CR ccpu00143040 */ + DIR *dir = NULLP; + + /* get current time, when file is created */ + getLogTimeStr(curTime); + temptr = strchr(curTime, '.'); + if (temptr != NULLP) + { + *temptr = 0; + } + /* Fix for CR ccpu00143040 */ + dir = opendir(g_logDir); + if ( dir == NULLP ) + { + mkdir(g_logDir, O_RDWR); + } + else + { + closedir(dir); + } + /* remove old file from system */ + if( g_fileList[g_nCurrFileIdx][0] != '\0' ) + unlink(g_fileList[g_nCurrFileIdx]); + +#ifdef RLOG_ENABLE_TEXT_LOGGING + /* create file name, Example-> dbglog_2013_08_11_15_30_00 */ + snprintf(g_fileList[g_nCurrFileIdx],MAX_FILENAME_LEN, "%s/%s_%s.txt",g_logDir, g_fileName, curTime ); + fp = fopen(g_fileList[g_nCurrFileIdx], "w+"); +#else + snprintf(g_fileList[g_nCurrFileIdx],MAX_FILENAME_LEN, "%s/%s_%s.bin",g_logDir, g_fileName, curTime ); + fp = fopen(g_fileList[g_nCurrFileIdx], "ab+"); +#endif + + if( fp == NULL ) { + fprintf(stderr, "Failed to open log file %s\n", g_fileList[g_nCurrFileIdx]); + return; + } + + fd = fileno(fp); + + g_fp = fp; + g_fd = fd; + + if( fcntl(g_fd, F_SETFL, fcntl(g_fd, F_GETFL, 0) | O_NONBLOCK | O_ASYNC ) == -1 ) { + fprintf(stderr, "RLOG: Cannot enable Buffer IO or make file non-blocking\n"); + } + +#ifdef RLOG_ENABLE_TEXT_LOGGING + setvbuf ( fp , NULL, _IOLBF, 1024 ); +#else + setvbuf ( fp , NULL, _IONBF, 1024 ); +#endif + +#ifndef RLOG_ENABLE_TEXT_LOGGING + storeFileHeader(fp); +#endif + + if( prev_fp != NULL ) + fclose(prev_fp); + + if( ++g_nCurrFileIdx == g_nMaxLogFiles ) + g_nCurrFileIdx = 0; + +#ifndef RLOG_ENABLE_TEXT_LOGGING +#ifdef RLOG_USE_TTI_LOGGING + logLev1(L_TIME_REFERENCE, L_ALWAYS, (U32)time(NULL)); +#endif +#endif +} + +void createL2LogFile() +{ + FILE *fp, *prev_fp = g_fp; + int fd; + char file[MAX_FILENAME_LEN]; + + strncpy(g_logDir, "/root/", MAX_FILENAME_LEN); + strncpy(g_fileName, "dbglog_l2", MAX_FILENAME_LEN); + snprintf(file, sizeof(file), "%s/%s.txt", g_logDir, g_fileName); + + fp = fopen(file, "w+"); + if( fp == NULL) { + printf("Failed to open file %s", file); + _exit(0); + } + + printf("Created L2 bin file FD=%s\n", g_fileName); + + setvbuf (fp , NULL, _IONBF, 1024 ); + + fd = fileno(fp); + + g_fp = fp; + g_fd = fd; + + if( fcntl(g_fd, F_SETFL, fcntl(g_fd, F_GETFL, 0) | O_NONBLOCK | O_ASYNC ) == -1 ) { + fprintf(stderr, "RLOG: Cannot enable Buffer IO or make file non-blocking\n"); + } + + setvbuf ( fp , NULL, _IOLBF, 1024 ); + + if( prev_fp != NULL ) + fclose(prev_fp); + + if( ++g_nCurrFileIdx == g_nMaxLogFiles ) + g_nCurrFileIdx = 0; + + +} + +////////////////////////////////////////////////////////////////////////// +// @Function : rlUdateRlogTti +// @Discription : This function will be called every 10 ms whenever +// application layer update the tti count +// @in : void +// @out : void +////////////////////////////////////////////////////////////////////////// +void rlUpdateRlogTti(Void) +{ +#ifndef RLOG_ENABLE_TEXT_LOGGING +#ifdef RLOG_USE_TTI_LOGGING + logLev1(L_TIME_TTI_UPDT, L_ALWAYS, (U32)time(NULL)); +#endif +#endif +} + +/* This function processes log buffer received from L2 + mBuf is Received from L2 through SPstTsk. This function + extracts buffer pointer and logLen and then these logs + written to L3 log buffer/file. + This function is called in application layer when EVTL2LOGBUF + event is recieved from ssi +*/ + +#ifdef ANSI +PUBLIC Void rlProcessLogBufFromL2 +( + void *mBuf + ) +#else +PUBLIC Void rlProcessLogBufFromL2(mBuf) + void *mBuf; +#endif +{ +#ifndef RLOG_ENABLE_TEXT_LOGGING + U32 logLength; + Data* logPtr; + startL2Logging = 1; + if(mBuf == NULL) + { + printf("NULL MBUF received \n"); + RETVOID; + } + /* Get Buffer pointer and length. This is SOC specific function which + will extract Log-Buffer pointer and length from mBuf */ + rlGetL2LogBufPtr(mBuf, &logLength,&logPtr); + rlSetL2LogBuf(logPtr,logLength); + readL2LogBuff(); +#endif + RETVOID; +} + +/* This function will get tick from RLC/CL and will process logs + according to tick threshold. Tick threshold is SOC specific */ +PUBLIC Void rlProcessTicks(void) +{ + static U32 rlogTickCount; + numTtiTicks++; + if(++rlogTickCount >= RLOGTICKSCNTTOPRCL2LOGS) + { + rlogTickCount = 0; + rlResetLogRateLmt(); /* Resetting rlog write count to 0 */ + + /* Tick count reached configured ticks to send L2 logs, + Send existing log buffer to Application and create + new log buffer to write logs */ + if (SFndProcId() == TENB_L2_PROC_ID) + { +#ifndef RLOG_ENABLE_TEXT_LOGGING + processL2LogBuff(); /* This processing of log buffer is done on L2 only + This is SOC specific function and use to send + log buffers to L3 and reset buffer pointer to + write logs */ +#else + /* Write functions specific to Text logging in cpul */ +#endif + } + else + { + /* L3 specific functions */ + } + } + RETVOID; +} + +#ifndef RLOG_ENABLE_TEXT_LOGGING +////////////////////////////////////////////////////////////////////////// +// @Function : readL2LogBuff +// @Description : This function first validates received Log Buffer and +// length from L2 and then writes L2 log buffer into L3 +// circular buffer. After reading it invalidates cache and +// also resets global Log buffer pointer and lenth variable. +// @in : void +// @out : void +////////////////////////////////////////////////////////////////////////// + +PUBLIC Void readL2LogBuff(void) +{ + /* Validate global buffer pointer and length */ + U8 ret; + ret = rlValidateL2LogBuf(); + if(ret != ROK) + { + printf(" Validation failed for log buffer/len \n"); + return; + } + g_writeCirBuf = 1; + saveLogDataFromCpul(g_logBufRcvdFromL2 , g_logBufLenRcvdFromL2 ); + /* TODO: Write SOC Specific function to invalidate cache */ + rlInvalidateL2LogsInCache(g_logBufRcvdFromL2 - sizeof(g_logBufLenRcvdFromL2) , (g_logBufLenRcvdFromL2 + sizeof(g_logBufLenRcvdFromL2))); + rlResetL2LogBuf(); + g_writeCirBuf = 0; + RETVOID; +} + +////////////////////////////////////////////////////////////////////////// +// @Function : rlStopLogCountLimit +// @Description : This function validates L2 Log buffer,length, and start +// L2 logging flag. +// @in : void +// @out : void +////////////////////////////////////////////////////////////////////////// + +#ifdef ANSI +PUBLIC S16 rlValidateL2LogBuf(void) +#else +PUBLIC S16 rlValidateL2LogBuf(void) +#endif +{ + S16 ret = ROK; + if(g_logBufRcvdFromL2 == NULL) + { + printf("Log-Buffer received from L2 is NULL \n"); + ret = RFAILED; + } + if(g_logBufLenRcvdFromL2 == 0) + { + printf("Log-Buffer Length received from L2 is 0 \n"); + ret = RFAILED; + } + if(startL2Logging == 0) + { + printf("startL2Logging flag is still inactive \n"); + ret = RFAILED; + } + + return(ret); +} + +////////////////////////////////////////////////////////////////////////// +// @Function : rlStopLogCountLimit +// @Description : This function set global log Buffer pointer & length +// @in : l2LogBuf - Log Buffer to be set in global pointer +// l2LogLen - Log length to be set in global lenth +// @out : void +////////////////////////////////////////////////////////////////////////// + +#ifdef ANSI +PUBLIC void rlSetL2LogBuf +( +U8 *l2LogBuf, +U32 l2logLen +) +#else +PUBLIC void rlSetL2LogBuf(l2LogBuf,l2logLen) +U8 *l2LogBuf; +U32 l2logLen; +#endif +{ + g_logBufRcvdFromL2 = l2LogBuf; + g_logBufLenRcvdFromL2 = l2logLen; +} + +////////////////////////////////////////////////////////////////////////// +// @Function : rlStopLogCountLimit +// @Description : This function flushes global log Buffer pointer & length +// @in : void +// @out : void +////////////////////////////////////////////////////////////////////////// + +#ifdef ANSI +PUBLIC void rlResetL2LogBuf +( +void +) +#else +PUBLIC void rlResetL2LogBuf(void) +#endif +{ + g_logBufRcvdFromL2 = NULL; + g_logBufLenRcvdFromL2 = 0; +} + +#endif + +////////////////////////////////////////////////////////////////////////// +// @Function : rlStartLogCountLimit +// @Discription : This function will be called by EnbApp after Cell is UP. +// This function start the log cnt limit. i.e Number of logs +// getting logged into curcular will be restricted to 100 logs. +// @in : void +// @out : void +////////////////////////////////////////////////////////////////////////// + +void rlStartLogCountLimit(Void) +{ + g_rlogWriteCount = 0; + g_rlLogCntLimit = RL_LOG_COUNT_LIMIT_START; + printf("Start Log Restriction\n"); +} + +////////////////////////////////////////////////////////////////////////// +// @Function : rlStopLogCountLimit +// @Discription : This function will be called by EnbApp after Cell Shutdown +// is triggered. This will enable to get all logs of shutdown. +// This function stops the log cnt limit. i.e Restricition on +// Number of logs getting logged into curcular will be removed +// @in : void +// @out : void +////////////////////////////////////////////////////////////////////////// + +void rlStopLogCountLimit(Void) +{ + printf("Stop Log Restriction\n"); + g_rlLogCntLimit = RL_LOG_COUNT_LIMIT_STOP; +} + +////////////////////////////////////////////////////////////////////////// +// @Function : rlResetLogRateLmt +// @Discription : This function will be called every 10 ms whenever +// application layer update the tti count. To reset the +// log rate control. And Enable logging for next 10 ms +// @in : void +// @out : void +////////////////////////////////////////////////////////////////////////// + +void rlResetLogRateLmt(void) +{ + g_rlogWriteCount = 0; + g_logsDropCnt = 0; +} + +void initGlbDataAtL2(void) +{ + strncpy(g_logDir, "/root/", MAX_FILENAME_LEN); +} + +/********************************************************************** + End of file +**********************************************************************/ diff --git a/src/rlog/rl_rlog.h b/src/rlog/rl_rlog.h index 1f465ba69..eba2c2c69 100755 --- a/src/rlog/rl_rlog.h +++ b/src/rlog/rl_rlog.h @@ -85,6 +85,74 @@ typedef enum rlLogCntLmt RL_LOG_COUNT_LIMIT_STOP }RLLogCntLmt; +#ifndef RLOG_ENABLE_TEXT_LOGGING + +typedef enum +{ + L_TIME_REFERENCE=0, + L_TIME_DELIMITER, + L_SIGSEGV, + L_TIME_TTI_UPDT +} LOGID_TYPE; + +typedef struct +{ + time_t tv_sec; + U32 ms_tti; +} __attribute__ ((__packed__)) LOGTIME; + +typedef struct +{ + LOGID logId; /* 4 bytes | 32 bits */ + LOGTIME logTime; /* 8 bytes */ + unsigned int argType :2; + unsigned int logLevel :3; + unsigned int numOfArgs :3; + U16 len; +} __attribute__ ((__packed__)) LOGDATA; + +typedef struct +{ + LOGDATA logData; + char buf[MAX_LOG_BUF_SIZE]; +} __attribute__ ((__packed__)) ARGDATA; + +typedef struct +{ + LOGDATA logData; + U32 arg1; + U32 arg2; + U32 arg3; + U32 arg4; + char unusedByte[19]; /* To make it as 50 byte */ +} __attribute__ ((__packed__)) ARG4DATA; + +typedef struct +{ + LOGDATA logData; + U8 splEnum; + U32 splArg; + U32 arg1; + U32 arg2; + U32 arg3; + U32 arg4; + char unusedByte[14]; /* To make it as 50 byte */ +} __attribute__ ((__packed__)) SPL_ARGDATA; + +typedef enum _endian {little_endian, big_endian} EndianType; + +typedef struct +{ + U16 version; + U32 dummy32; + U8 endianType; + char szTimeZone[RLOG_TIME_ZONE_LEN+1]; + U16 END_MARKER; + time_t time_sec; +} __attribute__ ((__packed__)) FILE_HEADER; + +#endif /* RLOG_ENABLE_TEXT_LOGGING */ + typedef struct { char szTaskName[RLOG_MAX_TAX_NAME]; diff --git a/src/rlog/rl_soc.c b/src/rlog/rl_soc.c new file mode 100644 index 000000000..f670b5bbe --- /dev/null +++ b/src/rlog/rl_soc.c @@ -0,0 +1,168 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/********************************************************************20** + + Name: Radisys Logging Framework + Type: C source file + Desc: This file contains logging framework implementation. + File: rl_soc.c + +*********************************************************************21*/ +/********************************************************************** + @ description: This source file has SOC specific functions required for + logging framework +************************************************************************/ +#include "envopt.h" +#include "envdep.h" + +#include "rl_interface.h" +#include "rl_rlog.h" +#include "rl_platform.h" + +#include "gen.h" +#include "ssi.h" +#include "ss_msg.h" +#include "ss_task.h" +#include "gen.x" +#include "ssi.x" +#include "ss_queue.h" +#include "ss_queue.x" +#include "ss_task.x" +#include "ss_msg.x" +#include "cm_inet.h" +#include "cm_inet.x" + +#include "rl_soc.h" + +////////////////////////////////////////////////////////////////////////// +// @Function : rlInitL2Log +// @Description : This will be trigigered from cl init function to +// allocate buffer from shared memory and to intialize +// the buffer +// @in : void +// @out : void +////////////////////////////////////////////////////////////////////////// + +PUBLIC void rlInitL2SocSpecific(void) +{ +#ifndef RLOG_ENABLE_TEXT_LOGGING + + if (SGetStaticBuffer(0, /* region - value does not matter in this case */ + 0, /* pool - value does not matter in this case */ + &g_l2rlogBuf, + L2LOG_BUFF_BLOCK_SIZE, /* Buffer size to be allocated */ + 0) != ROK) /* Memory type is SS_SHARABLE_MEMORY */ + { + printf("Memory allocation failed for g_l2rlogBuf!!!\n"); + /* kill binary */ + } + memset(g_l2rlogBuf, 0, L2LOG_BUFF_SIZE); + + g_l2LogBufBasePtr = g_l2rlogBuf; + g_l2LogBufStartPtr = g_l2rlogBuf + sizeof(g_l2LogBufLen); + +#endif + RETVOID; +} + +////////////////////////////////////////////////////////////////////////// +// @Function : processL2LogBuff +// @Description : This function will get triggered after every 10 tti +// and this will reset log buffers for L2 and also sends log +// buffer to L3 which was collected +// @in : void +// @out : void +////////////////////////////////////////////////////////////////////////// + +PUBLIC void processL2LogBuff(void) +{ +#ifndef RLOG_ENABLE_TEXT_LOGGING + if(g_l2LogBufLen > 0) + { + Data *l2rlogBuf_post; + + /* Log buffer position in flat buffer. If position is last wrap to first buffer */ + if (g_l2logBuffPos++ >=4) + { + g_l2logBuffPos = 0; + } + + g_writeCirBuf = 1; /* This will avoid contention while switching log buffers */ + + l2rlogBuf_post = g_l2LogBufBasePtr; /* copy logBufferPointer for later use */ + /* Set L2 Log Buffer length in first 4 bytes of flat buffer */ + *((U32*) g_l2LogBufBasePtr) = g_l2LogBufLen; /* Set L2 Log Buffer length in + first 4 bytes of flat buffer */ + + /* Re-setting pointer so that L2 will use this to write logs */ + g_l2LogBufBasePtr = g_l2rlogBuf + (g_l2logBuffPos * L2LOG_BUFF_BLOCK_SIZE) ; + g_l2LogBufStartPtr = g_l2LogBufBasePtr + sizeof(g_l2LogBufLen); + + g_l2LogBufLen = 0; + + g_writeCirBuf = 0; /* This will avoid contention while switching log buffers */ + + } +#endif + RETVOID; +} + +////////////////////////////////////////////////////////////////////////// +// @Function : rlGetL2LogBufPtr +// @Description : This function reads LogBufPointer and Length of log Buffer +// and stores pointer and length variable so that these +// values can be used while reading L2 Log Buffer +// @in : mBuf - Log Buffer +// @out : logLen - Length of log Buffer +// logPtr - Address of log Buffer +////////////////////////////////////////////////////////////////////////// + +PUBLIC void rlGetL2LogBufPtr +( + void *mBuf, + U32 *logLen, + Data **logPtr +) +{ + /* Get Buffer pointer and length */ + *logPtr = ((Data *)mBuf) + sizeof(logLen); + *logLen = *((U32 *) mBuf); +} + +////////////////////////////////////////////////////////////////////////// +// @Function : rlInvalidateL2LogsInCache +// @Description : Dummy function which is not used for this SOC. +// +// @in : ptr - starting address to be invalidated. +// len - Length to be invalidated. +// @out : void +////////////////////////////////////////////////////////////////////////// + +PUBLIC void rlInvalidateL2LogsInCache +( + Data *ptr, + U32 len +) +{ + RETVOID; +} + +/********************************************************************** + End of file +***********************************************************************/ diff --git a/src/rlog/rl_soc.h b/src/rlog/rl_soc.h new file mode 100755 index 000000000..d0a8e52e4 --- /dev/null +++ b/src/rlog/rl_soc.h @@ -0,0 +1,50 @@ +/******************************************************************************* +################################################################################ +# Copyright (c) [2017-2019] [Radisys] # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ +*******************************************************************************/ + +/********************************************************************20** + + Name: Radisys Logging Framework + Type: C source file + Desc: This file contains logging framework implementation. + File: rl_soc.c + +*********************************************************************21*/ +/********************************************************************** + @ description: This source file has SOC specific functions required for + logging framework +************************************************************************/ + +#define L2LOG_BUFF_SIZE 10000 +#define L2LOG_BUFF_BLOCK_SIZE L2LOG_BUFF_SIZE/4 +#define RLOGTICKSCNTTOPRCL2LOGS 10 +#define TENB_L2_PROC_ID 1 +#define RLOG_LIMIT_L2_COUNT 100 +#define RLOG_LIMIT_L3_COUNT 500 + +PUBLIC void rlInitL2SocSpecific(void); +PUBLIC void processL2LogBuff(void); +PUBLIC void rlGetL2LogBufPtr(void *mBuf,U32 *logLen,Data **logPtr); +PUBLIC void rlInvalidateL2LogsInCache(Data *ptr,U32 len); + +extern void rlInitL2SocSpecific(void); +extern void processL2LogBuff(void); +extern void rlGetL2LogBufPtr(void *mBuf,U32 *logLen,Data **logPtr); + +/********************************************************************** + End of file +**********************************************************************/ -- 2.16.6