[Feature][Modem]Update MTK MODEM V1.6 baseline version: MOLY.NR15.R3.MD700.IVT.MP1MR3.MP.V1.6

MTK modem version: MT2735_IVT_MOLY.NR15.R3.MD700.IVT.MP1MR3.MP.V1.6.tar.gz
RF  modem version: NA

Change-Id: I45a4c2752fa9d1a618beacd5d40737fb39ab64fb
diff --git a/mcu/interface/service/qmu_bm/binnum.h b/mcu/interface/service/qmu_bm/binnum.h
new file mode 100644
index 0000000..ee83222
--- /dev/null
+++ b/mcu/interface/service/qmu_bm/binnum.h
@@ -0,0 +1,127 @@
+/*****************************************************************************
+*  Copyright Statement:
+*  --------------------
+*  This software is protected by Copyright and the information contained
+*  herein is confidential. The software may not be copied and the information
+*  contained herein may not be used or disclosed except with the written
+*  permission of MediaTek Inc. (C) 2012
+*
+*  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+*  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+*  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+*  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+*  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+*  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+*  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+*  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+*  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+*  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+*  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+*  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+*  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+*  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+*  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+*  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+*  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+*  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+*  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+*  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+*  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+*  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ * Filename:
+ * ---------
+ *   binnum.h
+ *
+ * Project:
+ * --------
+ *   MOLY
+ *
+ * Description:
+ * ------------
+ *
+ *
+ * Author:
+ * -------
+ * -------
+ *   
+ *
+ * ==========================================================================
+ * $Log$
+ ****************************************************************************/
+/**
+ * 	@file binnum.h
+ *	@brief binary number utilities 
+ *	@author Howard Chen
+ * 
+ */
+#ifndef BINNUM_DEF
+#define BINNUM_DEF
+
+#define BU_LOG2(_v)				(((_v)==64)? 6:					\
+									((_v)==32)? 5: 				\
+										((_v)==16)? 4: 			\
+											((_v)==8)? 3: 		\
+												((_v)==4)? 2: 	\
+													((_v)==2)? 1:	\
+														((_v)==0)? 0: -1)
+
+#define BU_T_MSK(_n)				((1<<(_n))-1)
+#define BU_F_MSK(_ms,_ls)			(BU_T_MSK((_ms)-(_ls)+1)<<(_ls))
+#define BU_B_MSK(_n)				(1 << (_n))
+#define BU_WID(_ms,_ls)				((_ms)-(_ls)+1)
+
+#define BU_ALN(_i, _n)				((_i) & ~BU_T_MSK(_n))
+
+#define BU_RUP(_i, _n)				BU_ALN((_i)+BU_T_MSK(_n), _n)
+
+/**
+ *	@brief trucate <_i> to <_n> bits
+ */
+#define BU_TRU(_i, _n)				((_i) & BU_T_MSK(_n))
+
+/**
+ *	@brief get (<_ms>:<_ls>) field
+ */
+#define BU_G_FLD(_i,_ms,_ls)	    (((_i)<<(31-(_ms))) >> (31- (_ms) + (_ls)))
+
+/**
+ *	@brief or (<_ms>:<_ls>) field
+ */
+#define BU_O_FLD(_i,_ms,_ls,_v)   	((_i)|((BU_TRU(_v,BU_WID(_ms,_ls))<<(_ls))))
+
+/**
+ *	@brief clean (<_ms>:<_ls>) field
+ */
+#define BU_C_FLD(_i,_ms,_ls)		((_i) & ~BU_F_MSK(_ms,_ls))
+
+/**
+ *	@brief replace (<_ms>:<_ls>) field with <_v>
+ */
+#define BU_R_FLD(_i,_ms,_ls,_v)		((((_i)&~BU_F_MSK(_ms,_ls)))|((BU_TRU(_v,BU_WID(_ms,_ls))<<(_ls))))
+/**
+ *	@brief get <_n> bit
+ */
+#define BU_G_BIT(_i,_n)				BU_G_FLD(_i, _n, _n)
+
+/**
+ *	@brief or <_n> bit with 0x1
+ */
+#define BU_O_BIT(_i,_n)				((_i) |(1 << (_n)))
+
+/**
+ *	@brief clean <_n> bit
+ */
+#define BU_C_BIT(_i,_n)				((_i) & ~BU_B_MSK(_n))
+
+/**
+ *	@brief replace <_n> bit with <_v>
+ */
+#define BU_R_BIT(_i,_n,_v)			(((_i)&~BU_B_MSK(_n))|(((_v)&0x1)<<(_n)))
+
+#endif
diff --git a/mcu/interface/service/qmu_bm/qbm_config.h b/mcu/interface/service/qmu_bm/qbm_config.h
new file mode 100644
index 0000000..fd86a73
--- /dev/null
+++ b/mcu/interface/service/qmu_bm/qbm_config.h
@@ -0,0 +1,83 @@
+/*****************************************************************************
+*  Copyright Statement:
+*  --------------------
+*  This software is protected by Copyright and the information contained
+*  herein is confidential. The software may not be copied and the information
+*  contained herein may not be used or disclosed except with the written
+*  permission of MediaTek Inc. (C) 2012
+*
+*  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+*  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+*  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+*  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+*  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+*  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+*  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+*  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+*  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+*  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+*  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+*  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+*  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+*  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+*  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+*  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+*  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+*  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+*  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+*  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+*  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+*  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+/*******************************************************************************
+ * Filename:
+ * ---------
+ * qbm_config.h
+ *
+ * Project:
+ * --------
+ * MOLY
+ *
+ * Description:
+ * ------------
+ * QBM configure files.
+ *
+ * Author:
+ * -------
+ * -------
+ *   
+ *
+ * ==========================================================================
+ * $Log$
+ *
+ * 05 21 2015 stan.chen
+ * [MOLY00114732] [6291] MD Support RXSPD and 3KMTU
+ * [QBM] Support HIF_UL_SPD.
+ *
+ * 03 04 2015 stan.chen
+ * [MOLY00097681] [UMOLY][QBM] Add option for ATEST_DRV
+ * 	Check-in trunk.
+ *
+ * 11 11 2014 stan.chen
+ * [MOLY00079805] [TK6291_DEV] Support QBM/DNAS SPD LogDMA
+ * Merging QMU_BM from 91_DEV
+ *
+ * 07 02 2014 stan.chen
+ * [MOLY00068661] [TK6291_DEV] LTE Latest Code Sync from MOLY
+ * Correct the wrong option wrapping.
+ *
+ * 04 25 2014 moja.hsu
+ * [MOLY00061877] [TK6291]driver initial porting for TK6291
+ * reduce basic load BM memory.
+ *
+ *****************************************************************************/
+
+#if defined(__MAUI_BASIC__) && !defined(ATEST_DRV_ENABLE)
+#include "qbm_config_basic.h"
+#else
+#include "qbm_config_normal.h"
+#endif
+
diff --git a/mcu/interface/service/qmu_bm/qbm_config_basic.h b/mcu/interface/service/qmu_bm/qbm_config_basic.h
new file mode 100644
index 0000000..b6ced71
--- /dev/null
+++ b/mcu/interface/service/qmu_bm/qbm_config_basic.h
@@ -0,0 +1,99 @@
+/*****************************************************************************
+*  Copyright Statement:
+*  --------------------
+*  This software is protected by Copyright and the information contained
+*  herein is confidential. The software may not be copied and the information
+*  contained herein may not be used or disclosed except with the written
+*  permission of MediaTek Inc. (C) 2012
+*
+*  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+*  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+*  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+*  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+*  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+*  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+*  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+*  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+*  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+*  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+*  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+*  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+*  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+*  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+*  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+*  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+*  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+*  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+*  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+*  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+*  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+*  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ * Filename:
+ * ---------
+ *   qbm_config_basic.h
+ *
+ * Project:
+ * --------
+ *   MOLY
+ *
+ * Description:
+ * ------------
+ *  QBM configure files for basic load.
+ *  Since basic load only need little memory.
+ *
+ * Author:
+ * -------
+ * -------
+ *   
+ *
+ * ==========================================================================
+ * $Log$
+ *
+ ****************************************************************************/
+
+#define QBM_PD_NUM 10
+/*************************BM Pool CFG Begin****************/
+/*BM Buffer type*/
+bmcfg_type(QBM_TYPE_TGPD) 
+/*The buffer number*/
+bmcfg_num(QBM_PD_NUM) 
+/*The size of one buffer*/
+bmcfg_one_size(QBM_SIZE_TGPD) 
+/*Config do cache invalid for the data part when do de-q-rx*/
+bmcfg_cache_invalid(KAL_FALSE) 
+/*Config do cache flush the data part when do en-q-tx*/
+/*  Put all non-cache flush buffers on the front.*/
+bmcfg_cache_flush(KAL_FALSE) 
+/*************************BM Pool CFG END******************/
+
+/*************************BM Pool CFG Begin****************/
+/*BM Buffer type*/
+bmcfg_type(QBM_TYPE_TBD) 
+/*The buffer number*/
+bmcfg_num(QBM_PD_NUM) 
+/*The size of one buffer*/
+bmcfg_one_size(QBM_SIZE_TBD) 
+/*Config do cache invalid for the data part when do de-q-rx*/
+bmcfg_cache_invalid(KAL_FALSE) 
+/*Config do cache flush the data part when do en-q-tx*/
+bmcfg_cache_flush(KAL_FALSE) 
+/*************************BM Pool CFG END******************/
+
+/*************************BM Pool CFG Begin****************/
+/*BM Buffer type*/
+bmcfg_type(QBM_TYPE_TGPD_BPS) 
+/*The buffer number*/
+bmcfg_num(QBM_PD_NUM) 
+/*The size of one buffer*/
+bmcfg_one_size(QBM_SIZE_TGPD_BPS) 
+/*Config do cache invalid for the data part when do de-q-rx*/
+bmcfg_cache_invalid(KAL_FALSE) 
+/*Config do cache flush the data part when do en-q-tx*/
+bmcfg_cache_flush(KAL_FALSE) 
+/*************************BM Pool CFG END******************/
diff --git a/mcu/interface/service/qmu_bm/qbm_config_normal.h b/mcu/interface/service/qmu_bm/qbm_config_normal.h
new file mode 100644
index 0000000..1efba1c
--- /dev/null
+++ b/mcu/interface/service/qmu_bm/qbm_config_normal.h
@@ -0,0 +1,365 @@
+/*****************************************************************************
+*  Copyright Statement:
+*  --------------------
+*  This software is protected by Copyright and the information contained
+*  herein is confidential. The software may not be copied and the information
+*  contained herein may not be used or disclosed except with the written
+*  permission of MediaTek Inc. (C) 2012
+*
+*  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+*  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+*  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+*  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+*  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+*  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+*  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+*  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+*  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+*  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+*  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+*  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+*  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+*  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+*  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+*  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+*  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+*  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+*  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+*  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+*  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+*  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ * Filename:
+ * ---------
+ *   qbm_config_normal.h
+ *
+ * Project:
+ * --------
+ *   MOLY
+ *
+ * Description:
+ * ------------
+ *  QBM configure files.
+ *  NOTE:
+ *  For cache flush more efficiency.
+ *  Put all non-cache flush buffers on the front.
+ *
+ * Author:
+ * -------
+ * -------
+ *   
+ *
+ * ==========================================================================
+ * $Log$
+ *
+ * 11 13 2020 konark.mehra
+ * [MOLY00474811] [QMU_BM] Add new queue for NCCCI
+ * 	
+ * 	Add new queue for NCCCI
+ *
+ * 11 13 2020 konark.mehra
+ * [MOLY00474811] [QMU_BM] Add new queue for NCCCI
+ * 	
+ * 	Add new queue for NCCCI
+ *
+ * 06 14 2019 viney.kaushik
+ * [MOLY00407954] ??: RE: [OPPO P70][OPPO P90] MD patch?? - DUT receiver not working while on MO/MT call
+ * 	
+ * 	enable QBM_TYPE_NET_UL pool & configure it same as QBM_TYPE_NET_UL_SHRD.
+ *
+ * 05 10 2017 wen-jiunn.liu
+ * [MOLY00248479] [QBM] QBM Size Reduction
+ * qmu_bm reconfigure memory size for SLIM 
+ * 	
+ * 	QBM_TYPE_TTY_TYPE1: Wrapped by __TTY_UT__ (Normal Load Not Used Queue)
+ * 	QBM_TYPE_TTY_INT : SET NUM to 100
+ *
+ * 10 19 2016 wen-jiunn.liu
+ * [MOLY00208021] [UMOLYA] QMU_BM Code Review
+ * remove redundant codes
+ *
+ * 10 19 2016 wen-jiunn.liu
+ * [MOLY00208021] [UMOLYA] QMU_BM Code Review
+ * QMU_BM retires obsolete queues and mechanisms of buffers in flcv2 (ut pass)
+ *
+ * 01 21 2016 eric.hsieh
+ * [MOLY00160421] [MT6292] ePDCP CE RAM Optimization
+ * 92 EPDCP CE RAM Optimization.
+ *
+ * 01 04 2016 eric.hsieh
+ * [MOLY00152722] [WFC][CLDMA][QBM][volunteer patch] add IMS_UL QBM type and apply in CLDMA(QBM part)
+ * QBM IMS_UL check-in to UMOLY trunk.
+ *
+ * 05 21 2015 stan.chen
+ * [MOLY00114732] [6291] MD Support RXSPD and 3KMTU
+ * [QBM] Support HIF_UL_SPD.
+ *
+ * 08 29 2014 stan.chen
+ * [MOLY00074154] 6290 FLC RAM slim
+ * 	Merge patch from MOLY.
+ *
+ * 06 23 2014 stan.chen
+ * [MOLY00070195] [TK6291] Add Interfaces of SPD handling
+ * 	Add new interfaces of QBM: Support SPDs.
+ *
+ * 06 06 2014 stan.chen
+ * [MOLY00068661] [TK6291_DEV] LTE Latest Code Sync from MOLY
+ * Merging
+ * 	//MOLY/TRUNK/MOLY/mcu/service/qmu_bm/...
+ * 	to //UMOLY/DEV/TK6291_DEV/mcu/pcore/service/qmu_bm/...
+ * 	//MOLY/TRUNK/MOLY/mcu/interface/service/qmu_bm/...
+ * 	to //UMOLY/DEV/TK6291_DEV/mcu/pcore/interface/service/qmu_bm/...
+ *
+ * 05 14 2014 clark.peng
+ * [MOLY00063866] [ROME] data/ack multiple queues IT
+ * 1. QBM change data length of HIF_UL_TYPE_S from 64 to 128 for hooking this gpd type on CCMNI2. (wrapped by __CCCICCMNI_SUPPORT__)
+ * 	2. Map QBM_FLC_UL_POOL_ID_HIF_UL_02 to new FLC pool FLC2_POOL_ID_HIF_UL_02, which makes HIF_UL_TYPE and HIF_UL_TYPE_02 not sharing FLC pool.
+ * 	3. Do not toggle EMPTY TCP ACK in TFT_PF (wrapped by __CCCICCMNI_SUPPORT__)
+ * 	4. UPCM check priority by GPD type, instead of EMPTY TCP ACK bit toggled by TFT_PF (wrapped by __CCCICCMNI_SUPPORT__)
+ * 	5. Do not config queue for HIF_UL_TYPE_01
+ *
+ * 01 09 2014 clark.peng
+ * [MOLY00052994] TCP ACK packet replacement
+ * Add a new QBM type: QBM_TYPE_HIF_UL_TYPE_S for UL TCP ACK for better buffer usage efficiency.
+ *
+ * 08 29 2013 moja.hsu
+ * [MOLY00035765] Add Buffer Type QBM_TYPE_IMS_DL
+ * .
+ *
+ * 08 15 2013 moja.hsu
+ * [MOLY00033975] [MT6582LTE][TDD][2G/3G Bringup]
+ * prepare HIF_UL_TYPE, HIF_UL_TYPE_01, HIF_UL_TYPE_02.
+ *
+ * 05 15 2013 moja.hsu
+ * [MOLY00007625] Maintain code
+ * remoe MSD type from config init.
+ * MSD owner will use init_q by themself.
+ * Change MSD data len from 2048 to 1024..
+ *
+ * 02 21 2013 i-wei.tsai
+ * [MOLY00010632] add TTYCore new features
+ * modify compile flag for ttycore internal buffer
+ *
+ * 01 14 2013 moja.hsu
+ * [MOLY00007625] Maintain code
+ * add QBM_TYPE_MSD
+ *
+ * 01 10 2013 moja.hsu
+ * [MOLY00007625] Maintain code
+ * multi-mode data path support.
+ *
+ * 12 21 2012 tj.chang
+ * [MOLY00007810] CDCACM dail-up feature support
+ * [CDCACM] Add SIO_CMD_DCD command handling
+ *
+ * 11 08 2012 haoren.kao
+ * [MOLY00005322] TATAKA merge to MOLY
+ * 
+ * MOLY Migration from TATAKA
+ ****************************************************************************/
+/*
+ * =====================================================================================
+ *
+ *       Filename:  qbm_config.h
+ *
+ *    Description:  configure qbm pool.
+ *
+ *        Created:  2011/11/21 09:33:31
+ *        Author:  mtk01641 (moja)
+ * =====================================================================================
+ */
+
+#include "qbm_features.h"
+#include "qbm_config_num.h"
+
+/*************************BM Pool CFG Begin****************/
+/*BM Buffer type*/
+bmcfg_type(QBM_TYPE_TGPD) 
+/*The buffer number*/
+bmcfg_num(QBM_COMMON_NUM_TGPD) 
+/*The size of one buffer*/
+bmcfg_one_size(QBM_SIZE_TGPD) 
+/*Config do cache invalid for the data part when do de-q-rx*/
+bmcfg_cache_invalid(KAL_FALSE) 
+/*Config do cache flush the data part when do en-q-tx*/
+/*  Put all non-cache flush buffers on the front.*/
+bmcfg_cache_flush(KAL_FALSE) 
+/*************************BM Pool CFG END******************/
+
+/*************************BM Pool CFG Begin****************/
+/*BM Buffer type*/
+bmcfg_type(QBM_TYPE_TBD) 
+/*The buffer number*/
+bmcfg_num(QBM_COMMON_NUM_TBD) 
+/*The size of one buffer*/
+bmcfg_one_size(QBM_SIZE_TBD) 
+/*Config do cache invalid for the data part when do de-q-rx*/
+bmcfg_cache_invalid(KAL_FALSE) 
+/*Config do cache flush the data part when do en-q-tx*/
+bmcfg_cache_flush(KAL_FALSE) 
+/*************************BM Pool CFG END******************/
+
+/*************************BM Pool CFG Begin****************/
+/*BM Buffer type*/
+bmcfg_type(QBM_TYPE_TGPD_BPS) 
+/*The buffer number*/
+bmcfg_num(QBM_COMMON_NUM_TGPD_BPS) 
+/*The size of one buffer*/
+bmcfg_one_size(QBM_SIZE_TGPD_BPS) 
+/*Config do cache invalid for the data part when do de-q-rx*/
+bmcfg_cache_invalid(KAL_FALSE) 
+/*Config do cache flush the data part when do en-q-tx*/
+bmcfg_cache_flush(KAL_FALSE) 
+/*************************BM Pool CFG END******************/
+
+/*************************BM Pool CFG Begin****************/
+/*BM Buffer type*/
+bmcfg_type(QBM_TYPE_NET_DL) 
+/*The buffer number*/
+bmcfg_num(QBM_NUM_NET_DL) 
+/*The size of one buffer*/
+bmcfg_one_size(QBM_SIZE_NET_DL) 
+/*Config do cache invalid for the data part when do de-q-rx*/
+bmcfg_cache_invalid(KAL_FALSE) 
+/*Config do cache flush the data part when do en-q-tx*/
+bmcfg_cache_flush(KAL_FALSE) 
+/*************************BM Pool CFG END******************/
+
+
+/*************************BM Pool CFG Begin****************/
+/*BM Buffer type*/
+bmcfg_type(QBM_TYPE_NET_UL) 
+/*The buffer number*/
+bmcfg_num(QBM_NUM_NET_UL) 
+/*The size of one buffer*/
+bmcfg_one_size(QBM_SIZE_NET_UL) 
+/*Config do cache invalid for the data part when do de-q-rx*/
+bmcfg_cache_invalid(KAL_FALSE) 
+/*Config do cache flush the data part when do en-q-tx*/
+bmcfg_cache_flush(KAL_FALSE) 
+/*************************BM Pool CFG END******************/
+
+
+/*************************BM Pool CFG Begin****************/
+/*BM Buffer type*/
+bmcfg_type(QBM_TYPE_NET_UL_SHRD) 
+/*The buffer number*/
+bmcfg_num(QBM_NUM_NET_UL_SHRD) 
+/*The size of one buffer*/
+bmcfg_one_size(QBM_SIZE_NET_UL_SHRD) 
+/*Config do cache invalid for the data part when do de-q-rx*/
+bmcfg_cache_invalid(KAL_FALSE) 
+/*Config do cache flush the data part when do en-q-tx*/
+bmcfg_cache_flush(KAL_FALSE) 
+/*************************BM Pool CFG END******************/
+
+
+/*************************BM Pool CFG Begin****************/
+/*BM Buffer type*/
+bmcfg_type(QBM_TYPE_ACM) 
+/*The buffer number*/
+bmcfg_num(QBM_NUM_ACM)
+/*The size of one buffer*/
+bmcfg_one_size(QBM_SIZE_ACM)
+/*Config do cache invalid for the data part when do de-q-rx*/
+bmcfg_cache_invalid(KAL_FALSE) 
+/*Config do cache flush the data part when do en-q-tx*/
+bmcfg_cache_flush(KAL_FALSE) 
+/*************************BM Pool CFG END******************/
+
+/*-----------------------------------------------------------------------
+ |    Start from Cache Operation (need cache_invalid, and cache_flush)
+ ------------------------------------------------------------------------*/
+
+#if __HIF_CCCI_SUPPORT__
+/*************************BM Pool CFG Begin****************/
+/* 20120724 ian: QBM_TYPE_CCCI_COMM*/
+/* QBM_NUM_CCCI_COMM includes TTY internal used gpd */
+/*BM Buffer type*/
+bmcfg_type(QBM_TYPE_CCCI_COMM) 
+/*The buffer number*/
+bmcfg_num(QBM_NUM_CCCI_COMM) 
+/*The size of one buffer*/
+bmcfg_one_size(QBM_SIZE_CCCI_COMM) 
+/*Config do cache invalid for the data part when do de-q-rx*/
+bmcfg_cache_invalid(KAL_TRUE) 
+/*Config do cache flush the data part when do en-q-tx*/
+bmcfg_cache_flush(KAL_TRUE) 
+/*************************BM Pool CFG END******************/
+#endif
+
+/*************************BM Pool CFG Begin****************/
+/* 20151203 eric: QBM_TYPE_IMS_UL */
+/*BM Buffer type*/
+bmcfg_type(QBM_TYPE_IMS_UL) 
+/*The buffer number*/
+bmcfg_num(QBM_NUM_IMS_UL) 
+/*The size of one buffer*/
+bmcfg_one_size(QBM_SIZE_IMS_UL)  
+/*Config do cache invalid for the data part when do de-q-rx*/
+bmcfg_cache_invalid(KAL_TRUE) 
+/*Config do cache flush the data part when do en-q-tx*/
+bmcfg_cache_flush(KAL_TRUE) 
+/*************************BM Pool CFG END******************/
+
+/*************************BM Pool CFG Begin****************/
+/*BM Buffer type*/
+bmcfg_type(QBM_TYPE_TTY_INT) 
+/*The buffer number*/
+bmcfg_num(QBM_NUM_TTY_INT) 
+/*The size of one buffer*/
+bmcfg_one_size(QBM_SIZE_TTY_INT) 
+/*Config do cache invalid for the data part when do de-q-rx*/
+bmcfg_cache_invalid(KAL_TRUE) 
+/*Config do cache flush the data part when do en-q-tx*/
+bmcfg_cache_flush(KAL_TRUE) 
+/*************************BM Pool CFG END******************/
+
+#if defined(__TTY_UT__) || defined(__QBM_GTEST__)
+/*************************BM Pool CFG Begin****************/
+/*BM Buffer type*/
+bmcfg_type(QBM_TYPE_TTY_TYPE1) 
+/*The buffer number*/
+bmcfg_num(QBM_NUM_TTY_TYPE1) 
+/*The size of one buffer*/
+bmcfg_one_size(QBM_SIZE_TTY_TYPE1) 
+/*Config do cache invalid for the data part when do de-q-rx*/
+bmcfg_cache_invalid(KAL_TRUE) 
+/*Config do cache flush the data part when do en-q-tx*/
+bmcfg_cache_flush(KAL_TRUE) 
+/*************************BM Pool CFG END******************/
+#endif
+
+/*************************BM Pool CFG Begin****************/
+/*BM Buffer type*/
+bmcfg_type(QBM_TYPE_IMS_DL) 
+/*The buffer number*/
+bmcfg_num(QBM_NUM_IMS_DL)
+/*The size of one buffer*/
+bmcfg_one_size(QBM_SIZE_IMS_DL)
+/*Config do cache invalid for the data part when do de-q-rx*/
+bmcfg_cache_invalid(KAL_TRUE) 
+/*Config do cache flush the data part when do en-q-tx*/
+bmcfg_cache_flush(KAL_TRUE) 
+/*************************BM Pool CFG END******************/
+
+#if __HIF_CCCI_SUPPORT__
+/*************************BM Pool CFG Begin****************/
+/*BM Buffer type*/
+bmcfg_type(QBM_TYPE_NCCMNI_COMM) 
+/*The buffer number*/
+bmcfg_num(QBM_NUM_NCCMNI_COMM)
+/*The size of one buffer*/
+bmcfg_one_size(QBM_SIZE_NCCMNI_COMM)
+/*Config do cache invalid for the data part when do de-q-rx*/
+bmcfg_cache_invalid(KAL_TRUE) 
+/*Config do cache flush the data part when do en-q-tx*/
+bmcfg_cache_flush(KAL_TRUE) 
+/*************************BM Pool CFG END******************/
+#endif
+
diff --git a/mcu/interface/service/qmu_bm/qbm_config_num.h b/mcu/interface/service/qmu_bm/qbm_config_num.h
new file mode 100644
index 0000000..60e0f49
--- /dev/null
+++ b/mcu/interface/service/qmu_bm/qbm_config_num.h
@@ -0,0 +1,259 @@
+/*****************************************************************************
+*  Copyright Statement:
+*  --------------------
+*  This software is protected by Copyright and the information contained
+*  herein is confidential. The software may not be copied and the information
+*  contained herein may not be used or disclosed except with the written
+*  permission of MediaTek Inc. (C) 2012
+*
+*  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+*  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+*  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+*  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+*  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+*  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+*  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+*  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+*  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+*  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+*  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+*  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+*  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+*  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+*  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+*  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+*  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+*  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+*  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+*  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+*  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+*  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ * Filename:
+ * ---------
+ * qbm_config_num.h
+ *
+ * Project:
+ * --------
+ * MOLY
+ *
+ * Description:
+ * ------------
+ *
+ *
+ * Author:
+ * -------
+ * -------
+ *   
+ *
+ *============================================================================
+ *             HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *----------------------------------------------------------------------------
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *----------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+/*
+ * =====================================================================================
+ *
+ *       Filename:  qbm_config_num.h
+ *
+ *    Description:  Buffer number centeral control
+ *    User can put total number and init queue number definition here.
+ *
+ *        Created:  2012/1/13 W 11:32:34
+ *        Author:  mtk01641 (moja)
+ * =====================================================================================
+ */
+#ifndef  QMU_BM_CONFIG_NUM_INC
+#define  QMU_BM_CONFIG_NUM_INC
+
+#define QBM_COMMON_NUM_TGPD     600
+#define QBM_COMMON_NUM_TBD      600
+ /*
+  * worst case, one TCP Ack per frame.
+  * We need 800 for Ack pool, and 5xx for UL Type
+  * and remain for others. e.g. HIF DL Enqueue
+  */
+#define QBM_COMMON_NUM_TGPD_BPS 1400
+
+#define QBM_NUM_TTY_INT                 100
+
+#if __HIF_CCCI_SUPPORT__
+#define QBM_NUM_CCCI_COMM               200
+#define QBM_NUM_NCCMNI_COMM             30
+#endif
+
+#define QBM_NUM_IMS_UL                  64
+
+#define QBM_NUM_NET_DL      26              /* Number of downlink GPD for internal network protocols. */
+#define QBM_NUM_NET_UL      20              /* Number of uplink GPD for internal network protocols.   */
+#define QBM_NUM_NET_UL_SHRD 55       /* L4 + LTECSR = 10 + 20 + 20 [For 750ms PDCP Discard Timer] + 5[For Dispatcher]: Number of uplink GPD for IPCore(VoLTE, etc).*/
+
+#if defined(__TTY_UT__) || defined(__QBM_GTEST__)
+#define QBM_NUM_TTY_TYPE1 100
+#endif
+
+#define QBM_NUM_ACM       16                /* Number of ACM GPD */
+
+#define QBM_NUM_IMS_DL    16
+
+#endif   /* ----- #ifndef QMU_BM_CONFIG_NUM_INC  ----- */
+
diff --git a/mcu/interface/service/qmu_bm/qbm_features.h b/mcu/interface/service/qmu_bm/qbm_features.h
new file mode 100644
index 0000000..2b16658
--- /dev/null
+++ b/mcu/interface/service/qmu_bm/qbm_features.h
@@ -0,0 +1,87 @@
+/*****************************************************************************
+*  Copyright Statement:
+*  --------------------
+*  This software is protected by Copyright and the information contained
+*  herein is confidential. The software may not be copied and the information
+*  contained herein may not be used or disclosed except with the written
+*  permission of MediaTek Inc. (C) 2012
+*
+*  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+*  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+*  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+*  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+*  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+*  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+*  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+*  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+*  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+*  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+*  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+*  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+*  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+*  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+*  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+*  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+*  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+*  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+*  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+*  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+*  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+*  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ * Filename:
+ * ---------
+ *   qbm_features.h
+ *
+ * Project:
+ * --------
+ *   MOLY
+ *
+ * Description:
+ * ------------
+ *  To center control features. Only affect QBM user.
+ *
+ * Author:
+ * -------
+ * -------
+ *   
+ *
+ * ==========================================================================
+ * $Log$
+ *
+ * 10 19 2016 wen-jiunn.liu
+ * [MOLY00208021] [UMOLYA] QMU_BM Code Review
+ * remove redundant codes
+ *
+ * 10 19 2016 wen-jiunn.liu
+ * [MOLY00208021] [UMOLYA] QMU_BM Code Review
+ * QMU_BM retires obsolete queues and mechanisms of buffers in flcv2 (ut pass)
+ *
+ * 04 23 2013 moja.hsu
+ * [MOLY00013348] [MT6290 Bring-up] Basic Platform Support
+ * support multi-mode driver test environment, they don't have FLC now
+ *
+ * 04 23 2013 moja.hsu
+ * [MOLY00013348] [MT6290 Bring-up] Basic Platform Support
+ * support multi-mode driver test environment, They don't have FLC now
+ *
+ * 04 03 2013 jerry.ho
+ * [MOLY00013475] [MT6290 PO admit]  Checkin  MT6290 MM L1S build relative codes
+ * .
+ *
+ * 01 10 2013 moja.hsu
+ * [MOLY00007625] Maintain code
+ * multi-mode data path support.
+ ****************************************************************************/
+#ifndef  QBM_FEATURES_INC
+#define  QBM_FEATURES_INC
+
+#define QBM_DBG 1
+
+#endif   /* ----- #ifndef QBM_FEATURES_INC  ----- */
+
diff --git a/mcu/interface/service/qmu_bm/qbm_stats.h b/mcu/interface/service/qmu_bm/qbm_stats.h
new file mode 100644
index 0000000..066d885
--- /dev/null
+++ b/mcu/interface/service/qmu_bm/qbm_stats.h
@@ -0,0 +1,111 @@
+/*****************************************************************************
+*  Copyright Statement:
+*  --------------------
+*  This software is protected by Copyright and the information contained
+*  herein is confidential. The software may not be copied and the information
+*  contained herein may not be used or disclosed except with the written
+*  permission of MediaTek Inc. (C) 2012
+*
+*  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+*  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+*  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+*  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+*  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+*  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+*  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+*  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+*  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+*  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+*  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+*  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+*  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+*  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+*  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+*  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+*  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+*  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+*  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+*  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+*  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+*  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ * Filename:
+ * ---------
+ *   qbm_stats.h
+ *
+ * Project:
+ * --------
+ *   MOLY
+ *
+ * Description:
+ * ------------
+ *  Used for EM shown. 
+ *
+ *
+ * Author:
+ * -------
+ * -------
+ *   
+ *
+ * ==========================================================================
+ * $Log$
+ *
+ * 04 09 2018 wen-jiunn.liu
+ * [MOLY00318641] [MT6295][EL2] EM info structure refine
+ * [QMU_BM] Add em_info_enum field for EM_QBM_STATUS @ em_qbm_status_ind_struct
+ *
+ */
+
+#ifndef  QBM_STATS_INC
+#define  QBM_STATS_INC
+
+#include "qmu_bm_enum.h"
+#include "em_public_struct.h"
+
+typedef struct 
+{
+    kal_uint32 init_fail;
+
+    /*
+     * don't need to record free number,
+     * Because the queue won't be allocated if there is no free
+     */
+    kal_uint32 alloc_num;
+    kal_uint32 alloc_num_flc;
+    kal_uint32 alloc_nobuf;
+
+    /*
+     * only increased when the de_q has data.
+     */
+    kal_uint32 de_q_rx_times;
+
+    /*
+     * total buffers de-queued
+     */
+    kal_uint32 de_q_rx_num_total;
+    kal_uint32 de_q_rx_num_max;
+
+    /*
+     * User should use qbm_get_buff_remain_num to fill this filed 
+     * when he wants to deliver stats to Tool/AP
+     */
+    kal_uint32 rem_buff;
+} qbm_queue_stats;
+
+typedef struct 
+{
+    LOCAL_PARA_HDR
+
+    em_info_enum em_info;
+    qbm_queue_stats queue_stats[QBM_QUEUE_NUM];
+
+}em_qbm_status_ind_struct;
+
+extern em_qbm_status_ind_struct g_qbm_status;
+#endif   /* ----- #ifndef QBM_STATS_INC  ----- */
+
diff --git a/mcu/interface/service/qmu_bm/qmu_bm.h b/mcu/interface/service/qmu_bm/qmu_bm.h
new file mode 100644
index 0000000..e58fa23
--- /dev/null
+++ b/mcu/interface/service/qmu_bm/qmu_bm.h
@@ -0,0 +1,613 @@
+/*****************************************************************************
+*  Copyright Statement:
+*  --------------------
+*  This software is protected by Copyright and the information contained
+*  herein is confidential. The software may not be copied and the information
+*  contained herein may not be used or disclosed except with the written
+*  permission of MediaTek Inc. (C) 2012
+*
+*  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+*  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+*  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+*  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+*  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+*  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+*  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+*  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+*  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+*  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+*  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+*  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+*  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+*  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+*  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+*  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+*  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+*  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+*  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+*  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+*  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+*  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ * Filename:
+ * ---------
+ * qmu_bm.h
+ *
+ * Project:
+ * --------
+ * MOLY
+ *
+ * Description:
+ * ------------
+ * QMU BM export header file
+ *
+ * Author:
+ * -------
+ * -------
+ *   
+ *
+ *============================================================================
+ *             HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *----------------------------------------------------------------------------
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *----------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef QMU_BM_H
+#define QMU_BM_H
+/****************************************************************************/
+
+/*************************************************************************
+ * Note!!
+ * qmu_bm APIs only can be used on thread contex.
+ * Because of it uses mutex to protect state.
+ * So user can't use it on ISR/HISR context.
+ *
+ * Sample Code:
+ * Init qmu_bm first. (Note: it only need to be inited once)
+ *
+   qbm_init();
+ * 
+ * Now just init queue.
+ * Before init queue, we need to allocate a memory 
+ * The memory is from outside, BM just manager it.
+ * We need to init a config file fist.
+ * And then know the pool size and allocate enough memory.
+ *
+ 
+    // static memory for buffer pool.
+    kal_uint8 g_pool[QBM_QUEUE_GET_MEM_SIZE(QBM_SIZE_HIF_DL, 100)];
+
+	bm_queue_config conf;
+
+	qbm_init_q_config(&conf);
+    size = qbm_queue_get_mem_size(QBM_TYPE_HIF_DL, 100);
+	conf.buff_num = 100;
+    conf.p_mem_pool_str = g_pool;
+    conf.p_mem_pool_end = g_pool + size;
+	qbm_init_queue(
+			QBM_TYPE_HIF_DL,
+			&conf
+			);
+    
+ * or managed by QMU_BM.
+ * add the buffer config in qbm_config.h
+ 
+ *  
+ *  Now we can use this type buffer now.
+ *
+    ptr = QBM_ALLOC_ONE(QBM_TYPE_HIF_DL);
+    QBM_FREE_ONE(ptr);
+
+    qbmt_alloc_q(QBM_TYPE_HIF_DL, 50, &hif->p_head, &hif->p_tail);
+    qbmt_reload_q(QBM_TYPE_HIF_DL, 50, &hif->p_head, &hif->p_tail);
+ *
+ *************************************************************************/
+
+#include "qbm_features.h"
+#include "qmu_bm_enum.h"
+
+#include "kal_public_api.h"
+#include "sync_data.h"
+#include "qmu_bm_common.h"
+#include "qmu_bm_size.h"
+#include "qmu_bm_spd.h"
+
+/****************************************************************************
+ * Type Definitions
+ ****************************************************************************/
+
+/*
+ * Buffer header format.
+ * Reserve 12 bytes first.
+ *
+ * If use want to access bm_header member,
+ * Please use GET_BM_HDR_PTR(_p)->xxx.
+ */
+typedef struct
+{
+	kal_uint16 mcode_used;
+	kal_uint8  type;
+	kal_uint8  flc_pool_id;
+	union{
+		kal_uint32 	ref_count;
+		void		*p_root;
+	}rsv1;
+	kal_uint32 	rsv2;
+}_bm_header_in;
+
+/* 
+ * Put SW control field first.
+ * So we can detect if User use too much memory by mcode.
+ */
+typedef struct
+{
+    kal_uint8     sw_ctrl_field[QBM_HEAD_SIZE - sizeof(_bm_header_in)];
+    _bm_header_in header;
+}bm_header;
+
+#define GET_BM_HDR_PTR(_p) (&(((bm_header*)((kal_uint8*)(_p) - QBM_HEAD_SIZE))->header))
+
+/* 
+ * Get buffer type of the descriptor.
+ * @param _p PD/BD start address.
+ * @return buffer type (qbm_type)
+ */
+#define QBM_GET_TYPE(_p) \
+	(GET_BM_HDR_PTR(_p)->type)
+
+#define QBM_SET_TYPE(_p, _t) \
+	(GET_BM_HDR_PTR(_p)->type = _t )
+
+/* 
+ * Different type will have different format.
+ * The formats are pre-defined.
+ * For different buffer formats. 
+ * See the document
+ * http://teams.mediatek.inc/sites/LTE/Software%20Engineering/presentation/20110810_QMU_Intro_Moja/QMU_BM_buffer_format_1.01.pptx
+ *
+ * Add new buffer type working flow.
+ * QBM_TYPE_XXX is moved to qmu_bm_enum.h
+ * 1) define a QBM_TYPE_XXX (Should follow the attribute)
+ * 2) define QBM_SIZE_XXX in qmu_bm_size.h
+ * 3) add the QBM_SZIE_XXX to the right position in _g_qbm_size_ary in qmu_bm_queue.c
+ * 4) add unit test case in t_get_size in qmu_bm_queue.c if needed check content in t_chk_content
+ *    -> for RX queue, can test it in t_rx_data_size in qmu_bm.c 
+ *       (if the queue type is normal, just fill the type in _g_tst_rx_data_type)
+ * 5) add reset buffer function and init buffer function in qbm_queue.c
+      -> fill the table _g_queue_inif_conf_tbl[]
+ * 6) If needed add the entry size in _get_per_entry_size. (for some special case)
+ * 7) If the type is pseudo type, remember to modify 
+ *        qbm_get_buff_remain_num(qbm_type type)
+ *        _qbm_alloc_q() or qbm_alloc_one() by demand
+ * 8) Finished, now you can use this type after call qbm_init_queue(QBM_TYPE_XXX, queue_conf)
+ *
+ * UT case:
+ * add check format in t_chk_content in qmu_bm_queue.c
+ */
+
+#define QBM_TYPE_IS_ONLY_DESCRIPTOR(_t) (QBM_TYPE_TGPD      <= (_t) && (_t) < QBM_TYPE_TTY_TYPE1)
+#define QBM_TYPE_IS_GPD_DATA(_t)        (QBM_TYPE_TTY_TYPE1 <= (_t) && (_t) < QBM_TYPE_NET_DL)
+#define QBM_TYPE_IS_GPD_BD_DATA(_t)     (QBM_TYPE_NET_DL    <= (_t) && (_t) < QBM_TYPE_NON_FREE)
+#define QBM_TYPE_IS_PSEUDO(_t)          (QBM_TYPE_NON_FREE  <= (_t))
+
+typedef struct
+{
+    /* used to check if the config is inited or not */
+    kal_uint32 mcode;
+
+    /* Total buffer number */
+    kal_uint32 buff_num;
+
+    /* 
+     * The data part need to be invalidate when de-Q from QMU 
+     * It may be used on command queue.
+     * For user plane data (TCP/IP packet, user should set this flag to KAL_FALSE)
+     * Becuase we don't need to see the whole packet content.
+     *
+     * Note: the flag is only used when using the de-q api provided by qbm.
+     * (e.g. qbmt_de_q )
+     * User also can do invalidate thing by himself.
+     */
+    kal_bool   b_cache_invalid;
+
+    /* 
+     * The buffer need to be flused before en-Q 
+     * It may be used on event buffer.
+     * For user plane data (TCP/IP packet, user should set this flag to KAL_FALSE)
+     * Becuase we don't need to flush the whole packet content.
+     *
+     * Note: the flag is only used when using the en-q api provided by qbm.
+     * (e.g. qbmt_common_en_q)
+     * User also can do flush thing by himself.
+     */
+    kal_bool   b_cache_flush;
+
+	/*  
+	 *  Memory pool start/end address.
+	 */
+	kal_uint8* p_mem_pool_str;
+	kal_uint8* p_mem_pool_end;
+} bm_queue_config;
+
+
+/****************************************************************************
+ * Exported Macros
+ ****************************************************************************/
+
+/* 
+ * SW control field are stored in front of the BM header.
+ * We reserve CACHE size for total QBM_HEAD.
+ * If the CACHE SIZE is 32 bytes, the SW control field is 32 - sizeof(bm_header)
+ * Currently the sw control field space is 20 bytes.
+ * 
+ * The field is cast by the user to fill their proprietary structure.
+ */
+#define QBM_DES_GET_SW_CTRL_FIELD(_p) ((kal_uint8*)(_p) - QBM_HEAD_SIZE)
+
+
+/****************************************************************************
+ * Exported Function Prototypes
+ ****************************************************************************/
+
+/* 
+ * ===  FUNCTION  ======================================================================
+ *         Name:  qbm_init
+ *  Description:  Init QMU BM. 
+ *  Note: 
+ *  After init QMU BM, *  user also need to init it's needed queue befroe use the queue.
+ * =====================================================================================
+ */
+kal_bool qbm_init(void);
+
+/* 
+ * ===  FUNCTION  ======================================================================
+ *         Name:  qbm_queue_get_mem_size
+ *  Description:  Get total needed size of the queue.
+ *                User should use this API to get the needed size.
+ *                And allocate enough memory to init the queue.
+ * =====================================================================================
+ */
+kal_uint32 qbm_queue_get_mem_size(qbm_type type, kal_uint32 buff_num);
+
+/*
+ * Constant get needed memory size.
+ * So user can use it on the static memory. (e.g. kal_uint8 HIF_DL_MEM[QBM_QUEUE_GET_MEM_SIZE()]; )
+ * The _sz is defined in qmu_bm_size.h.
+ * User should have knowledge of the size for its queue.
+ * 
+ * QBM_CACHE_SIZE is added for first buffer cache aligned.
+ * Because all size is cache aligned, so only care about first buffer.
+ *
+ * Now we have the following size can be used.
+ *
+ * QBM_SIZE_TGPD 
+ * QBM_SIZE_TBD 
+ * QBM_SIZE_TGPD_BYPSS     
+ * QBM_SIZE_HIF_DL      
+ * ... others can be found in qmu_bm_size.h
+ */
+#define QBM_QUEUE_GET_MEM_SIZE(_sz, _buf_num) ((_sz)*((_buf_num) + 1) + QBM_CACHE_SIZE)
+
+/* 
+ * ===  FUNCTION  ======================================================================
+ *         Name:  qbm_init_q_config
+ *  Description:  init the queue config structure to default value.
+ *                User can overwrite its config after init the config.
+ * =====================================================================================
+ */
+void qbm_init_q_config(bm_queue_config *p_conf);
+
+/* 
+ * ===  FUNCTION  ======================================================================
+ *         Name:  qbm_init_queue
+ *  Description:  Before use the queue, user should init the queue first.
+ *                The buffer number is bound by the real memory pool size and configure buffer_num.
+ *                => The buffer number may be restricted 
+ *                    by p_conf->p_mem_pool_str and p_conf->p_mem_pool_end
+ *                 or by p_conf->buff_num.
+ *       Return:  qbm_error_code
+ *       Note:    before use it, you should init p_conf first.
+ * =====================================================================================
+ */
+kal_int32 qbm_init_queue(qbm_type type, bm_queue_config *p_conf);
+
+/* 
+ * ===  FUNCTION  ======================================================================
+ *         Name:  qbm_get_buff_remain_num
+ *  Description:  Get how many remain buffers in the specified buffer type.
+ * =====================================================================================
+ */
+kal_uint32 qbm_get_buff_remain_num(qbm_type type);
+
+/* 
+ * ===  FUNCTION  ======================================================================
+ *         Name:  qbm_cal_set_checksum
+ *  Description:  Calculate checksum and set it.
+ *                For easy and quick, the checksum length is fix to 12 bytes.
+ *                If you need to test other length, 
+ *                use qbm_cal_set_checksum_by_len in qbm_util.h
+ * =====================================================================================
+ */
+#ifdef __ENABLE_QMU_CHECKSUM__
+void       qbm_cal_set_checksum(const kal_uint8 * const data);
+kal_uint32 qbm_cal_checksum(const kal_uint8 * const data);
+#else
+#define qbm_cal_set_checksum(_d)
+#define qbm_cal_checksum(_d) 0
+#endif
+
+
+
+/****************************************************************************/
+/*! @brief QBM_ALLOC_ONE
+
+    allocate one buffer. 
+    It's a wrap API. user should use it to allocate buffer.
+
+    @note Do not invoke with QBM_TYPE_HIF_UL_SPD_HR and 
+    QBM_TYPE_HIF_UL_SPD_LR.
+    
+    @param[in] type 	qbm queue type.
+
+    @return void *, buffer pointer address.
+    @since UMOLY
+*/
+/****************************************************************************/
+void* qbm_alloc_one(kal_uint32 type);
+#define QBM_ALLOC_ONE(type) qbm_alloc_one(type)
+
+/* 
+ * ===  FUNCTION  ======================================================================
+ *         Name:  QBM_ALLOC_ONE_CHK
+ *  Description:  Just like qbm_alloc_one, but this API will check if the queue is empty.
+ *                If empy, this API will call assertion.
+ *                Used when user always can allocate buffer scenario.
+ *                Reduce code size. (check NULL in the center)
+ *        Return: void *, buffer pointer address.
+ * =====================================================================================
+ */
+void* qbm_alloc_one_chk(kal_uint32 type);
+#define QBM_ALLOC_ONE_CHK(type) qbm_alloc_one_chk(type)
+
+/* 
+ * ===  FUNCTION  ======================================================================
+ *         Name:  QBM_FREE_ONE
+ *  Description:  Only free one buffer.
+ *       Return:  qbm_error_code
+ * =====================================================================================
+ */
+ 
+kal_int32 qbm_free_one(void *ptr);
+#define QBM_FREE_ONE(ptr) qbm_free_one(ptr)
+
+/* 
+ * ===  FUNCTION  ======================================================================
+ *         Name:  QBM_FREE_PD_BD
+ *  Description:  Free PD and all BD list.
+ *                This API will check BDP in the PD,
+ *                If BDP is 1, it will release all BD list linked with the PD.
+ *
+ *       Return:  qbm_error_code
+ * =====================================================================================
+ */
+kal_int32 qbm_free_pd_bd(void *p_pd);
+#define QBM_FREE_PD_BD(p_pd) qbm_free_pd_bd(p_pd)
+
+/* 
+ * ===  FUNCTION  ======================================================================
+ *         Name:  qbmt_dest_q
+ *  Description:  Destroy the whole queue from p_head to p_tail.
+ *                It also release the TBD link.
+ *      p_tail:   If set to NULL, it means destroy from p_head to a NULL pointer.
+ *      Return:   The freed GPD number.
+ * =====================================================================================
+ */
+kal_uint32
+qbmt_dest_q(void *p_head, void *p_tail);
+
+/* 
+ * ===  FUNCTION  ======================================================================
+ *         Name:  qbmt_free_q_hwo
+ *  Description:  Release buffer from head to tail until HWO = 1 (not include tail).
+ *                This API will check the HWO bit before release the GPD.
+ *                It also release the TBD link.
+ *                After release, the *pp_head will be updated to the first HWO = 1 GPD.
+ *      Return:   The freed GPD number.
+ * =====================================================================================
+ */
+kal_uint32
+qbmt_free_q_hwo(void **pp_head, void **pp_tail);
+
+/* 
+ * ===  FUNCTION  ======================================================================
+ *         Name:  qbmt_alloc_q
+ *  Description:  Allocate a descriptor list in one time.
+ *                It will return the list to the pp_head and pp_tail.
+ *                The last descriptor HWO will be set to 0 for tail.
+ *
+ *                Use scenario:
+ *                  when user want to init a new queue for HW. 
+ *                  This API should only be called in the first time.
+ *                  After that, user should use qbmt_reload_q to reload buffer.
+ *               
+ *               Note:
+ *                 This API is suitable for GPD/BD with data buffer type.
+ *                 For pure GPD/BD case, use QBM_ALLOC_ONE otherwise 
+ *                 user should know the buffer looking when use this API.
+ *
+ *        type:     qbm_type
+ *        buff_num: buffer number
+ *        pp_head:  return allocated list header.
+ *        pp_tail:  return allocated list tail.
+ *
+ *       Return:  Number of buffers allocated.
+ * =====================================================================================
+ */
+kal_uint32
+qbmt_alloc_q(
+        kal_uint32 type,
+        kal_uint32 buff_num,
+        void **pp_head, 
+        void **pp_tail
+        );
+
+/* 
+ * ===  FUNCTION  ======================================================================
+ *         Name:  qbmt_alloc_q_no_tail
+ *  Description:  Just like qbmt_alloc_q, but the tail HWO is still 1.
+ *                =>All descriptor's HWO is 1.
+ *
+ *                Use scenario:
+ *                  when user want to allocate a new queue to receive data and do reload_q by other module.
+ *                    can use qbmt_common_en_q_rx
+ *                  when user want to allocate a new TGPD with data list to send data.
+ *
+ *        type:     qbm_type
+ *        buff_num: buffer number
+ *        pp_head:  return allocated list header.
+ *        pp_tail:  return allocated list tail.
+ *
+ *       Return:  Number of buffers allocated.
+ * =====================================================================================
+ */
+kal_uint32
+qbmt_alloc_q_no_tail(
+        kal_uint32 type,
+        kal_uint32 buff_num,
+        void **pp_head, 
+        void **pp_tail
+        );
+
+/* 
+ * ===  FUNCTION  ======================================================================
+ *         Name:  qbmt_reload_q
+ *  Description:  Allocate a descriptor list in one time.
+ *                This API also link the new list to the original queue.
+ *                The pp_tail will be updated to the new list tail.
+ *                The original tail HWO will be set to 1.
+ *                The last descriptor HWO will be set to 0 for tail.
+ *        type:     qbm_type
+ *        buff_num: buffer number
+ *        pp_head:  Original queue header.
+ *        pp_tail:  Original queue tail.
+ *       Return:  Number of buffers allocated.
+ * =====================================================================================
+ */
+kal_uint32
+qbmt_reload_q(
+        kal_uint32 type,
+        kal_uint32 buff_num,
+        void **pp_head, 
+        void **pp_tail
+        );
+
+#ifdef __SENSITIVE_DATA_MOSAIC__
+/* 
+ * ===  FUNCTION  ======================================================================
+ *         Name:  qbm_clear_all_sensitive_data
+ *  Description:  this API will reset the GPD queues which contain the sensitive data.
+ *                the queue which need to be reset should be provided by queue owners.
+ *                add the new queues which need to be reset in global g_qbm_reset.
+ * =====================================================================================
+ */
+void 
+qbm_clear_all_sensitive_data(void);
+
+#endif
+
+#endif /* QMU_BM_H */
+
diff --git a/mcu/interface/service/qmu_bm/qmu_bm_common.h b/mcu/interface/service/qmu_bm/qmu_bm_common.h
new file mode 100644
index 0000000..d6af316
--- /dev/null
+++ b/mcu/interface/service/qmu_bm/qmu_bm_common.h
@@ -0,0 +1,254 @@
+/*****************************************************************************
+*  Copyright Statement:
+*  --------------------
+*  This software is protected by Copyright and the information contained
+*  herein is confidential. The software may not be copied and the information
+*  contained herein may not be used or disclosed except with the written
+*  permission of MediaTek Inc. (C) 2015
+*
+*  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+*  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+*  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+*  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+*  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+*  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+*  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+*  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+*  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+*  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+*  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+*  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+*  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+*  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+*  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+*  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+*  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+*  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+*  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+*  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+*  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+*  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ * Filename:
+ * ---------
+ * qmu_bm_common.h
+ *
+ * Project:
+ * --------
+ * UMOLY
+ *
+ * Description:
+ * ------------
+ * QMU BM common definition header file.
+ *
+ * Author:
+ * -------
+ * -------
+ *   
+ *
+ *============================================================================
+ *             HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *----------------------------------------------------------------------------
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ *----------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef QMU_BM_COMMON_H
+#define QMU_BM_COMMON_H
+
+#include "kal_public_api.h"
+
+/****************************************************************************
+ * Type Definitions
+ ****************************************************************************/
+
+typedef struct _qbm_gpd qbm_gpd;
+
+/****************************************************************************/
+/*! @brief structure of GPD header.
+
+    @note It only can be used on 32 bits CPU, this pointer implies kal_uint32 
+          Declared as pointer is used for ICE debug easily.
+
+    @since MOLY
+*/
+/****************************************************************************/
+struct _qbm_gpd
+{
+    kal_uint8   flags;
+    kal_uint8   chksum;
+    kal_uint16  reserved1;
+    qbm_gpd    *p_next;
+    void       *p_data_tbd;
+    kal_uint16  data_len;
+    kal_uint8   ext_len;
+    kal_uint8   reserved2;
+};
+
+/****************************************************************************
+ * Exported Macros
+ ****************************************************************************/
+
+#define DES_FLAG_BIT_HWO  0x01
+#define DES_FLAG_BIT_EOL  0x01
+#define DES_FLAG_BIT_BDP  0x02
+#define DES_FLAG_BIT_BPS  0x04
+#define DES_FLAG_BIT_GPD  0x00
+#define DES_FLAG_BIT_SPD1 0x08
+#define DES_FLAG_BIT_SPD2 0x10
+#define DES_FLAG_BIT_SPD3 0x18
+#define DES_FLAG_BIT_PH   0x40
+#define DES_FLAG_BIT_IOC  0x80
+
+#define QBM_GET_GPD_PTR(_p) ((qbm_gpd*)(_p))
+
+#define QBM_DES_SET_HWO(_p) \
+          (QBM_GET_GPD_PTR(_p)->flags |= DES_FLAG_BIT_HWO)
+
+#define QBM_DES_CLR_HWO(_p) \
+          (QBM_GET_GPD_PTR(_p)->flags &= ~DES_FLAG_BIT_HWO)
+
+#define QBM_DES_GET_HWO(_p) \
+          (QBM_GET_GPD_PTR(_p)->flags & DES_FLAG_BIT_HWO)
+
+#define QBM_DES_SET_BDP(_p) \
+          (QBM_GET_GPD_PTR(_p)->flags |= DES_FLAG_BIT_BDP)
+
+#define QBM_DES_CLR_BDP(_p) \
+          (QBM_GET_GPD_PTR(_p)->flags &= ~DES_FLAG_BIT_BDP)
+
+#define QBM_DES_GET_BDP(_p) \
+          (QBM_GET_GPD_PTR(_p)->flags & DES_FLAG_BIT_BDP)
+
+#define QBM_DES_SET_BPS(_p) \
+          (QBM_GET_GPD_PTR(_p)->flags |= DES_FLAG_BIT_BPS)
+
+#define QBM_DES_CLR_BPS(_p) \
+          (QBM_GET_GPD_PTR(_p)->flags &= ~DES_FLAG_BIT_BPS)
+
+#define QBM_DES_GET_BPS(_p) \
+          (QBM_GET_GPD_PTR(_p)->flags & DES_FLAG_BIT_BPS)
+
+#define QBM_DES_SET_PH(_p) \
+          (QBM_GET_GPD_PTR(_p)->flags |= DES_FLAG_BIT_PH)
+
+#define QBM_DES_CLR_PH(_p) \
+          (QBM_GET_GPD_PTR(_p)->flags &= ~DES_FLAG_BIT_PH)
+
+#define QBM_DES_GET_PH(_p) \
+          (QBM_GET_GPD_PTR(_p)->flags & DES_FLAG_BIT_PH)
+
+#define QBM_DES_SET_IOC(_p) \
+          (QBM_GET_GPD_PTR(_p)->flags |= DES_FLAG_BIT_IOC)
+
+#define QBM_DES_CLR_IOC(_p) \
+          (QBM_GET_GPD_PTR(_p)->flags &= ~DES_FLAG_BIT_IOC)
+
+#define QBM_DES_GET_IOC(_p) \
+          (QBM_GET_GPD_PTR(_p)->flags & DES_FLAG_BIT_IOC)
+
+#define QBM_DES_SET_EOL(_p) \
+          (QBM_GET_GPD_PTR(_p)->flags |= DES_FLAG_BIT_EOL)
+
+#define QBM_DES_CLR_EOL(_p) \
+          (QBM_GET_GPD_PTR(_p)->flags &= ~DES_FLAG_BIT_EOL)
+
+#define QBM_DES_GET_EOL(_p) \
+          (QBM_GET_GPD_PTR(_p)->flags & DES_FLAG_BIT_EOL)
+
+#define QBM_DES_SET_GPD(_p) \
+          (QBM_GET_GPD_PTR(_p)->flags &= ~(DES_FLAG_BIT_SPD1|DES_FLAG_BIT_SPD2))
+
+#define QBM_DES_SET_SPD1(_p) \
+          (QBM_GET_GPD_PTR(_p)->flags &= ~(DES_FLAG_BIT_SPD2)); \
+          (QBM_GET_GPD_PTR(_p)->flags |= DES_FLAG_BIT_SPD1 )
+
+#define QBM_DES_SET_SPD2(_p) \
+          (QBM_GET_GPD_PTR(_p)->flags &= ~(DES_FLAG_BIT_SPD1)); \
+          (QBM_GET_GPD_PTR(_p)->flags |= DES_FLAG_BIT_SPD2 )
+
+#define QBM_DES_SET_SPD3(_p) \
+          (QBM_GET_GPD_PTR(_p)->flags |= DES_FLAG_BIT_SPD3 )
+
+#define QBM_DES_CLR_PDT(_p) \
+          (QBM_DES_SET_GPD(_p))
+          
+#define QBM_DES_GET_PDT(_p) \
+          (QBM_GET_GPD_PTR(_p)->flags & (DES_FLAG_BIT_SPD1|DES_FLAG_BIT_SPD2))
+
+#ifdef __ENABLE_QMU_CHECKSUM__
+#define QBM_DES_SET_CHKSUM(_p, _chk) \
+          (QBM_GET_GPD_PTR(_p)->chksum = (_chk))
+#else
+#define QBM_DES_SET_CHKSUM(_p, _chk)
+#endif
+
+#define QBM_DES_GET_CHKSUM(_p) \
+          QBM_GET_GPD_PTR(_p)->chksum
+
+#define QBM_DES_SET_ALLOW_LEN(_p, _len) \
+          (QBM_GET_GPD_PTR(_p)->reserved1 = (kal_uint16)(_len))
+
+#define QBM_DES_GET_ALLOW_LEN(_p) \
+          (QBM_GET_GPD_PTR(_p)->reserved1)
+
+#define QBM_DES_SET_DRP_ALLW(_p, _rst) \
+          (QBM_GET_GPD_PTR(_p)->reserved1 = (kal_uint16)(_rst))
+
+#define QBM_DES_GET_DRP_ALLW(_p) \
+          (QBM_GET_GPD_PTR(_p)->reserved1)
+
+#define QBM_DES_SET_NEXT(_p, _nxt)           \
+          QBM_GET_GPD_PTR(_p)->p_next = (qbm_gpd*)(_nxt)
+
+#define QBM_DES_GET_NEXT(_p) \
+          (QBM_GET_GPD_PTR(_p)->p_next)
+
+#define QBM_DES_SET_DATAPTR(_p, _dp)     \
+          (QBM_GET_GPD_PTR(_p)->p_data_tbd = (kal_uint8*)(_dp))
+
+#define QBM_DES_GET_DATAPTR(_p) \
+          (QBM_GET_GPD_PTR(_p)->p_data_tbd)
+
+#define QBM_DES_GET_DATALEN(_p) \
+          QBM_GET_GPD_PTR(_p)->data_len
+
+#define QBM_DES_SET_DATALEN(_p, _l) \
+          QBM_GET_GPD_PTR(_p)->data_len = (kal_uint16)(_l)
+
+#define QBM_DES_GET_EXTLEN(_p) \
+          QBM_GET_GPD_PTR(_p)->ext_len
+
+#define QBM_DES_SET_EXTLEN(_p, _l) \
+          QBM_GET_GPD_PTR(_p)->ext_len = (_l)
+
+#define QBM_DES_GET_EXT(_p) \
+          ((kal_uint8*)(_p) + sizeof(qbm_gpd)) 
+
+/****************************************************************************/
+#endif /* QMU_BM_COMMON_H */
+
diff --git a/mcu/interface/service/qmu_bm/qmu_bm_enum.h b/mcu/interface/service/qmu_bm/qmu_bm_enum.h
new file mode 100644
index 0000000..fe37a68
--- /dev/null
+++ b/mcu/interface/service/qmu_bm/qmu_bm_enum.h
@@ -0,0 +1,206 @@
+/*****************************************************************************
+*  Copyright Statement:
+*  --------------------
+*  This software is protected by Copyright and the information contained
+*  herein is confidential. The software may not be copied and the information
+*  contained herein may not be used or disclosed except with the written
+*  permission of MediaTek Inc. (C) 2012
+*
+*  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+*  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+*  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+*  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+*  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+*  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+*  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+*  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+*  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+*  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+*  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+*  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+*  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+*  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+*  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+*  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+*  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+*  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+*  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+*  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+*  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+*  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ * Filename:
+ * ---------
+ *   qmu_bm_enum.h
+ *
+ * Project:
+ * --------
+ *   MOLY
+ *
+ * Description:
+ * ------------
+ *  enum values.
+ *
+ *
+ * Author:
+ * -------
+ * -------
+ *   
+ *
+ *============================================================================
+ *             HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+ 
+#ifndef  QMU_BM_ENUM_INC
+#define  QMU_BM_ENUM_INC
+
+#include "qbm_features.h"
+
+typedef enum
+{
+    /*----------only descriptor buffer start----------*/
+    QBM_TYPE_TGPD, /*  note the first is anchor, don't change the order. */
+    QBM_TYPE_TBD,
+    QBM_TYPE_TGPD_BPS,
+    QBM_TYPE_DHL_GPD_BD,
+    QBM_TYPE_DHL_SPD,
+    /*----------only descriptor buffer end------------*/
+
+    /*----------GPD with data buffer start------------*/
+    QBM_TYPE_TTY_TYPE1, /*  note the first is anchor, don't change the order. */
+    QBM_TYPE_TTY_INT,
+    QBM_TYPE_GPD_BD_TST,
+    QBM_TYPE_ACM,
+    QBM_TYPE_MSD,
+    /*----------GPD with data buffer end--------------*/
+
+    /*----------GPD with BD with buffer start----------*/
+    /* It is allocated for LTE decipher engine DRB queue */
+    QBM_TYPE_NET_DL,    /*  note the first is anchor, don't change the order. */
+    QBM_TYPE_IMS_DL,
+    QBM_TYPE_NET_UL,
+    QBM_TYPE_NET_UL_SHRD,
+     /* 20120724 ian: QBM_TYPE_CCCI_COMM*/
+    /*
+     * Used for real queue end anchor.
+     * Please don't modify it, UT case will use it to test boundary cae
+     */
+    QBM_TYPE_CCCI_COMM,
+    QBM_TYPE_IMS_UL,
+    QBM_TYPE_NCCMNI_COMM,
+    QBM_TYPE_QUEUE_END = QBM_TYPE_NCCMNI_COMM,
+    /*----------GPD with BD with buffer end-------------*/
+
+    /*----------Pseudo type start----------*/
+    /* don't need to do free */
+    QBM_TYPE_NON_FREE,
+    /*----------Pseudo type end----------*/
+
+    QBM_QUEUE_NUM
+} qbm_type;
+
+typedef enum
+{
+    QBM_ERROR_OK                      = 0,
+    QBM_ERROR_QBM_NOT_INITED          = 1,
+    QBM_ERROR_QUEUE_IS_ALREADY_INITED = 2,
+    QBM_ERROR_MEM_NOT_ENOUGH          = 3,
+    QBM_ERROR_PRE_Q_IS_NOT_INITED     = 4,
+} qbm_error_code;
+
+typedef enum
+{
+    QBM_POOL_NORMAL = 0,
+    QBM_POOL_SHRINK, 
+    QBM_POOL_NONE,
+}qbm_pool_status;
+
+#endif   /* ----- #ifndef QMU_BM_ENUM_INC  ----- */
+
diff --git a/mcu/interface/service/qmu_bm/qmu_bm_in.h b/mcu/interface/service/qmu_bm/qmu_bm_in.h
new file mode 100644
index 0000000..288efb9
--- /dev/null
+++ b/mcu/interface/service/qmu_bm/qmu_bm_in.h
@@ -0,0 +1,80 @@
+/*****************************************************************************
+*  Copyright Statement:
+*  --------------------
+*  This software is protected by Copyright and the information contained
+*  herein is confidential. The software may not be copied and the information
+*  contained herein may not be used or disclosed except with the written
+*  permission of MediaTek Inc. (C) 2012
+*
+*  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+*  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+*  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+*  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+*  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+*  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+*  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+*  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+*  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+*  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+*  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+*  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+*  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+*  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+*  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+*  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+*  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+*  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+*  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+*  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+*  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+*  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ * Filename:
+ * ---------
+ *   qmu_bm_in.h
+ *
+ * Project:
+ * --------
+ *   MOLY
+ *
+ * Description:
+ * ------------
+ *
+ *
+ * Author:
+ * -------
+ * -------
+ *   
+ *
+ * ==========================================================================
+ * $Log$
+ ****************************************************************************/
+/*
+ * =====================================================================================
+ *
+ *       Filename:  qmu_bm_in.h
+ *
+ *    Description:  Don't want user directly access API, but also need to be exported.
+ *				    They may be wrap by a macro.
+ *
+ *        Created:  2011/6/14 ¤U¤È 05:17:10
+ *        Author:  mtk01641 (moja)
+ * =====================================================================================
+ */
+#ifndef  QMU_BM_IN_INC
+#define  QMU_BM_IN_INC
+
+#include "kal_public_api.h"
+
+void* qbm_alloc_one(kal_uint32 type);
+void* qbm_alloc_one_chk(kal_uint32 type);
+kal_int32 qbm_free_one(void *ptr);
+kal_int32 qbm_free_pd_bd(void *p_pd);
+
+#endif   /* ----- #ifndef QMU_BM_IN_INC  ----- */
+
diff --git a/mcu/interface/service/qmu_bm/qmu_bm_size.h b/mcu/interface/service/qmu_bm/qmu_bm_size.h
new file mode 100644
index 0000000..4366d5d
--- /dev/null
+++ b/mcu/interface/service/qmu_bm/qmu_bm_size.h
@@ -0,0 +1,352 @@
+/*****************************************************************************
+*  Copyright Statement:
+*  --------------------
+*  This software is protected by Copyright and the information contained
+*  herein is confidential. The software may not be copied and the information
+*  contained herein may not be used or disclosed except with the written
+*  permission of MediaTek Inc. (C) 2012
+*
+*  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+*  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+*  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+*  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+*  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+*  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+*  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+*  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+*  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+*  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+*  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+*  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+*  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+*  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+*  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+*  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+*  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+*  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+*  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+*  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+*  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+*  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ * Filename:
+ * ---------
+ *   qmu_bm_size.h
+ *
+ * Project:
+ * --------
+ *   MOLY
+ *
+ * Description:
+ * ------------
+ *
+ *
+ * Author:
+ * -------
+ * -------
+ *   
+ *
+ *============================================================================
+ *             HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+/*
+ * =====================================================================================
+ *
+ *       Filename:  qmu_bm_size.h
+ *
+ *    Description:  Each buffer type size. Defined as constant.
+ *                  For user can put it into array.
+ *                  Because in kal model, it don't prefer dynamic allocation.
+ *
+ *        Created:  2011/8/11 03:06:39
+ *        Author:  mtk01641 (moja)
+ * =====================================================================================
+ */
+ 
+#ifndef  QMU_BM_SIZE_INC
+#define  QMU_BM_SIZE_INC
+/****************************************************************************/
+
+#include "kal_public_defs.h"
+#include "ps_public_enum.h"
+#include "qmu_bm_spd.h"
+
+/****************************************************************************/
+
+#define _QBM_MAX(_a, _b)   (((_a) > (_b)) ? (_a):(_b))
+
+/****************************************************************************/
+
+/* 
+ * Because kal cache related api have alignment restriction.
+ * Not convenient. So just export this API for user who is not sure the alignement.
+ */
+#if defined(__DYNAMIC_SWITCH_CACHEABILITY__)
+#include "cache_sw.h"
+#define QBM_CACHE_ALIGN          CPU_CACHE_LINE_BIT_OFFSET
+#define QBM_CACHE_SIZE           CPU_CACHE_LINE_SIZE
+#define QBM_CACHE_LINE_SIZE_MASK CPU_CACHE_LINE_SIZE_MASK
+#else
+#define QBM_CACHE_ALIGN 5
+#define QBM_CACHE_SIZE  32
+#define QBM_CACHE_LINE_SIZE_MASK ((1 << QBM_CACHE_ALIGN) - 1)
+#endif
+
+/* calculate nearest cache aligned size. */
+#define QBM_SIZE_CACHE_ALIGN(_sz) (((_sz) + (QBM_CACHE_SIZE - 1)) & ~QBM_CACHE_LINE_SIZE_MASK)
+
+/****************************************************************************/
+
+#define QBM_HEAD_SIZE  (QBM_CACHE_SIZE)
+#define TGPD_SZ        (16)
+#define COMMON_EXT_LEN (QBM_CACHE_SIZE - TGPD_SZ)
+#define EMBEDDED_BD_SZ (2*QBM_CACHE_SIZE)
+#define QBM_SIZE_PD	   (QBM_HEAD_SIZE + TGPD_SZ)
+
+/****************************************************************************/
+
+/*! @brief define the MTU of HIF related buffers  */
+#define QBM_HIF_MTU 	(3072)
+#define QBM_HIF_MTU_MAX	(8188)
+
+/****************************************************************************/
+
+/* 
+ * Reserve RX_EXT_LEN space before data 
+ * So we can put the decompressed header on this space.
+ * Note: the extension is after the embedded BD.
+ */
+#define QBM_NET_DL_EXT_LEN   (224)
+#define QBM_NET_DL_DATA_LEN  (_QBM_MAX( 2080, QBM_SIZE_CACHE_ALIGN(QBM_HIF_MTU)))
+
+/*! @brief define the maximal size of DHL SPD extention part.
+    WITH CCCI + L2COPRO:  4 + (16 (CCCI) + 8(DHL) + 64(L2COPRO) + 4) * 16 = 1476bytes
+    USB + L2COPRO: 4 + (8 + 64 + 4) * 16 = 1220 bytes
+    MAX(1476, 1220) = 1476
+*/
+#define QBM_DHL_SPD_EXT_LEN    (1476)
+
+/* 20120724 ian: QBM_TYPE_CCCI_COMM*/
+#define QBM_CCCI_COMM_EXT_LEN  (128)
+#define QBM_CCCI_COMM_DATA_LEN (3584)
+#define QBM_IMS_DL_DATA_LEN    (4096)
+
+#define QBM_TTY_XXX_DATA_LEN       (1024)
+#define QBM_GPD_BD_TST_DATA_LEN    (2048)
+#define QBM_GPD_BD_TST_EXT_LEN     (256)
+
+#define QBM_ACM_DATA_LEN           (64)
+
+#define QBM_NET_UL_DATA_LEN        (1536 + QBM_CACHE_SIZE)
+#define QBM_NET_UL_SHRD_EXT_LEN    (128)
+#define QBM_NET_UL_SHRD_DATA_LEN   (1536 + QBM_CACHE_SIZE)
+#define QBM_MSD_DATA_LEN           (1024)
+
+/****************************************************************************/
+
+/*---------- Each foramt size constant ----------*/
+#define _QBM_SIZE_TGPD          (QBM_SIZE_PD + COMMON_EXT_LEN)
+#define _QBM_SIZE_TBD           (_QBM_SIZE_TGPD)
+#define _QBM_SIZE_TGPD_BPS      (_QBM_SIZE_TGPD)
+#define _QBM_SIZE_DHL_GPD_BD    (_QBM_SIZE_TGPD + _QBM_SIZE_TBD)
+#define _QBM_SIZE_DHL_SPD       (QBM_SIZE_PD + QBM_DHL_SPD_EXT_LEN)
+
+#define _QBM_SIZE_TTY_TYPE1     (_QBM_SIZE_TGPD + QBM_TTY_XXX_DATA_LEN)
+
+#define _QBM_SIZE_TTY_INT       (_QBM_SIZE_TTY_TYPE1)
+#define _QBM_SIZE_GPD_BD_TST    (QBM_SIZE_PD + QBM_GPD_BD_TST_EXT_LEN + QBM_GPD_BD_TST_DATA_LEN)
+
+#define _QBM_SIZE_ACM           (_QBM_SIZE_TGPD + QBM_ACM_DATA_LEN)
+#define _QBM_SIZE_MSD         	(_QBM_SIZE_TGPD + QBM_MSD_DATA_LEN)
+
+#define _QBM_SIZE_NET_DL        (_QBM_SIZE_TGPD + EMBEDDED_BD_SZ - COMMON_EXT_LEN + QBM_NET_DL_EXT_LEN + QBM_NET_DL_DATA_LEN)
+
+#define _QBM_SIZE_IMS_DL        (_QBM_SIZE_TGPD + EMBEDDED_BD_SZ + QBM_IMS_DL_DATA_LEN)
+#if defined(__MTK_TARGET__)
+#define _QBM_SIZE_NET_UL        (_QBM_SIZE_TGPD + EMBEDDED_BD_SZ - COMMON_EXT_LEN + QBM_NET_UL_SHRD_EXT_LEN + QBM_NET_UL_SHRD_DATA_LEN)
+#else
+#define _QBM_SIZE_NET_UL        (_QBM_SIZE_TGPD + EMBEDDED_BD_SZ + QBM_NET_UL_DATA_LEN)
+#endif
+#define _QBM_SIZE_NET_UL_SHRD   (_QBM_SIZE_TGPD + EMBEDDED_BD_SZ - COMMON_EXT_LEN + QBM_NET_UL_SHRD_EXT_LEN + QBM_NET_UL_SHRD_DATA_LEN)
+
+#define _QBM_SIZE_CCCI_COMM   	(_QBM_SIZE_TGPD + EMBEDDED_BD_SZ - COMMON_EXT_LEN + QBM_CCCI_COMM_EXT_LEN + QBM_CCCI_COMM_DATA_LEN)
+
+/*
+ * For the QBM_HEADER and Descriptor start address is cache aligned,
+ * We need to make sure all entry is cache aligned
+ * 
+ * Note:
+ * Don't use the size as the total size of your memory pool.
+ * Please use QBM_QUEUE_GET_MEM_SIZE(_sz, _buf_num) defined in qmu_bm.h to get total memory size.
+ * e.g. 
+ * QBM_QUEUE_GET_MEM_SIZE(QBM_SIZE_TGPD, 12);
+ */
+#define QBM_SIZE_TGPD           QBM_SIZE_CACHE_ALIGN(_QBM_SIZE_TGPD)
+#define QBM_SIZE_TBD            QBM_SIZE_CACHE_ALIGN(_QBM_SIZE_TBD)
+#define QBM_SIZE_TGPD_BPS       QBM_SIZE_CACHE_ALIGN(_QBM_SIZE_TGPD_BPS)
+#define QBM_SIZE_DHL_GPD_BD     QBM_SIZE_CACHE_ALIGN(_QBM_SIZE_DHL_GPD_BD)
+#define QBM_SIZE_DHL_SPD        QBM_SIZE_CACHE_ALIGN(_QBM_SIZE_DHL_SPD)
+
+#define QBM_SIZE_TTY_TYPE1      QBM_SIZE_CACHE_ALIGN(_QBM_SIZE_TTY_TYPE1)
+#define QBM_SIZE_TTY_INT        QBM_SIZE_CACHE_ALIGN(_QBM_SIZE_TTY_INT)
+#define QBM_SIZE_GPD_BD_TST     QBM_SIZE_CACHE_ALIGN(_QBM_SIZE_GPD_BD_TST)
+#define QBM_SIZE_ACM            QBM_SIZE_CACHE_ALIGN(_QBM_SIZE_ACM)
+#define QBM_SIZE_MSD            QBM_SIZE_CACHE_ALIGN(_QBM_SIZE_MSD)
+
+#define QBM_SIZE_NET_DL         QBM_SIZE_CACHE_ALIGN(_QBM_SIZE_NET_DL)
+#define QBM_SIZE_IMS_DL         QBM_SIZE_CACHE_ALIGN(_QBM_SIZE_IMS_DL)
+#define QBM_SIZE_NET_UL         QBM_SIZE_CACHE_ALIGN(_QBM_SIZE_NET_UL)
+#define QBM_SIZE_NET_UL_SHRD    QBM_SIZE_CACHE_ALIGN(_QBM_SIZE_NET_UL_SHRD)
+
+#define QBM_SIZE_CCCI_COMM      QBM_SIZE_CACHE_ALIGN(_QBM_SIZE_CCCI_COMM)
+#define QBM_SIZE_IMS_UL         QBM_SIZE_CCCI_COMM  // apply same config as CCCI_COMM requested by VoLTE_CSR
+#define QBM_SIZE_NCCMNI_COMM    QBM_SIZE_CCCI_COMM  // same config as CCCI_COMM
+
+/*---------- Each foramt size constant ----------*/
+
+/****************************************************************************/
+#endif  /* QMU_BM_SIZE_INC */
+
diff --git a/mcu/interface/service/qmu_bm/qmu_bm_spd.h b/mcu/interface/service/qmu_bm/qmu_bm_spd.h
new file mode 100644
index 0000000..e3f0684
--- /dev/null
+++ b/mcu/interface/service/qmu_bm/qmu_bm_spd.h
@@ -0,0 +1,482 @@
+/*****************************************************************************
+*  Copyright Statement:
+*  --------------------
+*  This software is protected by Copyright and the information contained
+*  herein is confidential. The software may not be copied and the information
+*  contained herein may not be used or disclosed except with the written
+*  permission of MediaTek Inc. (C) 2014
+*
+*  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+*  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+*  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+*  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+*  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+*  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+*  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+*  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+*  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+*  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+*  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+*  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+*  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+*  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+*  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+*  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+*  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+*  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+*  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+*  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+*  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+*  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*****************************************************************************
+ *
+ * Filename:
+ * ---------
+ * qmu_bm_spd.h
+ *
+ * Project:
+ * --------
+ * UMOLY
+ *
+ * Description:
+ * ------------
+ * The header file of all SPD related functions and definitions.  
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ *             HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *----------------------------------------------------------------------------
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ *----------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+/****************************************************************************/
+/*! @file qmu_bm_spd.h
+    @author Stan Chen
+    @date 2014/06/16
+
+    @brief The header file of all SPD related functions and definitions.
+*/
+/****************************************************************************/
+
+#ifndef QMU_BM_SPD_H
+#define QMU_BM_SPD_H
+
+#include "kal_public_api.h"
+
+/****************************************************************************
+ * External Variables
+ ****************************************************************************/
+
+extern kal_uint16 _g_qbm_spd_max_payload;
+
+/****************************************************************************
+ * Definitions
+ ****************************************************************************/
+
+/*! @brief define the maximal packet number in a single SPD (default:45).
+     
+    Ideally, MD handles 45 packets per millisecond. Add one single element for 
+    MBIM NTH header. Cat.4 = 30 Cat.6 = 45
+*/
+#define QBM_SPD_MAX_PKTNUM  (45)
+
+/*! @brief define the default value of maximal payload length in a single SPD.
+
+    Default is unlimited ( 0xFFFF )     
+*/
+#define QBM_SPD_MAX_PAYLOAD_DEFAULT (0xFFFF)
+
+/*! @brief define the maximal header size of a packet (default:60).
+     
+    RNDIS header size is 68bytes.
+*/
+#define QBM_SPD_MAX_HEADER_LEN 	(68)
+
+/*! @brief define the maximal size of SPD extention part.
+
+    RNDIS:  4bytes + (68 bytes + 4 bytes) * 30 = 2164
+    MBIM:   4bytes + (12 bytes + 4 bytes) + (20 bytes + 4 bytes) * 30 = 740
+*/
+#define QBM_SPD_MAX_EXTLEN 	(4 + (QBM_SPD_MAX_HEADER_LEN + 4 ) * 30 )
+
+#define QBM_SPD_GUARD_PATTERN   (0x86988698)
+
+/*! @brief define the number of subset RXSPD
+
+	8188 / 1536 = 5.33, config as 6 first.
+*/
+#define QBM_RXSPD_SUBPD_NUM		(6)
+
+/****************************************************************************
+ * Type Definitions
+ ****************************************************************************/
+
+typedef struct _qbm_spd qbm_spd;
+typedef struct _qbm_spd_ext qbm_spd_ext;
+typedef struct _qbm_spd_pi qbm_spd_pi;
+typedef struct _qbm_spd_pie qbm_spd_pie;
+
+typedef struct _qbm_spd qbm_txspd;
+typedef struct _qbm_spd_ext qbm_txspd_ext;
+typedef struct _qbm_spd_pi qbm_txspd_pi;
+typedef struct _qbm_spd_pie qbm_txspd_pie;
+
+typedef struct _qbm_rxspd qbm_rxspd;
+
+/****************************************************************************/
+/*! @brief structure of SPD header.
+
+    @note Similar structure design as qbm_gpd. 
+    @since UMOLY
+*/
+/****************************************************************************/
+struct _qbm_spd
+{
+    kal_uint8   flags;		/*!< includes HWO,BDP,BPS,PDT and IOC. */
+    kal_uint8   chksum;		/*!< checksum value of first 12 bytes of SPD. */
+    kal_uint16  reserved1;		
+    void       *p_next;		/*!< the pointer to next SPD/GPD. */
+    void       *p_data_tbd;	/*!< the pointer to the ring buffer segment. */
+    kal_uint16  data_len;	/*!< the total length of ring buffer payloads. */
+    kal_uint16  info;		/*!< spd piggyback info( pit_idx and rbuf_idx ).*/
+};
+
+/****************************************************************************/
+/*! @brief structure of SPD payload info elements.
+
+    @since UMOLY
+*/
+/****************************************************************************/
+struct _qbm_spd_pie
+{    
+    kal_uint16  payload_len;		/*!< the length of packet payload. */
+    kal_uint8   reserved;	
+    kal_uint8   flags;				/*!< includes IGR and EOL. */
+};
+
+/****************************************************************************/
+/*! @brief structure of SPD payload info part.
+
+    @since UMOLY
+*/
+/****************************************************************************/
+struct _qbm_spd_pi
+{
+    kal_uint16  pkt_num;		            /*!< MAX: QBM_SPD_MAX_PKTNUM. */
+    kal_uint16  reserved;
+    qbm_spd_pie pie[QBM_SPD_MAX_PKTNUM];    /*!< payload info elements. */
+    kal_uint32	guard_pattern;	            /*!< 0x86988698. */    
+};
+
+/****************************************************************************/
+/*! @brief structure of SPD extension part.
+
+    @since UMOLY
+*/
+/****************************************************************************/
+struct _qbm_spd_ext
+{
+    kal_uint8   ext_space[QBM_SPD_MAX_EXTLEN];  /*!< extension room. */
+    kal_uint32	guard_pattern;	    /*!< 0x86988698. */
+    qbm_spd_pi  payload_info;       /*!< payload info. */
+};
+
+/****************************************************************************/
+/*! @brief structure of RXSPD header.
+
+    @note Similar structure design as qbm_gpd. 
+    @since UMOLY
+*/
+/****************************************************************************/
+struct _qbm_rxspd
+{
+    kal_uint8   flags;		/*!< includes HWO,BDP,BPS,PDT and IOC. */
+    kal_uint8   chksum;		/*!< checksum value of first 12 bytes of PD. */
+    kal_uint16  allow_len;	/*!< allow length of this PD, read by HW */	
+    void       *p_next;		/*!< the pointer to next RXSPD/GPD. */
+    void       *p_data_tbd;	/*!< the pointer to data buffer segment. */
+    kal_uint16  data_len;	/*!< transfered length, modify by HW */	
+    kal_uint8   rxspd_info;	/*!< includes SKIP bit, modify by HW */	
+    kal_uint8   reserv_len;	/*!< reserved header length, read by HW */	
+};
+
+/****************************************************************************
+ * Exported Macros
+ ****************************************************************************/
+
+#define SPD_INFO_MASK_PIT   ((kal_uint16)0x0FFF)
+#define SPD_INFO_OFST_PIT   (0)
+#define SPD_INFO_MASK_RBUF  ((kal_uint16)0x000F)
+#define SPD_INFO_OFST_RBUF  (12)
+#define SPD_PIE_FLAG_BIT_EOL ((kal_uint8)0x40)
+#define SPD_PIE_FLAG_BIT_IGR ((kal_uint8)0x80)
+   
+#define QBM_SPD_SET_PIT(_p,_l)  \
+    (QBM_GET_SPD_PTR(_p)->info &= ~(SPD_INFO_MASK_PIT << SPD_INFO_OFST_PIT));\
+    (QBM_GET_SPD_PTR(_p)->info |= ((_l) << SPD_INFO_OFST_PIT) )
+             
+#define QBM_SPD_GET_PIT(_p)     \
+    ((QBM_GET_SPD_PTR(_p)->info >> SPD_INFO_OFST_PIT) & SPD_INFO_MASK_PIT)
+    
+#define QBM_SPD_SET_RBUF(_p,_l)  \
+    (QBM_GET_SPD_PTR(_p)->info &= ~(SPD_INFO_MASK_RBUF<<SPD_INFO_OFST_RBUF));\
+    (QBM_GET_SPD_PTR(_p)->info |= ((_l) << SPD_INFO_OFST_RBUF) )
+
+#define QBM_SPD_GET_RBUF(_p)     \
+    ((QBM_GET_SPD_PTR(_p)->info >> SPD_INFO_OFST_RBUF) & SPD_INFO_MASK_RBUF)
+
+#define QBM_SPD_SET_MAXPAYLOAD(_p,_l)  \
+    (_g_qbm_spd_max_payload = (kal_uint16)_l)
+
+#define QBM_SPD_GET_MAXPAYLOAD(_p)     \
+    ((kal_uint16)_g_qbm_spd_max_payload)
+
+#define QBM_SPD_PIE_SET_EOL(_p) \
+    (QBM_GET_SPD_PIE_PTR(_p)->flags |= SPD_PIE_FLAG_BIT_EOL)
+    
+#define QBM_SPD_PIE_CLR_EOL(_p) \
+    (QBM_GET_SPD_PIE_PTR(_p)->flags &= ~SPD_PIE_FLAG_BIT_EOL)
+
+#define QBM_SPD_PIE_GET_EOL(_p) \
+    (QBM_GET_SPD_PIE_PTR(_p)->flags & SPD_PIE_FLAG_BIT_EOL)
+
+#define QBM_SPD_PIE_SET_IGR(_p) \
+    (QBM_GET_SPD_PIE_PTR(_p)->flags |= SPD_PIE_FLAG_BIT_IGR)
+
+#define QBM_SPD_PIE_CLR_IGR(_p) \
+    (QBM_GET_SPD_PIE_PTR(_p)->flags &= ~SPD_PIE_FLAG_BIT_IGR)
+
+#define QBM_SPD_PIE_GET_IGR(_p) \
+    (QBM_GET_SPD_PIE_PTR(_p)->flags & SPD_PIE_FLAG_BIT_IGR)
+
+/****************************************************************************/
+
+#define RXSPD_INFO_FLAG_BIT_SKIP ((kal_uint8)0x40)
+
+#define QBM_RXSPD_SET_SKIP(_p) \
+	(QBM_GET_RXSPD_PTR(_p)->flags |= RXSPD_INFO_FLAG_BIT_SKIP)
+		
+#define QBM_RXSPD_CLR_SKIP(_p) \
+    (QBM_GET_RXSPD_PTR(_p)->flags &= ~RXSPD_INFO_FLAG_BIT_SKIP)	
+	
+#define QBM_RXSPD_GET_SKIP(_p) \
+    (QBM_GET_RXSPD_PTR(_p)->flags & RXSPD_INFO_FLAG_BIT_SKIP)	
+
+#define QBM_RXSPD_SET_RES(_p, _l) \
+	(QBM_GET_RXSPD_PTR(_p)->flags = _l)
+	
+#define QBM_RXSPD_GET_RES(_p) \
+	(QBM_GET_RXSPD_PTR(_p)->reserv_len)
+
+/****************************************************************************
+ * Inline Functions
+ ****************************************************************************/
+#ifndef GEN_FOR_PC
+INLINE_MODIFIER INLINE qbm_spd* QBM_GET_SPD_PTR( void *p ) 
+{
+    return (qbm_spd *)p;
+}
+
+INLINE_MODIFIER INLINE kal_uint8* QBM_SPD_GET_EXT( qbm_spd *p_spd )
+{
+    return (((kal_uint8*)(p_spd)) + sizeof(qbm_spd));
+}
+
+INLINE_MODIFIER INLINE kal_uint16 QBM_SPD_GET_EXTLEN( qbm_spd* p_spd )
+{
+    return (kal_uint16)(QBM_SPD_MAX_EXTLEN);
+}
+
+INLINE_MODIFIER INLINE qbm_spd_pi* QBM_SPD_GET_PI( qbm_spd* p_spd )
+{
+    return &((qbm_spd_ext *)QBM_SPD_GET_EXT(p_spd))->payload_info;
+
+}
+
+/****************************************************************************/
+
+INLINE_MODIFIER INLINE qbm_rxspd* QBM_GET_RXSPD_PTR( void *p ) 
+{
+    return (qbm_rxspd*)p;
+}
+
+INLINE_MODIFIER INLINE kal_uint8* QBM_RXSPD_GET_EXT( qbm_rxspd *p_spd )
+{
+    return (((kal_uint8*)(p_spd)) + sizeof(qbm_rxspd));
+}
+
+/****************************************************************************/
+
+INLINE_MODIFIER INLINE void QBM_SPD_PI_SET_PKTNUM( qbm_spd_pi *p_spdpi, 
+    kal_uint16 num )
+{
+    //DEBUG_ASSERT( num <= QBM_SPD_MAX_PKTNUM );
+    p_spdpi->pkt_num = num;
+}
+
+INLINE_MODIFIER INLINE kal_uint16 QBM_SPD_PI_GET_PKTNUM( 
+    qbm_spd_pi *p_spdpi )
+{
+    return p_spdpi->pkt_num;
+}
+
+/****************************************************************************/
+/*! @brief get the first element in payload info.
+
+    @note Payload info element is abbreviated of PIE
+    
+    @param[in] p_spdpi a pointer to a spd payload info.
+    @return p_spdpi->pie[0].
+    @since UMOLY
+*/
+/****************************************************************************/
+INLINE_MODIFIER INLINE qbm_spd_pie* QBM_SPD_PI_GET_FIRST_PIE( 
+    qbm_spd_pi *p_spdpi )
+{
+    return &(p_spdpi->pie[0]);
+}
+
+/****************************************************************************/
+
+INLINE_MODIFIER INLINE qbm_spd_pie* QBM_GET_SPD_PIE_PTR( void *p )
+{
+    return (qbm_spd_pie *)p;
+}
+
+INLINE_MODIFIER INLINE void QBM_SPD_PIE_SET_PAYLOAD_LEN( 
+    qbm_spd_pie  *p_spdpie, kal_uint16 len )
+{
+    p_spdpie->payload_len = len;
+}
+
+INLINE_MODIFIER INLINE kal_uint16 QBM_SPD_PIE_GET_PAYLOAD_LEN( 
+    qbm_spd_pie *p_spdpie )
+{
+    return p_spdpie->payload_len;
+}
+
+INLINE_MODIFIER INLINE qbm_spd_pie* QBM_SPD_PIE_NEXT( 
+    qbm_spd_pie *p_spdpie )
+{
+    kal_uint32* addr = (kal_uint32 *)((kal_uint8 *)(p_spdpie) + 
+        sizeof(p_spdpie));
+
+    if( *addr == QBM_SPD_GUARD_PATTERN )
+    {
+        return NULL;
+    }
+    else 
+    {
+        return (qbm_spd_pie *)addr;
+    }
+}
+
+/****************************************************************************/
+/*! @brief Get the next payload element in the ring buffer.
+
+    Basically, this function helps on 4-bytes aligment address shifting.
+    
+    @param[in] p_payload a pointer to a payload in a ring buffer.
+    @param[in] len the current payload length.
+    @return the address of next payload.
+    @since UMOLY
+*/
+/****************************************************************************/
+INLINE_MODIFIER INLINE kal_uint8* QBM_SPD_PAYLOAD_NEXT( 
+    kal_uint8 *p_payload, kal_uint16 len )
+{    
+    return (p_payload + ((len + 3) & ~(0x3)));
+}
+
+/****************************************************************************/
+/* Sample Code
+
+    p_spd = (qbm_spd*) QBM_ALLOC_ONE(QBM_TYPE_HIF_DL_SPD);
+
+    QBM_DES_SET_DATAPTR( p_psd, p_payload );
+    QBM_SPD_SET_PIT( p_spd,10);
+    QBM_SPD_SET_RBIT(p_spd,5);
+        
+    p_spd_pi = QBM_SPD_GET_PI(p_spd );
+    QBM_SPD_PI_SET_PKTNUM( p_spd_pi, 30 );
+
+    p_spd_pie = QBM_SPD_PI_GET_FIRST_PIE(p_spd_pi);
+    p_payload = QBM_DES_GET_DATAPTR( p_spd );
+
+    for (i=0;i<39;i++)
+    {
+        QBM_SPD_PIE_SET_PAYLOAD_LEN(p_spd_pie,1460);
+
+        if (i == 29 ) 
+        {
+            QBM_SPD_PIE_SET_EOL(p_spd_pie);
+        }            
+        else 
+        {
+            p_spd_pie = QBM_SPD_PIE_NEXT(p_spd_pie);
+            p_payload = QBM_SPD_PAYLOAD_NEXT(p_payload, 1460);
+        }            
+    }
+
+*/
+#endif /* #ifndef GEN_FOR_PC */
+/****************************************************************************/
+#endif /* QMU_BM_SPD_H */
+
diff --git a/mcu/interface/service/qmu_bm/qmu_bm_util.h b/mcu/interface/service/qmu_bm/qmu_bm_util.h
new file mode 100644
index 0000000..461191c
--- /dev/null
+++ b/mcu/interface/service/qmu_bm/qmu_bm_util.h
@@ -0,0 +1,685 @@
+/*****************************************************************************
+*  Copyright Statement:
+*  --------------------
+*  This software is protected by Copyright and the information contained
+*  herein is confidential. The software may not be copied and the information
+*  contained herein may not be used or disclosed except with the written
+*  permission of MediaTek Inc. (C) 2012
+*
+*  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+*  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+*  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
+*  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
+*  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
+*  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
+*  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
+*  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
+*  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
+*  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
+*  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
+*  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
+*
+*  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
+*  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
+*  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
+*  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
+*  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
+*
+*  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
+*  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
+*  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
+*  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
+*  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
+*
+*****************************************************************************/
+
+/*******************************************************************************
+ * Filename:
+ * ---------
+ *   qmu_bm_util.h
+ *
+ * Project:
+ * --------
+ *   MOLY
+ *
+ * Description:
+ * ------------
+ *
+ *
+ * Author:
+ * -------
+ * -------
+ *   
+ *
+ * ==========================================================================
+ * $Log$
+ *
+ * 11 21 2017 wen-jiunn.liu
+ * [MOLY00279230] [93/95 re-arch] Gen95 Development
+ * [QBM] qbm_env_is_dma_only_noncacheable() and INT_SW_SecVersion() Phase-Out
+ *
+ * 05 10 2017 wen-jiunn.liu
+ * [MOLY00248479] [QBM] QBM Size Reduction
+ * [QMU_BM] Code Sync from UMOLY for QBM Cache Flush Non-Blocking API
+ * 	
+ * 	[MOLY00191046] [QBM][UMOLY] check-in flush non-blocking API
+ * 	(eric.hsieh) @ //UMOLY/TRUNK/UMOLY/: CL2589147 - Add QBM cache flush non-blocking API.
+ *
+ * 07 14 2016 eric.hsieh
+ * [MOLY00191046] [QBM][UMOLY] check-in flush non-blocking API
+ * Add QBM cache flush non-blocking API.
+ * 10 19 2016 wen-jiunn.liu
+ * [MOLY00208021] [UMOLYA] QMU_BM Code Review
+ * remove redundant codes
+ *
+ * 10 19 2016 wen-jiunn.liu
+ * [MOLY00208021] [UMOLYA] QMU_BM Code Review
+ * QMU_BM retires obsolete queues and mechanisms of buffers in flcv2 (ut pass)
+ *
+ * 05 21 2015 stan.chen
+ * [MOLY00114732] [6291] MD Support RXSPD and 3KMTU
+ * [QBM] Support HIF_UL_SPD.
+ *
+ * 11 11 2014 stan.chen
+ * [MOLY00079805] [TK6291_DEV] Support QBM/DNAS SPD LogDMA
+ * Merging QMU_BM from 91_DEV
+ *
+ * 06 26 2014 moja.hsu
+ * [MOLY00070335] Inter rat FLC size change HIF notify
+ * notify upper layer about buffer shrink normal.
+ *
+ * 05 07 2014 moja.hsu
+ * [MOLY00064918] One SW Load for MT6595 E1/E2
+ * add DMA TYPE Query.
+ *
+ * 01 13 2014 moja.hsu
+ * [MOLY00053475] Disable GPD/BD checksum feature to save MIPS
+ * Merging
+ *  	
+ * 	//MOLY_CBr/tj.chang/MOLY_Profile.w1352p1/mcu/...
+ *  	
+ * 	to //MOLY/TRUNK/MOLY/mcu/...
+ *
+ * 01 31 2013 moja.hsu
+ * [MOLY00007625] Maintain code
+ * add comment for qbm_reset_pd API.
+ * For some user mis-understand it will help to calculate checksum.
+ * It won't.
+ *
+ * 01 02 2013 moja.hsu
+ * [MOLY00008133] Request to add QMU_BM GPD reset function
+ * add qbm_reset_pd function for user to reset their buffer format by QBM Type.
+ ****************************************************************************/
+/*
+ * =====================================================================================
+ *
+ *       Filename:  qmu_bm_util.h
+ *
+ *    Description:  Some customize API. 
+ *                  Used for testing, or easy manager HW Queue.
+ *
+ *           Note:  The all API are not protected, so for every potential lock problem.
+ *                  User should protect it by himself.
+ *                  e.g. 
+ *                  1) for HIF En-Q, it may be called by many threads.
+ *                     So when HIF use qbmt_common_en_q, it need lock.
+ *                  2) for PDCP Cipher en-q, it may only be called on PDCP context.
+ *                     So PDCP don't need to protect it.
+ *
+ *        Created:  2011/6/15 03:35:28
+ *        Author:  mtk01641 (moja)
+ * =====================================================================================
+ */
+#ifndef  QMU_BM_UTIL_INC
+#define  QMU_BM_UTIL_INC
+/****************************************************************************/
+
+#include "qmu_bm.h"
+
+/* 
+ * Because kal cache related api have alignment restriction.
+ * Not convenient. So just export this API for user who is not sure the alignement.
+ */
+#if defined(__DYNAMIC_SWITCH_CACHEABILITY__)
+#define QBM_CACHE_GET_ALIGN(_o, _sz, _alo, _alsz) \
+{                                                 \
+    _alo   = (kal_uint32)(_o);                    \
+    _alsz  = (_sz);                               \
+    if(_alo&CPU_CACHE_LINE_SIZE_MASK) {           \
+        _alo = (kal_uint32)(_o)&~CPU_CACHE_LINE_SIZE_MASK;    \
+        _alsz += (kal_uint32)(_o)&CPU_CACHE_LINE_SIZE_MASK;   \
+    }                                             \
+    _alsz = _alsz + CPU_CACHE_LINE_SIZE - 1;      \
+    _alsz = _alsz & ~CPU_CACHE_LINE_SIZE_MASK;    \
+}
+
+/**
+ * @brief QBM_CACHE_FLUSH_ALIGN 
+ * If we already know the address and size are align, 
+ * we can use this macro to save MIPs
+ *
+ * @param _o
+ * @param _sz
+ *
+ * @return 
+ */
+#define QBM_CACHE_FLUSH_ALIGN(_o, _sz) \
+{                                      \
+    clean_dcache((kal_uint32)(_o), (kal_uint32)(_sz));             \
+}
+
+#define QBM_CACHE_INVALID_ALIGN(_o, _sz) \
+{                                        \
+    invalidate_dcache((kal_uint32)(_o), (kal_uint32)(_sz));          \
+}
+
+#define QBM_CACHE_FLUSH(_o, _sz)                 \
+{                                                \
+    kal_uint32 _addr;                            \
+    kal_uint32 _isz;                             \
+    QBM_CACHE_GET_ALIGN((_o), _sz, _addr, _isz);   \
+    clean_dcache(                                \
+            _addr,                               \
+            _isz                                 \
+            );                                   \
+}
+
+#define QBM_CACHE_INVALID(_o, _sz)               \
+{                                                \
+    kal_uint32 _addr;                            \
+    kal_uint32 _isz;                             \
+    QBM_CACHE_GET_ALIGN((_o), _sz, _addr, _isz);   \
+    invalidate_dcache(                           \
+            _addr,                               \
+            _isz                                 \
+            );                                   \
+}
+
+#define QBM_CACHE_FLUSH_ALIGN_NO_DSR(_o, _sz) \
+{                                      \
+    clean_dcache_nonblocking((kal_uint32)(_o), (kal_uint32)(_sz));             \
+}
+
+#define QBM_CACHE_FLUSH_NO_DSR(_o, _sz)          \
+{                                                \
+    kal_uint32 _addr;                            \
+    kal_uint32 _isz;                             \
+    QBM_CACHE_GET_ALIGN((_o), _sz, _addr, _isz);   \
+    clean_dcache_nonblocking(                                \
+            _addr,                               \
+            _isz                                 \
+            );                                   \
+}
+
+#define QBM_DSR() MM_Sync()
+
+#else
+#define QBM_CACHE_FLUSH_ALIGN(_o, _sz)
+#define QBM_CACHE_INVALID_ALIGN(_o, _sz)
+#define QBM_CACHE_FLUSH(_o, _sz)
+#define QBM_CACHE_INVALID(_o, _sz)
+#define QBM_CACHE_FLUSH_ALIGN_NO_DSR(_o, _sz)
+#define QBM_CACHE_FLUSH_NO_DSR(_o, _sz)
+#define QBM_DSR()
+#endif
+
+/* 
+ * ===  FUNCTION  ======================================================================
+ *         Name:  qmu_util_set_flush_region
+ *  Description:  Set the flush region. It's used for en_q function.
+ *                en_q function only flush data part 
+ *                when the memory is in the flush region
+ *
+ *   Note: It is used internally.
+ *         Please don't call it unless testing purpose.
+ *
+ *  s_mem: region start address
+ *  e_mem: region end   address
+ * =====================================================================================
+ */
+void qmu_util_set_flush_region(kal_uint32 s_mem, kal_uint32 e_mem);
+
+/* 
+ * ===  FUNCTION  ======================================================================
+ *         Name:  qbm_cal_set_checksum_by_len
+ *  Description:  Calculate checksum for check_len bytes 
+ *                and set it in descriptor checksum field.
+ *                The formula is to use byte to store all bytes sum 
+ *                and use 0xFF - all bytes sum.
+ *        Note:   The check_len must be divided by 4
+ * @param data calculate checksum start address
+ * @param len  length of protected data.
+ * =====================================================================================
+ */
+#ifdef __ENABLE_QMU_CHECKSUM__
+void       qbm_cal_set_checksum_by_len(const kal_uint8 *data, const kal_uint32 check_len);
+kal_uint32 qbm_cal_checksum_by_len(const kal_uint8 *data, const kal_uint32 check_len);
+#else
+#define qbm_cal_set_checksum_by_len(_d, _l)
+#define qbm_cal_checksum_by_len(_d, _l) 0
+#endif
+
+/* 
+ * ===  FUNCTION  ======================================================================
+ *         Name:  qbm_cal_set_checksum_wth_hwo_by_len
+ *  Description:  Just like qbm_cal_set_checksum_by_len, but it will treat HWO bit as 1.
+ *                The HWO bit may not be 1 in the memory.
+ * =====================================================================================
+ */
+#ifdef __ENABLE_QMU_CHECKSUM__
+void       qbm_cal_set_checksum_wth_hwo_by_len(const kal_uint8 *data, const kal_uint32 check_len);
+kal_uint32 qbm_cal_checksum_wth_hwo_by_len(const kal_uint8 *data, const kal_uint32 check_len);
+#else
+#define qbm_cal_set_checksum_wth_hwo_by_len(_d, _l)
+#define qbm_cal_checksum_wth_hwo_by_len(_d, _l) 0
+#endif
+
+/** 
+ * @brief qbm_cal_set_checksum_wth_hwo
+ * Fix 12 bytes.
+ * Just like calculate checksum. But it will treat the HWO bit to 1.
+ * Because we may set HWO bit later and resume HW.
+ * In this case we can't use the first byte to calculate checksum.
+ */
+#ifdef __ENABLE_QMU_CHECKSUM__
+void       qbm_cal_set_checksum_wth_hwo(const kal_uint8 * const data);
+kal_uint32 qbm_cal_checksum_wth_hwo(const kal_uint8 * const data);
+#else
+#define qbm_cal_set_checksum_wth_hwo(_d)
+#define qbm_cal_checksum_wth_hwo(_d) 0
+#endif
+
+/**
+ * @brief qbmt_cache_flush_q 
+ * Flush PD/BD and data part(if the data part is configured to be flushed)
+ *
+ * @param p_head
+ * @param p_tail
+ * @param hwo     0: don't fill hwo bit.
+ *                1: fill hwo bit to 1 and recalculate checksum.
+ */
+void qbmt_cache_flush_q(void *p_head, void *p_tail, kal_uint32 hwo);
+
+/* 
+ * EnQ by reuse the tail descriptor.
+ * It will do memory copy, and hold the p_new_tail for tail(HWO = 0).
+ * Note: User should make sure all TGPD extension part are enough.
+ * This API will scan all TGPD/TBD list, and do cache flush.
+ *
+ * Param:
+ * p_new_head, p_new_tail: the new list want to be enqueued.
+ *
+ * pp_orig_head, pp_orig_tail: original list queue on HW QMU.
+ *
+ * The original source tail will be updated after en-queue.
+ * 
+ * hwo: 0 - don't do anything on the new list.
+ *          Assume the HWO of this queue from p_new_head to p_new_tail all "1" and checksum is right
+ *      1 - set hwo on the new list (from p_new_head to p_new_tail).
+ *      Because in some case, we may de-q data from one HW and en-q data to another HW.
+ *      e.g. 
+ *      HIF->PPP Copro
+ *      TFT Copro -> Cipher Engine.
+ *      
+ *      In this case, the HWO need to to reset to 1.
+ *      If we always set HWO to 1 by the user, it waste time.
+ *      (user need to traverse all list and en_q also traverse all list)
+ *      So we can reduce MIPs by set the HWO and checksum on en_Q process.
+ */
+void
+qbmt_common_en_q(
+		void *p_new_head, 
+		void *p_new_tail, 
+		void **pp_orig_head, 
+		void **pp_orig_tail,
+		kal_uint32 hwo
+		);
+
+/* 
+ * Like qbmt_common_en_q, but this api only link descriptor.
+ * Don't do travse the whole PD list to flush thing.
+ * Save MIPs when en_q a larger PD and the PD is non-cacheable or don't need to do flush.
+ */
+void
+qbmt_common_en_q_no_flush(
+		void *p_new_head, 
+		void *p_new_tail, 
+		void **pp_orig_head, 
+		void **pp_orig_tail
+		);
+
+/****************************************************************************/
+/*! @brief EnQ with a bypass bit TGPD.
+
+    This API will scan all TGPD/TBD list, and do cache flush.
+    The TGPD is allocated in this API. If no TGPD memory, it will return 
+    QBM_ERROR_MEM_NOT_ENOUGH.
+    This API assume the original tail is a bypass bit TGPD. So it just easily 
+    link the new list at the tail. The source tail will be updated to the 
+    bypass TGPD.
+
+    CAUTION:
+    For UMOLY SPDs, QBM only helps on flush descirptor part only. This is
+    because SPDs carry a large extension space.
+      
+    @param[in] p_new_head a pointer to a head of new pd list to enqueue.
+    @param[in] p_new_tail a pointer to a tail of new pd list to enqueue.
+    @param[in,out] pp_orig_head a pointer to a original queue head.
+    @param[in,out] pp_orig_tail a pointer to a original queue tail.
+    @param[in] hwo HOW bit value to set.   
+    @return QBM error code.
+    @since LR9
+*/
+/****************************************************************************/
+kal_int32
+qbmt_common_en_q_wth_bypass(
+		void *p_new_head, 
+		void *p_new_tail, 
+		void **pp_orig_head, 
+		void **pp_orig_tail,
+		kal_uint32 hwo
+		);
+
+/****************************************************************************/
+/*! @brief Like qbmt_common_en_q_wth_bypass, but don't do cache flush
+     
+    @param[in] p_new_head a pointer to a head of new pd list to enqueue.
+    @param[in] p_new_tail a pointer to a tail of new pd list to enqueue.
+    @param[in,out] pp_orig_head a pointer to a original queue head.
+    @param[in,out] pp_orig_tail a pointer to a original queue tail.
+    @return QBM error code.
+    @since LR9
+*/
+/****************************************************************************/
+kal_int32
+qbmt_common_en_q_wth_bypass_no_flush(
+		void *p_new_head, 
+		void *p_new_tail, 
+		void **pp_orig_head, 
+		void **pp_orig_tail
+		);
+
+/* 
+ * ===  FUNCTION  ======================================================================
+ *         Name:  qbmt_common_en_q_rx
+ *  Description:  En-q new list for Receiver side.
+ *                It is like reload_q, but the new list is from outside, 
+ *                this API just help to link new list to the original list.
+ *                This API won't help to do cache flush, 
+ *                because the new list is supposed from BM and it is done cache flush when
+ *                call alloc_q_no_tail.
+ *
+ *                This API will link new head to the orig_tail,
+ *                change new tail HWO to 0. (will help do cache flush)
+ *                and then change orig_tail'HWO to 1. (will help do cache flush)
+ *                Update *pp_orig_tail to the new tail.
+ *
+ *                Used scenario:
+ *                Driver don't allocate buffer, it is get buffer from upper APP.
+ * =====================================================================================
+ */
+void
+qbmt_common_en_q_rx(
+		void *p_new_head, 
+		void *p_new_tail, 
+		void **pp_orig_head, 
+		void **pp_orig_tail
+		);
+
+/* 
+ * ===  FUNCTION  ======================================================================
+ *         Name:  qbmt_de_q_n
+ *  Description:  DeQ RGPD from QMU. This API will check the HWO bit.
+ *                If HWO bit is 0, the buffer will be de-q from the QMU.
+ *                The RGPD/RBD descriptor will be cache invalided.
+ *
+ *	   	   Note: The whole buffer list in the QMU should have the same attribute.
+ *	   	         All data part are need to be invalidate or not.
+ *
+ *    pp_src_head, pp_src_tail 
+ *       Original queue on QMU (May be used to receive data from host)
+ *       After de-q, the *pp_src_head will be updated to the next of the last buffer.
+ *    
+ *    n: Max de-q number.
+ *    
+ *    pp_new_head, pp_new_tail
+ *       The de-queued buffer list will be stored here.
+ *
+ *    Return: The number of de-queued RGPD.
+ *          
+ * =====================================================================================
+ */
+kal_uint32
+qbmt_de_q_n(
+		void **pp_src_head, 
+		void **pp_src_tail, 
+		kal_uint32 max_n,
+		void **pp_new_head,
+		void **pp_new_tail
+		);
+
+/* 
+ * ===  FUNCTION  ======================================================================
+ *         Name:  qbmt_de_q
+ *  Description:  Just like qbmt_de_q_n, but the number is not restricted.
+ *                It will de-q until HWO = 1 or tail is reached (not include tail).
+ * =====================================================================================
+ */
+kal_uint32
+qbmt_de_q(
+		void **pp_src_head, 
+		void **pp_src_tail, 
+		void **pp_new_head, 
+		void **pp_new_tail
+		);
+
+/* 
+ * ===  FUNCTION  ======================================================================
+ *         Name:  qbmt_de_q_tx_n
+ *  Description:  DeQ TGPD from QMU. This API will check the HWO bit.
+ *                If HWO bit is 0, the buffer will be de-q from the QMU.
+ *                It only invalid TGPD.
+ *
+ *    pp_src_head, pp_src_tail 
+ *       Original TGPD queue on QMU (May be used to transmit data to host)
+ *       After de-q, the *pp_src_head will be updated to the next of the last buffer(*pp_new_tail).
+ *    
+ *    n: Max de-q number.
+ *    
+ *    pp_new_head, pp_new_tail
+ *       The de-queued buffer list will be stored here.
+ *
+ *    Return: The number of de-queued TGPD.
+ *          
+ * =====================================================================================
+ */
+kal_uint32
+qbmt_de_q_tx_n(
+		void **pp_src_head, 
+		void **pp_src_tail, 
+		kal_uint32 max_n,
+		void **pp_new_head,
+		void **pp_new_tail
+		);
+kal_uint32
+qbmt_de_q_tx(
+		void **pp_src_head, 
+		void **pp_src_tail, 
+		void **pp_new_head,
+		void **pp_new_tail
+		);
+
+/* 
+ * ===  FUNCTION  ======================================================================
+ *         Name:  qbm_set_extended_param
+ *  Description:  Set extended parameter value.
+ *                Used for some queue operation.
+ *                1. dynamic allow length for USB dynamic chunk size.
+ *
+ *                User should know the queue operation when set it.
+ * =====================================================================================
+ */
+void
+qbm_set_extended_param(kal_uint32 type, kal_int32 value);
+
+/* 
+ * ===  FUNCTION  ======================================================================
+ *         Name:  qbm_set_non_free
+ *  Description:  Set the PD as non-free type.
+ *                Used when user want to use their own buffer, (non-allocated from BM)
+ *                It should cooperate with qbm_set_used and qbm_get_used APIs.
+ *                Use set used to declare teh p_pd is used.
+ *                Use get_used to check if the PD is released by the BM.
+ *                User should reserve QBM_HEAD_SIZE before the p_pd.
+ * =====================================================================================
+ */
+void
+qbm_set_non_free(void *p_pd);
+
+/* 
+ * ===  FUNCTION  ======================================================================
+ *         Name:  qbm_init_queue_non_free
+ *  Description:  Just like qbm_init_q,
+ *                But it will init the all buffer as non-free type.
+ *                The descriptors will be returned on pp_head and pp_tail.
+ *
+ *                Just help to split non-free type memory pool for easy usage.
+ *                User also need to specify p_conf for the memory pool and buffer number.
+ *
+ *       Return:  qbm_error_code
+ *       Note:    before use it, you should init p_conf first.
+ *                This API won't affect qbm inner status. 
+ * =====================================================================================
+ */
+kal_int32 
+qbm_init_queue_non_free(qbm_type type, bm_queue_config *p_conf, void **pp_head, void **pp_tail);
+
+/**
+ * @brief qbm_init_queue_non_free_on_exception 
+ * It's pure function, just split memory by QBM_TYPE_TGPD format.
+ * If code section is protected, this API should always works.
+ * May be used on exception handler.
+ *
+ * The descriptors will be returned on pp_head and pp_tail.
+ *
+ * @param p_conf 
+ * @param pp_head
+ * @param pp_tail
+ *
+ * @return qbm_error_code
+ */
+kal_int32 
+qbm_init_queue_non_free_tgpd(bm_queue_config *p_conf, void **pp_head, void **pp_tail);
+
+/* 
+ * ===  FUNCTION  ======================================================================
+ *         Name:  qbm_get_used
+ *  Description:  Non-Free type API.
+ *                Check the used bit in BM Header.
+ *                Used to check if the PD is released by BM.
+ * =====================================================================================
+ */
+kal_uint32
+qbm_get_used(void *p_pd);
+
+/* 
+ * ===  FUNCTION  ======================================================================
+ *         Name:  qbm_set_used
+ *  Description:  Non-Free type API.
+ *                Set the PD as used.
+ *                Set it before en-q it to QMU.
+ * =====================================================================================
+ */
+void
+qbm_set_used(void *p_pd);
+
+/* 
+ * ===  FUNCTION  ======================================================================
+ *         Name:  qbm_reset_pd
+ *  Description:  Used to reset PD format by the specified type. 
+ *                It just reset the format to the format by document. 
+ *                The checksum will usually be 0.
+ * =====================================================================================
+ */
+void
+qbm_reset_pd(qbm_type type, void *p_pd);
+
+
+/* 
+ * Simple GPD list management.
+ * Used for data queue.
+ * We can use the same operation (Don't check null) by reserved head memory space.
+ */
+typedef struct 
+{
+    qbm_gpd head;
+    qbm_gpd *p_tail;
+}qbm_gpd_list;
+
+/*
+ * Clear the data list.
+ * Just reset p_tail to head
+ */
+#define qbm_gpd_list_clr(_p) \
+    (_p)->p_tail = &((_p)->head)
+
+/*
+ * Check if the data list is empty.
+ */
+#define qbm_gpd_list_is_empty(_p) \
+    ((_p)->p_tail == &((_p)->head))
+
+/*
+ * Get first PD node
+ */
+#define qbm_gpd_list_get_head(_p) \
+    QBM_DES_GET_NEXT(&(_p)->head)
+
+/*
+ * Get last PD node
+ */
+#define qbm_gpd_list_get_tail(_p) \
+    (_p)->p_tail
+
+/*
+ * Add GPD to the list
+ */
+#define qbm_gpd_list_add(_p, _pd)        \
+{                                        \
+    QBM_DES_SET_NEXT((_p)->p_tail, _pd); \
+    (_p)->p_tail = (qbm_gpd*)_pd;        \
+}
+
+/*
+ * Add GPD list to the list
+ * _pd_h, the new list head
+ * _pd_t, the new list tail
+ */
+#define qbm_gpd_list_add_list(_p, _pd_h, _pd_t) \
+{                                               \
+    QBM_DES_SET_NEXT((_p)->p_tail, _pd_h);      \
+    (_p)->p_tail = (qbm_gpd*)_pd_t;             \
+}
+
+/**
+ * @brief qbm_gpd_list_dest 
+ * Drop the PD on the list and reset the list to empty.
+ *
+ * @param _p
+ *
+ * @return 
+ */
+#define qbm_gpd_list_drop(_p)              \
+{                                          \
+    if (!qbm_gpd_list_is_empty(_p)) {      \
+        qbmt_dest_q(                       \
+                qbm_gpd_list_get_head(_p), \
+                qbm_gpd_list_get_tail(_p)  \
+                );                         \
+        qbm_gpd_list_clr(_p);              \
+    }                                      \
+}
+
+/****************************************************************************/
+#endif   /* ----- #ifndef QMU_BM_UTIL_INC  ----- */
+