- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

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

Go to the documentation of this file.

    00001
    00013 #ifndef _MAC_H_
    00014 #define _MAC_H_
    00015
    00029 /*
    00030  * INCLUDE FILES
    00031  ****************************************************************************************
    00032  */
    00033 // standard includes
    00034 #include "co_int.h"
    00035 #include "co_bool.h"
    00036 #include "co_math.h"
    00037 #include "co_utils.h"
    00038 #include "compiler.h"
    00039 #include "mac_types.h"
    00040
    00041 // for memcmp
    00042 #include <string.h>
    00043
    00044
    00045 /*
    00046  * DEFINES
    00047  ****************************************************************************************
    00048  */
    00050 #define TU_DURATION                     1024
    00051
    00053 #define MAC_BASIC_RATE                  0x80
    00054
    00056 #define WORD_ALIGN                      3
    00057
    00067 #define MAC_ADDR_CMP(addr1_ptr, addr2_ptr)                                              \
    00068     ((*(((uint16_t*)(addr1_ptr)) + 0) == *(((uint16_t*)(addr2_ptr)) + 0)) &&            \
    00069      (*(((uint16_t*)(addr1_ptr)) + 1) == *(((uint16_t*)(addr2_ptr)) + 1)) &&            \
    00070      (*(((uint16_t*)(addr1_ptr)) + 2) == *(((uint16_t*)(addr2_ptr)) + 2)))
    00071
    00080 #define MAC_ADDR_CMP_PACKED(__a1, __a2)                                                 \
    00081     (memcmp(__a1, __a2, MAC_ADDR_LEN) == 0)
    00082
    00091 #define MAC_ADDR_CPY(addr1_ptr, addr2_ptr)                                              \
    00092     *(((uint16_t*)(addr1_ptr)) + 0) = *(((uint16_t*)(addr2_ptr)) + 0);                  \
    00093     *(((uint16_t*)(addr1_ptr)) + 1) = *(((uint16_t*)(addr2_ptr)) + 1);                  \
    00094     *(((uint16_t*)(addr1_ptr)) + 2) = *(((uint16_t*)(addr2_ptr)) + 2)
    00095
    00104 #define MAC_SSID_CMP(ssid1_ptr,ssid2_ptr)                                               \
    00105     (((ssid1_ptr)->length == (ssid2_ptr)->length) &&                                    \
    00106      (memcmp((&(ssid1_ptr)->array[0]), (&(ssid2_ptr)->array[0]), (ssid1_ptr)->length) == 0))
    00107
    00115 #define MAC_ADDR_GROUP(mac_addr_ptr) ((*((uint8_t *)(mac_addr_ptr))) & 1)
    00116
    00118 #define MAC_FRAME_LEN 512
    00119
    00121 struct mac_frame
    00122 {
    00124     uint16_t length;
    00126     uint8_t array[MAC_FRAME_LEN];
    00127 };
    00128
    00130 #define MAC_DEFAULT_KEY_COUNT 4
    00132 #define MAC_DEFAULT_MFP_KEY_COUNT 6
    00133
    00135 struct key_info_tag
    00136 {
    00138     uint64_t rx_pn[TID_MAX];
    00140     uint64_t tx_pn;
    00142     union
    00143     {
    00144         struct
    00145         {
    00147             uint32_t tx_key[2];
    00149             uint32_t rx_key[2];
    00150         } mic;
    00151         struct
    00152         {
    00153             uint32_t key[4];
    00154         } mfp;
    00155     }u;
    00157     uint8_t cipher;
    00159     uint8_t key_idx;
    00161     uint8_t hw_key_idx;
    00163     bool valid;
    00164 };
    00165
    00167 struct mac_htoprnelmt
    00168 {
    00170     uint8_t     prim_channel;
    00172     uint8_t     ht_oper_1;
    00174     uint16_t    ht_oper_2;
    00176     uint16_t    ht_oper_3;
    00178     uint8_t     mcs_rate[MAX_MCS_LEN];
    00179
    00180 };
    00181
    00183 struct mac_mu_edca_param_set
    00184 {
    00186     uint32_t        ac_param[AC_MAX];
    00188     uint8_t         qos_info;
    00190     uint8_t         param_set_cnt;
    00191 };
    00192
    00194 struct mac_edca_param_set
    00195 {
    00197     uint32_t        ac_param[AC_MAX];
    00199     uint8_t         qos_info;
    00201     uint8_t         acm;
    00203     uint8_t         param_set_cnt;
    00204 };
    00205
    00207 #define MAC_QOS_INFO_STA_UAPSD_ENABLED_VO      CO_BIT(0)
    00209 #define MAC_QOS_INFO_STA_UAPSD_ENABLED_VI      CO_BIT(1)
    00211 #define MAC_QOS_INFO_STA_UAPSD_ENABLED_BK      CO_BIT(2)
    00213 #define MAC_QOS_INFO_STA_UAPSD_ENABLED_BE      CO_BIT(3)
    00215 #define MAC_QOS_INFO_STA_UAPSD_ENABLED_ALL     0x0F
    00217 #define MAC_QOS_INFO_AP_UAPSD_ENABLED          CO_BIT(7)
    00218
    00219 // Protection Status field (Bit indexes, Masks, Offsets)
    00221 #define MAC_PROT_NONERP_PRESENT_BIT        CO_BIT(0)
    00223 #define MAC_PROT_USE_PROTECTION_BIT        CO_BIT(1)
    00225 #define MAC_PROT_BARKER_PREAMB_BIT         CO_BIT(2)
    00227 #define MAC_PROT_ERP_STATUS_MASK           (MAC_PROT_NONERP_PRESENT_BIT |                \
    00228                                             MAC_PROT_USE_PROTECTION_BIT |                \
    00229                                             MAC_PROT_BARKER_PREAMB_BIT)
    00230
    00231 /*
    00232  * GLOBAL VARIABLES
    00233  ****************************************************************************************
    00234  */
    00236 extern const uint8_t mac_tid2ac[];
    00237
    00239 extern const uint8_t mac_ac2uapsd[];
    00240
    00242 extern const uint8_t mac_aci2ac[];
    00243
    00245 extern const uint8_t mac_ac2aci[];
    00246
    00247
    00249 extern const uint8_t mac_id2rate[];
    00250
    00252 extern const struct mac_addr mac_addr_bcst;
    00253
    00254
    00263 #define HE_MAC_CAPA_VAL_GET(he_cap, field)    co_val_get((he_cap)->mac_cap_info,         \
    00264                                                          HE_MAC_CAPA_##field##_OFT,      \
    00265                                                          HE_MAC_CAPA_##field##_WIDTH)
    00266
    00275 #define HE_MAC_CAPA_VAL_SET(he_cap, field, val) co_val_set((he_cap)->mac_cap_info,       \
    00276                                                            HE_MAC_CAPA_##field##_OFT,    \
    00277                                                            HE_MAC_CAPA_##field##_WIDTH,  \
    00278                                                            HE_MAC_CAPA_##field##_##val)
    00279
    00288 #define HE_MAC_CAPA_BIT_IS_SET(he_cap, bit)   co_bit_is_set((he_cap)->mac_cap_info,      \
    00289                                                             HE_MAC_CAPA_##bit##_POS)
    00290
    00298 #define HE_MAC_CAPA_BIT_SET(he_cap, bit)      co_bit_set((he_cap)->mac_cap_info,         \
    00299                                                           HE_MAC_CAPA_##bit##_POS)
    00300
    00308 #define HE_MAC_CAPA_BIT_CLR(he_cap, bit)      co_bit_clr((he_cap)->mac_cap_info,         \
    00309                                                          HE_MAC_CAPA_##bit##_POS)
    00310
    00319 #define HE_PHY_CAPA_VAL_GET(he_cap, field)    co_val_get((he_cap)->phy_cap_info,         \
    00320                                                          HE_PHY_CAPA_##field##_OFT,      \
    00321                                                          HE_PHY_CAPA_##field##_WIDTH)
    00322
    00331 #define HE_PHY_CAPA_VAL_SET(he_cap, field, val) co_val_set((he_cap)->phy_cap_info,       \
    00332                                                            HE_PHY_CAPA_##field##_OFT,    \
    00333                                                            HE_PHY_CAPA_##field##_WIDTH,  \
    00334                                                            HE_PHY_CAPA_##field##_##val)
    00335
    00344 #define HE_PHY_CAPA_BIT_IS_SET(he_cap, bit)   co_bit_is_set((he_cap)->phy_cap_info,      \
    00345                                                             HE_PHY_CAPA_##bit##_POS)
    00346
    00354 #define HE_PHY_CAPA_BIT_SET(he_cap, bit)      co_bit_set((he_cap)->phy_cap_info,         \
    00355                                                          HE_PHY_CAPA_##bit##_POS)
    00356
    00364 #define HE_PHY_CAPA_BIT_CLR(he_cap, bit)      co_bit_clr((he_cap)->phy_cap_info,         \
    00365                                                          HE_PHY_CAPA_##bit##_POS)
    00366
    00367 /*
    00368  * FUNCTION DECLARATIONS
    00369  ****************************************************************************************
    00370  */
    00384 __INLINE bool mac_nontxed_bssid_get(uint8_t bssid_index,
    00385                                     uint8_t max_bssid_ind,
    00386                                     struct mac_addr const *ref_bssid,
    00387                                     struct mac_addr *bssid)
    00388 {
    00389     uint16_t mask;
    00390
    00391     // Check if parameters are valid
    00392     if (!bssid_index || (max_bssid_ind > 8))
    00393         return false;
    00394
    00395     // Compute the nonTransmitted BSSID. Its (48-max_bss_ind) LSB shall be
    00396     // equal to the reference BSSID (48-max_bss_ind) LSB, and its max_bss_ind MSB
    00397     // are equal to: ((max_bss_ind reference BSSID LSB) + bssid_index) % (2^max_bss_ind)
    00398     mask = (CO_BIT(max_bssid_ind) - 1) << 8;
    00399     *bssid = *ref_bssid;
    00400     bssid->array[2] &= ~mask;
    00401     bssid->array[2] |= (ref_bssid->array[2] + (bssid_index << 8)) & mask;
    00402
    00403     return true;
    00404 }
    00405
    00417  __INLINE void mac_ref_bssid_get(uint8_t bssid_index,
    00418                                  uint8_t max_bssid_ind,
    00419                                  struct mac_addr const *bssid,
    00420                                  struct mac_addr *ref_bssid)
    00421 {
    00422     uint16_t mask;
    00423
    00424     // Compute the reference BSSID. Its (48-max_bss_ind) LSB shall be
    00425     // equal to the nonTransmitted BSSID (48-max_bss_ind) LSB, and its max_bss_ind MSB
    00426     // are equal to: ((max_bss_ind nonTransmitted BSSID LSB) - bssid_index) % (2^max_bss_ind)
    00427     mask = (CO_BIT(max_bssid_ind) - 1) << 8;
    00428     *ref_bssid = *bssid;
    00429     ref_bssid->array[2] &= ~mask;
    00430     ref_bssid->array[2] |= (bssid->array[2] - (bssid_index << 8)) & mask;
    00431 }
    00432
    00445 uint32_t mac_paid_gid_sta_compute(struct mac_addr const *mac_addr);
    00446
    00459 uint32_t mac_paid_gid_ap_compute(struct mac_addr const *mac_addr, uint16_t aid);
    00460
    00469 enum mac_akm_suite mac_akm_suite_value(uint32_t akm_suite);
    00470
    00479 enum mac_cipher_suite mac_cipher_suite_value(uint32_t cipher_suite);
    00480
    00481
    00483
    00484 #endif // _MAC_H_