• 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 	struct	__queue	{
44 		struct	list_head	queue;
45 		spinlock_t	lock;
46 	};
47 
get_next(struct list_head * list)48 static inline struct list_head *get_next(struct list_head	*list)
49 {
50 	return list->next;
51 }
52 
get_list_head(struct __queue * queue)53 static inline struct list_head	*get_list_head(struct __queue	*queue)
54 {
55 	return (&(queue->queue));
56 }
57 
_set_timer(struct timer_list * ptimer,u32 delay_time)58 static inline void _set_timer(struct timer_list *ptimer, u32 delay_time)
59 {
60 	mod_timer(ptimer, (jiffies + (delay_time * HZ / 1000)));
61 }
62 
_init_workitem(struct work_struct * pwork,void * pfunc,void * cntx)63 static inline void _init_workitem(struct work_struct *pwork, void *pfunc, void *cntx)
64 {
65 	INIT_WORK(pwork, pfunc);
66 }
67 
_set_workitem(struct work_struct * pwork)68 static inline void _set_workitem(struct work_struct *pwork)
69 {
70 	schedule_work(pwork);
71 }
72 
_cancel_workitem_sync(struct work_struct * pwork)73 static inline void _cancel_workitem_sync(struct work_struct *pwork)
74 {
75 	cancel_work_sync(pwork);
76 }
77 
rtw_netif_queue_stopped(struct net_device * pnetdev)78 static inline int rtw_netif_queue_stopped(struct net_device *pnetdev)
79 {
80 	return (netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 0)) &&
81 		netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 1)) &&
82 		netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 2)) &&
83 		netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 3)));
84 }
85 
rtw_netif_wake_queue(struct net_device * pnetdev)86 static inline void rtw_netif_wake_queue(struct net_device *pnetdev)
87 {
88 	netif_tx_wake_all_queues(pnetdev);
89 }
90 
rtw_netif_start_queue(struct net_device * pnetdev)91 static inline void rtw_netif_start_queue(struct net_device *pnetdev)
92 {
93 	netif_tx_start_all_queues(pnetdev);
94 }
95 
rtw_netif_stop_queue(struct net_device * pnetdev)96 static inline void rtw_netif_stop_queue(struct net_device *pnetdev)
97 {
98 	netif_tx_stop_all_queues(pnetdev);
99 }
100 
101 #define rtw_signal_process(pid, sig) kill_pid(find_vpid((pid)), (sig), 1)
102 
103 #define NDEV_ARG(ndev) ndev->name
104 #define ADPT_ARG(adapter) adapter->pnetdev->name
105 #define FUNC_NDEV_FMT "%s(%s)"
106 #define FUNC_NDEV_ARG(ndev) __func__, ndev->name
107 #define FUNC_ADPT_FMT "%s(%s)"
108 #define FUNC_ADPT_ARG(adapter) __func__, adapter->pnetdev->name
109 
110 struct rtw_netdev_priv_indicator {
111 	void *priv;
112 	u32 sizeof_priv;
113 };
114 
rtw_netdev_priv(struct net_device * netdev)115 static inline struct adapter *rtw_netdev_priv(struct net_device *netdev)
116 {
117 	return ((struct rtw_netdev_priv_indicator *)netdev_priv(netdev))->priv;
118 }
119 
120 struct net_device *rtw_alloc_etherdev_with_old_priv(int sizeof_priv, void *old_priv);
121 extern struct net_device *rtw_alloc_etherdev(int sizeof_priv);
122 
123 #endif
124