3 * See copyright notice in main.c
5 #include <linux/ieee80211.h>
6 #include <net/cfg80211.h>
13 /* Supported bitrates. Must agree with hw.c */
14 static struct ieee80211_rate orinoco_rates
[] = {
21 static const void * const orinoco_wiphy_privid
= &orinoco_wiphy_privid
;
23 /* Called after orinoco_private is allocated. */
24 void orinoco_wiphy_init(struct wiphy
*wiphy
)
26 struct orinoco_private
*priv
= wiphy_priv(wiphy
);
28 wiphy
->privid
= orinoco_wiphy_privid
;
30 set_wiphy_dev(wiphy
, priv
->dev
);
33 /* Called after firmware is initialised */
34 int orinoco_wiphy_register(struct wiphy
*wiphy
)
36 struct orinoco_private
*priv
= wiphy_priv(wiphy
);
39 if (priv
->firmware_type
== FIRMWARE_TYPE_AGERE
)
40 wiphy
->max_scan_ssids
= 1;
42 wiphy
->max_scan_ssids
= 0;
44 wiphy
->interface_modes
= BIT(NL80211_IFTYPE_STATION
);
46 /* TODO: should we set if we only have demo ad-hoc?
50 wiphy
->interface_modes
|= BIT(NL80211_IFTYPE_ADHOC
);
52 if (!priv
->broken_monitor
|| force_monitor
)
53 wiphy
->interface_modes
|= BIT(NL80211_IFTYPE_MONITOR
);
55 priv
->band
.bitrates
= orinoco_rates
;
56 priv
->band
.n_bitrates
= ARRAY_SIZE(orinoco_rates
);
58 /* Only support channels allowed by the card EEPROM */
59 for (i
= 0; i
< NUM_CHANNELS
; i
++) {
60 if (priv
->channel_mask
& (1 << i
)) {
61 priv
->channels
[i
].center_freq
=
62 ieee80211_dsss_chan_to_freq(i
+ 1);
66 priv
->band
.channels
= priv
->channels
;
67 priv
->band
.n_channels
= channels
;
69 wiphy
->bands
[IEEE80211_BAND_2GHZ
] = &priv
->band
;
70 wiphy
->signal_type
= CFG80211_SIGNAL_TYPE_MBM
;
74 priv
->cipher_suites
[i
] = WLAN_CIPHER_SUITE_WEP40
;
77 if (priv
->has_big_wep
) {
78 priv
->cipher_suites
[i
] = WLAN_CIPHER_SUITE_WEP104
;
83 priv
->cipher_suites
[i
] = WLAN_CIPHER_SUITE_TKIP
;
86 wiphy
->cipher_suites
= priv
->cipher_suites
;
87 wiphy
->n_cipher_suites
= i
;
89 wiphy
->rts_threshold
= priv
->rts_thresh
;
91 wiphy
->frag_threshold
= priv
->frag_thresh
+ 1;
92 wiphy
->retry_short
= priv
->short_retry_limit
;
93 wiphy
->retry_long
= priv
->long_retry_limit
;
95 return wiphy_register(wiphy
);
98 static int orinoco_change_vif(struct wiphy
*wiphy
, struct net_device
*dev
,
99 enum nl80211_iftype type
, u32
*flags
,
100 struct vif_params
*params
)
102 struct orinoco_private
*priv
= wiphy_priv(wiphy
);
106 if (orinoco_lock(priv
, &lock
) != 0)
110 case NL80211_IFTYPE_ADHOC
:
111 if (!priv
->has_ibss
&& !priv
->has_port3
)
115 case NL80211_IFTYPE_STATION
:
118 case NL80211_IFTYPE_MONITOR
:
119 if (priv
->broken_monitor
&& !force_monitor
) {
121 "Monitor mode support is buggy in this firmware, not enabling\n");
131 priv
->iw_mode
= type
;
133 err
= orinoco_commit(priv
);
136 orinoco_unlock(priv
, &lock
);
141 static int orinoco_scan(struct wiphy
*wiphy
,
142 struct cfg80211_scan_request
*request
)
144 struct orinoco_private
*priv
= wiphy_priv(wiphy
);
150 if (priv
->scan_request
&& priv
->scan_request
!= request
)
153 priv
->scan_request
= request
;
155 err
= orinoco_hw_trigger_scan(priv
, request
->ssids
);
156 /* On error the we aren't processing the request */
158 priv
->scan_request
= NULL
;
163 static int orinoco_set_monitor_channel(struct wiphy
*wiphy
,
164 struct cfg80211_chan_def
*chandef
)
166 struct orinoco_private
*priv
= wiphy_priv(wiphy
);
174 if (cfg80211_get_chandef_type(chandef
) != NL80211_CHAN_NO_HT
)
177 if (chandef
->chan
->band
!= IEEE80211_BAND_2GHZ
)
180 channel
= ieee80211_freq_to_dsss_chan(chandef
->chan
->center_freq
);
182 if ((channel
< 1) || (channel
> NUM_CHANNELS
) ||
183 !(priv
->channel_mask
& (1 << (channel
- 1))))
186 if (orinoco_lock(priv
, &flags
) != 0)
189 priv
->channel
= channel
;
190 if (priv
->iw_mode
== NL80211_IFTYPE_MONITOR
) {
191 /* Fast channel change - no commit if successful */
192 struct hermes
*hw
= &priv
->hw
;
193 err
= hw
->ops
->cmd_wait(hw
, HERMES_CMD_TEST
|
194 HERMES_TEST_SET_CHANNEL
,
197 orinoco_unlock(priv
, &flags
);
202 static int orinoco_set_wiphy_params(struct wiphy
*wiphy
, u32 changed
)
204 struct orinoco_private
*priv
= wiphy_priv(wiphy
);
209 if (changed
& WIPHY_PARAM_RETRY_SHORT
) {
210 /* Setting short retry not supported */
214 if (changed
& WIPHY_PARAM_RETRY_LONG
) {
215 /* Setting long retry not supported */
219 if (changed
& WIPHY_PARAM_FRAG_THRESHOLD
) {
220 /* Set fragmentation */
222 if (wiphy
->frag_threshold
< 0)
225 printk(KERN_WARNING
"%s: Fixed fragmentation "
226 "is not supported on this firmware. "
227 "Using MWO robust instead.\n",
232 if (wiphy
->frag_threshold
< 0)
234 else if ((wiphy
->frag_threshold
< 257) ||
235 (wiphy
->frag_threshold
> 2347))
238 /* cfg80211 value is 257-2347 (odd only)
239 * orinoco rid has range 256-2346 (even only) */
240 frag_value
= wiphy
->frag_threshold
& ~0x1;
244 if (changed
& WIPHY_PARAM_RTS_THRESHOLD
) {
247 * Prism documentation suggests default of 2432,
248 * and a range of 0-3000.
250 * Current implementation uses 2347 as the default and
254 if (wiphy
->rts_threshold
< 0)
256 else if (wiphy
->rts_threshold
> 2347)
259 rts_value
= wiphy
->rts_threshold
;
265 if (orinoco_lock(priv
, &flags
) != 0)
268 if (frag_value
>= 0) {
270 priv
->mwo_robust
= frag_value
;
272 priv
->frag_thresh
= frag_value
;
275 priv
->rts_thresh
= rts_value
;
277 err
= orinoco_commit(priv
);
279 orinoco_unlock(priv
, &flags
);
285 const struct cfg80211_ops orinoco_cfg_ops
= {
286 .change_virtual_intf
= orinoco_change_vif
,
287 .set_monitor_channel
= orinoco_set_monitor_channel
,
288 .scan
= orinoco_scan
,
289 .set_wiphy_params
= orinoco_set_wiphy_params
,