2009-06-13 13:38:31 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* File: int.c
|
|
|
|
*
|
|
|
|
* Purpose: Handle USB interrupt endpoint
|
|
|
|
*
|
|
|
|
* Author: Jerry Chen
|
|
|
|
*
|
|
|
|
* Date: Apr. 2, 2004
|
|
|
|
*
|
|
|
|
* Functions:
|
|
|
|
*
|
|
|
|
* Revision History:
|
|
|
|
* 04-02-2004 Jerry Chen: Initial release
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "int.h"
|
|
|
|
#include "mac.h"
|
|
|
|
#include "power.h"
|
|
|
|
#include "usbpipe.h"
|
|
|
|
|
2014-07-05 20:24:27 +02:00
|
|
|
static const u8 fallback_rate0[5][5] = {
|
|
|
|
{RATE_18M, RATE_18M, RATE_12M, RATE_12M, RATE_12M},
|
|
|
|
{RATE_24M, RATE_24M, RATE_18M, RATE_12M, RATE_12M},
|
|
|
|
{RATE_36M, RATE_36M, RATE_24M, RATE_18M, RATE_18M},
|
|
|
|
{RATE_48M, RATE_48M, RATE_36M, RATE_24M, RATE_24M},
|
|
|
|
{RATE_54M, RATE_54M, RATE_48M, RATE_36M, RATE_36M}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const u8 fallback_rate1[5][5] = {
|
|
|
|
{RATE_18M, RATE_18M, RATE_12M, RATE_6M, RATE_6M},
|
|
|
|
{RATE_24M, RATE_24M, RATE_18M, RATE_6M, RATE_6M},
|
|
|
|
{RATE_36M, RATE_36M, RATE_24M, RATE_12M, RATE_12M},
|
|
|
|
{RATE_48M, RATE_48M, RATE_24M, RATE_12M, RATE_12M},
|
|
|
|
{RATE_54M, RATE_54M, RATE_36M, RATE_18M, RATE_18M}
|
|
|
|
};
|
|
|
|
|
2014-07-15 20:54:35 +02:00
|
|
|
void vnt_int_start_interrupt(struct vnt_private *priv)
|
2009-06-13 13:38:31 +02:00
|
|
|
{
|
2014-05-24 15:36:57 +02:00
|
|
|
unsigned long flags;
|
2014-07-15 20:54:32 +02:00
|
|
|
int status;
|
2009-06-13 13:38:31 +02:00
|
|
|
|
2014-07-15 20:54:33 +02:00
|
|
|
dev_dbg(&priv->usb->dev, "---->Interrupt Polling Thread\n");
|
2009-06-13 13:38:31 +02:00
|
|
|
|
2014-07-15 20:54:32 +02:00
|
|
|
spin_lock_irqsave(&priv->lock, flags);
|
2014-02-17 22:24:33 +01:00
|
|
|
|
2014-07-15 20:54:37 +02:00
|
|
|
status = vnt_start_interrupt_urb(priv);
|
2014-02-17 22:24:33 +01:00
|
|
|
|
2014-07-15 20:54:32 +02:00
|
|
|
spin_unlock_irqrestore(&priv->lock, flags);
|
2010-03-29 15:28:19 +02:00
|
|
|
}
|
2009-06-13 13:38:31 +02:00
|
|
|
|
2014-07-05 20:24:27 +02:00
|
|
|
static int vnt_int_report_rate(struct vnt_private *priv, u8 pkt_no, u8 tsr)
|
|
|
|
{
|
|
|
|
struct vnt_usb_send_context *context;
|
|
|
|
struct ieee80211_tx_info *info;
|
|
|
|
struct ieee80211_rate *rate;
|
|
|
|
u8 tx_retry = (tsr & 0xf0) >> 4;
|
|
|
|
s8 idx;
|
|
|
|
|
2014-07-19 13:30:04 +02:00
|
|
|
if (pkt_no >= priv->num_tx_context)
|
2014-07-05 20:24:27 +02:00
|
|
|
return -EINVAL;
|
|
|
|
|
2014-07-18 07:36:16 +02:00
|
|
|
context = priv->tx_context[pkt_no];
|
2014-07-05 20:24:27 +02:00
|
|
|
|
|
|
|
if (!context->skb)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
info = IEEE80211_SKB_CB(context->skb);
|
|
|
|
idx = info->control.rates[0].idx;
|
|
|
|
|
|
|
|
if (context->fb_option && !(tsr & (TSR_TMO | TSR_RETRYTMO))) {
|
|
|
|
u8 tx_rate;
|
|
|
|
u8 retry = tx_retry;
|
|
|
|
|
|
|
|
rate = ieee80211_get_tx_rate(priv->hw, info);
|
|
|
|
tx_rate = rate->hw_value - RATE_18M;
|
|
|
|
|
|
|
|
if (retry > 4)
|
|
|
|
retry = 4;
|
|
|
|
|
|
|
|
if (context->fb_option == AUTO_FB_0)
|
|
|
|
tx_rate = fallback_rate0[tx_rate][retry];
|
|
|
|
else if (context->fb_option == AUTO_FB_1)
|
|
|
|
tx_rate = fallback_rate1[tx_rate][retry];
|
|
|
|
|
2016-04-12 15:56:15 +02:00
|
|
|
if (info->band == NL80211_BAND_5GHZ)
|
2014-07-05 20:24:27 +02:00
|
|
|
idx = tx_rate - RATE_6M;
|
|
|
|
else
|
|
|
|
idx = tx_rate;
|
|
|
|
}
|
|
|
|
|
|
|
|
ieee80211_tx_info_clear_status(info);
|
|
|
|
|
|
|
|
info->status.rates[0].count = tx_retry;
|
|
|
|
|
|
|
|
if (!(tsr & (TSR_TMO | TSR_RETRYTMO))) {
|
|
|
|
info->status.rates[0].idx = idx;
|
|
|
|
info->flags |= IEEE80211_TX_STAT_ACK;
|
|
|
|
}
|
|
|
|
|
|
|
|
ieee80211_tx_status_irqsafe(priv->hw, context->skb);
|
|
|
|
|
|
|
|
context->in_use = false;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-07-15 20:54:34 +02:00
|
|
|
void vnt_int_process_data(struct vnt_private *priv)
|
2009-06-13 13:38:31 +02:00
|
|
|
{
|
2014-02-16 20:10:18 +01:00
|
|
|
struct vnt_interrupt_data *int_data;
|
2014-06-29 21:39:54 +02:00
|
|
|
struct ieee80211_low_level_stats *low_stats = &priv->low_stats;
|
2010-03-29 15:28:19 +02:00
|
|
|
|
2014-07-15 20:54:33 +02:00
|
|
|
dev_dbg(&priv->usb->dev, "---->s_nsInterruptProcessData\n");
|
2010-03-29 15:28:19 +02:00
|
|
|
|
2014-02-19 19:39:09 +01:00
|
|
|
int_data = (struct vnt_interrupt_data *)priv->int_buf.data_buf;
|
2014-02-16 20:10:18 +01:00
|
|
|
|
2014-07-05 20:24:27 +02:00
|
|
|
if (int_data->tsr0 & TSR_VALID)
|
|
|
|
vnt_int_report_rate(priv, int_data->pkt0, int_data->tsr0);
|
2014-02-16 20:10:18 +01:00
|
|
|
|
2014-07-05 20:24:27 +02:00
|
|
|
if (int_data->tsr1 & TSR_VALID)
|
|
|
|
vnt_int_report_rate(priv, int_data->pkt1, int_data->tsr1);
|
2014-02-16 20:10:18 +01:00
|
|
|
|
2014-07-05 20:24:27 +02:00
|
|
|
if (int_data->tsr2 & TSR_VALID)
|
|
|
|
vnt_int_report_rate(priv, int_data->pkt2, int_data->tsr2);
|
2014-02-16 20:10:18 +01:00
|
|
|
|
2014-07-05 20:24:27 +02:00
|
|
|
if (int_data->tsr3 & TSR_VALID)
|
|
|
|
vnt_int_report_rate(priv, int_data->pkt3, int_data->tsr3);
|
2014-02-16 20:10:18 +01:00
|
|
|
|
|
|
|
if (int_data->isr0 != 0) {
|
2014-06-25 22:14:32 +02:00
|
|
|
if (int_data->isr0 & ISR_BNTX &&
|
2017-01-06 13:16:45 +01:00
|
|
|
priv->op_mode == NL80211_IFTYPE_AP)
|
2014-07-13 11:42:50 +02:00
|
|
|
vnt_schedule_command(priv, WLAN_CMD_BECON_SEND);
|
2014-02-16 20:10:18 +01:00
|
|
|
|
2015-09-27 10:17:41 +02:00
|
|
|
if (int_data->isr0 & ISR_TBTT &&
|
|
|
|
priv->hw->conf.flags & IEEE80211_CONF_PS) {
|
|
|
|
if (!priv->wake_up_count)
|
|
|
|
priv->wake_up_count =
|
|
|
|
priv->hw->conf.listen_interval;
|
|
|
|
|
|
|
|
--priv->wake_up_count;
|
|
|
|
|
|
|
|
/* Turn on wake up to listen next beacon */
|
|
|
|
if (priv->wake_up_count == 1)
|
2014-07-13 11:42:50 +02:00
|
|
|
vnt_schedule_command(priv,
|
2015-09-27 10:17:41 +02:00
|
|
|
WLAN_CMD_TBTT_WAKEUP);
|
2010-03-29 15:28:19 +02:00
|
|
|
}
|
2014-07-19 13:30:13 +02:00
|
|
|
priv->current_tsf = le64_to_cpu(int_data->tsf);
|
2014-06-29 21:39:54 +02:00
|
|
|
|
|
|
|
low_stats->dot11RTSSuccessCount += int_data->rts_success;
|
|
|
|
low_stats->dot11RTSFailureCount += int_data->rts_fail;
|
|
|
|
low_stats->dot11ACKFailureCount += int_data->ack_fail;
|
|
|
|
low_stats->dot11FCSErrorCount += int_data->fcs_err;
|
2010-03-29 15:28:19 +02:00
|
|
|
}
|
2014-02-16 20:10:18 +01:00
|
|
|
|
2014-02-19 19:39:09 +01:00
|
|
|
priv->int_buf.in_use = false;
|
2009-06-13 13:38:31 +02:00
|
|
|
}
|