Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/teigland/dlm
[sfrench/cifs-2.6.git] / drivers / staging / wlan-ng / cfg80211.c
1 /* cfg80211 Interface for prism2_usb module */
2
3
4 /* Prism2 channell/frequency/bitrate declarations */
5 static const struct ieee80211_channel prism2_channels[] = {
6         { .center_freq = 2412 },
7         { .center_freq = 2417 },
8         { .center_freq = 2422 },
9         { .center_freq = 2427 },
10         { .center_freq = 2432 },
11         { .center_freq = 2437 },
12         { .center_freq = 2442 },
13         { .center_freq = 2447 },
14         { .center_freq = 2452 },
15         { .center_freq = 2457 },
16         { .center_freq = 2462 },
17         { .center_freq = 2467 },
18         { .center_freq = 2472 },
19         { .center_freq = 2484 },
20 };
21
22 static const struct ieee80211_rate prism2_rates[] = {
23         { .bitrate = 10 },
24         { .bitrate = 20 },
25         { .bitrate = 55 },
26         { .bitrate = 110 }
27 };
28
29 #define PRISM2_NUM_CIPHER_SUITES 2
30 static const u32 prism2_cipher_suites[PRISM2_NUM_CIPHER_SUITES] = {
31         WLAN_CIPHER_SUITE_WEP40,
32         WLAN_CIPHER_SUITE_WEP104
33 };
34
35
36 /* prism2 device private data */
37 struct prism2_wiphy_private {
38         wlandevice_t *wlandev;
39
40         struct ieee80211_supported_band band;
41         struct ieee80211_channel channels[ARRAY_SIZE(prism2_channels)];
42         struct ieee80211_rate rates[ARRAY_SIZE(prism2_rates)];
43
44         struct cfg80211_scan_request *scan_request;
45 };
46
47 static const void * const prism2_wiphy_privid = &prism2_wiphy_privid;
48
49
50 /* Helper Functions */
51 static int prism2_result2err(int prism2_result)
52 {
53         int err = 0;
54
55         switch (prism2_result) {
56         case P80211ENUM_resultcode_invalid_parameters:
57                 err = -EINVAL;
58                 break;
59         case P80211ENUM_resultcode_implementation_failure:
60                 err = -EIO;
61                 break;
62         case P80211ENUM_resultcode_not_supported:
63                 err = -EOPNOTSUPP;
64                 break;
65         default:
66                 err = 0;
67                 break;
68         }
69
70         return err;
71 }
72
73 static int prism2_domibset_uint32(wlandevice_t *wlandev, u32 did, u32 data)
74 {
75         struct p80211msg_dot11req_mibset msg;
76         p80211item_uint32_t *mibitem = (p80211item_uint32_t *) &msg.mibattribute.data;
77
78         msg.msgcode = DIDmsg_dot11req_mibset;
79         mibitem->did = did;
80         mibitem->data = data;
81
82         return p80211req_dorequest(wlandev, (u8 *) &msg);
83 }
84
85 static int prism2_domibset_pstr32(wlandevice_t *wlandev,
86                                   u32 did, u8 len, u8 *data)
87 {
88         struct p80211msg_dot11req_mibset msg;
89         p80211item_pstr32_t *mibitem = (p80211item_pstr32_t *) &msg.mibattribute.data;
90
91         msg.msgcode = DIDmsg_dot11req_mibset;
92         mibitem->did = did;
93         mibitem->data.len = len;
94         memcpy(mibitem->data.data, data, len);
95
96         return p80211req_dorequest(wlandev, (u8 *) &msg);
97 }
98
99
100 /* The interface functions, called by the cfg80211 layer */
101 int prism2_change_virtual_intf(struct wiphy *wiphy,
102                                struct net_device *dev,
103                                enum nl80211_iftype type, u32 *flags,
104                                struct vif_params *params)
105 {
106         wlandevice_t *wlandev = dev->ml_priv;
107         u32 data;
108         int result;
109         int err = 0;
110
111         switch (type) {
112         case NL80211_IFTYPE_ADHOC:
113                 if (wlandev->macmode == WLAN_MACMODE_IBSS_STA)
114                         goto exit;
115                 wlandev->macmode = WLAN_MACMODE_IBSS_STA;
116                 data = 0;
117                 break;
118         case NL80211_IFTYPE_STATION:
119                 if (wlandev->macmode == WLAN_MACMODE_ESS_STA)
120                         goto exit;
121                 wlandev->macmode = WLAN_MACMODE_ESS_STA;
122                 data = 1;
123                 break;
124         default:
125                 printk(KERN_WARNING "Operation mode: %d not support\n", type);
126                 return -EOPNOTSUPP;
127         }
128
129         /* Set Operation mode to the PORT TYPE RID */
130         result = prism2_domibset_uint32(wlandev, DIDmib_p2_p2Static_p2CnfPortType, data);
131
132         if (result)
133                 err = -EFAULT;
134
135         dev->ieee80211_ptr->iftype = type;
136
137 exit:
138         return err;
139 }
140
141 int prism2_add_key(struct wiphy *wiphy, struct net_device *dev,
142                    u8 key_index, const u8 *mac_addr,
143                    struct key_params *params)
144 {
145         wlandevice_t *wlandev = dev->ml_priv;
146         u32 did;
147
148         int err = 0;
149         int result = 0;
150
151         switch (params->cipher) {
152         case WLAN_CIPHER_SUITE_WEP40:
153         case WLAN_CIPHER_SUITE_WEP104:
154                 result = prism2_domibset_uint32(wlandev,
155                                                 DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID,
156                                                 key_index);
157                 if (result)
158                         goto exit;
159
160                 /* send key to driver */
161                 switch (key_index) {
162                 case 0:
163                         did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0;
164                         break;
165
166                 case 1:
167                         did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1;
168                         break;
169
170                 case 2:
171                         did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2;
172                         break;
173
174                 case 3:
175                         did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3;
176                         break;
177
178                 default:
179                         err = -EINVAL;
180                         goto exit;
181                 }
182
183                 result = prism2_domibset_pstr32(wlandev, did, params->key_len, params->key);
184                 if (result)
185                         goto exit;
186                 break;
187
188         default:
189                 pr_debug("Unsupported cipher suite\n");
190                 result = 1;
191         }
192
193 exit:
194         if (result)
195                 err = -EFAULT;
196
197         return err;
198 }
199
200 int prism2_get_key(struct wiphy *wiphy, struct net_device *dev,
201                    u8 key_index, const u8 *mac_addr, void *cookie,
202                    void (*callback)(void *cookie, struct key_params*))
203 {
204         wlandevice_t *wlandev = dev->ml_priv;
205         struct key_params params;
206         int len;
207
208         if (key_index >= NUM_WEPKEYS)
209                 return -EINVAL;
210
211         len = wlandev->wep_keylens[key_index];
212         memset(&params, 0, sizeof(params));
213
214         if (len == 13)
215                 params.cipher = WLAN_CIPHER_SUITE_WEP104;
216         else if (len == 5)
217                 params.cipher = WLAN_CIPHER_SUITE_WEP104;
218         else
219                 return -ENOENT;
220         params.key_len = len;
221         params.key = wlandev->wep_keys[key_index];
222
223         callback(cookie, &params);
224
225         return 0;
226 }
227
228 int prism2_del_key(struct wiphy *wiphy, struct net_device *dev,
229                    u8 key_index, const u8 *mac_addr)
230 {
231         wlandevice_t *wlandev = dev->ml_priv;
232         u32 did;
233         int err = 0;
234         int result = 0;
235
236         /* There is no direct way in the hardware (AFAIK) of removing
237            a key, so we will cheat by setting the key to a bogus value */
238         /* send key to driver */
239         switch (key_index) {
240         case 0:
241                 did =
242                     DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0;
243                 break;
244
245         case 1:
246                 did =
247                     DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1;
248                 break;
249
250         case 2:
251                 did =
252                     DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2;
253                 break;
254
255         case 3:
256                 did =
257                     DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3;
258                 break;
259
260         default:
261                 err = -EINVAL;
262                 goto exit;
263         }
264
265         result = prism2_domibset_pstr32(wlandev, did, 13, "0000000000000");
266
267 exit:
268         if (result)
269                 err = -EFAULT;
270
271         return err;
272 }
273
274 int prism2_set_default_key(struct wiphy *wiphy, struct net_device *dev,
275                            u8 key_index)
276 {
277         wlandevice_t *wlandev = dev->ml_priv;
278
279         int err = 0;
280         int result = 0;
281
282         result = prism2_domibset_uint32(wlandev,
283                 DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID,
284                 key_index);
285
286         if (result)
287                 err = -EFAULT;
288
289         return err;
290 }
291
292
293 int prism2_get_station(struct wiphy *wiphy, struct net_device *dev,
294                        u8 *mac, struct station_info *sinfo)
295 {
296         wlandevice_t *wlandev = dev->ml_priv;
297         struct p80211msg_lnxreq_commsquality quality;
298         int result;
299
300         memset(sinfo, 0, sizeof(*sinfo));
301
302         if ((wlandev == NULL) || (wlandev->msdstate != WLAN_MSD_RUNNING))
303                 return -EOPNOTSUPP;
304
305         /* build request message */
306         quality.msgcode = DIDmsg_lnxreq_commsquality;
307         quality.dbm.data = P80211ENUM_truth_true;
308         quality.dbm.status = P80211ENUM_msgitem_status_data_ok;
309
310         /* send message to nsd */
311         if (wlandev->mlmerequest == NULL)
312                 return -EOPNOTSUPP;
313
314         result = wlandev->mlmerequest(wlandev, (struct p80211msg *) &quality);
315
316
317         if (result == 0) {
318                 sinfo->txrate.legacy = quality.txrate.data;
319                 sinfo->filled |= STATION_INFO_TX_BITRATE;
320                 sinfo->signal = quality.level.data;
321                 sinfo->filled |= STATION_INFO_SIGNAL;
322         }
323
324         return result;
325 }
326
327 int prism2_scan(struct wiphy *wiphy, struct net_device *dev,
328                 struct cfg80211_scan_request *request)
329 {
330         struct prism2_wiphy_private *priv = wiphy_priv(wiphy);
331         wlandevice_t *wlandev = dev->ml_priv;
332         struct p80211msg_dot11req_scan msg1;
333         struct p80211msg_dot11req_scan_results msg2;
334         int result;
335         int err = 0;
336         int numbss = 0;
337         int i = 0;
338         u8 ie_buf[46];
339         int ie_len;
340
341         if (!request)
342                 return -EINVAL;
343
344         if (priv->scan_request && priv->scan_request != request)
345                 return -EBUSY;
346
347         if (wlandev->macmode == WLAN_MACMODE_ESS_AP) {
348                 printk(KERN_ERR "Can't scan in AP mode\n");
349                 return -EOPNOTSUPP;
350         }
351
352         priv->scan_request = request;
353
354         memset(&msg1, 0x00, sizeof(struct p80211msg_dot11req_scan));
355         msg1.msgcode = DIDmsg_dot11req_scan;
356         msg1.bsstype.data = P80211ENUM_bsstype_any;
357
358         memset(&(msg1.bssid.data), 0xFF, sizeof(p80211item_pstr6_t));
359         msg1.bssid.data.len = 6;
360
361         if (request->n_ssids > 0) {
362                 msg1.scantype.data = P80211ENUM_scantype_active;
363                 msg1.ssid.data.len = request->ssids->ssid_len;
364                 memcpy(msg1.ssid.data.data, request->ssids->ssid, request->ssids->ssid_len);
365         } else {
366                 msg1.scantype.data = 0;
367         }
368         msg1.probedelay.data = 0;
369
370         for (i = 0;
371                 (i < request->n_channels) && i < ARRAY_SIZE(prism2_channels);
372                 i++)
373                 msg1.channellist.data.data[i] =
374                         ieee80211_frequency_to_channel(request->channels[i]->center_freq);
375         msg1.channellist.data.len = request->n_channels;
376
377         msg1.maxchanneltime.data = 250;
378         msg1.minchanneltime.data = 200;
379
380         result = p80211req_dorequest(wlandev, (u8 *) &msg1);
381         if (result) {
382                 err = prism2_result2err(msg1.resultcode.data);
383                 goto exit;
384         }
385         /* Now retrieve scan results */
386         numbss = msg1.numbss.data;
387
388         for (i = 0; i < numbss; i++) {
389                 memset(&msg2, 0, sizeof(msg2));
390                 msg2.msgcode = DIDmsg_dot11req_scan_results;
391                 msg2.bssindex.data = i;
392
393                 result = p80211req_dorequest(wlandev, (u8 *) &msg2);
394                 if ((result != 0) ||
395                     (msg2.resultcode.data != P80211ENUM_resultcode_success)) {
396                         break;
397                 }
398
399                 ie_buf[0] = WLAN_EID_SSID;
400                 ie_buf[1] = msg2.ssid.data.len;
401                 ie_len = ie_buf[1] + 2;
402                 memcpy(&ie_buf[2], &(msg2.ssid.data.data), msg2.ssid.data.len);
403                 cfg80211_inform_bss(wiphy,
404                         ieee80211_get_channel(wiphy, ieee80211_dsss_chan_to_freq(msg2.dschannel.data)),
405                         (const u8 *) &(msg2.bssid.data.data),
406                         msg2.timestamp.data, msg2.capinfo.data,
407                         msg2.beaconperiod.data,
408                         ie_buf,
409                         ie_len,
410                         (msg2.signal.data - 65536) * 100, /* Conversion to signed type */
411                         GFP_KERNEL
412                 );
413         }
414
415         if (result)
416                 err = prism2_result2err(msg2.resultcode.data);
417
418 exit:
419         cfg80211_scan_done(request, err ? 1 : 0);
420         priv->scan_request = NULL;
421         return err;
422 }
423
424 int prism2_set_wiphy_params(struct wiphy *wiphy, u32 changed)
425 {
426         struct prism2_wiphy_private *priv = wiphy_priv(wiphy);
427         wlandevice_t *wlandev = priv->wlandev;
428         u32 data;
429         int result;
430         int err = 0;
431
432         if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
433                 if (wiphy->rts_threshold == -1)
434                         data = 2347;
435                 else
436                         data = wiphy->rts_threshold;
437
438                 result = prism2_domibset_uint32(wlandev,
439                                                 DIDmib_dot11mac_dot11OperationTable_dot11RTSThreshold,
440                                                 data);
441                 if (result) {
442                         err = -EFAULT;
443                         goto exit;
444                 }
445         }
446
447         if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
448                 if (wiphy->frag_threshold == -1)
449                         data = 2346;
450                 else
451                         data = wiphy->frag_threshold;
452
453                 result = prism2_domibset_uint32(wlandev,
454                                                 DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold,
455                                                 data);
456                 if (result) {
457                         err = -EFAULT;
458                         goto exit;
459                 }
460         }
461
462 exit:
463         return err;
464 }
465
466 int prism2_connect(struct wiphy *wiphy, struct net_device *dev,
467                    struct cfg80211_connect_params *sme)
468 {
469         wlandevice_t *wlandev = dev->ml_priv;
470         struct ieee80211_channel *channel = sme->channel;
471         struct p80211msg_lnxreq_autojoin msg_join;
472         u32 did;
473         int length = sme->ssid_len;
474         int chan = -1;
475         int is_wep = (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP40) ||
476             (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP104);
477         int result;
478         int err = 0;
479
480         /* Set the channel */
481         if (channel) {
482                 chan = ieee80211_frequency_to_channel(channel->center_freq);
483                 result = prism2_domibset_uint32(wlandev,
484                                                 DIDmib_dot11phy_dot11PhyDSSSTable_dot11CurrentChannel,
485                                                 chan);
486                 if (result)
487                         goto exit;
488         }
489
490         /* Set the authorisation */
491         if ((sme->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM) ||
492                 ((sme->auth_type == NL80211_AUTHTYPE_AUTOMATIC) && !is_wep))
493                         msg_join.authtype.data = P80211ENUM_authalg_opensystem;
494         else if ((sme->auth_type == NL80211_AUTHTYPE_SHARED_KEY) ||
495                 ((sme->auth_type == NL80211_AUTHTYPE_AUTOMATIC) && is_wep))
496                         msg_join.authtype.data = P80211ENUM_authalg_sharedkey;
497         else
498                 printk(KERN_WARNING
499                         "Unhandled authorisation type for connect (%d)\n",
500                         sme->auth_type);
501
502         /* Set the encryption - we only support wep */
503         if (is_wep) {
504                 if (sme->key) {
505                         result = prism2_domibset_uint32(wlandev,
506                                 DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID,
507                                 sme->key_idx);
508                         if (result)
509                                 goto exit;
510
511                         /* send key to driver */
512                         switch (sme->key_idx) {
513                         case 0:
514                                 did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0;
515                                 break;
516
517                         case 1:
518                                 did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1;
519                                 break;
520
521                         case 2:
522                                 did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2;
523                                 break;
524
525                         case 3:
526                                 did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3;
527                                 break;
528
529                         default:
530                                 err = -EINVAL;
531                                 goto exit;
532                         }
533
534                         result = prism2_domibset_pstr32(wlandev, did, sme->key_len, (u8 *) sme->key);
535                         if (result)
536                                 goto exit;
537
538                 }
539
540                 /* Assume we should set privacy invoked and exclude unencrypted
541                    We could possibly use sme->privacy here, but the assumption
542                    seems reasonable anyway */
543                 result = prism2_domibset_uint32(wlandev,
544                                                 DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked,
545                                                 P80211ENUM_truth_true);
546                 if (result)
547                         goto exit;
548
549                 result = prism2_domibset_uint32(wlandev,
550                                                 DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted,
551                                                 P80211ENUM_truth_true);
552                 if (result)
553                         goto exit;
554
555         } else {
556                 /* Assume we should unset privacy invoked
557                    and exclude unencrypted */
558                 result = prism2_domibset_uint32(wlandev,
559                                                 DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked,
560                                                 P80211ENUM_truth_false);
561                 if (result)
562                         goto exit;
563
564                 result = prism2_domibset_uint32(wlandev,
565                                                 DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted,
566                                                 P80211ENUM_truth_false);
567                 if (result)
568                         goto exit;
569
570         }
571
572         /* Now do the actual join. Note there is no way that I can
573            see to request a specific bssid */
574         msg_join.msgcode = DIDmsg_lnxreq_autojoin;
575
576         memcpy(msg_join.ssid.data.data, sme->ssid, length);
577         msg_join.ssid.data.len = length;
578
579         result = p80211req_dorequest(wlandev, (u8 *) &msg_join);
580
581 exit:
582         if (result)
583                 err = -EFAULT;
584
585         return err;
586 }
587
588 int prism2_disconnect(struct wiphy *wiphy, struct net_device *dev,
589                       u16 reason_code)
590 {
591         wlandevice_t *wlandev = dev->ml_priv;
592         struct p80211msg_lnxreq_autojoin msg_join;
593         int result;
594         int err = 0;
595
596
597         /* Do a join, with a bogus ssid. Thats the only way I can think of */
598         msg_join.msgcode = DIDmsg_lnxreq_autojoin;
599
600         memcpy(msg_join.ssid.data.data, "---", 3);
601         msg_join.ssid.data.len = 3;
602
603         result = p80211req_dorequest(wlandev, (u8 *) &msg_join);
604
605         if (result)
606                 err = -EFAULT;
607
608         return err;
609 }
610
611
612 int prism2_join_ibss(struct wiphy *wiphy, struct net_device *dev,
613                      struct cfg80211_ibss_params *params)
614 {
615         return -EOPNOTSUPP;
616 }
617
618 int prism2_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
619 {
620         return -EOPNOTSUPP;
621 }
622
623
624 int prism2_set_tx_power(struct wiphy *wiphy, enum nl80211_tx_power_setting type,
625                         int mbm)
626 {
627         struct prism2_wiphy_private *priv = wiphy_priv(wiphy);
628         wlandevice_t *wlandev = priv->wlandev;
629         u32 data;
630         int result;
631         int err = 0;
632
633         if (type == NL80211_TX_POWER_AUTOMATIC)
634                 data = 30;
635         else
636                 data = MBM_TO_DBM(mbm);
637
638         result = prism2_domibset_uint32(wlandev,
639                 DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel,
640                 data);
641
642         if (result) {
643                 err = -EFAULT;
644                 goto exit;
645         }
646
647 exit:
648         return err;
649 }
650
651 int prism2_get_tx_power(struct wiphy *wiphy, int *dbm)
652 {
653         struct prism2_wiphy_private *priv = wiphy_priv(wiphy);
654         wlandevice_t *wlandev = priv->wlandev;
655         struct p80211msg_dot11req_mibget msg;
656         p80211item_uint32_t *mibitem = (p80211item_uint32_t *) &msg.mibattribute.data;
657         int result;
658         int err = 0;
659
660         msg.msgcode = DIDmsg_dot11req_mibget;
661         mibitem->did =
662             DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel;
663
664         result = p80211req_dorequest(wlandev, (u8 *) &msg);
665
666         if (result) {
667                 err = -EFAULT;
668                 goto exit;
669         }
670
671         *dbm = mibitem->data;
672
673 exit:
674         return err;
675 }
676
677
678
679
680 /* Interface callback functions, passing data back up to the cfg80211 layer */
681 void prism2_connect_result(wlandevice_t *wlandev, u8 failed)
682 {
683         u16 status = failed ? WLAN_STATUS_UNSPECIFIED_FAILURE : WLAN_STATUS_SUCCESS;
684
685         cfg80211_connect_result(wlandev->netdev, wlandev->bssid,
686                                 NULL, 0, NULL, 0, status, GFP_KERNEL);
687 }
688
689 void prism2_disconnected(wlandevice_t *wlandev)
690 {
691         cfg80211_disconnected(wlandev->netdev, 0, NULL,
692                 0, GFP_KERNEL);
693 }
694
695 void prism2_roamed(wlandevice_t *wlandev)
696 {
697         cfg80211_roamed(wlandev->netdev, wlandev->bssid,
698                 NULL, 0, NULL, 0, GFP_KERNEL);
699 }
700
701
702 /* Structures for declaring wiphy interface */
703 static const struct cfg80211_ops prism2_usb_cfg_ops = {
704         .change_virtual_intf = prism2_change_virtual_intf,
705         .add_key = prism2_add_key,
706         .get_key = prism2_get_key,
707         .del_key = prism2_del_key,
708         .set_default_key = prism2_set_default_key,
709         .get_station = prism2_get_station,
710         .scan = prism2_scan,
711         .set_wiphy_params = prism2_set_wiphy_params,
712         .connect = prism2_connect,
713         .disconnect = prism2_disconnect,
714         .join_ibss = prism2_join_ibss,
715         .leave_ibss = prism2_leave_ibss,
716         .set_tx_power = prism2_set_tx_power,
717         .get_tx_power = prism2_get_tx_power,
718 };
719
720
721 /* Functions to create/free wiphy interface */
722 struct wiphy *wlan_create_wiphy(struct device *dev, wlandevice_t *wlandev)
723 {
724         struct wiphy *wiphy;
725         struct prism2_wiphy_private *priv;
726         wiphy = wiphy_new(&prism2_usb_cfg_ops, sizeof(struct prism2_wiphy_private));
727         if (!wiphy)
728                 return NULL;
729
730         priv = wiphy_priv(wiphy);
731         priv->wlandev = wlandev;
732         memcpy(priv->channels, prism2_channels, sizeof(prism2_channels));
733         memcpy(priv->rates, prism2_rates, sizeof(prism2_rates));
734         priv->band.channels = priv->channels;
735         priv->band.n_channels = ARRAY_SIZE(prism2_channels);
736         priv->band.bitrates = priv->rates;
737         priv->band.n_bitrates = ARRAY_SIZE(prism2_rates);
738         wiphy->bands[IEEE80211_BAND_2GHZ] = &priv->band;
739
740         set_wiphy_dev(wiphy, dev);
741         wiphy->privid = prism2_wiphy_privid;
742         wiphy->max_scan_ssids = 1;
743         wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
744                                  | BIT(NL80211_IFTYPE_ADHOC);
745         wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
746         wiphy->n_cipher_suites = PRISM2_NUM_CIPHER_SUITES;
747         wiphy->cipher_suites = prism2_cipher_suites;
748
749         if (wiphy_register(wiphy) < 0)
750                 return NULL;
751
752         return wiphy;
753 }
754
755
756 void wlan_free_wiphy(struct wiphy *wiphy)
757 {
758         wiphy_unregister(wiphy);
759         wiphy_free(wiphy);
760 }