cmdresp.c 15.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/**
  * This file contains the handling of command
  * responses as well as events generated by firmware.
  */
#include <linux/delay.h>
#include <linux/if_arp.h>
#include <linux/netdevice.h>

#include <net/iw_handler.h>

#include "host.h"
#include "decl.h"
#include "defs.h"
#include "dev.h"
15
#include "assoc.h"
16 17 18 19 20 21 22
#include "wext.h"

/**
 *  @brief This function handles disconnect event. it
 *  reports disconnect to upper layer, clean tx/rx packets,
 *  reset link state etc.
 *
23
 *  @param priv    A pointer to struct lbs_private structure
24 25
 *  @return 	   n/a
 */
26
void lbs_mac_event_disconnected(struct lbs_private *priv)
27 28 29
{
	union iwreq_data wrqu;

30
	if (priv->connect_status != LBS_CONNECTED)
31 32
		return;

33
	lbs_deb_enter(LBS_DEB_ASSOC);
34 35 36 37 38 39 40 41 42 43

	memset(wrqu.ap_addr.sa_data, 0x00, ETH_ALEN);
	wrqu.ap_addr.sa_family = ARPHRD_ETHER;

	/*
	 * Cisco AP sends EAP failure and de-auth in less than 0.5 ms.
	 * It causes problem in the Supplicant
	 */

	msleep_interruptible(1000);
44
	wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL);
45 46

	/* report disconnect to upper layer */
47 48
	netif_stop_queue(priv->dev);
	netif_carrier_off(priv->dev);
49

50 51 52 53 54
	/* Free Tx and Rx packets */
	kfree_skb(priv->currenttxskb);
	priv->currenttxskb = NULL;
	priv->tx_pending_len = 0;

55
	/* reset SNR/NF/RSSI values */
56 57 58 59 60 61 62 63
	memset(priv->SNR, 0x00, sizeof(priv->SNR));
	memset(priv->NF, 0x00, sizeof(priv->NF));
	memset(priv->RSSI, 0x00, sizeof(priv->RSSI));
	memset(priv->rawSNR, 0x00, sizeof(priv->rawSNR));
	memset(priv->rawNF, 0x00, sizeof(priv->rawNF));
	priv->nextSNRNF = 0;
	priv->numSNRNF = 0;
	priv->connect_status = LBS_DISCONNECTED;
64

65 66 67
	/* Clear out associated SSID and BSSID since connection is
	 * no longer valid.
	 */
68 69 70
	memset(&priv->curbssparams.bssid, 0, ETH_ALEN);
	memset(&priv->curbssparams.ssid, 0, IW_ESSID_MAX_SIZE);
	priv->curbssparams.ssid_len = 0;
71

72
	if (priv->psstate != PS_STATE_FULL_POWER) {
73
		/* make firmware to exit PS mode */
74
		lbs_deb_cmd("disconnected, so exit PS mode\n");
75
		lbs_ps_wakeup(priv, 0);
76
	}
77
	lbs_deb_leave(LBS_DEB_ASSOC);
78 79 80 81 82
}

/**
 *  @brief This function handles MIC failure event.
 *
83
 *  @param priv    A pointer to struct lbs_private structure
84 85 86
 *  @para  event   the event id
 *  @return 	   n/a
 */
87
static void handle_mic_failureevent(struct lbs_private *priv, u32 event)
88 89 90
{
	char buf[50];

91
	lbs_deb_enter(LBS_DEB_CMD);
92 93 94 95 96 97 98 99 100 101
	memset(buf, 0, sizeof(buf));

	sprintf(buf, "%s", "MLME-MICHAELMICFAILURE.indication ");

	if (event == MACREG_INT_CODE_MIC_ERR_UNICAST) {
		strcat(buf, "unicast ");
	} else {
		strcat(buf, "multicast ");
	}

102
	lbs_send_iwevcustom_event(priv, buf);
103
	lbs_deb_leave(LBS_DEB_CMD);
104 105
}

