Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * WSM host interface (HI) interface for ST-Ericsson CW1200 mac80211 drivers
0004  *
0005  * Copyright (c) 2010, ST-Ericsson
0006  * Author: Dmitry Tarnyagin <dmitry.tarnyagin@lockless.no>
0007  *
0008  * Based on CW1200 UMAC WSM API, which is
0009  * Copyright (C) ST-Ericsson SA 2010
0010  * Author: Stewart Mathers <stewart.mathers@stericsson.com>
0011  */
0012 
0013 #ifndef CW1200_WSM_H_INCLUDED
0014 #define CW1200_WSM_H_INCLUDED
0015 
0016 #include <linux/spinlock.h>
0017 
0018 struct cw1200_common;
0019 
0020 /* Bands */
0021 /* Radio band 2.412 -2.484 GHz. */
0022 #define WSM_PHY_BAND_2_4G       (0)
0023 
0024 /* Radio band 4.9375-5.8250 GHz. */
0025 #define WSM_PHY_BAND_5G         (1)
0026 
0027 /* Transmit rates */
0028 /* 1   Mbps            ERP-DSSS */
0029 #define WSM_TRANSMIT_RATE_1     (0)
0030 
0031 /* 2   Mbps            ERP-DSSS */
0032 #define WSM_TRANSMIT_RATE_2     (1)
0033 
0034 /* 5.5 Mbps            ERP-CCK */
0035 #define WSM_TRANSMIT_RATE_5     (2)
0036 
0037 /* 11  Mbps            ERP-CCK */
0038 #define WSM_TRANSMIT_RATE_11        (3)
0039 
0040 /* 22  Mbps            ERP-PBCC (Not supported) */
0041 /* #define WSM_TRANSMIT_RATE_22     (4) */
0042 
0043 /* 33  Mbps            ERP-PBCC (Not supported) */
0044 /* #define WSM_TRANSMIT_RATE_33     (5) */
0045 
0046 /* 6   Mbps   (3 Mbps) ERP-OFDM, BPSK coding rate 1/2 */
0047 #define WSM_TRANSMIT_RATE_6     (6)
0048 
0049 /* 9   Mbps (4.5 Mbps) ERP-OFDM, BPSK coding rate 3/4 */
0050 #define WSM_TRANSMIT_RATE_9     (7)
0051 
0052 /* 12  Mbps  (6 Mbps)  ERP-OFDM, QPSK coding rate 1/2 */
0053 #define WSM_TRANSMIT_RATE_12        (8)
0054 
0055 /* 18  Mbps  (9 Mbps)  ERP-OFDM, QPSK coding rate 3/4 */
0056 #define WSM_TRANSMIT_RATE_18        (9)
0057 
0058 /* 24  Mbps (12 Mbps)  ERP-OFDM, 16QAM coding rate 1/2 */
0059 #define WSM_TRANSMIT_RATE_24        (10)
0060 
0061 /* 36  Mbps (18 Mbps)  ERP-OFDM, 16QAM coding rate 3/4 */
0062 #define WSM_TRANSMIT_RATE_36        (11)
0063 
0064 /* 48  Mbps (24 Mbps)  ERP-OFDM, 64QAM coding rate 1/2 */
0065 #define WSM_TRANSMIT_RATE_48        (12)
0066 
0067 /* 54  Mbps (27 Mbps)  ERP-OFDM, 64QAM coding rate 3/4 */
0068 #define WSM_TRANSMIT_RATE_54        (13)
0069 
0070 /* 6.5 Mbps            HT-OFDM, BPSK coding rate 1/2 */
0071 #define WSM_TRANSMIT_RATE_HT_6      (14)
0072 
0073 /* 13  Mbps            HT-OFDM, QPSK coding rate 1/2 */
0074 #define WSM_TRANSMIT_RATE_HT_13     (15)
0075 
0076 /* 19.5 Mbps           HT-OFDM, QPSK coding rate 3/4 */
0077 #define WSM_TRANSMIT_RATE_HT_19     (16)
0078 
0079 /* 26  Mbps            HT-OFDM, 16QAM coding rate 1/2 */
0080 #define WSM_TRANSMIT_RATE_HT_26     (17)
0081 
0082 /* 39  Mbps            HT-OFDM, 16QAM coding rate 3/4 */
0083 #define WSM_TRANSMIT_RATE_HT_39     (18)
0084 
0085 /* 52  Mbps            HT-OFDM, 64QAM coding rate 2/3 */
0086 #define WSM_TRANSMIT_RATE_HT_52     (19)
0087 
0088 /* 58.5 Mbps           HT-OFDM, 64QAM coding rate 3/4 */
0089 #define WSM_TRANSMIT_RATE_HT_58     (20)
0090 
0091 /* 65  Mbps            HT-OFDM, 64QAM coding rate 5/6 */
0092 #define WSM_TRANSMIT_RATE_HT_65     (21)
0093 
0094 /* Scan types */
0095 /* Foreground scan */
0096 #define WSM_SCAN_TYPE_FOREGROUND    (0)
0097 
0098 /* Background scan */
0099 #define WSM_SCAN_TYPE_BACKGROUND    (1)
0100 
0101 /* Auto scan */
0102 #define WSM_SCAN_TYPE_AUTO      (2)
0103 
0104 /* Scan flags */
0105 /* Forced background scan means if the station cannot */
0106 /* enter the power-save mode, it shall force to perform a */
0107 /* background scan. Only valid when ScanType is */
0108 /* background scan. */
0109 #define WSM_SCAN_FLAG_FORCE_BACKGROUND  (BIT(0))
0110 
0111 /* The WLAN device scans one channel at a time so */
0112 /* that disturbance to the data traffic is minimized. */
0113 #define WSM_SCAN_FLAG_SPLIT_METHOD  (BIT(1))
0114 
0115 /* Preamble Type. Long if not set. */
0116 #define WSM_SCAN_FLAG_SHORT_PREAMBLE    (BIT(2))
0117 
0118 /* 11n Tx Mode. Mixed if not set. */
0119 #define WSM_SCAN_FLAG_11N_GREENFIELD    (BIT(3))
0120 
0121 /* Scan constraints */
0122 /* Maximum number of channels to be scanned. */
0123 #define WSM_SCAN_MAX_NUM_OF_CHANNELS    (48)
0124 
0125 /* The maximum number of SSIDs that the device can scan for. */
0126 #define WSM_SCAN_MAX_NUM_OF_SSIDS   (2)
0127 
0128 /* Power management modes */
0129 /* 802.11 Active mode */
0130 #define WSM_PSM_ACTIVE          (0)
0131 
0132 /* 802.11 PS mode */
0133 #define WSM_PSM_PS          BIT(0)
0134 
0135 /* Fast Power Save bit */
0136 #define WSM_PSM_FAST_PS_FLAG        BIT(7)
0137 
0138 /* Dynamic aka Fast power save */
0139 #define WSM_PSM_FAST_PS         (BIT(0) | BIT(7))
0140 
0141 /* Undetermined */
0142 /* Note : Undetermined status is reported when the */
0143 /* NULL data frame used to advertise the PM mode to */
0144 /* the AP at Pre or Post Background Scan is not Acknowledged */
0145 #define WSM_PSM_UNKNOWN         BIT(1)
0146 
0147 /* Queue IDs */
0148 /* best effort/legacy */
0149 #define WSM_QUEUE_BEST_EFFORT       (0)
0150 
0151 /* background */
0152 #define WSM_QUEUE_BACKGROUND        (1)
0153 
0154 /* video */
0155 #define WSM_QUEUE_VIDEO         (2)
0156 
0157 /* voice */
0158 #define WSM_QUEUE_VOICE         (3)
0159 
0160 /* HT TX parameters */
0161 /* Non-HT */
0162 #define WSM_HT_TX_NON_HT        (0)
0163 
0164 /* Mixed format */
0165 #define WSM_HT_TX_MIXED         (1)
0166 
0167 /* Greenfield format */
0168 #define WSM_HT_TX_GREENFIELD        (2)
0169 
0170 /* STBC allowed */
0171 #define WSM_HT_TX_STBC          (BIT(7))
0172 
0173 /* EPTA prioirty flags for BT Coex */
0174 /* default epta priority */
0175 #define WSM_EPTA_PRIORITY_DEFAULT   4
0176 /* use for normal data */
0177 #define WSM_EPTA_PRIORITY_DATA      4
0178 /* use for connect/disconnect/roaming*/
0179 #define WSM_EPTA_PRIORITY_MGT       5
0180 /* use for action frames */
0181 #define WSM_EPTA_PRIORITY_ACTION    5
0182 /* use for AC_VI data */
0183 #define WSM_EPTA_PRIORITY_VIDEO     5
0184 /* use for AC_VO data */
0185 #define WSM_EPTA_PRIORITY_VOICE     6
0186 /* use for EAPOL exchange */
0187 #define WSM_EPTA_PRIORITY_EAPOL     7
0188 
0189 /* TX status */
0190 /* Frame was sent aggregated */
0191 /* Only valid for WSM_SUCCESS status. */
0192 #define WSM_TX_STATUS_AGGREGATION   (BIT(0))
0193 
0194 /* Host should requeue this frame later. */
0195 /* Valid only when status is WSM_REQUEUE. */
0196 #define WSM_TX_STATUS_REQUEUE       (BIT(1))
0197 
0198 /* Normal Ack */
0199 #define WSM_TX_STATUS_NORMAL_ACK    (0<<2)
0200 
0201 /* No Ack */
0202 #define WSM_TX_STATUS_NO_ACK        (1<<2)
0203 
0204 /* No explicit acknowledgement */
0205 #define WSM_TX_STATUS_NO_EXPLICIT_ACK   (2<<2)
0206 
0207 /* Block Ack */
0208 /* Only valid for WSM_SUCCESS status. */
0209 #define WSM_TX_STATUS_BLOCK_ACK     (3<<2)
0210 
0211 /* RX status */
0212 /* Unencrypted */
0213 #define WSM_RX_STATUS_UNENCRYPTED   (0<<0)
0214 
0215 /* WEP */
0216 #define WSM_RX_STATUS_WEP       (1<<0)
0217 
0218 /* TKIP */
0219 #define WSM_RX_STATUS_TKIP      (2<<0)
0220 
0221 /* AES */
0222 #define WSM_RX_STATUS_AES       (3<<0)
0223 
0224 /* WAPI */
0225 #define WSM_RX_STATUS_WAPI      (4<<0)
0226 
0227 /* Macro to fetch encryption subfield. */
0228 #define WSM_RX_STATUS_ENCRYPTION(status) ((status) & 0x07)
0229 
0230 /* Frame was part of an aggregation */
0231 #define WSM_RX_STATUS_AGGREGATE     (BIT(3))
0232 
0233 /* Frame was first in the aggregation */
0234 #define WSM_RX_STATUS_AGGREGATE_FIRST   (BIT(4))
0235 
0236 /* Frame was last in the aggregation */
0237 #define WSM_RX_STATUS_AGGREGATE_LAST    (BIT(5))
0238 
0239 /* Indicates a defragmented frame */
0240 #define WSM_RX_STATUS_DEFRAGMENTED  (BIT(6))
0241 
0242 /* Indicates a Beacon frame */
0243 #define WSM_RX_STATUS_BEACON        (BIT(7))
0244 
0245 /* Indicates STA bit beacon TIM field */
0246 #define WSM_RX_STATUS_TIM       (BIT(8))
0247 
0248 /* Indicates Beacon frame's virtual bitmap contains multicast bit */
0249 #define WSM_RX_STATUS_MULTICAST     (BIT(9))
0250 
0251 /* Indicates frame contains a matching SSID */
0252 #define WSM_RX_STATUS_MATCHING_SSID (BIT(10))
0253 
0254 /* Indicates frame contains a matching BSSI */
0255 #define WSM_RX_STATUS_MATCHING_BSSI (BIT(11))
0256 
0257 /* Indicates More bit set in Framectl field */
0258 #define WSM_RX_STATUS_MORE_DATA     (BIT(12))
0259 
0260 /* Indicates frame received during a measurement process */
0261 #define WSM_RX_STATUS_MEASUREMENT   (BIT(13))
0262 
0263 /* Indicates frame received as an HT packet */
0264 #define WSM_RX_STATUS_HT        (BIT(14))
0265 
0266 /* Indicates frame received with STBC */
0267 #define WSM_RX_STATUS_STBC      (BIT(15))
0268 
0269 /* Indicates Address 1 field matches dot11StationId */
0270 #define WSM_RX_STATUS_ADDRESS1      (BIT(16))
0271 
0272 /* Indicates Group address present in the Address 1 field */
0273 #define WSM_RX_STATUS_GROUP     (BIT(17))
0274 
0275 /* Indicates Broadcast address present in the Address 1 field */
0276 #define WSM_RX_STATUS_BROADCAST     (BIT(18))
0277 
0278 /* Indicates group key used with encrypted frames */
0279 #define WSM_RX_STATUS_GROUP_KEY     (BIT(19))
0280 
0281 /* Macro to fetch encryption key index. */
0282 #define WSM_RX_STATUS_KEY_IDX(status)   (((status >> 20)) & 0x0F)
0283 
0284 /* Indicates TSF inclusion after 802.11 frame body */
0285 #define WSM_RX_STATUS_TSF_INCLUDED  (BIT(24))
0286 
0287 /* Frame Control field starts at Frame offset + 2 */
0288 #define WSM_TX_2BYTES_SHIFT     (BIT(7))
0289 
0290 /* Join mode */
0291 /* IBSS */
0292 #define WSM_JOIN_MODE_IBSS      (0)
0293 
0294 /* BSS */
0295 #define WSM_JOIN_MODE_BSS       (1)
0296 
0297 /* PLCP preamble type */
0298 /* For long preamble */
0299 #define WSM_JOIN_PREAMBLE_LONG      (0)
0300 
0301 /* For short preamble (Long for 1Mbps) */
0302 #define WSM_JOIN_PREAMBLE_SHORT     (1)
0303 
0304 /* For short preamble (Long for 1 and 2Mbps) */
0305 #define WSM_JOIN_PREAMBLE_SHORT_2   (2)
0306 
0307 /* Join flags */
0308 /* Unsynchronized */
0309 #define WSM_JOIN_FLAGS_UNSYNCRONIZED    BIT(0)
0310 /* The BSS owner is a P2P GO */
0311 #define WSM_JOIN_FLAGS_P2P_GO       BIT(1)
0312 /* Force to join BSS with the BSSID and the
0313  * SSID specified without waiting for beacons. The
0314  * ProbeForJoin parameter is ignored.
0315  */
0316 #define WSM_JOIN_FLAGS_FORCE        BIT(2)
0317 /* Give probe request/response higher
0318  * priority over the BT traffic
0319  */
0320 #define WSM_JOIN_FLAGS_PRIO     BIT(3)
0321 /* Issue immediate join confirmation and use
0322  * join complete to notify about completion
0323  */
0324 #define WSM_JOIN_FLAGS_FORCE_WITH_COMPLETE_IND BIT(5)
0325 
0326 /* Key types */
0327 #define WSM_KEY_TYPE_WEP_DEFAULT    (0)
0328 #define WSM_KEY_TYPE_WEP_PAIRWISE   (1)
0329 #define WSM_KEY_TYPE_TKIP_GROUP     (2)
0330 #define WSM_KEY_TYPE_TKIP_PAIRWISE  (3)
0331 #define WSM_KEY_TYPE_AES_GROUP      (4)
0332 #define WSM_KEY_TYPE_AES_PAIRWISE   (5)
0333 #define WSM_KEY_TYPE_WAPI_GROUP     (6)
0334 #define WSM_KEY_TYPE_WAPI_PAIRWISE  (7)
0335 
0336 /* Key indexes */
0337 #define WSM_KEY_MAX_INDEX       (10)
0338 
0339 /* ACK policy */
0340 #define WSM_ACK_POLICY_NORMAL       (0)
0341 #define WSM_ACK_POLICY_NO_ACK       (1)
0342 
0343 /* Start modes */
0344 #define WSM_START_MODE_AP       (0) /* Mini AP */
0345 #define WSM_START_MODE_P2P_GO       (1) /* P2P GO */
0346 #define WSM_START_MODE_P2P_DEV      (2) /* P2P device */
0347 
0348 /* SetAssociationMode MIB flags */
0349 #define WSM_ASSOCIATION_MODE_USE_PREAMBLE_TYPE      (BIT(0))
0350 #define WSM_ASSOCIATION_MODE_USE_HT_MODE        (BIT(1))
0351 #define WSM_ASSOCIATION_MODE_USE_BASIC_RATE_SET     (BIT(2))
0352 #define WSM_ASSOCIATION_MODE_USE_MPDU_START_SPACING (BIT(3))
0353 #define WSM_ASSOCIATION_MODE_SNOOP_ASSOC_FRAMES     (BIT(4))
0354 
0355 /* RcpiRssiThreshold MIB flags */
0356 #define WSM_RCPI_RSSI_THRESHOLD_ENABLE  (BIT(0))
0357 #define WSM_RCPI_RSSI_USE_RSSI      (BIT(1))
0358 #define WSM_RCPI_RSSI_DONT_USE_UPPER    (BIT(2))
0359 #define WSM_RCPI_RSSI_DONT_USE_LOWER    (BIT(3))
0360 
0361 /* Update-ie constants */
0362 #define WSM_UPDATE_IE_BEACON        (BIT(0))
0363 #define WSM_UPDATE_IE_PROBE_RESP    (BIT(1))
0364 #define WSM_UPDATE_IE_PROBE_REQ     (BIT(2))
0365 
0366 /* WSM events */
0367 /* Error */
0368 #define WSM_EVENT_ERROR         (0)
0369 
0370 /* BSS lost */
0371 #define WSM_EVENT_BSS_LOST      (1)
0372 
0373 /* BSS regained */
0374 #define WSM_EVENT_BSS_REGAINED      (2)
0375 
0376 /* Radar detected */
0377 #define WSM_EVENT_RADAR_DETECTED    (3)
0378 
0379 /* RCPI or RSSI threshold triggered */
0380 #define WSM_EVENT_RCPI_RSSI     (4)
0381 
0382 /* BT inactive */
0383 #define WSM_EVENT_BT_INACTIVE       (5)
0384 
0385 /* BT active */
0386 #define WSM_EVENT_BT_ACTIVE     (6)
0387 
0388 /* MIB IDs */
0389 /* 4.1  dot11StationId */
0390 #define WSM_MIB_ID_DOT11_STATION_ID     0x0000
0391 
0392 /* 4.2  dot11MaxtransmitMsduLifeTime */
0393 #define WSM_MIB_ID_DOT11_MAX_TRANSMIT_LIFTIME   0x0001
0394 
0395 /* 4.3  dot11MaxReceiveLifeTime */
0396 #define WSM_MIB_ID_DOT11_MAX_RECEIVE_LIFETIME   0x0002
0397 
0398 /* 4.4  dot11SlotTime */
0399 #define WSM_MIB_ID_DOT11_SLOT_TIME      0x0003
0400 
0401 /* 4.5  dot11GroupAddressesTable */
0402 #define WSM_MIB_ID_DOT11_GROUP_ADDRESSES_TABLE  0x0004
0403 #define WSM_MAX_GRP_ADDRTABLE_ENTRIES       8
0404 
0405 /* 4.6  dot11WepDefaultKeyId */
0406 #define WSM_MIB_ID_DOT11_WEP_DEFAULT_KEY_ID 0x0005
0407 
0408 /* 4.7  dot11CurrentTxPowerLevel */
0409 #define WSM_MIB_ID_DOT11_CURRENT_TX_POWER_LEVEL 0x0006
0410 
0411 /* 4.8  dot11RTSThreshold */
0412 #define WSM_MIB_ID_DOT11_RTS_THRESHOLD      0x0007
0413 
0414 /* 4.9  NonErpProtection */
0415 #define WSM_MIB_ID_NON_ERP_PROTECTION       0x1000
0416 
0417 /* 4.10 ArpIpAddressesTable */
0418 #define WSM_MIB_ID_ARP_IP_ADDRESSES_TABLE   0x1001
0419 #define WSM_MAX_ARP_IP_ADDRTABLE_ENTRIES    1
0420 
0421 /* 4.11 TemplateFrame */
0422 #define WSM_MIB_ID_TEMPLATE_FRAME       0x1002
0423 
0424 /* 4.12 RxFilter */
0425 #define WSM_MIB_ID_RX_FILTER            0x1003
0426 
0427 /* 4.13 BeaconFilterTable */
0428 #define WSM_MIB_ID_BEACON_FILTER_TABLE      0x1004
0429 
0430 /* 4.14 BeaconFilterEnable */
0431 #define WSM_MIB_ID_BEACON_FILTER_ENABLE     0x1005
0432 
0433 /* 4.15 OperationalPowerMode */
0434 #define WSM_MIB_ID_OPERATIONAL_POWER_MODE   0x1006
0435 
0436 /* 4.16 BeaconWakeUpPeriod */
0437 #define WSM_MIB_ID_BEACON_WAKEUP_PERIOD     0x1007
0438 
0439 /* 4.17 RcpiRssiThreshold */
0440 #define WSM_MIB_ID_RCPI_RSSI_THRESHOLD      0x1009
0441 
0442 /* 4.18 StatisticsTable */
0443 #define WSM_MIB_ID_STATISTICS_TABLE     0x100A
0444 
0445 /* 4.19 IbssPsConfig */
0446 #define WSM_MIB_ID_IBSS_PS_CONFIG       0x100B
0447 
0448 /* 4.20 CountersTable */
0449 #define WSM_MIB_ID_COUNTERS_TABLE       0x100C
0450 
0451 /* 4.21 BlockAckPolicy */
0452 #define WSM_MIB_ID_BLOCK_ACK_POLICY     0x100E
0453 
0454 /* 4.22 OverrideInternalTxRate */
0455 #define WSM_MIB_ID_OVERRIDE_INTERNAL_TX_RATE    0x100F
0456 
0457 /* 4.23 SetAssociationMode */
0458 #define WSM_MIB_ID_SET_ASSOCIATION_MODE     0x1010
0459 
0460 /* 4.24 UpdateEptaConfigData */
0461 #define WSM_MIB_ID_UPDATE_EPTA_CONFIG_DATA  0x1011
0462 
0463 /* 4.25 SelectCcaMethod */
0464 #define WSM_MIB_ID_SELECT_CCA_METHOD        0x1012
0465 
0466 /* 4.26 SetUpasdInformation */
0467 #define WSM_MIB_ID_SET_UAPSD_INFORMATION    0x1013
0468 
0469 /* 4.27 SetAutoCalibrationMode  WBF00004073 */
0470 #define WSM_MIB_ID_SET_AUTO_CALIBRATION_MODE    0x1015
0471 
0472 /* 4.28 SetTxRateRetryPolicy */
0473 #define WSM_MIB_ID_SET_TX_RATE_RETRY_POLICY 0x1016
0474 
0475 /* 4.29 SetHostMessageTypeFilter */
0476 #define WSM_MIB_ID_SET_HOST_MSG_TYPE_FILTER 0x1017
0477 
0478 /* 4.30 P2PFindInfo */
0479 #define WSM_MIB_ID_P2P_FIND_INFO        0x1018
0480 
0481 /* 4.31 P2PPsModeInfo */
0482 #define WSM_MIB_ID_P2P_PS_MODE_INFO     0x1019
0483 
0484 /* 4.32 SetEtherTypeDataFrameFilter */
0485 #define WSM_MIB_ID_SET_ETHERTYPE_DATAFRAME_FILTER 0x101A
0486 
0487 /* 4.33 SetUDPPortDataFrameFilter */
0488 #define WSM_MIB_ID_SET_UDPPORT_DATAFRAME_FILTER 0x101B
0489 
0490 /* 4.34 SetMagicDataFrameFilter */
0491 #define WSM_MIB_ID_SET_MAGIC_DATAFRAME_FILTER   0x101C
0492 
0493 /* 4.35 P2PDeviceInfo */
0494 #define WSM_MIB_ID_P2P_DEVICE_INFO      0x101D
0495 
0496 /* 4.36 SetWCDMABand */
0497 #define WSM_MIB_ID_SET_WCDMA_BAND       0x101E
0498 
0499 /* 4.37 GroupTxSequenceCounter */
0500 #define WSM_MIB_ID_GRP_SEQ_COUNTER      0x101F
0501 
0502 /* 4.38 ProtectedMgmtPolicy */
0503 #define WSM_MIB_ID_PROTECTED_MGMT_POLICY    0x1020
0504 
0505 /* 4.39 SetHtProtection */
0506 #define WSM_MIB_ID_SET_HT_PROTECTION        0x1021
0507 
0508 /* 4.40 GPIO Command */
0509 #define WSM_MIB_ID_GPIO_COMMAND         0x1022
0510 
0511 /* 4.41 TSF Counter Value */
0512 #define WSM_MIB_ID_TSF_COUNTER          0x1023
0513 
0514 /* Test Purposes Only */
0515 #define WSM_MIB_ID_BLOCK_ACK_INFO       0x100D
0516 
0517 /* 4.42 UseMultiTxConfMessage */
0518 #define WSM_MIB_USE_MULTI_TX_CONF       0x1024
0519 
0520 /* 4.43 Keep-alive period */
0521 #define WSM_MIB_ID_KEEP_ALIVE_PERIOD        0x1025
0522 
0523 /* 4.44 Disable BSSID filter */
0524 #define WSM_MIB_ID_DISABLE_BSSID_FILTER     0x1026
0525 
0526 /* Frame template types */
0527 #define WSM_FRAME_TYPE_PROBE_REQUEST    (0)
0528 #define WSM_FRAME_TYPE_BEACON       (1)
0529 #define WSM_FRAME_TYPE_NULL     (2)
0530 #define WSM_FRAME_TYPE_QOS_NULL     (3)
0531 #define WSM_FRAME_TYPE_PS_POLL      (4)
0532 #define WSM_FRAME_TYPE_PROBE_RESPONSE   (5)
0533 
0534 #define WSM_FRAME_GREENFIELD        (0x80)  /* See 4.11 */
0535 
0536 /* Status */
0537 /* The WSM firmware has completed a request */
0538 /* successfully. */
0539 #define WSM_STATUS_SUCCESS              (0)
0540 
0541 /* This is a generic failure code if other error codes do */
0542 /* not apply. */
0543 #define WSM_STATUS_FAILURE              (1)
0544 
0545 /* A request contains one or more invalid parameters. */
0546 #define WSM_INVALID_PARAMETER           (2)
0547 
0548 /* The request cannot perform because the device is in */
0549 /* an inappropriate mode. */
0550 #define WSM_ACCESS_DENIED               (3)
0551 
0552 /* The frame received includes a decryption error. */
0553 #define WSM_STATUS_DECRYPTFAILURE       (4)
0554 
0555 /* A MIC failure is detected in the received packets. */
0556 #define WSM_STATUS_MICFAILURE           (5)
0557 
0558 /* The transmit request failed due to retry limit being */
0559 /* exceeded. */
0560 #define WSM_STATUS_RETRY_EXCEEDED       (6)
0561 
0562 /* The transmit request failed due to MSDU life time */
0563 /* being exceeded. */
0564 #define WSM_STATUS_TX_LIFETIME_EXCEEDED (7)
0565 
0566 /* The link to the AP is lost. */
0567 #define WSM_STATUS_LINK_LOST            (8)
0568 
0569 /* No key was found for the encrypted frame */
0570 #define WSM_STATUS_NO_KEY_FOUND         (9)
0571 
0572 /* Jammer was detected when transmitting this frame */
0573 #define WSM_STATUS_JAMMER_DETECTED      (10)
0574 
0575 /* The message should be requeued later. */
0576 /* This is applicable only to Transmit */
0577 #define WSM_REQUEUE                     (11)
0578 
0579 /* Advanced filtering options */
0580 #define WSM_MAX_FILTER_ELEMENTS     (4)
0581 
0582 #define WSM_FILTER_ACTION_IGNORE    (0)
0583 #define WSM_FILTER_ACTION_FILTER_IN (1)
0584 #define WSM_FILTER_ACTION_FILTER_OUT    (2)
0585 
0586 #define WSM_FILTER_PORT_TYPE_DST    (0)
0587 #define WSM_FILTER_PORT_TYPE_SRC    (1)
0588 
0589 /* Actual header of WSM messages */
0590 struct wsm_hdr {
0591     __le16 len;
0592     __le16 id;
0593 };
0594 
0595 #define WSM_TX_SEQ_MAX          (7)
0596 #define WSM_TX_SEQ(seq)         \
0597         ((seq & WSM_TX_SEQ_MAX) << 13)
0598 #define WSM_TX_LINK_ID_MAX      (0x0F)
0599 #define WSM_TX_LINK_ID(link_id)     \
0600         ((link_id & WSM_TX_LINK_ID_MAX) << 6)
0601 
0602 #define MAX_BEACON_SKIP_TIME_MS 1000
0603 
0604 #define WSM_CMD_LAST_CHANCE_TIMEOUT (HZ * 3 / 2)
0605 
0606 /* ******************************************************************** */
0607 /* WSM capability                           */
0608 
0609 #define WSM_STARTUP_IND_ID 0x0801
0610 
0611 struct wsm_startup_ind {
0612     u16 input_buffers;
0613     u16 input_buffer_size;
0614     u16 status;
0615     u16 hw_id;
0616     u16 hw_subid;
0617     u16 fw_cap;
0618     u16 fw_type;
0619     u16 fw_api;
0620     u16 fw_build;
0621     u16 fw_ver;
0622     char fw_label[128];
0623     u32 config[4];
0624 };
0625 
0626 /* ******************************************************************** */
0627 /* WSM commands                             */
0628 
0629 /* 3.1 */
0630 #define WSM_CONFIGURATION_REQ_ID 0x0009
0631 #define WSM_CONFIGURATION_RESP_ID 0x0409
0632 
0633 struct wsm_tx_power_range {
0634     int min_power_level;
0635     int max_power_level;
0636     u32 stepping;
0637 };
0638 
0639 struct wsm_configuration {
0640     /* [in] */ u32 dot11MaxTransmitMsduLifeTime;
0641     /* [in] */ u32 dot11MaxReceiveLifeTime;
0642     /* [in] */ u32 dot11RtsThreshold;
0643     /* [in, out] */ u8 *dot11StationId;
0644     /* [in] */ const void *dpdData;
0645     /* [in] */ size_t dpdData_size;
0646     /* [out] */ u8 dot11FrequencyBandsSupported;
0647     /* [out] */ u32 supportedRateMask;
0648     /* [out] */ struct wsm_tx_power_range txPowerRange[2];
0649 };
0650 
0651 int wsm_configuration(struct cw1200_common *priv,
0652               struct wsm_configuration *arg);
0653 
0654 /* 3.3 */
0655 #define WSM_RESET_REQ_ID 0x000A
0656 #define WSM_RESET_RESP_ID 0x040A
0657 struct wsm_reset {
0658     /* [in] */ int link_id;
0659     /* [in] */ bool reset_statistics;
0660 };
0661 
0662 int wsm_reset(struct cw1200_common *priv, const struct wsm_reset *arg);
0663 
0664 /* 3.5 */
0665 #define WSM_READ_MIB_REQ_ID 0x0005
0666 #define WSM_READ_MIB_RESP_ID 0x0405
0667 int wsm_read_mib(struct cw1200_common *priv, u16 mib_id, void *buf,
0668          size_t buf_size);
0669 
0670 /* 3.7 */
0671 #define WSM_WRITE_MIB_REQ_ID 0x0006
0672 #define WSM_WRITE_MIB_RESP_ID 0x0406
0673 int wsm_write_mib(struct cw1200_common *priv, u16 mib_id, void *buf,
0674           size_t buf_size);
0675 
0676 /* 3.9 */
0677 #define WSM_START_SCAN_REQ_ID 0x0007
0678 #define WSM_START_SCAN_RESP_ID 0x0407
0679 
0680 struct wsm_ssid {
0681     u8 ssid[32];
0682     u32 length;
0683 };
0684 
0685 struct wsm_scan_ch {
0686     u16 number;
0687     u32 min_chan_time;
0688     u32 max_chan_time;
0689     u32 tx_power_level;
0690 };
0691 
0692 struct wsm_scan {
0693     /* WSM_PHY_BAND_... */
0694     u8 band;
0695 
0696     /* WSM_SCAN_TYPE_... */
0697     u8 type;
0698 
0699     /* WSM_SCAN_FLAG_... */
0700     u8 flags;
0701 
0702     /* WSM_TRANSMIT_RATE_... */
0703     u8 max_tx_rate;
0704 
0705     /* Interval period in TUs that the device shall the re- */
0706     /* execute the requested scan. Max value supported by the device */
0707     /* is 256s. */
0708     u32 auto_scan_interval;
0709 
0710     /* Number of probe requests (per SSID) sent to one (1) */
0711     /* channel. Zero (0) means that none is send, which */
0712     /* means that a passive scan is to be done. Value */
0713     /* greater than zero (0) means that an active scan is to */
0714     /* be done. */
0715     u32 num_probes;
0716 
0717     /* Number of channels to be scanned. */
0718     /* Maximum value is WSM_SCAN_MAX_NUM_OF_CHANNELS. */
0719     u8 num_channels;
0720 
0721     /* Number of SSID provided in the scan command (this */
0722     /* is zero (0) in broadcast scan) */
0723     /* The maximum number of SSIDs is WSM_SCAN_MAX_NUM_OF_SSIDS. */
0724     u8 num_ssids;
0725 
0726     /* The delay time (in microseconds) period */
0727     /* before sending a probe-request. */
0728     u8 probe_delay;
0729 
0730     /* SSIDs to be scanned [numOfSSIDs]; */
0731     struct wsm_ssid *ssids;
0732 
0733     /* Channels to be scanned [numOfChannels]; */
0734     struct wsm_scan_ch *ch;
0735 };
0736 
0737 int wsm_scan(struct cw1200_common *priv, const struct wsm_scan *arg);
0738 
0739 /* 3.11 */
0740 #define WSM_STOP_SCAN_REQ_ID 0x0008
0741 #define WSM_STOP_SCAN_RESP_ID 0x0408
0742 int wsm_stop_scan(struct cw1200_common *priv);
0743 
0744 /* 3.13 */
0745 #define WSM_SCAN_COMPLETE_IND_ID 0x0806
0746 struct wsm_scan_complete {
0747     /* WSM_STATUS_... */
0748     u32 status;
0749 
0750     /* WSM_PSM_... */
0751     u8 psm;
0752 
0753     /* Number of channels that the scan operation completed. */
0754     u8 num_channels;
0755 };
0756 
0757 /* 3.14 */
0758 #define WSM_TX_CONFIRM_IND_ID 0x0404
0759 #define WSM_MULTI_TX_CONFIRM_ID 0x041E
0760 
0761 struct wsm_tx_confirm {
0762     /* Packet identifier used in wsm_tx. */
0763     u32 packet_id;
0764 
0765     /* WSM_STATUS_... */
0766     u32 status;
0767 
0768     /* WSM_TRANSMIT_RATE_... */
0769     u8 tx_rate;
0770 
0771     /* The number of times the frame was transmitted */
0772     /* without receiving an acknowledgement. */
0773     u8 ack_failures;
0774 
0775     /* WSM_TX_STATUS_... */
0776     u16 flags;
0777 
0778     /* The total time in microseconds that the frame spent in */
0779     /* the WLAN device before transmission as completed. */
0780     u32 media_delay;
0781 
0782     /* The total time in microseconds that the frame spent in */
0783     /* the WLAN device before transmission was started. */
0784     u32 tx_queue_delay;
0785 };
0786 
0787 /* 3.15 */
0788 
0789 /* Note that ideology of wsm_tx struct is different against the rest of
0790  * WSM API. wsm_hdr is /not/ a caller-adapted struct to be used as an input
0791  * argument for WSM call, but a prepared bytestream to be sent to firmware.
0792  * It is filled partly in cw1200_tx, partly in low-level WSM code.
0793  * Please pay attention once again: ideology is different.
0794  *
0795  * Legend:
0796  * - [in]: cw1200_tx must fill this field.
0797  * - [wsm]: the field is filled by low-level WSM.
0798  */
0799 struct wsm_tx {
0800     /* common WSM header */
0801     struct wsm_hdr hdr;
0802 
0803     /* Packet identifier that meant to be used in completion. */
0804     u32 packet_id;  /* Note this is actually a cookie */
0805 
0806     /* WSM_TRANSMIT_RATE_... */
0807     u8 max_tx_rate;
0808 
0809     /* WSM_QUEUE_... */
0810     u8 queue_id;
0811 
0812     /* True: another packet is pending on the host for transmission. */
0813     u8 more;
0814 
0815     /* Bit 0 = 0 - Start expiry time from first Tx attempt (default) */
0816     /* Bit 0 = 1 - Start expiry time from receipt of Tx Request */
0817     /* Bits 3:1  - PTA Priority */
0818     /* Bits 6:4  - Tx Rate Retry Policy */
0819     /* Bit 7 - Reserved */
0820     u8 flags;
0821 
0822     /* Should be 0. */
0823     u32 reserved;
0824 
0825     /* The elapsed time in TUs, after the initial transmission */
0826     /* of an MSDU, after which further attempts to transmit */
0827     /* the MSDU shall be terminated. Overrides the global */
0828     /* dot11MaxTransmitMsduLifeTime setting [optional] */
0829     /* Device will set the default value if this is 0. */
0830     __le32 expire_time;
0831 
0832     /* WSM_HT_TX_... */
0833     __le32 ht_tx_parameters;
0834 } __packed;
0835 
0836 /* = sizeof(generic hi hdr) + sizeof(wsm hdr) + sizeof(alignment) */
0837 #define WSM_TX_EXTRA_HEADROOM (28)
0838 
0839 /* 3.16 */
0840 #define WSM_RECEIVE_IND_ID 0x0804
0841 
0842 struct wsm_rx {
0843     /* WSM_STATUS_... */
0844     u32 status;
0845 
0846     /* Specifies the channel of the received packet. */
0847     u16 channel_number;
0848 
0849     /* WSM_TRANSMIT_RATE_... */
0850     u8 rx_rate;
0851 
0852     /* This value is expressed in signed Q8.0 format for */
0853     /* RSSI and unsigned Q7.1 format for RCPI. */
0854     u8 rcpi_rssi;
0855 
0856     /* WSM_RX_STATUS_... */
0857     u32 flags;
0858 };
0859 
0860 /* = sizeof(generic hi hdr) + sizeof(wsm hdr) */
0861 #define WSM_RX_EXTRA_HEADROOM (16)
0862 
0863 /* 3.17 */
0864 struct wsm_event {
0865     /* WSM_STATUS_... */
0866     /* [out] */ u32 id;
0867 
0868     /* Indication parameters. */
0869     /* For error indication, this shall be a 32-bit WSM status. */
0870     /* For RCPI or RSSI indication, this should be an 8-bit */
0871     /* RCPI or RSSI value. */
0872     /* [out] */ u32 data;
0873 };
0874 
0875 struct cw1200_wsm_event {
0876     struct list_head link;
0877     struct wsm_event evt;
0878 };
0879 
0880 /* 3.18 - 3.22 */
0881 /* Measurement. Skipped for now. Irrelevent. */
0882 
0883 typedef void (*wsm_event_cb) (struct cw1200_common *priv,
0884                   struct wsm_event *arg);
0885 
0886 /* 3.23 */
0887 #define WSM_JOIN_REQ_ID 0x000B
0888 #define WSM_JOIN_RESP_ID 0x040B
0889 
0890 struct wsm_join {
0891     /* WSM_JOIN_MODE_... */
0892     u8 mode;
0893 
0894     /* WSM_PHY_BAND_... */
0895     u8 band;
0896 
0897     /* Specifies the channel number to join. The channel */
0898     /* number will be mapped to an actual frequency */
0899     /* according to the band */
0900     u16 channel_number;
0901 
0902     /* Specifies the BSSID of the BSS or IBSS to be joined */
0903     /* or the IBSS to be started. */
0904     u8 bssid[6];
0905 
0906     /* ATIM window of IBSS */
0907     /* When ATIM window is zero the initiated IBSS does */
0908     /* not support power saving. */
0909     u16 atim_window;
0910 
0911     /* WSM_JOIN_PREAMBLE_... */
0912     u8 preamble_type;
0913 
0914     /* Specifies if a probe request should be send with the */
0915     /* specified SSID when joining to the network. */
0916     u8 probe_for_join;
0917 
0918     /* DTIM Period (In multiples of beacon interval) */
0919     u8 dtim_period;
0920 
0921     /* WSM_JOIN_FLAGS_... */
0922     u8 flags;
0923 
0924     /* Length of the SSID */
0925     u32 ssid_len;
0926 
0927     /* Specifies the SSID of the IBSS to join or start */
0928     u8 ssid[32];
0929 
0930     /* Specifies the time between TBTTs in TUs */
0931     u32 beacon_interval;
0932 
0933     /* A bit mask that defines the BSS basic rate set. */
0934     u32 basic_rate_set;
0935 };
0936 
0937 struct wsm_join_cnf {
0938     u32 status;
0939 
0940     /* Minimum transmission power level in units of 0.1dBm */
0941     u32 min_power_level;
0942 
0943     /* Maximum transmission power level in units of 0.1dBm */
0944     u32 max_power_level;
0945 };
0946 
0947 int wsm_join(struct cw1200_common *priv, struct wsm_join *arg);
0948 
0949 /* 3.24 */
0950 struct wsm_join_complete {
0951     /* WSM_STATUS_... */
0952     u32 status;
0953 };
0954 
0955 /* 3.25 */
0956 #define WSM_SET_PM_REQ_ID 0x0010
0957 #define WSM_SET_PM_RESP_ID 0x0410
0958 struct wsm_set_pm {
0959     /* WSM_PSM_... */
0960     u8 mode;
0961 
0962     /* in unit of 500us; 0 to use default */
0963     u8 fast_psm_idle_period;
0964 
0965     /* in unit of 500us; 0 to use default */
0966     u8 ap_psm_change_period;
0967 
0968     /* in unit of 500us; 0 to disable auto-pspoll */
0969     u8 min_auto_pspoll_period;
0970 };
0971 
0972 int wsm_set_pm(struct cw1200_common *priv, const struct wsm_set_pm *arg);
0973 
0974 /* 3.27 */
0975 struct wsm_set_pm_complete {
0976     u8 psm;         /* WSM_PSM_... */
0977 };
0978 
0979 /* 3.28 */
0980 #define WSM_SET_BSS_PARAMS_REQ_ID 0x0011
0981 #define WSM_SET_BSS_PARAMS_RESP_ID 0x0411
0982 struct wsm_set_bss_params {
0983     /* This resets the beacon loss counters only */
0984     u8 reset_beacon_loss;
0985 
0986     /* The number of lost consecutive beacons after which */
0987     /* the WLAN device should indicate the BSS-Lost event */
0988     /* to the WLAN host driver. */
0989     u8 beacon_lost_count;
0990 
0991     /* The AID received during the association process. */
0992     u16 aid;
0993 
0994     /* The operational rate set mask */
0995     u32 operational_rate_set;
0996 };
0997 
0998 int wsm_set_bss_params(struct cw1200_common *priv,
0999                const struct wsm_set_bss_params *arg);
1000 
1001 /* 3.30 */
1002 #define WSM_ADD_KEY_REQ_ID         0x000C
1003 #define WSM_ADD_KEY_RESP_ID        0x040C
1004 struct wsm_add_key {
1005     u8 type;        /* WSM_KEY_TYPE_... */
1006     u8 index;       /* Key entry index: 0 -- WSM_KEY_MAX_INDEX */
1007     u16 reserved;
1008     union {
1009         struct {
1010             u8 peer[6]; /* MAC address of the peer station */
1011             u8 reserved;
1012             u8 keylen;      /* Key length in bytes */
1013             u8 keydata[16];     /* Key data */
1014         } __packed wep_pairwise;
1015         struct {
1016             u8 keyid;   /* Unique per key identifier (0..3) */
1017             u8 keylen;      /* Key length in bytes */
1018             u16 reserved;
1019             u8 keydata[16];     /* Key data */
1020         } __packed wep_group;
1021         struct {
1022             u8 peer[6]; /* MAC address of the peer station */
1023             u16 reserved;
1024             u8 keydata[16]; /* TKIP key data */
1025             u8 rx_mic_key[8];       /* Rx MIC key */
1026             u8 tx_mic_key[8];       /* Tx MIC key */
1027         } __packed tkip_pairwise;
1028         struct {
1029             u8 keydata[16]; /* TKIP key data */
1030             u8 rx_mic_key[8];       /* Rx MIC key */
1031             u8 keyid;       /* Key ID */
1032             u8 reserved[3];
1033             u8 rx_seqnum[8];    /* Receive Sequence Counter */
1034         } __packed tkip_group;
1035         struct {
1036             u8 peer[6]; /* MAC address of the peer station */
1037             u16 reserved;
1038             u8 keydata[16]; /* AES key data */
1039         } __packed aes_pairwise;
1040         struct {
1041             u8 keydata[16]; /* AES key data */
1042             u8 keyid;       /* Key ID */
1043             u8 reserved[3];
1044             u8 rx_seqnum[8];    /* Receive Sequence Counter */
1045         } __packed aes_group;
1046         struct {
1047             u8 peer[6]; /* MAC address of the peer station */
1048             u8 keyid;       /* Key ID */
1049             u8 reserved;
1050             u8 keydata[16]; /* WAPI key data */
1051             u8 mic_key[16]; /* MIC key data */
1052         } __packed wapi_pairwise;
1053         struct {
1054             u8 keydata[16]; /* WAPI key data */
1055             u8 mic_key[16]; /* MIC key data */
1056             u8 keyid;       /* Key ID */
1057             u8 reserved[3];
1058         } __packed wapi_group;
1059     } __packed;
1060 } __packed;
1061 
1062 int wsm_add_key(struct cw1200_common *priv, const struct wsm_add_key *arg);
1063 
1064 /* 3.32 */
1065 #define WSM_REMOVE_KEY_REQ_ID         0x000D
1066 #define WSM_REMOVE_KEY_RESP_ID        0x040D
1067 struct wsm_remove_key {
1068     u8 index; /* Key entry index : 0-10 */
1069 };
1070 
1071 int wsm_remove_key(struct cw1200_common *priv,
1072            const struct wsm_remove_key *arg);
1073 
1074 /* 3.34 */
1075 struct wsm_set_tx_queue_params {
1076     /* WSM_ACK_POLICY_... */
1077     u8 ackPolicy;
1078 
1079     /* Medium Time of TSPEC (in 32us units) allowed per */
1080     /* One Second Averaging Period for this queue. */
1081     u16 allowedMediumTime;
1082 
1083     /* dot11MaxTransmitMsduLifetime to be used for the */
1084     /* specified queue. */
1085     u32 maxTransmitLifetime;
1086 };
1087 
1088 struct wsm_tx_queue_params {
1089     /* NOTE: index is a linux queue id. */
1090     struct wsm_set_tx_queue_params params[4];
1091 };
1092 
1093 
1094 #define WSM_TX_QUEUE_SET(queue_params, queue, ack_policy, allowed_time,\
1095         max_life_time)  \
1096 do {                            \
1097     struct wsm_set_tx_queue_params *p = &(queue_params)->params[queue]; \
1098     p->ackPolicy = (ack_policy);                \
1099     p->allowedMediumTime = (allowed_time);              \
1100     p->maxTransmitLifetime = (max_life_time);           \
1101 } while (0)
1102 
1103 int wsm_set_tx_queue_params(struct cw1200_common *priv,
1104                 const struct wsm_set_tx_queue_params *arg, u8 id);
1105 
1106 /* 3.36 */
1107 #define WSM_EDCA_PARAMS_REQ_ID 0x0013
1108 #define WSM_EDCA_PARAMS_RESP_ID 0x0413
1109 struct wsm_edca_queue_params {
1110     /* CWmin (in slots) for the access class. */
1111     u16 cwmin;
1112 
1113     /* CWmax (in slots) for the access class. */
1114     u16 cwmax;
1115 
1116     /* AIFS (in slots) for the access class. */
1117     u16 aifns;
1118 
1119     /* TX OP Limit (in microseconds) for the access class. */
1120     u16 txop_limit;
1121 
1122     /* dot11MaxReceiveLifetime to be used for the specified */
1123     /* the access class. Overrides the global */
1124     /* dot11MaxReceiveLifetime value */
1125     u32 max_rx_lifetime;
1126 };
1127 
1128 struct wsm_edca_params {
1129     /* NOTE: index is a linux queue id. */
1130     struct wsm_edca_queue_params params[4];
1131     bool uapsd_enable[4];
1132 };
1133 
1134 #define TXOP_UNIT 32
1135 #define WSM_EDCA_SET(__edca, __queue, __aifs, __cw_min, __cw_max, __txop, __lifetime,\
1136              __uapsd) \
1137     do {                            \
1138         struct wsm_edca_queue_params *p = &(__edca)->params[__queue]; \
1139         p->cwmin = __cw_min;                    \
1140         p->cwmax = __cw_max;                    \
1141         p->aifns = __aifs;                  \
1142         p->txop_limit = ((__txop) * TXOP_UNIT);         \
1143         p->max_rx_lifetime = __lifetime;            \
1144         (__edca)->uapsd_enable[__queue] = (__uapsd);        \
1145     } while (0)
1146 
1147 int wsm_set_edca_params(struct cw1200_common *priv,
1148             const struct wsm_edca_params *arg);
1149 
1150 int wsm_set_uapsd_param(struct cw1200_common *priv,
1151             const struct wsm_edca_params *arg);
1152 
1153 /* 3.38 */
1154 /* Set-System info. Skipped for now. Irrelevent. */
1155 
1156 /* 3.40 */
1157 #define WSM_SWITCH_CHANNEL_REQ_ID 0x0016
1158 #define WSM_SWITCH_CHANNEL_RESP_ID 0x0416
1159 
1160 struct wsm_switch_channel {
1161     /* 1 - means the STA shall not transmit any further */
1162     /* frames until the channel switch has completed */
1163     u8 mode;
1164 
1165     /* Number of TBTTs until channel switch occurs. */
1166     /* 0 - indicates switch shall occur at any time */
1167     /* 1 - occurs immediately before the next TBTT */
1168     u8 switch_count;
1169 
1170     /* The new channel number to switch to. */
1171     /* Note this is defined as per section 2.7. */
1172     u16 channel_number;
1173 };
1174 
1175 int wsm_switch_channel(struct cw1200_common *priv,
1176                const struct wsm_switch_channel *arg);
1177 
1178 #define WSM_START_REQ_ID 0x0017
1179 #define WSM_START_RESP_ID 0x0417
1180 
1181 struct wsm_start {
1182     /* WSM_START_MODE_... */
1183     /* [in] */ u8 mode;
1184 
1185     /* WSM_PHY_BAND_... */
1186     /* [in] */ u8 band;
1187 
1188     /* Channel number */
1189     /* [in] */ u16 channel_number;
1190 
1191     /* Client Traffic window in units of TU */
1192     /* Valid only when mode == ..._P2P */
1193     /* [in] */ u32 ct_window;
1194 
1195     /* Interval between two consecutive */
1196     /* beacon transmissions in TU. */
1197     /* [in] */ u32 beacon_interval;
1198 
1199     /* DTIM period in terms of beacon intervals */
1200     /* [in] */ u8 dtim_period;
1201 
1202     /* WSM_JOIN_PREAMBLE_... */
1203     /* [in] */ u8 preamble;
1204 
1205     /* The delay time (in microseconds) period */
1206     /* before sending a probe-request. */
1207     /* [in] */ u8 probe_delay;
1208 
1209     /* Length of the SSID */
1210     /* [in] */ u8 ssid_len;
1211 
1212     /* SSID of the BSS or P2P_GO to be started now. */
1213     /* [in] */ u8 ssid[32];
1214 
1215     /* The basic supported rates for the MiniAP. */
1216     /* [in] */ u32 basic_rate_set;
1217 };
1218 
1219 int wsm_start(struct cw1200_common *priv, const struct wsm_start *arg);
1220 
1221 #define WSM_BEACON_TRANSMIT_REQ_ID 0x0018
1222 #define WSM_BEACON_TRANSMIT_RESP_ID 0x0418
1223 
1224 struct wsm_beacon_transmit {
1225     /* 1: enable; 0: disable */
1226     /* [in] */ u8 enable_beaconing;
1227 };
1228 
1229 int wsm_beacon_transmit(struct cw1200_common *priv,
1230             const struct wsm_beacon_transmit *arg);
1231 
1232 int wsm_start_find(struct cw1200_common *priv);
1233 
1234 int wsm_stop_find(struct cw1200_common *priv);
1235 
1236 struct wsm_suspend_resume {
1237     /* See 3.52 */
1238     /* Link ID */
1239     /* [out] */ int link_id;
1240     /* Stop sending further Tx requests down to device for this link */
1241     /* [out] */ bool stop;
1242     /* Transmit multicast Frames */
1243     /* [out] */ bool multicast;
1244     /* The AC on which Tx to be suspended /resumed. */
1245     /* This is applicable only for U-APSD */
1246     /* WSM_QUEUE_... */
1247     /* [out] */ int queue;
1248 };
1249 
1250 /* 3.54 Update-IE request. */
1251 struct wsm_update_ie {
1252     /* WSM_UPDATE_IE_... */
1253     /* [in] */ u16 what;
1254     /* [in] */ u16 count;
1255     /* [in] */ u8 *ies;
1256     /* [in] */ size_t length;
1257 };
1258 
1259 int wsm_update_ie(struct cw1200_common *priv,
1260           const struct wsm_update_ie *arg);
1261 
1262 /* 3.56 */
1263 struct wsm_map_link {
1264     /* MAC address of the remote device */
1265     /* [in] */ u8 mac_addr[6];
1266     /* [in] */ u8 link_id;
1267 };
1268 
1269 int wsm_map_link(struct cw1200_common *priv, const struct wsm_map_link *arg);
1270 
1271 /* ******************************************************************** */
1272 /* MIB shortcats                            */
1273 
1274 static inline int wsm_set_output_power(struct cw1200_common *priv,
1275                        int power_level)
1276 {
1277     __le32 val = __cpu_to_le32(power_level);
1278     return wsm_write_mib(priv, WSM_MIB_ID_DOT11_CURRENT_TX_POWER_LEVEL,
1279                  &val, sizeof(val));
1280 }
1281 
1282 static inline int wsm_set_beacon_wakeup_period(struct cw1200_common *priv,
1283                            unsigned dtim_interval,
1284                            unsigned listen_interval)
1285 {
1286     struct {
1287         u8 numBeaconPeriods;
1288         u8 reserved;
1289         __le16 listenInterval;
1290     } val = {
1291         dtim_interval, 0, __cpu_to_le16(listen_interval)
1292     };
1293 
1294     if (dtim_interval > 0xFF || listen_interval > 0xFFFF)
1295         return -EINVAL;
1296     else
1297         return wsm_write_mib(priv, WSM_MIB_ID_BEACON_WAKEUP_PERIOD,
1298                      &val, sizeof(val));
1299 }
1300 
1301 struct wsm_rcpi_rssi_threshold {
1302     u8 rssiRcpiMode;    /* WSM_RCPI_RSSI_... */
1303     u8 lowerThreshold;
1304     u8 upperThreshold;
1305     u8 rollingAverageCount;
1306 };
1307 
1308 static inline int wsm_set_rcpi_rssi_threshold(struct cw1200_common *priv,
1309                     struct wsm_rcpi_rssi_threshold *arg)
1310 {
1311     return wsm_write_mib(priv, WSM_MIB_ID_RCPI_RSSI_THRESHOLD, arg,
1312                  sizeof(*arg));
1313 }
1314 
1315 struct wsm_mib_counters_table {
1316     __le32 plcp_errors;
1317     __le32 fcs_errors;
1318     __le32 tx_packets;
1319     __le32 rx_packets;
1320     __le32 rx_packet_errors;
1321     __le32 rx_decryption_failures;
1322     __le32 rx_mic_failures;
1323     __le32 rx_no_key_failures;
1324     __le32 tx_multicast_frames;
1325     __le32 tx_frames_success;
1326     __le32 tx_frame_failures;
1327     __le32 tx_frames_retried;
1328     __le32 tx_frames_multi_retried;
1329     __le32 rx_frame_duplicates;
1330     __le32 rts_success;
1331     __le32 rts_failures;
1332     __le32 ack_failures;
1333     __le32 rx_multicast_frames;
1334     __le32 rx_frames_success;
1335     __le32 rx_cmac_icv_errors;
1336     __le32 rx_cmac_replays;
1337     __le32 rx_mgmt_ccmp_replays;
1338 } __packed;
1339 
1340 static inline int wsm_get_counters_table(struct cw1200_common *priv,
1341                      struct wsm_mib_counters_table *arg)
1342 {
1343     return wsm_read_mib(priv, WSM_MIB_ID_COUNTERS_TABLE,
1344                 arg, sizeof(*arg));
1345 }
1346 
1347 static inline int wsm_get_station_id(struct cw1200_common *priv, u8 *mac)
1348 {
1349     return wsm_read_mib(priv, WSM_MIB_ID_DOT11_STATION_ID, mac, ETH_ALEN);
1350 }
1351 
1352 struct wsm_rx_filter {
1353     bool promiscuous;
1354     bool bssid;
1355     bool fcs;
1356     bool probeResponder;
1357 };
1358 
1359 static inline int wsm_set_rx_filter(struct cw1200_common *priv,
1360                     const struct wsm_rx_filter *arg)
1361 {
1362     __le32 val = 0;
1363     if (arg->promiscuous)
1364         val |= __cpu_to_le32(BIT(0));
1365     if (arg->bssid)
1366         val |= __cpu_to_le32(BIT(1));
1367     if (arg->fcs)
1368         val |= __cpu_to_le32(BIT(2));
1369     if (arg->probeResponder)
1370         val |= __cpu_to_le32(BIT(3));
1371     return wsm_write_mib(priv, WSM_MIB_ID_RX_FILTER, &val, sizeof(val));
1372 }
1373 
1374 int wsm_set_probe_responder(struct cw1200_common *priv, bool enable);
1375 
1376 #define WSM_BEACON_FILTER_IE_HAS_CHANGED    BIT(0)
1377 #define WSM_BEACON_FILTER_IE_NO_LONGER_PRESENT  BIT(1)
1378 #define WSM_BEACON_FILTER_IE_HAS_APPEARED   BIT(2)
1379 
1380 struct wsm_beacon_filter_table_entry {
1381     u8  ie_id;
1382     u8  flags;
1383     u8  oui[3];
1384     u8  match_data[3];
1385 } __packed;
1386 
1387 struct wsm_mib_beacon_filter_table {
1388     __le32 num;
1389     struct wsm_beacon_filter_table_entry entry[10];
1390 } __packed;
1391 
1392 static inline int wsm_set_beacon_filter_table(struct cw1200_common *priv,
1393                           struct wsm_mib_beacon_filter_table *ft)
1394 {
1395     size_t size = __le32_to_cpu(ft->num) *
1396              sizeof(struct wsm_beacon_filter_table_entry) +
1397              sizeof(__le32);
1398 
1399     return wsm_write_mib(priv, WSM_MIB_ID_BEACON_FILTER_TABLE, ft, size);
1400 }
1401 
1402 #define WSM_BEACON_FILTER_ENABLE    BIT(0) /* Enable/disable beacon filtering */
1403 #define WSM_BEACON_FILTER_AUTO_ERP  BIT(1) /* If 1 FW will handle ERP IE changes internally */
1404 
1405 struct wsm_beacon_filter_control {
1406     int enabled;
1407     int bcn_count;
1408 };
1409 
1410 static inline int wsm_beacon_filter_control(struct cw1200_common *priv,
1411                     struct wsm_beacon_filter_control *arg)
1412 {
1413     struct {
1414         __le32 enabled;
1415         __le32 bcn_count;
1416     } val;
1417     val.enabled = __cpu_to_le32(arg->enabled);
1418     val.bcn_count = __cpu_to_le32(arg->bcn_count);
1419     return wsm_write_mib(priv, WSM_MIB_ID_BEACON_FILTER_ENABLE, &val,
1420                  sizeof(val));
1421 }
1422 
1423 enum wsm_power_mode {
1424     wsm_power_mode_active = 0,
1425     wsm_power_mode_doze = 1,
1426     wsm_power_mode_quiescent = 2,
1427 };
1428 
1429 struct wsm_operational_mode {
1430     enum wsm_power_mode power_mode;
1431     int disable_more_flag_usage;
1432     int perform_ant_diversity;
1433 };
1434 
1435 static inline int wsm_set_operational_mode(struct cw1200_common *priv,
1436                     const struct wsm_operational_mode *arg)
1437 {
1438     u8 val = arg->power_mode;
1439     if (arg->disable_more_flag_usage)
1440         val |= BIT(4);
1441     if (arg->perform_ant_diversity)
1442         val |= BIT(5);
1443     return wsm_write_mib(priv, WSM_MIB_ID_OPERATIONAL_POWER_MODE, &val,
1444                  sizeof(val));
1445 }
1446 
1447 struct wsm_template_frame {
1448     u8 frame_type;
1449     u8 rate;
1450     struct sk_buff *skb;
1451 };
1452 
1453 static inline int wsm_set_template_frame(struct cw1200_common *priv,
1454                      struct wsm_template_frame *arg)
1455 {
1456     int ret;
1457     u8 *p = skb_push(arg->skb, 4);
1458     p[0] = arg->frame_type;
1459     p[1] = arg->rate;
1460     ((__le16 *)p)[1] = __cpu_to_le16(arg->skb->len - 4);
1461     ret = wsm_write_mib(priv, WSM_MIB_ID_TEMPLATE_FRAME, p, arg->skb->len);
1462     skb_pull(arg->skb, 4);
1463     return ret;
1464 }
1465 
1466 
1467 struct wsm_protected_mgmt_policy {
1468     bool protectedMgmtEnable;
1469     bool unprotectedMgmtFramesAllowed;
1470     bool encryptionForAuthFrame;
1471 };
1472 
1473 static inline int wsm_set_protected_mgmt_policy(struct cw1200_common *priv,
1474         struct wsm_protected_mgmt_policy *arg)
1475 {
1476     __le32 val = 0;
1477     int ret;
1478     if (arg->protectedMgmtEnable)
1479         val |= __cpu_to_le32(BIT(0));
1480     if (arg->unprotectedMgmtFramesAllowed)
1481         val |= __cpu_to_le32(BIT(1));
1482     if (arg->encryptionForAuthFrame)
1483         val |= __cpu_to_le32(BIT(2));
1484     ret = wsm_write_mib(priv, WSM_MIB_ID_PROTECTED_MGMT_POLICY,
1485             &val, sizeof(val));
1486     return ret;
1487 }
1488 
1489 struct wsm_mib_block_ack_policy {
1490     u8 tx_tid;
1491     u8 reserved1;
1492     u8 rx_tid;
1493     u8 reserved2;
1494 } __packed;
1495 
1496 static inline int wsm_set_block_ack_policy(struct cw1200_common *priv,
1497                        u8 tx_tid_policy,
1498                        u8 rx_tid_policy)
1499 {
1500     struct wsm_mib_block_ack_policy val = {
1501         .tx_tid = tx_tid_policy,
1502         .rx_tid = rx_tid_policy,
1503     };
1504     return wsm_write_mib(priv, WSM_MIB_ID_BLOCK_ACK_POLICY, &val,
1505                  sizeof(val));
1506 }
1507 
1508 struct wsm_mib_association_mode {
1509     u8 flags;       /* WSM_ASSOCIATION_MODE_... */
1510     u8 preamble;    /* WSM_JOIN_PREAMBLE_... */
1511     u8 greenfield;  /* 1 for greenfield */
1512     u8 mpdu_start_spacing;
1513     __le32 basic_rate_set;
1514 } __packed;
1515 
1516 static inline int wsm_set_association_mode(struct cw1200_common *priv,
1517                        struct wsm_mib_association_mode *arg)
1518 {
1519     return wsm_write_mib(priv, WSM_MIB_ID_SET_ASSOCIATION_MODE, arg,
1520                  sizeof(*arg));
1521 }
1522 
1523 #define WSM_TX_RATE_POLICY_FLAG_TERMINATE_WHEN_FINISHED BIT(2)
1524 #define WSM_TX_RATE_POLICY_FLAG_COUNT_INITIAL_TRANSMIT BIT(3)
1525 struct wsm_tx_rate_retry_policy {
1526     u8 index;
1527     u8 short_retries;
1528     u8 long_retries;
1529     /* BIT(2) - Terminate retries when Tx rate retry policy
1530      *          finishes.
1531      * BIT(3) - Count initial frame transmission as part of
1532      *          rate retry counting but not as a retry
1533      *          attempt
1534      */
1535     u8 flags;
1536     u8 rate_recoveries;
1537     u8 reserved[3];
1538     __le32 rate_count_indices[3];
1539 } __packed;
1540 
1541 struct wsm_set_tx_rate_retry_policy {
1542     u8 num;
1543     u8 reserved[3];
1544     struct wsm_tx_rate_retry_policy tbl[8];
1545 } __packed;
1546 
1547 static inline int wsm_set_tx_rate_retry_policy(struct cw1200_common *priv,
1548                 struct wsm_set_tx_rate_retry_policy *arg)
1549 {
1550     size_t size = 4 + arg->num * sizeof(struct wsm_tx_rate_retry_policy);
1551     return wsm_write_mib(priv, WSM_MIB_ID_SET_TX_RATE_RETRY_POLICY, arg,
1552                  size);
1553 }
1554 
1555 /* 4.32 SetEtherTypeDataFrameFilter */
1556 struct wsm_ether_type_filter_hdr {
1557     u8 num;     /* Up to WSM_MAX_FILTER_ELEMENTS */
1558     u8 reserved[3];
1559 } __packed;
1560 
1561 struct wsm_ether_type_filter {
1562     u8 action;  /* WSM_FILTER_ACTION_XXX */
1563     u8 reserved;
1564     __le16 type;    /* Type of ethernet frame */
1565 } __packed;
1566 
1567 static inline int wsm_set_ether_type_filter(struct cw1200_common *priv,
1568                 struct wsm_ether_type_filter_hdr *arg)
1569 {
1570     size_t size = sizeof(struct wsm_ether_type_filter_hdr) +
1571         arg->num * sizeof(struct wsm_ether_type_filter);
1572     return wsm_write_mib(priv, WSM_MIB_ID_SET_ETHERTYPE_DATAFRAME_FILTER,
1573         arg, size);
1574 }
1575 
1576 /* 4.33 SetUDPPortDataFrameFilter */
1577 struct wsm_udp_port_filter_hdr {
1578     u8 num;     /* Up to WSM_MAX_FILTER_ELEMENTS */
1579     u8 reserved[3];
1580 } __packed;
1581 
1582 struct wsm_udp_port_filter {
1583     u8 action;  /* WSM_FILTER_ACTION_XXX */
1584     u8 type;        /* WSM_FILTER_PORT_TYPE_XXX */
1585     __le16 port;        /* Port number */
1586 } __packed;
1587 
1588 static inline int wsm_set_udp_port_filter(struct cw1200_common *priv,
1589                 struct wsm_udp_port_filter_hdr *arg)
1590 {
1591     size_t size = sizeof(struct wsm_udp_port_filter_hdr) +
1592         arg->num * sizeof(struct wsm_udp_port_filter);
1593     return wsm_write_mib(priv, WSM_MIB_ID_SET_UDPPORT_DATAFRAME_FILTER,
1594         arg, size);
1595 }
1596 
1597 /* Undocumented MIBs: */
1598 /* 4.35 P2PDeviceInfo */
1599 #define D11_MAX_SSID_LEN        (32)
1600 
1601 struct wsm_p2p_device_type {
1602     __le16 category_id;
1603     u8 oui[4];
1604     __le16 subcategory_id;
1605 } __packed;
1606 
1607 struct wsm_p2p_device_info {
1608     struct wsm_p2p_device_type primaryDevice;
1609     u8 reserved1[3];
1610     u8 devname_size;
1611     u8 local_devname[D11_MAX_SSID_LEN];
1612     u8 reserved2[3];
1613     u8 num_secdev_supported;
1614     struct wsm_p2p_device_type secdevs[];
1615 } __packed;
1616 
1617 /* 4.36 SetWCDMABand - WO */
1618 struct wsm_cdma_band {
1619     u8 wcdma_band;
1620     u8 reserved[3];
1621 } __packed;
1622 
1623 /* 4.37 GroupTxSequenceCounter - RO */
1624 struct wsm_group_tx_seq {
1625     __le32 bits_47_16;
1626     __le16 bits_15_00;
1627     __le16 reserved;
1628 } __packed;
1629 
1630 /* 4.39 SetHtProtection - WO */
1631 #define WSM_DUAL_CTS_PROT_ENB       (1 << 0)
1632 #define WSM_NON_GREENFIELD_STA_PRESENT  (1 << 1)
1633 #define WSM_HT_PROT_MODE__NO_PROT   (0 << 2)
1634 #define WSM_HT_PROT_MODE__NON_MEMBER    (1 << 2)
1635 #define WSM_HT_PROT_MODE__20_MHZ    (2 << 2)
1636 #define WSM_HT_PROT_MODE__NON_HT_MIXED  (3 << 2)
1637 #define WSM_LSIG_TXOP_PROT_FULL     (1 << 4)
1638 #define WSM_LARGE_L_LENGTH_PROT     (1 << 5)
1639 
1640 struct wsm_ht_protection {
1641     __le32 flags;
1642 } __packed;
1643 
1644 /* 4.40 GPIO Command - R/W */
1645 #define WSM_GPIO_COMMAND_SETUP  0
1646 #define WSM_GPIO_COMMAND_READ   1
1647 #define WSM_GPIO_COMMAND_WRITE  2
1648 #define WSM_GPIO_COMMAND_RESET  3
1649 #define WSM_GPIO_ALL_PINS   0xFF
1650 
1651 struct wsm_gpio_command {
1652     u8 command;
1653     u8 pin;
1654     __le16 config;
1655 } __packed;
1656 
1657 /* 4.41 TSFCounter - RO */
1658 struct wsm_tsf_counter {
1659     __le64 tsf_counter;
1660 } __packed;
1661 
1662 /* 4.43 Keep alive period */
1663 struct wsm_keep_alive_period {
1664     __le16 period;
1665     u8 reserved[2];
1666 } __packed;
1667 
1668 static inline int wsm_keep_alive_period(struct cw1200_common *priv,
1669                     int period)
1670 {
1671     struct wsm_keep_alive_period arg = {
1672         .period = __cpu_to_le16(period),
1673     };
1674     return wsm_write_mib(priv, WSM_MIB_ID_KEEP_ALIVE_PERIOD,
1675             &arg, sizeof(arg));
1676 };
1677 
1678 /* BSSID filtering */
1679 struct wsm_set_bssid_filtering {
1680     u8 filter;
1681     u8 reserved[3];
1682 } __packed;
1683 
1684 static inline int wsm_set_bssid_filtering(struct cw1200_common *priv,
1685                       bool enabled)
1686 {
1687     struct wsm_set_bssid_filtering arg = {
1688         .filter = !enabled,
1689     };
1690     return wsm_write_mib(priv, WSM_MIB_ID_DISABLE_BSSID_FILTER,
1691             &arg, sizeof(arg));
1692 }
1693 
1694 /* Multicast filtering - 4.5 */
1695 struct wsm_mib_multicast_filter {
1696     __le32 enable;
1697     __le32 num_addrs;
1698     u8 macaddrs[WSM_MAX_GRP_ADDRTABLE_ENTRIES][ETH_ALEN];
1699 } __packed;
1700 
1701 static inline int wsm_set_multicast_filter(struct cw1200_common *priv,
1702                        struct wsm_mib_multicast_filter *fp)
1703 {
1704     return wsm_write_mib(priv, WSM_MIB_ID_DOT11_GROUP_ADDRESSES_TABLE,
1705                  fp, sizeof(*fp));
1706 }
1707 
1708 /* ARP IPv4 filtering - 4.10 */
1709 struct wsm_mib_arp_ipv4_filter {
1710     __le32 enable;
1711     __be32 ipv4addrs[WSM_MAX_ARP_IP_ADDRTABLE_ENTRIES];
1712 } __packed;
1713 
1714 static inline int wsm_set_arp_ipv4_filter(struct cw1200_common *priv,
1715                       struct wsm_mib_arp_ipv4_filter *fp)
1716 {
1717     return wsm_write_mib(priv, WSM_MIB_ID_ARP_IP_ADDRESSES_TABLE,
1718                 fp, sizeof(*fp));
1719 }
1720 
1721 /* P2P Power Save Mode Info - 4.31 */
1722 struct wsm_p2p_ps_modeinfo {
1723     u8  opp_ps_ct_window;
1724     u8  count;
1725     u8  reserved;
1726     u8  dtim_count;
1727     __le32  duration;
1728     __le32  interval;
1729     __le32  start_time;
1730 } __packed;
1731 
1732 static inline int wsm_set_p2p_ps_modeinfo(struct cw1200_common *priv,
1733                       struct wsm_p2p_ps_modeinfo *mi)
1734 {
1735     return wsm_write_mib(priv, WSM_MIB_ID_P2P_PS_MODE_INFO,
1736                  mi, sizeof(*mi));
1737 }
1738 
1739 static inline int wsm_get_p2p_ps_modeinfo(struct cw1200_common *priv,
1740                       struct wsm_p2p_ps_modeinfo *mi)
1741 {
1742     return wsm_read_mib(priv, WSM_MIB_ID_P2P_PS_MODE_INFO,
1743                 mi, sizeof(*mi));
1744 }
1745 
1746 /* UseMultiTxConfMessage */
1747 
1748 static inline int wsm_use_multi_tx_conf(struct cw1200_common *priv,
1749                     bool enabled)
1750 {
1751     __le32 arg = enabled ? __cpu_to_le32(1) : 0;
1752 
1753     return wsm_write_mib(priv, WSM_MIB_USE_MULTI_TX_CONF,
1754             &arg, sizeof(arg));
1755 }
1756 
1757 
1758 /* 4.26 SetUpasdInformation */
1759 struct wsm_uapsd_info {
1760     __le16 uapsd_flags;
1761     __le16 min_auto_trigger_interval;
1762     __le16 max_auto_trigger_interval;
1763     __le16 auto_trigger_step;
1764 };
1765 
1766 static inline int wsm_set_uapsd_info(struct cw1200_common *priv,
1767                      struct wsm_uapsd_info *arg)
1768 {
1769     return wsm_write_mib(priv, WSM_MIB_ID_SET_UAPSD_INFORMATION,
1770                 arg, sizeof(*arg));
1771 }
1772 
1773 /* 4.22 OverrideInternalTxRate */
1774 struct wsm_override_internal_txrate {
1775     u8 internalTxRate;
1776     u8 nonErpInternalTxRate;
1777     u8 reserved[2];
1778 } __packed;
1779 
1780 static inline int wsm_set_override_internal_txrate(struct cw1200_common *priv,
1781                      struct wsm_override_internal_txrate *arg)
1782 {
1783     return wsm_write_mib(priv, WSM_MIB_ID_OVERRIDE_INTERNAL_TX_RATE,
1784                 arg, sizeof(*arg));
1785 }
1786 
1787 /* ******************************************************************** */
1788 /* WSM TX port control                          */
1789 
1790 void wsm_lock_tx(struct cw1200_common *priv);
1791 void wsm_lock_tx_async(struct cw1200_common *priv);
1792 bool wsm_flush_tx(struct cw1200_common *priv);
1793 void wsm_unlock_tx(struct cw1200_common *priv);
1794 
1795 /* ******************************************************************** */
1796 /* WSM / BH API                             */
1797 
1798 int wsm_handle_exception(struct cw1200_common *priv, u8 *data, size_t len);
1799 int wsm_handle_rx(struct cw1200_common *priv, u16 id, struct wsm_hdr *wsm,
1800           struct sk_buff **skb_p);
1801 
1802 /* ******************************************************************** */
1803 /* wsm_buf API                              */
1804 
1805 struct wsm_buf {
1806     u8 *begin;
1807     u8 *data;
1808     u8 *end;
1809 };
1810 
1811 void wsm_buf_init(struct wsm_buf *buf);
1812 void wsm_buf_deinit(struct wsm_buf *buf);
1813 
1814 /* ******************************************************************** */
1815 /* wsm_cmd API                              */
1816 
1817 struct wsm_cmd {
1818     spinlock_t lock; /* Protect structure from multiple access */
1819     int done;
1820     u8 *ptr;
1821     size_t len;
1822     void *arg;
1823     int ret;
1824     u16 cmd;
1825 };
1826 
1827 /* ******************************************************************** */
1828 /* WSM TX buffer access                         */
1829 
1830 int wsm_get_tx(struct cw1200_common *priv, u8 **data,
1831            size_t *tx_len, int *burst);
1832 void wsm_txed(struct cw1200_common *priv, u8 *data);
1833 
1834 /* ******************************************************************** */
1835 /* Queue mapping: WSM <---> linux                   */
1836 /* Linux: VO VI BE BK                           */
1837 /* WSM:   BE BK VI VO                           */
1838 
1839 static inline u8 wsm_queue_id_to_linux(u8 queue_id)
1840 {
1841     static const u8 queue_mapping[] = {
1842         2, 3, 1, 0
1843     };
1844     return queue_mapping[queue_id];
1845 }
1846 
1847 static inline u8 wsm_queue_id_to_wsm(u8 queue_id)
1848 {
1849     static const u8 queue_mapping[] = {
1850         3, 2, 0, 1
1851     };
1852     return queue_mapping[queue_id];
1853 }
1854 
1855 #endif /* CW1200_HWIO_H_INCLUDED */