diff options
Diffstat (limited to 'drivers/staging/wlan-ng')
27 files changed, 2582 insertions, 3509 deletions
diff --git a/drivers/staging/wlan-ng/Kconfig b/drivers/staging/wlan-ng/Kconfig index f44294b0d8d..426d4efbabc 100644 --- a/drivers/staging/wlan-ng/Kconfig +++ b/drivers/staging/wlan-ng/Kconfig @@ -1,6 +1,8 @@ config PRISM2_USB tristate "Prism2.5/3 USB driver" - depends on WLAN && USB && WIRELESS_EXT + depends on WLAN && USB && CFG80211 + select WIRELESS_EXT + select WEXT_PRIV default n ---help--- This is the wlan-ng prism 2.5/3 USB driver for a wide range of diff --git a/drivers/staging/wlan-ng/Makefile b/drivers/staging/wlan-ng/Makefile index 5edac5c8d4e..32b69f238c6 100644 --- a/drivers/staging/wlan-ng/Makefile +++ b/drivers/staging/wlan-ng/Makefile @@ -1,8 +1,7 @@ obj-$(CONFIG_PRISM2_USB) += prism2_usb.o -prism2_usb-objs := prism2usb.o \ +prism2_usb-y := prism2usb.o \ p80211conv.o \ p80211req.o \ p80211wep.o \ - p80211wext.o \ p80211netdev.o diff --git a/drivers/staging/wlan-ng/cfg80211.c b/drivers/staging/wlan-ng/cfg80211.c new file mode 100644 index 00000000000..723319ee08f --- /dev/null +++ b/drivers/staging/wlan-ng/cfg80211.c @@ -0,0 +1,793 @@ +/* cfg80211 Interface for prism2_usb module */ + + +/* Prism2 channel/frequency/bitrate declarations */ +static const struct ieee80211_channel prism2_channels[] = { + { .center_freq = 2412 }, + { .center_freq = 2417 }, + { .center_freq = 2422 }, + { .center_freq = 2427 }, + { .center_freq = 2432 }, + { .center_freq = 2437 }, + { .center_freq = 2442 }, + { .center_freq = 2447 }, + { .center_freq = 2452 }, + { .center_freq = 2457 }, + { .center_freq = 2462 }, + { .center_freq = 2467 }, + { .center_freq = 2472 }, + { .center_freq = 2484 }, +}; + +static const struct ieee80211_rate prism2_rates[] = { + { .bitrate = 10 }, + { .bitrate = 20 }, + { .bitrate = 55 }, + { .bitrate = 110 } +}; + +#define PRISM2_NUM_CIPHER_SUITES 2 +static const u32 prism2_cipher_suites[PRISM2_NUM_CIPHER_SUITES] = { + WLAN_CIPHER_SUITE_WEP40, + WLAN_CIPHER_SUITE_WEP104 +}; + + +/* prism2 device private data */ +struct prism2_wiphy_private { + wlandevice_t *wlandev; + + struct ieee80211_supported_band band; + struct ieee80211_channel channels[ARRAY_SIZE(prism2_channels)]; + struct ieee80211_rate rates[ARRAY_SIZE(prism2_rates)]; + + struct cfg80211_scan_request *scan_request; +}; + +static const void * const prism2_wiphy_privid = &prism2_wiphy_privid; + + +/* Helper Functions */ +static int prism2_result2err(int prism2_result) +{ + int err = 0; + + switch (prism2_result) { + case P80211ENUM_resultcode_invalid_parameters: + err = -EINVAL; + break; + case P80211ENUM_resultcode_implementation_failure: + err = -EIO; + break; + case P80211ENUM_resultcode_not_supported: + err = -EOPNOTSUPP; + break; + default: + err = 0; + break; + } + + return err; +} + +static int prism2_domibset_uint32(wlandevice_t *wlandev, u32 did, u32 data) +{ + struct p80211msg_dot11req_mibset msg; + p80211item_uint32_t *mibitem = + (p80211item_uint32_t *) &msg.mibattribute.data; + + msg.msgcode = DIDmsg_dot11req_mibset; + mibitem->did = did; + mibitem->data = data; + + return p80211req_dorequest(wlandev, (u8 *) &msg); +} + +static int prism2_domibset_pstr32(wlandevice_t *wlandev, + u32 did, u8 len, const u8 *data) +{ + struct p80211msg_dot11req_mibset msg; + p80211item_pstr32_t *mibitem = + (p80211item_pstr32_t *) &msg.mibattribute.data; + + msg.msgcode = DIDmsg_dot11req_mibset; + mibitem->did = did; + mibitem->data.len = len; + memcpy(mibitem->data.data, data, len); + + return p80211req_dorequest(wlandev, (u8 *) &msg); +} + + +/* The interface functions, called by the cfg80211 layer */ +static int prism2_change_virtual_intf(struct wiphy *wiphy, + struct net_device *dev, + enum nl80211_iftype type, u32 *flags, + struct vif_params *params) +{ + wlandevice_t *wlandev = dev->ml_priv; + u32 data; + int result; + int err = 0; + + switch (type) { + case NL80211_IFTYPE_ADHOC: + if (wlandev->macmode == WLAN_MACMODE_IBSS_STA) + goto exit; + wlandev->macmode = WLAN_MACMODE_IBSS_STA; + data = 0; + break; + case NL80211_IFTYPE_STATION: + if (wlandev->macmode == WLAN_MACMODE_ESS_STA) + goto exit; + wlandev->macmode = WLAN_MACMODE_ESS_STA; + data = 1; + break; + default: + netdev_warn(dev, "Operation mode: %d not support\n", type); + return -EOPNOTSUPP; + } + + /* Set Operation mode to the PORT TYPE RID */ + result = prism2_domibset_uint32(wlandev, + DIDmib_p2_p2Static_p2CnfPortType, + data); + + if (result) + err = -EFAULT; + + dev->ieee80211_ptr->iftype = type; + +exit: + return err; +} + +static int prism2_add_key(struct wiphy *wiphy, struct net_device *dev, + u8 key_index, bool pairwise, const u8 *mac_addr, + struct key_params *params) +{ + wlandevice_t *wlandev = dev->ml_priv; + u32 did; + + int err = 0; + int result = 0; + + switch (params->cipher) { + case WLAN_CIPHER_SUITE_WEP40: + case WLAN_CIPHER_SUITE_WEP104: + result = prism2_domibset_uint32(wlandev, + DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID, + key_index); + if (result) + goto exit; + + /* send key to driver */ + switch (key_index) { + case 0: + did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0; + break; + + case 1: + did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1; + break; + + case 2: + did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2; + break; + + case 3: + did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3; + break; + + default: + err = -EINVAL; + goto exit; + } + + result = prism2_domibset_pstr32(wlandev, did, + params->key_len, params->key); + if (result) + goto exit; + break; + + default: + pr_debug("Unsupported cipher suite\n"); + result = 1; + } + +exit: + if (result) + err = -EFAULT; + + return err; +} + +static int prism2_get_key(struct wiphy *wiphy, struct net_device *dev, + u8 key_index, bool pairwise, + const u8 *mac_addr, void *cookie, + void (*callback)(void *cookie, struct key_params*)) +{ + wlandevice_t *wlandev = dev->ml_priv; + struct key_params params; + int len; + + if (key_index >= NUM_WEPKEYS) + return -EINVAL; + + len = wlandev->wep_keylens[key_index]; + memset(¶ms, 0, sizeof(params)); + + if (len == 13) + params.cipher = WLAN_CIPHER_SUITE_WEP104; + else if (len == 5) + params.cipher = WLAN_CIPHER_SUITE_WEP104; + else + return -ENOENT; + params.key_len = len; + params.key = wlandev->wep_keys[key_index]; + params.seq_len = 0; + + callback(cookie, ¶ms); + + return 0; +} + +static int prism2_del_key(struct wiphy *wiphy, struct net_device *dev, + u8 key_index, bool pairwise, const u8 *mac_addr) +{ + wlandevice_t *wlandev = dev->ml_priv; + u32 did; + int err = 0; + int result = 0; + + /* There is no direct way in the hardware (AFAIK) of removing + a key, so we will cheat by setting the key to a bogus value */ + /* send key to driver */ + switch (key_index) { + case 0: + did = + DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0; + break; + + case 1: + did = + DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1; + break; + + case 2: + did = + DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2; + break; + + case 3: + did = + DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3; + break; + + default: + err = -EINVAL; + goto exit; + } + + result = prism2_domibset_pstr32(wlandev, did, 13, "0000000000000"); + +exit: + if (result) + err = -EFAULT; + + return err; +} + +static int prism2_set_default_key(struct wiphy *wiphy, struct net_device *dev, + u8 key_index, bool unicast, bool multicast) +{ + wlandevice_t *wlandev = dev->ml_priv; + + int err = 0; + int result = 0; + + result = prism2_domibset_uint32(wlandev, + DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID, + key_index); + + if (result) + err = -EFAULT; + + return err; +} + + +static int prism2_get_station(struct wiphy *wiphy, struct net_device *dev, + const u8 *mac, struct station_info *sinfo) +{ + wlandevice_t *wlandev = dev->ml_priv; + struct p80211msg_lnxreq_commsquality quality; + int result; + + memset(sinfo, 0, sizeof(*sinfo)); + + if ((wlandev == NULL) || (wlandev->msdstate != WLAN_MSD_RUNNING)) + return -EOPNOTSUPP; + + /* build request message */ + quality.msgcode = DIDmsg_lnxreq_commsquality; + quality.dbm.data = P80211ENUM_truth_true; + quality.dbm.status = P80211ENUM_msgitem_status_data_ok; + + /* send message to nsd */ + if (wlandev->mlmerequest == NULL) + return -EOPNOTSUPP; + + result = wlandev->mlmerequest(wlandev, (struct p80211msg *) &quality); + + + if (result == 0) { + sinfo->txrate.legacy = quality.txrate.data; + sinfo->filled |= STATION_INFO_TX_BITRATE; + sinfo->signal = quality.level.data; + sinfo->filled |= STATION_INFO_SIGNAL; + } + + return result; +} + +static int prism2_scan(struct wiphy *wiphy, + struct cfg80211_scan_request *request) +{ + struct net_device *dev; + struct prism2_wiphy_private *priv = wiphy_priv(wiphy); + wlandevice_t *wlandev; + struct p80211msg_dot11req_scan msg1; + struct p80211msg_dot11req_scan_results msg2; + struct cfg80211_bss *bss; + int result; + int err = 0; + int numbss = 0; + int i = 0; + u8 ie_buf[46]; + int ie_len; + + if (!request) + return -EINVAL; + + dev = request->wdev->netdev; + wlandev = dev->ml_priv; + + if (priv->scan_request && priv->scan_request != request) + return -EBUSY; + + if (wlandev->macmode == WLAN_MACMODE_ESS_AP) { + netdev_err(dev, "Can't scan in AP mode\n"); + return -EOPNOTSUPP; + } + + priv->scan_request = request; + + memset(&msg1, 0x00, sizeof(struct p80211msg_dot11req_scan)); + msg1.msgcode = DIDmsg_dot11req_scan; + msg1.bsstype.data = P80211ENUM_bsstype_any; + + memset(&msg1.bssid.data.data, 0xFF, sizeof(msg1.bssid.data.data)); + msg1.bssid.data.len = 6; + + if (request->n_ssids > 0) { + msg1.scantype.data = P80211ENUM_scantype_active; + msg1.ssid.data.len = request->ssids->ssid_len; + memcpy(msg1.ssid.data.data, + request->ssids->ssid, request->ssids->ssid_len); + } else { + msg1.scantype.data = 0; + } + msg1.probedelay.data = 0; + + for (i = 0; + (i < request->n_channels) && i < ARRAY_SIZE(prism2_channels); + i++) + msg1.channellist.data.data[i] = + ieee80211_frequency_to_channel( + request->channels[i]->center_freq); + msg1.channellist.data.len = request->n_channels; + + msg1.maxchanneltime.data = 250; + msg1.minchanneltime.data = 200; + + result = p80211req_dorequest(wlandev, (u8 *) &msg1); + if (result) { + err = prism2_result2err(msg1.resultcode.data); + goto exit; + } + /* Now retrieve scan results */ + numbss = msg1.numbss.data; + + for (i = 0; i < numbss; i++) { + int freq; + + memset(&msg2, 0, sizeof(msg2)); + msg2.msgcode = DIDmsg_dot11req_scan_results; + msg2.bssindex.data = i; + + result = p80211req_dorequest(wlandev, (u8 *) &msg2); + if ((result != 0) || + (msg2.resultcode.data != P80211ENUM_resultcode_success)) { + break; + } + + ie_buf[0] = WLAN_EID_SSID; + ie_buf[1] = msg2.ssid.data.len; + ie_len = ie_buf[1] + 2; + memcpy(&ie_buf[2], &(msg2.ssid.data.data), msg2.ssid.data.len); + freq = ieee80211_channel_to_frequency(msg2.dschannel.data, + IEEE80211_BAND_2GHZ); + bss = cfg80211_inform_bss(wiphy, + ieee80211_get_channel(wiphy, freq), + (const u8 *) &(msg2.bssid.data.data), + msg2.timestamp.data, msg2.capinfo.data, + msg2.beaconperiod.data, + ie_buf, + ie_len, + (msg2.signal.data - 65536) * 100, /* Conversion to signed type */ + GFP_KERNEL + ); + + if (!bss) { + err = -ENOMEM; + goto exit; + } + + cfg80211_put_bss(wiphy, bss); + } + + if (result) + err = prism2_result2err(msg2.resultcode.data); + +exit: + cfg80211_scan_done(request, err ? 1 : 0); + priv->scan_request = NULL; + return err; +} + +static int prism2_set_wiphy_params(struct wiphy *wiphy, u32 changed) +{ + struct prism2_wiphy_private *priv = wiphy_priv(wiphy); + wlandevice_t *wlandev = priv->wlandev; + u32 data; + int result; + int err = 0; + + if (changed & WIPHY_PARAM_RTS_THRESHOLD) { + if (wiphy->rts_threshold == -1) + data = 2347; + else + data = wiphy->rts_threshold; + + result = prism2_domibset_uint32(wlandev, + DIDmib_dot11mac_dot11OperationTable_dot11RTSThreshold, + data); + if (result) { + err = -EFAULT; + goto exit; + } + } + + if (changed & WIPHY_PARAM_FRAG_THRESHOLD) { + if (wiphy->frag_threshold == -1) + data = 2346; + else + data = wiphy->frag_threshold; + + result = prism2_domibset_uint32(wlandev, + DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold, + data); + if (result) { + err = -EFAULT; + goto exit; + } + } + +exit: + return err; +} + +static int prism2_connect(struct wiphy *wiphy, struct net_device *dev, + struct cfg80211_connect_params *sme) +{ + wlandevice_t *wlandev = dev->ml_priv; + struct ieee80211_channel *channel = sme->channel; + struct p80211msg_lnxreq_autojoin msg_join; + u32 did; + int length = sme->ssid_len; + int chan = -1; + int is_wep = (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP40) || + (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP104); + int result; + int err = 0; + + /* Set the channel */ + if (channel) { + chan = ieee80211_frequency_to_channel(channel->center_freq); + result = prism2_domibset_uint32(wlandev, + DIDmib_dot11phy_dot11PhyDSSSTable_dot11CurrentChannel, + chan); + if (result) + goto exit; + } + + /* Set the authorization */ + if ((sme->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM) || + ((sme->auth_type == NL80211_AUTHTYPE_AUTOMATIC) && !is_wep)) + msg_join.authtype.data = P80211ENUM_authalg_opensystem; + else if ((sme->auth_type == NL80211_AUTHTYPE_SHARED_KEY) || + ((sme->auth_type == NL80211_AUTHTYPE_AUTOMATIC) && is_wep)) + msg_join.authtype.data = P80211ENUM_authalg_sharedkey; + else + netdev_warn(dev, + "Unhandled authorisation type for connect (%d)\n", + sme->auth_type); + + /* Set the encryption - we only support wep */ + if (is_wep) { + if (sme->key) { + result = prism2_domibset_uint32(wlandev, + DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID, + sme->key_idx); + if (result) + goto exit; + + /* send key to driver */ + switch (sme->key_idx) { + case 0: + did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0; + break; + + case 1: + did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1; + break; + + case 2: + did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2; + break; + + case 3: + did = DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3; + break; + + default: + err = -EINVAL; + goto exit; + } + + result = prism2_domibset_pstr32(wlandev, + did, sme->key_len, + (u8 *)sme->key); + if (result) + goto exit; + + } + + /* Assume we should set privacy invoked and exclude unencrypted + We could possibly use sme->privacy here, but the assumption + seems reasonable anyway */ + result = prism2_domibset_uint32(wlandev, + DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked, + P80211ENUM_truth_true); + if (result) + goto exit; + + result = prism2_domibset_uint32(wlandev, + DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted, + P80211ENUM_truth_true); + if (result) + goto exit; + + } else { + /* Assume we should unset privacy invoked + and exclude unencrypted */ + result = prism2_domibset_uint32(wlandev, + DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked, + P80211ENUM_truth_false); + if (result) + goto exit; + + result = prism2_domibset_uint32(wlandev, + DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted, + P80211ENUM_truth_false); + if (result) + goto exit; + + } + + /* Now do the actual join. Note there is no way that I can + see to request a specific bssid */ + msg_join.msgcode = DIDmsg_lnxreq_autojoin; + + memcpy(msg_join.ssid.data.data, sme->ssid, length); + msg_join.ssid.data.len = length; + + result = p80211req_dorequest(wlandev, (u8 *) &msg_join); + +exit: + if (result) + err = -EFAULT; + + return err; +} + +static int prism2_disconnect(struct wiphy *wiphy, struct net_device *dev, + u16 reason_code) +{ + wlandevice_t *wlandev = dev->ml_priv; + struct p80211msg_lnxreq_autojoin msg_join; + int result; + int err = 0; + + + /* Do a join, with a bogus ssid. Thats the only way I can think of */ + msg_join.msgcode = DIDmsg_lnxreq_autojoin; + + memcpy(msg_join.ssid.data.data, "---", 3); + msg_join.ssid.data.len = 3; + + result = p80211req_dorequest(wlandev, (u8 *) &msg_join); + + if (result) + err = -EFAULT; + + return err; +} + + +static int prism2_join_ibss(struct wiphy *wiphy, struct net_device *dev, + struct cfg80211_ibss_params *params) +{ + return -EOPNOTSUPP; +} + +static int prism2_leave_ibss(struct wiphy *wiphy, struct net_device *dev) +{ + return -EOPNOTSUPP; +} + + +static int prism2_set_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev, + enum nl80211_tx_power_setting type, int mbm) +{ + struct prism2_wiphy_private *priv = wiphy_priv(wiphy); + wlandevice_t *wlandev = priv->wlandev; + u32 data; + int result; + int err = 0; + + if (type == NL80211_TX_POWER_AUTOMATIC) + data = 30; + else + data = MBM_TO_DBM(mbm); + + result = prism2_domibset_uint32(wlandev, + DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel, + data); + + if (result) { + err = -EFAULT; + goto exit; + } + +exit: + return err; +} + +static int prism2_get_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev, + int *dbm) +{ + struct prism2_wiphy_private *priv = wiphy_priv(wiphy); + wlandevice_t *wlandev = priv->wlandev; + struct p80211msg_dot11req_mibget msg; + p80211item_uint32_t *mibitem; + int result; + int err = 0; + + mibitem = (p80211item_uint32_t *) &msg.mibattribute.data; + msg.msgcode = DIDmsg_dot11req_mibget; + mibitem->did = + DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel; + + result = p80211req_dorequest(wlandev, (u8 *) &msg); + + if (result) { + err = -EFAULT; + goto exit; + } + + *dbm = mibitem->data; + +exit: + return err; +} + + + + +/* Interface callback functions, passing data back up to the cfg80211 layer */ +void prism2_connect_result(wlandevice_t *wlandev, u8 failed) +{ + u16 status = failed ? + WLAN_STATUS_UNSPECIFIED_FAILURE : WLAN_STATUS_SUCCESS; + + cfg80211_connect_result(wlandev->netdev, wlandev->bssid, + NULL, 0, NULL, 0, status, GFP_KERNEL); +} + +void prism2_disconnected(wlandevice_t *wlandev) +{ + cfg80211_disconnected(wlandev->netdev, 0, NULL, + 0, GFP_KERNEL); +} + +void prism2_roamed(wlandevice_t *wlandev) +{ + cfg80211_roamed(wlandev->netdev, NULL, wlandev->bssid, + NULL, 0, NULL, 0, GFP_KERNEL); +} + + +/* Structures for declaring wiphy interface */ +static const struct cfg80211_ops prism2_usb_cfg_ops = { + .change_virtual_intf = prism2_change_virtual_intf, + .add_key = prism2_add_key, + .get_key = prism2_get_key, + .del_key = prism2_del_key, + .set_default_key = prism2_set_default_key, + .get_station = prism2_get_station, + .scan = prism2_scan, + .set_wiphy_params = prism2_set_wiphy_params, + .connect = prism2_connect, + .disconnect = prism2_disconnect, + .join_ibss = prism2_join_ibss, + .leave_ibss = prism2_leave_ibss, + .set_tx_power = prism2_set_tx_power, + .get_tx_power = prism2_get_tx_power, +}; + + +/* Functions to create/free wiphy interface */ +static struct wiphy *wlan_create_wiphy(struct device *dev, wlandevice_t *wlandev) +{ + struct wiphy *wiphy; + struct prism2_wiphy_private *priv; + + wiphy = wiphy_new(&prism2_usb_cfg_ops, sizeof(*priv)); + if (!wiphy) + return NULL; + + priv = wiphy_priv(wiphy); + priv->wlandev = wlandev; + memcpy(priv->channels, prism2_channels, sizeof(prism2_channels)); + memcpy(priv->rates, prism2_rates, sizeof(prism2_rates)); + priv->band.channels = priv->channels; + priv->band.n_channels = ARRAY_SIZE(prism2_channels); + priv->band.bitrates = priv->rates; + priv->band.n_bitrates = ARRAY_SIZE(prism2_rates); + priv->band.band = IEEE80211_BAND_2GHZ; + priv->band.ht_cap.ht_supported = false; + wiphy->bands[IEEE80211_BAND_2GHZ] = &priv->band; + + set_wiphy_dev(wiphy, dev); + wiphy->privid = prism2_wiphy_privid; + wiphy->max_scan_ssids = 1; + wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) + | BIT(NL80211_IFTYPE_ADHOC); + wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; + wiphy->n_cipher_suites = PRISM2_NUM_CIPHER_SUITES; + wiphy->cipher_suites = prism2_cipher_suites; + + if (wiphy_register(wiphy) < 0) + return NULL; + + return wiphy; +} + + +static void wlan_free_wiphy(struct wiphy *wiphy) +{ + wiphy_unregister(wiphy); + wiphy_free(wiphy); +} diff --git a/drivers/staging/wlan-ng/hfa384x.h b/drivers/staging/wlan-ng/hfa384x.h index 46cce8159e5..1f2c78cc008 100644 --- a/drivers/staging/wlan-ng/hfa384x.h +++ b/drivers/staging/wlan-ng/hfa384x.h @@ -59,19 +59,20 @@ #define HFA384x_FIRMWARE_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c)) #include <linux/if_ether.h> +#include <linux/usb.h> /*--- Mins & Maxs -----------------------------------*/ -#define HFA384x_PORTID_MAX ((u16)7) -#define HFA384x_NUMPORTS_MAX ((u16)(HFA384x_PORTID_MAX+1)) -#define HFA384x_PDR_LEN_MAX ((u16)512) /* in bytes, from EK */ -#define HFA384x_PDA_RECS_MAX ((u16)200) /* a guess */ -#define HFA384x_PDA_LEN_MAX ((u16)1024) /* in bytes, from EK */ -#define HFA384x_SCANRESULT_MAX ((u16)31) -#define HFA384x_HSCANRESULT_MAX ((u16)31) -#define HFA384x_CHINFORESULT_MAX ((u16)16) -#define HFA384x_RID_GUESSING_MAXLEN 2048 /* I'm not really sure */ -#define HFA384x_RIDDATA_MAXLEN HFA384x_RID_GUESSING_MAXLEN -#define HFA384x_USB_RWMEM_MAXLEN 2048 +#define HFA384x_PORTID_MAX ((u16)7) +#define HFA384x_NUMPORTS_MAX ((u16)(HFA384x_PORTID_MAX+1)) +#define HFA384x_PDR_LEN_MAX ((u16)512) /* in bytes, from EK */ +#define HFA384x_PDA_RECS_MAX ((u16)200) /* a guess */ +#define HFA384x_PDA_LEN_MAX ((u16)1024) /* in bytes, from EK*/ +#define HFA384x_SCANRESULT_MAX ((u16)31) +#define HFA384x_HSCANRESULT_MAX ((u16)31) +#define HFA384x_CHINFORESULT_MAX ((u16)16) +#define HFA384x_RID_GUESSING_MAXLEN 2048 /* I'm not really sure */ +#define HFA384x_RIDDATA_MAXLEN HFA384x_RID_GUESSING_MAXLEN +#define HFA384x_USB_RWMEM_MAXLEN 2048 /*--- Support Constants -----------------------------*/ #define HFA384x_PORTTYPE_IBSS ((u16)0) @@ -81,8 +82,8 @@ #define HFA384x_WEPFLAGS_EXCLUDE ((u16)BIT(1)) #define HFA384x_WEPFLAGS_DISABLE_TXCRYPT ((u16)BIT(4)) #define HFA384x_WEPFLAGS_DISABLE_RXCRYPT ((u16)BIT(7)) -#define HFA384x_ROAMMODE_HOSTSCAN_HOSTROAM ((u16)3) -#define HFA384x_PORTSTATUS_DISABLED ((u16)1) +#define HFA384x_ROAMMODE_HOSTSCAN_HOSTROAM ((u16)3) +#define HFA384x_PORTSTATUS_DISABLED ((u16)1) #define HFA384x_RATEBIT_1 ((u16)1) #define HFA384x_RATEBIT_2 ((u16)2) #define HFA384x_RATEBIT_5dot5 ((u16)4) @@ -115,8 +116,8 @@ /* Make a 32-bit flat address from AUX format 16-bit page and offset */ #define HFA384x_ADDR_AUX_MKFLAT(p, o) \ - (((u32)(((u16)(p))&HFA384x_ADDR_AUX_PAGE_MASK)) << 7) | \ - ((u32)(((u16)(o))&HFA384x_ADDR_AUX_OFF_MASK)) + ((((u32)(((u16)(p))&HFA384x_ADDR_AUX_PAGE_MASK)) << 7) | \ + ((u32)(((u16)(o))&HFA384x_ADDR_AUX_OFF_MASK))) /* Make CMD format offset and page from a 32-bit flat address */ #define HFA384x_ADDR_CMD_MKPAGE(f) \ @@ -135,12 +136,21 @@ #define HFA384x_DLSTATE_FLASHENABLED 2 /*--- Register Field Masks --------------------------*/ -#define HFA384x_CMD_AINFO ((u16)(BIT(14) | BIT(13) | BIT(12) | BIT(11) | BIT(10) | BIT(9) | BIT(8))) -#define HFA384x_CMD_MACPORT ((u16)(BIT(10) | BIT(9) | BIT(8))) +#define HFA384x_CMD_AINFO ((u16)(BIT(14) | BIT(13) \ + | BIT(12) | BIT(11) \ + | BIT(10) | BIT(9) \ + | BIT(8))) +#define HFA384x_CMD_MACPORT ((u16)(BIT(10) | BIT(9) | \ + BIT(8))) #define HFA384x_CMD_PROGMODE ((u16)(BIT(9) | BIT(8))) -#define HFA384x_CMD_CMDCODE ((u16)(BIT(5) | BIT(4) | BIT(3) | BIT(2) | BIT(1) | BIT(0))) +#define HFA384x_CMD_CMDCODE ((u16)(BIT(5) | BIT(4) | \ + BIT(3) | BIT(2) | \ + BIT(1) | BIT(0))) -#define HFA384x_STATUS_RESULT ((u16)(BIT(14) | BIT(13) | BIT(12) | BIT(11) | BIT(10) | BIT(9) | BIT(8))) +#define HFA384x_STATUS_RESULT ((u16)(BIT(14) | BIT(13) \ + | BIT(12) | BIT(11) \ + | BIT(10) | BIT(9) \ + | BIT(8))) /*--- Command Code Constants --------------------------*/ /*--- Controller Commands --------------------------*/ @@ -155,7 +165,7 @@ #define HFA384x_CMDCODE_DOWNLD ((u16)0x22) /*--- Debugging Commands -----------------------------*/ -#define HFA384x_CMDCODE_MONITOR ((u16)(0x38)) +#define HFA384x_CMDCODE_MONITOR ((u16)(0x38)) #define HFA384x_MONITOR_ENABLE ((u16)(0x0b)) #define HFA384x_MONITOR_DISABLE ((u16)(0x0f)) @@ -244,8 +254,10 @@ Information RID Lengths: MAC Information This is the length of JUST the DATA part of the RID (does not include the len or code fields) --------------------------------------------------------------------*/ -#define HFA384x_RID_DBMCOMMSQUALITY_LEN ((u16)sizeof(hfa384x_dbmcommsquality_t)) -#define HFA384x_RID_JOINREQUEST_LEN ((u16)sizeof(hfa384x_JoinRequest_data_t)) +#define HFA384x_RID_DBMCOMMSQUALITY_LEN \ + ((u16) sizeof(hfa384x_dbmcommsquality_t)) +#define HFA384x_RID_JOINREQUEST_LEN \ + ((u16)sizeof(hfa384x_JoinRequest_data_t)) /*-------------------------------------------------------------------- Information RIDs: Modem Information @@ -264,15 +276,15 @@ API ENHANCEMENTS (NOT ALREADY IMPLEMENTED) #define HFA384x_RID_CNFAUTHENTICATION ((u16)0xFC2A) #define HFA384x_RID_CNFROAMINGMODE ((u16)0xFC2D) #define HFA384x_RID_CNFAPBCNint ((u16)0xFC33) -#define HFA384x_RID_CNFDBMADJUST ((u16)0xFC46) -#define HFA384x_RID_CNFWPADATA ((u16)0xFC48) +#define HFA384x_RID_CNFDBMADJUST ((u16)0xFC46) +#define HFA384x_RID_CNFWPADATA ((u16)0xFC48) #define HFA384x_RID_CNFBASICRATES ((u16)0xFCB3) #define HFA384x_RID_CNFSUPPRATES ((u16)0xFCB4) #define HFA384x_RID_CNFPASSIVESCANCTRL ((u16)0xFCBA) -#define HFA384x_RID_TXPOWERMAX ((u16)0xFCBE) +#define HFA384x_RID_TXPOWERMAX ((u16)0xFCBE) #define HFA384x_RID_JOINREQUEST ((u16)0xFCE2) #define HFA384x_RID_AUTHENTICATESTA ((u16)0xFCE3) -#define HFA384x_RID_HOSTSCAN ((u16)0xFCE5) +#define HFA384x_RID_HOSTSCAN ((u16)0xFCE5) #define HFA384x_RID_CNFWEPDEFAULTKEY_LEN ((u16)6) #define HFA384x_RID_CNFWEP128DEFAULTKEY_LEN ((u16)14) @@ -300,7 +312,7 @@ PD Record codes #define HFA384x_PDR_HFA3861_IFRF ((u16)0x0204) #define HFA384x_PDR_HFA3861_CHCALSP ((u16)0x0300) #define HFA384x_PDR_HFA3861_CHCALI ((u16)0x0301) -#define HFA384x_PDR_MAX_TX_POWER ((u16)0x0302) +#define HFA384x_PDR_MAX_TX_POWER ((u16)0x0302) #define HFA384x_PDR_MASTER_CHAN_LIST ((u16)0x0303) #define HFA384x_PDR_3842_NIC_CONFIG ((u16)0x0400) #define HFA384x_PDR_USB_ID ((u16)0x0401) @@ -311,10 +323,10 @@ PD Record codes #define HFA384x_PDR_USB_POWER_TYPE ((u16)0x0407) #define HFA384x_PDR_USB_MAX_POWER ((u16)0x0409) #define HFA384x_PDR_USB_MANUFACTURER ((u16)0x0410) -#define HFA384x_PDR_USB_PRODUCT ((u16)0x0411) -#define HFA384x_PDR_ANT_DIVERSITY ((u16)0x0412) -#define HFA384x_PDR_HFO_DELAY ((u16)0x0413) -#define HFA384x_PDR_SCALE_THRESH ((u16)0x0414) +#define HFA384x_PDR_USB_PRODUCT ((u16)0x0411) +#define HFA384x_PDR_ANT_DIVERSITY ((u16)0x0412) +#define HFA384x_PDR_HFO_DELAY ((u16)0x0413) +#define HFA384x_PDR_SCALE_THRESH ((u16)0x0414) #define HFA384x_PDR_HFA3861_MANF_TESTSP ((u16)0x0900) #define HFA384x_PDR_HFA3861_MANF_TESTI ((u16)0x0901) @@ -322,9 +334,11 @@ PD Record codes /*--- Register Test/Get/Set Field macros ------------------------*/ -#define HFA384x_CMD_AINFO_SET(value) ((u16)((u16)(value) << 8)) -#define HFA384x_CMD_MACPORT_SET(value) ((u16)HFA384x_CMD_AINFO_SET(value)) -#define HFA384x_CMD_PROGMODE_SET(value) ((u16)HFA384x_CMD_AINFO_SET((u16)value)) +#define HFA384x_CMD_AINFO_SET(value) ((u16)((u16)(value) << 8)) +#define HFA384x_CMD_MACPORT_SET(value) \ + ((u16)HFA384x_CMD_AINFO_SET(value)) +#define HFA384x_CMD_PROGMODE_SET(value) \ + ((u16)HFA384x_CMD_AINFO_SET((u16)value)) #define HFA384x_CMD_CMDCODE_SET(value) ((u16)(value)) #define HFA384x_STATUS_RESULT_SET(value) (((u16)(value)) << 8) @@ -336,15 +350,15 @@ PD Record codes /*-------------------------------------------------------------*/ /* Commonly used basic types */ -typedef struct hfa384x_bytestr { +struct hfa384x_bytestr { u16 len; u8 data[0]; -} __attribute__ ((packed)) hfa384x_bytestr_t; +} __packed; typedef struct hfa384x_bytestr32 { u16 len; u8 data[32]; -} __attribute__ ((packed)) hfa384x_bytestr32_t; +} __packed hfa384x_bytestr32_t; /*-------------------------------------------------------------------- Configuration Record Structures: @@ -357,7 +371,7 @@ typedef struct hfa384x_compident { u16 variant; u16 major; u16 minor; -} __attribute__ ((packed)) hfa384x_compident_t; +} __packed hfa384x_compident_t; typedef struct hfa384x_caplevel { u16 role; @@ -365,12 +379,12 @@ typedef struct hfa384x_caplevel { u16 variant; u16 bottom; u16 top; -} __attribute__ ((packed)) hfa384x_caplevel_t; +} __packed hfa384x_caplevel_t; /*-- Configuration Record: cnfAuthentication --*/ #define HFA384x_CNFAUTHENTICATION_OPENSYSTEM 0x0001 #define HFA384x_CNFAUTHENTICATION_SHAREDKEY 0x0002 -#define HFA384x_CNFAUTHENTICATION_LEAP 0x0004 +#define HFA384x_CNFAUTHENTICATION_LEAP 0x0004 /*-------------------------------------------------------------------- Configuration Record Structures: @@ -384,26 +398,26 @@ typedef struct hfa384x_HostScanRequest_data { u16 channelList; u16 txRate; hfa384x_bytestr32_t ssid; -} __attribute__ ((packed)) hfa384x_HostScanRequest_data_t; +} __packed hfa384x_HostScanRequest_data_t; /*-- Configuration Record: JoinRequest (data portion only) --*/ typedef struct hfa384x_JoinRequest_data { u8 bssid[WLAN_BSSID_LEN]; u16 channel; -} __attribute__ ((packed)) hfa384x_JoinRequest_data_t; +} __packed hfa384x_JoinRequest_data_t; /*-- Configuration Record: authenticateStation (data portion only) --*/ typedef struct hfa384x_authenticateStation_data { u8 address[ETH_ALEN]; u16 status; u16 algorithm; -} __attribute__ ((packed)) hfa384x_authenticateStation_data_t; +} __packed hfa384x_authenticateStation_data_t; /*-- Configuration Record: WPAData (data portion only) --*/ typedef struct hfa384x_WPAData { u16 datalen; - u8 data[0]; // max 80 -} __attribute__ ((packed)) hfa384x_WPAData_t; + u8 data[0]; /* max 80 */ +} __packed hfa384x_WPAData_t; /*-------------------------------------------------------------------- Information Record Structures: NIC Information @@ -415,7 +429,7 @@ typedef struct hfa384x_downloadbuffer { u16 page; u16 offset; u16 len; -} __attribute__ ((packed)) hfa384x_downloadbuffer_t; +} __packed hfa384x_downloadbuffer_t; /*-------------------------------------------------------------------- Information Record Structures: NIC Information @@ -428,14 +442,14 @@ typedef struct hfa384x_commsquality { u16 CQ_currBSS; u16 ASL_currBSS; u16 ANL_currFC; -} __attribute__ ((packed)) hfa384x_commsquality_t; +} __packed hfa384x_commsquality_t; /*-- Information Record: dmbcommsquality --*/ typedef struct hfa384x_dbmcommsquality { u16 CQdbm_currBSS; u16 ASLdbm_currBSS; u16 ANLdbm_currFC; -} __attribute__ ((packed)) hfa384x_dbmcommsquality_t; +} __packed hfa384x_dbmcommsquality_t; /*-------------------------------------------------------------------- FRAME STRUCTURES: Communication Frames @@ -468,7 +482,7 @@ typedef struct hfa384x_tx_frame { u8 dest_addr[6]; u8 src_addr[6]; u16 data_length; /* big endian format */ -} __attribute__ ((packed)) hfa384x_tx_frame_t; +} __packed hfa384x_tx_frame_t; /*-------------------------------------------------------------------- Communication Frames: Field Masks for Transmit Frames --------------------------------------------------------------------*/ @@ -479,7 +493,8 @@ Communication Frames: Field Masks for Transmit Frames #define HFA384x_TXSTATUS_AGEDERR ((u16)BIT(1)) #define HFA384x_TXSTATUS_RETRYERR ((u16)BIT(0)) /*-- Transmit Control Field --*/ -#define HFA384x_TX_MACPORT ((u16)(BIT(10) | BIT(9) | BIT(8))) +#define HFA384x_TX_MACPORT ((u16)(BIT(10) | \ + BIT(9) | BIT(8))) #define HFA384x_TX_STRUCTYPE ((u16)(BIT(4) | BIT(3))) #define HFA384x_TX_TXEX ((u16)BIT(2)) #define HFA384x_TX_TXOK ((u16)BIT(1)) @@ -496,7 +511,8 @@ Communication Frames: Test/Get/Set Field Values for Transmit Frames #define HFA384x_TX_SET(v, m, s) ((((u16)(v))<<((u16)(s)))&((u16)(m))) #define HFA384x_TX_MACPORT_SET(v) HFA384x_TX_SET(v, HFA384x_TX_MACPORT, 8) -#define HFA384x_TX_STRUCTYPE_SET(v) HFA384x_TX_SET(v, HFA384x_TX_STRUCTYPE, 3) +#define HFA384x_TX_STRUCTYPE_SET(v) HFA384x_TX_SET(v, \ + HFA384x_TX_STRUCTYPE, 3) #define HFA384x_TX_TXEX_SET(v) HFA384x_TX_SET(v, HFA384x_TX_TXEX, 2) #define HFA384x_TX_TXOK_SET(v) HFA384x_TX_SET(v, HFA384x_TX_TXOK, 1) /*-------------------------------------------------------------------- @@ -515,32 +531,36 @@ typedef struct hfa384x_rx_frame { u16 reserved2; /*-- 802.11 Header Information (802.11 byte order) --*/ - u16 frame_control; + __le16 frame_control; u16 duration_id; u8 address1[6]; u8 address2[6]; u8 address3[6]; u16 sequence_control; u8 address4[6]; - u16 data_len; /* hfa384x (little endian) format */ + __le16 data_len; /* hfa384x (little endian) format */ /*-- 802.3 Header Information --*/ u8 dest_addr[6]; u8 src_addr[6]; u16 data_length; /* IEEE? (big endian) format */ -} __attribute__ ((packed)) hfa384x_rx_frame_t; +} __packed hfa384x_rx_frame_t; /*-------------------------------------------------------------------- Communication Frames: Field Masks for Receive Frames --------------------------------------------------------------------*/ /*-- Status Fields --*/ -#define HFA384x_RXSTATUS_MACPORT ((u16)(BIT(10) | BIT(9) | BIT(8))) +#define HFA384x_RXSTATUS_MACPORT ((u16)(BIT(10) | \ + BIT(9) | \ + BIT(8))) #define HFA384x_RXSTATUS_FCSERR ((u16)BIT(0)) /*-------------------------------------------------------------------- Communication Frames: Test/Get/Set Field Values for Receive Frames --------------------------------------------------------------------*/ -#define HFA384x_RXSTATUS_MACPORT_GET(value) ((u16)((((u16)(value)) & HFA384x_RXSTATUS_MACPORT) >> 8)) -#define HFA384x_RXSTATUS_ISFCSERR(value) ((u16)(((u16)(value)) & HFA384x_RXSTATUS_FCSERR)) +#define HFA384x_RXSTATUS_MACPORT_GET(value) ((u16)((((u16)(value)) \ + & HFA384x_RXSTATUS_MACPORT) >> 8)) +#define HFA384x_RXSTATUS_ISFCSERR(value) ((u16)(((u16)(value)) \ + & HFA384x_RXSTATUS_FCSERR)) /*-------------------------------------------------------------------- FRAME STRUCTURES: Information Types and Information Frame Structures ---------------------------------------------------------------------- @@ -556,8 +576,8 @@ Information Types #define HFA384x_IT_AUTHREQ ((u16)0xF202UL) #define HFA384x_IT_PSUSERCNT ((u16)0xF203UL) #define HFA384x_IT_KEYIDCHANGED ((u16)0xF204UL) -#define HFA384x_IT_ASSOCREQ ((u16)0xF205UL) -#define HFA384x_IT_MICFAILURE ((u16)0xF206UL) +#define HFA384x_IT_ASSOCREQ ((u16)0xF205UL) +#define HFA384x_IT_MICFAILURE ((u16)0xF206UL) /*-------------------------------------------------------------------- Information Frames Structures @@ -588,7 +608,7 @@ typedef struct hfa384x_CommTallies16 { u16 rxdiscardswepundecr; u16 rxmsginmsgfrag; u16 rxmsginbadmsgfrag; -} __attribute__ ((packed)) hfa384x_CommTallies16_t; +} __packed hfa384x_CommTallies16_t; typedef struct hfa384x_CommTallies32 { u32 txunicastframes; @@ -612,7 +632,7 @@ typedef struct hfa384x_CommTallies32 { u32 rxdiscardswepundecr; u32 rxmsginmsgfrag; u32 rxmsginbadmsgfrag; -} __attribute__ ((packed)) hfa384x_CommTallies32_t; +} __packed hfa384x_CommTallies32_t; /*-- Inquiry Frame, Diagnose: Scan Results & Subfields--*/ typedef struct hfa384x_ScanResultSub { @@ -625,13 +645,13 @@ typedef struct hfa384x_ScanResultSub { hfa384x_bytestr32_t ssid; u8 supprates[10]; /* 802.11 info element */ u16 proberesp_rate; -} __attribute__ ((packed)) hfa384x_ScanResultSub_t; +} __packed hfa384x_ScanResultSub_t; typedef struct hfa384x_ScanResult { u16 rsvd; u16 scanreason; hfa384x_ScanResultSub_t result[HFA384x_SCANRESULT_MAX]; -} __attribute__ ((packed)) hfa384x_ScanResult_t; +} __packed hfa384x_ScanResult_t; /*-- Inquiry Frame, Diagnose: ChInfo Results & Subfields--*/ typedef struct hfa384x_ChInfoResultSub { @@ -639,7 +659,7 @@ typedef struct hfa384x_ChInfoResultSub { u16 anl; u16 pnl; u16 active; -} __attribute__ ((packed)) hfa384x_ChInfoResultSub_t; +} __packed hfa384x_ChInfoResultSub_t; #define HFA384x_CHINFORESULT_BSSACTIVE BIT(0) #define HFA384x_CHINFORESULT_PCFACTIVE BIT(1) @@ -647,7 +667,7 @@ typedef struct hfa384x_ChInfoResultSub { typedef struct hfa384x_ChInfoResult { u16 scanchannels; hfa384x_ChInfoResultSub_t result[HFA384x_CHINFORESULT_MAX]; -} __attribute__ ((packed)) hfa384x_ChInfoResult_t; +} __packed hfa384x_ChInfoResult_t; /*-- Inquiry Frame, Diagnose: Host Scan Results & Subfields--*/ typedef struct hfa384x_HScanResultSub { @@ -661,13 +681,13 @@ typedef struct hfa384x_HScanResultSub { u8 supprates[10]; /* 802.11 info element */ u16 proberesp_rate; u16 atim; -} __attribute__ ((packed)) hfa384x_HScanResultSub_t; +} __packed hfa384x_HScanResultSub_t; typedef struct hfa384x_HScanResult { u16 nresult; u16 rsvd; hfa384x_HScanResultSub_t result[HFA384x_HSCANRESULT_MAX]; -} __attribute__ ((packed)) hfa384x_HScanResult_t; +} __packed hfa384x_HScanResult_t; /*-- Unsolicited Frame, MAC Mgmt: LinkStatus --*/ @@ -681,7 +701,7 @@ typedef struct hfa384x_HScanResult { typedef struct hfa384x_LinkStatus { u16 linkstatus; -} __attribute__ ((packed)) hfa384x_LinkStatus_t; +} __packed hfa384x_LinkStatus_t; /*-- Unsolicited Frame, MAC Mgmt: AssociationStatus (--*/ @@ -696,25 +716,25 @@ typedef struct hfa384x_AssocStatus { u8 old_ap_addr[ETH_ALEN]; u16 reason; u16 reserved; -} __attribute__ ((packed)) hfa384x_AssocStatus_t; +} __packed hfa384x_AssocStatus_t; /*-- Unsolicited Frame, MAC Mgmt: AuthRequest (AP Only) --*/ typedef struct hfa384x_AuthRequest { u8 sta_addr[ETH_ALEN]; u16 algorithm; -} __attribute__ ((packed)) hfa384x_AuthReq_t; +} __packed hfa384x_AuthReq_t; /*-- Unsolicited Frame, MAC Mgmt: PSUserCount (AP Only) --*/ typedef struct hfa384x_PSUserCount { u16 usercnt; -} __attribute__ ((packed)) hfa384x_PSUserCount_t; +} __packed hfa384x_PSUserCount_t; typedef struct hfa384x_KeyIDChanged { u8 sta_addr[ETH_ALEN]; u16 keyid; -} __attribute__ ((packed)) hfa384x_KeyIDChanged_t; +} __packed hfa384x_KeyIDChanged_t; /*-- Collection of all Inf frames ---------------*/ typedef union hfa384x_infodata { @@ -728,13 +748,13 @@ typedef union hfa384x_infodata { hfa384x_AuthReq_t authreq; hfa384x_PSUserCount_t psusercnt; hfa384x_KeyIDChanged_t keyidchanged; -} __attribute__ ((packed)) hfa384x_infodata_t; +} __packed hfa384x_infodata_t; typedef struct hfa384x_InfFrame { u16 framelen; u16 infotype; hfa384x_infodata_t info; -} __attribute__ ((packed)) hfa384x_InfFrame_t; +} __packed hfa384x_InfFrame_t; /*-------------------------------------------------------------------- USB Packet structures and constants. @@ -766,7 +786,7 @@ USB Packet structures and constants. typedef struct hfa384x_usb_txfrm { hfa384x_tx_frame_t desc; u8 data[WLAN_DATA_MAXLEN]; -} __attribute__ ((packed)) hfa384x_usb_txfrm_t; +} __packed hfa384x_usb_txfrm_t; typedef struct hfa384x_usb_cmdreq { u16 type; @@ -775,21 +795,21 @@ typedef struct hfa384x_usb_cmdreq { u16 parm1; u16 parm2; u8 pad[54]; -} __attribute__ ((packed)) hfa384x_usb_cmdreq_t; +} __packed hfa384x_usb_cmdreq_t; typedef struct hfa384x_usb_wridreq { u16 type; u16 frmlen; u16 rid; u8 data[HFA384x_RIDDATA_MAXLEN]; -} __attribute__ ((packed)) hfa384x_usb_wridreq_t; +} __packed hfa384x_usb_wridreq_t; typedef struct hfa384x_usb_rridreq { u16 type; u16 frmlen; u16 rid; u8 pad[58]; -} __attribute__ ((packed)) hfa384x_usb_rridreq_t; +} __packed hfa384x_usb_rridreq_t; typedef struct hfa384x_usb_wmemreq { u16 type; @@ -797,7 +817,7 @@ typedef struct hfa384x_usb_wmemreq { u16 offset; u16 page; u8 data[HFA384x_USB_RWMEM_MAXLEN]; -} __attribute__ ((packed)) hfa384x_usb_wmemreq_t; +} __packed hfa384x_usb_wmemreq_t; typedef struct hfa384x_usb_rmemreq { u16 type; @@ -805,7 +825,7 @@ typedef struct hfa384x_usb_rmemreq { u16 offset; u16 page; u8 pad[56]; -} __attribute__ ((packed)) hfa384x_usb_rmemreq_t; +} __packed hfa384x_usb_rmemreq_t; /*------------------------------------*/ /* Response (bulk IN) packet contents */ @@ -813,12 +833,12 @@ typedef struct hfa384x_usb_rmemreq { typedef struct hfa384x_usb_rxfrm { hfa384x_rx_frame_t desc; u8 data[WLAN_DATA_MAXLEN]; -} __attribute__ ((packed)) hfa384x_usb_rxfrm_t; +} __packed hfa384x_usb_rxfrm_t; typedef struct hfa384x_usb_infofrm { u16 type; hfa384x_InfFrame_t info; -} __attribute__ ((packed)) hfa384x_usb_infofrm_t; +} __packed hfa384x_usb_infofrm_t; typedef struct hfa384x_usb_statusresp { u16 type; @@ -826,7 +846,7 @@ typedef struct hfa384x_usb_statusresp { u16 resp0; u16 resp1; u16 resp2; -} __attribute__ ((packed)) hfa384x_usb_cmdresp_t; +} __packed hfa384x_usb_cmdresp_t; typedef hfa384x_usb_cmdresp_t hfa384x_usb_wridresp_t; @@ -835,7 +855,7 @@ typedef struct hfa384x_usb_rridresp { u16 frmlen; u16 rid; u8 data[HFA384x_RIDDATA_MAXLEN]; -} __attribute__ ((packed)) hfa384x_usb_rridresp_t; +} __packed hfa384x_usb_rridresp_t; typedef hfa384x_usb_cmdresp_t hfa384x_usb_wmemresp_t; @@ -843,17 +863,17 @@ typedef struct hfa384x_usb_rmemresp { u16 type; u16 frmlen; u8 data[HFA384x_USB_RWMEM_MAXLEN]; -} __attribute__ ((packed)) hfa384x_usb_rmemresp_t; +} __packed hfa384x_usb_rmemresp_t; typedef struct hfa384x_usb_bufavail { u16 type; u16 frmlen; -} __attribute__ ((packed)) hfa384x_usb_bufavail_t; +} __packed hfa384x_usb_bufavail_t; typedef struct hfa384x_usb_error { u16 type; u16 errortype; -} __attribute__ ((packed)) hfa384x_usb_error_t; +} __packed hfa384x_usb_error_t; /*----------------------------------------------------------*/ /* Unions for packaging all the known packet types together */ @@ -866,7 +886,7 @@ typedef union hfa384x_usbout { hfa384x_usb_rridreq_t rridreq; hfa384x_usb_wmemreq_t wmemreq; hfa384x_usb_rmemreq_t rmemreq; -} __attribute__ ((packed)) hfa384x_usbout_t; +} __packed hfa384x_usbout_t; typedef union hfa384x_usbin { u16 type; @@ -881,7 +901,7 @@ typedef union hfa384x_usbin { hfa384x_usb_bufavail_t bufavail; hfa384x_usb_error_t usberror; u8 boguspad[3000]; -} __attribute__ ((packed)) hfa384x_usbin_t; +} __packed hfa384x_usbin_t; /*-------------------------------------------------------------------- PD record structures. @@ -889,15 +909,15 @@ PD record structures. typedef struct hfa384x_pdr_pcb_partnum { u8 num[8]; -} __attribute__ ((packed)) hfa384x_pdr_pcb_partnum_t; +} __packed hfa384x_pdr_pcb_partnum_t; typedef struct hfa384x_pdr_pcb_tracenum { u8 num[8]; -} __attribute__ ((packed)) hfa384x_pdr_pcb_tracenum_t; +} __packed hfa384x_pdr_pcb_tracenum_t; typedef struct hfa384x_pdr_nic_serial { u8 num[12]; -} __attribute__ ((packed)) hfa384x_pdr_nic_serial_t; +} __packed hfa384x_pdr_nic_serial_t; typedef struct hfa384x_pdr_mkk_measurements { double carrier_freq; @@ -915,138 +935,138 @@ typedef struct hfa384x_pdr_mkk_measurements { double rx_spur_f2; double rx_spur_l1; double rx_spur_l2; -} __attribute__ ((packed)) hfa384x_pdr_mkk_measurements_t; +} __packed hfa384x_pdr_mkk_measurements_t; typedef struct hfa384x_pdr_nic_ramsize { u8 size[12]; /* units of KB */ -} __attribute__ ((packed)) hfa384x_pdr_nic_ramsize_t; +} __packed hfa384x_pdr_nic_ramsize_t; typedef struct hfa384x_pdr_mfisuprange { u16 id; u16 variant; u16 bottom; u16 top; -} __attribute__ ((packed)) hfa384x_pdr_mfisuprange_t; +} __packed hfa384x_pdr_mfisuprange_t; typedef struct hfa384x_pdr_cfisuprange { u16 id; u16 variant; u16 bottom; u16 top; -} __attribute__ ((packed)) hfa384x_pdr_cfisuprange_t; +} __packed hfa384x_pdr_cfisuprange_t; typedef struct hfa384x_pdr_nicid { u16 id; u16 variant; u16 major; u16 minor; -} __attribute__ ((packed)) hfa384x_pdr_nicid_t; +} __packed hfa384x_pdr_nicid_t; typedef struct hfa384x_pdr_refdac_measurements { u16 value[0]; -} __attribute__ ((packed)) hfa384x_pdr_refdac_measurements_t; +} __packed hfa384x_pdr_refdac_measurements_t; typedef struct hfa384x_pdr_vgdac_measurements { u16 value[0]; -} __attribute__ ((packed)) hfa384x_pdr_vgdac_measurements_t; +} __packed hfa384x_pdr_vgdac_measurements_t; typedef struct hfa384x_pdr_level_comp_measurements { u16 value[0]; -} __attribute__ ((packed)) hfa384x_pdr_level_compc_measurements_t; +} __packed hfa384x_pdr_level_compc_measurements_t; typedef struct hfa384x_pdr_mac_address { u8 addr[6]; -} __attribute__ ((packed)) hfa384x_pdr_mac_address_t; +} __packed hfa384x_pdr_mac_address_t; typedef struct hfa384x_pdr_mkk_callname { u8 callname[8]; -} __attribute__ ((packed)) hfa384x_pdr_mkk_callname_t; +} __packed hfa384x_pdr_mkk_callname_t; typedef struct hfa384x_pdr_regdomain { u16 numdomains; u16 domain[5]; -} __attribute__ ((packed)) hfa384x_pdr_regdomain_t; +} __packed hfa384x_pdr_regdomain_t; typedef struct hfa384x_pdr_allowed_channel { u16 ch_bitmap; -} __attribute__ ((packed)) hfa384x_pdr_allowed_channel_t; +} __packed hfa384x_pdr_allowed_channel_t; typedef struct hfa384x_pdr_default_channel { u16 channel; -} __attribute__ ((packed)) hfa384x_pdr_default_channel_t; +} __packed hfa384x_pdr_default_channel_t; typedef struct hfa384x_pdr_privacy_option { u16 available; -} __attribute__ ((packed)) hfa384x_pdr_privacy_option_t; +} __packed hfa384x_pdr_privacy_option_t; typedef struct hfa384x_pdr_temptype { u16 type; -} __attribute__ ((packed)) hfa384x_pdr_temptype_t; +} __packed hfa384x_pdr_temptype_t; typedef struct hfa384x_pdr_refdac_setup { u16 ch_value[14]; -} __attribute__ ((packed)) hfa384x_pdr_refdac_setup_t; +} __packed hfa384x_pdr_refdac_setup_t; typedef struct hfa384x_pdr_vgdac_setup { u16 ch_value[14]; -} __attribute__ ((packed)) hfa384x_pdr_vgdac_setup_t; +} __packed hfa384x_pdr_vgdac_setup_t; typedef struct hfa384x_pdr_level_comp_setup { u16 ch_value[14]; -} __attribute__ ((packed)) hfa384x_pdr_level_comp_setup_t; +} __packed hfa384x_pdr_level_comp_setup_t; typedef struct hfa384x_pdr_trimdac_setup { u16 trimidac; u16 trimqdac; -} __attribute__ ((packed)) hfa384x_pdr_trimdac_setup_t; +} __packed hfa384x_pdr_trimdac_setup_t; typedef struct hfa384x_pdr_ifr_setting { u16 value[3]; -} __attribute__ ((packed)) hfa384x_pdr_ifr_setting_t; +} __packed hfa384x_pdr_ifr_setting_t; typedef struct hfa384x_pdr_rfr_setting { u16 value[3]; -} __attribute__ ((packed)) hfa384x_pdr_rfr_setting_t; +} __packed hfa384x_pdr_rfr_setting_t; typedef struct hfa384x_pdr_hfa3861_baseline { u16 value[50]; -} __attribute__ ((packed)) hfa384x_pdr_hfa3861_baseline_t; +} __packed hfa384x_pdr_hfa3861_baseline_t; typedef struct hfa384x_pdr_hfa3861_shadow { u32 value[32]; -} __attribute__ ((packed)) hfa384x_pdr_hfa3861_shadow_t; +} __packed hfa384x_pdr_hfa3861_shadow_t; typedef struct hfa384x_pdr_hfa3861_ifrf { u32 value[20]; -} __attribute__ ((packed)) hfa384x_pdr_hfa3861_ifrf_t; +} __packed hfa384x_pdr_hfa3861_ifrf_t; typedef struct hfa384x_pdr_hfa3861_chcalsp { u16 value[14]; -} __attribute__ ((packed)) hfa384x_pdr_hfa3861_chcalsp_t; +} __packed hfa384x_pdr_hfa3861_chcalsp_t; typedef struct hfa384x_pdr_hfa3861_chcali { u16 value[17]; -} __attribute__ ((packed)) hfa384x_pdr_hfa3861_chcali_t; +} __packed hfa384x_pdr_hfa3861_chcali_t; typedef struct hfa384x_pdr_hfa3861_nic_config { u16 config_bitmap; -} __attribute__ ((packed)) hfa384x_pdr_nic_config_t; +} __packed hfa384x_pdr_nic_config_t; typedef struct hfa384x_pdr_hfo_delay { u8 hfo_delay; -} __attribute__ ((packed)) hfa384x_hfo_delay_t; +} __packed hfa384x_hfo_delay_t; typedef struct hfa384x_pdr_hfa3861_manf_testsp { u16 value[30]; -} __attribute__ ((packed)) hfa384x_pdr_hfa3861_manf_testsp_t; +} __packed hfa384x_pdr_hfa3861_manf_testsp_t; typedef struct hfa384x_pdr_hfa3861_manf_testi { u16 value[30]; -} __attribute__ ((packed)) hfa384x_pdr_hfa3861_manf_testi_t; +} __packed hfa384x_pdr_hfa3861_manf_testi_t; typedef struct hfa384x_end_of_pda { u16 crc; -} __attribute__ ((packed)) hfa384x_pdr_end_of_pda_t; +} __packed hfa384x_pdr_end_of_pda_t; typedef struct hfa384x_pdrec { u16 len; /* in words */ @@ -1088,7 +1108,7 @@ typedef struct hfa384x_pdrec { hfa384x_pdr_end_of_pda_t end_of_pda; } data; -} __attribute__ ((packed)) hfa384x_pdrec_t; +} __packed hfa384x_pdrec_t; #ifdef __KERNEL__ /*-------------------------------------------------------------------- @@ -1133,7 +1153,7 @@ struct hfa384x; typedef void (*ctlx_cmdcb_t) (struct hfa384x *, const struct hfa384x_usbctlx *); -typedef void (*ctlx_usercb_t) (struct hfa384x * hw, +typedef void (*ctlx_usercb_t) (struct hfa384x *hw, void *ctlxresult, void *usercb_data); typedef struct hfa384x_usbctlx { @@ -1174,14 +1194,14 @@ typedef struct hfa484x_metacmd { } hfa384x_metacmd_t; #define MAX_GRP_ADDR 32 -#define WLAN_COMMENT_MAX 80 /* Max. length of user comment string. */ +#define WLAN_COMMENT_MAX 80 /* Max. length of user comment string. */ -#define WLAN_AUTH_MAX 60 /* Max. # of authenticated stations. */ -#define WLAN_ACCESS_MAX 60 /* Max. # of stations in an access list. */ -#define WLAN_ACCESS_NONE 0 /* No stations may be authenticated. */ -#define WLAN_ACCESS_ALL 1 /* All stations may be authenticated. */ -#define WLAN_ACCESS_ALLOW 2 /* Authenticate only "allowed" stations. */ -#define WLAN_ACCESS_DENY 3 /* Do not authenticate "denied" stations. */ +#define WLAN_AUTH_MAX 60 /* Max. # of authenticated stations. */ +#define WLAN_ACCESS_MAX 60 /* Max. # of stations in an access list. */ +#define WLAN_ACCESS_NONE 0 /* No stations may be authenticated. */ +#define WLAN_ACCESS_ALL 1 /* All stations may be authenticated. */ +#define WLAN_ACCESS_ALLOW 2 /* Authenticate only "allowed" stations. */ +#define WLAN_ACCESS_DENY 3 /* Do not authenticate "denied" stations. */ /* XXX These are going away ASAP */ typedef struct prism2sta_authlist { @@ -1265,6 +1285,8 @@ typedef struct hfa384x { u16 link_status_new; struct sk_buff_head authq; + u32 txrate; + /* And here we have stuff that used to be in priv */ /* State variables */ @@ -1294,10 +1316,23 @@ typedef struct hfa384x { hfa384x_caplevel_t cap_sup_ap; /* Actor compatibility ranges */ - hfa384x_caplevel_t cap_act_pri_cfi; /* pri f/w to controller interface */ - hfa384x_caplevel_t cap_act_sta_cfi; /* sta f/w to controller interface */ + hfa384x_caplevel_t cap_act_pri_cfi; /* + * pri f/w to controller + * interface + */ + + hfa384x_caplevel_t cap_act_sta_cfi; /* + * sta f/w to controller + * interface + */ + hfa384x_caplevel_t cap_act_sta_mfi; /* sta f/w to modem interface */ - hfa384x_caplevel_t cap_act_ap_cfi; /* ap f/w to controller interface */ + + hfa384x_caplevel_t cap_act_ap_cfi; /* + * ap f/w to controller + * interface + */ + hfa384x_caplevel_t cap_act_ap_mfi; /* ap f/w to modem interface */ u32 psusercount; /* Power save user count. */ @@ -1320,25 +1355,25 @@ typedef struct hfa384x { } hfa384x_t; -void hfa384x_create(hfa384x_t * hw, struct usb_device *usb); -void hfa384x_destroy(hfa384x_t * hw); +void hfa384x_create(hfa384x_t *hw, struct usb_device *usb); +void hfa384x_destroy(hfa384x_t *hw); int -hfa384x_corereset(hfa384x_t * hw, int holdtime, int settletime, int genesis); -int hfa384x_drvr_commtallies(hfa384x_t * hw); -int hfa384x_drvr_disable(hfa384x_t * hw, u16 macport); -int hfa384x_drvr_enable(hfa384x_t * hw, u16 macport); -int hfa384x_drvr_flashdl_enable(hfa384x_t * hw); -int hfa384x_drvr_flashdl_disable(hfa384x_t * hw); -int hfa384x_drvr_flashdl_write(hfa384x_t * hw, u32 daddr, void *buf, u32 len); -int hfa384x_drvr_getconfig(hfa384x_t * hw, u16 rid, void *buf, u16 len); -int hfa384x_drvr_ramdl_enable(hfa384x_t * hw, u32 exeaddr); -int hfa384x_drvr_ramdl_disable(hfa384x_t * hw); -int hfa384x_drvr_ramdl_write(hfa384x_t * hw, u32 daddr, void *buf, u32 len); -int hfa384x_drvr_readpda(hfa384x_t * hw, void *buf, unsigned int len); -int hfa384x_drvr_setconfig(hfa384x_t * hw, u16 rid, void *buf, u16 len); - -static inline int hfa384x_drvr_getconfig16(hfa384x_t * hw, u16 rid, void *val) +hfa384x_corereset(hfa384x_t *hw, int holdtime, int settletime, int genesis); +int hfa384x_drvr_commtallies(hfa384x_t *hw); +int hfa384x_drvr_disable(hfa384x_t *hw, u16 macport); +int hfa384x_drvr_enable(hfa384x_t *hw, u16 macport); +int hfa384x_drvr_flashdl_enable(hfa384x_t *hw); +int hfa384x_drvr_flashdl_disable(hfa384x_t *hw); +int hfa384x_drvr_flashdl_write(hfa384x_t *hw, u32 daddr, void *buf, u32 len); +int hfa384x_drvr_getconfig(hfa384x_t *hw, u16 rid, void *buf, u16 len); +int hfa384x_drvr_ramdl_enable(hfa384x_t *hw, u32 exeaddr); +int hfa384x_drvr_ramdl_disable(hfa384x_t *hw); +int hfa384x_drvr_ramdl_write(hfa384x_t *hw, u32 daddr, void *buf, u32 len); +int hfa384x_drvr_readpda(hfa384x_t *hw, void *buf, unsigned int len); +int hfa384x_drvr_setconfig(hfa384x_t *hw, u16 rid, void *buf, u16 len); + +static inline int hfa384x_drvr_getconfig16(hfa384x_t *hw, u16 rid, void *val) { int result = 0; result = hfa384x_drvr_getconfig(hw, rid, val, sizeof(u16)); @@ -1347,46 +1382,46 @@ static inline int hfa384x_drvr_getconfig16(hfa384x_t * hw, u16 rid, void *val) return result; } -static inline int hfa384x_drvr_setconfig16(hfa384x_t * hw, u16 rid, u16 val) +static inline int hfa384x_drvr_setconfig16(hfa384x_t *hw, u16 rid, u16 val) { u16 value = cpu_to_le16(val); return hfa384x_drvr_setconfig(hw, rid, &value, sizeof(value)); } int -hfa384x_drvr_getconfig_async(hfa384x_t * hw, +hfa384x_drvr_getconfig_async(hfa384x_t *hw, u16 rid, ctlx_usercb_t usercb, void *usercb_data); int -hfa384x_drvr_setconfig_async(hfa384x_t * hw, +hfa384x_drvr_setconfig_async(hfa384x_t *hw, u16 rid, void *buf, u16 len, ctlx_usercb_t usercb, void *usercb_data); static inline int -hfa384x_drvr_setconfig16_async(hfa384x_t * hw, u16 rid, u16 val) +hfa384x_drvr_setconfig16_async(hfa384x_t *hw, u16 rid, u16 val) { u16 value = cpu_to_le16(val); return hfa384x_drvr_setconfig_async(hw, rid, &value, sizeof(value), NULL, NULL); } -int hfa384x_drvr_start(hfa384x_t * hw); -int hfa384x_drvr_stop(hfa384x_t * hw); +int hfa384x_drvr_start(hfa384x_t *hw); +int hfa384x_drvr_stop(hfa384x_t *hw); int -hfa384x_drvr_txframe(hfa384x_t * hw, struct sk_buff *skb, - p80211_hdr_t * p80211_hdr, p80211_metawep_t * p80211_wep); -void hfa384x_tx_timeout(wlandevice_t * wlandev); - -int hfa384x_cmd_initialize(hfa384x_t * hw); -int hfa384x_cmd_enable(hfa384x_t * hw, u16 macport); -int hfa384x_cmd_disable(hfa384x_t * hw, u16 macport); -int hfa384x_cmd_allocate(hfa384x_t * hw, u16 len); -int hfa384x_cmd_monitor(hfa384x_t * hw, u16 enable); +hfa384x_drvr_txframe(hfa384x_t *hw, struct sk_buff *skb, + union p80211_hdr *p80211_hdr, struct p80211_metawep *p80211_wep); +void hfa384x_tx_timeout(wlandevice_t *wlandev); + +int hfa384x_cmd_initialize(hfa384x_t *hw); +int hfa384x_cmd_enable(hfa384x_t *hw, u16 macport); +int hfa384x_cmd_disable(hfa384x_t *hw, u16 macport); +int hfa384x_cmd_allocate(hfa384x_t *hw, u16 len); +int hfa384x_cmd_monitor(hfa384x_t *hw, u16 enable); int -hfa384x_cmd_download(hfa384x_t * hw, +hfa384x_cmd_download(hfa384x_t *hw, u16 mode, u16 lowaddr, u16 highaddr, u16 codelen); -#endif /* __KERNEL__ */ +#endif /*__KERNEL__ */ -#endif /* _HFA384x_H */ +#endif /*_HFA384x_H */ diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c index 925678babd9..98343ff7061 100644 --- a/drivers/staging/wlan-ng/hfa384x_usb.c +++ b/drivers/staging/wlan-ng/hfa384x_usb.c @@ -52,7 +52,7 @@ * around the register accesses. The next higher level represents C-callable * prism2 API functions that match the Intersil documentation as closely * as is reasonable. The next higher layer implements common sequences -* of invokations of the API layer (e.g. write to bap, followed by cmd). +* of invocations of the API layer (e.g. write to bap, followed by cmd). * * Common sequences: * hfa384x_drvr_xxx Highest level abstractions provided by the @@ -62,9 +62,9 @@ * * hfa384x_drvr_xxxconfig An example of the drvr level abstraction. These * functions are wrappers for the RID get/set -* sequence. They call copy_[to|from]_bap() and -* cmd_access(). These functions operate on the -* RIDs and buffers without validation. The caller +* sequence. They call copy_[to|from]_bap() and +* cmd_access(). These functions operate on the +* RIDs and buffers without validation. The caller * is responsible for that. * * API wrapper functions: @@ -118,15 +118,15 @@ #include <linux/wireless.h> #include <linux/netdevice.h> #include <linux/timer.h> -#include <asm/io.h> +#include <linux/io.h> #include <linux/delay.h> #include <asm/byteorder.h> -#include <asm/bitops.h> +#include <linux/bitops.h> #include <linux/list.h> #include <linux/usb.h> #include <linux/byteorder/generic.h> -#define SUBMIT_URB(u,f) usb_submit_urb(u,f) +#define SUBMIT_URB(u, f) usb_submit_urb(u, f) #include "p80211types.h" #include "p80211hdr.h" @@ -144,7 +144,6 @@ enum cmd_mode { DOWAIT = 0, DOASYNC }; -typedef enum cmd_mode CMD_MODE; #define THROTTLE_JIFFIES (HZ/8) #define URB_ASYNC_UNLINK 0 @@ -172,11 +171,11 @@ static void hfa384x_ctlxout_callback(struct urb *urb); static void hfa384x_usbin_callback(struct urb *urb); static void -hfa384x_usbin_txcompl(wlandevice_t *wlandev, hfa384x_usbin_t * usbin); +hfa384x_usbin_txcompl(wlandevice_t *wlandev, hfa384x_usbin_t *usbin); static void hfa384x_usbin_rx(wlandevice_t *wlandev, struct sk_buff *skb); -static void hfa384x_usbin_info(wlandevice_t *wlandev, hfa384x_usbin_t * usbin); +static void hfa384x_usbin_info(wlandevice_t *wlandev, hfa384x_usbin_t *usbin); static void hfa384x_usbout_tx(wlandevice_t *wlandev, hfa384x_usbout_t *usbout); @@ -204,14 +203,13 @@ static int hfa384x_usbctlx_submit(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx); static void unlocked_usbctlx_complete(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx); struct usbctlx_completor { - int (*complete) (struct usbctlx_completor *); + int (*complete)(struct usbctlx_completor *); }; -typedef struct usbctlx_completor usbctlx_completor_t; static int hfa384x_usbctlx_complete_sync(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx, - usbctlx_completor_t *completor); + struct usbctlx_completor *completor); static int unlocked_usbctlx_cancel_async(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx); @@ -232,13 +230,13 @@ usbctlx_get_rridresult(const hfa384x_usb_rridresp_t *rridresp, /* Low level req/resp CTLX formatters and submitters */ static int hfa384x_docmd(hfa384x_t *hw, - CMD_MODE mode, + enum cmd_mode mode, hfa384x_metacmd_t *cmd, ctlx_cmdcb_t cmdcb, ctlx_usercb_t usercb, void *usercb_data); static int hfa384x_dorrid(hfa384x_t *hw, - CMD_MODE mode, + enum cmd_mode mode, u16 rid, void *riddata, unsigned int riddatalen, @@ -246,7 +244,7 @@ hfa384x_dorrid(hfa384x_t *hw, static int hfa384x_dowrid(hfa384x_t *hw, - CMD_MODE mode, + enum cmd_mode mode, u16 rid, void *riddata, unsigned int riddatalen, @@ -254,7 +252,7 @@ hfa384x_dowrid(hfa384x_t *hw, static int hfa384x_dormem(hfa384x_t *hw, - CMD_MODE mode, + enum cmd_mode mode, u16 page, u16 offset, void *data, @@ -263,7 +261,7 @@ hfa384x_dormem(hfa384x_t *hw, static int hfa384x_dowmem(hfa384x_t *hw, - CMD_MODE mode, + enum cmd_mode mode, u16 page, u16 offset, void *data, @@ -274,7 +272,7 @@ static int hfa384x_isgood_pdrcode(u16 pdrcode); static inline const char *ctlxstr(CTLX_STATE s) { - static const char *ctlx_str[] = { + static const char * const ctlx_str[] = { "Initial state", "Complete", "Request failed", @@ -287,7 +285,7 @@ static inline const char *ctlxstr(CTLX_STATE s) return ctlx_str[s]; }; -static inline hfa384x_usbctlx_t *get_active_ctlx(hfa384x_t * hw) +static inline hfa384x_usbctlx_t *get_active_ctlx(hfa384x_t *hw) { return list_entry(hw->ctlxq.active.next, hfa384x_usbctlx_t, list); } @@ -351,14 +349,15 @@ static int submit_rx_urb(hfa384x_t *hw, gfp_t memflags) hw->rx_urb_skb = skb; result = -ENOLINK; - if (!hw->wlandev->hwremoved && !test_bit(WORK_RX_HALT, &hw->usb_flags)) { + if (!hw->wlandev->hwremoved && + !test_bit(WORK_RX_HALT, &hw->usb_flags)) { result = SUBMIT_URB(&hw->rx_urb, memflags); /* Check whether we need to reset the RX pipe */ if (result == -EPIPE) { - printk(KERN_WARNING - "%s rx pipe stalled: requesting reset\n", - hw->wlandev->netdev->name); + netdev_warn(hw->wlandev->netdev, + "%s rx pipe stalled: requesting reset\n", + hw->wlandev->netdev->name); if (!test_and_set_bit(WORK_RX_HALT, &hw->usb_flags)) schedule_work(&hw->usb_work); } @@ -399,16 +398,15 @@ static int submit_tx_urb(hfa384x_t *hw, struct urb *tx_urb, gfp_t memflags) result = -ENOLINK; if (netif_running(netdev)) { - - if (!hw->wlandev->hwremoved - && !test_bit(WORK_TX_HALT, &hw->usb_flags)) { + if (!hw->wlandev->hwremoved && + !test_bit(WORK_TX_HALT, &hw->usb_flags)) { result = SUBMIT_URB(tx_urb, memflags); /* Test whether we need to reset the TX pipe */ if (result == -EPIPE) { - printk(KERN_WARNING - "%s tx pipe stalled: requesting reset\n", - netdev->name); + netdev_warn(hw->wlandev->netdev, + "%s tx pipe stalled: requesting reset\n", + netdev->name); set_bit(WORK_TX_HALT, &hw->usb_flags); schedule_work(&hw->usb_work); } else if (result == 0) { @@ -451,16 +449,16 @@ static void hfa384x_usb_defer(struct work_struct *data) if (test_bit(WORK_RX_HALT, &hw->usb_flags)) { int ret; - usb_kill_urb(&hw->rx_urb); /* Cannot be holding spinlock! */ + usb_kill_urb(&hw->rx_urb); /* Cannot be holding spinlock! */ ret = usb_clear_halt(hw->usb, hw->endp_in); if (ret != 0) { - printk(KERN_ERR - "Failed to clear rx pipe for %s: err=%d\n", - netdev->name, ret); + netdev_err(hw->wlandev->netdev, + "Failed to clear rx pipe for %s: err=%d\n", + netdev->name, ret); } else { - printk(KERN_INFO "%s rx pipe reset complete.\n", - netdev->name); + netdev_info(hw->wlandev->netdev, "%s rx pipe reset complete.\n", + netdev->name); clear_bit(WORK_RX_HALT, &hw->usb_flags); set_bit(WORK_RX_RESUME, &hw->usb_flags); } @@ -472,8 +470,9 @@ static void hfa384x_usb_defer(struct work_struct *data) ret = submit_rx_urb(hw, GFP_KERNEL); if (ret != 0) { - printk(KERN_ERR - "Failed to resume %s rx pipe.\n", netdev->name); + netdev_err(hw->wlandev->netdev, + "Failed to resume %s rx pipe.\n", + netdev->name); } else { clear_bit(WORK_RX_RESUME, &hw->usb_flags); } @@ -486,12 +485,12 @@ static void hfa384x_usb_defer(struct work_struct *data) usb_kill_urb(&hw->tx_urb); ret = usb_clear_halt(hw->usb, hw->endp_out); if (ret != 0) { - printk(KERN_ERR - "Failed to clear tx pipe for %s: err=%d\n", - netdev->name, ret); + netdev_err(hw->wlandev->netdev, + "Failed to clear tx pipe for %s: err=%d\n", + netdev->name, ret); } else { - printk(KERN_INFO "%s tx pipe reset complete.\n", - netdev->name); + netdev_info(hw->wlandev->netdev, "%s tx pipe reset complete.\n", + netdev->name); clear_bit(WORK_TX_HALT, &hw->usb_flags); set_bit(WORK_TX_RESUME, &hw->usb_flags); @@ -512,7 +511,7 @@ static void hfa384x_usb_defer(struct work_struct *data) * hfa384x_create * * Sets up the hfa384x_t data structure for use. Note this -* does _not_ intialize the actual hardware, just the data structures +* does _not_ initialize the actual hardware, just the data structures * we use to keep track of its state. * * Arguments: @@ -613,10 +612,8 @@ void hfa384x_destroy(hfa384x_t *hw) hfa384x_drvr_stop(hw); hw->state = HFA384x_STATE_PREINIT; - if (hw->scanresults) { - kfree(hw->scanresults); - hw->scanresults = NULL; - } + kfree(hw->scanresults); + hw->scanresults = NULL; /* Now to clean out the auth queue */ while ((skb = skb_dequeue(&hw->authq))) @@ -627,7 +624,7 @@ static hfa384x_usbctlx_t *usbctlx_alloc(void) { hfa384x_usbctlx_t *ctlx; - ctlx = kmalloc(sizeof(*ctlx), in_interrupt()? GFP_ATOMIC : GFP_KERNEL); + ctlx = kmalloc(sizeof(*ctlx), in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); if (ctlx != NULL) { memset(ctlx, 0, sizeof(*ctlx)); init_completion(&ctlx->done); @@ -645,8 +642,7 @@ usbctlx_get_status(const hfa384x_usb_cmdresp_t *cmdresp, result->resp1 = le16_to_cpu(cmdresp->resp1); result->resp2 = le16_to_cpu(cmdresp->resp2); - pr_debug("cmdresult:status=0x%04x " - "resp0=0x%04x resp1=0x%04x resp2=0x%04x\n", + pr_debug("cmdresult:status=0x%04x resp0=0x%04x resp1=0x%04x resp2=0x%04x\n", result->status, result->resp0, result->resp1, result->resp2); return result->status & HFA384x_STATUS_RESULT; @@ -659,7 +655,6 @@ usbctlx_get_rridresult(const hfa384x_usb_rridresp_t *rridresp, result->rid = le16_to_cpu(rridresp->rid); result->riddata = rridresp->data; result->riddata_len = ((le16_to_cpu(rridresp->frmlen) - 1) * 2); - } /*---------------------------------------------------------------- @@ -668,26 +663,26 @@ usbctlx_get_rridresult(const hfa384x_usb_rridresp_t *rridresp, * when processing a CTLX that returns a hfa384x_cmdresult_t structure. ----------------------------------------------------------------*/ struct usbctlx_cmd_completor { - usbctlx_completor_t head; + struct usbctlx_completor head; const hfa384x_usb_cmdresp_t *cmdresp; hfa384x_cmdresult_t *result; }; -typedef struct usbctlx_cmd_completor usbctlx_cmd_completor_t; -static int usbctlx_cmd_completor_fn(usbctlx_completor_t * head) +static inline int usbctlx_cmd_completor_fn(struct usbctlx_completor *head) { - usbctlx_cmd_completor_t *complete = (usbctlx_cmd_completor_t *) head; + struct usbctlx_cmd_completor *complete; + + complete = (struct usbctlx_cmd_completor *)head; return usbctlx_get_status(complete->cmdresp, complete->result); } -static inline usbctlx_completor_t *init_cmd_completor(usbctlx_cmd_completor_t * - completor, - const - hfa384x_usb_cmdresp_t * - cmdresp, - hfa384x_cmdresult_t * - result) +static inline struct usbctlx_completor *init_cmd_completor( + struct usbctlx_cmd_completor + *completor, + const hfa384x_usb_cmdresp_t + *cmdresp, + hfa384x_cmdresult_t *result) { completor->head.complete = usbctlx_cmd_completor_fn; completor->cmdresp = cmdresp; @@ -701,27 +696,26 @@ static inline usbctlx_completor_t *init_cmd_completor(usbctlx_cmd_completor_t * * when processing a CTLX that reads a RID. ----------------------------------------------------------------*/ struct usbctlx_rrid_completor { - usbctlx_completor_t head; + struct usbctlx_completor head; const hfa384x_usb_rridresp_t *rridresp; void *riddata; unsigned int riddatalen; }; -typedef struct usbctlx_rrid_completor usbctlx_rrid_completor_t; -static int usbctlx_rrid_completor_fn(usbctlx_completor_t *head) +static int usbctlx_rrid_completor_fn(struct usbctlx_completor *head) { - usbctlx_rrid_completor_t *complete = (usbctlx_rrid_completor_t *) head; + struct usbctlx_rrid_completor *complete; hfa384x_rridresult_t rridresult; + complete = (struct usbctlx_rrid_completor *)head; usbctlx_get_rridresult(complete->rridresp, &rridresult); /* Validate the length, note body len calculation in bytes */ if (rridresult.riddata_len != complete->riddatalen) { - printk(KERN_WARNING - "RID len mismatch, rid=0x%04x hlen=%d fwlen=%d\n", - rridresult.rid, - complete->riddatalen, rridresult.riddata_len); + pr_warn("RID len mismatch, rid=0x%04x hlen=%d fwlen=%d\n", + rridresult.rid, + complete->riddatalen, rridresult.riddata_len); return -ENODATA; } @@ -729,12 +723,13 @@ static int usbctlx_rrid_completor_fn(usbctlx_completor_t *head) return 0; } -static inline usbctlx_completor_t *init_rrid_completor(usbctlx_rrid_completor_t - *completor, - const - hfa384x_usb_rridresp_t * - rridresp, void *riddata, - unsigned int riddatalen) +static inline struct usbctlx_completor *init_rrid_completor( + struct usbctlx_rrid_completor + *completor, + const hfa384x_usb_rridresp_t + *rridresp, + void *riddata, + unsigned int riddatalen) { completor->head.complete = usbctlx_rrid_completor_fn; completor->rridresp = rridresp; @@ -747,14 +742,12 @@ static inline usbctlx_completor_t *init_rrid_completor(usbctlx_rrid_completor_t * Completor object: * Interprets the results of a synchronous RID-write ----------------------------------------------------------------*/ -typedef usbctlx_cmd_completor_t usbctlx_wrid_completor_t; #define init_wrid_completor init_cmd_completor /*---------------------------------------------------------------- * Completor object: * Interprets the results of a synchronous memory-write ----------------------------------------------------------------*/ -typedef usbctlx_cmd_completor_t usbctlx_wmem_completor_t; #define init_wmem_completor init_cmd_completor /*---------------------------------------------------------------- @@ -762,28 +755,30 @@ typedef usbctlx_cmd_completor_t usbctlx_wmem_completor_t; * Interprets the results of a synchronous memory-read ----------------------------------------------------------------*/ struct usbctlx_rmem_completor { - usbctlx_completor_t head; + struct usbctlx_completor head; const hfa384x_usb_rmemresp_t *rmemresp; void *data; unsigned int len; }; -typedef struct usbctlx_rmem_completor usbctlx_rmem_completor_t; -static int usbctlx_rmem_completor_fn(usbctlx_completor_t *head) +static int usbctlx_rmem_completor_fn(struct usbctlx_completor *head) { - usbctlx_rmem_completor_t *complete = (usbctlx_rmem_completor_t *) head; + struct usbctlx_rmem_completor *complete = + (struct usbctlx_rmem_completor *)head; pr_debug("rmemresp:len=%d\n", complete->rmemresp->frmlen); memcpy(complete->data, complete->rmemresp->data, complete->len); return 0; } -static inline usbctlx_completor_t *init_rmem_completor(usbctlx_rmem_completor_t - *completor, - hfa384x_usb_rmemresp_t - *rmemresp, void *data, - unsigned int len) +static inline struct usbctlx_completor *init_rmem_completor( + struct usbctlx_rmem_completor + *completor, + hfa384x_usb_rmemresp_t + *rmemresp, + void *data, + unsigned int len) { completor->head.complete = usbctlx_rmem_completor_fn; completor->rmemresp = rmemresp; @@ -991,9 +986,7 @@ int hfa384x_cmd_initialize(hfa384x_t *hw) result = hfa384x_docmd_wait(hw, &cmd); - pr_debug("cmdresp.init: " - "status=0x%04x, resp0=0x%04x, " - "resp1=0x%04x, resp2=0x%04x\n", + pr_debug("cmdresp.init: status=0x%04x, resp0=0x%04x, resp1=0x%04x, resp2=0x%04x\n", cmd.result.status, cmd.result.resp0, cmd.result.resp1, cmd.result.resp2); if (result == 0) { @@ -1211,8 +1204,8 @@ int hfa384x_corereset(hfa384x_t *hw, int holdtime, int settletime, int genesis) result = usb_reset_device(hw->usb); if (result < 0) { - printk(KERN_ERR "usb_reset_device() failed, result=%d.\n", - result); + netdev_err(hw->wlandev->netdev, "usb_reset_device() failed, result=%d.\n", + result); } return result; @@ -1226,7 +1219,7 @@ int hfa384x_corereset(hfa384x_t *hw, int holdtime, int settletime, int genesis) * * Arguments: * hw device structure -* ctlx CTLX ptr +* ctlx CTLX ptr * completor functor object to decide what to * do with the CTLX's result. * @@ -1244,7 +1237,7 @@ int hfa384x_corereset(hfa384x_t *hw, int holdtime, int settletime, int genesis) ----------------------------------------------------------------*/ static int hfa384x_usbctlx_complete_sync(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx, - usbctlx_completor_t *completor) + struct usbctlx_completor *completor) { unsigned long flags; int result; @@ -1311,9 +1304,9 @@ cleanup: if (ctlx->state == CTLX_COMPLETE) { result = completor->complete(completor); } else { - printk(KERN_WARNING "CTLX[%d] error: state(%s)\n", - le16_to_cpu(ctlx->outbuf.type), - ctlxstr(ctlx->state)); + netdev_warn(hw->wlandev->netdev, "CTLX[%d] error: state(%s)\n", + le16_to_cpu(ctlx->outbuf.type), + ctlxstr(ctlx->state)); result = -EIO; } @@ -1359,7 +1352,7 @@ cleanup: ----------------------------------------------------------------*/ static int hfa384x_docmd(hfa384x_t *hw, - CMD_MODE mode, + enum cmd_mode mode, hfa384x_metacmd_t *cmd, ctlx_cmdcb_t cmdcb, ctlx_usercb_t usercb, void *usercb_data) { @@ -1381,8 +1374,7 @@ hfa384x_docmd(hfa384x_t *hw, ctlx->outbufsize = sizeof(ctlx->outbuf.cmdreq); - pr_debug("cmdreq: cmd=0x%04x " - "parm0=0x%04x parm1=0x%04x parm2=0x%04x\n", + pr_debug("cmdreq: cmd=0x%04x parm0=0x%04x parm1=0x%04x parm2=0x%04x\n", cmd->cmd, cmd->parm0, cmd->parm1, cmd->parm2); ctlx->reapable = mode; @@ -1394,7 +1386,7 @@ hfa384x_docmd(hfa384x_t *hw, if (result != 0) { kfree(ctlx); } else if (mode == DOWAIT) { - usbctlx_cmd_completor_t completor; + struct usbctlx_cmd_completor completor; result = hfa384x_usbctlx_complete_sync(hw, ctlx, @@ -1448,7 +1440,7 @@ done: ----------------------------------------------------------------*/ static int hfa384x_dorrid(hfa384x_t *hw, - CMD_MODE mode, + enum cmd_mode mode, u16 rid, void *riddata, unsigned int riddatalen, @@ -1481,7 +1473,7 @@ hfa384x_dorrid(hfa384x_t *hw, if (result != 0) { kfree(ctlx); } else if (mode == DOWAIT) { - usbctlx_rrid_completor_t completor; + struct usbctlx_rrid_completor completor; result = hfa384x_usbctlx_complete_sync(hw, ctlx, @@ -1506,7 +1498,7 @@ done: * * Arguments: * hw device structure -* CMD_MODE DOWAIT or DOASYNC +* enum cmd_mode DOWAIT or DOASYNC * rid RID code * riddata Data portion of RID formatted for MAC * riddatalen Length of the data portion in bytes @@ -1529,7 +1521,7 @@ done: ----------------------------------------------------------------*/ static int hfa384x_dowrid(hfa384x_t *hw, - CMD_MODE mode, + enum cmd_mode mode, u16 rid, void *riddata, unsigned int riddatalen, @@ -1566,7 +1558,7 @@ hfa384x_dowrid(hfa384x_t *hw, if (result != 0) { kfree(ctlx); } else if (mode == DOWAIT) { - usbctlx_wrid_completor_t completor; + struct usbctlx_cmd_completor completor; hfa384x_cmdresult_t wridresult; result = hfa384x_usbctlx_complete_sync(hw, @@ -1616,7 +1608,7 @@ done: ----------------------------------------------------------------*/ static int hfa384x_dormem(hfa384x_t *hw, - CMD_MODE mode, + enum cmd_mode mode, u16 page, u16 offset, void *data, @@ -1658,7 +1650,7 @@ hfa384x_dormem(hfa384x_t *hw, if (result != 0) { kfree(ctlx); } else if (mode == DOWAIT) { - usbctlx_rmem_completor_t completor; + struct usbctlx_rmem_completor completor; result = hfa384x_usbctlx_complete_sync(hw, ctlx, @@ -1707,7 +1699,7 @@ done: ----------------------------------------------------------------*/ static int hfa384x_dowmem(hfa384x_t *hw, - CMD_MODE mode, + enum cmd_mode mode, u16 page, u16 offset, void *data, @@ -1748,7 +1740,7 @@ hfa384x_dowmem(hfa384x_t *hw, if (result != 0) { kfree(ctlx); } else if (mode == DOWAIT) { - usbctlx_wmem_completor_t completor; + struct usbctlx_cmd_completor completor; hfa384x_cmdresult_t wmemresult; result = hfa384x_usbctlx_complete_sync(hw, @@ -1909,18 +1901,19 @@ int hfa384x_drvr_flashdl_enable(hfa384x_t *hw) return -EINVAL; /* Retrieve the buffer loc&size and timeout */ - if ((result = hfa384x_drvr_getconfig(hw, HFA384x_RID_DOWNLOADBUFFER, - &(hw->bufinfo), - sizeof(hw->bufinfo)))) { + result = hfa384x_drvr_getconfig(hw, HFA384x_RID_DOWNLOADBUFFER, + &(hw->bufinfo), sizeof(hw->bufinfo)); + if (result) return result; - } + hw->bufinfo.page = le16_to_cpu(hw->bufinfo.page); hw->bufinfo.offset = le16_to_cpu(hw->bufinfo.offset); hw->bufinfo.len = le16_to_cpu(hw->bufinfo.len); - if ((result = hfa384x_drvr_getconfig16(hw, HFA384x_RID_MAXLOADTIME, - &(hw->dltimeout)))) { + result = hfa384x_drvr_getconfig16(hw, HFA384x_RID_MAXLOADTIME, + &(hw->dltimeout)); + if (result) return result; - } + hw->dltimeout = le16_to_cpu(hw->dltimeout); pr_debug("flashdl_enable\n"); @@ -2017,7 +2010,8 @@ int hfa384x_drvr_flashdl_write(hfa384x_t *hw, u32 daddr, void *buf, u32 len) if (hw->dlstate != HFA384x_DLSTATE_FLASHENABLED) return -EINVAL; - printk(KERN_INFO "Download %d bytes to flash @0x%06x\n", len, daddr); + netdev_info(hw->wlandev->netdev, + "Download %d bytes to flash @0x%06x\n", len, daddr); /* Convert to flat address for arithmetic */ /* NOTE: dlbuffer RID stores the address in AUX format */ @@ -2025,11 +2019,6 @@ int hfa384x_drvr_flashdl_write(hfa384x_t *hw, u32 daddr, void *buf, u32 len) HFA384x_ADDR_AUX_MKFLAT(hw->bufinfo.page, hw->bufinfo.offset); pr_debug("dlbuf.page=0x%04x dlbuf.offset=0x%04x dlbufaddr=0x%08x\n", hw->bufinfo.page, hw->bufinfo.offset, dlbufaddr); - -#if 0 - printk(KERN_WARNING "dlbuf@0x%06lx len=%d to=%d\n", dlbufaddr, - hw->bufinfo.len, hw->dltimeout); -#endif /* Calculations to determine how many fills of the dlbuffer to do * and how many USB wmemreq's to do for each fill. At this point * in time, the dlbuffer size and the wmemreq size are the same. @@ -2054,16 +2043,16 @@ int hfa384x_drvr_flashdl_write(hfa384x_t *hw, u32 daddr, void *buf, u32 len) burnlo = HFA384x_ADDR_CMD_MKOFF(burndaddr); burnhi = HFA384x_ADDR_CMD_MKPAGE(burndaddr); - printk(KERN_INFO "Writing %d bytes to flash @0x%06x\n", - burnlen, burndaddr); + netdev_info(hw->wlandev->netdev, "Writing %d bytes to flash @0x%06x\n", + burnlen, burndaddr); /* Set the download mode */ result = hfa384x_cmd_download(hw, HFA384x_PROGMODE_NV, burnlo, burnhi, burnlen); if (result) { - printk(KERN_ERR "download(NV,lo=%x,hi=%x,len=%x) " - "cmd failed, result=%d. Aborting d/l\n", - burnlo, burnhi, burnlen, result); + netdev_err(hw->wlandev->netdev, + "download(NV,lo=%x,hi=%x,len=%x) cmd failed, result=%d. Aborting d/l\n", + burnlo, burnhi, burnlen, result); goto exit_proc; } @@ -2074,12 +2063,9 @@ int hfa384x_drvr_flashdl_write(hfa384x_t *hw, u32 daddr, void *buf, u32 len) (j * HFA384x_USB_RWMEM_MAXLEN); writepage = HFA384x_ADDR_CMD_MKPAGE(dlbufaddr + - (j * - HFA384x_USB_RWMEM_MAXLEN)); - writeoffset = - HFA384x_ADDR_CMD_MKOFF(dlbufaddr + - (j * - HFA384x_USB_RWMEM_MAXLEN)); + (j * HFA384x_USB_RWMEM_MAXLEN)); + writeoffset = HFA384x_ADDR_CMD_MKOFF(dlbufaddr + + (j * HFA384x_USB_RWMEM_MAXLEN)); writelen = burnlen - (j * HFA384x_USB_RWMEM_MAXLEN); writelen = writelen > HFA384x_USB_RWMEM_MAXLEN ? @@ -2096,10 +2082,9 @@ int hfa384x_drvr_flashdl_write(hfa384x_t *hw, u32 daddr, void *buf, u32 len) HFA384x_PROGMODE_NVWRITE, 0, 0, 0); if (result) { - printk(KERN_ERR - "download(NVWRITE,lo=%x,hi=%x,len=%x) " - "cmd failed, result=%d. Aborting d/l\n", - burnlo, burnhi, burnlen, result); + netdev_err(hw->wlandev->netdev, + "download(NVWRITE,lo=%x,hi=%x,len=%x) cmd failed, result=%d. Aborting d/l\n", + burnlo, burnhi, burnlen, result); goto exit_proc; } @@ -2132,7 +2117,7 @@ exit_proc: * 0 success * >0 f/w reported error - f/w status code * <0 driver reported error -* -ENODATA length mismatch between argument and retrieved +* -ENODATA length mismatch between argument and retrieved * record. * * Side effects: @@ -2142,11 +2127,7 @@ exit_proc: ----------------------------------------------------------------*/ int hfa384x_drvr_getconfig(hfa384x_t *hw, u16 rid, void *buf, u16 len) { - int result; - - result = hfa384x_dorrid_wait(hw, rid, buf, len); - - return result; + return hfa384x_dorrid_wait(hw, rid, buf, len); } /*---------------------------------------------------------------- @@ -2285,15 +2266,15 @@ int hfa384x_drvr_ramdl_enable(hfa384x_t *hw, u32 exeaddr) /* Check that a port isn't active */ for (i = 0; i < HFA384x_PORTID_MAX; i++) { if (hw->port_enabled[i]) { - printk(KERN_ERR - "Can't download with a macport enabled.\n"); + netdev_err(hw->wlandev->netdev, + "Can't download with a macport enabled.\n"); return -EINVAL; } } /* Check that we're not already in a download state */ if (hw->dlstate != HFA384x_DLSTATE_DISABLED) { - printk(KERN_ERR "Download state not disabled.\n"); + netdev_err(hw->wlandev->netdev, "Download state not disabled.\n"); return -EINVAL; } @@ -2358,7 +2339,8 @@ int hfa384x_drvr_ramdl_write(hfa384x_t *hw, u32 daddr, void *buf, u32 len) if (hw->dlstate != HFA384x_DLSTATE_RAMENABLED) return -EINVAL; - printk(KERN_INFO "Writing %d bytes to ram @0x%06x\n", len, daddr); + netdev_info(hw->wlandev->netdev, "Writing %d bytes to ram @0x%06x\n", + len, daddr); /* How many dowmem calls? */ nwrites = len / HFA384x_USB_RWMEM_MAXLEN; @@ -2450,11 +2432,14 @@ int hfa384x_drvr_readpda(hfa384x_t *hw, void *buf, unsigned int len) currpage = HFA384x_ADDR_CMD_MKPAGE(pdaloc[i].cardaddr); curroffset = HFA384x_ADDR_CMD_MKOFF(pdaloc[i].cardaddr); - result = hfa384x_dormem_wait(hw, currpage, curroffset, buf, len); /* units of bytes */ + /* units of bytes */ + result = hfa384x_dormem_wait(hw, currpage, curroffset, buf, + len); if (result) { - printk(KERN_WARNING - "Read from index %zd failed, continuing\n", i); + netdev_warn(hw->wlandev->netdev, + "Read from index %zd failed, continuing\n", + i); continue; } @@ -2466,14 +2451,15 @@ int hfa384x_drvr_readpda(hfa384x_t *hw, void *buf, unsigned int len) pdrcode = le16_to_cpu(pda[currpdr + 1]); /* Test the record length */ if (pdrlen > HFA384x_PDR_LEN_MAX || pdrlen == 0) { - printk(KERN_ERR "pdrlen invalid=%d\n", pdrlen); + netdev_err(hw->wlandev->netdev, + "pdrlen invalid=%d\n", pdrlen); pdaok = 0; break; } /* Test the code */ if (!hfa384x_isgood_pdrcode(pdrcode)) { - printk(KERN_ERR "pdrcode invalid=%d\n", - pdrcode); + netdev_err(hw->wlandev->netdev, "pdrcode invalid=%d\n", + pdrcode); pdaok = 0; break; } @@ -2488,14 +2474,14 @@ int hfa384x_drvr_readpda(hfa384x_t *hw, void *buf, unsigned int len) } } if (pdaok) { - printk(KERN_INFO - "PDA Read from 0x%08x in %s space.\n", - pdaloc[i].cardaddr, - pdaloc[i].auxctl == 0 ? "EXTDS" : - pdaloc[i].auxctl == 1 ? "NV" : - pdaloc[i].auxctl == 2 ? "PHY" : - pdaloc[i].auxctl == 3 ? "ICSRAM" : - "<bogus auxctl>"); + netdev_info(hw->wlandev->netdev, + "PDA Read from 0x%08x in %s space.\n", + pdaloc[i].cardaddr, + pdaloc[i].auxctl == 0 ? "EXTDS" : + pdaloc[i].auxctl == 1 ? "NV" : + pdaloc[i].auxctl == 2 ? "PHY" : + pdaloc[i].auxctl == 3 ? "ICSRAM" : + "<bogus auxctl>"); break; } } @@ -2568,20 +2554,20 @@ int hfa384x_drvr_start(hfa384x_t *hw) result = usb_get_status(hw->usb, USB_RECIP_ENDPOINT, hw->endp_in, &status); if (result < 0) { - printk(KERN_ERR "Cannot get bulk in endpoint status.\n"); + netdev_err(hw->wlandev->netdev, "Cannot get bulk in endpoint status.\n"); goto done; } if ((status == 1) && usb_clear_halt(hw->usb, hw->endp_in)) - printk(KERN_ERR "Failed to reset bulk in endpoint.\n"); + netdev_err(hw->wlandev->netdev, "Failed to reset bulk in endpoint.\n"); result = usb_get_status(hw->usb, USB_RECIP_ENDPOINT, hw->endp_out, &status); if (result < 0) { - printk(KERN_ERR "Cannot get bulk out endpoint status.\n"); + netdev_err(hw->wlandev->netdev, "Cannot get bulk out endpoint status.\n"); goto done; } if ((status == 1) && usb_clear_halt(hw->usb, hw->endp_out)) - printk(KERN_ERR "Failed to reset bulk out endpoint.\n"); + netdev_err(hw->wlandev->netdev, "Failed to reset bulk out endpoint.\n"); /* Synchronous unlink, in case we're trying to restart the driver */ usb_kill_urb(&hw->rx_urb); @@ -2589,8 +2575,9 @@ int hfa384x_drvr_start(hfa384x_t *hw) /* Post the IN urb */ result = submit_rx_urb(hw, GFP_KERNEL); if (result != 0) { - printk(KERN_ERR - "Fatal, failed to submit RX URB, result=%d\n", result); + netdev_err(hw->wlandev->netdev, + "Fatal, failed to submit RX URB, result=%d\n", + result); goto done; } @@ -2606,26 +2593,25 @@ int hfa384x_drvr_start(hfa384x_t *hw) */ result1 = hfa384x_cmd_initialize(hw); msleep(1000); - result = result2 = hfa384x_cmd_initialize(hw); + result = hfa384x_cmd_initialize(hw); + result2 = result; if (result1 != 0) { if (result2 != 0) { - printk(KERN_ERR - "cmd_initialize() failed on two attempts, results %d and %d\n", - result1, result2); + netdev_err(hw->wlandev->netdev, + "cmd_initialize() failed on two attempts, results %d and %d\n", + result1, result2); usb_kill_urb(&hw->rx_urb); goto done; } else { pr_debug("First cmd_initialize() failed (result %d),\n", result1); - pr_debug - ("but second attempt succeeded. All should be ok\n"); + pr_debug("but second attempt succeeded. All should be ok\n"); } } else if (result2 != 0) { - printk(KERN_WARNING - "First cmd_initialize() succeeded, but second attempt failed (result=%d)\n", - result2); - printk(KERN_WARNING - "Most likely the card will be functional\n"); + netdev_warn(hw->wlandev->netdev, "First cmd_initialize() succeeded, but second attempt failed (result=%d)\n", + result2); + netdev_warn(hw->wlandev->netdev, + "Most likely the card will be functional\n"); goto done; } @@ -2656,7 +2642,6 @@ done: ----------------------------------------------------------------*/ int hfa384x_drvr_stop(hfa384x_t *hw) { - int result = 0; int i; might_sleep(); @@ -2681,7 +2666,7 @@ int hfa384x_drvr_stop(hfa384x_t *hw) for (i = 0; i < HFA384x_NUMPORTS_MAX; i++) hw->port_enabled[i] = 0; - return result; + return 0; } /*---------------------------------------------------------------- @@ -2706,8 +2691,8 @@ int hfa384x_drvr_stop(hfa384x_t *hw) * interrupt ----------------------------------------------------------------*/ int hfa384x_drvr_txframe(hfa384x_t *hw, struct sk_buff *skb, - p80211_hdr_t *p80211_hdr, - p80211_metawep_t *p80211_wep) + union p80211_hdr *p80211_hdr, + struct p80211_metawep *p80211_wep) { int usbpktlen = sizeof(hfa384x_tx_frame_t); int result; @@ -2715,7 +2700,7 @@ int hfa384x_drvr_txframe(hfa384x_t *hw, struct sk_buff *skb, char *ptr; if (hw->tx_urb.status == -EINPROGRESS) { - printk(KERN_WARNING "TX URB already in use\n"); + netdev_warn(hw->wlandev->netdev, "TX URB already in use\n"); result = 3; goto exit; } @@ -2752,7 +2737,7 @@ int hfa384x_drvr_txframe(hfa384x_t *hw, struct sk_buff *skb, /* copy the header over to the txdesc */ memcpy(&(hw->txbuff.txfrm.desc.frame_control), p80211_hdr, - sizeof(p80211_hdr_t)); + sizeof(union p80211_hdr)); /* if we're using host WEP, increase size by IV+ICV */ if (p80211_wep->data) { @@ -2790,7 +2775,8 @@ int hfa384x_drvr_txframe(hfa384x_t *hw, struct sk_buff *skb, result = 1; ret = submit_tx_urb(hw, &hw->tx_urb, GFP_ATOMIC); if (ret != 0) { - printk(KERN_ERR "submit_tx_urb() failed, error=%d\n", ret); + netdev_err(hw->wlandev->netdev, + "submit_tx_urb() failed, error=%d\n", ret); result = 3; } @@ -2805,11 +2791,13 @@ void hfa384x_tx_timeout(wlandevice_t *wlandev) spin_lock_irqsave(&hw->ctlxq.lock, flags); - if (!hw->wlandev->hwremoved && - /* Note the bitwise OR, not the logical OR. */ - (!test_and_set_bit(WORK_TX_HALT, &hw->usb_flags) | - !test_and_set_bit(WORK_RX_HALT, &hw->usb_flags))) { - schedule_work(&hw->usb_work); + if (!hw->wlandev->hwremoved) { + int sched; + + sched = !test_and_set_bit(WORK_TX_HALT, &hw->usb_flags); + sched |= !test_and_set_bit(WORK_RX_HALT, &hw->usb_flags); + if (sched) + schedule_work(&hw->usb_work); } spin_unlock_irqrestore(&hw->ctlxq.lock, flags); @@ -2830,7 +2818,7 @@ void hfa384x_tx_timeout(wlandevice_t *wlandev) ----------------------------------------------------------------*/ static void hfa384x_usbctlx_reaper_task(unsigned long data) { - hfa384x_t *hw = (hfa384x_t *) data; + hfa384x_t *hw = (hfa384x_t *)data; struct list_head *entry; struct list_head *temp; unsigned long flags; @@ -2849,7 +2837,6 @@ static void hfa384x_usbctlx_reaper_task(unsigned long data) } spin_unlock_irqrestore(&hw->ctlxq.lock, flags); - } /*---------------------------------------------------------------- @@ -2868,7 +2855,7 @@ static void hfa384x_usbctlx_reaper_task(unsigned long data) ----------------------------------------------------------------*/ static void hfa384x_usbctlx_completion_task(unsigned long data) { - hfa384x_t *hw = (hfa384x_t *) data; + hfa384x_t *hw = (hfa384x_t *)data; struct list_head *entry; struct list_head *temp; unsigned long flags; @@ -3013,8 +3000,9 @@ static void unlocked_usbctlx_complete(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx) break; default: - printk(KERN_ERR "CTLX[%d] not in a terminating state(%s)\n", - le16_to_cpu(ctlx->outbuf.type), ctlxstr(ctlx->state)); + netdev_err(hw->wlandev->netdev, "CTLX[%d] not in a terminating state(%s)\n", + le16_to_cpu(ctlx->outbuf.type), + ctlxstr(ctlx->state)); break; } /* switch */ } @@ -3071,9 +3059,9 @@ static void hfa384x_usbctlxq_run(hfa384x_t *hw) hfa384x_ctlxout_callback, hw); hw->ctlx_urb.transfer_flags |= USB_QUEUE_BULK; - /* Now submit the URB and update the CTLX's state - */ - if ((result = SUBMIT_URB(&hw->ctlx_urb, GFP_ATOMIC)) == 0) { + /* Now submit the URB and update the CTLX's state */ + result = SUBMIT_URB(&hw->ctlx_urb, GFP_ATOMIC); + if (result == 0) { /* This CTLX is now running on the active queue */ head->state = CTLX_REQ_SUBMITTED; @@ -3095,9 +3083,9 @@ static void hfa384x_usbctlxq_run(hfa384x_t *hw) * this CTLX back in the "pending" queue * and schedule a reset ... */ - printk(KERN_WARNING - "%s tx pipe stalled: requesting reset\n", - hw->wlandev->netdev->name); + netdev_warn(hw->wlandev->netdev, + "%s tx pipe stalled: requesting reset\n", + hw->wlandev->netdev->name); list_move(&head->list, &hw->ctlxq.pending); set_bit(WORK_TX_HALT, &hw->usb_flags); schedule_work(&hw->usb_work); @@ -3105,13 +3093,13 @@ static void hfa384x_usbctlxq_run(hfa384x_t *hw) } if (result == -ESHUTDOWN) { - printk(KERN_WARNING "%s urb shutdown!\n", - hw->wlandev->netdev->name); + netdev_warn(hw->wlandev->netdev, "%s urb shutdown!\n", + hw->wlandev->netdev->name); break; } - printk(KERN_ERR "Failed to submit CTLX[%d]: error=%d\n", - le16_to_cpu(head->outbuf.type), result); + netdev_err(hw->wlandev->netdev, "Failed to submit CTLX[%d]: error=%d\n", + le16_to_cpu(head->outbuf.type), result); unlocked_usbctlx_complete(hw, head); } /* while */ @@ -3139,7 +3127,7 @@ static void hfa384x_usbin_callback(struct urb *urb) { wlandevice_t *wlandev = urb->context; hfa384x_t *hw; - hfa384x_usbin_t *usbin = (hfa384x_usbin_t *) urb->transfer_buffer; + hfa384x_usbin_t *usbin = (hfa384x_usbin_t *)urb->transfer_buffer; struct sk_buff *skb = NULL; int result; int urb_status; @@ -3177,8 +3165,8 @@ static void hfa384x_usbin_callback(struct urb *urb) break; case -EPIPE: - printk(KERN_WARNING "%s rx pipe stalled: requesting reset\n", - wlandev->netdev->name); + netdev_warn(hw->wlandev->netdev, "%s rx pipe stalled: requesting reset\n", + wlandev->netdev->name); if (!test_and_set_bit(WORK_RX_HALT, &hw->usb_flags)) schedule_work(&hw->usb_work); ++(wlandev->linux_stats.rx_errors); @@ -3228,9 +3216,9 @@ static void hfa384x_usbin_callback(struct urb *urb) result = submit_rx_urb(hw, GFP_ATOMIC); if (result != 0) { - printk(KERN_ERR - "Fatal, failed to resubmit rx_urb. error=%d\n", - result); + netdev_err(hw->wlandev->netdev, + "Fatal, failed to resubmit rx_urb. error=%d\n", + result); } } @@ -3364,10 +3352,10 @@ retry: * Check that our message is what we're expecting ... */ if (ctlx->outbuf.type != intype) { - printk(KERN_WARNING - "Expected IN[%d], received IN[%d] - ignored.\n", - le16_to_cpu(ctlx->outbuf.type), - le16_to_cpu(intype)); + netdev_warn(hw->wlandev->netdev, + "Expected IN[%d], received IN[%d] - ignored.\n", + le16_to_cpu(ctlx->outbuf.type), + le16_to_cpu(intype)); goto unlock; } @@ -3381,8 +3369,7 @@ retry: * our request has been acknowledged. Odd, * but our OUT URB is still alive... */ - pr_debug - ("Causality violation: please reboot Universe, or email linux-wlan-devel@lists.linux-wlan.com\n"); + pr_debug("Causality violation: please reboot Universe\n"); ctlx->state = CTLX_RESP_COMPLETE; break; @@ -3401,11 +3388,10 @@ retry: /* * Throw this CTLX away ... */ - printk(KERN_ERR - "Matched IN URB, CTLX[%d] in invalid state(%s)." - " Discarded.\n", - le16_to_cpu(ctlx->outbuf.type), - ctlxstr(ctlx->state)); + netdev_err(hw->wlandev->netdev, + "Matched IN URB, CTLX[%d] in invalid state(%s). Discarded.\n", + le16_to_cpu(ctlx->outbuf.type), + ctlxstr(ctlx->state)); if (unlocked_usbctlx_cancel_async(hw, ctlx) == 0) run_queue = 1; break; @@ -3441,7 +3427,7 @@ static void hfa384x_usbin_txcompl(wlandevice_t *wlandev, { u16 status; - status = le16_to_cpu(usbin->type); /* yeah I know it says type... */ + status = le16_to_cpu(usbin->type); /* yeah I know it says type... */ /* Was there an error? */ if (HFA384x_TXSTATUS_ISERROR(status)) @@ -3469,10 +3455,10 @@ static void hfa384x_usbin_txcompl(wlandevice_t *wlandev, ----------------------------------------------------------------*/ static void hfa384x_usbin_rx(wlandevice_t *wlandev, struct sk_buff *skb) { - hfa384x_usbin_t *usbin = (hfa384x_usbin_t *) skb->data; + hfa384x_usbin_t *usbin = (hfa384x_usbin_t *)skb->data; hfa384x_t *hw = wlandev->priv; int hdrlen; - p80211_rxmeta_t *rxmeta; + struct p80211_rxmeta *rxmeta; u16 data_len; u16 fc; @@ -3539,8 +3525,9 @@ static void hfa384x_usbin_rx(wlandevice_t *wlandev, struct sk_buff *skb) break; default: - printk(KERN_WARNING "Received frame on unsupported port=%d\n", - HFA384x_RXSTATUS_MACPORT_GET(usbin->rxfrm.desc.status)); + netdev_warn(hw->wlandev->netdev, "Received frame on unsupported port=%d\n", + HFA384x_RXSTATUS_MACPORT_GET( + usbin->rxfrm.desc.status)); goto done; break; } @@ -3582,40 +3569,41 @@ static void hfa384x_int_rxmonitor(wlandevice_t *wlandev, struct sk_buff *skb; hfa384x_t *hw = wlandev->priv; - /* Don't forget the status, time, and data_len fields are in host order */ + /* Remember the status, time, and data_len fields are in host order */ /* Figure out how big the frame is */ fc = le16_to_cpu(rxdesc->frame_control); hdrlen = p80211_headerlen(fc); datalen = le16_to_cpu(rxdesc->data_len); /* Allocate an ind message+framesize skb */ - skblen = sizeof(p80211_caphdr_t) + hdrlen + datalen + WLAN_CRC_LEN; + skblen = sizeof(struct p80211_caphdr) + hdrlen + datalen + WLAN_CRC_LEN; /* sanity check the length */ if (skblen > - (sizeof(p80211_caphdr_t) + + (sizeof(struct p80211_caphdr) + WLAN_HDR_A4_LEN + WLAN_DATA_MAXLEN + WLAN_CRC_LEN)) { pr_debug("overlen frm: len=%zd\n", - skblen - sizeof(p80211_caphdr_t)); + skblen - sizeof(struct p80211_caphdr)); } - if ((skb = dev_alloc_skb(skblen)) == NULL) { - printk(KERN_ERR - "alloc_skb failed trying to allocate %d bytes\n", - skblen); + skb = dev_alloc_skb(skblen); + if (skb == NULL) { + netdev_err(hw->wlandev->netdev, + "alloc_skb failed trying to allocate %d bytes\n", + skblen); return; } /* only prepend the prism header if in the right mode */ if ((wlandev->netdev->type == ARPHRD_IEEE80211_PRISM) && (hw->sniffhdr != 0)) { - p80211_caphdr_t *caphdr; + struct p80211_caphdr *caphdr; /* The NEW header format! */ - datap = skb_put(skb, sizeof(p80211_caphdr_t)); - caphdr = (p80211_caphdr_t *) datap; + datap = skb_put(skb, sizeof(struct p80211_caphdr)); + caphdr = (struct p80211_caphdr *)datap; caphdr->version = htonl(P80211CAPTURE_VERSION); - caphdr->length = htonl(sizeof(p80211_caphdr_t)); + caphdr->length = htonl(sizeof(struct p80211_caphdr)); caphdr->mactime = __cpu_to_be64(rxdesc->time) * 1000; caphdr->hosttime = __cpu_to_be64(jiffies); caphdr->phytype = htonl(4); /* dss_dot11_b */ @@ -3630,7 +3618,8 @@ static void hfa384x_int_rxmonitor(wlandevice_t *wlandev, caphdr->encoding = htonl(1); /* cck */ } - /* Copy the 802.11 header to the skb (ctl frames may be less than a full header) */ + /* Copy the 802.11 header to the skb + (ctl frames may be less than a full header) */ datap = skb_put(skb, hdrlen); memcpy(datap, &(rxdesc->frame_control), hdrlen); @@ -3642,7 +3631,8 @@ static void hfa384x_int_rxmonitor(wlandevice_t *wlandev, /* check for unencrypted stuff if WEP bit set. */ if (*(datap - hdrlen + 1) & 0x40) /* wep set */ if ((*(datap) == 0xaa) && (*(datap + 1) == 0xaa)) - *(datap - hdrlen + 1) &= 0xbf; // clear wep; it's the 802.2 header! + /* clear wep; it's the 802.2 header! */ + *(datap - hdrlen + 1) &= 0xbf; } if (hw->sniff_fcs) { @@ -3707,7 +3697,6 @@ static void hfa384x_usbout_callback(struct urb *urb) #endif if (wlandev && wlandev->netdev) { - switch (urb->status) { case 0: hfa384x_usbout_tx(wlandev, usbout); @@ -3716,9 +3705,9 @@ static void hfa384x_usbout_callback(struct urb *urb) case -EPIPE: { hfa384x_t *hw = wlandev->priv; - printk(KERN_WARNING - "%s tx pipe stalled: requesting reset\n", - wlandev->netdev->name); + netdev_warn(hw->wlandev->netdev, + "%s tx pipe stalled: requesting reset\n", + wlandev->netdev->name); if (!test_and_set_bit (WORK_TX_HALT, &hw->usb_flags)) schedule_work(&hw->usb_work); @@ -3733,8 +3722,8 @@ static void hfa384x_usbout_callback(struct urb *urb) hfa384x_t *hw = wlandev->priv; if (!test_and_set_bit - (THROTTLE_TX, &hw->usb_flags) - && !timer_pending(&hw->throttle)) { + (THROTTLE_TX, &hw->usb_flags) && + !timer_pending(&hw->throttle)) { mod_timer(&hw->throttle, jiffies + THROTTLE_JIFFIES); } @@ -3749,8 +3738,8 @@ static void hfa384x_usbout_callback(struct urb *urb) break; default: - printk(KERN_INFO "unknown urb->status=%d\n", - urb->status); + netdev_info(wlandev->netdev, "unknown urb->status=%d\n", + urb->status); ++(wlandev->linux_stats.tx_errors); break; } /* switch */ @@ -3788,7 +3777,7 @@ static void hfa384x_ctlxout_callback(struct urb *urb) #endif if ((urb->status == -ESHUTDOWN) || (urb->status == -ENODEV) || (hw == NULL)) - goto done; + return; retry: spin_lock_irqsave(&hw->ctlxq.lock, flags); @@ -3801,7 +3790,7 @@ retry: */ if (list_empty(&hw->ctlxq.active)) { spin_unlock_irqrestore(&hw->ctlxq.lock, flags); - goto done; + return; } /* @@ -3843,19 +3832,19 @@ retry: default: /* This is NOT a valid CTLX "success" state! */ - printk(KERN_ERR - "Illegal CTLX[%d] success state(%s, %d) in OUT URB\n", - le16_to_cpu(ctlx->outbuf.type), - ctlxstr(ctlx->state), urb->status); + netdev_err(hw->wlandev->netdev, + "Illegal CTLX[%d] success state(%s, %d) in OUT URB\n", + le16_to_cpu(ctlx->outbuf.type), + ctlxstr(ctlx->state), urb->status); break; } /* switch */ } else { /* If the pipe has stalled then we need to reset it */ if ((urb->status == -EPIPE) && !test_and_set_bit(WORK_TX_HALT, &hw->usb_flags)) { - printk(KERN_WARNING - "%s tx pipe stalled: requesting reset\n", - hw->wlandev->netdev->name); + netdev_warn(hw->wlandev->netdev, + "%s tx pipe stalled: requesting reset\n", + hw->wlandev->netdev->name); schedule_work(&hw->usb_work); } @@ -3870,9 +3859,9 @@ retry: delresp: if (delete_resptimer) { - if ((timer_ok = del_timer(&hw->resptimer)) != 0) { + timer_ok = del_timer(&hw->resptimer); + if (timer_ok != 0) hw->resp_timer_done = 1; - } } spin_unlock_irqrestore(&hw->ctlxq.lock, flags); @@ -3884,9 +3873,6 @@ delresp: if (run_queue) hfa384x_usbctlxq_run(hw); - -done: - ; } /*---------------------------------------------------------------- @@ -3909,7 +3895,7 @@ done: ----------------------------------------------------------------*/ static void hfa384x_usbctlx_reqtimerfn(unsigned long data) { - hfa384x_t *hw = (hfa384x_t *) data; + hfa384x_t *hw = (hfa384x_t *)data; unsigned long flags; spin_lock_irqsave(&hw->ctlxq.lock, flags); @@ -3967,7 +3953,7 @@ static void hfa384x_usbctlx_reqtimerfn(unsigned long data) ----------------------------------------------------------------*/ static void hfa384x_usbctlx_resptimerfn(unsigned long data) { - hfa384x_t *hw = (hfa384x_t *) data; + hfa384x_t *hw = (hfa384x_t *)data; unsigned long flags; spin_lock_irqsave(&hw->ctlxq.lock, flags); @@ -3983,15 +3969,10 @@ static void hfa384x_usbctlx_resptimerfn(unsigned long data) if (unlocked_usbctlx_cancel_async(hw, ctlx) == 0) { spin_unlock_irqrestore(&hw->ctlxq.lock, flags); hfa384x_usbctlxq_run(hw); - goto done; + return; } } - spin_unlock_irqrestore(&hw->ctlxq.lock, flags); - -done: - ; - } /*---------------------------------------------------------------- @@ -4011,7 +3992,7 @@ done: ----------------------------------------------------------------*/ static void hfa384x_usb_throttlefn(unsigned long data) { - hfa384x_t *hw = (hfa384x_t *) data; + hfa384x_t *hw = (hfa384x_t *)data; unsigned long flags; spin_lock_irqsave(&hw->ctlxq.lock, flags); @@ -4055,23 +4036,20 @@ static void hfa384x_usb_throttlefn(unsigned long data) static int hfa384x_usbctlx_submit(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx) { unsigned long flags; - int ret; spin_lock_irqsave(&hw->ctlxq.lock, flags); if (hw->wlandev->hwremoved) { spin_unlock_irqrestore(&hw->ctlxq.lock, flags); - ret = -ENODEV; - } else { - ctlx->state = CTLX_PENDING; - list_add_tail(&ctlx->list, &hw->ctlxq.pending); - - spin_unlock_irqrestore(&hw->ctlxq.lock, flags); - hfa384x_usbctlxq_run(hw); - ret = 0; + return -ENODEV; } - return ret; + ctlx->state = CTLX_PENDING; + list_add_tail(&ctlx->list, &hw->ctlxq.pending); + spin_unlock_irqrestore(&hw->ctlxq.lock, flags); + hfa384x_usbctlxq_run(hw); + + return 0; } /*---------------------------------------------------------------- @@ -4152,13 +4130,13 @@ static int hfa384x_isgood_pdrcode(u16 pdrcode) default: if (pdrcode < 0x1000) { /* code is OK, but we don't know exactly what it is */ - pr_debug("Encountered unknown PDR#=0x%04x, " - "assuming it's ok.\n", pdrcode); + pr_debug("Encountered unknown PDR#=0x%04x, assuming it's ok.\n", + pdrcode); return 1; } else { /* bad code */ - pr_debug("Encountered unknown PDR#=0x%04x, " - "(>=0x1000), assuming it's bad.\n", pdrcode); + pr_debug("Encountered unknown PDR#=0x%04x, (>=0x1000), assuming it's bad.\n", + pdrcode); return 0; } break; diff --git a/drivers/staging/wlan-ng/p80211conv.c b/drivers/staging/wlan-ng/p80211conv.c index 5952c671073..913676e1797 100644 --- a/drivers/staging/wlan-ng/p80211conv.c +++ b/drivers/staging/wlan-ng/p80211conv.c @@ -103,15 +103,15 @@ static u8 oui_8021h[] = { 0x00, 0x00, 0xf8 }; * May be called in interrupt or non-interrupt context ----------------------------------------------------------------*/ int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv, - struct sk_buff *skb, p80211_hdr_t *p80211_hdr, - p80211_metawep_t *p80211_wep) + struct sk_buff *skb, union p80211_hdr *p80211_hdr, + struct p80211_metawep *p80211_wep) { u16 fc; u16 proto; - wlan_ethhdr_t e_hdr; - wlan_llc_t *e_llc; - wlan_snap_t *e_snap; + struct wlan_ethhdr e_hdr; + struct wlan_llc *e_llc; + struct wlan_snap *e_snap; int foo; memcpy(&e_hdr, skb->data, sizeof(e_hdr)); @@ -148,7 +148,8 @@ int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv, /* tack on SNAP */ e_snap = - (wlan_snap_t *) skb_push(skb, sizeof(wlan_snap_t)); + (struct wlan_snap *) skb_push(skb, + sizeof(struct wlan_snap)); e_snap->type = htons(proto); if (ethconv == WLAN_ETHCONV_8021h && p80211_stt_findproto(proto)) { @@ -161,7 +162,8 @@ int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv, /* tack on llc */ e_llc = - (wlan_llc_t *) skb_push(skb, sizeof(wlan_llc_t)); + (struct wlan_llc *) skb_push(skb, + sizeof(struct wlan_llc)); e_llc->dsap = 0xAA; /* SNAP, see IEEE 802 */ e_llc->ssap = 0xAA; e_llc->ctl = 0x03; @@ -193,8 +195,8 @@ int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv, memcpy(p80211_hdr->a3.a3, &e_hdr.saddr, ETH_ALEN); break; default: - printk(KERN_ERR - "Error: Converting eth to wlan in unknown mode.\n"); + netdev_err(wlandev->netdev, + "Error: Converting eth to wlan in unknown mode.\n"); return 1; break; } @@ -206,13 +208,12 @@ int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv, /* XXXX need to pick keynum other than default? */ p80211_wep->data = kmalloc(skb->len, GFP_ATOMIC); - - if ((foo = wep_encrypt(wlandev, skb->data, p80211_wep->data, - skb->len, - (wlandev->hostwep & - HOSTWEP_DEFAULTKEY_MASK), - p80211_wep->iv, p80211_wep->icv))) { - printk(KERN_WARNING + foo = wep_encrypt(wlandev, skb->data, p80211_wep->data, + skb->len, + (wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK), + p80211_wep->iv, p80211_wep->icv); + if (foo) { + netdev_warn(wlandev->netdev, "Host en-WEP failed, dropping frame (%d).\n", foo); return 2; @@ -231,7 +232,7 @@ int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv, /* jkriegl: from orinoco, modified */ static void orinoco_spy_gather(wlandevice_t *wlandev, char *mac, - p80211_rxmeta_t *rxmeta) + struct p80211_rxmeta *rxmeta) { int i; @@ -281,33 +282,35 @@ int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv, unsigned int payload_offset; u8 daddr[WLAN_ETHADDR_LEN]; u8 saddr[WLAN_ETHADDR_LEN]; - p80211_hdr_t *w_hdr; - wlan_ethhdr_t *e_hdr; - wlan_llc_t *e_llc; - wlan_snap_t *e_snap; + union p80211_hdr *w_hdr; + struct wlan_ethhdr *e_hdr; + struct wlan_llc *e_llc; + struct wlan_snap *e_snap; int foo; payload_length = skb->len - WLAN_HDR_A3_LEN - WLAN_CRC_LEN; payload_offset = WLAN_HDR_A3_LEN; - w_hdr = (p80211_hdr_t *) skb->data; + w_hdr = (union p80211_hdr *) skb->data; /* setup some vars for convenience */ fc = le16_to_cpu(w_hdr->a3.fc); if ((WLAN_GET_FC_TODS(fc) == 0) && (WLAN_GET_FC_FROMDS(fc) == 0)) { memcpy(daddr, w_hdr->a3.a1, WLAN_ETHADDR_LEN); memcpy(saddr, w_hdr->a3.a2, WLAN_ETHADDR_LEN); - } else if ((WLAN_GET_FC_TODS(fc) == 0) && (WLAN_GET_FC_FROMDS(fc) == 1)) { + } else if ((WLAN_GET_FC_TODS(fc) == 0) + && (WLAN_GET_FC_FROMDS(fc) == 1)) { memcpy(daddr, w_hdr->a3.a1, WLAN_ETHADDR_LEN); memcpy(saddr, w_hdr->a3.a3, WLAN_ETHADDR_LEN); - } else if ((WLAN_GET_FC_TODS(fc) == 1) && (WLAN_GET_FC_FROMDS(fc) == 0)) { + } else if ((WLAN_GET_FC_TODS(fc) == 1) + && (WLAN_GET_FC_FROMDS(fc) == 0)) { memcpy(daddr, w_hdr->a3.a3, WLAN_ETHADDR_LEN); memcpy(saddr, w_hdr->a3.a2, WLAN_ETHADDR_LEN); } else { payload_offset = WLAN_HDR_A4_LEN; if (payload_length < WLAN_HDR_A4_LEN - WLAN_HDR_A3_LEN) { - printk(KERN_ERR "A4 frame too short!\n"); + netdev_err(netdev, "A4 frame too short!\n"); return 1; } payload_length -= (WLAN_HDR_A4_LEN - WLAN_HDR_A3_LEN); @@ -319,15 +322,16 @@ int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv, if ((wlandev->hostwep & HOSTWEP_PRIVACYINVOKED) && WLAN_GET_FC_ISWEP(fc) && (wlandev->hostwep & HOSTWEP_DECRYPT)) { if (payload_length <= 8) { - printk(KERN_ERR "WEP frame too short (%u).\n", - skb->len); + netdev_err(netdev, + "WEP frame too short (%u).\n", skb->len); return 1; } - if ((foo = wep_decrypt(wlandev, skb->data + payload_offset + 4, + foo = wep_decrypt(wlandev, skb->data + payload_offset + 4, payload_length - 8, -1, skb->data + payload_offset, skb->data + payload_offset + - payload_length - 4))) { + payload_length - 4); + if (foo) { /* de-wep failed, drop skb. */ pr_debug("Host de-WEP failed, dropping frame (%d).\n", foo); @@ -345,14 +349,15 @@ int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv, wlandev->rx.decrypt++; } - e_hdr = (wlan_ethhdr_t *) (skb->data + payload_offset); + e_hdr = (struct wlan_ethhdr *) (skb->data + payload_offset); - e_llc = (wlan_llc_t *) (skb->data + payload_offset); + e_llc = (struct wlan_llc *) (skb->data + payload_offset); e_snap = - (wlan_snap_t *) (skb->data + payload_offset + sizeof(wlan_llc_t)); + (struct wlan_snap *) (skb->data + payload_offset + + sizeof(struct wlan_llc)); /* Test for the various encodings */ - if ((payload_length >= sizeof(wlan_ethhdr_t)) && + if ((payload_length >= sizeof(struct wlan_ethhdr)) && (e_llc->dsap != 0xaa || e_llc->ssap != 0xaa) && ((memcmp(daddr, e_hdr->daddr, WLAN_ETHADDR_LEN) == 0) || (memcmp(saddr, e_hdr->saddr, WLAN_ETHADDR_LEN) == 0))) { @@ -362,7 +367,7 @@ int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv, if (payload_length > (netdev->mtu + WLAN_ETHHDR_LEN)) { /* A bogus length ethfrm has been encap'd. */ /* Is someone trying an oflow attack? */ - printk(KERN_ERR "ENCAP frame too large (%d > %d)\n", + netdev_err(netdev, "ENCAP frame too large (%d > %d)\n", payload_length, netdev->mtu + WLAN_ETHHDR_LEN); return 1; } @@ -372,9 +377,11 @@ int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv, /* chop off the 802.11 CRC */ skb_trim(skb, skb->len - WLAN_CRC_LEN); - } else if ((payload_length >= sizeof(wlan_llc_t) + sizeof(wlan_snap_t)) - && (e_llc->dsap == 0xaa) && (e_llc->ssap == 0xaa) - && (e_llc->ctl == 0x03) + } else if ((payload_length >= sizeof(struct wlan_llc) + + sizeof(struct wlan_snap)) + && (e_llc->dsap == 0xaa) + && (e_llc->ssap == 0xaa) + && (e_llc->ctl == 0x03) && (((memcmp(e_snap->oui, oui_rfc1042, WLAN_IEEE_OUI_LEN) == 0) && (ethconv == WLAN_ETHCONV_8021h) @@ -389,7 +396,7 @@ int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv, if (payload_length > netdev->mtu) { /* A bogus length ethfrm has been sent. */ /* Is someone trying an oflow attack? */ - printk(KERN_ERR "SNAP frame too large (%d > %d)\n", + netdev_err(netdev, "SNAP frame too large (%d > %d)\n", payload_length, netdev->mtu); return 1; } @@ -398,7 +405,7 @@ int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv, skb_pull(skb, payload_offset); /* create 802.3 header at beginning of skb. */ - e_hdr = (wlan_ethhdr_t *) skb_push(skb, WLAN_ETHHDR_LEN); + e_hdr = (struct wlan_ethhdr *) skb_push(skb, WLAN_ETHHDR_LEN); memcpy(e_hdr->daddr, daddr, WLAN_ETHADDR_LEN); memcpy(e_hdr->saddr, saddr, WLAN_ETHADDR_LEN); e_hdr->type = htons(payload_length); @@ -406,21 +413,25 @@ int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv, /* chop off the 802.11 CRC */ skb_trim(skb, skb->len - WLAN_CRC_LEN); - } else if ((payload_length >= sizeof(wlan_llc_t) + sizeof(wlan_snap_t)) - && (e_llc->dsap == 0xaa) && (e_llc->ssap == 0xaa) - && (e_llc->ctl == 0x03)) { + } else if ((payload_length >= sizeof(struct wlan_llc) + + sizeof(struct wlan_snap)) + && (e_llc->dsap == 0xaa) + && (e_llc->ssap == 0xaa) + && (e_llc->ctl == 0x03)) { pr_debug("802.1h/RFC1042 len: %d\n", payload_length); - /* it's an 802.1h frame || (an RFC1042 && protocol is not in STT) */ - /* build a DIXII + RFC894 */ + /* it's an 802.1h frame || (an RFC1042 && protocol not in STT) + build a DIXII + RFC894 */ /* Test for an overlength frame */ - if ((payload_length - sizeof(wlan_llc_t) - sizeof(wlan_snap_t)) - > netdev->mtu) { + if ((payload_length - sizeof(struct wlan_llc) - + sizeof(struct wlan_snap)) + > netdev->mtu) { /* A bogus length ethfrm has been sent. */ /* Is someone trying an oflow attack? */ - printk(KERN_ERR "DIXII frame too large (%ld > %d)\n", - (long int)(payload_length - sizeof(wlan_llc_t) - - sizeof(wlan_snap_t)), netdev->mtu); + netdev_err(netdev, "DIXII frame too large (%ld > %d)\n", + (long int)(payload_length - + sizeof(struct wlan_llc) - + sizeof(struct wlan_snap)), netdev->mtu); return 1; } @@ -428,13 +439,13 @@ int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv, skb_pull(skb, payload_offset); /* chop llc header from skb. */ - skb_pull(skb, sizeof(wlan_llc_t)); + skb_pull(skb, sizeof(struct wlan_llc)); /* chop snap header from skb. */ - skb_pull(skb, sizeof(wlan_snap_t)); + skb_pull(skb, sizeof(struct wlan_snap)); /* create 802.3 header at beginning of skb. */ - e_hdr = (wlan_ethhdr_t *) skb_push(skb, WLAN_ETHHDR_LEN); + e_hdr = (struct wlan_ethhdr *) skb_push(skb, WLAN_ETHHDR_LEN); e_hdr->type = e_snap->type; memcpy(e_hdr->daddr, daddr, WLAN_ETHADDR_LEN); memcpy(e_hdr->saddr, saddr, WLAN_ETHADDR_LEN); @@ -452,7 +463,7 @@ int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv, if (payload_length > netdev->mtu) { /* A bogus length ethfrm has been sent. */ /* Is someone trying an oflow attack? */ - printk(KERN_ERR "OTHER frame too large (%d > %d)\n", + netdev_err(netdev, "OTHER frame too large (%d > %d)\n", payload_length, netdev->mtu); return 1; } @@ -461,7 +472,7 @@ int skb_p80211_to_ether(wlandevice_t *wlandev, u32 ethconv, skb_pull(skb, payload_offset); /* create 802.3 header at beginning of skb. */ - e_hdr = (wlan_ethhdr_t *) skb_push(skb, WLAN_ETHHDR_LEN); + e_hdr = (struct wlan_ethhdr *) skb_push(skb, WLAN_ETHHDR_LEN); memcpy(e_hdr->daddr, daddr, WLAN_ETHADDR_LEN); memcpy(e_hdr->saddr, saddr, WLAN_ETHADDR_LEN); e_hdr->type = htons(payload_length); @@ -542,23 +553,23 @@ int p80211_stt_findproto(u16 proto) ----------------------------------------------------------------*/ void p80211skb_rxmeta_detach(struct sk_buff *skb) { - p80211_rxmeta_t *rxmeta; - p80211_frmmeta_t *frmmeta; + struct p80211_rxmeta *rxmeta; + struct p80211_frmmeta *frmmeta; /* Sanity checks */ if (skb == NULL) { /* bad skb */ pr_debug("Called w/ null skb.\n"); - goto exit; + return; } frmmeta = P80211SKB_FRMMETA(skb); if (frmmeta == NULL) { /* no magic */ pr_debug("Called w/ bad frmmeta magic.\n"); - goto exit; + return; } rxmeta = frmmeta->rx; if (rxmeta == NULL) { /* bad meta ptr */ pr_debug("Called w/ bad rxmeta ptr.\n"); - goto exit; + return; } /* Free rxmeta */ @@ -566,8 +577,6 @@ void p80211skb_rxmeta_detach(struct sk_buff *skb) /* Clear skb->cb */ memset(skb->cb, 0, sizeof(skb->cb)); -exit: - return; } /*---------------------------------------------------------------- @@ -589,35 +598,34 @@ exit: int p80211skb_rxmeta_attach(struct wlandevice *wlandev, struct sk_buff *skb) { int result = 0; - p80211_rxmeta_t *rxmeta; - p80211_frmmeta_t *frmmeta; + struct p80211_rxmeta *rxmeta; + struct p80211_frmmeta *frmmeta; /* If these already have metadata, we error out! */ if (P80211SKB_RXMETA(skb) != NULL) { - printk(KERN_ERR "%s: RXmeta already attached!\n", - wlandev->name); + netdev_err(wlandev->netdev, + "%s: RXmeta already attached!\n", wlandev->name); result = 0; goto exit; } /* Allocate the rxmeta */ - rxmeta = kmalloc(sizeof(p80211_rxmeta_t), GFP_ATOMIC); + rxmeta = kzalloc(sizeof(struct p80211_rxmeta), GFP_ATOMIC); if (rxmeta == NULL) { - printk(KERN_ERR "%s: Failed to allocate rxmeta.\n", - wlandev->name); + netdev_err(wlandev->netdev, + "%s: Failed to allocate rxmeta.\n", wlandev->name); result = 1; goto exit; } /* Initialize the rxmeta */ - memset(rxmeta, 0, sizeof(p80211_rxmeta_t)); rxmeta->wlandev = wlandev; rxmeta->hosttime = jiffies; /* Overlay a frmmeta_t onto skb->cb */ - memset(skb->cb, 0, sizeof(p80211_frmmeta_t)); - frmmeta = (p80211_frmmeta_t *) (skb->cb); + memset(skb->cb, 0, sizeof(struct p80211_frmmeta)); + frmmeta = (struct p80211_frmmeta *) (skb->cb); frmmeta->magic = P80211_FRMMETA_MAGIC; frmmeta->rx = rxmeta; exit: @@ -642,13 +650,13 @@ exit: ----------------------------------------------------------------*/ void p80211skb_free(struct wlandevice *wlandev, struct sk_buff *skb) { - p80211_frmmeta_t *meta; + struct p80211_frmmeta *meta; meta = P80211SKB_FRMMETA(skb); if (meta && meta->rx) p80211skb_rxmeta_detach(skb); else - printk(KERN_ERR "Freeing an skb (%p) w/ no frmmeta.\n", skb); + netdev_err(wlandev->netdev, + "Freeing an skb (%p) w/ no frmmeta.\n", skb); dev_kfree_skb(skb); - return; } diff --git a/drivers/staging/wlan-ng/p80211conv.h b/drivers/staging/wlan-ng/p80211conv.h index 0c62df19fa7..e031a74d2ad 100644 --- a/drivers/staging/wlan-ng/p80211conv.h +++ b/drivers/staging/wlan-ng/p80211conv.h @@ -63,17 +63,19 @@ #define P80211CAPTURE_VERSION 0x80211001 -#define P80211_FRMMETA_MAGIC 0x802110 +#define P80211_FRMMETA_MAGIC 0x802110 #define P80211SKB_FRMMETA(s) \ - (((((p80211_frmmeta_t *)((s)->cb))->magic) == P80211_FRMMETA_MAGIC) ? \ - ((p80211_frmmeta_t *)((s)->cb)) : \ + (((((struct p80211_frmmeta *)((s)->cb))->magic) == \ + P80211_FRMMETA_MAGIC) ? \ + ((struct p80211_frmmeta *)((s)->cb)) : \ (NULL)) #define P80211SKB_RXMETA(s) \ - (P80211SKB_FRMMETA((s)) ? P80211SKB_FRMMETA((s))->rx : ((p80211_rxmeta_t *)(NULL))) + (P80211SKB_FRMMETA((s)) ? P80211SKB_FRMMETA((s))->rx : \ + ((struct p80211_rxmeta *)(NULL))) -typedef struct p80211_rxmeta { +struct p80211_rxmeta { struct wlandevice *wlandev; u64 mactime; /* Hi-rez MAC-supplied time value */ @@ -87,12 +89,12 @@ typedef struct p80211_rxmeta { unsigned int preamble; /* P80211ENUM_preambletype_* */ unsigned int encoding; /* P80211ENUM_encoding_* */ -} p80211_rxmeta_t; +}; -typedef struct p80211_frmmeta { +struct p80211_frmmeta { unsigned int magic; - p80211_rxmeta_t *rx; -} p80211_frmmeta_t; + struct p80211_rxmeta *rx; +}; void p80211skb_free(struct wlandevice *wlandev, struct sk_buff *skb); int p80211skb_rxmeta_attach(struct wlandevice *wlandev, struct sk_buff *skb); @@ -101,7 +103,7 @@ void p80211skb_rxmeta_detach(struct sk_buff *skb); /* * Frame capture header. (See doc/capturefrm.txt) */ -typedef struct p80211_caphdr { +struct p80211_caphdr { u32 version; u32 length; u64 mactime; @@ -116,36 +118,36 @@ typedef struct p80211_caphdr { s32 ssi_noise; u32 preamble; u32 encoding; -} p80211_caphdr_t; +}; /* buffer free method pointer type */ typedef void (*freebuf_method_t) (void *buf, int size); -typedef struct p80211_metawep { +struct p80211_metawep { void *data; u8 iv[4]; u8 icv[4]; -} p80211_metawep_t; +}; /* local ether header type */ -typedef struct wlan_ethhdr { +struct wlan_ethhdr { u8 daddr[WLAN_ETHADDR_LEN]; u8 saddr[WLAN_ETHADDR_LEN]; u16 type; -} __attribute__ ((packed)) wlan_ethhdr_t; +} __packed; /* local llc header type */ -typedef struct wlan_llc { +struct wlan_llc { u8 dsap; u8 ssap; u8 ctl; -} __attribute__ ((packed)) wlan_llc_t; +} __packed; /* local snap header type */ -typedef struct wlan_snap { +struct wlan_snap { u8 oui[WLAN_IEEE_OUI_LEN]; u16 type; -} __attribute__ ((packed)) wlan_snap_t; +} __packed; /* Circular include trick */ struct wlandevice; @@ -153,8 +155,8 @@ struct wlandevice; int skb_p80211_to_ether(struct wlandevice *wlandev, u32 ethconv, struct sk_buff *skb); int skb_ether_to_p80211(struct wlandevice *wlandev, u32 ethconv, - struct sk_buff *skb, p80211_hdr_t * p80211_hdr, - p80211_metawep_t * p80211_wep); + struct sk_buff *skb, union p80211_hdr *p80211_hdr, + struct p80211_metawep *p80211_wep); int p80211_stt_findproto(u16 proto); diff --git a/drivers/staging/wlan-ng/p80211hdr.h b/drivers/staging/wlan-ng/p80211hdr.h index 419de4dee56..66b5e201d41 100644 --- a/drivers/staging/wlan-ng/p80211hdr.h +++ b/drivers/staging/wlan-ng/p80211hdr.h @@ -94,7 +94,7 @@ /* Control */ #define WLAN_FSTYPE_BLOCKACKREQ 0x8 -#define WLAN_FSTYPE_BLOCKACK 0x9 +#define WLAN_FSTYPE_BLOCKACK 0x9 #define WLAN_FSTYPE_PSPOLL 0x0a #define WLAN_FSTYPE_RTS 0x0b #define WLAN_FSTYPE_CTS 0x0c @@ -133,13 +133,13 @@ #define WLAN_GET_FC_FTYPE(n) ((((u16)(n)) & (BIT(2) | BIT(3))) >> 2) #define WLAN_GET_FC_FSTYPE(n) ((((u16)(n)) & (BIT(4)|BIT(5)|BIT(6)|BIT(7))) >> 4) -#define WLAN_GET_FC_TODS(n) ((((u16)(n)) & (BIT(8))) >> 8) +#define WLAN_GET_FC_TODS(n) ((((u16)(n)) & (BIT(8))) >> 8) #define WLAN_GET_FC_FROMDS(n) ((((u16)(n)) & (BIT(9))) >> 9) #define WLAN_GET_FC_ISWEP(n) ((((u16)(n)) & (BIT(14))) >> 14) #define WLAN_SET_FC_FTYPE(n) (((u16)(n)) << 2) #define WLAN_SET_FC_FSTYPE(n) (((u16)(n)) << 4) -#define WLAN_SET_FC_TODS(n) (((u16)(n)) << 8) +#define WLAN_SET_FC_TODS(n) (((u16)(n)) << 8) #define WLAN_SET_FC_FROMDS(n) (((u16)(n)) << 9) #define WLAN_SET_FC_ISWEP(n) (((u16)(n)) << 14) @@ -147,16 +147,16 @@ /* Generic 802.11 Header types */ -typedef struct p80211_hdr_a3 { +struct p80211_hdr_a3 { u16 fc; u16 dur; u8 a1[ETH_ALEN]; u8 a2[ETH_ALEN]; u8 a3[ETH_ALEN]; u16 seq; -} __attribute__ ((packed)) p80211_hdr_a3_t; +} __packed; -typedef struct p80211_hdr_a4 { +struct p80211_hdr_a4 { u16 fc; u16 dur; u8 a1[ETH_ALEN]; @@ -164,18 +164,18 @@ typedef struct p80211_hdr_a4 { u8 a3[ETH_ALEN]; u16 seq; u8 a4[ETH_ALEN]; -} __attribute__ ((packed)) p80211_hdr_a4_t; +} __packed; -typedef union p80211_hdr { - p80211_hdr_a3_t a3; - p80211_hdr_a4_t a4; -} __attribute__ ((packed)) p80211_hdr_t; +union p80211_hdr { + struct p80211_hdr_a3 a3; + struct p80211_hdr_a4 a4; +} __packed; /* Frame and header length macros */ #define WLAN_CTL_FRAMELEN(fstype) (\ (fstype) == WLAN_FSTYPE_BLOCKACKREQ ? 24 : \ - (fstype) == WLAN_FSTYPE_BLOCKACK ? 152 : \ + (fstype) == WLAN_FSTYPE_BLOCKACK ? 152 : \ (fstype) == WLAN_FSTYPE_PSPOLL ? 20 : \ (fstype) == WLAN_FSTYPE_RTS ? 20 : \ (fstype) == WLAN_FSTYPE_CTS ? 14 : \ diff --git a/drivers/staging/wlan-ng/p80211ioctl.h b/drivers/staging/wlan-ng/p80211ioctl.h index 64ca7f95262..06c5e36649a 100644 --- a/drivers/staging/wlan-ng/p80211ioctl.h +++ b/drivers/staging/wlan-ng/p80211ioctl.h @@ -78,12 +78,12 @@ /* argument to the ioctl system call when issuing a request to */ /* the p80211 module. */ -typedef struct p80211ioctl_req { +struct p80211ioctl_req { char name[WLAN_DEVNAMELEN_MAX]; caddr_t data; u32 magic; u16 len; u32 result; -} __attribute__ ((packed)) p80211ioctl_req_t; +} __packed; #endif /* _P80211IOCTL_H */ diff --git a/drivers/staging/wlan-ng/p80211meta.h b/drivers/staging/wlan-ng/p80211meta.h index b9badcff681..c5f1a63add9 100644 --- a/drivers/staging/wlan-ng/p80211meta.h +++ b/drivers/staging/wlan-ng/p80211meta.h @@ -62,7 +62,7 @@ /* representation of category list metadata, group list metadata, */ /* and data item metadata for both Mib and Messages. */ -typedef struct p80211meta { +struct p80211meta { char *name; /* data item name */ u32 did; /* partial did */ u32 flags; /* set of various flag bits */ @@ -75,16 +75,16 @@ typedef struct p80211meta { p80211_totext_t totextptr; /* ptr to totext conversion function */ p80211_fromtext_t fromtextptr; /* ptr to totext conversion function */ p80211_valid_t validfunptr; /* ptr to totext conversion function */ -} p80211meta_t; +}; -typedef struct grplistitem { +struct grplistitem { char *name; - p80211meta_t *itemlist; -} grplistitem_t; + struct p80211meta *itemlist; +}; -typedef struct catlistitem { +struct catlistitem { char *name; - grplistitem_t *grplist; -} catlistitem_t; + struct grplistitem *grplist; +}; #endif /* _P80211META_H */ diff --git a/drivers/staging/wlan-ng/p80211metadef.h b/drivers/staging/wlan-ng/p80211metadef.h index da8b6f53c74..0ccfba1294d 100644 --- a/drivers/staging/wlan-ng/p80211metadef.h +++ b/drivers/staging/wlan-ng/p80211metadef.h @@ -190,9 +190,9 @@ (P80211DID_MKSECTION(2) | \ P80211DID_MKGROUP(1)) #define DIDmib_dot11mac_dot11OperationTable_dot11MACAddress \ - (P80211DID_MKSECTION(2) | \ - P80211DID_MKGROUP(1) | \ - P80211DID_MKITEM(1) | 0x18000000) + (P80211DID_MKSECTION(2) | \ + P80211DID_MKGROUP(1) | \ + P80211DID_MKITEM(1) | 0x18000000) #define DIDmib_dot11mac_dot11OperationTable_dot11RTSThreshold \ (P80211DID_MKSECTION(2) | \ P80211DID_MKGROUP(1) | \ @@ -210,18 +210,18 @@ P80211DID_MKGROUP(1) | \ P80211DID_MKITEM(5) | 0x18000000) #define DIDmib_dot11mac_dot11OperationTable_dot11MaxTransmitMSDULifetime \ - (P80211DID_MKSECTION(2) | \ - P80211DID_MKGROUP(1) | \ - P80211DID_MKITEM(6) | 0x10000000) + (P80211DID_MKSECTION(2) | \ + P80211DID_MKGROUP(1) | \ + P80211DID_MKITEM(6) | 0x10000000) #define DIDmib_cat_dot11phy \ P80211DID_MKSECTION(3) #define DIDmib_dot11phy_dot11PhyOperationTable \ (P80211DID_MKSECTION(3) | \ P80211DID_MKGROUP(1)) #define DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel \ - (P80211DID_MKSECTION(3) | \ - P80211DID_MKGROUP(3) | \ - P80211DID_MKITEM(10) | 0x18000000) + (P80211DID_MKSECTION(3) | \ + P80211DID_MKGROUP(3) | \ + P80211DID_MKITEM(10) | 0x18000000) #define DIDmib_dot11phy_dot11PhyDSSSTable \ (P80211DID_MKSECTION(3) | \ P80211DID_MKGROUP(5)) diff --git a/drivers/staging/wlan-ng/p80211metastruct.h b/drivers/staging/wlan-ng/p80211metastruct.h index db12713eeaa..c501162c302 100644 --- a/drivers/staging/wlan-ng/p80211metastruct.h +++ b/drivers/staging/wlan-ng/p80211metastruct.h @@ -47,23 +47,23 @@ #ifndef _P80211MKMETASTRUCT_H #define _P80211MKMETASTRUCT_H -typedef struct p80211msg_dot11req_mibget { +struct p80211msg_dot11req_mibget { u32 msgcode; u32 msglen; u8 devname[WLAN_DEVNAMELEN_MAX]; p80211item_unk392_t mibattribute; p80211item_uint32_t resultcode; -} __attribute__ ((packed)) p80211msg_dot11req_mibget_t; +} __packed; -typedef struct p80211msg_dot11req_mibset { +struct p80211msg_dot11req_mibset { u32 msgcode; u32 msglen; u8 devname[WLAN_DEVNAMELEN_MAX]; p80211item_unk392_t mibattribute; p80211item_uint32_t resultcode; -} __attribute__ ((packed)) p80211msg_dot11req_mibset_t; +} __packed; -typedef struct p80211msg_dot11req_scan { +struct p80211msg_dot11req_scan { u32 msgcode; u32 msglen; u8 devname[WLAN_DEVNAMELEN_MAX]; @@ -81,9 +81,9 @@ typedef struct p80211msg_dot11req_scan { p80211item_uint32_t resultcode; p80211item_uint32_t numbss; p80211item_uint32_t append; -} __attribute__ ((packed)) p80211msg_dot11req_scan_t; +} __packed; -typedef struct p80211msg_dot11req_scan_results { +struct p80211msg_dot11req_scan_results { u32 msgcode; u32 msglen; u8 devname[WLAN_DEVNAMELEN_MAX]; @@ -113,6 +113,7 @@ typedef struct p80211msg_dot11req_scan_results { p80211item_uint32_t cfpollable; p80211item_uint32_t cfpollreq; p80211item_uint32_t privacy; + p80211item_uint32_t capinfo; p80211item_uint32_t basicrate1; p80211item_uint32_t basicrate2; p80211item_uint32_t basicrate3; @@ -129,9 +130,9 @@ typedef struct p80211msg_dot11req_scan_results { p80211item_uint32_t supprate6; p80211item_uint32_t supprate7; p80211item_uint32_t supprate8; -} __attribute__ ((packed)) p80211msg_dot11req_scan_results_t; +} __packed; -typedef struct p80211msg_dot11req_start { +struct p80211msg_dot11req_start { u32 msgcode; u32 msglen; u8 devname[WLAN_DEVNAMELEN_MAX]; @@ -167,17 +168,17 @@ typedef struct p80211msg_dot11req_start { p80211item_uint32_t operationalrate7; p80211item_uint32_t operationalrate8; p80211item_uint32_t resultcode; -} __attribute__ ((packed)) p80211msg_dot11req_start_t; +} __packed; -typedef struct p80211msg_lnxreq_ifstate { +struct p80211msg_lnxreq_ifstate { u32 msgcode; u32 msglen; u8 devname[WLAN_DEVNAMELEN_MAX]; p80211item_uint32_t ifstate; p80211item_uint32_t resultcode; -} __attribute__ ((packed)) p80211msg_lnxreq_ifstate_t; +} __packed; -typedef struct p80211msg_lnxreq_wlansniff { +struct p80211msg_lnxreq_wlansniff { u32 msgcode; u32 msglen; u8 devname[WLAN_DEVNAMELEN_MAX]; @@ -189,18 +190,18 @@ typedef struct p80211msg_lnxreq_wlansniff { p80211item_uint32_t stripfcs; p80211item_uint32_t packet_trunc; p80211item_uint32_t resultcode; -} __attribute__ ((packed)) p80211msg_lnxreq_wlansniff_t; +} __packed; -typedef struct p80211msg_lnxreq_hostwep { +struct p80211msg_lnxreq_hostwep { u32 msgcode; u32 msglen; u8 devname[WLAN_DEVNAMELEN_MAX]; p80211item_uint32_t resultcode; p80211item_uint32_t decrypt; p80211item_uint32_t encrypt; -} __attribute__ ((packed)) p80211msg_lnxreq_hostwep_t; +} __packed; -typedef struct p80211msg_lnxreq_commsquality { +struct p80211msg_lnxreq_commsquality { u32 msgcode; u32 msglen; u8 devname[WLAN_DEVNAMELEN_MAX]; @@ -209,9 +210,10 @@ typedef struct p80211msg_lnxreq_commsquality { p80211item_uint32_t link; p80211item_uint32_t level; p80211item_uint32_t noise; -} __attribute__ ((packed)) p80211msg_lnxreq_commsquality_t; + p80211item_uint32_t txrate; +} __packed; -typedef struct p80211msg_lnxreq_autojoin { +struct p80211msg_lnxreq_autojoin { u32 msgcode; u32 msglen; u8 devname[WLAN_DEVNAMELEN_MAX]; @@ -219,26 +221,26 @@ typedef struct p80211msg_lnxreq_autojoin { u8 pad_19D[3]; p80211item_uint32_t authtype; p80211item_uint32_t resultcode; -} __attribute__ ((packed)) p80211msg_lnxreq_autojoin_t; +} __packed; -typedef struct p80211msg_p2req_readpda { +struct p80211msg_p2req_readpda { u32 msgcode; u32 msglen; u8 devname[WLAN_DEVNAMELEN_MAX]; p80211item_unk1024_t pda; p80211item_uint32_t resultcode; -} __attribute__ ((packed)) p80211msg_p2req_readpda_t; +} __packed; -typedef struct p80211msg_p2req_ramdl_state { +struct p80211msg_p2req_ramdl_state { u32 msgcode; u32 msglen; u8 devname[WLAN_DEVNAMELEN_MAX]; p80211item_uint32_t enable; p80211item_uint32_t exeaddr; p80211item_uint32_t resultcode; -} __attribute__ ((packed)) p80211msg_p2req_ramdl_state_t; +} __packed; -typedef struct p80211msg_p2req_ramdl_write { +struct p80211msg_p2req_ramdl_write { u32 msgcode; u32 msglen; u8 devname[WLAN_DEVNAMELEN_MAX]; @@ -246,17 +248,17 @@ typedef struct p80211msg_p2req_ramdl_write { p80211item_uint32_t len; p80211item_unk4096_t data; p80211item_uint32_t resultcode; -} __attribute__ ((packed)) p80211msg_p2req_ramdl_write_t; +} __packed; -typedef struct p80211msg_p2req_flashdl_state { +struct p80211msg_p2req_flashdl_state { u32 msgcode; u32 msglen; u8 devname[WLAN_DEVNAMELEN_MAX]; p80211item_uint32_t enable; p80211item_uint32_t resultcode; -} __attribute__ ((packed)) p80211msg_p2req_flashdl_state_t; +} __packed; -typedef struct p80211msg_p2req_flashdl_write { +struct p80211msg_p2req_flashdl_write { u32 msgcode; u32 msglen; u8 devname[WLAN_DEVNAMELEN_MAX]; @@ -264,6 +266,6 @@ typedef struct p80211msg_p2req_flashdl_write { p80211item_uint32_t len; p80211item_unk4096_t data; p80211item_uint32_t resultcode; -} __attribute__ ((packed)) p80211msg_p2req_flashdl_write_t; +} __packed; #endif diff --git a/drivers/staging/wlan-ng/p80211mgmt.h b/drivers/staging/wlan-ng/p80211mgmt.h index 14cdc86d167..3dd066ac034 100644 --- a/drivers/staging/wlan-ng/p80211mgmt.h +++ b/drivers/staging/wlan-ng/p80211mgmt.h @@ -91,7 +91,7 @@ * fall at the end of their respective frames). * 5a) The length field is set to include the last of the fixed and fixed * length fields. It may have to be updated for optional or variable -* length information elements. +* length information elements. * 6) Optional and variable length information elements are special cases * and must be handled individually by the client code. * -------------------------------------------------------------------- @@ -100,7 +100,7 @@ #ifndef _P80211MGMT_H #define _P80211MGMT_H -#ifndef _P80211HDR_H +#ifndef _P80211HDR_H #include "p80211hdr.h" #endif @@ -219,98 +219,98 @@ /*-- Information Element Types --------------------*/ /* prototype structure, all IEs start with these members */ -typedef struct wlan_ie { +struct wlan_ie { u8 eid; u8 len; -} __attribute__ ((packed)) wlan_ie_t; +} __packed; /*-- Service Set Identity (SSID) -----------------*/ -typedef struct wlan_ie_ssid { +struct wlan_ie_ssid { u8 eid; u8 len; u8 ssid[1]; /* may be zero, ptrs may overlap */ -} __attribute__ ((packed)) wlan_ie_ssid_t; +} __packed; /*-- Supported Rates -----------------------------*/ -typedef struct wlan_ie_supp_rates { +struct wlan_ie_supp_rates { u8 eid; u8 len; u8 rates[1]; /* had better be at LEAST one! */ -} __attribute__ ((packed)) wlan_ie_supp_rates_t; +} __packed; /*-- FH Parameter Set ----------------------------*/ -typedef struct wlan_ie_fh_parms { +struct wlan_ie_fh_parms { u8 eid; u8 len; u16 dwell; u8 hopset; u8 hoppattern; u8 hopindex; -} __attribute__ ((packed)) wlan_ie_fh_parms_t; +} __packed; /*-- DS Parameter Set ----------------------------*/ -typedef struct wlan_ie_ds_parms { +struct wlan_ie_ds_parms { u8 eid; u8 len; u8 curr_ch; -} __attribute__ ((packed)) wlan_ie_ds_parms_t; +} __packed; /*-- CF Parameter Set ----------------------------*/ -typedef struct wlan_ie_cf_parms { +struct wlan_ie_cf_parms { u8 eid; u8 len; u8 cfp_cnt; u8 cfp_period; u16 cfp_maxdur; u16 cfp_durremaining; -} __attribute__ ((packed)) wlan_ie_cf_parms_t; +} __packed; /*-- TIM ------------------------------------------*/ -typedef struct wlan_ie_tim { +struct wlan_ie_tim { u8 eid; u8 len; u8 dtim_cnt; u8 dtim_period; u8 bitmap_ctl; u8 virt_bm[1]; -} __attribute__ ((packed)) wlan_ie_tim_t; +} __packed; /*-- IBSS Parameter Set ---------------------------*/ -typedef struct wlan_ie_ibss_parms { +struct wlan_ie_ibss_parms { u8 eid; u8 len; u16 atim_win; -} __attribute__ ((packed)) wlan_ie_ibss_parms_t; +} __packed; /*-- Challenge Text ------------------------------*/ -typedef struct wlan_ie_challenge { +struct wlan_ie_challenge { u8 eid; u8 len; u8 challenge[1]; -} __attribute__ ((packed)) wlan_ie_challenge_t; +} __packed; /*-------------------------------------------------*/ /* Frame Types */ /* prototype structure, all mgmt frame types will start with these members */ -typedef struct wlan_fr_mgmt { +struct wlan_fr_mgmt { u16 type; u16 len; /* DOES NOT include CRC !!!! */ u8 *buf; - p80211_hdr_t *hdr; + union p80211_hdr *hdr; /* used for target specific data, skb in Linux */ void *priv; /*-- fixed fields -----------*/ /*-- info elements ----------*/ -} wlan_fr_mgmt_t; +}; /*-- Beacon ---------------------------------------*/ -typedef struct wlan_fr_beacon { +struct wlan_fr_beacon { u16 type; u16 len; u8 *buf; - p80211_hdr_t *hdr; + union p80211_hdr *hdr; /* used for target specific data, skb in Linux */ void *priv; /*-- fixed fields -----------*/ @@ -318,22 +318,22 @@ typedef struct wlan_fr_beacon { u16 *bcn_int; u16 *cap_info; /*-- info elements ----------*/ - wlan_ie_ssid_t *ssid; - wlan_ie_supp_rates_t *supp_rates; - wlan_ie_fh_parms_t *fh_parms; - wlan_ie_ds_parms_t *ds_parms; - wlan_ie_cf_parms_t *cf_parms; - wlan_ie_ibss_parms_t *ibss_parms; - wlan_ie_tim_t *tim; + struct wlan_ie_ssid *ssid; + struct wlan_ie_supp_rates *supp_rates; + struct wlan_ie_fh_parms *fh_parms; + struct wlan_ie_ds_parms *ds_parms; + struct wlan_ie_cf_parms *cf_parms; + struct wlan_ie_ibss_parms *ibss_parms; + struct wlan_ie_tim *tim; -} wlan_fr_beacon_t; +}; /*-- IBSS ATIM ------------------------------------*/ -typedef struct wlan_fr_ibssatim { +struct wlan_fr_ibssatim { u16 type; u16 len; u8 *buf; - p80211_hdr_t *hdr; + union p80211_hdr *hdr; /* used for target specific data, skb in Linux */ void *priv; @@ -342,14 +342,14 @@ typedef struct wlan_fr_ibssatim { /* this frame type has a null body */ -} wlan_fr_ibssatim_t; +}; /*-- Disassociation -------------------------------*/ -typedef struct wlan_fr_disassoc { +struct wlan_fr_disassoc { u16 type; u16 len; u8 *buf; - p80211_hdr_t *hdr; + union p80211_hdr *hdr; /* used for target specific data, skb in Linux */ void *priv; /*-- fixed fields -----------*/ @@ -357,31 +357,31 @@ typedef struct wlan_fr_disassoc { /*-- info elements ----------*/ -} wlan_fr_disassoc_t; +}; /*-- Association Request --------------------------*/ -typedef struct wlan_fr_assocreq { +struct wlan_fr_assocreq { u16 type; u16 len; u8 *buf; - p80211_hdr_t *hdr; + union p80211_hdr *hdr; /* used for target specific data, skb in Linux */ void *priv; /*-- fixed fields -----------*/ u16 *cap_info; u16 *listen_int; /*-- info elements ----------*/ - wlan_ie_ssid_t *ssid; - wlan_ie_supp_rates_t *supp_rates; + struct wlan_ie_ssid *ssid; + struct wlan_ie_supp_rates *supp_rates; -} wlan_fr_assocreq_t; +}; /*-- Association Response -------------------------*/ -typedef struct wlan_fr_assocresp { +struct wlan_fr_assocresp { u16 type; u16 len; u8 *buf; - p80211_hdr_t *hdr; + union p80211_hdr *hdr; /* used for target specific data, skb in Linux */ void *priv; /*-- fixed fields -----------*/ @@ -389,16 +389,16 @@ typedef struct wlan_fr_assocresp { u16 *status; u16 *aid; /*-- info elements ----------*/ - wlan_ie_supp_rates_t *supp_rates; + struct wlan_ie_supp_rates *supp_rates; -} wlan_fr_assocresp_t; +}; /*-- Reassociation Request ------------------------*/ -typedef struct wlan_fr_reassocreq { +struct wlan_fr_reassocreq { u16 type; u16 len; u8 *buf; - p80211_hdr_t *hdr; + union p80211_hdr *hdr; /* used for target specific data, skb in Linux */ void *priv; /*-- fixed fields -----------*/ @@ -406,17 +406,17 @@ typedef struct wlan_fr_reassocreq { u16 *listen_int; u8 *curr_ap; /*-- info elements ----------*/ - wlan_ie_ssid_t *ssid; - wlan_ie_supp_rates_t *supp_rates; + struct wlan_ie_ssid *ssid; + struct wlan_ie_supp_rates *supp_rates; -} wlan_fr_reassocreq_t; +}; /*-- Reassociation Response -----------------------*/ -typedef struct wlan_fr_reassocresp { +struct wlan_fr_reassocresp { u16 type; u16 len; u8 *buf; - p80211_hdr_t *hdr; + union p80211_hdr *hdr; /* used for target specific data, skb in Linux */ void *priv; /*-- fixed fields -----------*/ @@ -424,31 +424,31 @@ typedef struct wlan_fr_reassocresp { u16 *status; u16 *aid; /*-- info elements ----------*/ - wlan_ie_supp_rates_t *supp_rates; + struct wlan_ie_supp_rates *supp_rates; -} wlan_fr_reassocresp_t; +}; /*-- Probe Request --------------------------------*/ -typedef struct wlan_fr_probereq { +struct wlan_fr_probereq { u16 type; u16 len; u8 *buf; - p80211_hdr_t *hdr; + union p80211_hdr *hdr; /* used for target specific data, skb in Linux */ void *priv; /*-- fixed fields -----------*/ /*-- info elements ----------*/ - wlan_ie_ssid_t *ssid; - wlan_ie_supp_rates_t *supp_rates; + struct wlan_ie_ssid *ssid; + struct wlan_ie_supp_rates *supp_rates; -} wlan_fr_probereq_t; +}; /*-- Probe Response -------------------------------*/ -typedef struct wlan_fr_proberesp { +struct wlan_fr_proberesp { u16 type; u16 len; u8 *buf; - p80211_hdr_t *hdr; + union p80211_hdr *hdr; /* used for target specific data, skb in Linux */ void *priv; /*-- fixed fields -----------*/ @@ -456,20 +456,20 @@ typedef struct wlan_fr_proberesp { u16 *bcn_int; u16 *cap_info; /*-- info elements ----------*/ - wlan_ie_ssid_t *ssid; - wlan_ie_supp_rates_t *supp_rates; - wlan_ie_fh_parms_t *fh_parms; - wlan_ie_ds_parms_t *ds_parms; - wlan_ie_cf_parms_t *cf_parms; - wlan_ie_ibss_parms_t *ibss_parms; -} wlan_fr_proberesp_t; + struct wlan_ie_ssid *ssid; + struct wlan_ie_supp_rates *supp_rates; + struct wlan_ie_fh_parms *fh_parms; + struct wlan_ie_ds_parms *ds_parms; + struct wlan_ie_cf_parms *cf_parms; + struct wlan_ie_ibss_parms *ibss_parms; +}; /*-- Authentication -------------------------------*/ -typedef struct wlan_fr_authen { +struct wlan_fr_authen { u16 type; u16 len; u8 *buf; - p80211_hdr_t *hdr; + union p80211_hdr *hdr; /* used for target specific data, skb in Linux */ void *priv; /*-- fixed fields -----------*/ @@ -477,16 +477,16 @@ typedef struct wlan_fr_authen { u16 *auth_seq; u16 *status; /*-- info elements ----------*/ - wlan_ie_challenge_t *challenge; + struct wlan_ie_challenge *challenge; -} wlan_fr_authen_t; +}; /*-- Deauthenication -----------------------------*/ -typedef struct wlan_fr_deauthen { +struct wlan_fr_deauthen { u16 type; u16 len; u8 *buf; - p80211_hdr_t *hdr; + union p80211_hdr *hdr; /* used for target specific data, skb in Linux */ void *priv; /*-- fixed fields -----------*/ @@ -494,27 +494,27 @@ typedef struct wlan_fr_deauthen { /*-- info elements ----------*/ -} wlan_fr_deauthen_t; - -void wlan_mgmt_encode_beacon(wlan_fr_beacon_t * f); -void wlan_mgmt_decode_beacon(wlan_fr_beacon_t * f); -void wlan_mgmt_encode_disassoc(wlan_fr_disassoc_t * f); -void wlan_mgmt_decode_disassoc(wlan_fr_disassoc_t * f); -void wlan_mgmt_encode_assocreq(wlan_fr_assocreq_t * f); -void wlan_mgmt_decode_assocreq(wlan_fr_assocreq_t * f); -void wlan_mgmt_encode_assocresp(wlan_fr_assocresp_t * f); -void wlan_mgmt_decode_assocresp(wlan_fr_assocresp_t * f); -void wlan_mgmt_encode_reassocreq(wlan_fr_reassocreq_t * f); -void wlan_mgmt_decode_reassocreq(wlan_fr_reassocreq_t * f); -void wlan_mgmt_encode_reassocresp(wlan_fr_reassocresp_t * f); -void wlan_mgmt_decode_reassocresp(wlan_fr_reassocresp_t * f); -void wlan_mgmt_encode_probereq(wlan_fr_probereq_t * f); -void wlan_mgmt_decode_probereq(wlan_fr_probereq_t * f); -void wlan_mgmt_encode_proberesp(wlan_fr_proberesp_t * f); -void wlan_mgmt_decode_proberesp(wlan_fr_proberesp_t * f); -void wlan_mgmt_encode_authen(wlan_fr_authen_t * f); -void wlan_mgmt_decode_authen(wlan_fr_authen_t * f); -void wlan_mgmt_encode_deauthen(wlan_fr_deauthen_t * f); -void wlan_mgmt_decode_deauthen(wlan_fr_deauthen_t * f); +}; + +void wlan_mgmt_encode_beacon(struct wlan_fr_beacon *f); +void wlan_mgmt_decode_beacon(struct wlan_fr_beacon *f); +void wlan_mgmt_encode_disassoc(struct wlan_fr_disassoc *f); +void wlan_mgmt_decode_disassoc(struct wlan_fr_disassoc *f); +void wlan_mgmt_encode_assocreq(struct wlan_fr_assocreq *f); +void wlan_mgmt_decode_assocreq(struct wlan_fr_assocreq *f); +void wlan_mgmt_encode_assocresp(struct wlan_fr_assocresp *f); +void wlan_mgmt_decode_assocresp(struct wlan_fr_assocresp *f); +void wlan_mgmt_encode_reassocreq(struct wlan_fr_reassocreq *f); +void wlan_mgmt_decode_reassocreq(struct wlan_fr_reassocreq *f); +void wlan_mgmt_encode_reassocresp(struct wlan_fr_reassocresp *f); +void wlan_mgmt_decode_reassocresp(struct wlan_fr_reassocresp *f); +void wlan_mgmt_encode_probereq(struct wlan_fr_probereq *f); +void wlan_mgmt_decode_probereq(struct wlan_fr_probereq *f); +void wlan_mgmt_encode_proberesp(struct wlan_fr_proberesp *f); +void wlan_mgmt_decode_proberesp(struct wlan_fr_proberesp *f); +void wlan_mgmt_encode_authen(struct wlan_fr_authen *f); +void wlan_mgmt_decode_authen(struct wlan_fr_authen *f); +void wlan_mgmt_encode_deauthen(struct wlan_fr_deauthen *f); +void wlan_mgmt_decode_deauthen(struct wlan_fr_deauthen *f); #endif /* _P80211MGMT_H */ diff --git a/drivers/staging/wlan-ng/p80211msg.h b/drivers/staging/wlan-ng/p80211msg.h index c691d3eeb9d..43d2f971e2c 100644 --- a/drivers/staging/wlan-ng/p80211msg.h +++ b/drivers/staging/wlan-ng/p80211msg.h @@ -50,10 +50,10 @@ #define WLAN_DEVNAMELEN_MAX 16 -typedef struct p80211msg { +struct p80211msg { u32 msgcode; u32 msglen; u8 devname[WLAN_DEVNAMELEN_MAX]; -} __attribute__ ((packed)) p80211msg_t; +} __packed; #endif /* _P80211MSG_H */ diff --git a/drivers/staging/wlan-ng/p80211netdev.c b/drivers/staging/wlan-ng/p80211netdev.c index 22424c8903e..00b186c5972 100644 --- a/drivers/staging/wlan-ng/p80211netdev.c +++ b/drivers/staging/wlan-ng/p80211netdev.c @@ -75,6 +75,7 @@ #include <net/iw_handler.h> #include <net/net_namespace.h> +#include <net/cfg80211.h> #include "p80211types.h" #include "p80211hdr.h" @@ -87,8 +88,7 @@ #include "p80211metastruct.h" #include "p80211metadef.h" -/* Support functions */ -static void p80211netdev_rx_bh(unsigned long arg); +#include "cfg80211.c" /* netdevice method functions */ static int p80211knetdev_init(netdevice_t *netdev); @@ -147,7 +147,7 @@ static int p80211knetdev_init(netdevice_t *netdev) * Returns: * the address of the statistics structure ----------------------------------------------------------------*/ -static struct net_device_stats *p80211knetdev_get_stats(netdevice_t * netdev) +static struct net_device_stats *p80211knetdev_get_stats(netdevice_t *netdev) { wlandevice_t *wlandev = netdev->ml_priv; @@ -237,32 +237,62 @@ void p80211netdev_rx(wlandevice_t *wlandev, struct sk_buff *skb) { /* Enqueue for post-irq processing */ skb_queue_tail(&wlandev->nsd_rxq, skb); - tasklet_schedule(&wlandev->rx_bh); +} + +#define CONV_TO_ETHER_SKIPPED 0x01 +#define CONV_TO_ETHER_FAILED 0x02 + +/** + * p80211_convert_to_ether - conversion from 802.11 frame to ethernet frame + * @wlandev: pointer to WLAN device + * @skb: pointer to socket buffer + * + * Returns: 0 if conversion succeeded + * CONV_TO_ETHER_FAILED if conversion failed + * CONV_TO_ETHER_SKIPPED if frame is ignored + */ +static int p80211_convert_to_ether(wlandevice_t *wlandev, struct sk_buff *skb) +{ + struct p80211_hdr_a3 *hdr; + + hdr = (struct p80211_hdr_a3 *) skb->data; + if (p80211_rx_typedrop(wlandev, hdr->fc)) + return CONV_TO_ETHER_SKIPPED; + + /* perform mcast filtering: allow my local address through but reject + * anything else that isn't multicast + */ + if (wlandev->netdev->flags & IFF_ALLMULTI) { + if (!ether_addr_equal_unaligned(wlandev->netdev->dev_addr, + hdr->a1)) { + if (!is_multicast_ether_addr(hdr->a1)) + return CONV_TO_ETHER_SKIPPED; + } + } + + if (skb_p80211_to_ether(wlandev, wlandev->ethconv, skb) == 0) { + skb->dev->last_rx = jiffies; + wlandev->linux_stats.rx_packets++; + wlandev->linux_stats.rx_bytes += skb->len; + netif_rx_ni(skb); + return 0; + } - return; + netdev_dbg(wlandev->netdev, "p80211_convert_to_ether failed.\n"); + return CONV_TO_ETHER_FAILED; } -/*---------------------------------------------------------------- -* p80211netdev_rx_bh -* -* Deferred processing of all received frames. -* -* Arguments: -* wlandev WLAN network device structure -* skb skbuff containing a full 802.11 frame. -* Returns: -* nothing -* Side effects: -* -----------------------------------------------------------------*/ +/** + * p80211netdev_rx_bh - deferred processing of all received frames + * + * @arg: pointer to WLAN network device structure (cast to unsigned long) + */ static void p80211netdev_rx_bh(unsigned long arg) { wlandevice_t *wlandev = (wlandevice_t *) arg; struct sk_buff *skb = NULL; netdevice_t *dev = wlandev->netdev; - p80211_hdr_a3_t *hdr; - u16 fc; /* Let's empty our our queue */ while ((skb = skb_dequeue(&wlandev->nsd_rxq))) { @@ -285,37 +315,8 @@ static void p80211netdev_rx_bh(unsigned long arg) netif_rx_ni(skb); continue; } else { - hdr = (p80211_hdr_a3_t *) skb->data; - fc = le16_to_cpu(hdr->fc); - if (p80211_rx_typedrop(wlandev, fc)) { - dev_kfree_skb(skb); - continue; - } - - /* perform mcast filtering */ - if (wlandev->netdev->flags & IFF_ALLMULTI) { - /* allow my local address through */ - if (memcmp - (hdr->a1, wlandev->netdev->dev_addr, - ETH_ALEN) != 0) { - /* but reject anything else that isn't multicast */ - if (!(hdr->a1[0] & 0x01)) { - dev_kfree_skb(skb); - continue; - } - } - } - - if (skb_p80211_to_ether - (wlandev, wlandev->ethconv, skb) == 0) { - skb->dev->last_rx = jiffies; - wlandev->linux_stats.rx_packets++; - wlandev->linux_stats.rx_bytes += - skb->len; - netif_rx_ni(skb); + if (!p80211_convert_to_ether(wlandev, skb)) continue; - } - pr_debug("p80211_to_ether failed.\n"); } } dev_kfree_skb(skb); @@ -347,8 +348,10 @@ static int p80211knetdev_hard_start_xmit(struct sk_buff *skb, int result = 0; int txresult = -1; wlandevice_t *wlandev = netdev->ml_priv; - p80211_hdr_t p80211_hdr; - p80211_metawep_t p80211_wep; + union p80211_hdr p80211_hdr; + struct p80211_metawep p80211_wep; + + p80211_wep.data = NULL; if (skb == NULL) return NETDEV_TX_OK; @@ -358,11 +361,11 @@ static int p80211knetdev_hard_start_xmit(struct sk_buff *skb, goto failed; } - memset(&p80211_hdr, 0, sizeof(p80211_hdr_t)); - memset(&p80211_wep, 0, sizeof(p80211_metawep_t)); + memset(&p80211_hdr, 0, sizeof(union p80211_hdr)); + memset(&p80211_wep, 0, sizeof(struct p80211_metawep)); if (netif_queue_stopped(netdev)) { - pr_debug("called when queue stopped.\n"); + netdev_dbg(netdev, "called when queue stopped.\n"); result = 1; goto failed; } @@ -382,8 +385,7 @@ static int p80211knetdev_hard_start_xmit(struct sk_buff *skb, */ if (skb->protocol != ETH_P_80211_RAW) { netif_start_queue(wlandev->netdev); - printk(KERN_NOTICE - "Tx attempt prior to association, frame dropped.\n"); + netdev_notice(netdev, "Tx attempt prior to association, frame dropped.\n"); wlandev->linux_stats.tx_dropped++; result = 0; goto failed; @@ -398,15 +400,15 @@ static int p80211knetdev_hard_start_xmit(struct sk_buff *skb, goto failed; } /* move the header over */ - memcpy(&p80211_hdr, skb->data, sizeof(p80211_hdr_t)); - skb_pull(skb, sizeof(p80211_hdr_t)); + memcpy(&p80211_hdr, skb->data, sizeof(union p80211_hdr)); + skb_pull(skb, sizeof(union p80211_hdr)); } else { if (skb_ether_to_p80211 (wlandev, wlandev->ethconv, skb, &p80211_hdr, &p80211_wep) != 0) { /* convert failed */ - pr_debug("ether_to_80211(%d) failed.\n", - wlandev->ethconv); + netdev_dbg(netdev, "ether_to_80211(%d) failed.\n", + wlandev->ethconv); result = 1; goto failed; } @@ -431,17 +433,17 @@ static int p80211knetdev_hard_start_xmit(struct sk_buff *skb, result = NETDEV_TX_OK; } else if (txresult == 1) { /* success, no more avail */ - pr_debug("txframe success, no more bufs\n"); + netdev_dbg(netdev, "txframe success, no more bufs\n"); /* netdev->tbusy = 1; don't set here, irqhdlr */ /* may have already cleared it */ result = NETDEV_TX_OK; } else if (txresult == 2) { /* alloc failure, drop frame */ - pr_debug("txframe returned alloc_fail\n"); + netdev_dbg(netdev, "txframe returned alloc_fail\n"); result = NETDEV_TX_BUSY; } else { /* buffer full or queue busy, drop frame. */ - pr_debug("txframe returned full or busy\n"); + netdev_dbg(netdev, "txframe returned full or busy\n"); result = NETDEV_TX_BUSY; } @@ -460,7 +462,7 @@ failed: /*---------------------------------------------------------------- * p80211knetdev_set_multicast_list * -* Called from higher lavers whenever there's a need to set/clear +* Called from higher layers whenever there's a need to set/clear * promiscuous mode or rewrite the multicast list. * * Arguments: @@ -519,8 +521,8 @@ static int p80211netdev_ethtool(wlandevice_t *wlandev, void __user *useraddr) if (copy_to_user(useraddr, &edata, sizeof(edata))) return -EFAULT; return 0; - } #endif + } return -EOPNOTSUPP; } @@ -557,11 +559,11 @@ static int p80211netdev_ethtool(wlandevice_t *wlandev, void __user *useraddr) static int p80211knetdev_do_ioctl(netdevice_t *dev, struct ifreq *ifr, int cmd) { int result = 0; - p80211ioctl_req_t *req = (p80211ioctl_req_t *) ifr; + struct p80211ioctl_req *req = (struct p80211ioctl_req *) ifr; wlandevice_t *wlandev = dev->ml_priv; u8 *msgbuf; - pr_debug("rx'd ioctl, cmd=%d, len=%d\n", cmd, req->len); + netdev_dbg(dev, "rx'd ioctl, cmd=%d, len=%d\n", cmd, req->len); #ifdef SIOCETHTOOL if (cmd == SIOCETHTOOL) { @@ -586,7 +588,8 @@ static int p80211knetdev_do_ioctl(netdevice_t *dev, struct ifreq *ifr, int cmd) } /* Allocate a buf of size req->len */ - if ((msgbuf = kmalloc(req->len, GFP_KERNEL))) { + msgbuf = kmalloc(req->len, GFP_KERNEL); + if (msgbuf) { if (copy_from_user(msgbuf, (void __user *)req->data, req->len)) result = -EFAULT; else @@ -603,7 +606,8 @@ static int p80211knetdev_do_ioctl(netdevice_t *dev, struct ifreq *ifr, int cmd) result = -ENOMEM; } bail: - return result; /* If allocate,copyfrom or copyto fails, return errno */ + /* If allocate,copyfrom or copyto fails, return errno */ + return result; } /*---------------------------------------------------------------- @@ -634,11 +638,11 @@ bail: static int p80211knetdev_set_mac_address(netdevice_t *dev, void *addr) { struct sockaddr *new_addr = addr; - p80211msg_dot11req_mibset_t dot11req; + struct p80211msg_dot11req_mibset dot11req; p80211item_unk392_t *mibattr; p80211item_pstr6_t *macaddr; p80211item_uint32_t *resultcode; - int result = 0; + int result; /* If we're running, we don't allow MAC address changes */ if (netif_running(dev)) @@ -646,13 +650,13 @@ static int p80211knetdev_set_mac_address(netdevice_t *dev, void *addr) /* Set up some convenience pointers. */ mibattr = &dot11req.mibattribute; - macaddr = (p80211item_pstr6_t *) & mibattr->data; + macaddr = (p80211item_pstr6_t *) &mibattr->data; resultcode = &dot11req.resultcode; /* Set up a dot11req_mibset */ - memset(&dot11req, 0, sizeof(p80211msg_dot11req_mibset_t)); + memset(&dot11req, 0, sizeof(struct p80211msg_dot11req_mibset)); dot11req.msgcode = DIDmsg_dot11req_mibset; - dot11req.msglen = sizeof(p80211msg_dot11req_mibset_t); + dot11req.msglen = sizeof(struct p80211msg_dot11req_mibset); memcpy(dot11req.devname, ((wlandevice_t *) dev->ml_priv)->name, WLAN_DEVNAMELEN_MAX - 1); @@ -674,14 +678,13 @@ static int p80211knetdev_set_mac_address(netdevice_t *dev, void *addr) resultcode->data = 0; /* now fire the request */ - result = p80211req_dorequest(dev->ml_priv, (u8 *) & dot11req); + result = p80211req_dorequest(dev->ml_priv, (u8 *) &dot11req); /* If the request wasn't successful, report an error and don't * change the netdev address */ if (result != 0 || resultcode->data != P80211ENUM_resultcode_success) { - printk(KERN_ERR - "Low-level driver failed dot11req_mibset(dot11MACAddress).\n"); + netdev_err(dev, "Low-level driver failed dot11req_mibset(dot11MACAddress).\n"); result = -EADDRNOTAVAIL; } else { /* everything's ok, change the addr in netdev */ @@ -709,7 +712,7 @@ static const struct net_device_ops p80211_netdev_ops = { .ndo_stop = p80211knetdev_stop, .ndo_get_stats = p80211knetdev_get_stats, .ndo_start_xmit = p80211knetdev_hard_start_xmit, - .ndo_set_multicast_list = p80211knetdev_set_multicast_list, + .ndo_set_rx_mode = p80211knetdev_set_multicast_list, .ndo_do_ioctl = p80211knetdev_do_ioctl, .ndo_set_mac_address = p80211knetdev_set_mac_address, .ndo_tx_timeout = p80211knetdev_tx_timeout, @@ -731,6 +734,7 @@ static const struct net_device_ops p80211_netdev_ops = { * Arguments: * wlandev ptr to the wlandev structure for the * interface. +* physdev ptr to usb device * Returns: * zero on success, non-zero otherwise. * Call Context: @@ -739,10 +743,12 @@ static const struct net_device_ops p80211_netdev_ops = { * compiled drivers, this function will be called in the * context of the kernel startup code. ----------------------------------------------------------------*/ -int wlan_setup(wlandevice_t *wlandev) +int wlan_setup(wlandevice_t *wlandev, struct device *physdev) { int result = 0; - netdevice_t *dev; + netdevice_t *netdev; + struct wiphy *wiphy; + struct wireless_dev *wdev; /* Set up the wlandev */ wlandev->state = WLAN_DEVICE_CLOSED; @@ -754,20 +760,31 @@ int wlan_setup(wlandevice_t *wlandev) tasklet_init(&wlandev->rx_bh, p80211netdev_rx_bh, (unsigned long)wlandev); + /* Allocate and initialize the wiphy struct */ + wiphy = wlan_create_wiphy(physdev, wlandev); + if (wiphy == NULL) { + dev_err(physdev, "Failed to alloc wiphy.\n"); + return 1; + } + /* Allocate and initialize the struct device */ - dev = alloc_netdev(0, "wlan%d", ether_setup); - if (dev == NULL) { - printk(KERN_ERR "Failed to alloc netdev.\n"); + netdev = alloc_netdev(sizeof(struct wireless_dev), "wlan%d", + ether_setup); + if (netdev == NULL) { + dev_err(physdev, "Failed to alloc netdev.\n"); + wlan_free_wiphy(wiphy); result = 1; } else { - wlandev->netdev = dev; - dev->ml_priv = wlandev; - dev->netdev_ops = &p80211_netdev_ops; - - dev->wireless_handlers = &p80211wext_handler_def; - - netif_stop_queue(dev); - netif_carrier_off(dev); + wlandev->netdev = netdev; + netdev->ml_priv = wlandev; + netdev->netdev_ops = &p80211_netdev_ops; + wdev = netdev_priv(netdev); + wdev->wiphy = wiphy; + wdev->iftype = NL80211_IFTYPE_STATION; + netdev->ieee80211_ptr = wdev; + + netif_stop_queue(netdev); + netif_carrier_off(netdev); } return result; @@ -786,29 +803,25 @@ int wlan_setup(wlandevice_t *wlandev) * Arguments: * wlandev ptr to the wlandev structure for the * interface. -* Returns: -* zero on success, non-zero otherwise. * Call Context: * Should be process thread. We'll assume it might be * interrupt though. When we add support for statically * compiled drivers, this function will be called in the * context of the kernel startup code. ----------------------------------------------------------------*/ -int wlan_unsetup(wlandevice_t *wlandev) +void wlan_unsetup(wlandevice_t *wlandev) { - int result = 0; + struct wireless_dev *wdev; tasklet_kill(&wlandev->rx_bh); - if (wlandev->netdev == NULL) { - printk(KERN_ERR "called without wlandev->netdev set.\n"); - result = 1; - } else { + if (wlandev->netdev) { + wdev = netdev_priv(wlandev->netdev); + if (wdev->wiphy) + wlan_free_wiphy(wdev->wiphy); free_netdev(wlandev->netdev); wlandev->netdev = NULL; } - - return 0; } /*---------------------------------------------------------------- @@ -832,13 +845,7 @@ int wlan_unsetup(wlandevice_t *wlandev) ----------------------------------------------------------------*/ int register_wlandev(wlandevice_t *wlandev) { - int i = 0; - - i = register_netdev(wlandev->netdev); - if (i) - return i; - - return 0; + return register_netdev(wlandev->netdev); } /*---------------------------------------------------------------- @@ -940,7 +947,8 @@ static int p80211_rx_typedrop(wlandevice_t *wlandev, u16 fc) ftype = WLAN_GET_FC_FTYPE(fc); fstype = WLAN_GET_FC_FSTYPE(fc); #if 0 - pr_debug("rx_typedrop : ftype=%d fstype=%d.\n", ftype, fstype); + netdev_dbg(wlandev->netdev, "rx_typedrop : ftype=%d fstype=%d.\n", + ftype, fstype); #endif switch (ftype) { case WLAN_FTYPE_MGMT: @@ -949,7 +957,7 @@ static int p80211_rx_typedrop(wlandevice_t *wlandev, u16 fc) drop = 1; break; } - pr_debug("rx'd mgmt:\n"); + netdev_dbg(wlandev->netdev, "rx'd mgmt:\n"); wlandev->rx.mgmt++; switch (fstype) { case WLAN_FSTYPE_ASSOCREQ: @@ -1011,7 +1019,7 @@ static int p80211_rx_typedrop(wlandevice_t *wlandev, u16 fc) drop = 1; break; } - pr_debug("rx'd ctl:\n"); + netdev_dbg(wlandev->netdev, "rx'd ctl:\n"); wlandev->rx.ctl++; switch (fstype) { case WLAN_FSTYPE_PSPOLL: @@ -1063,19 +1071,19 @@ static int p80211_rx_typedrop(wlandevice_t *wlandev, u16 fc) wlandev->rx.data__cfack_cfpoll++; break; case WLAN_FSTYPE_NULL: - pr_debug("rx'd data:null\n"); + netdev_dbg(wlandev->netdev, "rx'd data:null\n"); wlandev->rx.null++; break; case WLAN_FSTYPE_CFACK: - pr_debug("rx'd data:cfack\n"); + netdev_dbg(wlandev->netdev, "rx'd data:cfack\n"); wlandev->rx.cfack++; break; case WLAN_FSTYPE_CFPOLL: - pr_debug("rx'd data:cfpoll\n"); + netdev_dbg(wlandev->netdev, "rx'd data:cfpoll\n"); wlandev->rx.cfpoll++; break; case WLAN_FSTYPE_CFACK_CFPOLL: - pr_debug("rx'd data:cfack_cfpoll\n"); + netdev_dbg(wlandev->netdev, "rx'd data:cfack_cfpoll\n"); wlandev->rx.cfack_cfpoll++; break; default: @@ -1096,8 +1104,8 @@ static void p80211knetdev_tx_timeout(netdevice_t *netdev) if (wlandev->tx_timeout) { wlandev->tx_timeout(wlandev); } else { - printk(KERN_WARNING "Implement tx_timeout for %s\n", - wlandev->nsdname); + netdev_warn(netdev, "Implement tx_timeout for %s\n", + wlandev->nsdname); netif_wake_queue(wlandev->netdev); } } diff --git a/drivers/staging/wlan-ng/p80211netdev.h b/drivers/staging/wlan-ng/p80211netdev.h index 8bd9dfb3b9b..2e0bd24f997 100644 --- a/drivers/staging/wlan-ng/p80211netdev.h +++ b/drivers/staging/wlan-ng/p80211netdev.h @@ -94,11 +94,11 @@ typedef struct net_device netdevice_t; #endif /*--- NSD Capabilities Flags ------------------------------*/ -#define P80211_NSDCAP_HARDWAREWEP 0x01 /* hardware wep engine */ -#define P80211_NSDCAP_SHORT_PREAMBLE 0x10 /* hardware supports */ -#define P80211_NSDCAP_HWFRAGMENT 0x80 /* nsd handles frag/defrag */ -#define P80211_NSDCAP_AUTOJOIN 0x100 /* nsd does autojoin */ -#define P80211_NSDCAP_NOSCAN 0x200 /* nsd can scan */ +#define P80211_NSDCAP_HARDWAREWEP 0x01 /* hardware wep engine */ +#define P80211_NSDCAP_SHORT_PREAMBLE 0x10 /* hardware supports */ +#define P80211_NSDCAP_HWFRAGMENT 0x80 /* nsd handles frag/defrag */ +#define P80211_NSDCAP_AUTOJOIN 0x100 /* nsd does autojoin */ +#define P80211_NSDCAP_NOSCAN 0x200 /* nsd can scan */ /* Received frame statistics */ typedef struct p80211_frmrx_t { @@ -138,7 +138,7 @@ typedef struct p80211_frmrx_t { } p80211_frmrx_t; /* called by /proc/net/wireless */ -struct iw_statistics *p80211wext_get_wireless_stats(netdevice_t * dev); +struct iw_statistics *p80211wext_get_wireless_stats(netdevice_t *dev); /* wireless extensions' ioctls */ extern struct iw_handler_def p80211wext_handler_def; int p80211wext_event_associated(struct wlandevice *wlandev, int assoc); @@ -148,6 +148,7 @@ int p80211wext_event_associated(struct wlandevice *wlandev, int assoc); #define MAX_KEYLEN 32 #define HOSTWEP_DEFAULTKEY_MASK (BIT(1)|BIT(0)) +#define HOSTWEP_SHAREDKEY BIT(3) #define HOSTWEP_DECRYPT BIT(4) #define HOSTWEP_ENCRYPT BIT(5) #define HOSTWEP_PRIVACYINVOKED BIT(6) @@ -179,16 +180,16 @@ typedef struct wlandevice { unsigned int ethconv; /* device methods (init by MSD, used by p80211 */ - int (*open) (struct wlandevice * wlandev); - int (*close) (struct wlandevice * wlandev); - void (*reset) (struct wlandevice * wlandev); - int (*txframe) (struct wlandevice * wlandev, struct sk_buff * skb, - p80211_hdr_t * p80211_hdr, - p80211_metawep_t * p80211_wep); - int (*mlmerequest) (struct wlandevice * wlandev, p80211msg_t * msg); - int (*set_multicast_list) (struct wlandevice * wlandev, - netdevice_t * dev); - void (*tx_timeout) (struct wlandevice * wlandev); + int (*open) (struct wlandevice *wlandev); + int (*close) (struct wlandevice *wlandev); + void (*reset) (struct wlandevice *wlandev); + int (*txframe) (struct wlandevice *wlandev, struct sk_buff *skb, + union p80211_hdr *p80211_hdr, + struct p80211_metawep *p80211_wep); + int (*mlmerequest) (struct wlandevice *wlandev, struct p80211msg *msg); + int (*set_multicast_list) (struct wlandevice *wlandev, + netdevice_t *dev); + void (*tx_timeout) (struct wlandevice *wlandev); /* 802.11 State */ u8 bssid[WLAN_BSSID_LEN]; @@ -227,16 +228,16 @@ typedef struct wlandevice { } wlandevice_t; /* WEP stuff */ -int wep_change_key(wlandevice_t * wlandev, int keynum, u8 * key, int keylen); -int wep_decrypt(wlandevice_t * wlandev, u8 * buf, u32 len, int key_override, - u8 * iv, u8 * icv); -int wep_encrypt(wlandevice_t * wlandev, u8 * buf, u8 * dst, u32 len, int keynum, - u8 * iv, u8 * icv); - -int wlan_setup(wlandevice_t * wlandev); -int wlan_unsetup(wlandevice_t * wlandev); -int register_wlandev(wlandevice_t * wlandev); -int unregister_wlandev(wlandevice_t * wlandev); -void p80211netdev_rx(wlandevice_t * wlandev, struct sk_buff *skb); -void p80211netdev_hwremoved(wlandevice_t * wlandev); +int wep_change_key(wlandevice_t *wlandev, int keynum, u8 *key, int keylen); +int wep_decrypt(wlandevice_t *wlandev, u8 *buf, u32 len, int key_override, + u8 *iv, u8 *icv); +int wep_encrypt(wlandevice_t *wlandev, u8 *buf, u8 *dst, u32 len, int keynum, + u8 *iv, u8 *icv); + +int wlan_setup(wlandevice_t *wlandev, struct device *physdev); +void wlan_unsetup(wlandevice_t *wlandev); +int register_wlandev(wlandevice_t *wlandev); +int unregister_wlandev(wlandevice_t *wlandev); +void p80211netdev_rx(wlandevice_t *wlandev, struct sk_buff *skb); +void p80211netdev_hwremoved(wlandevice_t *wlandev); #endif diff --git a/drivers/staging/wlan-ng/p80211req.c b/drivers/staging/wlan-ng/p80211req.c index c88156cdf68..7221379c974 100644 --- a/drivers/staging/wlan-ng/p80211req.c +++ b/drivers/staging/wlan-ng/p80211req.c @@ -55,7 +55,6 @@ #include <linux/sched.h> #include <linux/types.h> #include <linux/skbuff.h> -#include <linux/slab.h> #include <linux/wireless.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> @@ -73,9 +72,9 @@ #include "p80211metastruct.h" #include "p80211req.h" -static void p80211req_handlemsg(wlandevice_t *wlandev, p80211msg_t *msg); -static int p80211req_mibset_mibget(wlandevice_t *wlandev, - p80211msg_dot11req_mibget_t *mib_msg, +static void p80211req_handlemsg(wlandevice_t *wlandev, struct p80211msg *msg); +static void p80211req_mibset_mibget(wlandevice_t *wlandev, + struct p80211msg_dot11req_mibget *mib_msg, int isget); /*---------------------------------------------------------------- @@ -94,10 +93,9 @@ static int p80211req_mibset_mibget(wlandevice_t *wlandev, * Potentially blocks the caller, so it's a good idea to * not call this function from an interrupt context. ----------------------------------------------------------------*/ -int p80211req_dorequest(wlandevice_t * wlandev, u8 * msgbuf) +int p80211req_dorequest(wlandevice_t *wlandev, u8 *msgbuf) { - int result = 0; - p80211msg_t *msg = (p80211msg_t *) msgbuf; + struct p80211msg *msg = (struct p80211msg *) msgbuf; /* Check to make sure the MSD is running */ if (!((wlandev->msdstate == WLAN_MSD_HWPRESENT && @@ -108,10 +106,11 @@ int p80211req_dorequest(wlandevice_t * wlandev, u8 * msgbuf) } /* Check Permissions */ - if (!capable(CAP_NET_ADMIN) && (msg->msgcode != DIDmsg_dot11req_mibget)) { - printk(KERN_ERR - "%s: only dot11req_mibget allowed for non-root.\n", - wlandev->name); + if (!capable(CAP_NET_ADMIN) && + (msg->msgcode != DIDmsg_dot11req_mibget)) { + netdev_err(wlandev->netdev, + "%s: only dot11req_mibget allowed for non-root.\n", + wlandev->name); return -EPERM; } @@ -129,7 +128,7 @@ int p80211req_dorequest(wlandevice_t * wlandev, u8 * msgbuf) wlandev->mlmerequest(wlandev, msg); clear_bit(1, &(wlandev->request_pending)); - return result; /* if result==0, msg->status still may contain an err */ + return 0; /* if result==0, msg->status still may contain an err */ } /*---------------------------------------------------------------- @@ -150,38 +149,35 @@ int p80211req_dorequest(wlandevice_t * wlandev, u8 * msgbuf) * Call context: * Process thread ----------------------------------------------------------------*/ -static void p80211req_handlemsg(wlandevice_t *wlandev, p80211msg_t *msg) +static void p80211req_handlemsg(wlandevice_t *wlandev, struct p80211msg *msg) { switch (msg->msgcode) { case DIDmsg_lnxreq_hostwep:{ - p80211msg_lnxreq_hostwep_t *req = - (p80211msg_lnxreq_hostwep_t *) msg; - wlandev->hostwep &= - ~(HOSTWEP_DECRYPT | HOSTWEP_ENCRYPT); - if (req->decrypt.data == P80211ENUM_truth_true) - wlandev->hostwep |= HOSTWEP_DECRYPT; - if (req->encrypt.data == P80211ENUM_truth_true) - wlandev->hostwep |= HOSTWEP_ENCRYPT; - - break; - } + struct p80211msg_lnxreq_hostwep *req = + (struct p80211msg_lnxreq_hostwep *) msg; + wlandev->hostwep &= + ~(HOSTWEP_DECRYPT | HOSTWEP_ENCRYPT); + if (req->decrypt.data == P80211ENUM_truth_true) + wlandev->hostwep |= HOSTWEP_DECRYPT; + if (req->encrypt.data == P80211ENUM_truth_true) + wlandev->hostwep |= HOSTWEP_ENCRYPT; + + break; + } case DIDmsg_dot11req_mibget: case DIDmsg_dot11req_mibset:{ - int isget = (msg->msgcode == DIDmsg_dot11req_mibget); - p80211msg_dot11req_mibget_t *mib_msg = - (p80211msg_dot11req_mibget_t *) msg; - p80211req_mibset_mibget(wlandev, mib_msg, isget); - } - default: - ; + int isget = (msg->msgcode == DIDmsg_dot11req_mibget); + struct p80211msg_dot11req_mibget *mib_msg = + (struct p80211msg_dot11req_mibget *) msg; + p80211req_mibset_mibget(wlandev, mib_msg, isget); + break; + } } /* switch msg->msgcode */ - - return; } -static int p80211req_mibset_mibget(wlandevice_t *wlandev, - p80211msg_dot11req_mibget_t *mib_msg, +static void p80211req_mibset_mibget(wlandevice_t *wlandev, + struct p80211msg_dot11req_mibget *mib_msg, int isget) { p80211itemd_t *mibitem = (p80211itemd_t *) mib_msg->mibattribute.data; @@ -190,76 +186,65 @@ static int p80211req_mibset_mibget(wlandevice_t *wlandev, switch (mibitem->did) { case DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0:{ - if (!isget) - wep_change_key(wlandev, 0, key, pstr->len); - break; - } + if (!isget) + wep_change_key(wlandev, 0, key, pstr->len); + break; + } case DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1:{ - if (!isget) - wep_change_key(wlandev, 1, key, pstr->len); - break; - } + if (!isget) + wep_change_key(wlandev, 1, key, pstr->len); + break; + } case DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2:{ - if (!isget) - wep_change_key(wlandev, 2, key, pstr->len); - break; - } + if (!isget) + wep_change_key(wlandev, 2, key, pstr->len); + break; + } case DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3:{ - if (!isget) - wep_change_key(wlandev, 3, key, pstr->len); - break; - } + if (!isget) + wep_change_key(wlandev, 3, key, pstr->len); + break; + } case DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID:{ - u32 *data = (u32 *) mibitem->data; + u32 *data = (u32 *) mibitem->data; - if (isget) { - *data = - wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK; - } else { - wlandev->hostwep &= ~(HOSTWEP_DEFAULTKEY_MASK); - - wlandev->hostwep |= - (*data & HOSTWEP_DEFAULTKEY_MASK); - } - break; + if (isget) { + *data = wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK; + } else { + wlandev->hostwep &= ~(HOSTWEP_DEFAULTKEY_MASK); + wlandev->hostwep |= (*data & HOSTWEP_DEFAULTKEY_MASK); } + break; + } case DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked:{ - u32 *data = (u32 *) mibitem->data; - - if (isget) { - if (wlandev->hostwep & HOSTWEP_PRIVACYINVOKED) - *data = P80211ENUM_truth_true; - else - *data = P80211ENUM_truth_false; - } else { - wlandev->hostwep &= ~(HOSTWEP_PRIVACYINVOKED); - if (*data == P80211ENUM_truth_true) - wlandev->hostwep |= - HOSTWEP_PRIVACYINVOKED; - } - break; + u32 *data = (u32 *) mibitem->data; + + if (isget) { + if (wlandev->hostwep & HOSTWEP_PRIVACYINVOKED) + *data = P80211ENUM_truth_true; + else + *data = P80211ENUM_truth_false; + } else { + wlandev->hostwep &= ~(HOSTWEP_PRIVACYINVOKED); + if (*data == P80211ENUM_truth_true) + wlandev->hostwep |= HOSTWEP_PRIVACYINVOKED; } + break; + } case DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted:{ - u32 *data = (u32 *) mibitem->data; - - if (isget) { - if (wlandev->hostwep & - HOSTWEP_EXCLUDEUNENCRYPTED) - *data = P80211ENUM_truth_true; - else - *data = P80211ENUM_truth_false; - } else { - wlandev->hostwep &= - ~(HOSTWEP_EXCLUDEUNENCRYPTED); - if (*data == P80211ENUM_truth_true) - wlandev->hostwep |= - HOSTWEP_EXCLUDEUNENCRYPTED; - } - break; + u32 *data = (u32 *) mibitem->data; + + if (isget) { + if (wlandev->hostwep & HOSTWEP_EXCLUDEUNENCRYPTED) + *data = P80211ENUM_truth_true; + else + *data = P80211ENUM_truth_false; + } else { + wlandev->hostwep &= ~(HOSTWEP_EXCLUDEUNENCRYPTED); + if (*data == P80211ENUM_truth_true) + wlandev->hostwep |= HOSTWEP_EXCLUDEUNENCRYPTED; } - default: - ; + break; + } } - - return 0; } diff --git a/drivers/staging/wlan-ng/p80211req.h b/drivers/staging/wlan-ng/p80211req.h index 5d9176762ba..a95a45a6814 100644 --- a/drivers/staging/wlan-ng/p80211req.h +++ b/drivers/staging/wlan-ng/p80211req.h @@ -48,6 +48,6 @@ #ifndef _LINUX_P80211REQ_H #define _LINUX_P80211REQ_H -int p80211req_dorequest(wlandevice_t * wlandev, u8 * msgbuf); +int p80211req_dorequest(wlandevice_t *wlandev, u8 *msgbuf); #endif diff --git a/drivers/staging/wlan-ng/p80211types.h b/drivers/staging/wlan-ng/p80211types.h index 2b83ab0c711..8cb4fc6448a 100644 --- a/drivers/staging/wlan-ng/p80211types.h +++ b/drivers/staging/wlan-ng/p80211types.h @@ -141,14 +141,14 @@ #define P80211DID_LSB_ITEM (12) #define P80211DID_LSB_INDEX (18) #define P80211DID_LSB_ISTABLE (26) -#define P80211DID_LSB_ACCESS (27) +#define P80211DID_LSB_ACCESS (27) #define P80211DID_MASK_SECTION (0x0000003fUL) #define P80211DID_MASK_GROUP (0x0000003fUL) #define P80211DID_MASK_ITEM (0x0000003fUL) #define P80211DID_MASK_INDEX (0x000000ffUL) #define P80211DID_MASK_ISTABLE (0x00000001UL) -#define P80211DID_MASK_ACCESS (0x00000003UL) +#define P80211DID_MASK_ACCESS (0x00000003UL) #define P80211DID_MK(a, m, l) ((((u32)(a)) & (m)) << (l)) @@ -168,12 +168,12 @@ P80211DID_MASK_ISTABLE, \ P80211DID_LSB_ISTABLE) -#define P80211DID_MKID(s,g,i,n,t,a) (P80211DID_MKSECTION(s) | \ - P80211DID_MKGROUP(g) | \ - P80211DID_MKITEM(i) | \ - P80211DID_MKINDEX(n) | \ - P80211DID_MKISTABLE(t) | \ - (a)) +#define P80211DID_MKID(s, g, i, n, t, a) (P80211DID_MKSECTION(s) | \ + P80211DID_MKGROUP(g) | \ + P80211DID_MKITEM(i) | \ + P80211DID_MKINDEX(n) | \ + P80211DID_MKISTABLE(t) | \ + (a)) #define P80211DID_GET(a, m, l) ((((u32)(a)) >> (l)) & (m)) @@ -197,7 +197,7 @@ P80211DID_LSB_ACCESS) /*----------------------------------------------------------------*/ -/* The following structure types are used for the represenation */ +/* The following structure types are used for the representation */ /* of ENUMint type metadata. */ typedef struct p80211enumpair { @@ -217,49 +217,49 @@ typedef struct p80211enum { /* Template pascal string */ typedef struct p80211pstr { u8 len; -} __attribute__ ((packed)) p80211pstr_t; +} __packed p80211pstr_t; typedef struct p80211pstrd { u8 len; u8 data[0]; -} __attribute__ ((packed)) p80211pstrd_t; +} __packed p80211pstrd_t; /* Maximum pascal string */ typedef struct p80211pstr255 { u8 len; u8 data[MAXLEN_PSTR255]; -} __attribute__ ((packed)) p80211pstr255_t; +} __packed p80211pstr255_t; /* pascal string for macaddress and bssid */ typedef struct p80211pstr6 { u8 len; u8 data[MAXLEN_PSTR6]; -} __attribute__ ((packed)) p80211pstr6_t; +} __packed p80211pstr6_t; /* pascal string for channel list */ typedef struct p80211pstr14 { u8 len; u8 data[MAXLEN_PSTR14]; -} __attribute__ ((packed)) p80211pstr14_t; +} __packed p80211pstr14_t; /* pascal string for ssid */ typedef struct p80211pstr32 { u8 len; u8 data[MAXLEN_PSTR32]; -} __attribute__ ((packed)) p80211pstr32_t; +} __packed p80211pstr32_t; /* MAC address array */ typedef struct p80211macarray { u32 cnt; u8 data[1][MAXLEN_PSTR6]; -} __attribute__ ((packed)) p80211macarray_t; +} __packed p80211macarray_t; /* prototype template */ typedef struct p80211item { u32 did; u16 status; u16 len; -} __attribute__ ((packed)) p80211item_t; +} __packed p80211item_t; /* prototype template w/ data item */ typedef struct p80211itemd { @@ -267,7 +267,7 @@ typedef struct p80211itemd { u16 status; u16 len; u8 data[0]; -} __attribute__ ((packed)) p80211itemd_t; +} __packed p80211itemd_t; /* message data item for int, BOUNDEDINT, ENUMINT */ typedef struct p80211item_uint32 { @@ -275,7 +275,7 @@ typedef struct p80211item_uint32 { u16 status; u16 len; u32 data; -} __attribute__ ((packed)) p80211item_uint32_t; +} __packed p80211item_uint32_t; /* message data item for OCTETSTR, DISPLAYSTR */ typedef struct p80211item_pstr6 { @@ -283,7 +283,7 @@ typedef struct p80211item_pstr6 { u16 status; u16 len; p80211pstr6_t data; -} __attribute__ ((packed)) p80211item_pstr6_t; +} __packed p80211item_pstr6_t; /* message data item for OCTETSTR, DISPLAYSTR */ typedef struct p80211item_pstr14 { @@ -291,7 +291,7 @@ typedef struct p80211item_pstr14 { u16 status; u16 len; p80211pstr14_t data; -} __attribute__ ((packed)) p80211item_pstr14_t; +} __packed p80211item_pstr14_t; /* message data item for OCTETSTR, DISPLAYSTR */ typedef struct p80211item_pstr32 { @@ -299,7 +299,7 @@ typedef struct p80211item_pstr32 { u16 status; u16 len; p80211pstr32_t data; -} __attribute__ ((packed)) p80211item_pstr32_t; +} __packed p80211item_pstr32_t; /* message data item for OCTETSTR, DISPLAYSTR */ typedef struct p80211item_pstr255 { @@ -307,7 +307,7 @@ typedef struct p80211item_pstr255 { u16 status; u16 len; p80211pstr255_t data; -} __attribute__ ((packed)) p80211item_pstr255_t; +} __packed p80211item_pstr255_t; /* message data item for UNK 392, namely mib items */ typedef struct p80211item_unk392 { @@ -315,7 +315,7 @@ typedef struct p80211item_unk392 { u16 status; u16 len; u8 data[MAXLEN_MIBATTRIBUTE]; -} __attribute__ ((packed)) p80211item_unk392_t; +} __packed p80211item_unk392_t; /* message data item for UNK 1025, namely p2 pdas */ typedef struct p80211item_unk1024 { @@ -323,7 +323,7 @@ typedef struct p80211item_unk1024 { u16 status; u16 len; u8 data[1024]; -} __attribute__ ((packed)) p80211item_unk1024_t; +} __packed p80211item_unk1024_t; /* message data item for UNK 4096, namely p2 download chunks */ typedef struct p80211item_unk4096 { @@ -331,7 +331,7 @@ typedef struct p80211item_unk4096 { u16 status; u16 len; u8 data[4096]; -} __attribute__ ((packed)) p80211item_unk4096_t; +} __packed p80211item_unk4096_t; struct catlistitem; @@ -340,11 +340,11 @@ struct catlistitem; /* metadata items. Some components may choose to use more, */ /* less or different metadata items. */ -typedef void (*p80211_totext_t) (struct catlistitem *, u32 did, u8 * itembuf, +typedef void (*p80211_totext_t) (struct catlistitem *, u32 did, u8 *itembuf, char *textbuf); -typedef void (*p80211_fromtext_t) (struct catlistitem *, u32 did, u8 * itembuf, +typedef void (*p80211_fromtext_t) (struct catlistitem *, u32 did, u8 *itembuf, char *textbuf); -typedef u32(*p80211_valid_t) (struct catlistitem *, u32 did, u8 * itembuf); +typedef u32(*p80211_valid_t) (struct catlistitem *, u32 did, u8 *itembuf); /*----------------------------------------------------------------*/ /* Enumeration Lists */ diff --git a/drivers/staging/wlan-ng/p80211wep.c b/drivers/staging/wlan-ng/p80211wep.c index ecbb15b297a..c4fabadf5d7 100644 --- a/drivers/staging/wlan-ng/p80211wep.c +++ b/drivers/staging/wlan-ng/p80211wep.c @@ -50,7 +50,6 @@ #include <linux/netdevice.h> #include <linux/wireless.h> -#include <linux/slab.h> #include <linux/random.h> #include <linux/kernel.h> @@ -135,10 +134,8 @@ int wep_change_key(wlandevice_t *wlandev, int keynum, u8 *key, int keylen) return -1; #ifdef WEP_DEBUG - printk(KERN_DEBUG - "WEP key %d len %d = %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n", - keynum, keylen, key[0], key[1], key[2], key[3], key[4], key[5], - key[6], key[7]); + pr_debug("WEP key %d len %d = %*phC\n", keynum, keylen, + 8, key); #endif wlandev->wep_keylens[keynum] = keylen; @@ -185,10 +182,8 @@ int wep_decrypt(wlandevice_t *wlandev, u8 *buf, u32 len, int key_override, keylen += 3; /* add in IV bytes */ #ifdef WEP_DEBUG - printk(KERN_DEBUG - "D %d: %02x %02x %02x (%d %d) %02x:%02x:%02x:%02x:%02x\n", len, - key[0], key[1], key[2], keyidx, keylen, key[3], key[4], key[5], - key[6], key[7]); + pr_debug("D %d: %*ph (%d %d) %*phC\n", len, 3, key, + keyidx, keylen, 5, key + 3); #endif /* set up the RC4 state */ @@ -264,10 +259,8 @@ int wep_encrypt(wlandevice_t *wlandev, u8 *buf, u8 *dst, u32 len, int keynum, keylen += 3; /* add in IV bytes */ #ifdef WEP_DEBUG - printk(KERN_DEBUG - "E %d (%d/%d %d) %02x %02x %02x %02x:%02x:%02x:%02x:%02x\n", len, - iv[3], keynum, keylen, key[0], key[1], key[2], key[3], key[4], - key[5], key[6], key[7]); + pr_debug("E %d (%d/%d %d) %*ph %*phC\n", len, + iv[3], keynum, keylen, 3, key, 5, key + 3); #endif /* set up the RC4 state */ diff --git a/drivers/staging/wlan-ng/p80211wext.c b/drivers/staging/wlan-ng/p80211wext.c deleted file mode 100644 index 74d8022adb2..00000000000 --- a/drivers/staging/wlan-ng/p80211wext.c +++ /dev/null @@ -1,1761 +0,0 @@ -/* src/p80211/p80211wext.c -* -* Glue code to make linux-wlan-ng a happy wireless extension camper. -* -* original author: Reyk Floeter <reyk@synack.de> -* Completely re-written by Solomon Peachy <solomon@linux-wlan.com> -* -* Copyright (C) 2002 AbsoluteValue Systems, Inc. All Rights Reserved. -* -------------------------------------------------------------------- -* -* linux-wlan -* -* The contents of this file are subject to the Mozilla Public -* License Version 1.1 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS -* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* Alternatively, the contents of this file may be used under the -* terms of the GNU Public License version 2 (the "GPL"), in which -* case the provisions of the GPL are applicable instead of the -* above. If you wish to allow the use of your version of this file -* only under the terms of the GPL and not to allow others to use -* your version of this file under the MPL, indicate your decision -* by deleting the provisions above and replace them with the notice -* and other provisions required by the GPL. If you do not delete -* the provisions above, a recipient may use your version of this -* file under either the MPL or the GPL. -* -* -------------------------------------------------------------------- -*/ - -/*================================================================*/ -/* System Includes */ - -#include <linux/kernel.h> -#include <linux/sched.h> -#include <linux/types.h> -#include <linux/slab.h> -#include <linux/netdevice.h> -#include <linux/etherdevice.h> -#include <linux/wireless.h> -#include <net/iw_handler.h> -#include <linux/if_arp.h> -#include <asm/bitops.h> -#include <asm/uaccess.h> -#include <asm/byteorder.h> -#include <linux/if_ether.h> -#include <linux/bitops.h> - -#include "p80211types.h" -#include "p80211hdr.h" -#include "p80211conv.h" -#include "p80211mgmt.h" -#include "p80211msg.h" -#include "p80211metastruct.h" -#include "p80211metadef.h" -#include "p80211netdev.h" -#include "p80211ioctl.h" -#include "p80211req.h" - -static int p80211wext_giwrate(netdevice_t *dev, - struct iw_request_info *info, - struct iw_param *rrq, char *extra); -static int p80211wext_giwessid(netdevice_t *dev, - struct iw_request_info *info, - struct iw_point *data, char *essid); - -static u8 p80211_mhz_to_channel(u16 mhz) -{ - if (mhz >= 5000) - return (mhz - 5000) / 5; - - if (mhz == 2482) - return 14; - - if (mhz >= 2407) - return (mhz - 2407) / 5; - - return 0; -} - -static u16 p80211_channel_to_mhz(u8 ch, int dot11a) -{ - - if (ch == 0) - return 0; - if (ch > 200) - return 0; - - /* 5G */ - if (dot11a) - return 5000 + (5 * ch); - - /* 2.4G */ - if (ch == 14) - return 2484; - - if ((ch < 14) && (ch > 0)) - return 2407 + (5 * ch); - - return 0; -} - -/* taken from orinoco.c ;-) */ -static const long p80211wext_channel_freq[] = { - 2412, 2417, 2422, 2427, 2432, 2437, 2442, - 2447, 2452, 2457, 2462, 2467, 2472, 2484 -}; - -#define NUM_CHANNELS ARRAY_SIZE(p80211wext_channel_freq) - -/* steal a spare bit to store the shared/opensystems state. - should default to open if not set */ -#define HOSTWEP_SHAREDKEY BIT(3) - -static int qual_as_percent(int snr) -{ - if (snr <= 0) - return 0; - if (snr <= 40) - return snr * 5 / 2; - return 100; -} - -static int p80211wext_dorequest(wlandevice_t *wlandev, u32 did, u32 data) -{ - p80211msg_dot11req_mibset_t msg; - p80211item_uint32_t mibitem; - int result; - - msg.msgcode = DIDmsg_dot11req_mibset; - mibitem.did = did; - mibitem.data = data; - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) & msg); - - return result; -} - -static int p80211wext_autojoin(wlandevice_t *wlandev) -{ - p80211msg_lnxreq_autojoin_t msg; - struct iw_point data; - char ssid[IW_ESSID_MAX_SIZE]; - - int result; - int err = 0; - - /* Get ESSID */ - result = p80211wext_giwessid(wlandev->netdev, NULL, &data, ssid); - - if (result) { - err = -EFAULT; - goto exit; - } - - if (wlandev->hostwep & HOSTWEP_SHAREDKEY) - msg.authtype.data = P80211ENUM_authalg_sharedkey; - else - msg.authtype.data = P80211ENUM_authalg_opensystem; - - msg.msgcode = DIDmsg_lnxreq_autojoin; - - /* Trim the last '\0' to fit the SSID format */ - - if (data.length && ssid[data.length - 1] == '\0') - data.length = data.length - 1; - - memcpy(msg.ssid.data.data, ssid, data.length); - msg.ssid.data.len = data.length; - - result = p80211req_dorequest(wlandev, (u8 *) & msg); - - if (result) { - err = -EFAULT; - goto exit; - } - -exit: - - return err; - -} - -/* called by /proc/net/wireless */ -struct iw_statistics *p80211wext_get_wireless_stats(netdevice_t *dev) -{ - p80211msg_lnxreq_commsquality_t quality; - wlandevice_t *wlandev = dev->ml_priv; - struct iw_statistics *wstats = &wlandev->wstats; - int retval; - - /* Check */ - if ((wlandev == NULL) || (wlandev->msdstate != WLAN_MSD_RUNNING)) - return NULL; - - /* XXX Only valid in station mode */ - wstats->status = 0; - - /* build request message */ - quality.msgcode = DIDmsg_lnxreq_commsquality; - quality.dbm.data = P80211ENUM_truth_true; - quality.dbm.status = P80211ENUM_msgitem_status_data_ok; - - /* send message to nsd */ - if (wlandev->mlmerequest == NULL) - return NULL; - - retval = wlandev->mlmerequest(wlandev, (p80211msg_t *) & quality); - - wstats->qual.qual = qual_as_percent(quality.link.data); /* overall link quality */ - wstats->qual.level = quality.level.data; /* instant signal level */ - wstats->qual.noise = quality.noise.data; /* instant noise level */ - - wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM; - wstats->discard.code = wlandev->rx.decrypt_err; - wstats->discard.nwid = 0; - wstats->discard.misc = 0; - - wstats->discard.fragment = 0; /* incomplete fragments */ - wstats->discard.retries = 0; /* tx retries. */ - wstats->miss.beacon = 0; - - return wstats; -} - -static int p80211wext_giwname(netdevice_t *dev, - struct iw_request_info *info, - char *name, char *extra) -{ - struct iw_param rate; - int result; - int err = 0; - - result = p80211wext_giwrate(dev, NULL, &rate, NULL); - - if (result) { - err = -EFAULT; - goto exit; - } - - switch (rate.value) { - case 1000000: - case 2000000: - strcpy(name, "IEEE 802.11-DS"); - break; - case 5500000: - case 11000000: - strcpy(name, "IEEE 802.11-b"); - break; - } -exit: - return err; -} - -static int p80211wext_giwfreq(netdevice_t *dev, - struct iw_request_info *info, - struct iw_freq *freq, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - p80211item_uint32_t mibitem; - p80211msg_dot11req_mibset_t msg; - int result; - int err = 0; - - msg.msgcode = DIDmsg_dot11req_mibget; - mibitem.did = DIDmib_dot11phy_dot11PhyDSSSTable_dot11CurrentChannel; - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) & msg); - - if (result) { - err = -EFAULT; - goto exit; - } - - memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem)); - - if (mibitem.data > NUM_CHANNELS) { - err = -EFAULT; - goto exit; - } - - /* convert into frequency instead of a channel */ - freq->e = 1; - freq->m = p80211_channel_to_mhz(mibitem.data, 0) * 100000; - -exit: - return err; -} - -static int p80211wext_siwfreq(netdevice_t *dev, - struct iw_request_info *info, - struct iw_freq *freq, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - p80211item_uint32_t mibitem; - p80211msg_dot11req_mibset_t msg; - int result; - int err = 0; - - if (!wlan_wext_write) { - err = (-EOPNOTSUPP); - goto exit; - } - - msg.msgcode = DIDmsg_dot11req_mibset; - mibitem.did = DIDmib_dot11phy_dot11PhyDSSSTable_dot11CurrentChannel; - mibitem.status = P80211ENUM_msgitem_status_data_ok; - - if ((freq->e == 0) && (freq->m <= 1000)) - mibitem.data = freq->m; - else - mibitem.data = p80211_mhz_to_channel(freq->m); - - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) & msg); - - if (result) { - err = -EFAULT; - goto exit; - } - -exit: - return err; -} - -static int p80211wext_giwmode(netdevice_t *dev, - struct iw_request_info *info, - __u32 *mode, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - - switch (wlandev->macmode) { - case WLAN_MACMODE_IBSS_STA: - *mode = IW_MODE_ADHOC; - break; - case WLAN_MACMODE_ESS_STA: - *mode = IW_MODE_INFRA; - break; - case WLAN_MACMODE_ESS_AP: - *mode = IW_MODE_MASTER; - break; - default: - /* Not set yet. */ - *mode = IW_MODE_AUTO; - } - - return 0; -} - -static int p80211wext_siwmode(netdevice_t *dev, - struct iw_request_info *info, - __u32 *mode, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - p80211item_uint32_t mibitem; - p80211msg_dot11req_mibset_t msg; - int result; - int err = 0; - - if (!wlan_wext_write) { - err = (-EOPNOTSUPP); - goto exit; - } - - if (*mode != IW_MODE_ADHOC && *mode != IW_MODE_INFRA && - *mode != IW_MODE_MASTER) { - err = (-EOPNOTSUPP); - goto exit; - } - - /* Operation mode is the same with current mode */ - if (*mode == wlandev->macmode) - goto exit; - - switch (*mode) { - case IW_MODE_ADHOC: - wlandev->macmode = WLAN_MACMODE_IBSS_STA; - break; - case IW_MODE_INFRA: - wlandev->macmode = WLAN_MACMODE_ESS_STA; - break; - case IW_MODE_MASTER: - wlandev->macmode = WLAN_MACMODE_ESS_AP; - break; - default: - /* Not set yet. */ - printk(KERN_INFO "Operation mode: %d not support\n", *mode); - return -EOPNOTSUPP; - } - - /* Set Operation mode to the PORT TYPE RID */ - msg.msgcode = DIDmsg_dot11req_mibset; - mibitem.did = DIDmib_p2_p2Static_p2CnfPortType; - mibitem.data = (*mode == IW_MODE_ADHOC) ? 0 : 1; - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) & msg); - - if (result) - err = -EFAULT; - -exit: - return err; -} - -static int p80211wext_giwrange(netdevice_t *dev, - struct iw_request_info *info, - struct iw_point *data, char *extra) -{ - struct iw_range *range = (struct iw_range *)extra; - int i, val; - - /* for backward compatability set size and zero everything we don't understand */ - data->length = sizeof(*range); - memset(range, 0, sizeof(*range)); - - range->txpower_capa = IW_TXPOW_DBM; - /* XXX what about min/max_pmp, min/max_pmt, etc. */ - - range->we_version_compiled = WIRELESS_EXT; - range->we_version_source = 13; - - range->retry_capa = IW_RETRY_LIMIT; - range->retry_flags = IW_RETRY_LIMIT; - range->min_retry = 0; - range->max_retry = 255; - - range->event_capa[0] = (IW_EVENT_CAPA_K_0 | /* mode/freq/ssid */ - IW_EVENT_CAPA_MASK(SIOCGIWAP) | - IW_EVENT_CAPA_MASK(SIOCGIWSCAN)); - range->event_capa[1] = IW_EVENT_CAPA_K_1; /* encode */ - range->event_capa[4] = (IW_EVENT_CAPA_MASK(IWEVQUAL) | - IW_EVENT_CAPA_MASK(IWEVCUSTOM)); - - range->num_channels = NUM_CHANNELS; - - /* XXX need to filter against the regulatory domain &| active set */ - val = 0; - for (i = 0; i < NUM_CHANNELS; i++) { - range->freq[val].i = i + 1; - range->freq[val].m = p80211wext_channel_freq[i] * 100000; - range->freq[val].e = 1; - val++; - } - - range->num_frequency = val; - - /* Max of /proc/net/wireless */ - range->max_qual.qual = 100; - range->max_qual.level = 0; - range->max_qual.noise = 0; - range->sensitivity = 3; - /* XXX these need to be nsd-specific! */ - - range->min_rts = 0; - range->max_rts = 2347; - range->min_frag = 256; - range->max_frag = 2346; - - range->max_encoding_tokens = NUM_WEPKEYS; - range->num_encoding_sizes = 2; - range->encoding_size[0] = 5; - range->encoding_size[1] = 13; - - /* XXX what about num_bitrates/throughput? */ - range->num_bitrates = 0; - - /* estimated max throughput */ - /* XXX need to cap it if we're running at ~2Mbps.. */ - range->throughput = 5500000; - - return 0; -} - -static int p80211wext_giwap(netdevice_t *dev, - struct iw_request_info *info, - struct sockaddr *ap_addr, char *extra) -{ - - wlandevice_t *wlandev = dev->ml_priv; - - memcpy(ap_addr->sa_data, wlandev->bssid, WLAN_BSSID_LEN); - ap_addr->sa_family = ARPHRD_ETHER; - - return 0; -} - -static int p80211wext_giwencode(netdevice_t *dev, - struct iw_request_info *info, - struct iw_point *erq, char *key) -{ - wlandevice_t *wlandev = dev->ml_priv; - int err = 0; - int i; - - i = (erq->flags & IW_ENCODE_INDEX) - 1; - erq->flags = 0; - - if (wlandev->hostwep & HOSTWEP_PRIVACYINVOKED) - erq->flags |= IW_ENCODE_ENABLED; - else - erq->flags |= IW_ENCODE_DISABLED; - - if (wlandev->hostwep & HOSTWEP_EXCLUDEUNENCRYPTED) - erq->flags |= IW_ENCODE_RESTRICTED; - else - erq->flags |= IW_ENCODE_OPEN; - - i = (erq->flags & IW_ENCODE_INDEX) - 1; - - if (i == -1) - i = wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK; - - if ((i < 0) || (i >= NUM_WEPKEYS)) { - err = -EINVAL; - goto exit; - } - - erq->flags |= i + 1; - - /* copy the key from the driver cache as the keys are read-only MIBs */ - erq->length = wlandev->wep_keylens[i]; - memcpy(key, wlandev->wep_keys[i], erq->length); - -exit: - return err; -} - -static int p80211wext_siwencode(netdevice_t *dev, - struct iw_request_info *info, - struct iw_point *erq, char *key) -{ - wlandevice_t *wlandev = dev->ml_priv; - p80211msg_dot11req_mibset_t msg; - p80211item_pstr32_t pstr; - - int err = 0; - int result = 0; - int i; - - if (!wlan_wext_write) { - err = (-EOPNOTSUPP); - goto exit; - } - - /* Check the Key index first. */ - if ((i = (erq->flags & IW_ENCODE_INDEX))) { - - if ((i < 1) || (i > NUM_WEPKEYS)) { - err = -EINVAL; - goto exit; - } else - i--; - - /* Set current key number only if no keys are given */ - if (erq->flags & IW_ENCODE_NOKEY) { - result = - p80211wext_dorequest(wlandev, - DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID, - i); - - if (result) { - err = -EFAULT; - goto exit; - } - } - - } else { - /* Use defaultkey if no Key Index */ - i = wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK; - } - - /* Check if there is no key information in the iwconfig request */ - if ((erq->flags & IW_ENCODE_NOKEY) == 0) { - - /*------------------------------------------------------------ - * If there is WEP Key for setting, check the Key Information - * and then set it to the firmware. - -------------------------------------------------------------*/ - - if (erq->length > 0) { - - /* copy the key from the driver cache as the keys are read-only MIBs */ - wlandev->wep_keylens[i] = erq->length; - memcpy(wlandev->wep_keys[i], key, erq->length); - - /* Prepare data struture for p80211req_dorequest. */ - memcpy(pstr.data.data, key, erq->length); - pstr.data.len = erq->length; - - switch (i) { - case 0: - pstr.did = - DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0; - break; - - case 1: - pstr.did = - DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1; - break; - - case 2: - pstr.did = - DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2; - break; - - case 3: - pstr.did = - DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3; - break; - - default: - err = -EINVAL; - goto exit; - } - - msg.msgcode = DIDmsg_dot11req_mibset; - memcpy(&msg.mibattribute.data, &pstr, sizeof(pstr)); - result = p80211req_dorequest(wlandev, (u8 *) & msg); - - if (result) { - err = -EFAULT; - goto exit; - } - } - - } - - /* Check the PrivacyInvoked flag */ - if (erq->flags & IW_ENCODE_DISABLED) { - result = - p80211wext_dorequest(wlandev, - DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked, - P80211ENUM_truth_false); - } else { - result = - p80211wext_dorequest(wlandev, - DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked, - P80211ENUM_truth_true); - } - - if (result) { - err = -EFAULT; - goto exit; - } - - /* The security mode may be open or restricted, and its meaning - depends on the card used. With most cards, in open mode no - authentication is used and the card may also accept non- - encrypted sessions, whereas in restricted mode only encrypted - sessions are accepted and the card will use authentication if - available. - */ - if (erq->flags & IW_ENCODE_RESTRICTED) { - result = - p80211wext_dorequest(wlandev, - DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted, - P80211ENUM_truth_true); - } else if (erq->flags & IW_ENCODE_OPEN) { - result = - p80211wext_dorequest(wlandev, - DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted, - P80211ENUM_truth_false); - } - - if (result) { - err = -EFAULT; - goto exit; - } - -exit: - - return err; -} - -static int p80211wext_giwessid(netdevice_t *dev, - struct iw_request_info *info, - struct iw_point *data, char *essid) -{ - wlandevice_t *wlandev = dev->ml_priv; - - if (wlandev->ssid.len) { - data->length = wlandev->ssid.len; - data->flags = 1; - memcpy(essid, wlandev->ssid.data, data->length); - essid[data->length] = 0; - } else { - memset(essid, 0, sizeof(wlandev->ssid.data)); - data->length = 0; - data->flags = 0; - } - - return 0; -} - -static int p80211wext_siwessid(netdevice_t *dev, - struct iw_request_info *info, - struct iw_point *data, char *essid) -{ - wlandevice_t *wlandev = dev->ml_priv; - p80211msg_lnxreq_autojoin_t msg; - - int result; - int err = 0; - int length = data->length; - - if (!wlan_wext_write) { - err = (-EOPNOTSUPP); - goto exit; - } - - if (wlandev->hostwep & HOSTWEP_SHAREDKEY) - msg.authtype.data = P80211ENUM_authalg_sharedkey; - else - msg.authtype.data = P80211ENUM_authalg_opensystem; - - msg.msgcode = DIDmsg_lnxreq_autojoin; - - /* Trim the last '\0' to fit the SSID format */ - if (length && essid[length - 1] == '\0') - length--; - - memcpy(msg.ssid.data.data, essid, length); - msg.ssid.data.len = length; - - pr_debug("autojoin_ssid for %s \n", essid); - result = p80211req_dorequest(wlandev, (u8 *) & msg); - pr_debug("autojoin_ssid %d\n", result); - - if (result) { - err = -EFAULT; - goto exit; - } - -exit: - return err; -} - -static int p80211wext_siwcommit(netdevice_t *dev, - struct iw_request_info *info, - struct iw_point *data, char *essid) -{ - wlandevice_t *wlandev = dev->ml_priv; - int err = 0; - - if (!wlan_wext_write) { - err = (-EOPNOTSUPP); - goto exit; - } - - /* Auto Join */ - err = p80211wext_autojoin(wlandev); - -exit: - return err; -} - -static int p80211wext_giwrate(netdevice_t *dev, - struct iw_request_info *info, - struct iw_param *rrq, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - p80211item_uint32_t mibitem; - p80211msg_dot11req_mibset_t msg; - int result; - int err = 0; - - msg.msgcode = DIDmsg_dot11req_mibget; - mibitem.did = DIDmib_p2_p2MAC_p2CurrentTxRate; - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) & msg); - - if (result) { - err = -EFAULT; - goto exit; - } - - memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem)); - - rrq->fixed = 0; /* can it change? */ - rrq->disabled = 0; - rrq->value = 0; - -#define HFA384x_RATEBIT_1 ((u16)1) -#define HFA384x_RATEBIT_2 ((u16)2) -#define HFA384x_RATEBIT_5dot5 ((u16)4) -#define HFA384x_RATEBIT_11 ((u16)8) - - switch (mibitem.data) { - case HFA384x_RATEBIT_1: - rrq->value = 1000000; - break; - case HFA384x_RATEBIT_2: - rrq->value = 2000000; - break; - case HFA384x_RATEBIT_5dot5: - rrq->value = 5500000; - break; - case HFA384x_RATEBIT_11: - rrq->value = 11000000; - break; - default: - err = -EINVAL; - } -exit: - return err; -} - -static int p80211wext_giwrts(netdevice_t *dev, - struct iw_request_info *info, - struct iw_param *rts, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - p80211item_uint32_t mibitem; - p80211msg_dot11req_mibset_t msg; - int result; - int err = 0; - - msg.msgcode = DIDmsg_dot11req_mibget; - mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11RTSThreshold; - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) & msg); - - if (result) { - err = -EFAULT; - goto exit; - } - - memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem)); - - rts->value = mibitem.data; - rts->disabled = (rts->value == 2347); - rts->fixed = 1; - -exit: - return err; -} - -static int p80211wext_siwrts(netdevice_t *dev, - struct iw_request_info *info, - struct iw_param *rts, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - p80211item_uint32_t mibitem; - p80211msg_dot11req_mibset_t msg; - int result; - int err = 0; - - if (!wlan_wext_write) { - err = (-EOPNOTSUPP); - goto exit; - } - - msg.msgcode = DIDmsg_dot11req_mibget; - mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11RTSThreshold; - if (rts->disabled) - mibitem.data = 2347; - else - mibitem.data = rts->value; - - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) & msg); - - if (result) { - err = -EFAULT; - goto exit; - } - -exit: - return err; -} - -static int p80211wext_giwfrag(netdevice_t *dev, - struct iw_request_info *info, - struct iw_param *frag, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - p80211item_uint32_t mibitem; - p80211msg_dot11req_mibset_t msg; - int result; - int err = 0; - - msg.msgcode = DIDmsg_dot11req_mibget; - mibitem.did = - DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold; - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) & msg); - - if (result) { - err = -EFAULT; - goto exit; - } - - memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem)); - - frag->value = mibitem.data; - frag->disabled = (frag->value == 2346); - frag->fixed = 1; - -exit: - return err; -} - -static int p80211wext_siwfrag(netdevice_t *dev, - struct iw_request_info *info, - struct iw_param *frag, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - p80211item_uint32_t mibitem; - p80211msg_dot11req_mibset_t msg; - int result; - int err = 0; - - if (!wlan_wext_write) { - err = (-EOPNOTSUPP); - goto exit; - } - - msg.msgcode = DIDmsg_dot11req_mibset; - mibitem.did = - DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold; - - if (frag->disabled) - mibitem.data = 2346; - else - mibitem.data = frag->value; - - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) & msg); - - if (result) { - err = -EFAULT; - goto exit; - } - -exit: - return err; -} - -#ifndef IW_RETRY_LONG -#define IW_RETRY_LONG IW_RETRY_MAX -#endif - -#ifndef IW_RETRY_SHORT -#define IW_RETRY_SHORT IW_RETRY_MIN -#endif - -static int p80211wext_giwretry(netdevice_t *dev, - struct iw_request_info *info, - struct iw_param *rrq, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - p80211item_uint32_t mibitem; - p80211msg_dot11req_mibset_t msg; - int result; - int err = 0; - u16 shortretry, longretry, lifetime; - - msg.msgcode = DIDmsg_dot11req_mibget; - mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11ShortRetryLimit; - - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) & msg); - - if (result) { - err = -EFAULT; - goto exit; - } - - memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem)); - - shortretry = mibitem.data; - - mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11LongRetryLimit; - - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) & msg); - - if (result) { - err = -EFAULT; - goto exit; - } - - memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem)); - - longretry = mibitem.data; - - mibitem.did = - DIDmib_dot11mac_dot11OperationTable_dot11MaxTransmitMSDULifetime; - - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) & msg); - - if (result) { - err = -EFAULT; - goto exit; - } - - memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem)); - - lifetime = mibitem.data; - - rrq->disabled = 0; - - if ((rrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) { - rrq->flags = IW_RETRY_LIFETIME; - rrq->value = lifetime * 1024; - } else { - if (rrq->flags & IW_RETRY_LONG) { - rrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG; - rrq->value = longretry; - } else { - rrq->flags = IW_RETRY_LIMIT; - rrq->value = shortretry; - if (shortretry != longretry) - rrq->flags |= IW_RETRY_SHORT; - } - } - -exit: - return err; - -} - -static int p80211wext_siwretry(netdevice_t *dev, - struct iw_request_info *info, - struct iw_param *rrq, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - p80211item_uint32_t mibitem; - p80211msg_dot11req_mibset_t msg; - int result; - int err = 0; - - if (!wlan_wext_write) { - err = (-EOPNOTSUPP); - goto exit; - } - - if (rrq->disabled) { - err = -EINVAL; - goto exit; - } - - msg.msgcode = DIDmsg_dot11req_mibset; - - if ((rrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) { - mibitem.did = - DIDmib_dot11mac_dot11OperationTable_dot11MaxTransmitMSDULifetime; - mibitem.data = rrq->value /= 1024; - - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) & msg); - - if (result) { - err = -EFAULT; - goto exit; - } - } else { - if (rrq->flags & IW_RETRY_LONG) { - mibitem.did = - DIDmib_dot11mac_dot11OperationTable_dot11LongRetryLimit; - mibitem.data = rrq->value; - - memcpy(&msg.mibattribute.data, &mibitem, - sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) & msg); - - if (result) { - err = -EFAULT; - goto exit; - } - } - - if (rrq->flags & IW_RETRY_SHORT) { - mibitem.did = - DIDmib_dot11mac_dot11OperationTable_dot11ShortRetryLimit; - mibitem.data = rrq->value; - - memcpy(&msg.mibattribute.data, &mibitem, - sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) & msg); - - if (result) { - err = -EFAULT; - goto exit; - } - } - } - -exit: - return err; - -} - -static int p80211wext_siwtxpow(netdevice_t *dev, - struct iw_request_info *info, - struct iw_param *rrq, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - p80211item_uint32_t mibitem; - p80211msg_dot11req_mibset_t msg; - int result; - int err = 0; - - if (!wlan_wext_write) { - err = (-EOPNOTSUPP); - goto exit; - } - - msg.msgcode = DIDmsg_dot11req_mibset; - mibitem.did = - DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel; - if (rrq->fixed == 0) - mibitem.data = 30; - else - mibitem.data = rrq->value; - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) & msg); - - if (result) { - err = -EFAULT; - goto exit; - } - -exit: - return err; -} - -static int p80211wext_giwtxpow(netdevice_t *dev, - struct iw_request_info *info, - struct iw_param *rrq, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - p80211item_uint32_t mibitem; - p80211msg_dot11req_mibset_t msg; - int result; - int err = 0; - - msg.msgcode = DIDmsg_dot11req_mibget; - mibitem.did = - DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel; - - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) & msg); - - if (result) { - err = -EFAULT; - goto exit; - } - - memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem)); - - /* XXX handle OFF by setting disabled = 1; */ - - rrq->flags = 0; /* IW_TXPOW_DBM; */ - rrq->disabled = 0; - rrq->fixed = 0; - rrq->value = mibitem.data; - -exit: - return err; -} - -static int p80211wext_siwspy(netdevice_t *dev, - struct iw_request_info *info, - struct iw_point *srq, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - struct sockaddr address[IW_MAX_SPY]; - int number = srq->length; - int i; - - /* Copy the data from the input buffer */ - memcpy(address, extra, sizeof(struct sockaddr) * number); - - wlandev->spy_number = 0; - - if (number > 0) { - - /* extract the addresses */ - for (i = 0; i < number; i++) { - - memcpy(wlandev->spy_address[i], address[i].sa_data, - ETH_ALEN); - } - - /* reset stats */ - memset(wlandev->spy_stat, 0, - sizeof(struct iw_quality) * IW_MAX_SPY); - - /* set number of addresses */ - wlandev->spy_number = number; - } - - return 0; -} - -/* jkriegl: from orinoco, modified */ -static int p80211wext_giwspy(netdevice_t *dev, - struct iw_request_info *info, - struct iw_point *srq, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - - struct sockaddr address[IW_MAX_SPY]; - struct iw_quality spy_stat[IW_MAX_SPY]; - int number; - int i; - - number = wlandev->spy_number; - - if (number > 0) { - - /* populate address and spy struct's */ - for (i = 0; i < number; i++) { - memcpy(address[i].sa_data, wlandev->spy_address[i], - ETH_ALEN); - address[i].sa_family = AF_UNIX; - memcpy(&spy_stat[i], &wlandev->spy_stat[i], - sizeof(struct iw_quality)); - } - - /* reset update flag */ - for (i = 0; i < number; i++) - wlandev->spy_stat[i].updated = 0; - } - - /* push stuff to user space */ - srq->length = number; - memcpy(extra, address, sizeof(struct sockaddr) * number); - memcpy(extra + sizeof(struct sockaddr) * number, spy_stat, - sizeof(struct iw_quality) * number); - - return 0; -} - -static int prism2_result2err(int prism2_result) -{ - int err = 0; - - switch (prism2_result) { - case P80211ENUM_resultcode_invalid_parameters: - err = -EINVAL; - break; - case P80211ENUM_resultcode_implementation_failure: - err = -EIO; - break; - case P80211ENUM_resultcode_not_supported: - err = -EOPNOTSUPP; - break; - default: - err = 0; - break; - } - - return err; -} - -static int p80211wext_siwscan(netdevice_t *dev, - struct iw_request_info *info, - struct iw_point *srq, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - p80211msg_dot11req_scan_t msg; - int result; - int err = 0; - int i = 0; - - if (wlandev->macmode == WLAN_MACMODE_ESS_AP) { - printk(KERN_ERR "Can't scan in AP mode\n"); - err = (-EOPNOTSUPP); - goto exit; - } - - memset(&msg, 0x00, sizeof(p80211msg_dot11req_scan_t)); - msg.msgcode = DIDmsg_dot11req_scan; - msg.bsstype.data = P80211ENUM_bsstype_any; - - memset(&(msg.bssid.data), 0xFF, sizeof(p80211item_pstr6_t)); - msg.bssid.data.len = 6; - - msg.scantype.data = P80211ENUM_scantype_active; - msg.probedelay.data = 0; - - for (i = 1; i <= 14; i++) - msg.channellist.data.data[i - 1] = i; - msg.channellist.data.len = 14; - - msg.maxchanneltime.data = 250; - msg.minchanneltime.data = 200; - - result = p80211req_dorequest(wlandev, (u8 *) & msg); - if (result) - err = prism2_result2err(msg.resultcode.data); - -exit: - return err; -} - -/* Helper to translate scan into Wireless Extensions scan results. - * Inspired by the prism54 code, which was in turn inspired by the - * airo driver code. - */ -static char *wext_translate_bss(struct iw_request_info *info, char *current_ev, - char *end_buf, - p80211msg_dot11req_scan_results_t *bss) -{ - struct iw_event iwe; /* Temporary buffer */ - - /* The first entry must be the MAC address */ - memcpy(iwe.u.ap_addr.sa_data, bss->bssid.data.data, WLAN_BSSID_LEN); - iwe.u.ap_addr.sa_family = ARPHRD_ETHER; - iwe.cmd = SIOCGIWAP; - current_ev = - iwe_stream_add_event(info, current_ev, end_buf, &iwe, - IW_EV_ADDR_LEN); - - /* The following entries will be displayed in the same order we give them */ - - /* The ESSID. */ - if (bss->ssid.data.len > 0) { - char essid[IW_ESSID_MAX_SIZE + 1]; - int size; - - size = - min_t(unsigned short, IW_ESSID_MAX_SIZE, - bss->ssid.data.len); - memset(&essid, 0, sizeof(essid)); - memcpy(&essid, bss->ssid.data.data, size); - pr_debug(" essid size = %d\n", size); - iwe.u.data.length = size; - iwe.u.data.flags = 1; - iwe.cmd = SIOCGIWESSID; - current_ev = - iwe_stream_add_point(info, current_ev, end_buf, &iwe, - &essid[0]); - pr_debug(" essid size OK.\n"); - } - - switch (bss->bsstype.data) { - case P80211ENUM_bsstype_infrastructure: - iwe.u.mode = IW_MODE_MASTER; - break; - - case P80211ENUM_bsstype_independent: - iwe.u.mode = IW_MODE_ADHOC; - break; - - default: - iwe.u.mode = 0; - break; - } - iwe.cmd = SIOCGIWMODE; - if (iwe.u.mode) - current_ev = - iwe_stream_add_event(info, current_ev, end_buf, &iwe, - IW_EV_UINT_LEN); - - /* Encryption capability */ - if (bss->privacy.data == P80211ENUM_truth_true) - iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; - else - iwe.u.data.flags = IW_ENCODE_DISABLED; - iwe.u.data.length = 0; - iwe.cmd = SIOCGIWENCODE; - current_ev = - iwe_stream_add_point(info, current_ev, end_buf, &iwe, NULL); - - /* Add frequency. (short) bss->channel is the frequency in MHz */ - iwe.u.freq.m = bss->dschannel.data; - iwe.u.freq.e = 0; - iwe.cmd = SIOCGIWFREQ; - current_ev = - iwe_stream_add_event(info, current_ev, end_buf, &iwe, - IW_EV_FREQ_LEN); - - /* Add quality statistics */ - iwe.u.qual.level = bss->signal.data; - iwe.u.qual.noise = bss->noise.data; - /* do a simple SNR for quality */ - iwe.u.qual.qual = qual_as_percent(bss->signal.data - bss->noise.data); - iwe.cmd = IWEVQUAL; - current_ev = - iwe_stream_add_event(info, current_ev, end_buf, &iwe, - IW_EV_QUAL_LEN); - - return current_ev; -} - -static int p80211wext_giwscan(netdevice_t *dev, - struct iw_request_info *info, - struct iw_point *srq, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - p80211msg_dot11req_scan_results_t msg; - int result = 0; - int err = 0; - int i = 0; - int scan_good = 0; - char *current_ev = extra; - - /* Since wireless tools doesn't really have a way of passing how - * many scan results results there were back here, keep grabbing them - * until we fail. - */ - do { - memset(&msg, 0, sizeof(msg)); - msg.msgcode = DIDmsg_dot11req_scan_results; - msg.bssindex.data = i; - - result = p80211req_dorequest(wlandev, (u8 *) & msg); - if ((result != 0) || - (msg.resultcode.data != P80211ENUM_resultcode_success)) { - break; - } - - current_ev = - wext_translate_bss(info, current_ev, - extra + IW_SCAN_MAX_DATA, &msg); - scan_good = 1; - i++; - } while (i < IW_MAX_AP); - - srq->length = (current_ev - extra); - srq->flags = 0; /* todo */ - - if (result && !scan_good) - err = prism2_result2err(msg.resultcode.data); - - return err; -} - -/* extra wireless extensions stuff to support NetworkManager (I hope) */ - -/* SIOCSIWENCODEEXT */ -static int p80211wext_set_encodeext(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; - p80211msg_dot11req_mibset_t msg; - p80211item_pstr32_t *pstr; - - int result = 0; - struct iw_point *encoding = &wrqu->encoding; - int idx = encoding->flags & IW_ENCODE_INDEX; - - pr_debug("set_encode_ext flags[%d] alg[%d] keylen[%d]\n", - ext->ext_flags, (int)ext->alg, (int)ext->key_len); - - if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) { - /* set default key ? I'm not sure if this the the correct thing to do here */ - - if (idx) { - if (idx < 1 || idx > NUM_WEPKEYS) - return -EINVAL; - else - idx--; - } - pr_debug("setting default key (%d)\n", idx); - result = - p80211wext_dorequest(wlandev, - DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID, - idx); - if (result) - return -EFAULT; - } - - if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) { - if (ext->alg != IW_ENCODE_ALG_WEP) { - pr_debug("asked to set a non wep key :(\n"); - return -EINVAL; - } - if (idx) { - if (idx < 1 || idx > NUM_WEPKEYS) - return -EINVAL; - else - idx--; - } - pr_debug("Set WEP key (%d)\n", idx); - wlandev->wep_keylens[idx] = ext->key_len; - memcpy(wlandev->wep_keys[idx], ext->key, ext->key_len); - - memset(&msg, 0, sizeof(msg)); - pstr = (p80211item_pstr32_t *) & msg.mibattribute.data; - memcpy(pstr->data.data, ext->key, ext->key_len); - pstr->data.len = ext->key_len; - switch (idx) { - case 0: - pstr->did = - DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0; - break; - case 1: - pstr->did = - DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1; - break; - case 2: - pstr->did = - DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2; - break; - case 3: - pstr->did = - DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3; - break; - default: - break; - } - msg.msgcode = DIDmsg_dot11req_mibset; - result = p80211req_dorequest(wlandev, (u8 *) & msg); - pr_debug("result (%d)\n", result); - } - return result; -} - -/* SIOCGIWENCODEEXT */ -static int p80211wext_get_encodeext(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; - - struct iw_point *encoding = &wrqu->encoding; - int result = 0; - int max_len; - int idx; - - pr_debug("get_encode_ext flags[%d] alg[%d] keylen[%d]\n", - ext->ext_flags, (int)ext->alg, (int)ext->key_len); - - max_len = encoding->length - sizeof(*ext); - if (max_len <= 0) { - pr_debug("get_encodeext max_len [%d] invalid\n", max_len); - result = -EINVAL; - goto exit; - } - idx = encoding->flags & IW_ENCODE_INDEX; - - pr_debug("get_encode_ext index [%d]\n", idx); - - if (idx) { - if (idx < 1 || idx > NUM_WEPKEYS) { - pr_debug("get_encode_ext invalid key index [%d]\n", - idx); - result = -EINVAL; - goto exit; - } - idx--; - } else { - /* default key ? not sure what to do */ - /* will just use key[0] for now ! FIX ME */ - } - - encoding->flags = idx + 1; - memset(ext, 0, sizeof(*ext)); - - ext->alg = IW_ENCODE_ALG_WEP; - ext->key_len = wlandev->wep_keylens[idx]; - memcpy(ext->key, wlandev->wep_keys[idx], ext->key_len); - - encoding->flags |= IW_ENCODE_ENABLED; -exit: - return result; -} - -/* SIOCSIWAUTH */ -static int p80211_wext_set_iwauth(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - struct iw_param *param = &wrqu->param; - int result = 0; - - pr_debug("set_iwauth flags[%d]\n", (int)param->flags & IW_AUTH_INDEX); - - switch (param->flags & IW_AUTH_INDEX) { - case IW_AUTH_DROP_UNENCRYPTED: - pr_debug("drop_unencrypted %d\n", param->value); - if (param->value) - result = - p80211wext_dorequest(wlandev, - DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted, - P80211ENUM_truth_true); - else - result = - p80211wext_dorequest(wlandev, - DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted, - P80211ENUM_truth_false); - break; - - case IW_AUTH_PRIVACY_INVOKED: - pr_debug("privacy invoked %d\n", param->value); - if (param->value) - result = - p80211wext_dorequest(wlandev, - DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked, - P80211ENUM_truth_true); - else - result = - p80211wext_dorequest(wlandev, - DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked, - P80211ENUM_truth_false); - - break; - - case IW_AUTH_80211_AUTH_ALG: - if (param->value & IW_AUTH_ALG_OPEN_SYSTEM) { - pr_debug("set open_system\n"); - wlandev->hostwep &= ~HOSTWEP_SHAREDKEY; - } else if (param->value & IW_AUTH_ALG_SHARED_KEY) { - pr_debug("set shared key\n"); - wlandev->hostwep |= HOSTWEP_SHAREDKEY; - } else { - /* don't know what to do know */ - pr_debug("unknown AUTH_ALG (%d)\n", param->value); - result = -EINVAL; - } - break; - - default: - break; - } - - return result; -} - -/* SIOCSIWAUTH */ -static int p80211_wext_get_iwauth(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - struct iw_param *param = &wrqu->param; - int result = 0; - - pr_debug("get_iwauth flags[%d]\n", (int)param->flags & IW_AUTH_INDEX); - - switch (param->flags & IW_AUTH_INDEX) { - case IW_AUTH_DROP_UNENCRYPTED: - param->value = - wlandev->hostwep & HOSTWEP_EXCLUDEUNENCRYPTED ? 1 : 0; - break; - - case IW_AUTH_PRIVACY_INVOKED: - param->value = - wlandev->hostwep & HOSTWEP_PRIVACYINVOKED ? 1 : 0; - break; - - case IW_AUTH_80211_AUTH_ALG: - param->value = - wlandev->hostwep & HOSTWEP_SHAREDKEY ? - IW_AUTH_ALG_SHARED_KEY : IW_AUTH_ALG_OPEN_SYSTEM; - break; - - default: - break; - } - - return result; -} - -static iw_handler p80211wext_handlers[] = { - (iw_handler) p80211wext_siwcommit, /* SIOCSIWCOMMIT */ - (iw_handler) p80211wext_giwname, /* SIOCGIWNAME */ - (iw_handler) NULL, /* SIOCSIWNWID */ - (iw_handler) NULL, /* SIOCGIWNWID */ - (iw_handler) p80211wext_siwfreq, /* SIOCSIWFREQ */ - (iw_handler) p80211wext_giwfreq, /* SIOCGIWFREQ */ - (iw_handler) p80211wext_siwmode, /* SIOCSIWMODE */ - (iw_handler) p80211wext_giwmode, /* SIOCGIWMODE */ - (iw_handler) NULL, /* SIOCSIWSENS */ - (iw_handler) NULL, /* SIOCGIWSENS */ - (iw_handler) NULL, /* not used *//* SIOCSIWRANGE */ - (iw_handler) p80211wext_giwrange, /* SIOCGIWRANGE */ - (iw_handler) NULL, /* not used *//* SIOCSIWPRIV */ - (iw_handler) NULL, /* kernel code *//* SIOCGIWPRIV */ - (iw_handler) NULL, /* not used *//* SIOCSIWSTATS */ - (iw_handler) NULL, /* kernel code *//* SIOCGIWSTATS */ - (iw_handler) p80211wext_siwspy, /* SIOCSIWSPY */ - (iw_handler) p80211wext_giwspy, /* SIOCGIWSPY */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) NULL, /* SIOCSIWAP */ - (iw_handler) p80211wext_giwap, /* SIOCGIWAP */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) NULL, /* SIOCGIWAPLIST */ - (iw_handler) p80211wext_siwscan, /* SIOCSIWSCAN */ - (iw_handler) p80211wext_giwscan, /* SIOCGIWSCAN */ - (iw_handler) p80211wext_siwessid, /* SIOCSIWESSID */ - (iw_handler) p80211wext_giwessid, /* SIOCGIWESSID */ - (iw_handler) NULL, /* SIOCSIWNICKN */ - (iw_handler) p80211wext_giwessid, /* SIOCGIWNICKN */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) NULL, /* SIOCSIWRATE */ - (iw_handler) p80211wext_giwrate, /* SIOCGIWRATE */ - (iw_handler) p80211wext_siwrts, /* SIOCSIWRTS */ - (iw_handler) p80211wext_giwrts, /* SIOCGIWRTS */ - (iw_handler) p80211wext_siwfrag, /* SIOCSIWFRAG */ - (iw_handler) p80211wext_giwfrag, /* SIOCGIWFRAG */ - (iw_handler) p80211wext_siwtxpow, /* SIOCSIWTXPOW */ - (iw_handler) p80211wext_giwtxpow, /* SIOCGIWTXPOW */ - (iw_handler) p80211wext_siwretry, /* SIOCSIWRETRY */ - (iw_handler) p80211wext_giwretry, /* SIOCGIWRETRY */ - (iw_handler) p80211wext_siwencode, /* SIOCSIWENCODE */ - (iw_handler) p80211wext_giwencode, /* SIOCGIWENCODE */ - (iw_handler) NULL, /* SIOCSIWPOWER */ - (iw_handler) NULL, /* SIOCGIWPOWER */ -/* WPA operations */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) NULL, /* SIOCSIWGENIE set generic IE */ - (iw_handler) NULL, /* SIOCGIWGENIE get generic IE */ - (iw_handler) p80211_wext_set_iwauth, /* SIOCSIWAUTH set authentication mode params */ - (iw_handler) p80211_wext_get_iwauth, /* SIOCGIWAUTH get authentication mode params */ - - (iw_handler) p80211wext_set_encodeext, /* SIOCSIWENCODEEXT set encoding token & mode */ - (iw_handler) p80211wext_get_encodeext, /* SIOCGIWENCODEEXT get encoding token & mode */ - (iw_handler) NULL, /* SIOCSIWPMKSA PMKSA cache operation */ -}; - -struct iw_handler_def p80211wext_handler_def = { - .num_standard = ARRAY_SIZE(p80211wext_handlers), - .num_private = 0, - .num_private_args = 0, - .standard = p80211wext_handlers, - .private = NULL, - .private_args = NULL, - .get_wireless_stats = p80211wext_get_wireless_stats -}; - -int p80211wext_event_associated(wlandevice_t * wlandev, int assoc) -{ - union iwreq_data data; - - /* Send the association state first */ - data.ap_addr.sa_family = ARPHRD_ETHER; - if (assoc) - memcpy(data.ap_addr.sa_data, wlandev->bssid, ETH_ALEN); - else - memset(data.ap_addr.sa_data, 0, ETH_ALEN); - - if (wlan_wext_write) - wireless_send_event(wlandev->netdev, SIOCGIWAP, &data, NULL); - - if (!assoc) - goto done; - - /* XXX send association data, like IEs, etc etc. */ - -done: - return 0; -} diff --git a/drivers/staging/wlan-ng/prism2fw.c b/drivers/staging/wlan-ng/prism2fw.c index aaa70ed5771..f7870355c69 100644 --- a/drivers/staging/wlan-ng/prism2fw.c +++ b/drivers/staging/wlan-ng/prism2fw.c @@ -48,11 +48,13 @@ /*================================================================*/ /* System Includes */ #include <linux/ihex.h> +#include <linux/slab.h> /*================================================================*/ /* Local Constants */ #define PRISM2_USB_FWFILE "prism2_ru.fw" +MODULE_FIRMWARE(PRISM2_USB_FWFILE); #define S3DATA_MAX 5000 #define S3PLUG_MAX 200 @@ -71,26 +73,26 @@ /*================================================================*/ /* Local Types */ -typedef struct s3datarec { +struct s3datarec { u32 len; u32 addr; u8 checksum; u8 *data; -} s3datarec_t; +}; -typedef struct s3plugrec { +struct s3plugrec { u32 itemcode; u32 addr; u32 len; -} s3plugrec_t; +}; -typedef struct s3crcrec { +struct s3crcrec { u32 addr; u32 len; unsigned int dowrite; -} s3crcrec_t; +}; -typedef struct s3inforec { +struct s3inforec { u16 len; u16 type; union { @@ -99,20 +101,20 @@ typedef struct s3inforec { u16 buildseq; hfa384x_compident_t platform; } info; -} s3inforec_t; +}; -typedef struct pda { +struct pda { u8 buf[HFA384x_PDA_LEN_MAX]; hfa384x_pdrec_t *rec[HFA384x_PDA_RECS_MAX]; unsigned int nrec; -} pda_t; +}; -typedef struct imgchunk { - u32 addr; /* start address */ - u32 len; /* in bytes */ - u16 crc; /* CRC value (if it falls at a chunk boundary) */ +struct imgchunk { + u32 addr; /* start address */ + u32 len; /* in bytes */ + u16 crc; /* CRC value (if it falls at a chunk boundary) */ u8 *data; -} imgchunk_t; +}; /*================================================================*/ /* Local Static Definitions */ @@ -121,27 +123,27 @@ typedef struct imgchunk { /* s-record image processing */ /* Data records */ -unsigned int ns3data; -s3datarec_t s3data[S3DATA_MAX]; +static unsigned int ns3data; +static struct s3datarec s3data[S3DATA_MAX]; /* Plug records */ -unsigned int ns3plug; -s3plugrec_t s3plug[S3PLUG_MAX]; +static unsigned int ns3plug; +static struct s3plugrec s3plug[S3PLUG_MAX]; /* CRC records */ -unsigned int ns3crc; -s3crcrec_t s3crc[S3CRC_MAX]; +static unsigned int ns3crc; +static struct s3crcrec s3crc[S3CRC_MAX]; /* Info records */ -unsigned int ns3info; -s3inforec_t s3info[S3INFO_MAX]; +static unsigned int ns3info; +static struct s3inforec s3info[S3INFO_MAX]; /* S7 record (there _better_ be only one) */ -u32 startaddr; +static u32 startaddr; /* Load image chunks */ -unsigned int nfchunks; -imgchunk_t fchunk[CHUNKS_MAX]; +static unsigned int nfchunks; +static struct imgchunk fchunk[CHUNKS_MAX]; /* Note that for the following pdrec_t arrays, the len and code */ /* fields are stored in HOST byte order. The mkpdrlist() function */ @@ -149,30 +151,39 @@ imgchunk_t fchunk[CHUNKS_MAX]; /*----------------------------------------------------------------*/ /* PDA, built from [card|newfile]+[addfile1+addfile2...] */ -pda_t pda; -hfa384x_compident_t nicid; -hfa384x_caplevel_t rfid; -hfa384x_caplevel_t macid; -hfa384x_caplevel_t priid; +static struct pda pda; +static hfa384x_compident_t nicid; +static hfa384x_caplevel_t rfid; +static hfa384x_caplevel_t macid; +static hfa384x_caplevel_t priid; /*================================================================*/ /* Local Function Declarations */ -int prism2_fwapply(const struct ihex_binrec *rfptr, wlandevice_t *wlandev); -int read_fwfile(const struct ihex_binrec *rfptr); -int mkimage(imgchunk_t *clist, unsigned int *ccnt); -int read_cardpda(pda_t *pda, wlandevice_t *wlandev); -int mkpdrlist(pda_t *pda); -int plugimage(imgchunk_t *fchunk, unsigned int nfchunks, - s3plugrec_t *s3plug, unsigned int ns3plug, pda_t * pda); -int crcimage(imgchunk_t *fchunk, unsigned int nfchunks, - s3crcrec_t *s3crc, unsigned int ns3crc); -int writeimage(wlandevice_t *wlandev, imgchunk_t *fchunk, +static int prism2_fwapply(const struct ihex_binrec *rfptr, +wlandevice_t *wlandev); + +static int read_fwfile(const struct ihex_binrec *rfptr); + +static int mkimage(struct imgchunk *clist, unsigned int *ccnt); + +static int read_cardpda(struct pda *pda, wlandevice_t *wlandev); + +static int mkpdrlist(struct pda *pda); + +static int plugimage(struct imgchunk *fchunk, unsigned int nfchunks, + struct s3plugrec *s3plug, unsigned int ns3plug, struct pda *pda); + +static int crcimage(struct imgchunk *fchunk, unsigned int nfchunks, + struct s3crcrec *s3crc, unsigned int ns3crc); + +static int writeimage(wlandevice_t *wlandev, struct imgchunk *fchunk, unsigned int nfchunks); -void free_chunks(imgchunk_t *fchunk, unsigned int *nfchunks); -void free_srecs(void); +static void free_chunks(struct imgchunk *fchunk, unsigned int *nfchunks); + +static void free_srecs(void); -int validate_identity(void); +static int validate_identity(void); /*================================================================*/ /* Function Definitions */ @@ -190,22 +201,24 @@ int validate_identity(void); * 0 - success * ~0 - failure ----------------------------------------------------------------*/ -int prism2_fwtry(struct usb_device *udev, wlandevice_t *wlandev) +static int prism2_fwtry(struct usb_device *udev, wlandevice_t *wlandev) { const struct firmware *fw_entry = NULL; - printk(KERN_INFO "prism2_usb: Checking for firmware %s\n", + netdev_info(wlandev->netdev, "prism2_usb: Checking for firmware %s\n", PRISM2_USB_FWFILE); - if (request_ihex_firmware(&fw_entry, PRISM2_USB_FWFILE, &udev->dev) != 0) { - printk(KERN_INFO + if (request_ihex_firmware(&fw_entry, + PRISM2_USB_FWFILE, &udev->dev) != 0) { + netdev_info(wlandev->netdev, "prism2_usb: Firmware not available, but not essential\n"); - printk(KERN_INFO + netdev_info(wlandev->netdev, "prism2_usb: can continue to use card anyway.\n"); return 1; } - printk(KERN_INFO "prism2_usb: %s will be processed, size %d\n", - PRISM2_USB_FWFILE, fw_entry->size); + netdev_info(wlandev->netdev, + "prism2_usb: %s will be processed, size %zu\n", + PRISM2_USB_FWFILE, fw_entry->size); prism2_fwapply((const struct ihex_binrec *)fw_entry->data, wlandev); release_firmware(fw_entry); @@ -225,10 +238,10 @@ int prism2_fwtry(struct usb_device *udev, wlandevice_t *wlandev) * 0 - success * ~0 - failure ----------------------------------------------------------------*/ -int prism2_fwapply(const struct ihex_binrec *rfptr, wlandevice_t *wlandev) +static int prism2_fwapply(const struct ihex_binrec *rfptr, wlandevice_t *wlandev) { signed int result = 0; - p80211msg_dot11req_mibget_t getmsg; + struct p80211msg_dot11req_mibget getmsg; p80211itemd_t *item; u32 *data; @@ -253,7 +266,7 @@ int prism2_fwapply(const struct ihex_binrec *rfptr, wlandevice_t *wlandev) /* clear the pda and add an initial END record */ memset(&pda, 0, sizeof(pda)); pda.rec[0] = (hfa384x_pdrec_t *) pda.buf; - pda.rec[0]->len = cpu_to_le16(2); /* len in words *//* len in words */ + pda.rec[0]->len = cpu_to_le16(2); /* len in words */ pda.rec[0]->code = cpu_to_le16(HFA384x_PDR_END_OF_PDA); pda.nrec = 1; @@ -263,8 +276,8 @@ int prism2_fwapply(const struct ihex_binrec *rfptr, wlandevice_t *wlandev) /* Build the PDA we're going to use. */ if (read_cardpda(&pda, wlandev)) { - printk(KERN_ERR "load_cardpda failed, exiting.\n"); - return (1); + netdev_err(wlandev->netdev, "load_cardpda failed, exiting.\n"); + return 1; } /* read the card's PRI-SUP */ @@ -286,9 +299,8 @@ int prism2_fwapply(const struct ihex_binrec *rfptr, wlandevice_t *wlandev) /* DIDmsg_dot11req_mibget */ prism2mgmt_mibset_mibget(wlandev, &getmsg); - if (getmsg.resultcode.data != P80211ENUM_resultcode_success) { - printk(KERN_ERR "Couldn't fetch PRI-SUP info\n"); - } + if (getmsg.resultcode.data != P80211ENUM_resultcode_success) + netdev_err(wlandev->netdev, "Couldn't fetch PRI-SUP info\n"); /* Already in host order */ priid.role = *data++; @@ -300,20 +312,22 @@ int prism2_fwapply(const struct ihex_binrec *rfptr, wlandevice_t *wlandev) /* Read the S3 file */ result = read_fwfile(rfptr); if (result) { - printk(KERN_ERR "Failed to read the data exiting.\n"); - return (1); + netdev_err(wlandev->netdev, + "Failed to read the data exiting.\n"); + return 1; } result = validate_identity(); if (result) { - printk(KERN_ERR "Incompatible firmware image.\n"); - return (1); + netdev_err(wlandev->netdev, "Incompatible firmware image.\n"); + return 1; } if (startaddr == 0x00000000) { - printk(KERN_ERR "Can't RAM download a Flash image!\n"); - return (1); + netdev_err(wlandev->netdev, + "Can't RAM download a Flash image!\n"); + return 1; } /* Make the image chunks */ @@ -322,28 +336,28 @@ int prism2_fwapply(const struct ihex_binrec *rfptr, wlandevice_t *wlandev) /* Do any plugging */ result = plugimage(fchunk, nfchunks, s3plug, ns3plug, &pda); if (result) { - printk(KERN_ERR "Failed to plug data.\n"); - return (1); + netdev_err(wlandev->netdev, "Failed to plug data.\n"); + return 1; } /* Insert any CRCs */ if (crcimage(fchunk, nfchunks, s3crc, ns3crc)) { - printk(KERN_ERR "Failed to insert all CRCs\n"); - return (1); + netdev_err(wlandev->netdev, "Failed to insert all CRCs\n"); + return 1; } /* Write the image */ result = writeimage(wlandev, fchunk, nfchunks); if (result) { - printk(KERN_ERR "Failed to ramwrite image data.\n"); - return (1); + netdev_err(wlandev->netdev, "Failed to ramwrite image data.\n"); + return 1; } /* clear any allocated memory */ free_chunks(fchunk, &nfchunks); free_srecs(); - printk(KERN_INFO "prism2_usb: firmware loading finished.\n"); + netdev_info(wlandev->netdev, "prism2_usb: firmware loading finished.\n"); return result; } @@ -365,8 +379,8 @@ int prism2_fwapply(const struct ihex_binrec *rfptr, wlandevice_t *wlandev) * 0 success * ~0 failure ----------------------------------------------------------------*/ -int crcimage(imgchunk_t *fchunk, unsigned int nfchunks, s3crcrec_t *s3crc, - unsigned int ns3crc) +static int crcimage(struct imgchunk *fchunk, unsigned int nfchunks, + struct s3crcrec *s3crc, unsigned int ns3crc) { int result = 0; int i; @@ -387,21 +401,19 @@ int crcimage(imgchunk_t *fchunk, unsigned int nfchunks, s3crcrec_t *s3crc, for (c = 0; c < nfchunks; c++) { cstart = fchunk[c].addr; cend = fchunk[c].addr + fchunk[c].len; - /* the line below does an address & len match search */ - /* unfortunately, I've found that the len fields of */ - /* some crc records don't match with the length of */ - /* the actual data, so we're not checking right */ - /* now */ - /* if ( crcstart-2 >= cstart && crcend <= cend ) break; */ + /* the line below does an address & len match search */ + /* unfortunately, I've found that the len fields of */ + /* some crc records don't match with the length of */ + /* the actual data, so we're not checking right now */ + /* if (crcstart-2 >= cstart && crcend <= cend) break; */ /* note the -2 below, it's to make sure the chunk has */ - /* space for the CRC value */ + /* space for the CRC value */ if (crcstart - 2 >= cstart && crcstart < cend) break; } if (c >= nfchunks) { - printk(KERN_ERR - "Failed to find chunk for " + pr_err("Failed to find chunk for " "crcrec[%d], addr=0x%06x len=%d , " "aborting crc.\n", i, s3crc[i].addr, s3crc[i].len); @@ -430,14 +442,12 @@ int crcimage(imgchunk_t *fchunk, unsigned int nfchunks, s3crcrec_t *s3crc, * Returns: * nothing ----------------------------------------------------------------*/ -void free_chunks(imgchunk_t *fchunk, unsigned int *nfchunks) +static void free_chunks(struct imgchunk *fchunk, unsigned int *nfchunks) { int i; - for (i = 0; i < *nfchunks; i++) { - if (fchunk[i].data != NULL) { - kfree(fchunk[i].data); - } - } + for (i = 0; i < *nfchunks; i++) + kfree(fchunk[i].data); + *nfchunks = 0; memset(fchunk, 0, sizeof(*fchunk)); @@ -454,7 +464,7 @@ void free_chunks(imgchunk_t *fchunk, unsigned int *nfchunks) * Returns: * nothing ----------------------------------------------------------------*/ -void free_srecs(void) +static void free_srecs(void) { ns3data = 0; memset(s3data, 0, sizeof(s3data)); @@ -481,7 +491,7 @@ void free_srecs(void) * 0 - success * ~0 - failure (probably an errno) ----------------------------------------------------------------*/ -int mkimage(imgchunk_t *clist, unsigned int *ccnt) +static int mkimage(struct imgchunk *clist, unsigned int *ccnt) { int result = 0; int i; @@ -527,13 +537,11 @@ int mkimage(imgchunk_t *clist, unsigned int *ccnt) /* Allocate buffer space for chunks */ for (i = 0; i < *ccnt; i++) { - clist[i].data = kmalloc(clist[i].len, GFP_KERNEL); + clist[i].data = kzalloc(clist[i].len, GFP_KERNEL); if (clist[i].data == NULL) { - printk(KERN_ERR - "failed to allocate image space, exitting.\n"); - return (1); + pr_err("failed to allocate image space, exitting.\n"); + return 1; } - memset(clist[i].data, 0, clist[i].len); pr_debug("chunk[%d]: addr=0x%06x len=%d\n", i, clist[i].addr, clist[i].len); } @@ -545,15 +553,13 @@ int mkimage(imgchunk_t *clist, unsigned int *ccnt) for (j = 0; j < *ccnt; j++) { cstart = clist[j].addr; cend = cstart + clist[j].len - 1; - if (s3start >= cstart && s3end <= cend) { + if (s3start >= cstart && s3end <= cend) break; - } } if (((unsigned int)j) >= (*ccnt)) { - printk(KERN_ERR - "s3rec(a=0x%06x,l=%d), no chunk match, exiting.\n", + pr_err("s3rec(a=0x%06x,l=%d), no chunk match, exiting.\n", s3start, s3data[i].len); - return (1); + return 1; } coffset = s3start - cstart; memcpy(clist[j].data + coffset, s3data[i].data, s3data[i].len); @@ -576,7 +582,7 @@ int mkimage(imgchunk_t *clist, unsigned int *ccnt) * 0 - success * ~0 - failure (probably an errno) ----------------------------------------------------------------*/ -int mkpdrlist(pda_t *pda) +static int mkpdrlist(struct pda *pda) { int result = 0; u16 *pda16 = (u16 *) pda->buf; @@ -586,9 +592,10 @@ int mkpdrlist(pda_t *pda) curroff = 0; while (curroff < (HFA384x_PDA_LEN_MAX / 2) && le16_to_cpu(pda16[curroff + 1]) != HFA384x_PDR_END_OF_PDA) { - pda->rec[pda->nrec] = (hfa384x_pdrec_t *) & (pda16[curroff]); + pda->rec[pda->nrec] = (hfa384x_pdrec_t *) &(pda16[curroff]); - if (le16_to_cpu(pda->rec[pda->nrec]->code) == HFA384x_PDR_NICID) { + if (le16_to_cpu(pda->rec[pda->nrec]->code) == + HFA384x_PDR_NICID) { memcpy(&nicid, &pda->rec[pda->nrec]->data.nicid, sizeof(nicid)); nicid.id = le16_to_cpu(nicid.id); @@ -620,13 +627,12 @@ int mkpdrlist(pda_t *pda) } if (curroff >= (HFA384x_PDA_LEN_MAX / 2)) { - printk(KERN_ERR - "no end record found or invalid lengths in " + pr_err("no end record found or invalid lengths in " "PDR data, exiting. %x %d\n", curroff, pda->nrec); - return (1); + return 1; } if (le16_to_cpu(pda16[curroff + 1]) == HFA384x_PDR_END_OF_PDA) { - pda->rec[pda->nrec] = (hfa384x_pdrec_t *) & (pda16[curroff]); + pda->rec[pda->nrec] = (hfa384x_pdrec_t *) &(pda16[curroff]); (pda->nrec)++; } return result; @@ -649,8 +655,8 @@ int mkpdrlist(pda_t *pda) * 0 success * ~0 failure ----------------------------------------------------------------*/ -int plugimage(imgchunk_t *fchunk, unsigned int nfchunks, - s3plugrec_t *s3plug, unsigned int ns3plug, pda_t * pda) +static int plugimage(struct imgchunk *fchunk, unsigned int nfchunks, + struct s3plugrec *s3plug, unsigned int ns3plug, struct pda *pda) { int result = 0; int i; /* plug index */ @@ -668,7 +674,7 @@ int plugimage(imgchunk_t *fchunk, unsigned int nfchunks, pstart = s3plug[i].addr; pend = s3plug[i].addr + s3plug[i].len; /* find the matching PDR (or filename) */ - if (s3plug[i].itemcode != 0xffffffffUL) { /* not filename */ + if (s3plug[i].itemcode != 0xffffffffUL) { /* not filename */ for (j = 0; j < pda->nrec; j++) { if (s3plug[i].itemcode == le16_to_cpu(pda->rec[j]->code)) @@ -677,9 +683,8 @@ int plugimage(imgchunk_t *fchunk, unsigned int nfchunks, } else { j = -1; } - if (j >= pda->nrec && j != -1) { /* if no matching PDR, fail */ - printk(KERN_WARNING - "warning: Failed to find PDR for " + if (j >= pda->nrec && j != -1) { /* if no matching PDR, fail */ + pr_warn("warning: Failed to find PDR for " "plugrec 0x%04x.\n", s3plug[i].itemcode); continue; /* and move on to the next PDR */ #if 0 @@ -697,8 +702,7 @@ int plugimage(imgchunk_t *fchunk, unsigned int nfchunks, /* Validate plug len against PDR len */ if (j != -1 && s3plug[i].len < le16_to_cpu(pda->rec[j]->len)) { - printk(KERN_ERR - "error: Plug vs. PDR len mismatch for " + pr_err("error: Plug vs. PDR len mismatch for " "plugrec 0x%04x, abort plugging.\n", s3plug[i].itemcode); result = 1; @@ -713,8 +717,7 @@ int plugimage(imgchunk_t *fchunk, unsigned int nfchunks, break; } if (c >= nfchunks) { - printk(KERN_ERR - "error: Failed to find image chunk for " + pr_err("error: Failed to find image chunk for " "plugrec 0x%04x.\n", s3plug[i].itemcode); result = 1; continue; @@ -757,10 +760,10 @@ int plugimage(imgchunk_t *fchunk, unsigned int nfchunks, * 0 - success * ~0 - failure (probably an errno) ----------------------------------------------------------------*/ -int read_cardpda(pda_t *pda, wlandevice_t *wlandev) +static int read_cardpda(struct pda *pda, wlandevice_t *wlandev) { int result = 0; - p80211msg_p2req_readpda_t msg; + struct p80211msg_p2req_readpda msg; /* set up the msg */ msg.msgcode = DIDmsg_p2req_readpda; @@ -799,7 +802,7 @@ int read_cardpda(pda_t *pda, wlandevice_t *wlandev) * * Note also that the start address record, originally an S7 record in * the srec file, is expected in the fw file to be like a data record but -* with a certain address to make it identiable. +* with a certain address to make it identifiable. * * Here's the SREC format that the fw should have come from: * S[37]nnaaaaaaaaddd...dddcc @@ -832,7 +835,7 @@ int read_cardpda(pda_t *pda, wlandevice_t *wlandev) * ssssttttdd..dd * s - Size in words (little endian) * t - Info type (little endian), see #defines and -* s3inforec_t for details about types. +* struct s3inforec for details about types. * d - (s - 1) little endian words giving the contents of * the given info type. * @@ -847,7 +850,7 @@ int read_cardpda(pda_t *pda, wlandevice_t *wlandev) * 0 - success * ~0 - failure (probably an errno) ----------------------------------------------------------------*/ -int read_fwfile(const struct ihex_binrec *record) +static int read_fwfile(const struct ihex_binrec *record) { int i; int rcnt = 0; @@ -869,7 +872,7 @@ int read_fwfile(const struct ihex_binrec *record) ptr16 = (u16 *) record->data; /* parse what was an S3 srec and put it in the right array */ - switch(addr) { + switch (addr) { case S3ADDR_START: startaddr = *ptr32; pr_debug(" S7 start addr, record=%d " @@ -890,8 +893,8 @@ int read_fwfile(const struct ihex_binrec *record) s3plug[ns3plug].len); ns3plug++; - if ( ns3plug == S3PLUG_MAX ) { - printk(KERN_ERR "S3 plugrec limit reached - aborting\n"); + if (ns3plug == S3PLUG_MAX) { + pr_err("S3 plugrec limit reached - aborting\n"); return 1; } break; @@ -907,8 +910,8 @@ int read_fwfile(const struct ihex_binrec *record) s3crc[ns3crc].len, s3crc[ns3crc].dowrite); ns3crc++; - if ( ns3crc == S3CRC_MAX ) { - printk(KERN_ERR "S3 crcrec limit reached - aborting\n"); + if (ns3crc == S3CRC_MAX) { + pr_err("S3 crcrec limit reached - aborting\n"); return 1; } break; @@ -921,12 +924,12 @@ int read_fwfile(const struct ihex_binrec *record) rcnt, s3info[ns3info].len, s3info[ns3info].type); - if ( ((s3info[ns3info].len - 1) * sizeof(u16)) > sizeof(s3info[ns3info].info) ) { - printk(KERN_ERR " S3 inforec length too long - aborting\n"); + if (((s3info[ns3info].len - 1) * sizeof(u16)) > sizeof(s3info[ns3info].info)) { + pr_err("S3 inforec length too long - aborting\n"); return 1; } - tmpinfo = (u16*)&(s3info[ns3info].info.version); + tmpinfo = (u16 *)&(s3info[ns3info].info.version); pr_debug(" info="); for (i = 0; i < s3info[ns3info].len - 1; i++) { tmpinfo[i] = *(ptr16 + 2 + i); @@ -935,8 +938,8 @@ int read_fwfile(const struct ihex_binrec *record) pr_debug("\n"); ns3info++; - if ( ns3info == S3INFO_MAX ) { - printk(KERN_ERR "S3 inforec limit reached - aborting\n"); + if (ns3info == S3INFO_MAX) { + pr_err("S3 inforec limit reached - aborting\n"); return 1; } break; @@ -945,8 +948,8 @@ int read_fwfile(const struct ihex_binrec *record) s3data[ns3data].len = len; s3data[ns3data].data = (uint8_t *) record->data; ns3data++; - if ( ns3data == S3DATA_MAX ) { - printk(KERN_ERR "S3 datarec limit reached - aborting\n"); + if (ns3data == S3DATA_MAX) { + pr_err("S3 datarec limit reached - aborting\n"); return 1; } break; @@ -971,13 +974,12 @@ int read_fwfile(const struct ihex_binrec *record) * 0 success * ~0 failure ----------------------------------------------------------------*/ -int writeimage(wlandevice_t *wlandev, imgchunk_t *fchunk, +static int writeimage(wlandevice_t *wlandev, struct imgchunk *fchunk, unsigned int nfchunks) { int result = 0; - p80211msg_p2req_ramdl_state_t rstatemsg; - p80211msg_p2req_ramdl_write_t rwritemsg; - p80211msg_t *msgp; + struct p80211msg_p2req_ramdl_state *rstmsg; + struct p80211msg_p2req_ramdl_write *rwrmsg; u32 resultcode; int i; int j; @@ -986,57 +988,68 @@ int writeimage(wlandevice_t *wlandev, imgchunk_t *fchunk, u32 currlen; u32 currdaddr; + rstmsg = kmalloc(sizeof(*rstmsg), GFP_KERNEL); + rwrmsg = kmalloc(sizeof(*rwrmsg), GFP_KERNEL); + if (!rstmsg || !rwrmsg) { + kfree(rstmsg); + kfree(rwrmsg); + netdev_err(wlandev->netdev, + "writeimage: no memory for firmware download, " + "aborting download\n"); + return -ENOMEM; + } + /* Initialize the messages */ - memset(&rstatemsg, 0, sizeof(rstatemsg)); - strcpy(rstatemsg.devname, wlandev->name); - rstatemsg.msgcode = DIDmsg_p2req_ramdl_state; - rstatemsg.msglen = sizeof(rstatemsg); - rstatemsg.enable.did = DIDmsg_p2req_ramdl_state_enable; - rstatemsg.exeaddr.did = DIDmsg_p2req_ramdl_state_exeaddr; - rstatemsg.resultcode.did = DIDmsg_p2req_ramdl_state_resultcode; - rstatemsg.enable.status = P80211ENUM_msgitem_status_data_ok; - rstatemsg.exeaddr.status = P80211ENUM_msgitem_status_data_ok; - rstatemsg.resultcode.status = P80211ENUM_msgitem_status_no_value; - rstatemsg.enable.len = sizeof(u32); - rstatemsg.exeaddr.len = sizeof(u32); - rstatemsg.resultcode.len = sizeof(u32); - - memset(&rwritemsg, 0, sizeof(rwritemsg)); - strcpy(rwritemsg.devname, wlandev->name); - rwritemsg.msgcode = DIDmsg_p2req_ramdl_write; - rwritemsg.msglen = sizeof(rwritemsg); - rwritemsg.addr.did = DIDmsg_p2req_ramdl_write_addr; - rwritemsg.len.did = DIDmsg_p2req_ramdl_write_len; - rwritemsg.data.did = DIDmsg_p2req_ramdl_write_data; - rwritemsg.resultcode.did = DIDmsg_p2req_ramdl_write_resultcode; - rwritemsg.addr.status = P80211ENUM_msgitem_status_data_ok; - rwritemsg.len.status = P80211ENUM_msgitem_status_data_ok; - rwritemsg.data.status = P80211ENUM_msgitem_status_data_ok; - rwritemsg.resultcode.status = P80211ENUM_msgitem_status_no_value; - rwritemsg.addr.len = sizeof(u32); - rwritemsg.len.len = sizeof(u32); - rwritemsg.data.len = WRITESIZE_MAX; - rwritemsg.resultcode.len = sizeof(u32); + memset(rstmsg, 0, sizeof(*rstmsg)); + strcpy(rstmsg->devname, wlandev->name); + rstmsg->msgcode = DIDmsg_p2req_ramdl_state; + rstmsg->msglen = sizeof(*rstmsg); + rstmsg->enable.did = DIDmsg_p2req_ramdl_state_enable; + rstmsg->exeaddr.did = DIDmsg_p2req_ramdl_state_exeaddr; + rstmsg->resultcode.did = DIDmsg_p2req_ramdl_state_resultcode; + rstmsg->enable.status = P80211ENUM_msgitem_status_data_ok; + rstmsg->exeaddr.status = P80211ENUM_msgitem_status_data_ok; + rstmsg->resultcode.status = P80211ENUM_msgitem_status_no_value; + rstmsg->enable.len = sizeof(u32); + rstmsg->exeaddr.len = sizeof(u32); + rstmsg->resultcode.len = sizeof(u32); + + memset(rwrmsg, 0, sizeof(*rwrmsg)); + strcpy(rwrmsg->devname, wlandev->name); + rwrmsg->msgcode = DIDmsg_p2req_ramdl_write; + rwrmsg->msglen = sizeof(*rwrmsg); + rwrmsg->addr.did = DIDmsg_p2req_ramdl_write_addr; + rwrmsg->len.did = DIDmsg_p2req_ramdl_write_len; + rwrmsg->data.did = DIDmsg_p2req_ramdl_write_data; + rwrmsg->resultcode.did = DIDmsg_p2req_ramdl_write_resultcode; + rwrmsg->addr.status = P80211ENUM_msgitem_status_data_ok; + rwrmsg->len.status = P80211ENUM_msgitem_status_data_ok; + rwrmsg->data.status = P80211ENUM_msgitem_status_data_ok; + rwrmsg->resultcode.status = P80211ENUM_msgitem_status_no_value; + rwrmsg->addr.len = sizeof(u32); + rwrmsg->len.len = sizeof(u32); + rwrmsg->data.len = WRITESIZE_MAX; + rwrmsg->resultcode.len = sizeof(u32); /* Send xxx_state(enable) */ pr_debug("Sending dl_state(enable) message.\n"); - rstatemsg.enable.data = P80211ENUM_truth_true; - rstatemsg.exeaddr.data = startaddr; + rstmsg->enable.data = P80211ENUM_truth_true; + rstmsg->exeaddr.data = startaddr; - msgp = (p80211msg_t *) & rstatemsg; - result = prism2mgmt_ramdl_state(wlandev, msgp); + result = prism2mgmt_ramdl_state(wlandev, rstmsg); if (result) { - printk(KERN_ERR - "writeimage state enable failed w/ result=%d, " - "aborting download\n", result); - return result; + netdev_err(wlandev->netdev, + "writeimage state enable failed w/ result=%d, " + "aborting download\n", result); + goto free_result; } - resultcode = rstatemsg.resultcode.data; + resultcode = rstmsg->resultcode.data; if (resultcode != P80211ENUM_resultcode_success) { - printk(KERN_ERR - "writeimage()->xxxdl_state msg indicates failure, " - "w/ resultcode=%d, aborting download.\n", resultcode); - return 1; + netdev_err(wlandev->netdev, + "writeimage()->xxxdl_state msg indicates failure, " + "w/ resultcode=%d, aborting download.\n", resultcode); + result = 1; + goto free_result; } /* Now, loop through the data chunks and send WRITESIZE_MAX data */ @@ -1045,17 +1058,18 @@ int writeimage(wlandevice_t *wlandev, imgchunk_t *fchunk, nwrites += (fchunk[i].len % WRITESIZE_MAX) ? 1 : 0; curroff = 0; for (j = 0; j < nwrites; j++) { - currlen = - (fchunk[i].len - (WRITESIZE_MAX * j)) > - WRITESIZE_MAX ? WRITESIZE_MAX : (fchunk[i].len - - (WRITESIZE_MAX * - j)); + /* TODO Move this to a separate function */ + int lenleft = fchunk[i].len - (WRITESIZE_MAX * j); + if (fchunk[i].len > WRITESIZE_MAX) + currlen = WRITESIZE_MAX; + else + currlen = lenleft; curroff = j * WRITESIZE_MAX; currdaddr = fchunk[i].addr + curroff; /* Setup the message */ - rwritemsg.addr.data = currdaddr; - rwritemsg.len.data = currlen; - memcpy(rwritemsg.data.data, + rwrmsg->addr.data = currdaddr; + rwrmsg->len.data = currlen; + memcpy(rwrmsg->data.data, fchunk[i].data + curroff, currlen); /* Send flashdl_write(pda) */ @@ -1063,23 +1077,22 @@ int writeimage(wlandevice_t *wlandev, imgchunk_t *fchunk, ("Sending xxxdl_write message addr=%06x len=%d.\n", currdaddr, currlen); - msgp = (p80211msg_t *) & rwritemsg; - result = prism2mgmt_ramdl_write(wlandev, msgp); + result = prism2mgmt_ramdl_write(wlandev, rwrmsg); /* Check the results */ if (result) { - printk(KERN_ERR - "writeimage chunk write failed w/ result=%d, " - "aborting download\n", result); - return result; + netdev_err(wlandev->netdev, + "writeimage chunk write failed w/ " + "result=%d, aborting download\n", result); + goto free_result; } - resultcode = rstatemsg.resultcode.data; + resultcode = rstmsg->resultcode.data; if (resultcode != P80211ENUM_resultcode_success) { - printk(KERN_ERR - "writeimage()->xxxdl_write msg indicates failure, " + pr_err("writeimage()->xxxdl_write msg indicates failure, " "w/ resultcode=%d, aborting download.\n", resultcode); - return 1; + result = 1; + goto free_result; } } @@ -1087,28 +1100,32 @@ int writeimage(wlandevice_t *wlandev, imgchunk_t *fchunk, /* Send xxx_state(disable) */ pr_debug("Sending dl_state(disable) message.\n"); - rstatemsg.enable.data = P80211ENUM_truth_false; - rstatemsg.exeaddr.data = 0; + rstmsg->enable.data = P80211ENUM_truth_false; + rstmsg->exeaddr.data = 0; - msgp = (p80211msg_t *) & rstatemsg; - result = prism2mgmt_ramdl_state(wlandev, msgp); + result = prism2mgmt_ramdl_state(wlandev, rstmsg); if (result) { - printk(KERN_ERR - "writeimage state disable failed w/ result=%d, " - "aborting download\n", result); - return result; + netdev_err(wlandev->netdev, + "writeimage state disable failed w/ result=%d, " + "aborting download\n", result); + goto free_result; } - resultcode = rstatemsg.resultcode.data; + resultcode = rstmsg->resultcode.data; if (resultcode != P80211ENUM_resultcode_success) { - printk(KERN_ERR - "writeimage()->xxxdl_state msg indicates failure, " - "w/ resultcode=%d, aborting download.\n", resultcode); - return 1; + netdev_err(wlandev->netdev, + "writeimage()->xxxdl_state msg indicates failure, " + "w/ resultcode=%d, aborting download.\n", resultcode); + result = 1; + goto free_result; } + +free_result: + kfree(rstmsg); + kfree(rwrmsg); return result; } -int validate_identity(void) +static int validate_identity(void) { int i; int result = 1; @@ -1161,7 +1178,7 @@ int validate_identity(void) /* SEC compat range */ if ((s3info[i].info.compat.role == 1) && (s3info[i].info.compat.id == 4)) { - + /* FIXME: isn't something missing here? */ } break; @@ -1196,8 +1213,9 @@ int validate_identity(void) pr_debug("Unknown inforec type %d\n", s3info[i].type); } } - // walk through + /* walk through */ - if (trump && (result != 2)) result = 0; + if (trump && (result != 2)) + result = 0; return result; } diff --git a/drivers/staging/wlan-ng/prism2mgmt.c b/drivers/staging/wlan-ng/prism2mgmt.c index 9f7d96cae8e..d110b362c3b 100644 --- a/drivers/staging/wlan-ng/prism2mgmt.c +++ b/drivers/staging/wlan-ng/prism2mgmt.c @@ -63,11 +63,10 @@ #include <linux/wait.h> #include <linux/sched.h> #include <linux/types.h> -#include <linux/slab.h> #include <linux/wireless.h> #include <linux/netdevice.h> #include <linux/delay.h> -#include <asm/io.h> +#include <linux/io.h> #include <asm/byteorder.h> #include <linux/random.h> #include <linux/usb.h> @@ -118,7 +117,7 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp) { int result = 0; hfa384x_t *hw = wlandev->priv; - p80211msg_dot11req_scan_t *msg = msgp; + struct p80211msg_dot11req_scan *msg = msgp; u16 roamingmode, word; int i, timeout; int istmpenable = 0; @@ -130,8 +129,8 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp) hw->ident_sta_fw.minor, hw->ident_sta_fw.variant) < HFA384x_FIRMWARE_VERSION(1, 3, 2)) { - printk(KERN_ERR - "HostScan not supported with current firmware (<1.3.2).\n"); + netdev_err(wlandev->netdev, + "HostScan not supported with current firmware (<1.3.2).\n"); result = 1; msg->resultcode.data = P80211ENUM_resultcode_not_supported; goto exit; @@ -144,8 +143,8 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp) HFA384x_RID_CNFROAMINGMODE, &roamingmode); if (result) { - printk(KERN_ERR "getconfig(ROAMMODE) failed. result=%d\n", - result); + netdev_err(wlandev->netdev, + "getconfig(ROAMMODE) failed. result=%d\n", result); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; @@ -156,8 +155,8 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp) HFA384x_RID_CNFROAMINGMODE, HFA384x_ROAMMODE_HOSTSCAN_HOSTROAM); if (result) { - printk(KERN_ERR "setconfig(ROAMINGMODE) failed. result=%d\n", - result); + netdev_err(wlandev->netdev, + "setconfig(ROAMINGMODE) failed. result=%d\n", result); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; @@ -177,8 +176,9 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp) hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFPASSIVESCANCTRL, word); if (result) { - printk(KERN_WARNING "Passive scan not supported with " - "current firmware. (<1.5.1)\n"); + netdev_warn(wlandev->netdev, + "Passive scan not supported with " + "current firmware. (<1.5.1)\n"); } } @@ -204,8 +204,8 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp) /* Enable the MAC port if it's not already enabled */ result = hfa384x_drvr_getconfig16(hw, HFA384x_RID_PORTSTATUS, &word); if (result) { - printk(KERN_ERR "getconfig(PORTSTATUS) failed. " - "result=%d\n", result); + netdev_err(wlandev->netdev, + "getconfig(PORTSTATUS) failed. result=%d\n", result); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; @@ -214,12 +214,12 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp) u16 wordbuf[17]; result = hfa384x_drvr_setconfig16(hw, - HFA384x_RID_CNFROAMINGMODE, - HFA384x_ROAMMODE_HOSTSCAN_HOSTROAM); + HFA384x_RID_CNFROAMINGMODE, + HFA384x_ROAMMODE_HOSTSCAN_HOSTROAM); if (result) { - printk(KERN_ERR - "setconfig(ROAMINGMODE) failed. result=%d\n", - result); + netdev_err(wlandev->netdev, + "setconfig(ROAMINGMODE) failed. result=%d\n", + result); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; @@ -233,7 +233,7 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp) wordbuf, HFA384x_RID_CNFOWNSSID_LEN); if (result) { - printk(KERN_ERR "Failed to set OwnSSID.\n"); + netdev_err(wlandev->netdev, "Failed to set OwnSSID.\n"); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; @@ -242,7 +242,8 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp) wordbuf, HFA384x_RID_CNFDESIREDSSID_LEN); if (result) { - printk(KERN_ERR "Failed to set DesiredSSID.\n"); + netdev_err(wlandev->netdev, + "Failed to set DesiredSSID.\n"); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; @@ -252,25 +253,27 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp) HFA384x_RID_CNFPORTTYPE, HFA384x_PORTTYPE_IBSS); if (result) { - printk(KERN_ERR "Failed to set CNFPORTTYPE.\n"); + netdev_err(wlandev->netdev, + "Failed to set CNFPORTTYPE.\n"); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; } /* ibss options */ result = hfa384x_drvr_setconfig16(hw, - HFA384x_RID_CREATEIBSS, - HFA384x_CREATEIBSS_JOINCREATEIBSS); + HFA384x_RID_CREATEIBSS, + HFA384x_CREATEIBSS_JOINCREATEIBSS); if (result) { - printk(KERN_ERR "Failed to set CREATEIBSS.\n"); + netdev_err(wlandev->netdev, + "Failed to set CREATEIBSS.\n"); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; } result = hfa384x_drvr_enable(hw, 0); if (result) { - printk(KERN_ERR "drvr_enable(0) failed. " - "result=%d\n", result); + netdev_err(wlandev->netdev, + "drvr_enable(0) failed. result=%d\n", result); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; @@ -289,8 +292,8 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp) HFA384x_RID_HOSTSCAN, &scanreq, sizeof(hfa384x_HostScanRequest_data_t)); if (result) { - printk(KERN_ERR "setconfig(SCANREQUEST) failed. result=%d\n", - result); + netdev_err(wlandev->netdev, + "setconfig(SCANREQUEST) failed. result=%d\n", result); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; @@ -311,8 +314,8 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp) if (istmpenable) { result = hfa384x_drvr_disable(hw, 0); if (result) { - printk(KERN_ERR "drvr_disable(0) failed. " - "result=%d\n", result); + netdev_err(wlandev->netdev, + "drvr_disable(0) failed. result=%d\n", result); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; @@ -323,8 +326,8 @@ int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp) result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFROAMINGMODE, roamingmode); if (result) { - printk(KERN_ERR "setconfig(ROAMMODE) failed. result=%d\n", - result); + netdev_err(wlandev->netdev, + "setconfig(ROAMMODE) failed. result=%d\n", result); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; goto exit; @@ -362,27 +365,28 @@ exit: int prism2mgmt_scan_results(wlandevice_t *wlandev, void *msgp) { int result = 0; - p80211msg_dot11req_scan_results_t *req; + struct p80211msg_dot11req_scan_results *req; hfa384x_t *hw = wlandev->priv; hfa384x_HScanResultSub_t *item = NULL; int count; - req = (p80211msg_dot11req_scan_results_t *) msgp; + req = (struct p80211msg_dot11req_scan_results *) msgp; req->resultcode.status = P80211ENUM_msgitem_status_data_ok; if (!hw->scanresults) { - printk(KERN_ERR - "dot11req_scan_results can only be used after a successful dot11req_scan.\n"); + netdev_err(wlandev->netdev, + "dot11req_scan_results can only be used after " + "a successful dot11req_scan.\n"); result = 2; req->resultcode.data = P80211ENUM_resultcode_invalid_parameters; goto exit; } count = (hw->scanresults->framelen - 3) / 32; - if (count > 32) - count = 32; + if (count > HFA384x_SCANRESULT_MAX) + count = HFA384x_SCANRESULT_MAX; if (req->bssindex.data >= count) { pr_debug("requested index (%d) out of range (%d)\n", @@ -407,6 +411,7 @@ int prism2mgmt_scan_results(wlandevice_t *wlandev, void *msgp) /* SSID */ req->ssid.status = P80211ENUM_msgitem_status_data_ok; req->ssid.data.len = le16_to_cpu(item->ssid.len); + req->ssid.data.len = min_t(u16, req->ssid.data.len, WLAN_SSID_MAXLEN); memcpy(req->ssid.data.data, item->ssid.data, req->ssid.data.len); /* supported rates */ @@ -415,10 +420,14 @@ int prism2mgmt_scan_results(wlandevice_t *wlandev, void *msgp) break; #define REQBASICRATE(N) \ - if ((count >= N) && DOT11_RATE5_ISBASIC_GET(item->supprates[(N)-1])) { \ - req->basicrate ## N .data = item->supprates[(N)-1]; \ - req->basicrate ## N .status = P80211ENUM_msgitem_status_data_ok; \ - } + do { \ + if ((count >= N) && DOT11_RATE5_ISBASIC_GET( \ + item->supprates[(N)-1])) { \ + req->basicrate ## N .data = item->supprates[(N)-1]; \ + req->basicrate ## N .status = \ + P80211ENUM_msgitem_status_data_ok; \ + } \ + } while (0) REQBASICRATE(1); REQBASICRATE(2); @@ -430,10 +439,13 @@ int prism2mgmt_scan_results(wlandevice_t *wlandev, void *msgp) REQBASICRATE(8); #define REQSUPPRATE(N) \ - if (count >= N) { \ - req->supprate ## N .data = item->supprates[(N)-1]; \ - req->supprate ## N .status = P80211ENUM_msgitem_status_data_ok; \ - } + do { \ + if (count >= N) { \ + req->supprate ## N .data = item->supprates[(N)-1]; \ + req->supprate ## N .status = \ + P80211ENUM_msgitem_status_data_ok; \ + } \ + } while (0) REQSUPPRATE(1); REQSUPPRATE(2); @@ -464,6 +476,8 @@ int prism2mgmt_scan_results(wlandevice_t *wlandev, void *msgp) /* capinfo bits */ count = le16_to_cpu(item->capinfo); + req->capinfo.status = P80211ENUM_msgitem_status_data_ok; + req->capinfo.data = count; /* privacy flag */ req->privacy.status = P80211ENUM_msgitem_status_data_ok; @@ -512,11 +526,11 @@ int prism2mgmt_start(wlandevice_t *wlandev, void *msgp) { int result = 0; hfa384x_t *hw = wlandev->priv; - p80211msg_dot11req_start_t *msg = msgp; + struct p80211msg_dot11req_start *msg = msgp; p80211pstrd_t *pstr; u8 bytebuf[80]; - hfa384x_bytestr_t *p2bytestr = (hfa384x_bytestr_t *) bytebuf; + struct hfa384x_bytestr *p2bytestr = (struct hfa384x_bytestr *) bytebuf; u16 word; wlandev->macmode = WLAN_MACMODE_NONE; @@ -541,19 +555,19 @@ int prism2mgmt_start(wlandevice_t *wlandev, void *msgp) /*** STATION ***/ /* Set the REQUIRED config items */ /* SSID */ - pstr = (p80211pstrd_t *) & (msg->ssid.data); + pstr = (p80211pstrd_t *) &(msg->ssid.data); prism2mgmt_pstr2bytestr(p2bytestr, pstr); result = hfa384x_drvr_setconfig(hw, HFA384x_RID_CNFOWNSSID, bytebuf, HFA384x_RID_CNFOWNSSID_LEN); if (result) { - printk(KERN_ERR "Failed to set CnfOwnSSID\n"); + netdev_err(wlandev->netdev, "Failed to set CnfOwnSSID\n"); goto failed; } result = hfa384x_drvr_setconfig(hw, HFA384x_RID_CNFDESIREDSSID, bytebuf, HFA384x_RID_CNFDESIREDSSID_LEN); if (result) { - printk(KERN_ERR "Failed to set CnfDesiredSSID\n"); + netdev_err(wlandev->netdev, "Failed to set CnfDesiredSSID\n"); goto failed; } @@ -565,7 +579,8 @@ int prism2mgmt_start(wlandevice_t *wlandev, void *msgp) word = msg->beaconperiod.data; result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFAPBCNint, word); if (result) { - printk(KERN_ERR "Failed to set beacon period=%d.\n", word); + netdev_err(wlandev->netdev, + "Failed to set beacon period=%d.\n", word); goto failed; } @@ -573,7 +588,8 @@ int prism2mgmt_start(wlandevice_t *wlandev, void *msgp) word = msg->dschannel.data; result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFOWNCHANNEL, word); if (result) { - printk(KERN_ERR "Failed to set channel=%d.\n", word); + netdev_err(wlandev->netdev, + "Failed to set channel=%d.\n", word); goto failed; } /* Basic rates */ @@ -601,7 +617,8 @@ int prism2mgmt_start(wlandevice_t *wlandev, void *msgp) result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFBASICRATES, word); if (result) { - printk(KERN_ERR "Failed to set basicrates=%d.\n", word); + netdev_err(wlandev->netdev, + "Failed to set basicrates=%d.\n", word); goto failed; } @@ -630,13 +647,14 @@ int prism2mgmt_start(wlandevice_t *wlandev, void *msgp) result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_CNFSUPPRATES, word); if (result) { - printk(KERN_ERR "Failed to set supprates=%d.\n", word); + netdev_err(wlandev->netdev, + "Failed to set supprates=%d.\n", word); goto failed; } result = hfa384x_drvr_setconfig16(hw, HFA384x_RID_TXRATECNTL, word); if (result) { - printk(KERN_ERR "Failed to set txrates=%d.\n", word); + netdev_err(wlandev->netdev, "Failed to set txrates=%d.\n", word); goto failed; } @@ -650,7 +668,8 @@ int prism2mgmt_start(wlandevice_t *wlandev, void *msgp) /* Enable the Port */ result = hfa384x_drvr_enable(hw, 0); if (result) { - printk(KERN_ERR "Enable macport failed, result=%d.\n", result); + netdev_err(wlandev->netdev, + "Enable macport failed, result=%d.\n", result); goto failed; } @@ -688,15 +707,15 @@ done: int prism2mgmt_readpda(wlandevice_t *wlandev, void *msgp) { hfa384x_t *hw = wlandev->priv; - p80211msg_p2req_readpda_t *msg = msgp; + struct p80211msg_p2req_readpda *msg = msgp; int result; /* We only support collecting the PDA when in the FWLOAD * state. */ if (wlandev->msdstate != WLAN_MSD_FWLOAD) { - printk(KERN_ERR - "PDA may only be read " "in the fwload state.\n"); + netdev_err(wlandev->netdev, + "PDA may only be read in the fwload state.\n"); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; @@ -708,9 +727,9 @@ int prism2mgmt_readpda(wlandevice_t *wlandev, void *msgp) msg->pda.data, HFA384x_PDA_LEN_MAX); if (result) { - printk(KERN_ERR - "hfa384x_drvr_readpda() failed, " - "result=%d\n", result); + netdev_err(wlandev->netdev, + "hfa384x_drvr_readpda() failed, " + "result=%d\n", result); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; @@ -754,12 +773,12 @@ int prism2mgmt_readpda(wlandevice_t *wlandev, void *msgp) int prism2mgmt_ramdl_state(wlandevice_t *wlandev, void *msgp) { hfa384x_t *hw = wlandev->priv; - p80211msg_p2req_ramdl_state_t *msg = msgp; + struct p80211msg_p2req_ramdl_state *msg = msgp; if (wlandev->msdstate != WLAN_MSD_FWLOAD) { - printk(KERN_ERR - "ramdl_state(): may only be called " - "in the fwload state.\n"); + netdev_err(wlandev->netdev, + "ramdl_state(): may only be called " + "in the fwload state.\n"); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; @@ -810,15 +829,15 @@ int prism2mgmt_ramdl_state(wlandevice_t *wlandev, void *msgp) int prism2mgmt_ramdl_write(wlandevice_t *wlandev, void *msgp) { hfa384x_t *hw = wlandev->priv; - p80211msg_p2req_ramdl_write_t *msg = msgp; + struct p80211msg_p2req_ramdl_write *msg = msgp; u32 addr; u32 len; u8 *buf; if (wlandev->msdstate != WLAN_MSD_FWLOAD) { - printk(KERN_ERR - "ramdl_write(): may only be called " - "in the fwload state.\n"); + netdev_err(wlandev->netdev, + "ramdl_write(): may only be called " + "in the fwload state.\n"); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; @@ -873,12 +892,12 @@ int prism2mgmt_flashdl_state(wlandevice_t *wlandev, void *msgp) { int result = 0; hfa384x_t *hw = wlandev->priv; - p80211msg_p2req_flashdl_state_t *msg = msgp; + struct p80211msg_p2req_flashdl_state *msg = msgp; if (wlandev->msdstate != WLAN_MSD_FWLOAD) { - printk(KERN_ERR - "flashdl_state(): may only be called " - "in the fwload state.\n"); + netdev_err(wlandev->netdev, + "flashdl_state(): may only be called " + "in the fwload state.\n"); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; @@ -911,8 +930,9 @@ int prism2mgmt_flashdl_state(wlandevice_t *wlandev, void *msgp) wlandev->msdstate = WLAN_MSD_HWPRESENT; result = prism2sta_ifstate(wlandev, P80211ENUM_ifstate_fwload); if (result != P80211ENUM_resultcode_success) { - printk(KERN_ERR "prism2sta_ifstate(fwload) failed," - "P80211ENUM_resultcode=%d\n", result); + netdev_err(wlandev->netdev, + "prism2sta_ifstate(fwload) failed," + "P80211ENUM_resultcode=%d\n", result); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; result = -1; @@ -943,15 +963,15 @@ int prism2mgmt_flashdl_state(wlandevice_t *wlandev, void *msgp) int prism2mgmt_flashdl_write(wlandevice_t *wlandev, void *msgp) { hfa384x_t *hw = wlandev->priv; - p80211msg_p2req_flashdl_write_t *msg = msgp; + struct p80211msg_p2req_flashdl_write *msg = msgp; u32 addr; u32 len; u8 *buf; if (wlandev->msdstate != WLAN_MSD_FWLOAD) { - printk(KERN_ERR - "flashdl_write(): may only be called " - "in the fwload state.\n"); + netdev_err(wlandev->netdev, + "flashdl_write(): may only be called " + "in the fwload state.\n"); msg->resultcode.data = P80211ENUM_resultcode_implementation_failure; msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; @@ -1007,10 +1027,10 @@ int prism2mgmt_autojoin(wlandevice_t *wlandev, void *msgp) int result = 0; u16 reg; u16 port_type; - p80211msg_lnxreq_autojoin_t *msg = msgp; + struct p80211msg_lnxreq_autojoin *msg = msgp; p80211pstrd_t *pstr; u8 bytebuf[256]; - hfa384x_bytestr_t *p2bytestr = (hfa384x_bytestr_t *) bytebuf; + struct hfa384x_bytestr *p2bytestr = (struct hfa384x_bytestr *) bytebuf; wlandev->macmode = WLAN_MACMODE_NONE; @@ -1034,7 +1054,7 @@ int prism2mgmt_autojoin(wlandevice_t *wlandev, void *msgp) /* Set the ssid */ memset(bytebuf, 0, 256); - pstr = (p80211pstrd_t *) & (msg->ssid.data); + pstr = (p80211pstrd_t *) &(msg->ssid.data); prism2mgmt_pstr2bytestr(p2bytestr, pstr); result = hfa384x_drvr_setconfig(hw, HFA384x_RID_CNFDESIREDSSID, bytebuf, @@ -1075,7 +1095,7 @@ int prism2mgmt_autojoin(wlandevice_t *wlandev, void *msgp) int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp) { int result = 0; - p80211msg_lnxreq_wlansniff_t *msg = msgp; + struct p80211msg_lnxreq_wlansniff *msg = msgp; hfa384x_t *hw = wlandev->priv; u16 word; @@ -1101,7 +1121,7 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp) result = hfa384x_drvr_disable(hw, 0); if (result) { pr_debug - ("failed to disable port 0 after sniffing, result=%d\n", + ("failed to disable port 0 after sniffing, result=%d\n", result); goto failed; } @@ -1123,8 +1143,8 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp) if (hw->presniff_port_type != 0) { word = hw->presniff_port_type; result = hfa384x_drvr_setconfig16(hw, - HFA384x_RID_CNFPORTTYPE, - word); + HFA384x_RID_CNFPORTTYPE, + word); if (result) { pr_debug ("failed to restore porttype, result=%d\n", @@ -1135,9 +1155,8 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp) /* Enable the port */ result = hfa384x_drvr_enable(hw, 0); if (result) { - pr_debug - ("failed to enable port to presniff setting, result=%d\n", - result); + pr_debug("failed to enable port to presniff setting, result=%d\n", + result); goto failed; } } else { @@ -1145,7 +1164,7 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp) } - printk(KERN_INFO "monitor mode disabled\n"); + netdev_info(wlandev->netdev, "monitor mode disabled\n"); msg->resultcode.data = P80211ENUM_resultcode_success; result = 0; goto exit; @@ -1156,43 +1175,37 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp) if (wlandev->netdev->type == ARPHRD_ETHER) { /* Save macport 0 state */ result = hfa384x_drvr_getconfig16(hw, - HFA384x_RID_CNFPORTTYPE, - & - (hw-> - presniff_port_type)); + HFA384x_RID_CNFPORTTYPE, + &(hw->presniff_port_type)); if (result) { pr_debug - ("failed to read porttype, result=%d\n", + ("failed to read porttype, result=%d\n", result); goto failed; } /* Save the wepflags state */ result = hfa384x_drvr_getconfig16(hw, - HFA384x_RID_CNFWEPFLAGS, - & - (hw-> - presniff_wepflags)); + HFA384x_RID_CNFWEPFLAGS, + &(hw->presniff_wepflags)); if (result) { pr_debug - ("failed to read wepflags, result=%d\n", + ("failed to read wepflags, result=%d\n", result); goto failed; } hfa384x_drvr_stop(hw); result = hfa384x_drvr_start(hw); if (result) { - pr_debug - ("failed to restart the card for sniffing, result=%d\n", - result); + pr_debug("failed to restart the card for sniffing, result=%d\n", + result); goto failed; } } else { /* Disable the port */ result = hfa384x_drvr_disable(hw, 0); if (result) { - pr_debug - ("failed to enable port for sniffing, result=%d\n", - result); + pr_debug("failed to enable port for sniffing, result=%d\n", + result); goto failed; } } @@ -1218,8 +1231,8 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp) /* Set the port type to pIbss */ word = HFA384x_PORTTYPE_PSUEDOIBSS; result = hfa384x_drvr_setconfig16(hw, - HFA384x_RID_CNFPORTTYPE, - word); + HFA384x_RID_CNFPORTTYPE, + word); if (result) { pr_debug ("failed to set porttype %d, result=%d\n", @@ -1235,14 +1248,14 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp) HFA384x_WEPFLAGS_DISABLE_RXCRYPT; result = hfa384x_drvr_setconfig16(hw, - HFA384x_RID_CNFWEPFLAGS, - word); + HFA384x_RID_CNFWEPFLAGS, + word); } if (result) { pr_debug - ("failed to set wepflags=0x%04x, result=%d\n", - word, result); + ("failed to set wepflags=0x%04x, result=%d\n", + word, result); goto failed; } } @@ -1280,7 +1293,7 @@ int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp) } if (wlandev->netdev->type == ARPHRD_ETHER) - printk(KERN_INFO "monitor mode enabled\n"); + netdev_info(wlandev->netdev, "monitor mode enabled\n"); /* Set the driver state */ /* Do we want the prism2 header? */ diff --git a/drivers/staging/wlan-ng/prism2mgmt.h b/drivers/staging/wlan-ng/prism2mgmt.h index bdf2b3e0325..b62fdcba94e 100644 --- a/drivers/staging/wlan-ng/prism2mgmt.h +++ b/drivers/staging/wlan-ng/prism2mgmt.h @@ -63,43 +63,45 @@ extern int prism2_reset_holdtime; extern int prism2_reset_settletime; -u32 prism2sta_ifstate(wlandevice_t * wlandev, u32 ifstate); +u32 prism2sta_ifstate(wlandevice_t *wlandev, u32 ifstate); -void prism2sta_ev_info(wlandevice_t * wlandev, hfa384x_InfFrame_t * inf); -void prism2sta_ev_txexc(wlandevice_t * wlandev, u16 status); -void prism2sta_ev_tx(wlandevice_t * wlandev, u16 status); -void prism2sta_ev_rx(wlandevice_t * wlandev, struct sk_buff *skb); -void prism2sta_ev_alloc(wlandevice_t * wlandev); +void prism2sta_ev_info(wlandevice_t *wlandev, hfa384x_InfFrame_t *inf); +void prism2sta_ev_txexc(wlandevice_t *wlandev, u16 status); +void prism2sta_ev_tx(wlandevice_t *wlandev, u16 status); +void prism2sta_ev_rx(wlandevice_t *wlandev, struct sk_buff *skb); +void prism2sta_ev_alloc(wlandevice_t *wlandev); -int prism2mgmt_mibset_mibget(wlandevice_t * wlandev, void *msgp); -int prism2mgmt_scan(wlandevice_t * wlandev, void *msgp); -int prism2mgmt_scan_results(wlandevice_t * wlandev, void *msgp); -int prism2mgmt_start(wlandevice_t * wlandev, void *msgp); -int prism2mgmt_wlansniff(wlandevice_t * wlandev, void *msgp); -int prism2mgmt_readpda(wlandevice_t * wlandev, void *msgp); -int prism2mgmt_ramdl_state(wlandevice_t * wlandev, void *msgp); -int prism2mgmt_ramdl_write(wlandevice_t * wlandev, void *msgp); -int prism2mgmt_flashdl_state(wlandevice_t * wlandev, void *msgp); -int prism2mgmt_flashdl_write(wlandevice_t * wlandev, void *msgp); -int prism2mgmt_autojoin(wlandevice_t * wlandev, void *msgp); +int prism2mgmt_mibset_mibget(wlandevice_t *wlandev, void *msgp); +int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp); +int prism2mgmt_scan_results(wlandevice_t *wlandev, void *msgp); +int prism2mgmt_start(wlandevice_t *wlandev, void *msgp); +int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp); +int prism2mgmt_readpda(wlandevice_t *wlandev, void *msgp); +int prism2mgmt_ramdl_state(wlandevice_t *wlandev, void *msgp); +int prism2mgmt_ramdl_write(wlandevice_t *wlandev, void *msgp); +int prism2mgmt_flashdl_state(wlandevice_t *wlandev, void *msgp); +int prism2mgmt_flashdl_write(wlandevice_t *wlandev, void *msgp); +int prism2mgmt_autojoin(wlandevice_t *wlandev, void *msgp); /*--------------------------------------------------------------- * conversion functions going between wlan message data types and * Prism2 data types ---------------------------------------------------------------*/ /* byte area conversion functions*/ -void prism2mgmt_pstr2bytearea(u8 * bytearea, p80211pstrd_t * pstr); -void prism2mgmt_bytearea2pstr(u8 * bytearea, p80211pstrd_t * pstr, int len); +void prism2mgmt_pstr2bytearea(u8 *bytearea, p80211pstrd_t *pstr); +void prism2mgmt_bytearea2pstr(u8 *bytearea, p80211pstrd_t *pstr, int len); /* byte string conversion functions*/ -void prism2mgmt_pstr2bytestr(hfa384x_bytestr_t * bytestr, p80211pstrd_t * pstr); -void prism2mgmt_bytestr2pstr(hfa384x_bytestr_t * bytestr, p80211pstrd_t * pstr); +void prism2mgmt_pstr2bytestr(struct hfa384x_bytestr *bytestr, + p80211pstrd_t *pstr); +void prism2mgmt_bytestr2pstr(struct hfa384x_bytestr *bytestr, + p80211pstrd_t *pstr); /* functions to convert Group Addresses */ -void prism2mgmt_get_grpaddr(u32 did, p80211pstrd_t * pstr, hfa384x_t * priv); +void prism2mgmt_get_grpaddr(u32 did, p80211pstrd_t *pstr, hfa384x_t *priv); int prism2mgmt_set_grpaddr(u32 did, - u8 * prism2buf, p80211pstrd_t * pstr, - hfa384x_t * priv); + u8 *prism2buf, p80211pstrd_t *pstr, + hfa384x_t *priv); int prism2mgmt_get_grpaddr_index(u32 did); void prism2sta_processing_defer(struct work_struct *data); @@ -107,4 +109,9 @@ void prism2sta_processing_defer(struct work_struct *data); void prism2sta_commsqual_defer(struct work_struct *data); void prism2sta_commsqual_timer(unsigned long data); +/* Interface callback functions, passing data back up to the cfg80211 layer */ +void prism2_connect_result(wlandevice_t *wlandev, u8 failed); +void prism2_disconnected(wlandevice_t *wlandev); +void prism2_roamed(wlandevice_t *wlandev); + #endif diff --git a/drivers/staging/wlan-ng/prism2mib.c b/drivers/staging/wlan-ng/prism2mib.c index 2fff0a110bc..0fb42dfca2a 100644 --- a/drivers/staging/wlan-ng/prism2mib.c +++ b/drivers/staging/wlan-ng/prism2mib.c @@ -54,7 +54,6 @@ #include <linux/kernel.h> #include <linux/sched.h> #include <linux/types.h> -#include <linux/slab.h> #include <linux/wireless.h> #include <linux/netdevice.h> #include <linux/io.h> @@ -80,7 +79,7 @@ #define F_READ 0x2 /* MIB may be read. */ #define F_WRITE 0x4 /* MIB may be written. */ -typedef struct mibrec { +struct mibrec { u32 did; u16 flag; u16 parm1; @@ -90,63 +89,63 @@ typedef struct mibrec { int isget, wlandevice_t *wlandev, hfa384x_t *hw, - p80211msg_dot11req_mibset_t *msg, void *data); -} mibrec_t; + struct p80211msg_dot11req_mibset *msg, void *data); +}; -static int prism2mib_bytearea2pstr(mibrec_t *mib, +static int prism2mib_bytearea2pstr(struct mibrec *mib, int isget, wlandevice_t *wlandev, hfa384x_t *hw, - p80211msg_dot11req_mibset_t *msg, + struct p80211msg_dot11req_mibset *msg, void *data); -static int prism2mib_uint32(mibrec_t *mib, +static int prism2mib_uint32(struct mibrec *mib, int isget, wlandevice_t *wlandev, hfa384x_t *hw, - p80211msg_dot11req_mibset_t *msg, void *data); + struct p80211msg_dot11req_mibset *msg, void *data); -static int prism2mib_flag(mibrec_t *mib, +static int prism2mib_flag(struct mibrec *mib, int isget, wlandevice_t *wlandev, hfa384x_t *hw, - p80211msg_dot11req_mibset_t *msg, void *data); + struct p80211msg_dot11req_mibset *msg, void *data); -static int prism2mib_wepdefaultkey(mibrec_t *mib, +static int prism2mib_wepdefaultkey(struct mibrec *mib, int isget, - wlandevice_t * wlandev, + wlandevice_t *wlandev, hfa384x_t *hw, - p80211msg_dot11req_mibset_t *msg, + struct p80211msg_dot11req_mibset *msg, void *data); -static int prism2mib_privacyinvoked(mibrec_t *mib, +static int prism2mib_privacyinvoked(struct mibrec *mib, int isget, wlandevice_t *wlandev, hfa384x_t *hw, - p80211msg_dot11req_mibset_t *msg, + struct p80211msg_dot11req_mibset *msg, void *data); -static int prism2mib_excludeunencrypted(mibrec_t *mib, +static int prism2mib_excludeunencrypted(struct mibrec *mib, int isget, wlandevice_t *wlandev, hfa384x_t *hw, - p80211msg_dot11req_mibset_t *msg, + struct p80211msg_dot11req_mibset *msg, void *data); -static int prism2mib_fragmentationthreshold(mibrec_t *mib, +static int prism2mib_fragmentationthreshold(struct mibrec *mib, int isget, wlandevice_t *wlandev, hfa384x_t *hw, - p80211msg_dot11req_mibset_t *msg, + struct p80211msg_dot11req_mibset *msg, void *data); -static int prism2mib_priv(mibrec_t *mib, +static int prism2mib_priv(struct mibrec *mib, int isget, wlandevice_t *wlandev, hfa384x_t *hw, - p80211msg_dot11req_mibset_t *msg, void *data); + struct p80211msg_dot11req_mibset *msg, void *data); -static mibrec_t mibtab[] = { +static struct mibrec mibtab[] = { /* dot11smt MIB's */ {DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0, @@ -262,11 +261,11 @@ int prism2mgmt_mibset_mibget(wlandevice_t *wlandev, void *msgp) { hfa384x_t *hw = wlandev->priv; int result, isget; - mibrec_t *mib; + struct mibrec *mib; u16 which; - p80211msg_dot11req_mibset_t *msg = msgp; + struct p80211msg_dot11req_mibset *msg = msgp; p80211itemd_t *mibitem; msg->resultcode.status = P80211ENUM_msgitem_status_data_ok; @@ -372,11 +371,11 @@ done: * ----------------------------------------------------------------*/ -static int prism2mib_bytearea2pstr(mibrec_t *mib, +static int prism2mib_bytearea2pstr(struct mibrec *mib, int isget, wlandevice_t *wlandev, hfa384x_t *hw, - p80211msg_dot11req_mibset_t *msg, + struct p80211msg_dot11req_mibset *msg, void *data) { int result; @@ -422,11 +421,11 @@ static int prism2mib_bytearea2pstr(mibrec_t *mib, * ----------------------------------------------------------------*/ -static int prism2mib_uint32(mibrec_t *mib, +static int prism2mib_uint32(struct mibrec *mib, int isget, wlandevice_t *wlandev, hfa384x_t *hw, - p80211msg_dot11req_mibset_t *msg, void *data) + struct p80211msg_dot11req_mibset *msg, void *data) { int result; u32 *uint32 = (u32 *) data; @@ -469,11 +468,11 @@ static int prism2mib_uint32(mibrec_t *mib, * ----------------------------------------------------------------*/ -static int prism2mib_flag(mibrec_t *mib, +static int prism2mib_flag(struct mibrec *mib, int isget, wlandevice_t *wlandev, hfa384x_t *hw, - p80211msg_dot11req_mibset_t *msg, void *data) + struct p80211msg_dot11req_mibset *msg, void *data) { int result; u32 *uint32 = (u32 *) data; @@ -526,11 +525,11 @@ static int prism2mib_flag(mibrec_t *mib, * ----------------------------------------------------------------*/ -static int prism2mib_wepdefaultkey(mibrec_t *mib, +static int prism2mib_wepdefaultkey(struct mibrec *mib, int isget, wlandevice_t *wlandev, hfa384x_t *hw, - p80211msg_dot11req_mibset_t *msg, + struct p80211msg_dot11req_mibset *msg, void *data) { int result; @@ -576,11 +575,11 @@ static int prism2mib_wepdefaultkey(mibrec_t *mib, * ----------------------------------------------------------------*/ -static int prism2mib_privacyinvoked(mibrec_t *mib, +static int prism2mib_privacyinvoked(struct mibrec *mib, int isget, wlandevice_t *wlandev, hfa384x_t *hw, - p80211msg_dot11req_mibset_t *msg, + struct p80211msg_dot11req_mibset *msg, void *data) { int result; @@ -622,11 +621,11 @@ static int prism2mib_privacyinvoked(mibrec_t *mib, * ----------------------------------------------------------------*/ -static int prism2mib_excludeunencrypted(mibrec_t *mib, +static int prism2mib_excludeunencrypted(struct mibrec *mib, int isget, wlandevice_t *wlandev, hfa384x_t *hw, - p80211msg_dot11req_mibset_t *msg, + struct p80211msg_dot11req_mibset *msg, void *data) { int result; @@ -661,11 +660,11 @@ static int prism2mib_excludeunencrypted(mibrec_t *mib, * ----------------------------------------------------------------*/ -static int prism2mib_fragmentationthreshold(mibrec_t *mib, +static int prism2mib_fragmentationthreshold(struct mibrec *mib, int isget, wlandevice_t *wlandev, hfa384x_t *hw, - p80211msg_dot11req_mibset_t *msg, + struct p80211msg_dot11req_mibset *msg, void *data) { int result; @@ -673,7 +672,7 @@ static int prism2mib_fragmentationthreshold(mibrec_t *mib, if (!isget) if ((*uint32) % 2) { - printk(KERN_WARNING "Attempt to set odd number " + netdev_warn(wlandev->netdev, "Attempt to set odd number " "FragmentationThreshold\n"); msg->resultcode.data = P80211ENUM_resultcode_not_supported; @@ -710,11 +709,11 @@ static int prism2mib_fragmentationthreshold(mibrec_t *mib, * ----------------------------------------------------------------*/ -static int prism2mib_priv(mibrec_t *mib, +static int prism2mib_priv(struct mibrec *mib, int isget, wlandevice_t *wlandev, hfa384x_t *hw, - p80211msg_dot11req_mibset_t *msg, void *data) + struct p80211msg_dot11req_mibset *msg, void *data) { p80211pstrd_t *pstr = (p80211pstrd_t *) data; @@ -726,7 +725,7 @@ static int prism2mib_priv(mibrec_t *mib, if (isget) { hfa384x_drvr_getconfig(hw, HFA384x_RID_CNFWPADATA, - (u8 *) & wpa, + (u8 *) &wpa, sizeof(wpa)); pstr->len = le16_to_cpu(wpa.datalen); memcpy(pstr->data, wpa.data, pstr->len); @@ -736,14 +735,14 @@ static int prism2mib_priv(mibrec_t *mib, result = hfa384x_drvr_setconfig(hw, - HFA384x_RID_CNFWPADATA, - (u8 *) & wpa, - sizeof(wpa)); + HFA384x_RID_CNFWPADATA, + (u8 *) &wpa, + sizeof(wpa)); } break; } default: - printk(KERN_ERR "Unhandled DID 0x%08x\n", mib->did); + netdev_err(wlandev->netdev, "Unhandled DID 0x%08x\n", mib->did); } return 0; @@ -764,7 +763,8 @@ static int prism2mib_priv(mibrec_t *mib, * ----------------------------------------------------------------*/ -void prism2mgmt_pstr2bytestr(hfa384x_bytestr_t *bytestr, p80211pstrd_t *pstr) +void prism2mgmt_pstr2bytestr(struct hfa384x_bytestr *bytestr, + p80211pstrd_t *pstr) { bytestr->len = cpu_to_le16((u16) (pstr->len)); memcpy(bytestr->data, pstr->data, pstr->len); @@ -805,7 +805,8 @@ void prism2mgmt_pstr2bytearea(u8 *bytearea, p80211pstrd_t *pstr) * ----------------------------------------------------------------*/ -void prism2mgmt_bytestr2pstr(hfa384x_bytestr_t *bytestr, p80211pstrd_t *pstr) +void prism2mgmt_bytestr2pstr(struct hfa384x_bytestr *bytestr, + p80211pstrd_t *pstr) { pstr->len = (u8) (le16_to_cpu((u16) (bytestr->len))); memcpy(pstr->data, bytestr->data, pstr->len); diff --git a/drivers/staging/wlan-ng/prism2sta.c b/drivers/staging/wlan-ng/prism2sta.c index 50f301d6521..278b6a1ef31 100644 --- a/drivers/staging/wlan-ng/prism2sta.c +++ b/drivers/staging/wlan-ng/prism2sta.c @@ -50,13 +50,11 @@ * -------------------------------------------------------------------- */ -#include <linux/version.h> #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/types.h> -#include <linux/init.h> #include <linux/slab.h> #include <linux/wireless.h> #include <linux/netdevice.h> @@ -64,7 +62,7 @@ #include <linux/byteorder/generic.h> #include <linux/ctype.h> -#include <asm/io.h> +#include <linux/io.h> #include <linux/delay.h> #include <asm/byteorder.h> #include <linux/if_arp.h> @@ -83,8 +81,6 @@ #include "hfa384x.h" #include "prism2mgmt.h" -#define wlan_hexchar(x) (((x) < 0x0a) ? ('0' + (x)) : ('a' + ((x) - 0x0a))) - /* Create a string of printable chars from something that might not be */ /* It's recommended that the str be 4*len + 1 bytes long */ #define wlan_mkprintstr(buf, buflen, str, strlen) \ @@ -99,8 +95,8 @@ } else { \ (str)[j] = '\\'; \ (str)[j+1] = 'x'; \ - (str)[j+2] = wlan_hexchar(((buf)[i] & 0xf0) >> 4); \ - (str)[j+3] = wlan_hexchar(((buf)[i] & 0x0f)); \ + (str)[j+2] = hex_asc_hi((buf)[i]); \ + (str)[j+3] = hex_asc_lo((buf)[i]); \ j += 4; \ } \ } \ @@ -128,9 +124,9 @@ static int prism2sta_open(wlandevice_t *wlandev); static int prism2sta_close(wlandevice_t *wlandev); static void prism2sta_reset(wlandevice_t *wlandev); static int prism2sta_txframe(wlandevice_t *wlandev, struct sk_buff *skb, - p80211_hdr_t *p80211_hdr, - p80211_metawep_t *p80211_wep); -static int prism2sta_mlmerequest(wlandevice_t *wlandev, p80211msg_t *msg); + union p80211_hdr *p80211_hdr, + struct p80211_metawep *p80211_wep); +static int prism2sta_mlmerequest(wlandevice_t *wlandev, struct p80211msg *msg); static int prism2sta_getcardinfo(wlandevice_t *wlandev); static int prism2sta_globalsetup(wlandevice_t *wlandev); static int prism2sta_setmulticast(wlandevice_t *wlandev, netdevice_t *dev); @@ -241,7 +237,6 @@ static int prism2sta_close(wlandevice_t *wlandev) ----------------------------------------------------------------*/ static void prism2sta_reset(wlandevice_t *wlandev) { - return; } /*---------------------------------------------------------------- @@ -266,8 +261,8 @@ static void prism2sta_reset(wlandevice_t *wlandev) * process thread ----------------------------------------------------------------*/ static int prism2sta_txframe(wlandevice_t *wlandev, struct sk_buff *skb, - p80211_hdr_t *p80211_hdr, - p80211_metawep_t *p80211_wep) + union p80211_hdr *p80211_hdr, + struct p80211_metawep *p80211_wep) { hfa384x_t *hw = (hfa384x_t *) wlandev->priv; int result; @@ -307,7 +302,7 @@ static int prism2sta_txframe(wlandevice_t *wlandev, struct sk_buff *skb, * Call context: * process thread ----------------------------------------------------------------*/ -static int prism2sta_mlmerequest(wlandevice_t *wlandev, p80211msg_t *msg) +static int prism2sta_mlmerequest(wlandevice_t *wlandev, struct p80211msg *msg) { hfa384x_t *hw = (hfa384x_t *) wlandev->priv; @@ -364,9 +359,9 @@ static int prism2sta_mlmerequest(wlandevice_t *wlandev, p80211msg_t *msg) break; /* ignore me. */ case DIDmsg_lnxreq_ifstate: { - p80211msg_lnxreq_ifstate_t *ifstatemsg; + struct p80211msg_lnxreq_ifstate *ifstatemsg; pr_debug("Received mlme ifstate request\n"); - ifstatemsg = (p80211msg_lnxreq_ifstate_t *) msg; + ifstatemsg = (struct p80211msg_lnxreq_ifstate *) msg; result = prism2sta_ifstate(wlandev, ifstatemsg->ifstate.data); @@ -385,11 +380,11 @@ static int prism2sta_mlmerequest(wlandevice_t *wlandev, p80211msg_t *msg) result = prism2mgmt_autojoin(wlandev, msg); break; case DIDmsg_lnxreq_commsquality:{ - p80211msg_lnxreq_commsquality_t *qualmsg; + struct p80211msg_lnxreq_commsquality *qualmsg; pr_debug("Received commsquality request\n"); - qualmsg = (p80211msg_lnxreq_commsquality_t *) msg; + qualmsg = (struct p80211msg_lnxreq_commsquality *) msg; qualmsg->link.status = P80211ENUM_msgitem_status_data_ok; @@ -401,12 +396,14 @@ static int prism2sta_mlmerequest(wlandevice_t *wlandev, p80211msg_t *msg) qualmsg->link.data = le16_to_cpu(hw->qual.CQ_currBSS); qualmsg->level.data = le16_to_cpu(hw->qual.ASL_currBSS); qualmsg->noise.data = le16_to_cpu(hw->qual.ANL_currFC); + qualmsg->txrate.data = hw->txrate; break; } default: - printk(KERN_WARNING "Unknown mgmt request message 0x%08x", - msg->msgcode); + netdev_warn(wlandev->netdev, + "Unknown mgmt request message 0x%08x", + msg->msgcode); break; } @@ -426,7 +423,7 @@ static int prism2sta_mlmerequest(wlandevice_t *wlandev, p80211msg_t *msg) * msgp ptr to msg buffer * * Returns: -* A p80211 message resultcode value. +* A p80211 message resultcode value. * * Side effects: * @@ -454,11 +451,10 @@ u32 prism2sta_ifstate(wlandevice_t *wlandev, u32 ifstate) */ result = hfa384x_drvr_start(hw); if (result) { - printk(KERN_ERR - "hfa384x_drvr_start() failed," - "result=%d\n", (int)result); + netdev_err(wlandev->netdev, + "hfa384x_drvr_start() failed,result=%d\n", (int)result); result = - P80211ENUM_resultcode_implementation_failure; + P80211ENUM_resultcode_implementation_failure; wlandev->msdstate = WLAN_MSD_HWPRESENT; break; } @@ -470,7 +466,7 @@ u32 prism2sta_ifstate(wlandevice_t *wlandev, u32 ifstate) result = P80211ENUM_resultcode_success; break; case WLAN_MSD_RUNNING: - printk(KERN_WARNING + netdev_warn(wlandev->netdev, "Cannot enter fwload state from enable state," "you must disable first.\n"); result = P80211ENUM_resultcode_invalid_parameters; @@ -499,33 +495,30 @@ u32 prism2sta_ifstate(wlandevice_t *wlandev, u32 ifstate) */ result = hfa384x_drvr_start(hw); if (result) { - printk(KERN_ERR - "hfa384x_drvr_start() failed," - "result=%d\n", (int)result); + netdev_err(wlandev->netdev, + "hfa384x_drvr_start() failed,result=%d\n", (int)result); result = - P80211ENUM_resultcode_implementation_failure; + P80211ENUM_resultcode_implementation_failure; wlandev->msdstate = WLAN_MSD_HWPRESENT; break; } result = prism2sta_getcardinfo(wlandev); if (result) { - printk(KERN_ERR - "prism2sta_getcardinfo() failed," - "result=%d\n", (int)result); + netdev_err(wlandev->netdev, + "prism2sta_getcardinfo() failed,result=%d\n", (int)result); result = - P80211ENUM_resultcode_implementation_failure; + P80211ENUM_resultcode_implementation_failure; hfa384x_drvr_stop(hw); wlandev->msdstate = WLAN_MSD_HWPRESENT; break; } result = prism2sta_globalsetup(wlandev); if (result) { - printk(KERN_ERR - "prism2sta_globalsetup() failed," - "result=%d\n", (int)result); + netdev_err(wlandev->netdev, + "prism2sta_globalsetup() failed,result=%d\n", (int)result); result = - P80211ENUM_resultcode_implementation_failure; + P80211ENUM_resultcode_implementation_failure; hfa384x_drvr_stop(hw); wlandev->msdstate = WLAN_MSD_HWPRESENT; break; @@ -623,7 +616,7 @@ static int prism2sta_getcardinfo(wlandevice_t *wlandev) &hw->ident_nic, sizeof(hfa384x_compident_t)); if (result) { - printk(KERN_ERR "Failed to retrieve NICIDENTITY\n"); + netdev_err(wlandev->netdev, "Failed to retrieve NICIDENTITY\n"); goto failed; } @@ -633,7 +626,7 @@ static int prism2sta_getcardinfo(wlandevice_t *wlandev) hw->ident_nic.major = le16_to_cpu(hw->ident_nic.major); hw->ident_nic.minor = le16_to_cpu(hw->ident_nic.minor); - printk(KERN_INFO "ident: nic h/w: id=0x%02x %d.%d.%d\n", + netdev_info(wlandev->netdev, "ident: nic h/w: id=0x%02x %d.%d.%d\n", hw->ident_nic.id, hw->ident_nic.major, hw->ident_nic.minor, hw->ident_nic.variant); @@ -642,7 +635,7 @@ static int prism2sta_getcardinfo(wlandevice_t *wlandev) &hw->ident_pri_fw, sizeof(hfa384x_compident_t)); if (result) { - printk(KERN_ERR "Failed to retrieve PRIIDENTITY\n"); + netdev_err(wlandev->netdev, "Failed to retrieve PRIIDENTITY\n"); goto failed; } @@ -652,7 +645,7 @@ static int prism2sta_getcardinfo(wlandevice_t *wlandev) hw->ident_pri_fw.major = le16_to_cpu(hw->ident_pri_fw.major); hw->ident_pri_fw.minor = le16_to_cpu(hw->ident_pri_fw.minor); - printk(KERN_INFO "ident: pri f/w: id=0x%02x %d.%d.%d\n", + netdev_info(wlandev->netdev, "ident: pri f/w: id=0x%02x %d.%d.%d\n", hw->ident_pri_fw.id, hw->ident_pri_fw.major, hw->ident_pri_fw.minor, hw->ident_pri_fw.variant); @@ -661,12 +654,12 @@ static int prism2sta_getcardinfo(wlandevice_t *wlandev) &hw->ident_sta_fw, sizeof(hfa384x_compident_t)); if (result) { - printk(KERN_ERR "Failed to retrieve STAIDENTITY\n"); + netdev_err(wlandev->netdev, "Failed to retrieve STAIDENTITY\n"); goto failed; } if (hw->ident_nic.id < 0x8000) { - printk(KERN_ERR + netdev_err(wlandev->netdev, "FATAL: Card is not an Intersil Prism2/2.5/3\n"); result = -1; goto failed; @@ -683,16 +676,16 @@ static int prism2sta_getcardinfo(wlandevice_t *wlandev) hw->ident_sta_fw.variant &= ~((u16) (BIT(14) | BIT(15))); if (hw->ident_sta_fw.id == 0x1f) { - printk(KERN_INFO + netdev_info(wlandev->netdev, "ident: sta f/w: id=0x%02x %d.%d.%d\n", hw->ident_sta_fw.id, hw->ident_sta_fw.major, hw->ident_sta_fw.minor, hw->ident_sta_fw.variant); } else { - printk(KERN_INFO + netdev_info(wlandev->netdev, "ident: ap f/w: id=0x%02x %d.%d.%d\n", hw->ident_sta_fw.id, hw->ident_sta_fw.major, hw->ident_sta_fw.minor, hw->ident_sta_fw.variant); - printk(KERN_ERR "Unsupported Tertiary AP firmeare loaded!\n"); + netdev_err(wlandev->netdev, "Unsupported Tertiary AP firmeare loaded!\n"); goto failed; } @@ -701,7 +694,7 @@ static int prism2sta_getcardinfo(wlandevice_t *wlandev) &hw->cap_sup_mfi, sizeof(hfa384x_caplevel_t)); if (result) { - printk(KERN_ERR "Failed to retrieve MFISUPRANGE\n"); + netdev_err(wlandev->netdev, "Failed to retrieve MFISUPRANGE\n"); goto failed; } @@ -713,7 +706,7 @@ static int prism2sta_getcardinfo(wlandevice_t *wlandev) hw->cap_sup_mfi.bottom = le16_to_cpu(hw->cap_sup_mfi.bottom); hw->cap_sup_mfi.top = le16_to_cpu(hw->cap_sup_mfi.top); - printk(KERN_INFO + netdev_info(wlandev->netdev, "MFI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", hw->cap_sup_mfi.role, hw->cap_sup_mfi.id, hw->cap_sup_mfi.variant, hw->cap_sup_mfi.bottom, @@ -724,7 +717,7 @@ static int prism2sta_getcardinfo(wlandevice_t *wlandev) &hw->cap_sup_cfi, sizeof(hfa384x_caplevel_t)); if (result) { - printk(KERN_ERR "Failed to retrieve CFISUPRANGE\n"); + netdev_err(wlandev->netdev, "Failed to retrieve CFISUPRANGE\n"); goto failed; } @@ -736,7 +729,7 @@ static int prism2sta_getcardinfo(wlandevice_t *wlandev) hw->cap_sup_cfi.bottom = le16_to_cpu(hw->cap_sup_cfi.bottom); hw->cap_sup_cfi.top = le16_to_cpu(hw->cap_sup_cfi.top); - printk(KERN_INFO + netdev_info(wlandev->netdev, "CFI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", hw->cap_sup_cfi.role, hw->cap_sup_cfi.id, hw->cap_sup_cfi.variant, hw->cap_sup_cfi.bottom, @@ -747,7 +740,7 @@ static int prism2sta_getcardinfo(wlandevice_t *wlandev) &hw->cap_sup_pri, sizeof(hfa384x_caplevel_t)); if (result) { - printk(KERN_ERR "Failed to retrieve PRISUPRANGE\n"); + netdev_err(wlandev->netdev, "Failed to retrieve PRISUPRANGE\n"); goto failed; } @@ -759,7 +752,7 @@ static int prism2sta_getcardinfo(wlandevice_t *wlandev) hw->cap_sup_pri.bottom = le16_to_cpu(hw->cap_sup_pri.bottom); hw->cap_sup_pri.top = le16_to_cpu(hw->cap_sup_pri.top); - printk(KERN_INFO + netdev_info(wlandev->netdev, "PRI:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", hw->cap_sup_pri.role, hw->cap_sup_pri.id, hw->cap_sup_pri.variant, hw->cap_sup_pri.bottom, @@ -770,7 +763,7 @@ static int prism2sta_getcardinfo(wlandevice_t *wlandev) &hw->cap_sup_sta, sizeof(hfa384x_caplevel_t)); if (result) { - printk(KERN_ERR "Failed to retrieve STASUPRANGE\n"); + netdev_err(wlandev->netdev, "Failed to retrieve STASUPRANGE\n"); goto failed; } @@ -783,13 +776,13 @@ static int prism2sta_getcardinfo(wlandevice_t *wlandev) hw->cap_sup_sta.top = le16_to_cpu(hw->cap_sup_sta.top); if (hw->cap_sup_sta.id == 0x04) { - printk(KERN_INFO + netdev_info(wlandev->netdev, "STA:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", hw->cap_sup_sta.role, hw->cap_sup_sta.id, hw->cap_sup_sta.variant, hw->cap_sup_sta.bottom, hw->cap_sup_sta.top); } else { - printk(KERN_INFO + netdev_info(wlandev->netdev, "AP:SUP:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", hw->cap_sup_sta.role, hw->cap_sup_sta.id, hw->cap_sup_sta.variant, hw->cap_sup_sta.bottom, @@ -801,7 +794,7 @@ static int prism2sta_getcardinfo(wlandevice_t *wlandev) &hw->cap_act_pri_cfi, sizeof(hfa384x_caplevel_t)); if (result) { - printk(KERN_ERR "Failed to retrieve PRI_CFIACTRANGES\n"); + netdev_err(wlandev->netdev, "Failed to retrieve PRI_CFIACTRANGES\n"); goto failed; } @@ -813,7 +806,7 @@ static int prism2sta_getcardinfo(wlandevice_t *wlandev) hw->cap_act_pri_cfi.bottom = le16_to_cpu(hw->cap_act_pri_cfi.bottom); hw->cap_act_pri_cfi.top = le16_to_cpu(hw->cap_act_pri_cfi.top); - printk(KERN_INFO + netdev_info(wlandev->netdev, "PRI-CFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", hw->cap_act_pri_cfi.role, hw->cap_act_pri_cfi.id, hw->cap_act_pri_cfi.variant, hw->cap_act_pri_cfi.bottom, @@ -824,7 +817,7 @@ static int prism2sta_getcardinfo(wlandevice_t *wlandev) &hw->cap_act_sta_cfi, sizeof(hfa384x_caplevel_t)); if (result) { - printk(KERN_ERR "Failed to retrieve STA_CFIACTRANGES\n"); + netdev_err(wlandev->netdev, "Failed to retrieve STA_CFIACTRANGES\n"); goto failed; } @@ -836,7 +829,7 @@ static int prism2sta_getcardinfo(wlandevice_t *wlandev) hw->cap_act_sta_cfi.bottom = le16_to_cpu(hw->cap_act_sta_cfi.bottom); hw->cap_act_sta_cfi.top = le16_to_cpu(hw->cap_act_sta_cfi.top); - printk(KERN_INFO + netdev_info(wlandev->netdev, "STA-CFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", hw->cap_act_sta_cfi.role, hw->cap_act_sta_cfi.id, hw->cap_act_sta_cfi.variant, hw->cap_act_sta_cfi.bottom, @@ -847,7 +840,7 @@ static int prism2sta_getcardinfo(wlandevice_t *wlandev) &hw->cap_act_sta_mfi, sizeof(hfa384x_caplevel_t)); if (result) { - printk(KERN_ERR "Failed to retrieve STA_MFIACTRANGES\n"); + netdev_err(wlandev->netdev, "Failed to retrieve STA_MFIACTRANGES\n"); goto failed; } @@ -859,7 +852,7 @@ static int prism2sta_getcardinfo(wlandevice_t *wlandev) hw->cap_act_sta_mfi.bottom = le16_to_cpu(hw->cap_act_sta_mfi.bottom); hw->cap_act_sta_mfi.top = le16_to_cpu(hw->cap_act_sta_mfi.top); - printk(KERN_INFO + netdev_info(wlandev->netdev, "STA-MFI:ACT:role=0x%02x:id=0x%02x:var=0x%02x:b/t=%d/%d\n", hw->cap_act_sta_mfi.role, hw->cap_act_sta_mfi.id, hw->cap_act_sta_mfi.variant, hw->cap_act_sta_mfi.bottom, @@ -871,9 +864,9 @@ static int prism2sta_getcardinfo(wlandevice_t *wlandev) if (!result) { wlan_mkprintstr(snum, HFA384x_RID_NICSERIALNUMBER_LEN, pstr, sizeof(pstr)); - printk(KERN_INFO "Prism2 card SN: %s\n", pstr); + netdev_info(wlandev->netdev, "Prism2 card SN: %s\n", pstr); } else { - printk(KERN_ERR "Failed to retrieve Prism2 Card SN\n"); + netdev_err(wlandev->netdev, "Failed to retrieve Prism2 Card SN\n"); goto failed; } @@ -881,7 +874,7 @@ static int prism2sta_getcardinfo(wlandevice_t *wlandev) result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CNFOWNMACADDR, wlandev->netdev->dev_addr, ETH_ALEN); if (result != 0) { - printk(KERN_ERR "Failed to retrieve mac address\n"); + netdev_err(wlandev->netdev, "Failed to retrieve mac address\n"); goto failed; } @@ -909,7 +902,7 @@ static int prism2sta_getcardinfo(wlandevice_t *wlandev) goto done; failed: - printk(KERN_ERR "Failed, result=%d\n", result); + netdev_err(wlandev->netdev, "Failed, result=%d\n", result); done: return result; } @@ -986,7 +979,6 @@ static void prism2sta_inf_handover(wlandevice_t *wlandev, hfa384x_InfFrame_t *inf) { pr_debug("received infoframe:HANDOVER (unhandled)\n"); - return; } /*---------------------------------------------------------------- @@ -1023,18 +1015,16 @@ static void prism2sta_inf_tallies(wlandevice_t *wlandev, cnt = sizeof(hfa384x_CommTallies32_t) / sizeof(u32); if (inf->framelen > 22) { - dst = (u32 *) & hw->tallies; - src32 = (u32 *) & inf->info.commtallies32; + dst = (u32 *) &hw->tallies; + src32 = (u32 *) &inf->info.commtallies32; for (i = 0; i < cnt; i++, dst++, src32++) *dst += le32_to_cpu(*src32); } else { - dst = (u32 *) & hw->tallies; - src16 = (u16 *) & inf->info.commtallies16; + dst = (u32 *) &hw->tallies; + src16 = (u16 *) &inf->info.commtallies16; for (i = 0; i < cnt; i++, dst++, src16++) *dst += le16_to_cpu(*src16); } - - return; } /*---------------------------------------------------------------- @@ -1088,11 +1078,9 @@ static void prism2sta_inf_scanresults(wlandevice_t *wlandev, HFA384x_RID_JOINREQUEST, &joinreq, HFA384x_RID_JOINREQUEST_LEN); if (result) { - printk(KERN_ERR "setconfig(joinreq) failed, result=%d\n", + netdev_err(wlandev->netdev, "setconfig(joinreq) failed, result=%d\n", result); } - - return; } /*---------------------------------------------------------------- @@ -1126,8 +1114,7 @@ static void prism2sta_inf_hostscanresults(wlandevice_t *wlandev, kfree(hw->scanresults); - hw->scanresults = kmalloc(sizeof(hfa384x_InfFrame_t), GFP_ATOMIC); - memcpy(hw->scanresults, inf, sizeof(hfa384x_InfFrame_t)); + hw->scanresults = kmemdup(inf, sizeof(hfa384x_InfFrame_t), GFP_ATOMIC); if (nbss == 0) nbss = -1; @@ -1164,35 +1151,37 @@ static void prism2sta_inf_chinforesults(wlandevice_t *wlandev, le16_to_cpu(inf->info.chinforesult.scanchannels); for (i = 0, n = 0; i < HFA384x_CHINFORESULT_MAX; i++) { - if (hw->channel_info.results.scanchannels & (1 << i)) { - int channel = - le16_to_cpu(inf->info.chinforesult.result[n].chid) - - 1; - hfa384x_ChInfoResultSub_t *chinforesult = - &hw->channel_info.results.result[channel]; - chinforesult->chid = channel; - chinforesult->anl = - le16_to_cpu(inf->info.chinforesult.result[n].anl); - chinforesult->pnl = - le16_to_cpu(inf->info.chinforesult.result[n].pnl); - chinforesult->active = - le16_to_cpu(inf->info.chinforesult.result[n]. - active); - pr_debug - ("chinfo: channel %d, %s level (avg/peak)=%d/%d dB, pcf %d\n", - channel + 1, - chinforesult-> - active & HFA384x_CHINFORESULT_BSSACTIVE ? "signal" - : "noise", chinforesult->anl, chinforesult->pnl, - chinforesult-> - active & HFA384x_CHINFORESULT_PCFACTIVE ? 1 : 0); - n++; - } + hfa384x_ChInfoResultSub_t *result; + hfa384x_ChInfoResultSub_t *chinforesult; + int chan; + + if (!(hw->channel_info.results.scanchannels & (1 << i))) + continue; + + result = &inf->info.chinforesult.result[n]; + chan = le16_to_cpu(result->chid) - 1; + + if (chan < 0 || chan >= HFA384x_CHINFORESULT_MAX) + continue; + + chinforesult = &hw->channel_info.results.result[chan]; + chinforesult->chid = chan; + chinforesult->anl = le16_to_cpu(result->anl); + chinforesult->pnl = le16_to_cpu(result->pnl); + chinforesult->active = le16_to_cpu(result->active); + + pr_debug("chinfo: channel %d, %s level (avg/peak)=%d/%d dB, pcf %d\n", + chan + 1, + (chinforesult->active & HFA384x_CHINFORESULT_BSSACTIVE) + ? "signal" : "noise", + chinforesult->anl, chinforesult->pnl, + (chinforesult->active & HFA384x_CHINFORESULT_PCFACTIVE) + ? 1 : 0); + n++; } atomic_set(&hw->channel_info.done, 2); hw->channel_info.count = n; - return; } void prism2sta_processing_defer(struct work_struct *data) @@ -1216,7 +1205,7 @@ void prism2sta_processing_defer(struct work_struct *data) /* Now let's handle the linkstatus stuff */ if (hw->link_status == hw->link_status_new) - goto failed; + return; hw->link_status = hw->link_status_new; @@ -1230,7 +1219,7 @@ void prism2sta_processing_defer(struct work_struct *data) */ netif_carrier_off(wlandev->netdev); - printk(KERN_INFO "linkstatus=NOTCONNECTED (unhandled)\n"); + netdev_info(wlandev->netdev, "linkstatus=NOTCONNECTED (unhandled)\n"); break; case HFA384x_LINK_CONNECTED: @@ -1246,7 +1235,9 @@ void prism2sta_processing_defer(struct work_struct *data) netif_carrier_on(wlandev->netdev); - /* If we are joining a specific AP, set our state and reset retries */ + /* If we are joining a specific AP, set our + * state and reset retries + */ if (hw->join_ap == 1) hw->join_ap = 2; hw->join_retries = 60; @@ -1255,20 +1246,20 @@ void prism2sta_processing_defer(struct work_struct *data) if (wlandev->netdev->type == ARPHRD_ETHER) { u16 portstatus; - printk(KERN_INFO "linkstatus=CONNECTED\n"); + netdev_info(wlandev->netdev, "linkstatus=CONNECTED\n"); /* For non-usb devices, we can use the sync versions */ /* Collect the BSSID, and set state to allow tx */ result = hfa384x_drvr_getconfig(hw, - HFA384x_RID_CURRENTBSSID, - wlandev->bssid, - WLAN_BSSID_LEN); + HFA384x_RID_CURRENTBSSID, + wlandev->bssid, + WLAN_BSSID_LEN); if (result) { pr_debug ("getconfig(0x%02x) failed, result = %d\n", HFA384x_RID_CURRENTBSSID, result); - goto failed; + return; } result = hfa384x_drvr_getconfig(hw, @@ -1278,26 +1269,29 @@ void prism2sta_processing_defer(struct work_struct *data) pr_debug ("getconfig(0x%02x) failed, result = %d\n", HFA384x_RID_CURRENTSSID, result); - goto failed; + return; } - prism2mgmt_bytestr2pstr((hfa384x_bytestr_t *) & ssid, + prism2mgmt_bytestr2pstr((struct hfa384x_bytestr *) &ssid, (p80211pstrd_t *) & wlandev->ssid); /* Collect the port status */ result = hfa384x_drvr_getconfig16(hw, - HFA384x_RID_PORTSTATUS, - &portstatus); + HFA384x_RID_PORTSTATUS, + &portstatus); if (result) { pr_debug ("getconfig(0x%02x) failed, result = %d\n", HFA384x_RID_PORTSTATUS, result); - goto failed; + return; } wlandev->macmode = (portstatus == HFA384x_PSTATUS_CONN_IBSS) ? WLAN_MACMODE_IBSS_STA : WLAN_MACMODE_ESS_STA; + /* signal back up to cfg80211 layer */ + prism2_connect_result(wlandev, P80211ENUM_truth_false); + /* Get the ball rolling on the comms quality stuff */ prism2sta_commsqual_defer(&hw->commsqual_bh); } @@ -1313,25 +1307,16 @@ void prism2sta_processing_defer(struct work_struct *data) * Indicate Deauthentication * Block Transmits, Ignore receives of data frames */ - if (hw->join_ap == 2) { - hfa384x_JoinRequest_data_t joinreq; - joinreq = hw->joinreq; - /* Send the join request */ - hfa384x_drvr_setconfig(hw, - HFA384x_RID_JOINREQUEST, - &joinreq, - HFA384x_RID_JOINREQUEST_LEN); - printk(KERN_INFO - "linkstatus=DISCONNECTED (re-submitting join)\n"); - } else { - if (wlandev->netdev->type == ARPHRD_ETHER) - printk(KERN_INFO - "linkstatus=DISCONNECTED (unhandled)\n"); - } + if (wlandev->netdev->type == ARPHRD_ETHER) + netdev_info(wlandev->netdev, + "linkstatus=DISCONNECTED (unhandled)\n"); wlandev->macmode = WLAN_MACMODE_NONE; netif_carrier_off(wlandev->netdev); + /* signal back up to cfg80211 layer */ + prism2_disconnected(wlandev); + break; case HFA384x_LINK_AP_CHANGE: @@ -1349,7 +1334,7 @@ void prism2sta_processing_defer(struct work_struct *data) * Indicate Reassociation * Enable Transmits, Receives and pass up data frames */ - printk(KERN_INFO "linkstatus=AP_CHANGE\n"); + netdev_info(wlandev->netdev, "linkstatus=AP_CHANGE\n"); result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CURRENTBSSID, @@ -1357,7 +1342,7 @@ void prism2sta_processing_defer(struct work_struct *data) if (result) { pr_debug("getconfig(0x%02x) failed, result = %d\n", HFA384x_RID_CURRENTBSSID, result); - goto failed; + return; } result = hfa384x_drvr_getconfig(hw, @@ -1366,14 +1351,17 @@ void prism2sta_processing_defer(struct work_struct *data) if (result) { pr_debug("getconfig(0x%02x) failed, result = %d\n", HFA384x_RID_CURRENTSSID, result); - goto failed; + return; } - prism2mgmt_bytestr2pstr((hfa384x_bytestr_t *) & ssid, - (p80211pstrd_t *) & wlandev->ssid); + prism2mgmt_bytestr2pstr((struct hfa384x_bytestr *) &ssid, + (p80211pstrd_t *) &wlandev->ssid); hw->link_status = HFA384x_LINK_CONNECTED; netif_carrier_on(wlandev->netdev); + /* signal back up to cfg80211 layer */ + prism2_roamed(wlandev); + break; case HFA384x_LINK_AP_OUTOFRANGE: @@ -1388,7 +1376,7 @@ void prism2sta_processing_defer(struct work_struct *data) * Response: * Block Transmits, Ignore receives of data frames */ - printk(KERN_INFO "linkstatus=AP_OUTOFRANGE (unhandled)\n"); + netdev_info(wlandev->netdev, "linkstatus=AP_OUTOFRANGE (unhandled)\n"); netif_carrier_off(wlandev->netdev); @@ -1401,7 +1389,7 @@ void prism2sta_processing_defer(struct work_struct *data) * Response: * Enable Transmits, Receives and pass up data frames */ - printk(KERN_INFO "linkstatus=AP_INRANGE\n"); + netdev_info(wlandev->netdev, "linkstatus=AP_INRANGE\n"); hw->link_status = HFA384x_LINK_CONNECTED; netif_carrier_on(wlandev->netdev); @@ -1425,29 +1413,27 @@ void prism2sta_processing_defer(struct work_struct *data) HFA384x_RID_JOINREQUEST, &joinreq, HFA384x_RID_JOINREQUEST_LEN); - printk(KERN_INFO + netdev_info(wlandev->netdev, "linkstatus=ASSOCFAIL (re-submitting join)\n"); } else { - printk(KERN_INFO "linkstatus=ASSOCFAIL (unhandled)\n"); + netdev_info(wlandev->netdev, "linkstatus=ASSOCFAIL (unhandled)\n"); } netif_carrier_off(wlandev->netdev); + /* signal back up to cfg80211 layer */ + prism2_connect_result(wlandev, P80211ENUM_truth_true); + break; default: /* This is bad, IO port problems? */ - printk(KERN_WARNING + netdev_warn(wlandev->netdev, "unknown linkstatus=0x%02x\n", hw->link_status); - goto failed; - break; + return; } wlandev->linkstatus = (hw->link_status == HFA384x_LINK_CONNECTED); - p80211wext_event_associated(wlandev, wlandev->linkstatus); - -failed: - return; } /*---------------------------------------------------------------- @@ -1475,8 +1461,6 @@ static void prism2sta_inf_linkstatus(wlandevice_t *wlandev, hw->link_status_new = le16_to_cpu(inf->info.linkstatus.linkstatus); schedule_work(&hw->link_bh); - - return; } /*---------------------------------------------------------------- @@ -1509,14 +1493,15 @@ static void prism2sta_inf_assocstatus(wlandevice_t *wlandev, rec.reason = le16_to_cpu(rec.reason); /* - ** Find the address in the list of authenticated stations. If it wasn't - ** found, then this address has not been previously authenticated and - ** something weird has happened if this is anything other than an - ** "authentication failed" message. If the address was found, then - ** set the "associated" flag for that station, based on whether the - ** station is associating or losing its association. Something weird - ** has also happened if we find the address in the list of authenticated - ** stations but we are getting an "authentication failed" message. + ** Find the address in the list of authenticated stations. + ** If it wasn't found, then this address has not been previously + ** authenticated and something weird has happened if this is + ** anything other than an "authentication failed" message. + ** If the address was found, then set the "associated" flag for + ** that station, based on whether the station is associating or + ** losing its association. Something weird has also happened + ** if we find the address in the list of authenticated stations + ** but we are getting an "authentication failed" message. */ for (i = 0; i < hw->authlist.cnt; i++) @@ -1525,19 +1510,17 @@ static void prism2sta_inf_assocstatus(wlandevice_t *wlandev, if (i >= hw->authlist.cnt) { if (rec.assocstatus != HFA384x_ASSOCSTATUS_AUTHFAIL) - printk(KERN_WARNING - "assocstatus info frame received for non-authenticated station.\n"); + netdev_warn(wlandev->netdev, + "assocstatus info frame received for non-authenticated station.\n"); } else { hw->authlist.assoc[i] = (rec.assocstatus == HFA384x_ASSOCSTATUS_STAASSOC || rec.assocstatus == HFA384x_ASSOCSTATUS_REASSOC); if (rec.assocstatus == HFA384x_ASSOCSTATUS_AUTHFAIL) - printk(KERN_WARNING - "authfail assocstatus info frame received for authenticated station.\n"); + netdev_warn(wlandev->netdev, +"authfail assocstatus info frame received for authenticated station.\n"); } - - return; } /*---------------------------------------------------------------- @@ -1681,12 +1664,12 @@ static void prism2sta_inf_authreq_defer(wlandevice_t *wlandev, } /* - ** If the authentication is okay, then add the MAC address to the list - ** of authenticated stations. Don't add the address if it is already in - ** the list. (802.11b does not seem to disallow a station from issuing - ** an authentication request when the station is already authenticated. - ** Does this sort of thing ever happen? We might as well do the check - ** just in case.) + ** If the authentication is okay, then add the MAC address to the + ** list of authenticated stations. Don't add the address if it + ** is already in the list. (802.11b does not seem to disallow + ** a station from issuing an authentication request when the + ** station is already authenticated. Does this sort of thing + ** ever happen? We might as well do the check just in case.) */ added = 0; @@ -1723,11 +1706,10 @@ static void prism2sta_inf_authreq_defer(wlandevice_t *wlandev, if (result) { if (added) hw->authlist.cnt--; - printk(KERN_ERR + netdev_err(wlandev->netdev, "setconfig(authenticatestation) failed, result=%d\n", result); } - return; } /*---------------------------------------------------------------- @@ -1754,8 +1736,6 @@ static void prism2sta_inf_psusercnt(wlandevice_t *wlandev, hfa384x_t *hw = (hfa384x_t *) wlandev->priv; hw->psusercount = le16_to_cpu(inf->info.psusercnt.usercnt); - - return; } /*---------------------------------------------------------------- @@ -1808,20 +1788,19 @@ void prism2sta_ev_info(wlandevice_t *wlandev, hfa384x_InfFrame_t *inf) prism2sta_inf_psusercnt(wlandev, inf); break; case HFA384x_IT_KEYIDCHANGED: - printk(KERN_WARNING "Unhandled IT_KEYIDCHANGED\n"); + netdev_warn(wlandev->netdev, "Unhandled IT_KEYIDCHANGED\n"); break; case HFA384x_IT_ASSOCREQ: - printk(KERN_WARNING "Unhandled IT_ASSOCREQ\n"); + netdev_warn(wlandev->netdev, "Unhandled IT_ASSOCREQ\n"); break; case HFA384x_IT_MICFAILURE: - printk(KERN_WARNING "Unhandled IT_MICFAILURE\n"); + netdev_warn(wlandev->netdev, "Unhandled IT_MICFAILURE\n"); break; default: - printk(KERN_WARNING + netdev_warn(wlandev->netdev, "Unknown info type=0x%02x\n", inf->infotype); break; } - return; } /*---------------------------------------------------------------- @@ -1846,8 +1825,6 @@ void prism2sta_ev_info(wlandevice_t *wlandev, hfa384x_InfFrame_t *inf) void prism2sta_ev_txexc(wlandevice_t *wlandev, u16 status) { pr_debug("TxExc status=0x%x.\n", status); - - return; } /*---------------------------------------------------------------- @@ -1871,7 +1848,6 @@ void prism2sta_ev_tx(wlandevice_t *wlandev, u16 status) pr_debug("Tx Complete, status=0x%04x\n", status); /* update linux network stats */ wlandev->linux_stats.tx_packets++; - return; } /*---------------------------------------------------------------- @@ -1893,7 +1869,6 @@ void prism2sta_ev_tx(wlandevice_t *wlandev, u16 status) void prism2sta_ev_rx(wlandevice_t *wlandev, struct sk_buff *skb) { p80211netdev_rx(wlandev, skb); - return; } /*---------------------------------------------------------------- @@ -1915,7 +1890,6 @@ void prism2sta_ev_rx(wlandevice_t *wlandev, struct sk_buff *skb) void prism2sta_ev_alloc(wlandevice_t *wlandev) { netif_wake_queue(wlandev->netdev); - return; } /*---------------------------------------------------------------- @@ -1931,7 +1905,7 @@ void prism2sta_ev_alloc(wlandevice_t *wlandev) * the created wlandevice_t structure. * * Side effects: -* also allocates the priv/hw structures. +* also allocates the priv/hw structures. * * Call context: * process thread @@ -1943,20 +1917,16 @@ static wlandevice_t *create_wlan(void) hfa384x_t *hw = NULL; /* Alloc our structures */ - wlandev = kmalloc(sizeof(wlandevice_t), GFP_KERNEL); - hw = kmalloc(sizeof(hfa384x_t), GFP_KERNEL); + wlandev = kzalloc(sizeof(wlandevice_t), GFP_KERNEL); + hw = kzalloc(sizeof(hfa384x_t), GFP_KERNEL); if (!wlandev || !hw) { - printk(KERN_ERR "%s: Memory allocation failure.\n", dev_info); + pr_err("%s: Memory allocation failure.\n", dev_info); kfree(wlandev); kfree(hw); return NULL; } - /* Clear all the structs */ - memset(wlandev, 0, sizeof(wlandevice_t)); - memset(hw, 0, sizeof(hfa384x_t)); - /* Initialize the network device object. */ wlandev->nsdname = dev_info; wlandev->msdstate = WLAN_MSD_HWPRESENT_PENDING; @@ -1971,7 +1941,7 @@ static wlandevice_t *create_wlan(void) wlandev->nsdcaps = P80211_NSDCAP_HWFRAGMENT | P80211_NSDCAP_AUTOJOIN; - /* Initialize the device private data stucture. */ + /* Initialize the device private data structure. */ hw->dot11_desired_bss_type = 1; return wlandev; @@ -1982,26 +1952,29 @@ void prism2sta_commsqual_defer(struct work_struct *data) hfa384x_t *hw = container_of(data, struct hfa384x, commsqual_bh); wlandevice_t *wlandev = hw->wlandev; hfa384x_bytestr32_t ssid; + struct p80211msg_dot11req_mibget msg; + p80211item_uint32_t *mibitem = (p80211item_uint32_t *) + &msg.mibattribute.data; int result = 0; if (hw->wlandev->hwremoved) - goto done; + return; /* we don't care if we're in AP mode */ if ((wlandev->macmode == WLAN_MACMODE_NONE) || (wlandev->macmode == WLAN_MACMODE_ESS_AP)) { - goto done; + return; } /* It only makes sense to poll these in non-IBSS */ if (wlandev->macmode != WLAN_MACMODE_IBSS_STA) { - result = hfa384x_drvr_getconfig(hw, HFA384x_RID_DBMCOMMSQUALITY, - &hw->qual, - HFA384x_RID_DBMCOMMSQUALITY_LEN); + result = hfa384x_drvr_getconfig( + hw, HFA384x_RID_DBMCOMMSQUALITY, + &hw->qual, HFA384x_RID_DBMCOMMSQUALITY_LEN); if (result) { - printk(KERN_ERR "error fetching commsqual\n"); - goto done; + netdev_err(wlandev->netdev, "error fetching commsqual\n"); + return; } pr_debug("commsqual %d %d %d\n", @@ -2010,6 +1983,34 @@ void prism2sta_commsqual_defer(struct work_struct *data) le16_to_cpu(hw->qual.ANL_currFC)); } + /* Get the signal rate */ + msg.msgcode = DIDmsg_dot11req_mibget; + mibitem->did = DIDmib_p2_p2MAC_p2CurrentTxRate; + result = p80211req_dorequest(wlandev, (u8 *) &msg); + + if (result) { + pr_debug("get signal rate failed, result = %d\n", + result); + return; + } + + switch (mibitem->data) { + case HFA384x_RATEBIT_1: + hw->txrate = 10; + break; + case HFA384x_RATEBIT_2: + hw->txrate = 20; + break; + case HFA384x_RATEBIT_5dot5: + hw->txrate = 55; + break; + case HFA384x_RATEBIT_11: + hw->txrate = 110; + break; + default: + pr_debug("Bad ratebit (%d)\n", mibitem->data); + } + /* Lastly, we need to make sure the BSSID didn't change on us */ result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CURRENTBSSID, @@ -2017,7 +2018,7 @@ void prism2sta_commsqual_defer(struct work_struct *data) if (result) { pr_debug("getconfig(0x%02x) failed, result = %d\n", HFA384x_RID_CURRENTBSSID, result); - goto done; + return; } result = hfa384x_drvr_getconfig(hw, @@ -2026,16 +2027,13 @@ void prism2sta_commsqual_defer(struct work_struct *data) if (result) { pr_debug("getconfig(0x%02x) failed, result = %d\n", HFA384x_RID_CURRENTSSID, result); - goto done; + return; } - prism2mgmt_bytestr2pstr((hfa384x_bytestr_t *) & ssid, - (p80211pstrd_t *) & wlandev->ssid); + prism2mgmt_bytestr2pstr((struct hfa384x_bytestr *) &ssid, + (p80211pstrd_t *) &wlandev->ssid); /* Reschedule timer */ mod_timer(&hw->commsqual_timer, jiffies + HZ); - -done: - ; } void prism2sta_commsqual_timer(unsigned long data) diff --git a/drivers/staging/wlan-ng/prism2usb.c b/drivers/staging/wlan-ng/prism2usb.c index 9dde68be8d7..e92bbc12bb0 100644 --- a/drivers/staging/wlan-ng/prism2usb.c +++ b/drivers/staging/wlan-ng/prism2usb.c @@ -4,103 +4,58 @@ #include "prism2sta.c" #include "prism2fw.c" -#define PRISM_USB_DEVICE(vid, pid, name) \ - USB_DEVICE(vid, pid), \ - .driver_info = (unsigned long) name +#define PRISM_DEV(vid, pid, name) \ + { USB_DEVICE(vid, pid), \ + .driver_info = (unsigned long) name } static struct usb_device_id usb_prism_tbl[] = { - {PRISM_USB_DEVICE(0x04bb, 0x0922, "IOData AirPort WN-B11/USBS")}, - {PRISM_USB_DEVICE(0x07aa, 0x0012, "Corega Wireless LAN USB Stick-11")}, - {PRISM_USB_DEVICE(0x09aa, 0x3642, "Prism2.x 11Mbps WLAN USB Adapter")}, - {PRISM_USB_DEVICE - (0x1668, 0x0408, "Actiontec Prism2.5 11Mbps WLAN USB Adapter")}, - {PRISM_USB_DEVICE - (0x1668, 0x0421, "Actiontec Prism2.5 11Mbps WLAN USB Adapter")}, - {PRISM_USB_DEVICE - (0x1915, 0x2236, "Linksys WUSB11v3.0 11Mbps WLAN USB Adapter")}, - {PRISM_USB_DEVICE - (0x066b, 0x2212, "Linksys WUSB11v2.5 11Mbps WLAN USB Adapter")}, - {PRISM_USB_DEVICE - (0x066b, 0x2213, "Linksys WUSB12v1.1 11Mbps WLAN USB Adapter")}, - {PRISM_USB_DEVICE - (0x067c, 0x1022, "Siemens SpeedStream 1022 11Mbps WLAN USB Adapter")}, - {PRISM_USB_DEVICE(0x049f, 0x0033, - "Compaq/Intel W100 PRO/Wireless 11Mbps multiport WLAN Adapter")}, - {PRISM_USB_DEVICE - (0x0411, 0x0016, "Melco WLI-USB-S11 11Mbps WLAN Adapter")}, - {PRISM_USB_DEVICE - (0x08de, 0x7a01, "PRISM25 IEEE 802.11 Mini USB Adapter")}, - {PRISM_USB_DEVICE - (0x8086, 0x1111, "Intel PRO/Wireless 2011B LAN USB Adapter")}, - {PRISM_USB_DEVICE - (0x0d8e, 0x7a01, "PRISM25 IEEE 802.11 Mini USB Adapter")}, - {PRISM_USB_DEVICE - (0x045e, 0x006e, "Microsoft MN510 Wireless USB Adapter")}, - {PRISM_USB_DEVICE(0x0967, 0x0204, "Acer Warplink USB Adapter")}, - {PRISM_USB_DEVICE - (0x0cde, 0x0002, "Z-Com 725/726 Prism2.5 USB/USB Integrated")}, - {PRISM_USB_DEVICE - (0x0cde, 0x0005, "Z-Com Xl735 Wireless 802.11b USB Adapter")}, - {PRISM_USB_DEVICE - (0x413c, 0x8100, "Dell TrueMobile 1180 Wireless USB Adapter")}, - {PRISM_USB_DEVICE - (0x0b3b, 0x1601, "ALLNET 0193 11Mbps WLAN USB Adapter")}, - {PRISM_USB_DEVICE - (0x0b3b, 0x1602, "ZyXEL ZyAIR B200 Wireless USB Adapter")}, - {PRISM_USB_DEVICE - (0x0baf, 0x00eb, "USRobotics USR1120 Wireless USB Adapter")}, - {PRISM_USB_DEVICE - (0x0411, 0x0027, "Melco WLI-USB-KS11G 11Mbps WLAN Adapter")}, - {PRISM_USB_DEVICE - (0x04f1, 0x3009, "JVC MP-XP7250 Builtin USB WLAN Adapter")}, - {PRISM_USB_DEVICE(0x0846, 0x4110, "NetGear MA111")}, - {PRISM_USB_DEVICE(0x03f3, 0x0020, "Adaptec AWN-8020 USB WLAN Adapter")}, -/* {PRISM_USB_DEVICE(0x0ace, 0x1201, "ZyDAS ZD1201 Wireless USB Adapter")}, */ - {PRISM_USB_DEVICE(0x2821, 0x3300, "ASUS-WL140 Wireless USB Adapter")}, - {PRISM_USB_DEVICE(0x2001, 0x3700, "DWL-122 Wireless USB Adapter")}, - {PRISM_USB_DEVICE - (0x2001, 0x3702, "DWL-120 Rev F Wireless USB Adapter")}, - {PRISM_USB_DEVICE(0x50c2, 0x4013, "Averatec USB WLAN Adapter")}, - {PRISM_USB_DEVICE(0x2c02, 0x14ea, "Planex GW-US11H WLAN USB Adapter")}, - {PRISM_USB_DEVICE(0x124a, 0x168b, "Airvast PRISM3 WLAN USB Adapter")}, - {PRISM_USB_DEVICE(0x083a, 0x3503, "T-Sinus 111 USB WLAN Adapter")}, - {PRISM_USB_DEVICE(0x2821, 0x3300, "Hawking HighDB USB Adapter")}, - {PRISM_USB_DEVICE - (0x0411, 0x0044, "Melco WLI-USB-KB11 11Mbps WLAN Adapter")}, - {PRISM_USB_DEVICE(0x1668, 0x6106, "ROPEX FreeLan 802.11b USB Adapter")}, - {PRISM_USB_DEVICE - (0x124a, 0x4017, "Pheenet WL-503IA 802.11b USB Adapter")}, - {PRISM_USB_DEVICE(0x0bb2, 0x0302, "Ambit Microsystems Corp.")}, - {PRISM_USB_DEVICE - (0x9016, 0x182d, "Sitecom WL-022 802.11b USB Adapter")}, - {PRISM_USB_DEVICE - (0x0543, 0x0f01, "ViewSonic Airsync USB Adapter 11Mbps (Prism2.5)")}, - { /* terminator */ } + PRISM_DEV(0x04bb, 0x0922, "IOData AirPort WN-B11/USBS"), + PRISM_DEV(0x07aa, 0x0012, "Corega Wireless LAN USB Stick-11"), + PRISM_DEV(0x09aa, 0x3642, "Prism2.x 11Mbps WLAN USB Adapter"), + PRISM_DEV(0x1668, 0x0408, "Actiontec Prism2.5 11Mbps WLAN USB Adapter"), + PRISM_DEV(0x1668, 0x0421, "Actiontec Prism2.5 11Mbps WLAN USB Adapter"), + PRISM_DEV(0x1915, 0x2236, "Linksys WUSB11v3.0 11Mbps WLAN USB Adapter"), + PRISM_DEV(0x066b, 0x2212, "Linksys WUSB11v2.5 11Mbps WLAN USB Adapter"), + PRISM_DEV(0x066b, 0x2213, "Linksys WUSB12v1.1 11Mbps WLAN USB Adapter"), + PRISM_DEV(0x0411, 0x0016, "Melco WLI-USB-S11 11Mbps WLAN Adapter"), + PRISM_DEV(0x08de, 0x7a01, "PRISM25 IEEE 802.11 Mini USB Adapter"), + PRISM_DEV(0x8086, 0x1111, "Intel PRO/Wireless 2011B LAN USB Adapter"), + PRISM_DEV(0x0d8e, 0x7a01, "PRISM25 IEEE 802.11 Mini USB Adapter"), + PRISM_DEV(0x045e, 0x006e, "Microsoft MN510 Wireless USB Adapter"), + PRISM_DEV(0x0967, 0x0204, "Acer Warplink USB Adapter"), + PRISM_DEV(0x0cde, 0x0002, "Z-Com 725/726 Prism2.5 USB/USB Integrated"), + PRISM_DEV(0x0cde, 0x0005, "Z-Com Xl735 Wireless 802.11b USB Adapter"), + PRISM_DEV(0x413c, 0x8100, "Dell TrueMobile 1180 Wireless USB Adapter"), + PRISM_DEV(0x0b3b, 0x1601, "ALLNET 0193 11Mbps WLAN USB Adapter"), + PRISM_DEV(0x0b3b, 0x1602, "ZyXEL ZyAIR B200 Wireless USB Adapter"), + PRISM_DEV(0x0baf, 0x00eb, "USRobotics USR1120 Wireless USB Adapter"), + PRISM_DEV(0x0411, 0x0027, "Melco WLI-USB-KS11G 11Mbps WLAN Adapter"), + PRISM_DEV(0x04f1, 0x3009, "JVC MP-XP7250 Builtin USB WLAN Adapter"), + PRISM_DEV(0x0846, 0x4110, "NetGear MA111"), + PRISM_DEV(0x03f3, 0x0020, "Adaptec AWN-8020 USB WLAN Adapter"), + PRISM_DEV(0x2821, 0x3300, "ASUS-WL140 Wireless USB Adapter"), + PRISM_DEV(0x2001, 0x3700, "DWL-122 Wireless USB Adapter"), + PRISM_DEV(0x2001, 0x3702, "DWL-120 Rev F Wireless USB Adapter"), + PRISM_DEV(0x50c2, 0x4013, "Averatec USB WLAN Adapter"), + PRISM_DEV(0x2c02, 0x14ea, "Planex GW-US11H WLAN USB Adapter"), + PRISM_DEV(0x124a, 0x168b, "Airvast PRISM3 WLAN USB Adapter"), + PRISM_DEV(0x083a, 0x3503, "T-Sinus 111 USB WLAN Adapter"), + PRISM_DEV(0x2821, 0x3300, "Hawking HighDB USB Adapter"), + PRISM_DEV(0x0411, 0x0044, "Melco WLI-USB-KB11 11Mbps WLAN Adapter"), + PRISM_DEV(0x1668, 0x6106, "ROPEX FreeLan 802.11b USB Adapter"), + PRISM_DEV(0x124a, 0x4017, "Pheenet WL-503IA 802.11b USB Adapter"), + PRISM_DEV(0x0bb2, 0x0302, "Ambit Microsystems Corp."), + PRISM_DEV(0x9016, 0x182d, "Sitecom WL-022 802.11b USB Adapter"), + PRISM_DEV(0x0543, 0x0f01, + "ViewSonic Airsync USB Adapter 11Mbps (Prism2.5)"), + PRISM_DEV(0x067c, 0x1022, + "Siemens SpeedStream 1022 11Mbps WLAN USB Adapter"), + PRISM_DEV(0x049f, 0x0033, + "Compaq/Intel W100 PRO/Wireless 11Mbps multiport WLAN Adapter"), + { } /* terminator */ }; - MODULE_DEVICE_TABLE(usb, usb_prism_tbl); -/*---------------------------------------------------------------- -* prism2sta_probe_usb -* -* Probe routine called by the USB subsystem. -* -* Arguments: -* dev ptr to the usb_device struct -* ifnum interface number being offered -* -* Returns: -* NULL - we're not claiming the device+interface -* non-NULL - we are claiming the device+interface and -* this is a ptr to the data we want back -* when disconnect is called. -* -* Side effects: -* -* Call context: -* I'm not sure, assume it's interrupt. -* -----------------------------------------------------------------*/ static int prism2sta_probe_usb(struct usb_interface *interface, const struct usb_device_id *id) { @@ -113,14 +68,14 @@ static int prism2sta_probe_usb(struct usb_interface *interface, dev = interface_to_usbdev(interface); wlandev = create_wlan(); if (wlandev == NULL) { - printk(KERN_ERR "%s: Memory allocation failure.\n", dev_info); + dev_err(&interface->dev, "Memory allocation failure.\n"); result = -EIO; goto failed; } hw = wlandev->priv; - if (wlan_setup(wlandev) != 0) { - printk(KERN_ERR "%s: wlan_setup() failed.\n", dev_info); + if (wlan_setup(wlandev, &(interface->dev)) != 0) { + dev_err(&interface->dev, "wlan_setup() failed.\n"); result = -EIO; goto failed; } @@ -140,12 +95,10 @@ static int prism2sta_probe_usb(struct usb_interface *interface, prism2_reset_holdtime, prism2_reset_settletime, 0); if (result != 0) { - unregister_wlandev(wlandev); - hfa384x_destroy(hw); result = -EIO; - printk(KERN_ERR - "%s: hfa384x_corereset() failed.\n", dev_info); - goto failed; + dev_err(&interface->dev, + "hfa384x_corereset() failed.\n"); + goto failed_reset; } } @@ -158,13 +111,17 @@ static int prism2sta_probe_usb(struct usb_interface *interface, prism2sta_ifstate(wlandev, P80211ENUM_ifstate_enable); if (register_wlandev(wlandev) != 0) { - printk(KERN_ERR "%s: register_wlandev() failed.\n", dev_info); + dev_err(&interface->dev, "register_wlandev() failed.\n"); result = -EIO; - goto failed; + goto failed_register; } goto done; +failed_register: + usb_put_dev(dev); +failed_reset: + wlan_unsetup(wlandev); failed: kfree(wlandev); kfree(hw); @@ -175,31 +132,11 @@ done: return result; } -/*---------------------------------------------------------------- -* prism2sta_disconnect_usb -* -* Called when a device previously claimed by probe is removed -* from the USB. -* -* Arguments: -* dev ptr to the usb_device struct -* ptr ptr returned by probe() when the device -* was claimed. -* -* Returns: -* Nothing -* -* Side effects: -* -* Call context: -* process -----------------------------------------------------------------*/ static void prism2sta_disconnect_usb(struct usb_interface *interface) { wlandevice_t *wlandev; wlandev = (wlandevice_t *) usb_get_intfdata(interface); - if (wlandev != NULL) { LIST_HEAD(cleanlist); struct list_head *entry; @@ -285,24 +222,78 @@ exit: usb_set_intfdata(interface, NULL); } +#ifdef CONFIG_PM +static int prism2sta_suspend(struct usb_interface *interface, + pm_message_t message) +{ + hfa384x_t *hw = NULL; + wlandevice_t *wlandev; + + wlandev = (wlandevice_t *) usb_get_intfdata(interface); + if (!wlandev) + return -ENODEV; + + hw = wlandev->priv; + if (!hw) + return -ENODEV; + + prism2sta_ifstate(wlandev, P80211ENUM_ifstate_disable); + + usb_kill_urb(&hw->rx_urb); + usb_kill_urb(&hw->tx_urb); + usb_kill_urb(&hw->ctlx_urb); + + return 0; +} + +static int prism2sta_resume(struct usb_interface *interface) +{ + int result = 0; + hfa384x_t *hw = NULL; + wlandevice_t *wlandev; + + wlandev = (wlandevice_t *) usb_get_intfdata(interface); + if (!wlandev) + return -ENODEV; + + hw = wlandev->priv; + if (!hw) + return -ENODEV; + + /* Do a chip-level reset on the MAC */ + if (prism2_doreset) { + result = hfa384x_corereset(hw, + prism2_reset_holdtime, + prism2_reset_settletime, 0); + if (result != 0) { + unregister_wlandev(wlandev); + hfa384x_destroy(hw); + dev_err(&interface->dev, "hfa384x_corereset() failed.\n"); + kfree(wlandev); + kfree(hw); + wlandev = NULL; + return -ENODEV; + } + } + + prism2sta_ifstate(wlandev, P80211ENUM_ifstate_enable); + + return 0; +} +#else +#define prism2sta_suspend NULL +#define prism2sta_resume NULL +#endif /* CONFIG_PM */ + static struct usb_driver prism2_usb_driver = { .name = "prism2_usb", .probe = prism2sta_probe_usb, .disconnect = prism2sta_disconnect_usb, .id_table = usb_prism_tbl, + .suspend = prism2sta_suspend, + .resume = prism2sta_resume, + .reset_resume = prism2sta_resume, /* fops, minor? */ }; -static int __init prism2usb_init(void) -{ - /* This call will result in calls to prism2sta_probe_usb. */ - return usb_register(&prism2_usb_driver); -}; - -static void __exit prism2usb_cleanup(void) -{ - usb_deregister(&prism2_usb_driver); -}; - -module_init(prism2usb_init); -module_exit(prism2usb_cleanup); +module_usb_driver(prism2_usb_driver); |
