These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / staging / rtl8188eu / 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  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17  *
18  *
19  ******************************************************************************/
20 #ifndef __OSDEP_SERVICE_H_
21 #define __OSDEP_SERVICE_H_
22
23 #include <basic_types.h>
24
25 #define _FAIL           0
26 #define _SUCCESS        1
27 #define RTW_RX_HANDLED  2
28
29 #include <linux/spinlock.h>
30 #include <linux/compiler.h>
31 #include <linux/kernel.h>
32 #include <linux/errno.h>
33 #include <linux/slab.h>
34 #include <linux/module.h>
35 #include <linux/kref.h>
36 #include <linux/netdevice.h>
37 #include <linux/skbuff.h>
38 #include <linux/circ_buf.h>
39 #include <linux/uaccess.h>
40 #include <asm/byteorder.h>
41 #include <linux/atomic.h>
42 #include <linux/io.h>
43 #include <linux/semaphore.h>
44 #include <linux/sem.h>
45 #include <linux/sched.h>
46 #include <linux/etherdevice.h>
47 #include <linux/wireless.h>
48 #include <net/iw_handler.h>
49 #include <linux/if_arp.h>
50 #include <linux/rtnetlink.h>
51 #include <linux/delay.h>
52 #include <linux/proc_fs.h>      /*  Necessary because we use the proc fs */
53 #include <linux/interrupt.h>    /*  for struct tasklet_struct */
54 #include <linux/ip.h>
55 #include <linux/kthread.h>
56
57 #include <linux/usb.h>
58 #include <linux/usb/ch9.h>
59
60 struct  __queue {
61         struct  list_head       queue;
62         spinlock_t lock;
63 };
64
65 static inline struct list_head *get_list_head(struct __queue *queue)
66 {
67         return &(queue->queue);
68 }
69
70 static inline int rtw_netif_queue_stopped(struct net_device *pnetdev)
71 {
72         return  netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 0)) &&
73                 netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 1)) &&
74                 netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 2)) &&
75                 netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 3));
76 }
77
78 int RTW_STATUS_CODE(int error_code);
79
80 #define rtw_update_mem_stat(flag, sz) do {} while (0)
81 u8 *_rtw_malloc(u32 sz);
82 #define rtw_malloc(sz)                  _rtw_malloc((sz))
83
84 void *rtw_malloc2d(int h, int w, int size);
85
86 u32  _rtw_down_sema(struct semaphore *sema);
87
88 void _rtw_init_queue(struct __queue *pqueue);
89
90 s32  rtw_get_passing_time_ms(u32 start);
91
92 struct rtw_netdev_priv_indicator {
93         void *priv;
94         u32 sizeof_priv;
95 };
96 struct net_device *rtw_alloc_etherdev_with_old_priv(int sizeof_priv,
97                                                     void *old_priv);
98
99 #define rtw_netdev_priv(netdev)                                 \
100         (((struct rtw_netdev_priv_indicator *)netdev_priv(netdev))->priv)
101 void rtw_free_netdev(struct net_device *netdev);
102
103 #define NDEV_FMT "%s"
104 #define NDEV_ARG(ndev) ndev->name
105 #define ADPT_FMT "%s"
106 #define ADPT_ARG(adapter) adapter->pnetdev->name
107 #define FUNC_NDEV_FMT "%s(%s)"
108 #define FUNC_NDEV_ARG(ndev) __func__, ndev->name
109 #define FUNC_ADPT_FMT "%s(%s)"
110 #define FUNC_ADPT_ARG(adapter) __func__, adapter->pnetdev->name
111
112 u64 rtw_modular64(u64 x, u64 y);
113
114 /* Macros for handling unaligned memory accesses */
115
116 #define RTW_GET_BE24(a) ((((u32)(a)[0]) << 16) | (((u32) (a)[1]) << 8) | \
117                          ((u32)(a)[2]))
118
119 void rtw_buf_free(u8 **buf, u32 *buf_len);
120 void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len);
121 #endif