1 /* 2 * rate.h 3 * 4 * Copyright(c) 1998 - 2010 Texas Instruments. All rights reserved. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 11 * * Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * * Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in 15 * the documentation and/or other materials provided with the 16 * distribution. 17 * * Neither the name Texas Instruments nor the names of its 18 * contributors may be used to endorse or promote products derived 19 * from this software without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34 35 /** \file rate.h 36 * \brief Rate conversion 37 * 38 * \see rate.c 39 */ 40 41 #ifndef RATE_H 42 #define RATE_H 43 44 #include "TWDriver.h" 45 46 47 typedef enum 48 { 49 NET_BASIC_MASK = 0x80, 50 NET_RATE_AUTO = 0x00, 51 NET_RATE_1M = 0x02, 52 NET_RATE_2M = 0x04, 53 NET_RATE_5_5M = 0x0B, 54 NET_RATE_11M = 0x16, 55 NET_RATE_22M = 0x2C, 56 NET_RATE_6M = 0x0C, 57 NET_RATE_9M = 0x12, 58 NET_RATE_12M = 0x18, 59 NET_RATE_18M = 0x24, 60 NET_RATE_24M = 0x30, 61 NET_RATE_36M = 0x48, 62 NET_RATE_48M = 0x60, 63 NET_RATE_54M = 0x6C, 64 NET_RATE_MCS0 = 0x0D, /* MCS0 6.5M */ 65 NET_RATE_MCS1 = 0x1A, /* MCS1 13M */ 66 NET_RATE_MCS2 = 0x27, /* MCS2 19.5M */ 67 NET_RATE_MCS3 = 0x34, /* MCS3 26M */ 68 NET_RATE_MCS4 = 0x4E, /* MCS4 39M */ 69 NET_RATE_MCS5 = 0x68, /* MCS5 52M */ 70 NET_RATE_MCS6 = 0x75, /* MCS6 58.5M */ 71 NET_RATE_MCS7 = 0x7F /* MCS7 65M */ 72 73 } ENetRate; 74 75 76 typedef enum 77 { 78 NET_RATE_1M_BASIC = (NET_RATE_1M | NET_BASIC_MASK), 79 NET_RATE_2M_BASIC = (NET_RATE_2M | NET_BASIC_MASK), 80 NET_RATE_5_5M_BASIC = (NET_RATE_5_5M | NET_BASIC_MASK), 81 NET_RATE_11M_BASIC = (NET_RATE_11M | NET_BASIC_MASK), 82 NET_RATE_22M_BASIC = (NET_RATE_22M | NET_BASIC_MASK), 83 NET_RATE_6M_BASIC = (NET_RATE_6M | NET_BASIC_MASK), 84 NET_RATE_9M_BASIC = (NET_RATE_9M | NET_BASIC_MASK), 85 NET_RATE_12M_BASIC = (NET_RATE_12M | NET_BASIC_MASK), 86 NET_RATE_18M_BASIC = (NET_RATE_18M | NET_BASIC_MASK), 87 NET_RATE_24M_BASIC = (NET_RATE_24M | NET_BASIC_MASK), 88 NET_RATE_36M_BASIC = (NET_RATE_36M | NET_BASIC_MASK), 89 NET_RATE_48M_BASIC = (NET_RATE_48M | NET_BASIC_MASK), 90 NET_RATE_54M_BASIC = (NET_RATE_54M | NET_BASIC_MASK), 91 NET_RATE_MCS0_BASIC = (NET_RATE_MCS0 | NET_BASIC_MASK), 92 NET_RATE_MCS1_BASIC = (NET_RATE_MCS1 | NET_BASIC_MASK), 93 NET_RATE_MCS2_BASIC = (NET_RATE_MCS2 | NET_BASIC_MASK), 94 NET_RATE_MCS3_BASIC = (NET_RATE_MCS3 | NET_BASIC_MASK), 95 NET_RATE_MCS4_BASIC = (NET_RATE_MCS4 | NET_BASIC_MASK), 96 NET_RATE_MCS5_BASIC = (NET_RATE_MCS5 | NET_BASIC_MASK), 97 NET_RATE_MCS6_BASIC = (NET_RATE_MCS6 | NET_BASIC_MASK), 98 NET_RATE_MCS7_BASIC = (NET_RATE_MCS7 | NET_BASIC_MASK) 99 100 } ENetRateBasic; 101 102 103 typedef enum 104 { 105 BASIC_RATE_SET_1_2 = 0, 106 BASIC_RATE_SET_1_2_5_5_11 = 1, 107 BASIC_RATE_SET_UP_TO_12 = 2, 108 BASIC_RATE_SET_UP_TO_18 = 3, 109 BASIC_RATE_SET_1_2_5_5_6_11_12_24 = 4, 110 BASIC_RATE_SET_UP_TO_36 = 5, 111 BASIC_RATE_SET_UP_TO_48 = 6, 112 BASIC_RATE_SET_UP_TO_54 = 7, 113 BASIC_RATE_SET_UP_TO_24 = 8, 114 BASIC_RATE_SET_6_12_24 = 9, 115 BASIC_RATE_SET_ALL_MCS_RATES = 10 116 } EBasicRateSet; 117 118 119 /* Keep increasing define values - related to increasing suported rates */ 120 typedef enum 121 { 122 SUPPORTED_RATE_SET_1_2 = 0, 123 SUPPORTED_RATE_SET_1_2_5_5_11 = 1, 124 SUPPORTED_RATE_SET_1_2_5_5_11_22 = 2, 125 SUPPORTED_RATE_SET_UP_TO_18 = 3, 126 SUPPORTED_RATE_SET_UP_TO_24 = 4, 127 SUPPORTED_RATE_SET_UP_TO_36 = 5, 128 SUPPORTED_RATE_SET_UP_TO_48 = 6, 129 SUPPORTED_RATE_SET_UP_TO_54 = 7, 130 SUPPORTED_RATE_SET_ALL = 8, 131 SUPPORTED_RATE_SET_ALL_OFDM = 9, 132 SUPPORTED_RATE_SET_ALL_MCS_RATES = 10 133 134 } ESupportedRateSet; 135 136 137 typedef enum 138 { 139 DRV_MODULATION_NONE = 0, 140 DRV_MODULATION_CCK = 1, 141 DRV_MODULATION_PBCC = 2, 142 DRV_MODULATION_QPSK = 3, 143 DRV_MODULATION_OFDM = 4 144 145 } EModulationType; 146 147 148 #define NET_BASIC_RATE(rate) ((rate) & NET_BASIC_MASK) 149 #define NET_ACTIVE_RATE(rate) (!NET_BASIC_RATE (rate)) 150 151 152 ERate rate_NumberToDrv (TI_UINT32 rate); 153 TI_UINT32 rate_DrvToNumber (ERate eRate); 154 ERate rate_NetToDrv (TI_UINT32 rate); 155 ENetRate rate_DrvToNet (ERate eRate); 156 TI_STATUS rate_DrvBitmapToNetStr (TI_UINT32 uSuppRatesBitMap, TI_UINT32 uBasicRatesBitMap, TI_UINT8 *string, TI_UINT32 *len, TI_UINT32 *pFirstOfdmRate); 157 TI_STATUS rate_DrvBitmapToNetStrIncluding11n (TI_UINT32 uSuppRatesBitMap, TI_UINT32 uBasicRatesBitMap, TI_UINT8 *string, TI_UINT32 *pFirstOfdmRate); 158 TI_STATUS rate_NetStrToDrvBitmap (TI_UINT32 *pBitMap, TI_UINT8 *string, TI_UINT32 len); 159 TI_STATUS rate_NetBasicStrToDrvBitmap (TI_UINT32 *pBitMap, TI_UINT8 *string, TI_UINT32 len); 160 TI_STATUS rate_McsNetStrToDrvBitmap (TI_UINT32 *pBitMap, TI_UINT8 *string); 161 TI_STATUS rate_DrvBitmapToHwBitmap (TI_UINT32 uDrvBitmap, TI_UINT32 *pHwBitmap); 162 TI_STATUS rate_PolicyToDrv (ETxRateClassId ePolicyRate, ERate *eAppRate); 163 TI_UINT32 rate_BasicToDrvBitmap (EBasicRateSet eBasicRateSet, TI_BOOL bDot11a); 164 TI_UINT32 rate_SupportedToDrvBitmap (ESupportedRateSet eSupportedRateSet, TI_BOOL bDot11a); 165 166 ERate rate_GetMaxFromDrvBitmap (TI_UINT32 uBitMap); 167 ENetRate rate_GetMaxBasicFromStr (TI_UINT8 *pRatesString, TI_UINT32 len, ENetRate eMaxRate); 168 ENetRate rate_GetMaxActiveFromStr (TI_UINT8 *pRatesString, TI_UINT32 len, ENetRate eMaxRate); 169 170 TI_STATUS rate_ValidateVsBand (TI_UINT32 *pSupportedMask, TI_UINT32 *pBasicMask, TI_BOOL bDot11a); 171 172 TI_UINT32 rate_GetDrvBitmapForDefaultBasicSet (void); 173 TI_UINT32 rate_GetDrvBitmapForDefaultSupporteSet (void); 174 175 #endif 176 177 178