2022-06-08 23:46:35 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
/* Copyright(c) 2007 - 2012 Realtek Corporation. */
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
#define _RTW_XMIT_C_
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
#include "../include/osdep_service.h"
|
|
|
|
#include "../include/drv_types.h"
|
|
|
|
#include "../include/wifi.h"
|
|
|
|
#include "../include/osdep_intf.h"
|
|
|
|
#include "../include/usb_ops.h"
|
|
|
|
#include "../include/usb_osintf.h"
|
|
|
|
#include "../include/rtl8188e_xmit.h"
|
|
|
|
#include <linux/version.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)
|
|
|
|
{
|
2014-12-01 22:31:15 +00:00
|
|
|
|
2014-12-13 05:13:40 +00:00
|
|
|
INIT_LIST_HEAD(&ptxservq->tx_pending);
|
2022-06-08 23:46:35 +00:00
|
|
|
rtw_init_queue(&ptxservq->sta_pending);
|
2013-05-08 21:45:39 +00:00
|
|
|
ptxservq->qcnt = 0;
|
2014-12-01 22:31:15 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void _rtw_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv)
|
2013-05-19 04:28:07 +00:00
|
|
|
{
|
2014-12-01 22:31:15 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
memset((unsigned char *)psta_xmitpriv, 0, sizeof(struct sta_xmit_priv));
|
2014-11-28 17:14:29 +00:00
|
|
|
spin_lock_init(&psta_xmitpriv->lock);
|
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);
|
2014-12-13 05:13:40 +00:00
|
|
|
INIT_LIST_HEAD(&psta_xmitpriv->legacy_dz);
|
|
|
|
INIT_LIST_HEAD(&psta_xmitpriv->apsd);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +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;
|
2013-08-03 03:16:03 +00:00
|
|
|
int 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;
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
/* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-11-28 17:14:29 +00:00
|
|
|
spin_lock_init(&pxmitpriv->lock);
|
2014-12-13 21:25:08 +00:00
|
|
|
sema_init(&pxmitpriv->terminate_xmitthread_sema, 0);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
/*
|
2022-06-08 23:46:35 +00:00
|
|
|
* Please insert all the queue initializaiton using rtw_init_queue below
|
|
|
|
*/
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pxmitpriv->adapter = padapter;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2022-06-08 23:46:35 +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);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
rtw_init_queue(&pxmitpriv->free_xmit_queue);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
/*
|
2022-06-08 23:46:35 +00:00
|
|
|
* Please allocate memory with the sz = (struct xmit_frame) * NR_XMITFRAME,
|
|
|
|
* and initialize free_xmit_frame below.
|
|
|
|
* Please also apply free_txobj to link_up all the xmit_frames...
|
|
|
|
*/
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
pxmitpriv->pallocated_frame_buf = vzalloc(NR_XMITFRAME * sizeof(struct xmit_frame) + 4);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!pxmitpriv->pallocated_frame_buf) {
|
2013-08-03 03:16:03 +00:00
|
|
|
pxmitpriv->pxmit_frame_buf = NULL;
|
|
|
|
res = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
2013-07-24 17:19:14 +00:00
|
|
|
pxmitpriv->pxmit_frame_buf = (u8 *)N_BYTE_ALIGMENT((size_t)(pxmitpriv->pallocated_frame_buf), 4);
|
2013-07-09 22:38:46 +00:00
|
|
|
/* pxmitpriv->pxmit_frame_buf = pxmitpriv->pallocated_frame_buf + 4 - */
|
2013-07-24 17:19:14 +00:00
|
|
|
/* ((size_t) (pxmitpriv->pallocated_frame_buf) &3); */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
pxframe = (struct xmit_frame *)pxmitpriv->pxmit_frame_buf;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
for (i = 0; i < NR_XMITFRAME; i++) {
|
2022-06-08 23:46:35 +00:00
|
|
|
INIT_LIST_HEAD(&pxframe->list);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pxframe->padapter = padapter;
|
|
|
|
pxframe->frame_tag = NULL_FRAMETAG;
|
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
pxframe->pkt = NULL;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pxframe->buf_addr = NULL;
|
|
|
|
pxframe->pxmitbuf = NULL;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
list_add_tail(&pxframe->list, &pxmitpriv->free_xmit_queue.queue);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pxframe++;
|
|
|
|
}
|
|
|
|
|
|
|
|
pxmitpriv->free_xmitframe_cnt = NR_XMITFRAME;
|
|
|
|
|
|
|
|
pxmitpriv->frag_len = MAX_FRAG_THRESHOLD;
|
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* init xmit_buf */
|
2022-06-08 23:46:35 +00:00
|
|
|
rtw_init_queue(&pxmitpriv->free_xmitbuf_queue);
|
|
|
|
rtw_init_queue(&pxmitpriv->pending_xmitbuf_queue);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
pxmitpriv->pallocated_xmitbuf = vzalloc(NR_XMITBUFF * sizeof(struct xmit_buf) + 4);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!pxmitpriv->pallocated_xmitbuf) {
|
2013-08-03 03:16:03 +00:00
|
|
|
res = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2013-07-24 17:19:14 +00:00
|
|
|
pxmitpriv->pxmitbuf = (u8 *)N_BYTE_ALIGMENT((size_t)(pxmitpriv->pallocated_xmitbuf), 4);
|
2013-07-09 22:38:46 +00:00
|
|
|
/* pxmitpriv->pxmitbuf = pxmitpriv->pallocated_xmitbuf + 4 - */
|
2013-07-24 17:19:14 +00:00
|
|
|
/* ((size_t) (pxmitpriv->pallocated_xmitbuf) &3); */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
for (i = 0; i < NR_XMITBUFF; i++) {
|
2014-12-13 05:13:40 +00:00
|
|
|
INIT_LIST_HEAD(&pxmitbuf->list);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pxmitbuf->priv_data = NULL;
|
|
|
|
pxmitbuf->padapter = padapter;
|
2013-05-26 03:02:10 +00:00
|
|
|
pxmitbuf->ext_tag = false;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
/* Tx buf allocation may fail sometimes, so sleep and retry. */
|
2013-08-03 03:16:03 +00:00
|
|
|
res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ));
|
|
|
|
if (res == _FAIL) {
|
2022-06-08 23:46:35 +00:00
|
|
|
msleep(10);
|
2013-08-03 03:16:03 +00:00
|
|
|
res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ));
|
2022-06-08 23:46:35 +00:00
|
|
|
if (res == _FAIL)
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
pxmitbuf->flags = XMIT_VO_QUEUE;
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
list_add_tail(&pxmitbuf->list, &pxmitpriv->free_xmitbuf_queue.queue);
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitbuf++;
|
|
|
|
}
|
|
|
|
|
|
|
|
pxmitpriv->free_xmitbuf_cnt = NR_XMITBUFF;
|
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* Init xmit extension buff */
|
2022-06-08 23:46:35 +00:00
|
|
|
rtw_init_queue(&pxmitpriv->free_xmit_extbuf_queue);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
pxmitpriv->pallocated_xmit_extbuf = vzalloc(num_xmit_extbuf * sizeof(struct xmit_buf) + 4);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!pxmitpriv->pallocated_xmit_extbuf) {
|
2013-08-03 03:16:03 +00:00
|
|
|
res = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2013-07-24 17:19:14 +00:00
|
|
|
pxmitpriv->pxmit_extbuf = (u8 *)N_BYTE_ALIGMENT((size_t)(pxmitpriv->pallocated_xmit_extbuf), 4);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
for (i = 0; i < num_xmit_extbuf; i++) {
|
2014-12-13 05:13:40 +00:00
|
|
|
INIT_LIST_HEAD(&pxmitbuf->list);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pxmitbuf->priv_data = NULL;
|
|
|
|
pxmitbuf->padapter = padapter;
|
2013-05-26 03:02:10 +00:00
|
|
|
pxmitbuf->ext_tag = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf, max_xmit_extbuf_size + XMITBUF_ALIGN_SZ);
|
|
|
|
if (res == _FAIL) {
|
2013-05-08 21:45:39 +00:00
|
|
|
res = _FAIL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
list_add_tail(&pxmitbuf->list, &pxmitpriv->free_xmit_extbuf_queue.queue);
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitbuf++;
|
|
|
|
}
|
|
|
|
|
|
|
|
pxmitpriv->free_xmit_extbuf_cnt = num_xmit_extbuf;
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (rtw_alloc_hwxmits(padapter)) {
|
|
|
|
res = _FAIL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_init_hwxmits(pxmitpriv->hwxmits, pxmitpriv->hwxmit_entry);
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
for (i = 0; i < 4; i++)
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitpriv->wmm_para_seq[i] = i;
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
pxmitpriv->txirp_cnt = 1;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
sema_init(&pxmitpriv->tx_retevt, 0);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-09 22:38:46 +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;
|
|
|
|
|
2013-05-26 03:02:10 +00:00
|
|
|
pxmitpriv->ack_tx = false;
|
2022-06-08 23:46:35 +00:00
|
|
|
mutex_init(&pxmitpriv->ack_tx_mutex);
|
2013-05-19 04:28:07 +00:00
|
|
|
rtw_sctx_init(&pxmitpriv->ack_tx_ops, 0);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
rtl8188eu_init_xmit_priv(padapter);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
exit:
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-08-03 03:16:03 +00:00
|
|
|
int i;
|
|
|
|
struct adapter *padapter = pxmitpriv->adapter;
|
|
|
|
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;
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!pxmitpriv->pxmit_frame_buf)
|
2014-12-01 22:31:15 +00:00
|
|
|
return;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
for (i = 0; i < NR_XMITFRAME; i++) {
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_os_xmit_complete(padapter, pxmitframe);
|
|
|
|
|
|
|
|
pxmitframe++;
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
for (i = 0; i < NR_XMITBUFF; i++) {
|
|
|
|
rtw_os_xmit_resource_free(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ));
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitbuf++;
|
|
|
|
}
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
vfree(pxmitpriv->pallocated_frame_buf);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
vfree(pxmitpriv->pallocated_xmitbuf);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf;
|
2013-08-03 03:16:03 +00:00
|
|
|
for (i = 0; i < num_xmit_extbuf; i++) {
|
|
|
|
rtw_os_xmit_resource_free(padapter, pxmitbuf, (max_xmit_extbuf_size + XMITBUF_ALIGN_SZ));
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitbuf++;
|
|
|
|
}
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
vfree(pxmitpriv->pallocated_xmit_extbuf);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
rtw_free_hwxmits(padapter);
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
mutex_destroy(&pxmitpriv->ack_tx_mutex);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +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;
|
2022-06-08 23:46:35 +00:00
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
|
|
|
struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
if (pattrib->nr_frags != 1)
|
|
|
|
sz = padapter->xmitpriv.frag_len;
|
2013-07-09 22:38:46 +00:00
|
|
|
else /* no frag */
|
2013-05-08 21:45:39 +00:00
|
|
|
sz = pattrib->last_txcmdsz;
|
|
|
|
|
2013-07-09 22:38:46 +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. */
|
2013-08-03 03:16:03 +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;
|
2013-08-03 03:16:03 +00:00
|
|
|
} else {
|
2013-05-09 04:04:25 +00:00
|
|
|
if (psta->rtsen)
|
2013-05-08 21:45:39 +00:00
|
|
|
pattrib->vcs_mode = RTS_CTS;
|
2013-05-09 04:04:25 +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;
|
|
|
|
}
|
2013-08-03 03:16:03 +00:00
|
|
|
} else {
|
|
|
|
while (true) {
|
2013-07-09 22:38:46 +00:00
|
|
|
/* IOT action */
|
2013-08-03 03:16:03 +00:00
|
|
|
if ((pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_ATHEROS) && pattrib->ampdu_en &&
|
|
|
|
(padapter->securitypriv.dot11PrivacyAlgrthm == _AES_)) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pattrib->vcs_mode = CTS_TO_SELF;
|
|
|
|
break;
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* check ERP protection */
|
2013-08-03 03:16:03 +00:00
|
|
|
if (psta->rtsen || psta->cts2self) {
|
2013-05-09 04:04:25 +00:00
|
|
|
if (psta->rtsen)
|
2013-05-08 21:45:39 +00:00
|
|
|
pattrib->vcs_mode = RTS_CTS;
|
2013-05-09 04:04:25 +00:00
|
|
|
else if (psta->cts2self)
|
2013-05-08 21:45:39 +00:00
|
|
|
pattrib->vcs_mode = CTS_TO_SELF;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* check HT op mode */
|
2013-08-03 03:16:03 +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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* check rts */
|
2013-08-03 03:16:03 +00:00
|
|
|
if (sz > padapter->registrypriv.rts_thresh) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pattrib->vcs_mode = RTS_CTS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* to do list: check MIMO power save condition. */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* check AMPDU aggregation for TXOP */
|
2013-08-03 03:16:03 +00:00
|
|
|
if (pattrib->ampdu_en) {
|
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)
|
|
|
|
{
|
2013-05-19 04:28:07 +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;*/
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pattrib->mdata = 0;
|
|
|
|
pattrib->eosp = 0;
|
2013-08-03 03:16:03 +00:00
|
|
|
pattrib->triggered = 0;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-03 03:16:03 +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;
|
2013-05-19 04:28:07 +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;
|
2013-08-03 03:16:03 +00:00
|
|
|
pattrib->sgi = psta->htpriv.sgi;
|
2013-05-26 03:02:10 +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;
|
|
|
|
|
2013-08-03 03:16:03 +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:
|
|
|
|
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;
|
2013-08-03 03:16:03 +00:00
|
|
|
s32 user_prio = 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
_rtw_open_pktfile(ppktfile->pkt, ppktfile);
|
2013-08-03 03:16:03 +00:00
|
|
|
_rtw_pktfile_read(ppktfile, (unsigned char *)ðerhdr, ETH_HLEN);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
/* get user_prio from IP hdr */
|
2013-05-08 21:45:39 +00:00
|
|
|
if (pattrib->ether_type == 0x0800) {
|
2013-08-03 03:16:03 +00:00
|
|
|
_rtw_pktfile_read(ppktfile, (u8 *)&ip_hdr, sizeof(ip_hdr));
|
|
|
|
/* user_prio = (ntohs(ip_hdr.tos) >> 5) & 0x3; */
|
|
|
|
user_prio = ip_hdr.tos >> 5;
|
2013-05-08 21:45:39 +00:00
|
|
|
} else if (pattrib->ether_type == 0x888e) {
|
2013-07-09 22:38:46 +00:00
|
|
|
/* "When priority processing of data frames is supported, */
|
|
|
|
/* a STA's SME should send EAPOL-Key frames at the highest priority." */
|
2013-08-03 03:16:03 +00:00
|
|
|
user_prio = 7;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
pattrib->priority = user_prio;
|
2013-05-08 21:45:39 +00:00
|
|
|
pattrib->hdrlen = WLAN_HDR_A3_QOS_LEN;
|
2022-06-08 23:46:35 +00:00
|
|
|
pattrib->subtype = IEEE80211_STYPE_QOS_DATA | IEEE80211_FTYPE_DATA;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct pkt_attrib *pattrib)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct pkt_file pktfile;
|
|
|
|
struct sta_info *psta = NULL;
|
|
|
|
struct ethhdr etherhdr;
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
bool 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;
|
2013-08-03 03:16:03 +00:00
|
|
|
struct qos_priv *pqospriv = &pmlmepriv->qospriv;
|
2013-07-26 22:56:14 +00:00
|
|
|
int res = _SUCCESS;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
_rtw_open_pktfile(pkt, &pktfile);
|
2013-08-03 03:16:03 +00:00
|
|
|
_rtw_pktfile_read(&pktfile, (u8 *)ðerhdr, ETH_HLEN);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pattrib->ether_type = ntohs(etherhdr.h_proto);
|
|
|
|
|
2013-10-19 17:45:47 +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;
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) ||
|
|
|
|
check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) {
|
2013-10-19 17:45:47 +00:00
|
|
|
memcpy(pattrib->ra, pattrib->dst, ETH_ALEN);
|
|
|
|
memcpy(pattrib->ta, pattrib->src, ETH_ALEN);
|
2013-08-03 03:16:03 +00:00
|
|
|
} else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
|
2013-10-19 17:45:47 +00:00
|
|
|
memcpy(pattrib->ra, get_bssid(pmlmepriv), ETH_ALEN);
|
|
|
|
memcpy(pattrib->ta, pattrib->src, ETH_ALEN);
|
2013-08-03 03:16:03 +00:00
|
|
|
} else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
|
2013-10-19 17:45:47 +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;
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
if (ETH_P_IP == pattrib->ether_type) {
|
2013-07-09 22:38:46 +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;
|
2013-07-09 22:38:46 +00:00
|
|
|
if (pktfile.pkt_len > 282) {/* MINIMUM_DHCP_PACKET_SIZE) { */
|
2022-06-08 23:46:35 +00:00
|
|
|
if (((tmp[21] == 68) && (tmp[23] == 67)) ||
|
|
|
|
((tmp[21] == 67) && (tmp[23] == 68))) {
|
|
|
|
/* 68 : UDP BOOTP client */
|
|
|
|
/* 67 : UDP BOOTP server */
|
|
|
|
/* Use low rate to send DHCP packet. */
|
|
|
|
pattrib->dhcp_pkt = 1;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-03 03:16:03 +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);
|
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* If EAPOL , ARP , OR DHCP packet, driver must be in active mode. */
|
2013-08-03 03:16:03 +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);
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
bmcast = is_multicast_ether_addr(pattrib->ra);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-07-09 22:38:46 +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);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!psta) { /* if we cannot get psta => drrp the pkt */
|
2013-08-03 03:16:03 +00:00
|
|
|
res = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
2022-06-08 23:46:35 +00:00
|
|
|
} else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) && !(psta->state & _FW_LINKED)) {
|
2013-08-03 03:16:03 +00:00
|
|
|
res = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
if (psta) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pattrib->mac_id = psta->mac_id;
|
|
|
|
pattrib->psta = psta;
|
2013-08-03 03:16:03 +00:00
|
|
|
} else {
|
2013-07-09 22:38:46 +00:00
|
|
|
/* if we cannot get psta => drop the pkt */
|
2013-05-08 21:45:39 +00:00
|
|
|
res = _FAIL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
pattrib->ack_policy = 0;
|
2013-07-09 22:38:46 +00:00
|
|
|
/* get ether_hdr_len */
|
2013-08-03 03:16:03 +00:00
|
|
|
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;
|
2022-06-08 23:46:35 +00:00
|
|
|
pattrib->subtype = IEEE80211_FTYPE_DATA;
|
2013-05-08 21:45:39 +00:00
|
|
|
pattrib->priority = 0;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (check_fwstate(pmlmepriv, WIFI_AP_STATE | WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE)) {
|
2013-05-09 04:04:25 +00:00
|
|
|
if (psta->qos_option)
|
2013-05-08 21:45:39 +00:00
|
|
|
set_qos(&pktfile, pattrib);
|
2013-08-03 03:16:03 +00:00
|
|
|
} else {
|
|
|
|
if (pqospriv->qos_option) {
|
2013-05-08 21:45:39 +00:00
|
|
|
set_qos(&pktfile, pattrib);
|
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if (pmlmepriv->acm_mask != 0)
|
2013-05-08 21:45:39 +00:00
|
|
|
pattrib->priority = qos_acm(pmlmepriv->acm_mask, pattrib->priority);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
if (psta->ieee8021x_blocked) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pattrib->encrypt = 0;
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
if ((pattrib->ether_type != 0x888e) && !check_fwstate(pmlmepriv, WIFI_MP_STATE)) {
|
2013-05-08 21:45:39 +00:00
|
|
|
res = _FAIL;
|
|
|
|
goto exit;
|
|
|
|
}
|
2013-08-03 03:16:03 +00:00
|
|
|
} else {
|
2013-05-08 21:45:39 +00:00
|
|
|
GET_ENCRY_ALGO(psecuritypriv, psta, pattrib->encrypt, bmcast);
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
switch (psecuritypriv->dot11AuthAlgrthm) {
|
|
|
|
case dot11AuthAlgrthm_Open:
|
|
|
|
case dot11AuthAlgrthm_Shared:
|
|
|
|
case dot11AuthAlgrthm_Auto:
|
|
|
|
pattrib->key_idx = (u8)psecuritypriv->dot11PrivacyKeyIndex;
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
2013-08-03 03:16:03 +00:00
|
|
|
case dot11AuthAlgrthm_8021X:
|
|
|
|
if (bmcast)
|
|
|
|
pattrib->key_idx = (u8)psecuritypriv->dot118021XGrpKeyid;
|
|
|
|
else
|
|
|
|
pattrib->key_idx = 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
|
|
|
default:
|
2013-08-03 03:16:03 +00:00
|
|
|
pattrib->key_idx = 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
2013-08-03 03:16:03 +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;
|
|
|
|
|
|
|
|
if (padapter->securitypriv.busetkipkey == _FAIL) {
|
|
|
|
res = _FAIL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case _AES_:
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
if (pattrib->encrypt &&
|
2022-06-08 23:46:35 +00:00
|
|
|
(padapter->securitypriv.sw_encrypt || !psecuritypriv->hw_decrypted))
|
2013-05-26 03:02:10 +00:00
|
|
|
pattrib->bswenc = true;
|
2022-06-08 23:46:35 +00:00
|
|
|
else
|
2013-05-26 03:02:10 +00:00
|
|
|
pattrib->bswenc = false;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
update_attrib_phy_info(pattrib, psta);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitframe)
|
|
|
|
{
|
|
|
|
int curfragnum, length;
|
|
|
|
u8 *pframe, *payload, mic[8];
|
|
|
|
struct mic_data micdata;
|
|
|
|
struct sta_info *stainfo;
|
|
|
|
struct pkt_attrib *pattrib = &pxmitframe->attrib;
|
|
|
|
struct security_priv *psecuritypriv = &padapter->securitypriv;
|
|
|
|
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;
|
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if (pattrib->psta)
|
2013-05-08 21:45:39 +00:00
|
|
|
stainfo = pattrib->psta;
|
|
|
|
else
|
2022-06-08 23:46:35 +00:00
|
|
|
stainfo = rtw_get_stainfo(&padapter->stapriv, &pattrib->ra[0]);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
hw_hdr_offset = TXDESC_SIZE + (pxmitframe->pkt_offset * PACKET_OFFSET_SZ);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
if (pattrib->encrypt == _TKIP_) {/* if (psecuritypriv->dot11PrivacyAlgrthm == _TKIP_PRIVACY_) */
|
2013-07-09 22:38:46 +00:00
|
|
|
/* encode mic code */
|
2022-06-08 23:46:35 +00:00
|
|
|
if (stainfo) {
|
2013-08-03 03:16:03 +00:00
|
|
|
u8 null_key[16] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
|
|
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
|
|
|
0x0, 0x0};
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pframe = pxmitframe->buf_addr + hw_hdr_offset;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (is_multicast_ether_addr(pattrib->ra)) {
|
2014-12-13 15:38:17 +00:00
|
|
|
if (!memcmp(psecuritypriv->dot118021XGrptxmickey[psecuritypriv->dot118021XGrpKeyid].skey, null_key, 16))
|
2013-05-08 21:45:39 +00:00
|
|
|
return _FAIL;
|
2013-07-09 22:38:46 +00:00
|
|
|
/* start to calculate the mic code */
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_secmicsetkey(&micdata, psecuritypriv->dot118021XGrptxmickey[psecuritypriv->dot118021XGrpKeyid].skey);
|
2013-08-03 03:16:03 +00:00
|
|
|
} else {
|
2014-12-13 15:38:17 +00:00
|
|
|
if (!memcmp(&stainfo->dot11tkiptxmickey.skey[0], null_key, 16)) {
|
2022-06-08 23:46:35 +00:00
|
|
|
/* msleep(10); */
|
2013-05-08 21:45:39 +00:00
|
|
|
return _FAIL;
|
|
|
|
}
|
2013-07-09 22:38:46 +00:00
|
|
|
/* start to calculate the mic code */
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_secmicsetkey(&micdata, &stainfo->dot11tkiptxmickey.skey[0]);
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (pframe[1] & 1) { /* ToDS == 1 */
|
2013-07-09 22:38:46 +00:00
|
|
|
rtw_secmicappend(&micdata, &pframe[16], 6); /* DA */
|
2022-06-08 23:46:35 +00:00
|
|
|
if (pframe[1] & 2) /* From Ds == 1 */
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_secmicappend(&micdata, &pframe[24], 6);
|
|
|
|
else
|
2013-05-19 04:28:07 +00:00
|
|
|
rtw_secmicappend(&micdata, &pframe[10], 6);
|
2013-08-03 03:16:03 +00:00
|
|
|
} else { /* ToDS == 0 */
|
2013-07-09 22:38:46 +00:00
|
|
|
rtw_secmicappend(&micdata, &pframe[4], 6); /* DA */
|
2022-06-08 23:46:35 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
if (pattrib->qos_en)
|
|
|
|
priority[0] = (u8)pxmitframe->attrib.priority;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_secmicappend(&micdata, &priority[0], 4);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
payload = pframe;
|
|
|
|
|
|
|
|
for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) {
|
2022-06-08 23:46:35 +00:00
|
|
|
payload = PTR_ALIGN(payload, 4);
|
|
|
|
|
|
|
|
payload = payload + 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);
|
2013-08-03 03:16:03 +00:00
|
|
|
rtw_secmicappend(&micdata, payload, length);
|
2022-06-08 23:46:35 +00:00
|
|
|
payload = payload + length;
|
2013-08-03 03:16:03 +00:00
|
|
|
} else {
|
2022-06-08 23:46:35 +00:00
|
|
|
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);
|
2022-06-08 23:46:35 +00:00
|
|
|
payload = payload + length + pattrib->icv_len;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
2022-06-08 23:46:35 +00:00
|
|
|
rtw_secgetmic(&micdata, &mic[0]);
|
2013-07-09 22:38:46 +00:00
|
|
|
/* add mic code and add the mic code length in last_txcmdsz */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
memcpy(payload, &mic[0], 8);
|
2013-08-03 03:16:03 +00:00
|
|
|
pattrib->last_txcmdsz += 8;
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
payload = payload - pattrib->last_txcmdsz + 8;
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return _SUCCESS;
|
|
|
|
}
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
static s32 xmitframe_swencrypt(struct adapter *padapter, struct xmit_frame *pxmitframe)
|
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
struct pkt_attrib *pattrib = &pxmitframe->attrib;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
if (pattrib->bswenc) {
|
|
|
|
switch (pattrib->encrypt) {
|
2013-05-08 21:45:39 +00:00
|
|
|
case _WEP40_:
|
|
|
|
case _WEP104_:
|
2022-06-08 23:46:35 +00:00
|
|
|
rtw_wep_encrypt(padapter, pxmitframe);
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
|
|
|
case _TKIP_:
|
2022-06-08 23:46:35 +00:00
|
|
|
rtw_tkip_encrypt(padapter, pxmitframe);
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
|
|
|
case _AES_:
|
2022-06-08 23:46:35 +00:00
|
|
|
rtw_aes_encrypt(padapter, pxmitframe);
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
|
|
|
default:
|
2013-07-12 06:29:15 +00:00
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return _SUCCESS;
|
|
|
|
}
|
|
|
|
|
2022-06-08 23:46:35 +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;
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
struct ieee80211_hdr *pwlanhdr = (struct ieee80211_hdr *)hdr;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
|
|
|
struct qos_priv *pqospriv = &pmlmepriv->qospriv;
|
2013-05-26 03:02:10 +00:00
|
|
|
u8 qos_option = false;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-26 22:56:14 +00:00
|
|
|
int res = _SUCCESS;
|
2022-06-08 23:46:35 +00:00
|
|
|
__le16 *fctrl = &pwlanhdr->frame_control;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
struct sta_info *psta;
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (pattrib->psta)
|
2013-05-08 21:45:39 +00:00
|
|
|
psta = pattrib->psta;
|
2022-06-08 23:46:35 +00:00
|
|
|
else if (is_multicast_ether_addr(pattrib->ra))
|
|
|
|
psta = rtw_get_bcmc_stainfo(padapter);
|
|
|
|
else
|
|
|
|
psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 04:43:35 +00:00
|
|
|
memset(hdr, 0, WLANHDR_OFFSET);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
SetFrameSubType(fctrl, pattrib->subtype);
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (pattrib->subtype & IEEE80211_FTYPE_DATA) {
|
|
|
|
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {
|
2013-07-09 22:38:46 +00:00
|
|
|
/* to_ds = 1, fr_ds = 0; */
|
2013-07-12 01:13:07 +00:00
|
|
|
/* Data transfer to AP */
|
|
|
|
SetToDs(fctrl);
|
2013-10-19 17:45:47 +00:00
|
|
|
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)
|
2013-05-26 03:02:10 +00:00
|
|
|
qos_option = true;
|
2013-08-03 03:16:03 +00:00
|
|
|
} else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
|
2013-07-09 22:38:46 +00:00
|
|
|
/* to_ds = 0, fr_ds = 1; */
|
2013-05-08 21:45:39 +00:00
|
|
|
SetFrDs(fctrl);
|
2013-10-19 17:45:47 +00:00
|
|
|
memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN);
|
|
|
|
memcpy(pwlanhdr->addr2, get_bssid(pmlmepriv), ETH_ALEN);
|
|
|
|
memcpy(pwlanhdr->addr3, pattrib->src, ETH_ALEN);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
if (psta->qos_option)
|
2013-05-26 03:02:10 +00:00
|
|
|
qos_option = true;
|
2013-08-03 03:16:03 +00:00
|
|
|
} else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) ||
|
|
|
|
check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) {
|
2013-10-19 17:45:47 +00:00
|
|
|
memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN);
|
|
|
|
memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN);
|
|
|
|
memcpy(pwlanhdr->addr3, get_bssid(pmlmepriv), ETH_ALEN);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
if (psta->qos_option)
|
2013-05-26 03:02:10 +00:00
|
|
|
qos_option = true;
|
2013-08-03 03:16:03 +00:00
|
|
|
} else {
|
2013-05-08 21:45:39 +00:00
|
|
|
res = _FAIL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if (pattrib->mdata)
|
2013-05-08 21:45:39 +00:00
|
|
|
SetMData(fctrl);
|
|
|
|
|
|
|
|
if (pattrib->encrypt)
|
|
|
|
SetPrivacy(fctrl);
|
|
|
|
|
2013-08-03 03:16:03 +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);
|
|
|
|
}
|
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* TODO: fill HT Control Field */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* Update Seq Num will be handled by f/w */
|
2013-08-03 03:16:03 +00:00
|
|
|
if (psta) {
|
|
|
|
psta->sta_xmitpriv.txseq_tid[pattrib->priority]++;
|
|
|
|
psta->sta_xmitpriv.txseq_tid[pattrib->priority] &= 0xFFF;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
pattrib->seqnum = psta->sta_xmitpriv.txseq_tid[pattrib->priority];
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
SetSeqNum(hdr, pattrib->seqnum);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
/* check if enable ampdu */
|
|
|
|
if (pattrib->ht_en && psta->htpriv.ampdu_enable) {
|
|
|
|
if (psta->htpriv.agg_enable_bitmap & BIT(pattrib->priority))
|
2022-06-08 23:46:35 +00:00
|
|
|
pattrib->ampdu_en = true;
|
2013-08-03 03:16:03 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
/* re-check if enable ampdu by BA_starting_seqctrl */
|
|
|
|
if (pattrib->ampdu_en) {
|
|
|
|
u16 tx_seq;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
tx_seq = psta->BA_starting_seqctrl[pattrib->priority & 0x0f];
|
|
|
|
|
|
|
|
/* check BA_starting_seqctrl */
|
|
|
|
if (SN_LESS(pattrib->seqnum, tx_seq)) {
|
|
|
|
pattrib->ampdu_en = false;/* AGG BK */
|
|
|
|
} else if (SN_EQUAL(pattrib->seqnum, tx_seq)) {
|
2022-06-08 23:46:35 +00:00
|
|
|
psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (tx_seq + 1) & 0xfff;
|
2013-08-03 03:16:03 +00:00
|
|
|
|
|
|
|
pattrib->ampdu_en = true;/* AGG EN */
|
|
|
|
} else {
|
2022-06-08 23:46:35 +00:00
|
|
|
psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (pattrib->seqnum + 1) & 0xfff;
|
2013-08-03 03:16:03 +00:00
|
|
|
pattrib->ampdu_en = true;/* AGG EN */
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exit:
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +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-13 21:06:22 +00:00
|
|
|
return (!list_empty(&pxmitpriv->be_pending.queue) ||
|
|
|
|
!list_empty(&pxmitpriv->bk_pending.queue) ||
|
|
|
|
!list_empty(&pxmitpriv->vi_pending.queue) ||
|
|
|
|
!list_empty(&pxmitpriv->vo_pending.queue));
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
s32 rtw_txframes_sta_ac_pending(struct adapter *padapter, struct pkt_attrib *pattrib)
|
2013-05-19 04:28:07 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
struct sta_info *psta;
|
|
|
|
struct tx_servq *ptxservq;
|
|
|
|
int priority = pattrib->priority;
|
|
|
|
|
|
|
|
psta = pattrib->psta;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
switch (priority) {
|
|
|
|
case 1:
|
|
|
|
case 2:
|
2022-06-08 23:46:35 +00:00
|
|
|
ptxservq = &psta->sta_xmitpriv.bk_q;
|
2013-08-03 03:16:03 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
case 5:
|
2022-06-08 23:46:35 +00:00
|
|
|
ptxservq = &psta->sta_xmitpriv.vi_q;
|
2013-08-03 03:16:03 +00:00
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
case 7:
|
2022-06-08 23:46:35 +00:00
|
|
|
ptxservq = &psta->sta_xmitpriv.vo_q;
|
2013-08-03 03:16:03 +00:00
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
case 3:
|
|
|
|
default:
|
2022-06-08 23:46:35 +00:00
|
|
|
ptxservq = &psta->sta_xmitpriv.be_q;
|
2013-08-03 03:16:03 +00:00
|
|
|
break;
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
|
|
|
|
2017-01-21 02:07:49 +00:00
|
|
|
if (ptxservq)
|
|
|
|
return ptxservq->qcnt;
|
|
|
|
return 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2022-06-08 23:46:35 +00:00
|
|
|
* 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
|
|
|
|
* 6. apply sw-encrypt, if necessary.
|
2013-05-08 21:45:39 +00:00
|
|
|
*/
|
2013-07-27 01:08:39 +00:00
|
|
|
s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct xmit_frame *pxmitframe)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct pkt_file pktfile;
|
|
|
|
s32 frg_inx, frg_len, mpdu_len, llc_sz, mem_sz;
|
|
|
|
u8 *pframe, *mem_start;
|
|
|
|
u8 hw_hdr_offset;
|
|
|
|
struct sta_info *psta;
|
|
|
|
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
|
|
|
|
struct pkt_attrib *pattrib = &pxmitframe->attrib;
|
|
|
|
u8 *pbuf_start;
|
2022-06-08 23:46:35 +00:00
|
|
|
bool bmcst = is_multicast_ether_addr(pattrib->ra);
|
2013-05-08 21:45:39 +00:00
|
|
|
s32 res = _SUCCESS;
|
|
|
|
|
2017-01-16 21:37:23 +00:00
|
|
|
if (!pkt)
|
|
|
|
return _FAIL;
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!psta)
|
2013-05-08 21:45:39 +00:00
|
|
|
return _FAIL;
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!pxmitframe->buf_addr)
|
2013-05-08 21:45:39 +00:00
|
|
|
return _FAIL;
|
|
|
|
|
|
|
|
pbuf_start = pxmitframe->buf_addr;
|
2013-05-19 04:28:07 +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) {
|
|
|
|
res = _FAIL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
_rtw_open_pktfile(pkt, &pktfile);
|
|
|
|
_rtw_pktfile_read(&pktfile, NULL, pattrib->pkt_hdrlen);
|
|
|
|
|
|
|
|
frg_inx = 0;
|
2013-07-09 22:38:46 +00:00
|
|
|
frg_len = pxmitpriv->frag_len - 4;/* 2346-4 = 2342 */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-03 03:16:03 +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;
|
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* adding icv, if necessary... */
|
2013-08-03 03:16:03 +00:00
|
|
|
if (pattrib->iv_len) {
|
2022-06-08 23:46:35 +00:00
|
|
|
if (psta) {
|
2013-08-03 03:16:03 +00:00
|
|
|
switch (pattrib->encrypt) {
|
|
|
|
case _WEP40_:
|
|
|
|
case _WEP104_:
|
2013-10-19 17:45:47 +00:00
|
|
|
WEP_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx);
|
2013-08-03 03:16:03 +00:00
|
|
|
break;
|
|
|
|
case _TKIP_:
|
|
|
|
if (bmcst)
|
|
|
|
TKIP_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx);
|
|
|
|
else
|
|
|
|
TKIP_IV(pattrib->iv, psta->dot11txpn, 0);
|
|
|
|
break;
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-19 17:45:47 +00:00
|
|
|
memcpy(pframe, pattrib->iv, pattrib->iv_len);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
if ((pattrib->icv_len > 0) && (pattrib->bswenc)) {
|
2013-05-08 21:45:39 +00:00
|
|
|
mpdu_len -= pattrib->icv_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bmcst) {
|
2013-07-09 22:38:46 +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;
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
if ((pattrib->icv_len > 0) && (pattrib->bswenc)) {
|
2013-10-19 17:45:47 +00:00
|
|
|
memcpy(pframe, pattrib->icv, pattrib->icv_len);
|
2013-05-08 21:45:39 +00:00
|
|
|
pframe += pattrib->icv_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
frg_inx++;
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
if (bmcst || rtw_endofpktfile(&pktfile)) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pattrib->nr_frags = frg_inx;
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
pattrib->last_txcmdsz = pattrib->hdrlen + pattrib->iv_len + ((pattrib->nr_frags == 1) ? llc_sz : 0) +
|
|
|
|
((pattrib->bswenc) ? pattrib->icv_len : 0) + mem_sz;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
ClearMFrag(mem_start);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
mem_start = PTR_ALIGN(pframe, 4) + hw_hdr_offset;
|
2013-10-19 17:45:47 +00:00
|
|
|
memcpy(mem_start, pbuf_start + hw_hdr_offset, pattrib->hdrlen);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
if (xmitframe_addmic(padapter, pxmitframe) == _FAIL) {
|
2013-05-08 21:45:39 +00:00
|
|
|
res = _FAIL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
xmitframe_swencrypt(padapter, pxmitframe);
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
if (!bmcst)
|
2013-05-08 21:45:39 +00:00
|
|
|
update_attrib_vcs_info(padapter, pxmitframe);
|
|
|
|
else
|
|
|
|
pattrib->vcs_mode = NONE_VCS;
|
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
exit:
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
|
|
|
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;
|
2013-05-19 04:28:07 +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];
|
|
|
|
|
2013-06-03 19:52:18 +00:00
|
|
|
*(__be16 *)(data + SNAP_SIZE) = htons(h_proto);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return SNAP_SIZE + sizeof(u16);
|
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
void rtw_update_protection(struct adapter *padapter, u8 *ie, uint ie_len)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
uint protection;
|
|
|
|
u8 *perp;
|
2013-07-26 22:56:14 +00:00
|
|
|
int erp_len;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
|
|
|
|
struct registry_priv *pregistrypriv = &padapter->registrypriv;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
switch (pxmitpriv->vcs_setting) {
|
|
|
|
case DISABLE_VCS:
|
|
|
|
pxmitpriv->vcs = NONE_VCS;
|
|
|
|
break;
|
|
|
|
case ENABLE_VCS:
|
|
|
|
break;
|
|
|
|
case AUTO_VCS:
|
|
|
|
default:
|
|
|
|
perp = rtw_get_ie(ie, _ERPINFO_IE_, &erp_len, ie_len);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!perp) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitpriv->vcs = NONE_VCS;
|
2013-08-03 03:16:03 +00:00
|
|
|
} else {
|
|
|
|
protection = (*(perp + 2)) & BIT(1);
|
|
|
|
if (protection) {
|
|
|
|
if (pregistrypriv->vcs_type == RTS_CTS)
|
|
|
|
pxmitpriv->vcs = RTS_CTS;
|
2013-05-08 21:45:39 +00:00
|
|
|
else
|
2013-08-03 03:16:03 +00:00
|
|
|
pxmitpriv->vcs = CTS_TO_SELF;
|
|
|
|
} else {
|
|
|
|
pxmitpriv->vcs = NONE_VCS;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-08-03 03:16:03 +00:00
|
|
|
}
|
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-08-03 03:16:03 +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;
|
|
|
|
|
2022-06-08 23:46:35 +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;
|
2013-07-19 04:58:55 +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;
|
2013-07-25 14:49:25 +00:00
|
|
|
struct list_head *plist, *phead;
|
2013-07-24 22:55:38 +00:00
|
|
|
struct __queue *pfree_queue = &pxmitpriv->free_xmit_extbuf_queue;
|
2014-11-28 23:37:57 +00:00
|
|
|
unsigned long flags;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-11-28 23:37:57 +00:00
|
|
|
spin_lock_irqsave(&pfree_queue->lock, flags);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 21:06:22 +00:00
|
|
|
if (list_empty(&pfree_queue->queue)) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitbuf = NULL;
|
|
|
|
} else {
|
|
|
|
phead = get_list_head(pfree_queue);
|
|
|
|
|
2014-12-13 21:06:22 +00:00
|
|
|
plist = phead->next;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 16:40:44 +00:00
|
|
|
pxmitbuf = container_of(plist, struct xmit_buf, list);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
list_del_init(&pxmitbuf->list);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (pxmitbuf) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitpriv->free_xmit_extbuf_cnt--;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitbuf->priv_data = NULL;
|
2013-07-09 22:38:46 +00:00
|
|
|
/* pxmitbuf->ext_tag = true; */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (pxmitbuf->sctx)
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_BUF_ALLOC);
|
|
|
|
}
|
|
|
|
|
2014-11-28 23:37:57 +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)
|
|
|
|
{
|
2013-07-24 22:55:38 +00:00
|
|
|
struct __queue *pfree_queue = &pxmitpriv->free_xmit_extbuf_queue;
|
2014-11-28 23:37:57 +00:00
|
|
|
unsigned long flags;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!pxmitbuf)
|
2013-05-08 21:45:39 +00:00
|
|
|
return _FAIL;
|
|
|
|
|
2014-11-28 23:37:57 +00:00
|
|
|
spin_lock_irqsave(&pfree_queue->lock, flags);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 21:06:22 +00:00
|
|
|
list_del_init(&pxmitbuf->list);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
list_add_tail(&pxmitbuf->list, get_list_head(pfree_queue));
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitpriv->free_xmit_extbuf_cnt++;
|
|
|
|
|
2014-11-28 23:37:57 +00:00
|
|
|
spin_unlock_irqrestore(&pfree_queue->lock, flags);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return _SUCCESS;
|
2013-05-19 04:28:07 +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;
|
2013-07-25 14:49:25 +00:00
|
|
|
struct list_head *plist, *phead;
|
2013-07-24 22:55:38 +00:00
|
|
|
struct __queue *pfree_xmitbuf_queue = &pxmitpriv->free_xmitbuf_queue;
|
2014-11-28 23:37:57 +00:00
|
|
|
unsigned long flags;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-11-28 23:37:57 +00:00
|
|
|
spin_lock_irqsave(&pfree_xmitbuf_queue->lock, flags);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 21:06:22 +00:00
|
|
|
if (list_empty(&pfree_xmitbuf_queue->queue)) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitbuf = NULL;
|
|
|
|
} else {
|
|
|
|
phead = get_list_head(pfree_xmitbuf_queue);
|
|
|
|
|
2014-12-13 21:06:22 +00:00
|
|
|
plist = phead->next;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 16:40:44 +00:00
|
|
|
pxmitbuf = container_of(plist, struct xmit_buf, list);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
list_del_init(&pxmitbuf->list);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (pxmitbuf) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitpriv->free_xmitbuf_cnt--;
|
|
|
|
pxmitbuf->priv_data = NULL;
|
2022-06-08 23:46:35 +00:00
|
|
|
if (pxmitbuf->sctx)
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_BUF_ALLOC);
|
|
|
|
}
|
2014-11-28 23:37:57 +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)
|
|
|
|
{
|
2013-07-24 22:55:38 +00:00
|
|
|
struct __queue *pfree_xmitbuf_queue = &pxmitpriv->free_xmitbuf_queue;
|
2014-11-28 23:37:57 +00:00
|
|
|
unsigned long flags;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!pxmitbuf)
|
2013-05-08 21:45:39 +00:00
|
|
|
return _FAIL;
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (pxmitbuf->sctx)
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_BUF_FREE);
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
if (pxmitbuf->ext_tag) {
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_free_xmitbuf_ext(pxmitpriv, pxmitbuf);
|
2013-08-03 03:16:03 +00:00
|
|
|
} else {
|
2014-11-28 23:37:57 +00:00
|
|
|
spin_lock_irqsave(&pfree_xmitbuf_queue->lock, flags);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 21:06:22 +00:00
|
|
|
list_del_init(&pxmitbuf->list);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
list_add_tail(&pxmitbuf->list, get_list_head(pfree_xmitbuf_queue));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pxmitpriv->free_xmitbuf_cnt++;
|
2014-11-28 23:37:57 +00:00
|
|
|
spin_unlock_irqrestore(&pfree_xmitbuf_queue->lock, flags);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
return _SUCCESS;
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
/*
|
2022-06-08 23:46:35 +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...
|
|
|
|
*/
|
2013-07-09 22:38:46 +00:00
|
|
|
struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv)/* _queue *pfree_xmit_queue) */
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
/*
|
2022-06-08 23:46:35 +00:00
|
|
|
* Please remember to use all the osdep_service api,
|
|
|
|
* and lock/unlock or _enter/_exit critical to protect
|
|
|
|
* pfree_xmit_queue
|
|
|
|
*/
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
struct xmit_frame *pxframe = NULL;
|
2013-07-25 14:49:25 +00:00
|
|
|
struct list_head *plist, *phead;
|
2013-07-24 22:55:38 +00:00
|
|
|
struct __queue *pfree_xmit_queue = &pxmitpriv->free_xmit_queue;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_lock_bh(&pfree_xmit_queue->lock);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 21:06:22 +00:00
|
|
|
if (list_empty(&pfree_xmit_queue->queue)) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pxframe = NULL;
|
|
|
|
} else {
|
|
|
|
phead = get_list_head(pfree_xmit_queue);
|
|
|
|
|
2014-12-13 21:06:22 +00:00
|
|
|
plist = phead->next;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 16:40:44 +00:00
|
|
|
pxframe = container_of(plist, struct xmit_frame, list);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
list_del_init(&pxframe->list);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (pxframe) { /* default value setting */
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitpriv->free_xmitframe_cnt--;
|
|
|
|
|
|
|
|
pxframe->buf_addr = NULL;
|
|
|
|
pxframe->pxmitbuf = NULL;
|
|
|
|
|
2014-12-13 04:43:35 +00:00
|
|
|
memset(&pxframe->attrib, 0, sizeof(struct pkt_attrib));
|
2013-07-09 22:38:46 +00:00
|
|
|
/* pxframe->attrib.psta = NULL; */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pxframe->frame_tag = DATA_FRAMETAG;
|
|
|
|
|
|
|
|
pxframe->pkt = NULL;
|
2013-07-09 22:38:46 +00:00
|
|
|
pxframe->pkt_offset = 1;/* default use pkt_offset to fill tx desc */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pxframe->agg_num = 1;
|
|
|
|
pxframe->ack_report = 0;
|
|
|
|
}
|
|
|
|
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_unlock_bh(&pfree_xmit_queue->lock);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return pxframe;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv, struct xmit_frame *pxmitframe)
|
2013-05-19 04:28:07 +00:00
|
|
|
{
|
2013-07-24 22:55:38 +00:00
|
|
|
struct __queue *pfree_xmit_queue = &pxmitpriv->free_xmit_queue;
|
2013-07-27 01:08:39 +00:00
|
|
|
struct adapter *padapter = pxmitpriv->adapter;
|
2013-07-24 22:03:54 +00:00
|
|
|
struct sk_buff *pndis_pkt = NULL;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!pxmitframe)
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_lock_bh(&pfree_xmit_queue->lock);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 21:06:22 +00:00
|
|
|
list_del_init(&pxmitframe->list);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
if (pxmitframe->pkt) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pndis_pkt = pxmitframe->pkt;
|
|
|
|
pxmitframe->pkt = NULL;
|
|
|
|
}
|
|
|
|
|
2014-12-13 17:50:41 +00:00
|
|
|
list_add_tail(&pxmitframe->list, get_list_head(pfree_xmit_queue));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pxmitpriv->free_xmitframe_cnt++;
|
|
|
|
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_unlock_bh(&pfree_xmit_queue->lock);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if (pndis_pkt)
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_os_pkt_complete(padapter, pndis_pkt);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
|
|
|
|
return _SUCCESS;
|
|
|
|
}
|
|
|
|
|
2013-07-24 22:55:38 +00:00
|
|
|
void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, struct __queue *pframequeue)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-07-25 14:49:25 +00:00
|
|
|
struct list_head *plist, *phead;
|
2013-05-19 04:28:07 +00:00
|
|
|
struct xmit_frame *pxmitframe;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_lock_bh(&pframequeue->lock);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
phead = get_list_head(pframequeue);
|
2014-12-13 21:06:22 +00:00
|
|
|
plist = phead->next;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-13 21:06:22 +00:00
|
|
|
while (phead != plist) {
|
2014-12-13 16:40:44 +00:00
|
|
|
pxmitframe = container_of(plist, struct xmit_frame, list);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 21:06:22 +00:00
|
|
|
plist = plist->next;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
rtw_free_xmitframe(pxmitpriv, pxmitframe);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_unlock_bh(&pframequeue->lock);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
s32 rtw_xmitframe_enqueue(struct adapter *padapter, struct xmit_frame *pxmitframe)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-08-03 03:16:03 +00:00
|
|
|
if (rtw_xmit_classifier(padapter, pxmitframe) == _FAIL) {
|
2013-07-09 22:38:46 +00:00
|
|
|
/* pxmitframe->pkt = NULL; */
|
2013-05-08 21:45:39 +00:00
|
|
|
return _FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return _SUCCESS;
|
|
|
|
}
|
|
|
|
|
2013-07-24 22:55:38 +00:00
|
|
|
static struct xmit_frame *dequeue_one_xmitframe(struct xmit_priv *pxmitpriv, struct hw_xmit *phwxmit, struct tx_servq *ptxservq, struct __queue *pframe_queue)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-07-25 14:49:25 +00:00
|
|
|
struct list_head *xmitframe_plist, *xmitframe_phead;
|
2013-08-03 03:16:03 +00:00
|
|
|
struct xmit_frame *pxmitframe = NULL;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
xmitframe_phead = get_list_head(pframe_queue);
|
2014-12-13 21:06:22 +00:00
|
|
|
xmitframe_plist = xmitframe_phead->next;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 21:06:22 +00:00
|
|
|
if (xmitframe_phead != xmitframe_plist) {
|
2014-12-13 16:40:44 +00:00
|
|
|
pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list);
|
2013-10-19 17:45:47 +00:00
|
|
|
|
2014-12-13 21:06:22 +00:00
|
|
|
xmitframe_plist = xmitframe_plist->next;
|
2013-10-19 17:45:47 +00:00
|
|
|
|
2014-12-13 21:06:22 +00:00
|
|
|
list_del_init(&pxmitframe->list);
|
2013-10-19 17:45:47 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
ptxservq->qcnt--;
|
|
|
|
}
|
|
|
|
return pxmitframe;
|
|
|
|
}
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
struct xmit_frame *rtw_dequeue_xframe(struct xmit_priv *pxmitpriv, struct hw_xmit *phwxmit_i, int entry)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-07-25 14:49:25 +00:00
|
|
|
struct list_head *sta_plist, *sta_phead;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct hw_xmit *phwxmit;
|
|
|
|
struct tx_servq *ptxservq = NULL;
|
2013-07-24 22:55:38 +00:00
|
|
|
struct __queue *pframe_queue = NULL;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct xmit_frame *pxmitframe = NULL;
|
2013-07-27 01:08:39 +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];
|
|
|
|
|
|
|
|
inx[0] = 0; inx[1] = 1; inx[2] = 2; inx[3] = 3;
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
if (pregpriv->wifi_spec == 1) {
|
2013-09-06 00:44:02 +00:00
|
|
|
int j;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
for (j = 0; j < 4; j++)
|
2013-05-08 21:45:39 +00:00
|
|
|
inx[j] = pxmitpriv->wmm_para_seq[j];
|
|
|
|
}
|
|
|
|
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_lock_bh(&pxmitpriv->lock);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
for (i = 0; i < entry; i++) {
|
2013-05-08 21:45:39 +00:00
|
|
|
phwxmit = phwxmit_i + inx[i];
|
|
|
|
|
|
|
|
sta_phead = get_list_head(phwxmit->sta_queue);
|
2014-12-13 21:06:22 +00:00
|
|
|
sta_plist = sta_phead->next;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 21:06:22 +00:00
|
|
|
while (sta_phead != sta_plist) {
|
2014-12-13 16:40:44 +00:00
|
|
|
ptxservq = container_of(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);
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
if (pxmitframe) {
|
2013-05-08 21:45:39 +00:00
|
|
|
phwxmit->accnt--;
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
/* Remove sta node when there are no pending packets. */
|
2014-12-13 21:06:22 +00:00
|
|
|
if (list_empty(&pframe_queue->queue)) /* must be done after get_next and before break */
|
|
|
|
list_del_init(&ptxservq->tx_pending);
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-13 21:06:22 +00:00
|
|
|
sta_plist = sta_plist->next;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
exit:
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_unlock_bh(&pxmitpriv->lock);
|
2014-12-01 22:31:15 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return pxmitframe;
|
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, struct sta_info *psta, int up, u8 *ac)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct tx_servq *ptxservq;
|
|
|
|
|
2013-07-11 15:59:02 +00:00
|
|
|
switch (up) {
|
|
|
|
case 1:
|
|
|
|
case 2:
|
2022-06-08 23:46:35 +00:00
|
|
|
ptxservq = &psta->sta_xmitpriv.bk_q;
|
2013-07-27 02:37:57 +00:00
|
|
|
*(ac) = 3;
|
2013-07-11 15:59:02 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
case 5:
|
2022-06-08 23:46:35 +00:00
|
|
|
ptxservq = &psta->sta_xmitpriv.vi_q;
|
2013-07-27 02:37:57 +00:00
|
|
|
*(ac) = 1;
|
2013-07-11 15:59:02 +00:00
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
case 7:
|
2022-06-08 23:46:35 +00:00
|
|
|
ptxservq = &psta->sta_xmitpriv.vo_q;
|
2013-07-27 02:37:57 +00:00
|
|
|
*(ac) = 0;
|
2013-07-11 15:59:02 +00:00
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
case 3:
|
|
|
|
default:
|
2022-06-08 23:46:35 +00:00
|
|
|
ptxservq = &psta->sta_xmitpriv.be_q;
|
2013-07-27 02:37:57 +00:00
|
|
|
*(ac) = 2;
|
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
return ptxservq;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Will enqueue pxmitframe to the proper queue,
|
|
|
|
* and indicate it to xx_pending list.....
|
|
|
|
*/
|
2013-07-27 01:08:39 +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;
|
2013-07-26 22:56:14 +00:00
|
|
|
int res = _SUCCESS;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (pattrib->psta)
|
2013-05-19 04:28:07 +00:00
|
|
|
psta = pattrib->psta;
|
2022-06-08 23:46:35 +00:00
|
|
|
else
|
2013-05-08 21:45:39 +00:00
|
|
|
psta = rtw_get_stainfo(pstapriv, pattrib->ra);
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!psta) {
|
2013-05-08 21:45:39 +00:00
|
|
|
res = _FAIL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
ptxservq = rtw_get_sta_pending(padapter, psta, pattrib->priority, (u8 *)(&ac_index));
|
|
|
|
|
2014-12-13 21:06:22 +00:00
|
|
|
if (list_empty(&ptxservq->tx_pending))
|
2014-12-13 17:50:41 +00:00
|
|
|
list_add_tail(&ptxservq->tx_pending, get_list_head(phwxmits[ac_index].sta_queue));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 17:50:41 +00:00
|
|
|
list_add_tail(&pxmitframe->list, get_list_head(&ptxservq->sta_pending));
|
2013-05-08 21:45:39 +00:00
|
|
|
ptxservq->qcnt++;
|
|
|
|
phwxmits[ac_index].accnt++;
|
|
|
|
exit:
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
int 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;
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
pxmitpriv->hwxmits = kzalloc(sizeof(struct hw_xmit) * pxmitpriv->hwxmit_entry, GFP_KERNEL);
|
|
|
|
if (!pxmitpriv->hwxmits)
|
|
|
|
return -ENOMEM;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
hwxmits = pxmitpriv->hwxmits;
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
hwxmits[0].sta_queue = &pxmitpriv->vo_pending;
|
|
|
|
hwxmits[1].sta_queue = &pxmitpriv->vi_pending;
|
|
|
|
hwxmits[2].sta_queue = &pxmitpriv->be_pending;
|
|
|
|
hwxmits[3].sta_queue = &pxmitpriv->bk_pending;
|
|
|
|
|
|
|
|
return 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +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;
|
2013-10-19 17:45:47 +00:00
|
|
|
kfree(hwxmits);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-07-26 22:56:14 +00:00
|
|
|
void rtw_init_hwxmits(struct hw_xmit *phwxmit, int entry)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-07-26 22:56:14 +00:00
|
|
|
int i;
|
2014-12-01 22:31:15 +00:00
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
for (i = 0; i < entry; i++, phwxmit++)
|
2013-05-08 21:45:39 +00:00
|
|
|
phwxmit->accnt = 0;
|
2014-12-01 22:31:15 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +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;
|
2013-08-03 03:16:03 +00:00
|
|
|
int res, is_vlan_tag = 0, i, do_nat25 = 1;
|
|
|
|
unsigned short vlan_hdr = 0;
|
|
|
|
void *br_port = NULL;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
rcu_read_lock();
|
2014-02-12 17:05:30 +00:00
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
|
2013-08-03 03:16:03 +00:00
|
|
|
br_port = rcu_dereference(padapter->pnetdev->rx_handler_data);
|
2014-02-12 17:05:30 +00:00
|
|
|
#else
|
|
|
|
br_port = rcu_dereference(padapter->pnetdev->br_port);
|
|
|
|
#endif
|
2013-08-03 03:16:03 +00:00
|
|
|
rcu_read_unlock();
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_lock_bh(&padapter->br_ext_lock);
|
2013-08-03 03:16:03 +00:00
|
|
|
if (!(skb->data[0] & 1) && br_port &&
|
2022-06-08 23:46:35 +00:00
|
|
|
memcmp(skb->data + ETH_ALEN, padapter->br_mac, ETH_ALEN) &&
|
|
|
|
*((__be16 *)(skb->data + ETH_ALEN * 2)) != __constant_htons(ETH_P_8021Q) &&
|
|
|
|
*((__be16 *)(skb->data + ETH_ALEN * 2)) == __constant_htons(ETH_P_IP) &&
|
|
|
|
!memcmp(padapter->scdb_mac, skb->data + ETH_ALEN, ETH_ALEN) && padapter->scdb_entry) {
|
|
|
|
memcpy(skb->data + ETH_ALEN, GET_MY_HWADDR(padapter), ETH_ALEN);
|
2013-08-03 03:16:03 +00:00
|
|
|
padapter->scdb_entry->ageing_timer = jiffies;
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_unlock_bh(&padapter->br_ext_lock);
|
2013-08-03 03:16:03 +00:00
|
|
|
} else {
|
2022-06-08 23:46:35 +00:00
|
|
|
if (*((__be16 *)(skb->data + ETH_ALEN * 2)) == __constant_htons(ETH_P_8021Q)) {
|
2013-08-03 03:16:03 +00:00
|
|
|
is_vlan_tag = 1;
|
2022-06-08 23:46:35 +00:00
|
|
|
vlan_hdr = *((unsigned short *)(skb->data + ETH_ALEN * 2 + 2));
|
2013-08-03 03:16:03 +00:00
|
|
|
for (i = 0; i < 6; i++)
|
2022-06-08 23:46:35 +00:00
|
|
|
*((unsigned short *)(skb->data + ETH_ALEN * 2 + 2 - i * 2)) = *((unsigned short *)(skb->data + ETH_ALEN * 2 - 2 - i * 2));
|
2013-08-03 03:16:03 +00:00
|
|
|
skb_pull(skb, 4);
|
|
|
|
}
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!memcmp(skb->data + ETH_ALEN, padapter->br_mac, ETH_ALEN) &&
|
|
|
|
(*((__be16 *)(skb->data + ETH_ALEN * 2)) == __constant_htons(ETH_P_IP)))
|
|
|
|
memcpy(padapter->br_ip, skb->data + WLAN_ETHHDR_LEN + 12, 4);
|
2013-08-03 03:16:03 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (*((__be16 *)(skb->data + ETH_ALEN * 2)) == __constant_htons(ETH_P_IP)) {
|
|
|
|
if (memcmp(padapter->scdb_mac, skb->data + ETH_ALEN, ETH_ALEN)) {
|
2013-08-03 03:16:03 +00:00
|
|
|
padapter->scdb_entry = (struct nat25_network_db_entry *)scdb_findEntry(padapter,
|
2022-06-08 23:46:35 +00:00
|
|
|
skb->data + WLAN_ETHHDR_LEN + 12);
|
2013-08-03 03:16:03 +00:00
|
|
|
if (padapter->scdb_entry) {
|
2022-06-08 23:46:35 +00:00
|
|
|
memcpy(padapter->scdb_mac, skb->data + ETH_ALEN, ETH_ALEN);
|
|
|
|
memcpy(padapter->scdb_ip, skb->data + WLAN_ETHHDR_LEN + 12, 4);
|
2013-08-03 03:16:03 +00:00
|
|
|
padapter->scdb_entry->ageing_timer = jiffies;
|
|
|
|
do_nat25 = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (padapter->scdb_entry) {
|
|
|
|
padapter->scdb_entry->ageing_timer = jiffies;
|
|
|
|
do_nat25 = 0;
|
2013-05-30 20:51:53 +00:00
|
|
|
} else {
|
2022-06-08 23:46:35 +00:00
|
|
|
memset(padapter->scdb_mac, 0, ETH_ALEN);
|
2013-08-03 03:16:03 +00:00
|
|
|
memset(padapter->scdb_ip, 0, 4);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
2013-08-03 03:16:03 +00:00
|
|
|
}
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_unlock_bh(&padapter->br_ext_lock);
|
2013-08-03 03:16:03 +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++)
|
2022-06-08 23:46:35 +00:00
|
|
|
*((unsigned short *)(skb->data + i * 2)) = *((unsigned short *)(skb->data + 4 + i * 2));
|
|
|
|
*((__be16 *)(skb->data + ETH_ALEN * 2)) = __constant_htons(ETH_P_8021Q);
|
|
|
|
*((unsigned short *)(skb->data + ETH_ALEN * 2 + 2)) = vlan_hdr;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
newskb = skb_copy(skb, GFP_ATOMIC);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!newskb)
|
2013-08-03 03:16:03 +00:00
|
|
|
return -1;
|
|
|
|
dev_kfree_skb_any(skb);
|
|
|
|
|
|
|
|
*pskb = skb = newskb;
|
|
|
|
if (is_vlan_tag) {
|
2022-06-08 23:46:35 +00:00
|
|
|
vlan_hdr = *((unsigned short *)(skb->data + ETH_ALEN * 2 + 2));
|
2013-08-03 03:16:03 +00:00
|
|
|
for (i = 0; i < 6; i++)
|
2022-06-08 23:46:35 +00:00
|
|
|
*((unsigned short *)(skb->data + ETH_ALEN * 2 + 2 - i * 2)) = *((unsigned short *)(skb->data + ETH_ALEN * 2 - 2 - i * 2));
|
2013-08-03 03:16:03 +00:00
|
|
|
skb_pull(skb, 4);
|
|
|
|
}
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
res = skb_linearize(skb);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (res < 0)
|
|
|
|
return -1;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
res = nat25_db_handle(padapter, skb, NAT25_INSERT);
|
|
|
|
if (res < 0) {
|
2022-06-08 23:46:35 +00:00
|
|
|
if (res == -2)
|
2013-08-03 03:16:03 +00:00
|
|
|
return -1;
|
2022-06-08 23:46:35 +00:00
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
return 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-08-03 03:16:03 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
memcpy(skb->data + ETH_ALEN, GET_MY_HWADDR(padapter), ETH_ALEN);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
dhcp_flag_bcast(padapter, skb);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
if (is_vlan_tag) {
|
|
|
|
skb_push(skb, 4);
|
|
|
|
for (i = 0; i < 6; i++)
|
2022-06-08 23:46:35 +00:00
|
|
|
*((unsigned short *)(skb->data + i * 2)) = *((unsigned short *)(skb->data + 4 + i * 2));
|
|
|
|
*((__be16 *)(skb->data + ETH_ALEN * 2)) = __constant_htons(ETH_P_8021Q);
|
|
|
|
*((unsigned short *)(skb->data + ETH_ALEN * 2 + 2)) = vlan_hdr;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-08-03 03:16:03 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
/* check if SA is equal to our MAC */
|
2022-06-08 23:46:35 +00:00
|
|
|
if (memcmp(skb->data + ETH_ALEN, GET_MY_HWADDR(padapter), ETH_ALEN))
|
|
|
|
return -1;
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 rtw_get_ff_hwaddr(struct xmit_frame *pxmitframe)
|
|
|
|
{
|
|
|
|
u32 addr;
|
2013-05-19 04:28:07 +00:00
|
|
|
struct pkt_attrib *pattrib = &pxmitframe->attrib;
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
switch (pattrib->qsel) {
|
|
|
|
case 0:
|
|
|
|
case 3:
|
|
|
|
addr = BE_QUEUE_INX;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
addr = BK_QUEUE_INX;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
case 5:
|
|
|
|
addr = VI_QUEUE_INX;
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
case 7:
|
|
|
|
addr = VO_QUEUE_INX;
|
|
|
|
break;
|
|
|
|
case 0x10:
|
|
|
|
addr = BCN_QUEUE_INX;
|
|
|
|
break;
|
|
|
|
case 0x11:/* BC/MC in PS (HIQ) */
|
|
|
|
addr = HIGH_QUEUE_INX;
|
|
|
|
break;
|
|
|
|
case 0x12:
|
|
|
|
default:
|
|
|
|
addr = MGT_QUEUE_INX;
|
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return addr;
|
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
static void do_queue_select(struct adapter *padapter, struct pkt_attrib *pattrib)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
u8 qsel;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
qsel = pattrib->priority;
|
|
|
|
|
|
|
|
pattrib->qsel = qsel;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The main transmit(tx) entry
|
|
|
|
*
|
|
|
|
* Return
|
|
|
|
* 1 enqueue
|
|
|
|
* 0 success, hardware will handle this xmit frame(packet)
|
|
|
|
* <0 fail
|
|
|
|
*/
|
2013-07-27 01:08:39 +00:00
|
|
|
s32 rtw_xmit(struct adapter *padapter, struct sk_buff **ppkt)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
|
|
|
|
struct xmit_frame *pxmitframe = NULL;
|
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
|
|
|
void *br_port = NULL;
|
|
|
|
s32 res;
|
|
|
|
|
|
|
|
pxmitframe = rtw_alloc_xmitframe(pxmitpriv);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!pxmitframe)
|
2013-05-08 21:45:39 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
rcu_read_lock();
|
2014-02-12 17:05:30 +00:00
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
|
2013-05-08 21:45:39 +00:00
|
|
|
br_port = rcu_dereference(padapter->pnetdev->rx_handler_data);
|
2014-02-12 17:05:30 +00:00
|
|
|
#else
|
|
|
|
br_port = rcu_dereference(padapter->pnetdev->br_port);
|
|
|
|
#endif
|
2013-05-08 21:45:39 +00:00
|
|
|
rcu_read_unlock();
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (br_port && check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_ADHOC_STATE)) {
|
2013-05-08 21:45:39 +00:00
|
|
|
res = rtw_br_client_tx(padapter, ppkt);
|
2013-08-03 03:16:03 +00:00
|
|
|
if (res == -1) {
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_free_xmitframe(pxmitpriv, pxmitframe);
|
|
|
|
return -1;
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
res = update_attrib(padapter, *ppkt, &pxmitframe->attrib);
|
|
|
|
|
|
|
|
if (res == _FAIL) {
|
|
|
|
rtw_free_xmitframe(pxmitpriv, pxmitframe);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
pxmitframe->pkt = *ppkt;
|
|
|
|
|
|
|
|
rtw_led_control(padapter, LED_CTL_TX);
|
|
|
|
|
|
|
|
do_queue_select(padapter, &pxmitframe->attrib);
|
|
|
|
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_lock_bh(&pxmitpriv->lock);
|
2013-08-03 03:16:03 +00:00
|
|
|
if (xmitframe_enqueue_for_sleeping_sta(padapter, pxmitframe)) {
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_unlock_bh(&pxmitpriv->lock);
|
2013-05-19 04:28:07 +00:00
|
|
|
return 1;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_unlock_bh(&pxmitpriv->lock);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!rtl8188eu_hal_xmit(padapter, pxmitframe))
|
2013-05-08 21:45:39 +00:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_frame *pxmitframe)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-08-03 03:16:03 +00:00
|
|
|
int ret = false;
|
|
|
|
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;
|
2022-06-08 23:46:35 +00:00
|
|
|
bool bmcst = is_multicast_ether_addr(pattrib->ra);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!check_fwstate(pmlmepriv, WIFI_AP_STATE))
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if (pattrib->psta)
|
2013-05-08 21:45:39 +00:00
|
|
|
psta = pattrib->psta;
|
|
|
|
else
|
2013-08-03 03:16:03 +00:00
|
|
|
psta = rtw_get_stainfo(pstapriv, pattrib->ra);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!psta)
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
if (pattrib->triggered == 1) {
|
2013-05-09 04:04:25 +00:00
|
|
|
if (bmcst)
|
2013-07-09 22:38:46 +00:00
|
|
|
pattrib->qsel = 0x11;/* HIQ */
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
if (bmcst) {
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_lock_bh(&psta->sleep_q.lock);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
if (pstapriv->sta_dz_bitmap) {/* if any one sta is in ps mode */
|
2014-12-13 21:06:22 +00:00
|
|
|
list_del_init(&pxmitframe->list);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-13 17:50:41 +00:00
|
|
|
list_add_tail(&pxmitframe->list, get_list_head(&psta->sleep_q));
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
psta->sleepq_len++;
|
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
pstapriv->tim_bitmap |= BIT(0);/* */
|
2013-05-08 21:45:39 +00:00
|
|
|
pstapriv->sta_dz_bitmap |= BIT(0);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
update_beacon(padapter, _TIM_IE_, NULL, false);/* tx bc/mc packets after upate bcn */
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-26 03:02:10 +00:00
|
|
|
ret = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_unlock_bh(&psta->sleep_q.lock);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_lock_bh(&psta->sleep_q.lock);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (psta->state & WIFI_SLEEP_STATE) {
|
2013-08-03 03:16:03 +00:00
|
|
|
u8 wmmps_ac = 0;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (pstapriv->sta_dz_bitmap & BIT(psta->aid)) {
|
2014-12-13 21:06:22 +00:00
|
|
|
list_del_init(&pxmitframe->list);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-13 17:50:41 +00:00
|
|
|
list_add_tail(&pxmitframe->list, get_list_head(&psta->sleep_q));
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
psta->sleepq_len++;
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
switch (pattrib->priority) {
|
|
|
|
case 1:
|
|
|
|
case 2:
|
2022-06-08 23:46:35 +00:00
|
|
|
wmmps_ac = psta->uapsd_bk & BIT(0);
|
2013-08-03 03:16:03 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
case 5:
|
2022-06-08 23:46:35 +00:00
|
|
|
wmmps_ac = psta->uapsd_vi & BIT(0);
|
2013-08-03 03:16:03 +00:00
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
case 7:
|
2022-06-08 23:46:35 +00:00
|
|
|
wmmps_ac = psta->uapsd_vo & BIT(0);
|
2013-08-03 03:16:03 +00:00
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
case 3:
|
|
|
|
default:
|
2022-06-08 23:46:35 +00:00
|
|
|
wmmps_ac = psta->uapsd_be & BIT(0);
|
2013-08-03 03:16:03 +00:00
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if (wmmps_ac)
|
2013-05-08 21:45:39 +00:00
|
|
|
psta->sleepq_ac_len++;
|
|
|
|
|
2013-08-03 03:16:03 +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);
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
if (psta->sleepq_len == 1) {
|
2013-07-09 22:38:46 +00:00
|
|
|
/* upate BCN for TIM IE */
|
2013-05-26 03:02:10 +00:00
|
|
|
update_beacon(padapter, _TIM_IE_, NULL, false);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
2013-05-26 03:02:10 +00:00
|
|
|
ret = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_unlock_bh(&psta->sleep_q.lock);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
static void dequeue_xmitframes_to_sleeping_queue(struct adapter *padapter, struct sta_info *psta, struct __queue *pframequeue)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-07-25 14:49:25 +00:00
|
|
|
struct list_head *plist, *phead;
|
2013-05-08 21:45:39 +00:00
|
|
|
u8 ac_index;
|
|
|
|
struct tx_servq *ptxservq;
|
|
|
|
struct pkt_attrib *pattrib;
|
2013-05-19 04:28:07 +00:00
|
|
|
struct xmit_frame *pxmitframe;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct hw_xmit *phwxmits = padapter->xmitpriv.hwxmits;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
phead = get_list_head(pframequeue);
|
2014-12-13 21:06:22 +00:00
|
|
|
plist = phead->next;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-13 21:06:22 +00:00
|
|
|
while (phead != plist) {
|
2014-12-13 16:40:44 +00:00
|
|
|
pxmitframe = container_of(plist, struct xmit_frame, list);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 21:06:22 +00:00
|
|
|
plist = plist->next;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
|
|
|
xmitframe_enqueue_for_sleeping_sta(padapter, pxmitframe);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pattrib = &pxmitframe->attrib;
|
|
|
|
|
|
|
|
ptxservq = rtw_get_sta_pending(padapter, psta, pattrib->priority, (u8 *)(&ac_index));
|
|
|
|
|
|
|
|
ptxservq->qcnt--;
|
2013-05-19 04:28:07 +00:00
|
|
|
phwxmits[ac_index].accnt--;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
void stop_sta_xmit(struct adapter *padapter, struct sta_info *psta)
|
2013-05-19 04:28:07 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
struct sta_info *psta_bmc;
|
|
|
|
struct sta_xmit_priv *pstaxmitpriv;
|
2013-05-19 04:28:07 +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;
|
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* for BC/MC Frames */
|
2013-05-08 21:45:39 +00:00
|
|
|
psta_bmc = rtw_get_bcmc_stainfo(padapter);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_lock_bh(&pxmitpriv->lock);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
psta->state |= WIFI_SLEEP_STATE;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +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
|
|
|
dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->vo_q.sta_pending);
|
2022-06-08 23:46:35 +00:00
|
|
|
list_del_init(&pstaxmitpriv->vo_q.tx_pending);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->vi_q.sta_pending);
|
2022-06-08 23:46:35 +00:00
|
|
|
list_del_init(&pstaxmitpriv->vi_q.tx_pending);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->be_q.sta_pending);
|
2022-06-08 23:46:35 +00:00
|
|
|
list_del_init(&pstaxmitpriv->be_q.tx_pending);
|
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);
|
2022-06-08 23:46:35 +00:00
|
|
|
list_del_init(&pstaxmitpriv->bk_q.tx_pending);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-09 22:38:46 +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);
|
2022-06-08 23:46:35 +00:00
|
|
|
list_del_init(&pstaxmitpriv->be_q.tx_pending);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_unlock_bh(&pxmitpriv->lock);
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta)
|
2013-05-19 04:28:07 +00:00
|
|
|
{
|
2013-08-03 03:16:03 +00:00
|
|
|
u8 update_mask = 0, wmmps_ac = 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct sta_info *psta_bmc;
|
2013-07-25 14:49:25 +00:00
|
|
|
struct list_head *xmitframe_plist, *xmitframe_phead;
|
2013-08-03 03:16:03 +00:00
|
|
|
struct xmit_frame *pxmitframe = NULL;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct sta_priv *pstapriv = &padapter->stapriv;
|
|
|
|
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_lock_bh(&psta->sleep_q.lock);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
xmitframe_phead = get_list_head(&psta->sleep_q);
|
2014-12-13 21:06:22 +00:00
|
|
|
xmitframe_plist = xmitframe_phead->next;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 21:06:22 +00:00
|
|
|
while (xmitframe_phead != xmitframe_plist) {
|
2014-12-13 16:40:44 +00:00
|
|
|
pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 21:06:22 +00:00
|
|
|
xmitframe_plist = xmitframe_plist->next;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 21:06:22 +00:00
|
|
|
list_del_init(&pxmitframe->list);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
switch (pxmitframe->attrib.priority) {
|
|
|
|
case 1:
|
|
|
|
case 2:
|
2022-06-08 23:46:35 +00:00
|
|
|
wmmps_ac = psta->uapsd_bk & BIT(1);
|
2013-08-03 03:16:03 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
case 5:
|
2022-06-08 23:46:35 +00:00
|
|
|
wmmps_ac = psta->uapsd_vi & BIT(1);
|
2013-08-03 03:16:03 +00:00
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
case 7:
|
2022-06-08 23:46:35 +00:00
|
|
|
wmmps_ac = psta->uapsd_vo & BIT(1);
|
2013-08-03 03:16:03 +00:00
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
case 3:
|
|
|
|
default:
|
2022-06-08 23:46:35 +00:00
|
|
|
wmmps_ac = psta->uapsd_be & BIT(1);
|
2013-08-03 03:16:03 +00:00
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
psta->sleepq_len--;
|
2013-08-03 03:16:03 +00:00
|
|
|
if (psta->sleepq_len > 0)
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitframe->attrib.mdata = 1;
|
|
|
|
else
|
|
|
|
pxmitframe->attrib.mdata = 0;
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
if (wmmps_ac) {
|
2013-05-08 21:45:39 +00:00
|
|
|
psta->sleepq_ac_len--;
|
2013-08-03 03:16:03 +00:00
|
|
|
if (psta->sleepq_ac_len > 0) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitframe->attrib.mdata = 1;
|
|
|
|
pxmitframe->attrib.eosp = 0;
|
2013-08-03 03:16:03 +00:00
|
|
|
} else {
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitframe->attrib.mdata = 0;
|
|
|
|
pxmitframe->attrib.eosp = 1;
|
|
|
|
}
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitframe->attrib.triggered = 1;
|
|
|
|
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_unlock_bh(&psta->sleep_q.lock);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (rtl8188eu_hal_xmit(padapter, pxmitframe))
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_os_xmit_complete(padapter, pxmitframe);
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_lock_bh(&psta->sleep_q.lock);
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
if (psta->sleepq_len == 0) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pstapriv->tim_bitmap &= ~BIT(psta->aid);
|
|
|
|
|
|
|
|
update_mask = BIT(0);
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (psta->state & WIFI_SLEEP_STATE)
|
2013-05-08 21:45:39 +00:00
|
|
|
psta->state ^= WIFI_SLEEP_STATE;
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
if (psta->state & WIFI_STA_ALIVE_CHK_STATE) {
|
2013-05-08 21:45:39 +00:00
|
|
|
psta->expire_to = pstapriv->expire_to;
|
|
|
|
psta->state ^= WIFI_STA_ALIVE_CHK_STATE;
|
|
|
|
}
|
|
|
|
|
|
|
|
pstapriv->sta_dz_bitmap &= ~BIT(psta->aid);
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_unlock_bh(&psta->sleep_q.lock);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* for BC/MC Frames */
|
2013-05-08 21:45:39 +00:00
|
|
|
psta_bmc = rtw_get_bcmc_stainfo(padapter);
|
2013-05-09 04:04:25 +00:00
|
|
|
if (!psta_bmc)
|
2013-05-08 21:45:39 +00:00
|
|
|
return;
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if ((pstapriv->sta_dz_bitmap & 0xfffe) == 0x0) { /* no any sta in ps mode */
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_lock_bh(&psta_bmc->sleep_q.lock);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
xmitframe_phead = get_list_head(&psta_bmc->sleep_q);
|
2014-12-13 21:06:22 +00:00
|
|
|
xmitframe_plist = xmitframe_phead->next;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 21:06:22 +00:00
|
|
|
while (xmitframe_phead != xmitframe_plist) {
|
2014-12-13 16:40:44 +00:00
|
|
|
pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 21:06:22 +00:00
|
|
|
xmitframe_plist = xmitframe_plist->next;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 21:06:22 +00:00
|
|
|
list_del_init(&pxmitframe->list);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
psta_bmc->sleepq_len--;
|
2013-08-03 03:16:03 +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;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitframe->attrib.triggered = 1;
|
|
|
|
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_unlock_bh(&psta_bmc->sleep_q.lock);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (rtl8188eu_hal_xmit(padapter, pxmitframe))
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_os_xmit_complete(padapter, pxmitframe);
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_lock_bh(&psta_bmc->sleep_q.lock);
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
|
|
|
|
2013-08-03 03:16:03 +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);
|
|
|
|
|
|
|
|
update_mask |= BIT(1);
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
|
|
|
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_unlock_bh(&psta_bmc->sleep_q.lock);
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if (update_mask)
|
2013-05-26 03:02:10 +00:00
|
|
|
update_beacon(padapter, _TIM_IE_, NULL, false);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *psta)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-08-03 03:16:03 +00:00
|
|
|
u8 wmmps_ac = 0;
|
2013-07-25 14:49:25 +00:00
|
|
|
struct list_head *xmitframe_plist, *xmitframe_phead;
|
2013-08-03 03:16:03 +00:00
|
|
|
struct xmit_frame *pxmitframe = NULL;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct sta_priv *pstapriv = &padapter->stapriv;
|
|
|
|
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_lock_bh(&psta->sleep_q.lock);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
xmitframe_phead = get_list_head(&psta->sleep_q);
|
2014-12-13 21:06:22 +00:00
|
|
|
xmitframe_plist = xmitframe_phead->next;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 21:06:22 +00:00
|
|
|
while (xmitframe_phead != xmitframe_plist) {
|
2014-12-13 16:40:44 +00:00
|
|
|
pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 21:06:22 +00:00
|
|
|
xmitframe_plist = xmitframe_plist->next;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
switch (pxmitframe->attrib.priority) {
|
|
|
|
case 1:
|
|
|
|
case 2:
|
2022-06-08 23:46:35 +00:00
|
|
|
wmmps_ac = psta->uapsd_bk & BIT(1);
|
2013-08-03 03:16:03 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
case 5:
|
2022-06-08 23:46:35 +00:00
|
|
|
wmmps_ac = psta->uapsd_vi & BIT(1);
|
2013-08-03 03:16:03 +00:00
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
case 7:
|
2022-06-08 23:46:35 +00:00
|
|
|
wmmps_ac = psta->uapsd_vo & BIT(1);
|
2013-08-03 03:16:03 +00:00
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
case 3:
|
|
|
|
default:
|
2022-06-08 23:46:35 +00:00
|
|
|
wmmps_ac = psta->uapsd_be & BIT(1);
|
2013-08-03 03:16:03 +00:00
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if (!wmmps_ac)
|
2013-05-08 21:45:39 +00:00
|
|
|
continue;
|
|
|
|
|
2014-12-13 21:06:22 +00:00
|
|
|
list_del_init(&pxmitframe->list);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
psta->sleepq_len--;
|
|
|
|
psta->sleepq_ac_len--;
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
if (psta->sleepq_ac_len > 0) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitframe->attrib.mdata = 1;
|
|
|
|
pxmitframe->attrib.eosp = 0;
|
2013-08-03 03:16:03 +00:00
|
|
|
} else {
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmitframe->attrib.mdata = 0;
|
|
|
|
pxmitframe->attrib.eosp = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
pxmitframe->attrib.triggered = 1;
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (rtl8188eu_hal_xmit(padapter, pxmitframe))
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_os_xmit_complete(padapter, pxmitframe);
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
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);
|
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* upate BCN for TIM IE */
|
2013-05-26 03:02:10 +00:00
|
|
|
update_beacon(padapter, _TIM_IE_, NULL, false);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
|
|
|
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_unlock_bh(&psta->sleep_q.lock);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void rtw_sctx_init(struct submit_ctx *sctx, int timeout_ms)
|
|
|
|
{
|
|
|
|
sctx->timeout_ms = timeout_ms;
|
2014-12-13 21:18:54 +00:00
|
|
|
sctx->submit_time = jiffies;
|
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;
|
2013-05-19 04:28:07 +00:00
|
|
|
unsigned long expire;
|
2013-05-08 21:45:39 +00:00
|
|
|
int status = 0;
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
expire = sctx->timeout_ms ? msecs_to_jiffies(sctx->timeout_ms) : MAX_SCHEDULE_TIMEOUT;
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!wait_for_completion_timeout(&sctx->done, expire))
|
2013-05-08 21:45:39 +00:00
|
|
|
/* timeout, do something?? */
|
|
|
|
status = RTW_SCTX_DONE_TIMEOUT;
|
2022-06-08 23:46:35 +00:00
|
|
|
else
|
2013-05-08 21:45:39 +00:00
|
|
|
status = sctx->status;
|
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
if (status == RTW_SCTX_DONE_SUCCESS)
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = _SUCCESS;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void rtw_sctx_done_err(struct submit_ctx **sctx, int status)
|
|
|
|
{
|
|
|
|
if (*sctx) {
|
|
|
|
(*sctx)->status = status;
|
|
|
|
complete(&((*sctx)->done));
|
|
|
|
*sctx = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int rtw_ack_tx_wait(struct xmit_priv *pxmitpriv, u32 timeout_ms)
|
|
|
|
{
|
|
|
|
struct submit_ctx *pack_tx_ops = &pxmitpriv->ack_tx_ops;
|
|
|
|
|
2014-12-13 21:18:54 +00:00
|
|
|
pack_tx_ops->submit_time = jiffies;
|
2013-05-08 21:45:39 +00:00
|
|
|
pack_tx_ops->timeout_ms = timeout_ms;
|
|
|
|
pack_tx_ops->status = RTW_SCTX_SUBMITTED;
|
|
|
|
|
|
|
|
return rtw_sctx_wait(pack_tx_ops);
|
|
|
|
}
|
|
|
|
|
|
|
|
void rtw_ack_tx_done(struct xmit_priv *pxmitpriv, int status)
|
|
|
|
{
|
|
|
|
struct submit_ctx *pack_tx_ops = &pxmitpriv->ack_tx_ops;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-03 03:16:03 +00:00
|
|
|
if (pxmitpriv->ack_tx)
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_sctx_done_err(&pack_tx_ops, status);
|
|
|
|
}
|