1b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
2cb3126e6SKarl Relton /* cfg80211 Interface for prism2_usb module */
36eaf0788STair Rzayev #include "hfa384x.h"
46eaf0788STair Rzayev #include "prism2mgmt.h"
5cb3126e6SKarl Relton 
6d34602deSJustin P. Mattock /* Prism2 channel/frequency/bitrate declarations */
7cb3126e6SKarl Relton static const struct ieee80211_channel prism2_channels[] = {
8cb3126e6SKarl Relton 	{ .center_freq = 2412 },
9cb3126e6SKarl Relton 	{ .center_freq = 2417 },
10cb3126e6SKarl Relton 	{ .center_freq = 2422 },
11cb3126e6SKarl Relton 	{ .center_freq = 2427 },
12cb3126e6SKarl Relton 	{ .center_freq = 2432 },
13cb3126e6SKarl Relton 	{ .center_freq = 2437 },
14cb3126e6SKarl Relton 	{ .center_freq = 2442 },
15cb3126e6SKarl Relton 	{ .center_freq = 2447 },
16cb3126e6SKarl Relton 	{ .center_freq = 2452 },
17cb3126e6SKarl Relton 	{ .center_freq = 2457 },
18cb3126e6SKarl Relton 	{ .center_freq = 2462 },
19cb3126e6SKarl Relton 	{ .center_freq = 2467 },
20cb3126e6SKarl Relton 	{ .center_freq = 2472 },
21cb3126e6SKarl Relton 	{ .center_freq = 2484 },
22cb3126e6SKarl Relton };
23cb3126e6SKarl Relton 
24cb3126e6SKarl Relton static const struct ieee80211_rate prism2_rates[] = {
25cb3126e6SKarl Relton 	{ .bitrate = 10 },
26cb3126e6SKarl Relton 	{ .bitrate = 20 },
27cb3126e6SKarl Relton 	{ .bitrate = 55 },
28cb3126e6SKarl Relton 	{ .bitrate = 110 }
29cb3126e6SKarl Relton };
30cb3126e6SKarl Relton 
31cb3126e6SKarl Relton #define PRISM2_NUM_CIPHER_SUITES 2
32cb3126e6SKarl Relton static const u32 prism2_cipher_suites[PRISM2_NUM_CIPHER_SUITES] = {
33cb3126e6SKarl Relton 	WLAN_CIPHER_SUITE_WEP40,
34cb3126e6SKarl Relton 	WLAN_CIPHER_SUITE_WEP104
35cb3126e6SKarl Relton };
36cb3126e6SKarl Relton 
37cb3126e6SKarl Relton /* prism2 device private data */
38cb3126e6SKarl Relton struct prism2_wiphy_private {
39c9573a8dSsayli karnik 	struct wlandevice *wlandev;
40cb3126e6SKarl Relton 
41cb3126e6SKarl Relton 	struct ieee80211_supported_band band;
42cb3126e6SKarl Relton 	struct ieee80211_channel channels[ARRAY_SIZE(prism2_channels)];
43cb3126e6SKarl Relton 	struct ieee80211_rate rates[ARRAY_SIZE(prism2_rates)];
44cb3126e6SKarl Relton 
45cb3126e6SKarl Relton 	struct cfg80211_scan_request *scan_request;
46cb3126e6SKarl Relton };
47cb3126e6SKarl Relton 
48cb3126e6SKarl Relton static const void * const prism2_wiphy_privid = &prism2_wiphy_privid;
49cb3126e6SKarl Relton 
50cb3126e6SKarl Relton /* Helper Functions */
51cb3126e6SKarl Relton static int prism2_result2err(int prism2_result)
52cb3126e6SKarl Relton {
53cb3126e6SKarl Relton 	int err = 0;
54cb3126e6SKarl Relton 
55cb3126e6SKarl Relton 	switch (prism2_result) {
56cb3126e6SKarl Relton 	case P80211ENUM_resultcode_invalid_parameters:
57cb3126e6SKarl Relton 		err = -EINVAL;
58cb3126e6SKarl Relton 		break;
59cb3126e6SKarl Relton 	case P80211ENUM_resultcode_implementation_failure:
60cb3126e6SKarl Relton 		err = -EIO;
61cb3126e6SKarl Relton 		break;
62cb3126e6SKarl Relton 	case P80211ENUM_resultcode_not_supported:
63cb3126e6SKarl Relton 		err = -EOPNOTSUPP;
64cb3126e6SKarl Relton 		break;
65cb3126e6SKarl Relton 	default:
66cb3126e6SKarl Relton 		err = 0;
67cb3126e6SKarl Relton 		break;
68cb3126e6SKarl Relton 	}
69cb3126e6SKarl Relton 
70cb3126e6SKarl Relton 	return err;
71cb3126e6SKarl Relton }
72cb3126e6SKarl Relton 
73c9573a8dSsayli karnik static int prism2_domibset_uint32(struct wlandevice *wlandev, u32 did, u32 data)
74cb3126e6SKarl Relton {
75b6bb56e6SEdgardo Hames 	struct p80211msg_dot11req_mibset msg;
76b26b2325SSergio Paracuellos 	struct p80211item_uint32 *mibitem =
77b26b2325SSergio Paracuellos 			(struct p80211item_uint32 *)&msg.mibattribute.data;
78cb3126e6SKarl Relton 
79cb3126e6SKarl Relton 	msg.msgcode = DIDmsg_dot11req_mibset;
80cb3126e6SKarl Relton 	mibitem->did = did;
81cb3126e6SKarl Relton 	mibitem->data = data;
82cb3126e6SKarl Relton 
83cb3126e6SKarl Relton 	return p80211req_dorequest(wlandev, (u8 *)&msg);
84cb3126e6SKarl Relton }
85cb3126e6SKarl Relton 
86c9573a8dSsayli karnik static int prism2_domibset_pstr32(struct wlandevice *wlandev,
87c1e5f471SJohannes Berg 				  u32 did, u8 len, const u8 *data)
88cb3126e6SKarl Relton {
89b6bb56e6SEdgardo Hames 	struct p80211msg_dot11req_mibset msg;
906a50b5afSSergio Paracuellos 	struct p80211item_pstr32 *mibitem =
916a50b5afSSergio Paracuellos 			(struct p80211item_pstr32 *)&msg.mibattribute.data;
92cb3126e6SKarl Relton 
93cb3126e6SKarl Relton 	msg.msgcode = DIDmsg_dot11req_mibset;
94cb3126e6SKarl Relton 	mibitem->did = did;
95cb3126e6SKarl Relton 	mibitem->data.len = len;
96cb3126e6SKarl Relton 	memcpy(mibitem->data.data, data, len);
97cb3126e6SKarl Relton 
98cb3126e6SKarl Relton 	return p80211req_dorequest(wlandev, (u8 *)&msg);
99cb3126e6SKarl Relton }
100cb3126e6SKarl Relton 
101cb3126e6SKarl Relton /* The interface functions, called by the cfg80211 layer */
10255da06ebSTeodora Baluta static int prism2_change_virtual_intf(struct wiphy *wiphy,
103cb3126e6SKarl Relton 				      struct net_device *dev,
104818a986eSJohannes Berg 				      enum nl80211_iftype type,
105cb3126e6SKarl Relton 				      struct vif_params *params)
106cb3126e6SKarl Relton {
107c9573a8dSsayli karnik 	struct wlandevice *wlandev = dev->ml_priv;
108cb3126e6SKarl Relton 	u32 data;
109cb3126e6SKarl Relton 	int result;
110cb3126e6SKarl Relton 	int err = 0;
111cb3126e6SKarl Relton 
112cb3126e6SKarl Relton 	switch (type) {
113cb3126e6SKarl Relton 	case NL80211_IFTYPE_ADHOC:
1148dd82ebeSEdgardo Hames 		if (wlandev->macmode == WLAN_MACMODE_IBSS_STA)
1158dd82ebeSEdgardo Hames 			goto exit;
116cb3126e6SKarl Relton 		wlandev->macmode = WLAN_MACMODE_IBSS_STA;
117cb3126e6SKarl Relton 		data = 0;
118cb3126e6SKarl Relton 		break;
119cb3126e6SKarl Relton 	case NL80211_IFTYPE_STATION:
1208dd82ebeSEdgardo Hames 		if (wlandev->macmode == WLAN_MACMODE_ESS_STA)
1218dd82ebeSEdgardo Hames 			goto exit;
122cb3126e6SKarl Relton 		wlandev->macmode = WLAN_MACMODE_ESS_STA;
123cb3126e6SKarl Relton 		data = 1;
124cb3126e6SKarl Relton 		break;
125cb3126e6SKarl Relton 	default:
126eed88971SAvinash Kumar 		netdev_warn(dev, "Operation mode: %d not support\n", type);
127cb3126e6SKarl Relton 		return -EOPNOTSUPP;
128cb3126e6SKarl Relton 	}
129cb3126e6SKarl Relton 
130cb3126e6SKarl Relton 	/* Set Operation mode to the PORT TYPE RID */
1318aac4d44SDevendra Naga 	result = prism2_domibset_uint32(wlandev,
1328aac4d44SDevendra Naga 					DIDmib_p2_p2Static_p2CnfPortType,
1338aac4d44SDevendra Naga 					data);
134cb3126e6SKarl Relton 
135cb3126e6SKarl Relton 	if (result)
136cb3126e6SKarl Relton 		err = -EFAULT;
137cb3126e6SKarl Relton 
138cb3126e6SKarl Relton 	dev->ieee80211_ptr->iftype = type;
139cb3126e6SKarl Relton 
140cb3126e6SKarl Relton exit:
141cb3126e6SKarl Relton 	return err;
142cb3126e6SKarl Relton }
143cb3126e6SKarl Relton 
14455da06ebSTeodora Baluta static int prism2_add_key(struct wiphy *wiphy, struct net_device *dev,
14534a488c1SBen Hutchings 			  u8 key_index, bool pairwise, const u8 *mac_addr,
1468dd82ebeSEdgardo Hames 			  struct key_params *params)
1478dd82ebeSEdgardo Hames {
148c9573a8dSsayli karnik 	struct wlandevice *wlandev = dev->ml_priv;
149cb3126e6SKarl Relton 	u32 did;
150cb3126e6SKarl Relton 
151cb3126e6SKarl Relton 	int err = 0;
152cb3126e6SKarl Relton 	int result = 0;
153cb3126e6SKarl Relton 
1540ca6d8e7SClaudiu Beznea 	if (key_index >= NUM_WEPKEYS)
1550ca6d8e7SClaudiu Beznea 		return -EINVAL;
1560ca6d8e7SClaudiu Beznea 
157cb3126e6SKarl Relton 	switch (params->cipher) {
158cb3126e6SKarl Relton 	case WLAN_CIPHER_SUITE_WEP40:
159cb3126e6SKarl Relton 	case WLAN_CIPHER_SUITE_WEP104:
160cb3126e6SKarl Relton 		result = prism2_domibset_uint32(wlandev,
161cb3126e6SKarl Relton 						DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID,
162cb3126e6SKarl Relton 						key_index);
1638dd82ebeSEdgardo Hames 		if (result)
1648dd82ebeSEdgardo Hames 			goto exit;
165cb3126e6SKarl Relton 
166cb3126e6SKarl Relton 		/* send key to driver */
1670ca6d8e7SClaudiu Beznea 		did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_key(key_index + 1);
168cb3126e6SKarl Relton 
169bb1da756SHimangi Saraogi 		result = prism2_domibset_pstr32(wlandev, did,
170bb1da756SHimangi Saraogi 						params->key_len, params->key);
1718dd82ebeSEdgardo Hames 		if (result)
1728dd82ebeSEdgardo Hames 			goto exit;
173cb3126e6SKarl Relton 		break;
174cb3126e6SKarl Relton 
175cb3126e6SKarl Relton 	default:
176cb3126e6SKarl Relton 		pr_debug("Unsupported cipher suite\n");
177cb3126e6SKarl Relton 		result = 1;
178cb3126e6SKarl Relton 	}
179cb3126e6SKarl Relton 
180cb3126e6SKarl Relton exit:
1818dd82ebeSEdgardo Hames 	if (result)
1828dd82ebeSEdgardo Hames 		err = -EFAULT;
183cb3126e6SKarl Relton 
184cb3126e6SKarl Relton 	return err;
185cb3126e6SKarl Relton }
186cb3126e6SKarl Relton 
18755da06ebSTeodora Baluta static int prism2_get_key(struct wiphy *wiphy, struct net_device *dev,
18855da06ebSTeodora Baluta 			  u8 key_index, bool pairwise,
18955da06ebSTeodora Baluta 			  const u8 *mac_addr, void *cookie,
1908dd82ebeSEdgardo Hames 			  void (*callback)(void *cookie, struct key_params*))
1918dd82ebeSEdgardo Hames {
192c9573a8dSsayli karnik 	struct wlandevice *wlandev = dev->ml_priv;
193cb3126e6SKarl Relton 	struct key_params params;
194cb3126e6SKarl Relton 	int len;
195cb3126e6SKarl Relton 
1968dd82ebeSEdgardo Hames 	if (key_index >= NUM_WEPKEYS)
1978dd82ebeSEdgardo Hames 		return -EINVAL;
198cb3126e6SKarl Relton 
199cb3126e6SKarl Relton 	len = wlandev->wep_keylens[key_index];
200cb3126e6SKarl Relton 	memset(&params, 0, sizeof(params));
201cb3126e6SKarl Relton 
2028dd82ebeSEdgardo Hames 	if (len == 13)
203cb3126e6SKarl Relton 		params.cipher = WLAN_CIPHER_SUITE_WEP104;
2048dd82ebeSEdgardo Hames 	else if (len == 5)
205cb3126e6SKarl Relton 		params.cipher = WLAN_CIPHER_SUITE_WEP104;
2068dd82ebeSEdgardo Hames 	else
2078dd82ebeSEdgardo Hames 		return -ENOENT;
208cb3126e6SKarl Relton 	params.key_len = len;
209cb3126e6SKarl Relton 	params.key = wlandev->wep_keys[key_index];
210aff3ea4eSKarl Relton 	params.seq_len = 0;
211cb3126e6SKarl Relton 
212cb3126e6SKarl Relton 	callback(cookie, &params);
2138dd82ebeSEdgardo Hames 
214cb3126e6SKarl Relton 	return 0;
215cb3126e6SKarl Relton }
216cb3126e6SKarl Relton 
21755da06ebSTeodora Baluta static int prism2_del_key(struct wiphy *wiphy, struct net_device *dev,
21834a488c1SBen Hutchings 			  u8 key_index, bool pairwise, const u8 *mac_addr)
2198dd82ebeSEdgardo Hames {
220c9573a8dSsayli karnik 	struct wlandevice *wlandev = dev->ml_priv;
221cb3126e6SKarl Relton 	u32 did;
222cb3126e6SKarl Relton 	int err = 0;
223cb3126e6SKarl Relton 	int result = 0;
224cb3126e6SKarl Relton 
225cb3126e6SKarl Relton 	/* There is no direct way in the hardware (AFAIK) of removing
22635028fe1SGavin O'Leary 	 * a key, so we will cheat by setting the key to a bogus value
22735028fe1SGavin O'Leary 	 */
22835028fe1SGavin O'Leary 
2290ca6d8e7SClaudiu Beznea 	if (key_index >= NUM_WEPKEYS)
2300ca6d8e7SClaudiu Beznea 		return -EINVAL;
2310ca6d8e7SClaudiu Beznea 
232cb3126e6SKarl Relton 	/* send key to driver */
2330ca6d8e7SClaudiu Beznea 	did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_key(key_index + 1);
234cb3126e6SKarl Relton 	result = prism2_domibset_pstr32(wlandev, did, 13, "0000000000000");
235cb3126e6SKarl Relton 
2368dd82ebeSEdgardo Hames 	if (result)
2378dd82ebeSEdgardo Hames 		err = -EFAULT;
238cb3126e6SKarl Relton 
239cb3126e6SKarl Relton 	return err;
240cb3126e6SKarl Relton }
241cb3126e6SKarl Relton 
24255da06ebSTeodora Baluta static int prism2_set_default_key(struct wiphy *wiphy, struct net_device *dev,
2439005fcd8SHarry Wei 				  u8 key_index, bool unicast, bool multicast)
2448dd82ebeSEdgardo Hames {
245c9573a8dSsayli karnik 	struct wlandevice *wlandev = dev->ml_priv;
246cb3126e6SKarl Relton 
247cb3126e6SKarl Relton 	int err = 0;
248cb3126e6SKarl Relton 	int result = 0;
249cb3126e6SKarl Relton 
250cb3126e6SKarl Relton 	result = prism2_domibset_uint32(wlandev,
251cb3126e6SKarl Relton 		DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID,
252cb3126e6SKarl Relton 		key_index);
253cb3126e6SKarl Relton 
2548dd82ebeSEdgardo Hames 	if (result)
2558dd82ebeSEdgardo Hames 		err = -EFAULT;
256cb3126e6SKarl Relton 
257cb3126e6SKarl Relton 	return err;
258cb3126e6SKarl Relton }
259cb3126e6SKarl Relton 
26055da06ebSTeodora Baluta static int prism2_get_station(struct wiphy *wiphy, struct net_device *dev,
2613b3a0162SJohannes Berg 			      const u8 *mac, struct station_info *sinfo)
2628dd82ebeSEdgardo Hames {
263c9573a8dSsayli karnik 	struct wlandevice *wlandev = dev->ml_priv;
264b6bb56e6SEdgardo Hames 	struct p80211msg_lnxreq_commsquality quality;
265cb3126e6SKarl Relton 	int result;
266cb3126e6SKarl Relton 
267cb3126e6SKarl Relton 	memset(sinfo, 0, sizeof(*sinfo));
268cb3126e6SKarl Relton 
269e52f2149SSandhya Bankar 	if (!wlandev || (wlandev->msdstate != WLAN_MSD_RUNNING))
270cb3126e6SKarl Relton 		return -EOPNOTSUPP;
271cb3126e6SKarl Relton 
272cb3126e6SKarl Relton 	/* build request message */
273cb3126e6SKarl Relton 	quality.msgcode = DIDmsg_lnxreq_commsquality;
274cb3126e6SKarl Relton 	quality.dbm.data = P80211ENUM_truth_true;
275cb3126e6SKarl Relton 	quality.dbm.status = P80211ENUM_msgitem_status_data_ok;
276cb3126e6SKarl Relton 
277cb3126e6SKarl Relton 	/* send message to nsd */
278e52f2149SSandhya Bankar 	if (!wlandev->mlmerequest)
279cb3126e6SKarl Relton 		return -EOPNOTSUPP;
280cb3126e6SKarl Relton 
2813d049431SEdgardo Hames 	result = wlandev->mlmerequest(wlandev, (struct p80211msg *)&quality);
282cb3126e6SKarl Relton 
283cb3126e6SKarl Relton 	if (result == 0) {
284cb3126e6SKarl Relton 		sinfo->txrate.legacy = quality.txrate.data;
285319090bfSJohannes Berg 		sinfo->filled |= BIT(NL80211_STA_INFO_TX_BITRATE);
286cb3126e6SKarl Relton 		sinfo->signal = quality.level.data;
287319090bfSJohannes Berg 		sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL);
288cb3126e6SKarl Relton 	}
289cb3126e6SKarl Relton 
290cb3126e6SKarl Relton 	return result;
291cb3126e6SKarl Relton }
292cb3126e6SKarl Relton 
293bb1da756SHimangi Saraogi static int prism2_scan(struct wiphy *wiphy,
294bb1da756SHimangi Saraogi 		       struct cfg80211_scan_request *request)
295cb3126e6SKarl Relton {
2965d5d7c3bSEmil Goode 	struct net_device *dev;
297cb3126e6SKarl Relton 	struct prism2_wiphy_private *priv = wiphy_priv(wiphy);
298c9573a8dSsayli karnik 	struct wlandevice *wlandev;
299b6bb56e6SEdgardo Hames 	struct p80211msg_dot11req_scan msg1;
300b6bb56e6SEdgardo Hames 	struct p80211msg_dot11req_scan_results msg2;
30119f798adSKrzysztof Wilczynski 	struct cfg80211_bss *bss;
3021d76250bSAvraham Stern 	struct cfg80211_scan_info info = {};
3031d76250bSAvraham Stern 
304cb3126e6SKarl Relton 	int result;
305cb3126e6SKarl Relton 	int err = 0;
306cb3126e6SKarl Relton 	int numbss = 0;
307cb3126e6SKarl Relton 	int i = 0;
308cb3126e6SKarl Relton 	u8 ie_buf[46];
309cb3126e6SKarl Relton 	int ie_len;
310cb3126e6SKarl Relton 
311cb3126e6SKarl Relton 	if (!request)
312cb3126e6SKarl Relton 		return -EINVAL;
313cb3126e6SKarl Relton 
3145d5d7c3bSEmil Goode 	dev = request->wdev->netdev;
3155d5d7c3bSEmil Goode 	wlandev = dev->ml_priv;
3165d5d7c3bSEmil Goode 
317cb3126e6SKarl Relton 	if (priv->scan_request && priv->scan_request != request)
318cb3126e6SKarl Relton 		return -EBUSY;
319cb3126e6SKarl Relton 
320cb3126e6SKarl Relton 	if (wlandev->macmode == WLAN_MACMODE_ESS_AP) {
321eed88971SAvinash Kumar 		netdev_err(dev, "Can't scan in AP mode\n");
322cb3126e6SKarl Relton 		return -EOPNOTSUPP;
323cb3126e6SKarl Relton 	}
324cb3126e6SKarl Relton 
325cb3126e6SKarl Relton 	priv->scan_request = request;
326cb3126e6SKarl Relton 
32789e13b45SSergio Paracuellos 	memset(&msg1, 0x00, sizeof(msg1));
328cb3126e6SKarl Relton 	msg1.msgcode = DIDmsg_dot11req_scan;
329cb3126e6SKarl Relton 	msg1.bsstype.data = P80211ENUM_bsstype_any;
330cb3126e6SKarl Relton 
331625aeb3aSDan Carpenter 	memset(&msg1.bssid.data.data, 0xFF, sizeof(msg1.bssid.data.data));
332cb3126e6SKarl Relton 	msg1.bssid.data.len = 6;
333cb3126e6SKarl Relton 
334cb3126e6SKarl Relton 	if (request->n_ssids > 0) {
335cb3126e6SKarl Relton 		msg1.scantype.data = P80211ENUM_scantype_active;
336cb3126e6SKarl Relton 		msg1.ssid.data.len = request->ssids->ssid_len;
3378aac4d44SDevendra Naga 		memcpy(msg1.ssid.data.data,
3388aac4d44SDevendra Naga 		       request->ssids->ssid, request->ssids->ssid_len);
339cb3126e6SKarl Relton 	} else {
340cb3126e6SKarl Relton 		msg1.scantype.data = 0;
341cb3126e6SKarl Relton 	}
342cb3126e6SKarl Relton 	msg1.probedelay.data = 0;
343cb3126e6SKarl Relton 
344cb3126e6SKarl Relton 	for (i = 0;
345cb3126e6SKarl Relton 		(i < request->n_channels) && i < ARRAY_SIZE(prism2_channels);
346cb3126e6SKarl Relton 		i++)
347cb3126e6SKarl Relton 		msg1.channellist.data.data[i] =
348bb1da756SHimangi Saraogi 			ieee80211_frequency_to_channel(
349bb1da756SHimangi Saraogi 				request->channels[i]->center_freq);
350cb3126e6SKarl Relton 	msg1.channellist.data.len = request->n_channels;
351cb3126e6SKarl Relton 
352cb3126e6SKarl Relton 	msg1.maxchanneltime.data = 250;
353cb3126e6SKarl Relton 	msg1.minchanneltime.data = 200;
354cb3126e6SKarl Relton 
355cb3126e6SKarl Relton 	result = p80211req_dorequest(wlandev, (u8 *)&msg1);
356cb3126e6SKarl Relton 	if (result) {
357cb3126e6SKarl Relton 		err = prism2_result2err(msg1.resultcode.data);
358cb3126e6SKarl Relton 		goto exit;
359cb3126e6SKarl Relton 	}
360cb3126e6SKarl Relton 	/* Now retrieve scan results */
361cb3126e6SKarl Relton 	numbss = msg1.numbss.data;
362cb3126e6SKarl Relton 
363cb3126e6SKarl Relton 	for (i = 0; i < numbss; i++) {
3644e5e9d7cSZhao, Gang 		int freq;
3654e5e9d7cSZhao, Gang 
366cb3126e6SKarl Relton 		memset(&msg2, 0, sizeof(msg2));
367cb3126e6SKarl Relton 		msg2.msgcode = DIDmsg_dot11req_scan_results;
368cb3126e6SKarl Relton 		msg2.bssindex.data = i;
369cb3126e6SKarl Relton 
370cb3126e6SKarl Relton 		result = p80211req_dorequest(wlandev, (u8 *)&msg2);
371cb3126e6SKarl Relton 		if ((result != 0) ||
372cb3126e6SKarl Relton 		    (msg2.resultcode.data != P80211ENUM_resultcode_success)) {
373cb3126e6SKarl Relton 			break;
374cb3126e6SKarl Relton 		}
375cb3126e6SKarl Relton 
376cb3126e6SKarl Relton 		ie_buf[0] = WLAN_EID_SSID;
377cb3126e6SKarl Relton 		ie_buf[1] = msg2.ssid.data.len;
378cb3126e6SKarl Relton 		ie_len = ie_buf[1] + 2;
379efffed8eSsayli karnik 		memcpy(&ie_buf[2], &msg2.ssid.data.data, msg2.ssid.data.len);
3804e5e9d7cSZhao, Gang 		freq = ieee80211_channel_to_frequency(msg2.dschannel.data,
38157fbcce3SJohannes Berg 						      NL80211_BAND_2GHZ);
38219f798adSKrzysztof Wilczynski 		bss = cfg80211_inform_bss(wiphy,
3834e5e9d7cSZhao, Gang 			ieee80211_get_channel(wiphy, freq),
3845bc8c1f2SJohannes Berg 			CFG80211_BSS_FTYPE_UNKNOWN,
385efffed8eSsayli karnik 			(const u8 *)&msg2.bssid.data.data,
386cb3126e6SKarl Relton 			msg2.timestamp.data, msg2.capinfo.data,
387cb3126e6SKarl Relton 			msg2.beaconperiod.data,
388cb3126e6SKarl Relton 			ie_buf,
389cb3126e6SKarl Relton 			ie_len,
390cb3126e6SKarl Relton 			(msg2.signal.data - 65536) * 100, /* Conversion to signed type */
391cb3126e6SKarl Relton 			GFP_KERNEL
392cb3126e6SKarl Relton 		);
39319f798adSKrzysztof Wilczynski 
39419f798adSKrzysztof Wilczynski 		if (!bss) {
39519f798adSKrzysztof Wilczynski 			err = -ENOMEM;
39619f798adSKrzysztof Wilczynski 			goto exit;
39719f798adSKrzysztof Wilczynski 		}
39819f798adSKrzysztof Wilczynski 
3995b112d3dSJohannes Berg 		cfg80211_put_bss(wiphy, bss);
400cb3126e6SKarl Relton 	}
401cb3126e6SKarl Relton 
4028dd82ebeSEdgardo Hames 	if (result)
403cb3126e6SKarl Relton 		err = prism2_result2err(msg2.resultcode.data);
404cb3126e6SKarl Relton 
405cb3126e6SKarl Relton exit:
4061d76250bSAvraham Stern 	info.aborted = !!(err);
4071d76250bSAvraham Stern 	cfg80211_scan_done(request, &info);
408cb3126e6SKarl Relton 	priv->scan_request = NULL;
409cb3126e6SKarl Relton 	return err;
410cb3126e6SKarl Relton }
411cb3126e6SKarl Relton 
41255da06ebSTeodora Baluta static int prism2_set_wiphy_params(struct wiphy *wiphy, u32 changed)
4138dd82ebeSEdgardo Hames {
414cb3126e6SKarl Relton 	struct prism2_wiphy_private *priv = wiphy_priv(wiphy);
415c9573a8dSsayli karnik 	struct wlandevice *wlandev = priv->wlandev;
416cb3126e6SKarl Relton 	u32 data;
417cb3126e6SKarl Relton 	int result;
418cb3126e6SKarl Relton 	int err = 0;
419cb3126e6SKarl Relton 
420cb3126e6SKarl Relton 	if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
421cb3126e6SKarl Relton 		if (wiphy->rts_threshold == -1)
422cb3126e6SKarl Relton 			data = 2347;
423cb3126e6SKarl Relton 		else
424cb3126e6SKarl Relton 			data = wiphy->rts_threshold;
425cb3126e6SKarl Relton 
4268dd82ebeSEdgardo Hames 		result = prism2_domibset_uint32(wlandev,
427cb3126e6SKarl Relton 						DIDmib_dot11mac_dot11OperationTable_dot11RTSThreshold,
428cb3126e6SKarl Relton 						data);
429cb3126e6SKarl Relton 		if (result) {
430cb3126e6SKarl Relton 			err = -EFAULT;
431cb3126e6SKarl Relton 			goto exit;
432cb3126e6SKarl Relton 		}
433cb3126e6SKarl Relton 	}
434cb3126e6SKarl Relton 
435cb3126e6SKarl Relton 	if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
436cb3126e6SKarl Relton 		if (wiphy->frag_threshold == -1)
437cb3126e6SKarl Relton 			data = 2346;
438cb3126e6SKarl Relton 		else
439cb3126e6SKarl Relton 			data = wiphy->frag_threshold;
440cb3126e6SKarl Relton 
4418dd82ebeSEdgardo Hames 		result = prism2_domibset_uint32(wlandev,
442cb3126e6SKarl Relton 						DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold,
443cb3126e6SKarl Relton 						data);
444cb3126e6SKarl Relton 		if (result) {
445cb3126e6SKarl Relton 			err = -EFAULT;
446cb3126e6SKarl Relton 			goto exit;
447cb3126e6SKarl Relton 		}
448cb3126e6SKarl Relton 	}
449cb3126e6SKarl Relton 
450cb3126e6SKarl Relton exit:
451cb3126e6SKarl Relton 	return err;
452cb3126e6SKarl Relton }
453cb3126e6SKarl Relton 
45455da06ebSTeodora Baluta static int prism2_connect(struct wiphy *wiphy, struct net_device *dev,
4558dd82ebeSEdgardo Hames 			  struct cfg80211_connect_params *sme)
4568dd82ebeSEdgardo Hames {
457c9573a8dSsayli karnik 	struct wlandevice *wlandev = dev->ml_priv;
458cb3126e6SKarl Relton 	struct ieee80211_channel *channel = sme->channel;
459b6bb56e6SEdgardo Hames 	struct p80211msg_lnxreq_autojoin msg_join;
460cb3126e6SKarl Relton 	u32 did;
461cb3126e6SKarl Relton 	int length = sme->ssid_len;
462cb3126e6SKarl Relton 	int chan = -1;
463cb3126e6SKarl Relton 	int is_wep = (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP40) ||
464cb3126e6SKarl Relton 	    (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP104);
465cb3126e6SKarl Relton 	int result;
466cb3126e6SKarl Relton 	int err = 0;
467cb3126e6SKarl Relton 
468cb3126e6SKarl Relton 	/* Set the channel */
469cb3126e6SKarl Relton 	if (channel) {
470cb3126e6SKarl Relton 		chan = ieee80211_frequency_to_channel(channel->center_freq);
4718dd82ebeSEdgardo Hames 		result = prism2_domibset_uint32(wlandev,
472cb3126e6SKarl Relton 						DIDmib_dot11phy_dot11PhyDSSSTable_dot11CurrentChannel,
473cb3126e6SKarl Relton 						chan);
4748dd82ebeSEdgardo Hames 		if (result)
4758dd82ebeSEdgardo Hames 			goto exit;
476cb3126e6SKarl Relton 	}
477cb3126e6SKarl Relton 
478d34602deSJustin P. Mattock 	/* Set the authorization */
479cb3126e6SKarl Relton 	if ((sme->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM) ||
480cb3126e6SKarl Relton 	    ((sme->auth_type == NL80211_AUTHTYPE_AUTOMATIC) && !is_wep))
481cb3126e6SKarl Relton 		msg_join.authtype.data = P80211ENUM_authalg_opensystem;
482cb3126e6SKarl Relton 	else if ((sme->auth_type == NL80211_AUTHTYPE_SHARED_KEY) ||
483cb3126e6SKarl Relton 		 ((sme->auth_type == NL80211_AUTHTYPE_AUTOMATIC) && is_wep))
484cb3126e6SKarl Relton 		msg_join.authtype.data = P80211ENUM_authalg_sharedkey;
4858dd82ebeSEdgardo Hames 	else
486eed88971SAvinash Kumar 		netdev_warn(dev,
4878dd82ebeSEdgardo Hames 			    "Unhandled authorisation type for connect (%d)\n",
4888dd82ebeSEdgardo Hames 			    sme->auth_type);
489cb3126e6SKarl Relton 
490cb3126e6SKarl Relton 	/* Set the encryption - we only support wep */
491cb3126e6SKarl Relton 	if (is_wep) {
492cb3126e6SKarl Relton 		if (sme->key) {
4930ca6d8e7SClaudiu Beznea 			if (sme->key_idx >= NUM_WEPKEYS) {
4940ca6d8e7SClaudiu Beznea 				err = -EINVAL;
4950ca6d8e7SClaudiu Beznea 				goto exit;
4960ca6d8e7SClaudiu Beznea 			}
4970ca6d8e7SClaudiu Beznea 
498cb3126e6SKarl Relton 			result = prism2_domibset_uint32(wlandev,
499cb3126e6SKarl Relton 				DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID,
500cb3126e6SKarl Relton 				sme->key_idx);
5018dd82ebeSEdgardo Hames 			if (result)
5028dd82ebeSEdgardo Hames 				goto exit;
503cb3126e6SKarl Relton 
504cb3126e6SKarl Relton 			/* send key to driver */
5050ca6d8e7SClaudiu Beznea 			did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_key(
5060ca6d8e7SClaudiu Beznea 					sme->key_idx + 1);
5078aac4d44SDevendra Naga 			result = prism2_domibset_pstr32(wlandev,
5088aac4d44SDevendra Naga 							did, sme->key_len,
5098aac4d44SDevendra Naga 							(u8 *)sme->key);
5108dd82ebeSEdgardo Hames 			if (result)
5118dd82ebeSEdgardo Hames 				goto exit;
512cb3126e6SKarl Relton 		}
513cb3126e6SKarl Relton 
514cb3126e6SKarl Relton 		/* Assume we should set privacy invoked and exclude unencrypted
51535028fe1SGavin O'Leary 		 * We could possible use sme->privacy here, but the assumption
51635028fe1SGavin O'Leary 		 * seems reasonable anyways
51735028fe1SGavin O'Leary 		 */
5188dd82ebeSEdgardo Hames 		result = prism2_domibset_uint32(wlandev,
5198dd82ebeSEdgardo Hames 						DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked,
520cb3126e6SKarl Relton 						P80211ENUM_truth_true);
5218dd82ebeSEdgardo Hames 		if (result)
5228dd82ebeSEdgardo Hames 			goto exit;
5238dd82ebeSEdgardo Hames 
5248dd82ebeSEdgardo Hames 		result = prism2_domibset_uint32(wlandev,
5258dd82ebeSEdgardo Hames 						DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted,
526cb3126e6SKarl Relton 						P80211ENUM_truth_true);
5278dd82ebeSEdgardo Hames 		if (result)
5288dd82ebeSEdgardo Hames 			goto exit;
529cb3126e6SKarl Relton 
530cb3126e6SKarl Relton 	} else {
5318dd82ebeSEdgardo Hames 		/* Assume we should unset privacy invoked
53235028fe1SGavin O'Leary 		 * and exclude unencrypted
53335028fe1SGavin O'Leary 		 */
5348dd82ebeSEdgardo Hames 		result = prism2_domibset_uint32(wlandev,
5358dd82ebeSEdgardo Hames 						DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked,
536cb3126e6SKarl Relton 						P80211ENUM_truth_false);
5378dd82ebeSEdgardo Hames 		if (result)
5388dd82ebeSEdgardo Hames 			goto exit;
5398dd82ebeSEdgardo Hames 
5408dd82ebeSEdgardo Hames 		result = prism2_domibset_uint32(wlandev,
5418dd82ebeSEdgardo Hames 						DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted,
542cb3126e6SKarl Relton 						P80211ENUM_truth_false);
5438dd82ebeSEdgardo Hames 		if (result)
5448dd82ebeSEdgardo Hames 			goto exit;
545cb3126e6SKarl Relton 	}
546cb3126e6SKarl Relton 
547cb3126e6SKarl Relton 	/* Now do the actual join. Note there is no way that I can
5484f9de774SGavin O'Leary 	 * see to request a specific bssid
5494f9de774SGavin O'Leary 	 */
550cb3126e6SKarl Relton 	msg_join.msgcode = DIDmsg_lnxreq_autojoin;
551cb3126e6SKarl Relton 
552cb3126e6SKarl Relton 	memcpy(msg_join.ssid.data.data, sme->ssid, length);
553cb3126e6SKarl Relton 	msg_join.ssid.data.len = length;
554cb3126e6SKarl Relton 
555cb3126e6SKarl Relton 	result = p80211req_dorequest(wlandev, (u8 *)&msg_join);
556cb3126e6SKarl Relton 
557cb3126e6SKarl Relton exit:
5588dd82ebeSEdgardo Hames 	if (result)
5598dd82ebeSEdgardo Hames 		err = -EFAULT;
560cb3126e6SKarl Relton 
561cb3126e6SKarl Relton 	return err;
562cb3126e6SKarl Relton }
563cb3126e6SKarl Relton 
56455da06ebSTeodora Baluta static int prism2_disconnect(struct wiphy *wiphy, struct net_device *dev,
5658dd82ebeSEdgardo Hames 			     u16 reason_code)
5668dd82ebeSEdgardo Hames {
567c9573a8dSsayli karnik 	struct wlandevice *wlandev = dev->ml_priv;
568b6bb56e6SEdgardo Hames 	struct p80211msg_lnxreq_autojoin msg_join;
569cb3126e6SKarl Relton 	int result;
570cb3126e6SKarl Relton 	int err = 0;
571cb3126e6SKarl Relton 
572cb3126e6SKarl Relton 	/* Do a join, with a bogus ssid. Thats the only way I can think of */
573cb3126e6SKarl Relton 	msg_join.msgcode = DIDmsg_lnxreq_autojoin;
574cb3126e6SKarl Relton 
575cb3126e6SKarl Relton 	memcpy(msg_join.ssid.data.data, "---", 3);
576cb3126e6SKarl Relton 	msg_join.ssid.data.len = 3;
577cb3126e6SKarl Relton 
578cb3126e6SKarl Relton 	result = p80211req_dorequest(wlandev, (u8 *)&msg_join);
579cb3126e6SKarl Relton 
5808dd82ebeSEdgardo Hames 	if (result)
5818dd82ebeSEdgardo Hames 		err = -EFAULT;
582cb3126e6SKarl Relton 
583cb3126e6SKarl Relton 	return err;
584cb3126e6SKarl Relton }
585cb3126e6SKarl Relton 
58655da06ebSTeodora Baluta static int prism2_join_ibss(struct wiphy *wiphy, struct net_device *dev,
5878dd82ebeSEdgardo Hames 			    struct cfg80211_ibss_params *params)
5888dd82ebeSEdgardo Hames {
589cb3126e6SKarl Relton 	return -EOPNOTSUPP;
590cb3126e6SKarl Relton }
591cb3126e6SKarl Relton 
59255da06ebSTeodora Baluta static int prism2_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
5938dd82ebeSEdgardo Hames {
594cb3126e6SKarl Relton 	return -EOPNOTSUPP;
595cb3126e6SKarl Relton }
596cb3126e6SKarl Relton 
59755da06ebSTeodora Baluta static int prism2_set_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev,
5985f3b361aSEmil Goode 			       enum nl80211_tx_power_setting type, int mbm)
5998dd82ebeSEdgardo Hames {
600cb3126e6SKarl Relton 	struct prism2_wiphy_private *priv = wiphy_priv(wiphy);
601c9573a8dSsayli karnik 	struct wlandevice *wlandev = priv->wlandev;
602cb3126e6SKarl Relton 	u32 data;
603cb3126e6SKarl Relton 	int result;
604cb3126e6SKarl Relton 	int err = 0;
605cb3126e6SKarl Relton 
6069015e499SChristoph Fritz 	if (type == NL80211_TX_POWER_AUTOMATIC)
607cb3126e6SKarl Relton 		data = 30;
608cb3126e6SKarl Relton 	else
6099015e499SChristoph Fritz 		data = MBM_TO_DBM(mbm);
610cb3126e6SKarl Relton 
611cb3126e6SKarl Relton 	result = prism2_domibset_uint32(wlandev,
612cb3126e6SKarl Relton 		DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel,
613cb3126e6SKarl Relton 		data);
614cb3126e6SKarl Relton 
615cb3126e6SKarl Relton 	if (result) {
616cb3126e6SKarl Relton 		err = -EFAULT;
617cb3126e6SKarl Relton 		goto exit;
618cb3126e6SKarl Relton 	}
619cb3126e6SKarl Relton 
620cb3126e6SKarl Relton exit:
621cb3126e6SKarl Relton 	return err;
622cb3126e6SKarl Relton }
623cb3126e6SKarl Relton 
62455da06ebSTeodora Baluta static int prism2_get_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev,
6255f3b361aSEmil Goode 			       int *dbm)
6268dd82ebeSEdgardo Hames {
627cb3126e6SKarl Relton 	struct prism2_wiphy_private *priv = wiphy_priv(wiphy);
628c9573a8dSsayli karnik 	struct wlandevice *wlandev = priv->wlandev;
629b6bb56e6SEdgardo Hames 	struct p80211msg_dot11req_mibget msg;
630b26b2325SSergio Paracuellos 	struct p80211item_uint32 *mibitem;
631cb3126e6SKarl Relton 	int result;
632cb3126e6SKarl Relton 	int err = 0;
633cb3126e6SKarl Relton 
634b26b2325SSergio Paracuellos 	mibitem = (struct p80211item_uint32 *)&msg.mibattribute.data;
635cb3126e6SKarl Relton 	msg.msgcode = DIDmsg_dot11req_mibget;
636cb3126e6SKarl Relton 	mibitem->did =
637cb3126e6SKarl Relton 	    DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel;
638cb3126e6SKarl Relton 
639cb3126e6SKarl Relton 	result = p80211req_dorequest(wlandev, (u8 *)&msg);
640cb3126e6SKarl Relton 
641cb3126e6SKarl Relton 	if (result) {
642cb3126e6SKarl Relton 		err = -EFAULT;
643cb3126e6SKarl Relton 		goto exit;
644cb3126e6SKarl Relton 	}
645cb3126e6SKarl Relton 
646cb3126e6SKarl Relton 	*dbm = mibitem->data;
647cb3126e6SKarl Relton 
648cb3126e6SKarl Relton exit:
649cb3126e6SKarl Relton 	return err;
650cb3126e6SKarl Relton }
651cb3126e6SKarl Relton 
652cb3126e6SKarl Relton /* Interface callback functions, passing data back up to the cfg80211 layer */
653c9573a8dSsayli karnik void prism2_connect_result(struct wlandevice *wlandev, u8 failed)
6548dd82ebeSEdgardo Hames {
6558aac4d44SDevendra Naga 	u16 status = failed ?
6568aac4d44SDevendra Naga 		     WLAN_STATUS_UNSPECIFIED_FAILURE : WLAN_STATUS_SUCCESS;
657cb3126e6SKarl Relton 
658cb3126e6SKarl Relton 	cfg80211_connect_result(wlandev->netdev, wlandev->bssid,
6598dd82ebeSEdgardo Hames 				NULL, 0, NULL, 0, status, GFP_KERNEL);
660cb3126e6SKarl Relton }
661cb3126e6SKarl Relton 
662c9573a8dSsayli karnik void prism2_disconnected(struct wlandevice *wlandev)
6638dd82ebeSEdgardo Hames {
664cb3126e6SKarl Relton 	cfg80211_disconnected(wlandev->netdev, 0, NULL,
66580279fb7SJohannes Berg 			      0, false, GFP_KERNEL);
666cb3126e6SKarl Relton }
667cb3126e6SKarl Relton 
668c9573a8dSsayli karnik void prism2_roamed(struct wlandevice *wlandev)
6698dd82ebeSEdgardo Hames {
67029ce6ecbSAvraham Stern 	struct cfg80211_roam_info roam_info = {
67129ce6ecbSAvraham Stern 		.bssid = wlandev->bssid,
67229ce6ecbSAvraham Stern 	};
67329ce6ecbSAvraham Stern 
67429ce6ecbSAvraham Stern 	cfg80211_roamed(wlandev->netdev, &roam_info, GFP_KERNEL);
675cb3126e6SKarl Relton }
676cb3126e6SKarl Relton 
677cb3126e6SKarl Relton /* Structures for declaring wiphy interface */
678cb3126e6SKarl Relton static const struct cfg80211_ops prism2_usb_cfg_ops = {
679cb3126e6SKarl Relton 	.change_virtual_intf = prism2_change_virtual_intf,
680cb3126e6SKarl Relton 	.add_key = prism2_add_key,
681cb3126e6SKarl Relton 	.get_key = prism2_get_key,
682cb3126e6SKarl Relton 	.del_key = prism2_del_key,
683cb3126e6SKarl Relton 	.set_default_key = prism2_set_default_key,
684cb3126e6SKarl Relton 	.get_station = prism2_get_station,
685cb3126e6SKarl Relton 	.scan = prism2_scan,
686cb3126e6SKarl Relton 	.set_wiphy_params = prism2_set_wiphy_params,
687cb3126e6SKarl Relton 	.connect = prism2_connect,
688cb3126e6SKarl Relton 	.disconnect = prism2_disconnect,
689cb3126e6SKarl Relton 	.join_ibss = prism2_join_ibss,
690cb3126e6SKarl Relton 	.leave_ibss = prism2_leave_ibss,
691cb3126e6SKarl Relton 	.set_tx_power = prism2_set_tx_power,
692cb3126e6SKarl Relton 	.get_tx_power = prism2_get_tx_power,
693cb3126e6SKarl Relton };
694cb3126e6SKarl Relton 
695cb3126e6SKarl Relton /* Functions to create/free wiphy interface */
696c9573a8dSsayli karnik static struct wiphy *wlan_create_wiphy(struct device *dev, struct wlandevice *wlandev)
697cb3126e6SKarl Relton {
698cb3126e6SKarl Relton 	struct wiphy *wiphy;
699cb3126e6SKarl Relton 	struct prism2_wiphy_private *priv;
7008aac4d44SDevendra Naga 
7018aac4d44SDevendra Naga 	wiphy = wiphy_new(&prism2_usb_cfg_ops, sizeof(*priv));
702cb3126e6SKarl Relton 	if (!wiphy)
703cb3126e6SKarl Relton 		return NULL;
704cb3126e6SKarl Relton 
705cb3126e6SKarl Relton 	priv = wiphy_priv(wiphy);
706cb3126e6SKarl Relton 	priv->wlandev = wlandev;
707cb3126e6SKarl Relton 	memcpy(priv->channels, prism2_channels, sizeof(prism2_channels));
708cb3126e6SKarl Relton 	memcpy(priv->rates, prism2_rates, sizeof(prism2_rates));
709cb3126e6SKarl Relton 	priv->band.channels = priv->channels;
710cb3126e6SKarl Relton 	priv->band.n_channels = ARRAY_SIZE(prism2_channels);
711cb3126e6SKarl Relton 	priv->band.bitrates = priv->rates;
712cb3126e6SKarl Relton 	priv->band.n_bitrates = ARRAY_SIZE(prism2_rates);
71357fbcce3SJohannes Berg 	priv->band.band = NL80211_BAND_2GHZ;
714aff3ea4eSKarl Relton 	priv->band.ht_cap.ht_supported = false;
71557fbcce3SJohannes Berg 	wiphy->bands[NL80211_BAND_2GHZ] = &priv->band;
716cb3126e6SKarl Relton 
717cb3126e6SKarl Relton 	set_wiphy_dev(wiphy, dev);
718cb3126e6SKarl Relton 	wiphy->privid = prism2_wiphy_privid;
719cb3126e6SKarl Relton 	wiphy->max_scan_ssids = 1;
7208dd82ebeSEdgardo Hames 	wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
7218dd82ebeSEdgardo Hames 				 | BIT(NL80211_IFTYPE_ADHOC);
722cb3126e6SKarl Relton 	wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
723cb3126e6SKarl Relton 	wiphy->n_cipher_suites = PRISM2_NUM_CIPHER_SUITES;
724cb3126e6SKarl Relton 	wiphy->cipher_suites = prism2_cipher_suites;
725cb3126e6SKarl Relton 
726f96b36c7SClaudiu Beznea 	if (wiphy_register(wiphy) < 0) {
727f96b36c7SClaudiu Beznea 		wiphy_free(wiphy);
728cb3126e6SKarl Relton 		return NULL;
729f96b36c7SClaudiu Beznea 	}
730cb3126e6SKarl Relton 
731cb3126e6SKarl Relton 	return wiphy;
732cb3126e6SKarl Relton }
733cb3126e6SKarl Relton 
73436d9c250STugce Sirin static void wlan_free_wiphy(struct wiphy *wiphy)
735cb3126e6SKarl Relton {
736cb3126e6SKarl Relton 	wiphy_unregister(wiphy);
737cb3126e6SKarl Relton 	wiphy_free(wiphy);
738cb3126e6SKarl Relton }
739