18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * This file is part of wl1251
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (c) 1998-2007 Texas Instruments Incorporated
68c2ecf20Sopenharmony_ci * Copyright (C) 2008 Nokia Corporation
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#ifndef __WL1251_RX_H__
108c2ecf20Sopenharmony_ci#define __WL1251_RX_H__
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <linux/bitops.h>
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#include "wl1251.h"
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci/*
178c2ecf20Sopenharmony_ci * RX PATH
188c2ecf20Sopenharmony_ci *
198c2ecf20Sopenharmony_ci * The Rx path uses a double buffer and an rx_contro structure, each located
208c2ecf20Sopenharmony_ci * at a fixed address in the device memory. The host keeps track of which
218c2ecf20Sopenharmony_ci * buffer is available and alternates between them on a per packet basis.
228c2ecf20Sopenharmony_ci * The size of each of the two buffers is large enough to hold the longest
238c2ecf20Sopenharmony_ci * 802.3 packet.
248c2ecf20Sopenharmony_ci * The RX path goes like that:
258c2ecf20Sopenharmony_ci * 1) The target generates an interrupt each time a new packet is received.
268c2ecf20Sopenharmony_ci *   There are 2 RX interrupts, one for each buffer.
278c2ecf20Sopenharmony_ci * 2) The host reads the received packet from one of the double buffers.
288c2ecf20Sopenharmony_ci * 3) The host triggers a target interrupt.
298c2ecf20Sopenharmony_ci * 4) The target prepares the next RX packet.
308c2ecf20Sopenharmony_ci */
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci#define WL1251_RX_MAX_RSSI -30
338c2ecf20Sopenharmony_ci#define WL1251_RX_MIN_RSSI -95
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci#define WL1251_RX_ALIGN_TO 4
368c2ecf20Sopenharmony_ci#define WL1251_RX_ALIGN(len) (((len) + WL1251_RX_ALIGN_TO - 1) & \
378c2ecf20Sopenharmony_ci			     ~(WL1251_RX_ALIGN_TO - 1))
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci#define SHORT_PREAMBLE_BIT   BIT(0)
408c2ecf20Sopenharmony_ci#define OFDM_RATE_BIT        BIT(6)
418c2ecf20Sopenharmony_ci#define PBCC_RATE_BIT        BIT(7)
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci#define PLCP_HEADER_LENGTH 8
448c2ecf20Sopenharmony_ci#define RX_DESC_PACKETID_SHIFT 11
458c2ecf20Sopenharmony_ci#define RX_MAX_PACKET_ID 3
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci#define RX_DESC_VALID_FCS         0x0001
488c2ecf20Sopenharmony_ci#define RX_DESC_MATCH_RXADDR1     0x0002
498c2ecf20Sopenharmony_ci#define RX_DESC_MCAST             0x0004
508c2ecf20Sopenharmony_ci#define RX_DESC_STAINTIM          0x0008
518c2ecf20Sopenharmony_ci#define RX_DESC_VIRTUAL_BM        0x0010
528c2ecf20Sopenharmony_ci#define RX_DESC_BCAST             0x0020
538c2ecf20Sopenharmony_ci#define RX_DESC_MATCH_SSID        0x0040
548c2ecf20Sopenharmony_ci#define RX_DESC_MATCH_BSSID       0x0080
558c2ecf20Sopenharmony_ci#define RX_DESC_ENCRYPTION_MASK   0x0300
568c2ecf20Sopenharmony_ci#define RX_DESC_MEASURMENT        0x0400
578c2ecf20Sopenharmony_ci#define RX_DESC_SEQNUM_MASK       0x1800
588c2ecf20Sopenharmony_ci#define	RX_DESC_MIC_FAIL	  0x2000
598c2ecf20Sopenharmony_ci#define	RX_DESC_DECRYPT_FAIL	  0x4000
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_cistruct wl1251_rx_descriptor {
628c2ecf20Sopenharmony_ci	u32 timestamp; /* In microseconds */
638c2ecf20Sopenharmony_ci	u16 length; /* Paylod length, including headers */
648c2ecf20Sopenharmony_ci	u16 flags;
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci	/*
678c2ecf20Sopenharmony_ci	 * 0 - 802.11
688c2ecf20Sopenharmony_ci	 * 1 - 802.3
698c2ecf20Sopenharmony_ci	 * 2 - IP
708c2ecf20Sopenharmony_ci	 * 3 - Raw Codec
718c2ecf20Sopenharmony_ci	 */
728c2ecf20Sopenharmony_ci	u8 type;
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci	/*
758c2ecf20Sopenharmony_ci	 * Received Rate:
768c2ecf20Sopenharmony_ci	 * 0x0A - 1MBPS
778c2ecf20Sopenharmony_ci	 * 0x14 - 2MBPS
788c2ecf20Sopenharmony_ci	 * 0x37 - 5_5MBPS
798c2ecf20Sopenharmony_ci	 * 0x0B - 6MBPS
808c2ecf20Sopenharmony_ci	 * 0x0F - 9MBPS
818c2ecf20Sopenharmony_ci	 * 0x6E - 11MBPS
828c2ecf20Sopenharmony_ci	 * 0x0A - 12MBPS
838c2ecf20Sopenharmony_ci	 * 0x0E - 18MBPS
848c2ecf20Sopenharmony_ci	 * 0xDC - 22MBPS
858c2ecf20Sopenharmony_ci	 * 0x09 - 24MBPS
868c2ecf20Sopenharmony_ci	 * 0x0D - 36MBPS
878c2ecf20Sopenharmony_ci	 * 0x08 - 48MBPS
888c2ecf20Sopenharmony_ci	 * 0x0C - 54MBPS
898c2ecf20Sopenharmony_ci	 */
908c2ecf20Sopenharmony_ci	u8 rate;
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci	u8 mod_pre; /* Modulation and preamble */
938c2ecf20Sopenharmony_ci	u8 channel;
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci	/*
968c2ecf20Sopenharmony_ci	 * 0 - 2.4 Ghz
978c2ecf20Sopenharmony_ci	 * 1 - 5 Ghz
988c2ecf20Sopenharmony_ci	 */
998c2ecf20Sopenharmony_ci	u8 band;
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci	s8 rssi; /* in dB */
1028c2ecf20Sopenharmony_ci	u8 rcpi; /* in dB */
1038c2ecf20Sopenharmony_ci	u8 snr; /* in dB */
1048c2ecf20Sopenharmony_ci} __packed;
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_civoid wl1251_rx(struct wl1251 *wl);
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci#endif
109