/****************************************************************************** * * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along with * this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * * ******************************************************************************/ #ifndef _RTW_RECV_H_ #define _RTW_RECV_H_ #include #include #define NR_RECVFRAME 256 #define RXFRAME_ALIGN 8 #define RXFRAME_ALIGN_SZ (1<signal_stat_timer, jiffies + \ msecs_to_jiffies((recvpriv)->signal_stat_sampling_interval)) struct sta_recv_priv { spinlock_t lock; int option; struct __queue defrag_q; /* keeping the fragment frame until defrag */ struct stainfo_rxcache rxcache; }; struct recv_buf { struct adapter *adapter; struct urb *purb; struct sk_buff *pskb; u8 reuse; }; /* head -----> data -----> payload tail -----> end -----> len = (unsigned int )(tail - data); */ struct recv_frame { struct list_head list; struct sk_buff *pkt; struct sk_buff *pkt_newalloc; struct adapter *adapter; struct rx_pkt_attrib attrib; uint len; u8 *rx_head; u8 *rx_data; u8 *rx_tail; u8 *rx_end; struct sta_info *psta; /* for A-MPDU Rx reordering buffer control */ struct recv_reorder_ctrl *preorder_ctrl; }; struct recv_frame *_rtw_alloc_recvframe(struct __queue *pfree_recv_queue); struct recv_frame *rtw_alloc_recvframe(struct __queue *pfree_recv_queue); void rtw_init_recvframe(struct recv_frame *precvframe, struct recv_priv *precvpriv); int rtw_free_recvframe(struct recv_frame *precvframe, struct __queue *pfree_recv_queue); #define rtw_dequeue_recvframe(queue) rtw_alloc_recvframe(queue) int _rtw_enqueue_recvframe(struct recv_frame *precvframe, struct __queue *queue); int rtw_enqueue_recvframe(struct recv_frame *precvframe, struct __queue *queue); void rtw_free_recvframe_queue(struct __queue *pframequeue, struct __queue *pfree_recv_queue); u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter); void rtw_reordering_ctrl_timeout_handler(unsigned long data); static inline u8 *get_rxmem(struct recv_frame *precvframe) { /* always return rx_head... */ if (precvframe == NULL) return NULL; return precvframe->rx_head; } static inline u8 *recvframe_pull(struct recv_frame *precvframe, int sz) { /* rx_data += sz; move rx_data sz bytes hereafter */ /* used for extract sz bytes from rx_data, update rx_data and return * the updated rx_data to the caller */ if (precvframe == NULL) return NULL; precvframe->rx_data += sz; if (precvframe->rx_data > precvframe->rx_tail) { precvframe->rx_data -= sz; return NULL; } precvframe->len -= sz; return precvframe->rx_data; } static inline u8 *recvframe_put(struct recv_frame *precvframe, int sz) { /* used for append sz bytes from ptr to rx_tail, update rx_tail * and return the updated rx_tail to the caller */ /* after putting, rx_tail must be still larger than rx_end. */ if (precvframe == NULL) return NULL; precvframe->rx_tail += sz; if (precvframe->rx_tail > precvframe->rx_end) { precvframe->rx_tail -= sz; return NULL; } precvframe->len += sz; return precvframe->rx_tail; } static inline u8 *recvframe_pull_tail(struct recv_frame *precvframe, int sz) { /* rmv data from rx_tail (by yitsen) */ /* used for extract sz bytes from rx_end, update rx_end and return * the updated rx_end to the caller */ /* after pulling, rx_end must be still larger than rx_data. */ if (precvframe == NULL) return NULL; precvframe->rx_tail -= sz; if (precvframe->rx_tail < precvframe->rx_data) { precvframe->rx_tail += sz; return NULL; } precvframe->len -= sz; return precvframe->rx_tail; } static inline s32 translate_percentage_to_dbm(u32 sig_stren_index) { s32 power; /* in dBm. */ /* Translate to dBm (x=0.5y-95). */ power = (s32)((sig_stren_index + 1) >> 1); power -= 95; return power; } struct sta_info; void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv); void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame); #endif