diff options
author | Tomas Winkler <tomas.winkler@intel.com> | 2008-05-29 04:35:16 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-06-03 15:00:25 -0400 |
commit | 30e553e3ea3572bee3118fcde36e043c0cb2174c (patch) | |
tree | 5cb6bd4634e4dba343b69df0b1971ff275ec25fa /drivers/net/wireless/iwlwifi/iwl-tx.c | |
parent | 5083e56326208f9a1d4e597529912004968c77d7 (diff) |
iwlwifi: move aggregation code to iwl-tx.c
This patch moves aggregation action code to iwl-tx.c in iwlcore.
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-tx.c')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-tx.c | 190 |
1 files changed, 190 insertions, 0 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c index 224bcec21e5b..cfe6f4b233dd 100644 --- a/drivers/net/wireless/iwlwifi/iwl-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-tx.c | |||
@@ -36,6 +36,32 @@ | |||
36 | #include "iwl-io.h" | 36 | #include "iwl-io.h" |
37 | #include "iwl-helpers.h" | 37 | #include "iwl-helpers.h" |
38 | 38 | ||
39 | #ifdef CONFIG_IWL4965_HT | ||
40 | |||
41 | static const u16 default_tid_to_tx_fifo[] = { | ||
42 | IWL_TX_FIFO_AC1, | ||
43 | IWL_TX_FIFO_AC0, | ||
44 | IWL_TX_FIFO_AC0, | ||
45 | IWL_TX_FIFO_AC1, | ||
46 | IWL_TX_FIFO_AC2, | ||
47 | IWL_TX_FIFO_AC2, | ||
48 | IWL_TX_FIFO_AC3, | ||
49 | IWL_TX_FIFO_AC3, | ||
50 | IWL_TX_FIFO_NONE, | ||
51 | IWL_TX_FIFO_NONE, | ||
52 | IWL_TX_FIFO_NONE, | ||
53 | IWL_TX_FIFO_NONE, | ||
54 | IWL_TX_FIFO_NONE, | ||
55 | IWL_TX_FIFO_NONE, | ||
56 | IWL_TX_FIFO_NONE, | ||
57 | IWL_TX_FIFO_NONE, | ||
58 | IWL_TX_FIFO_AC3 | ||
59 | }; | ||
60 | |||
61 | #endif /*CONFIG_IWL4965_HT */ | ||
62 | |||
63 | |||
64 | |||
39 | /** | 65 | /** |
40 | * iwl_hw_txq_free_tfd - Free all chunks referenced by TFD [txq->q.read_ptr] | 66 | * iwl_hw_txq_free_tfd - Free all chunks referenced by TFD [txq->q.read_ptr] |
41 | * | 67 | * |
@@ -1171,6 +1197,170 @@ void iwl_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb) | |||
1171 | EXPORT_SYMBOL(iwl_tx_cmd_complete); | 1197 | EXPORT_SYMBOL(iwl_tx_cmd_complete); |
1172 | 1198 | ||
1173 | 1199 | ||
1200 | #ifdef CONFIG_IWL4965_HT | ||
1201 | /* | ||
1202 | * Find first available (lowest unused) Tx Queue, mark it "active". | ||
1203 | * Called only when finding queue for aggregation. | ||
1204 | * Should never return anything < 7, because they should already | ||
1205 | * be in use as EDCA AC (0-3), Command (4), HCCA (5, 6). | ||
1206 | */ | ||
1207 | static int iwl_txq_ctx_activate_free(struct iwl_priv *priv) | ||
1208 | { | ||
1209 | int txq_id; | ||
1210 | |||
1211 | for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) | ||
1212 | if (!test_and_set_bit(txq_id, &priv->txq_ctx_active_msk)) | ||
1213 | return txq_id; | ||
1214 | return -1; | ||
1215 | } | ||
1216 | |||
1217 | int iwl_tx_agg_start(struct iwl_priv *priv, const u8 *ra, u16 tid, u16 *ssn) | ||
1218 | { | ||
1219 | int sta_id; | ||
1220 | int tx_fifo; | ||
1221 | int txq_id; | ||
1222 | int ret; | ||
1223 | unsigned long flags; | ||
1224 | struct iwl_tid_data *tid_data; | ||
1225 | DECLARE_MAC_BUF(mac); | ||
1226 | |||
1227 | if (likely(tid < ARRAY_SIZE(default_tid_to_tx_fifo))) | ||
1228 | tx_fifo = default_tid_to_tx_fifo[tid]; | ||
1229 | else | ||
1230 | return -EINVAL; | ||
1231 | |||
1232 | IWL_WARNING("%s on ra = %s tid = %d\n", | ||
1233 | __func__, print_mac(mac, ra), tid); | ||
1234 | |||
1235 | sta_id = iwl_find_station(priv, ra); | ||
1236 | if (sta_id == IWL_INVALID_STATION) | ||
1237 | return -ENXIO; | ||
1238 | |||
1239 | if (priv->stations[sta_id].tid[tid].agg.state != IWL_AGG_OFF) { | ||
1240 | IWL_ERROR("Start AGG when state is not IWL_AGG_OFF !\n"); | ||
1241 | return -ENXIO; | ||
1242 | } | ||
1243 | |||
1244 | txq_id = iwl_txq_ctx_activate_free(priv); | ||
1245 | if (txq_id == -1) | ||
1246 | return -ENXIO; | ||
1247 | |||
1248 | spin_lock_irqsave(&priv->sta_lock, flags); | ||
1249 | tid_data = &priv->stations[sta_id].tid[tid]; | ||
1250 | *ssn = SEQ_TO_SN(tid_data->seq_number); | ||
1251 | tid_data->agg.txq_id = txq_id; | ||
1252 | spin_unlock_irqrestore(&priv->sta_lock, flags); | ||
1253 | |||
1254 | ret = priv->cfg->ops->lib->txq_agg_enable(priv, txq_id, tx_fifo, | ||
1255 | sta_id, tid, *ssn); | ||
1256 | if (ret) | ||
1257 | return ret; | ||
1258 | |||
1259 | if (tid_data->tfds_in_queue == 0) { | ||
1260 | printk(KERN_ERR "HW queue is empty\n"); | ||
1261 | tid_data->agg.state = IWL_AGG_ON; | ||
1262 | ieee80211_start_tx_ba_cb_irqsafe(priv->hw, ra, tid); | ||
1263 | } else { | ||
1264 | IWL_DEBUG_HT("HW queue is NOT empty: %d packets in HW queue\n", | ||
1265 | tid_data->tfds_in_queue); | ||
1266 | tid_data->agg.state = IWL_EMPTYING_HW_QUEUE_ADDBA; | ||
1267 | } | ||
1268 | return ret; | ||
1269 | } | ||
1270 | EXPORT_SYMBOL(iwl_tx_agg_start); | ||
1271 | |||
1272 | int iwl_tx_agg_stop(struct iwl_priv *priv , const u8 *ra, u16 tid) | ||
1273 | { | ||
1274 | int tx_fifo_id, txq_id, sta_id, ssn = -1; | ||
1275 | struct iwl_tid_data *tid_data; | ||
1276 | int ret, write_ptr, read_ptr; | ||
1277 | unsigned long flags; | ||
1278 | DECLARE_MAC_BUF(mac); | ||
1279 | |||
1280 | if (!ra) { | ||
1281 | IWL_ERROR("ra = NULL\n"); | ||
1282 | return -EINVAL; | ||
1283 | } | ||
1284 | |||
1285 | if (likely(tid < ARRAY_SIZE(default_tid_to_tx_fifo))) | ||
1286 | tx_fifo_id = default_tid_to_tx_fifo[tid]; | ||
1287 | else | ||
1288 | return -EINVAL; | ||
1289 | |||
1290 | sta_id = iwl_find_station(priv, ra); | ||
1291 | |||
1292 | if (sta_id == IWL_INVALID_STATION) | ||
1293 | return -ENXIO; | ||
1294 | |||
1295 | if (priv->stations[sta_id].tid[tid].agg.state != IWL_AGG_ON) | ||
1296 | IWL_WARNING("Stopping AGG while state not IWL_AGG_ON\n"); | ||
1297 | |||
1298 | tid_data = &priv->stations[sta_id].tid[tid]; | ||
1299 | ssn = (tid_data->seq_number & IEEE80211_SCTL_SEQ) >> 4; | ||
1300 | txq_id = tid_data->agg.txq_id; | ||
1301 | write_ptr = priv->txq[txq_id].q.write_ptr; | ||
1302 | read_ptr = priv->txq[txq_id].q.read_ptr; | ||
1303 | |||
1304 | /* The queue is not empty */ | ||
1305 | if (write_ptr != read_ptr) { | ||
1306 | IWL_DEBUG_HT("Stopping a non empty AGG HW QUEUE\n"); | ||
1307 | priv->stations[sta_id].tid[tid].agg.state = | ||
1308 | IWL_EMPTYING_HW_QUEUE_DELBA; | ||
1309 | return 0; | ||
1310 | } | ||
1311 | |||
1312 | IWL_DEBUG_HT("HW queue is empty\n"); | ||
1313 | priv->stations[sta_id].tid[tid].agg.state = IWL_AGG_OFF; | ||
1314 | |||
1315 | spin_lock_irqsave(&priv->lock, flags); | ||
1316 | ret = priv->cfg->ops->lib->txq_agg_disable(priv, txq_id, ssn, | ||
1317 | tx_fifo_id); | ||
1318 | spin_unlock_irqrestore(&priv->lock, flags); | ||
1319 | |||
1320 | if (ret) | ||
1321 | return ret; | ||
1322 | |||
1323 | ieee80211_stop_tx_ba_cb_irqsafe(priv->hw, ra, tid); | ||
1324 | |||
1325 | return 0; | ||
1326 | } | ||
1327 | EXPORT_SYMBOL(iwl_tx_agg_stop); | ||
1328 | |||
1329 | int iwl_txq_check_empty(struct iwl_priv *priv, int sta_id, u8 tid, int txq_id) | ||
1330 | { | ||
1331 | struct iwl_queue *q = &priv->txq[txq_id].q; | ||
1332 | u8 *addr = priv->stations[sta_id].sta.sta.addr; | ||
1333 | struct iwl_tid_data *tid_data = &priv->stations[sta_id].tid[tid]; | ||
1334 | |||
1335 | switch (priv->stations[sta_id].tid[tid].agg.state) { | ||
1336 | case IWL_EMPTYING_HW_QUEUE_DELBA: | ||
1337 | /* We are reclaiming the last packet of the */ | ||
1338 | /* aggregated HW queue */ | ||
1339 | if (txq_id == tid_data->agg.txq_id && | ||
1340 | q->read_ptr == q->write_ptr) { | ||
1341 | u16 ssn = SEQ_TO_SN(tid_data->seq_number); | ||
1342 | int tx_fifo = default_tid_to_tx_fifo[tid]; | ||
1343 | IWL_DEBUG_HT("HW queue empty: continue DELBA flow\n"); | ||
1344 | priv->cfg->ops->lib->txq_agg_disable(priv, txq_id, | ||
1345 | ssn, tx_fifo); | ||
1346 | tid_data->agg.state = IWL_AGG_OFF; | ||
1347 | ieee80211_stop_tx_ba_cb_irqsafe(priv->hw, addr, tid); | ||
1348 | } | ||
1349 | break; | ||
1350 | case IWL_EMPTYING_HW_QUEUE_ADDBA: | ||
1351 | /* We are reclaiming the last packet of the queue */ | ||
1352 | if (tid_data->tfds_in_queue == 0) { | ||
1353 | IWL_DEBUG_HT("HW queue empty: continue ADDBA flow\n"); | ||
1354 | tid_data->agg.state = IWL_AGG_ON; | ||
1355 | ieee80211_start_tx_ba_cb_irqsafe(priv->hw, addr, tid); | ||
1356 | } | ||
1357 | break; | ||
1358 | } | ||
1359 | return 0; | ||
1360 | } | ||
1361 | EXPORT_SYMBOL(iwl_txq_check_empty); | ||
1362 | #endif /* CONFIG_IWL4965_HT */ | ||
1363 | |||
1174 | #ifdef CONFIG_IWLWIF_DEBUG | 1364 | #ifdef CONFIG_IWLWIF_DEBUG |
1175 | #define TX_STATUS_ENTRY(x) case TX_STATUS_FAIL_ ## x: return #x | 1365 | #define TX_STATUS_ENTRY(x) case TX_STATUS_FAIL_ ## x: return #x |
1176 | 1366 | ||