root/drivers/staging/rtl8188eu/include/wifi.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. get_da
  2. get_sa
  3. get_hdr_bssid
  4. IsFrameTypeCtrl

   1 /* SPDX-License-Identifier: GPL-2.0 */
   2 /******************************************************************************
   3  *
   4  * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
   5  *
   6  ******************************************************************************/
   7 #ifndef _WIFI_H_
   8 #define _WIFI_H_
   9 
  10 #define WLAN_IEEE_OUI_LEN       3
  11 #define WLAN_CRC_LEN            4
  12 #define WLAN_BSSID_LEN          6
  13 #define WLAN_BSS_TS_LEN         8
  14 #define WLAN_HDR_A3_LEN         24
  15 #define WLAN_HDR_A4_LEN         30
  16 #define WLAN_HDR_A3_QOS_LEN     26
  17 #define WLAN_HDR_A4_QOS_LEN     32
  18 #define WLAN_DATA_MAXLEN        2312
  19 
  20 #define WLAN_A3_PN_OFFSET       24
  21 #define WLAN_A4_PN_OFFSET       30
  22 
  23 #define WLAN_MIN_ETHFRM_LEN     60
  24 #define WLAN_MAX_ETHFRM_LEN     1514
  25 
  26 #define P80211CAPTURE_VERSION   0x80211001
  27 
  28 /*  This value is tested by WiFi 11n Test Plan 5.2.3. */
  29 /*  This test verifies the WLAN NIC can update the NAV through sending
  30  *  the CTS with large duration.
  31  */
  32 #define WiFiNavUpperUs                          30000   /*  30 ms */
  33 
  34 enum WIFI_FRAME_TYPE {
  35         WIFI_MGT_TYPE  =        (0),
  36         WIFI_CTRL_TYPE =        (BIT(2)),
  37         WIFI_DATA_TYPE =        (BIT(3)),
  38         WIFI_QOS_DATA_TYPE      = (BIT(7)|BIT(3)),      /*  QoS Data */
  39 };
  40 
  41 enum WIFI_FRAME_SUBTYPE {
  42         /*  below is for mgt frame */
  43         WIFI_ASSOCREQ       = (0 | WIFI_MGT_TYPE),
  44         WIFI_ASSOCRSP       = (BIT(4) | WIFI_MGT_TYPE),
  45         WIFI_REASSOCREQ     = (BIT(5) | WIFI_MGT_TYPE),
  46         WIFI_REASSOCRSP     = (BIT(5) | BIT(4) | WIFI_MGT_TYPE),
  47         WIFI_PROBEREQ       = (BIT(6) | WIFI_MGT_TYPE),
  48         WIFI_PROBERSP       = (BIT(6) | BIT(4) | WIFI_MGT_TYPE),
  49         WIFI_BEACON         = (BIT(7) | WIFI_MGT_TYPE),
  50         WIFI_ATIM           = (BIT(7) | BIT(4) | WIFI_MGT_TYPE),
  51         WIFI_DISASSOC       = (BIT(7) | BIT(5) | WIFI_MGT_TYPE),
  52         WIFI_AUTH           = (BIT(7) | BIT(5) | BIT(4) | WIFI_MGT_TYPE),
  53         WIFI_DEAUTH         = (BIT(7) | BIT(6) | WIFI_MGT_TYPE),
  54         WIFI_ACTION         = (BIT(7) | BIT(6) | BIT(4) | WIFI_MGT_TYPE),
  55 
  56         /*  below is for control frame */
  57         WIFI_PSPOLL         = (BIT(7) | BIT(5) | WIFI_CTRL_TYPE),
  58         WIFI_RTS            = (BIT(7) | BIT(5) | BIT(4) | WIFI_CTRL_TYPE),
  59         WIFI_CTS            = (BIT(7) | BIT(6) | WIFI_CTRL_TYPE),
  60         WIFI_ACK            = (BIT(7) | BIT(6) | BIT(4) | WIFI_CTRL_TYPE),
  61         WIFI_CFEND          = (BIT(7) | BIT(6) | BIT(5) | WIFI_CTRL_TYPE),
  62         WIFI_CFEND_CFACK    = (BIT(7) | BIT(6) | BIT(5) | BIT(4) |
  63         WIFI_CTRL_TYPE),
  64 
  65         /*  below is for data frame */
  66         WIFI_DATA           = (0 | WIFI_DATA_TYPE),
  67         WIFI_DATA_CFACK     = (BIT(4) | WIFI_DATA_TYPE),
  68         WIFI_DATA_CFPOLL    = (BIT(5) | WIFI_DATA_TYPE),
  69         WIFI_DATA_CFACKPOLL = (BIT(5) | BIT(4) | WIFI_DATA_TYPE),
  70         WIFI_DATA_NULL      = (BIT(6) | WIFI_DATA_TYPE),
  71         WIFI_CF_ACK         = (BIT(6) | BIT(4) | WIFI_DATA_TYPE),
  72         WIFI_CF_POLL        = (BIT(6) | BIT(5) | WIFI_DATA_TYPE),
  73         WIFI_CF_ACKPOLL     = (BIT(6) | BIT(5) | BIT(4) | WIFI_DATA_TYPE),
  74         WIFI_QOS_DATA_NULL      = (BIT(6) | WIFI_QOS_DATA_TYPE),
  75 };
  76 
  77 enum WIFI_REASON_CODE   {
  78         _RSON_RESERVED_                 = 0,
  79         _RSON_UNSPECIFIED_              = 1,
  80         _RSON_AUTH_NO_LONGER_VALID_     = 2,
  81         _RSON_DEAUTH_STA_LEAVING_       = 3,
  82         _RSON_INACTIVITY_               = 4,
  83         _RSON_UNABLE_HANDLE_            = 5,
  84         _RSON_CLS2_                     = 6,
  85         _RSON_CLS3_                     = 7,
  86         _RSON_DISAOC_STA_LEAVING_       = 8,
  87         _RSON_ASOC_NOT_AUTH_            = 9,
  88 
  89         /*  WPA reason */
  90         _RSON_INVALID_IE_               = 13,
  91         _RSON_MIC_FAILURE_              = 14,
  92         _RSON_4WAY_HNDSHK_TIMEOUT_      = 15,
  93         _RSON_GROUP_KEY_UPDATE_TIMEOUT_ = 16,
  94         _RSON_DIFF_IE_                  = 17,
  95         _RSON_MLTCST_CIPHER_NOT_VALID_  = 18,
  96         _RSON_UNICST_CIPHER_NOT_VALID_  = 19,
  97         _RSON_AKMP_NOT_VALID_           = 20,
  98         _RSON_UNSUPPORT_RSNE_VER_       = 21,
  99         _RSON_INVALID_RSNE_CAP_         = 22,
 100         _RSON_IEEE_802DOT1X_AUTH_FAIL_  = 23,
 101 
 102         /* belowing are Realtek definition */
 103         _RSON_PMK_NOT_AVAILABLE_        = 24,
 104         _RSON_TDLS_TEAR_TOOFAR_         = 25,
 105         _RSON_TDLS_TEAR_UN_RSN_         = 26,
 106 };
 107 
 108 enum WIFI_STATUS_CODE {
 109         _STATS_SUCCESSFUL_              = 0,
 110         _STATS_FAILURE_                 = 1,
 111         _STATS_CAP_FAIL_                = 10,
 112         _STATS_NO_ASOC_                 = 11,
 113         _STATS_OTHER_                   = 12,
 114         _STATS_NO_SUPP_ALG_             = 13,
 115         _STATS_OUT_OF_AUTH_SEQ_         = 14,
 116         _STATS_CHALLENGE_FAIL_          = 15,
 117         _STATS_AUTH_TIMEOUT_            = 16,
 118         _STATS_UNABLE_HANDLE_STA_       = 17,
 119         _STATS_RATE_FAIL_               = 18,
 120 };
 121 
 122 enum WIFI_REG_DOMAIN {
 123         DOMAIN_FCC      = 1,
 124         DOMAIN_IC       = 2,
 125         DOMAIN_ETSI     = 3,
 126         DOMAIN_SPA      = 4,
 127         DOMAIN_FRANCE   = 5,
 128         DOMAIN_MKK      = 6,
 129         DOMAIN_ISRAEL   = 7,
 130         DOMAIN_MKK1     = 8,
 131         DOMAIN_MKK2     = 9,
 132         DOMAIN_MKK3     = 10,
 133         DOMAIN_MAX
 134 };
 135 
 136 #define _TO_DS_         BIT(8)
 137 #define _FROM_DS_       BIT(9)
 138 #define _MORE_FRAG_     BIT(10)
 139 #define _RETRY_         BIT(11)
 140 #define _PWRMGT_        BIT(12)
 141 #define _MORE_DATA_     BIT(13)
 142 #define _PRIVACY_       BIT(14)
 143 #define _ORDER_         BIT(15)
 144 
 145 #define SetToDs(pbuf)   \
 146         *(__le16 *)(pbuf) |= cpu_to_le16(_TO_DS_)
 147 
 148 #define GetToDs(pbuf)   (((*(__le16 *)(pbuf)) & cpu_to_le16(_TO_DS_)) != 0)
 149 
 150 #define ClearToDs(pbuf) \
 151         *(__le16 *)(pbuf) &= (~cpu_to_le16(_TO_DS_))
 152 
 153 #define SetFrDs(pbuf)   \
 154         *(__le16 *)(pbuf) |= cpu_to_le16(_FROM_DS_)
 155 
 156 #define GetFrDs(pbuf)   (((*(__le16 *)(pbuf)) & cpu_to_le16(_FROM_DS_)) != 0)
 157 
 158 #define ClearFrDs(pbuf) \
 159         *(__le16 *)(pbuf) &= (~cpu_to_le16(_FROM_DS_))
 160 
 161 #define get_tofr_ds(pframe)     ((GetToDs(pframe) << 1) | GetFrDs(pframe))
 162 
 163 
 164 #define SetMFrag(pbuf)  \
 165         *(__le16 *)(pbuf) |= cpu_to_le16(_MORE_FRAG_)
 166 
 167 #define GetMFrag(pbuf)  (((*(__le16 *)(pbuf)) & cpu_to_le16(_MORE_FRAG_)) != 0)
 168 
 169 #define ClearMFrag(pbuf)        \
 170         *(__le16 *)(pbuf) &= (~cpu_to_le16(_MORE_FRAG_))
 171 
 172 #define SetRetry(pbuf)  \
 173         *(__le16 *)(pbuf) |= cpu_to_le16(_RETRY_)
 174 
 175 #define GetRetry(pbuf)  (((*(__le16 *)(pbuf)) & cpu_to_le16(_RETRY_)) != 0)
 176 
 177 #define ClearRetry(pbuf)        \
 178         *(__le16 *)(pbuf) &= (~cpu_to_le16(_RETRY_))
 179 
 180 #define SetPwrMgt(pbuf) \
 181         *(__le16 *)(pbuf) |= cpu_to_le16(_PWRMGT_)
 182 
 183 #define GetPwrMgt(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_PWRMGT_)) != 0)
 184 
 185 #define ClearPwrMgt(pbuf)       \
 186         *(__le16 *)(pbuf) &= (~cpu_to_le16(_PWRMGT_))
 187 
 188 #define SetMData(pbuf)  \
 189         *(__le16 *)(pbuf) |= cpu_to_le16(_MORE_DATA_)
 190 
 191 #define GetMData(pbuf)  (((*(__le16 *)(pbuf)) & cpu_to_le16(_MORE_DATA_)) != 0)
 192 
 193 #define ClearMData(pbuf)        \
 194         *(__le16 *)(pbuf) &= (~cpu_to_le16(_MORE_DATA_))
 195 
 196 #define SetPrivacy(pbuf)        \
 197         *(__le16 *)(pbuf) |= cpu_to_le16(_PRIVACY_)
 198 
 199 #define GetPrivacy(pbuf)                                        \
 200         (((*(__le16 *)(pbuf)) & cpu_to_le16(_PRIVACY_)) != 0)
 201 
 202 #define GetOrder(pbuf)                                  \
 203         (((*(__le16 *)(pbuf)) & cpu_to_le16(_ORDER_)) != 0)
 204 
 205 #define GetFrameType(pbuf)                              \
 206         (le16_to_cpu(*(__le16 *)(pbuf)) & (BIT(3) | BIT(2)))
 207 
 208 #define GetFrameSubType(pbuf)   (le16_to_cpu(*(__le16 *)(pbuf)) & (BIT(7) |\
 209          BIT(6) | BIT(5) | BIT(4) | BIT(3) | BIT(2)))
 210 
 211 #define SetFrameSubType(pbuf, type) \
 212         do {    \
 213                 *(__le16 *)(pbuf) &= cpu_to_le16(~(BIT(7) | BIT(6) |    \
 214                  BIT(5) | BIT(4) | BIT(3) | BIT(2))); \
 215                 *(__le16 *)(pbuf) |= cpu_to_le16(type); \
 216         } while (0)
 217 
 218 #define GetSequence(pbuf)                       \
 219         (le16_to_cpu(*(__le16 *)((size_t)(pbuf) + 22)) >> 4)
 220 
 221 #define GetFragNum(pbuf)                        \
 222         (le16_to_cpu(*(__le16 *)((size_t)(pbuf) + 22)) & 0x0f)
 223 
 224 #define SetSeqNum(pbuf, num) \
 225         do {    \
 226                 *(__le16 *)((size_t)(pbuf) + 22) = \
 227                         ((*(__le16 *)((size_t)(pbuf) + 22)) & cpu_to_le16((unsigned short)0x000f)) | \
 228                         cpu_to_le16((unsigned short)(0xfff0 & (num << 4))); \
 229         } while (0)
 230 
 231 #define SetDuration(pbuf, dur) \
 232         *(__le16 *)((size_t)(pbuf) + 2) = cpu_to_le16(0xffff & (dur))
 233 
 234 
 235 #define SetPriority(pbuf, tid)  \
 236         *(__le16 *)(pbuf) |= cpu_to_le16(tid & 0xf)
 237 
 238 #define GetPriority(pbuf)       ((le16_to_cpu(*(__le16 *)(pbuf))) & 0xf)
 239 
 240 #define SetEOSP(pbuf, eosp)     \
 241                 *(__le16 *)(pbuf) |= cpu_to_le16((eosp & 1) << 4)
 242 
 243 #define SetAckpolicy(pbuf, ack) \
 244         *(__le16 *)(pbuf) |= cpu_to_le16((ack & 3) << 5)
 245 
 246 #define GetAckpolicy(pbuf) (((le16_to_cpu(*(__le16 *)pbuf)) >> 5) & 0x3)
 247 
 248 #define GetAMsdu(pbuf) (((le16_to_cpu(*(__le16 *)pbuf)) >> 7) & 0x1)
 249 
 250 #define GetAid(pbuf)    (le16_to_cpu(*(__le16 *)((size_t)(pbuf) + 2)) & 0x3fff)
 251 
 252 #define GetAddr1Ptr(pbuf)       ((unsigned char *)((size_t)(pbuf) + 4))
 253 
 254 #define GetAddr2Ptr(pbuf)       ((unsigned char *)((size_t)(pbuf) + 10))
 255 
 256 #define GetAddr3Ptr(pbuf)       ((unsigned char *)((size_t)(pbuf) + 16))
 257 
 258 #define GetAddr4Ptr(pbuf)       ((unsigned char *)((size_t)(pbuf) + 24))
 259 
 260 static inline unsigned char *get_da(unsigned char *pframe)
 261 {
 262         unsigned char   *da;
 263         unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe);
 264 
 265         switch (to_fr_ds) {
 266         case 0x00:      /*  ToDs=0, FromDs=0 */
 267                 da = GetAddr1Ptr(pframe);
 268                 break;
 269         case 0x01:      /*  ToDs=0, FromDs=1 */
 270                 da = GetAddr1Ptr(pframe);
 271                 break;
 272         case 0x02:      /*  ToDs=1, FromDs=0 */
 273                 da = GetAddr3Ptr(pframe);
 274                 break;
 275         default:        /*  ToDs=1, FromDs=1 */
 276                 da = GetAddr3Ptr(pframe);
 277                 break;
 278         }
 279         return da;
 280 }
 281 
 282 static inline unsigned char *get_sa(unsigned char *pframe)
 283 {
 284         unsigned char   *sa;
 285         unsigned int    to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe);
 286 
 287         switch (to_fr_ds) {
 288         case 0x00:      /*  ToDs=0, FromDs=0 */
 289                 sa = GetAddr2Ptr(pframe);
 290                 break;
 291         case 0x01:      /*  ToDs=0, FromDs=1 */
 292                 sa = GetAddr3Ptr(pframe);
 293                 break;
 294         case 0x02:      /*  ToDs=1, FromDs=0 */
 295                 sa = GetAddr2Ptr(pframe);
 296                 break;
 297         default:        /*  ToDs=1, FromDs=1 */
 298                 sa = GetAddr4Ptr(pframe);
 299                 break;
 300         }
 301         return sa;
 302 }
 303 
 304 static inline unsigned char *get_hdr_bssid(unsigned char *pframe)
 305 {
 306         unsigned char   *sa;
 307         unsigned int    to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe);
 308 
 309         switch (to_fr_ds) {
 310         case 0x00:      /*  ToDs=0, FromDs=0 */
 311                 sa = GetAddr3Ptr(pframe);
 312                 break;
 313         case 0x01:      /*  ToDs=0, FromDs=1 */
 314                 sa = GetAddr2Ptr(pframe);
 315                 break;
 316         case 0x02:      /*  ToDs=1, FromDs=0 */
 317                 sa = GetAddr1Ptr(pframe);
 318                 break;
 319         case 0x03:      /*  ToDs=1, FromDs=1 */
 320                 sa = GetAddr1Ptr(pframe);
 321                 break;
 322         default:
 323                 sa = NULL; /*  */
 324                 break;
 325         }
 326         return sa;
 327 }
 328 
 329 static inline int IsFrameTypeCtrl(unsigned char *pframe)
 330 {
 331         if (WIFI_CTRL_TYPE == GetFrameType(pframe))
 332                 return true;
 333         else
 334                 return false;
 335 }
 336 /*-----------------------------------------------------------------------------
 337                         Below is for the security related definition
 338 ------------------------------------------------------------------------------*/
 339 #define _RESERVED_FRAME_TYPE_           0
 340 #define _SKB_FRAME_TYPE_                2
 341 #define _PRE_ALLOCMEM_                  1
 342 #define _PRE_ALLOCHDR_                  3
 343 #define _PRE_ALLOCLLCHDR_               4
 344 #define _PRE_ALLOCICVHDR_               5
 345 #define _PRE_ALLOCMICHDR_               6
 346 
 347 #define _SIFSTIME_                              \
 348         ((priv->pmib->dot11BssType.net_work_type & WIRELESS_11A) ? 16 : 10)
 349 #define _ACKCTSLNG_             14      /* 14 bytes long, including crclng */
 350 #define _CRCLNG_                4
 351 
 352 #define _ASOCREQ_IE_OFFSET_     4       /*  excluding wlan_hdr */
 353 #define _ASOCRSP_IE_OFFSET_     6
 354 #define _REASOCREQ_IE_OFFSET_   10
 355 #define _REASOCRSP_IE_OFFSET_   6
 356 #define _PROBEREQ_IE_OFFSET_    0
 357 #define _PROBERSP_IE_OFFSET_    12
 358 #define _AUTH_IE_OFFSET_        6
 359 #define _DEAUTH_IE_OFFSET_      0
 360 #define _BEACON_IE_OFFSET_      12
 361 #define _PUBLIC_ACTION_IE_OFFSET_       8
 362 
 363 #define _FIXED_IE_LENGTH_       _BEACON_IE_OFFSET_
 364 
 365 #define _SSID_IE_               0
 366 #define _SUPPORTEDRATES_IE_     1
 367 #define _DSSET_IE_              3
 368 #define _TIM_IE_                5
 369 #define _IBSS_PARA_IE_          6
 370 #define _COUNTRY_IE_            7
 371 #define _CHLGETXT_IE_           16
 372 #define _SUPPORTED_CH_IE_       36
 373 #define _CH_SWTICH_ANNOUNCE_    37      /* Secondary Channel Offset */
 374 #define _RSN_IE_2_              48
 375 #define _SSN_IE_1_              221
 376 #define _ERPINFO_IE_            42
 377 #define _EXT_SUPPORTEDRATES_IE_ 50
 378 
 379 #define _HT_CAPABILITY_IE_      45
 380 #define _FTIE_                  55
 381 #define _TIMEOUT_ITVL_IE_       56
 382 #define _SRC_IE_                59
 383 #define _HT_EXTRA_INFO_IE_      61
 384 #define _HT_ADD_INFO_IE_        61 /* _HT_EXTRA_INFO_IE_ */
 385 #define _WAPI_IE_               68
 386 
 387 
 388 #define EID_BSSCoexistence      72 /*  20/40 BSS Coexistence */
 389 #define EID_BSSIntolerantChlReport      73
 390 #define _RIC_Descriptor_IE_     75
 391 
 392 #define _LINK_ID_IE_            101
 393 #define _CH_SWITCH_TIMING_      104
 394 #define _PTI_BUFFER_STATUS_     106
 395 #define _EXT_CAP_IE_            127
 396 #define _VENDOR_SPECIFIC_IE_    221
 397 
 398 #define _RESERVED47_            47
 399 
 400 /* ---------------------------------------------------------------------------
 401                                         Below is the fixed elements...
 402 -----------------------------------------------------------------------------*/
 403 #define _AUTH_ALGM_NUM_         2
 404 #define _AUTH_SEQ_NUM_          2
 405 #define _BEACON_ITERVAL_        2
 406 #define _CAPABILITY_            2
 407 #define _CURRENT_APADDR_        6
 408 #define _LISTEN_INTERVAL_       2
 409 #define _RSON_CODE_             2
 410 #define _ASOC_ID_               2
 411 #define _STATUS_CODE_           2
 412 #define _TIMESTAMP_             8
 413 
 414 #define AUTH_ODD_TO             0
 415 #define AUTH_EVEN_TO            1
 416 
 417 #define WLAN_ETHCONV_ENCAP      1
 418 #define WLAN_ETHCONV_RFC1042    2
 419 #define WLAN_ETHCONV_8021h      3
 420 
 421 #define cap_ESS         BIT(0)
 422 #define cap_IBSS        BIT(1)
 423 #define cap_CFPollable  BIT(2)
 424 #define cap_CFRequest   BIT(3)
 425 #define cap_Privacy     BIT(4)
 426 #define cap_ShortPremble BIT(5)
 427 #define cap_PBCC        BIT(6)
 428 #define cap_ChAgility   BIT(7)
 429 #define cap_SpecMgmt    BIT(8)
 430 #define cap_QoSi        BIT(9)
 431 #define cap_ShortSlot   BIT(10)
 432 
 433 /*-----------------------------------------------------------------------------
 434                                 Below is the definition for 802.11i / 802.1x
 435 ------------------------------------------------------------------------------*/
 436 #define _IEEE8021X_MGT_                 1       /*  WPA */
 437 #define _IEEE8021X_PSK_                 2       /*  WPA with pre-shared key */
 438 
 439 /*
 440  * #define _NO_PRIVACY_                 0
 441  * #define _WEP_40_PRIVACY_             1
 442  * #define _TKIP_PRIVACY_               2
 443  * #define _WRAP_PRIVACY_               3
 444  * #define _CCMP_PRIVACY_               4
 445  * #define _WEP_104_PRIVACY_            5
 446  * #define _WEP_WPA_MIXED_PRIVACY_ 6    WEP + WPA
 447  */
 448 
 449 /*-----------------------------------------------------------------------------
 450                                 Below is the definition for WMM
 451 ------------------------------------------------------------------------------*/
 452 #define _WMM_IE_Length_                         7  /*  for WMM STA */
 453 #define _WMM_Para_Element_Length_               24
 454 
 455 
 456 /*-----------------------------------------------------------------------------
 457                                 Below is the definition for 802.11n
 458 ------------------------------------------------------------------------------*/
 459 
 460 /* 802.11 BAR control masks */
 461 #define IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL     0x0000
 462 #define IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA  0x0004
 463 
 464 /**
 465  * struct rtw_ieee80211_ht_cap - HT additional information
 466  *
 467  * This structure refers to "HT information element" as
 468  * described in 802.11n draft section 7.3.2.53
 469  */
 470 struct ieee80211_ht_addt_info {
 471         unsigned char   control_chan;
 472         unsigned char   ht_param;
 473         unsigned short  operation_mode;
 474         unsigned short  stbc_param;
 475         unsigned char   basic_set[16];
 476 } __packed;
 477 
 478 struct HT_info_element {
 479         unsigned char   primary_channel;
 480         unsigned char   infos[5];
 481         unsigned char   MCS_rate[16];
 482 } __packed;
 483 
 484 struct AC_param {
 485         unsigned char           ACI_AIFSN;
 486         unsigned char           CW;
 487         __le16  TXOP_limit;
 488 } __packed;
 489 
 490 struct WMM_para_element {
 491         unsigned char           QoS_info;
 492         unsigned char           reserved;
 493         struct AC_param ac_param[4];
 494 } __packed;
 495 
 496 struct ADDBA_request {
 497         unsigned char   dialog_token;
 498         __le16          BA_para_set;
 499         unsigned short  BA_timeout_value;
 500         unsigned short  BA_starting_seqctrl;
 501 } __packed;
 502 
 503 enum ht_cap_ampdu_factor {
 504         MAX_AMPDU_FACTOR_8K     = 0,
 505         MAX_AMPDU_FACTOR_16K    = 1,
 506         MAX_AMPDU_FACTOR_32K    = 2,
 507         MAX_AMPDU_FACTOR_64K    = 3,
 508 };
 509 
 510 /* 802.11n HT capabilities masks */
 511 #define IEEE80211_HT_CAP_SUP_WIDTH              0x0002
 512 #define IEEE80211_HT_CAP_SM_PS                  0x000C
 513 #define IEEE80211_HT_CAP_GRN_FLD                0x0010
 514 #define IEEE80211_HT_CAP_SGI_20                 0x0020
 515 #define IEEE80211_HT_CAP_SGI_40                 0x0040
 516 #define IEEE80211_HT_CAP_TX_STBC                0x0080
 517 #define IEEE80211_HT_CAP_RX_STBC                0x0300
 518 #define IEEE80211_HT_CAP_DELAY_BA               0x0400
 519 #define IEEE80211_HT_CAP_MAX_AMSDU              0x0800
 520 #define IEEE80211_HT_CAP_DSSSCCK40              0x1000
 521 /* 802.11n HT capability AMPDU settings */
 522 #define IEEE80211_HT_CAP_AMPDU_FACTOR           0x03
 523 #define IEEE80211_HT_CAP_AMPDU_DENSITY          0x1C
 524 /* 802.11n HT capability MSC set */
 525 #define IEEE80211_SUPP_MCS_SET_UEQM             4
 526 #define IEEE80211_HT_CAP_MAX_STREAMS            4
 527 #define IEEE80211_SUPP_MCS_SET_LEN              10
 528 /* maximum streams the spec allows */
 529 #define IEEE80211_HT_CAP_MCS_TX_DEFINED         0x01
 530 #define IEEE80211_HT_CAP_MCS_TX_RX_DIFF         0x02
 531 #define IEEE80211_HT_CAP_MCS_TX_STREAMS         0x0C
 532 #define IEEE80211_HT_CAP_MCS_TX_UEQM            0x10
 533 /* 802.11n HT IE masks */
 534 #define IEEE80211_HT_IE_CHA_SEC_OFFSET          0x03
 535 #define IEEE80211_HT_IE_CHA_SEC_NONE            0x00
 536 #define IEEE80211_HT_IE_CHA_SEC_ABOVE           0x01
 537 #define IEEE80211_HT_IE_CHA_SEC_BELOW           0x03
 538 #define IEEE80211_HT_IE_CHA_WIDTH               0x04
 539 #define IEEE80211_HT_IE_HT_PROTECTION           0x0003
 540 #define IEEE80211_HT_IE_NON_GF_STA_PRSNT        0x0004
 541 #define IEEE80211_HT_IE_NON_HT_STA_PRSNT        0x0010
 542 
 543 /* block-ack parameters */
 544 #define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002
 545 #define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C
 546 #define RTW_IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFC0
 547 #define IEEE80211_DELBA_PARAM_TID_MASK 0xF000
 548 #define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800
 549 
 550 /*
 551  * A-PMDU buffer sizes
 552  * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2)
 553  */
 554 #define IEEE80211_MIN_AMPDU_BUF 0x8
 555 
 556 
 557 #define OP_MODE_PURE                    0
 558 #define OP_MODE_MAY_BE_LEGACY_STAS      1
 559 #define OP_MODE_20MHZ_HT_STA_ASSOCED    2
 560 #define OP_MODE_MIXED                   3
 561 
 562 #define HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK        ((u8)BIT(0) | BIT(1))
 563 #define HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE           ((u8)BIT(0))
 564 #define HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW           ((u8)BIT(0) | BIT(1))
 565 #define HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH           ((u8)BIT(2))
 566 #define HT_INFO_HT_PARAM_RIFS_MODE                      ((u8)BIT(3))
 567 #define HT_INFO_HT_PARAM_CTRL_ACCESS_ONLY               ((u8)BIT(4))
 568 #define HT_INFO_HT_PARAM_SRV_INTERVAL_GRANULARITY       ((u8)BIT(5))
 569 
 570 #define HT_INFO_OPERATION_MODE_OP_MODE_MASK     \
 571                 ((u16)(0x0001 | 0x0002))
 572 #define HT_INFO_OPERATION_MODE_OP_MODE_OFFSET           0
 573 #define HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT      ((u8)BIT(2))
 574 #define HT_INFO_OPERATION_MODE_TRANSMIT_BURST_LIMIT     ((u8)BIT(3))
 575 #define HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT       ((u8)BIT(4))
 576 
 577 #define HT_INFO_STBC_PARAM_DUAL_BEACON          ((u16)BIT(6))
 578 #define HT_INFO_STBC_PARAM_DUAL_STBC_PROTECT    ((u16)BIT(7))
 579 #define HT_INFO_STBC_PARAM_SECONDARY_BC         ((u16)BIT(8))
 580 #define HT_INFO_STBC_PARAM_LSIG_TXOP_PROTECT_ALLOWED    ((u16)BIT(9))
 581 #define HT_INFO_STBC_PARAM_PCO_ACTIVE           ((u16)BIT(10))
 582 #define HT_INFO_STBC_PARAM_PCO_PHASE            ((u16)BIT(11))
 583 
 584 /*      ===============WPS Section=============== */
 585 /*      For WPSv1.0 */
 586 #define WPSOUI                                  0x0050f204
 587 /*      WPS attribute ID */
 588 #define WPS_ATTR_VER1                           0x104A
 589 #define WPS_ATTR_SIMPLE_CONF_STATE              0x1044
 590 #define WPS_ATTR_RESP_TYPE                      0x103B
 591 #define WPS_ATTR_UUID_E                         0x1047
 592 #define WPS_ATTR_MANUFACTURER                   0x1021
 593 #define WPS_ATTR_MODEL_NAME                     0x1023
 594 #define WPS_ATTR_MODEL_NUMBER                   0x1024
 595 #define WPS_ATTR_SERIAL_NUMBER                  0x1042
 596 #define WPS_ATTR_PRIMARY_DEV_TYPE               0x1054
 597 #define WPS_ATTR_SEC_DEV_TYPE_LIST              0x1055
 598 #define WPS_ATTR_DEVICE_NAME                    0x1011
 599 #define WPS_ATTR_CONF_METHOD                    0x1008
 600 #define WPS_ATTR_RF_BANDS                       0x103C
 601 #define WPS_ATTR_DEVICE_PWID                    0x1012
 602 #define WPS_ATTR_REQUEST_TYPE                   0x103A
 603 #define WPS_ATTR_ASSOCIATION_STATE              0x1002
 604 #define WPS_ATTR_CONFIG_ERROR                   0x1009
 605 #define WPS_ATTR_VENDOR_EXT                     0x1049
 606 #define WPS_ATTR_SELECTED_REGISTRAR             0x1041
 607 
 608 /*      Value of WPS Request Type Attribute */
 609 #define WPS_REQ_TYPE_ENROLLEE_INFO_ONLY         0x00
 610 #define WPS_REQ_TYPE_ENROLLEE_OPEN_8021X        0x01
 611 #define WPS_REQ_TYPE_REGISTRAR                  0x02
 612 #define WPS_REQ_TYPE_WLAN_MANAGER_REGISTRAR     0x03
 613 
 614 /*      Value of WPS Response Type Attribute */
 615 #define WPS_RESPONSE_TYPE_INFO_ONLY     0x00
 616 #define WPS_RESPONSE_TYPE_8021X         0x01
 617 #define WPS_RESPONSE_TYPE_REGISTRAR     0x02
 618 #define WPS_RESPONSE_TYPE_AP            0x03
 619 
 620 /*      Value of WPS WiFi Simple Configuration State Attribute */
 621 #define WPS_WSC_STATE_NOT_CONFIG        0x01
 622 #define WPS_WSC_STATE_CONFIG            0x02
 623 
 624 /*      Value of WPS Version Attribute */
 625 #define WPS_VERSION_1                   0x10
 626 
 627 /*      Value of WPS Configuration Method Attribute */
 628 #define WPS_CONFIG_METHOD_FLASH         0x0001
 629 #define WPS_CONFIG_METHOD_ETHERNET      0x0002
 630 #define WPS_CONFIG_METHOD_LABEL         0x0004
 631 #define WPS_CONFIG_METHOD_DISPLAY       0x0008
 632 #define WPS_CONFIG_METHOD_E_NFC         0x0010
 633 #define WPS_CONFIG_METHOD_I_NFC         0x0020
 634 #define WPS_CONFIG_METHOD_NFC           0x0040
 635 #define WPS_CONFIG_METHOD_PBC           0x0080
 636 #define WPS_CONFIG_METHOD_KEYPAD        0x0100
 637 #define WPS_CONFIG_METHOD_VPBC          0x0280
 638 #define WPS_CONFIG_METHOD_PPBC          0x0480
 639 #define WPS_CONFIG_METHOD_VDISPLAY      0x2008
 640 #define WPS_CONFIG_METHOD_PDISPLAY      0x4008
 641 
 642 /*      Value of Category ID of WPS Primary Device Type Attribute */
 643 #define WPS_PDT_CID_DISPLAYS            0x0007
 644 #define WPS_PDT_CID_MULIT_MEDIA         0x0008
 645 #define WPS_PDT_CID_RTK_WIDI            WPS_PDT_CID_MULIT_MEDIA
 646 
 647 /*      Value of Sub Category ID of WPS Primary Device Type Attribute */
 648 #define WPS_PDT_SCID_MEDIA_SERVER       0x0005
 649 #define WPS_PDT_SCID_RTK_DMP            WPS_PDT_SCID_MEDIA_SERVER
 650 
 651 /*      Value of Device Password ID */
 652 #define WPS_DPID_P                      0x0000
 653 #define WPS_DPID_USER_SPEC              0x0001
 654 #define WPS_DPID_MACHINE_SPEC           0x0002
 655 #define WPS_DPID_REKEY                  0x0003
 656 #define WPS_DPID_PBC                    0x0004
 657 #define WPS_DPID_REGISTRAR_SPEC         0x0005
 658 
 659 /*      Value of WPS RF Bands Attribute */
 660 #define WPS_RF_BANDS_2_4_GHZ            0x01
 661 #define WPS_RF_BANDS_5_GHZ              0x02
 662 
 663 /*      Value of WPS Association State Attribute */
 664 #define WPS_ASSOC_STATE_NOT_ASSOCIATED          0x00
 665 #define WPS_ASSOC_STATE_CONNECTION_SUCCESS      0x01
 666 #define WPS_ASSOC_STATE_CONFIGURATION_FAILURE   0x02
 667 #define WPS_ASSOC_STATE_ASSOCIATION_FAILURE     0x03
 668 #define WPS_ASSOC_STATE_IP_FAILURE              0x04
 669 
 670 /*      WPS Configuration Method */
 671 #define WPS_CM_NONE                     0x0000
 672 #define WPS_CM_LABEL                    0x0004
 673 #define WPS_CM_DISPLYA                  0x0008
 674 #define WPS_CM_EXTERNAL_NFC_TOKEN       0x0010
 675 #define WPS_CM_INTEGRATED_NFC_TOKEN     0x0020
 676 #define WPS_CM_NFC_INTERFACE            0x0040
 677 #define WPS_CM_PUSH_BUTTON              0x0080
 678 #define WPS_CM_KEYPAD                   0x0100
 679 #define WPS_CM_SW_PUHS_BUTTON           0x0280
 680 #define WPS_CM_HW_PUHS_BUTTON           0x0480
 681 #define WPS_CM_SW_DISPLAY_P             0x2008
 682 #define WPS_CM_LCD_DISPLAY_P            0x4008
 683 
 684 #define IP_MCAST_MAC(mac)                               \
 685         ((mac[0] == 0x01) && (mac[1] == 0x00) && (mac[2] == 0x5e))
 686 #define ICMPV6_MCAST_MAC(mac)                           \
 687         ((mac[0] == 0x33) && (mac[1] == 0x33) && (mac[2] != 0xff))
 688 
 689 #endif /*  _WIFI_H_ */

/* [<][>][^][v][top][bottom][index][help] */