2013-05-08 21:45:39 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
|
2013-05-19 04:28:07 +00:00
|
|
|
*
|
2013-05-08 21:45:39 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of version 2 of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
|
|
|
|
*
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
#include<rtw_iol.h>
|
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
struct xmit_frame *rtw_IOL_accquire_xmit_frame(struct adapter *adapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct xmit_frame *xmit_frame;
|
|
|
|
struct xmit_buf *xmitbuf;
|
|
|
|
struct pkt_attrib *pattrib;
|
|
|
|
struct xmit_priv *pxmitpriv = &(adapter->xmitpriv);
|
|
|
|
|
2013-07-27 02:37:57 +00:00
|
|
|
if ((xmit_frame = rtw_alloc_xmitframe(pxmitpriv)) == NULL) {
|
2013-05-25 23:35:42 +00:00
|
|
|
DBG_88E("%s rtw_alloc_xmitframe return null\n", __func__);
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-07-27 02:37:57 +00:00
|
|
|
if ((xmitbuf = rtw_alloc_xmitbuf(pxmitpriv)) == NULL) {
|
2013-05-25 23:35:42 +00:00
|
|
|
DBG_88E("%s rtw_alloc_xmitbuf return null\n", __func__);
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_free_xmitframe(pxmitpriv, xmit_frame);
|
|
|
|
xmit_frame=NULL;
|
|
|
|
goto exit;
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
xmit_frame->frame_tag = MGNT_FRAMETAG;
|
|
|
|
xmit_frame->pxmitbuf = xmitbuf;
|
|
|
|
xmit_frame->buf_addr = xmitbuf->pbuf;
|
|
|
|
xmitbuf->priv_data = xmit_frame;
|
|
|
|
|
|
|
|
pattrib = &xmit_frame->attrib;
|
|
|
|
update_mgntframe_attrib(adapter, pattrib);
|
2013-07-09 22:38:46 +00:00
|
|
|
pattrib->qsel = 0x10;/* Beacon */
|
2013-05-19 04:28:07 +00:00
|
|
|
pattrib->subtype = WIFI_BEACON;
|
2013-05-08 21:45:39 +00:00
|
|
|
pattrib->pktlen = pattrib->last_txcmdsz = 0;
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return xmit_frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int rtw_IOL_append_cmds(struct xmit_frame *xmit_frame, u8 *IOL_cmds, u32 cmd_len)
|
|
|
|
{
|
|
|
|
struct pkt_attrib *pattrib = &xmit_frame->attrib;
|
|
|
|
u16 buf_offset;
|
|
|
|
u32 ori_len;
|
|
|
|
|
|
|
|
buf_offset = TXDESC_OFFSET;
|
|
|
|
ori_len = buf_offset+pattrib->pktlen;
|
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* check if the io_buf can accommodate new cmds */
|
2013-05-09 04:04:25 +00:00
|
|
|
if (ori_len + cmd_len + 8 > MAX_XMITBUF_SZ) {
|
2013-05-25 23:35:42 +00:00
|
|
|
DBG_88E("%s %u is large than MAX_XMITBUF_SZ:%u, can't accommodate new cmds\n", __func__
|
2013-05-08 21:45:39 +00:00
|
|
|
, ori_len + cmd_len + 8, MAX_XMITBUF_SZ);
|
|
|
|
return _FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
_rtw_memcpy(xmit_frame->buf_addr + buf_offset + pattrib->pktlen, IOL_cmds, cmd_len);
|
|
|
|
pattrib->pktlen += cmd_len;
|
|
|
|
pattrib->last_txcmdsz += cmd_len;
|
|
|
|
|
|
|
|
return _SUCCESS;
|
|
|
|
}
|
2013-07-09 22:38:46 +00:00
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
bool rtw_IOL_applied(struct adapter *adapter)
|
2013-05-19 04:28:07 +00:00
|
|
|
{
|
2013-05-09 04:04:25 +00:00
|
|
|
if (1 == adapter->registrypriv.fw_iol)
|
2013-05-26 03:02:10 +00:00
|
|
|
return true;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if ((2 == adapter->registrypriv.fw_iol) && (!adapter_to_dvobj(adapter)->ishighspeed))
|
2013-05-26 03:02:10 +00:00
|
|
|
return true;
|
|
|
|
return false;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
int rtw_IOL_exec_cmds_sync(struct adapter *adapter, struct xmit_frame *xmit_frame, u32 max_wating_ms, u32 bndy_cnt)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
return rtw_hal_iol_cmd(adapter, xmit_frame, max_wating_ms,bndy_cnt);
|
|
|
|
}
|
|
|
|
|
|
|
|
int rtw_IOL_append_LLT_cmd(struct xmit_frame *xmit_frame, u8 page_boundary)
|
|
|
|
{
|
|
|
|
return _SUCCESS;
|
|
|
|
}
|
|
|
|
int _rtw_IOL_append_WB_cmd(struct xmit_frame *xmit_frame, u16 addr, u8 value, u8 mask)
|
|
|
|
{
|
|
|
|
struct ioreg_cfg cmd = {8,IOREG_CMD_WB_REG,0x0, 0x0,0x0};
|
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
cmd.address = cpu_to_le16(addr);
|
2013-05-08 21:45:39 +00:00
|
|
|
cmd.data = cpu_to_le32(value);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if (mask!=0xFF)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
cmd.length = 12;
|
|
|
|
cmd.mask = cpu_to_le32(mask);
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return rtw_IOL_append_cmds(xmit_frame, (u8*)&cmd, cmd.length);
|
|
|
|
}
|
2013-07-09 22:38:46 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
int _rtw_IOL_append_WW_cmd(struct xmit_frame *xmit_frame, u16 addr, u16 value, u16 mask)
|
|
|
|
{
|
|
|
|
struct ioreg_cfg cmd = {8,IOREG_CMD_WW_REG,0x0, 0x0,0x0};
|
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
cmd.address = cpu_to_le16(addr);
|
2013-05-08 21:45:39 +00:00
|
|
|
cmd.data = cpu_to_le32(value);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if (mask!=0xFFFF)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
cmd.length = 12;
|
|
|
|
cmd.mask = cpu_to_le32(mask);
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return rtw_IOL_append_cmds(xmit_frame, (u8*)&cmd, cmd.length);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
int _rtw_IOL_append_WD_cmd(struct xmit_frame *xmit_frame, u16 addr, u32 value, u32 mask)
|
|
|
|
{
|
|
|
|
struct ioreg_cfg cmd = {8,IOREG_CMD_WD_REG,0x0, 0x0,0x0};
|
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
cmd.address = cpu_to_le16(addr);
|
2013-05-08 21:45:39 +00:00
|
|
|
cmd.data = cpu_to_le32(value);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if (mask!=0xFFFFFFFF)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
cmd.length = 12;
|
|
|
|
cmd.mask = cpu_to_le32(mask);
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return rtw_IOL_append_cmds(xmit_frame, (u8*)&cmd, cmd.length);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int _rtw_IOL_append_WRF_cmd(struct xmit_frame *xmit_frame, u8 rf_path, u16 addr, u32 value, u32 mask)
|
|
|
|
{
|
|
|
|
struct ioreg_cfg cmd = {8,IOREG_CMD_W_RF,0x0, 0x0,0x0};
|
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
cmd.address = cpu_to_le16((rf_path<<8) |((addr) &0xFF));
|
2013-05-08 21:45:39 +00:00
|
|
|
cmd.data = cpu_to_le32(value);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
if (mask != 0x000FFFFF) {
|
2013-05-08 21:45:39 +00:00
|
|
|
cmd.length = 12;
|
|
|
|
cmd.mask = cpu_to_le32(mask);
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return rtw_IOL_append_cmds(xmit_frame, (u8*)&cmd, cmd.length);
|
|
|
|
}
|
|
|
|
|
|
|
|
int rtw_IOL_append_DELAY_US_cmd(struct xmit_frame *xmit_frame, u16 us)
|
|
|
|
{
|
|
|
|
struct ioreg_cfg cmd = {4,IOREG_CMD_DELAY_US,0x0, 0x0,0x0};
|
2013-05-19 04:28:07 +00:00
|
|
|
cmd.address = cpu_to_le16(us);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return rtw_IOL_append_cmds(xmit_frame, (u8*)&cmd, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
int rtw_IOL_append_DELAY_MS_cmd(struct xmit_frame *xmit_frame, u16 ms)
|
|
|
|
{
|
|
|
|
struct ioreg_cfg cmd = {4,IOREG_CMD_DELAY_US,0x0, 0x0,0x0};
|
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
cmd.address = cpu_to_le16(ms);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
return rtw_IOL_append_cmds(xmit_frame, (u8*)&cmd, 4);
|
|
|
|
}
|
|
|
|
int rtw_IOL_append_END_cmd(struct xmit_frame *xmit_frame)
|
2013-05-19 04:28:07 +00:00
|
|
|
{
|
2013-07-09 22:38:46 +00:00
|
|
|
struct ioreg_cfg cmd = {4, IOREG_CMD_END, cpu_to_le16(0xFFFF), cpu_to_le32(0xFF), 0x0};
|
2013-05-08 21:45:39 +00:00
|
|
|
return rtw_IOL_append_cmds(xmit_frame, (u8*)&cmd, 4);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
u8 rtw_IOL_cmd_boundary_handle(struct xmit_frame *pxmit_frame)
|
2013-05-19 04:28:07 +00:00
|
|
|
{
|
2013-05-26 03:02:10 +00:00
|
|
|
u8 is_cmd_bndy = false;
|
2013-05-09 04:04:25 +00:00
|
|
|
if (((pxmit_frame->attrib.pktlen+32)%256) + 8 >= 256){
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_IOL_append_END_cmd(pxmit_frame);
|
|
|
|
pxmit_frame->attrib.pktlen = ((((pxmit_frame->attrib.pktlen+32)/256)+1)*256 );
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pxmit_frame->attrib.last_txcmdsz = pxmit_frame->attrib.pktlen;
|
2013-05-26 03:02:10 +00:00
|
|
|
is_cmd_bndy = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
return is_cmd_bndy;
|
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
void rtw_IOL_cmd_buf_dump(struct adapter *Adapter,int buf_len,u8 *pbuf)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int j=1;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-09 16:23:32 +00:00
|
|
|
printk("###### %s ######\n",__func__);
|
2013-05-09 04:04:25 +00:00
|
|
|
for (i=0;i< buf_len;i++){
|
2013-05-08 21:45:39 +00:00
|
|
|
printk("%02x-",*(pbuf+i));
|
2013-05-19 04:28:07 +00:00
|
|
|
|
|
|
|
if (j%32 ==0) printk("\n");j++;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
printk("\n");
|
2013-05-19 04:28:07 +00:00
|
|
|
printk("============= ioreg_cmd len = %d ===============\n",buf_len);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|