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;
93 return wiphy_register(wiphy);
96 static int orinoco_change_vif(struct wiphy *wiphy, struct net_device *dev,
97 enum nl80211_iftype type, u32 *flags,
98 struct vif_params *params)
100 struct orinoco_private *priv = wiphy_priv(wiphy);
104 if (orinoco_lock(priv, &lock) != 0)
108 case NL80211_IFTYPE_ADHOC:
109 if (!priv->has_ibss && !priv->has_port3)
113 case NL80211_IFTYPE_STATION:
116 case NL80211_IFTYPE_MONITOR:
117 if (priv->broken_monitor && !force_monitor) {
118 printk(KERN_WARNING "%s: Monitor mode support is "
119 "buggy in this firmware, not enabling\n",
130 priv->iw_mode = type;
132 err = orinoco_commit(priv);
135 orinoco_unlock(priv, &lock);
140 static int orinoco_scan(struct wiphy *wiphy, struct net_device *dev,
141 struct cfg80211_scan_request *request)
143 struct orinoco_private *priv = wiphy_priv(wiphy);
149 if (priv->scan_request && priv->scan_request != request)
152 priv->scan_request = request;
154 err = orinoco_hw_trigger_scan(priv, request->ssids);
159 static int orinoco_set_channel(struct wiphy *wiphy,
160 struct ieee80211_channel *chan,
161 enum nl80211_channel_type channel_type)
163 struct orinoco_private *priv = wiphy_priv(wiphy);
171 if (channel_type != NL80211_CHAN_NO_HT)
174 if (chan->band != IEEE80211_BAND_2GHZ)
177 channel = ieee80211_freq_to_dsss_chan(chan->center_freq);
179 if ((channel < 1) || (channel > NUM_CHANNELS) ||
180 !(priv->channel_mask & (1 << (channel-1))))
183 if (orinoco_lock(priv, &flags) != 0)
186 priv->channel = channel;
187 if (priv->iw_mode == NL80211_IFTYPE_MONITOR) {
188 /* Fast channel change - no commit if successful */
189 hermes_t *hw = &priv->hw;
190 err = hermes_docmd_wait(hw, HERMES_CMD_TEST |
191 HERMES_TEST_SET_CHANNEL,
194 orinoco_unlock(priv, &flags);
199 const struct cfg80211_ops orinoco_cfg_ops = {
200 .change_virtual_intf = orinoco_change_vif,
201 .set_channel = orinoco_set_channel,
202 .scan = orinoco_scan,