1 /******************************************************************************
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
19 ******************************************************************************/
23 struct xmit_frame *rtw_IOL_accquire_xmit_frame(struct adapter *adapter)
25 struct xmit_frame *xmit_frame;
26 struct xmit_buf *xmitbuf;
27 struct pkt_attrib *pattrib;
28 struct xmit_priv *pxmitpriv = &(adapter->xmitpriv);
30 xmit_frame = rtw_alloc_xmitframe(pxmitpriv);
31 if (xmit_frame == NULL) {
32 DBG_88E("%s rtw_alloc_xmitframe return null\n", __func__);
36 xmitbuf = rtw_alloc_xmitbuf(pxmitpriv);
37 if (xmitbuf == NULL) {
38 DBG_88E("%s rtw_alloc_xmitbuf return null\n", __func__);
39 rtw_free_xmitframe(pxmitpriv, xmit_frame);
44 xmit_frame->frame_tag = MGNT_FRAMETAG;
45 xmit_frame->pxmitbuf = xmitbuf;
46 xmit_frame->buf_addr = xmitbuf->pbuf;
47 xmitbuf->priv_data = xmit_frame;
49 pattrib = &xmit_frame->attrib;
50 update_mgntframe_attrib(adapter, pattrib);
51 pattrib->qsel = 0x10;/* Beacon */
52 pattrib->subtype = WIFI_BEACON;
54 pattrib->last_txcmdsz = 0;
59 int rtw_IOL_append_cmds(struct xmit_frame *xmit_frame, u8 *IOL_cmds, u32 cmd_len)
61 struct pkt_attrib *pattrib = &xmit_frame->attrib;
65 buf_offset = TXDESC_OFFSET;
66 ori_len = buf_offset+pattrib->pktlen;
68 /* check if the io_buf can accommodate new cmds */
69 if (ori_len + cmd_len + 8 > MAX_XMITBUF_SZ) {
70 DBG_88E("%s %u is large than MAX_XMITBUF_SZ:%u, can't accommodate new cmds\n",
71 __func__ , ori_len + cmd_len + 8, MAX_XMITBUF_SZ);
75 memcpy(xmit_frame->buf_addr + buf_offset + pattrib->pktlen, IOL_cmds, cmd_len);
76 pattrib->pktlen += cmd_len;
77 pattrib->last_txcmdsz += cmd_len;
82 bool rtw_IOL_applied(struct adapter *adapter)
84 if (1 == adapter->registrypriv.fw_iol)
87 if ((2 == adapter->registrypriv.fw_iol) && (!adapter_to_dvobj(adapter)->ishighspeed))
92 int rtw_IOL_exec_cmds_sync(struct adapter *adapter, struct xmit_frame *xmit_frame, u32 max_wating_ms, u32 bndy_cnt)
94 return rtw_hal_iol_cmd(adapter, xmit_frame, max_wating_ms, bndy_cnt);
97 int rtw_IOL_append_LLT_cmd(struct xmit_frame *xmit_frame, u8 page_boundary)
102 int _rtw_IOL_append_WB_cmd(struct xmit_frame *xmit_frame, u16 addr, u8 value, u8 mask)
104 struct ioreg_cfg cmd = {8, IOREG_CMD_WB_REG, 0x0, 0x0, 0x0};
106 cmd.address = cpu_to_le16(addr);
107 cmd.data = cpu_to_le32(value);
111 cmd.mask = cpu_to_le32(mask);
113 return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, cmd.length);
116 int _rtw_IOL_append_WW_cmd(struct xmit_frame *xmit_frame, u16 addr, u16 value, u16 mask)
118 struct ioreg_cfg cmd = {8, IOREG_CMD_WW_REG, 0x0, 0x0, 0x0};
120 cmd.address = cpu_to_le16(addr);
121 cmd.data = cpu_to_le32(value);
123 if (mask != 0xFFFF) {
125 cmd.mask = cpu_to_le32(mask);
127 return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, cmd.length);
130 int _rtw_IOL_append_WD_cmd(struct xmit_frame *xmit_frame, u16 addr, u32 value, u32 mask)
132 struct ioreg_cfg cmd = {8, IOREG_CMD_WD_REG, 0x0, 0x0, 0x0};
134 cmd.address = cpu_to_le16(addr);
135 cmd.data = cpu_to_le32(value);
137 if (mask != 0xFFFFFFFF) {
139 cmd.mask = cpu_to_le32(mask);
141 return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, cmd.length);
144 int _rtw_IOL_append_WRF_cmd(struct xmit_frame *xmit_frame, u8 rf_path, u16 addr, u32 value, u32 mask)
146 struct ioreg_cfg cmd = {8, IOREG_CMD_W_RF, 0x0, 0x0, 0x0};
148 cmd.address = cpu_to_le16((rf_path<<8) | ((addr) & 0xFF));
149 cmd.data = cpu_to_le32(value);
151 if (mask != 0x000FFFFF) {
153 cmd.mask = cpu_to_le32(mask);
155 return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, cmd.length);
158 int rtw_IOL_append_DELAY_US_cmd(struct xmit_frame *xmit_frame, u16 us)
160 struct ioreg_cfg cmd = {4, IOREG_CMD_DELAY_US, 0x0, 0x0, 0x0};
161 cmd.address = cpu_to_le16(us);
163 return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, 4);
166 int rtw_IOL_append_DELAY_MS_cmd(struct xmit_frame *xmit_frame, u16 ms)
168 struct ioreg_cfg cmd = {4, IOREG_CMD_DELAY_US, 0x0, 0x0, 0x0};
170 cmd.address = cpu_to_le16(ms);
171 return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, 4);
174 int rtw_IOL_append_END_cmd(struct xmit_frame *xmit_frame)
176 struct ioreg_cfg cmd = {4, IOREG_CMD_END, cpu_to_le16(0xFFFF), cpu_to_le32(0xFF), 0x0};
178 return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, 4);
181 u8 rtw_IOL_cmd_boundary_handle(struct xmit_frame *pxmit_frame)
183 u8 is_cmd_bndy = false;
184 if (((pxmit_frame->attrib.pktlen+32)%256) + 8 >= 256) {
185 rtw_IOL_append_END_cmd(pxmit_frame);
186 pxmit_frame->attrib.pktlen = ((((pxmit_frame->attrib.pktlen+32)/256)+1)*256);
188 pxmit_frame->attrib.last_txcmdsz = pxmit_frame->attrib.pktlen;
194 void rtw_IOL_cmd_buf_dump(struct adapter *Adapter, int buf_len, u8 *pbuf)
199 pr_info("###### %s ######\n", __func__);
200 for (i = 0; i < buf_len; i++) {
201 printk("%02x-", *(pbuf+i));
208 pr_info("=============ioreg_cmd len=%d===============\n", buf_len);