rtl871x_recv.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. #ifndef _RTL871X_RECV_H_
  2. #define _RTL871X_RECV_H_
  3. #include "osdep_service.h"
  4. #include "drv_types.h"
  5. #define NR_RECVFRAME 256
  6. #define RXFRAME_ALIGN 8
  7. #define RXFRAME_ALIGN_SZ (1 << RXFRAME_ALIGN)
  8. #define MAX_SUBFRAME_COUNT 64
  9. #define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
  10. /* for Rx reordering buffer control */
  11. struct recv_reorder_ctrl {
  12. struct _adapter *padapter;
  13. u16 indicate_seq; /* =wstart_b, init_value=0xffff */
  14. u16 wend_b;
  15. u8 wsize_b;
  16. struct __queue pending_recvframe_queue;
  17. struct timer_list reordering_ctrl_timer;
  18. };
  19. struct stainfo_rxcache {
  20. u16 tid_rxseq[16];
  21. };
  22. #define PHY_RSSI_SLID_WIN_MAX 100
  23. #define PHY_LINKQUALITY_SLID_WIN_MAX 20
  24. struct smooth_rssi_data {
  25. u32 elements[100]; /* array to store values */
  26. u32 index; /* index to current array to store */
  27. u32 total_num; /* num of valid elements */
  28. u32 total_val; /* sum of valid elements */
  29. };
  30. struct rx_pkt_attrib {
  31. u8 amsdu;
  32. u8 order;
  33. u8 qos;
  34. u8 to_fr_ds;
  35. u8 frag_num;
  36. u16 seq_num;
  37. u8 pw_save;
  38. u8 mfrag;
  39. u8 mdata;
  40. u8 privacy; /* in frame_ctrl field */
  41. u8 bdecrypted;
  42. int hdrlen; /* the WLAN Header Len */
  43. int encrypt; /* 0 no encrypt. != 0 encrypt algorith */
  44. int iv_len;
  45. int icv_len;
  46. int priority;
  47. int ack_policy;
  48. u8 crc_err;
  49. u8 dst[ETH_ALEN];
  50. u8 src[ETH_ALEN];
  51. u8 ta[ETH_ALEN];
  52. u8 ra[ETH_ALEN];
  53. u8 bssid[ETH_ALEN];
  54. u8 tcpchk_valid; /* 0: invalid, 1: valid */
  55. u8 ip_chkrpt; /* 0: incorrect, 1: correct */
  56. u8 tcp_chkrpt; /* 0: incorrect, 1: correct */
  57. u8 signal_qual;
  58. s8 rx_mimo_signal_qual[2];
  59. u8 mcs_rate;
  60. u8 htc;
  61. u8 signal_strength;
  62. };
  63. /*
  64. accesser of recv_priv: recv_entry(dispatch / passive level);
  65. recv_thread(passive) ; returnpkt(dispatch)
  66. ; halt(passive) ;
  67. using enter_critical section to protect
  68. */
  69. struct recv_priv {
  70. spinlock_t lock;
  71. struct __queue free_recv_queue;
  72. struct __queue recv_pending_queue;
  73. u8 *pallocated_frame_buf;
  74. u8 *precv_frame_buf;
  75. uint free_recvframe_cnt;
  76. struct _adapter *adapter;
  77. uint rx_bytes;
  78. uint rx_pkts;
  79. uint rx_drop;
  80. uint rx_icv_err;
  81. uint rx_largepacket_crcerr;
  82. uint rx_smallpacket_crcerr;
  83. uint rx_middlepacket_crcerr;
  84. u8 rx_pending_cnt;
  85. uint ff_hwaddr;
  86. struct tasklet_struct recv_tasklet;
  87. struct sk_buff_head free_recv_skb_queue;
  88. struct sk_buff_head rx_skb_queue;
  89. u8 *pallocated_recv_buf;
  90. u8 *precv_buf; /* 4 alignment */
  91. struct __queue free_recv_buf_queue;
  92. u32 free_recv_buf_queue_cnt;
  93. /* For the phy informatiom */
  94. s8 rssi;
  95. u8 signal;
  96. u8 noise;
  97. u8 fw_rssi;
  98. struct smooth_rssi_data signal_qual_data;
  99. struct smooth_rssi_data signal_strength_data;
  100. };
  101. struct sta_recv_priv {
  102. spinlock_t lock;
  103. sint option;
  104. struct __queue defrag_q; /* keeping the fragment frame until defrag */
  105. struct stainfo_rxcache rxcache;
  106. uint sta_rx_bytes;
  107. uint sta_rx_pkts;
  108. uint sta_rx_fail;
  109. };
  110. #include "rtl8712_recv.h"
  111. /* get a free recv_frame from pfree_recv_queue */
  112. union recv_frame *r8712_alloc_recvframe(struct __queue *pfree_recv_queue);
  113. int r8712_free_recvframe(union recv_frame *precvframe,
  114. struct __queue *pfree_recv_queue);
  115. void r8712_free_recvframe_queue(struct __queue *pframequeue,
  116. struct __queue *pfree_recv_queue);
  117. int r8712_wlanhdr_to_ethhdr(union recv_frame *precvframe);
  118. int recv_func(struct _adapter *padapter, void *pcontext);
  119. static inline u8 *get_rxmem(union recv_frame *precvframe)
  120. {
  121. /* always return rx_head... */
  122. if (precvframe == NULL)
  123. return NULL;
  124. return precvframe->u.hdr.rx_head;
  125. }
  126. static inline u8 *get_recvframe_data(union recv_frame *precvframe)
  127. {
  128. /* always return rx_data */
  129. if (precvframe == NULL)
  130. return NULL;
  131. return precvframe->u.hdr.rx_data;
  132. }
  133. static inline u8 *recvframe_pull(union recv_frame *precvframe, sint sz)
  134. {
  135. /* used for extract sz bytes from rx_data, update rx_data and return
  136. * the updated rx_data to the caller */
  137. if (precvframe == NULL)
  138. return NULL;
  139. precvframe->u.hdr.rx_data += sz;
  140. if (precvframe->u.hdr.rx_data > precvframe->u.hdr.rx_tail) {
  141. precvframe->u.hdr.rx_data -= sz;
  142. return NULL;
  143. }
  144. precvframe->u.hdr.len -= sz;
  145. return precvframe->u.hdr.rx_data;
  146. }
  147. static inline u8 *recvframe_put(union recv_frame *precvframe, sint sz)
  148. {
  149. /* used for append sz bytes from ptr to rx_tail, update rx_tail and
  150. * return the updated rx_tail to the caller
  151. * after putting, rx_tail must be still larger than rx_end. */
  152. if (precvframe == NULL)
  153. return NULL;
  154. precvframe->u.hdr.rx_tail += sz;
  155. if (precvframe->u.hdr.rx_tail > precvframe->u.hdr.rx_end) {
  156. precvframe->u.hdr.rx_tail -= sz;
  157. return NULL;
  158. }
  159. precvframe->u.hdr.len += sz;
  160. return precvframe->u.hdr.rx_tail;
  161. }
  162. static inline u8 *recvframe_pull_tail(union recv_frame *precvframe, sint sz)
  163. {
  164. /* rmv data from rx_tail (by yitsen)
  165. * used for extract sz bytes from rx_end, update rx_end and return the
  166. * updated rx_end to the caller
  167. * after pulling, rx_end must be still larger than rx_data. */
  168. if (precvframe == NULL)
  169. return NULL;
  170. precvframe->u.hdr.rx_tail -= sz;
  171. if (precvframe->u.hdr.rx_tail < precvframe->u.hdr.rx_data) {
  172. precvframe->u.hdr.rx_tail += sz;
  173. return NULL;
  174. }
  175. precvframe->u.hdr.len -= sz;
  176. return precvframe->u.hdr.rx_tail;
  177. }
  178. struct sta_info;
  179. void _r8712_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv);
  180. sint r8712_recvframe_chkmic(struct _adapter *adapter,
  181. union recv_frame *precvframe);
  182. union recv_frame *r8712_decryptor(struct _adapter *adapter,
  183. union recv_frame *precv_frame);
  184. union recv_frame *r8712_recvframe_chk_defrag(struct _adapter *adapter,
  185. union recv_frame *precv_frame);
  186. int r8712_validate_recv_frame(struct _adapter *adapter,
  187. union recv_frame *precv_frame);
  188. union recv_frame *r8712_portctrl(struct _adapter *adapter,
  189. union recv_frame *precv_frame);
  190. #endif