• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Data Transmission thread for XRadio drivers
3  *
4  * Copyright (c) 2013
5  * Xradio Technology Co., Ltd. <www.xradiotech.com>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.
10  */
11 
12 #ifndef XRADIO_BH_H
13 #define XRADIO_BH_H
14 
15 #define XRADIO_BH_THREAD   "xradio_bh"
16 #define XRADIO_PROC_THREAD "xradio_proc"
17 
18 /* extern */ struct xradio_common;
19 
20 #define ITEM_F_RESERVE  0x80  /* use reserved skb */
21 #define ITEM_F_CMDCFM   0x40  /* cmd confirm packets */
22 #define ITEM_F_TXCFM    0x20  /* tx confirm packets */
23 
24 #if BH_PROC_TX
25 #define BH_WAITING_RX_THRESHOLD  8
26 #endif
27 
28 #ifdef BH_PROC_THREAD
29 struct bh_items {
30 	struct list_head  head;
31 	u8                *data;
32 	u16               datalen;
33 	u8                if_id;
34 	u8                flags;
35 };
36 
37 #if BH_PROC_DPA
38 struct thread_dpa {
39 	int policy;
40 	int priority;
41 };
42 extern u32 proc_dpa_cnt;
43 extern u32 proc_up_cnt;
44 extern u32 proc_down_cnt;
45 #endif
46 #define ITEM_RESERVED   256
47 #define PROC_POOL_NUM   8
48 #define PROC_POOL_SIZE  (sizeof(struct bh_items)*ITEM_RESERVED)
49 struct bh_proc {
50 	struct bh_items    *bh_pool[PROC_POOL_NUM];
51 	struct list_head    bh_free;
52 	struct list_head    bh_tx;
53 	struct list_head    bh_rx;
54 	atomic_t            tx_queued;
55 	atomic_t            rx_queued;
56 	atomic_t            proc_tx;
57 	spinlock_t          lock;
58 	size_t              txed_num;
59 	size_t              rxed_num;
60 	struct task_struct *proc_thread;
61 	int                 proc_state;
62 	wait_queue_head_t   proc_wq;
63 #if BH_PROC_DPA
64 	s8                  proc_prio;
65 	s8                  prio_cnt;
66 #endif
67 };
68 int bh_proc_init(struct xradio_common *hw_priv);
69 void bh_proc_deinit(struct xradio_common *hw_priv);
70 int bh_proc_reinit(struct xradio_common *hw_priv);
71 int bh_proc_flush_queue(struct xradio_common *hw_priv);
72 int bh_proc_flush_txqueue(struct xradio_common *hw_priv, int if_id);
73 #endif /*BH_PROC_THREAD*/
74 
75 int xradio_register_bh(struct xradio_common *hw_priv);
76 void xradio_unregister_bh(struct xradio_common *hw_priv);
77 void xradio_irq_handler(void *priv);
78 void xradio_bh_wakeup(struct xradio_common *hw_priv);
79 int xradio_bh_suspend(struct xradio_common *hw_priv);
80 int xradio_bh_resume(struct xradio_common *hw_priv);
81 /* Must be called from BH thread. */
82 void xradio_enable_powersave(struct xradio_vif *priv, bool enable);
83 int wsm_release_tx_buffer(struct xradio_common *hw_priv, int count);
84 int wsm_release_vif_tx_buffer(struct xradio_common *hw_priv, int if_id,
85 			      int count);
86 int xradio_init_resv_skb(struct xradio_common *hw_priv);
87 void xradio_deinit_resv_skb(struct xradio_common *hw_priv);
88 int xradio_realloc_resv_skb(struct xradio_common *hw_priv,
89 							struct sk_buff *skb, u8 flags);
90 
91 #ifdef BH_PROC_THREAD
92 void xradio_proc_wakeup(struct xradio_common *hw_priv);
93 #else
xradio_proc_wakeup(struct xradio_common * hw_priv)94 static inline void xradio_proc_wakeup(struct xradio_common *hw_priv)
95 {
96 	xradio_bh_wakeup(hw_priv);
97 }
98 #endif
99 
100 #endif /* XRADIO_BH_H */
101