static void _init_stainfo(struct sta_info *psta) { _func_enter_; _rtw_memset((u8 *)psta, 0, sizeof (struct sta_info)); _rtw_spinlock_init(&psta->lock); _rtw_init_listhead(&psta->list); _rtw_init_listhead(&psta->hash_list); //_rtw_init_listhead(&psta->asoc_list); //_rtw_init_listhead(&psta->sleep_list); //_rtw_init_listhead(&psta->wakeup_list); _rtw_init_queue(&psta->sleep_q); psta->sleepq_len = 0; _rtw_init_sta_xmit_priv(&psta->sta_xmitpriv); _rtw_init_sta_recv_priv(&psta->sta_recvpriv); #ifdef CONFIG_NATIVEAP_MLME _rtw_init_listhead(&psta->asoc_list); _rtw_init_listhead(&psta->auth_list); #endif _func_exit_; }
void _rtw_init_stainfo(struct sta_info *psta) { _func_enter_; _rtw_memset((u8 *)psta, 0, sizeof (struct sta_info)); _rtw_spinlock_init(&psta->lock); _rtw_init_listhead(&psta->list); _rtw_init_listhead(&psta->hash_list); //_rtw_init_listhead(&psta->asoc_list); //_rtw_init_listhead(&psta->sleep_list); //_rtw_init_listhead(&psta->wakeup_list); _rtw_init_queue(&psta->sleep_q); psta->sleepq_len = 0; _rtw_init_sta_xmit_priv(&psta->sta_xmitpriv); _rtw_init_sta_recv_priv(&psta->sta_recvpriv); #ifdef CONFIG_AP_MODE _rtw_init_listhead(&psta->asoc_list); _rtw_init_listhead(&psta->auth_list); psta->expire_to = 0; psta->flags = 0; psta->capability = 0; psta->bpairwise_key_installed = _FALSE; #ifdef CONFIG_NATIVEAP_MLME psta->nonerp_set = 0; psta->no_short_slot_time_set = 0; psta->no_short_preamble_set = 0; psta->no_ht_gf_set = 0; psta->no_ht_set = 0; psta->ht_20mhz_set = 0; psta->ht_40mhz_intolerant = 0; #endif #ifdef CONFIG_TX_MCAST2UNI psta->under_exist_checking = 0; #endif // CONFIG_TX_MCAST2UNI psta->keep_alive_trycnt = 0; #endif // CONFIG_AP_MODE rtw_st_ctl_init(&psta->st_ctl); _func_exit_; }
u32 _rtw_init_sta_priv(struct sta_priv *pstapriv) { struct sta_info *psta; s32 i; _func_enter_; pstapriv->pallocated_stainfo_buf = _rtw_zmalloc (sizeof(struct sta_info) * NUM_STA+ 4); if(!pstapriv->pallocated_stainfo_buf) return _FAIL; pstapriv->pstainfo_buf = pstapriv->pallocated_stainfo_buf + 4 - ((SIZE_PTR)(pstapriv->pallocated_stainfo_buf ) & 3); _rtw_init_queue(&pstapriv->free_sta_queue); _rtw_spinlock_init(&pstapriv->sta_hash_lock); //_rtw_init_queue(&pstapriv->asoc_q); pstapriv->asoc_sta_count = 0; _rtw_init_queue(&pstapriv->sleep_q); _rtw_init_queue(&pstapriv->wakeup_q); psta = (struct sta_info *)(pstapriv->pstainfo_buf); for(i = 0; i < NUM_STA; i++) { _init_stainfo(psta); _rtw_init_listhead(&(pstapriv->sta_hash[i])); rtw_list_insert_tail(&psta->list, get_list_head(&pstapriv->free_sta_queue)); psta++; } #ifdef CONFIG_NATIVEAP_MLME _rtw_init_listhead(&pstapriv->asoc_list); _rtw_init_listhead(&pstapriv->auth_list); //pstapriv->auth_to = ???; //pstapriv->assoc_to = ???; //pstapriv->expire_to = ???; #endif _func_exit_; return _SUCCESS; }
void _rtw_init_stainfo(struct sta_info *psta) { _func_enter_; _rtw_memset((u8 *)psta, 0, sizeof (struct sta_info)); _rtw_spinlock_init(&psta->lock); _rtw_init_listhead(&psta->list); _rtw_init_listhead(&psta->hash_list); _rtw_init_queue(&psta->sleep_q); psta->sleepq_len = 0; _rtw_init_sta_xmit_priv(&psta->sta_xmitpriv); _rtw_init_sta_recv_priv(&psta->sta_recvpriv); #ifdef CONFIG_AP_MODE _rtw_init_listhead(&psta->asoc_list); _rtw_init_listhead(&psta->auth_list); psta->expire_to = 0; psta->flags = 0; psta->capability = 0; psta->bpairwise_key_installed = false; #ifdef CONFIG_AP_MODE psta->nonerp_set = 0; psta->no_short_slot_time_set = 0; psta->no_short_preamble_set = 0; psta->no_ht_gf_set = 0; psta->no_ht_set = 0; psta->ht_20mhz_set = 0; #endif psta->under_exist_checking = 0; psta->keep_alive_trycnt = 0; #endif /* CONFIG_AP_MODE */ _func_exit_; }
void _rtw_init_stainfo(struct sta_info *psta) { _func_enter_; _rtw_memset((u8 *)psta, 0, sizeof (struct sta_info)); _rtw_spinlock_init(&psta->lock); _rtw_init_listhead(&psta->list); _rtw_init_listhead(&psta->hash_list); //_rtw_init_listhead(&psta->asoc_list); //_rtw_init_listhead(&psta->sleep_list); //_rtw_init_listhead(&psta->wakeup_list); _rtw_init_queue(&psta->sleep_q); psta->sleepq_len = 0; _rtw_init_sta_xmit_priv(&psta->sta_xmitpriv); _rtw_init_sta_recv_priv(&psta->sta_recvpriv); #ifdef CONFIG_AP_MODE _rtw_init_listhead(&psta->asoc_list); _rtw_init_listhead(&psta->auth_list); psta->expire_to = 0; psta->flags = 0; psta->capability = 0; #ifdef CONFIG_NATIVEAP_MLME psta->nonerp_set = 0; psta->no_short_slot_time_set = 0; psta->no_short_preamble_set = 0; psta->no_ht_gf_set = 0; psta->no_ht_set = 0; psta->ht_20mhz_set = 0; #endif #endif _func_exit_; }
void _rtw_init_queue(_queue *pqueue) { _rtw_init_listhead(&(pqueue->queue)); _rtw_spinlock_init(&(pqueue->lock)); }
static s32 initrecvbuf(struct recv_buf *precvbuf, PADAPTER padapter) { _rtw_init_listhead(&precvbuf->list); _rtw_spinlock_init(&precvbuf->recvbuf_lock); precvbuf->adapter = padapter; return _SUCCESS; }
/* * Initialize recv private variable for hardware dependent * 1. recv buf * 2. recv tasklet * */ s32 rtl8195as_init_recv_priv(PADAPTER padapter) { s32 res; u32 i, n; struct recv_buf *precvbuf; struct recv_priv *precvpriv = &padapter->recvpriv; res = _SUCCESS; //3 1. init recv buffer _rtw_init_queue(&precvpriv->free_recv_buf_queue); _rtw_init_queue(&precvpriv->recv_buf_pending_queue); n = NR_RECVBUFF * sizeof(struct recv_buf) + 4; precvpriv->pallocated_recv_buf = rtw_zmalloc(n); if (precvpriv->pallocated_recv_buf == NULL) { res = _FAIL; goto exit; } precvpriv->precv_buf = (u8*)N_BYTE_ALIGMENT((SIZE_PTR)(precvpriv->pallocated_recv_buf), 4); // init each recv buffer precvbuf = (struct recv_buf*)precvpriv->precv_buf; for (i = 0; i < NR_RECVBUFF; i++) { _rtw_init_listhead(&precvbuf->list); precvbuf->adapter = padapter; rtw_list_insert_tail(&precvbuf->list, &precvpriv->free_recv_buf_queue.queue); precvbuf++; } precvpriv->free_recv_buf_queue_cnt = i; //3 2. init tasklet tasklet_init(&precvpriv->recv_tasklet, (void(*)(unsigned long))rtl8195as_recv_tasklet, (unsigned long)padapter); goto exit; exit: return res; }
int init_mp_priv(struct mp_priv *pmp_priv) { int i, res; struct mp_xmit_frame *pmp_xmitframe; //DBG_871X("+_init_mp_priv\n"); _init_mp_priv_(pmp_priv); _rtw_init_queue(&pmp_priv->free_mp_xmitqueue); pmp_priv->pallocated_mp_xmitframe_buf = NULL; pmp_priv->pallocated_mp_xmitframe_buf = _rtw_zmalloc(NR_MP_XMITFRAME * sizeof(struct mp_xmit_frame) + 4); if (pmp_priv->pallocated_mp_xmitframe_buf == NULL) { //ERR_8712("_init_mp_priv, alloc mp_xmitframe_buf fail\n"); res = _FAIL; goto _exit_init_mp_priv; } pmp_priv->pmp_xmtframe_buf = pmp_priv->pallocated_mp_xmitframe_buf + 4 - ((uint) (pmp_priv->pallocated_mp_xmitframe_buf) & 3); pmp_xmitframe = (struct mp_xmit_frame*)pmp_priv->pmp_xmtframe_buf; for (i = 0; i < NR_MP_XMITFRAME; i++) { _rtw_init_listhead(&(pmp_xmitframe->list)); rtw_list_insert_tail(&(pmp_xmitframe->list), &(pmp_priv->free_mp_xmitqueue.queue)); pmp_xmitframe->pkt = NULL; pmp_xmitframe->frame_tag = MP_FRAMETAG; pmp_xmitframe->padapter = pmp_priv->papdater; pmp_xmitframe++; } pmp_priv->free_mp_xmitframe_cnt = NR_MP_XMITFRAME; res = _SUCCESS; _exit_init_mp_priv: return res; }
static s32 _rtw_mi_buddy_clone_bcmc_packet(_adapter *adapter, union recv_frame *precvframe, u8 *pphy_status, union recv_frame *pcloneframe) { s32 ret = _SUCCESS; u8 *pbuf = precvframe->u.hdr.rx_data; struct rx_pkt_attrib *pattrib = NULL; HAL_DATA_TYPE *pHalData = GET_HAL_DATA(adapter); if (pcloneframe) { pcloneframe->u.hdr.adapter = adapter; _rtw_init_listhead(&pcloneframe->u.hdr.list); pcloneframe->u.hdr.precvbuf = NULL; /*can't access the precvbuf for new arch.*/ pcloneframe->u.hdr.len = 0; _rtw_memcpy(&pcloneframe->u.hdr.attrib, &precvframe->u.hdr.attrib, sizeof(struct rx_pkt_attrib)); pattrib = &pcloneframe->u.hdr.attrib; #ifdef CONFIG_SKB_ALLOCATED if (rtw_os_alloc_recvframe(adapter, pcloneframe, pbuf, NULL) == _SUCCESS) #else if (rtw_os_recvframe_duplicate_skb(adapter, pcloneframe, precvframe->u.hdr.pkt) == _SUCCESS) #endif { #ifdef CONFIG_SKB_ALLOCATED recvframe_put(pcloneframe, pattrib->pkt_len); #endif #ifdef DBG_SKB_PROCESS rtw_dbg_skb_process(adapter, precvframe, pcloneframe); #endif if (pattrib->physt && pphy_status) rx_query_phy_status(pcloneframe, pphy_status); ret = rtw_recv_entry(pcloneframe); } else { ret = -1; RTW_INFO("%s()-%d: rtw_os_alloc_recvframe() failed!\n", __func__, __LINE__); } } return ret; }
void rtl8723bs_free_xmit_priv(PADAPTER padapter) { PHAL_DATA_TYPE phal; struct xmit_priv *pxmitpriv; struct xmit_buf *pxmitbuf; _queue *pqueue; _list *plist, *phead; _list tmplist; _irqL irql; phal = GET_HAL_DATA(padapter); pxmitpriv = &padapter->xmitpriv; pqueue = &pxmitpriv->pending_xmitbuf_queue; phead = get_list_head(pqueue); _rtw_init_listhead(&tmplist); _enter_critical_bh(&pqueue->lock, &irql); if (_rtw_queue_empty(pqueue) == _FALSE) { // Insert tmplist to end of queue, and delete phead // then tmplist become head of queue. rtw_list_insert_tail(&tmplist, phead); rtw_list_delete(phead); } _exit_critical_bh(&pqueue->lock, &irql); phead = &tmplist; while (rtw_is_list_empty(phead) == _FALSE) { plist = get_next(phead); rtw_list_delete(plist); pxmitbuf = LIST_CONTAINOR(plist, struct xmit_buf, list); rtw_free_xmitframe(pxmitpriv, (struct xmit_frame*)pxmitbuf->priv_data); pxmitbuf->priv_data = NULL; rtw_free_xmitbuf(pxmitpriv, pxmitbuf); } _rtw_spinlock_free(&phal->SdioTxFIFOFreePageLock); }
static int init_mp_priv_by_os(struct mp_priv *pmp_priv) { int i, res; struct mp_xmit_frame *pmp_xmitframe; if (pmp_priv == NULL) return _FAIL; _rtw_init_queue(&pmp_priv->free_mp_xmitqueue); pmp_priv->pallocated_mp_xmitframe_buf = NULL; pmp_priv->pallocated_mp_xmitframe_buf = rtw_zmalloc(NR_MP_XMITFRAME * sizeof(struct mp_xmit_frame) + 4); if (pmp_priv->pallocated_mp_xmitframe_buf == NULL) { res = _FAIL; goto _exit_init_mp_priv; } pmp_priv->pmp_xmtframe_buf = pmp_priv->pallocated_mp_xmitframe_buf + 4 - ((uint) (pmp_priv->pallocated_mp_xmitframe_buf) & 3); pmp_xmitframe = (struct mp_xmit_frame*)pmp_priv->pmp_xmtframe_buf; for (i = 0; i < NR_MP_XMITFRAME; i++) { _rtw_init_listhead(&pmp_xmitframe->list); rtw_list_insert_tail(&pmp_xmitframe->list, &pmp_priv->free_mp_xmitqueue.queue); pmp_xmitframe->pkt = NULL; pmp_xmitframe->frame_tag = MP_FRAMETAG; pmp_xmitframe->padapter = pmp_priv->papdater; pmp_xmitframe++; } pmp_priv->free_mp_xmitframe_cnt = NR_MP_XMITFRAME; res = _SUCCESS; _exit_init_mp_priv: return res; }
u32 _rtw_init_sta_priv(struct sta_priv *pstapriv) { struct sta_info *psta; s32 i; _func_enter_; pstapriv->pallocated_stainfo_buf = rtw_zvmalloc (sizeof(struct sta_info) * NUM_STA+ 4); if (!pstapriv->pallocated_stainfo_buf) return _FAIL; pstapriv->pstainfo_buf = pstapriv->pallocated_stainfo_buf + 4 - ((size_t)(pstapriv->pallocated_stainfo_buf ) & 3); _rtw_init_queue(&pstapriv->free_sta_queue); _rtw_spinlock_init(&pstapriv->sta_hash_lock); pstapriv->asoc_sta_count = 0; _rtw_init_queue(&pstapriv->sleep_q); _rtw_init_queue(&pstapriv->wakeup_q); psta = (struct sta_info *)(pstapriv->pstainfo_buf); for (i = 0; i < NUM_STA; i++) { _rtw_init_stainfo(psta); _rtw_init_listhead(&(pstapriv->sta_hash[i])); rtw_list_insert_tail(&psta->list, get_list_head(&pstapriv->free_sta_queue)); psta++; } #ifdef CONFIG_AP_MODE pstapriv->sta_dz_bitmap = 0; pstapriv->tim_bitmap = 0; _rtw_init_listhead(&pstapriv->asoc_list); _rtw_init_listhead(&pstapriv->auth_list); _rtw_spinlock_init(&pstapriv->asoc_list_lock); _rtw_spinlock_init(&pstapriv->auth_list_lock); pstapriv->asoc_list_cnt = 0; pstapriv->auth_list_cnt = 0; pstapriv->auth_to = 3; /* 3*2 = 6 sec */ pstapriv->assoc_to = 3; pstapriv->expire_to = 3; /* 3*2 = 6 sec */ pstapriv->max_num_sta = NUM_STA; #endif _func_exit_; return _SUCCESS; }
int recvbuf2recvframe(PADAPTER padapter, void *ptr) { u8 *pbuf; u8 pkt_cnt = 0; u32 pkt_offset; s32 transfer_len; u8 *pdata, *pphy_status; union recv_frame *precvframe = NULL; struct rx_pkt_attrib *pattrib = NULL; PHAL_DATA_TYPE pHalData; struct recv_priv *precvpriv; _queue *pfree_recv_queue; _pkt *pskb; pHalData = GET_HAL_DATA(padapter); precvpriv = &padapter->recvpriv; pfree_recv_queue = &precvpriv->free_recv_queue; #ifdef CONFIG_USE_USB_BUFFER_ALLOC_RX pskb = NULL; transfer_len = (s32)((struct recv_buf*)ptr)->transfer_len; pbuf = ((struct recv_buf*)ptr)->pbuf; #else // !CONFIG_USE_USB_BUFFER_ALLOC_RX pskb = (_pkt*)ptr; transfer_len = (s32)pskb->len; pbuf = pskb->data; #endif // !CONFIG_USE_USB_BUFFER_ALLOC_RX #ifdef CONFIG_USB_RX_AGGREGATION pkt_cnt = GET_RX_STATUS_DESC_USB_AGG_PKTNUM_8723B(pbuf); #endif do { precvframe = rtw_alloc_recvframe(pfree_recv_queue); if (precvframe == NULL) { DBG_8192C("%s: rtw_alloc_recvframe() failed! RX Drop!\n", __FUNCTION__); goto _exit_recvbuf2recvframe; } if (transfer_len >1500) _rtw_init_listhead(&precvframe->u.hdr.list); precvframe->u.hdr.precvbuf = NULL; //can't access the precvbuf for new arch. precvframe->u.hdr.len = 0; rtl8723b_query_rx_desc_status(precvframe, pbuf); pattrib = &precvframe->u.hdr.attrib; if ((padapter->registrypriv.mp_mode == 0) && ((pattrib->crc_err) || (pattrib->icv_err))) { DBG_8192C("%s: RX Warning! crc_err=%d icv_err=%d, skip!\n", __FUNCTION__, pattrib->crc_err, pattrib->icv_err); rtw_free_recvframe(precvframe, pfree_recv_queue); goto _exit_recvbuf2recvframe; } pkt_offset = RXDESC_SIZE + pattrib->drvinfo_sz + pattrib->shift_sz + pattrib->pkt_len; if ((pattrib->pkt_len <= 0) || (pkt_offset > transfer_len)) { DBG_8192C("%s: RX Error! pkt_len=%d pkt_offset=%d transfer_len=%d\n", __FUNCTION__, pattrib->pkt_len, pkt_offset, transfer_len); rtw_free_recvframe(precvframe, pfree_recv_queue); goto _exit_recvbuf2recvframe; } pdata = pbuf + RXDESC_SIZE + pattrib->drvinfo_sz + pattrib->shift_sz; if (rtw_os_alloc_recvframe(padapter, precvframe, pdata, pskb) == _FAIL) { DBG_8192C("%s: RX Error! rtw_os_alloc_recvframe FAIL!\n", __FUNCTION__); rtw_free_recvframe(precvframe, pfree_recv_queue); goto _exit_recvbuf2recvframe; } recvframe_put(precvframe, pattrib->pkt_len); if (pattrib->pkt_rpt_type == NORMAL_RX) { if (pattrib->physt) pphy_status = pbuf + RXDESC_OFFSET; else pphy_status = NULL; #ifdef CONFIG_CONCURRENT_MODE if (rtw_buddy_adapter_up(padapter)) { if (pre_recv_entry(precvframe, pphy_status) != _SUCCESS) { // Return fail except data frame //DBG_8192C("%s: RX Error! (concurrent)pre_recv_entry FAIL!\n", __FUNCTION__); } } #endif // CONFIG_CONCURRENT_MODE if (pphy_status) rx_query_phy_status(precvframe, pphy_status); if (rtw_recv_entry(precvframe) != _SUCCESS) { // Return fail except data frame //DBG_8192C("%s: RX Error! rtw_recv_entry FAIL!\n", __FUNCTION__); } } else { #ifdef CONFIG_C2H_PACKET_EN if (pattrib->pkt_rpt_type == C2H_PACKET) { rtl8723b_c2h_packet_handler(padapter, precvframe->u.hdr.rx_data, pattrib->pkt_len); } else { DBG_8192C("%s: [WARNNING] RX type(%d) not be handled!\n", __FUNCTION__, pattrib->pkt_rpt_type); } #endif // CONFIG_C2H_PACKET_EN rtw_free_recvframe(precvframe, pfree_recv_queue); } #ifdef CONFIG_USB_RX_AGGREGATION // jaguar 8-byte alignment pkt_offset = (u16)_RND8(pkt_offset); pkt_cnt--; pbuf += pkt_offset; #endif transfer_len -= pkt_offset; precvframe = NULL; } while (transfer_len > 0); _exit_recvbuf2recvframe: return _SUCCESS; }
static s32 pre_recv_entry(union recv_frame *precvframe, u8 *pphy_status) { s32 ret=_SUCCESS; #ifdef CONFIG_CONCURRENT_MODE u8 *secondary_myid, *paddr1; union recv_frame *precvframe_if2 = NULL; _adapter *primary_padapter = precvframe->u.hdr.adapter; _adapter *secondary_padapter = primary_padapter->pbuddy_adapter; struct recv_priv *precvpriv = &primary_padapter->recvpriv; _queue *pfree_recv_queue = &precvpriv->free_recv_queue; u8 *pbuf = precvframe->u.hdr.rx_data; if(!secondary_padapter) return ret; paddr1 = GetAddr1Ptr(pbuf); if(IS_MCAST(paddr1) == _FALSE)//unicast packets { secondary_myid = adapter_mac_addr(secondary_padapter); if(_rtw_memcmp(paddr1, secondary_myid, ETH_ALEN)) { //change to secondary interface precvframe->u.hdr.adapter = secondary_padapter; } //ret = recv_entry(precvframe); } else // Handle BC/MC Packets { u8 clone = _TRUE; #if 0 u8 type, subtype, *paddr2, *paddr3; type = GetFrameType(pbuf); subtype = GetFrameSubType(pbuf); //bit(7)~bit(2) switch (type) { case WIFI_MGT_TYPE: //Handle BC/MC mgnt Packets if(subtype == WIFI_BEACON) { paddr3 = GetAddr3Ptr(precvframe->u.hdr.rx_data); if (check_fwstate(&secondary_padapter->mlmepriv, _FW_LINKED) && _rtw_memcmp(paddr3, get_bssid(&secondary_padapter->mlmepriv), ETH_ALEN)) { //change to secondary interface precvframe->u.hdr.adapter = secondary_padapter; clone = _FALSE; } if(check_fwstate(&primary_padapter->mlmepriv, _FW_LINKED) && _rtw_memcmp(paddr3, get_bssid(&primary_padapter->mlmepriv), ETH_ALEN)) { if(clone==_FALSE) { clone = _TRUE; } else { clone = _FALSE; } precvframe->u.hdr.adapter = primary_padapter; } if(check_fwstate(&primary_padapter->mlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING) || check_fwstate(&secondary_padapter->mlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING)) { clone = _TRUE; precvframe->u.hdr.adapter = primary_padapter; } } else if(subtype == WIFI_PROBEREQ) { //probe req frame is only for interface2 //change to secondary interface precvframe->u.hdr.adapter = secondary_padapter; clone = _FALSE; } break; case WIFI_CTRL_TYPE: // Handle BC/MC ctrl Packets break; case WIFI_DATA_TYPE: //Handle BC/MC data Packets //Notes: AP MODE never rx BC/MC data packets paddr2 = GetAddr2Ptr(precvframe->u.hdr.rx_data); if(_rtw_memcmp(paddr2, get_bssid(&secondary_padapter->mlmepriv), ETH_ALEN)) { //change to secondary interface precvframe->u.hdr.adapter = secondary_padapter; clone = _FALSE; } break; default: break; } #endif if(_TRUE == clone) { //clone/copy to if2 struct rx_pkt_attrib *pattrib = NULL; precvframe_if2 = rtw_alloc_recvframe(pfree_recv_queue); if(precvframe_if2) { precvframe_if2->u.hdr.adapter = secondary_padapter; _rtw_init_listhead(&precvframe_if2->u.hdr.list); precvframe_if2->u.hdr.precvbuf = NULL; //can't access the precvbuf for new arch. precvframe_if2->u.hdr.len=0; _rtw_memcpy(&precvframe_if2->u.hdr.attrib, &precvframe->u.hdr.attrib, sizeof(struct rx_pkt_attrib)); pattrib = &precvframe_if2->u.hdr.attrib; if(rtw_os_alloc_recvframe(secondary_padapter, precvframe_if2, pbuf, NULL) == _SUCCESS) { recvframe_put(precvframe_if2, pattrib->pkt_len); //recvframe_pull(precvframe_if2, drvinfo_sz + RXDESC_SIZE); if (pattrib->physt && pphy_status) rx_query_phy_status(precvframe_if2, pphy_status); ret = rtw_recv_entry(precvframe_if2); } else { rtw_free_recvframe(precvframe_if2, pfree_recv_queue); DBG_8192C("%s()-%d: alloc_skb() failed!\n", __FUNCTION__, __LINE__); } } } } //if (precvframe->u.hdr.attrib.physt) // rx_query_phy_status(precvframe, pphy_status); //ret = rtw_recv_entry(precvframe); #endif return ret; }
int rtl8192cu_init_recv_priv(_adapter *padapter) { struct recv_priv *precvpriv = &padapter->recvpriv; int i, res = _SUCCESS; struct recv_buf *precvbuf; #ifdef CONFIG_RECV_THREAD_MODE _rtw_init_sema(&precvpriv->recv_sema, 0);//will be removed _rtw_init_sema(&precvpriv->terminate_recvthread_sema, 0);//will be removed #endif #ifdef PLATFORM_LINUX tasklet_init(&precvpriv->recv_tasklet, (void(*)(unsigned long))rtl8192cu_recv_tasklet, (unsigned long)padapter); #endif #ifdef CONFIG_USB_INTERRUPT_IN_PIPE #ifdef PLATFORM_LINUX precvpriv->int_in_urb = usb_alloc_urb(0, GFP_KERNEL); if(precvpriv->int_in_urb == NULL){ DBG_8192C("alloc_urb for interrupt in endpoint fail !!!!\n"); } #endif precvpriv->int_in_buf = rtw_zmalloc(sizeof(INTERRUPT_MSG_FORMAT_EX)); if(precvpriv->int_in_buf == NULL){ DBG_8192C("alloc_mem for interrupt in endpoint fail !!!!\n"); } #endif //init recv_buf _rtw_init_queue(&precvpriv->free_recv_buf_queue); #ifdef CONFIG_USE_USB_BUFFER_ALLOC_RX _rtw_init_queue(&precvpriv->recv_buf_pending_queue); #endif // CONFIG_USE_USB_BUFFER_ALLOC_RX precvpriv->pallocated_recv_buf = rtw_zmalloc(NR_RECVBUFF *sizeof(struct recv_buf) + 4); if(precvpriv->pallocated_recv_buf==NULL){ res= _FAIL; RT_TRACE(_module_rtl871x_recv_c_,_drv_err_,("alloc recv_buf fail!\n")); goto exit; } _rtw_memset(precvpriv->pallocated_recv_buf, 0, NR_RECVBUFF *sizeof(struct recv_buf) + 4); precvpriv->precv_buf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(precvpriv->pallocated_recv_buf), 4); //precvpriv->precv_buf = precvpriv->pallocated_recv_buf + 4 - // ((uint) (precvpriv->pallocated_recv_buf) &(4-1)); precvbuf = (struct recv_buf*)precvpriv->precv_buf; for(i=0; i < NR_RECVBUFF ; i++) { _rtw_init_listhead(&precvbuf->list); _rtw_spinlock_init(&precvbuf->recvbuf_lock); precvbuf->alloc_sz = MAX_RECVBUF_SZ; res = rtw_os_recvbuf_resource_alloc(padapter, precvbuf); if(res==_FAIL) break; precvbuf->ref_cnt = 0; precvbuf->adapter =padapter; //rtw_list_insert_tail(&precvbuf->list, &(precvpriv->free_recv_buf_queue.queue)); precvbuf++; } precvpriv->free_recv_buf_queue_cnt = NR_RECVBUFF; #ifdef PLATFORM_LINUX skb_queue_head_init(&precvpriv->rx_skb_queue); #ifdef CONFIG_PREALLOC_RECV_SKB { int i; SIZE_PTR tmpaddr=0; SIZE_PTR alignment=0; struct sk_buff *pskb=NULL; skb_queue_head_init(&precvpriv->free_recv_skb_queue); for(i=0; i<NR_PREALLOC_RECV_SKB; i++) { #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)) // http://www.mail-archive.com/[email protected]/msg17214.html pskb = dev_alloc_skb(MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ); #else pskb = netdev_alloc_skb(padapter->pnetdev, MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ); #endif if(pskb) { pskb->dev = padapter->pnetdev; tmpaddr = (SIZE_PTR)pskb->data; alignment = tmpaddr & (RECVBUFF_ALIGN_SZ-1); skb_reserve(pskb, (RECVBUFF_ALIGN_SZ - alignment)); skb_queue_tail(&precvpriv->free_recv_skb_queue, pskb); } pskb=NULL; } } #endif #endif exit: return res; }
u32 _rtw_init_sta_priv(struct sta_priv *pstapriv) { struct sta_info *psta; s32 i; _func_enter_; #ifdef MEM_ALLOC_REFINE pstapriv->pallocated_stainfo_buf = rtw_zvmalloc (sizeof(struct sta_info) * NUM_STA+ 4); #else pstapriv->pallocated_stainfo_buf = rtw_zmalloc (sizeof(struct sta_info) * NUM_STA+ 4); #endif if(!pstapriv->pallocated_stainfo_buf) return _FAIL; pstapriv->pstainfo_buf = pstapriv->pallocated_stainfo_buf + 4 - ((SIZE_PTR)(pstapriv->pallocated_stainfo_buf ) & 3); _rtw_init_queue(&pstapriv->free_sta_queue); _rtw_spinlock_init(&pstapriv->sta_hash_lock); //_rtw_init_queue(&pstapriv->asoc_q); pstapriv->asoc_sta_count = 0; _rtw_init_queue(&pstapriv->sleep_q); _rtw_init_queue(&pstapriv->wakeup_q); psta = (struct sta_info *)(pstapriv->pstainfo_buf); for(i = 0; i < NUM_STA; i++) { _rtw_init_stainfo(psta); _rtw_init_listhead(&(pstapriv->sta_hash[i])); rtw_list_insert_tail(&psta->list, get_list_head(&pstapriv->free_sta_queue)); psta++; } #ifdef CONFIG_AP_MODE pstapriv->sta_dz_bitmap = 0; pstapriv->tim_bitmap = 0; _rtw_init_listhead(&pstapriv->asoc_list); _rtw_init_listhead(&pstapriv->auth_list); pstapriv->auth_to = 3; // 3*2 = 6 sec pstapriv->assoc_to = 3; pstapriv->expire_to = 900;// 900*2 = 1800 sec = 30 min, expire after no any traffic. pstapriv->max_num_sta = NUM_STA; #endif _func_exit_; return _SUCCESS; }
s32 rtw_init_xmit_priv(PADAPTER padapter) { struct xmit_buf *pxmitbuf; sint res=_SUCCESS; int i , j=0; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; _rtw_init_queue(&pxmitpriv->free_xmit_queue); _rtw_init_queue(&pxmitpriv->xmitbuf_pending_queue); _rtw_spinlock_init(&pxmitpriv->lock_sctx); _rtw_init_sema(&pxmitpriv->xmit_sema, 0); //_rtw_init_sema(&padapter->XmitTerminateSema, 0); pxmitpriv->padapter = padapter; pxmitpriv->pallocated_freebuf = rtw_zvmalloc(NR_XMITBUFF*sizeof(struct xmit_buf)+4); if(pxmitpriv->pallocated_freebuf==NULL) { DBG_871X("%s: pallocated_freebuf failed!\n", __FUNCTION__); res = _FAIL; goto exit; } pxmitpriv->xmit_freebuf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(pxmitpriv->pallocated_freebuf), 4); pxmitbuf = (struct xmit_buf *)pxmitpriv->xmit_freebuf; for (i = 0; i < NR_XMITBUFF; i++) { _rtw_init_listhead(&(pxmitbuf->list)); pxmitbuf->padapter = padapter; /* Tx buf allocation may fail sometimes, so sleep and retry. */ if((res=rtw_os_xmit_resource_alloc(padapter, pxmitbuf,(MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ), _TRUE)) == _FAIL) { rtw_msleep_os(10); res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf,(MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ), _TRUE); if (res == _FAIL) { goto free_os_resource; } } #if defined(CONFIG_SDIO_HCI) || defined(CONFIG_GSPI_HCI) pxmitbuf->phead = pxmitbuf->pbuf; pxmitbuf->pend = pxmitbuf->pbuf + MAX_XMITBUF_SZ; pxmitbuf->pkt_len = 0; pxmitbuf->pdata = pxmitbuf->ptail = pxmitbuf->phead; #endif rtw_list_insert_tail(&(pxmitbuf->list), &(pxmitpriv->free_xmit_queue.queue)); #ifdef DBG_XMIT_BUF pxmitbuf->no=i; #endif pxmitbuf++; } pxmitpriv->free_xmitbuf_cnt = NR_XMITBUFF; #ifdef CONFIG_USB_HCI pxmitpriv->txirp_cnt=1; _rtw_init_sema(&(pxmitpriv->tx_retevt), 0); //per AC pending irp pxmitpriv->beq_cnt = 0; pxmitpriv->bkq_cnt = 0; pxmitpriv->viq_cnt = 0; pxmitpriv->voq_cnt = 0; #endif if((res = rtw_hal_init_xmit_priv(padapter)) == _FAIL) goto free_os_resource; free_os_resource: if(res == _FAIL){ pxmitbuf = (struct xmit_buf *)pxmitpriv->xmit_freebuf; for(j=1;j<i;j++) { rtw_os_xmit_resource_free(padapter, pxmitbuf,(MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ), _TRUE); pxmitbuf++; } } if((res == _FAIL)&&(pxmitpriv->pallocated_freebuf)) rtw_vmfree(pxmitpriv->pallocated_freebuf, NR_XMITBUFF*sizeof(struct xmit_buf)+4); exit: _func_exit_; return res; }
int recvbuf2recvframe(PADAPTER padapter, void *ptr) { u8 *pbuf; u8 pkt_cnt = 0; u32 pkt_offset; s32 transfer_len; u8 *pphy_status = NULL; union recv_frame *precvframe = NULL; struct rx_pkt_attrib *pattrib = NULL; HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); struct recv_priv *precvpriv = &padapter->recvpriv; _queue *pfree_recv_queue = &precvpriv->free_recv_queue; _pkt *pskb; #ifdef CONFIG_USE_USB_BUFFER_ALLOC_RX pskb = NULL; transfer_len = (s32)((struct recv_buf*)ptr)->transfer_len; pbuf = ((struct recv_buf*)ptr)->pbuf; #else pskb = (_pkt*)ptr; transfer_len = (s32)pskb->len; pbuf = pskb->data; #endif//CONFIG_USE_USB_BUFFER_ALLOC_RX #ifdef CONFIG_USB_RX_AGGREGATION pkt_cnt = GET_RX_STATUS_DESC_USB_AGG_PKTNUM_8812(pbuf); #endif do{ precvframe = rtw_alloc_recvframe(pfree_recv_queue); if(precvframe==NULL) { RT_TRACE(_module_rtl871x_recv_c_,_drv_err_,("recvbuf2recvframe: precvframe==NULL\n")); DBG_8192C("%s()-%d: rtw_alloc_recvframe() failed! RX Drop!\n", __FUNCTION__, __LINE__); goto _exit_recvbuf2recvframe; } _rtw_init_listhead(&precvframe->u.hdr.list); precvframe->u.hdr.precvbuf = NULL; //can't access the precvbuf for new arch. precvframe->u.hdr.len=0; rtl8812_query_rx_desc_status(precvframe, pbuf); pattrib = &precvframe->u.hdr.attrib; if ((padapter->registrypriv.mp_mode == 0) && ((pattrib->crc_err) || (pattrib->icv_err))) { DBG_8192C("%s: RX Warning! crc_err=%d icv_err=%d, skip!\n", __FUNCTION__, pattrib->crc_err, pattrib->icv_err); rtw_free_recvframe(precvframe, pfree_recv_queue); goto _exit_recvbuf2recvframe; } pkt_offset = RXDESC_SIZE + pattrib->drvinfo_sz + pattrib->shift_sz + pattrib->pkt_len; if((pattrib->pkt_len<=0) || (pkt_offset>transfer_len)) { RT_TRACE(_module_rtl871x_recv_c_,_drv_info_,("recvbuf2recvframe: pkt_len<=0\n")); DBG_8192C("%s()-%d: RX Warning!,pkt_len<=0 or pkt_offset> transfer_len \n", __FUNCTION__, __LINE__); rtw_free_recvframe(precvframe, pfree_recv_queue); goto _exit_recvbuf2recvframe; } #ifdef CONFIG_RX_PACKET_APPEND_FCS if(pattrib->pkt_rpt_type == NORMAL_RX) pattrib->pkt_len -= IEEE80211_FCS_LEN; #endif if(rtw_os_alloc_recvframe(padapter, precvframe, (pbuf + pattrib->shift_sz + pattrib->drvinfo_sz + RXDESC_SIZE), pskb) == _FAIL) { rtw_free_recvframe(precvframe, pfree_recv_queue); goto _exit_recvbuf2recvframe; } recvframe_put(precvframe, pattrib->pkt_len); //recvframe_pull(precvframe, drvinfo_sz + RXDESC_SIZE); if(pattrib->pkt_rpt_type == NORMAL_RX)//Normal rx packet { if(pattrib->physt) pphy_status = (pbuf + RXDESC_OFFSET); #ifdef CONFIG_CONCURRENT_MODE if(rtw_buddy_adapter_up(padapter)) { if(pre_recv_entry(precvframe, pphy_status) != _SUCCESS) { RT_TRACE(_module_rtl871x_recv_c_,_drv_err_, ("recvbuf2recvframe: recv_entry(precvframe) != _SUCCESS\n")); } } #endif //CONFIG_CONCURRENT_MODE if(pattrib->physt && pphy_status) rx_query_phy_status(precvframe, pphy_status); if(rtw_recv_entry(precvframe) != _SUCCESS) { RT_TRACE(_module_rtl871x_recv_c_,_drv_err_, ("recvbuf2recvframe: rtw_recv_entry(precvframe) != _SUCCESS\n")); } } else{ // pkt_rpt_type == TX_REPORT1-CCX, TX_REPORT2-TX RTP,HIS_REPORT-USB HISR RTP if (pattrib->pkt_rpt_type == C2H_PACKET) { //DBG_8192C("rx C2H_PACKET \n"); C2HPacketHandler_8812(padapter,precvframe->u.hdr.rx_data,pattrib->pkt_len); } rtw_free_recvframe(precvframe, pfree_recv_queue); } #ifdef CONFIG_USB_RX_AGGREGATION // jaguar 8-byte alignment pkt_offset = (u16)_RND8(pkt_offset); pkt_cnt--; pbuf += pkt_offset; #endif transfer_len -= pkt_offset; precvframe = NULL; }while(transfer_len>0); _exit_recvbuf2recvframe: return _SUCCESS; }
u32 _rtw_init_sta_priv(struct sta_priv *pstapriv) { struct sta_info *psta; s32 i; _func_enter_; pstapriv->pallocated_stainfo_buf = rtw_zvmalloc (sizeof(struct sta_info) * NUM_STA+ 4); if(!pstapriv->pallocated_stainfo_buf) return _FAIL; pstapriv->pstainfo_buf = pstapriv->pallocated_stainfo_buf + 4 - ((SIZE_PTR)(pstapriv->pallocated_stainfo_buf ) & 3); _rtw_init_queue(&pstapriv->free_sta_queue); _rtw_spinlock_init(&pstapriv->sta_hash_lock); //_rtw_init_queue(&pstapriv->asoc_q); pstapriv->asoc_sta_count = 0; _rtw_init_queue(&pstapriv->sleep_q); _rtw_init_queue(&pstapriv->wakeup_q); psta = (struct sta_info *)(pstapriv->pstainfo_buf); for(i = 0; i < NUM_STA; i++) { _rtw_init_stainfo(psta); _rtw_init_listhead(&(pstapriv->sta_hash[i])); rtw_list_insert_tail(&psta->list, get_list_head(&pstapriv->free_sta_queue)); psta++; } #ifdef CONFIG_AP_MODE pstapriv->sta_dz_bitmap = 0; pstapriv->tim_bitmap = 0; _rtw_init_listhead(&pstapriv->asoc_list); _rtw_init_listhead(&pstapriv->auth_list); _rtw_spinlock_init(&pstapriv->asoc_list_lock); _rtw_spinlock_init(&pstapriv->auth_list_lock); pstapriv->asoc_list_cnt = 0; pstapriv->auth_list_cnt = 0; pstapriv->auth_to = 3; // 3*2 = 6 sec pstapriv->assoc_to = 3; //pstapriv->expire_to = 900;// 900*2 = 1800 sec = 30 min, expire after no any traffic. //pstapriv->expire_to = 30;// 30*2 = 60 sec = 1 min, expire after no any traffic. #ifdef CONFIG_ACTIVE_KEEP_ALIVE_CHECK pstapriv->expire_to = 3; // 3*2 = 6 sec #else pstapriv->expire_to = 60;// 60*2 = 120 sec = 2 min, expire after no any traffic. #endif #ifdef CONFIG_ATMEL_RC_PATCH _rtw_memset( pstapriv->atmel_rc_pattern, 0, ETH_ALEN); #endif pstapriv->max_num_sta = NUM_STA; #endif _func_exit_; return _SUCCESS; }
int usb_init_recv_priv(_adapter *padapter, u16 ini_in_buf_sz) { struct recv_priv *precvpriv = &padapter->recvpriv; int i, res = _SUCCESS; struct recv_buf *precvbuf; #ifdef CONFIG_RECV_THREAD_MODE _rtw_init_sema(&precvpriv->recv_sema, 0);//will be removed _rtw_init_sema(&precvpriv->terminate_recvthread_sema, 0);//will be removed #endif /* CONFIG_RECV_THREAD_MODE */ #ifdef PLATFORM_LINUX tasklet_init(&precvpriv->recv_tasklet, (void(*)(unsigned long))usb_recv_tasklet, (unsigned long)padapter); #endif /* PLATFORM_LINUX */ #ifdef PLATFORM_FREEBSD #ifdef CONFIG_RX_INDICATE_QUEUE TASK_INIT(&precvpriv->rx_indicate_tasklet, 0, rtw_rx_indicate_tasklet, padapter); #endif /* CONFIG_RX_INDICATE_QUEUE */ #endif /* PLATFORM_FREEBSD */ #ifdef CONFIG_USB_INTERRUPT_IN_PIPE #ifdef PLATFORM_LINUX precvpriv->int_in_urb = usb_alloc_urb(0, GFP_KERNEL); if(precvpriv->int_in_urb == NULL){ res = _FAIL; DBG_8192C("alloc_urb for interrupt in endpoint fail !!!!\n"); goto exit; } #endif /* PLATFORM_LINUX */ precvpriv->int_in_buf = rtw_zmalloc(ini_in_buf_sz); if(precvpriv->int_in_buf == NULL){ res = _FAIL; DBG_8192C("alloc_mem for interrupt in endpoint fail !!!!\n"); goto exit; } #endif /* CONFIG_USB_INTERRUPT_IN_PIPE */ /* init recv_buf */ _rtw_init_queue(&precvpriv->free_recv_buf_queue); _rtw_init_queue(&precvpriv->recv_buf_pending_queue); #ifndef CONFIG_USE_USB_BUFFER_ALLOC_RX /* this is used only when RX_IOBUF is sk_buff */ skb_queue_head_init(&precvpriv->free_recv_skb_queue); #endif DBG_871X("NR_RECVBUFF: %d\n", NR_RECVBUFF); DBG_871X("MAX_RECVBUF_SZ: %d\n", MAX_RECVBUF_SZ); precvpriv->pallocated_recv_buf = rtw_zmalloc(NR_RECVBUFF *sizeof(struct recv_buf) + 4); if(precvpriv->pallocated_recv_buf==NULL){ res= _FAIL; RT_TRACE(_module_rtl871x_recv_c_,_drv_err_,("alloc recv_buf fail!\n")); goto exit; } precvpriv->precv_buf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(precvpriv->pallocated_recv_buf), 4); precvbuf = (struct recv_buf*)precvpriv->precv_buf; for(i=0; i < NR_RECVBUFF ; i++) { _rtw_init_listhead(&precvbuf->list); _rtw_spinlock_init(&precvbuf->recvbuf_lock); precvbuf->alloc_sz = MAX_RECVBUF_SZ; res = rtw_os_recvbuf_resource_alloc(padapter, precvbuf); if(res==_FAIL) break; precvbuf->ref_cnt = 0; precvbuf->adapter =padapter; //rtw_list_insert_tail(&precvbuf->list, &(precvpriv->free_recv_buf_queue.queue)); precvbuf++; } precvpriv->free_recv_buf_queue_cnt = NR_RECVBUFF; #if defined(PLATFORM_LINUX) || defined(PLATFORM_FREEBSD) skb_queue_head_init(&precvpriv->rx_skb_queue); #ifdef CONFIG_RX_INDICATE_QUEUE memset(&precvpriv->rx_indicate_queue, 0, sizeof(struct ifqueue)); mtx_init(&precvpriv->rx_indicate_queue.ifq_mtx, "rx_indicate_queue", NULL, MTX_DEF); #endif /* CONFIG_RX_INDICATE_QUEUE */ #ifdef CONFIG_PREALLOC_RECV_SKB { int i; SIZE_PTR tmpaddr=0; SIZE_PTR alignment=0; struct sk_buff *pskb=NULL; DBG_871X("NR_PREALLOC_RECV_SKB: %d\n", NR_PREALLOC_RECV_SKB); #ifdef CONFIG_FIX_NR_BULKIN_BUFFER DBG_871X("Enable CONFIG_FIX_NR_BULKIN_BUFFER\n"); #endif for(i=0; i<NR_PREALLOC_RECV_SKB; i++) { #ifdef CONFIG_PREALLOC_RX_SKB_BUFFER pskb = rtw_alloc_skb_premem(MAX_RECVBUF_SZ); #else pskb = rtw_skb_alloc(MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ); #endif //CONFIG_PREALLOC_RX_SKB_BUFFER if(pskb) { #ifdef PLATFORM_FREEBSD pskb->dev = padapter->pifp; #else pskb->dev = padapter->pnetdev; #endif //PLATFORM_FREEBSD #ifndef CONFIG_PREALLOC_RX_SKB_BUFFER tmpaddr = (SIZE_PTR)pskb->data; alignment = tmpaddr & (RECVBUFF_ALIGN_SZ-1); skb_reserve(pskb, (RECVBUFF_ALIGN_SZ - alignment)); #endif skb_queue_tail(&precvpriv->free_recv_skb_queue, pskb); } } } #endif /* CONFIG_PREALLOC_RECV_SKB */ #endif /* defined(PLATFORM_LINUX) || defined(PLATFORM_FREEBSD) */ exit: return res; }