Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _RTL871X_RECV_H_
0003 #define _RTL871X_RECV_H_
0004 
0005 #include "osdep_service.h"
0006 #include "drv_types.h"
0007 
0008 #define NR_RECVFRAME 256
0009 
0010 #define RXFRAME_ALIGN   8
0011 #define RXFRAME_ALIGN_SZ    (1 << RXFRAME_ALIGN)
0012 
0013 #define MAX_SUBFRAME_COUNT  64
0014 
0015 /* for Rx reordering buffer control */
0016 struct recv_reorder_ctrl {
0017     struct _adapter *padapter;
0018     u16 indicate_seq; /* =wstart_b, init_value=0xffff */
0019     u16 wend_b;
0020     u8 wsize_b;
0021     struct  __queue pending_recvframe_queue;
0022     struct timer_list reordering_ctrl_timer;
0023 };
0024 
0025 struct  stainfo_rxcache {
0026     u16 tid_rxseq[16];
0027 };
0028 
0029 #define     PHY_RSSI_SLID_WIN_MAX           100
0030 #define     PHY_LINKQUALITY_SLID_WIN_MAX        20
0031 
0032 struct smooth_rssi_data {
0033     u32 elements[100];  /* array to store values */
0034     u32 index;      /* index to current array to store */
0035     u32 total_num;  /* num of valid elements */
0036     u32 total_val;  /* sum of valid elements */
0037 };
0038 
0039 struct rx_pkt_attrib {
0040     u8  amsdu;
0041     u8  order;
0042     u8  qos;
0043     u8  to_fr_ds;
0044     u8  frag_num;
0045     u16 seq_num;
0046     u8   pw_save;
0047     u8    mfrag;
0048     u8    mdata;
0049     u8  privacy; /* in frame_ctrl field */
0050     u8  bdecrypted;
0051     int hdrlen;  /* the WLAN Header Len */
0052     int encrypt; /* 0 no encrypt. != 0 encrypt algorithm */
0053     int iv_len;
0054     int icv_len;
0055     int priority;
0056     int ack_policy;
0057     u8  crc_err;
0058     u8  dst[ETH_ALEN];
0059     u8  src[ETH_ALEN];
0060     u8  ta[ETH_ALEN];
0061     u8  ra[ETH_ALEN];
0062     u8  bssid[ETH_ALEN];
0063     u8  tcpchk_valid; /* 0: invalid, 1: valid */
0064     u8  ip_chkrpt; /* 0: incorrect, 1: correct */
0065     u8  tcp_chkrpt; /* 0: incorrect, 1: correct */
0066     u8  signal_qual;
0067     s8  rx_mimo_signal_qual[2];
0068     u8  mcs_rate;
0069     u8  htc;
0070     u8  signal_strength;
0071 };
0072 
0073 /*
0074  * accesser of recv_priv: recv_entry(dispatch / passive level);
0075  * recv_thread(passive) ; returnpkt(dispatch)
0076  * ; halt(passive) ;
0077  *
0078  * using enter_critical section to protect
0079  */
0080 struct recv_priv {
0081     spinlock_t lock;
0082     struct  __queue free_recv_queue;
0083     struct  __queue recv_pending_queue;
0084     u8 *pallocated_frame_buf;
0085     u8 *precv_frame_buf;
0086     uint free_recvframe_cnt;
0087     struct _adapter *adapter;
0088     uint    rx_bytes;
0089     uint    rx_pkts;
0090     uint    rx_drop;
0091     uint  rx_icv_err;
0092     uint  rx_largepacket_crcerr;
0093     uint  rx_smallpacket_crcerr;
0094     uint  rx_middlepacket_crcerr;
0095     u8  rx_pending_cnt;
0096     uint    ff_hwaddr;
0097     struct tasklet_struct recv_tasklet;
0098     struct sk_buff_head free_recv_skb_queue;
0099     struct sk_buff_head rx_skb_queue;
0100     u8 *pallocated_recv_buf;
0101     u8 *precv_buf;    /* 4 alignment */
0102     struct  __queue free_recv_buf_queue;
0103     u32 free_recv_buf_queue_cnt;
0104     /* For the phy information */
0105     s8 rssi;
0106     u8 signal;
0107     u8 noise;
0108     u8 fw_rssi;
0109     struct smooth_rssi_data signal_qual_data;
0110     struct smooth_rssi_data signal_strength_data;
0111 };
0112 
0113 struct sta_recv_priv {
0114     spinlock_t lock;
0115     sint    option;
0116     struct  __queue defrag_q; /* keeping the fragment frame until defrag */
0117     struct  stainfo_rxcache rxcache;
0118     uint    sta_rx_bytes;
0119     uint    sta_rx_pkts;
0120     uint    sta_rx_fail;
0121 };
0122 
0123 #include "rtl8712_recv.h"
0124 
0125 /* get a free recv_frame from pfree_recv_queue */
0126 union recv_frame *r8712_alloc_recvframe(struct  __queue *pfree_recv_queue);
0127 void r8712_free_recvframe(union recv_frame *precvframe,
0128               struct  __queue *pfree_recv_queue);
0129 void r8712_free_recvframe_queue(struct  __queue *pframequeue,
0130                  struct  __queue *pfree_recv_queue);
0131 int r8712_wlanhdr_to_ethhdr(union recv_frame *precvframe);
0132 int recv_func(struct _adapter *padapter, void *pcontext);
0133 
0134 static inline u8 *get_rxmem(union recv_frame *precvframe)
0135 {
0136     /* always return rx_head... */
0137     if (!precvframe)
0138         return NULL;
0139     return precvframe->u.hdr.rx_head;
0140 }
0141 
0142 static inline u8 *recvframe_pull(union recv_frame *precvframe, sint sz)
0143 {
0144     /* used for extract sz bytes from rx_data, update rx_data and return
0145      * the updated rx_data to the caller
0146      */
0147     if (!precvframe)
0148         return NULL;
0149     precvframe->u.hdr.rx_data += sz;
0150     if (precvframe->u.hdr.rx_data > precvframe->u.hdr.rx_tail) {
0151         precvframe->u.hdr.rx_data -= sz;
0152         return NULL;
0153     }
0154     precvframe->u.hdr.len -= sz;
0155     return precvframe->u.hdr.rx_data;
0156 }
0157 
0158 static inline u8 *recvframe_put(union recv_frame *precvframe, sint sz)
0159 {
0160     /* used for append sz bytes from ptr to rx_tail, update rx_tail and
0161      * return the updated rx_tail to the caller
0162      * after putting, rx_tail must be still larger than rx_end.
0163      */
0164     if (!precvframe)
0165         return NULL;
0166     precvframe->u.hdr.rx_tail += sz;
0167     if (precvframe->u.hdr.rx_tail > precvframe->u.hdr.rx_end) {
0168         precvframe->u.hdr.rx_tail -= sz;
0169         return NULL;
0170     }
0171     precvframe->u.hdr.len += sz;
0172     return precvframe->u.hdr.rx_tail;
0173 }
0174 
0175 static inline u8 *recvframe_pull_tail(union recv_frame *precvframe, sint sz)
0176 {
0177     /* rmv data from rx_tail (by yitsen)
0178      * used for extract sz bytes from rx_end, update rx_end and return the
0179      * updated rx_end to the caller
0180      * after pulling, rx_end must be still larger than rx_data.
0181      */
0182     if (!precvframe)
0183         return NULL;
0184     precvframe->u.hdr.rx_tail -= sz;
0185     if (precvframe->u.hdr.rx_tail < precvframe->u.hdr.rx_data) {
0186         precvframe->u.hdr.rx_tail += sz;
0187         return NULL;
0188     }
0189     precvframe->u.hdr.len -= sz;
0190     return precvframe->u.hdr.rx_tail;
0191 }
0192 
0193 struct sta_info;
0194 
0195 void    _r8712_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv);
0196 sint r8712_recvframe_chkmic(struct _adapter *adapter,
0197                 union recv_frame *precvframe);
0198 union recv_frame *r8712_decryptor(struct _adapter *adapter,
0199                   union recv_frame *precv_frame);
0200 union recv_frame *r8712_recvframe_chk_defrag(struct _adapter *adapter,
0201                          union recv_frame *precv_frame);
0202 int r8712_validate_recv_frame(struct _adapter *adapter,
0203                   union recv_frame *precv_frame);
0204 union recv_frame *r8712_portctrl(struct _adapter *adapter,
0205                  union recv_frame *precv_frame);
0206 
0207 #endif
0208