106
static int lbs_ret_reg_access(struct lbs_private *priv,
107 108
			       u16 type, struct cmd_ds_command *resp)
{
109
	int ret = 0;
110

111
	lbs_deb_enter(LBS_DEB_CMD);
112 113

	switch (type) {
114
	case CMD_RET(CMD_MAC_REG_ACCESS):
115
		{
116
			struct cmd_ds_mac_reg_access *reg = &resp->params.macreg;
117

118 119
			priv->offsetvalue.offset = (u32)le16_to_cpu(reg->offset);
			priv->offsetvalue.value = le32_to_cpu(reg->value);
120 121 122
			break;
		}

123
	case CMD_RET(CMD_BBP_REG_ACCESS):
124
		{
125
			struct cmd_ds_bbp_reg_access *reg = &resp->params.bbpreg;
126

127 128
			priv->offsetvalue.offset = (u32)le16_to_cpu(reg->offset);
			priv->offsetvalue.value = reg->value;
129 130 131
			break;
		}

132
	case CMD_RET(CMD_RF_REG_ACCESS):
133
		{
134
			struct cmd_ds_rf_reg_access *reg = &resp->params.rfreg;
135

136 137
			priv->offsetvalue.offset = (u32)le16_to_cpu(reg->offset);
			priv->offsetvalue.value = reg->value;
138 139 140 141
			break;
		}

	default:
142
		ret = -1;
143 144
	}

145
	lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
146
	return ret;
147 148
}

149
static int lbs_ret_802_11_rssi(struct lbs_private *priv,
150 151 152 153
				struct cmd_ds_command *resp)
{
	struct cmd_ds_802_11_rssi_rsp *rssirsp = &resp->params.rssirsp;

154 155
	lbs_deb_enter(LBS_DEB_CMD);

156
	/* store the non average value */
157 158
	priv->SNR[TYPE_BEACON][TYPE_NOAVG] = le16_to_cpu(rssirsp->SNR);
	priv->NF[TYPE_BEACON][TYPE_NOAVG] = le16_to_cpu(rssirsp->noisefloor);
159

160 161
	priv->SNR[TYPE_BEACON][TYPE_AVG] = le16_to_cpu(rssirsp->avgSNR);
	priv->NF[TYPE_BEACON][TYPE_AVG] = le16_to_cpu(rssirsp->avgnoisefloor);
162

163 164 165
	priv->RSSI[TYPE_BEACON][TYPE_NOAVG] =
	    CAL_RSSI(priv->SNR[TYPE_BEACON][TYPE_NOAVG],
		     priv->NF[TYPE_BEACON][TYPE_NOAVG]);
166

167 168 169
	priv->RSSI[TYPE_BEACON][TYPE_AVG] =
	    CAL_RSSI(priv->SNR[TYPE_BEACON][TYPE_AVG] / AVG_SCALE,
		     priv->NF[TYPE_BEACON][TYPE_AVG] / AVG_SCALE);
170

171
	lbs_deb_cmd("RSSI: beacon %d, avg %d\n",
172 173
	       priv->RSSI[TYPE_BEACON][TYPE_NOAVG],
	       priv->RSSI[TYPE_BEACON][TYPE_AVG]);
174

175
	lbs_deb_leave(LBS_DEB_CMD);
176 177 178
	return 0;
}

179 180 181 182 183 184 185 186 187
static int lbs_ret_802_11_bcn_ctrl(struct lbs_private * priv,
					struct cmd_ds_command *resp)
{
	struct cmd_ds_802_11_beacon_control *bcn_ctrl =
	    &resp->params.bcn_ctrl;

	lbs_deb_enter(LBS_DEB_CMD);

	if (bcn_ctrl->action == CMD_ACT_GET) {
188 189
		priv->beacon_enable = (u8) le16_to_cpu(bcn_ctrl->beacon_enable);
		priv->beacon_period = le16_to_cpu(bcn_ctrl->beacon_period);
190 191 192 193 194 195
	}

	lbs_deb_enter(LBS_DEB_CMD);
	return 0;
}

196
static inline int handle_cmd_response(struct lbs_private *priv,
197
				      struct cmd_header *cmd_response)
