platforms/os/Symbian/WVSS/src/wha/TIWhaUtils.h
changeset 0 10c42ec6c05f
equal deleted inserted replaced
-1:000000000000 0:10c42ec6c05f
       
     1 /*
       
     2  * TIWhaUtils.h
       
     3  *
       
     4  * Copyright(c) 1998 - 2010 Texas Instruments. All rights reserved.      
       
     5  * All rights reserved.      
       
     6  * 
       
     7  * This program and the accompanying materials are made available under the 
       
     8  * terms of the Eclipse Public License v1.0 or BSD License which accompanies
       
     9  * this distribution. The Eclipse Public License is available at
       
    10  * http://www.eclipse.org/legal/epl-v10.html and the BSD License is as below.                                   
       
    11  *                                                                       
       
    12  * Redistribution and use in source and binary forms, with or without    
       
    13  * modification, are permitted provided that the following conditions    
       
    14  * are met:                                                              
       
    15  *                                                                       
       
    16  *  * Redistributions of source code must retain the above copyright     
       
    17  *    notice, this list of conditions and the following disclaimer.      
       
    18  *  * Redistributions in binary form must reproduce the above copyright  
       
    19  *    notice, this list of conditions and the following disclaimer in    
       
    20  *    the documentation and/or other materials provided with the         
       
    21  *    distribution.                                                      
       
    22  *  * Neither the name Texas Instruments nor the names of its            
       
    23  *    contributors may be used to endorse or promote products derived    
       
    24  *    from this software without specific prior written permission.      
       
    25  *                                                                       
       
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   
       
    27  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     
       
    28  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
       
    29  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  
       
    30  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
       
    31  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      
       
    32  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
       
    33  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
       
    34  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   
       
    35  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
       
    36  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
       
    37  */
       
    38 
       
    39 
       
    40 
       
    41 /** \file  TIWhaUtils.h 
       
    42  *  \brief  Utilities used by TIWha layer only
       
    43  *
       
    44  *  \see   
       
    45  */
       
    46 
       
    47 #ifndef TI_WHA_UITLS_H
       
    48 #define TI_WHA_UITLS_H
       
    49 
       
    50 #include "TIWhaDef.h" 
       
    51 
       
    52 /**
       
    53  * TIWhaUtils class
       
    54  */
       
    55 class TIWhaUtils
       
    56 {
       
    57 public:  
       
    58 	static EMibTemplateType WhaToTwdFrameType(WHA::TTemplateType aFrameType); 
       
    59 	static ERate WhaToTwdRate (WHA::TRate aRate);
       
    60 	static WHA::TRate PolicyToWhaRate (ETxRateClassId aRate);
       
    61 	static TI_UINT32		WhaToMaskRate (WHA::TRate aRate);
       
    62     static TI_UINT32		WhaRateToRatePolicy(WHA::StxAutoRatePolicy* pTxAutoRatePolicy);
       
    63 #ifdef HT_SUPPORT
       
    64 	static TI_UINT32		HTWhaRateToRatePolicy(WHA::StxAutoRatePolicy* pTxAutoRatePolicy);
       
    65 	static TI_UINT32  		HTWhaToMaskRate (WHA::TRate aRate,WHA::THtMcsSet	aMcsRates);
       
    66 #endif /* HT_SUPPORT */
       
    67 };
       
    68 
       
    69 
       
    70 /* Align header to data: HEADER - OFFSET - DATA --> HEADER - DATA                            */
       
    71 /* pOriginalFrame points to the original place. It will change to point offset bytes ahead   */
       
    72 #define ALIGN_HEADER_TO_DATA_FORWARD(pOriginalFrame, uOffset, bQos) \
       
    73 {   \
       
    74     TI_INT32 i;    \
       
    75     TI_UINT16 *pNewFrame = ((TI_UINT16*)pOriginalFrame) + (uOffset / sizeof(TI_UINT16)); \
       
    76     if (bQos)   \
       
    77     {   \
       
    78         *((TI_UINT16*)pNewFrame + (WLAN_HDR_LEN / sizeof(TI_UINT16))) =    \
       
    79         *((TI_UINT16*)pOriginalFrame + (WLAN_HDR_LEN / sizeof(TI_UINT16)));   \
       
    80     }   \
       
    81     for (i = ((WLAN_HDR_LEN / sizeof(TI_UINT16)) - 1) ; i >= 0 ; i--) \
       
    82     {   \
       
    83 		pNewFrame[i] = *((TI_UINT16*)pOriginalFrame + i); \
       
    84     }   \
       
    85     pOriginalFrame = pNewFrame; \
       
    86 }
       
    87 
       
    88 /* Align header to data: HEADER - DATA --> HEADER - OFFSET - DATA                            */
       
    89 /* pOriginalFrame points to the original place. It will change to point offset bytes before  */
       
    90 #define ALIGN_HEADER_TO_DATA_BACKWARD(pOriginalFrame, uOffset, bQos) \
       
    91 {   \
       
    92     TI_INT32 i;    \
       
    93     TI_UINT16 *pNewFrame = ((TI_UINT16*)pOriginalFrame) - (uOffset / sizeof(TI_UINT16));  \
       
    94     for (i = 0 ; i < WLAN_HDR_LEN / sizeof(TI_UINT16) ; i++)    \
       
    95     {   \
       
    96         pNewFrame[i] = *((TI_UINT16*)pOriginalFrame + i); \
       
    97     }   \
       
    98     if (bQos)   \
       
    99     {   \
       
   100         *((TI_UINT16*)pNewFrame + (WLAN_HDR_LEN / sizeof(TI_UINT16))) =    \
       
   101         *((TI_UINT16*)pOriginalFrame + (WLAN_HDR_LEN / sizeof(TI_UINT16)));   \
       
   102     }   \
       
   103     pOriginalFrame = pNewFrame; \
       
   104 }
       
   105 
       
   106 
       
   107 #define CONVERT_TU_2_MICRO(tu)               (tu) * 1024
       
   108 
       
   109 /* 
       
   110 * Small macro to convert Dbm units into Dbm/10 units. This macro is important
       
   111 * in order to avoid over-flow of Dbm units bigger than 25
       
   112 */
       
   113 
       
   114 #define DBM2DBMDIV10(uTxPower) \
       
   115 	((uTxPower) > (MAX_TX_POWER / DBM_TO_TX_POWER_FACTOR) ? \
       
   116 		MAX_TX_POWER : (uTxPower) * DBM_TO_TX_POWER_FACTOR)		
       
   117 
       
   118 
       
   119 
       
   120 
       
   121 #endif /* TI_WHA_UITLS_H */
       
   122