/* Time to stay on the channel */ #define LBS_DWELL_PASSIVE 100 #define LBS_DWELL_ACTIVE 40
/*************************************************************************** * Misc utility functions * * TLVs are Marvell specific. They are very similar to IEs, they have the * same structure: type, length, data*. The only difference: for IEs, the * type and length are u8, but for TLVs they're __le16.
*/
/* * Convert NL80211's auth_type to the one from Libertas, see chapter 5.9.1 * in the firmware spec
*/ staticint lbs_auth_to_authtype(enum nl80211_auth_type auth_type)
{ int ret = -ENOTSUPP;
switch (auth_type) { case NL80211_AUTHTYPE_OPEN_SYSTEM: case NL80211_AUTHTYPE_SHARED_KEY:
ret = auth_type; break; case NL80211_AUTHTYPE_AUTOMATIC:
ret = NL80211_AUTHTYPE_OPEN_SYSTEM; break; case NL80211_AUTHTYPE_NETWORK_EAP:
ret = 0x80; break; default: /* silence compiler */ break;
} return ret;
}
/* * Various firmware commands need the list of supported rates, but with * the hight-bit set for basic rates
*/ staticint lbs_add_rates(u8 *rates)
{
size_t i;
/*************************************************************************** * TLV utility functions * * TLVs are Marvell specific. They are very similar to IEs, they have the * same structure: type, length, data*. The only difference: for IEs, the * type and length are u8, but for TLVs they're __le16.
*/
/* * Add rates TLV * * The rates are in lbs_bg_rates[], but for the 802.11b * rates the high bit is set. We add this TLV only because * there's a firmware which otherwise doesn't report all * APs in range.
*/ #define LBS_MAX_RATES_TLV_SIZE \
(sizeof(struct mrvl_ie_header) \
+ (ARRAY_SIZE(lbs_rates)))
/* Adds a TLV with all rates the hardware supports */ staticint lbs_add_supported_rates_tlv(u8 *tlv)
{
size_t i; struct mrvl_ie_rates_param_set *rate_tlv = (void *)tlv;
/* Add common rates from a TLV and return the new end of the TLV */ static u8 *
add_ie_rates(u8 *tlv, const u8 *ie, int *nrates)
{ int hw, ap, ap_max = ie[1];
u8 hw_rate;
if (ap_max > MAX_RATES) {
lbs_deb_assoc("invalid rates\n"); return tlv;
} /* Advance past IE header */
ie += 2;
/* * Add auth type TLV. * * This is only needed for newer firmware (V9 and up).
*/ #define LBS_MAX_AUTH_TYPE_TLV_SIZE \ sizeof(struct mrvl_ie_auth_type)
/* Find the first RSN or WPA IE to use */
wpaie = cfg80211_find_elem(WLAN_EID_RSN, ie, ie_len); if (!wpaie)
wpaie = cfg80211_find_vendor_elem(WLAN_OUI_MICROSOFT,
WLAN_OUI_TYPE_MICROSOFT_WPA,
ie, ie_len); if (!wpaie || wpaie->datalen > 128) return 0;
/* * Convert the found IE to a TLV. IEs use u8 for the header, * u8 type * u8 len * u8[] data * but TLVs use __le16 instead: * __le16 type * __le16 len * u8[] data
*/
wpatlv->header.type = cpu_to_le16(wpaie->id);
wpatlv->header.len = cpu_to_le16(wpaie->datalen);
memcpy(wpatlv->data, wpaie->data, wpaie->datalen);
/* Return the total number of bytes added to the TLV buffer */ returnsizeof(struct mrvl_ie_header) + wpaie->datalen;
}
/* Look for a WPS IE and add it to the probe request */
wpsie = cfg80211_find_vendor_elem(WLAN_OUI_MICROSOFT,
WLAN_OUI_TYPE_MICROSOFT_WPS,
ie, ie_len); if (!wpsie) return 0;
/* Convert the WPS IE to a TLV. The IE looks like this: * u8 type (WLAN_EID_VENDOR_SPECIFIC) * u8 len * u8[] data * but the TLV will look like this instead: * __le16 type (TLV_TYPE_WPS_ENROLLEE) * __le16 len * u8[] data
*/
wpstlv->header.type = cpu_to_le16(TLV_TYPE_WPS_ENROLLEE);
wpstlv->header.len = cpu_to_le16(wpsie->datalen);
memcpy(wpstlv->data, wpsie->data, wpsie->datalen);
/* Return the total number of bytes added to the TLV buffer */ returnsizeof(struct mrvl_ie_header) + wpsie->datalen;
}
/* * Set Channel
*/
staticint lbs_cfg_set_monitor_channel(struct wiphy *wiphy, struct net_device *dev, struct cfg80211_chan_def *chandef)
{ struct lbs_private *priv = wiphy_priv(wiphy); int ret = -ENOTSUPP;
if (cfg80211_get_chandef_type(chandef) != NL80211_CHAN_NO_HT) goto out;
ret = lbs_set_channel(priv, chandef->chan->hw_value);
out: return ret;
}
staticint lbs_cfg_set_mesh_channel(struct wiphy *wiphy, struct net_device *netdev, struct ieee80211_channel *channel)
{ struct lbs_private *priv = wiphy_priv(wiphy); int ret = -ENOTSUPP;
if (netdev != priv->mesh_dev) goto out;
ret = lbs_mesh_set_channel(priv, channel->hw_value);
out: return ret;
}
/* * Scanning
*/
/* * When scanning, the firmware doesn't send a nul packet with the power-safe * bit to the AP. So we cannot stay away from our current channel too long, * otherwise we loose data. So take a "nap" while scanning every other * while.
*/ #define LBS_SCAN_BEFORE_NAP 4
/* * When the firmware reports back a scan-result, it gives us an "u8 rssi", * which isn't really an RSSI, as it becomes larger when moving away from * the AP. Anyway, we need to convert that into mBm.
*/ #define LBS_SCAN_RSSI_TO_MBM(rssi) \
((-(int)rssi + 3)*100)
staticint lbs_ret_scan(struct lbs_private *priv, unsignedlong dummy, struct cmd_header *resp)
{ struct cfg80211_bss *bss; struct cmd_ds_802_11_scan_rsp *scanresp = (void *)resp; int bsssize; const u8 *pos; const u8 *tsfdesc; int tsfsize; int i; int ret = -EILSEQ;
if (scanresp->nr_sets == 0) {
ret = 0; goto done;
}
/* * The general layout of the scan response is described in chapter * 5.7.1. Basically we have a common part, then any number of BSS * descriptor sections. Finally we have section with the same number * of TSFs. * * cmd_ds_802_11_scan_rsp * cmd_header * pos_size * nr_sets * bssdesc 1 * bssid * rssi * timestamp * intvl * capa * IEs * bssdesc 2 * bssdesc n * MrvlIEtypes_TsfFimestamp_t * TSF for BSS 1 * TSF for BSS 2 * TSF for BSS n
*/
/* Validity check: we expect a Marvell-Local TLV */
i = get_unaligned_le16(tsfdesc);
tsfdesc += 2; if (i != TLV_TYPE_TSFTIMESTAMP) {
lbs_deb_scan("scan response: invalid TSF Timestamp %d\n", i); goto done;
}
/* * Validity check: the TLV holds TSF values with 8 bytes each, so * the size in the TLV must match the nr_sets value
*/
i = get_unaligned_le16(tsfdesc);
tsfdesc += 2; if (i / 8 != scanresp->nr_sets) {
lbs_deb_scan("scan response: invalid number of TSF timestamp " "sets (expected %d got %d)\n", scanresp->nr_sets,
i / 8); goto done;
}
for (i = 0; i < scanresp->nr_sets; i++) { const u8 *bssid; const u8 *ie; int left; int ielen; int rssi;
u16 intvl;
u16 capa; int chan_no = -1; const u8 *ssid = NULL;
u8 ssid_len = 0;
/* * Our scan command contains a TLV, consisting of a SSID TLV, a channel list * TLV, a rates TLV, and an optional WPS IE. Determine the maximum size of them:
*/ #define LBS_SCAN_MAX_CMD_SIZE \
(sizeof(struct cmd_ds_802_11_scan) \
+ LBS_MAX_SSID_TLV_SIZE \
+ LBS_MAX_CHANNEL_LIST_TLV_SIZE \
+ LBS_MAX_RATES_TLV_SIZE \
+ LBS_MAX_WPS_ENROLLEE_TLV_SIZE)
/* * Assumes priv->scan_req is initialized and valid * Assumes priv->scan_channel is initialized
*/ staticvoid lbs_scan_worker(struct work_struct *work)
{ struct lbs_private *priv =
container_of(work, struct lbs_private, scan_work.work); struct cmd_ds_802_11_scan *scan_cmd;
u8 *tlv; /* pointer into our current, growing TLV storage area */ int last_channel; int running, carrier;
scan_cmd = kzalloc(LBS_SCAN_MAX_CMD_SIZE, GFP_KERNEL); if (scan_cmd == NULL) return;
/* prepare fixed part of scan command */
scan_cmd->bsstype = CMD_BSS_TYPE_ANY;
/* stop network while we're away from our main channel */
running = !netif_queue_stopped(priv->dev);
carrier = netif_carrier_ok(priv->dev); if (running)
netif_stop_queue(priv->dev); if (carrier)
netif_carrier_off(priv->dev);
/* prepare fixed part of scan command */
tlv = scan_cmd->tlvbuffer;
if (priv->scan_channel < priv->scan_req->n_channels) {
cancel_delayed_work(&priv->scan_work); if (netif_running(priv->dev))
queue_delayed_work(priv->work_thread, &priv->scan_work,
msecs_to_jiffies(300));
}
/* This is the final data we are about to send */
scan_cmd->hdr.size = cpu_to_le16(tlv - (u8 *)scan_cmd);
lbs_deb_hex(LBS_DEB_SCAN, "SCAN_CMD", (void *)scan_cmd, sizeof(*scan_cmd));
lbs_deb_hex(LBS_DEB_SCAN, "SCAN_TLV", scan_cmd->tlvbuffer,
tlv - scan_cmd->tlvbuffer);
if (priv->scan_channel >= priv->scan_req->n_channels) { /* Mark scan done */
cancel_delayed_work(&priv->scan_work);
lbs_scan_done(priv);
}
/* Restart network */ if (carrier)
netif_carrier_on(priv->dev); if (running && !priv->tx_pending_len)
netif_wake_queue(priv->dev);
kfree(scan_cmd);
/* Wake up anything waiting on scan completion */ if (priv->scan_req == NULL) {
lbs_deb_scan("scan: waking up waiters\n");
wake_up_all(&priv->scan_q);
}
}
/* * Clean up priv->scan_req. Should be used to handle the allocation details.
*/ void lbs_scan_done(struct lbs_private *priv)
{
WARN_ON(!priv->scan_req);
if (priv->internal_scan) {
kfree(priv->scan_req);
} else { struct cfg80211_scan_info info = {
.aborted = false,
};
cfg80211_scan_done(priv->scan_req, &info);
}
priv->scan_req = NULL;
}
staticint lbs_cfg_scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
{ struct lbs_private *priv = wiphy_priv(wiphy); int ret = 0;
if (priv->scan_req || delayed_work_pending(&priv->scan_work)) { /* old scan request not yet processed */
ret = -EAGAIN; goto out;
}
staticint lbs_set_key_material(struct lbs_private *priv, int key_type, int key_info, const u8 *key, u16 key_len)
{ struct cmd_key_material cmd; int ret;
/* * Example for WPA (TKIP): * * cmd 5e 00 * size 34 00 * sequence xx xx * result 00 00 * action 01 00 * TLV type 00 01 key param * length 00 26 * key type 01 00 TKIP * key info 06 00 UNICAST | ENABLED * key len 20 00 * key 32 bytes
*/
memset(&cmd, 0, sizeof(cmd));
cmd.hdr.size = cpu_to_le16(sizeof(cmd));
cmd.action = cpu_to_le16(CMD_ACT_SET);
cmd.param.type = cpu_to_le16(TLV_TYPE_KEY_MATERIAL);
cmd.param.length = cpu_to_le16(sizeof(cmd.param) - 4);
cmd.param.keytypeid = cpu_to_le16(key_type);
cmd.param.keyinfo = cpu_to_le16(key_info);
cmd.param.keylen = cpu_to_le16(key_len); if (key && key_len)
memcpy(cmd.param.key, key, key_len);
ret = lbs_cmd_with_response(priv, CMD_802_11_KEY_MATERIAL, &cmd);
return ret;
}
/* * Sets the auth type (open, shared, etc) in the firmware. That * we use CMD_802_11_AUTHENTICATE is misleading, this firmware * command doesn't send an authentication frame at all, it just * stores the auth_type.
*/ staticint lbs_set_authtype(struct lbs_private *priv, struct cfg80211_connect_params *sme)
{ struct cmd_ds_802_11_authenticate cmd; int ret;
/* * cmd 11 00 * size 19 00 * sequence xx xx * result 00 00 * BSS id 00 13 19 80 da 30 * auth type 00 * reserved 00 00 00 00 00 00 00 00 00 00
*/
memset(&cmd, 0, sizeof(cmd));
cmd.hdr.size = cpu_to_le16(sizeof(cmd)); if (sme->bssid)
memcpy(cmd.bssid, sme->bssid, ETH_ALEN); /* convert auth_type */
ret = lbs_auth_to_authtype(sme->auth_type); if (ret < 0) goto done;
cmd.authtype = ret;
ret = lbs_cmd_with_response(priv, CMD_802_11_AUTHENTICATE, &cmd);
/* store for later use */
memcpy(priv->assoc_bss, bss->bssid, ETH_ALEN);
ret = lbs_cmd_with_response(priv, CMD_802_11_ASSOCIATE, cmd); if (ret) goto done;
/* generate connect message to cfg80211 */
resp = (void *) cmd; /* recast for easier field access */
status = le16_to_cpu(resp->statuscode);
/* Older FW versions map the IEEE 802.11 Status Code in the association * response to the following values returned in resp->statuscode: * * IEEE Status Code Marvell Status Code * 0 -> 0x0000 ASSOC_RESULT_SUCCESS * 13 -> 0x0004 ASSOC_RESULT_AUTH_REFUSED * 14 -> 0x0004 ASSOC_RESULT_AUTH_REFUSED * 15 -> 0x0004 ASSOC_RESULT_AUTH_REFUSED * 16 -> 0x0004 ASSOC_RESULT_AUTH_REFUSED * others -> 0x0003 ASSOC_RESULT_REFUSED * * Other response codes: * 0x0001 -> ASSOC_RESULT_INVALID_PARAMETERS (unused) * 0x0002 -> ASSOC_RESULT_TIMEOUT (internal timer expired waiting for * association response from the AP)
*/ if (MRVL_FW_MAJOR_REV(priv->fwrelease) <= 8) { switch (status) { case 0: break; case 1:
lbs_deb_assoc("invalid association parameters\n");
status = WLAN_STATUS_CAPS_UNSUPPORTED; break; case 2:
lbs_deb_assoc("timer expired while waiting for AP\n");
status = WLAN_STATUS_AUTH_TIMEOUT; break; case 3:
lbs_deb_assoc("association refused by AP\n");
status = WLAN_STATUS_ASSOC_DENIED_UNSPEC; break; case 4:
lbs_deb_assoc("authentication refused by AP\n");
status = WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION; break; default:
lbs_deb_assoc("association failure %d\n", status); /* v5 OLPC firmware does return the AP status code if * it's not one of the values above. Let that through.
*/ break;
}
}
if (status == 0) { /* TODO: get rid of priv->connect_status */
priv->connect_status = LBS_CONNECTED;
netif_carrier_on(priv->dev); if (!priv->tx_pending_len)
netif_tx_wake_all_queues(priv->dev);
}
/* SSIDs come after channels */
creq->ssids = (void *)&creq->channels[n_channels];
creq->n_channels = n_channels;
creq->n_ssids = 1;
/* Scan all available channels */
i = 0; for (band = 0; band < NUM_NL80211_BANDS; band++) { int j;
if (!wiphy->bands[band]) continue;
for (j = 0; j < wiphy->bands[band]->n_channels; j++) { /* ignore disabled channels */ if (wiphy->bands[band]->channels[j].flags &
IEEE80211_CHAN_DISABLED) continue;
creq->channels[i] = &wiphy->bands[band]->channels[j];
i++;
}
} if (i) { /* Set real number of channels specified in creq->channels[] */
creq->n_channels = i;
/* Scan for the SSID we're going to connect to */
memcpy(creq->ssids[0].ssid, sme->ssid, sme->ssid_len);
creq->ssids[0].ssid_len = sme->ssid_len;
} else { /* No channels found... */
kfree(creq);
creq = NULL;
}
if (!sme->bssid) { struct cfg80211_scan_request *creq;
/* * Scan for the requested network after waiting for existing * scans to finish.
*/
lbs_deb_assoc("assoc: waiting for existing scans\n");
wait_event_interruptible_timeout(priv->scan_q,
(priv->scan_req == NULL),
(15 * HZ));
creq = _new_connect_scan_req(wiphy, sme); if (!creq) {
ret = -EINVAL; goto done;
}
lbs_deb_assoc("assoc: scanning for compatible AP\n");
_internal_start_scan(priv, true, creq);
lbs_deb_assoc("assoc: waiting for scan to complete\n");
wait_event_interruptible_timeout(priv->scan_q,
(priv->scan_req == NULL),
(15 * HZ));
lbs_deb_assoc("assoc: scanning completed\n");
}
/* Find the BSS we want using available scan results */
bss = cfg80211_get_bss(wiphy, sme->channel, sme->bssid,
sme->ssid, sme->ssid_len, IEEE80211_BSS_TYPE_ESS,
IEEE80211_PRIVACY_ANY); if (!bss) {
wiphy_err(wiphy, "assoc: bss %pM not in scan results\n",
sme->bssid);
ret = -ENOENT; goto done;
}
lbs_deb_assoc("trying %pM\n", bss->bssid);
lbs_deb_assoc("cipher 0x%x, key index %d, key len %d\n",
sme->crypto.cipher_group,
sme->key_idx, sme->key_len);
/* As this is a new connection, clear locally stored WEP keys */
priv->wep_tx_key = 0;
memset(priv->wep_key, 0, sizeof(priv->wep_key));
memset(priv->wep_key_len, 0, sizeof(priv->wep_key_len));
/* set/remove WEP keys */ switch (sme->crypto.cipher_group) { case WLAN_CIPHER_SUITE_WEP40: case WLAN_CIPHER_SUITE_WEP104: /* Store provided WEP keys in priv-> */
priv->wep_tx_key = sme->key_idx;
priv->wep_key_len[sme->key_idx] = sme->key_len;
memcpy(priv->wep_key[sme->key_idx], sme->key, sme->key_len); /* Set WEP keys and WEP mode */
lbs_set_wep_keys(priv);
priv->mac_control |= CMD_ACT_MAC_WEP_ENABLE;
lbs_set_mac_control(priv); /* No RSN mode for WEP */
lbs_enable_rsn(priv, 0); break; case 0: /* there's no WLAN_CIPHER_SUITE_NONE definition */ /* * If we don't have no WEP, no WPA and no WPA2, * we remove all keys like in the WPA/WPA2 setup, * we just don't set RSN. * * Therefore: fall-through
*/ case WLAN_CIPHER_SUITE_TKIP: case WLAN_CIPHER_SUITE_CCMP: /* Remove WEP keys and WEP mode */
lbs_remove_wep_keys(priv);
priv->mac_control &= ~CMD_ACT_MAC_WEP_ENABLE;
lbs_set_mac_control(priv);
ret = lbs_set_authtype(priv, sme); if (ret == -ENOTSUPP) {
wiphy_err(wiphy, "unsupported authtype 0x%x\n", sme->auth_type); goto done;
}
lbs_set_radio(priv, preamble, 1);
/* Do the actual association */
ret = lbs_associate(priv, bss, sme);
done: if (bss)
cfg80211_put_bss(wiphy, bss); return ret;
}
int lbs_disconnect(struct lbs_private *priv, u16 reason)
{ struct cmd_ds_802_11_deauthenticate cmd; int ret;
memset(&cmd, 0, sizeof(cmd));
cmd.hdr.size = cpu_to_le16(sizeof(cmd)); /* Mildly ugly to use a locally store my own BSSID ... */
memcpy(cmd.macaddr, &priv->assoc_bss, ETH_ALEN);
cmd.reasoncode = cpu_to_le16(reason);
ret = lbs_cmd_with_response(priv, CMD_802_11_DEAUTHENTICATE, &cmd); if (ret) return ret;
#ifdef TODO struct lbs_private *priv = wiphy_priv(wiphy); /* * I think can keep this a NO-OP, because:
* - we clear all keys whenever we do lbs_cfg_connect() anyway * - neither "iw" nor "wpa_supplicant" won't call this during * an ongoing connection * - TODO: but I have to check if this is still true when * I set the AP to periodic re-keying * - we've not kzallec() something when we've added a key at * lbs_cfg_connect() or lbs_cfg_add_key(). * * This causes lbs_cfg_del_key() only called at disconnect time, * where we'd just waste time deleting a key that is not going * to be used anyway.
*/ if (key_index < 3 && priv->wep_key_len[key_index]) {
priv->wep_key_len[key_index] = 0;
lbs_set_wep_keys(priv);
} #endif
/* Get current RSSI */
ret = lbs_get_rssi(priv, &signal, &noise); if (ret == 0) {
sinfo->signal = signal;
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL);
}
/* Convert priv->cur_rate from hw_value to NL80211 value */ for (i = 0; i < ARRAY_SIZE(lbs_rates); i++) { if (priv->cur_rate == lbs_rates[i].hw_value) {
sinfo->txrate.legacy = lbs_rates[i].bitrate;
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE); break;
}
}
switch (type) { case NL80211_IFTYPE_MONITOR: case NL80211_IFTYPE_STATION: case NL80211_IFTYPE_ADHOC: break; default: return -EOPNOTSUPP;
}
if (priv->iface_running)
ret = lbs_set_iface_type(priv, type);
if (!ret)
priv->wdev->iftype = type;
return ret;
}
/* * IBSS (Ad-Hoc)
*/
/* * The firmware needs the following bits masked out of the beacon-derived * capability field when associating/joining to a BSS: * 9 (QoS), 11 (APSD), 12 (unused), 14 (unused), 15 (unused)
*/ #define CAPINFO_MASK (~(0xda00))
/* TODO: consider doing this at MACREG_INT_CODE_LINK_SENSED time */
priv->connect_status = LBS_CONNECTED;
netif_carrier_on(priv->dev); if (!priv->tx_pending_len)
netif_wake_queue(priv->dev);
}
/* set rates to the intersection of our rates and the rates in the
bss */
rcu_read_lock();
rates_eid = ieee80211_bss_get_ie(bss, WLAN_EID_SUPP_RATES); if (!rates_eid) {
lbs_add_rates(cmd.bss.rates);
} else {
rates_max = rates_eid[1]; if (rates_max > MAX_RATES) {
lbs_deb_join("invalid rates");
rcu_read_unlock();
ret = -EINVAL; goto out;
}
rates = cmd.bss.rates; for (hw = 0; hw < ARRAY_SIZE(lbs_rates); hw++) {
u8 hw_rate = lbs_rates[hw].bitrate / 5; for (i = 0; i < rates_max; i++) { if (hw_rate == (rates_eid[i+2] & 0x7f)) {
u8 rate = rates_eid[i+2]; if (rate == 0x02 || rate == 0x04 ||
rate == 0x0b || rate == 0x16)
rate |= 0x80;
*rates++ = rate;
}
}
}
}
rcu_read_unlock();
/* Only v8 and below support setting this */ if (MRVL_FW_MAJOR_REV(priv->fwrelease) <= 8) {
cmd.failtimeout = cpu_to_le16(MRVDRV_ASSOCIATION_TIME_OUT);
cmd.probedelay = cpu_to_le16(CMD_SCAN_PROBE_DELAY_TIME);
}
ret = lbs_cmd_with_response(priv, CMD_802_11_AD_HOC_JOIN, &cmd); if (ret) goto out;
/* * This is a sample response to CMD_802_11_AD_HOC_JOIN: * * response 2c 80 * size 09 00 * sequence xx xx * result 00 00 * reserved 00
*/
lbs_join_post(priv, params, bss->bssid, bss->capability);
if (!params->chandef.chan) {
ret = -ENOTSUPP; goto out;
}
ret = lbs_set_channel(priv, params->chandef.chan->hw_value); if (ret) goto out;
/* Search if someone is beaconing. This assumes that the
* bss list is populated already */
bss = cfg80211_get_bss(wiphy, params->chandef.chan, params->bssid,
params->ssid, params->ssid_len,
IEEE80211_BSS_TYPE_IBSS, IEEE80211_PRIVACY_ANY);
if (bss) {
ret = lbs_ibss_join_existing(priv, params, bss);
cfg80211_put_bss(wiphy, bss);
} else
ret = lbs_ibss_start_new(priv, params);
out: return ret;
}
staticint lbs_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
{ struct lbs_private *priv = wiphy_priv(wiphy); struct cmd_ds_802_11_ad_hoc_stop cmd; int ret = 0;
if (!(priv->fwcapinfo & FW_CAPINFO_PS)) { if (!enabled) return 0; else return -EINVAL;
} /* firmware does not work well with too long latency with power saving * enabled, so do not enable it if there is only polling, no * interrupts (like in some sdio hosts which can only * poll for sdio irqs)
*/ if (priv->is_polling) { if (!enabled) return 0; else return -EINVAL;
} if (!enabled) {
priv->psmode = LBS802_11POWERMODECAM; if (priv->psstate != PS_STATE_FULL_POWER)
lbs_set_ps_mode(priv,
PS_MODE_ACTION_EXIT_PS, true); return 0;
} if (priv->psmode != LBS802_11POWERMODECAM) return 0;
priv->psmode = LBS802_11POWERMODEMAX_PSP; if (priv->connect_status == LBS_CONNECTED)
lbs_set_ps_mode(priv, PS_MODE_ACTION_ENTER_PS, true); return 0;
}
/* * At this time lbs_private *priv doesn't even exist, so we just allocate * memory and don't initialize the wiphy further. This is postponed until we * can talk to the firmware and happens at registration time in * lbs_cfg_wiphy_register().
*/ struct wireless_dev *lbs_cfg_alloc(struct device *dev)
{ int ret = 0; struct wireless_dev *wdev;
wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL); if (!wdev) return ERR_PTR(-ENOMEM);
wdev->wiphy = wiphy_new(&lbs_cfg80211_ops, sizeof(struct lbs_private)); if (!wdev->wiphy) {
dev_err(dev, "cannot allocate wiphy\n");
ret = -ENOMEM; goto err_wiphy_new;
}
memcpy(priv->country_code, request->alpha2, sizeof(request->alpha2)); if (lbs_iface_active(priv))
lbs_set_11d_domain_info(priv);
}
/* * This function gets called after lbs_setup_firmware() determined the * firmware capabilities. So we can setup the wiphy according to our * hardware/firmware.
*/ int lbs_cfg_register(struct lbs_private *priv)
{ struct wireless_dev *wdev = priv->wdev; int ret;
/* * We could check priv->fwcapinfo && FW_CAPINFO_WPA, but I have * never seen a firmware without WPA
*/
wdev->wiphy->cipher_suites = cipher_suites;
wdev->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites);
wdev->wiphy->reg_notifier = lbs_reg_notifier;
ret = wiphy_register(wdev->wiphy); if (ret < 0)
pr_err("cannot register wiphy device\n");
priv->wiphy_registered = true;
ret = register_netdev(priv->dev); if (ret)
pr_err("cannot register network device\n");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.