]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blob - drivers/staging/rtl8723au/include/osdep_service.h
Merge tag 'pm+acpi-3.15-rc1-3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafae...
[mirror_ubuntu-hirsute-kernel.git] / drivers / staging / rtl8723au / include / osdep_service.h
1 /******************************************************************************
2 *
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 ******************************************************************************/
15 #ifndef __OSDEP_SERVICE_H_
16 #define __OSDEP_SERVICE_H_
17
18 #define _FAIL 0
19 #define _SUCCESS 1
20 #define RTW_RX_HANDLED 2
21
22 #include <linux/version.h>
23 #include <linux/spinlock.h>
24 #include <linux/compiler.h>
25 #include <linux/kernel.h>
26 #include <linux/errno.h>
27 #include <linux/init.h>
28 #include <linux/slab.h>
29 #include <linux/module.h>
30 #include <linux/kref.h>
31 #include <linux/netdevice.h>
32 #include <linux/skbuff.h>
33 #include <linux/circ_buf.h>
34 #include <asm/uaccess.h>
35 #include <asm/byteorder.h>
36 #include <asm/atomic.h>
37 #include <asm/io.h>
38 #include <linux/semaphore.h>
39 #include <linux/sem.h>
40 #include <linux/sched.h>
41 #include <linux/etherdevice.h>
42 #include <linux/wireless.h>
43 #include <net/iw_handler.h>
44 #include <linux/if_arp.h>
45 #include <linux/rtnetlink.h>
46 #include <linux/delay.h>
47 #include <linux/proc_fs.h> /* Necessary because we use the proc fs */
48 #include <linux/interrupt.h> /* for struct tasklet_struct */
49 #include <linux/ip.h>
50 #include <linux/kthread.h>
51
52
53 /* #include <linux/ieee80211.h> */
54 #include <net/ieee80211_radiotap.h>
55 #include <net/cfg80211.h>
56 #include <linux/usb.h>
57 #include <linux/usb/ch9.h>
58
59 struct rtw_adapter;
60 struct c2h_evt_hdr;
61
62 typedef s32 (*c2h_id_filter)(u8 id);
63
64 struct rtw_queue {
65 struct list_head queue;
66 spinlock_t lock;
67 };
68
69 static inline struct list_head *get_list_head(struct rtw_queue *queue)
70 {
71 return (&queue->queue);
72 }
73
74 static inline int rtw_netif_queue_stopped(struct net_device *pnetdev)
75 {
76 return (netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 0)) &&
77 netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 1)) &&
78 netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 2)) &&
79 netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 3)) );
80 }
81
82 #ifndef BIT
83 #define BIT(x) ( 1 << (x))
84 #endif
85 static inline u32 CHKBIT(u32 x)
86 {
87 WARN_ON(x >= 32);
88 if (x >= 32)
89 return 0;
90 return BIT(x);
91 }
92
93 #define BIT0 0x00000001
94 #define BIT1 0x00000002
95 #define BIT2 0x00000004
96 #define BIT3 0x00000008
97 #define BIT4 0x00000010
98 #define BIT5 0x00000020
99 #define BIT6 0x00000040
100 #define BIT7 0x00000080
101 #define BIT8 0x00000100
102 #define BIT9 0x00000200
103 #define BIT10 0x00000400
104 #define BIT11 0x00000800
105 #define BIT12 0x00001000
106 #define BIT13 0x00002000
107 #define BIT14 0x00004000
108 #define BIT15 0x00008000
109 #define BIT16 0x00010000
110 #define BIT17 0x00020000
111 #define BIT18 0x00040000
112 #define BIT19 0x00080000
113 #define BIT20 0x00100000
114 #define BIT21 0x00200000
115 #define BIT22 0x00400000
116 #define BIT23 0x00800000
117 #define BIT24 0x01000000
118 #define BIT25 0x02000000
119 #define BIT26 0x04000000
120 #define BIT27 0x08000000
121 #define BIT28 0x10000000
122 #define BIT29 0x20000000
123 #define BIT30 0x40000000
124 #define BIT31 0x80000000
125 #define BIT32 0x0100000000
126 #define BIT33 0x0200000000
127 #define BIT34 0x0400000000
128 #define BIT35 0x0800000000
129 #define BIT36 0x1000000000
130
131 int RTW_STATUS_CODE23a(int error_code);
132
133 u8* _rtw_vmalloc(u32 sz);
134 u8* _rtw_zvmalloc(u32 sz);
135 void _rtw_vmfree(u8 *pbuf, u32 sz);
136 #define rtw_vmalloc(sz) _rtw_vmalloc((sz))
137 #define rtw_zvmalloc(sz) _rtw_zvmalloc((sz))
138 #define rtw_vmfree(pbuf, sz) _rtw_vmfree((pbuf), (sz))
139
140 extern unsigned char REALTEK_96B_IE23A[];
141 extern unsigned char MCS_rate_2R23A[16];
142 extern unsigned char RTW_WPA_OUI23A[];
143 extern unsigned char WPA_TKIP_CIPHER23A[4];
144 extern unsigned char RSN_TKIP_CIPHER23A[4];
145
146 extern unsigned char MCS_rate_2R23A[16];
147 extern unsigned char MCS_rate_1R23A[16];
148
149 void _rtw_init_queue23a(struct rtw_queue *pqueue);
150 u32 _rtw_queue_empty23a(struct rtw_queue *pqueue);
151
152 static inline u32 bitshift(u32 bitmask)
153 {
154 u32 i;
155
156 for (i = 0; i <= 31; i++)
157 if (((bitmask>>i) & 0x1) == 1) break;
158
159 return i;
160 }
161
162 void rtw_suspend_lock_init(void);
163 void rtw_suspend_lock_uninit(void);
164 void rtw_lock_suspend(void);
165 void rtw_unlock_suspend(void);
166
167
168 #define NDEV_FMT "%s"
169 #define NDEV_ARG(ndev) ndev->name
170 #define ADPT_FMT "%s"
171 #define ADPT_ARG(adapter) adapter->pnetdev->name
172 #define FUNC_NDEV_FMT "%s(%s)"
173 #define FUNC_NDEV_ARG(ndev) __func__, ndev->name
174 #define FUNC_ADPT_FMT "%s(%s)"
175 #define FUNC_ADPT_ARG(adapter) __func__, adapter->pnetdev->name
176
177 #define rtw_signal_process(pid, sig) kill_pid(find_vpid((pid)),(sig), 1)
178
179 u64 rtw_modular6423a(u64 x, u64 y);
180 u64 rtw_division6423a(u64 x, u64 y);
181
182
183 /* Macros for handling unaligned memory accesses */
184
185 #define RTW_GET_BE24(a) ((((u32) (a)[0]) << 16) | (((u32) (a)[1]) << 8) | \
186 ((u32) (a)[2]))
187
188
189 struct rtw_cbuf {
190 u32 write;
191 u32 read;
192 u32 size;
193 void *bufs[0];
194 };
195
196 bool rtw_cbuf_full23a(struct rtw_cbuf *cbuf);
197 bool rtw_cbuf_empty23a(struct rtw_cbuf *cbuf);
198 bool rtw_cbuf_push23a(struct rtw_cbuf *cbuf, void *buf);
199 void *rtw_cbuf_pop23a(struct rtw_cbuf *cbuf);
200 struct rtw_cbuf *rtw_cbuf_alloc23a(u32 size);
201 void rtw_cbuf_free(struct rtw_cbuf *cbuf);
202 int rtw_change_ifname(struct rtw_adapter *padapter, const char *ifname);
203 s32 c2h_evt_hdl(struct rtw_adapter *adapter, struct c2h_evt_hdr *c2h_evt, c2h_id_filter filter);
204 void indicate_wx_scan_complete_event(struct rtw_adapter *padapter);
205 u8 rtw_do_join23a(struct rtw_adapter *padapter);
206
207 #endif