Path: blob/main/sys/dev/ath/ath_hal/ar5211/ar5211_xmit.c
39566 views
/*-1* SPDX-License-Identifier: ISC2*3* Copyright (c) 2002-2009 Sam Leffler, Errno Consulting4* Copyright (c) 2002-2006 Atheros Communications, Inc.5*6* Permission to use, copy, modify, and/or distribute this software for any7* purpose with or without fee is hereby granted, provided that the above8* copyright notice and this permission notice appear in all copies.9*10* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES11* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF12* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR13* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES14* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN15* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF16* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.17*/18#include "opt_ah.h"1920#include "ah.h"21#include "ah_internal.h"22#include "ah_desc.h"2324#include "ar5211/ar5211.h"25#include "ar5211/ar5211reg.h"26#include "ar5211/ar5211desc.h"2728/*29* Update Tx FIFO trigger level.30*31* Set bIncTrigLevel to TRUE to increase the trigger level.32* Set bIncTrigLevel to FALSE to decrease the trigger level.33*34* Returns TRUE if the trigger level was updated35*/36HAL_BOOL37ar5211UpdateTxTrigLevel(struct ath_hal *ah, HAL_BOOL bIncTrigLevel)38{39uint32_t curTrigLevel, txcfg;40HAL_INT ints = ar5211GetInterrupts(ah);4142/*43* Disable chip interrupts. This is because halUpdateTxTrigLevel44* is called from both ISR and non-ISR contexts.45*/46ar5211SetInterrupts(ah, ints &~ HAL_INT_GLOBAL);47txcfg = OS_REG_READ(ah, AR_TXCFG);48curTrigLevel = (txcfg & AR_TXCFG_FTRIG_M) >> AR_TXCFG_FTRIG_S;49if (bIncTrigLevel){50/* increase the trigger level */51curTrigLevel = curTrigLevel +52((MAX_TX_FIFO_THRESHOLD - curTrigLevel) / 2);53} else {54/* decrease the trigger level if not already at the minimum */55if (curTrigLevel > MIN_TX_FIFO_THRESHOLD) {56/* decrease the trigger level */57curTrigLevel--;58} else {59/* no update to the trigger level */60/* re-enable chip interrupts */61ar5211SetInterrupts(ah, ints);62return AH_FALSE;63}64}65/* Update the trigger level */66OS_REG_WRITE(ah, AR_TXCFG, (txcfg &~ AR_TXCFG_FTRIG_M) |67((curTrigLevel << AR_TXCFG_FTRIG_S) & AR_TXCFG_FTRIG_M));68/* re-enable chip interrupts */69ar5211SetInterrupts(ah, ints);70return AH_TRUE;71}7273/*74* Set the properties of the tx queue with the parameters75* from qInfo. The queue must previously have been setup76* with a call to ar5211SetupTxQueue.77*/78HAL_BOOL79ar5211SetTxQueueProps(struct ath_hal *ah, int q, const HAL_TXQ_INFO *qInfo)80{81struct ath_hal_5211 *ahp = AH5211(ah);8283if (q >= HAL_NUM_TX_QUEUES) {84HALDEBUG(ah, HAL_DEBUG_ANY, "%s: invalid queue num %u\n",85__func__, q);86return AH_FALSE;87}88return ath_hal_setTxQProps(ah, &ahp->ah_txq[q], qInfo);89}9091/*92* Return the properties for the specified tx queue.93*/94HAL_BOOL95ar5211GetTxQueueProps(struct ath_hal *ah, int q, HAL_TXQ_INFO *qInfo)96{97struct ath_hal_5211 *ahp = AH5211(ah);9899if (q >= HAL_NUM_TX_QUEUES) {100HALDEBUG(ah, HAL_DEBUG_ANY, "%s: invalid queue num %u\n",101__func__, q);102return AH_FALSE;103}104return ath_hal_getTxQProps(ah, qInfo, &ahp->ah_txq[q]);105}106107/*108* Allocate and initialize a tx DCU/QCU combination.109*/110int111ar5211SetupTxQueue(struct ath_hal *ah, HAL_TX_QUEUE type,112const HAL_TXQ_INFO *qInfo)113{114struct ath_hal_5211 *ahp = AH5211(ah);115HAL_TX_QUEUE_INFO *qi;116int q;117118switch (type) {119case HAL_TX_QUEUE_BEACON:120q = 9;121break;122case HAL_TX_QUEUE_CAB:123q = 8;124break;125case HAL_TX_QUEUE_DATA:126q = 0;127if (ahp->ah_txq[q].tqi_type != HAL_TX_QUEUE_INACTIVE)128return q;129break;130default:131HALDEBUG(ah, HAL_DEBUG_ANY, "%s: bad tx queue type %u\n",132__func__, type);133return -1;134}135136HALDEBUG(ah, HAL_DEBUG_TXQUEUE, "%s: queue %u\n", __func__, q);137138qi = &ahp->ah_txq[q];139if (qi->tqi_type != HAL_TX_QUEUE_INACTIVE) {140HALDEBUG(ah, HAL_DEBUG_ANY, "%s: tx queue %u already active\n",141__func__, q);142return -1;143}144OS_MEMZERO(qi, sizeof(HAL_TX_QUEUE_INFO));145qi->tqi_type = type;146if (qInfo == AH_NULL) {147/* by default enable OK+ERR+DESC+URN interrupts */148qi->tqi_qflags =149HAL_TXQ_TXOKINT_ENABLE150| HAL_TXQ_TXERRINT_ENABLE151| HAL_TXQ_TXDESCINT_ENABLE152| HAL_TXQ_TXURNINT_ENABLE153;154qi->tqi_aifs = INIT_AIFS;155qi->tqi_cwmin = HAL_TXQ_USEDEFAULT; /* NB: do at reset */156qi->tqi_cwmax = INIT_CWMAX;157qi->tqi_shretry = INIT_SH_RETRY;158qi->tqi_lgretry = INIT_LG_RETRY;159} else160(void) ar5211SetTxQueueProps(ah, q, qInfo);161return q;162}163164/*165* Update the h/w interrupt registers to reflect a tx q's configuration.166*/167static void168setTxQInterrupts(struct ath_hal *ah, HAL_TX_QUEUE_INFO *qi)169{170struct ath_hal_5211 *ahp = AH5211(ah);171172HALDEBUG(ah, HAL_DEBUG_TXQUEUE,173"%s: tx ok 0x%x err 0x%x desc 0x%x eol 0x%x urn 0x%x\n", __func__174, ahp->ah_txOkInterruptMask175, ahp->ah_txErrInterruptMask176, ahp->ah_txDescInterruptMask177, ahp->ah_txEolInterruptMask178, ahp->ah_txUrnInterruptMask179);180181OS_REG_WRITE(ah, AR_IMR_S0,182SM(ahp->ah_txOkInterruptMask, AR_IMR_S0_QCU_TXOK)183| SM(ahp->ah_txDescInterruptMask, AR_IMR_S0_QCU_TXDESC)184);185OS_REG_WRITE(ah, AR_IMR_S1,186SM(ahp->ah_txErrInterruptMask, AR_IMR_S1_QCU_TXERR)187| SM(ahp->ah_txEolInterruptMask, AR_IMR_S1_QCU_TXEOL)188);189OS_REG_RMW_FIELD(ah, AR_IMR_S2,190AR_IMR_S2_QCU_TXURN, ahp->ah_txUrnInterruptMask);191}192193/*194* Free a tx DCU/QCU combination.195*/196HAL_BOOL197ar5211ReleaseTxQueue(struct ath_hal *ah, u_int q)198{199struct ath_hal_5211 *ahp = AH5211(ah);200HAL_TX_QUEUE_INFO *qi;201202if (q >= HAL_NUM_TX_QUEUES) {203HALDEBUG(ah, HAL_DEBUG_ANY, "%s: invalid queue num %u\n",204__func__, q);205return AH_FALSE;206}207qi = &ahp->ah_txq[q];208if (qi->tqi_type == HAL_TX_QUEUE_INACTIVE) {209HALDEBUG(ah, HAL_DEBUG_TXQUEUE, "%s: inactive queue %u\n",210__func__, q);211return AH_FALSE;212}213214HALDEBUG(ah, HAL_DEBUG_TXQUEUE, "%s: release queue %u\n", __func__, q);215216qi->tqi_type = HAL_TX_QUEUE_INACTIVE;217ahp->ah_txOkInterruptMask &= ~(1 << q);218ahp->ah_txErrInterruptMask &= ~(1 << q);219ahp->ah_txDescInterruptMask &= ~(1 << q);220ahp->ah_txEolInterruptMask &= ~(1 << q);221ahp->ah_txUrnInterruptMask &= ~(1 << q);222setTxQInterrupts(ah, qi);223224return AH_TRUE;225}226227/*228* Set the retry, aifs, cwmin/max, readyTime regs for specified queue229*/230HAL_BOOL231ar5211ResetTxQueue(struct ath_hal *ah, u_int q)232{233struct ath_hal_5211 *ahp = AH5211(ah);234const struct ieee80211_channel *chan = AH_PRIVATE(ah)->ah_curchan;235HAL_TX_QUEUE_INFO *qi;236uint32_t cwMin, chanCwMin, value;237238if (q >= HAL_NUM_TX_QUEUES) {239HALDEBUG(ah, HAL_DEBUG_ANY, "%s: invalid queue num %u\n",240__func__, q);241return AH_FALSE;242}243qi = &ahp->ah_txq[q];244if (qi->tqi_type == HAL_TX_QUEUE_INACTIVE) {245HALDEBUG(ah, HAL_DEBUG_TXQUEUE, "%s: inactive queue %u\n",246__func__, q);247return AH_TRUE; /* XXX??? */248}249250if (qi->tqi_cwmin == HAL_TXQ_USEDEFAULT) {251/*252* Select cwmin according to channel type.253* NB: chan can be NULL during attach254*/255if (chan && IEEE80211_IS_CHAN_B(chan))256chanCwMin = INIT_CWMIN_11B;257else258chanCwMin = INIT_CWMIN;259/* make sure that the CWmin is of the form (2^n - 1) */260for (cwMin = 1; cwMin < chanCwMin; cwMin = (cwMin << 1) | 1)261;262} else263cwMin = qi->tqi_cwmin;264265/* set cwMin/Max and AIFS values */266OS_REG_WRITE(ah, AR_DLCL_IFS(q),267SM(cwMin, AR_D_LCL_IFS_CWMIN)268| SM(qi->tqi_cwmax, AR_D_LCL_IFS_CWMAX)269| SM(qi->tqi_aifs, AR_D_LCL_IFS_AIFS));270271/* Set retry limit values */272OS_REG_WRITE(ah, AR_DRETRY_LIMIT(q),273SM(INIT_SSH_RETRY, AR_D_RETRY_LIMIT_STA_SH)274| SM(INIT_SLG_RETRY, AR_D_RETRY_LIMIT_STA_LG)275| SM(qi->tqi_lgretry, AR_D_RETRY_LIMIT_FR_LG)276| SM(qi->tqi_shretry, AR_D_RETRY_LIMIT_FR_SH)277);278279/* enable early termination on the QCU */280OS_REG_WRITE(ah, AR_QMISC(q), AR_Q_MISC_DCU_EARLY_TERM_REQ);281282if (AH_PRIVATE(ah)->ah_macVersion < AR_SREV_VERSION_OAHU) {283/* Configure DCU to use the global sequence count */284OS_REG_WRITE(ah, AR_DMISC(q), AR5311_D_MISC_SEQ_NUM_CONTROL);285}286/* multiqueue support */287if (qi->tqi_cbrPeriod) {288OS_REG_WRITE(ah, AR_QCBRCFG(q),289SM(qi->tqi_cbrPeriod,AR_Q_CBRCFG_CBR_INTERVAL)290| SM(qi->tqi_cbrOverflowLimit, AR_Q_CBRCFG_CBR_OVF_THRESH));291OS_REG_WRITE(ah, AR_QMISC(q),292OS_REG_READ(ah, AR_QMISC(q)) |293AR_Q_MISC_FSP_CBR |294(qi->tqi_cbrOverflowLimit ?295AR_Q_MISC_CBR_EXP_CNTR_LIMIT : 0));296}297if (qi->tqi_readyTime) {298OS_REG_WRITE(ah, AR_QRDYTIMECFG(q),299SM(qi->tqi_readyTime, AR_Q_RDYTIMECFG_INT) |300AR_Q_RDYTIMECFG_EN);301}302if (qi->tqi_burstTime) {303OS_REG_WRITE(ah, AR_DCHNTIME(q),304SM(qi->tqi_burstTime, AR_D_CHNTIME_DUR) |305AR_D_CHNTIME_EN);306if (qi->tqi_qflags & HAL_TXQ_RDYTIME_EXP_POLICY_ENABLE) {307OS_REG_WRITE(ah, AR_QMISC(q),308OS_REG_READ(ah, AR_QMISC(q)) |309AR_Q_MISC_RDYTIME_EXP_POLICY);310}311}312313if (qi->tqi_qflags & HAL_TXQ_BACKOFF_DISABLE) {314OS_REG_WRITE(ah, AR_DMISC(q),315OS_REG_READ(ah, AR_DMISC(q)) |316AR_D_MISC_POST_FR_BKOFF_DIS);317}318if (qi->tqi_qflags & HAL_TXQ_FRAG_BURST_BACKOFF_ENABLE) {319OS_REG_WRITE(ah, AR_DMISC(q),320OS_REG_READ(ah, AR_DMISC(q)) |321AR_D_MISC_FRAG_BKOFF_EN);322}323switch (qi->tqi_type) {324case HAL_TX_QUEUE_BEACON:325/* Configure QCU for beacons */326OS_REG_WRITE(ah, AR_QMISC(q),327OS_REG_READ(ah, AR_QMISC(q))328| AR_Q_MISC_FSP_DBA_GATED329| AR_Q_MISC_BEACON_USE330| AR_Q_MISC_CBR_INCR_DIS1);331/* Configure DCU for beacons */332value = (AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL << AR_D_MISC_ARB_LOCKOUT_CNTRL_S)333| AR_D_MISC_BEACON_USE | AR_D_MISC_POST_FR_BKOFF_DIS;334if (AH_PRIVATE(ah)->ah_macVersion < AR_SREV_VERSION_OAHU)335value |= AR5311_D_MISC_SEQ_NUM_CONTROL;336OS_REG_WRITE(ah, AR_DMISC(q), value);337break;338case HAL_TX_QUEUE_CAB:339/* Configure QCU for CAB (Crap After Beacon) frames */340OS_REG_WRITE(ah, AR_QMISC(q),341OS_REG_READ(ah, AR_QMISC(q))342| AR_Q_MISC_FSP_DBA_GATED | AR_Q_MISC_CBR_INCR_DIS1343| AR_Q_MISC_CBR_INCR_DIS0 | AR_Q_MISC_RDYTIME_EXP_POLICY);344345value = (ahp->ah_beaconInterval346- (ah->ah_config.ah_sw_beacon_response_time347- ah->ah_config.ah_dma_beacon_response_time)348- ah->ah_config.ah_additional_swba_backoff) * 1024;349OS_REG_WRITE(ah, AR_QRDYTIMECFG(q), value | AR_Q_RDYTIMECFG_EN);350351/* Configure DCU for CAB */352value = (AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL << AR_D_MISC_ARB_LOCKOUT_CNTRL_S);353if (AH_PRIVATE(ah)->ah_macVersion < AR_SREV_VERSION_OAHU)354value |= AR5311_D_MISC_SEQ_NUM_CONTROL;355OS_REG_WRITE(ah, AR_QMISC(q), value);356break;357default:358/* NB: silence compiler */359break;360}361362/*363* Always update the secondary interrupt mask registers - this364* could be a new queue getting enabled in a running system or365* hw getting re-initialized during a reset!366*367* Since we don't differentiate between tx interrupts corresponding368* to individual queues - secondary tx mask regs are always unmasked;369* tx interrupts are enabled/disabled for all queues collectively370* using the primary mask reg371*/372if (qi->tqi_qflags & HAL_TXQ_TXOKINT_ENABLE)373ahp->ah_txOkInterruptMask |= 1 << q;374else375ahp->ah_txOkInterruptMask &= ~(1 << q);376if (qi->tqi_qflags & HAL_TXQ_TXERRINT_ENABLE)377ahp->ah_txErrInterruptMask |= 1 << q;378else379ahp->ah_txErrInterruptMask &= ~(1 << q);380if (qi->tqi_qflags & HAL_TXQ_TXDESCINT_ENABLE)381ahp->ah_txDescInterruptMask |= 1 << q;382else383ahp->ah_txDescInterruptMask &= ~(1 << q);384if (qi->tqi_qflags & HAL_TXQ_TXEOLINT_ENABLE)385ahp->ah_txEolInterruptMask |= 1 << q;386else387ahp->ah_txEolInterruptMask &= ~(1 << q);388if (qi->tqi_qflags & HAL_TXQ_TXURNINT_ENABLE)389ahp->ah_txUrnInterruptMask |= 1 << q;390else391ahp->ah_txUrnInterruptMask &= ~(1 << q);392setTxQInterrupts(ah, qi);393394return AH_TRUE;395}396397/*398* Get the TXDP for the specified data queue.399*/400uint32_t401ar5211GetTxDP(struct ath_hal *ah, u_int q)402{403HALASSERT(q < HAL_NUM_TX_QUEUES);404return OS_REG_READ(ah, AR_QTXDP(q));405}406407/*408* Set the TxDP for the specified tx queue.409*/410HAL_BOOL411ar5211SetTxDP(struct ath_hal *ah, u_int q, uint32_t txdp)412{413HALASSERT(q < HAL_NUM_TX_QUEUES);414HALASSERT(AH5211(ah)->ah_txq[q].tqi_type != HAL_TX_QUEUE_INACTIVE);415416/*417* Make sure that TXE is deasserted before setting the TXDP. If TXE418* is still asserted, setting TXDP will have no effect.419*/420HALASSERT((OS_REG_READ(ah, AR_Q_TXE) & (1 << q)) == 0);421422OS_REG_WRITE(ah, AR_QTXDP(q), txdp);423424return AH_TRUE;425}426427/*428* Set Transmit Enable bits for the specified queues.429*/430HAL_BOOL431ar5211StartTxDma(struct ath_hal *ah, u_int q)432{433HALASSERT(q < HAL_NUM_TX_QUEUES);434HALASSERT(AH5211(ah)->ah_txq[q].tqi_type != HAL_TX_QUEUE_INACTIVE);435436/* Check that queue is not already active */437HALASSERT((OS_REG_READ(ah, AR_Q_TXD) & (1<<q)) == 0);438439HALDEBUG(ah, HAL_DEBUG_TXQUEUE, "%s: queue %u\n", __func__, q);440441/* Check to be sure we're not enabling a q that has its TXD bit set. */442HALASSERT((OS_REG_READ(ah, AR_Q_TXD) & (1 << q)) == 0);443444OS_REG_WRITE(ah, AR_Q_TXE, 1 << q);445return AH_TRUE;446}447448/*449* Return the number of frames pending on the specified queue.450*/451uint32_t452ar5211NumTxPending(struct ath_hal *ah, u_int q)453{454uint32_t n;455456HALASSERT(q < HAL_NUM_TX_QUEUES);457HALASSERT(AH5211(ah)->ah_txq[q].tqi_type != HAL_TX_QUEUE_INACTIVE);458459n = OS_REG_READ(ah, AR_QSTS(q)) & AR_Q_STS_PEND_FR_CNT_M;460/*461* Pending frame count (PFC) can momentarily go to zero462* while TXE remains asserted. In other words a PFC of463* zero is not sufficient to say that the queue has stopped.464*/465if (n == 0 && (OS_REG_READ(ah, AR_Q_TXE) & (1<<q)))466n = 1; /* arbitrarily pick 1 */467return n;468}469470/*471* Stop transmit on the specified queue472*/473HAL_BOOL474ar5211StopTxDma(struct ath_hal *ah, u_int q)475{476int i;477478HALASSERT(q < HAL_NUM_TX_QUEUES);479HALASSERT(AH5211(ah)->ah_txq[q].tqi_type != HAL_TX_QUEUE_INACTIVE);480481OS_REG_WRITE(ah, AR_Q_TXD, 1<<q);482for (i = 0; i < 10000; i++) {483if (ar5211NumTxPending(ah, q) == 0)484break;485OS_DELAY(10);486}487OS_REG_WRITE(ah, AR_Q_TXD, 0);488489return (i < 10000);490}491492/*493* Descriptor Access Functions494*/495496#define VALID_PKT_TYPES \497((1<<HAL_PKT_TYPE_NORMAL)|(1<<HAL_PKT_TYPE_ATIM)|\498(1<<HAL_PKT_TYPE_PSPOLL)|(1<<HAL_PKT_TYPE_PROBE_RESP)|\499(1<<HAL_PKT_TYPE_BEACON))500#define isValidPktType(_t) ((1<<(_t)) & VALID_PKT_TYPES)501#define VALID_TX_RATES \502((1<<0x0b)|(1<<0x0f)|(1<<0x0a)|(1<<0x0e)|(1<<0x09)|(1<<0x0d)|\503(1<<0x08)|(1<<0x0c)|(1<<0x1b)|(1<<0x1a)|(1<<0x1e)|(1<<0x19)|\504(1<<0x1d)|(1<<0x18)|(1<<0x1c))505#define isValidTxRate(_r) ((1<<(_r)) & VALID_TX_RATES)506507HAL_BOOL508ar5211SetupTxDesc(struct ath_hal *ah, struct ath_desc *ds,509u_int pktLen,510u_int hdrLen,511HAL_PKT_TYPE type,512u_int txPower,513u_int txRate0, u_int txTries0,514u_int keyIx,515u_int antMode,516u_int flags,517u_int rtsctsRate,518u_int rtsctsDuration,519u_int compicvLen,520u_int compivLen,521u_int comp)522{523struct ar5211_desc *ads = AR5211DESC(ds);524525(void) hdrLen;526(void) txPower;527(void) rtsctsRate; (void) rtsctsDuration;528529HALASSERT(txTries0 != 0);530HALASSERT(isValidPktType(type));531HALASSERT(isValidTxRate(txRate0));532/* XXX validate antMode */533534ads->ds_ctl0 = (pktLen & AR_FrameLen)535| (txRate0 << AR_XmitRate_S)536| (antMode << AR_AntModeXmit_S)537| (flags & HAL_TXDESC_CLRDMASK ? AR_ClearDestMask : 0)538| (flags & HAL_TXDESC_INTREQ ? AR_TxInterReq : 0)539| (flags & HAL_TXDESC_RTSENA ? AR_RTSCTSEnable : 0)540| (flags & HAL_TXDESC_VEOL ? AR_VEOL : 0)541;542ads->ds_ctl1 = (type << 26)543| (flags & HAL_TXDESC_NOACK ? AR_NoAck : 0)544;545546if (keyIx != HAL_TXKEYIX_INVALID) {547ads->ds_ctl1 |=548(keyIx << AR_EncryptKeyIdx_S) & AR_EncryptKeyIdx;549ads->ds_ctl0 |= AR_EncryptKeyValid;550}551return AH_TRUE;552#undef RATE553}554555HAL_BOOL556ar5211SetupXTxDesc(struct ath_hal *ah, struct ath_desc *ds,557u_int txRate1, u_int txTries1,558u_int txRate2, u_int txTries2,559u_int txRate3, u_int txTries3)560{561(void) ah; (void) ds;562(void) txRate1; (void) txTries1;563(void) txRate2; (void) txTries2;564(void) txRate3; (void) txTries3;565return AH_FALSE;566}567568void569ar5211IntrReqTxDesc(struct ath_hal *ah, struct ath_desc *ds)570{571struct ar5211_desc *ads = AR5211DESC(ds);572573ads->ds_ctl0 |= AR_TxInterReq;574}575576HAL_BOOL577ar5211FillTxDesc(struct ath_hal *ah, struct ath_desc *ds,578HAL_DMA_ADDR *bufAddrList, uint32_t *segLenList, u_int qcuId,579u_int descId, HAL_BOOL firstSeg, HAL_BOOL lastSeg,580const struct ath_desc *ds0)581{582struct ar5211_desc *ads = AR5211DESC(ds);583uint32_t segLen = segLenList[0];584585ds->ds_data = bufAddrList[0];586587HALASSERT((segLen &~ AR_BufLen) == 0);588589if (firstSeg) {590/*591* First descriptor, don't clobber xmit control data592* setup by ar5211SetupTxDesc.593*/594ads->ds_ctl1 |= segLen | (lastSeg ? 0 : AR_More);595} else if (lastSeg) { /* !firstSeg && lastSeg */596/*597* Last descriptor in a multi-descriptor frame,598* copy the transmit parameters from the first599* frame for processing on completion.600*/601ads->ds_ctl0 = AR5211DESC_CONST(ds0)->ds_ctl0;602ads->ds_ctl1 = segLen;603} else { /* !firstSeg && !lastSeg */604/*605* Intermediate descriptor in a multi-descriptor frame.606*/607ads->ds_ctl0 = 0;608ads->ds_ctl1 = segLen | AR_More;609}610ads->ds_status0 = ads->ds_status1 = 0;611return AH_TRUE;612}613614/*615* Processing of HW TX descriptor.616*/617HAL_STATUS618ar5211ProcTxDesc(struct ath_hal *ah,619struct ath_desc *ds, struct ath_tx_status *ts)620{621struct ar5211_desc *ads = AR5211DESC(ds);622623if ((ads->ds_status1 & AR_Done) == 0)624return HAL_EINPROGRESS;625626/* Update software copies of the HW status */627ts->ts_seqnum = MS(ads->ds_status1, AR_SeqNum);628ts->ts_tstamp = MS(ads->ds_status0, AR_SendTimestamp);629ts->ts_status = 0;630if ((ads->ds_status0 & AR_FrmXmitOK) == 0) {631if (ads->ds_status0 & AR_ExcessiveRetries)632ts->ts_status |= HAL_TXERR_XRETRY;633if (ads->ds_status0 & AR_Filtered)634ts->ts_status |= HAL_TXERR_FILT;635if (ads->ds_status0 & AR_FIFOUnderrun)636ts->ts_status |= HAL_TXERR_FIFO;637}638ts->ts_rate = MS(ads->ds_ctl0, AR_XmitRate);639ts->ts_rssi = MS(ads->ds_status1, AR_AckSigStrength);640ts->ts_shortretry = MS(ads->ds_status0, AR_ShortRetryCnt);641ts->ts_longretry = MS(ads->ds_status0, AR_LongRetryCnt);642ts->ts_virtcol = MS(ads->ds_status0, AR_VirtCollCnt);643ts->ts_antenna = 0; /* NB: don't know */644ts->ts_finaltsi = 0;645/*646* NB: the number of retries is one less than it should be.647* Also, 0 retries and 1 retry are both reported as 0 retries.648*/649if (ts->ts_shortretry > 0)650ts->ts_shortretry++;651if (ts->ts_longretry > 0)652ts->ts_longretry++;653654return HAL_OK;655}656657/*658* Determine which tx queues need interrupt servicing.659* STUB.660*/661void662ar5211GetTxIntrQueue(struct ath_hal *ah, uint32_t *txqs)663{664return;665}666667/*668* Retrieve the rate table from the given TX completion descriptor669*/670HAL_BOOL671ar5211GetTxCompletionRates(struct ath_hal *ah, const struct ath_desc *ds0, int *rates, int *tries)672{673return AH_FALSE;674}675676void677ar5211SetTxDescLink(struct ath_hal *ah, void *ds, uint32_t link)678{679struct ar5211_desc *ads = AR5211DESC(ds);680681ads->ds_link = link;682}683684void685ar5211GetTxDescLink(struct ath_hal *ah, void *ds, uint32_t *link)686{687struct ar5211_desc *ads = AR5211DESC(ds);688689*link = ads->ds_link;690}691692void693ar5211GetTxDescLinkPtr(struct ath_hal *ah, void *ds, uint32_t **linkptr)694{695struct ar5211_desc *ads = AR5211DESC(ds);696697*linkptr = &ads->ds_link;698}699700701