Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
rt2x00queue.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2004 - 2010 Ivo van Doorn <[email protected]>
3  <http://rt2x00.serialmonkey.com>
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the
17  Free Software Foundation, Inc.,
18  59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19  */
20 
21 /*
22  Module: rt2x00
23  Abstract: rt2x00 queue datastructures and routines
24  */
25 
26 #ifndef RT2X00QUEUE_H
27 #define RT2X00QUEUE_H
28 
29 #include <linux/prefetch.h>
30 
41 #define DATA_FRAME_SIZE 2432
42 #define MGMT_FRAME_SIZE 256
43 #define AGGREGATION_SIZE 3840
44 
60  QID_AC_VO = 0,
61  QID_AC_VI = 1,
62  QID_AC_BE = 2,
63  QID_AC_BK = 3,
64  QID_HCCA = 4,
65  QID_MGMT = 13,
66  QID_RX = 14,
67  QID_OTHER = 15,
70 };
71 
90 };
91 
111 
115 
116  void *desc;
117 
118  __le32 iv[2];
119 
121 
122  struct queue_entry *entry;
123 };
124 
129 static inline struct skb_frame_desc* get_skb_frame_desc(struct sk_buff *skb)
130 {
131  BUILD_BUG_ON(sizeof(struct skb_frame_desc) >
133  return (struct skb_frame_desc *)&IEEE80211_SKB_CB(skb)->driver_data;
134 }
135 
155 };
156 
162 #define RXDONE_SIGNAL_MASK \
163  ( RXDONE_SIGNAL_PLCP | RXDONE_SIGNAL_BITRATE | RXDONE_SIGNAL_MCS )
164 
184  int signal;
185  int rssi;
186  int size;
187  int flags;
192 
193  __le32 iv[2];
195 };
196 
221 };
222 
233  unsigned long flags;
234  int retry;
235 };
236 
276 };
277 
303 struct txentry_desc {
304  unsigned long flags;
305 
308 
309  union {
310  struct {
315  enum ifs ifs;
316  } plcp;
317 
318  struct {
323  enum txop txop;
324  int wcid;
325  } ht;
326  } u;
327 
329 
330  short retry_limit;
331 
336 };
337 
362 };
363 
376 struct queue_entry {
377  unsigned long flags;
378  unsigned long last_action;
379 
380  struct data_queue *queue;
381 
382  struct sk_buff *skb;
383 
384  unsigned int entry_idx;
385 
386  void *priv_data;
387 };
388 
407 };
408 
424 };
425 
455 struct data_queue {
457  struct queue_entry *entries;
458 
460  unsigned long flags;
461 
465 
466  unsigned int count;
467  unsigned short limit;
468  unsigned short threshold;
469  unsigned short length;
470  unsigned short index[Q_INDEX_MAX];
471 
472  unsigned short txop;
473  unsigned short aifs;
474  unsigned short cw_min;
475  unsigned short cw_max;
476 
477  unsigned short data_size;
478  unsigned short desc_size;
479 
480  unsigned short usb_endpoint;
481  unsigned short usb_maxpacket;
482 };
483 
496  unsigned short entry_num;
497  unsigned short data_size;
498  unsigned short desc_size;
499  unsigned short priv_size;
500 };
501 
510 #define queue_end(__dev) \
511  &(__dev)->rx[(__dev)->data_queues]
512 
521 #define tx_queue_end(__dev) \
522  &(__dev)->tx[(__dev)->ops->tx_queues]
523 
534 #define queue_next(__queue) \
535  &(__queue)[1]
536 
545 #define queue_loop(__entry, __start, __end) \
546  for ((__entry) = (__start); \
547  prefetch(queue_next(__entry)), (__entry) != (__end);\
548  (__entry) = queue_next(__entry))
549 
557 #define queue_for_each(__dev, __entry) \
558  queue_loop(__entry, (__dev)->rx, queue_end(__dev))
559 
568 #define tx_queue_for_each(__dev, __entry) \
569  queue_loop(__entry, (__dev)->tx, tx_queue_end(__dev))
570 
579 #define txall_queue_for_each(__dev, __entry) \
580  queue_loop(__entry, (__dev)->tx, queue_end(__dev))
581 
597  enum queue_index start,
598  enum queue_index end,
599  bool (*fn)(struct queue_entry *entry));
600 
605 static inline int rt2x00queue_empty(struct data_queue *queue)
606 {
607  return queue->length == 0;
608 }
609 
614 static inline int rt2x00queue_full(struct data_queue *queue)
615 {
616  return queue->length == queue->limit;
617 }
618 
623 static inline int rt2x00queue_available(struct data_queue *queue)
624 {
625  return queue->limit - queue->length;
626 }
627 
632 static inline int rt2x00queue_threshold(struct data_queue *queue)
633 {
634  return rt2x00queue_available(queue) < queue->threshold;
635 }
640 static inline int rt2x00queue_dma_timeout(struct queue_entry *entry)
641 {
642  if (!test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags))
643  return false;
644  return time_after(jiffies, entry->last_action + msecs_to_jiffies(100));
645 }
646 
653 static inline void _rt2x00_desc_read(__le32 *desc, const u8 word, __le32 *value)
654 {
655  *value = desc[word];
656 }
657 
665 static inline void rt2x00_desc_read(__le32 *desc, const u8 word, u32 *value)
666 {
667  __le32 tmp;
668  _rt2x00_desc_read(desc, word, &tmp);
669  *value = le32_to_cpu(tmp);
670 }
671 
679 static inline void _rt2x00_desc_write(__le32 *desc, const u8 word, __le32 value)
680 {
681  desc[word] = value;
682 }
683 
690 static inline void rt2x00_desc_write(__le32 *desc, const u8 word, u32 value)
691 {
692  _rt2x00_desc_write(desc, word, cpu_to_le32(value));
693 }
694 
695 #endif /* RT2X00QUEUE_H */