2013-05-08 21:45:39 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
|
2014-12-19 06:59:46 +00:00
|
|
|
*
|
2013-05-08 21:45:39 +00:00
|
|
|
* 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
|
|
|
|
*
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
#define _RTW_XMIT_C_
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
#include <drv_conf.h>
|
2013-05-08 21:45:39 +00:00
|
|
|
#include <osdep_service.h>
|
|
|
|
#include <drv_types.h>
|
|
|
|
#include <wifi.h>
|
|
|
|
#include <osdep_intf.h>
|
2014-12-11 21:15:04 +00:00
|
|
|
#include <circ_buf.h>
|
2013-05-08 21:45:39 +00:00
|
|
|
#include <ip.h>
|
|
|
|
#include <usb_ops.h>
|
2015-01-28 05:14:58 +00:00
|
|
|
#include "rtw_br_ext.h"
|
2015-01-30 03:41:53 +00:00
|
|
|
#include <usb_osintf.h>
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 };
|
|
|
|
static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 };
|
|
|
|
|
|
|
|
static void _init_txservq(struct tx_servq *ptxservq)
|
|
|
|
{
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2013-05-08 21:45:39 +00:00
|
|
|
_rtw_init_listhead(&ptxservq->tx_pending);
|
|
|
|
_rtw_init_queue(&ptxservq->sta_pending);
|
|
|
|
ptxservq->qcnt = 0;
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
void _rtw_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-01 22:31:15 +00:00
|
|
|
|
2015-02-19 20:58:09 +00:00
|
|
|
memset((unsigned char *)psta_xmitpriv, 0, sizeof (struct sta_xmit_priv));
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2015-03-05 20:42:30 +00:00
|
|
|
spin_lock_init(&psta_xmitpriv->lock);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* for(i = 0 ; i < MAX_NUMBLKS; i++) */
|
|
|
|
/* _init_txservq(&(psta_xmitpriv->blk_q[i])); */
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
_init_txservq(&psta_xmitpriv->be_q);
|
|
|
|
_init_txservq(&psta_xmitpriv->bk_q);
|
|
|
|
_init_txservq(&psta_xmitpriv->vi_q);
|
|
|
|
_init_txservq(&psta_xmitpriv->vo_q);
|
|
|
|
_rtw_init_listhead(&psta_xmitpriv->legacy_dz);
|
|
|
|
_rtw_init_listhead(&psta_xmitpriv->apsd);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct xmit_buf *pxmitbuf;
|
|
|
|
struct xmit_frame *pxframe;
|
2014-12-19 06:59:46 +00:00
|
|
|
sint res=_SUCCESS;
|
2013-05-08 21:45:39 +00:00
|
|
|
u32 max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ;
|
|
|
|
u32 num_xmit_extbuf = NR_XMIT_EXTBUFF;
|
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* We don't need to memset padapter->XXX to zero, because adapter is allocated by rtw_zvmalloc(). */
|
|
|
|
/* memset((unsigned char *)pxmitpriv, 0, sizeof(struct xmit_priv)); */
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-03-05 20:42:30 +00:00
|
|
|
spin_lock_init(&pxmitpriv->lock);
|
|
|
|
spin_lock_init(&pxmitpriv->lock_sctx);
|
2013-05-08 21:45:39 +00:00
|
|
|
_rtw_init_sema(&pxmitpriv->xmit_sema, 0);
|
|
|
|
_rtw_init_sema(&pxmitpriv->terminate_xmitthread_sema, 0);
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
/*
|
2013-05-08 21:45:39 +00:00
|
|
|
Please insert all the queue initializaiton using _rtw_init_queue below
|
|
|
|
*/
|
|
|
|
|
|
|
|
pxmitpriv->adapter = padapter;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* for(i = 0 ; i < MAX_NUMBLKS; i++) */
|
|
|
|
/* _rtw_init_queue(&pxmitpriv->blk_strms[i]); */
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
_rtw_init_queue(&pxmitpriv->be_pending);
|
|
|
|
_rtw_init_queue(&pxmitpriv->bk_pending);
|
|
|
|
_rtw_init_queue(&pxmitpriv->vi_pending);
|
|
|
|
_rtw_init_queue(&pxmitpriv->vo_pending);
|
|
|
|
_rtw_init_queue(&pxmitpriv->bm_pending);
|
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* _rtw_init_queue(&pxmitpriv->legacy_dz_queue); */
|
|
|
|
/* _rtw_init_queue(&pxmitpriv->apsd_queue); */
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
_rtw_init_queue(&pxmitpriv->free_xmit_queue);
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
/*
|
|
|
|
Please allocate memory with the sz = (struct xmit_frame) * NR_XMITFRAME,
|
2013-05-08 21:45:39 +00:00
|
|
|
and initialize free_xmit_frame below.
|
|
|
|
Please also apply free_txobj to link_up all the xmit_frames...
|
|
|
|
*/
|
|
|
|
|
|
|
|
pxmitpriv->pallocated_frame_buf = rtw_zvmalloc(NR_XMITFRAME * sizeof(struct xmit_frame) + 4);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if (pxmitpriv->pallocated_frame_buf == NULL){
|
|
|
|
pxmitpriv->pxmit_frame_buf =NULL;
|
2014-12-19 06:59:46 +00:00
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_,_drv_err_,("alloc xmit_frame fail!\n"));
|
2014-12-11 21:15:04 +00:00
|
|
|
res= _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
pxmitpriv->pxmit_frame_buf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(pxmitpriv->pallocated_frame_buf), 4);
|
2015-02-19 21:34:32 +00:00
|
|
|
/* pxmitpriv->pxmit_frame_buf = pxmitpriv->pallocated_frame_buf + 4 - */
|
|
|
|
/* ((SIZE_PTR) (pxmitpriv->pallocated_frame_buf) &3); */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
pxframe = (struct xmit_frame*) pxmitpriv->pxmit_frame_buf;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
for (i = 0; i < NR_XMITFRAME; i++)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
_rtw_init_listhead(&(pxframe->list));
|
|
|
|
|
|
|
|
pxframe->padapter = padapter;
|
|
|
|
pxframe->frame_tag = NULL_FRAMETAG;
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
pxframe->pkt = NULL;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pxframe->buf_addr = NULL;
|
|
|
|
pxframe->pxmitbuf = NULL;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_list_insert_tail(&(pxframe->list), &(pxmitpriv->free_xmit_queue.queue));
|
|
|
|
|
|
|
|
pxframe++;
|
|
|
|
}
|
|
|
|
|
|
|
|
pxmitpriv->free_xmitframe_cnt = NR_XMITFRAME;
|
|
|
|
|
|
|
|
pxmitpriv->frag_len = MAX_FRAG_THRESHOLD;
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* init xmit_buf */
|
2013-05-08 21:45:39 +00:00
|
|
|
_rtw_init_queue(&pxmitpriv->free_xmitbuf_queue);
|
|
|
|
_rtw_init_queue(&pxmitpriv->pending_xmitbuf_queue);
|
|
|
|
|
|
|
|
pxmitpriv->pallocated_xmitbuf = rtw_zvmalloc(NR_XMITBUFF * sizeof(struct xmit_buf) + 4);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if (pxmitpriv->pallocated_xmitbuf == NULL){
|
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_,_drv_err_,("alloc xmit_buf fail!\n"));
|
|
|
|
res= _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
pxmitpriv->pxmitbuf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(pxmitpriv->pallocated_xmitbuf), 4);
|
2015-02-19 21:34:32 +00:00
|
|
|
/* pxmitpriv->pxmitbuf = pxmitpriv->pallocated_xmitbuf + 4 - */
|
|
|
|
/* ((SIZE_PTR) (pxmitpriv->pallocated_xmitbuf) &3); */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
pxmitbuf = (struct xmit_buf*)pxmitpriv->pxmitbuf;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
for (i = 0; i < NR_XMITBUFF; i++)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
_rtw_init_listhead(&pxmitbuf->list);
|
|
|
|
|
|
|
|
pxmitbuf->priv_data = NULL;
|
|
|
|
pxmitbuf->padapter = padapter;
|
2014-12-29 02:13:24 +00:00
|
|
|
pxmitbuf->ext_tag = false;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
/* Tx buf allocation may fail sometimes, so sleep and retry. */
|
2014-12-11 21:15:04 +00:00
|
|
|
if((res=rtw_os_xmit_resource_alloc(padapter, pxmitbuf,(MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ))) == _FAIL) {
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_msleep_os(10);
|
2014-12-11 21:15:04 +00:00
|
|
|
res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf,(MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ));
|
2013-05-08 21:45:39 +00:00
|
|
|
if (res == _FAIL) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pxmitbuf->flags = XMIT_VO_QUEUE;
|
|
|
|
|
|
|
|
rtw_list_insert_tail(&pxmitbuf->list, &(pxmitpriv->free_xmitbuf_queue.queue));
|
2014-12-11 21:15:04 +00:00
|
|
|
#ifdef DBG_XMIT_BUF
|
|
|
|
pxmitbuf->no=i;
|
|
|
|
#endif
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitbuf++;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pxmitpriv->free_xmitbuf_cnt = NR_XMITBUFF;
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
/* init xframe_ext queue, the same count as extbuf */
|
|
|
|
_rtw_init_queue(&pxmitpriv->free_xframe_ext_queue);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
pxmitpriv->xframe_ext_alloc_addr = rtw_zvmalloc(num_xmit_extbuf * sizeof(struct xmit_frame) + 4);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if (pxmitpriv->xframe_ext_alloc_addr == NULL){
|
|
|
|
pxmitpriv->xframe_ext = NULL;
|
2014-12-19 06:59:46 +00:00
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_,_drv_err_,("alloc xframe_ext fail!\n"));
|
2014-12-11 21:15:04 +00:00
|
|
|
res= _FAIL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
pxmitpriv->xframe_ext = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(pxmitpriv->xframe_ext_alloc_addr), 4);
|
|
|
|
pxframe = (struct xmit_frame*)pxmitpriv->xframe_ext;
|
|
|
|
|
|
|
|
for (i = 0; i < num_xmit_extbuf; i++) {
|
|
|
|
_rtw_init_listhead(&(pxframe->list));
|
|
|
|
|
|
|
|
pxframe->padapter = padapter;
|
|
|
|
pxframe->frame_tag = NULL_FRAMETAG;
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
pxframe->pkt = NULL;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
pxframe->buf_addr = NULL;
|
|
|
|
pxframe->pxmitbuf = NULL;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
pxframe->ext_tag = 1;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
rtw_list_insert_tail(&(pxframe->list), &(pxmitpriv->free_xframe_ext_queue.queue));
|
|
|
|
|
|
|
|
pxframe++;
|
|
|
|
}
|
|
|
|
pxmitpriv->free_xframe_ext_cnt = num_xmit_extbuf;
|
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* Init xmit extension buff */
|
2013-05-08 21:45:39 +00:00
|
|
|
_rtw_init_queue(&pxmitpriv->free_xmit_extbuf_queue);
|
|
|
|
|
|
|
|
pxmitpriv->pallocated_xmit_extbuf = rtw_zvmalloc(num_xmit_extbuf * sizeof(struct xmit_buf) + 4);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if (pxmitpriv->pallocated_xmit_extbuf == NULL){
|
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_,_drv_err_,("alloc xmit_extbuf fail!\n"));
|
|
|
|
res= _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
pxmitpriv->pxmit_extbuf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(pxmitpriv->pallocated_xmit_extbuf), 4);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
pxmitbuf = (struct xmit_buf*)pxmitpriv->pxmit_extbuf;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
for (i = 0; i < num_xmit_extbuf; i++)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
_rtw_init_listhead(&pxmitbuf->list);
|
|
|
|
|
|
|
|
pxmitbuf->priv_data = NULL;
|
|
|
|
pxmitbuf->padapter = padapter;
|
2014-12-29 02:13:24 +00:00
|
|
|
pxmitbuf->ext_tag = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
/*
|
|
|
|
pxmitbuf->pallocated_buf = rtw_zmalloc(max_xmit_extbuf_size);
|
|
|
|
if (pxmitbuf->pallocated_buf == NULL)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
res = _FAIL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
pxmitbuf->pbuf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(pxmitbuf->pallocated_buf), 4);
|
2014-12-19 06:59:46 +00:00
|
|
|
*/
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
if((res=rtw_os_xmit_resource_alloc(padapter, pxmitbuf,max_xmit_extbuf_size + XMITBUF_ALIGN_SZ)) == _FAIL) {
|
|
|
|
res= _FAIL;
|
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_list_insert_tail(&pxmitbuf->list, &(pxmitpriv->free_xmit_extbuf_queue.queue));
|
2014-12-11 21:15:04 +00:00
|
|
|
#ifdef DBG_XMIT_BUF_EXT
|
|
|
|
pxmitbuf->no=i;
|
|
|
|
#endif
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitbuf++;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pxmitpriv->free_xmit_extbuf_cnt = num_xmit_extbuf;
|
|
|
|
|
|
|
|
rtw_alloc_hwxmits(padapter);
|
|
|
|
rtw_init_hwxmits(pxmitpriv->hwxmits, pxmitpriv->hwxmit_entry);
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
for (i = 0; i < 4; i ++)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitpriv->wmm_para_seq[i] = i;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
pxmitpriv->txirp_cnt=1;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
_rtw_init_sema(&(pxmitpriv->tx_retevt), 0);
|
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* per AC pending irp */
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitpriv->beq_cnt = 0;
|
|
|
|
pxmitpriv->bkq_cnt = 0;
|
|
|
|
pxmitpriv->viq_cnt = 0;
|
|
|
|
pxmitpriv->voq_cnt = 0;
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
pxmitpriv->ack_tx = false;
|
2013-05-08 21:45:39 +00:00
|
|
|
_rtw_mutex_init(&pxmitpriv->ack_tx_mutex);
|
2014-12-19 06:59:46 +00:00
|
|
|
rtw_sctx_init(&pxmitpriv->ack_tx_ops, 0);
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_hal_init_xmit_priv(padapter);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
void rtw_mfree_xmit_priv_lock (struct xmit_priv *pxmitpriv)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
_rtw_free_sema(&pxmitpriv->xmit_sema);
|
|
|
|
_rtw_free_sema(&pxmitpriv->terminate_xmitthread_sema);
|
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
void _rtw_free_xmit_priv (struct xmit_priv *pxmitpriv)
|
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
int i;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = pxmitpriv->adapter;
|
2014-12-11 21:15:04 +00:00
|
|
|
struct xmit_frame *pxmitframe = (struct xmit_frame*) pxmitpriv->pxmit_frame_buf;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct xmit_buf *pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf;
|
|
|
|
u32 max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ;
|
|
|
|
u32 num_xmit_extbuf = NR_XMIT_EXTBUFF;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
rtw_hal_free_xmit_priv(padapter);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_mfree_xmit_priv_lock(pxmitpriv);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
if(pxmitpriv->pxmit_frame_buf==NULL)
|
2014-12-11 21:15:04 +00:00
|
|
|
goto out;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
for(i=0; i<NR_XMITFRAME; i++)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_os_xmit_complete(padapter, pxmitframe);
|
|
|
|
|
|
|
|
pxmitframe++;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
for(i=0; i<NR_XMITBUFF; i++)
|
|
|
|
{
|
|
|
|
rtw_os_xmit_resource_free(padapter, pxmitbuf,(MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ));
|
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* if(pxmitbuf->pallocated_buf) */
|
|
|
|
/* rtw_mfree(pxmitbuf->pallocated_buf, MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ); */
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitbuf++;
|
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if(pxmitpriv->pallocated_frame_buf) {
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_vmfree(pxmitpriv->pallocated_frame_buf, NR_XMITFRAME * sizeof(struct xmit_frame) + 4);
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if(pxmitpriv->pallocated_xmitbuf) {
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_vmfree(pxmitpriv->pallocated_xmitbuf, NR_XMITBUFF * sizeof(struct xmit_buf) + 4);
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* free xframe_ext queue, the same count as extbuf */
|
|
|
|
if ((pxmitframe = (struct xmit_frame*)pxmitpriv->xframe_ext)) {
|
|
|
|
for (i=0; i<num_xmit_extbuf; i++) {
|
|
|
|
rtw_os_xmit_complete(padapter, pxmitframe);
|
|
|
|
pxmitframe++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (pxmitpriv->xframe_ext_alloc_addr)
|
|
|
|
rtw_vmfree(pxmitpriv->xframe_ext_alloc_addr, num_xmit_extbuf * sizeof(struct xmit_frame) + 4);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* free xmit extension buff */
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf;
|
2014-12-11 21:15:04 +00:00
|
|
|
for(i=0; i<num_xmit_extbuf; i++)
|
|
|
|
{
|
|
|
|
rtw_os_xmit_resource_free(padapter, pxmitbuf,(max_xmit_extbuf_size + XMITBUF_ALIGN_SZ));
|
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* if(pxmitbuf->pallocated_buf) */
|
|
|
|
/* rtw_mfree(pxmitbuf->pallocated_buf, max_xmit_extbuf_size); */
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitbuf++;
|
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if(pxmitpriv->pallocated_xmit_extbuf) {
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_vmfree(pxmitpriv->pallocated_xmit_extbuf, num_xmit_extbuf * sizeof(struct xmit_buf) + 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
rtw_free_hwxmits(padapter);
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
_rtw_mutex_free(&pxmitpriv->ack_tx_mutex);
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
out:
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
static void update_attrib_vcs_info(struct adapter *padapter, struct xmit_frame *pxmitframe)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
u32 sz;
|
|
|
|
struct pkt_attrib *pattrib = &pxmitframe->attrib;
|
|
|
|
struct sta_info *psta = pattrib->psta;
|
|
|
|
struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
|
|
|
|
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if(pattrib->psta)
|
|
|
|
{
|
|
|
|
psta = pattrib->psta;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DBG_871X("%s, call rtw_get_stainfo()\n", __func__);
|
|
|
|
psta=rtw_get_stainfo(&padapter->stapriv ,&pattrib->ra[0] );
|
|
|
|
}
|
|
|
|
|
|
|
|
if(psta==NULL)
|
|
|
|
{
|
|
|
|
DBG_871X("%s, psta==NUL\n", __func__);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!(psta->state &_FW_LINKED))
|
|
|
|
{
|
|
|
|
DBG_871X("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, psta->state);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
if (pattrib->nr_frags != 1)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
sz = padapter->xmitpriv.frag_len;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2015-02-19 21:34:32 +00:00
|
|
|
else /* no frag */
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
sz = pattrib->last_txcmdsz;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* (1) RTS_Threshold is compared to the MPDU, not MSDU. */
|
|
|
|
/* (2) If there are more than one frag in this MSDU, only the first frag uses protection frame. */
|
|
|
|
/* Other fragments are protected by previous fragment. */
|
|
|
|
/* So we only need to check the length of first fragment. */
|
2014-12-11 21:15:04 +00:00
|
|
|
if(pmlmeext->cur_wireless_mode < WIRELESS_11_24N || padapter->registrypriv.wifi_spec)
|
|
|
|
{
|
|
|
|
if(sz > padapter->registrypriv.rts_thresh)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pattrib->vcs_mode = RTS_CTS;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(psta->rtsen)
|
2013-05-08 21:45:39 +00:00
|
|
|
pattrib->vcs_mode = RTS_CTS;
|
2014-12-11 21:15:04 +00:00
|
|
|
else if(psta->cts2self)
|
2013-05-08 21:45:39 +00:00
|
|
|
pattrib->vcs_mode = CTS_TO_SELF;
|
|
|
|
else
|
|
|
|
pattrib->vcs_mode = NONE_VCS;
|
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
while (true)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2015-02-19 21:34:32 +00:00
|
|
|
/* IOT action */
|
2014-12-29 02:13:24 +00:00
|
|
|
if((pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_ATHEROS) && (pattrib->ampdu_en==true) &&
|
2014-12-11 21:15:04 +00:00
|
|
|
(padapter->securitypriv.dot11PrivacyAlgrthm == _AES_ ))
|
|
|
|
{
|
|
|
|
pattrib->vcs_mode = CTS_TO_SELF;
|
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* check ERP protection */
|
2014-12-11 21:15:04 +00:00
|
|
|
if(psta->rtsen || psta->cts2self)
|
|
|
|
{
|
|
|
|
if(psta->rtsen)
|
2013-05-08 21:45:39 +00:00
|
|
|
pattrib->vcs_mode = RTS_CTS;
|
2014-12-11 21:15:04 +00:00
|
|
|
else if(psta->cts2self)
|
2013-05-08 21:45:39 +00:00
|
|
|
pattrib->vcs_mode = CTS_TO_SELF;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* check HT op mode */
|
2014-12-11 21:15:04 +00:00
|
|
|
if(pattrib->ht_en)
|
|
|
|
{
|
|
|
|
u8 HTOpMode = pmlmeinfo->HT_protection;
|
|
|
|
if((pmlmeext->cur_bwmode && (HTOpMode == 2 || HTOpMode == 3)) ||
|
|
|
|
(!pmlmeext->cur_bwmode && HTOpMode == 3) )
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pattrib->vcs_mode = RTS_CTS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* check rts */
|
2014-12-11 21:15:04 +00:00
|
|
|
if(sz > padapter->registrypriv.rts_thresh)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pattrib->vcs_mode = RTS_CTS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* to do list: check MIMO power save condition. */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* check AMPDU aggregation for TXOP */
|
2014-12-29 02:13:24 +00:00
|
|
|
if(pattrib->ampdu_en==true)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pattrib->vcs_mode = RTS_CTS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pattrib->vcs_mode = NONE_VCS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void update_attrib_phy_info(struct pkt_attrib *pattrib, struct sta_info *psta)
|
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
/*if(psta->rtsen)
|
|
|
|
pattrib->vcs_mode = RTS_CTS;
|
|
|
|
else if(psta->cts2self)
|
|
|
|
pattrib->vcs_mode = CTS_TO_SELF;
|
2013-05-08 21:45:39 +00:00
|
|
|
else
|
|
|
|
pattrib->vcs_mode = NONE_VCS;*/
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pattrib->mdata = 0;
|
|
|
|
pattrib->eosp = 0;
|
2014-12-11 21:15:04 +00:00
|
|
|
pattrib->triggered=0;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* qos_en, ht_en, init rate, ,bw, ch_offset, sgi */
|
2013-05-08 21:45:39 +00:00
|
|
|
pattrib->qos_en = psta->qos_option;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pattrib->raid = psta->raid;
|
|
|
|
pattrib->ht_en = psta->htpriv.ht_option;
|
|
|
|
pattrib->bwmode = psta->htpriv.bwmode;
|
|
|
|
pattrib->ch_offset = psta->htpriv.ch_offset;
|
2014-12-11 21:15:04 +00:00
|
|
|
pattrib->sgi= psta->htpriv.sgi;
|
2014-12-29 02:13:24 +00:00
|
|
|
pattrib->ampdu_en = false;
|
|
|
|
pattrib->retry_ctrl = false;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
u8 qos_acm(u8 acm_mask, u8 priority)
|
|
|
|
{
|
|
|
|
u8 change_priority = priority;
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
switch (priority)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
case 3:
|
|
|
|
if(acm_mask & BIT(1))
|
|
|
|
change_priority = 1;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
case 5:
|
|
|
|
if(acm_mask & BIT(2))
|
|
|
|
change_priority = 0;
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
case 7:
|
|
|
|
if(acm_mask & BIT(3))
|
|
|
|
change_priority = 5;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
DBG_871X("qos_acm(): invalid pattrib->priority: %d!!!\n", priority);
|
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return change_priority;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void set_qos(struct pkt_file *ppktfile, struct pkt_attrib *pattrib)
|
|
|
|
{
|
|
|
|
struct ethhdr etherhdr;
|
|
|
|
struct iphdr ip_hdr;
|
2014-12-11 21:15:04 +00:00
|
|
|
s32 UserPriority = 0;
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
_rtw_open_pktfile(ppktfile->pkt, ppktfile);
|
2014-12-11 21:15:04 +00:00
|
|
|
_rtw_pktfile_read(ppktfile, (unsigned char*)ðerhdr, ETH_HLEN);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* get UserPriority from IP hdr */
|
2013-05-08 21:45:39 +00:00
|
|
|
if (pattrib->ether_type == 0x0800) {
|
2014-12-11 21:15:04 +00:00
|
|
|
_rtw_pktfile_read(ppktfile, (u8*)&ip_hdr, sizeof(ip_hdr));
|
2015-02-19 21:34:32 +00:00
|
|
|
/* UserPriority = (ntohs(ip_hdr.tos) >> 5) & 0x3; */
|
2014-12-11 21:15:04 +00:00
|
|
|
UserPriority = ip_hdr.tos >> 5;
|
2013-05-08 21:45:39 +00:00
|
|
|
} else if (pattrib->ether_type == 0x888e) {
|
2015-02-19 21:34:32 +00:00
|
|
|
/* "When priority processing of data frames is supported, */
|
|
|
|
/* a STA's SME should send EAPOL-Key frames at the highest priority." */
|
2014-12-11 21:15:04 +00:00
|
|
|
UserPriority = 7;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
pattrib->priority = UserPriority;
|
2013-05-08 21:45:39 +00:00
|
|
|
pattrib->hdrlen = WLAN_HDR_A3_QOS_LEN;
|
|
|
|
pattrib->subtype = WIFI_QOS_DATA_TYPE;
|
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
static s32 update_attrib(struct adapter *padapter, _pkt *pkt, struct pkt_attrib *pattrib)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
uint i;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct pkt_file pktfile;
|
|
|
|
struct sta_info *psta = NULL;
|
|
|
|
struct ethhdr etherhdr;
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
sint bmcast;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct sta_priv *pstapriv = &padapter->stapriv;
|
|
|
|
struct security_priv *psecuritypriv = &padapter->securitypriv;
|
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2014-12-11 21:15:04 +00:00
|
|
|
struct qos_priv *pqospriv= &pmlmepriv->qospriv;
|
|
|
|
sint res = _SUCCESS;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
_rtw_open_pktfile(pkt, &pktfile);
|
2014-12-11 21:15:04 +00:00
|
|
|
i = _rtw_pktfile_read(&pktfile, (u8*)ðerhdr, ETH_HLEN);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pattrib->ether_type = ntohs(etherhdr.h_proto);
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(pattrib->dst, ðerhdr.h_dest, ETH_ALEN);
|
|
|
|
memcpy(pattrib->src, ðerhdr.h_source, ETH_ALEN);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pattrib->pctrl = 0;
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) ||
|
|
|
|
(check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) {
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(pattrib->ra, pattrib->dst, ETH_ALEN);
|
|
|
|
memcpy(pattrib->ta, pattrib->src, ETH_ALEN);
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(pattrib->ra, get_bssid(pmlmepriv), ETH_ALEN);
|
|
|
|
memcpy(pattrib->ta, pattrib->src, ETH_ALEN);
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(pattrib->ra, pattrib->dst, ETH_ALEN);
|
|
|
|
memcpy(pattrib->ta, get_bssid(pmlmepriv), ETH_ALEN);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pattrib->pktlen = pktfile.pkt_len;
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if (ETH_P_IP == pattrib->ether_type)
|
|
|
|
{
|
2015-02-19 21:34:32 +00:00
|
|
|
/* The following is for DHCP and ARP packet, we use cck1M to tx these packets and let LPS awake some time */
|
|
|
|
/* to prevent DHCP protocol fail */
|
2013-05-08 21:45:39 +00:00
|
|
|
u8 tmp[24];
|
|
|
|
_rtw_pktfile_read(&pktfile, &tmp[0], 24);
|
|
|
|
pattrib->dhcp_pkt = 0;
|
2015-02-19 21:34:32 +00:00
|
|
|
if (pktfile.pkt_len > 282) {/* MINIMUM_DHCP_PACKET_SIZE) { */
|
|
|
|
if (ETH_P_IP == pattrib->ether_type) {/* IP header */
|
2013-05-08 21:45:39 +00:00
|
|
|
if (((tmp[21] == 68) && (tmp[23] == 67)) ||
|
2014-12-11 21:15:04 +00:00
|
|
|
((tmp[21] == 67) && (tmp[23] == 68))) {
|
2015-02-19 21:34:32 +00:00
|
|
|
/* 68 : UDP BOOTP client */
|
|
|
|
/* 67 : UDP BOOTP server */
|
2014-12-11 21:15:04 +00:00
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_,_drv_err_,("======================update_attrib: get DHCP Packet \n"));
|
2015-02-19 21:34:32 +00:00
|
|
|
/* Use low rate to send DHCP packet. */
|
2013-05-08 21:45:39 +00:00
|
|
|
pattrib->dhcp_pkt = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (0x888e == pattrib->ether_type) {
|
2014-12-11 21:15:04 +00:00
|
|
|
DBG_871X_LEVEL(_drv_always_, "send eapol packet\n");
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if ( (pattrib->ether_type == 0x888e) || (pattrib->dhcp_pkt == 1) )
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_set_scan_deny(padapter, 3000);
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* If EAPOL , ARP , OR DHCP packet, driver must be in active mode. */
|
2014-12-11 21:15:04 +00:00
|
|
|
if ( (pattrib->ether_type == 0x0806) || (pattrib->ether_type == 0x888e) || (pattrib->dhcp_pkt == 1) )
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SPECIAL_PACKET, 1);
|
|
|
|
|
|
|
|
bmcast = IS_MCAST(pattrib->ra);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* get sta_info */
|
2013-05-08 21:45:39 +00:00
|
|
|
if (bmcast) {
|
|
|
|
psta = rtw_get_bcmc_stainfo(padapter);
|
|
|
|
} else {
|
|
|
|
psta = rtw_get_stainfo(pstapriv, pattrib->ra);
|
2015-02-19 21:34:32 +00:00
|
|
|
if (psta == NULL) { /* if we cannot get psta => drrp the pkt */
|
2014-12-11 21:15:04 +00:00
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_, _drv_alert_, ("\nupdate_attrib => get sta_info fail, ra:" MAC_FMT"\n", MAC_ARG(pattrib->ra)));
|
|
|
|
#ifdef DBG_TX_DROP_FRAME
|
|
|
|
DBG_871X("DBG_TX_DROP_FRAME %s get sta_info fail, ra:" MAC_FMT"\n", __FUNCTION__, MAC_ARG(pattrib->ra));
|
|
|
|
#endif
|
|
|
|
res =_FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2014-12-29 02:13:24 +00:00
|
|
|
else if((check_fwstate(pmlmepriv, WIFI_AP_STATE)==true)&&(!(psta->state & _FW_LINKED)))
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
res =_FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if (psta)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pattrib->mac_id = psta->mac_id;
|
2015-02-19 21:34:32 +00:00
|
|
|
/* DBG_8192C("%s ==> mac_id(%d)\n",__FUNCTION__,pattrib->mac_id ); */
|
2013-05-08 21:45:39 +00:00
|
|
|
pattrib->psta = psta;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-02-19 21:34:32 +00:00
|
|
|
/* if we cannot get psta => drop the pkt */
|
2014-12-11 21:15:04 +00:00
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_, _drv_alert_, ("\nupdate_attrib => get sta_info fail, ra:" MAC_FMT "\n", MAC_ARG(pattrib->ra)));
|
|
|
|
#ifdef DBG_TX_DROP_FRAME
|
|
|
|
DBG_871X("DBG_TX_DROP_FRAME %s get sta_info fail, ra:" MAC_FMT"\n", __FUNCTION__, MAC_ARG(pattrib->ra));
|
|
|
|
#endif
|
2013-05-08 21:45:39 +00:00
|
|
|
res = _FAIL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
pattrib->ack_policy = 0;
|
2015-02-19 21:34:32 +00:00
|
|
|
/* get ether_hdr_len */
|
|
|
|
pattrib->pkt_hdrlen = ETH_HLEN;/* pattrib->ether_type == 0x8100) ? (14 + 4 ): 14; vlan tag */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pattrib->hdrlen = WLAN_HDR_A3_LEN;
|
2014-12-19 06:59:46 +00:00
|
|
|
pattrib->subtype = WIFI_DATA_TYPE;
|
2013-05-08 21:45:39 +00:00
|
|
|
pattrib->priority = 0;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if (check_fwstate(pmlmepriv, WIFI_AP_STATE|WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE))
|
|
|
|
{
|
|
|
|
if(psta->qos_option)
|
2013-05-08 21:45:39 +00:00
|
|
|
set_qos(&pktfile, pattrib);
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(pqospriv->qos_option)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
set_qos(&pktfile, pattrib);
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if(pmlmepriv->acm_mask != 0)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pattrib->priority = qos_acm(pmlmepriv->acm_mask, pattrib->priority);
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
2015-02-19 21:34:32 +00:00
|
|
|
if (psta->ieee8021x_blocked == true) {
|
2014-12-29 02:13:24 +00:00
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_,_drv_err_,("\n psta->ieee8021x_blocked == true \n"));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pattrib->encrypt = 0;
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if((pattrib->ether_type != 0x888e) && (check_fwstate(pmlmepriv, WIFI_MP_STATE) == false))
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_,_drv_err_,("\npsta->ieee8021x_blocked == true, pattrib->ether_type(%.4x) != 0x888e\n",pattrib->ether_type));
|
2014-12-11 21:15:04 +00:00
|
|
|
#ifdef DBG_TX_DROP_FRAME
|
2014-12-29 02:13:24 +00:00
|
|
|
DBG_871X("DBG_TX_DROP_FRAME %s psta->ieee8021x_blocked == true, pattrib->ether_type(%04x) != 0x888e\n", __FUNCTION__,pattrib->ether_type);
|
2014-12-11 21:15:04 +00:00
|
|
|
#endif
|
2013-05-08 21:45:39 +00:00
|
|
|
res = _FAIL;
|
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
GET_ENCRY_ALGO(psecuritypriv, psta, pattrib->encrypt, bmcast);
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
switch(psecuritypriv->dot11AuthAlgrthm)
|
|
|
|
{
|
|
|
|
case dot11AuthAlgrthm_Open:
|
|
|
|
case dot11AuthAlgrthm_Shared:
|
2014-12-19 06:59:46 +00:00
|
|
|
case dot11AuthAlgrthm_Auto:
|
2014-12-11 21:15:04 +00:00
|
|
|
pattrib->key_idx = (u8)psecuritypriv->dot11PrivacyKeyIndex;
|
|
|
|
break;
|
|
|
|
case dot11AuthAlgrthm_8021X:
|
2014-12-19 06:59:46 +00:00
|
|
|
if(bmcast)
|
|
|
|
pattrib->key_idx = (u8)psecuritypriv->dot118021XGrpKeyid;
|
2014-12-11 21:15:04 +00:00
|
|
|
else
|
|
|
|
pattrib->key_idx = 0;
|
|
|
|
break;
|
|
|
|
default:
|
2013-08-03 03:16:03 +00:00
|
|
|
pattrib->key_idx = 0;
|
2014-12-11 21:15:04 +00:00
|
|
|
break;
|
2013-08-03 03:16:03 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
switch (pattrib->encrypt)
|
|
|
|
{
|
|
|
|
case _WEP40_:
|
|
|
|
case _WEP104_:
|
|
|
|
pattrib->iv_len = 4;
|
|
|
|
pattrib->icv_len = 4;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case _TKIP_:
|
|
|
|
pattrib->iv_len = 8;
|
|
|
|
pattrib->icv_len = 4;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if(padapter->securitypriv.busetkipkey==_FAIL)
|
|
|
|
{
|
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_,_drv_err_,("\npadapter->securitypriv.busetkipkey(%d)==_FAIL drop packet\n", padapter->securitypriv.busetkipkey));
|
|
|
|
#ifdef DBG_TX_DROP_FRAME
|
|
|
|
DBG_871X("DBG_TX_DROP_FRAME %s padapter->securitypriv.busetkipkey(%d)==_FAIL drop packet\n", __FUNCTION__, padapter->securitypriv.busetkipkey);
|
|
|
|
#endif
|
|
|
|
res =_FAIL;
|
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
break;
|
2014-12-11 21:15:04 +00:00
|
|
|
case _AES_:
|
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_,_drv_info_,("pattrib->encrypt=%d (_AES_)\n",pattrib->encrypt));
|
|
|
|
pattrib->iv_len = 8;
|
|
|
|
pattrib->icv_len = 8;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
pattrib->iv_len = 0;
|
|
|
|
pattrib->icv_len = 0;
|
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_,
|
|
|
|
("update_attrib: encrypt=%d securitypriv.sw_encrypt=%d\n",
|
|
|
|
pattrib->encrypt, padapter->securitypriv.sw_encrypt));
|
|
|
|
|
|
|
|
if (pattrib->encrypt &&
|
2014-12-29 02:13:24 +00:00
|
|
|
((padapter->securitypriv.sw_encrypt == true) || (psecuritypriv->hw_decrypted == false)))
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
pattrib->bswenc = true;
|
2014-12-11 21:15:04 +00:00
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_,_drv_err_,
|
2014-12-29 02:13:24 +00:00
|
|
|
("update_attrib: encrypt=%d securitypriv.hw_decrypted=%d bswenc=true\n",
|
2013-05-08 21:45:39 +00:00
|
|
|
pattrib->encrypt, padapter->securitypriv.sw_encrypt));
|
|
|
|
} else {
|
2014-12-29 02:13:24 +00:00
|
|
|
pattrib->bswenc = false;
|
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_,_drv_info_,("update_attrib: bswenc=false\n"));
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
rtw_set_tx_chksum_offload(pkt, pattrib);
|
|
|
|
|
|
|
|
update_attrib_phy_info(pattrib, psta);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitframe){
|
2014-12-19 06:59:46 +00:00
|
|
|
sint curfragnum,length;
|
2014-12-11 21:15:04 +00:00
|
|
|
u8 *pframe, *payload,mic[8];
|
|
|
|
struct mic_data micdata;
|
|
|
|
struct sta_info *stainfo;
|
2014-12-19 06:59:46 +00:00
|
|
|
struct qos_priv *pqospriv= &(padapter->mlmepriv.qospriv);
|
2014-12-11 21:15:04 +00:00
|
|
|
struct pkt_attrib *pattrib = &pxmitframe->attrib;
|
2014-12-19 06:59:46 +00:00
|
|
|
struct security_priv *psecuritypriv=&padapter->securitypriv;
|
2014-12-11 21:15:04 +00:00
|
|
|
struct xmit_priv *pxmitpriv=&padapter->xmitpriv;
|
|
|
|
u8 priority[4]={0x0,0x0,0x0,0x0};
|
2013-05-08 21:45:39 +00:00
|
|
|
u8 hw_hdr_offset = 0;
|
2014-12-11 21:15:04 +00:00
|
|
|
sint bmcst = IS_MCAST(pattrib->ra);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if(pattrib->psta)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
stainfo = pattrib->psta;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
else
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
DBG_871X("%s, call rtw_get_stainfo()\n", __func__);
|
|
|
|
stainfo=rtw_get_stainfo(&padapter->stapriv ,&pattrib->ra[0]);
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if(stainfo==NULL)
|
|
|
|
{
|
|
|
|
DBG_871X("%s, psta==NUL\n", __func__);
|
|
|
|
return _FAIL;
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if(!(stainfo->state &_FW_LINKED))
|
|
|
|
{
|
|
|
|
DBG_871X("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, stainfo->state);
|
|
|
|
return _FAIL;
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
hw_hdr_offset = TXDESC_SIZE + (pxmitframe->pkt_offset * PACKET_OFFSET_SZ);;
|
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
if(pattrib->encrypt ==_TKIP_)/* if(psecuritypriv->dot11PrivacyAlgrthm==_TKIP_PRIVACY_) */
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2015-02-19 21:34:32 +00:00
|
|
|
/* encode mic code */
|
2014-12-11 21:15:04 +00:00
|
|
|
if(stainfo!= NULL){
|
|
|
|
u8 null_key[16]={0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0};
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
pframe = pxmitframe->buf_addr + hw_hdr_offset;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if(bmcst)
|
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
if(_rtw_memcmp(psecuritypriv->dot118021XGrptxmickey[psecuritypriv->dot118021XGrpKeyid].skey, null_key, 16)==true){
|
2015-02-19 21:34:32 +00:00
|
|
|
/* DbgPrint("\nxmitframe_addmic:stainfo->dot11tkiptxmickey==0\n"); */
|
|
|
|
/* rtw_msleep_os(10); */
|
2013-05-08 21:45:39 +00:00
|
|
|
return _FAIL;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2015-02-19 21:34:32 +00:00
|
|
|
/* start to calculate the mic code */
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_secmicsetkey(&micdata, psecuritypriv->dot118021XGrptxmickey[psecuritypriv->dot118021XGrpKeyid].skey);
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
if(_rtw_memcmp(&stainfo->dot11tkiptxmickey.skey[0],null_key, 16)==true){
|
2015-02-19 21:34:32 +00:00
|
|
|
/* DbgPrint("\nxmitframe_addmic:stainfo->dot11tkiptxmickey==0\n"); */
|
|
|
|
/* rtw_msleep_os(10); */
|
2013-05-08 21:45:39 +00:00
|
|
|
return _FAIL;
|
|
|
|
}
|
2015-02-19 21:34:32 +00:00
|
|
|
/* start to calculate the mic code */
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_secmicsetkey(&micdata, &stainfo->dot11tkiptxmickey.skey[0]);
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
if(pframe[1]&1){ /* ToDS==1 */
|
|
|
|
rtw_secmicappend(&micdata, &pframe[16], 6); /* DA */
|
|
|
|
if(pframe[1]&2) /* From Ds==1 */
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_secmicappend(&micdata, &pframe[24], 6);
|
|
|
|
else
|
2014-12-19 06:59:46 +00:00
|
|
|
rtw_secmicappend(&micdata, &pframe[10], 6);
|
|
|
|
}
|
2015-02-19 21:34:32 +00:00
|
|
|
else{ /* ToDS==0 */
|
|
|
|
rtw_secmicappend(&micdata, &pframe[4], 6); /* DA */
|
|
|
|
if(pframe[1]&2) /* From Ds==1 */
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_secmicappend(&micdata, &pframe[16], 6);
|
|
|
|
else
|
|
|
|
rtw_secmicappend(&micdata, &pframe[10], 6);
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* if(pqospriv->qos_option==1) */
|
2014-12-11 21:15:04 +00:00
|
|
|
if(pattrib->qos_en)
|
|
|
|
priority[0]=(u8)pxmitframe->attrib.priority;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_secmicappend(&micdata, &priority[0], 4);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
payload=pframe;
|
|
|
|
|
|
|
|
for(curfragnum=0;curfragnum<pattrib->nr_frags;curfragnum++){
|
|
|
|
payload=(u8 *)RND4((SIZE_PTR)(payload));
|
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_,_drv_err_,("===curfragnum=%d, pframe= 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x,!!!\n",
|
|
|
|
curfragnum,*payload, *(payload+1),*(payload+2),*(payload+3),*(payload+4),*(payload+5),*(payload+6),*(payload+7)));
|
|
|
|
|
|
|
|
payload=payload+pattrib->hdrlen+pattrib->iv_len;
|
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_,_drv_err_,("curfragnum=%d pattrib->hdrlen=%d pattrib->iv_len=%d",curfragnum,pattrib->hdrlen,pattrib->iv_len));
|
|
|
|
if((curfragnum+1)==pattrib->nr_frags){
|
|
|
|
length=pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-( (pattrib->bswenc) ? pattrib->icv_len : 0);
|
|
|
|
rtw_secmicappend(&micdata, payload,length);
|
|
|
|
payload=payload+length;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
length=pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-( (pattrib->bswenc) ? pattrib->icv_len : 0);
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_secmicappend(&micdata, payload, length);
|
2014-12-11 21:15:04 +00:00
|
|
|
payload=payload+length+pattrib->icv_len;
|
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_,_drv_err_,("curfragnum=%d length=%d pattrib->icv_len=%d",curfragnum,length,pattrib->icv_len));
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
rtw_secgetmic(&micdata,&(mic[0]));
|
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_,_drv_err_,("xmitframe_addmic: before add mic code!!!\n"));
|
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_,_drv_err_,("xmitframe_addmic: pattrib->last_txcmdsz=%d!!!\n",pattrib->last_txcmdsz));
|
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_,_drv_err_,("xmitframe_addmic: mic[0]=0x%.2x ,mic[1]=0x%.2x ,mic[2]=0x%.2x ,mic[3]=0x%.2x \n\
|
|
|
|
mic[4]=0x%.2x ,mic[5]=0x%.2x ,mic[6]=0x%.2x ,mic[7]=0x%.2x !!!!\n",
|
|
|
|
mic[0],mic[1],mic[2],mic[3],mic[4],mic[5],mic[6],mic[7]));
|
2015-02-19 21:34:32 +00:00
|
|
|
/* add mic code and add the mic code length in last_txcmdsz */
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(payload, &(mic[0]),8);
|
2014-12-11 21:15:04 +00:00
|
|
|
pattrib->last_txcmdsz+=8;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_,_drv_info_,("\n ========last pkt========\n"));
|
|
|
|
payload=payload-pattrib->last_txcmdsz+8;
|
|
|
|
for(curfragnum=0;curfragnum<pattrib->last_txcmdsz;curfragnum=curfragnum+8)
|
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_,_drv_info_,(" %.2x, %.2x, %.2x, %.2x, %.2x, %.2x, %.2x, %.2x ",
|
|
|
|
*(payload+curfragnum), *(payload+curfragnum+1), *(payload+curfragnum+2),*(payload+curfragnum+3),
|
|
|
|
*(payload+curfragnum+4),*(payload+curfragnum+5),*(payload+curfragnum+6),*(payload+curfragnum+7)));
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_,_drv_err_,("xmitframe_addmic: rtw_get_stainfo==NULL!!!\n"));
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return _SUCCESS;
|
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
static s32 xmitframe_swencrypt(struct adapter *padapter, struct xmit_frame *pxmitframe){
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
struct pkt_attrib *pattrib = &pxmitframe->attrib;
|
2015-02-19 21:34:32 +00:00
|
|
|
/* struct security_priv *psecuritypriv=&padapter->securitypriv; */
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* if((psecuritypriv->sw_encrypt)||(pattrib->bswenc)) */
|
2014-12-11 21:15:04 +00:00
|
|
|
if(pattrib->bswenc)
|
|
|
|
{
|
2015-02-19 21:34:32 +00:00
|
|
|
/* DBG_871X("start xmitframe_swencrypt\n"); */
|
2014-12-11 21:15:04 +00:00
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_,_drv_alert_,("### xmitframe_swencrypt\n"));
|
|
|
|
switch(pattrib->encrypt){
|
2013-05-08 21:45:39 +00:00
|
|
|
case _WEP40_:
|
|
|
|
case _WEP104_:
|
|
|
|
rtw_wep_encrypt(padapter, (u8 *)pxmitframe);
|
|
|
|
break;
|
|
|
|
case _TKIP_:
|
|
|
|
rtw_tkip_encrypt(padapter, (u8 *)pxmitframe);
|
|
|
|
break;
|
|
|
|
case _AES_:
|
2014-12-11 21:15:04 +00:00
|
|
|
rtw_aes_encrypt(padapter, (u8 * )pxmitframe);
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
|
|
|
default:
|
2014-12-11 21:15:04 +00:00
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
} else {
|
2014-12-11 21:15:04 +00:00
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_,_drv_notice_,("### xmitframe_hwencrypt\n"));
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return _SUCCESS;
|
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
s32 rtw_make_wlanhdr (struct adapter *padapter , u8 *hdr, struct pkt_attrib *pattrib)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
u16 *qc;
|
|
|
|
|
|
|
|
struct rtw_ieee80211_hdr *pwlanhdr = (struct rtw_ieee80211_hdr *)hdr;
|
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
|
|
|
struct qos_priv *pqospriv = &pmlmepriv->qospriv;
|
2014-12-29 02:13:24 +00:00
|
|
|
u8 qos_option = false;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
sint res = _SUCCESS;
|
2015-01-28 05:14:58 +00:00
|
|
|
__le16 *fctrl = &pwlanhdr->frame_ctl;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
struct sta_info *psta;
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
sint bmcst = IS_MCAST(pattrib->ra);
|
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
if (pattrib->psta) {
|
|
|
|
psta = pattrib->psta;
|
|
|
|
} else {
|
2014-12-11 21:15:04 +00:00
|
|
|
DBG_871X("%s, call rtw_get_stainfo()\n", __func__);
|
|
|
|
if(bmcst) {
|
2013-05-08 21:45:39 +00:00
|
|
|
psta = rtw_get_bcmc_stainfo(padapter);
|
|
|
|
} else {
|
|
|
|
psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if(psta==NULL)
|
|
|
|
{
|
|
|
|
DBG_871X("%s, psta==NUL\n", __func__);
|
|
|
|
return _FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!(psta->state &_FW_LINKED))
|
|
|
|
{
|
|
|
|
DBG_871X("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, psta->state);
|
|
|
|
return _FAIL;
|
|
|
|
}
|
|
|
|
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(hdr, 0, WLANHDR_OFFSET);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
SetFrameSubType(fctrl, pattrib->subtype);
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if (pattrib->subtype & WIFI_DATA_TYPE)
|
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true)) {
|
2015-02-19 21:34:32 +00:00
|
|
|
/* to_ds = 1, fr_ds = 0; */
|
2015-03-04 21:31:57 +00:00
|
|
|
/* Data transfer to AP */
|
|
|
|
SetToDs(fctrl);
|
|
|
|
memcpy(pwlanhdr->addr1, get_bssid(pmlmepriv), ETH_ALEN);
|
|
|
|
memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN);
|
|
|
|
memcpy(pwlanhdr->addr3, pattrib->dst, ETH_ALEN);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
if (pqospriv->qos_option)
|
2014-12-29 02:13:24 +00:00
|
|
|
qos_option = true;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
}
|
2014-12-29 02:13:24 +00:00
|
|
|
else if ((check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) ) {
|
2015-02-19 21:34:32 +00:00
|
|
|
/* to_ds = 0, fr_ds = 1; */
|
2013-05-08 21:45:39 +00:00
|
|
|
SetFrDs(fctrl);
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN);
|
|
|
|
memcpy(pwlanhdr->addr2, get_bssid(pmlmepriv), ETH_ALEN);
|
|
|
|
memcpy(pwlanhdr->addr3, pattrib->src, ETH_ALEN);
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
if(psta->qos_option)
|
2014-12-29 02:13:24 +00:00
|
|
|
qos_option = true;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2014-12-29 02:13:24 +00:00
|
|
|
else if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) ||
|
|
|
|
(check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) {
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN);
|
|
|
|
memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN);
|
|
|
|
memcpy(pwlanhdr->addr3, get_bssid(pmlmepriv), ETH_ALEN);
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
if(psta->qos_option)
|
2014-12-29 02:13:24 +00:00
|
|
|
qos_option = true;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_,_drv_err_,("fw_state:%x is not allowed to xmit frame\n", get_fwstate(pmlmepriv)));
|
2013-05-08 21:45:39 +00:00
|
|
|
res = _FAIL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if(pattrib->mdata)
|
2013-05-08 21:45:39 +00:00
|
|
|
SetMData(fctrl);
|
|
|
|
|
|
|
|
if (pattrib->encrypt)
|
|
|
|
SetPrivacy(fctrl);
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if (qos_option)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
qc = (unsigned short *)(hdr + pattrib->hdrlen - 2);
|
|
|
|
|
|
|
|
if (pattrib->priority)
|
|
|
|
SetPriority(qc, pattrib->priority);
|
|
|
|
|
|
|
|
SetEOSP(qc, pattrib->eosp);
|
|
|
|
|
|
|
|
SetAckpolicy(qc, pattrib->ack_policy);
|
|
|
|
}
|
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* TODO: fill HT Control Field */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* Update Seq Num will be handled by f/w */
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
if(psta){
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
psta->sta_xmitpriv.txseq_tid[pattrib->priority]++;
|
|
|
|
psta->sta_xmitpriv.txseq_tid[pattrib->priority] &= 0xFFF;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
pattrib->seqnum = psta->sta_xmitpriv.txseq_tid[pattrib->priority];
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
SetSeqNum(hdr, pattrib->seqnum);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* check if enable ampdu */
|
2014-12-11 21:15:04 +00:00
|
|
|
if(pattrib->ht_en && psta->htpriv.ampdu_enable)
|
|
|
|
{
|
|
|
|
if(psta->htpriv.agg_enable_bitmap & BIT(pattrib->priority))
|
2014-12-29 02:13:24 +00:00
|
|
|
pattrib->ampdu_en = true;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-08-03 03:16:03 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* re-check if enable ampdu by BA_starting_seqctrl */
|
2014-12-29 02:13:24 +00:00
|
|
|
if(pattrib->ampdu_en == true)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
u16 tx_seq;
|
|
|
|
|
|
|
|
tx_seq = psta->BA_starting_seqctrl[pattrib->priority & 0x0f];
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* check BA_starting_seqctrl */
|
2014-12-11 21:15:04 +00:00
|
|
|
if(SN_LESS(pattrib->seqnum, tx_seq))
|
|
|
|
{
|
2015-02-19 21:34:32 +00:00
|
|
|
/* DBG_871X("tx ampdu seqnum(%d) < tx_seq(%d)\n", pattrib->seqnum, tx_seq); */
|
|
|
|
pattrib->ampdu_en = false;/* AGG BK */
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
else if(SN_EQUAL(pattrib->seqnum, tx_seq))
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (tx_seq+1)&0xfff;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
pattrib->ampdu_en = true;/* AGG EN */
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-02-19 21:34:32 +00:00
|
|
|
/* DBG_871X("tx ampdu over run\n"); */
|
2014-12-11 21:15:04 +00:00
|
|
|
psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (pattrib->seqnum+1)&0xfff;
|
2015-02-19 21:34:32 +00:00
|
|
|
pattrib->ampdu_en = true;/* AGG EN */
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-08-03 03:16:03 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
exit:
|
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
s32 rtw_txframes_pending(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
return ((_rtw_queue_empty(&pxmitpriv->be_pending) == false) ||
|
|
|
|
(_rtw_queue_empty(&pxmitpriv->bk_pending) == false) ||
|
|
|
|
(_rtw_queue_empty(&pxmitpriv->vi_pending) == false) ||
|
|
|
|
(_rtw_queue_empty(&pxmitpriv->vo_pending) == false));
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
s32 rtw_txframes_sta_ac_pending(struct adapter *padapter, struct pkt_attrib *pattrib)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
struct sta_info *psta;
|
|
|
|
struct tx_servq *ptxservq;
|
|
|
|
int priority = pattrib->priority;
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if(pattrib->psta)
|
|
|
|
{
|
|
|
|
psta = pattrib->psta;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DBG_871X("%s, call rtw_get_stainfo()\n", __func__);
|
|
|
|
psta=rtw_get_stainfo(&padapter->stapriv ,&pattrib->ra[0]);
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
if(psta==NULL)
|
|
|
|
{
|
|
|
|
DBG_871X("%s, psta==NUL\n", __func__);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!(psta->state &_FW_LINKED))
|
|
|
|
{
|
|
|
|
DBG_871X("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, psta->state);
|
|
|
|
return 0;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
switch(priority)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
case 2:
|
2014-12-19 06:59:46 +00:00
|
|
|
ptxservq = &(psta->sta_xmitpriv.bk_q);
|
2014-12-11 21:15:04 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
case 5:
|
2014-12-19 06:59:46 +00:00
|
|
|
ptxservq = &(psta->sta_xmitpriv.vi_q);
|
2014-12-11 21:15:04 +00:00
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
case 7:
|
2014-12-19 06:59:46 +00:00
|
|
|
ptxservq = &(psta->sta_xmitpriv.vo_q);
|
2014-12-11 21:15:04 +00:00
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
case 3:
|
|
|
|
default:
|
2014-12-19 06:59:46 +00:00
|
|
|
ptxservq = &(psta->sta_xmitpriv.be_q);
|
2014-12-11 21:15:04 +00:00
|
|
|
break;
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ptxservq->qcnt;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
/*
|
|
|
|
* Calculate wlan 802.11 packet MAX size from pkt_attrib
|
|
|
|
* This function doesn't consider fragment case
|
|
|
|
*/
|
|
|
|
u32 rtw_calculate_wlan_pkt_size_by_attribue(struct pkt_attrib *pattrib)
|
|
|
|
{
|
|
|
|
u32 len = 0;
|
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
len = pattrib->hdrlen + pattrib->iv_len; /* WLAN Header and IV */
|
|
|
|
len += SNAP_SIZE + sizeof(u16); /* LLC */
|
2013-05-08 21:45:39 +00:00
|
|
|
len += pattrib->pktlen;
|
2015-02-19 21:34:32 +00:00
|
|
|
if (pattrib->encrypt == _TKIP_) len += 8; /* MIC */
|
|
|
|
len += ((pattrib->bswenc) ? pattrib->icv_len : 0); /* ICV */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
This sub-routine will perform all the following:
|
|
|
|
|
|
|
|
1. remove 802.3 header.
|
|
|
|
2. create wlan_header, based on the info in pxmitframe
|
|
|
|
3. append sta's iv/ext-iv
|
|
|
|
4. append LLC
|
|
|
|
5. move frag chunk from pframe to pxmitframe->mem
|
2014-12-19 06:59:46 +00:00
|
|
|
6. apply sw-encrypt, if necessary.
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
*/
|
2014-12-17 23:13:53 +00:00
|
|
|
s32 rtw_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit_frame *pxmitframe)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct pkt_file pktfile;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
s32 frg_inx, frg_len, mpdu_len, llc_sz, mem_sz;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
SIZE_PTR addr;
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
u8 *pframe, *mem_start;
|
|
|
|
u8 hw_hdr_offset;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
struct sta_info *psta;
|
2015-02-19 21:34:32 +00:00
|
|
|
/* struct sta_priv *pstapriv = &padapter->stapriv; */
|
|
|
|
/* struct mlme_priv *pmlmepriv = &padapter->mlmepriv; */
|
2013-05-08 21:45:39 +00:00
|
|
|
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
struct pkt_attrib *pattrib = &pxmitframe->attrib;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
u8 *pbuf_start;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
s32 bmcst = IS_MCAST(pattrib->ra);
|
|
|
|
s32 res = _SUCCESS;
|
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if (pattrib->psta)
|
|
|
|
{
|
|
|
|
psta = pattrib->psta;
|
|
|
|
} else
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
DBG_871X("%s, call rtw_get_stainfo()\n", __func__);
|
|
|
|
psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(psta==NULL)
|
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
DBG_871X("%s, psta==NUL\n", __func__);
|
2013-05-08 21:45:39 +00:00
|
|
|
return _FAIL;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if(!(psta->state &_FW_LINKED))
|
|
|
|
{
|
|
|
|
DBG_871X("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, psta->state);
|
2013-05-08 21:45:39 +00:00
|
|
|
return _FAIL;
|
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if (pxmitframe->buf_addr == NULL){
|
|
|
|
DBG_8192C("==> %s buf_addr==NULL \n",__FUNCTION__);
|
|
|
|
return _FAIL;
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
pbuf_start = pxmitframe->buf_addr;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
hw_hdr_offset = TXDESC_SIZE + (pxmitframe->pkt_offset * PACKET_OFFSET_SZ);
|
|
|
|
|
|
|
|
mem_start = pbuf_start + hw_hdr_offset;
|
|
|
|
|
|
|
|
if (rtw_make_wlanhdr(padapter, mem_start, pattrib) == _FAIL) {
|
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("rtw_xmitframe_coalesce: rtw_make_wlanhdr fail; drop pkt\n"));
|
2014-12-11 21:15:04 +00:00
|
|
|
DBG_8192C("rtw_xmitframe_coalesce: rtw_make_wlanhdr fail; drop pkt\n");
|
2013-05-08 21:45:39 +00:00
|
|
|
res = _FAIL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
_rtw_open_pktfile(pkt, &pktfile);
|
|
|
|
_rtw_pktfile_read(&pktfile, NULL, pattrib->pkt_hdrlen);
|
|
|
|
|
|
|
|
frg_inx = 0;
|
2015-02-19 21:34:32 +00:00
|
|
|
frg_len = pxmitpriv->frag_len - 4;/* 2346-4 = 2342 */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
while (1)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
llc_sz = 0;
|
|
|
|
|
|
|
|
mpdu_len = frg_len;
|
|
|
|
|
|
|
|
pframe = mem_start;
|
|
|
|
|
|
|
|
SetMFrag(mem_start);
|
|
|
|
|
|
|
|
pframe += pattrib->hdrlen;
|
|
|
|
mpdu_len -= pattrib->hdrlen;
|
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* adding icv, if necessary... */
|
2014-12-11 21:15:04 +00:00
|
|
|
if (pattrib->iv_len)
|
|
|
|
{
|
2015-02-19 21:34:32 +00:00
|
|
|
/* if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) */
|
|
|
|
/* psta = rtw_get_stainfo(pstapriv, get_bssid(pmlmepriv)); */
|
|
|
|
/* else */
|
|
|
|
/* psta = rtw_get_stainfo(pstapriv, pattrib->ra); */
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
if (psta != NULL)
|
|
|
|
{
|
|
|
|
switch(pattrib->encrypt)
|
|
|
|
{
|
|
|
|
case _WEP40_:
|
|
|
|
case _WEP104_:
|
2014-12-19 06:59:46 +00:00
|
|
|
WEP_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx);
|
2014-12-11 21:15:04 +00:00
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
case _TKIP_:
|
2014-12-11 21:15:04 +00:00
|
|
|
if(bmcst)
|
|
|
|
TKIP_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx);
|
|
|
|
else
|
|
|
|
TKIP_IV(pattrib->iv, psta->dot11txpn, 0);
|
2014-12-19 06:59:46 +00:00
|
|
|
break;
|
2014-12-11 21:15:04 +00:00
|
|
|
case _AES_:
|
|
|
|
if(bmcst)
|
|
|
|
AES_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx);
|
|
|
|
else
|
|
|
|
AES_IV(pattrib->iv, psta->dot11txpn, 0);
|
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(pframe, pattrib->iv, pattrib->iv_len);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_, _drv_notice_,
|
|
|
|
("rtw_xmitframe_coalesce: keyid=%d pattrib->iv[3]=%.2x pframe=%.2x %.2x %.2x %.2x\n",
|
|
|
|
padapter->securitypriv.dot11PrivacyKeyIndex, pattrib->iv[3], *pframe, *(pframe+1), *(pframe+2), *(pframe+3)));
|
|
|
|
|
|
|
|
pframe += pattrib->iv_len;
|
|
|
|
|
|
|
|
mpdu_len -= pattrib->iv_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (frg_inx == 0) {
|
|
|
|
llc_sz = rtw_put_snap(pframe, pattrib->ether_type);
|
|
|
|
pframe += llc_sz;
|
|
|
|
mpdu_len -= llc_sz;
|
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if ((pattrib->icv_len >0) && (pattrib->bswenc)) {
|
2013-05-08 21:45:39 +00:00
|
|
|
mpdu_len -= pattrib->icv_len;
|
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
if (bmcst) {
|
2015-02-19 21:34:32 +00:00
|
|
|
/* don't do fragment to broadcat/multicast packets */
|
2013-05-08 21:45:39 +00:00
|
|
|
mem_sz = _rtw_pktfile_read(&pktfile, pframe, pattrib->pktlen);
|
|
|
|
} else {
|
|
|
|
mem_sz = _rtw_pktfile_read(&pktfile, pframe, mpdu_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
pframe += mem_sz;
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if ((pattrib->icv_len >0 )&& (pattrib->bswenc)) {
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(pframe, pattrib->icv, pattrib->icv_len);
|
2013-05-08 21:45:39 +00:00
|
|
|
pframe += pattrib->icv_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
frg_inx++;
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if (bmcst || (rtw_endofpktfile(&pktfile) == true))
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pattrib->nr_frags = frg_inx;
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
pattrib->last_txcmdsz = pattrib->hdrlen + pattrib->iv_len + ((pattrib->nr_frags==1)? llc_sz:0) +
|
2014-12-11 21:15:04 +00:00
|
|
|
((pattrib->bswenc) ? pattrib->icv_len : 0) + mem_sz;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
ClearMFrag(mem_start);
|
|
|
|
|
|
|
|
break;
|
|
|
|
} else {
|
2014-12-11 21:15:04 +00:00
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("%s: There're still something in packet!\n", __FUNCTION__));
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
addr = (SIZE_PTR)(pframe);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
mem_start = (unsigned char *)RND4(addr) + hw_hdr_offset;
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(mem_start, pbuf_start + hw_hdr_offset, pattrib->hdrlen);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if (xmitframe_addmic(padapter, pxmitframe) == _FAIL)
|
|
|
|
{
|
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic(padapter, pxmitframe)==_FAIL\n"));
|
|
|
|
DBG_8192C("xmitframe_addmic(padapter, pxmitframe)==_FAIL\n");
|
2013-05-08 21:45:39 +00:00
|
|
|
res = _FAIL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
xmitframe_swencrypt(padapter, pxmitframe);
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if(bmcst == false)
|
2013-05-08 21:45:39 +00:00
|
|
|
update_attrib_vcs_info(padapter, pxmitframe);
|
|
|
|
else
|
|
|
|
pattrib->vcs_mode = NONE_VCS;
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
exit:
|
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
#ifdef CONFIG_IEEE80211W
|
2015-02-19 21:34:32 +00:00
|
|
|
/* broadcast or multicast management pkt use BIP, unicast management pkt use CCMP encryption */
|
2014-12-17 23:13:53 +00:00
|
|
|
s32 rtw_mgmt_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit_frame *pxmitframe)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
struct pkt_file pktfile;
|
|
|
|
s32 frg_inx, frg_len, mpdu_len, llc_sz, mem_sz;
|
|
|
|
SIZE_PTR addr;
|
|
|
|
u8 *pframe, *mem_start = NULL, *tmp_buf=NULL;
|
|
|
|
u8 hw_hdr_offset, subtype ;
|
|
|
|
struct sta_info *psta = NULL;
|
|
|
|
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
|
|
|
|
struct pkt_attrib *pattrib = &pxmitframe->attrib;
|
|
|
|
u8 *pbuf_start;
|
|
|
|
s32 bmcst = IS_MCAST(pattrib->ra);
|
|
|
|
s32 res = _FAIL;
|
|
|
|
u8 *BIP_AAD;
|
|
|
|
u8 *MGMT_body=NULL;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
|
|
|
struct rtw_ieee80211_hdr *pwlanhdr;
|
|
|
|
u8 MME[_MME_IE_LENGTH_];
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
u32 ori_len;
|
|
|
|
mem_start = pframe = (u8 *)(pxmitframe->buf_addr) + TXDESC_OFFSET;
|
|
|
|
pwlanhdr = (struct rtw_ieee80211_hdr *)pframe;
|
|
|
|
tmp_buf = BIP_AAD;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-11 21:15:04 +00:00
|
|
|
ori_len = BIP_AAD_SIZE+pattrib->pktlen;
|
|
|
|
tmp_buf = BIP_AAD = rtw_zmalloc(ori_len);
|
2015-02-19 21:34:32 +00:00
|
|
|
subtype = GetFrameSubType(pframe); /* bit(7)~bit(2) */
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if(BIP_AAD == NULL)
|
|
|
|
return _FAIL;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&padapter->security_key_mutex);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* only support station mode */
|
2014-12-11 21:15:04 +00:00
|
|
|
if(!check_fwstate(pmlmepriv, WIFI_STATION_STATE) || !check_fwstate(pmlmepriv, _FW_LINKED))
|
|
|
|
goto xmitframe_coalesce_success;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* IGTK key is not install, it may not support 802.11w */
|
2014-12-29 02:13:24 +00:00
|
|
|
if(padapter->securitypriv.binstallBIPkey != true)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
DBG_871X("no instll BIP key\n");
|
|
|
|
goto xmitframe_coalesce_success;
|
|
|
|
}
|
2015-02-19 21:34:32 +00:00
|
|
|
/* station mode doesn't need TX BIP, just ready the code */
|
2014-12-11 21:15:04 +00:00
|
|
|
if(bmcst)
|
|
|
|
{
|
|
|
|
int frame_body_len;
|
|
|
|
u8 mic[16];
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(MME, 0, 18);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* other types doesn't need the BIP */
|
2014-12-11 21:15:04 +00:00
|
|
|
if(GetFrameSubType(pframe) != WIFI_DEAUTH && GetFrameSubType(pframe) != WIFI_DISASSOC)
|
|
|
|
goto xmitframe_coalesce_fail;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
MGMT_body = pframe + sizeof(struct rtw_ieee80211_hdr_3addr);
|
|
|
|
pframe += pattrib->pktlen;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* octent 0 and 1 is key index ,BIP keyid is 4 or 5, LSB only need octent 0 */
|
2014-12-11 21:15:04 +00:00
|
|
|
MME[0]=padapter->securitypriv.dot11wBIPKeyid;
|
2015-02-19 21:34:32 +00:00
|
|
|
/* copy packet number */
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(&MME[2], &pmlmeext->mgnt_80211w_IPN, 6);
|
2015-02-19 21:34:32 +00:00
|
|
|
/* increase the packet number */
|
2014-12-11 21:15:04 +00:00
|
|
|
pmlmeext->mgnt_80211w_IPN++;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* add MME IE with MIC all zero, MME string doesn't include element id and length */
|
2014-12-11 21:15:04 +00:00
|
|
|
pframe = rtw_set_ie(pframe, _MME_IE_ , 16 , MME, &(pattrib->pktlen));
|
|
|
|
pattrib->last_txcmdsz = pattrib->pktlen;
|
2015-02-19 21:34:32 +00:00
|
|
|
/* total frame length - header length */
|
2014-12-11 21:15:04 +00:00
|
|
|
frame_body_len = pattrib->pktlen - sizeof(struct rtw_ieee80211_hdr_3addr);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* conscruct AAD, copy frame control field */
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(BIP_AAD, &pwlanhdr->frame_ctl, 2);
|
2014-12-11 21:15:04 +00:00
|
|
|
ClearRetry(BIP_AAD);
|
|
|
|
ClearPwrMgt(BIP_AAD);
|
|
|
|
ClearMData(BIP_AAD);
|
2015-02-19 21:34:32 +00:00
|
|
|
/* conscruct AAD, copy address 1 to address 3 */
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(BIP_AAD+2, pwlanhdr->addr1, 18);
|
2015-02-19 21:34:32 +00:00
|
|
|
/* copy management fram body */
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(BIP_AAD+BIP_AAD_SIZE, MGMT_body, frame_body_len);
|
2015-02-19 21:34:32 +00:00
|
|
|
/*/* dump total packet include MME with zero MIC */
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
printk("Total packet: ");
|
|
|
|
for(i=0; i < BIP_AAD_SIZE+frame_body_len; i++)
|
|
|
|
printk(" %02x ", BIP_AAD[i]);
|
|
|
|
printk("\n");
|
|
|
|
}*/
|
2015-02-19 21:34:32 +00:00
|
|
|
/* calculate mic */
|
2014-12-11 21:15:04 +00:00
|
|
|
if(omac1_aes_128(padapter->securitypriv.dot11wBIPKey[padapter->securitypriv.dot11wBIPKeyid].skey
|
|
|
|
, BIP_AAD, BIP_AAD_SIZE+frame_body_len, mic))
|
|
|
|
goto xmitframe_coalesce_fail;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/*/* dump calculated mic result */
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
printk("Calculated mic result: ");
|
|
|
|
for(i=0; i<16; i++)
|
|
|
|
printk(" %02x ", mic[i]);
|
|
|
|
printk("\n");
|
|
|
|
}*/
|
2015-02-19 21:34:32 +00:00
|
|
|
/* copy right BIP mic value, total is 128bits, we use the 0~63 bits */
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(pframe-8, mic, 8);
|
2014-12-11 21:15:04 +00:00
|
|
|
/*/dump all packet after mic ok
|
|
|
|
{
|
|
|
|
int pp;
|
|
|
|
printk("pattrib->pktlen = %d \n", pattrib->pktlen);
|
|
|
|
for(pp=0;pp< pattrib->pktlen; pp++)
|
|
|
|
printk(" %02x ", mem_start[pp]);
|
|
|
|
printk("\n");
|
|
|
|
}*/
|
|
|
|
}
|
2015-02-19 21:34:32 +00:00
|
|
|
else /* unicast mgmt frame TX */
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2015-02-19 21:34:32 +00:00
|
|
|
/* start to encrypt mgmt frame */
|
2014-12-11 21:15:04 +00:00
|
|
|
if(subtype == WIFI_DEAUTH || subtype == WIFI_DISASSOC ||
|
|
|
|
subtype == WIFI_REASSOCREQ || subtype == WIFI_ACTION)
|
|
|
|
{
|
|
|
|
if (pattrib->psta)
|
|
|
|
psta = pattrib->psta;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra);
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if(psta==NULL)
|
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
DBG_871X("%s, psta==NUL\n", __func__);
|
|
|
|
goto xmitframe_coalesce_fail;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if(!(psta->state & _FW_LINKED) || pxmitframe->buf_addr==NULL)
|
|
|
|
{
|
|
|
|
DBG_871X("%s, not _FW_LINKED or addr null\n", __func__);
|
|
|
|
goto xmitframe_coalesce_fail;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* DBG_871X("%s, action frame category=%d \n", __func__, pframe[WLAN_HDR_A3_LEN]); */
|
|
|
|
/* according 802.11-2012 standard, these five types are not robust types */
|
2014-12-19 06:59:46 +00:00
|
|
|
if(subtype == WIFI_ACTION &&
|
2014-12-11 21:15:04 +00:00
|
|
|
(pframe[WLAN_HDR_A3_LEN] == RTW_WLAN_CATEGORY_PUBLIC ||
|
|
|
|
pframe[WLAN_HDR_A3_LEN] == RTW_WLAN_CATEGORY_HT ||
|
|
|
|
pframe[WLAN_HDR_A3_LEN] == RTW_WLAN_CATEGORY_UNPROTECTED_WNM ||
|
|
|
|
pframe[WLAN_HDR_A3_LEN] == RTW_WLAN_CATEGORY_SELF_PROTECTED ||
|
|
|
|
pframe[WLAN_HDR_A3_LEN] == RTW_WLAN_CATEGORY_P2P))
|
|
|
|
goto xmitframe_coalesce_fail;
|
2015-02-19 21:34:32 +00:00
|
|
|
/*/* before encrypt dump the management packet content */
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
printk("Management pkt: ");
|
|
|
|
for(i=0; i<pattrib->pktlen; i++)
|
|
|
|
printk(" %02x ", pframe[i]);
|
|
|
|
printk("=======\n");
|
|
|
|
}*/
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* bakeup original management packet */
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(tmp_buf, pframe, pattrib->pktlen);
|
2015-02-19 21:34:32 +00:00
|
|
|
/* move to data portion */
|
2014-12-11 21:15:04 +00:00
|
|
|
pframe += pattrib->hdrlen;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* 802.11w unicast management packet must be _AES_ */
|
2014-12-11 21:15:04 +00:00
|
|
|
pattrib->iv_len = 8;
|
2015-02-19 21:34:32 +00:00
|
|
|
/* it's MIC of AES */
|
2014-12-11 21:15:04 +00:00
|
|
|
pattrib->icv_len = 8;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
switch(pattrib->encrypt)
|
|
|
|
{
|
|
|
|
case _AES_:
|
2015-02-19 21:34:32 +00:00
|
|
|
/* set AES IV header */
|
2014-12-11 21:15:04 +00:00
|
|
|
AES_IV(pattrib->iv, psta->dot11wtxpn, 0);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto xmitframe_coalesce_fail;
|
|
|
|
}
|
2015-02-19 21:34:32 +00:00
|
|
|
/* insert iv header into management frame */
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(pframe, pattrib->iv, pattrib->iv_len);
|
2014-12-11 21:15:04 +00:00
|
|
|
pframe += pattrib->iv_len;
|
2015-02-19 21:34:32 +00:00
|
|
|
/* copy mgmt data portion after CCMP header */
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(pframe, tmp_buf+pattrib->hdrlen, pattrib->pktlen-pattrib->hdrlen);
|
2015-02-19 21:34:32 +00:00
|
|
|
/* move pframe to end of mgmt pkt */
|
2014-12-11 21:15:04 +00:00
|
|
|
pframe += pattrib->pktlen-pattrib->hdrlen;
|
2015-02-19 21:34:32 +00:00
|
|
|
/* add 8 bytes CCMP IV header to length */
|
2014-12-11 21:15:04 +00:00
|
|
|
pattrib->pktlen += pattrib->iv_len;
|
2015-02-19 21:34:32 +00:00
|
|
|
/*/* dump management packet include AES IV header */
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
printk("Management pkt + IV: ");
|
2015-02-19 21:34:32 +00:00
|
|
|
/* for(i=0; i<pattrib->pktlen; i++) */
|
|
|
|
/* printk(" %02x ", mem_start[i]); */
|
2014-12-11 21:15:04 +00:00
|
|
|
printk("@@@@@@@@@@@@@\n");
|
|
|
|
}*/
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if ((pattrib->icv_len >0 )&& (pattrib->bswenc)) {
|
2015-02-19 20:50:04 +00:00
|
|
|
memcpy(pframe, pattrib->icv, pattrib->icv_len);
|
2014-12-11 21:15:04 +00:00
|
|
|
pframe += pattrib->icv_len;
|
|
|
|
}
|
2015-02-19 21:34:32 +00:00
|
|
|
/* add 8 bytes MIC */
|
2014-12-11 21:15:04 +00:00
|
|
|
pattrib->pktlen += pattrib->icv_len;
|
2015-02-19 21:34:32 +00:00
|
|
|
/* set final tx command size */
|
2014-12-11 21:15:04 +00:00
|
|
|
pattrib->last_txcmdsz = pattrib->pktlen;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* set protected bit must be beofre SW encrypt */
|
2014-12-11 21:15:04 +00:00
|
|
|
SetPrivacy(mem_start);
|
2015-02-19 21:34:32 +00:00
|
|
|
/*/* dump management packet include AES header */
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
printk("prepare to enc Management pkt + IV: ");
|
|
|
|
for(i=0; i<pattrib->pktlen; i++)
|
|
|
|
printk(" %02x ", mem_start[i]);
|
|
|
|
printk("@@@@@@@@@@@@@\n");
|
|
|
|
}*/
|
2015-02-19 21:34:32 +00:00
|
|
|
/* software encrypt */
|
2014-12-11 21:15:04 +00:00
|
|
|
xmitframe_swencrypt(padapter, pxmitframe);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
xmitframe_coalesce_success:
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&padapter->security_key_mutex);
|
2014-12-11 21:15:04 +00:00
|
|
|
rtw_mfree(BIP_AAD, ori_len);
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-11 21:15:04 +00:00
|
|
|
return _SUCCESS;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
xmitframe_coalesce_fail:
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&padapter->security_key_mutex);
|
2014-12-11 21:15:04 +00:00
|
|
|
rtw_mfree(BIP_AAD, ori_len);
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
return _FAIL;
|
|
|
|
}
|
2015-02-19 21:34:32 +00:00
|
|
|
#endif /* CONFIG_IEEE80211W */
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
/* Logical Link Control(LLC) SubNetwork Attachment Point(SNAP) header
|
|
|
|
* IEEE LLC/SNAP header contains 8 octets
|
|
|
|
* First 3 octets comprise the LLC portion
|
|
|
|
* SNAP portion, 5 octets, is divided into two fields:
|
|
|
|
* Organizationally Unique Identifier(OUI), 3 octets,
|
|
|
|
* type, defined by that organization, 2 octets.
|
|
|
|
*/
|
|
|
|
s32 rtw_put_snap(u8 *data, u16 h_proto)
|
|
|
|
{
|
|
|
|
struct ieee80211_snap_hdr *snap;
|
|
|
|
u8 *oui;
|
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
snap = (struct ieee80211_snap_hdr *)data;
|
|
|
|
snap->dsap = 0xaa;
|
|
|
|
snap->ssap = 0xaa;
|
|
|
|
snap->ctrl = 0x03;
|
|
|
|
|
|
|
|
if (h_proto == 0x8137 || h_proto == 0x80f3)
|
|
|
|
oui = P802_1H_OUI;
|
|
|
|
else
|
|
|
|
oui = RFC1042_OUI;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
snap->oui[0] = oui[0];
|
|
|
|
snap->oui[1] = oui[1];
|
|
|
|
snap->oui[2] = oui[2];
|
|
|
|
|
2015-01-28 05:14:58 +00:00
|
|
|
*(__be16 *)(data + SNAP_SIZE) = htons(h_proto);
|
2013-05-08 21:45:39 +00:00
|
|
|
return SNAP_SIZE + sizeof(u16);
|
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void rtw_update_protection(struct adapter *padapter, u8 *ie, uint ie_len)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
uint protection;
|
|
|
|
u8 *perp;
|
2014-12-11 21:15:04 +00:00
|
|
|
sint erp_len;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
|
|
|
|
struct registry_priv *pregistrypriv = &padapter->registrypriv;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
switch(pxmitpriv->vcs_setting)
|
|
|
|
{
|
|
|
|
case DISABLE_VCS:
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitpriv->vcs = NONE_VCS;
|
2014-12-11 21:15:04 +00:00
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
case ENABLE_VCS:
|
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
case AUTO_VCS:
|
|
|
|
default:
|
|
|
|
perp = rtw_get_ie(ie, _ERPINFO_IE_, &erp_len, ie_len);
|
|
|
|
if(perp == NULL)
|
|
|
|
{
|
2013-08-03 03:16:03 +00:00
|
|
|
pxmitpriv->vcs = NONE_VCS;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
protection = (*(perp + 2)) & BIT(1);
|
|
|
|
if (protection)
|
|
|
|
{
|
|
|
|
if(pregistrypriv->vcs_type == RTS_CTS)
|
|
|
|
pxmitpriv->vcs = RTS_CTS;
|
|
|
|
else
|
|
|
|
pxmitpriv->vcs = CTS_TO_SELF;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pxmitpriv->vcs = NONE_VCS;
|
|
|
|
}
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
break;
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void rtw_count_tx_stats(struct adapter *padapter, struct xmit_frame *pxmitframe, int sz)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct sta_info *psta = NULL;
|
|
|
|
struct stainfo_stats *pstats = NULL;
|
|
|
|
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
|
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if ((pxmitframe->frame_tag&0x0f) == DATA_FRAMETAG)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitpriv->tx_bytes += sz;
|
|
|
|
pmlmepriv->LinkDetectInfo.NumTxOkInPeriod += pxmitframe->agg_num;
|
|
|
|
psta = pxmitframe->attrib.psta;
|
2015-02-26 20:19:01 +00:00
|
|
|
if (psta) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pstats = &psta->sta_stats;
|
|
|
|
pstats->tx_pkts += pxmitframe->agg_num;
|
|
|
|
pstats->tx_bytes += sz;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv)
|
|
|
|
{
|
|
|
|
struct xmit_buf *pxmitbuf = NULL;
|
2014-12-11 21:15:04 +00:00
|
|
|
_list *plist, *phead;
|
|
|
|
_queue *pfree_queue = &pxmitpriv->free_xmit_extbuf_queue;
|
2015-03-06 17:54:48 +00:00
|
|
|
unsigned long flags;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_irqsave(&pfree_queue->lock, flags);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if(_rtw_queue_empty(pfree_queue) == true) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitbuf = NULL;
|
|
|
|
} else {
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
phead = get_list_head(pfree_queue);
|
|
|
|
|
|
|
|
plist = get_next(phead);
|
|
|
|
|
|
|
|
pxmitbuf = LIST_CONTAINOR(plist, struct xmit_buf, list);
|
|
|
|
|
|
|
|
rtw_list_delete(&(pxmitbuf->list));
|
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if (pxmitbuf != NULL)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitpriv->free_xmit_extbuf_cnt--;
|
2014-12-11 21:15:04 +00:00
|
|
|
#ifdef DBG_XMIT_BUF_EXT
|
|
|
|
DBG_871X("DBG_XMIT_BUF_EXT ALLOC no=%d, free_xmit_extbuf_cnt=%d\n",pxmitbuf->no, pxmitpriv->free_xmit_extbuf_cnt);
|
|
|
|
#endif
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitbuf->priv_data = NULL;
|
2015-02-19 21:34:32 +00:00
|
|
|
/* pxmitbuf->ext_tag = true; */
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
if (pxmitbuf->sctx) {
|
2014-12-11 21:15:04 +00:00
|
|
|
DBG_871X("%s pxmitbuf->sctx is not NULL\n", __func__);
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_BUF_ALLOC);
|
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_irqrestore(&pfree_queue->lock, flags);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return pxmitbuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 rtw_free_xmitbuf_ext(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf)
|
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
_queue *pfree_queue = &pxmitpriv->free_xmit_extbuf_queue;
|
2015-03-06 17:54:48 +00:00
|
|
|
unsigned long flags;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if(pxmitbuf==NULL)
|
2013-05-08 21:45:39 +00:00
|
|
|
return _FAIL;
|
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_irqsave(&pfree_queue->lock, flags);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
rtw_list_delete(&pxmitbuf->list);
|
|
|
|
|
|
|
|
rtw_list_insert_tail(&(pxmitbuf->list), get_list_head(pfree_queue));
|
|
|
|
pxmitpriv->free_xmit_extbuf_cnt++;
|
2014-12-11 21:15:04 +00:00
|
|
|
#ifdef DBG_XMIT_BUF_EXT
|
|
|
|
DBG_871X("DBG_XMIT_BUF_EXT FREE no=%d, free_xmit_extbuf_cnt=%d\n",pxmitbuf->no ,pxmitpriv->free_xmit_extbuf_cnt);
|
|
|
|
#endif
|
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_irqrestore(&pfree_queue->lock, flags);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return _SUCCESS;
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv)
|
|
|
|
{
|
|
|
|
struct xmit_buf *pxmitbuf = NULL;
|
2014-12-11 21:15:04 +00:00
|
|
|
_list *plist, *phead;
|
|
|
|
_queue *pfree_xmitbuf_queue = &pxmitpriv->free_xmitbuf_queue;
|
2015-03-06 17:54:48 +00:00
|
|
|
unsigned long flags;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* DBG_871X("+rtw_alloc_xmitbuf\n"); */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_irqsave(&pfree_xmitbuf_queue->lock, flags);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if(_rtw_queue_empty(pfree_xmitbuf_queue) == true) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitbuf = NULL;
|
|
|
|
} else {
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
phead = get_list_head(pfree_xmitbuf_queue);
|
|
|
|
|
|
|
|
plist = get_next(phead);
|
|
|
|
|
|
|
|
pxmitbuf = LIST_CONTAINOR(plist, struct xmit_buf, list);
|
|
|
|
|
|
|
|
rtw_list_delete(&(pxmitbuf->list));
|
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if (pxmitbuf != NULL)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitpriv->free_xmitbuf_cnt--;
|
2014-12-11 21:15:04 +00:00
|
|
|
#ifdef DBG_XMIT_BUF
|
|
|
|
DBG_871X("DBG_XMIT_BUF ALLOC no=%d, free_xmitbuf_cnt=%d\n",pxmitbuf->no, pxmitpriv->free_xmitbuf_cnt);
|
|
|
|
#endif
|
2015-02-19 21:34:32 +00:00
|
|
|
/* DBG_871X("alloc, free_xmitbuf_cnt=%d\n", pxmitpriv->free_xmitbuf_cnt); */
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitbuf->priv_data = NULL;
|
2015-02-19 21:34:32 +00:00
|
|
|
/* pxmitbuf->ext_tag = false; */
|
2013-05-08 21:45:39 +00:00
|
|
|
if (pxmitbuf->sctx) {
|
2014-12-11 21:15:04 +00:00
|
|
|
DBG_871X("%s pxmitbuf->sctx is not NULL\n", __func__);
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_BUF_ALLOC);
|
|
|
|
}
|
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
#ifdef DBG_XMIT_BUF
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DBG_871X("DBG_XMIT_BUF rtw_alloc_xmitbuf return NULL\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_irqrestore(&pfree_xmitbuf_queue->lock, flags);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return pxmitbuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf)
|
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
_queue *pfree_xmitbuf_queue = &pxmitpriv->free_xmitbuf_queue;
|
2015-03-06 17:54:48 +00:00
|
|
|
unsigned long flags;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
if(pxmitbuf==NULL)
|
2013-05-08 21:45:39 +00:00
|
|
|
return _FAIL;
|
|
|
|
|
|
|
|
if (pxmitbuf->sctx) {
|
2014-12-11 21:15:04 +00:00
|
|
|
DBG_871X("%s pxmitbuf->sctx is not NULL\n", __func__);
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_BUF_FREE);
|
|
|
|
}
|
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
if(pxmitbuf->ext_tag) {
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_free_xmitbuf_ext(pxmitpriv, pxmitbuf);
|
2015-03-06 17:54:48 +00:00
|
|
|
} else {
|
|
|
|
spin_lock_irqsave(&pfree_xmitbuf_queue->lock, flags);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
rtw_list_delete(&pxmitbuf->list);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
rtw_list_insert_tail(&(pxmitbuf->list), get_list_head(pfree_xmitbuf_queue));
|
|
|
|
|
|
|
|
pxmitpriv->free_xmitbuf_cnt++;
|
2015-02-19 21:34:32 +00:00
|
|
|
/* DBG_871X("FREE, free_xmitbuf_cnt=%d\n", pxmitpriv->free_xmitbuf_cnt); */
|
2014-12-11 21:15:04 +00:00
|
|
|
#ifdef DBG_XMIT_BUF
|
|
|
|
DBG_871X("DBG_XMIT_BUF FREE no=%d, free_xmitbuf_cnt=%d\n",pxmitbuf->no ,pxmitpriv->free_xmitbuf_cnt);
|
|
|
|
#endif
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_irqrestore(&pfree_xmitbuf_queue->lock, flags);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
return _SUCCESS;
|
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2015-01-28 05:14:58 +00:00
|
|
|
static void rtw_init_xmitframe(struct xmit_frame *pxframe)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2015-02-19 21:34:32 +00:00
|
|
|
if (pxframe != NULL)/* default value setting */
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
pxframe->buf_addr = NULL;
|
|
|
|
pxframe->pxmitbuf = NULL;
|
|
|
|
|
2015-02-19 20:58:09 +00:00
|
|
|
memset(&pxframe->attrib, 0, sizeof(struct pkt_attrib));
|
2015-02-19 21:34:32 +00:00
|
|
|
/* pxframe->attrib.psta = NULL; */
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
pxframe->frame_tag = DATA_FRAMETAG;
|
|
|
|
|
|
|
|
pxframe->pkt = NULL;
|
2015-02-19 21:34:32 +00:00
|
|
|
pxframe->pkt_offset = 1;/* default use pkt_offset to fill tx desc */
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
pxframe->agg_num = 1;
|
|
|
|
pxframe->ack_report = 0;
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
Calling context:
|
|
|
|
1. OS_TXENTRY
|
|
|
|
2. RXENTRY (rx_thread or RX_ISR/RX_CallBack)
|
|
|
|
|
|
|
|
If we turn on USE_RXTHREAD, then, no need for critical section.
|
|
|
|
Otherwise, we must use _enter/_exit critical to protect free_xmit_queue...
|
|
|
|
|
|
|
|
Must be very very cautious...
|
|
|
|
|
|
|
|
*/
|
2015-02-19 21:34:32 +00:00
|
|
|
struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv)/* _queue *pfree_xmit_queue) */
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
Please remember to use all the osdep_service api,
|
2014-12-19 06:59:46 +00:00
|
|
|
and lock/unlock or _enter/_exit critical to protect
|
2013-05-08 21:45:39 +00:00
|
|
|
pfree_xmit_queue
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct xmit_frame *pxframe = NULL;
|
2014-12-11 21:15:04 +00:00
|
|
|
_list *plist, *phead;
|
|
|
|
_queue *pfree_xmit_queue = &pxmitpriv->free_xmit_queue;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = pxmitpriv->adapter;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&pfree_xmit_queue->lock);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if (_rtw_queue_empty(pfree_xmit_queue) == true) {
|
2014-12-11 21:15:04 +00:00
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_,_drv_info_,("rtw_alloc_xmitframe:%d\n", pxmitpriv->free_xmitframe_cnt));
|
2013-05-08 21:45:39 +00:00
|
|
|
pxframe = NULL;
|
|
|
|
} else {
|
|
|
|
phead = get_list_head(pfree_xmit_queue);
|
|
|
|
|
|
|
|
plist = get_next(phead);
|
|
|
|
|
|
|
|
pxframe = LIST_CONTAINOR(plist, struct xmit_frame, list);
|
|
|
|
|
|
|
|
rtw_list_delete(&(pxframe->list));
|
2014-12-11 21:15:04 +00:00
|
|
|
pxmitpriv->free_xmitframe_cnt--;
|
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_alloc_xmitframe():free_xmitframe_cnt=%d\n", pxmitpriv->free_xmitframe_cnt));
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&pfree_xmit_queue->lock);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
rtw_init_xmitframe(pxframe);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
return pxframe;
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
struct xmit_frame *rtw_alloc_xmitframe_ext(struct xmit_priv *pxmitpriv)
|
|
|
|
{
|
|
|
|
struct xmit_frame *pxframe = NULL;
|
|
|
|
_list *plist, *phead;
|
|
|
|
_queue *queue = &pxmitpriv->free_xframe_ext_queue;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&queue->lock);
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if (_rtw_queue_empty(queue) == true) {
|
2014-12-11 21:15:04 +00:00
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_,_drv_info_,("rtw_alloc_xmitframe_ext:%d\n", pxmitpriv->free_xframe_ext_cnt));
|
|
|
|
pxframe = NULL;
|
|
|
|
} else {
|
|
|
|
phead = get_list_head(queue);
|
|
|
|
plist = get_next(phead);
|
|
|
|
pxframe = LIST_CONTAINOR(plist, struct xmit_frame, list);
|
|
|
|
|
|
|
|
rtw_list_delete(&(pxframe->list));
|
|
|
|
pxmitpriv->free_xframe_ext_cnt--;
|
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_alloc_xmitframe_ext():free_xmitframe_cnt=%d\n", pxmitpriv->free_xframe_ext_cnt));
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&queue->lock);
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
rtw_init_xmitframe(pxframe);
|
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return pxframe;
|
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
struct xmit_frame *rtw_alloc_xmitframe_once(struct xmit_priv *pxmitpriv)
|
2013-05-19 04:28:07 +00:00
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
struct xmit_frame *pxframe = NULL;
|
|
|
|
u8 *alloc_addr;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
alloc_addr = rtw_zmalloc(sizeof(struct xmit_frame) + 4);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if (alloc_addr == NULL)
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
pxframe = (struct xmit_frame *)N_BYTE_ALIGMENT((SIZE_PTR)(alloc_addr), 4);
|
|
|
|
pxframe->alloc_addr = alloc_addr;
|
|
|
|
|
|
|
|
pxframe->padapter = pxmitpriv->adapter;
|
|
|
|
pxframe->frame_tag = NULL_FRAMETAG;
|
|
|
|
|
|
|
|
pxframe->pkt = NULL;
|
|
|
|
|
|
|
|
pxframe->buf_addr = NULL;
|
|
|
|
pxframe->pxmitbuf = NULL;
|
|
|
|
|
|
|
|
rtw_init_xmitframe(pxframe);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
DBG_871X("################## %s ##################\n", __func__);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
exit:
|
|
|
|
return pxframe;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv, struct xmit_frame *pxmitframe)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
_queue *queue;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = pxmitpriv->adapter;
|
2014-12-11 21:15:04 +00:00
|
|
|
_pkt *pndis_pkt = NULL;
|
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
if (pxmitframe == NULL) {
|
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("======rtw_free_xmitframe():pxmitframe==NULL!!!!!!!!!!\n"));
|
|
|
|
goto exit;
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if (pxmitframe->pkt){
|
2013-05-08 21:45:39 +00:00
|
|
|
pndis_pkt = pxmitframe->pkt;
|
|
|
|
pxmitframe->pkt = NULL;
|
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if (pxmitframe->alloc_addr) {
|
|
|
|
DBG_871X("################## %s with alloc_addr ##################\n", __func__);
|
|
|
|
rtw_mfree(pxmitframe->alloc_addr, sizeof(struct xmit_frame) + 4);
|
|
|
|
goto check_pkt_complete;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pxmitframe->ext_tag == 0)
|
|
|
|
queue = &pxmitpriv->free_xmit_queue;
|
|
|
|
else if(pxmitframe->ext_tag == 1)
|
|
|
|
queue = &pxmitpriv->free_xframe_ext_queue;
|
|
|
|
else
|
|
|
|
{}
|
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&queue->lock);
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
rtw_list_delete(&pxmitframe->list);
|
2014-12-11 21:15:04 +00:00
|
|
|
rtw_list_insert_tail(&pxmitframe->list, get_list_head(queue));
|
|
|
|
if (pxmitframe->ext_tag == 0) {
|
|
|
|
pxmitpriv->free_xmitframe_cnt++;
|
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_, _drv_debug_, ("rtw_free_xmitframe():free_xmitframe_cnt=%d\n", pxmitpriv->free_xmitframe_cnt));
|
|
|
|
} else if(pxmitframe->ext_tag == 1) {
|
|
|
|
pxmitpriv->free_xframe_ext_cnt++;
|
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_, _drv_debug_, ("rtw_free_xmitframe():free_xframe_ext_cnt=%d\n", pxmitpriv->free_xframe_ext_cnt));
|
|
|
|
} else {
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&queue->lock);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
check_pkt_complete:
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if(pndis_pkt)
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_os_pkt_complete(padapter, pndis_pkt);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return _SUCCESS;
|
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, _queue *pframequeue)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
_list *plist, *phead;
|
2014-12-19 06:59:46 +00:00
|
|
|
struct xmit_frame *pxmitframe;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&(pframequeue->lock));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
phead = get_list_head(pframequeue);
|
|
|
|
plist = get_next(phead);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
while (rtw_end_of_queue_search(phead, plist) == false)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitframe = LIST_CONTAINOR(plist, struct xmit_frame, list);
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
plist = get_next(plist);
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
rtw_free_xmitframe(pxmitpriv,pxmitframe);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&(pframequeue->lock));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
s32 rtw_xmitframe_enqueue(struct adapter *padapter, struct xmit_frame *pxmitframe)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
if (rtw_xmit_classifier(padapter, pxmitframe) == _FAIL)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_,
|
|
|
|
("rtw_xmitframe_enqueue: drop xmit pkt for classifier fail\n"));
|
2015-02-19 21:34:32 +00:00
|
|
|
/* pxmitframe->pkt = NULL; */
|
2013-05-08 21:45:39 +00:00
|
|
|
return _FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return _SUCCESS;
|
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
static struct xmit_frame *dequeue_one_xmitframe(struct xmit_priv *pxmitpriv, struct hw_xmit *phwxmit, struct tx_servq *ptxservq, _queue *pframe_queue)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
_list *xmitframe_plist, *xmitframe_phead;
|
|
|
|
struct xmit_frame *pxmitframe=NULL;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
xmitframe_phead = get_list_head(pframe_queue);
|
|
|
|
xmitframe_plist = get_next(xmitframe_phead);
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
while ((rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist)) == false)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list);
|
2013-10-19 17:45:47 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
xmitframe_plist = get_next(xmitframe_plist);
|
2013-10-19 17:45:47 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_list_delete(&pxmitframe->list);
|
2013-10-19 17:45:47 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
ptxservq->qcnt--;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
break;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
pxmitframe = NULL;
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return pxmitframe;
|
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
struct xmit_frame* rtw_dequeue_xframe(struct xmit_priv *pxmitpriv, struct hw_xmit *phwxmit_i, sint entry)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
_list *sta_plist, *sta_phead;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct hw_xmit *phwxmit;
|
|
|
|
struct tx_servq *ptxservq = NULL;
|
2014-12-11 21:15:04 +00:00
|
|
|
_queue *pframe_queue = NULL;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct xmit_frame *pxmitframe = NULL;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter = pxmitpriv->adapter;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct registry_priv *pregpriv = &padapter->registrypriv;
|
|
|
|
int i, inx[4];
|
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
inx[0] = 0; inx[1] = 1; inx[2] = 2; inx[3] = 3;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if(pregpriv->wifi_spec==1)
|
|
|
|
{
|
|
|
|
int j, tmp, acirp_cnt[4];
|
|
|
|
for(j=0; j<4; j++)
|
2013-05-08 21:45:39 +00:00
|
|
|
inx[j] = pxmitpriv->wmm_para_seq[j];
|
|
|
|
}
|
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&pxmitpriv->lock);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
for(i = 0; i < entry; i++)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
phwxmit = phwxmit_i + inx[i];
|
|
|
|
|
|
|
|
sta_phead = get_list_head(phwxmit->sta_queue);
|
|
|
|
sta_plist = get_next(sta_phead);
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
while ((rtw_end_of_queue_search(sta_phead, sta_plist)) == false)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
ptxservq= LIST_CONTAINOR(sta_plist, struct tx_servq, tx_pending);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pframe_queue = &ptxservq->sta_pending;
|
|
|
|
|
|
|
|
pxmitframe = dequeue_one_xmitframe(pxmitpriv, phwxmit, ptxservq, pframe_queue);
|
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
if(pxmitframe) {
|
2013-05-08 21:45:39 +00:00
|
|
|
phwxmit->accnt--;
|
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* Remove sta node when there is no pending packets. */
|
|
|
|
if(_rtw_queue_empty(pframe_queue)) /* must be done after get_next and before break */
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_list_delete(&ptxservq->tx_pending);
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
sta_plist = get_next(sta_plist);
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
exit:
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&pxmitpriv->lock);
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-01 22:31:15 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return pxmitframe;
|
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, struct sta_info *psta, sint up, u8 *ac)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
struct tx_servq *ptxservq=NULL;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
switch (up)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
ptxservq = &(psta->sta_xmitpriv.bk_q);
|
|
|
|
*(ac) = 3;
|
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_,_drv_info_,("rtw_get_sta_pending : BK \n"));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
case 5:
|
|
|
|
ptxservq = &(psta->sta_xmitpriv.vi_q);
|
|
|
|
*(ac) = 1;
|
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_,_drv_info_,("rtw_get_sta_pending : VI\n"));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 6:
|
|
|
|
case 7:
|
|
|
|
ptxservq = &(psta->sta_xmitpriv.vo_q);
|
|
|
|
*(ac) = 0;
|
2014-12-19 06:59:46 +00:00
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_,_drv_info_,("rtw_get_sta_pending : VO \n"));
|
2014-12-11 21:15:04 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
case 3:
|
|
|
|
default:
|
|
|
|
ptxservq = &(psta->sta_xmitpriv.be_q);
|
|
|
|
*(ac) = 2;
|
2014-12-19 06:59:46 +00:00
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_,_drv_info_,("rtw_get_sta_pending : BE \n"));
|
2013-07-11 15:59:02 +00:00
|
|
|
break;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
return ptxservq;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Will enqueue pxmitframe to the proper queue,
|
|
|
|
* and indicate it to xx_pending list.....
|
|
|
|
*/
|
2014-12-17 23:13:53 +00:00
|
|
|
s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
u8 ac_index;
|
|
|
|
struct sta_info *psta;
|
|
|
|
struct tx_servq *ptxservq;
|
|
|
|
struct pkt_attrib *pattrib = &pxmitframe->attrib;
|
|
|
|
struct sta_priv *pstapriv = &padapter->stapriv;
|
|
|
|
struct hw_xmit *phwxmits = padapter->xmitpriv.hwxmits;
|
2014-12-11 21:15:04 +00:00
|
|
|
sint res = _SUCCESS;
|
|
|
|
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
if (pattrib->psta) {
|
2014-12-19 06:59:46 +00:00
|
|
|
psta = pattrib->psta;
|
2013-05-08 21:45:39 +00:00
|
|
|
} else {
|
2014-12-11 21:15:04 +00:00
|
|
|
DBG_871X("%s, call rtw_get_stainfo()\n", __func__);
|
2013-05-08 21:45:39 +00:00
|
|
|
psta = rtw_get_stainfo(pstapriv, pattrib->ra);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (psta == NULL) {
|
|
|
|
res = _FAIL;
|
2014-12-11 21:15:04 +00:00
|
|
|
DBG_8192C("rtw_xmit_classifier: psta == NULL\n");
|
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_,_drv_err_,("rtw_xmit_classifier: psta == NULL\n"));
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if(!(psta->state &_FW_LINKED))
|
|
|
|
{
|
|
|
|
DBG_871X("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, psta->state);
|
|
|
|
return _FAIL;
|
|
|
|
}
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
ptxservq = rtw_get_sta_pending(padapter, psta, pattrib->priority, (u8 *)(&ac_index));
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if (rtw_is_list_empty(&ptxservq->tx_pending)) {
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_list_insert_tail(&ptxservq->tx_pending, get_list_head(phwxmits[ac_index].sta_queue));
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_list_insert_tail(&pxmitframe->list, get_list_head(&ptxservq->sta_pending));
|
|
|
|
ptxservq->qcnt++;
|
|
|
|
phwxmits[ac_index].accnt++;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
exit:
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void rtw_alloc_hwxmits(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct hw_xmit *hwxmits;
|
|
|
|
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
|
|
|
|
|
|
|
|
pxmitpriv->hwxmit_entry = HWXMIT_ENTRY;
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
pxmitpriv->hwxmits = (struct hw_xmit *)rtw_zmalloc(sizeof (struct hw_xmit) * pxmitpriv->hwxmit_entry);
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
hwxmits = pxmitpriv->hwxmits;
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if(pxmitpriv->hwxmit_entry == 5)
|
|
|
|
{
|
2015-02-19 21:34:32 +00:00
|
|
|
/* pxmitpriv->bmc_txqueue.head = 0; */
|
|
|
|
/* hwxmits[0] .phwtxqueue = &pxmitpriv->bmc_txqueue; */
|
2013-05-08 21:45:39 +00:00
|
|
|
hwxmits[0] .sta_queue = &pxmitpriv->bm_pending;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* pxmitpriv->vo_txqueue.head = 0; */
|
|
|
|
/* hwxmits[1] .phwtxqueue = &pxmitpriv->vo_txqueue; */
|
2013-05-08 21:45:39 +00:00
|
|
|
hwxmits[1] .sta_queue = &pxmitpriv->vo_pending;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* pxmitpriv->vi_txqueue.head = 0; */
|
|
|
|
/* hwxmits[2] .phwtxqueue = &pxmitpriv->vi_txqueue; */
|
2013-05-08 21:45:39 +00:00
|
|
|
hwxmits[2] .sta_queue = &pxmitpriv->vi_pending;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* pxmitpriv->bk_txqueue.head = 0; */
|
|
|
|
/* hwxmits[3] .phwtxqueue = &pxmitpriv->bk_txqueue; */
|
2013-05-08 21:45:39 +00:00
|
|
|
hwxmits[3] .sta_queue = &pxmitpriv->bk_pending;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* pxmitpriv->be_txqueue.head = 0; */
|
|
|
|
/* hwxmits[4] .phwtxqueue = &pxmitpriv->be_txqueue; */
|
2013-05-08 21:45:39 +00:00
|
|
|
hwxmits[4] .sta_queue = &pxmitpriv->be_pending;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
else if(pxmitpriv->hwxmit_entry == 4)
|
|
|
|
{
|
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* pxmitpriv->vo_txqueue.head = 0; */
|
|
|
|
/* hwxmits[0] .phwtxqueue = &pxmitpriv->vo_txqueue; */
|
2013-05-08 21:45:39 +00:00
|
|
|
hwxmits[0] .sta_queue = &pxmitpriv->vo_pending;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* pxmitpriv->vi_txqueue.head = 0; */
|
|
|
|
/* hwxmits[1] .phwtxqueue = &pxmitpriv->vi_txqueue; */
|
2013-05-08 21:45:39 +00:00
|
|
|
hwxmits[1] .sta_queue = &pxmitpriv->vi_pending;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* pxmitpriv->be_txqueue.head = 0; */
|
|
|
|
/* hwxmits[2] .phwtxqueue = &pxmitpriv->be_txqueue; */
|
2013-05-08 21:45:39 +00:00
|
|
|
hwxmits[2] .sta_queue = &pxmitpriv->be_pending;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* pxmitpriv->bk_txqueue.head = 0; */
|
|
|
|
/* hwxmits[3] .phwtxqueue = &pxmitpriv->bk_txqueue; */
|
2013-05-08 21:45:39 +00:00
|
|
|
hwxmits[3] .sta_queue = &pxmitpriv->bk_pending;
|
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
else
|
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void rtw_free_hwxmits(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct hw_xmit *hwxmits;
|
|
|
|
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
|
|
|
|
|
|
|
|
hwxmits = pxmitpriv->hwxmits;
|
2014-12-11 21:15:04 +00:00
|
|
|
if(hwxmits)
|
|
|
|
rtw_mfree((u8 *)hwxmits, (sizeof (struct hw_xmit) * pxmitpriv->hwxmit_entry));
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
void rtw_init_hwxmits(struct hw_xmit *phwxmit, sint entry)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
sint i;
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2014-12-11 21:15:04 +00:00
|
|
|
for(i = 0; i < entry; i++, phwxmit++)
|
|
|
|
{
|
2015-03-05 20:42:30 +00:00
|
|
|
/* spin_lock_init(&phwxmit->xmit_lock); */
|
2015-02-19 21:34:32 +00:00
|
|
|
/* _rtw_init_listhead(&phwxmit->pending); */
|
|
|
|
/* phwxmit->txcmdcnt = 0; */
|
2013-05-08 21:45:39 +00:00
|
|
|
phwxmit->accnt = 0;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2015-01-26 22:20:25 +00:00
|
|
|
;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
#ifdef CONFIG_BR_EXT
|
2015-01-28 05:14:58 +00:00
|
|
|
static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct sk_buff *skb = *pskb;
|
2014-12-11 21:15:04 +00:00
|
|
|
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
|
2015-02-19 21:34:32 +00:00
|
|
|
/* if(check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_ADHOC_STATE) == true) */
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
int res, is_vlan_tag=0, i, do_nat25=1;
|
|
|
|
unsigned short vlan_hdr=0;
|
|
|
|
void *br_port = NULL;
|
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* mac_clone_handle_frame(priv, skb); */
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 35))
|
|
|
|
br_port = padapter->pnetdev->br_port;
|
2015-02-19 21:34:32 +00:00
|
|
|
#else /* (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 35)) */
|
2014-12-11 21:15:04 +00:00
|
|
|
rcu_read_lock();
|
|
|
|
br_port = rcu_dereference(padapter->pnetdev->rx_handler_data);
|
|
|
|
rcu_read_unlock();
|
2015-02-19 21:34:32 +00:00
|
|
|
#endif /* (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 35)) */
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&padapter->br_ext_lock);
|
2014-12-11 21:15:04 +00:00
|
|
|
if ( !(skb->data[0] & 1) &&
|
|
|
|
br_port &&
|
|
|
|
memcmp(skb->data+MACADDRLEN, padapter->br_mac, MACADDRLEN) &&
|
2015-01-28 05:14:58 +00:00
|
|
|
*((__be16 *)(skb->data+MACADDRLEN*2)) != __constant_htons(ETH_P_8021Q) &&
|
|
|
|
*((__be16 *)(skb->data+MACADDRLEN*2)) == __constant_htons(ETH_P_IP) &&
|
2014-12-11 21:15:04 +00:00
|
|
|
!memcmp(padapter->scdb_mac, skb->data+MACADDRLEN, MACADDRLEN) && padapter->scdb_entry) {
|
|
|
|
memcpy(skb->data+MACADDRLEN, GET_MY_HWADDR(padapter), MACADDRLEN);
|
|
|
|
padapter->scdb_entry->ageing_timer = jiffies;
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&padapter->br_ext_lock);
|
2013-08-03 03:16:03 +00:00
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
else
|
|
|
|
{
|
2015-01-28 05:14:58 +00:00
|
|
|
if (*((__be16 *)(skb->data+MACADDRLEN*2)) == __constant_htons(ETH_P_8021Q)) {
|
2014-12-11 21:15:04 +00:00
|
|
|
is_vlan_tag = 1;
|
|
|
|
vlan_hdr = *((unsigned short *)(skb->data+MACADDRLEN*2+2));
|
|
|
|
for (i=0; i<6; i++)
|
|
|
|
*((unsigned short *)(skb->data+MACADDRLEN*2+2-i*2)) = *((unsigned short *)(skb->data+MACADDRLEN*2-2-i*2));
|
|
|
|
skb_pull(skb, 4);
|
|
|
|
}
|
2015-02-19 21:34:32 +00:00
|
|
|
/* if SA == br_mac && skb== IP => copy SIP to br_ip ?? why */
|
2014-12-11 21:15:04 +00:00
|
|
|
if (!memcmp(skb->data+MACADDRLEN, padapter->br_mac, MACADDRLEN) &&
|
2015-01-28 05:14:58 +00:00
|
|
|
(*((__be16 *)(skb->data+MACADDRLEN*2)) == __constant_htons(ETH_P_IP)))
|
2014-12-11 21:15:04 +00:00
|
|
|
memcpy(padapter->br_ip, skb->data+WLAN_ETHHDR_LEN+12, 4);
|
|
|
|
|
2015-01-28 05:14:58 +00:00
|
|
|
if (*((__be16 *)(skb->data+MACADDRLEN*2)) == __constant_htons(ETH_P_IP)) {
|
2014-12-11 21:15:04 +00:00
|
|
|
if (memcmp(padapter->scdb_mac, skb->data+MACADDRLEN, MACADDRLEN)) {
|
|
|
|
if ((padapter->scdb_entry = (struct nat25_network_db_entry *)scdb_findEntry(padapter,
|
|
|
|
skb->data+MACADDRLEN, skb->data+WLAN_ETHHDR_LEN+12)) != NULL) {
|
|
|
|
memcpy(padapter->scdb_mac, skb->data+MACADDRLEN, MACADDRLEN);
|
|
|
|
memcpy(padapter->scdb_ip, skb->data+WLAN_ETHHDR_LEN+12, 4);
|
|
|
|
padapter->scdb_entry->ageing_timer = jiffies;
|
|
|
|
do_nat25 = 0;
|
|
|
|
}
|
2013-08-03 03:16:03 +00:00
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
else {
|
|
|
|
if (padapter->scdb_entry) {
|
|
|
|
padapter->scdb_entry->ageing_timer = jiffies;
|
|
|
|
do_nat25 = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
memset(padapter->scdb_mac, 0, MACADDRLEN);
|
|
|
|
memset(padapter->scdb_ip, 0, 4);
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&padapter->br_ext_lock);
|
2014-12-11 21:15:04 +00:00
|
|
|
if (do_nat25)
|
|
|
|
{
|
|
|
|
if (nat25_db_handle(padapter, skb, NAT25_CHECK) == 0) {
|
|
|
|
struct sk_buff *newskb;
|
|
|
|
|
|
|
|
if (is_vlan_tag) {
|
|
|
|
skb_push(skb, 4);
|
|
|
|
for (i=0; i<6; i++)
|
|
|
|
*((unsigned short *)(skb->data+i*2)) = *((unsigned short *)(skb->data+4+i*2));
|
2015-01-28 05:14:58 +00:00
|
|
|
*((__be16 *)(skb->data+MACADDRLEN*2)) = __constant_htons(ETH_P_8021Q);
|
2014-12-11 21:15:04 +00:00
|
|
|
*((unsigned short *)(skb->data+MACADDRLEN*2+2)) = vlan_hdr;
|
|
|
|
}
|
|
|
|
|
|
|
|
newskb = rtw_skb_copy(skb);
|
|
|
|
if (newskb == NULL) {
|
2015-02-19 21:34:32 +00:00
|
|
|
/* priv->ext_stats.tx_drops++; */
|
2014-12-11 21:15:04 +00:00
|
|
|
DEBUG_ERR("TX DROP: rtw_skb_copy fail!\n");
|
2015-02-19 21:34:32 +00:00
|
|
|
/* goto stop_proc; */
|
2014-12-11 21:15:04 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
rtw_skb_free(skb);
|
|
|
|
|
|
|
|
*pskb = skb = newskb;
|
|
|
|
if (is_vlan_tag) {
|
|
|
|
vlan_hdr = *((unsigned short *)(skb->data+MACADDRLEN*2+2));
|
|
|
|
for (i=0; i<6; i++)
|
|
|
|
*((unsigned short *)(skb->data+MACADDRLEN*2+2-i*2)) = *((unsigned short *)(skb->data+MACADDRLEN*2-2-i*2));
|
|
|
|
skb_pull(skb, 4);
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if (skb_is_nonlinear(skb))
|
|
|
|
DEBUG_ERR("%s(): skb_is_nonlinear!!\n", __FUNCTION__);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18))
|
|
|
|
res = skb_linearize(skb, GFP_ATOMIC);
|
2015-02-19 21:34:32 +00:00
|
|
|
#else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18)) */
|
2014-12-11 21:15:04 +00:00
|
|
|
res = skb_linearize(skb);
|
2015-02-19 21:34:32 +00:00
|
|
|
#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18)) */
|
2014-12-19 06:59:46 +00:00
|
|
|
if (res < 0) {
|
2014-12-11 21:15:04 +00:00
|
|
|
DEBUG_ERR("TX DROP: skb_linearize fail!\n");
|
2015-02-19 21:34:32 +00:00
|
|
|
/* goto free_and_stop; */
|
2014-12-11 21:15:04 +00:00
|
|
|
return -1;
|
2013-08-03 03:16:03 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
res = nat25_db_handle(padapter, skb, NAT25_INSERT);
|
|
|
|
if (res < 0) {
|
|
|
|
if (res == -2) {
|
2015-02-19 21:34:32 +00:00
|
|
|
/* priv->ext_stats.tx_drops++; */
|
2014-12-11 21:15:04 +00:00
|
|
|
DEBUG_ERR("TX DROP: nat25_db_handle fail!\n");
|
2015-02-19 21:34:32 +00:00
|
|
|
/* goto free_and_stop; */
|
2014-12-11 21:15:04 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
2015-02-19 21:34:32 +00:00
|
|
|
/* we just print warning message and let it go */
|
|
|
|
/* DEBUG_WARN("%s()-%d: nat25_db_handle INSERT Warning!\n", __FUNCTION__, __LINE__); */
|
|
|
|
/* return -1; return -1 will cause system crash on 2011/08/30! */
|
2014-12-11 21:15:04 +00:00
|
|
|
return 0;
|
2013-08-03 03:16:03 +00:00
|
|
|
}
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
memcpy(skb->data+MACADDRLEN, GET_MY_HWADDR(padapter), MACADDRLEN);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
dhcp_flag_bcast(padapter, skb);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if (is_vlan_tag) {
|
|
|
|
skb_push(skb, 4);
|
|
|
|
for (i=0; i<6; i++)
|
|
|
|
*((unsigned short *)(skb->data+i*2)) = *((unsigned short *)(skb->data+4+i*2));
|
2015-01-28 05:14:58 +00:00
|
|
|
*((__be16 *)(skb->data+MACADDRLEN*2)) = __constant_htons(ETH_P_8021Q);
|
2014-12-11 21:15:04 +00:00
|
|
|
*((unsigned short *)(skb->data+MACADDRLEN*2+2)) = vlan_hdr;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-08-03 03:16:03 +00:00
|
|
|
}
|
2015-02-19 21:34:32 +00:00
|
|
|
/* check if SA is equal to our MAC */
|
2014-12-11 21:15:04 +00:00
|
|
|
if (memcmp(skb->data+MACADDRLEN, GET_MY_HWADDR(padapter), MACADDRLEN)) {
|
2015-02-19 21:34:32 +00:00
|
|
|
/* priv->ext_stats.tx_drops++; */
|
2014-12-11 21:15:04 +00:00
|
|
|
DEBUG_ERR("TX DROP: untransformed frame SA:%02X%02X%02X%02X%02X%02X!\n",
|
|
|
|
skb->data[6],skb->data[7],skb->data[8],skb->data[9],skb->data[10],skb->data[11]);
|
2015-02-19 21:34:32 +00:00
|
|
|
/* goto free_and_stop; */
|
2013-05-08 21:45:39 +00:00
|
|
|
return -1;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2015-02-19 21:34:32 +00:00
|
|
|
#endif /* CONFIG_BR_EXT */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
u32 rtw_get_ff_hwaddr(struct xmit_frame *pxmitframe)
|
|
|
|
{
|
|
|
|
u32 addr;
|
2014-12-19 06:59:46 +00:00
|
|
|
struct pkt_attrib *pattrib = &pxmitframe->attrib;
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
switch(pattrib->qsel)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
case 3:
|
|
|
|
addr = BE_QUEUE_INX;
|
2014-12-19 06:59:46 +00:00
|
|
|
break;
|
2014-12-11 21:15:04 +00:00
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
addr = BK_QUEUE_INX;
|
2014-12-19 06:59:46 +00:00
|
|
|
break;
|
2014-12-11 21:15:04 +00:00
|
|
|
case 4:
|
|
|
|
case 5:
|
|
|
|
addr = VI_QUEUE_INX;
|
2014-12-19 06:59:46 +00:00
|
|
|
break;
|
2014-12-11 21:15:04 +00:00
|
|
|
case 6:
|
|
|
|
case 7:
|
|
|
|
addr = VO_QUEUE_INX;
|
|
|
|
break;
|
|
|
|
case 0x10:
|
|
|
|
addr = BCN_QUEUE_INX;
|
|
|
|
break;
|
2015-02-19 21:34:32 +00:00
|
|
|
case 0x11:/* BC/MC in PS (HIQ) */
|
2014-12-11 21:15:04 +00:00
|
|
|
addr = HIGH_QUEUE_INX;
|
|
|
|
break;
|
|
|
|
case 0x12:
|
|
|
|
default:
|
|
|
|
addr = MGT_QUEUE_INX;
|
2014-12-19 06:59:46 +00:00
|
|
|
break;
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return addr;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
static void do_queue_select(struct adapter *padapter, struct pkt_attrib *pattrib)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
u8 qsel;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
qsel = pattrib->priority;
|
2014-12-11 21:15:04 +00:00
|
|
|
RT_TRACE(_module_rtl871x_xmit_c_,_drv_info_,("### do_queue_select priority=%d ,qsel = %d\n",pattrib->priority ,qsel));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pattrib->qsel = qsel;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The main transmit(tx) entry
|
|
|
|
*
|
|
|
|
* Return
|
|
|
|
* 1 enqueue
|
|
|
|
* 0 success, hardware will handle this xmit frame(packet)
|
|
|
|
* <0 fail
|
|
|
|
*/
|
2014-12-17 23:13:53 +00:00
|
|
|
s32 rtw_xmit(struct adapter *padapter, _pkt **ppkt)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
static u32 start = 0;
|
|
|
|
static u32 drop_cnt = 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
|
|
|
|
struct xmit_frame *pxmitframe = NULL;
|
2014-12-11 21:15:04 +00:00
|
|
|
#ifdef CONFIG_BR_EXT
|
2013-05-08 21:45:39 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
|
|
|
void *br_port = NULL;
|
2015-02-19 21:34:32 +00:00
|
|
|
#endif /* CONFIG_BR_EXT */
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
s32 res;
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if (start == 0)
|
|
|
|
start = rtw_get_current_time();
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitframe = rtw_alloc_xmitframe(pxmitpriv);
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
if (rtw_get_passing_time_ms(start) > 2000) {
|
|
|
|
if (drop_cnt)
|
|
|
|
DBG_871X("DBG_TX_DROP_FRAME %s no more pxmitframe, drop_cnt:%u\n", __FUNCTION__, drop_cnt);
|
|
|
|
start = rtw_get_current_time();
|
|
|
|
drop_cnt = 0;
|
|
|
|
}
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
if (pxmitframe == NULL) {
|
2014-12-11 21:15:04 +00:00
|
|
|
drop_cnt ++;
|
2013-05-08 21:45:39 +00:00
|
|
|
RT_TRACE(_module_xmit_osdep_c_, _drv_err_, ("rtw_xmit: no more pxmitframe\n"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
#ifdef CONFIG_BR_EXT
|
|
|
|
|
|
|
|
#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 35))
|
|
|
|
br_port = padapter->pnetdev->br_port;
|
2015-02-19 21:34:32 +00:00
|
|
|
#else /* (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 35)) */
|
2013-05-08 21:45:39 +00:00
|
|
|
rcu_read_lock();
|
|
|
|
br_port = rcu_dereference(padapter->pnetdev->rx_handler_data);
|
|
|
|
rcu_read_unlock();
|
2015-02-19 21:34:32 +00:00
|
|
|
#endif /* (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 35)) */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if( br_port && check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_ADHOC_STATE) == true)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
res = rtw_br_client_tx(padapter, ppkt);
|
2014-12-11 21:15:04 +00:00
|
|
|
if (res == -1)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_free_xmitframe(pxmitpriv, pxmitframe);
|
|
|
|
return -1;
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
#endif /* CONFIG_BR_EXT */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
res = update_attrib(padapter, *ppkt, &pxmitframe->attrib);
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if (res == _FAIL) {
|
2013-05-08 21:45:39 +00:00
|
|
|
RT_TRACE(_module_xmit_osdep_c_, _drv_err_, ("rtw_xmit: update attrib fail\n"));
|
2014-12-11 21:15:04 +00:00
|
|
|
#ifdef DBG_TX_DROP_FRAME
|
|
|
|
DBG_871X("DBG_TX_DROP_FRAME %s update attrib fail\n", __FUNCTION__);
|
|
|
|
#endif
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_free_xmitframe(pxmitpriv, pxmitframe);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
pxmitframe->pkt = *ppkt;
|
|
|
|
|
|
|
|
rtw_led_control(padapter, LED_CTL_TX);
|
|
|
|
|
|
|
|
do_queue_select(padapter, &pxmitframe->attrib);
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
#ifdef CONFIG_AP_MODE
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&pxmitpriv->lock);
|
2014-12-29 02:13:24 +00:00
|
|
|
if(xmitframe_enqueue_for_sleeping_sta(padapter, pxmitframe) == true)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&pxmitpriv->lock);
|
2014-12-19 06:59:46 +00:00
|
|
|
return 1;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&pxmitpriv->lock);
|
2013-05-08 21:45:39 +00:00
|
|
|
#endif
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if (rtw_hal_xmit(padapter, pxmitframe) == false)
|
2013-05-08 21:45:39 +00:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-03-04 21:31:57 +00:00
|
|
|
#if defined(CONFIG_AP_MODE)
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
sint xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_frame *pxmitframe)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-29 02:13:24 +00:00
|
|
|
sint ret=false;
|
2014-12-11 21:15:04 +00:00
|
|
|
struct sta_info *psta=NULL;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct sta_priv *pstapriv = &padapter->stapriv;
|
|
|
|
struct pkt_attrib *pattrib = &pxmitframe->attrib;
|
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2014-12-11 21:15:04 +00:00
|
|
|
sint bmcst = IS_MCAST(pattrib->ra);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == false)
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if(pattrib->psta)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
psta = pattrib->psta;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
else
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
DBG_871X("%s, call rtw_get_stainfo()\n", __func__);
|
|
|
|
psta=rtw_get_stainfo(pstapriv, pattrib->ra);
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if(psta==NULL)
|
|
|
|
{
|
|
|
|
DBG_871X("%s, psta==NUL\n", __func__);
|
2014-12-29 02:13:24 +00:00
|
|
|
return false;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(!(psta->state &_FW_LINKED))
|
|
|
|
{
|
|
|
|
DBG_871X("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, psta->state);
|
2014-12-29 02:13:24 +00:00
|
|
|
return false;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(pattrib->triggered==1)
|
|
|
|
{
|
2015-02-19 21:34:32 +00:00
|
|
|
/* DBG_871X("directly xmit pspoll_triggered packet\n"); */
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* pattrib->triggered=0; */
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
if(bmcst)
|
2015-02-19 21:34:32 +00:00
|
|
|
pattrib->qsel = 0x11;/* HIQ */
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if(bmcst)
|
|
|
|
{
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&psta->sleep_q.lock);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
if(pstapriv->sta_dz_bitmap)/* if anyone sta is in ps mode */
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_list_delete(&pxmitframe->list);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_list_insert_tail(&pxmitframe->list, get_list_head(&psta->sleep_q));
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
psta->sleepq_len++;
|
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
pstapriv->tim_bitmap |= BIT(0);/* */
|
2013-05-08 21:45:39 +00:00
|
|
|
pstapriv->sta_dz_bitmap |= BIT(0);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
update_beacon(padapter, _TIM_IE_, NULL, false);/* tx bc/mc packets after upate bcn */
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
ret = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&psta->sleep_q.lock);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&psta->sleep_q.lock);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if(psta->state&WIFI_SLEEP_STATE)
|
|
|
|
{
|
|
|
|
u8 wmmps_ac=0;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
if(pstapriv->sta_dz_bitmap&BIT(psta->aid))
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_list_delete(&pxmitframe->list);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
/* spin_lock_bh(&psta->sleep_q.lock); */
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_list_insert_tail(&pxmitframe->list, get_list_head(&psta->sleep_q));
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
psta->sleepq_len++;
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
switch(pattrib->priority)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
wmmps_ac = psta->uapsd_bk&BIT(0);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
case 5:
|
|
|
|
wmmps_ac = psta->uapsd_vi&BIT(0);
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
case 7:
|
|
|
|
wmmps_ac = psta->uapsd_vo&BIT(0);
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
case 3:
|
|
|
|
default:
|
|
|
|
wmmps_ac = psta->uapsd_be&BIT(0);
|
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if(wmmps_ac)
|
2013-05-08 21:45:39 +00:00
|
|
|
psta->sleepq_ac_len++;
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if(((psta->has_legacy_ac) && (!wmmps_ac)) ||((!psta->has_legacy_ac)&&(wmmps_ac)))
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pstapriv->tim_bitmap |= BIT(psta->aid);
|
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* DBG_871X("enqueue, sq_len=%d, tim=%x\n", psta->sleepq_len, pstapriv->tim_bitmap); */
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
if(psta->sleepq_len==1)
|
|
|
|
{
|
2015-02-19 21:34:32 +00:00
|
|
|
/* DBG_871X("sleepq_len==1, update BCNTIM\n"); */
|
|
|
|
/* upate BCN for TIM IE */
|
2014-12-29 02:13:24 +00:00
|
|
|
update_beacon(padapter, _TIM_IE_, NULL, false);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
/* spin_unlock_bh(&psta->sleep_q.lock); */
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* if(psta->sleepq_len > (NR_XMITFRAME>>3)) */
|
|
|
|
/* */
|
|
|
|
/* wakeup_sta_to_xmit(padapter, psta); */
|
|
|
|
/* */
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
ret = true;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&psta->sleep_q.lock);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return ret;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
static void dequeue_xmitframes_to_sleeping_queue(struct adapter *padapter, struct sta_info *psta, _queue *pframequeue)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
sint ret;
|
|
|
|
_list *plist, *phead;
|
2013-05-08 21:45:39 +00:00
|
|
|
u8 ac_index;
|
|
|
|
struct tx_servq *ptxservq;
|
|
|
|
struct pkt_attrib *pattrib;
|
2014-12-19 06:59:46 +00:00
|
|
|
struct xmit_frame *pxmitframe;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct hw_xmit *phwxmits = padapter->xmitpriv.hwxmits;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
phead = get_list_head(pframequeue);
|
|
|
|
plist = get_next(phead);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
while (rtw_end_of_queue_search(phead, plist) == false)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitframe = LIST_CONTAINOR(plist, struct xmit_frame, list);
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
plist = get_next(plist);
|
|
|
|
|
|
|
|
ret = xmitframe_enqueue_for_sleeping_sta(padapter, pxmitframe);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if(true == ret)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
pattrib = &pxmitframe->attrib;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
ptxservq = rtw_get_sta_pending(padapter, psta, pattrib->priority, (u8 *)(&ac_index));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
ptxservq->qcnt--;
|
|
|
|
phwxmits[ac_index].accnt--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-02-19 21:34:32 +00:00
|
|
|
/* DBG_871X("xmitframe_enqueue_for_sleeping_sta return false\n"); */
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void stop_sta_xmit(struct adapter *padapter, struct sta_info *psta)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
struct sta_info *psta_bmc;
|
|
|
|
struct sta_xmit_priv *pstaxmitpriv;
|
2014-12-19 06:59:46 +00:00
|
|
|
struct sta_priv *pstapriv = &padapter->stapriv;
|
|
|
|
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pstaxmitpriv = &psta->sta_xmitpriv;
|
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* for BC/MC Frames */
|
2013-05-08 21:45:39 +00:00
|
|
|
psta_bmc = rtw_get_bcmc_stainfo(padapter);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&pxmitpriv->lock);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
psta->state |= WIFI_SLEEP_STATE;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pstapriv->sta_dz_bitmap |= BIT(psta->aid);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->vo_q.sta_pending);
|
|
|
|
rtw_list_delete(&(pstaxmitpriv->vo_q.tx_pending));
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->vi_q.sta_pending);
|
|
|
|
rtw_list_delete(&(pstaxmitpriv->vi_q.tx_pending));
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->be_q.sta_pending);
|
|
|
|
rtw_list_delete(&(pstaxmitpriv->be_q.tx_pending));
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->bk_q.sta_pending);
|
|
|
|
rtw_list_delete(&(pstaxmitpriv->bk_q.tx_pending));
|
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* for BC/MC Frames */
|
2013-05-08 21:45:39 +00:00
|
|
|
pstaxmitpriv = &psta_bmc->sta_xmitpriv;
|
|
|
|
dequeue_xmitframes_to_sleeping_queue(padapter, psta_bmc, &pstaxmitpriv->be_q.sta_pending);
|
|
|
|
rtw_list_delete(&(pstaxmitpriv->be_q.tx_pending));
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&pxmitpriv->lock);
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
u8 update_mask=0, wmmps_ac=0;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct sta_info *psta_bmc;
|
2014-12-11 21:15:04 +00:00
|
|
|
_list *xmitframe_plist, *xmitframe_phead;
|
|
|
|
struct xmit_frame *pxmitframe=NULL;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct sta_priv *pstapriv = &padapter->stapriv;
|
2014-12-11 21:15:04 +00:00
|
|
|
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
psta_bmc = rtw_get_bcmc_stainfo(padapter);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&pxmitpriv->lock);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
xmitframe_phead = get_list_head(&psta->sleep_q);
|
|
|
|
xmitframe_plist = get_next(xmitframe_phead);
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
while ((rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist)) == false)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list);
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
xmitframe_plist = get_next(xmitframe_plist);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
rtw_list_delete(&pxmitframe->list);
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
switch(pxmitframe->attrib.priority)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
wmmps_ac = psta->uapsd_bk&BIT(1);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
case 5:
|
|
|
|
wmmps_ac = psta->uapsd_vi&BIT(1);
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
case 7:
|
|
|
|
wmmps_ac = psta->uapsd_vo&BIT(1);
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
case 3:
|
|
|
|
default:
|
|
|
|
wmmps_ac = psta->uapsd_be&BIT(1);
|
2014-12-19 06:59:46 +00:00
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
psta->sleepq_len--;
|
2014-12-11 21:15:04 +00:00
|
|
|
if(psta->sleepq_len>0)
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitframe->attrib.mdata = 1;
|
|
|
|
else
|
|
|
|
pxmitframe->attrib.mdata = 0;
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if(wmmps_ac)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
psta->sleepq_ac_len--;
|
2014-12-11 21:15:04 +00:00
|
|
|
if(psta->sleepq_ac_len>0)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitframe->attrib.mdata = 1;
|
|
|
|
pxmitframe->attrib.eosp = 0;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitframe->attrib.mdata = 0;
|
|
|
|
pxmitframe->attrib.eosp = 1;
|
|
|
|
}
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitframe->attrib.triggered = 1;
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
/*
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&psta->sleep_q.lock);
|
2014-12-29 02:13:24 +00:00
|
|
|
if(rtw_hal_xmit(padapter, pxmitframe) == true)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_os_xmit_complete(padapter, pxmitframe);
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&psta->sleep_q.lock);
|
2014-12-11 21:15:04 +00:00
|
|
|
*/
|
|
|
|
rtw_hal_xmitframe_enqueue(padapter, pxmitframe);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* for BC/MC Frames */
|
2014-12-11 21:15:04 +00:00
|
|
|
if(!psta_bmc)
|
|
|
|
goto _exit;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
if((pstapriv->sta_dz_bitmap&0xfffe) == 0x0)/* no any sta in ps mode */
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
xmitframe_phead = get_list_head(&psta_bmc->sleep_q);
|
|
|
|
xmitframe_plist = get_next(xmitframe_phead);
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
while ((rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist)) == false)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list);
|
|
|
|
|
|
|
|
xmitframe_plist = get_next(xmitframe_plist);
|
|
|
|
|
|
|
|
rtw_list_delete(&pxmitframe->list);
|
|
|
|
|
|
|
|
psta_bmc->sleepq_len--;
|
2014-12-11 21:15:04 +00:00
|
|
|
if(psta_bmc->sleepq_len>0)
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitframe->attrib.mdata = 1;
|
|
|
|
else
|
|
|
|
pxmitframe->attrib.mdata = 0;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitframe->attrib.triggered = 1;
|
2014-12-11 21:15:04 +00:00
|
|
|
/*
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&psta_bmc->sleep_q.lock);
|
2014-12-29 02:13:24 +00:00
|
|
|
if(rtw_hal_xmit(padapter, pxmitframe) == true)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_os_xmit_complete(padapter, pxmitframe);
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&psta_bmc->sleep_q.lock);
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
*/
|
|
|
|
rtw_hal_xmitframe_enqueue(padapter, pxmitframe);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if(psta_bmc->sleepq_len==0)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pstapriv->tim_bitmap &= ~BIT(0);
|
|
|
|
pstapriv->sta_dz_bitmap &= ~BIT(0);
|
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* DBG_871X("wakeup to xmit, qlen==0, update_BCNTIM, tim=%x\n", pstapriv->tim_bitmap); */
|
|
|
|
/* upate BCN for TIM IE */
|
|
|
|
/* update_BCNTIM(padapter); */
|
2013-05-08 21:45:39 +00:00
|
|
|
update_mask |= BIT(1);
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
if(psta->sleepq_len==0)
|
|
|
|
{
|
|
|
|
pstapriv->tim_bitmap &= ~BIT(psta->aid);
|
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* DBG_871X("wakeup to xmit, qlen==0, update_BCNTIM, tim=%x\n", pstapriv->tim_bitmap); */
|
|
|
|
/* upate BCN for TIM IE */
|
|
|
|
/* update_BCNTIM(padapter); */
|
2014-12-11 21:15:04 +00:00
|
|
|
update_mask = BIT(0);
|
|
|
|
|
|
|
|
if(psta->state&WIFI_SLEEP_STATE)
|
|
|
|
psta->state ^= WIFI_SLEEP_STATE;
|
|
|
|
|
|
|
|
if(psta->state & WIFI_STA_ALIVE_CHK_STATE)
|
|
|
|
{
|
|
|
|
psta->expire_to = pstapriv->expire_to;
|
|
|
|
psta->state ^= WIFI_STA_ALIVE_CHK_STATE;
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
pstapriv->sta_dz_bitmap &= ~BIT(psta->aid);
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
_exit:
|
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
/* spin_unlock_bh(&psta_bmc->sleep_q.lock); */
|
|
|
|
spin_unlock_bh(&pxmitpriv->lock);
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if(update_mask)
|
|
|
|
{
|
2015-02-19 21:34:32 +00:00
|
|
|
/* update_BCNTIM(padapter); */
|
|
|
|
/* printk("%s => call update_beacon\n",__FUNCTION__); */
|
2014-12-29 02:13:24 +00:00
|
|
|
update_beacon(padapter, _TIM_IE_, NULL, false);
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 23:13:53 +00:00
|
|
|
void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *psta)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
u8 wmmps_ac=0;
|
|
|
|
_list *xmitframe_plist, *xmitframe_phead;
|
|
|
|
struct xmit_frame *pxmitframe=NULL;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct sta_priv *pstapriv = &padapter->stapriv;
|
2014-12-11 21:15:04 +00:00
|
|
|
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
/* spin_lock_bh(&psta->sleep_q.lock); */
|
|
|
|
spin_lock_bh(&pxmitpriv->lock);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
xmitframe_phead = get_list_head(&psta->sleep_q);
|
|
|
|
xmitframe_plist = get_next(xmitframe_phead);
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
while ((rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist)) == false)
|
2014-12-19 06:59:46 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list);
|
|
|
|
|
|
|
|
xmitframe_plist = get_next(xmitframe_plist);
|
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
switch(pxmitframe->attrib.priority) {
|
2014-12-11 21:15:04 +00:00
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
wmmps_ac = psta->uapsd_bk&BIT(1);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
case 5:
|
|
|
|
wmmps_ac = psta->uapsd_vi&BIT(1);
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
case 7:
|
|
|
|
wmmps_ac = psta->uapsd_vo&BIT(1);
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
case 3:
|
|
|
|
default:
|
|
|
|
wmmps_ac = psta->uapsd_be&BIT(1);
|
2014-12-19 06:59:46 +00:00
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if(!wmmps_ac)
|
2013-05-08 21:45:39 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
rtw_list_delete(&pxmitframe->list);
|
|
|
|
|
|
|
|
psta->sleepq_len--;
|
|
|
|
psta->sleepq_ac_len--;
|
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
if(psta->sleepq_ac_len>0) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitframe->attrib.mdata = 1;
|
|
|
|
pxmitframe->attrib.eosp = 0;
|
2015-03-06 17:54:48 +00:00
|
|
|
} else {
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitframe->attrib.mdata = 0;
|
|
|
|
pxmitframe->attrib.eosp = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
pxmitframe->attrib.triggered = 1;
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
rtw_hal_xmitframe_enqueue(padapter, pxmitframe);
|
|
|
|
|
|
|
|
if((psta->sleepq_ac_len==0) && (!psta->has_legacy_ac) && (wmmps_ac))
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
pstapriv->tim_bitmap &= ~BIT(psta->aid);
|
|
|
|
|
2015-02-19 21:34:32 +00:00
|
|
|
/* upate BCN for TIM IE */
|
2014-12-29 02:13:24 +00:00
|
|
|
update_beacon(padapter, _TIM_IE_, NULL, false);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&pxmitpriv->lock);
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_XMIT_THREAD_MODE
|
|
|
|
void enqueue_pending_xmitbuf(
|
|
|
|
struct xmit_priv *pxmitpriv,
|
|
|
|
struct xmit_buf *pxmitbuf)
|
|
|
|
{
|
|
|
|
_queue *pqueue;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *pri_adapter = pxmitpriv->adapter;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
pqueue = &pxmitpriv->pending_xmitbuf_queue;
|
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&pqueue->lock, &irql);
|
2014-12-11 21:15:04 +00:00
|
|
|
rtw_list_delete(&pxmitbuf->list);
|
|
|
|
rtw_list_insert_tail(&pxmitbuf->list, get_list_head(pqueue));
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&pqueue->lock, &irql);
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
_rtw_up_sema(&(pri_adapter->xmitpriv.xmit_sema));
|
|
|
|
}
|
|
|
|
|
|
|
|
struct xmit_buf* dequeue_pending_xmitbuf(
|
|
|
|
struct xmit_priv *pxmitpriv)
|
|
|
|
{
|
|
|
|
struct xmit_buf *pxmitbuf;
|
|
|
|
_queue *pqueue;
|
|
|
|
|
|
|
|
|
|
|
|
pxmitbuf = NULL;
|
|
|
|
pqueue = &pxmitpriv->pending_xmitbuf_queue;
|
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&pqueue->lock, &irql);
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if (_rtw_queue_empty(pqueue) == false)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
_list *plist, *phead;
|
|
|
|
|
|
|
|
phead = get_list_head(pqueue);
|
|
|
|
plist = get_next(phead);
|
|
|
|
pxmitbuf = LIST_CONTAINOR(plist, struct xmit_buf, list);
|
|
|
|
rtw_list_delete(&pxmitbuf->list);
|
|
|
|
}
|
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&pqueue->lock, &irql);
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
return pxmitbuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct xmit_buf* dequeue_pending_xmitbuf_under_survey(
|
|
|
|
struct xmit_priv *pxmitpriv)
|
|
|
|
{
|
|
|
|
struct xmit_buf *pxmitbuf;
|
|
|
|
struct xmit_frame *pxmitframe;
|
|
|
|
_queue *pqueue;
|
|
|
|
|
|
|
|
|
|
|
|
pxmitbuf = NULL;
|
|
|
|
pqueue = &pxmitpriv->pending_xmitbuf_queue;
|
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_lock_bh(&pqueue->lock, &irql);
|
2014-12-11 21:15:04 +00:00
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if (_rtw_queue_empty(pqueue) == false)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
_list *plist, *phead;
|
|
|
|
u8 type;
|
|
|
|
|
|
|
|
phead = get_list_head(pqueue);
|
|
|
|
plist = phead;
|
|
|
|
do {
|
|
|
|
plist = get_next(plist);
|
|
|
|
if (plist == phead) break;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
pxmitbuf = LIST_CONTAINOR(plist, struct xmit_buf, list);
|
|
|
|
|
|
|
|
pxmitframe = (struct xmit_frame*)pxmitbuf->priv_data;
|
|
|
|
if(pxmitframe)
|
|
|
|
type = GetFrameSubType(pxmitbuf->pbuf + TXDESC_SIZE + pxmitframe->pkt_offset * PACKET_OFFSET_SZ);
|
|
|
|
else
|
|
|
|
DBG_871X("%s, !!!ERROR!!! For USB, TODO ITEM \n", __FUNCTION__);
|
|
|
|
|
|
|
|
if ((type == WIFI_PROBEREQ) ||
|
|
|
|
(type == WIFI_DATA_NULL) ||
|
|
|
|
(type == WIFI_QOS_DATA_NULL))
|
|
|
|
{
|
|
|
|
rtw_list_delete(&pxmitbuf->list);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pxmitbuf = NULL;
|
|
|
|
} while (1);
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
|
|
|
|
2015-03-06 17:54:48 +00:00
|
|
|
spin_unlock_bh(&pqueue->lock, &irql);
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
return pxmitbuf;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
sint check_pending_xmitbuf(
|
|
|
|
struct xmit_priv *pxmitpriv)
|
|
|
|
{
|
|
|
|
_queue *pqueue;
|
|
|
|
|
|
|
|
pqueue = &pxmitpriv->pending_xmitbuf_queue;
|
|
|
|
|
2014-12-29 02:13:24 +00:00
|
|
|
if(_rtw_queue_empty(pqueue) == false)
|
|
|
|
return true;
|
2014-12-11 21:15:04 +00:00
|
|
|
else
|
2014-12-29 02:13:24 +00:00
|
|
|
return false;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
thread_return rtw_xmit_thread(thread_context context)
|
|
|
|
{
|
|
|
|
s32 err;
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *padapter;
|
2014-12-11 21:15:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
err = _SUCCESS;
|
|
|
|
padapter = (PADAPTER)context;
|
|
|
|
|
|
|
|
thread_enter("RTW_XMIT_THREAD");
|
|
|
|
|
|
|
|
do {
|
|
|
|
err = rtw_hal_xmit_thread_handler(padapter);
|
|
|
|
flush_signals_thread();
|
|
|
|
} while (_SUCCESS == err);
|
|
|
|
|
|
|
|
_rtw_up_sema(&padapter->xmitpriv.terminate_xmitthread_sema);
|
|
|
|
|
|
|
|
thread_exit();
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
void rtw_sctx_init(struct submit_ctx *sctx, int timeout_ms)
|
|
|
|
{
|
|
|
|
sctx->timeout_ms = timeout_ms;
|
2014-12-11 21:15:04 +00:00
|
|
|
sctx->submit_time= rtw_get_current_time();
|
2013-05-08 21:45:39 +00:00
|
|
|
init_completion(&sctx->done);
|
|
|
|
sctx->status = RTW_SCTX_SUBMITTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
int rtw_sctx_wait(struct submit_ctx *sctx)
|
|
|
|
{
|
|
|
|
int ret = _FAIL;
|
2014-12-19 06:59:46 +00:00
|
|
|
unsigned long expire;
|
2013-05-08 21:45:39 +00:00
|
|
|
int status = 0;
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
expire= sctx->timeout_ms ? msecs_to_jiffies(sctx->timeout_ms) : MAX_SCHEDULE_TIMEOUT;
|
2013-05-08 21:45:39 +00:00
|
|
|
if (!wait_for_completion_timeout(&sctx->done, expire)) {
|
|
|
|
/* timeout, do something?? */
|
|
|
|
status = RTW_SCTX_DONE_TIMEOUT;
|
2014-12-19 06:59:46 +00:00
|
|
|
DBG_871X("%s timeout\n", __func__);
|
2013-05-08 21:45:39 +00:00
|
|
|
} else {
|
|
|
|
status = sctx->status;
|
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if (status == RTW_SCTX_DONE_SUCCESS) {
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = _SUCCESS;
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-01-28 05:14:58 +00:00
|
|
|
static bool rtw_sctx_chk_waring_status(int status)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
switch(status) {
|
2013-05-08 21:45:39 +00:00
|
|
|
case RTW_SCTX_DONE_UNKNOWN:
|
|
|
|
case RTW_SCTX_DONE_BUF_ALLOC:
|
|
|
|
case RTW_SCTX_DONE_BUF_FREE:
|
|
|
|
|
|
|
|
case RTW_SCTX_DONE_DRV_STOP:
|
|
|
|
case RTW_SCTX_DONE_DEV_REMOVE:
|
2014-12-29 02:13:24 +00:00
|
|
|
return true;
|
2013-05-08 21:45:39 +00:00
|
|
|
default:
|
2014-12-29 02:13:24 +00:00
|
|
|
return false;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void rtw_sctx_done_err(struct submit_ctx **sctx, int status)
|
|
|
|
{
|
|
|
|
if (*sctx) {
|
|
|
|
if (rtw_sctx_chk_waring_status(status))
|
2014-12-11 21:15:04 +00:00
|
|
|
DBG_871X("%s status:%d\n", __func__, status);
|
2013-05-08 21:45:39 +00:00
|
|
|
(*sctx)->status = status;
|
|
|
|
complete(&((*sctx)->done));
|
|
|
|
*sctx = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void rtw_sctx_done(struct submit_ctx **sctx)
|
|
|
|
{
|
|
|
|
rtw_sctx_done_err(sctx, RTW_SCTX_DONE_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
#ifdef CONFIG_DETECT_C2H_BY_POLLING
|
2014-12-17 23:13:53 +00:00
|
|
|
s32 c2h_evt_hdl(struct adapter *adapter, struct c2h_evt_hdr *c2h_evt, c2h_id_filter filter);
|
2014-12-11 21:15:04 +00:00
|
|
|
#endif
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
int rtw_ack_tx_wait(struct xmit_priv *pxmitpriv, u32 timeout_ms)
|
|
|
|
{
|
2014-12-11 21:15:04 +00:00
|
|
|
#ifdef CONFIG_DETECT_C2H_BY_POLLING
|
2014-12-17 23:13:53 +00:00
|
|
|
struct adapter *adapter = container_of(pxmitpriv, struct adapter, xmitpriv);
|
2014-12-11 21:15:04 +00:00
|
|
|
c2h_id_filter ccx_id_filter = rtw_hal_c2h_id_filter_ccx(adapter);
|
|
|
|
struct submit_ctx *pack_tx_ops = &pxmitpriv->ack_tx_ops;
|
|
|
|
u8 check_c2hcmd;
|
|
|
|
u8 check_ccx;
|
|
|
|
int ret = _FAIL;
|
|
|
|
|
|
|
|
pack_tx_ops->submit_time = rtw_get_current_time();
|
|
|
|
pack_tx_ops->timeout_ms = timeout_ms;
|
|
|
|
pack_tx_ops->status = RTW_SCTX_SUBMITTED;
|
|
|
|
|
|
|
|
do {
|
|
|
|
rtw_msleep_os(10);
|
2015-02-19 21:34:32 +00:00
|
|
|
/* check_c2hcmd = rtw_read8(adapter, 0x1AF); */
|
|
|
|
/* check_ccx = rtw_read8(adapter, 0x1A0); */
|
2014-12-11 21:15:04 +00:00
|
|
|
rtw_hal_get_hwreg(adapter, HW_VAR_C2HEVT_CLEAR, (u8 *)(&check_c2hcmd));
|
|
|
|
rtw_hal_get_hwreg(adapter, HW_VAR_C2HEVT_MSG_NORMAL, (u8 *)(&check_ccx));
|
|
|
|
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if (check_c2hcmd != 0)
|
|
|
|
{
|
|
|
|
if (check_c2hcmd != 0xFF)
|
|
|
|
{
|
2014-12-19 06:59:46 +00:00
|
|
|
c2h_evt_clear(adapter);
|
2014-12-11 21:15:04 +00:00
|
|
|
}
|
2014-12-29 02:13:24 +00:00
|
|
|
else if (ccx_id_filter(check_ccx & 0x0F) == true)
|
2014-12-11 21:15:04 +00:00
|
|
|
{
|
|
|
|
c2h_evt_hdl(adapter, NULL, ccx_id_filter);
|
|
|
|
if (pack_tx_ops->status != RTW_SCTX_SUBMITTED)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (adapter->bDriverStopped) {
|
|
|
|
pack_tx_ops->status = RTW_SCTX_DONE_DRV_STOP;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (adapter->bSurpriseRemoved) {
|
|
|
|
pack_tx_ops->status = RTW_SCTX_DONE_DEV_REMOVE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-12-19 06:59:46 +00:00
|
|
|
}
|
2014-12-11 21:15:04 +00:00
|
|
|
} while (rtw_get_passing_time_ms(pack_tx_ops->submit_time) < timeout_ms);
|
|
|
|
|
|
|
|
if (pack_tx_ops->status == RTW_SCTX_SUBMITTED) {
|
|
|
|
pack_tx_ops->status = RTW_SCTX_DONE_TIMEOUT;
|
|
|
|
DBG_871X("%s timeout\n", __func__);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pack_tx_ops->status == RTW_SCTX_DONE_SUCCESS)
|
|
|
|
ret = _SUCCESS;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
#else
|
2013-05-08 21:45:39 +00:00
|
|
|
struct submit_ctx *pack_tx_ops = &pxmitpriv->ack_tx_ops;
|
|
|
|
|
|
|
|
pack_tx_ops->submit_time = rtw_get_current_time();
|
|
|
|
pack_tx_ops->timeout_ms = timeout_ms;
|
|
|
|
pack_tx_ops->status = RTW_SCTX_SUBMITTED;
|
|
|
|
|
|
|
|
return rtw_sctx_wait(pack_tx_ops);
|
2014-12-11 21:15:04 +00:00
|
|
|
#endif
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void rtw_ack_tx_done(struct xmit_priv *pxmitpriv, int status)
|
|
|
|
{
|
|
|
|
struct submit_ctx *pack_tx_ops = &pxmitpriv->ack_tx_ops;
|
2014-12-19 06:59:46 +00:00
|
|
|
|
2014-12-11 21:15:04 +00:00
|
|
|
if (pxmitpriv->ack_tx) {
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_sctx_done_err(&pack_tx_ops, status);
|
2014-12-11 21:15:04 +00:00
|
|
|
} else {
|
|
|
|
DBG_871X("%s ack_tx not set\n", __func__);
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|