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;
95 RFvRSSITodBm(priv, *rssi, &rx_dbm);
97 priv->byBBPreEDRSSI = (u8)rx_dbm + 1;
98 priv->uCurrRSSI = *rssi;
101 skb_trim(skb, frame_size);
103 rx_status.mactime = le64_to_cpu(*tsf_time);
104 rx_status.band = hw->conf.chandef.chan->band;
105 rx_status.signal = rx_dbm;
107 rx_status.freq = hw->conf.chandef.chan->center_freq;
109 hdr = (struct ieee80211_hdr *)(skb->data);
110 fc = hdr->frame_control;
112 rx_status.rate_idx = rate_idx;
114 if (ieee80211_has_protected(fc)) {
115 if (priv->byLocalID > REV_ID_VT3253_A1)
116 rx_status.flag = RX_FLAG_DECRYPTED;
119 if (priv->vif && priv->bDiversityEnable) {
120 if (ieee80211_is_data(fc) &&
121 (frame_size > 50) && priv->vif->bss_conf.assoc)
122 BBvAntennaDiversity(priv, priv->rx_rate, 0);
125 memcpy(IEEE80211_SKB_RXCB(skb), &rx_status, sizeof(rx_status));
127 ieee80211_rx_irqsafe(priv->hw, skb);
132 bool vnt_receive_frame(struct vnt_private *priv, PSRxDesc curr_rd)
134 PDEVICE_RD_INFO rd_info = curr_rd->pRDInfo;
140 pci_unmap_single(priv->pcid, rd_info->skb_dma,
141 priv->rx_buf_sz, PCI_DMA_FROMDEVICE);
143 frame_size = le16_to_cpu(curr_rd->m_rd1RD1.wReqCount)
144 - cpu_to_le16(curr_rd->m_rd0RD0.wResCount);
146 if ((frame_size > 2364) || (frame_size < 33)) {
147 /* Frame Size error drop this packet.*/
148 dev_dbg(&priv->pcid->dev, "Wrong frame size %d\n", frame_size);
149 dev_kfree_skb_irq(skb);
153 if (vnt_rx_data(priv, skb, frame_size))
156 dev_kfree_skb_irq(skb);