/* * So, the firmware is somewhat stupid and doesn't know what places in its * memory incoming data should go to. By poking around in the firmware, we * can find some unused memory to upload our packets to. However, data that we * want the card to TX needs to stay intact until the card has told us that * it is done with it. This function finds empty places we can upload to and * marks allocated areas as reserved if necessary. p54_find_and_unlink_skb or * p54_free_skb frees allocated areas.
*/ staticint p54_assign_address(struct p54_common *priv, struct sk_buff *skb)
{ struct sk_buff *entry, *target_skb = NULL; struct ieee80211_tx_info *info; struct p54_tx_info *range; struct p54_hdr *data = (void *) skb->data; unsignedlong flags;
u32 last_addr = priv->rx_start;
u32 target_addr = priv->rx_start;
u16 len = priv->headroom + skb->len + priv->tailroom + 3;
info = IEEE80211_SKB_CB(skb);
range = (void *) info->rate_driver_data;
len = (range->extra_len + len) & ~0x3;
spin_lock_irqsave(&priv->tx_queue.lock, flags); if (unlikely(skb_queue_len(&priv->tx_queue) == 32)) { /* * The tx_queue is now really full. * * TODO: check if the device has crashed and reset it.
*/
spin_unlock_irqrestore(&priv->tx_queue.lock, flags); return -EBUSY;
}
skb_queue_walk(&priv->tx_queue, entry) {
u32 hole_size;
info = IEEE80211_SKB_CB(entry);
range = (void *) info->rate_driver_data;
hole_size = range->start_addr - last_addr;
if (!target_skb && hole_size >= len) {
target_skb = entry->prev;
hole_size -= len;
target_addr = last_addr; break;
}
last_addr = range->end_addr;
} if (unlikely(!target_skb)) { if (priv->rx_end - last_addr >= len) {
target_skb = skb_peek_tail(&priv->tx_queue); if (target_skb) {
info = IEEE80211_SKB_CB(target_skb);
range = (void *)info->rate_driver_data;
target_addr = range->end_addr;
}
} else {
spin_unlock_irqrestore(&priv->tx_queue.lock, flags); return -ENOSPC;
}
}
info = IEEE80211_SKB_CB(skb);
range = (void *) info->rate_driver_data;
range->start_addr = target_addr;
range->end_addr = target_addr + len;
data->req_id = cpu_to_le32(target_addr + priv->headroom); if (IS_DATA_FRAME(skb) &&
unlikely(GET_HW_QUEUE(skb) == P54_QUEUE_BEACON))
priv->beacon_req_id = data->req_id;
if (unlikely(GET_HW_QUEUE(skb) == P54_QUEUE_BEACON)) { if (priv->beacon_req_id == GET_REQ_ID(skb)) { /* this is the active beacon set anymore */
priv->beacon_req_id = 0;
}
complete(&priv->beacon_comp);
}
}
p54_wake_queues(priv);
}
/* * Even if the firmware is capable of dealing with incoming traffic, * while dozing, we have to prepared in case mac80211 uses PS-POLL * to retrieve outstanding frames from our AP. * (see comment in net/mac80211/mlme.c @ line 1993)
*/ staticvoid p54_pspoll_workaround(struct p54_common *priv, struct sk_buff *skb)
{ struct ieee80211_hdr *hdr = (void *) skb->data; struct ieee80211_tim_ie *tim_ie;
u8 *tim;
u8 tim_len; bool new_psm;
/* only beacons have a TIM IE */ if (!ieee80211_is_beacon(hdr->frame_control)) return;
if (!priv->aid) return;
/* only consider beacons from the associated BSSID */ if (!ether_addr_equal_64bits(hdr->addr3, priv->bssid)) return;
tim = p54_find_ie(skb, WLAN_EID_TIM); if (!tim) return;
/* * If the device is in a unspecified state we have to * ignore all data frames. Else we could end up with a * nasty crash.
*/ if (unlikely(priv->mode == NL80211_IFTYPE_UNSPECIFIED)) return 0;
if (!(hdr->flags & cpu_to_le16(P54_HDR_FLAG_DATA_IN_FCS_GOOD))) return 0;
if (hdr->decrypt_status == P54_DECRYPT_OK)
rx_status->flag |= RX_FLAG_DECRYPTED; if ((hdr->decrypt_status == P54_DECRYPT_FAIL_MICHAEL) ||
(hdr->decrypt_status == P54_DECRYPT_FAIL_TKIP))
rx_status->flag |= RX_FLAG_MMIC_ERROR;
/* LMAC API Page 10/29 - s_lm_data_in - clock * "usec accurate timestamp of hardware clock * at end of frame (before OFDM SIFS EOF padding"
*/
rx_status->flag |= RX_FLAG_MACTIME_END;
if (hdr->flags & cpu_to_le16(P54_HDR_FLAG_DATA_ALIGN))
header_len += hdr->align[0];
/* * Frames in P54_QUEUE_FWSCAN and P54_QUEUE_BEACON are * generated by the driver. Therefore tx_status is bogus * and we don't want to confuse the mac80211 stack.
*/ if (unlikely(entry_data->hw_queue < P54_QUEUE_FWSCAN)) {
dev_kfree_skb_any(entry); return ;
}
/* * Clear manually, ieee80211_tx_info_clear_status would * clear the counts too and we need them.
*/
memset_after(&info->status, 0, rates);
if (entry_hdr->flags & cpu_to_le16(P54_HDR_FLAG_DATA_ALIGN))
pad = entry_data->align[0];
/* walk through the rates array and adjust the counts */
count = payload->tries; for (idx = 0; idx < 4; idx++) { if (count >= info->status.rates[idx].count) {
count -= info->status.rates[idx].count;
} elseif (count > 0) {
info->status.rates[idx].count = count;
count = 0;
} else {
info->status.rates[idx].idx = -1;
info->status.rates[idx].count = 0;
}
}
/* Undo all changes to the frame. */ switch (entry_data->key_type) { case P54_CRYPTO_TKIPMICHAEL: {
u8 *iv = (u8 *)(entry_data->align + pad +
entry_data->crypt_offset);
/* Restore the original TKIP IV. */
iv[2] = iv[0];
iv[0] = iv[1];
iv[1] = (iv[0] | 0x20) & 0x7f; /* WEPSeed - 8.3.2.2 */
/* * STSW450X LMAC API page 26 - 3.8 Statistics * "The exact measurement period can be derived from the * timestamp member".
*/
dtime = tsf32 - priv->survey_raw.timestamp;
/* * STSW450X LMAC API page 26 - 3.8.1 Noise histogram * The LMAC samples RSSI, CCA and transmit state at regular * periods (typically 8 times per 1k [as in 1024] usec).
*/
cca = le32_to_cpu(stats->sample_cca);
tx = le32_to_cpu(stats->sample_tx);
rssi = 0; for (i = 0; i < ARRAY_SIZE(stats->sample_noise); i++)
rssi += le32_to_cpu(stats->sample_noise[i]);
/* * update statistics when more than a second is over since the * last call, or when a update is badly needed.
*/ if (dtotal && (priv->update_stats || dtime >= USEC_PER_SEC) &&
dtime >= dtotal) {
priv->survey_raw.timestamp = tsf32;
priv->update_stats = false;
unit = dtime / dtotal;
switch (le16_to_cpu(hdr->type)) { case P54_CONTROL_TYPE_TXDONE:
p54_rx_frame_sent(priv, skb); break; case P54_CONTROL_TYPE_TRAP:
p54_rx_trap(priv, skb); break; case P54_CONTROL_TYPE_BBP: break; case P54_CONTROL_TYPE_STAT_READBACK:
p54_rx_stats(priv, skb); break; case P54_CONTROL_TYPE_EEPROM_READBACK:
p54_rx_eeprom_readback(priv, skb); break; default:
wiphy_debug(priv->hw->wiphy, "not handling 0x%02x type control frame\n",
le16_to_cpu(hdr->type)); break;
} return 0;
}
/* returns zero if skb can be reused */ int p54_rx(struct ieee80211_hw *dev, struct sk_buff *skb)
{ struct p54_common *priv = dev->priv;
u16 type = le16_to_cpu(*((__le16 *)skb->data));
switch (priv->mode) { case NL80211_IFTYPE_MONITOR: /* * We have to set P54_HDR_FLAG_DATA_OUT_PROMISC for * every frame in promiscuous/monitor mode. * see STSW45x0C LMAC API - page 12.
*/
*aid = 0;
*flags |= P54_HDR_FLAG_DATA_OUT_PROMISC; break; case NL80211_IFTYPE_STATION:
*aid = 1; break; case NL80211_IFTYPE_AP: case NL80211_IFTYPE_ADHOC: case NL80211_IFTYPE_MESH_POINT: if (info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) {
*aid = 0;
*queue = P54_QUEUE_CAB; return;
}
if (info->control.hw_key) {
crypt_offset = ieee80211_get_hdrlen_from_skb(skb); if (info->control.hw_key->cipher == WLAN_CIPHER_SUITE_TKIP) {
u8 *iv = (u8 *)(skb->data + crypt_offset); /* * The firmware excepts that the IV has to have * this special format
*/
iv[1] = iv[0];
iv[0] = iv[2];
iv[2] = 0;
}
}
/* see how many rates got used */ for (i = 0; i < dev->max_rates; i++) { if (info->control.rates[i].idx < 0) break;
nrates++;
}
/* limit tries to 8/nrates per rate */ for (i = 0; i < nrates; i++) { /* * The magic expression here is equivalent to 8/nrates for * all values that matter, but avoids division and jumps. * Note that nrates can only take the values 1 through 4.
*/
calculated_tries[i] = min_t(int, ((15 >> nrates) | 1) + 1,
info->control.rates[i].count);
nremaining -= calculated_tries[i];
}
/* if there are tries left, distribute from back to front */ for (i = nrates - 1; nremaining > 0 && i >= 0; i--) { int tmp = info->control.rates[i].count - calculated_tries[i];
if (tmp <= 0) continue; /* RC requested more tries at this rate */
ridx = 0; for (i = 0; i < nrates && ridx < 8; i++) { /* we register the rates in perfect order */
rate = info->control.rates[i].idx; if (info->band == NL80211_BAND_5GHZ)
rate += 4;
/* store the count we actually calculated for TX status */
info->control.rates[i].count = calculated_tries[i];
if (burst_allowed)
hdr_flags |= P54_HDR_FLAG_DATA_OUT_BURST;
/* TODO: enable bursting */
hdr->flags = cpu_to_le16(hdr_flags);
hdr->tries = ridx;
txhdr->rts_rate_idx = 0; if (info->control.hw_key) {
txhdr->key_type = p54_convert_algo(info->control.hw_key->cipher);
txhdr->key_len = min((u8)16, info->control.hw_key->keylen);
memcpy(txhdr->key, info->control.hw_key->key, txhdr->key_len); if (info->control.hw_key->cipher == WLAN_CIPHER_SUITE_TKIP) { /* reserve space for the MIC key */
len += 8;
skb_put_data(skb,
&(info->control.hw_key->key[NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY]),
8);
} /* reserve some space for ICV */
len += info->control.hw_key->icv_len;
skb_put_zero(skb, info->control.hw_key->icv_len);
} else {
txhdr->key_type = 0;
txhdr->key_len = 0;
}
txhdr->crypt_offset = crypt_offset;
txhdr->hw_queue = queue;
txhdr->backlog = priv->tx_stats[queue].len - 1;
memset(txhdr->durations, 0, sizeof(txhdr->durations));
txhdr->tx_antenna = 2 & priv->tx_diversity_mask; if (priv->rxhw == 5) {
txhdr->longbow.cts_rate = cts_rate;
txhdr->longbow.output_power = cpu_to_le16(priv->output_power);
} else {
txhdr->normal.output_power = priv->output_power;
txhdr->normal.cts_rate = cts_rate;
} if (padding)
txhdr->align[0] = padding;
hdr->len = cpu_to_le16(len); /* modifies skb->cb and with it info, so must be last! */
p54info = (void *) info->rate_driver_data;
p54info->extra_len = extra_len;
p54_tx(priv, skb);
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.22 Sekunden
(vorverarbeitet)
¤
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.