198
{
199
	struct cmd_ds_command *resp = (struct cmd_ds_command *) cmd_response;
200 201
	int ret = 0;
	unsigned long flags;
202
	uint16_t respcmd = le16_to_cpu(resp->command);
203

204 205
	lbs_deb_enter(LBS_DEB_HOST);

206
	switch (respcmd) {
207 208 209
	case CMD_RET(CMD_MAC_REG_ACCESS):
	case CMD_RET(CMD_BBP_REG_ACCESS):
	case CMD_RET(CMD_RF_REG_ACCESS):
210
		ret = lbs_ret_reg_access(priv, respcmd, resp);
211 212
		break;

213 214
	case CMD_RET(CMD_802_11_SET_AFC):
	case CMD_RET(CMD_802_11_GET_AFC):
215
		spin_lock_irqsave(&priv->driver_lock, flags);
216
		memmove((void *)priv->cur_cmd->callback_arg, &resp->params.afc,
217
			sizeof(struct cmd_ds_802_11_afc));
218
		spin_unlock_irqrestore(&priv->driver_lock, flags);
219 220 221

		break;

222
	case CMD_RET(CMD_802_11_BEACON_STOP):
223 224
		break;

225
	case CMD_RET(CMD_802_11_RSSI):
226
		ret = lbs_ret_802_11_rssi(priv, resp);
227 228
		break;

229
	case CMD_RET(CMD_802_11D_DOMAIN_INFO):
230
		ret = lbs_ret_802_11d_domain_info(resp);
231 232
		break;

233
	case CMD_RET(CMD_802_11_TPC_CFG):
234
		spin_lock_irqsave(&priv->driver_lock, flags);
235
		memmove((void *)priv->cur_cmd->callback_arg, &resp->params.tpccfg,
236
			sizeof(struct cmd_ds_802_11_tpc_cfg));
237
		spin_unlock_irqrestore(&priv->driver_lock, flags);
238
		break;
239
	case CMD_RET(CMD_802_11_LED_GPIO_CTRL):
240
		spin_lock_irqsave(&priv->driver_lock, flags);
241
		memmove((void *)priv->cur_cmd->callback_arg, &resp->params.ledgpio,
242
			sizeof(struct cmd_ds_802_11_led_ctrl));
243
		spin_unlock_irqrestore(&priv->driver_lock, flags);
244
		break;
245

246
	case CMD_RET(CMD_GET_TSF):
247
		spin_lock_irqsave(&priv->driver_lock, flags);
248
		memcpy((void *)priv->cur_cmd->callback_arg,
249
		       &resp->params.gettsf.tsfvalue, sizeof(u64));
250
		spin_unlock_irqrestore(&priv->driver_lock, flags);
251
		break;
252
	case CMD_RET(CMD_BT_ACCESS):
253
		spin_lock_irqsave(&priv->driver_lock, flags);
254 255
		if (priv->cur_cmd->callback_arg)
			memcpy((void *)priv->cur_cmd->callback_arg,
256
			       &resp->params.bt.addr1, 2 * ETH_ALEN);
257
		spin_unlock_irqrestore(&priv->driver_lock, flags);
258
		break;
259
	case CMD_RET(CMD_FWT_ACCESS):
260
		spin_lock_irqsave(&priv->driver_lock, flags);
261 262
		if (priv->cur_cmd->callback_arg)
			memcpy((void *)priv->cur_cmd->callback_arg, &resp->params.fwt,
263
			       sizeof(resp->params.fwt));
264
		spin_unlock_irqrestore(&priv->driver_lock, flags);
265
		break;
266 267 268 269
	case CMD_RET(CMD_802_11_BEACON_CTRL):
		ret = lbs_ret_802_11_bcn_ctrl(priv, resp);
		break;

270
	default:
271 272
		lbs_pr_err("CMD_RESP: unknown cmd response 0x%04x\n",
			   le16_to_cpu(resp->command));
273 274
		break;
	}
275
	lbs_deb_leave(LBS_DEB_HOST);
276 277 278
	return ret;
}

