1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
8 * Purpose: handle dpc rx functions
26 int vnt_rx_data(struct vnt_private
*priv
, struct vnt_rcb
*ptr_rcb
,
27 unsigned long bytes_received
)
29 struct ieee80211_hw
*hw
= priv
->hw
;
30 struct ieee80211_supported_band
*sband
;
32 struct ieee80211_rx_status
*rx_status
;
33 struct vnt_rx_header
*head
;
34 struct vnt_rx_tail
*tail
;
37 u16 rx_bitrate
, pay_load_with_padding
;
42 rx_status
= IEEE80211_SKB_RXCB(skb
);
44 /* [31:16]RcvByteCount ( not include 4-byte Status ) */
45 head
= (struct vnt_rx_header
*)skb
->data
;
46 frame_size
= head
->wbk_status
>> 16;
49 if (bytes_received
!= frame_size
) {
50 dev_dbg(&priv
->usb
->dev
, "------- WRONG Length 1\n");
54 if ((bytes_received
> 2372) || (bytes_received
<= 40)) {
55 /* Frame Size error drop this packet.*/
56 dev_dbg(&priv
->usb
->dev
, "------ WRONG Length 2\n");
60 /* real Frame Size = USBframe_size -4WbkStatus - 4RxStatus */
61 /* -8TSF - 4RSR - 4SQ3 - ?Padding */
63 /* if SQ3 the range is 24~27, if no SQ3 the range is 20~23 */
65 /*Fix hardware bug => PLCP_Length error */
66 if (((bytes_received
- head
->pay_load_len
) > 27) ||
67 ((bytes_received
- head
->pay_load_len
) < 24) ||
68 (bytes_received
< head
->pay_load_len
)) {
69 dev_dbg(&priv
->usb
->dev
, "Wrong PLCP Length %x\n",
74 sband
= hw
->wiphy
->bands
[hw
->conf
.chandef
.chan
->band
];
75 rx_bitrate
= head
->rx_rate
* 5; /* rx_rate * 5 */
77 for (ii
= 0; ii
< sband
->n_bitrates
; ii
++) {
78 if (sband
->bitrates
[ii
].bitrate
== rx_bitrate
) {
84 if (ii
== sband
->n_bitrates
) {
85 dev_dbg(&priv
->usb
->dev
, "Wrong Rx Bit Rate %d\n", rx_bitrate
);
89 pay_load_with_padding
= ((head
->pay_load_len
/ 4) +
90 ((head
->pay_load_len
% 4) ? 1 : 0)) * 4;
92 tail
= (struct vnt_rx_tail
*)(skb
->data
+
93 sizeof(*head
) + pay_load_with_padding
);
94 priv
->tsf_time
= le64_to_cpu(tail
->tsf_time
);
96 if (tail
->rsr
& (RSR_IVLDTYP
| RSR_IVLDLEN
))
99 vnt_rf_rssi_to_dbm(priv
, tail
->rssi
, &rx_dbm
);
101 priv
->bb_pre_ed_rssi
= (u8
)rx_dbm
+ 1;
102 priv
->current_rssi
= priv
->bb_pre_ed_rssi
;
104 skb_pull(skb
, sizeof(*head
));
105 skb_trim(skb
, head
->pay_load_len
);
107 rx_status
->mactime
= priv
->tsf_time
;
108 rx_status
->band
= hw
->conf
.chandef
.chan
->band
;
109 rx_status
->signal
= rx_dbm
;
111 rx_status
->freq
= hw
->conf
.chandef
.chan
->center_freq
;
113 if (!(tail
->rsr
& RSR_CRCOK
))
114 rx_status
->flag
|= RX_FLAG_FAILED_FCS_CRC
;
116 rx_status
->rate_idx
= rate_idx
;
118 if (tail
->new_rsr
& NEWRSR_DECRYPTOK
)
119 rx_status
->flag
|= RX_FLAG_DECRYPTED
;
121 ieee80211_rx_irqsafe(priv
->hw
, skb
);