2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 * Purpose: Handles the management command interface functions
28 * s_vProbeChannel - Active scan channel
29 * s_MgrMakeProbeRequest - Make ProbeRequest packet
30 * CommandTimer - Timer function to handle command
31 * s_bCommandComplete - Command Complete function
32 * bScheduleCommand - Push Command and wait Command Scheduler to do
33 * vCommandTimer- Command call back functions
34 * vCommandTimerWait- Call back timer
35 * s_bClearBSSID_SCAN- Clear BSSID_SCAN cmd in CMD Queue
52 static int msglevel = MSG_LEVEL_INFO;
53 //static int msglevel = MSG_LEVEL_DEBUG;
55 static int s_bCommandComplete(struct vnt_private *);
57 static void vCommandTimerWait(struct vnt_private *priv, unsigned long msecs)
59 schedule_delayed_work(&priv->run_command_work, msecs_to_jiffies(msecs));
62 void vRunCommand(struct work_struct *work)
64 struct vnt_private *pDevice =
65 container_of(work, struct vnt_private, run_command_work.work);
68 if (pDevice->Flags & fMP_DISCONNECTED)
71 if (pDevice->bCmdRunning != true)
74 switch (pDevice->eCommandState) {
75 case WLAN_CMD_INIT_MAC80211_START:
79 dev_info(&pDevice->usb->dev, "Starting mac80211\n");
81 if (vnt_init(pDevice)) {
82 /* If fail all ends TODO retry */
83 dev_err(&pDevice->usb->dev, "failed to start\n");
84 ieee80211_free_hw(pDevice->hw);
90 case WLAN_CMD_CHANGE_BBSENSITIVITY_START:
92 pDevice->bStopDataPkt = true;
93 pDevice->byBBVGACurrent = pDevice->byBBVGANew;
94 BBvSetVGAGainOffset(pDevice, pDevice->byBBVGACurrent);
95 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Change sensitivity pDevice->byBBVGACurrent = %x\n", pDevice->byBBVGACurrent);
96 pDevice->bStopDataPkt = false;
99 case WLAN_CMD_TBTT_WAKEUP_START:
100 vnt_next_tbtt_wakeup(pDevice);
103 case WLAN_CMD_BECON_SEND_START:
107 vnt_beacon_make(pDevice, pDevice->vif);
109 vnt_mac_reg_bits_on(pDevice, MAC_REG_TCR, TCR_AUTOBCNTX);
113 case WLAN_CMD_SETPOWER_START:
115 vnt_rf_setpower(pDevice, pDevice->wCurrentRate,
116 pDevice->hw->conf.chandef.chan->hw_value);
120 case WLAN_CMD_CHANGE_ANTENNA_START:
121 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Change from Antenna%d to", (int)pDevice->dwRxAntennaSel);
122 if (pDevice->dwRxAntennaSel == 0) {
123 pDevice->dwRxAntennaSel = 1;
124 if (pDevice->bTxRxAntInv == true)
125 BBvSetAntennaMode(pDevice, ANT_RXA);
127 BBvSetAntennaMode(pDevice, ANT_RXB);
129 pDevice->dwRxAntennaSel = 0;
130 if (pDevice->bTxRxAntInv == true)
131 BBvSetAntennaMode(pDevice, ANT_RXB);
133 BBvSetAntennaMode(pDevice, ANT_RXA);
137 case WLAN_CMD_MAC_DISPOWERSAVING_START:
138 vnt_control_in_u8(pDevice, MESSAGE_REQUEST_MACREG, MAC_REG_PSCTL, &byData);
139 if ((byData & PSCTL_PS) != 0) {
140 // disable power saving hw function
141 vnt_control_out(pDevice,
142 MESSAGE_TYPE_DISABLE_PS,
151 case WLAN_CMD_11H_CHSW_START:
152 vnt_set_channel(pDevice, pDevice->hw->conf.chandef.chan->hw_value);
155 case WLAN_CMD_CONFIGURE_FILTER_START:
161 s_bCommandComplete(pDevice);
166 static int s_bCommandComplete(struct vnt_private *pDevice)
168 int bRadioCmd = false;
169 int bForceSCAN = true;
171 pDevice->eCommandState = WLAN_CMD_IDLE;
172 if (pDevice->cbFreeCmdQueue == CMD_Q_SIZE) {
173 //Command Queue Empty
174 pDevice->bCmdRunning = false;
177 pDevice->eCommand = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].eCmd;
178 bRadioCmd = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].bRadioCmd;
179 bForceSCAN = pDevice->eCmdQueue[pDevice->uCmdDequeueIdx].bForceSCAN;
180 ADD_ONE_WITH_WRAP_AROUND(pDevice->uCmdDequeueIdx, CMD_Q_SIZE);
181 pDevice->cbFreeCmdQueue++;
182 pDevice->bCmdRunning = true;
183 switch (pDevice->eCommand) {
184 case WLAN_CMD_INIT_MAC80211:
185 pDevice->eCommandState = WLAN_CMD_INIT_MAC80211_START;
188 case WLAN_CMD_CHANGE_BBSENSITIVITY:
189 pDevice->eCommandState = WLAN_CMD_CHANGE_BBSENSITIVITY_START;
192 case WLAN_CMD_TBTT_WAKEUP:
193 pDevice->eCommandState = WLAN_CMD_TBTT_WAKEUP_START;
196 case WLAN_CMD_BECON_SEND:
197 pDevice->eCommandState = WLAN_CMD_BECON_SEND_START;
200 case WLAN_CMD_SETPOWER:
201 pDevice->eCommandState = WLAN_CMD_SETPOWER_START;
204 case WLAN_CMD_CHANGE_ANTENNA:
205 pDevice->eCommandState = WLAN_CMD_CHANGE_ANTENNA_START;
208 case WLAN_CMD_MAC_DISPOWERSAVING:
209 pDevice->eCommandState = WLAN_CMD_MAC_DISPOWERSAVING_START;
212 case WLAN_CMD_11H_CHSW:
213 pDevice->eCommandState = WLAN_CMD_11H_CHSW_START;
219 vCommandTimerWait(pDevice, 0);
225 int bScheduleCommand(struct vnt_private *pDevice,
226 CMD_CODE eCommand, u8 *pbyItem0)
229 if (pDevice->cbFreeCmdQueue == 0)
231 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].eCmd = eCommand;
232 pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].bForceSCAN = true;
234 ADD_ONE_WITH_WRAP_AROUND(pDevice->uCmdEnqueueIdx, CMD_Q_SIZE);
235 pDevice->cbFreeCmdQueue--;
237 if (pDevice->bCmdRunning == false)
238 s_bCommandComplete(pDevice);
244 void vResetCommandTimer(struct vnt_private *pDevice)
246 pDevice->cbFreeCmdQueue = CMD_Q_SIZE;
247 pDevice->uCmdDequeueIdx = 0;
248 pDevice->uCmdEnqueueIdx = 0;
249 pDevice->eCommandState = WLAN_CMD_IDLE;
250 pDevice->bCmdRunning = false;
251 pDevice->bCmdClear = false;