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 __IOCTL_CFG80211_H__
16 #define __IOCTL_CFG80211_H__
17 
18 #include <linux/version.h>
19 
20 struct rtw_wdev_invit_info {
21 	u8 state; /* 0: req, 1:rep */
22 	u8 peer_mac[ETH_ALEN];
23 	u8 active;
24 	u8 token;
25 	u8 flags;
26 	u8 status;
27 	u8 req_op_ch;
28 	u8 rsp_op_ch;
29 };
30 
31 #define rtw_wdev_invit_info_init(invit_info) \
32 	do { \
33 		(invit_info)->state = 0xff; \
34 		memset((invit_info)->peer_mac, 0, ETH_ALEN); \
35 		(invit_info)->active = 0xff; \
36 		(invit_info)->token = 0; \
37 		(invit_info)->flags = 0x00; \
38 		(invit_info)->status = 0xff; \
39 		(invit_info)->req_op_ch = 0; \
40 		(invit_info)->rsp_op_ch = 0; \
41 	} while (0)
42 
43 struct rtw_wdev_nego_info {
44 	u8 state; /* 0: req, 1:rep, 2:conf */
45 	u8 peer_mac[ETH_ALEN];
46 	u8 active;
47 	u8 token;
48 	u8 status;
49 	u8 req_intent;
50 	u8 req_op_ch;
51 	u8 req_listen_ch;
52 	u8 rsp_intent;
53 	u8 rsp_op_ch;
54 	u8 conf_op_ch;
55 };
56 
57 #define rtw_wdev_nego_info_init(nego_info) \
58 	do { \
59 		(nego_info)->state = 0xff; \
60 		memset((nego_info)->peer_mac, 0, ETH_ALEN); \
61 		(nego_info)->active = 0xff; \
62 		(nego_info)->token = 0; \
63 		(nego_info)->status = 0xff; \
64 		(nego_info)->req_intent = 0xff; \
65 		(nego_info)->req_op_ch = 0; \
66 		(nego_info)->req_listen_ch = 0; \
67 		(nego_info)->rsp_intent = 0xff; \
68 		(nego_info)->rsp_op_ch = 0; \
69 		(nego_info)->conf_op_ch = 0; \
70 	} while (0)
71 
72 struct rtw_wdev_priv
73 {
74 	struct wireless_dev *rtw_wdev;
75 
76 	struct adapter *padapter;
77 
78 	struct cfg80211_scan_request *scan_request;
79 	_lock scan_req_lock;
80 
81 	struct net_device *pmon_ndev;/* for monitor interface */
82 	char ifname_mon[IFNAMSIZ + 1]; /* interface name for monitor interface */
83 
84 	u8 p2p_enabled;
85 
86 	u8 provdisc_req_issued;
87 
88 	struct rtw_wdev_invit_info invit_info;
89 	struct rtw_wdev_nego_info nego_info;
90 
91 	u8 bandroid_scan;
92 	bool block;
93 	bool power_mgmt;
94 };
95 
96 #define wiphy_to_adapter(x) (*((struct adapter **)wiphy_priv(x)))
97 
98 #define wdev_to_ndev(w) ((w)->netdev)
99 
100 int rtw_wdev_alloc(struct adapter *padapter, struct device *dev);
101 void rtw_wdev_free(struct wireless_dev *wdev);
102 void rtw_wdev_unregister(struct wireless_dev *wdev);
103 
104 void rtw_cfg80211_init_wiphy(struct adapter *padapter);
105 
106 void rtw_cfg80211_unlink_bss(struct adapter *padapter, struct wlan_network *pnetwork);
107 void rtw_cfg80211_surveydone_event_callback(struct adapter *padapter);
108 struct cfg80211_bss *rtw_cfg80211_inform_bss(struct adapter *padapter, struct wlan_network *pnetwork);
109 int rtw_cfg80211_check_bss(struct adapter *padapter);
110 void rtw_cfg80211_ibss_indicate_connect(struct adapter *padapter);
111 void rtw_cfg80211_indicate_connect(struct adapter *padapter);
112 void rtw_cfg80211_indicate_disconnect(struct adapter *padapter);
113 void rtw_cfg80211_indicate_scan_done(struct adapter *adapter, bool aborted);
114 
115 void rtw_cfg80211_indicate_sta_assoc(struct adapter *padapter, u8 *pmgmt_frame, uint frame_len);
116 void rtw_cfg80211_indicate_sta_disassoc(struct adapter *padapter, unsigned char *da, unsigned short reason);
117 
118 void rtw_cfg80211_rx_action(struct adapter *adapter, u8 *frame, uint frame_len, const char*msg);
119 
120 bool rtw_cfg80211_pwr_mgmt(struct adapter *adapter);
121 
122 #define rtw_cfg80211_rx_mgmt(adapter, freq, sig_dbm, buf, len, gfp) cfg80211_rx_mgmt((adapter)->rtw_wdev, freq, sig_dbm, buf, len, 0)
123 #define rtw_cfg80211_send_rx_assoc(adapter, bss, buf, len) cfg80211_send_rx_assoc((adapter)->pnetdev, bss, buf, len)
124 #define rtw_cfg80211_mgmt_tx_status(adapter, cookie, buf, len, ack, gfp) cfg80211_mgmt_tx_status((adapter)->rtw_wdev, cookie, buf, len, ack, gfp)
125 #define rtw_cfg80211_ready_on_channel(adapter, cookie, chan, channel_type, duration, gfp)  cfg80211_ready_on_channel((adapter)->rtw_wdev, cookie, chan, duration, gfp)
126 #define rtw_cfg80211_remain_on_channel_expired(adapter, cookie, chan, chan_type, gfp) cfg80211_remain_on_channel_expired((adapter)->rtw_wdev, cookie, chan, gfp)
127 
128 #endif /* __IOCTL_CFG80211_H__ */
129