• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /******************************************************************************
3  *
4  * Copyright(c) 2007 - 2013 Realtek Corporation. All rights reserved.
5  *
6  ******************************************************************************/
7 #ifndef __OSDEP_LINUX_SERVICE_H_
8 #define __OSDEP_LINUX_SERVICE_H_
9 
10 	#include <linux/spinlock.h>
11 	#include <linux/compiler.h>
12 	#include <linux/kernel.h>
13 	#include <linux/errno.h>
14 	#include <linux/init.h>
15 	#include <linux/slab.h>
16 	#include <linux/module.h>
17 	#include <linux/kref.h>
18 	/* include <linux/smp_lock.h> */
19 	#include <linux/netdevice.h>
20 	#include <linux/skbuff.h>
21 	#include <linux/uaccess.h>
22 	#include <asm/byteorder.h>
23 	#include <linux/atomic.h>
24 	#include <linux/io.h>
25 	#include <linux/sem.h>
26 	#include <linux/sched.h>
27 	#include <linux/etherdevice.h>
28 	#include <linux/wireless.h>
29 	#include <net/iw_handler.h>
30 	#include <linux/if_arp.h>
31 	#include <linux/rtnetlink.h>
32 	#include <linux/delay.h>
33 	#include <linux/interrupt.h>	/*  for struct tasklet_struct */
34 	#include <linux/ip.h>
35 	#include <linux/kthread.h>
36 	#include <linux/list.h>
37 	#include <linux/vmalloc.h>
38 
39 /* 	#include <linux/ieee80211.h> */
40         #include <net/ieee80211_radiotap.h>
41 	#include <net/cfg80211.h>
42 
43 	typedef	spinlock_t	_lock;
44 	typedef struct mutex		_mutex;
45 	typedef struct timer_list _timer;
46 
47 	struct	__queue	{
48 		struct	list_head	queue;
49 		_lock	lock;
50 	};
51 
52 	typedef	struct sk_buff	_pkt;
53 	typedef unsigned char _buffer;
54 
55 	typedef	int	_OS_STATUS;
56 	/* typedef u32 _irqL; */
57 	typedef unsigned long _irqL;
58 	typedef	struct	net_device * _nic_hdl;
59 
60 	#define thread_exit() complete_and_exit(NULL, 0)
61 
62 	typedef void timer_hdl_return;
63 	typedef void* timer_hdl_context;
64 
65 	typedef struct work_struct _workitem;
66 
get_next(struct list_head * list)67 static inline struct list_head *get_next(struct list_head	*list)
68 {
69 	return list->next;
70 }
71 
get_list_head(struct __queue * queue)72 static inline struct list_head	*get_list_head(struct __queue	*queue)
73 {
74 	return (&(queue->queue));
75 }
76 
77 
78 #define LIST_CONTAINOR(ptr, type, member) \
79 	container_of(ptr, type, member)
80 
_set_timer(_timer * ptimer,u32 delay_time)81 static inline void _set_timer(_timer *ptimer, u32 delay_time)
82 {
83 	mod_timer(ptimer, (jiffies + (delay_time * HZ / 1000)));
84 }
85 
_init_workitem(_workitem * pwork,void * pfunc,void * cntx)86 static inline void _init_workitem(_workitem *pwork, void *pfunc, void *cntx)
87 {
88 	INIT_WORK(pwork, pfunc);
89 }
90 
_set_workitem(_workitem * pwork)91 static inline void _set_workitem(_workitem *pwork)
92 {
93 	schedule_work(pwork);
94 }
95 
_cancel_workitem_sync(_workitem * pwork)96 static inline void _cancel_workitem_sync(_workitem *pwork)
97 {
98 	cancel_work_sync(pwork);
99 }
100 
rtw_netif_queue_stopped(struct net_device * pnetdev)101 static inline int rtw_netif_queue_stopped(struct net_device *pnetdev)
102 {
103 	return (netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 0)) &&
104 		netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 1)) &&
105 		netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 2)) &&
106 		netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 3)));
107 }
108 
rtw_netif_wake_queue(struct net_device * pnetdev)109 static inline void rtw_netif_wake_queue(struct net_device *pnetdev)
110 {
111 	netif_tx_wake_all_queues(pnetdev);
112 }
113 
rtw_netif_start_queue(struct net_device * pnetdev)114 static inline void rtw_netif_start_queue(struct net_device *pnetdev)
115 {
116 	netif_tx_start_all_queues(pnetdev);
117 }
118 
rtw_netif_stop_queue(struct net_device * pnetdev)119 static inline void rtw_netif_stop_queue(struct net_device *pnetdev)
120 {
121 	netif_tx_stop_all_queues(pnetdev);
122 }
123 
124 #define rtw_signal_process(pid, sig) kill_pid(find_vpid((pid)), (sig), 1)
125 
126 #define NDEV_FMT "%s"
127 #define NDEV_ARG(ndev) ndev->name
128 #define ADPT_FMT "%s"
129 #define ADPT_ARG(adapter) adapter->pnetdev->name
130 #define FUNC_NDEV_FMT "%s(%s)"
131 #define FUNC_NDEV_ARG(ndev) __func__, ndev->name
132 #define FUNC_ADPT_FMT "%s(%s)"
133 #define FUNC_ADPT_ARG(adapter) __func__, adapter->pnetdev->name
134 
135 struct rtw_netdev_priv_indicator {
136 	void *priv;
137 	u32 sizeof_priv;
138 };
139 
rtw_netdev_priv(struct net_device * netdev)140 static inline struct adapter *rtw_netdev_priv(struct net_device *netdev)
141 {
142 	return ((struct rtw_netdev_priv_indicator *)netdev_priv(netdev))->priv;
143 }
144 
145 struct net_device *rtw_alloc_etherdev_with_old_priv(int sizeof_priv, void *old_priv);
146 extern struct net_device * rtw_alloc_etherdev(int sizeof_priv);
147 
148 #endif
149