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_CMD_C_
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
#include "../include/osdep_service.h"
|
|
|
|
#include "../include/drv_types.h"
|
|
|
|
#include "../include/recv_osdep.h"
|
|
|
|
#include "../include/mlme_osdep.h"
|
|
|
|
#include "../include/rtw_br_ext.h"
|
|
|
|
#include "../include/rtw_mlme_ext.h"
|
|
|
|
#include "../include/rtl8188e_dm.h"
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
Caller and the rtw_cmd_thread can protect cmd_q by spin_lock.
|
|
|
|
No irqsave is necessary.
|
|
|
|
*/
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
static int _rtw_init_cmd_priv(struct cmd_priv *pcmdpriv)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-07-27 19:49:25 +00:00
|
|
|
int res = _SUCCESS;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
init_completion(&pcmdpriv->enqueue_cmd);
|
2014-12-13 21:25:08 +00:00
|
|
|
/* sema_init(&(pcmdpriv->cmd_done_sema), 0); */
|
2022-06-08 23:46:35 +00:00
|
|
|
init_completion(&pcmdpriv->start_cmd_thread);
|
|
|
|
init_completion(&pcmdpriv->stop_cmd_thread);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
rtw_init_queue(&pcmdpriv->cmd_queue);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pcmdpriv->cmd_seq = 1;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-13 15:08:01 +00:00
|
|
|
pcmdpriv->cmd_allocated_buf = kzalloc(MAX_CMDSZ + CMDBUFF_ALIGN_SZ,
|
|
|
|
GFP_KERNEL);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!pcmdpriv->cmd_allocated_buf) {
|
2013-07-27 19:49:25 +00:00
|
|
|
res = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
pcmdpriv->cmd_buf = pcmdpriv->cmd_allocated_buf + CMDBUFF_ALIGN_SZ - ((size_t)(pcmdpriv->cmd_allocated_buf) & (CMDBUFF_ALIGN_SZ - 1));
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-13 15:08:01 +00:00
|
|
|
pcmdpriv->rsp_allocated_buf = kzalloc(MAX_RSPSZ + 4, GFP_KERNEL);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!pcmdpriv->rsp_allocated_buf) {
|
2013-07-27 19:49:25 +00:00
|
|
|
res = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
pcmdpriv->rsp_buf = pcmdpriv->rsp_allocated_buf + 4 - ((size_t)(pcmdpriv->rsp_allocated_buf) & 3);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
pcmdpriv->cmd_done_cnt = 0;
|
|
|
|
pcmdpriv->rsp_cnt = 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
exit:
|
2014-12-01 22:31:15 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return res;
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-25 16:02:03 +00:00
|
|
|
static void c2h_wk_callback(struct work_struct *work);
|
2013-07-21 15:35:02 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
static int _rtw_init_evt_priv(struct evt_priv *pevtpriv)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-07-27 19:49:25 +00:00
|
|
|
int res = _SUCCESS;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */
|
2022-06-08 23:46:35 +00:00
|
|
|
atomic_set(&pevtpriv->event_seq, 0);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
INIT_WORK(&pevtpriv->c2h_wk, c2h_wk_callback);
|
2013-05-26 03:02:10 +00:00
|
|
|
pevtpriv->c2h_wk_alive = false;
|
2022-06-08 23:46:35 +00:00
|
|
|
pevtpriv->c2h_queue = rtw_cbuf_alloc(C2H_QUEUE_MAX_LEN + 1);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2013-10-19 17:45:47 +00:00
|
|
|
void rtw_free_evt_priv(struct evt_priv *pevtpriv)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2022-06-08 23:46:35 +00:00
|
|
|
cancel_work_sync(&pevtpriv->c2h_wk);
|
2013-05-09 04:04:25 +00:00
|
|
|
while (pevtpriv->c2h_wk_alive)
|
2022-06-08 23:46:35 +00:00
|
|
|
msleep(10);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
while (!rtw_cbuf_empty(pevtpriv->c2h_queue)) {
|
2013-07-27 19:49:25 +00:00
|
|
|
void *c2h = rtw_cbuf_pop(pevtpriv->c2h_queue);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (c2h && c2h != (void *)pevtpriv)
|
2013-10-19 17:45:47 +00:00
|
|
|
kfree(c2h);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
static void _rtw_free_cmd_priv(struct cmd_priv *pcmdpriv)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-07-27 19:49:25 +00:00
|
|
|
if (pcmdpriv) {
|
2022-06-08 23:46:35 +00:00
|
|
|
kfree(pcmdpriv->cmd_allocated_buf);
|
|
|
|
kfree(pcmdpriv->rsp_allocated_buf);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Calling Context:
|
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
rtw_enqueue_cmd can only be called between kernel thread,
|
2013-05-08 21:45:39 +00:00
|
|
|
since only spin_lock is used.
|
|
|
|
|
|
|
|
ISR/Call-Back functions can't call this sub-function.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
static int _rtw_enqueue_cmd(struct __queue *queue, struct cmd_obj *obj)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2014-11-28 23:37:57 +00:00
|
|
|
unsigned long flags;
|
2014-12-01 22:31:15 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!obj)
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
|
2014-11-28 23:37:57 +00:00
|
|
|
spin_lock_irqsave(&queue->lock, flags);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 17:50:41 +00:00
|
|
|
list_add_tail(&obj->list, &queue->queue);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-11-28 23:37:57 +00:00
|
|
|
spin_unlock_irqrestore(&queue->lock, flags);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
exit:
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return _SUCCESS;
|
|
|
|
}
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
static struct cmd_obj *_rtw_dequeue_cmd(struct __queue *queue)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct cmd_obj *obj;
|
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(&queue->lock, flags);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (list_empty(&queue->queue)) {
|
2013-05-08 21:45:39 +00:00
|
|
|
obj = NULL;
|
2013-07-27 19:49:25 +00:00
|
|
|
} else {
|
2022-06-08 23:46:35 +00:00
|
|
|
obj = container_of((&queue->queue)->next, struct cmd_obj, list);
|
|
|
|
list_del_init(&obj->list);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2014-11-28 23:37:57 +00:00
|
|
|
spin_unlock_irqrestore(&queue->lock, flags);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 rtw_init_cmd_priv(struct cmd_priv *pcmdpriv)
|
|
|
|
{
|
|
|
|
u32 res;
|
2014-12-01 22:31:15 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
res = _rtw_init_cmd_priv(pcmdpriv);
|
2014-12-01 22:31:15 +00:00
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
return res;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
u32 rtw_init_evt_priv(struct evt_priv *pevtpriv)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
int res;
|
2014-12-01 22:31:15 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
res = _rtw_init_evt_priv(pevtpriv);
|
2014-12-01 22:31:15 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2013-10-19 17:45:47 +00:00
|
|
|
void rtw_free_cmd_priv(struct cmd_priv *pcmdpriv)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
_rtw_free_cmd_priv(pcmdpriv);
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-10-19 17:45:47 +00:00
|
|
|
static int rtw_cmd_filter(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-07-09 22:38:46 +00:00
|
|
|
u8 bAllow = false; /* set to true to allow enqueuing cmd when hw_init_completed is false */
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if (cmd_obj->cmdcode == GEN_CMD_CODE(_SetChannelPlan))
|
2013-05-26 03:02:10 +00:00
|
|
|
bAllow = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
if ((!pcmdpriv->padapter->hw_init_completed && !bAllow) ||
|
|
|
|
!pcmdpriv->cmdthd_running) /* com_thread not running */
|
2013-05-08 21:45:39 +00:00
|
|
|
return _FAIL;
|
|
|
|
return _SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj)
|
|
|
|
{
|
|
|
|
int res = _FAIL;
|
2013-07-27 19:49:25 +00:00
|
|
|
struct adapter *padapter = pcmdpriv->padapter;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!cmd_obj)
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
|
|
|
|
cmd_obj->padapter = padapter;
|
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
res = rtw_cmd_filter(pcmdpriv, cmd_obj);
|
|
|
|
if (_FAIL == res) {
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_free_cmd_obj(cmd_obj);
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
res = _rtw_enqueue_cmd(&pcmdpriv->cmd_queue, cmd_obj);
|
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if (res == _SUCCESS)
|
2022-06-08 23:46:35 +00:00
|
|
|
complete(&pcmdpriv->enqueue_cmd);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
|
|
|
exit:
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct cmd_obj *rtw_dequeue_cmd(struct cmd_priv *pcmdpriv)
|
|
|
|
{
|
|
|
|
struct cmd_obj *cmd_obj;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
cmd_obj = _rtw_dequeue_cmd(&pcmdpriv->cmd_queue);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return cmd_obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
void rtw_free_cmd_obj(struct cmd_obj *pcmd)
|
|
|
|
{
|
2014-12-01 22:31:15 +00:00
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
if ((pcmd->cmdcode != _JoinBss_CMD_) && (pcmd->cmdcode != _CreateBss_CMD_)) {
|
2013-07-09 22:38:46 +00:00
|
|
|
/* free parmbuf in cmd_obj */
|
2013-10-19 17:45:47 +00:00
|
|
|
kfree(pcmd->parmbuf);
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (pcmd->rsp) {
|
2013-07-27 19:49:25 +00:00
|
|
|
if (pcmd->rspsz != 0) {
|
2013-07-09 22:38:46 +00:00
|
|
|
/* free rsp in cmd_obj */
|
2013-10-19 17:45:47 +00:00
|
|
|
kfree(pcmd->rsp);
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* free cmd_obj */
|
2013-10-19 17:45:47 +00:00
|
|
|
kfree(pcmd);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-07-24 17:47:20 +00:00
|
|
|
int rtw_cmd_thread(void *context)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
u8 ret;
|
|
|
|
struct cmd_obj *pcmd;
|
2013-06-21 18:41:29 +00:00
|
|
|
u8 *pcmdbuf;
|
2013-07-27 19:49:25 +00:00
|
|
|
u8 (*cmd_hdl)(struct adapter *padapter, u8 *pbuf);
|
2013-07-27 01:08:39 +00:00
|
|
|
void (*pcmd_callback)(struct adapter *dev, struct cmd_obj *pcmd);
|
2013-07-27 19:49:25 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)context;
|
2022-06-08 23:46:35 +00:00
|
|
|
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pcmdbuf = pcmdpriv->cmd_buf;
|
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
pcmdpriv->cmdthd_running = true;
|
2022-06-08 23:46:35 +00:00
|
|
|
complete(&pcmdpriv->start_cmd_thread);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
while (1) {
|
2022-06-08 23:46:35 +00:00
|
|
|
wait_for_completion(&pcmdpriv->enqueue_cmd);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
_next:
|
2013-07-27 19:49:25 +00:00
|
|
|
if (padapter->bDriverStopped ||
|
2022-06-08 23:46:35 +00:00
|
|
|
padapter->bSurpriseRemoved)
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
pcmd = rtw_dequeue_cmd(pcmdpriv);
|
|
|
|
if (!pcmd)
|
2013-05-08 21:45:39 +00:00
|
|
|
continue;
|
|
|
|
|
2013-07-20 02:12:05 +00:00
|
|
|
if (_FAIL == rtw_cmd_filter(pcmdpriv, pcmd)) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pcmd->res = H2C_DROPPED;
|
|
|
|
goto post_process;
|
|
|
|
}
|
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
pcmd->cmdsz = _RND4((pcmd->cmdsz));/* _RND4 */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-10-19 17:45:47 +00:00
|
|
|
memcpy(pcmdbuf, pcmd->parmbuf, pcmd->cmdsz);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-10-19 17:45:47 +00:00
|
|
|
if (pcmd->cmdcode < ARRAY_SIZE(wlancmds)) {
|
2013-05-08 21:45:39 +00:00
|
|
|
cmd_hdl = wlancmds[pcmd->cmdcode].h2cfuns;
|
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
if (cmd_hdl) {
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = cmd_hdl(pcmd->padapter, pcmdbuf);
|
|
|
|
pcmd->res = ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
pcmdpriv->cmd_seq++;
|
2013-07-27 19:49:25 +00:00
|
|
|
} else {
|
2013-05-08 21:45:39 +00:00
|
|
|
pcmd->res = H2C_PARAMETERS_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd_hdl = NULL;
|
|
|
|
|
|
|
|
post_process:
|
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* call callback function for post-processed */
|
2013-10-19 17:45:47 +00:00
|
|
|
if (pcmd->cmdcode < ARRAY_SIZE(rtw_cmd_callback)) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pcmd_callback = rtw_cmd_callback[pcmd->cmdcode].callback;
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!pcmd_callback)
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_free_cmd_obj(pcmd);
|
2022-06-08 23:46:35 +00:00
|
|
|
else
|
2013-07-27 19:49:25 +00:00
|
|
|
/* todo: !!! fill rsp_buf to pcmd->rsp if (pcmd->rsp!= NULL) */
|
2013-07-09 22:38:46 +00:00
|
|
|
pcmd_callback(pcmd->padapter, pcmd);/* need conider that free cmd_obj in rtw_cmd_callback */
|
2013-07-27 19:49:25 +00:00
|
|
|
} else {
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_free_cmd_obj(pcmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
flush_signals_thread();
|
|
|
|
|
|
|
|
goto _next;
|
|
|
|
}
|
2013-07-27 19:49:25 +00:00
|
|
|
pcmdpriv->cmdthd_running = false;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* free all cmd_obj resources */
|
2013-07-27 19:49:25 +00:00
|
|
|
do {
|
2013-05-08 21:45:39 +00:00
|
|
|
pcmd = rtw_dequeue_cmd(pcmdpriv);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!pcmd)
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
rtw_free_cmd_obj(pcmd);
|
2013-07-27 19:49:25 +00:00
|
|
|
} while (1);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
complete(&pcmdpriv->stop_cmd_thread);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
return 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
rtw_sitesurvey_cmd(~)
|
|
|
|
### NOTE:#### (!!!!)
|
|
|
|
MUST TAKE CARE THAT BEFORE CALLING THIS FUNC, YOU SHOULD HAVE LOCKED pmlmepriv->lock
|
|
|
|
*/
|
2013-07-27 01:08:39 +00:00
|
|
|
u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, int ssid_num,
|
2013-05-08 21:45:39 +00:00
|
|
|
struct rtw_ieee80211_channel *ch, int ch_num)
|
|
|
|
{
|
|
|
|
u8 res = _FAIL;
|
|
|
|
struct cmd_obj *ph2c;
|
|
|
|
struct sitesurvey_parm *psurveyPara;
|
2013-05-19 04:28:07 +00:00
|
|
|
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (check_fwstate(pmlmepriv, _FW_LINKED)) {
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SCAN, 1);
|
|
|
|
}
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (check_fwstate(pmlmepriv, _FW_LINKED)) {
|
2013-05-08 21:45:39 +00:00
|
|
|
p2p_ps_wk_cmd(padapter, P2P_PS_SCAN, 1);
|
|
|
|
}
|
|
|
|
|
2014-12-13 15:08:01 +00:00
|
|
|
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!ph2c)
|
2013-05-08 21:45:39 +00:00
|
|
|
return _FAIL;
|
|
|
|
|
2014-12-13 15:08:01 +00:00
|
|
|
psurveyPara = kzalloc(sizeof(struct sitesurvey_parm), GFP_ATOMIC);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!psurveyPara) {
|
2013-10-19 17:45:47 +00:00
|
|
|
kfree(ph2c);
|
2013-05-08 21:45:39 +00:00
|
|
|
return _FAIL;
|
|
|
|
}
|
|
|
|
|
2013-05-26 03:02:10 +00:00
|
|
|
rtw_free_network_queue(padapter, false);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
init_h2fwcmd_w_parm_no_rsp(ph2c, psurveyPara, GEN_CMD_CODE(_SiteSurvey));
|
|
|
|
|
|
|
|
/* psurveyPara->bsslimit = 48; */
|
|
|
|
psurveyPara->scan_mode = pmlmepriv->scan_mode;
|
|
|
|
|
|
|
|
/* prepare ssid list */
|
|
|
|
if (ssid) {
|
|
|
|
int i;
|
2013-07-27 19:49:25 +00:00
|
|
|
for (i = 0; i < ssid_num && i < RTW_SSID_SCAN_AMOUNT; i++) {
|
2013-05-08 21:45:39 +00:00
|
|
|
if (ssid[i].SsidLength) {
|
2013-10-19 17:45:47 +00:00
|
|
|
memcpy(&psurveyPara->ssid[i], &ssid[i], sizeof(struct ndis_802_11_ssid));
|
2013-05-08 21:45:39 +00:00
|
|
|
psurveyPara->ssid_num++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* prepare channel list */
|
|
|
|
if (ch) {
|
|
|
|
int i;
|
2013-07-27 19:49:25 +00:00
|
|
|
for (i = 0; i < ch_num && i < RTW_CHANNEL_SCAN_AMOUNT; i++) {
|
2013-05-08 21:45:39 +00:00
|
|
|
if (ch[i].hw_value && !(ch[i].flags & RTW_IEEE80211_CHAN_DISABLED)) {
|
2013-10-19 17:45:47 +00:00
|
|
|
memcpy(&psurveyPara->ch[i], &ch[i], sizeof(struct rtw_ieee80211_channel));
|
2013-05-08 21:45:39 +00:00
|
|
|
psurveyPara->ch_num++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
set_fwstate(pmlmepriv, _FW_UNDER_SURVEY);
|
|
|
|
|
|
|
|
res = rtw_enqueue_cmd(pcmdpriv, ph2c);
|
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if (res == _SUCCESS) {
|
2014-12-13 21:18:54 +00:00
|
|
|
pmlmepriv->scan_start_time = jiffies;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-21 02:59:59 +00:00
|
|
|
_set_timer(&pmlmepriv->scan_to_timer, SCANNING_TIMEOUT);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
rtw_led_control(padapter, LED_CTL_SITE_SURVEY);
|
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
pmlmepriv->scan_interval = SCAN_INTERVAL;/* 30*2 sec = 60sec */
|
2013-05-08 21:45:39 +00:00
|
|
|
} else {
|
|
|
|
_clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY);
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-07-27 19:49:25 +00:00
|
|
|
struct cmd_obj *ph2c;
|
|
|
|
struct setdatarate_parm *pbsetdataratepara;
|
|
|
|
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
2013-05-08 21:45:39 +00:00
|
|
|
u8 res = _SUCCESS;
|
|
|
|
|
2014-12-13 15:08:01 +00:00
|
|
|
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!ph2c) {
|
2013-05-08 21:45:39 +00:00
|
|
|
res = _FAIL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-13 15:08:01 +00:00
|
|
|
pbsetdataratepara = kzalloc(sizeof(struct setdatarate_parm), GFP_ATOMIC);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!pbsetdataratepara) {
|
2013-10-19 17:45:47 +00:00
|
|
|
kfree(ph2c);
|
2013-05-08 21:45:39 +00:00
|
|
|
res = _FAIL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
init_h2fwcmd_w_parm_no_rsp(ph2c, pbsetdataratepara, GEN_CMD_CODE(_SetDataRate));
|
|
|
|
pbsetdataratepara->mac_id = 5;
|
2013-10-19 17:45:47 +00:00
|
|
|
memcpy(pbsetdataratepara->datarates, rateset, NumRates);
|
2013-05-08 21:45:39 +00:00
|
|
|
res = rtw_enqueue_cmd(pcmdpriv, ph2c);
|
|
|
|
exit:
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
void rtw_getbbrfreg_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd)
|
2013-05-19 04:28:07 +00:00
|
|
|
{
|
2014-12-01 22:31:15 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-10-19 17:45:47 +00:00
|
|
|
kfree(pcmd->parmbuf);
|
|
|
|
kfree(pcmd);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
u8 rtw_createbss_cmd(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-07-27 19:49:25 +00:00
|
|
|
struct cmd_obj *pcmd;
|
|
|
|
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
|
|
|
struct wlan_bssid_ex *pdev_network = &padapter->registrypriv.dev_network;
|
|
|
|
u8 res = _SUCCESS;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
rtw_led_control(padapter, LED_CTL_START_TO_LINK);
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
pcmd = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
|
|
|
|
if (!pcmd) {
|
2013-07-27 19:49:25 +00:00
|
|
|
res = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-13 05:13:40 +00:00
|
|
|
INIT_LIST_HEAD(&pcmd->list);
|
2013-05-08 21:45:39 +00:00
|
|
|
pcmd->cmdcode = _CreateBss_CMD_;
|
|
|
|
pcmd->parmbuf = (unsigned char *)pdev_network;
|
2013-07-27 19:49:25 +00:00
|
|
|
pcmd->cmdsz = get_wlan_bssid_ex_sz((struct wlan_bssid_ex *)pdev_network);
|
2013-05-08 21:45:39 +00:00
|
|
|
pcmd->rsp = NULL;
|
2013-05-19 04:28:07 +00:00
|
|
|
pcmd->rspsz = 0;
|
|
|
|
pdev_network->Length = pcmd->cmdsz;
|
|
|
|
res = rtw_enqueue_cmd(pcmdpriv, pcmd);
|
2013-05-08 21:45:39 +00:00
|
|
|
exit:
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-06-21 18:41:29 +00:00
|
|
|
u8 res = _SUCCESS;
|
2013-05-08 21:45:39 +00:00
|
|
|
uint t_len = 0;
|
2013-07-24 02:31:04 +00:00
|
|
|
struct wlan_bssid_ex *psecnetwork;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct cmd_obj *pcmd;
|
2013-07-27 19:49:25 +00:00
|
|
|
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
|
|
|
struct qos_priv *pqospriv = &pmlmepriv->qospriv;
|
|
|
|
struct security_priv *psecuritypriv = &padapter->securitypriv;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct registry_priv *pregistrypriv = &padapter->registrypriv;
|
2013-07-27 19:49:25 +00:00
|
|
|
struct ht_priv *phtpriv = &pmlmepriv->htpriv;
|
2013-07-24 02:31:04 +00:00
|
|
|
enum ndis_802_11_network_infra ndis_network_mode = pnetwork->network.InfrastructureMode;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
2022-06-08 23:46:35 +00:00
|
|
|
struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
rtw_led_control(padapter, LED_CTL_START_TO_LINK);
|
|
|
|
|
2014-12-13 15:08:01 +00:00
|
|
|
pcmd = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!pcmd) {
|
2013-07-27 19:49:25 +00:00
|
|
|
res = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
2013-07-09 22:38:46 +00:00
|
|
|
/* for IEs is fix buf size */
|
2013-07-24 02:31:04 +00:00
|
|
|
t_len = sizeof(struct wlan_bssid_ex);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* for hidden ap to set fw_state here */
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_ADHOC_STATE)) {
|
2013-07-27 19:49:25 +00:00
|
|
|
switch (ndis_network_mode) {
|
|
|
|
case Ndis802_11IBSS:
|
|
|
|
set_fwstate(pmlmepriv, WIFI_ADHOC_STATE);
|
|
|
|
break;
|
|
|
|
case Ndis802_11Infrastructure:
|
|
|
|
set_fwstate(pmlmepriv, WIFI_STATION_STATE);
|
|
|
|
break;
|
|
|
|
case Ndis802_11APMode:
|
|
|
|
case Ndis802_11AutoUnknown:
|
|
|
|
case Ndis802_11InfrastructureMax:
|
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
psecnetwork = (struct wlan_bssid_ex *)&psecuritypriv->sec_bss;
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!psecnetwork) {
|
|
|
|
kfree(pcmd);
|
2013-07-27 19:49:25 +00:00
|
|
|
res = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-13 04:43:35 +00:00
|
|
|
memset(psecnetwork, 0, t_len);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-10-19 17:45:47 +00:00
|
|
|
memcpy(psecnetwork, &pnetwork->network, get_wlan_bssid_ex_sz(&pnetwork->network));
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
psecuritypriv->authenticator_ie[0] = (unsigned char)psecnetwork->IELength;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (psecnetwork->IELength - 12 < 255) {
|
|
|
|
memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->IEs[12], psecnetwork->IELength - 12);
|
2013-05-08 21:45:39 +00:00
|
|
|
} else {
|
2022-06-08 23:46:35 +00:00
|
|
|
memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->IEs[12], 255);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
psecnetwork->IELength = 0;
|
2013-07-09 22:38:46 +00:00
|
|
|
/* Added by Albert 2009/02/18 */
|
|
|
|
/* If the the driver wants to use the bssid to create the connection. */
|
|
|
|
/* If not, we have to copy the connecting AP's MAC address to it so that */
|
|
|
|
/* the driver just has the bssid information for PMKIDList searching. */
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
if (!pmlmepriv->assoc_by_bssid)
|
2013-10-19 17:45:47 +00:00
|
|
|
memcpy(&pmlmepriv->assoc_bssid[0], &pnetwork->network.MacAddress[0], ETH_ALEN);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
psecnetwork->IELength = rtw_restruct_sec_ie(padapter, &pnetwork->network.IEs[0], &psecnetwork->IEs[0], pnetwork->network.IELength);
|
|
|
|
|
|
|
|
pqospriv->qos_option = 0;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
if (pregistrypriv->wmm_enable) {
|
2013-05-08 21:45:39 +00:00
|
|
|
u32 tmp_len;
|
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
tmp_len = rtw_restruct_wmm_ie(padapter, &pnetwork->network.IEs[0], &psecnetwork->IEs[0], pnetwork->network.IELength, psecnetwork->IELength);
|
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
if (psecnetwork->IELength != tmp_len) {
|
2013-05-08 21:45:39 +00:00
|
|
|
psecnetwork->IELength = tmp_len;
|
2013-07-09 22:38:46 +00:00
|
|
|
pqospriv->qos_option = 1; /* There is WMM IE in this corresp. beacon */
|
2013-07-27 19:49:25 +00:00
|
|
|
} else {
|
2013-07-09 22:38:46 +00:00
|
|
|
pqospriv->qos_option = 0;/* There is no WMM IE in this corresp. beacon */
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-05-26 03:02:10 +00:00
|
|
|
phtpriv->ht_option = false;
|
2013-07-27 19:49:25 +00:00
|
|
|
if (pregistrypriv->ht_enable) {
|
2013-07-09 22:38:46 +00:00
|
|
|
/* Added by Albert 2010/06/23 */
|
|
|
|
/* For the WEP mode, we will use the bg mode to do the connection to avoid some IOT issue. */
|
|
|
|
/* Especially for Realtek 8192u SoftAP. */
|
2013-07-27 19:49:25 +00:00
|
|
|
if ((padapter->securitypriv.dot11PrivacyAlgrthm != _WEP40_) &&
|
|
|
|
(padapter->securitypriv.dot11PrivacyAlgrthm != _WEP104_) &&
|
|
|
|
(padapter->securitypriv.dot11PrivacyAlgrthm != _TKIP_)) {
|
2013-07-09 22:38:46 +00:00
|
|
|
/* rtw_restructure_ht_ie */
|
2013-05-19 04:28:07 +00:00
|
|
|
rtw_restructure_ht_ie(padapter, &pnetwork->network.IEs[0], &psecnetwork->IEs[0],
|
|
|
|
pnetwork->network.IELength, &psecnetwork->IELength);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pmlmeinfo->assoc_AP_vendor = check_assoc_AP(pnetwork->network.IEs, pnetwork->network.IELength);
|
|
|
|
|
|
|
|
if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_TENDA)
|
|
|
|
padapter->pwrctrlpriv.smart_ps = 0;
|
|
|
|
else
|
|
|
|
padapter->pwrctrlpriv.smart_ps = padapter->registrypriv.smart_ps;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-07-24 02:31:04 +00:00
|
|
|
pcmd->cmdsz = get_wlan_bssid_ex_sz(psecnetwork);/* get cmdsz before endian conversion */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 05:13:40 +00:00
|
|
|
INIT_LIST_HEAD(&pcmd->list);
|
2013-07-09 22:38:46 +00:00
|
|
|
pcmd->cmdcode = _JoinBss_CMD_;/* GEN_CMD_CODE(_JoinBss) */
|
2013-05-08 21:45:39 +00:00
|
|
|
pcmd->parmbuf = (unsigned char *)psecnetwork;
|
|
|
|
pcmd->rsp = NULL;
|
|
|
|
pcmd->rspsz = 0;
|
|
|
|
|
|
|
|
res = rtw_enqueue_cmd(pcmdpriv, pcmd);
|
|
|
|
|
|
|
|
exit:
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueue) /* for sta_mode */
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct cmd_obj *cmdobj = NULL;
|
|
|
|
struct disconnect_parm *param = NULL;
|
|
|
|
struct cmd_priv *cmdpriv = &padapter->cmdpriv;
|
|
|
|
u8 res = _SUCCESS;
|
|
|
|
|
|
|
|
/* prepare cmd parameter */
|
2015-04-08 19:16:39 +00:00
|
|
|
param = kzalloc(sizeof(*param), GFP_ATOMIC);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!param) {
|
2013-05-08 21:45:39 +00:00
|
|
|
res = _FAIL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
param->deauth_timeout_ms = deauth_timeout_ms;
|
|
|
|
|
|
|
|
if (enqueue) {
|
|
|
|
/* need enqueue, prepare cmd_obj and enqueue */
|
2015-04-08 19:16:39 +00:00
|
|
|
cmdobj = kzalloc(sizeof(*cmdobj), GFP_ATOMIC);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!cmdobj) {
|
2013-05-08 21:45:39 +00:00
|
|
|
res = _FAIL;
|
2013-10-19 17:45:47 +00:00
|
|
|
kfree(param);
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
init_h2fwcmd_w_parm_no_rsp(cmdobj, param, _DisConnect_CMD_);
|
|
|
|
res = rtw_enqueue_cmd(cmdpriv, cmdobj);
|
|
|
|
} else {
|
|
|
|
/* no need to enqueue, do the cmd hdl directly and free cmd parameter */
|
|
|
|
if (H2C_SUCCESS != disconnect_hdl(padapter, (u8 *)param))
|
|
|
|
res = _FAIL;
|
2013-10-19 17:45:47 +00:00
|
|
|
kfree(param);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
exit:
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
u8 rtw_setopmode_cmd(struct adapter *padapter, enum ndis_802_11_network_infra networktype)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-07-27 19:49:25 +00:00
|
|
|
struct cmd_obj *ph2c;
|
|
|
|
struct setopmode_parm *psetop;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
|
|
|
u8 res = _SUCCESS;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 15:08:01 +00:00
|
|
|
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!ph2c) {
|
2013-07-27 19:49:25 +00:00
|
|
|
res = false;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
2014-12-13 15:08:01 +00:00
|
|
|
psetop = kzalloc(sizeof(struct setopmode_parm), GFP_KERNEL);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!psetop) {
|
2013-10-19 17:45:47 +00:00
|
|
|
kfree(ph2c);
|
2013-07-27 19:49:25 +00:00
|
|
|
res = false;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
init_h2fwcmd_w_parm_no_rsp(ph2c, psetop, _SetOpMode_CMD_);
|
|
|
|
psetop->mode = (u8)networktype;
|
|
|
|
|
|
|
|
res = rtw_enqueue_cmd(pcmdpriv, ph2c);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
u8 rtw_setstakey_cmd(struct adapter *padapter, u8 *psta, u8 unicast_key)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-07-27 19:49:25 +00:00
|
|
|
struct cmd_obj *ph2c;
|
|
|
|
struct set_stakey_parm *psetstakey_para;
|
|
|
|
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
|
|
|
struct set_stakey_rsp *psetstakey_rsp = NULL;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
|
|
|
struct security_priv *psecuritypriv = &padapter->securitypriv;
|
|
|
|
struct sta_info *sta = (struct sta_info *)psta;
|
|
|
|
u8 res = _SUCCESS;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 15:08:01 +00:00
|
|
|
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!ph2c) {
|
2013-07-27 19:49:25 +00:00
|
|
|
res = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-13 15:08:01 +00:00
|
|
|
psetstakey_para = kzalloc(sizeof(struct set_stakey_parm), GFP_KERNEL);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!psetstakey_para) {
|
2013-10-19 17:45:47 +00:00
|
|
|
kfree(ph2c);
|
2013-07-27 19:49:25 +00:00
|
|
|
res = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-13 15:08:01 +00:00
|
|
|
psetstakey_rsp = kzalloc(sizeof(struct set_stakey_rsp), GFP_KERNEL);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!psetstakey_rsp) {
|
2013-10-19 17:45:47 +00:00
|
|
|
kfree(ph2c);
|
|
|
|
kfree(psetstakey_para);
|
2013-07-27 19:49:25 +00:00
|
|
|
res = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
init_h2fwcmd_w_parm_no_rsp(ph2c, psetstakey_para, _SetStaKey_CMD_);
|
2013-07-27 19:49:25 +00:00
|
|
|
ph2c->rsp = (u8 *)psetstakey_rsp;
|
2013-05-08 21:45:39 +00:00
|
|
|
ph2c->rspsz = sizeof(struct set_stakey_rsp);
|
|
|
|
|
2013-10-19 17:45:47 +00:00
|
|
|
memcpy(psetstakey_para->addr, sta->hwaddr, ETH_ALEN);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE))
|
2022-06-08 23:46:35 +00:00
|
|
|
psetstakey_para->algorithm = (unsigned char)psecuritypriv->dot11PrivacyAlgrthm;
|
2013-07-27 19:49:25 +00:00
|
|
|
else
|
2013-05-26 03:02:10 +00:00
|
|
|
GET_ENCRY_ALGO(psecuritypriv, sta, psetstakey_para->algorithm, false);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
if (unicast_key)
|
2013-10-19 17:45:47 +00:00
|
|
|
memcpy(&psetstakey_para->key, &sta->dot118021x_UncstKey, 16);
|
2013-07-27 19:49:25 +00:00
|
|
|
else
|
2013-10-19 17:45:47 +00:00
|
|
|
memcpy(&psetstakey_para->key, &psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey, 16);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-11-29 22:10:20 +00:00
|
|
|
/* jeff: set this because at least sw key is ready */
|
2013-07-27 19:49:25 +00:00
|
|
|
padapter->securitypriv.busetkipkey = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
res = rtw_enqueue_cmd(pcmdpriv, ph2c);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
exit:
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
u8 rtw_clearstakey_cmd(struct adapter *padapter, u8 *psta, u8 entry, u8 enqueue)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-07-27 19:49:25 +00:00
|
|
|
struct cmd_obj *ph2c;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct set_stakey_parm *psetstakey_para;
|
2013-07-27 19:49:25 +00:00
|
|
|
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
|
|
|
struct set_stakey_rsp *psetstakey_rsp = NULL;
|
|
|
|
struct sta_info *sta = (struct sta_info *)psta;
|
|
|
|
u8 res = _SUCCESS;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
if (!enqueue) {
|
2013-05-08 21:45:39 +00:00
|
|
|
clear_cam_entry(padapter, entry);
|
2013-07-27 19:49:25 +00:00
|
|
|
} else {
|
2014-12-13 15:08:01 +00:00
|
|
|
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!ph2c) {
|
2013-07-27 19:49:25 +00:00
|
|
|
res = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-13 15:08:01 +00:00
|
|
|
psetstakey_para = kzalloc(sizeof(struct set_stakey_parm),
|
|
|
|
GFP_ATOMIC);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!psetstakey_para) {
|
2013-10-19 17:45:47 +00:00
|
|
|
kfree(ph2c);
|
2013-07-27 19:49:25 +00:00
|
|
|
res = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-13 15:08:01 +00:00
|
|
|
psetstakey_rsp = kzalloc(sizeof(struct set_stakey_rsp),
|
|
|
|
GFP_ATOMIC);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!psetstakey_rsp) {
|
2013-10-19 17:45:47 +00:00
|
|
|
kfree(ph2c);
|
|
|
|
kfree(psetstakey_para);
|
2013-07-27 19:49:25 +00:00
|
|
|
res = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
init_h2fwcmd_w_parm_no_rsp(ph2c, psetstakey_para, _SetStaKey_CMD_);
|
2013-07-27 19:49:25 +00:00
|
|
|
ph2c->rsp = (u8 *)psetstakey_rsp;
|
2013-05-08 21:45:39 +00:00
|
|
|
ph2c->rspsz = sizeof(struct set_stakey_rsp);
|
|
|
|
|
2013-10-19 17:45:47 +00:00
|
|
|
memcpy(psetstakey_para->addr, sta->hwaddr, ETH_ALEN);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
psetstakey_para->algorithm = _NO_PRIVACY_;
|
|
|
|
|
|
|
|
psetstakey_para->id = entry;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
|
|
|
res = rtw_enqueue_cmd(pcmdpriv, ph2c);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
exit:
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
u8 rtw_addbareq_cmd(struct adapter *padapter, u8 tid, u8 *addr)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-07-27 19:49:25 +00:00
|
|
|
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
|
|
|
struct cmd_obj *ph2c;
|
|
|
|
struct addBaReq_parm *paddbareq_parm;
|
|
|
|
u8 res = _SUCCESS;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
|
|
|
|
if (!ph2c) {
|
2013-07-27 19:49:25 +00:00
|
|
|
res = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
paddbareq_parm = kzalloc(sizeof(struct addBaReq_parm), GFP_ATOMIC);
|
|
|
|
if (!paddbareq_parm) {
|
2013-10-19 17:45:47 +00:00
|
|
|
kfree(ph2c);
|
2013-07-27 19:49:25 +00:00
|
|
|
res = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
paddbareq_parm->tid = tid;
|
2013-10-19 17:45:47 +00:00
|
|
|
memcpy(paddbareq_parm->addr, addr, ETH_ALEN);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
init_h2fwcmd_w_parm_no_rsp(ph2c, paddbareq_parm, GEN_CMD_CODE(_AddBAReq));
|
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* rtw_enqueue_cmd(pcmdpriv, ph2c); */
|
2013-05-08 21:45:39 +00:00
|
|
|
res = rtw_enqueue_cmd(pcmdpriv, ph2c);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
exit:
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
u8 rtw_dynamic_chk_wk_cmd(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-07-27 19:49:25 +00:00
|
|
|
struct cmd_obj *ph2c;
|
|
|
|
struct drvextra_cmd_parm *pdrvextra_cmd_parm;
|
|
|
|
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
|
|
|
u8 res = _SUCCESS;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-13 15:08:01 +00:00
|
|
|
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!ph2c) {
|
2013-07-27 19:49:25 +00:00
|
|
|
res = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-13 15:08:01 +00:00
|
|
|
pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!pdrvextra_cmd_parm) {
|
2013-10-19 17:45:47 +00:00
|
|
|
kfree(ph2c);
|
2013-07-27 19:49:25 +00:00
|
|
|
res = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
pdrvextra_cmd_parm->ec_id = DYNAMIC_CHK_WK_CID;
|
|
|
|
pdrvextra_cmd_parm->type_size = 0;
|
|
|
|
pdrvextra_cmd_parm->pbuf = (u8 *)padapter;
|
|
|
|
|
|
|
|
init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra));
|
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* rtw_enqueue_cmd(pcmdpriv, ph2c); */
|
2013-05-08 21:45:39 +00:00
|
|
|
res = rtw_enqueue_cmd(pcmdpriv, ph2c);
|
|
|
|
exit:
|
2014-12-01 22:31:15 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-07-27 19:49:25 +00:00
|
|
|
struct cmd_obj *pcmdobj;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct SetChannelPlan_param *setChannelPlan_param;
|
|
|
|
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
u8 res = _SUCCESS;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* check input parameter */
|
2013-05-09 04:04:25 +00:00
|
|
|
if (!rtw_is_channel_plan_valid(chplan)) {
|
2013-05-08 21:45:39 +00:00
|
|
|
res = _FAIL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* prepare cmd parameter */
|
2014-12-13 15:08:01 +00:00
|
|
|
setChannelPlan_param = kzalloc(sizeof(struct SetChannelPlan_param),
|
|
|
|
GFP_KERNEL);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!setChannelPlan_param) {
|
2013-07-27 19:49:25 +00:00
|
|
|
res = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
2013-07-27 19:49:25 +00:00
|
|
|
setChannelPlan_param->channel_plan = chplan;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
/* need enqueue, prepare cmd_obj and enqueue */
|
|
|
|
pcmdobj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
|
|
|
|
if (!pcmdobj) {
|
2013-10-19 17:45:47 +00:00
|
|
|
kfree(setChannelPlan_param);
|
2013-07-27 19:49:25 +00:00
|
|
|
res = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
init_h2fwcmd_w_parm_no_rsp(pcmdobj, setChannelPlan_param, GEN_CMD_CODE(_SetChannelPlan));
|
2013-05-08 21:45:39 +00:00
|
|
|
res = rtw_enqueue_cmd(pcmdpriv, pcmdobj);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
/* do something based on res... */
|
|
|
|
if (res == _SUCCESS)
|
|
|
|
padapter->mlmepriv.ChannelPlan = chplan;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
exit:
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
static void traffic_status_watchdog(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
u8 bEnterPS;
|
2013-05-26 03:02:10 +00:00
|
|
|
u8 bBusyTraffic = false, bTxBusyTraffic = false, bRxBusyTraffic = false;
|
|
|
|
u8 bHigherBusyTraffic = false, bHigherBusyRxTraffic = false, bHigherBusyTxTraffic = false;
|
2022-06-08 23:46:35 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* */
|
|
|
|
/* Determine if our traffic is busy now */
|
|
|
|
/* */
|
2013-07-27 19:49:25 +00:00
|
|
|
if (check_fwstate(pmlmepriv, _FW_LINKED)) {
|
|
|
|
if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > 100 ||
|
2013-10-19 17:45:47 +00:00
|
|
|
pmlmepriv->LinkDetectInfo.NumTxOkInPeriod > 100) {
|
2013-05-26 03:02:10 +00:00
|
|
|
bBusyTraffic = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > pmlmepriv->LinkDetectInfo.NumTxOkInPeriod)
|
2013-05-26 03:02:10 +00:00
|
|
|
bRxBusyTraffic = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
else
|
2013-05-26 03:02:10 +00:00
|
|
|
bTxBusyTraffic = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* Higher Tx/Rx data. */
|
2013-07-27 19:49:25 +00:00
|
|
|
if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > 4000 ||
|
|
|
|
pmlmepriv->LinkDetectInfo.NumTxOkInPeriod > 4000) {
|
2013-05-26 03:02:10 +00:00
|
|
|
bHigherBusyTraffic = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > pmlmepriv->LinkDetectInfo.NumTxOkInPeriod)
|
2013-05-26 03:02:10 +00:00
|
|
|
bHigherBusyRxTraffic = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
else
|
2013-05-26 03:02:10 +00:00
|
|
|
bHigherBusyTxTraffic = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* check traffic for powersaving. */
|
2013-07-27 19:49:25 +00:00
|
|
|
if (((pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod + pmlmepriv->LinkDetectInfo.NumTxOkInPeriod) > 8) ||
|
|
|
|
(pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod > 2))
|
|
|
|
bEnterPS = false;
|
2013-05-08 21:45:39 +00:00
|
|
|
else
|
2013-07-27 19:49:25 +00:00
|
|
|
bEnterPS = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* LeisurePS only work in infra mode. */
|
2013-05-09 04:04:25 +00:00
|
|
|
if (bEnterPS)
|
2013-05-08 21:45:39 +00:00
|
|
|
LPS_Enter(padapter);
|
|
|
|
else
|
|
|
|
LPS_Leave(padapter);
|
2013-07-27 19:49:25 +00:00
|
|
|
} else {
|
2013-05-08 21:45:39 +00:00
|
|
|
LPS_Leave(padapter);
|
|
|
|
}
|
|
|
|
|
|
|
|
pmlmepriv->LinkDetectInfo.NumRxOkInPeriod = 0;
|
|
|
|
pmlmepriv->LinkDetectInfo.NumTxOkInPeriod = 0;
|
|
|
|
pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod = 0;
|
|
|
|
pmlmepriv->LinkDetectInfo.bBusyTraffic = bBusyTraffic;
|
|
|
|
pmlmepriv->LinkDetectInfo.bTxBusyTraffic = bTxBusyTraffic;
|
|
|
|
pmlmepriv->LinkDetectInfo.bRxBusyTraffic = bRxBusyTraffic;
|
|
|
|
pmlmepriv->LinkDetectInfo.bHigherBusyTraffic = bHigherBusyTraffic;
|
|
|
|
pmlmepriv->LinkDetectInfo.bHigherBusyRxTraffic = bHigherBusyRxTraffic;
|
|
|
|
pmlmepriv->LinkDetectInfo.bHigherBusyTxTraffic = bHigherBusyTxTraffic;
|
|
|
|
}
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
static void rtl8188e_sreset_xmit_status_check(struct adapter *padapter)
|
|
|
|
{
|
|
|
|
u32 txdma_status;
|
|
|
|
|
|
|
|
txdma_status = rtw_read32(padapter, REG_TXDMA_STATUS);
|
|
|
|
if (txdma_status != 0x00)
|
|
|
|
rtw_write32(padapter, REG_TXDMA_STATUS, txdma_status);
|
|
|
|
/* total xmit irp = 4 */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dynamic_chk_wk_hdl(struct adapter *padapter, u8 *pbuf)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct mlme_priv *pmlmepriv;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
padapter = (struct adapter *)pbuf;
|
2022-06-08 23:46:35 +00:00
|
|
|
pmlmepriv = &padapter->mlmepriv;
|
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
|
|
|
expire_timeout_chk(padapter);
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
rtl8188e_sreset_xmit_status_check(padapter);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-19 22:05:40 +00:00
|
|
|
linked_status_chk(padapter);
|
|
|
|
traffic_status_watchdog(padapter);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
rtl8188e_HalDmWatchDog(padapter);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-10-19 17:45:47 +00:00
|
|
|
static void lps_ctrl_wk_hdl(struct adapter *padapter, u8 lps_ctrl_type)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
|
2022-06-08 23:46:35 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2013-05-08 21:45:39 +00:00
|
|
|
u8 mstatus;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) ||
|
|
|
|
check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))
|
2013-05-08 21:45:39 +00:00
|
|
|
return;
|
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
switch (lps_ctrl_type) {
|
|
|
|
case LPS_CTRL_SCAN:
|
2022-06-08 23:46:35 +00:00
|
|
|
if (check_fwstate(pmlmepriv, _FW_LINKED)) {
|
2013-10-19 17:45:47 +00:00
|
|
|
/* connect */
|
|
|
|
LPS_Leave(padapter);
|
2013-07-27 19:49:25 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case LPS_CTRL_JOINBSS:
|
|
|
|
LPS_Leave(padapter);
|
|
|
|
break;
|
|
|
|
case LPS_CTRL_CONNECT:
|
|
|
|
mstatus = 1;/* connect */
|
|
|
|
/* Reset LPS Setting */
|
|
|
|
padapter->pwrctrlpriv.LpsIdleCount = 0;
|
2022-06-08 23:46:35 +00:00
|
|
|
SetHwReg8188EU(padapter, HW_VAR_H2C_FW_JOINBSSRPT, (u8 *)(&mstatus));
|
2013-07-27 19:49:25 +00:00
|
|
|
break;
|
|
|
|
case LPS_CTRL_DISCONNECT:
|
|
|
|
mstatus = 0;/* disconnect */
|
2013-10-19 17:45:47 +00:00
|
|
|
LPS_Leave(padapter);
|
2022-06-08 23:46:35 +00:00
|
|
|
SetHwReg8188EU(padapter, HW_VAR_H2C_FW_JOINBSSRPT, (u8 *)(&mstatus));
|
2013-07-27 19:49:25 +00:00
|
|
|
break;
|
|
|
|
case LPS_CTRL_SPECIAL_PACKET:
|
2014-12-13 21:18:54 +00:00
|
|
|
pwrpriv->DelayLPSLastTimeStamp = jiffies;
|
2013-10-19 17:45:47 +00:00
|
|
|
LPS_Leave(padapter);
|
2013-07-27 19:49:25 +00:00
|
|
|
break;
|
|
|
|
case LPS_CTRL_LEAVE:
|
2013-10-19 17:45:47 +00:00
|
|
|
LPS_Leave(padapter);
|
2013-07-27 19:49:25 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
u8 rtw_lps_ctrl_wk_cmd(struct adapter *padapter, u8 lps_ctrl_type, u8 enqueue)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct cmd_obj *ph2c;
|
|
|
|
struct drvextra_cmd_parm *pdrvextra_cmd_parm;
|
|
|
|
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
2013-07-09 22:38:46 +00:00
|
|
|
/* struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; */
|
2013-05-08 21:45:39 +00:00
|
|
|
u8 res = _SUCCESS;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* if (!pwrctrlpriv->bLeisurePs) */
|
|
|
|
/* return res; */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
if (enqueue) {
|
2014-12-13 15:08:01 +00:00
|
|
|
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!ph2c) {
|
2013-07-27 19:49:25 +00:00
|
|
|
res = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-13 15:08:01 +00:00
|
|
|
pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm),
|
|
|
|
GFP_ATOMIC);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!pdrvextra_cmd_parm) {
|
2013-10-19 17:45:47 +00:00
|
|
|
kfree(ph2c);
|
2013-07-27 19:49:25 +00:00
|
|
|
res = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
pdrvextra_cmd_parm->ec_id = LPS_CTRL_WK_CID;
|
|
|
|
pdrvextra_cmd_parm->type_size = lps_ctrl_type;
|
|
|
|
pdrvextra_cmd_parm->pbuf = NULL;
|
|
|
|
|
|
|
|
init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra));
|
|
|
|
|
|
|
|
res = rtw_enqueue_cmd(pcmdpriv, ph2c);
|
2013-07-27 19:49:25 +00:00
|
|
|
} else {
|
2013-05-08 21:45:39 +00:00
|
|
|
lps_ctrl_wk_hdl(padapter, lps_ctrl_type);
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
exit:
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
static void rpt_timer_setting_wk_hdl(struct adapter *padapter, u16 min_time)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2022-06-08 23:46:35 +00:00
|
|
|
SetHwReg8188EU(padapter, HW_VAR_RPT_TIMER_SETTING, (u8 *)(&min_time));
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
u8 rtw_rpt_timer_cfg_cmd(struct adapter *padapter, u16 min_time)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct cmd_obj *ph2c;
|
2013-05-19 04:28:07 +00:00
|
|
|
struct drvextra_cmd_parm *pdrvextra_cmd_parm;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
|
|
|
|
|
|
|
u8 res = _SUCCESS;
|
|
|
|
|
2014-12-13 15:08:01 +00:00
|
|
|
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!ph2c) {
|
2013-07-27 19:49:25 +00:00
|
|
|
res = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-13 15:08:01 +00:00
|
|
|
pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm),
|
|
|
|
GFP_ATOMIC);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!pdrvextra_cmd_parm) {
|
2013-10-19 17:45:47 +00:00
|
|
|
kfree(ph2c);
|
2013-07-27 19:49:25 +00:00
|
|
|
res = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
pdrvextra_cmd_parm->ec_id = RTP_TIMER_CFG_WK_CID;
|
2013-07-27 19:49:25 +00:00
|
|
|
pdrvextra_cmd_parm->type_size = min_time;
|
2013-05-08 21:45:39 +00:00
|
|
|
pdrvextra_cmd_parm->pbuf = NULL;
|
|
|
|
init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra));
|
|
|
|
res = rtw_enqueue_cmd(pcmdpriv, ph2c);
|
|
|
|
exit:
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
static void antenna_select_wk_hdl(struct adapter *padapter, u8 antenna)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2022-06-08 23:46:35 +00:00
|
|
|
SetHwReg8188EU(padapter, HW_VAR_ANTENNA_DIVERSITY_SELECT, (u8 *)(&antenna));
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
u8 rtw_antenna_select_cmd(struct adapter *padapter, u8 antenna, u8 enqueue)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct cmd_obj *ph2c;
|
2013-05-19 04:28:07 +00:00
|
|
|
struct drvextra_cmd_parm *pdrvextra_cmd_parm;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
2013-07-27 19:49:25 +00:00
|
|
|
u8 support_ant_div;
|
2013-05-08 21:45:39 +00:00
|
|
|
u8 res = _SUCCESS;
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
GetHalDefVar8188EUsb(padapter, HAL_DEF_IS_SUPPORT_ANT_DIV, &support_ant_div);
|
2013-07-27 19:49:25 +00:00
|
|
|
if (!support_ant_div)
|
|
|
|
return res;
|
|
|
|
|
|
|
|
if (enqueue) {
|
2014-12-13 15:08:01 +00:00
|
|
|
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!ph2c) {
|
2013-07-27 19:49:25 +00:00
|
|
|
res = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-13 15:08:01 +00:00
|
|
|
pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm),
|
|
|
|
GFP_KERNEL);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!pdrvextra_cmd_parm) {
|
2013-10-19 17:45:47 +00:00
|
|
|
kfree(ph2c);
|
2013-07-27 19:49:25 +00:00
|
|
|
res = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
pdrvextra_cmd_parm->ec_id = ANT_SELECT_WK_CID;
|
|
|
|
pdrvextra_cmd_parm->type_size = antenna;
|
|
|
|
pdrvextra_cmd_parm->pbuf = NULL;
|
|
|
|
init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra));
|
|
|
|
|
|
|
|
res = rtw_enqueue_cmd(pcmdpriv, ph2c);
|
2013-07-27 19:49:25 +00:00
|
|
|
} else {
|
|
|
|
antenna_select_wk_hdl(padapter, antenna);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
exit:
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
u8 p2p_protocol_wk_cmd(struct adapter *padapter, int intCmdType)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct cmd_obj *ph2c;
|
|
|
|
struct drvextra_cmd_parm *pdrvextra_cmd_parm;
|
2022-06-08 23:46:35 +00:00
|
|
|
struct wifidirect_info *pwdinfo = &padapter->wdinfo;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
|
|
|
u8 res = _SUCCESS;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
|
2013-05-08 21:45:39 +00:00
|
|
|
return res;
|
|
|
|
|
2014-12-13 15:08:01 +00:00
|
|
|
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!ph2c) {
|
2013-07-27 19:49:25 +00:00
|
|
|
res = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-13 15:08:01 +00:00
|
|
|
pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!pdrvextra_cmd_parm) {
|
2013-10-19 17:45:47 +00:00
|
|
|
kfree(ph2c);
|
2013-07-27 19:49:25 +00:00
|
|
|
res = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
pdrvextra_cmd_parm->ec_id = P2P_PROTO_WK_CID;
|
2013-07-09 22:38:46 +00:00
|
|
|
pdrvextra_cmd_parm->type_size = intCmdType; /* As the command tppe. */
|
|
|
|
pdrvextra_cmd_parm->pbuf = NULL; /* Must be NULL here */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra));
|
|
|
|
|
|
|
|
res = rtw_enqueue_cmd(pcmdpriv, ph2c);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
exit:
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
u8 rtw_ps_cmd(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct cmd_obj *ppscmd;
|
2013-05-19 04:28:07 +00:00
|
|
|
struct drvextra_cmd_parm *pdrvextra_cmd_parm;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
u8 res = _SUCCESS;
|
2014-12-01 22:31:15 +00:00
|
|
|
|
2014-12-13 15:08:01 +00:00
|
|
|
ppscmd = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!ppscmd) {
|
2013-07-27 19:49:25 +00:00
|
|
|
res = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-13 15:08:01 +00:00
|
|
|
pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!pdrvextra_cmd_parm) {
|
2013-10-19 17:45:47 +00:00
|
|
|
kfree(ppscmd);
|
2013-07-27 19:49:25 +00:00
|
|
|
res = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
pdrvextra_cmd_parm->ec_id = POWER_SAVING_CTRL_WK_CID;
|
2013-05-08 21:45:39 +00:00
|
|
|
pdrvextra_cmd_parm->pbuf = NULL;
|
|
|
|
init_h2fwcmd_w_parm_no_rsp(ppscmd, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra));
|
|
|
|
|
|
|
|
res = rtw_enqueue_cmd(pcmdpriv, ppscmd);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
exit:
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
static void rtw_chk_hi_queue_hdl(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-07-27 19:49:25 +00:00
|
|
|
int cnt = 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct sta_info *psta_bmc;
|
|
|
|
struct sta_priv *pstapriv = &padapter->stapriv;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
if (psta_bmc->sleepq_len == 0) {
|
2013-05-08 21:45:39 +00:00
|
|
|
u8 val = 0;
|
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
/* while ((rtw_read32(padapter, 0x414)&0x00ffff00)!= 0) */
|
|
|
|
/* while ((rtw_read32(padapter, 0x414)&0x0000ff00)!= 0) */
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
GetHwReg8188EU(padapter, HW_VAR_CHK_HI_QUEUE_EMPTY, &val);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
while (!val) {
|
2022-06-08 23:46:35 +00:00
|
|
|
msleep(100);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
cnt++;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
if (cnt > 10)
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
GetHwReg8188EU(padapter, HW_VAR_CHK_HI_QUEUE_EMPTY, &val);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
if (cnt <= 10) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pstapriv->tim_bitmap &= ~BIT(0);
|
|
|
|
pstapriv->sta_dz_bitmap &= ~BIT(0);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-26 03:02:10 +00:00
|
|
|
update_beacon(padapter, _TIM_IE_, NULL, false);
|
2013-07-27 19:49:25 +00:00
|
|
|
} else { /* re check again */
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_chk_hi_queue_cmd(padapter);
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
u8 rtw_chk_hi_queue_cmd(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct cmd_obj *ph2c;
|
2013-05-19 04:28:07 +00:00
|
|
|
struct drvextra_cmd_parm *pdrvextra_cmd_parm;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
|
|
|
u8 res = _SUCCESS;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2018-03-14 15:48:51 +00:00
|
|
|
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!ph2c) {
|
2013-07-27 19:49:25 +00:00
|
|
|
res = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2018-03-14 15:48:51 +00:00
|
|
|
pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!pdrvextra_cmd_parm) {
|
2013-10-19 17:45:47 +00:00
|
|
|
kfree(ph2c);
|
2013-07-27 19:49:25 +00:00
|
|
|
res = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
pdrvextra_cmd_parm->ec_id = CHECK_HIQ_WK_CID;
|
|
|
|
pdrvextra_cmd_parm->type_size = 0;
|
|
|
|
pdrvextra_cmd_parm->pbuf = NULL;
|
|
|
|
|
|
|
|
init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra));
|
|
|
|
|
|
|
|
res = rtw_enqueue_cmd(pcmdpriv, ph2c);
|
|
|
|
exit:
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
u8 rtw_c2h_wk_cmd(struct adapter *padapter, u8 *c2h_evt)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct cmd_obj *ph2c;
|
|
|
|
struct drvextra_cmd_parm *pdrvextra_cmd_parm;
|
|
|
|
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
|
|
|
|
u8 res = _SUCCESS;
|
|
|
|
|
2014-12-13 15:08:01 +00:00
|
|
|
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!ph2c) {
|
2013-05-08 21:45:39 +00:00
|
|
|
res = _FAIL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2014-12-13 15:08:01 +00:00
|
|
|
pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!pdrvextra_cmd_parm) {
|
2013-10-19 17:45:47 +00:00
|
|
|
kfree(ph2c);
|
2013-05-08 21:45:39 +00:00
|
|
|
res = _FAIL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
pdrvextra_cmd_parm->ec_id = C2H_WK_CID;
|
2013-07-27 19:49:25 +00:00
|
|
|
pdrvextra_cmd_parm->type_size = c2h_evt ? 16 : 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
pdrvextra_cmd_parm->pbuf = c2h_evt;
|
|
|
|
|
|
|
|
init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra));
|
|
|
|
|
|
|
|
res = rtw_enqueue_cmd(pcmdpriv, ph2c);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
exit:
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
static void c2h_evt_hdl(struct adapter *adapter, struct c2h_evt_hdr *c2h_evt, c2h_id_filter filter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
u8 buf[16];
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!c2h_evt)
|
|
|
|
c2h_evt_read(adapter, buf);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-07-25 16:02:03 +00:00
|
|
|
static void c2h_wk_callback(struct work_struct *work)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct evt_priv *evtpriv = container_of(work, struct evt_priv, c2h_wk);
|
2013-07-27 01:08:39 +00:00
|
|
|
struct adapter *adapter = container_of(evtpriv, struct adapter, evtpriv);
|
2013-05-08 21:45:39 +00:00
|
|
|
struct c2h_evt_hdr *c2h_evt;
|
|
|
|
|
2013-05-26 03:02:10 +00:00
|
|
|
evtpriv->c2h_wk_alive = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
while (!rtw_cbuf_empty(evtpriv->c2h_queue)) {
|
2022-06-08 23:46:35 +00:00
|
|
|
c2h_evt = (struct c2h_evt_hdr *)rtw_cbuf_pop(evtpriv->c2h_queue);
|
|
|
|
if (c2h_evt) {
|
2013-05-08 21:45:39 +00:00
|
|
|
/* This C2H event is read, clear it */
|
2022-06-08 23:46:35 +00:00
|
|
|
rtw_write8(adapter, REG_C2HEVT_CLEAR, C2H_EVT_HOST_CLOSE);
|
|
|
|
} else {
|
|
|
|
c2h_evt = kmalloc(16, GFP_KERNEL);
|
|
|
|
if (c2h_evt) {
|
|
|
|
/* This C2H event is not read, read & clear now */
|
|
|
|
if (c2h_evt_read(adapter, (u8 *)c2h_evt) != _SUCCESS) {
|
|
|
|
kfree(c2h_evt);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Special pointer to trigger c2h_evt_clear only */
|
|
|
|
if ((void *)c2h_evt == (void *)evtpriv)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!c2h_evt_exist(c2h_evt)) {
|
2013-10-19 17:45:47 +00:00
|
|
|
kfree(c2h_evt);
|
2013-05-08 21:45:39 +00:00
|
|
|
continue;
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
/* Enqueue into cmd_thread for others */
|
|
|
|
rtw_c2h_wk_cmd(adapter, (u8 *)c2h_evt);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-05-26 03:02:10 +00:00
|
|
|
evtpriv->c2h_wk_alive = false;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
u8 rtw_drvextra_cmd_hdl(struct adapter *padapter, unsigned char *pbuf)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct drvextra_cmd_parm *pdrvextra_cmd;
|
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if (!pbuf)
|
2013-05-08 21:45:39 +00:00
|
|
|
return H2C_PARAMETERS_ERROR;
|
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
pdrvextra_cmd = (struct drvextra_cmd_parm *)pbuf;
|
|
|
|
|
|
|
|
switch (pdrvextra_cmd->ec_id) {
|
|
|
|
case DYNAMIC_CHK_WK_CID:
|
2022-06-08 23:46:35 +00:00
|
|
|
dynamic_chk_wk_hdl(padapter, pdrvextra_cmd->pbuf);
|
2013-07-27 19:49:25 +00:00
|
|
|
break;
|
|
|
|
case POWER_SAVING_CTRL_WK_CID:
|
2022-06-08 23:46:35 +00:00
|
|
|
rtw_ps_processor(padapter);
|
2013-07-27 19:49:25 +00:00
|
|
|
break;
|
|
|
|
case LPS_CTRL_WK_CID:
|
|
|
|
lps_ctrl_wk_hdl(padapter, (u8)pdrvextra_cmd->type_size);
|
|
|
|
break;
|
|
|
|
case RTP_TIMER_CFG_WK_CID:
|
|
|
|
rpt_timer_setting_wk_hdl(padapter, pdrvextra_cmd->type_size);
|
|
|
|
break;
|
|
|
|
case ANT_SELECT_WK_CID:
|
|
|
|
antenna_select_wk_hdl(padapter, pdrvextra_cmd->type_size);
|
|
|
|
break;
|
|
|
|
case P2P_PS_WK_CID:
|
|
|
|
p2p_ps_wk_hdl(padapter, pdrvextra_cmd->type_size);
|
|
|
|
break;
|
|
|
|
case P2P_PROTO_WK_CID:
|
|
|
|
/* Commented by Albert 2011/07/01 */
|
|
|
|
/* I used the type_size as the type command */
|
|
|
|
p2p_protocol_wk_hdl(padapter, pdrvextra_cmd->type_size);
|
|
|
|
break;
|
|
|
|
case CHECK_HIQ_WK_CID:
|
|
|
|
rtw_chk_hi_queue_hdl(padapter);
|
|
|
|
break;
|
|
|
|
case C2H_WK_CID:
|
|
|
|
c2h_evt_hdl(padapter, (struct c2h_evt_hdr *)pdrvextra_cmd->pbuf, NULL);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
if (pdrvextra_cmd->pbuf && pdrvextra_cmd->type_size > 0)
|
2013-10-19 17:45:47 +00:00
|
|
|
kfree(pdrvextra_cmd->pbuf);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return H2C_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
void rtw_survey_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-05-19 04:28:07 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
if (pcmd->res == H2C_DROPPED) {
|
2013-07-09 22:38:46 +00:00
|
|
|
/* TODO: cancel timer and do timeout handler directly... */
|
|
|
|
/* need to make timeout handlerOS independent */
|
2013-05-08 21:45:39 +00:00
|
|
|
_set_timer(&pmlmepriv->scan_to_timer, 1);
|
2013-07-27 19:49:25 +00:00
|
|
|
} else if (pcmd->res != H2C_SUCCESS) {
|
2013-05-08 21:45:39 +00:00
|
|
|
_set_timer(&pmlmepriv->scan_to_timer, 1);
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* free cmd */
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_free_cmd_obj(pcmd);
|
|
|
|
|
|
|
|
}
|
2013-07-27 19:49:25 +00:00
|
|
|
void rtw_disassoc_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-05-19 04:28:07 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
|
|
|
|
2013-07-18 15:42:52 +00:00
|
|
|
if (pcmd->res != H2C_SUCCESS) {
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_lock_bh(&pmlmepriv->lock);
|
2013-05-08 21:45:39 +00:00
|
|
|
set_fwstate(pmlmepriv, _FW_LINKED);
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_unlock_bh(&pmlmepriv->lock);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-12-01 22:31:15 +00:00
|
|
|
return;
|
2013-07-18 15:42:52 +00:00
|
|
|
} else /* clear bridge database */
|
2013-05-08 21:45:39 +00:00
|
|
|
nat25_db_cleanup(padapter);
|
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* free cmd */
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_free_cmd_obj(pcmd);
|
|
|
|
}
|
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
void rtw_joinbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-05-19 04:28:07 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
if (pcmd->res == H2C_DROPPED) {
|
2013-07-09 22:38:46 +00:00
|
|
|
/* TODO: cancel timer and do timeout handler directly... */
|
|
|
|
/* need to make timeout handlerOS independent */
|
2013-05-08 21:45:39 +00:00
|
|
|
_set_timer(&pmlmepriv->assoc_timer, 1);
|
2013-07-27 19:49:25 +00:00
|
|
|
} else if (pcmd->res != H2C_SUCCESS) {
|
2013-05-19 04:28:07 +00:00
|
|
|
_set_timer(&pmlmepriv->assoc_timer, 1);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_free_cmd_obj(pcmd);
|
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd)
|
2013-05-19 04:28:07 +00:00
|
|
|
{
|
2013-05-08 21:45:39 +00:00
|
|
|
struct sta_info *psta = NULL;
|
2013-05-19 04:28:07 +00:00
|
|
|
struct wlan_network *pwlan = NULL;
|
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2013-07-24 02:31:04 +00:00
|
|
|
struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)pcmd->parmbuf;
|
2022-06-08 23:46:35 +00:00
|
|
|
struct wlan_network *tgt_network = &pmlmepriv->cur_network;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (pcmd->res != H2C_SUCCESS)
|
2013-07-27 19:49:25 +00:00
|
|
|
_set_timer(&pmlmepriv->assoc_timer, 1);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
del_timer_sync(&pmlmepriv->assoc_timer);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_lock_bh(&pmlmepriv->lock);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
|
2013-05-08 21:45:39 +00:00
|
|
|
psta = rtw_get_stainfo(&padapter->stapriv, pnetwork->MacAddress);
|
2013-07-22 03:06:42 +00:00
|
|
|
if (!psta) {
|
|
|
|
psta = rtw_alloc_stainfo(&padapter->stapriv, pnetwork->MacAddress);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!psta)
|
|
|
|
goto createbss_cmd_fail;
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
rtw_indicate_connect(padapter);
|
2013-07-22 03:06:42 +00:00
|
|
|
} else {
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pwlan = _rtw_alloc_network(pmlmepriv);
|
2022-06-08 23:46:35 +00:00
|
|
|
spin_lock_bh(&pmlmepriv->scanned_queue.lock);
|
|
|
|
if (!pwlan) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pwlan = rtw_get_oldest_wlan_network(&pmlmepriv->scanned_queue);
|
2022-06-08 23:46:35 +00:00
|
|
|
if (!pwlan) {
|
|
|
|
spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
|
2013-05-08 21:45:39 +00:00
|
|
|
goto createbss_cmd_fail;
|
|
|
|
}
|
2014-12-13 21:18:54 +00:00
|
|
|
pwlan->last_scanned = jiffies;
|
2013-07-27 19:49:25 +00:00
|
|
|
} else {
|
2022-06-08 23:46:35 +00:00
|
|
|
list_add_tail(&pwlan->list, &pmlmepriv->scanned_queue.queue);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-07-24 02:31:04 +00:00
|
|
|
pnetwork->Length = get_wlan_bssid_ex_sz(pnetwork);
|
2022-06-08 23:46:35 +00:00
|
|
|
memcpy(&pwlan->network, pnetwork, pnetwork->Length);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-10-19 17:45:47 +00:00
|
|
|
memcpy(&tgt_network->network, pnetwork, (get_wlan_bssid_ex_sz(pnetwork)));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
_clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
spin_unlock_bh(&pmlmepriv->scanned_queue.lock);
|
2013-07-09 22:38:46 +00:00
|
|
|
/* we will set _FW_LINKED when there is one more sat to join us (rtw_stassoc_event_callback) */
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
createbss_cmd_fail:
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_unlock_bh(&pmlmepriv->lock);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
rtw_free_cmd_obj(pcmd);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
void rtw_setstaKey_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-07-27 19:49:25 +00:00
|
|
|
struct sta_priv *pstapriv = &padapter->stapriv;
|
|
|
|
struct set_stakey_rsp *psetstakey_rsp = (struct set_stakey_rsp *)(pcmd->rsp);
|
|
|
|
struct sta_info *psta = rtw_get_stainfo(pstapriv, psetstakey_rsp->addr);
|
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
|
|
|
goto exit;
|
2013-05-19 04:28:07 +00:00
|
|
|
exit:
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_free_cmd_obj(pcmd);
|
2014-12-01 22:31:15 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-07-09 22:38:46 +00:00
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
void rtw_setassocsta_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-07-27 19:49:25 +00:00
|
|
|
struct sta_priv *pstapriv = &padapter->stapriv;
|
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
|
|
|
struct set_assocsta_parm *passocsta_parm = (struct set_assocsta_parm *)(pcmd->parmbuf);
|
|
|
|
struct set_assocsta_rsp *passocsta_rsp = (struct set_assocsta_rsp *)(pcmd->rsp);
|
|
|
|
struct sta_info *psta = rtw_get_stainfo(pstapriv, passocsta_parm->addr);
|
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
|
|
|
goto exit;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-07-27 19:49:25 +00:00
|
|
|
psta->aid = passocsta_rsp->cam_id;
|
|
|
|
psta->mac_id = passocsta_rsp->cam_id;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_lock_bh(&pmlmepriv->lock);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
if (check_fwstate(pmlmepriv, WIFI_MP_STATE) && check_fwstate(pmlmepriv, _FW_UNDER_LINKING))
|
2013-05-08 21:45:39 +00:00
|
|
|
_clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING);
|
|
|
|
|
|
|
|
set_fwstate(pmlmepriv, _FW_LINKED);
|
2014-11-29 00:42:41 +00:00
|
|
|
spin_unlock_bh(&pmlmepriv->lock);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
exit:
|
|
|
|
rtw_free_cmd_obj(pcmd);
|
|
|
|
|
|
|
|
}
|