279
int lbs_process_command_response(struct lbs_private *priv, u8 *data, u32 len)
280
{
281
	uint16_t respcmd, curcmd;
282
	struct cmd_header *resp;
283
	int ret = 0;
284 285
	unsigned long flags;
	uint16_t result;
286

287
	lbs_deb_enter(LBS_DEB_HOST);
288

289 290
	mutex_lock(&priv->lock);
	spin_lock_irqsave(&priv->driver_lock, flags);
291

292
	if (!priv->cur_cmd) {
293
		lbs_deb_host("CMD_RESP: cur_cmd is NULL\n");
294
		ret = -1;
295
		spin_unlock_irqrestore(&priv->driver_lock, flags);
296 297
		goto done;
	}
298

299
	resp = (void *)data;
300
	curcmd = le16_to_cpu(priv->cur_cmd->cmdbuf->command);
301 302 303
	respcmd = le16_to_cpu(resp->command);
	result = le16_to_cpu(resp->result);

H
Holger Schurig 已提交
304
	lbs_deb_cmd("CMD_RESP: response 0x%04x, seq %d, size %d\n",
305 306
		     respcmd, le16_to_cpu(resp->seqnum), len);
	lbs_deb_hex(LBS_DEB_CMD, "CMD_RESP", (void *) resp, len);
307

308
	if (resp->seqnum != priv->cur_cmd->cmdbuf->seqnum) {
309
		lbs_pr_info("Received CMD_RESP with invalid sequence %d (expected %d)\n",
310
			    le16_to_cpu(resp->seqnum), le16_to_cpu(priv->cur_cmd->cmdbuf->seqnum));
311
		spin_unlock_irqrestore(&priv->driver_lock, flags);
312 313 314
		ret = -1;
		goto done;
	}
315
	if (respcmd != CMD_RET(curcmd) &&
316
	    respcmd != CMD_RET_802_11_ASSOCIATE && curcmd != CMD_802_11_ASSOCIATE) {
317 318 319 320 321 322
		lbs_pr_info("Invalid CMD_RESP %x to command %x!\n", respcmd, curcmd);
		spin_unlock_irqrestore(&priv->driver_lock, flags);
		ret = -1;
		goto done;
	}

323 324 325 326 327 328 329 330 331 332
	if (resp->result == cpu_to_le16(0x0004)) {
		/* 0x0004 means -EAGAIN. Drop the response, let it time out
		   and be resubmitted */
		lbs_pr_info("Firmware returns DEFER to command %x. Will let it time out...\n",
			    le16_to_cpu(resp->command));
		spin_unlock_irqrestore(&priv->driver_lock, flags);
		ret = -1;
		goto done;
	}

333 334
	/* Now we got response from FW, cancel the command timer */
	del_timer(&priv->command_timer);
335 336 337 338 339 340
	priv->cmd_timed_out = 0;
	if (priv->nr_retries) {
		lbs_pr_info("Received result %x to command %x after %d retries\n",
			    result, curcmd, priv->nr_retries);
		priv->nr_retries = 0;
	}
341 342

	/* Store the response code to cur_cmd_retcode. */
343
	priv->cur_cmd_retcode = result;
344

345
	if (respcmd == CMD_RET(CMD_802_11_PS_MODE)) {
346
		struct cmd_ds_802_11_ps_mode *psmode = (void *) &resp[1];
347
		u16 action = le16_to_cpu(psmode->action);
348

349 350
		lbs_deb_host(
		       "CMD_RESP: PS_MODE cmd reply result 0x%x, action 0x%x\n",
351
		       result, action);
352 353

		if (result) {
354
			lbs_deb_host("CMD_RESP: PS command failed with 0x%x\n",
355 356 357 358
				    result);
			/*
			 * We should not re-try enter-ps command in
			 * ad-hoc mode. It takes place in
359
			 * lbs_execute_next_command().
360
			 */
361
			if (priv->mode == IW_MODE_ADHOC &&
362
			    action == CMD_SUBCMD_ENTER_PS)
363
				priv->psmode = LBS802_11POWERMODECAM;
364
		} else if (action == CMD_SUBCMD_ENTER_PS) {
365 366
			priv->needtowakeup = 0;
			priv->psstate = PS_STATE_AWAKE;
367

368
			lbs_deb_host("CMD_RESP: ENTER_PS command response\n");
369
			if (priv->connect_status != LBS_CONNECTED) {
370 371 372 373
				/*
				 * When Deauth Event received before Enter_PS command
				 * response, We need to wake up the firmware.
				 */
374
				lbs_deb_host(
375
				       "disconnected, invoking lbs_ps_wakeup\n");
376

377 378
				spin_unlock_irqrestore(&priv->driver_lock, flags);
				mutex_unlock(&priv->lock);
379
				lbs_ps_wakeup(priv, 0);
380 381
				mutex_lock(&priv->lock);
				spin_lock_irqsave(&priv->driver_lock, flags);
382
			}
383
		} else if (action == CMD_SUBCMD_EXIT_PS) {
384 385
			priv->needtowakeup = 0;
			priv->psstate = PS_STATE_FULL_POWER;
386
			lbs_deb_host("CMD_RESP: EXIT_PS command response\n");
387
		} else {
388
			lbs_deb_host("CMD_RESP: PS action 0x%X\n", action);
389 390
		}

391
		lbs_complete_command(priv, priv->cur_cmd, result);
392
		spin_unlock_irqrestore(&priv->driver_lock, flags);
393 394 395 396 397 398 399

		ret = 0;
		goto done;
	}

	/* If the command is not successful, cleanup and return failure */
	if ((result != 0 || !(respcmd & 0x8000))) {
400 401
		lbs_deb_host("CMD_RESP: error 0x%04x in command reply 0x%04x\n",
		       result, respcmd);
402 403 404 405
		/*
		 * Handling errors here
		 */
		switch (respcmd) {
406 407
		case CMD_RET(CMD_GET_HW_SPEC):
		case CMD_RET(CMD_802_11_RESET):
408
			lbs_deb_host("CMD_RESP: reset failed\n");
409 410 411
			break;

		}
412
		lbs_complete_command(priv, priv->cur_cmd, result);
413
		spin_unlock_irqrestore(&priv->driver_lock, flags);
414 415 416 417 418

		ret = -1;
		goto done;
	}

419
	spin_unlock_irqrestore(&priv->driver_lock, flags);
420

421 422
	if (priv->cur_cmd && priv->cur_cmd->callback) {
		ret = priv->cur_cmd->callback(priv, priv->cur_cmd->callback_arg,
423
				resp);
424
	} else
425
		ret = handle_cmd_response(priv, resp);
426

427
	spin_lock_irqsave(&priv->driver_lock, flags);
428

429
	if (priv->cur_cmd) {
430
		/* Clean up and Put current command back to cmdfreeq */
431
		lbs_complete_command(priv, priv->cur_cmd, result);
432
	}
433
	spin_unlock_irqrestore(&priv->driver_lock, flags);
434 435

done:
436
	mutex_unlock(&priv->lock);
437
	lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret);
