- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

# /space/home/slher/rel/Beken/v6_4_5/macsw/modules/mac/src/mac.c

Go to the documentation of this file.

    00001
    00020 /*
    00021  * INCLUDE FILES
    00022  ****************************************************************************************
    00023  */
    00024 // for other MAC definitions
    00025 #include "mac.h"
    00026 #include "hal_desc.h"
    00027
    00028 /*
    00029  * GLOBAL VARIABLES
    00030  ****************************************************************************************
    00031  */
    00032 const uint8_t mac_tid2ac[TID_MAX] =
    00033 {
    00034     AC_BE,    // TID0
    00035     AC_BK,    // TID1
    00036     AC_BK,    // TID2
    00037     AC_BE,    // TID3
    00038     AC_VI,    // TID4
    00039     AC_VI,    // TID5
    00040     AC_VO,    // TID6
    00041     AC_VO,    // TID7
    00042     AC_VO     // TIDMGT
    00043 };
    00044
    00045 const uint8_t mac_ac2uapsd[AC_MAX] =
    00046 {
    00047     [AC_BK] = MAC_QOS_INFO_STA_UAPSD_ENABLED_BK,
    00048     [AC_BE] = MAC_QOS_INFO_STA_UAPSD_ENABLED_BE,
    00049     [AC_VI] = MAC_QOS_INFO_STA_UAPSD_ENABLED_VI,
    00050     [AC_VO] = MAC_QOS_INFO_STA_UAPSD_ENABLED_VO,
    00051 };
    00052
    00053 const uint8_t mac_aci2ac[AC_MAX] =
    00054 {
    00055     [0] = AC_BE,
    00056     [1] = AC_BK,
    00057     [2] = AC_VI,
    00058     [3] = AC_VO,
    00059 };
    00060
    00061 const uint8_t mac_ac2aci[AC_MAX] =
    00062 {
    00063     [AC_BK] = 1,
    00064     [AC_BE] = 0,
    00065     [AC_VI] = 2,
    00066     [AC_VO] = 3,
    00067 };
    00068
    00069 const uint8_t mac_id2rate[MAC_RATESET_LEN] =
    00070 {
    00071     MAC_RATE_1MBPS,
    00072     MAC_RATE_2MBPS,
    00073     MAC_RATE_5_5MBPS,
    00074     MAC_RATE_11MBPS,
    00075     MAC_RATE_6MBPS,
    00076     MAC_RATE_9MBPS,
    00077     MAC_RATE_12MBPS,
    00078     MAC_RATE_18MBPS,
    00079     MAC_RATE_24MBPS,
    00080     MAC_RATE_36MBPS,
    00081     MAC_RATE_48MBPS,
    00082     MAC_RATE_54MBPS
    00083 };
    00084
    00085 const struct mac_addr mac_addr_bcst = {{0xFFFF, 0xFFFF, 0xFFFF}};
    00086
    00087
    00088 /*
    00089  * FUNCTIONS
    00090  ****************************************************************************************
    00091  */
    00092 uint32_t mac_paid_gid_sta_compute(struct mac_addr const *mac_addr)
    00093 {
    00094     uint32_t paid, gid;
    00095     uint32_t mac_ptr = CPU2HW(mac_addr);
    00096
    00097     paid = (co_read8p(mac_ptr + 4) >> 7) | (co_read8p(mac_ptr + 5) << 1);
    00098     gid = 0;
    00099
    00100     return((paid << PAID_TX_OFT) | (gid << GID_TX_OFT));
    00101 }
    00102
    00103 uint32_t mac_paid_gid_ap_compute(struct mac_addr const *mac_addr, uint16_t aid)
    00104 {
    00105     uint32_t paid, gid;
    00106     uint32_t mac_ptr = CPU2HW(mac_addr);
    00107
    00108     paid = ((aid & 0x1FF) + (((co_read8p(mac_ptr + 5) & 0x0F) ^
    00109                                  ((co_read8p(mac_ptr + 5) & 0xF0) >> 4)) << 5))
    00110                                                   & 0x1FF;
    00111     gid = 63;
    00112
    00113     return((paid << PAID_TX_OFT) | (gid << GID_TX_OFT));
    00114 }
    00115
    00116 enum mac_akm_suite mac_akm_suite_value(uint32_t akm_suite)
    00117 {
    00118     switch (akm_suite)
    00119     {
    00120         case MAC_RSNIE_AKM_8021X:
    00121         case MAC_WPA_AKM_8021X:
    00122             return MAC_AKM_8021X;
    00123         case MAC_RSNIE_AKM_PSK:
    00124         case MAC_WPA_AKM_PSK:
    00125             return MAC_AKM_PSK;
    00126         case MAC_RSNIE_AKM_FT_8021X:
    00127             return MAC_AKM_FT_8021X;
    00128         case MAC_RSNIE_AKM_FT_PSK:
    00129             return MAC_AKM_FT_PSK;
    00130         case MAC_RSNIE_AKM_8021X_SHA256:
    00131             return MAC_AKM_8021X_SHA256;
    00132         case MAC_RSNIE_AKM_PSK_SHA256:
    00133             return MAC_AKM_PSK_SHA256;
    00134         case MAC_RSNIE_AKM_TDLS:
    00135             return MAC_AKM_TDLS;
    00136         case MAC_RSNIE_AKM_SAE:
    00137             return MAC_AKM_SAE;
    00138         case MAC_RSNIE_AKM_FT_OVER_SAE:
    00139             return MAC_AKM_FT_OVER_SAE;
    00140         case MAC_RSNIE_AKM_8021X_SUITE_B:
    00141             return MAC_AKM_8021X_SUITE_B;
    00142         case MAC_RSNIE_AKM_8021X_SUITE_B_192:
    00143             return MAC_AKM_8021X_SUITE_B_192;
    00144         case MAC_RSNIE_AKM_FILS_SHA256:
    00145             return MAC_AKM_FILS_SHA256;
    00146         case MAC_RSNIE_AKM_FILS_SHA384:
    00147             return MAC_AKM_FILS_SHA384;
    00148         case MAC_RSNIE_AKM_FT_FILS_SHA256:
    00149             return MAC_AKM_FT_FILS_SHA256;
    00150         case MAC_RSNIE_AKM_FT_FILS_SHA384:
    00151             return MAC_AKM_FT_FILS_SHA384;
    00152         case MAC_RSNIE_AKM_OWE:
    00153             return MAC_AKM_OWE;
    00154         case MAC_WAPI_AKM_CERT:
    00155             return MAC_AKM_WAPI_CERT;
    00156         case MAC_WAPI_AKM_PSK:
    00157             return MAC_AKM_WAPI_PSK;
    00158         default:
    00159             return -1;
    00160     }
    00161 }
    00162
    00163 enum mac_cipher_suite mac_cipher_suite_value(uint32_t cipher_suite)
    00164 {
    00165     switch (cipher_suite)
    00166     {
    00167         case MAC_RSNIE_CIPHER_WEP_40:
    00168             return MAC_CIPHER_WEP40;
    00169         case MAC_RSNIE_CIPHER_TKIP:
    00170         case MAC_WPA_CIPHER_TKIP:
    00171             return MAC_CIPHER_TKIP;
    00172         case MAC_RSNIE_CIPHER_CCMP_128:
    00173         case MAC_WPA_CIPHER_CCMP:
    00174             return MAC_CIPHER_CCMP;
    00175         case MAC_RSNIE_CIPHER_WEP_104:
    00176             return MAC_CIPHER_WEP104;
    00177         case MAC_RSNIE_CIPHER_BIP_CMAC_128:
    00178             return MAC_CIPHER_BIP_CMAC_128;
    00179         case MAC_RSNIE_CIPHER_GCMP_128:
    00180             return MAC_CIPHER_GCMP_128;
    00181         case MAC_RSNIE_CIPHER_GCMP_256:
    00182             return MAC_CIPHER_GCMP_256;
    00183         case MAC_RSNIE_CIPHER_CCMP_256:
    00184             return MAC_CIPHER_CCMP_256;
    00185         case MAC_RSNIE_CIPHER_BIP_GMAC_128:
    00186             return MAC_CIPHER_BIP_GMAC_128;
    00187         case MAC_RSNIE_CIPHER_BIP_GMAC_256:
    00188             return MAC_CIPHER_BIP_GMAC_256;
    00189         case MAC_RSNIE_CIPHER_BIP_CMAC_256:
    00190             return MAC_CIPHER_BIP_CMAC_256;
    00191         case MAC_WAPI_CIPHER_WPI_SMS4:
    00192             return MAC_CIPHER_WPI_SMS4;
    00193         default:
    00194             return -1;
    00195     }
    00196 }
    00197
    00199