1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
8 * Purpose: handle dpc rx functions
25 static bool vnt_rx_data(struct vnt_private
*priv
, struct sk_buff
*skb
,
28 struct ieee80211_hw
*hw
= priv
->hw
;
29 struct ieee80211_supported_band
*sband
;
30 struct ieee80211_rx_status rx_status
= { 0 };
31 struct ieee80211_hdr
*hdr
;
33 u8
*rsr
, *new_rsr
, *rssi
;
40 u8 rate
[MAX_RATE
] = {2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108};
43 /* [31:16]RcvByteCount ( not include 4-byte Status ) */
44 frame_size
= le16_to_cpu(*((__le16
*)(skb
->data
+ 2)));
45 if (frame_size
> 2346 || frame_size
< 14) {
46 dev_dbg(&priv
->pcid
->dev
, "------- WRONG Length 1\n");
50 skb_data
= (u8
*)skb
->data
;
52 rx_rate
= skb_data
+ 1;
54 sband
= hw
->wiphy
->bands
[hw
->conf
.chandef
.chan
->band
];
56 for (r
= RATE_1M
; r
< MAX_RATE
; r
++) {
57 if (*rx_rate
== rate
[r
])
63 for (ii
= 0; ii
< sband
->n_bitrates
; ii
++) {
64 if (sband
->bitrates
[ii
].hw_value
== r
) {
70 if (ii
== sband
->n_bitrates
) {
71 dev_dbg(&priv
->pcid
->dev
, "Wrong RxRate %x\n", *rx_rate
);
75 tsf_time
= (__le64
*)(skb_data
+ bytes_received
- 12);
76 new_rsr
= skb_data
+ bytes_received
- 3;
77 rssi
= skb_data
+ bytes_received
- 2;
78 rsr
= skb_data
+ bytes_received
- 1;
79 if (*rsr
& (RSR_IVLDTYP
| RSR_IVLDLEN
))
82 RFvRSSITodBm(priv
, *rssi
, &rx_dbm
);
84 priv
->byBBPreEDRSSI
= (u8
)rx_dbm
+ 1;
85 priv
->uCurrRSSI
= *rssi
;
88 skb_trim(skb
, frame_size
);
90 rx_status
.mactime
= le64_to_cpu(*tsf_time
);
91 rx_status
.band
= hw
->conf
.chandef
.chan
->band
;
92 rx_status
.signal
= rx_dbm
;
94 rx_status
.freq
= hw
->conf
.chandef
.chan
->center_freq
;
96 if (!(*rsr
& RSR_CRCOK
))
97 rx_status
.flag
|= RX_FLAG_FAILED_FCS_CRC
;
99 hdr
= (struct ieee80211_hdr
*)(skb
->data
);
100 fc
= hdr
->frame_control
;
102 rx_status
.rate_idx
= rate_idx
;
104 if (ieee80211_has_protected(fc
)) {
105 if (priv
->byLocalID
> REV_ID_VT3253_A1
)
106 rx_status
.flag
|= RX_FLAG_DECRYPTED
;
109 if (!(*new_rsr
& NEWRSR_DECRYPTOK
))
113 memcpy(IEEE80211_SKB_RXCB(skb
), &rx_status
, sizeof(rx_status
));
115 ieee80211_rx_irqsafe(priv
->hw
, skb
);
120 bool vnt_receive_frame(struct vnt_private
*priv
, struct vnt_rx_desc
*curr_rd
)
122 struct vnt_rd_info
*rd_info
= curr_rd
->rd_info
;
128 dma_unmap_single(&priv
->pcid
->dev
, rd_info
->skb_dma
,
129 priv
->rx_buf_sz
, DMA_FROM_DEVICE
);
131 frame_size
= le16_to_cpu(curr_rd
->rd1
.req_count
)
132 - le16_to_cpu(curr_rd
->rd0
.res_count
);
134 if ((frame_size
> 2364) || (frame_size
< 33)) {
135 /* Frame Size error drop this packet.*/
136 dev_dbg(&priv
->pcid
->dev
, "Wrong frame size %d\n", frame_size
);
137 dev_kfree_skb_irq(skb
);
141 if (vnt_rx_data(priv
, skb
, frame_size
))
144 dev_kfree_skb_irq(skb
);