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_channel_to_frequency(i + 1,
67 priv->band.channels = priv->channels;
68 priv->band.n_channels = channels;
70 wiphy->bands[NL80211_BAND_2GHZ] = &priv->band;
71 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
75 priv->cipher_suites[i] = WLAN_CIPHER_SUITE_WEP40;
78 if (priv->has_big_wep) {
79 priv->cipher_suites[i] = WLAN_CIPHER_SUITE_WEP104;
84 priv->cipher_suites[i] = WLAN_CIPHER_SUITE_TKIP;
87 wiphy->cipher_suites = priv->cipher_suites;
88 wiphy->n_cipher_suites = i;
90 wiphy->rts_threshold = priv->rts_thresh;
92 wiphy->frag_threshold = priv->frag_thresh + 1;
93 wiphy->retry_short = priv->short_retry_limit;
94 wiphy->retry_long = priv->long_retry_limit;
96 return wiphy_register(wiphy);
99 static int orinoco_change_vif(struct wiphy *wiphy, struct net_device *dev,
100 enum nl80211_iftype type, u32 *flags,
101 struct vif_params *params)
103 struct orinoco_private *priv = wiphy_priv(wiphy);
107 if (orinoco_lock(priv, &lock) != 0)
111 case NL80211_IFTYPE_ADHOC:
112 if (!priv->has_ibss && !priv->has_port3)
116 case NL80211_IFTYPE_STATION:
119 case NL80211_IFTYPE_MONITOR:
120 if (priv->broken_monitor && !force_monitor) {
122 "Monitor mode support is buggy in this firmware, not enabling\n");
132 priv->iw_mode = type;
134 err = orinoco_commit(priv);
137 orinoco_unlock(priv, &lock);
142 static int orinoco_scan(struct wiphy *wiphy,
143 struct cfg80211_scan_request *request)
145 struct orinoco_private *priv = wiphy_priv(wiphy);
151 if (priv->scan_request && priv->scan_request != request)
154 priv->scan_request = request;
156 err = orinoco_hw_trigger_scan(priv, request->ssids);
157 /* On error the we aren't processing the request */
159 priv->scan_request = NULL;
164 static int orinoco_set_monitor_channel(struct wiphy *wiphy,
165 struct cfg80211_chan_def *chandef)
167 struct orinoco_private *priv = wiphy_priv(wiphy);
175 if (cfg80211_get_chandef_type(chandef) != NL80211_CHAN_NO_HT)
178 if (chandef->chan->band != NL80211_BAND_2GHZ)
181 channel = ieee80211_frequency_to_channel(chandef->chan->center_freq);
183 if ((channel < 1) || (channel > NUM_CHANNELS) ||
184 !(priv->channel_mask & (1 << (channel - 1))))
187 if (orinoco_lock(priv, &flags) != 0)
190 priv->channel = channel;
191 if (priv->iw_mode == NL80211_IFTYPE_MONITOR) {
192 /* Fast channel change - no commit if successful */
193 struct hermes *hw = &priv->hw;
194 err = hw->ops->cmd_wait(hw, HERMES_CMD_TEST |
195 HERMES_TEST_SET_CHANNEL,
198 orinoco_unlock(priv, &flags);
203 static int orinoco_set_wiphy_params(struct wiphy *wiphy, u32 changed)
205 struct orinoco_private *priv = wiphy_priv(wiphy);
210 if (changed & WIPHY_PARAM_RETRY_SHORT) {
211 /* Setting short retry not supported */
215 if (changed & WIPHY_PARAM_RETRY_LONG) {
216 /* Setting long retry not supported */
220 if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
221 /* Set fragmentation */
223 if (wiphy->frag_threshold == -1)
226 printk(KERN_WARNING "%s: Fixed fragmentation "
227 "is not supported on this firmware. "
228 "Using MWO robust instead.\n",
233 if (wiphy->frag_threshold == -1)
235 else if ((wiphy->frag_threshold < 257) ||
236 (wiphy->frag_threshold > 2347))
239 /* cfg80211 value is 257-2347 (odd only)
240 * orinoco rid has range 256-2346 (even only) */
241 frag_value = wiphy->frag_threshold & ~0x1;
245 if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
248 * Prism documentation suggests default of 2432,
249 * and a range of 0-3000.
251 * Current implementation uses 2347 as the default and
255 if (wiphy->rts_threshold == -1)
257 else if (wiphy->rts_threshold > 2347)
260 rts_value = wiphy->rts_threshold;
266 if (orinoco_lock(priv, &flags) != 0)
269 if (frag_value >= 0) {
271 priv->mwo_robust = frag_value;
273 priv->frag_thresh = frag_value;
276 priv->rts_thresh = rts_value;
278 err = orinoco_commit(priv);
280 orinoco_unlock(priv, &flags);
286 const struct cfg80211_ops orinoco_cfg_ops = {
287 .change_virtual_intf = orinoco_change_vif,
288 .set_monitor_channel = orinoco_set_monitor_channel,
289 .scan = orinoco_scan,
290 .set_wiphy_params = orinoco_set_wiphy_params,