2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 * Purpose: handle dpc rx functions
38 static bool vnt_rx_data(struct vnt_private *priv, struct sk_buff *skb,
41 struct ieee80211_hw *hw = priv->hw;
42 struct ieee80211_supported_band *sband;
43 struct ieee80211_rx_status rx_status = { 0 };
44 struct ieee80211_hdr *hdr;
46 u8 *rsr, *new_rsr, *rssi;
50 u8 *rx_sts, *rx_rate, *sq;
53 u8 rate[MAX_RATE] = {2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108};
56 /* [31:16]RcvByteCount ( not include 4-byte Status ) */
57 frame_size = le16_to_cpu(*((__le16 *)(skb->data + 2)));
58 if (frame_size > 2346 || frame_size < 14) {
59 dev_dbg(&priv->pcid->dev, "------- WRONG Length 1\n");
63 skb_data = (u8 *)skb->data;
66 rx_rate = skb_data + 1;
68 sband = hw->wiphy->bands[hw->conf.chandef.chan->band];
70 for (r = RATE_1M; r < MAX_RATE; r++) {
71 if (*rx_rate == rate[r])
77 for (ii = 0; ii < sband->n_bitrates; ii++) {
78 if (sband->bitrates[ii].hw_value == r) {
84 if (ii == sband->n_bitrates) {
85 dev_dbg(&priv->pcid->dev, "Wrong RxRate %x\n", *rx_rate);
89 tsf_time = (__le64 *)(skb_data + bytes_received - 12);
90 sq = skb_data + bytes_received - 4;
91 new_rsr = skb_data + bytes_received - 3;
92 rssi = skb_data + bytes_received - 2;
93 rsr = skb_data + bytes_received - 1;
94 if (*rsr & (RSR_IVLDTYP | RSR_IVLDLEN))
97 RFvRSSITodBm(priv, *rssi, &rx_dbm);
99 priv->byBBPreEDRSSI = (u8)rx_dbm + 1;
100 priv->uCurrRSSI = *rssi;
103 skb_trim(skb, frame_size);
105 rx_status.mactime = le64_to_cpu(*tsf_time);
106 rx_status.band = hw->conf.chandef.chan->band;
107 rx_status.signal = rx_dbm;
109 rx_status.freq = hw->conf.chandef.chan->center_freq;
111 if (!(*rsr & RSR_CRCOK))
112 rx_status.flag |= RX_FLAG_FAILED_FCS_CRC;
114 hdr = (struct ieee80211_hdr *)(skb->data);
115 fc = hdr->frame_control;
117 rx_status.rate_idx = rate_idx;
119 if (ieee80211_has_protected(fc)) {
120 if (priv->byLocalID > REV_ID_VT3253_A1)
121 rx_status.flag |= RX_FLAG_DECRYPTED;
124 if (!(*new_rsr & NEWRSR_DECRYPTOK))
128 memcpy(IEEE80211_SKB_RXCB(skb), &rx_status, sizeof(rx_status));
130 ieee80211_rx_irqsafe(priv->hw, skb);
135 bool vnt_receive_frame(struct vnt_private *priv, PSRxDesc curr_rd)
137 PDEVICE_RD_INFO rd_info = curr_rd->pRDInfo;
143 dma_unmap_single(&priv->pcid->dev, rd_info->skb_dma,
144 priv->rx_buf_sz, DMA_FROM_DEVICE);
146 frame_size = le16_to_cpu(curr_rd->m_rd1RD1.wReqCount)
147 - cpu_to_le16(curr_rd->m_rd0RD0.wResCount);
149 if ((frame_size > 2364) || (frame_size < 33)) {
150 /* Frame Size error drop this packet.*/
151 dev_dbg(&priv->pcid->dev, "Wrong frame size %d\n", frame_size);
152 dev_kfree_skb_irq(skb);
156 if (vnt_rx_data(priv, skb, frame_size))
159 dev_kfree_skb_irq(skb);