xref: /linux/drivers/net/wireless/ti/wlcore/rx.h (revision 75bf465f0bc33e9b776a46d6a1b9b990f5fb7c37)
1*2b27bdccSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
27b3115f2SLuciano Coelho /*
37b3115f2SLuciano Coelho  * This file is part of wl1271
47b3115f2SLuciano Coelho  *
57b3115f2SLuciano Coelho  * Copyright (C) 1998-2009 Texas Instruments. All rights reserved.
67b3115f2SLuciano Coelho  * Copyright (C) 2008-2009 Nokia Corporation
77b3115f2SLuciano Coelho  *
87b3115f2SLuciano Coelho  * Contact: Luciano Coelho <luciano.coelho@nokia.com>
97b3115f2SLuciano Coelho  */
107b3115f2SLuciano Coelho 
117b3115f2SLuciano Coelho #ifndef __RX_H__
127b3115f2SLuciano Coelho #define __RX_H__
137b3115f2SLuciano Coelho 
147b3115f2SLuciano Coelho #include <linux/bitops.h>
157b3115f2SLuciano Coelho 
167b3115f2SLuciano Coelho #define WL1271_RX_MAX_RSSI -30
177b3115f2SLuciano Coelho #define WL1271_RX_MIN_RSSI -95
187b3115f2SLuciano Coelho 
195d6af28aSGuy Mishol #define RSSI_LEVEL_BITMASK	0x7F
205d6af28aSGuy Mishol #define ANT_DIVERSITY_BITMASK	BIT(7)
215d6af28aSGuy Mishol 
227b3115f2SLuciano Coelho #define SHORT_PREAMBLE_BIT   BIT(0)
237b3115f2SLuciano Coelho #define OFDM_RATE_BIT        BIT(6)
247b3115f2SLuciano Coelho #define PBCC_RATE_BIT        BIT(7)
257b3115f2SLuciano Coelho 
267b3115f2SLuciano Coelho #define PLCP_HEADER_LENGTH 8
277b3115f2SLuciano Coelho #define RX_DESC_PACKETID_SHIFT 11
287b3115f2SLuciano Coelho #define RX_MAX_PACKET_ID 3
297b3115f2SLuciano Coelho 
307b3115f2SLuciano Coelho #define RX_DESC_VALID_FCS         0x0001
317b3115f2SLuciano Coelho #define RX_DESC_MATCH_RXADDR1     0x0002
327b3115f2SLuciano Coelho #define RX_DESC_MCAST             0x0004
337b3115f2SLuciano Coelho #define RX_DESC_STAINTIM          0x0008
347b3115f2SLuciano Coelho #define RX_DESC_VIRTUAL_BM        0x0010
357b3115f2SLuciano Coelho #define RX_DESC_BCAST             0x0020
367b3115f2SLuciano Coelho #define RX_DESC_MATCH_SSID        0x0040
377b3115f2SLuciano Coelho #define RX_DESC_MATCH_BSSID       0x0080
387b3115f2SLuciano Coelho #define RX_DESC_ENCRYPTION_MASK   0x0300
397b3115f2SLuciano Coelho #define RX_DESC_MEASURMENT        0x0400
407b3115f2SLuciano Coelho #define RX_DESC_SEQNUM_MASK       0x1800
417b3115f2SLuciano Coelho #define	RX_DESC_MIC_FAIL	  0x2000
427b3115f2SLuciano Coelho #define	RX_DESC_DECRYPT_FAIL	  0x4000
437b3115f2SLuciano Coelho 
447b3115f2SLuciano Coelho /*
457b3115f2SLuciano Coelho  * RX Descriptor flags:
467b3115f2SLuciano Coelho  *
477b3115f2SLuciano Coelho  * Bits 0-1 - band
487b3115f2SLuciano Coelho  * Bit  2   - STBC
497b3115f2SLuciano Coelho  * Bit  3   - A-MPDU
507b3115f2SLuciano Coelho  * Bit  4   - HT
517b3115f2SLuciano Coelho  * Bits 5-7 - encryption
527b3115f2SLuciano Coelho  */
537b3115f2SLuciano Coelho #define WL1271_RX_DESC_BAND_MASK    0x03
547b3115f2SLuciano Coelho #define WL1271_RX_DESC_ENCRYPT_MASK 0xE0
557b3115f2SLuciano Coelho 
567b3115f2SLuciano Coelho #define WL1271_RX_DESC_BAND_BG      0x00
577b3115f2SLuciano Coelho #define WL1271_RX_DESC_BAND_J       0x01
587b3115f2SLuciano Coelho #define WL1271_RX_DESC_BAND_A       0x02
597b3115f2SLuciano Coelho 
607b3115f2SLuciano Coelho #define WL1271_RX_DESC_STBC         BIT(2)
617b3115f2SLuciano Coelho #define WL1271_RX_DESC_A_MPDU       BIT(3)
627b3115f2SLuciano Coelho #define WL1271_RX_DESC_HT           BIT(4)
637b3115f2SLuciano Coelho 
647b3115f2SLuciano Coelho #define WL1271_RX_DESC_ENCRYPT_WEP  0x20
657b3115f2SLuciano Coelho #define WL1271_RX_DESC_ENCRYPT_TKIP 0x40
667b3115f2SLuciano Coelho #define WL1271_RX_DESC_ENCRYPT_AES  0x60
677b3115f2SLuciano Coelho #define WL1271_RX_DESC_ENCRYPT_GEM  0x80
687b3115f2SLuciano Coelho 
697b3115f2SLuciano Coelho /*
707b3115f2SLuciano Coelho  * RX Descriptor status
717b3115f2SLuciano Coelho  *
727b3115f2SLuciano Coelho  * Bits 0-2 - error code
737b3115f2SLuciano Coelho  * Bits 3-5 - process_id tag (AP mode FW)
747b3115f2SLuciano Coelho  * Bits 6-7 - reserved
757b3115f2SLuciano Coelho  */
76387116b8SArik Nemtsov #define WL1271_RX_DESC_STATUS_MASK      0x07
777b3115f2SLuciano Coelho 
787b3115f2SLuciano Coelho #define WL1271_RX_DESC_SUCCESS          0x00
797b3115f2SLuciano Coelho #define WL1271_RX_DESC_DECRYPT_FAIL     0x01
807b3115f2SLuciano Coelho #define WL1271_RX_DESC_MIC_FAIL         0x02
817b3115f2SLuciano Coelho 
827b3115f2SLuciano Coelho #define RX_MEM_BLOCK_MASK            0xFF
837b3115f2SLuciano Coelho #define RX_BUF_SIZE_MASK             0xFFF00
847b3115f2SLuciano Coelho #define RX_BUF_SIZE_SHIFT_DIV        6
855766435eSArik Nemtsov #define ALIGNED_RX_BUF_SIZE_MASK     0xFFFF00
865766435eSArik Nemtsov #define ALIGNED_RX_BUF_SIZE_SHIFT    8
875766435eSArik Nemtsov 
887b3115f2SLuciano Coelho /* If set, the start of IP payload is not 4 bytes aligned */
897b3115f2SLuciano Coelho #define RX_BUF_UNALIGNED_PAYLOAD     BIT(20)
907b3115f2SLuciano Coelho 
919c809f88SArik Nemtsov /* If set, the buffer was padded by the FW to be 4 bytes aligned */
929c809f88SArik Nemtsov #define RX_BUF_PADDED_PAYLOAD        BIT(30)
939c809f88SArik Nemtsov 
9404414e2aSEyal Shapira /*
9504414e2aSEyal Shapira  * Account for the padding inserted by the FW in case of RX_ALIGNMENT
9604414e2aSEyal Shapira  * or for fixing alignment in case the packet wasn't aligned.
9704414e2aSEyal Shapira  */
9804414e2aSEyal Shapira #define RX_BUF_ALIGN                 2
9904414e2aSEyal Shapira 
100cd70f6a4SArik Nemtsov /* Describes the alignment state of a Rx buffer */
101cd70f6a4SArik Nemtsov enum wl_rx_buf_align {
102cd70f6a4SArik Nemtsov 	WLCORE_RX_BUF_ALIGNED,
103cd70f6a4SArik Nemtsov 	WLCORE_RX_BUF_UNALIGNED,
104cd70f6a4SArik Nemtsov 	WLCORE_RX_BUF_PADDED,
105cd70f6a4SArik Nemtsov };
106cd70f6a4SArik Nemtsov 
1077b3115f2SLuciano Coelho enum {
1087b3115f2SLuciano Coelho 	WL12XX_RX_CLASS_UNKNOWN,
1097b3115f2SLuciano Coelho 	WL12XX_RX_CLASS_MANAGEMENT,
1107b3115f2SLuciano Coelho 	WL12XX_RX_CLASS_DATA,
1117b3115f2SLuciano Coelho 	WL12XX_RX_CLASS_QOS_DATA,
1127b3115f2SLuciano Coelho 	WL12XX_RX_CLASS_BCN_PRBRSP,
1137b3115f2SLuciano Coelho 	WL12XX_RX_CLASS_EAPOL,
1147b3115f2SLuciano Coelho 	WL12XX_RX_CLASS_BA_EVENT,
1157b3115f2SLuciano Coelho 	WL12XX_RX_CLASS_AMSDU,
1167b3115f2SLuciano Coelho 	WL12XX_RX_CLASS_LOGGER,
1177b3115f2SLuciano Coelho };
1187b3115f2SLuciano Coelho 
1197b3115f2SLuciano Coelho struct wl1271_rx_descriptor {
1207b3115f2SLuciano Coelho 	__le16 length;
1217b3115f2SLuciano Coelho 	u8  status;
1227b3115f2SLuciano Coelho 	u8  flags;
1237b3115f2SLuciano Coelho 	u8  rate;
1247b3115f2SLuciano Coelho 	u8  channel;
1257b3115f2SLuciano Coelho 	s8  rssi;
1267b3115f2SLuciano Coelho 	u8  snr;
1277b3115f2SLuciano Coelho 	__le32 timestamp;
1287b3115f2SLuciano Coelho 	u8  packet_class;
1297b3115f2SLuciano Coelho 	u8  hlid;
1307b3115f2SLuciano Coelho 	u8  pad_len;
1317b3115f2SLuciano Coelho 	u8  reserved;
1327b3115f2SLuciano Coelho } __packed;
1337b3115f2SLuciano Coelho 
13475fb4df7SEliad Peller int wlcore_rx(struct wl1271 *wl, struct wl_fw_status *status);
13557fbcce3SJohannes Berg u8 wl1271_rate_to_idx(int rate, enum nl80211_band band);
136dbe0a8cdSEyal Shapira int wl1271_rx_filter_enable(struct wl1271 *wl,
137dbe0a8cdSEyal Shapira 			    int index, bool enable,
138dbe0a8cdSEyal Shapira 			    struct wl12xx_rx_filter *filter);
139c439a1caSArik Nemtsov int wl1271_rx_filter_clear_all(struct wl1271 *wl);
1407b3115f2SLuciano Coelho 
1417b3115f2SLuciano Coelho #endif
142