438 439 440
	return ret;
}

441 442
static int lbs_send_confirmwake(struct lbs_private *priv)
{
443
	struct cmd_header cmd;
444 445 446 447
	int ret = 0;

	lbs_deb_enter(LBS_DEB_HOST);

448 449 450 451
	cmd.command = cpu_to_le16(CMD_802_11_WAKEUP_CONFIRM);
	cmd.size = cpu_to_le16(sizeof(cmd));
	cmd.seqnum = cpu_to_le16(++priv->seqnum);
	cmd.result = 0;
452

453 454
	lbs_deb_hex(LBS_DEB_HOST, "wake confirm", (u8 *) &cmd,
		sizeof(cmd));
455

456
	ret = priv->hw_host_to_card(priv, MVMS_CMD, (u8 *) &cmd, sizeof(cmd));
457 458 459 460 461 462 463
	if (ret)
		lbs_pr_alert("SEND_WAKEC_CMD: Host to Card failed for Confirm Wake\n");

	lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret);
	return ret;
}

464
int lbs_process_event(struct lbs_private *priv, u32 event)
465 466 467
{
	int ret = 0;

468 469
	lbs_deb_enter(LBS_DEB_CMD);

470
	switch (event) {
471
	case MACREG_INT_CODE_LINK_SENSED:
472
		lbs_deb_cmd("EVENT: link sensed\n");
473 474 475
		break;

	case MACREG_INT_CODE_DEAUTHENTICATED:
476
		lbs_deb_cmd("EVENT: deauthenticated\n");
477
		lbs_mac_event_disconnected(priv);
478 479 480
		break;

	case MACREG_INT_CODE_DISASSOCIATED:
481
		lbs_deb_cmd("EVENT: disassociated\n");
482
		lbs_mac_event_disconnected(priv);
483 484
		break;

485
	case MACREG_INT_CODE_LINK_LOST_NO_SCAN:
486
		lbs_deb_cmd("EVENT: link lost\n");
487
		lbs_mac_event_disconnected(priv);
488 489 490
		break;

	case MACREG_INT_CODE_PS_SLEEP:
491
		lbs_deb_cmd("EVENT: ps sleep\n");
492 493

		/* handle unexpected PS SLEEP event */
494
		if (priv->psstate == PS_STATE_FULL_POWER) {
495
			lbs_deb_cmd(
496
			       "EVENT: in FULL POWER mode, ignoreing PS_SLEEP\n");
497 498
			break;
		}
499
		priv->psstate = PS_STATE_PRE_SLEEP;
500

501
		lbs_ps_confirm_sleep(priv);
502 503 504

		break;

505
	case MACREG_INT_CODE_HOST_AWAKE:
506
		lbs_deb_cmd("EVENT: host awake\n");
507 508 509
		lbs_send_confirmwake(priv);
		break;

510
	case MACREG_INT_CODE_PS_AWAKE:
511
		lbs_deb_cmd("EVENT: ps awake\n");
512
		/* handle unexpected PS AWAKE event */
513
		if (priv->psstate == PS_STATE_FULL_POWER) {
514
			lbs_deb_cmd(
515 516 517 518
			       "EVENT: In FULL POWER mode - ignore PS AWAKE\n");
			break;
		}

519
		priv->psstate = PS_STATE_AWAKE;
520

521
		if (priv->needtowakeup) {
522 523 524
			/*
			 * wait for the command processing to finish
			 * before resuming sending
525
			 * priv->needtowakeup will be set to FALSE
526
			 * in lbs_ps_wakeup()
527
			 */
528
			lbs_deb_cmd("waking up ...\n");
529
			lbs_ps_wakeup(priv, 0);
530 531 532 533
		}
		break;

	case MACREG_INT_CODE_MIC_ERR_UNICAST:
534
		lbs_deb_cmd("EVENT: UNICAST MIC ERROR\n");
535 536 537 538
		handle_mic_failureevent(priv, MACREG_INT_CODE_MIC_ERR_UNICAST);
		break;

	case MACREG_INT_CODE_MIC_ERR_MULTICAST:
539
		lbs_deb_cmd("EVENT: MULTICAST MIC ERROR\n");
540 541
		handle_mic_failureevent(priv, MACREG_INT_CODE_MIC_ERR_MULTICAST);
		break;
542

543
	case MACREG_INT_CODE_MIB_CHANGED:
544 545
		lbs_deb_cmd("EVENT: MIB CHANGED\n");
		break;
546
	case MACREG_INT_CODE_INIT_DONE:
547
		lbs_deb_cmd("EVENT: INIT DONE\n");
548 549
		break;
	case MACREG_INT_CODE_ADHOC_BCN_LOST:
550
		lbs_deb_cmd("EVENT: ADHOC beacon lost\n");
551 552
		break;
	case MACREG_INT_CODE_RSSI_LOW:
553
		lbs_pr_alert("EVENT: rssi low\n");
554 555
		break;
	case MACREG_INT_CODE_SNR_LOW:
556
		lbs_pr_alert("EVENT: snr low\n");
557 558
		break;
	case MACREG_INT_CODE_MAX_FAIL:
559
		lbs_pr_alert("EVENT: max fail\n");
560 561
		break;
	case MACREG_INT_CODE_RSSI_HIGH:
562
		lbs_pr_alert("EVENT: rssi high\n");
563 564
		break;
	case MACREG_INT_CODE_SNR_HIGH:
565
		lbs_pr_alert("EVENT: snr high\n");
566 567
		break;

568
	case MACREG_INT_CODE_MESH_AUTO_STARTED:
569 570 571 572 573
		/* Ignore spurious autostart events if autostart is disabled */
		if (!priv->mesh_autostart_enabled) {
			lbs_pr_info("EVENT: MESH_AUTO_STARTED (ignoring)\n");
			break;
		}
574
		lbs_pr_info("EVENT: MESH_AUTO_STARTED\n");
575
		priv->mesh_connect_status = LBS_CONNECTED;
576
		if (priv->mesh_open) {
577
			netif_carrier_on(priv->mesh_dev);
578 579
			if (!priv->tx_pending_len)
				netif_wake_queue(priv->mesh_dev);
580
		}
581
		priv->mode = IW_MODE_ADHOC;
582
		schedule_work(&priv->sync_channel);
583 584
		break;

585
	default:
586
		lbs_pr_alert("EVENT: unknown event id %d\n", event);
587 588 589
		break;
	}

590
	lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
591 592
	return ret;
}