Lines Matching full:queue
12 Abstract: rt2x00 queue specific routines.
25 struct data_queue *queue = entry->queue; in rt2x00queue_alloc_rxskb() local
26 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev; in rt2x00queue_alloc_rxskb()
37 frame_size = queue->data_size + queue->desc_size + queue->winfo_size; in rt2x00queue_alloc_rxskb()
95 struct device *dev = entry->queue->rt2x00dev->dev; in rt2x00queue_map_txskb()
112 struct device *dev = entry->queue->rt2x00dev->dev; in rt2x00queue_unmap_skb()
488 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; in rt2x00queue_write_tx_data()
493 * a queue corruption! in rt2x00queue_write_tx_data()
498 "Corrupt queue %d, accessing entry which is not ours\n" in rt2x00queue_write_tx_data()
500 entry->queue->qid, DRV_PROJECT); in rt2x00queue_write_tx_data()
529 struct data_queue *queue = entry->queue; in rt2x00queue_write_tx_descriptor() local
531 queue->rt2x00dev->ops->lib->write_tx_desc(entry, txdesc); in rt2x00queue_write_tx_descriptor()
537 rt2x00debug_dump_frame(queue->rt2x00dev, DUMP_FRAME_TX, entry); in rt2x00queue_write_tx_descriptor()
540 static void rt2x00queue_kick_tx_queue(struct data_queue *queue, in rt2x00queue_kick_tx_queue() argument
544 * Check if we need to kick the queue, there are however a few rules in rt2x00queue_kick_tx_queue()
550 * in the queue are less then a certain threshold. in rt2x00queue_kick_tx_queue()
552 if (rt2x00queue_threshold(queue) || in rt2x00queue_kick_tx_queue()
554 queue->rt2x00dev->ops->lib->kick_queue(queue); in rt2x00queue_kick_tx_queue()
559 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; in rt2x00queue_bar_check()
599 int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb, in rt2x00queue_write_tx_frame() argument
614 rt2x00queue_create_tx_descriptor(queue->rt2x00dev, skb, &txdesc, sta); in rt2x00queue_write_tx_frame()
639 if (rt2x00_has_cap_flag(queue->rt2x00dev, REQUIRE_COPY_IV)) in rt2x00queue_write_tx_frame()
653 if (rt2x00_has_cap_flag(queue->rt2x00dev, REQUIRE_L2PAD)) in rt2x00queue_write_tx_frame()
655 else if (rt2x00_has_cap_flag(queue->rt2x00dev, REQUIRE_DMA)) in rt2x00queue_write_tx_frame()
661 spin_lock(&queue->tx_lock); in rt2x00queue_write_tx_frame()
663 if (unlikely(rt2x00queue_full(queue))) { in rt2x00queue_write_tx_frame()
664 rt2x00_dbg(queue->rt2x00dev, "Dropping frame due to full tx queue %d\n", in rt2x00queue_write_tx_frame()
665 queue->qid); in rt2x00queue_write_tx_frame()
670 entry = rt2x00queue_get_entry(queue, Q_INDEX); in rt2x00queue_write_tx_frame()
674 rt2x00_err(queue->rt2x00dev, in rt2x00queue_write_tx_frame()
675 "Arrived at non-free entry in the non-full queue %d\n" in rt2x00queue_write_tx_frame()
677 queue->qid, DRV_PROJECT); in rt2x00queue_write_tx_frame()
685 * It could be possible that the queue was corrupted and this in rt2x00queue_write_tx_frame()
705 rt2x00queue_kick_tx_queue(queue, &txdesc); in rt2x00queue_write_tx_frame()
709 * Pausing queue has to be serialized with rt2x00lib_txdone(), so we in rt2x00queue_write_tx_frame()
710 * do this under queue->tx_lock. Bottom halve was already disabled in rt2x00queue_write_tx_frame()
713 if (rt2x00queue_threshold(queue)) in rt2x00queue_write_tx_frame()
714 rt2x00queue_pause_queue(queue); in rt2x00queue_write_tx_frame()
716 spin_unlock(&queue->tx_lock); in rt2x00queue_write_tx_frame()
735 * since the beacon queue will get stopped anyway). in rt2x00queue_clear_beacon()
784 bool rt2x00queue_for_each_entry(struct data_queue *queue, in rt2x00queue_for_each_entry() argument
797 rt2x00_err(queue->rt2x00dev, in rt2x00queue_for_each_entry()
809 spin_lock_irqsave(&queue->index_lock, irqflags); in rt2x00queue_for_each_entry()
810 index_start = queue->index[start]; in rt2x00queue_for_each_entry()
811 index_end = queue->index[end]; in rt2x00queue_for_each_entry()
812 spin_unlock_irqrestore(&queue->index_lock, irqflags); in rt2x00queue_for_each_entry()
820 if (fn(&queue->entries[i], data)) in rt2x00queue_for_each_entry()
824 for (i = index_start; i < queue->limit; i++) { in rt2x00queue_for_each_entry()
825 if (fn(&queue->entries[i], data)) in rt2x00queue_for_each_entry()
830 if (fn(&queue->entries[i], data)) in rt2x00queue_for_each_entry()
839 struct queue_entry *rt2x00queue_get_entry(struct data_queue *queue, in rt2x00queue_get_entry() argument
846 rt2x00_err(queue->rt2x00dev, "Entry requested from invalid index type (%d)\n", in rt2x00queue_get_entry()
851 spin_lock_irqsave(&queue->index_lock, irqflags); in rt2x00queue_get_entry()
853 entry = &queue->entries[queue->index[index]]; in rt2x00queue_get_entry()
855 spin_unlock_irqrestore(&queue->index_lock, irqflags); in rt2x00queue_get_entry()
863 struct data_queue *queue = entry->queue; in rt2x00queue_index_inc() local
867 rt2x00_err(queue->rt2x00dev, in rt2x00queue_index_inc()
872 spin_lock_irqsave(&queue->index_lock, irqflags); in rt2x00queue_index_inc()
874 queue->index[index]++; in rt2x00queue_index_inc()
875 if (queue->index[index] >= queue->limit) in rt2x00queue_index_inc()
876 queue->index[index] = 0; in rt2x00queue_index_inc()
881 queue->length++; in rt2x00queue_index_inc()
883 queue->length--; in rt2x00queue_index_inc()
884 queue->count++; in rt2x00queue_index_inc()
887 spin_unlock_irqrestore(&queue->index_lock, irqflags); in rt2x00queue_index_inc()
890 static void rt2x00queue_pause_queue_nocheck(struct data_queue *queue) in rt2x00queue_pause_queue_nocheck() argument
892 switch (queue->qid) { in rt2x00queue_pause_queue_nocheck()
898 * For TX queues, we have to disable the queue in rt2x00queue_pause_queue_nocheck()
901 ieee80211_stop_queue(queue->rt2x00dev->hw, queue->qid); in rt2x00queue_pause_queue_nocheck()
907 void rt2x00queue_pause_queue(struct data_queue *queue) in rt2x00queue_pause_queue() argument
909 if (!test_bit(DEVICE_STATE_PRESENT, &queue->rt2x00dev->flags) || in rt2x00queue_pause_queue()
910 !test_bit(QUEUE_STARTED, &queue->flags) || in rt2x00queue_pause_queue()
911 test_and_set_bit(QUEUE_PAUSED, &queue->flags)) in rt2x00queue_pause_queue()
914 rt2x00queue_pause_queue_nocheck(queue); in rt2x00queue_pause_queue()
918 void rt2x00queue_unpause_queue(struct data_queue *queue) in rt2x00queue_unpause_queue() argument
920 if (!test_bit(DEVICE_STATE_PRESENT, &queue->rt2x00dev->flags) || in rt2x00queue_unpause_queue()
921 !test_bit(QUEUE_STARTED, &queue->flags) || in rt2x00queue_unpause_queue()
922 !test_and_clear_bit(QUEUE_PAUSED, &queue->flags)) in rt2x00queue_unpause_queue()
925 switch (queue->qid) { in rt2x00queue_unpause_queue()
931 * For TX queues, we have to enable the queue in rt2x00queue_unpause_queue()
934 ieee80211_wake_queue(queue->rt2x00dev->hw, queue->qid); in rt2x00queue_unpause_queue()
938 * For RX we need to kick the queue now in order to in rt2x00queue_unpause_queue()
941 queue->rt2x00dev->ops->lib->kick_queue(queue); in rt2x00queue_unpause_queue()
949 void rt2x00queue_start_queue(struct data_queue *queue) in rt2x00queue_start_queue() argument
951 mutex_lock(&queue->status_lock); in rt2x00queue_start_queue()
953 if (!test_bit(DEVICE_STATE_PRESENT, &queue->rt2x00dev->flags) || in rt2x00queue_start_queue()
954 test_and_set_bit(QUEUE_STARTED, &queue->flags)) { in rt2x00queue_start_queue()
955 mutex_unlock(&queue->status_lock); in rt2x00queue_start_queue()
959 set_bit(QUEUE_PAUSED, &queue->flags); in rt2x00queue_start_queue()
961 queue->rt2x00dev->ops->lib->start_queue(queue); in rt2x00queue_start_queue()
963 rt2x00queue_unpause_queue(queue); in rt2x00queue_start_queue()
965 mutex_unlock(&queue->status_lock); in rt2x00queue_start_queue()
969 void rt2x00queue_stop_queue(struct data_queue *queue) in rt2x00queue_stop_queue() argument
971 mutex_lock(&queue->status_lock); in rt2x00queue_stop_queue()
973 if (!test_and_clear_bit(QUEUE_STARTED, &queue->flags)) { in rt2x00queue_stop_queue()
974 mutex_unlock(&queue->status_lock); in rt2x00queue_stop_queue()
978 rt2x00queue_pause_queue_nocheck(queue); in rt2x00queue_stop_queue()
980 queue->rt2x00dev->ops->lib->stop_queue(queue); in rt2x00queue_stop_queue()
982 mutex_unlock(&queue->status_lock); in rt2x00queue_stop_queue()
986 void rt2x00queue_flush_queue(struct data_queue *queue, bool drop) in rt2x00queue_flush_queue() argument
989 (queue->qid == QID_AC_VO) || in rt2x00queue_flush_queue()
990 (queue->qid == QID_AC_VI) || in rt2x00queue_flush_queue()
991 (queue->qid == QID_AC_BE) || in rt2x00queue_flush_queue()
992 (queue->qid == QID_AC_BK); in rt2x00queue_flush_queue()
994 if (rt2x00queue_empty(queue)) in rt2x00queue_flush_queue()
1000 * to the queue to make sure the hardware will in rt2x00queue_flush_queue()
1004 queue->rt2x00dev->ops->lib->kick_queue(queue); in rt2x00queue_flush_queue()
1009 * alternative which just waits for the queue to become empty. in rt2x00queue_flush_queue()
1011 if (likely(queue->rt2x00dev->ops->lib->flush_queue)) in rt2x00queue_flush_queue()
1012 queue->rt2x00dev->ops->lib->flush_queue(queue, drop); in rt2x00queue_flush_queue()
1015 * The queue flush has failed... in rt2x00queue_flush_queue()
1017 if (unlikely(!rt2x00queue_empty(queue))) in rt2x00queue_flush_queue()
1018 rt2x00_warn(queue->rt2x00dev, "Queue %d failed to flush\n", in rt2x00queue_flush_queue()
1019 queue->qid); in rt2x00queue_flush_queue()
1025 struct data_queue *queue; in rt2x00queue_start_queues() local
1029 * for each queue after is has been properly initialized. in rt2x00queue_start_queues()
1031 tx_queue_for_each(rt2x00dev, queue) in rt2x00queue_start_queues()
1032 rt2x00queue_start_queue(queue); in rt2x00queue_start_queues()
1040 struct data_queue *queue; in rt2x00queue_stop_queues() local
1050 tx_queue_for_each(rt2x00dev, queue) in rt2x00queue_stop_queues()
1051 rt2x00queue_stop_queue(queue); in rt2x00queue_stop_queues()
1059 struct data_queue *queue; in rt2x00queue_flush_queues() local
1061 tx_queue_for_each(rt2x00dev, queue) in rt2x00queue_flush_queues()
1062 rt2x00queue_flush_queue(queue, drop); in rt2x00queue_flush_queues()
1068 static void rt2x00queue_reset(struct data_queue *queue) in rt2x00queue_reset() argument
1073 spin_lock_irqsave(&queue->index_lock, irqflags); in rt2x00queue_reset()
1075 queue->count = 0; in rt2x00queue_reset()
1076 queue->length = 0; in rt2x00queue_reset()
1079 queue->index[i] = 0; in rt2x00queue_reset()
1081 spin_unlock_irqrestore(&queue->index_lock, irqflags); in rt2x00queue_reset()
1086 struct data_queue *queue; in rt2x00queue_init_queues() local
1089 queue_for_each(rt2x00dev, queue) { in rt2x00queue_init_queues()
1090 rt2x00queue_reset(queue); in rt2x00queue_init_queues()
1092 for (i = 0; i < queue->limit; i++) in rt2x00queue_init_queues()
1093 rt2x00dev->ops->lib->clear_entry(&queue->entries[i]); in rt2x00queue_init_queues()
1097 static int rt2x00queue_alloc_entries(struct data_queue *queue) in rt2x00queue_alloc_entries() argument
1103 rt2x00queue_reset(queue); in rt2x00queue_alloc_entries()
1106 * Allocate all queue entries. in rt2x00queue_alloc_entries()
1108 entry_size = sizeof(*entries) + queue->priv_size; in rt2x00queue_alloc_entries()
1109 entries = kcalloc(queue->limit, entry_size, GFP_KERNEL); in rt2x00queue_alloc_entries()
1117 for (i = 0; i < queue->limit; i++) { in rt2x00queue_alloc_entries()
1119 entries[i].queue = queue; in rt2x00queue_alloc_entries()
1123 QUEUE_ENTRY_PRIV_OFFSET(entries, i, queue->limit, in rt2x00queue_alloc_entries()
1124 sizeof(*entries), queue->priv_size); in rt2x00queue_alloc_entries()
1129 queue->entries = entries; in rt2x00queue_alloc_entries()
1134 static void rt2x00queue_free_skbs(struct data_queue *queue) in rt2x00queue_free_skbs() argument
1138 if (!queue->entries) in rt2x00queue_free_skbs()
1141 for (i = 0; i < queue->limit; i++) { in rt2x00queue_free_skbs()
1142 rt2x00queue_free_skb(&queue->entries[i]); in rt2x00queue_free_skbs()
1146 static int rt2x00queue_alloc_rxskbs(struct data_queue *queue) in rt2x00queue_alloc_rxskbs() argument
1151 for (i = 0; i < queue->limit; i++) { in rt2x00queue_alloc_rxskbs()
1152 skb = rt2x00queue_alloc_rxskb(&queue->entries[i], GFP_KERNEL); in rt2x00queue_alloc_rxskbs()
1155 queue->entries[i].skb = skb; in rt2x00queue_alloc_rxskbs()
1163 struct data_queue *queue; in rt2x00queue_initialize() local
1170 tx_queue_for_each(rt2x00dev, queue) { in rt2x00queue_initialize()
1171 status = rt2x00queue_alloc_entries(queue); in rt2x00queue_initialize()
1193 rt2x00_err(rt2x00dev, "Queue entries allocation failed\n"); in rt2x00queue_initialize()
1202 struct data_queue *queue; in rt2x00queue_uninitialize() local
1206 queue_for_each(rt2x00dev, queue) { in rt2x00queue_uninitialize()
1207 kfree(queue->entries); in rt2x00queue_uninitialize()
1208 queue->entries = NULL; in rt2x00queue_uninitialize()
1213 struct data_queue *queue, enum data_queue_qid qid) in rt2x00queue_init() argument
1215 mutex_init(&queue->status_lock); in rt2x00queue_init()
1216 spin_lock_init(&queue->tx_lock); in rt2x00queue_init()
1217 spin_lock_init(&queue->index_lock); in rt2x00queue_init()
1219 queue->rt2x00dev = rt2x00dev; in rt2x00queue_init()
1220 queue->qid = qid; in rt2x00queue_init()
1221 queue->txop = 0; in rt2x00queue_init()
1222 queue->aifs = 2; in rt2x00queue_init()
1223 queue->cw_min = 5; in rt2x00queue_init()
1224 queue->cw_max = 10; in rt2x00queue_init()
1226 rt2x00dev->ops->queue_init(queue); in rt2x00queue_init()
1228 queue->threshold = DIV_ROUND_UP(queue->limit, 10); in rt2x00queue_init()
1233 struct data_queue *queue; in rt2x00queue_allocate() local
1247 queue = kcalloc(rt2x00dev->data_queues, sizeof(*queue), GFP_KERNEL); in rt2x00queue_allocate()
1248 if (!queue) in rt2x00queue_allocate()
1254 rt2x00dev->rx = queue; in rt2x00queue_allocate()
1255 rt2x00dev->tx = &queue[1]; in rt2x00queue_allocate()
1256 rt2x00dev->bcn = &queue[1 + rt2x00dev->ops->tx_queues]; in rt2x00queue_allocate()
1257 rt2x00dev->atim = req_atim ? &queue[2 + rt2x00dev->ops->tx_queues] : NULL; in rt2x00queue_allocate()
1260 * Initialize queue parameters. in rt2x00queue_allocate()
1271 tx_queue_for_each(rt2x00dev, queue) in rt2x00queue_allocate()
1272 rt2x00queue_init(rt2x00dev, queue, qid++); in rt2x00queue_allocate()