/* * Copyright (c) 2004-2011 Atheros Communications Inc. * Copyright (c) 2011-2012 Qualcomm Atheros, Inc. * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
if (is_multicast_ether_addr(eth_hdr->h_dest)) return ENDPOINT_2;
for (i = 0; i < ar->node_num; i++) { if (memcmp(eth_hdr->h_dest, ar->node_map[i].mac_addr,
ETH_ALEN) == 0) {
*map_no = i + 1;
ar->node_map[i].tx_pend++; return ar->node_map[i].ep_id;
}
if ((ep_map == -1) && !ar->node_map[i].tx_pend)
ep_map = i;
}
if (ep_map == -1) {
ep_map = ar->node_num;
ar->node_num++; if (ar->node_num > MAX_NODE_NUM) return ENDPOINT_UNUSED;
}
for (i = ENDPOINT_2; i <= ENDPOINT_5; i++) { if (!ar->tx_pending[i]) {
ar->node_map[ep_map].ep_id = i; break;
}
/* * No free endpoint is available, start redistribution on * the inuse endpoints.
*/ if (i == ENDPOINT_5) {
ar->node_map[ep_map].ep_id = ar->next_ep_id;
ar->next_ep_id++; if (ar->next_ep_id > ENDPOINT_5)
ar->next_ep_id = ENDPOINT_2;
}
}
if (conn->sta_flags & STA_PS_APSD_TRIGGER) { /* * This tx is because of a uAPSD trigger, determine * more and EOSP bit. Set EOSP if queue is empty * or sufficient frames are delivered for this trigger.
*/
spin_lock_bh(&conn->psq_lock); if (!skb_queue_empty(&conn->apsdq))
*flags |= WMI_DATA_HDR_FLAGS_MORE; elseif (conn->sta_flags & STA_PS_APSD_EOSP)
*flags |= WMI_DATA_HDR_FLAGS_EOSP;
*flags |= WMI_DATA_HDR_FLAGS_UAPSD;
spin_unlock_bh(&conn->psq_lock); returnfalse;
} elseif (!conn->apsd_info) { returnfalse;
}
if (test_bit(WMM_ENABLED, &vif->flags)) {
ether_type = be16_to_cpu(datap->h_proto); if (is_ethertype(ether_type)) { /* packet is in DIX format */
ip_hdr = (u8 *)(datap + 1);
} else { /* packet is in 802.3 format */
llc_hdr = (struct ath6kl_llc_snap_hdr *)
(datap + 1);
ether_type = be16_to_cpu(llc_hdr->eth_type);
ip_hdr = (u8 *)(llc_hdr + 1);
}
if (ether_type == IP_ETHERTYPE)
up = ath6kl_wmi_determine_user_priority(
ip_hdr, 0);
}
traffic_class = ath6kl_wmi_get_traffic_class(up);
if ((conn->apsd_info & (1 << traffic_class)) == 0) returnfalse;
/* Queue the frames if the STA is sleeping */
spin_lock_bh(&conn->psq_lock);
is_apsdq_empty = skb_queue_empty(&conn->apsdq);
skb_queue_tail(&conn->apsdq, skb);
spin_unlock_bh(&conn->psq_lock);
/* * If this is the first pkt getting queued * for this STA, update the PVB for this STA
*/ if (is_apsdq_empty) {
ath6kl_wmi_set_apsd_bfrd_traf(ar->wmi,
vif->fw_vif_idx,
conn->aid, 1, 0);
}
*flags |= WMI_DATA_HDR_FLAGS_UAPSD;
if (conn->sta_flags & STA_PS_POLLED) {
spin_lock_bh(&conn->psq_lock); if (!skb_queue_empty(&conn->psq))
*flags |= WMI_DATA_HDR_FLAGS_MORE;
spin_unlock_bh(&conn->psq_lock); returnfalse;
}
/* Queue the frames if the STA is sleeping */
spin_lock_bh(&conn->psq_lock);
is_psq_empty = skb_queue_empty(&conn->psq);
skb_queue_tail(&conn->psq, skb);
spin_unlock_bh(&conn->psq_lock);
/* * If this is the first pkt getting queued * for this STA, update the PVB for this * STA.
*/ if (is_psq_empty)
ath6kl_wmi_set_pvb_cmd(ar->wmi,
vif->fw_vif_idx,
conn->aid, 1); returntrue;
}
for (ctr = 0; ctr < AP_MAX_NUM_STA; ctr++) { if (ar->sta_list[ctr].sta_flags & STA_PS_SLEEP) {
q_mcast = true; break;
}
}
if (q_mcast) { /* * If this transmit is not because of a Dtim Expiry * q it.
*/ if (!test_bit(DTIM_EXPIRED, &vif->flags)) { bool is_mcastq_empty = false;
/* * If this is the first Mcast pkt getting * queued indicate to the target to set the * BitmapControl LSB of the TIM IE.
*/ if (is_mcastq_empty)
ath6kl_wmi_set_pvb_cmd(ar->wmi,
vif->fw_vif_idx,
MCAST_AID, 1);
ps_queued = true;
} else { /* * This transmit is because of Dtim expiry. * Determine if MoreData bit has to be set.
*/
spin_lock_bh(&ar->mcastpsq_lock); if (!skb_queue_empty(&ar->mcastpsq))
*flags |= WMI_DATA_HDR_FLAGS_MORE;
spin_unlock_bh(&ar->mcastpsq_lock);
}
}
} else {
conn = ath6kl_find_sta(vif, datap->h_dest); if (!conn) {
dev_kfree_skb(skb);
/* Inform the caller that the skb is consumed */ returntrue;
}
if (test_bit(WMI_CTRL_EP_FULL, &ar->flag) && (eid == ar->ctrl_ep)) { /* * Control endpoint is full, don't allocate resources, we * are just going to drop this packet.
*/
cookie = NULL;
ath6kl_err("wmi ctrl ep full, dropping pkt : 0x%p, len:%d\n",
skb, skb->len);
} else {
cookie = ath6kl_alloc_cookie(ar);
}
if (cookie == NULL) {
spin_unlock_bh(&ar->lock);
status = -ENOMEM; goto fail_ctrl_tx;
}
/* * This interface is asynchronous, if there is an error, cleanup * will happen in the TX completion callback.
*/
ath6kl_htc_tx(ar->htc_target, &cookie->htc_pkt);
if (eid == 0 || eid == ENDPOINT_UNUSED) {
ath6kl_err("eid %d is not mapped!\n", eid);
spin_unlock_bh(&ar->lock); goto fail_tx;
}
/* allocate resource for this packet */
cookie = ath6kl_alloc_cookie(ar);
if (!cookie) {
spin_unlock_bh(&ar->lock); goto fail_tx;
}
/* update counts while the lock is held */
ar->tx_pending[eid]++;
ar->total_tx_data_pend++;
spin_unlock_bh(&ar->lock);
if (!IS_ALIGNED((unsignedlong) skb->data - HTC_HDR_LENGTH, 4) &&
skb_cloned(skb)) { /* * We will touch (move the buffer data to align it. Since the * skb buffer is cloned and not only the header is changed, we * have to copy it to allow the changes. Since we are copying * the data here, we may as well align it by reserving suitable * headroom to avoid the memmove in ath6kl_htc_tx_buf_align().
*/ struct sk_buff *nskb;
/* * HTC interface is asynchronous, if this fails, cleanup will * happen in the ath6kl_tx_complete callback.
*/
ath6kl_htc_tx(ar->htc_target, &cookie->htc_pkt);
/* indicate tx activity or inactivity on a WMI stream */ void ath6kl_indicate_tx_activity(void *devt, u8 traffic_class, bool active)
{ struct ath6kl *ar = devt; enum htc_endpoint_id eid; int i;
eid = ar->ac2ep_map[traffic_class];
if (!test_bit(WMI_ENABLED, &ar->flag)) goto notify_htc;
spin_lock_bh(&ar->lock);
ar->ac_stream_active[traffic_class] = active;
if (active) { /* * Keep track of the active stream with the highest * priority.
*/ if (ar->ac_stream_pri_map[traffic_class] >
ar->hiac_stream_active_pri) /* set the new highest active priority */
ar->hiac_stream_active_pri =
ar->ac_stream_pri_map[traffic_class];
} else { /* * We may have to search for the next active stream * that is the highest priority.
*/ if (ar->hiac_stream_active_pri ==
ar->ac_stream_pri_map[traffic_class]) { /* * The highest priority stream just went inactive * reset and search for the "next" highest "active" * priority stream.
*/
ar->hiac_stream_active_pri = 0;
for (i = 0; i < WMM_NUM_AC; i++) { if (ar->ac_stream_active[i] &&
(ar->ac_stream_pri_map[i] >
ar->hiac_stream_active_pri)) /* * Set the new highest active * priority.
*/
ar->hiac_stream_active_pri =
ar->ac_stream_pri_map[i];
}
}
}
spin_unlock_bh(&ar->lock);
notify_htc: /* notify HTC, this may cause credit distribution changes */
ath6kl_htc_activity_changed(ar->htc_target, eid, active);
}
if (endpoint == ar->ctrl_ep) { /* * Under normal WMI if this is getting full, then something * is running rampant the host should not be exhausting the * WMI queue with too many commands the only exception to * this is during testing using endpointping.
*/
set_bit(WMI_CTRL_EP_FULL, &ar->flag);
ath6kl_err("wmi ctrl ep is full\n");
ath6kl_recovery_err_notify(ar, ATH6KL_FW_EP_FULL); return action;
}
if (packet->info.tx.tag == ATH6KL_CONTROL_PKT_TAG) return action;
/* * The last MAX_HI_COOKIE_NUM "batch" of cookies are reserved for * the highest active stream.
*/ if (ar->ac_stream_pri_map[ar->ep2ac_map[endpoint]] <
ar->hiac_stream_active_pri &&
ar->cookie_count <=
target->endpoint[endpoint].tx_drop_packet_threshold) /* * Give preference to the highest priority stream by * dropping the packets which overflowed.
*/
action = HTC_SEND_FULL_DROP;
void ath6kl_tx_data_cleanup(struct ath6kl *ar)
{ int i;
/* flush all the data (non-control) streams */ for (i = 0; i < WMM_NUM_AC; i++)
ath6kl_htc_flush_txep(ar->htc_target, ar->ac2ep_map[i],
ATH6KL_DATA_PKT_TAG);
}
/* * Callback to allocate a receive buffer for a pending packet. We use a * pre-allocated list of buffers of maximum AMSDU size (4K).
*/ struct htc_packet *ath6kl_alloc_amsdu_rxbuf(struct htc_target *target, enum htc_endpoint_id endpoint, int len)
{ struct ath6kl *ar = target->dev->ar; struct htc_packet *packet = NULL; struct list_head *pkt_pos; int refill_cnt = 0, depth = 0;
/* * idx_end is typically the last possible frame in the window, * but changes to 'the' seq_no, when BAR comes. If seq_no * is non-zero, we will go up to that and stop. * Note: last seq no in current window will occupy the same * index position as index that is just previous to start. * An imp point : if win_sz is 7, for seq_no space of 4095, * then, there would be holes when sequence wrap around occurs. * Target should judiciously choose the win_sz, based on * this condition. For 4095, (TID_WINDOW_SZ = 2 x win_sz * 2, 4, 8, 16 win_sz works fine). * We must deque from "idx" to "idx_end", including both.
*/
seq_end = seq_no ? seq_no : rxtid->seq_next;
idx_end = AGGR_WIN_IDX(seq_end, rxtid->hold_q_sz);
do {
node = &rxtid->hold_q[idx]; if ((order == 1) && (!node->skb)) break;
if (node->skb) { if (node->is_amsdu)
aggr_slice_amsdu(agg_conn->aggr_info, rxtid,
node->skb); else
skb_queue_tail(&rxtid->q, node->skb);
node->skb = NULL;
} else {
stats->num_hole++;
}
if (((end < extended_end) &&
(cur < end || cur > extended_end)) ||
((end > extended_end) && (cur > extended_end) &&
(cur < end))) {
aggr_deque_frms(agg_conn, tid, 0, 0);
spin_lock_bh(&rxtid->lock); if (cur >= rxtid->hold_q_sz - 1)
rxtid->seq_next = cur - (rxtid->hold_q_sz - 1); else
rxtid->seq_next = ATH6KL_MAX_SEQ_NO -
(rxtid->hold_q_sz - 2 - cur);
spin_unlock_bh(&rxtid->lock);
} else { /* * Dequeue only those frames that are outside the * new shifted window.
*/ if (cur >= rxtid->hold_q_sz - 1)
st = cur - (rxtid->hold_q_sz - 1); else
st = ATH6KL_MAX_SEQ_NO -
(rxtid->hold_q_sz - 2 - cur);
aggr_deque_frms(agg_conn, tid, st, 0);
}
stats->num_oow++;
}
idx = AGGR_WIN_IDX(seq_no, rxtid->hold_q_sz);
node = &rxtid->hold_q[idx];
spin_lock_bh(&rxtid->lock);
/* * Is the cur frame duplicate or something beyond our window(hold_q * -> which is 2x, already)? * * 1. Duplicate is easy - drop incoming frame. * 2. Not falling in current sliding window. * 2a. is the frame_seq_no preceding current tid_seq_no? * -> drop the frame. perhaps sender did not get our ACK. * this is taken care of above. * 2b. is the frame_seq_no beyond window(st, TID_WINDOW_SZ); * -> Taken care of it above, by moving window forward.
*/
dev_kfree_skb(node->skb);
stats->num_dups++;
if (node->is_amsdu)
stats->num_amsdu++; else
stats->num_mpdu++;
spin_unlock_bh(&rxtid->lock);
aggr_deque_frms(agg_conn, tid, 0, 1);
if (agg_conn->timer_scheduled) return is_queued;
spin_lock_bh(&rxtid->lock); for (idx = 0; idx < rxtid->hold_q_sz; idx++) { if (rxtid->hold_q[idx].skb) { /* * There is a frame in the queue and no * timer so start a timer to ensure that * the frame doesn't remain stuck * forever.
*/
agg_conn->timer_scheduled = true;
mod_timer(&agg_conn->timer,
(jiffies + (HZ * AGGR_RX_TIMEOUT) / 1000));
rxtid->timer_mon = true; break;
}
}
spin_unlock_bh(&rxtid->lock);
/* * If the APSD q for this STA is not empty, dequeue and * send a pkt from the head of the q. Also update the * More data bit in the WMI_DATA_HDR if there are * more pkts for this STA in the APSD q. * If there are no more pkts for this STA, * update the APSD bitmap for this STA.
*/
num_frames_to_deliver = (conn->apsd_info >> ATH6KL_APSD_NUM_OF_AC) &
ATH6KL_APSD_FRAME_MASK; /* * Number of frames to send in a service period is * indicated by the station * in the QOS_INFO of the association request * If it is zero, send all frames
*/ if (!num_frames_to_deliver)
num_frames_to_deliver = ATH6KL_APSD_ALL_FRAME;
/* * In the case of AP mode we may receive NULL data frames * that do not have LLC hdr. They are 16 bytes in size. * Allow these frames in the AP mode.
*/ if (vif->nw_type != AP_NETWORK &&
((packet->act_len < min_hdr_len) ||
(packet->act_len > WMI_MAX_AMSDU_RX_DATA_FRAME_LENGTH))) {
ath6kl_info("frame len is too short or too long\n");
vif->ndev->stats.rx_errors++;
vif->ndev->stats.rx_length_errors++;
dev_kfree_skb(skb); return;
}
/* * If there is a change in PS state of the STA, * take appropriate steps: * * 1. If Sleep-->Awake, flush the psq for the STA * Clear the PVB for the STA. * 2. If Awake-->Sleep, Starting queueing frames * the STA.
*/
prev_ps = !!(conn->sta_flags & STA_PS_SLEEP);
if (ps_state)
conn->sta_flags |= STA_PS_SLEEP; else
conn->sta_flags &= ~STA_PS_SLEEP;
/* Accept trigger only when the station is in sleep */ if ((conn->sta_flags & STA_PS_SLEEP) && trig_state)
ath6kl_uapsd_trigger_frame_rx(vif, conn);
if (!is_apsdq_empty)
ath6kl_wmi_set_apsd_bfrd_traf(
ar->wmi,
vif->fw_vif_idx,
conn->aid, 0, 0);
/* Clear the PVB for this STA */
ath6kl_wmi_set_pvb_cmd(ar->wmi, vif->fw_vif_idx,
conn->aid, 0);
}
}
/* drop NULL data frames here */ if ((packet->act_len < min_hdr_len) ||
(packet->act_len >
WMI_MAX_AMSDU_RX_DATA_FRAME_LENGTH)) {
dev_kfree_skb(skb); return;
}
}
switch (meta_type) { case WMI_META_VERSION_1:
skb_pull(skb, sizeof(struct wmi_rx_meta_v1)); break; case WMI_META_VERSION_2:
meta = (struct wmi_rx_meta_v2 *) skb->data; if (meta->csum_flags & 0x1) {
skb->ip_summed = CHECKSUM_COMPLETE;
skb->csum = (__force __wsum) meta->csum;
}
skb_pull(skb, sizeof(struct wmi_rx_meta_v2)); break; default: break;
}
skb_pull(skb, pad_before_data_start);
if (dot11_hdr)
status = ath6kl_wmi_dot11_hdr_remove(ar->wmi, skb); elseif (!is_amsdu)
status = ath6kl_wmi_dot3_2_dix(skb);
if (status) { /* * Drop frames that could not be processed (lack of * memory, etc.)
*/
dev_kfree_skb(skb); return;
}
if (!(vif->ndev->flags & IFF_UP)) {
dev_kfree_skb(skb); return;
}
if (vif->nw_type == AP_NETWORK) {
datap = (struct ethhdr *) skb->data; if (is_multicast_ether_addr(datap->h_dest)) /* * Bcast/Mcast frames should be sent to the * OS stack as well as on the air.
*/
skb1 = skb_copy(skb, GFP_ATOMIC); else { /* * Search for a connected STA with dstMac * as the Mac address. If found send the * frame to it on the air else send the * frame up the stack.
*/
conn = ath6kl_find_sta(vif, datap->h_dest);
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.