Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (c) 2008-2011 Atheros Communications Inc.
0003  *
0004  * Permission to use, copy, modify, and/or distribute this software for any
0005  * purpose with or without fee is hereby granted, provided that the above
0006  * copyright notice and this permission notice appear in all copies.
0007  *
0008  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
0009  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
0010  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
0011  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
0012  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
0013  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
0014  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
0015  */
0016 
0017 #ifndef MAC_H
0018 #define MAC_H
0019 #include <net/cfg80211.h>
0020 
0021 #define set11nTries(_series, _index) \
0022     (SM((_series)[_index].Tries, AR_XmitDataTries##_index))
0023 
0024 #define set11nRate(_series, _index) \
0025     (SM((_series)[_index].Rate, AR_XmitRate##_index))
0026 
0027 #define set11nPktDurRTSCTS(_series, _index)             \
0028     (SM((_series)[_index].PktDuration, AR_PacketDur##_index) |  \
0029      ((_series)[_index].RateFlags & ATH9K_RATESERIES_RTS_CTS   ?    \
0030       AR_RTSCTSQual##_index : 0))
0031 
0032 #define set11nRateFlags(_series, _index)                \
0033     (((_series)[_index].RateFlags & ATH9K_RATESERIES_2040 ?     \
0034       AR_2040_##_index : 0)                     \
0035      |((_series)[_index].RateFlags & ATH9K_RATESERIES_HALFGI ?  \
0036        AR_GI##_index : 0)                       \
0037      |((_series)[_index].RateFlags & ATH9K_RATESERIES_STBC ?    \
0038        AR_STBC##_index : 0))
0039 
0040 #define set11nChainSel(_series, _index)                 \
0041     (SM((_series)[_index].ChSel, AR_ChainSel##_index))
0042 
0043 #define CCK_SIFS_TIME        10
0044 #define CCK_PREAMBLE_BITS   144
0045 #define CCK_PLCP_BITS        48
0046 
0047 #define OFDM_SIFS_TIME        16
0048 #define OFDM_PREAMBLE_TIME    20
0049 #define OFDM_PLCP_BITS        22
0050 #define OFDM_SYMBOL_TIME      4
0051 
0052 #define OFDM_SIFS_TIME_HALF     32
0053 #define OFDM_PREAMBLE_TIME_HALF 40
0054 #define OFDM_PLCP_BITS_HALF     22
0055 #define OFDM_SYMBOL_TIME_HALF   8
0056 
0057 #define OFDM_SIFS_TIME_QUARTER      64
0058 #define OFDM_PREAMBLE_TIME_QUARTER  80
0059 #define OFDM_PLCP_BITS_QUARTER      22
0060 #define OFDM_SYMBOL_TIME_QUARTER    16
0061 
0062 #define INIT_AIFS       2
0063 #define INIT_CWMIN      15
0064 #define INIT_CWMIN_11B  31
0065 #define INIT_CWMAX      1023
0066 #define INIT_SH_RETRY   10
0067 #define INIT_LG_RETRY   10
0068 #define INIT_SSH_RETRY  32
0069 #define INIT_SLG_RETRY  32
0070 
0071 #define ATH9K_TXERR_XRETRY         0x01
0072 #define ATH9K_TXERR_FILT           0x02
0073 #define ATH9K_TXERR_FIFO           0x04
0074 #define ATH9K_TXERR_XTXOP          0x08
0075 #define ATH9K_TXERR_TIMER_EXPIRED  0x10
0076 #define ATH9K_TX_ACKED         0x20
0077 #define ATH9K_TX_FLUSH         0x40
0078 #define ATH9K_TXERR_MASK                        \
0079     (ATH9K_TXERR_XRETRY | ATH9K_TXERR_FILT | ATH9K_TXERR_FIFO | \
0080      ATH9K_TXERR_XTXOP | ATH9K_TXERR_TIMER_EXPIRED | ATH9K_TX_FLUSH)
0081 
0082 #define ATH9K_TX_BA                0x01
0083 #define ATH9K_TX_PWRMGMT           0x02
0084 #define ATH9K_TX_DESC_CFG_ERR      0x04
0085 #define ATH9K_TX_DATA_UNDERRUN     0x08
0086 #define ATH9K_TX_DELIM_UNDERRUN    0x10
0087 #define ATH9K_TX_SW_FILTERED       0x80
0088 
0089 /* 64 bytes */
0090 #define MIN_TX_FIFO_THRESHOLD   0x1
0091 
0092 /*
0093  * Single stream device AR9285 and AR9271 require 2 KB
0094  * to work around a hardware issue, all other devices
0095  * have can use the max 4 KB limit.
0096  */
0097 #define MAX_TX_FIFO_THRESHOLD   ((4096 / 64) - 1)
0098 
0099 struct ath_tx_status {
0100     u32 ts_tstamp;
0101     u16 ts_seqnum;
0102     u8 ts_status;
0103     u8 ts_rateindex;
0104     int8_t ts_rssi;
0105     u8 ts_shortretry;
0106     u8 ts_longretry;
0107     u8 ts_virtcol;
0108     u8 ts_flags;
0109     int8_t ts_rssi_ctl0;
0110     int8_t ts_rssi_ctl1;
0111     int8_t ts_rssi_ctl2;
0112     int8_t ts_rssi_ext0;
0113     int8_t ts_rssi_ext1;
0114     int8_t ts_rssi_ext2;
0115     u8 qid;
0116     u16 desc_id;
0117     u8 tid;
0118     u32 ba_low;
0119     u32 ba_high;
0120     u32 evm0;
0121     u32 evm1;
0122     u32 evm2;
0123     u32 duration;
0124 };
0125 
0126 struct ath_rx_status {
0127     u32 rs_tstamp;
0128     u16 rs_datalen;
0129     u8 rs_status;
0130     u8 rs_phyerr;
0131     int8_t rs_rssi;
0132     u8 rs_keyix;
0133     u8 rs_rate;
0134     u8 rs_antenna;
0135     u8 rs_more;
0136     int8_t rs_rssi_ctl[3];
0137     int8_t rs_rssi_ext[3];
0138     u8 rs_isaggr;
0139     u8 rs_firstaggr;
0140     u8 rs_moreaggr;
0141     u8 rs_num_delims;
0142     u8 rs_flags;
0143     bool is_mybeacon;
0144     u32 evm0;
0145     u32 evm1;
0146     u32 evm2;
0147     u32 evm3;
0148     u32 evm4;
0149     u16 enc_flags;
0150     enum rate_info_bw bw;
0151 };
0152 
0153 struct ath_htc_rx_status {
0154     __be64 rs_tstamp;
0155     __be16 rs_datalen;
0156     u8 rs_status;
0157     u8 rs_phyerr;
0158     int8_t rs_rssi;
0159     int8_t rs_rssi_ctl[3];
0160     int8_t rs_rssi_ext[3];
0161     u8 rs_keyix;
0162     u8 rs_rate;
0163     u8 rs_antenna;
0164     u8 rs_more;
0165     u8 rs_isaggr;
0166     u8 rs_moreaggr;
0167     u8 rs_num_delims;
0168     u8 rs_flags;
0169     u8 rs_dummy;
0170     /* FIXME: evm* never used? */
0171     __be32 evm0;
0172     __be32 evm1;
0173     __be32 evm2;
0174 };
0175 
0176 #define ATH9K_RXERR_CRC           0x01
0177 #define ATH9K_RXERR_PHY           0x02
0178 #define ATH9K_RXERR_FIFO          0x04
0179 #define ATH9K_RXERR_DECRYPT       0x08
0180 #define ATH9K_RXERR_MIC           0x10
0181 #define ATH9K_RXERR_KEYMISS       0x20
0182 #define ATH9K_RXERR_CORRUPT_DESC  0x40
0183 
0184 #define ATH9K_RX_MORE             0x01
0185 #define ATH9K_RX_MORE_AGGR        0x02
0186 #define ATH9K_RX_GI               0x04
0187 #define ATH9K_RX_2040             0x08
0188 #define ATH9K_RX_DELIM_CRC_PRE    0x10
0189 #define ATH9K_RX_DELIM_CRC_POST   0x20
0190 #define ATH9K_RX_DECRYPT_BUSY     0x40
0191 
0192 #define ATH9K_RXKEYIX_INVALID   ((u8)-1)
0193 #define ATH9K_TXKEYIX_INVALID   ((u8)-1)
0194 
0195 enum ath9k_phyerr {
0196     ATH9K_PHYERR_UNDERRUN             = 0,  /* Transmit underrun */
0197     ATH9K_PHYERR_TIMING               = 1,  /* Timing error */
0198     ATH9K_PHYERR_PARITY               = 2,  /* Illegal parity */
0199     ATH9K_PHYERR_RATE                 = 3,  /* Illegal rate */
0200     ATH9K_PHYERR_LENGTH               = 4,  /* Illegal length */
0201     ATH9K_PHYERR_RADAR                = 5,  /* Radar detect */
0202     ATH9K_PHYERR_SERVICE              = 6,  /* Illegal service */
0203     ATH9K_PHYERR_TOR                  = 7,  /* Transmit override receive */
0204 
0205     ATH9K_PHYERR_OFDM_TIMING          = 17,
0206     ATH9K_PHYERR_OFDM_SIGNAL_PARITY   = 18,
0207     ATH9K_PHYERR_OFDM_RATE_ILLEGAL    = 19,
0208     ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL  = 20,
0209     ATH9K_PHYERR_OFDM_POWER_DROP      = 21,
0210     ATH9K_PHYERR_OFDM_SERVICE         = 22,
0211     ATH9K_PHYERR_OFDM_RESTART         = 23,
0212 
0213     ATH9K_PHYERR_CCK_BLOCKER          = 24,
0214     ATH9K_PHYERR_CCK_TIMING           = 25,
0215     ATH9K_PHYERR_CCK_HEADER_CRC       = 26,
0216     ATH9K_PHYERR_CCK_RATE_ILLEGAL     = 27,
0217     ATH9K_PHYERR_CCK_LENGTH_ILLEGAL   = 28,
0218     ATH9K_PHYERR_CCK_POWER_DROP       = 29,
0219     ATH9K_PHYERR_CCK_SERVICE          = 30,
0220     ATH9K_PHYERR_CCK_RESTART          = 31,
0221 
0222     ATH9K_PHYERR_HT_CRC_ERROR         = 32,
0223     ATH9K_PHYERR_HT_LENGTH_ILLEGAL    = 33,
0224     ATH9K_PHYERR_HT_RATE_ILLEGAL      = 34,
0225     ATH9K_PHYERR_HT_ZLF               = 35,
0226 
0227     ATH9K_PHYERR_FALSE_RADAR_EXT      = 36,
0228     ATH9K_PHYERR_GREEN_FIELD          = 37,
0229     ATH9K_PHYERR_SPECTRAL             = 38,
0230 
0231     ATH9K_PHYERR_MAX                  = 39,
0232 };
0233 
0234 struct ath_desc {
0235     u32 ds_link;
0236     u32 ds_data;
0237     u32 ds_ctl0;
0238     u32 ds_ctl1;
0239     u32 ds_hw[20];
0240     void *ds_vdata;
0241 } __packed __aligned(4);
0242 
0243 #define ATH9K_TXDESC_NOACK      0x0002
0244 #define ATH9K_TXDESC_RTSENA     0x0004
0245 #define ATH9K_TXDESC_CTSENA     0x0008
0246 /* ATH9K_TXDESC_INTREQ forces a tx interrupt to be generated for
0247  * the descriptor its marked on.  We take a tx interrupt to reap
0248  * descriptors when the h/w hits an EOL condition or
0249  * when the descriptor is specifically marked to generate
0250  * an interrupt with this flag. Descriptors should be
0251  * marked periodically to insure timely replenishing of the
0252  * supply needed for sending frames. Defering interrupts
0253  * reduces system load and potentially allows more concurrent
0254  * work to be done but if done to aggressively can cause
0255  * senders to backup. When the hardware queue is left too
0256  * large rate control information may also be too out of
0257  * date. An Alternative for this is TX interrupt mitigation
0258  * but this needs more testing. */
0259 #define ATH9K_TXDESC_INTREQ     0x0010
0260 #define ATH9K_TXDESC_VEOL       0x0020
0261 #define ATH9K_TXDESC_EXT_ONLY       0x0040
0262 #define ATH9K_TXDESC_EXT_AND_CTL    0x0080
0263 #define ATH9K_TXDESC_VMF        0x0100
0264 #define ATH9K_TXDESC_FRAG_IS_ON     0x0200
0265 #define ATH9K_TXDESC_LOWRXCHAIN     0x0400
0266 #define ATH9K_TXDESC_LDPC       0x0800
0267 #define ATH9K_TXDESC_CLRDMASK       0x1000
0268 
0269 #define ATH9K_TXDESC_PAPRD      0x70000
0270 #define ATH9K_TXDESC_PAPRD_S        16
0271 
0272 #define ATH9K_RXDESC_INTREQ     0x0020
0273 
0274 struct ar5416_desc {
0275     u32 ds_link;
0276     u32 ds_data;
0277     u32 ds_ctl0;
0278     u32 ds_ctl1;
0279     union {
0280         struct {
0281             u32 ctl2;
0282             u32 ctl3;
0283             u32 ctl4;
0284             u32 ctl5;
0285             u32 ctl6;
0286             u32 ctl7;
0287             u32 ctl8;
0288             u32 ctl9;
0289             u32 ctl10;
0290             u32 ctl11;
0291             u32 status0;
0292             u32 status1;
0293             u32 status2;
0294             u32 status3;
0295             u32 status4;
0296             u32 status5;
0297             u32 status6;
0298             u32 status7;
0299             u32 status8;
0300             u32 status9;
0301         } tx;
0302         struct {
0303             u32 status0;
0304             u32 status1;
0305             u32 status2;
0306             u32 status3;
0307             u32 status4;
0308             u32 status5;
0309             u32 status6;
0310             u32 status7;
0311             u32 status8;
0312         } rx;
0313     } u;
0314 } __packed __aligned(4);
0315 
0316 #define AR5416DESC(_ds)         ((struct ar5416_desc *)(_ds))
0317 #define AR5416DESC_CONST(_ds)   ((const struct ar5416_desc *)(_ds))
0318 
0319 #define ds_ctl2     u.tx.ctl2
0320 #define ds_ctl3     u.tx.ctl3
0321 #define ds_ctl4     u.tx.ctl4
0322 #define ds_ctl5     u.tx.ctl5
0323 #define ds_ctl6     u.tx.ctl6
0324 #define ds_ctl7     u.tx.ctl7
0325 #define ds_ctl8     u.tx.ctl8
0326 #define ds_ctl9     u.tx.ctl9
0327 #define ds_ctl10    u.tx.ctl10
0328 #define ds_ctl11    u.tx.ctl11
0329 
0330 #define ds_txstatus0    u.tx.status0
0331 #define ds_txstatus1    u.tx.status1
0332 #define ds_txstatus2    u.tx.status2
0333 #define ds_txstatus3    u.tx.status3
0334 #define ds_txstatus4    u.tx.status4
0335 #define ds_txstatus5    u.tx.status5
0336 #define ds_txstatus6    u.tx.status6
0337 #define ds_txstatus7    u.tx.status7
0338 #define ds_txstatus8    u.tx.status8
0339 #define ds_txstatus9    u.tx.status9
0340 
0341 #define ds_rxstatus0    u.rx.status0
0342 #define ds_rxstatus1    u.rx.status1
0343 #define ds_rxstatus2    u.rx.status2
0344 #define ds_rxstatus3    u.rx.status3
0345 #define ds_rxstatus4    u.rx.status4
0346 #define ds_rxstatus5    u.rx.status5
0347 #define ds_rxstatus6    u.rx.status6
0348 #define ds_rxstatus7    u.rx.status7
0349 #define ds_rxstatus8    u.rx.status8
0350 
0351 #define AR_FrameLen         0x00000fff
0352 #define AR_VirtMoreFrag     0x00001000
0353 #define AR_TxCtlRsvd00      0x0000e000
0354 #define AR_XmitPower0       0x003f0000
0355 #define AR_XmitPower0_S     16
0356 #define AR_XmitPower1       0x3f000000
0357 #define AR_XmitPower1_S     24
0358 #define AR_XmitPower2       0x3f000000
0359 #define AR_XmitPower2_S     24
0360 #define AR_XmitPower3       0x3f000000
0361 #define AR_XmitPower3_S     24
0362 #define AR_RTSEnable        0x00400000
0363 #define AR_VEOL             0x00800000
0364 #define AR_ClrDestMask      0x01000000
0365 #define AR_TxCtlRsvd01      0x1e000000
0366 #define AR_TxIntrReq        0x20000000
0367 #define AR_DestIdxValid     0x40000000
0368 #define AR_CTSEnable        0x80000000
0369 
0370 #define AR_TxMore           0x00001000
0371 #define AR_DestIdx          0x000fe000
0372 #define AR_DestIdx_S        13
0373 #define AR_FrameType        0x00f00000
0374 #define AR_FrameType_S      20
0375 #define AR_NoAck            0x01000000
0376 #define AR_InsertTS         0x02000000
0377 #define AR_CorruptFCS       0x04000000
0378 #define AR_ExtOnly          0x08000000
0379 #define AR_ExtAndCtl        0x10000000
0380 #define AR_MoreAggr         0x20000000
0381 #define AR_IsAggr           0x40000000
0382 
0383 #define AR_BurstDur         0x00007fff
0384 #define AR_BurstDur_S       0
0385 #define AR_DurUpdateEna     0x00008000
0386 #define AR_XmitDataTries0   0x000f0000
0387 #define AR_XmitDataTries0_S 16
0388 #define AR_XmitDataTries1   0x00f00000
0389 #define AR_XmitDataTries1_S 20
0390 #define AR_XmitDataTries2   0x0f000000
0391 #define AR_XmitDataTries2_S 24
0392 #define AR_XmitDataTries3   0xf0000000
0393 #define AR_XmitDataTries3_S 28
0394 
0395 #define AR_XmitRate0        0x000000ff
0396 #define AR_XmitRate0_S      0
0397 #define AR_XmitRate1        0x0000ff00
0398 #define AR_XmitRate1_S      8
0399 #define AR_XmitRate2        0x00ff0000
0400 #define AR_XmitRate2_S      16
0401 #define AR_XmitRate3        0xff000000
0402 #define AR_XmitRate3_S      24
0403 
0404 #define AR_PacketDur0       0x00007fff
0405 #define AR_PacketDur0_S     0
0406 #define AR_RTSCTSQual0      0x00008000
0407 #define AR_PacketDur1       0x7fff0000
0408 #define AR_PacketDur1_S     16
0409 #define AR_RTSCTSQual1      0x80000000
0410 
0411 #define AR_PacketDur2       0x00007fff
0412 #define AR_PacketDur2_S     0
0413 #define AR_RTSCTSQual2      0x00008000
0414 #define AR_PacketDur3       0x7fff0000
0415 #define AR_PacketDur3_S     16
0416 #define AR_RTSCTSQual3      0x80000000
0417 
0418 #define AR_AggrLen          0x0000ffff
0419 #define AR_AggrLen_S        0
0420 #define AR_TxCtlRsvd60      0x00030000
0421 #define AR_PadDelim         0x03fc0000
0422 #define AR_PadDelim_S       18
0423 #define AR_EncrType         0x0c000000
0424 #define AR_EncrType_S       26
0425 #define AR_TxCtlRsvd61      0xf0000000
0426 #define AR_LDPC             0x80000000
0427 
0428 #define AR_2040_0           0x00000001
0429 #define AR_GI0              0x00000002
0430 #define AR_ChainSel0        0x0000001c
0431 #define AR_ChainSel0_S      2
0432 #define AR_2040_1           0x00000020
0433 #define AR_GI1              0x00000040
0434 #define AR_ChainSel1        0x00000380
0435 #define AR_ChainSel1_S      7
0436 #define AR_2040_2           0x00000400
0437 #define AR_GI2              0x00000800
0438 #define AR_ChainSel2        0x00007000
0439 #define AR_ChainSel2_S      12
0440 #define AR_2040_3           0x00008000
0441 #define AR_GI3              0x00010000
0442 #define AR_ChainSel3        0x000e0000
0443 #define AR_ChainSel3_S      17
0444 #define AR_RTSCTSRate       0x0ff00000
0445 #define AR_RTSCTSRate_S     20
0446 #define AR_STBC0            0x10000000
0447 #define AR_STBC1            0x20000000
0448 #define AR_STBC2            0x40000000
0449 #define AR_STBC3            0x80000000
0450 
0451 #define AR_TxRSSIAnt00      0x000000ff
0452 #define AR_TxRSSIAnt00_S    0
0453 #define AR_TxRSSIAnt01      0x0000ff00
0454 #define AR_TxRSSIAnt01_S    8
0455 #define AR_TxRSSIAnt02      0x00ff0000
0456 #define AR_TxRSSIAnt02_S    16
0457 #define AR_TxStatusRsvd00   0x3f000000
0458 #define AR_TxBaStatus       0x40000000
0459 #define AR_TxStatusRsvd01   0x80000000
0460 
0461 /*
0462  * AR_FrmXmitOK - Frame transmission success flag. If set, the frame was
0463  * transmitted successfully. If clear, no ACK or BA was received to indicate
0464  * successful transmission when we were expecting an ACK or BA.
0465  */
0466 #define AR_FrmXmitOK            0x00000001
0467 #define AR_ExcessiveRetries     0x00000002
0468 #define AR_FIFOUnderrun         0x00000004
0469 #define AR_Filtered             0x00000008
0470 #define AR_RTSFailCnt           0x000000f0
0471 #define AR_RTSFailCnt_S         4
0472 #define AR_DataFailCnt          0x00000f00
0473 #define AR_DataFailCnt_S        8
0474 #define AR_VirtRetryCnt         0x0000f000
0475 #define AR_VirtRetryCnt_S       12
0476 #define AR_TxDelimUnderrun      0x00010000
0477 #define AR_TxDataUnderrun       0x00020000
0478 #define AR_DescCfgErr           0x00040000
0479 #define AR_TxTimerExpired       0x00080000
0480 #define AR_TxStatusRsvd10       0xfff00000
0481 
0482 #define AR_SendTimestamp    ds_txstatus2
0483 #define AR_BaBitmapLow      ds_txstatus3
0484 #define AR_BaBitmapHigh     ds_txstatus4
0485 
0486 #define AR_TxRSSIAnt10      0x000000ff
0487 #define AR_TxRSSIAnt10_S    0
0488 #define AR_TxRSSIAnt11      0x0000ff00
0489 #define AR_TxRSSIAnt11_S    8
0490 #define AR_TxRSSIAnt12      0x00ff0000
0491 #define AR_TxRSSIAnt12_S    16
0492 #define AR_TxRSSICombined   0xff000000
0493 #define AR_TxRSSICombined_S 24
0494 
0495 #define AR_TxTid    0xf0000000
0496 #define AR_TxTid_S  28
0497 
0498 #define AR_TxEVM0           ds_txstatus5
0499 #define AR_TxEVM1           ds_txstatus6
0500 #define AR_TxEVM2           ds_txstatus7
0501 
0502 #define AR_TxDone           0x00000001
0503 #define AR_SeqNum           0x00001ffe
0504 #define AR_SeqNum_S         1
0505 #define AR_TxStatusRsvd80   0x0001e000
0506 #define AR_TxOpExceeded     0x00020000
0507 #define AR_TxStatusRsvd81   0x001c0000
0508 #define AR_FinalTxIdx       0x00600000
0509 #define AR_FinalTxIdx_S     21
0510 #define AR_TxStatusRsvd82   0x01800000
0511 #define AR_PowerMgmt        0x02000000
0512 #define AR_TxStatusRsvd83   0xfc000000
0513 
0514 #define AR_RxCTLRsvd00  0xffffffff
0515 
0516 #define AR_RxCtlRsvd00  0x00001000
0517 #define AR_RxIntrReq    0x00002000
0518 #define AR_RxCtlRsvd01  0xffffc000
0519 
0520 #define AR_RxRSSIAnt00      0x000000ff
0521 #define AR_RxRSSIAnt00_S    0
0522 #define AR_RxRSSIAnt01      0x0000ff00
0523 #define AR_RxRSSIAnt01_S    8
0524 #define AR_RxRSSIAnt02      0x00ff0000
0525 #define AR_RxRSSIAnt02_S    16
0526 #define AR_RxRate           0xff000000
0527 #define AR_RxRate_S         24
0528 #define AR_RxStatusRsvd00   0xff000000
0529 
0530 #define AR_DataLen          0x00000fff
0531 #define AR_RxMore           0x00001000
0532 #define AR_NumDelim         0x003fc000
0533 #define AR_NumDelim_S       14
0534 #define AR_RxStatusRsvd10   0xff800000
0535 
0536 #define AR_RcvTimestamp     ds_rxstatus2
0537 
0538 #define AR_GI               0x00000001
0539 #define AR_2040             0x00000002
0540 #define AR_Parallel40       0x00000004
0541 #define AR_Parallel40_S     2
0542 #define AR_STBC             0x00000008 /* on ar9280 and later */
0543 #define AR_RxStatusRsvd30   0x000000f0
0544 #define AR_RxAntenna        0xffffff00
0545 #define AR_RxAntenna_S      8
0546 
0547 #define AR_RxRSSIAnt10            0x000000ff
0548 #define AR_RxRSSIAnt10_S          0
0549 #define AR_RxRSSIAnt11            0x0000ff00
0550 #define AR_RxRSSIAnt11_S          8
0551 #define AR_RxRSSIAnt12            0x00ff0000
0552 #define AR_RxRSSIAnt12_S          16
0553 #define AR_RxRSSICombined         0xff000000
0554 #define AR_RxRSSICombined_S       24
0555 
0556 #define AR_RxEVM0           ds_rxstatus4
0557 #define AR_RxEVM1           ds_rxstatus5
0558 #define AR_RxEVM2           ds_rxstatus6
0559 
0560 #define AR_RxDone           0x00000001
0561 #define AR_RxFrameOK        0x00000002
0562 #define AR_CRCErr           0x00000004
0563 #define AR_DecryptCRCErr    0x00000008
0564 #define AR_PHYErr           0x00000010
0565 #define AR_MichaelErr       0x00000020
0566 #define AR_PreDelimCRCErr   0x00000040
0567 #define AR_RxStatusRsvd70   0x00000080
0568 #define AR_RxKeyIdxValid    0x00000100
0569 #define AR_KeyIdx           0x0000fe00
0570 #define AR_KeyIdx_S         9
0571 #define AR_PHYErrCode       0x0000ff00
0572 #define AR_PHYErrCode_S     8
0573 #define AR_RxMoreAggr       0x00010000
0574 #define AR_RxAggr           0x00020000
0575 #define AR_PostDelimCRCErr  0x00040000
0576 #define AR_RxStatusRsvd71   0x3ff80000
0577 #define AR_RxFirstAggr      0x20000000
0578 #define AR_DecryptBusyErr   0x40000000
0579 #define AR_KeyMiss          0x80000000
0580 
0581 enum ath9k_tx_queue {
0582     ATH9K_TX_QUEUE_INACTIVE = 0,
0583     ATH9K_TX_QUEUE_DATA,
0584     ATH9K_TX_QUEUE_BEACON,
0585     ATH9K_TX_QUEUE_CAB,
0586     ATH9K_TX_QUEUE_UAPSD,
0587     ATH9K_TX_QUEUE_PSPOLL
0588 };
0589 
0590 #define ATH9K_NUM_TX_QUEUES 10
0591 
0592 /* Used as a queue subtype instead of a WMM AC */
0593 #define ATH9K_WME_UPSD  4
0594 
0595 enum ath9k_tx_queue_flags {
0596     TXQ_FLAG_TXINT_ENABLE = 0x0001,
0597     TXQ_FLAG_TXDESCINT_ENABLE = 0x0002,
0598     TXQ_FLAG_TXEOLINT_ENABLE = 0x0004,
0599     TXQ_FLAG_TXURNINT_ENABLE = 0x0008,
0600     TXQ_FLAG_BACKOFF_DISABLE = 0x0010,
0601     TXQ_FLAG_COMPRESSION_ENABLE = 0x0020,
0602     TXQ_FLAG_RDYTIME_EXP_POLICY_ENABLE = 0x0040,
0603     TXQ_FLAG_FRAG_BURST_BACKOFF_ENABLE = 0x0080,
0604 };
0605 
0606 #define ATH9K_TXQ_USEDEFAULT ((u32) -1)
0607 #define ATH9K_TXQ_USE_LOCKOUT_BKOFF_DIS 0x00000001
0608 
0609 #define ATH9K_DECOMP_MASK_SIZE     128
0610 
0611 enum ath9k_pkt_type {
0612     ATH9K_PKT_TYPE_NORMAL = 0,
0613     ATH9K_PKT_TYPE_ATIM,
0614     ATH9K_PKT_TYPE_PSPOLL,
0615     ATH9K_PKT_TYPE_BEACON,
0616     ATH9K_PKT_TYPE_PROBE_RESP,
0617     ATH9K_PKT_TYPE_CHIRP,
0618     ATH9K_PKT_TYPE_GRP_POLL,
0619 };
0620 
0621 struct ath9k_tx_queue_info {
0622     u32 tqi_ver;
0623     enum ath9k_tx_queue tqi_type;
0624     int tqi_subtype;
0625     enum ath9k_tx_queue_flags tqi_qflags;
0626     u32 tqi_priority;
0627     u32 tqi_aifs;
0628     u32 tqi_cwmin;
0629     u32 tqi_cwmax;
0630     u16 tqi_shretry;
0631     u16 tqi_lgretry;
0632     u32 tqi_cbrPeriod;
0633     u32 tqi_cbrOverflowLimit;
0634     u32 tqi_burstTime;
0635     u32 tqi_readyTime;
0636     u32 tqi_physCompBuf;
0637     u32 tqi_intFlags;
0638 };
0639 
0640 enum ath9k_rx_filter {
0641     ATH9K_RX_FILTER_UCAST = 0x00000001,
0642     ATH9K_RX_FILTER_MCAST = 0x00000002,
0643     ATH9K_RX_FILTER_BCAST = 0x00000004,
0644     ATH9K_RX_FILTER_CONTROL = 0x00000008,
0645     ATH9K_RX_FILTER_BEACON = 0x00000010,
0646     ATH9K_RX_FILTER_PROM = 0x00000020,
0647     ATH9K_RX_FILTER_PROBEREQ = 0x00000080,
0648     ATH9K_RX_FILTER_PHYERR = 0x00000100,
0649     ATH9K_RX_FILTER_MYBEACON = 0x00000200,
0650     ATH9K_RX_FILTER_COMP_BAR = 0x00000400,
0651     ATH9K_RX_FILTER_COMP_BA = 0x00000800,
0652     ATH9K_RX_FILTER_UNCOMP_BA_BAR = 0x00001000,
0653     ATH9K_RX_FILTER_PSPOLL = 0x00004000,
0654     ATH9K_RX_FILTER_PHYRADAR = 0x00002000,
0655     ATH9K_RX_FILTER_MCAST_BCAST_ALL = 0x00008000,
0656     ATH9K_RX_FILTER_CONTROL_WRAPPER = 0x00080000,
0657     ATH9K_RX_FILTER_4ADDRESS = 0x00100000,
0658 };
0659 
0660 #define ATH9K_RATESERIES_RTS_CTS  0x0001
0661 #define ATH9K_RATESERIES_2040     0x0002
0662 #define ATH9K_RATESERIES_HALFGI   0x0004
0663 #define ATH9K_RATESERIES_STBC     0x0008
0664 
0665 struct ath9k_11n_rate_series {
0666     u32 Tries;
0667     u32 Rate;
0668     u32 PktDuration;
0669     u32 ChSel;
0670     u32 RateFlags;
0671 };
0672 
0673 enum aggr_type {
0674     AGGR_BUF_NONE,
0675     AGGR_BUF_FIRST,
0676     AGGR_BUF_MIDDLE,
0677     AGGR_BUF_LAST,
0678 };
0679 
0680 enum ath9k_key_type {
0681     ATH9K_KEY_TYPE_CLEAR,
0682     ATH9K_KEY_TYPE_WEP,
0683     ATH9K_KEY_TYPE_AES,
0684     ATH9K_KEY_TYPE_TKIP,
0685 };
0686 
0687 struct ath_tx_info {
0688     u8 qcu;
0689 
0690     bool is_first;
0691     bool is_last;
0692 
0693     enum aggr_type aggr;
0694     u8 ndelim;
0695     u16 aggr_len;
0696 
0697     dma_addr_t link;
0698     int pkt_len;
0699     u32 flags;
0700 
0701     dma_addr_t buf_addr[4];
0702     int buf_len[4];
0703 
0704     struct ath9k_11n_rate_series rates[4];
0705     u8 rtscts_rate;
0706     bool dur_update;
0707 
0708     enum ath9k_pkt_type type;
0709     enum ath9k_key_type keytype;
0710     u8 keyix;
0711     u8 txpower[4];
0712 };
0713 
0714 struct ath_hw;
0715 struct ath9k_channel;
0716 enum ath9k_int;
0717 
0718 u32 ath9k_hw_gettxbuf(struct ath_hw *ah, u32 q);
0719 void ath9k_hw_puttxbuf(struct ath_hw *ah, u32 q, u32 txdp);
0720 void ath9k_hw_txstart(struct ath_hw *ah, u32 q);
0721 u32 ath9k_hw_numtxpending(struct ath_hw *ah, u32 q);
0722 bool ath9k_hw_updatetxtriglevel(struct ath_hw *ah, bool bIncTrigLevel);
0723 bool ath9k_hw_stop_dma_queue(struct ath_hw *ah, u32 q);
0724 void ath9k_hw_abort_tx_dma(struct ath_hw *ah);
0725 bool ath9k_hw_set_txq_props(struct ath_hw *ah, int q,
0726                 const struct ath9k_tx_queue_info *qinfo);
0727 bool ath9k_hw_get_txq_props(struct ath_hw *ah, int q,
0728                 struct ath9k_tx_queue_info *qinfo);
0729 int ath9k_hw_setuptxqueue(struct ath_hw *ah, enum ath9k_tx_queue type,
0730               const struct ath9k_tx_queue_info *qinfo);
0731 bool ath9k_hw_releasetxqueue(struct ath_hw *ah, u32 q);
0732 bool ath9k_hw_resettxqueue(struct ath_hw *ah, u32 q);
0733 int ath9k_hw_rxprocdesc(struct ath_hw *ah, struct ath_desc *ds,
0734             struct ath_rx_status *rs);
0735 void ath9k_hw_setuprxdesc(struct ath_hw *ah, struct ath_desc *ds,
0736               u32 size, u32 flags);
0737 bool ath9k_hw_setrxabort(struct ath_hw *ah, bool set);
0738 void ath9k_hw_putrxbuf(struct ath_hw *ah, u32 rxdp);
0739 void ath9k_hw_startpcureceive(struct ath_hw *ah, bool is_scanning);
0740 void ath9k_hw_abortpcurecv(struct ath_hw *ah);
0741 bool ath9k_hw_stopdmarecv(struct ath_hw *ah, bool *reset);
0742 int ath9k_hw_beaconq_setup(struct ath_hw *ah);
0743 void ath9k_hw_set_tx_filter(struct ath_hw *ah, u8 destidx, bool set);
0744 
0745 /* Interrupt Handling */
0746 bool ath9k_hw_intrpend(struct ath_hw *ah);
0747 void ath9k_hw_set_interrupts(struct ath_hw *ah);
0748 void ath9k_hw_enable_interrupts(struct ath_hw *ah);
0749 void ath9k_hw_disable_interrupts(struct ath_hw *ah);
0750 void ath9k_hw_kill_interrupts(struct ath_hw *ah);
0751 void ath9k_hw_resume_interrupts(struct ath_hw *ah);
0752 
0753 void ar9002_hw_attach_mac_ops(struct ath_hw *ah);
0754 
0755 #endif /* MAC_H */