272 ASSERT(tid->tx_buf[cindex] == NULL);
273 tid->tx_buf[cindex] = bf;
274
275 if (index >= ((tid->baw_tail - tid->baw_head) &
276 (ATH_TID_MAX_BUFS - 1))) {
277 tid->baw_tail = cindex;
278 INCR(tid->baw_tail, ATH_TID_MAX_BUFS);
279 }
280 }
281
282 /*
283 * TODO: For frame(s) that are in the retry state, we will reuse the
284 * sequence number(s) without setting the retry bit. The
285 * alternative is to give up on these and BAR the receiver's window
286 * forward.
287 */
288 static void
289 arn_tid_drain(struct arn_softc *sc,
290 struct ath_txq *txq,
291 struct ath_atx_tid *tid)
292
293 {
294 struct ath_buf *bf;
295
296 list_t list;
297 list_create(&list, sizeof (struct ath_buf),
298 offsetof(struct ath_buf, bf_node));
299
300 for (;;) {
301 if (list_empty(&tid->buf_q))
302 break;
303
304 bf = list_head(&tid->buf_q);
305 list_remove(&tid->buf_q, bf);
306 list_insert_tail(&list, bf);
307
308 if (bf_isretried(bf))
309 arn_tx_update_baw(sc, tid, bf->bf_seqno);
310
311 mutex_enter(&txq->axq_lock);
312 arn_tx_complete_buf(sc, bf, &list, 0, 0);
1130
1131 ARN_DBG((ARN_DBG_QUEUE,
1132 "qnum: %d, txq depth: %d\n", txq->axq_qnum, txq->axq_depth));
1133
1134 if (txq->axq_link == NULL) {
1135 ath9k_hw_puttxbuf(sc->sc_ah, txq->axq_qnum, bf->bf_daddr);
1136 ARN_DBG((ARN_DBG_XMIT,
1137 "TXDP[%u] = %llx (%p)\n",
1138 txq->axq_qnum, ito64(bf->bf_daddr), bf->bf_desc));
1139 } else {
1140 *txq->axq_link = bf->bf_daddr;
1141 ARN_DBG((ARN_DBG_XMIT, "link[%u] (%p)=%llx (%p)\n",
1142 txq->axq_qnum, txq->axq_link,
1143 ito64(bf->bf_daddr), bf->bf_desc));
1144 }
1145 txq->axq_link = &(bf->bf_lastbf->bf_desc->ds_link);
1146 ath9k_hw_txstart(sc->sc_ah, txq->axq_qnum);
1147 }
1148 #endif /* ARN_TX_AGGREGATION */
1149
1150 /*
1151 * ath_pkt_dur - compute packet duration (NB: not NAV)
1152 * rix - rate index
1153 * pktlen - total bytes (delims + data + fcs + pads + pad delims)
1154 * width - 0 for 20 MHz, 1 for 40 MHz
1155 * half_gi - to use 4us v/s 3.6 us for symbol time
1156 */
1157
1158 static uint32_t
1159 /* LINTED E_STATIC_UNUSED */
1160 arn_pkt_duration(struct arn_softc *sc, uint8_t rix, struct ath_buf *bf,
1161 int width, int half_gi, boolean_t shortPreamble)
1162 {
1163 struct ath_rate_table *rate_table = sc->sc_currates;
1164 uint32_t nbits, nsymbits, duration, nsymbols;
1165 uint8_t rc;
1166 int streams, pktlen;
1167
1168 pktlen = bf_isaggr(bf) ? bf->bf_al : bf->bf_frmlen;
1169 rc = rate_table->info[rix].ratecode;
1170
1171 /* for legacy rates, use old function to compute packet duration */
1172 if (!IS_HT_RATE(rc))
1173 return (ath9k_hw_computetxtime(sc->sc_ah, rate_table, pktlen,
1174 rix, shortPreamble));
1175
1176 /* find number of symbols: PLCP + data */
1177 nbits = (pktlen << 3) + OFDM_PLCP_BITS;
1178 nsymbits = bits_per_symbol[HT_RC_2_MCS(rc)][width];
1179 nsymbols = (nbits + nsymbits - 1) / nsymbits;
1180
1181 if (!half_gi)
1182 duration = SYMBOL_TIME(nsymbols);
1183 else
1184 duration = SYMBOL_TIME_HALFGI(nsymbols);
1185
1186 /* addup duration for legacy/ht training and signal fields */
1187 streams = HT_RC_2_STREAMS(rc);
1188 duration += L_STF + L_LTF + L_SIG + HT_SIG + HT_STF + HT_LTF(streams);
1189
1190 return (duration);
1191 }
1192
1193 static struct ath_buf *
1194 arn_tx_get_buffer(struct arn_softc *sc)
1195 {
1196 struct ath_buf *bf = NULL;
1197
1198 mutex_enter(&sc->sc_txbuflock);
1199 bf = list_head(&sc->sc_txbuf_list);
1200 /* Check if a tx buffer is available */
1201 if (bf != NULL)
1202 list_remove(&sc->sc_txbuf_list, bf);
1203 if (list_empty(&sc->sc_txbuf_list)) {
1204 ARN_DBG((ARN_DBG_XMIT, "arn: arn_tx(): "
1205 "stop queue\n"));
1206 sc->sc_stats.ast_tx_qstop++;
1207 }
1208 mutex_exit(&sc->sc_txbuflock);
1209
1210 return (bf);
1211 }
1212
1315 /* find number of symbols: PLCP + data */
1316 nbits = (pktlen << 3) + OFDM_PLCP_BITS;
1317 nsymbits = bits_per_symbol[HT_RC_2_MCS(rc)][width];
1318 nsymbols = (nbits + nsymbits - 1) / nsymbits;
1319
1320 if (!half_gi)
1321 duration = SYMBOL_TIME(nsymbols);
1322 else
1323 duration = SYMBOL_TIME_HALFGI(nsymbols);
1324
1325 /* addup duration for legacy/ht training and signal fields */
1326 streams = HT_RC_2_STREAMS(rc);
1327 duration += L_STF + L_LTF + L_SIG + HT_SIG + HT_STF + HT_LTF(streams);
1328
1329 return (duration);
1330 }
1331
1332 /* Rate module function to set rate related fields in tx descriptor */
1333 static void
1334 ath_buf_set_rate(struct arn_softc *sc,
1335 struct ath_buf *bf,
1336 struct ieee80211_frame *wh)
1337 {
1338 struct ath_hal *ah = sc->sc_ah;
1339 struct ath_rate_table *rt;
1340 struct ath_desc *ds = bf->bf_desc;
1341 struct ath_desc *lastds = bf->bf_desc; /* temp workground */
1342 struct ath9k_11n_rate_series series[4];
1343 struct ath9k_tx_rate *rates;
1344 int i, flags, rtsctsena = 0;
1345 uint32_t ctsduration = 0;
1346 uint8_t rix = 0, cix, ctsrate = 0;
1347
1348 (void) memset(series, 0, sizeof (struct ath9k_11n_rate_series) * 4);
1349
1350 rates = bf->rates;
1351
1352 if (IEEE80211_HAS_MOREFRAGS(wh) ||
1353 wh->i_seq[0] & IEEE80211_SEQ_FRAG_MASK) {
1354 rates[1].count = rates[2].count = rates[3].count = 0;
1355 rates[1].idx = rates[2].idx = rates[3].idx = 0;
1356 rates[0].count = ATH_TXMAXTRY;
|
272 ASSERT(tid->tx_buf[cindex] == NULL);
273 tid->tx_buf[cindex] = bf;
274
275 if (index >= ((tid->baw_tail - tid->baw_head) &
276 (ATH_TID_MAX_BUFS - 1))) {
277 tid->baw_tail = cindex;
278 INCR(tid->baw_tail, ATH_TID_MAX_BUFS);
279 }
280 }
281
282 /*
283 * TODO: For frame(s) that are in the retry state, we will reuse the
284 * sequence number(s) without setting the retry bit. The
285 * alternative is to give up on these and BAR the receiver's window
286 * forward.
287 */
288 static void
289 arn_tid_drain(struct arn_softc *sc,
290 struct ath_txq *txq,
291 struct ath_atx_tid *tid)
292 {
293 struct ath_buf *bf;
294
295 list_t list;
296 list_create(&list, sizeof (struct ath_buf),
297 offsetof(struct ath_buf, bf_node));
298
299 for (;;) {
300 if (list_empty(&tid->buf_q))
301 break;
302
303 bf = list_head(&tid->buf_q);
304 list_remove(&tid->buf_q, bf);
305 list_insert_tail(&list, bf);
306
307 if (bf_isretried(bf))
308 arn_tx_update_baw(sc, tid, bf->bf_seqno);
309
310 mutex_enter(&txq->axq_lock);
311 arn_tx_complete_buf(sc, bf, &list, 0, 0);
1129
1130 ARN_DBG((ARN_DBG_QUEUE,
1131 "qnum: %d, txq depth: %d\n", txq->axq_qnum, txq->axq_depth));
1132
1133 if (txq->axq_link == NULL) {
1134 ath9k_hw_puttxbuf(sc->sc_ah, txq->axq_qnum, bf->bf_daddr);
1135 ARN_DBG((ARN_DBG_XMIT,
1136 "TXDP[%u] = %llx (%p)\n",
1137 txq->axq_qnum, ito64(bf->bf_daddr), bf->bf_desc));
1138 } else {
1139 *txq->axq_link = bf->bf_daddr;
1140 ARN_DBG((ARN_DBG_XMIT, "link[%u] (%p)=%llx (%p)\n",
1141 txq->axq_qnum, txq->axq_link,
1142 ito64(bf->bf_daddr), bf->bf_desc));
1143 }
1144 txq->axq_link = &(bf->bf_lastbf->bf_desc->ds_link);
1145 ath9k_hw_txstart(sc->sc_ah, txq->axq_qnum);
1146 }
1147 #endif /* ARN_TX_AGGREGATION */
1148
1149 static struct ath_buf *
1150 arn_tx_get_buffer(struct arn_softc *sc)
1151 {
1152 struct ath_buf *bf = NULL;
1153
1154 mutex_enter(&sc->sc_txbuflock);
1155 bf = list_head(&sc->sc_txbuf_list);
1156 /* Check if a tx buffer is available */
1157 if (bf != NULL)
1158 list_remove(&sc->sc_txbuf_list, bf);
1159 if (list_empty(&sc->sc_txbuf_list)) {
1160 ARN_DBG((ARN_DBG_XMIT, "arn: arn_tx(): "
1161 "stop queue\n"));
1162 sc->sc_stats.ast_tx_qstop++;
1163 }
1164 mutex_exit(&sc->sc_txbuflock);
1165
1166 return (bf);
1167 }
1168
1271 /* find number of symbols: PLCP + data */
1272 nbits = (pktlen << 3) + OFDM_PLCP_BITS;
1273 nsymbits = bits_per_symbol[HT_RC_2_MCS(rc)][width];
1274 nsymbols = (nbits + nsymbits - 1) / nsymbits;
1275
1276 if (!half_gi)
1277 duration = SYMBOL_TIME(nsymbols);
1278 else
1279 duration = SYMBOL_TIME_HALFGI(nsymbols);
1280
1281 /* addup duration for legacy/ht training and signal fields */
1282 streams = HT_RC_2_STREAMS(rc);
1283 duration += L_STF + L_LTF + L_SIG + HT_SIG + HT_STF + HT_LTF(streams);
1284
1285 return (duration);
1286 }
1287
1288 /* Rate module function to set rate related fields in tx descriptor */
1289 static void
1290 ath_buf_set_rate(struct arn_softc *sc,
1291 struct ath_buf *bf,
1292 struct ieee80211_frame *wh)
1293 {
1294 struct ath_hal *ah = sc->sc_ah;
1295 struct ath_rate_table *rt;
1296 struct ath_desc *ds = bf->bf_desc;
1297 struct ath_desc *lastds = bf->bf_desc; /* temp workground */
1298 struct ath9k_11n_rate_series series[4];
1299 struct ath9k_tx_rate *rates;
1300 int i, flags, rtsctsena = 0;
1301 uint32_t ctsduration = 0;
1302 uint8_t rix = 0, cix, ctsrate = 0;
1303
1304 (void) memset(series, 0, sizeof (struct ath9k_11n_rate_series) * 4);
1305
1306 rates = bf->rates;
1307
1308 if (IEEE80211_HAS_MOREFRAGS(wh) ||
1309 wh->i_seq[0] & IEEE80211_SEQ_FRAG_MASK) {
1310 rates[1].count = rates[2].count = rates[3].count = 0;
1311 rates[1].idx = rates[2].idx = rates[3].idx = 0;
1312 rates[0].count = ATH_TXMAXTRY;
|