rx.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*
  2. * This file is part of wl1271
  3. *
  4. * Copyright (C) 1998-2009 Texas Instruments. All rights reserved.
  5. * Copyright (C) 2008-2009 Nokia Corporation
  6. *
  7. * Contact: Luciano Coelho <luciano.coelho@nokia.com>
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * version 2 as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  21. * 02110-1301 USA
  22. *
  23. */
  24. #ifndef __RX_H__
  25. #define __RX_H__
  26. #include <linux/bitops.h>
  27. #define WL1271_RX_MAX_RSSI -30
  28. #define WL1271_RX_MIN_RSSI -95
  29. #define RSSI_LEVEL_BITMASK 0x7F
  30. #define ANT_DIVERSITY_BITMASK BIT(7)
  31. #define SHORT_PREAMBLE_BIT BIT(0)
  32. #define OFDM_RATE_BIT BIT(6)
  33. #define PBCC_RATE_BIT BIT(7)
  34. #define PLCP_HEADER_LENGTH 8
  35. #define RX_DESC_PACKETID_SHIFT 11
  36. #define RX_MAX_PACKET_ID 3
  37. #define RX_DESC_VALID_FCS 0x0001
  38. #define RX_DESC_MATCH_RXADDR1 0x0002
  39. #define RX_DESC_MCAST 0x0004
  40. #define RX_DESC_STAINTIM 0x0008
  41. #define RX_DESC_VIRTUAL_BM 0x0010
  42. #define RX_DESC_BCAST 0x0020
  43. #define RX_DESC_MATCH_SSID 0x0040
  44. #define RX_DESC_MATCH_BSSID 0x0080
  45. #define RX_DESC_ENCRYPTION_MASK 0x0300
  46. #define RX_DESC_MEASURMENT 0x0400
  47. #define RX_DESC_SEQNUM_MASK 0x1800
  48. #define RX_DESC_MIC_FAIL 0x2000
  49. #define RX_DESC_DECRYPT_FAIL 0x4000
  50. /*
  51. * RX Descriptor flags:
  52. *
  53. * Bits 0-1 - band
  54. * Bit 2 - STBC
  55. * Bit 3 - A-MPDU
  56. * Bit 4 - HT
  57. * Bits 5-7 - encryption
  58. */
  59. #define WL1271_RX_DESC_BAND_MASK 0x03
  60. #define WL1271_RX_DESC_ENCRYPT_MASK 0xE0
  61. #define WL1271_RX_DESC_BAND_BG 0x00
  62. #define WL1271_RX_DESC_BAND_J 0x01
  63. #define WL1271_RX_DESC_BAND_A 0x02
  64. #define WL1271_RX_DESC_STBC BIT(2)
  65. #define WL1271_RX_DESC_A_MPDU BIT(3)
  66. #define WL1271_RX_DESC_HT BIT(4)
  67. #define WL1271_RX_DESC_ENCRYPT_WEP 0x20
  68. #define WL1271_RX_DESC_ENCRYPT_TKIP 0x40
  69. #define WL1271_RX_DESC_ENCRYPT_AES 0x60
  70. #define WL1271_RX_DESC_ENCRYPT_GEM 0x80
  71. /*
  72. * RX Descriptor status
  73. *
  74. * Bits 0-2 - error code
  75. * Bits 3-5 - process_id tag (AP mode FW)
  76. * Bits 6-7 - reserved
  77. */
  78. #define WL1271_RX_DESC_STATUS_MASK 0x07
  79. #define WL1271_RX_DESC_SUCCESS 0x00
  80. #define WL1271_RX_DESC_DECRYPT_FAIL 0x01
  81. #define WL1271_RX_DESC_MIC_FAIL 0x02
  82. #define RX_MEM_BLOCK_MASK 0xFF
  83. #define RX_BUF_SIZE_MASK 0xFFF00
  84. #define RX_BUF_SIZE_SHIFT_DIV 6
  85. #define ALIGNED_RX_BUF_SIZE_MASK 0xFFFF00
  86. #define ALIGNED_RX_BUF_SIZE_SHIFT 8
  87. /* If set, the start of IP payload is not 4 bytes aligned */
  88. #define RX_BUF_UNALIGNED_PAYLOAD BIT(20)
  89. /* If set, the buffer was padded by the FW to be 4 bytes aligned */
  90. #define RX_BUF_PADDED_PAYLOAD BIT(30)
  91. /*
  92. * Account for the padding inserted by the FW in case of RX_ALIGNMENT
  93. * or for fixing alignment in case the packet wasn't aligned.
  94. */
  95. #define RX_BUF_ALIGN 2
  96. /* Describes the alignment state of a Rx buffer */
  97. enum wl_rx_buf_align {
  98. WLCORE_RX_BUF_ALIGNED,
  99. WLCORE_RX_BUF_UNALIGNED,
  100. WLCORE_RX_BUF_PADDED,
  101. };
  102. enum {
  103. WL12XX_RX_CLASS_UNKNOWN,
  104. WL12XX_RX_CLASS_MANAGEMENT,
  105. WL12XX_RX_CLASS_DATA,
  106. WL12XX_RX_CLASS_QOS_DATA,
  107. WL12XX_RX_CLASS_BCN_PRBRSP,
  108. WL12XX_RX_CLASS_EAPOL,
  109. WL12XX_RX_CLASS_BA_EVENT,
  110. WL12XX_RX_CLASS_AMSDU,
  111. WL12XX_RX_CLASS_LOGGER,
  112. };
  113. struct wl1271_rx_descriptor {
  114. __le16 length;
  115. u8 status;
  116. u8 flags;
  117. u8 rate;
  118. u8 channel;
  119. s8 rssi;
  120. u8 snr;
  121. __le32 timestamp;
  122. u8 packet_class;
  123. u8 hlid;
  124. u8 pad_len;
  125. u8 reserved;
  126. } __packed;
  127. int wlcore_rx(struct wl1271 *wl, struct wl_fw_status *status);
  128. u8 wl1271_rate_to_idx(int rate, enum nl80211_band band);
  129. int wl1271_rx_filter_enable(struct wl1271 *wl,
  130. int index, bool enable,
  131. struct wl12xx_rx_filter *filter);
  132. int wl1271_rx_filter_clear_all(struct wl1271 *wl);
  133. #endif