2 * This file contains the handling of command.
3 * It prepares command and sends it to firmware when it is ready.
6 #include <linux/kfifo.h>
7 #include <linux/sched.h>
19 static struct cmd_ctrl_node *lbs_get_cmd_ctrl_node(struct lbs_private *priv);
22 * @brief Simple callback that copies response back into command
24 * @param priv A pointer to struct lbs_private structure
25 * @param extra A pointer to the original command structure for which
26 * 'resp' is a response
27 * @param resp A pointer to the command response
29 * @return 0 on success, error on failure
31 int lbs_cmd_copyback(struct lbs_private *priv, unsigned long extra,
32 struct cmd_header *resp)
34 struct cmd_header *buf = (void *)extra;
37 copy_len = min(le16_to_cpu(buf->size), le16_to_cpu(resp->size));
38 memcpy(buf, resp, copy_len);
41 EXPORT_SYMBOL_GPL(lbs_cmd_copyback);
44 * @brief Simple callback that ignores the result. Use this if
45 * you just want to send a command to the hardware, but don't
46 * care for the result.
49 * @param extra ignored
52 * @return 0 for success
54 static int lbs_cmd_async_callback(struct lbs_private *priv, unsigned long extra,
55 struct cmd_header *resp)
62 * @brief Checks whether a command is allowed in Power Save mode
64 * @param command the command ID
65 * @return 1 if allowed, 0 if not allowed
67 static u8 is_command_allowed_in_ps(u16 cmd)
79 * @brief This function checks if the command is allowed.
81 * @param priv A pointer to lbs_private structure
82 * @return allowed or not allowed.
85 static int lbs_is_cmd_allowed(struct lbs_private *priv)
89 lbs_deb_enter(LBS_DEB_CMD);
91 if (!priv->is_auto_deep_sleep_enabled) {
92 if (priv->is_deep_sleep) {
93 lbs_deb_cmd("command not allowed in deep sleep\n");
98 lbs_deb_leave(LBS_DEB_CMD);
103 * @brief Updates the hardware details like MAC address and regulatory region
105 * @param priv A pointer to struct lbs_private structure
107 * @return 0 on success, error on failure
109 int lbs_update_hw_spec(struct lbs_private *priv)
111 struct cmd_ds_get_hw_spec cmd;
115 lbs_deb_enter(LBS_DEB_CMD);
117 memset(&cmd, 0, sizeof(cmd));
118 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
119 memcpy(cmd.permanentaddr, priv->current_addr, ETH_ALEN);
120 ret = lbs_cmd_with_response(priv, CMD_GET_HW_SPEC, &cmd);
124 priv->fwcapinfo = le32_to_cpu(cmd.fwcapinfo);
126 /* The firmware release is in an interesting format: the patch
127 * level is in the most significant nibble ... so fix that: */
128 priv->fwrelease = le32_to_cpu(cmd.fwrelease);
129 priv->fwrelease = (priv->fwrelease << 8) |
130 (priv->fwrelease >> 24 & 0xff);
132 /* Some firmware capabilities:
133 * CF card firmware 5.0.16p0: cap 0x00000303
134 * USB dongle firmware 5.110.17p2: cap 0x00000303
136 lbs_pr_info("%pM, fw %u.%u.%up%u, cap 0x%08x\n",
138 priv->fwrelease >> 24 & 0xff,
139 priv->fwrelease >> 16 & 0xff,
140 priv->fwrelease >> 8 & 0xff,
141 priv->fwrelease & 0xff,
143 lbs_deb_cmd("GET_HW_SPEC: hardware interface 0x%x, hardware spec 0x%04x\n",
144 cmd.hwifversion, cmd.version);
146 /* Clamp region code to 8-bit since FW spec indicates that it should
147 * only ever be 8-bit, even though the field size is 16-bit. Some firmware
148 * returns non-zero high 8 bits here.
150 * Firmware version 4.0.102 used in CF8381 has region code shifted. We
151 * need to check for this problem and handle it properly.
153 if (MRVL_FW_MAJOR_REV(priv->fwrelease) == MRVL_FW_V4)
154 priv->regioncode = (le16_to_cpu(cmd.regioncode) >> 8) & 0xFF;
156 priv->regioncode = le16_to_cpu(cmd.regioncode) & 0xFF;
158 for (i = 0; i < MRVDRV_MAX_REGION_CODE; i++) {
159 /* use the region code to search for the index */
160 if (priv->regioncode == lbs_region_code_to_index[i])
164 /* if it's unidentified region code, use the default (USA) */
165 if (i >= MRVDRV_MAX_REGION_CODE) {
166 priv->regioncode = 0x10;
167 lbs_pr_info("unidentified region code; using the default (USA)\n");
170 if (priv->current_addr[0] == 0xff)
171 memmove(priv->current_addr, cmd.permanentaddr, ETH_ALEN);
173 memcpy(priv->dev->dev_addr, priv->current_addr, ETH_ALEN);
175 memcpy(priv->mesh_dev->dev_addr, priv->current_addr, ETH_ALEN);
177 if (lbs_set_regiontable(priv, priv->regioncode, 0)) {
183 lbs_deb_leave(LBS_DEB_CMD);
187 int lbs_host_sleep_cfg(struct lbs_private *priv, uint32_t criteria,
188 struct wol_config *p_wol_config)
190 struct cmd_ds_host_sleep cmd_config;
193 cmd_config.hdr.size = cpu_to_le16(sizeof(cmd_config));
194 cmd_config.criteria = cpu_to_le32(criteria);
195 cmd_config.gpio = priv->wol_gpio;
196 cmd_config.gap = priv->wol_gap;
198 if (p_wol_config != NULL)
199 memcpy((uint8_t *)&cmd_config.wol_conf, (uint8_t *)p_wol_config,
200 sizeof(struct wol_config));
202 cmd_config.wol_conf.action = CMD_ACT_ACTION_NONE;
204 ret = lbs_cmd_with_response(priv, CMD_802_11_HOST_SLEEP_CFG, &cmd_config);
207 lbs_deb_cmd("Set WOL criteria to %x\n", criteria);
208 priv->wol_criteria = criteria;
210 memcpy((uint8_t *) p_wol_config,
211 (uint8_t *)&cmd_config.wol_conf,
212 sizeof(struct wol_config));
214 lbs_pr_info("HOST_SLEEP_CFG failed %d\n", ret);
219 EXPORT_SYMBOL_GPL(lbs_host_sleep_cfg);
221 static int lbs_cmd_802_11_ps_mode(struct cmd_ds_command *cmd,
224 struct cmd_ds_802_11_ps_mode *psm = &cmd->params.psmode;
226 lbs_deb_enter(LBS_DEB_CMD);
228 cmd->command = cpu_to_le16(CMD_802_11_PS_MODE);
229 cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_ps_mode) +
230 sizeof(struct cmd_header));
231 psm->action = cpu_to_le16(cmd_action);
232 psm->multipledtim = 0;
233 switch (cmd_action) {
234 case CMD_SUBCMD_ENTER_PS:
235 lbs_deb_cmd("PS command:" "SubCode- Enter PS\n");
237 psm->locallisteninterval = 0;
238 psm->nullpktinterval = 0;
240 cpu_to_le16(MRVDRV_DEFAULT_MULTIPLE_DTIM);
243 case CMD_SUBCMD_EXIT_PS:
244 lbs_deb_cmd("PS command:" "SubCode- Exit PS\n");
247 case CMD_SUBCMD_SLEEP_CONFIRMED:
248 lbs_deb_cmd("PS command: SubCode- sleep confirm\n");
255 lbs_deb_leave(LBS_DEB_CMD);
259 int lbs_cmd_802_11_sleep_params(struct lbs_private *priv, uint16_t cmd_action,
260 struct sleep_params *sp)
262 struct cmd_ds_802_11_sleep_params cmd;
265 lbs_deb_enter(LBS_DEB_CMD);
267 if (cmd_action == CMD_ACT_GET) {
268 memset(&cmd, 0, sizeof(cmd));
270 cmd.error = cpu_to_le16(sp->sp_error);
271 cmd.offset = cpu_to_le16(sp->sp_offset);
272 cmd.stabletime = cpu_to_le16(sp->sp_stabletime);
273 cmd.calcontrol = sp->sp_calcontrol;
274 cmd.externalsleepclk = sp->sp_extsleepclk;
275 cmd.reserved = cpu_to_le16(sp->sp_reserved);
277 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
278 cmd.action = cpu_to_le16(cmd_action);
280 ret = lbs_cmd_with_response(priv, CMD_802_11_SLEEP_PARAMS, &cmd);
283 lbs_deb_cmd("error 0x%x, offset 0x%x, stabletime 0x%x, "
284 "calcontrol 0x%x extsleepclk 0x%x\n",
285 le16_to_cpu(cmd.error), le16_to_cpu(cmd.offset),
286 le16_to_cpu(cmd.stabletime), cmd.calcontrol,
287 cmd.externalsleepclk);
289 sp->sp_error = le16_to_cpu(cmd.error);
290 sp->sp_offset = le16_to_cpu(cmd.offset);
291 sp->sp_stabletime = le16_to_cpu(cmd.stabletime);
292 sp->sp_calcontrol = cmd.calcontrol;
293 sp->sp_extsleepclk = cmd.externalsleepclk;
294 sp->sp_reserved = le16_to_cpu(cmd.reserved);
297 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
301 static int lbs_wait_for_ds_awake(struct lbs_private *priv)
305 lbs_deb_enter(LBS_DEB_CMD);
307 if (priv->is_deep_sleep) {
308 if (!wait_event_interruptible_timeout(priv->ds_awake_q,
309 !priv->is_deep_sleep, (10 * HZ))) {
310 lbs_pr_err("ds_awake_q: timer expired\n");
315 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
319 int lbs_set_deep_sleep(struct lbs_private *priv, int deep_sleep)
323 lbs_deb_enter(LBS_DEB_CMD);
326 if (priv->is_deep_sleep != 1) {
327 lbs_deb_cmd("deep sleep: sleep\n");
328 BUG_ON(!priv->enter_deep_sleep);
329 ret = priv->enter_deep_sleep(priv);
331 netif_stop_queue(priv->dev);
332 netif_carrier_off(priv->dev);
335 lbs_pr_err("deep sleep: already enabled\n");
338 if (priv->is_deep_sleep) {
339 lbs_deb_cmd("deep sleep: wakeup\n");
340 BUG_ON(!priv->exit_deep_sleep);
341 ret = priv->exit_deep_sleep(priv);
343 ret = lbs_wait_for_ds_awake(priv);
345 lbs_pr_err("deep sleep: wakeup"
351 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
356 * @brief Set an SNMP MIB value
358 * @param priv A pointer to struct lbs_private structure
359 * @param oid The OID to set in the firmware
360 * @param val Value to set the OID to
362 * @return 0 on success, error on failure
364 int lbs_set_snmp_mib(struct lbs_private *priv, u32 oid, u16 val)
366 struct cmd_ds_802_11_snmp_mib cmd;
369 lbs_deb_enter(LBS_DEB_CMD);
371 memset(&cmd, 0, sizeof (cmd));
372 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
373 cmd.action = cpu_to_le16(CMD_ACT_SET);
374 cmd.oid = cpu_to_le16((u16) oid);
377 case SNMP_MIB_OID_BSS_TYPE:
378 cmd.bufsize = cpu_to_le16(sizeof(u8));
381 case SNMP_MIB_OID_11D_ENABLE:
382 case SNMP_MIB_OID_FRAG_THRESHOLD:
383 case SNMP_MIB_OID_RTS_THRESHOLD:
384 case SNMP_MIB_OID_SHORT_RETRY_LIMIT:
385 case SNMP_MIB_OID_LONG_RETRY_LIMIT:
386 cmd.bufsize = cpu_to_le16(sizeof(u16));
387 *((__le16 *)(&cmd.value)) = cpu_to_le16(val);
390 lbs_deb_cmd("SNMP_CMD: (set) unhandled OID 0x%x\n", oid);
395 lbs_deb_cmd("SNMP_CMD: (set) oid 0x%x, oid size 0x%x, value 0x%x\n",
396 le16_to_cpu(cmd.oid), le16_to_cpu(cmd.bufsize), val);
398 ret = lbs_cmd_with_response(priv, CMD_802_11_SNMP_MIB, &cmd);
401 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
406 * @brief Get an SNMP MIB value
408 * @param priv A pointer to struct lbs_private structure
409 * @param oid The OID to retrieve from the firmware
410 * @param out_val Location for the returned value
412 * @return 0 on success, error on failure
414 int lbs_get_snmp_mib(struct lbs_private *priv, u32 oid, u16 *out_val)
416 struct cmd_ds_802_11_snmp_mib cmd;
419 lbs_deb_enter(LBS_DEB_CMD);
421 memset(&cmd, 0, sizeof (cmd));
422 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
423 cmd.action = cpu_to_le16(CMD_ACT_GET);
424 cmd.oid = cpu_to_le16(oid);
426 ret = lbs_cmd_with_response(priv, CMD_802_11_SNMP_MIB, &cmd);
430 switch (le16_to_cpu(cmd.bufsize)) {
432 *out_val = cmd.value[0];
435 *out_val = le16_to_cpu(*((__le16 *)(&cmd.value)));
438 lbs_deb_cmd("SNMP_CMD: (get) unhandled OID 0x%x size %d\n",
439 oid, le16_to_cpu(cmd.bufsize));
444 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
449 * @brief Get the min, max, and current TX power
451 * @param priv A pointer to struct lbs_private structure
452 * @param curlevel Current power level in dBm
453 * @param minlevel Minimum supported power level in dBm (optional)
454 * @param maxlevel Maximum supported power level in dBm (optional)
456 * @return 0 on success, error on failure
458 int lbs_get_tx_power(struct lbs_private *priv, s16 *curlevel, s16 *minlevel,
461 struct cmd_ds_802_11_rf_tx_power cmd;
464 lbs_deb_enter(LBS_DEB_CMD);
466 memset(&cmd, 0, sizeof(cmd));
467 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
468 cmd.action = cpu_to_le16(CMD_ACT_GET);
470 ret = lbs_cmd_with_response(priv, CMD_802_11_RF_TX_POWER, &cmd);
472 *curlevel = le16_to_cpu(cmd.curlevel);
474 *minlevel = cmd.minlevel;
476 *maxlevel = cmd.maxlevel;
479 lbs_deb_leave(LBS_DEB_CMD);
484 * @brief Set the TX power
486 * @param priv A pointer to struct lbs_private structure
487 * @param dbm The desired power level in dBm
489 * @return 0 on success, error on failure
491 int lbs_set_tx_power(struct lbs_private *priv, s16 dbm)
493 struct cmd_ds_802_11_rf_tx_power cmd;
496 lbs_deb_enter(LBS_DEB_CMD);
498 memset(&cmd, 0, sizeof(cmd));
499 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
500 cmd.action = cpu_to_le16(CMD_ACT_SET);
501 cmd.curlevel = cpu_to_le16(dbm);
503 lbs_deb_cmd("SET_RF_TX_POWER: %d dBm\n", dbm);
505 ret = lbs_cmd_with_response(priv, CMD_802_11_RF_TX_POWER, &cmd);
507 lbs_deb_leave(LBS_DEB_CMD);
511 static int lbs_cmd_802_11_monitor_mode(struct cmd_ds_command *cmd,
512 u16 cmd_action, void *pdata_buf)
514 struct cmd_ds_802_11_monitor_mode *monitor = &cmd->params.monitor;
516 cmd->command = cpu_to_le16(CMD_802_11_MONITOR_MODE);
518 cpu_to_le16(sizeof(struct cmd_ds_802_11_monitor_mode) +
519 sizeof(struct cmd_header));
521 monitor->action = cpu_to_le16(cmd_action);
522 if (cmd_action == CMD_ACT_SET) {
524 cpu_to_le16((u16) (*(u32 *) pdata_buf));
531 * @brief Get the radio channel
533 * @param priv A pointer to struct lbs_private structure
535 * @return The channel on success, error on failure
537 static int lbs_get_channel(struct lbs_private *priv)
539 struct cmd_ds_802_11_rf_channel cmd;
542 lbs_deb_enter(LBS_DEB_CMD);
544 memset(&cmd, 0, sizeof(cmd));
545 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
546 cmd.action = cpu_to_le16(CMD_OPT_802_11_RF_CHANNEL_GET);
548 ret = lbs_cmd_with_response(priv, CMD_802_11_RF_CHANNEL, &cmd);
552 ret = le16_to_cpu(cmd.channel);
553 lbs_deb_cmd("current radio channel is %d\n", ret);
556 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
560 int lbs_update_channel(struct lbs_private *priv)
564 /* the channel in f/w could be out of sync; get the current channel */
565 lbs_deb_enter(LBS_DEB_ASSOC);
567 ret = lbs_get_channel(priv);
572 lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
577 * @brief Set the radio channel
579 * @param priv A pointer to struct lbs_private structure
580 * @param channel The desired channel, or 0 to clear a locked channel
582 * @return 0 on success, error on failure
584 int lbs_set_channel(struct lbs_private *priv, u8 channel)
586 struct cmd_ds_802_11_rf_channel cmd;
588 u8 old_channel = priv->channel;
592 lbs_deb_enter(LBS_DEB_CMD);
594 memset(&cmd, 0, sizeof(cmd));
595 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
596 cmd.action = cpu_to_le16(CMD_OPT_802_11_RF_CHANNEL_SET);
597 cmd.channel = cpu_to_le16(channel);
599 ret = lbs_cmd_with_response(priv, CMD_802_11_RF_CHANNEL, &cmd);
603 priv->channel = (uint8_t) le16_to_cpu(cmd.channel);
604 lbs_deb_cmd("channel switch from %d to %d\n", old_channel,
608 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
612 static int lbs_cmd_reg_access(struct cmd_ds_command *cmdptr,
613 u8 cmd_action, void *pdata_buf)
615 struct lbs_offset_value *offval;
617 lbs_deb_enter(LBS_DEB_CMD);
619 offval = (struct lbs_offset_value *)pdata_buf;
621 switch (le16_to_cpu(cmdptr->command)) {
622 case CMD_MAC_REG_ACCESS:
624 struct cmd_ds_mac_reg_access *macreg;
627 cpu_to_le16(sizeof (struct cmd_ds_mac_reg_access)
628 + sizeof(struct cmd_header));
630 (struct cmd_ds_mac_reg_access *)&cmdptr->params.
633 macreg->action = cpu_to_le16(cmd_action);
634 macreg->offset = cpu_to_le16((u16) offval->offset);
635 macreg->value = cpu_to_le32(offval->value);
640 case CMD_BBP_REG_ACCESS:
642 struct cmd_ds_bbp_reg_access *bbpreg;
646 (struct cmd_ds_bbp_reg_access)
647 + sizeof(struct cmd_header));
649 (struct cmd_ds_bbp_reg_access *)&cmdptr->params.
652 bbpreg->action = cpu_to_le16(cmd_action);
653 bbpreg->offset = cpu_to_le16((u16) offval->offset);
654 bbpreg->value = (u8) offval->value;
659 case CMD_RF_REG_ACCESS:
661 struct cmd_ds_rf_reg_access *rfreg;
665 (struct cmd_ds_rf_reg_access) +
666 sizeof(struct cmd_header));
668 (struct cmd_ds_rf_reg_access *)&cmdptr->params.
671 rfreg->action = cpu_to_le16(cmd_action);
672 rfreg->offset = cpu_to_le16((u16) offval->offset);
673 rfreg->value = (u8) offval->value;
682 lbs_deb_leave(LBS_DEB_CMD);
686 static void lbs_queue_cmd(struct lbs_private *priv,
687 struct cmd_ctrl_node *cmdnode)
692 lbs_deb_enter(LBS_DEB_HOST);
695 lbs_deb_host("QUEUE_CMD: cmdnode is NULL\n");
698 if (!cmdnode->cmdbuf->size) {
699 lbs_deb_host("DNLD_CMD: cmd size is zero\n");
704 /* Exit_PS command needs to be queued in the header always. */
705 if (le16_to_cpu(cmdnode->cmdbuf->command) == CMD_802_11_PS_MODE) {
706 struct cmd_ds_802_11_ps_mode *psm = (void *) &cmdnode->cmdbuf[1];
708 if (psm->action == cpu_to_le16(CMD_SUBCMD_EXIT_PS)) {
709 if (priv->psstate != PS_STATE_FULL_POWER)
714 spin_lock_irqsave(&priv->driver_lock, flags);
717 list_add_tail(&cmdnode->list, &priv->cmdpendingq);
719 list_add(&cmdnode->list, &priv->cmdpendingq);
721 spin_unlock_irqrestore(&priv->driver_lock, flags);
723 lbs_deb_host("QUEUE_CMD: inserted command 0x%04x into cmdpendingq\n",
724 le16_to_cpu(cmdnode->cmdbuf->command));
727 lbs_deb_leave(LBS_DEB_HOST);
730 static void lbs_submit_command(struct lbs_private *priv,
731 struct cmd_ctrl_node *cmdnode)
734 struct cmd_header *cmd;
740 lbs_deb_enter(LBS_DEB_HOST);
742 cmd = cmdnode->cmdbuf;
744 spin_lock_irqsave(&priv->driver_lock, flags);
745 priv->cur_cmd = cmdnode;
746 priv->cur_cmd_retcode = 0;
747 spin_unlock_irqrestore(&priv->driver_lock, flags);
749 cmdsize = le16_to_cpu(cmd->size);
750 command = le16_to_cpu(cmd->command);
752 /* These commands take longer */
753 if (command == CMD_802_11_SCAN || command == CMD_802_11_ASSOCIATE)
756 lbs_deb_cmd("DNLD_CMD: command 0x%04x, seq %d, size %d\n",
757 command, le16_to_cpu(cmd->seqnum), cmdsize);
758 lbs_deb_hex(LBS_DEB_CMD, "DNLD_CMD", (void *) cmdnode->cmdbuf, cmdsize);
760 ret = priv->hw_host_to_card(priv, MVMS_CMD, (u8 *) cmd, cmdsize);
763 lbs_pr_info("DNLD_CMD: hw_host_to_card failed: %d\n", ret);
764 /* Let the timer kick in and retry, and potentially reset
765 the whole thing if the condition persists */
769 if (command == CMD_802_11_DEEP_SLEEP) {
770 if (priv->is_auto_deep_sleep_enabled) {
771 priv->wakeup_dev_required = 1;
774 priv->is_deep_sleep = 1;
775 lbs_complete_command(priv, cmdnode, 0);
777 /* Setup the timer after transmit command */
778 mod_timer(&priv->command_timer, jiffies + timeo);
781 lbs_deb_leave(LBS_DEB_HOST);
785 * This function inserts command node to cmdfreeq
786 * after cleans it. Requires priv->driver_lock held.
788 static void __lbs_cleanup_and_insert_cmd(struct lbs_private *priv,
789 struct cmd_ctrl_node *cmdnode)
791 lbs_deb_enter(LBS_DEB_HOST);
796 cmdnode->callback = NULL;
797 cmdnode->callback_arg = 0;
799 memset(cmdnode->cmdbuf, 0, LBS_CMD_BUFFER_SIZE);
801 list_add_tail(&cmdnode->list, &priv->cmdfreeq);
803 lbs_deb_leave(LBS_DEB_HOST);
806 static void lbs_cleanup_and_insert_cmd(struct lbs_private *priv,
807 struct cmd_ctrl_node *ptempcmd)
811 spin_lock_irqsave(&priv->driver_lock, flags);
812 __lbs_cleanup_and_insert_cmd(priv, ptempcmd);
813 spin_unlock_irqrestore(&priv->driver_lock, flags);
816 void lbs_complete_command(struct lbs_private *priv, struct cmd_ctrl_node *cmd,
819 if (cmd == priv->cur_cmd)
820 priv->cur_cmd_retcode = result;
822 cmd->result = result;
823 cmd->cmdwaitqwoken = 1;
824 wake_up_interruptible(&cmd->cmdwait_q);
826 if (!cmd->callback || cmd->callback == lbs_cmd_async_callback)
827 __lbs_cleanup_and_insert_cmd(priv, cmd);
828 priv->cur_cmd = NULL;
831 int lbs_set_radio(struct lbs_private *priv, u8 preamble, u8 radio_on)
833 struct cmd_ds_802_11_radio_control cmd;
836 lbs_deb_enter(LBS_DEB_CMD);
838 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
839 cmd.action = cpu_to_le16(CMD_ACT_SET);
841 /* Only v8 and below support setting the preamble */
842 if (priv->fwrelease < 0x09000000) {
844 case RADIO_PREAMBLE_SHORT:
845 case RADIO_PREAMBLE_AUTO:
846 case RADIO_PREAMBLE_LONG:
847 cmd.control = cpu_to_le16(preamble);
855 cmd.control |= cpu_to_le16(0x1);
857 cmd.control &= cpu_to_le16(~0x1);
858 priv->txpower_cur = 0;
861 lbs_deb_cmd("RADIO_CONTROL: radio %s, preamble %d\n",
862 radio_on ? "ON" : "OFF", preamble);
864 priv->radio_on = radio_on;
866 ret = lbs_cmd_with_response(priv, CMD_802_11_RADIO_CONTROL, &cmd);
869 lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
873 void lbs_set_mac_control(struct lbs_private *priv)
875 struct cmd_ds_mac_control cmd;
877 lbs_deb_enter(LBS_DEB_CMD);
879 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
880 cmd.action = cpu_to_le16(priv->mac_control);
883 lbs_cmd_async(priv, CMD_MAC_CONTROL, &cmd.hdr, sizeof(cmd));
885 lbs_deb_leave(LBS_DEB_CMD);
889 * @brief This function prepare the command before send to firmware.
891 * @param priv A pointer to struct lbs_private structure
892 * @param cmd_no command number
893 * @param cmd_action command action: GET or SET
894 * @param wait_option wait option: wait response or not
895 * @param cmd_oid cmd oid: treated as sub command
896 * @param pdata_buf A pointer to informaion buffer
899 int lbs_prepare_and_send_command(struct lbs_private *priv,
902 u16 wait_option, u32 cmd_oid, void *pdata_buf)
905 struct cmd_ctrl_node *cmdnode;
906 struct cmd_ds_command *cmdptr;
909 lbs_deb_enter(LBS_DEB_HOST);
912 lbs_deb_host("PREP_CMD: priv is NULL\n");
917 if (priv->surpriseremoved) {
918 lbs_deb_host("PREP_CMD: card removed\n");
923 if (!lbs_is_cmd_allowed(priv)) {
928 cmdnode = lbs_get_cmd_ctrl_node(priv);
930 if (cmdnode == NULL) {
931 lbs_deb_host("PREP_CMD: cmdnode is NULL\n");
933 /* Wake up main thread to execute next command */
934 wake_up_interruptible(&priv->waitq);
939 cmdnode->callback = NULL;
940 cmdnode->callback_arg = (unsigned long)pdata_buf;
942 cmdptr = (struct cmd_ds_command *)cmdnode->cmdbuf;
944 lbs_deb_host("PREP_CMD: command 0x%04x\n", cmd_no);
946 /* Set sequence number, command and INT option */
948 cmdptr->seqnum = cpu_to_le16(priv->seqnum);
950 cmdptr->command = cpu_to_le16(cmd_no);
954 case CMD_802_11_PS_MODE:
955 ret = lbs_cmd_802_11_ps_mode(cmdptr, cmd_action);
958 case CMD_MAC_REG_ACCESS:
959 case CMD_BBP_REG_ACCESS:
960 case CMD_RF_REG_ACCESS:
961 ret = lbs_cmd_reg_access(cmdptr, cmd_action, pdata_buf);
964 case CMD_802_11_MONITOR_MODE:
965 ret = lbs_cmd_802_11_monitor_mode(cmdptr,
966 cmd_action, pdata_buf);
969 case CMD_802_11_RSSI:
970 ret = lbs_cmd_802_11_rssi(priv, cmdptr);
973 case CMD_802_11_SET_AFC:
974 case CMD_802_11_GET_AFC:
976 cmdptr->command = cpu_to_le16(cmd_no);
977 cmdptr->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_afc) +
978 sizeof(struct cmd_header));
980 memmove(&cmdptr->params.afc,
981 pdata_buf, sizeof(struct cmd_ds_802_11_afc));
986 case CMD_802_11_TPC_CFG:
987 cmdptr->command = cpu_to_le16(CMD_802_11_TPC_CFG);
989 cpu_to_le16(sizeof(struct cmd_ds_802_11_tpc_cfg) +
990 sizeof(struct cmd_header));
992 memmove(&cmdptr->params.tpccfg,
993 pdata_buf, sizeof(struct cmd_ds_802_11_tpc_cfg));
998 #ifdef CONFIG_LIBERTAS_MESH
1001 ret = lbs_cmd_bt_access(cmdptr, cmd_action, pdata_buf);
1004 case CMD_FWT_ACCESS:
1005 ret = lbs_cmd_fwt_access(cmdptr, cmd_action, pdata_buf);
1010 case CMD_802_11_BEACON_CTRL:
1011 ret = lbs_cmd_bcn_ctrl(priv, cmdptr, cmd_action);
1013 case CMD_802_11_DEEP_SLEEP:
1014 cmdptr->command = cpu_to_le16(CMD_802_11_DEEP_SLEEP);
1015 cmdptr->size = cpu_to_le16(sizeof(struct cmd_header));
1018 lbs_pr_err("PREP_CMD: unknown command 0x%04x\n", cmd_no);
1023 /* return error, since the command preparation failed */
1025 lbs_deb_host("PREP_CMD: command preparation failed\n");
1026 lbs_cleanup_and_insert_cmd(priv, cmdnode);
1031 cmdnode->cmdwaitqwoken = 0;
1033 lbs_queue_cmd(priv, cmdnode);
1034 wake_up_interruptible(&priv->waitq);
1036 if (wait_option & CMD_OPTION_WAITFORRSP) {
1037 lbs_deb_host("PREP_CMD: wait for response\n");
1039 wait_event_interruptible(cmdnode->cmdwait_q,
1040 cmdnode->cmdwaitqwoken);
1043 spin_lock_irqsave(&priv->driver_lock, flags);
1044 if (priv->cur_cmd_retcode) {
1045 lbs_deb_host("PREP_CMD: command failed with return code %d\n",
1046 priv->cur_cmd_retcode);
1047 priv->cur_cmd_retcode = 0;
1050 spin_unlock_irqrestore(&priv->driver_lock, flags);
1053 lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret);
1058 * @brief This function allocates the command buffer and link
1059 * it to command free queue.
1061 * @param priv A pointer to struct lbs_private structure
1064 int lbs_allocate_cmd_buffer(struct lbs_private *priv)
1069 struct cmd_ctrl_node *cmdarray;
1071 lbs_deb_enter(LBS_DEB_HOST);
1073 /* Allocate and initialize the command array */
1074 bufsize = sizeof(struct cmd_ctrl_node) * LBS_NUM_CMD_BUFFERS;
1075 if (!(cmdarray = kzalloc(bufsize, GFP_KERNEL))) {
1076 lbs_deb_host("ALLOC_CMD_BUF: tempcmd_array is NULL\n");
1080 priv->cmd_array = cmdarray;
1082 /* Allocate and initialize each command buffer in the command array */
1083 for (i = 0; i < LBS_NUM_CMD_BUFFERS; i++) {
1084 cmdarray[i].cmdbuf = kzalloc(LBS_CMD_BUFFER_SIZE, GFP_KERNEL);
1085 if (!cmdarray[i].cmdbuf) {
1086 lbs_deb_host("ALLOC_CMD_BUF: ptempvirtualaddr is NULL\n");
1092 for (i = 0; i < LBS_NUM_CMD_BUFFERS; i++) {
1093 init_waitqueue_head(&cmdarray[i].cmdwait_q);
1094 lbs_cleanup_and_insert_cmd(priv, &cmdarray[i]);
1099 lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret);
1104 * @brief This function frees the command buffer.
1106 * @param priv A pointer to struct lbs_private structure
1109 int lbs_free_cmd_buffer(struct lbs_private *priv)
1111 struct cmd_ctrl_node *cmdarray;
1114 lbs_deb_enter(LBS_DEB_HOST);
1116 /* need to check if cmd array is allocated or not */
1117 if (priv->cmd_array == NULL) {
1118 lbs_deb_host("FREE_CMD_BUF: cmd_array is NULL\n");
1122 cmdarray = priv->cmd_array;
1124 /* Release shared memory buffers */
1125 for (i = 0; i < LBS_NUM_CMD_BUFFERS; i++) {
1126 if (cmdarray[i].cmdbuf) {
1127 kfree(cmdarray[i].cmdbuf);
1128 cmdarray[i].cmdbuf = NULL;
1132 /* Release cmd_ctrl_node */
1133 if (priv->cmd_array) {
1134 kfree(priv->cmd_array);
1135 priv->cmd_array = NULL;
1139 lbs_deb_leave(LBS_DEB_HOST);
1144 * @brief This function gets a free command node if available in
1145 * command free queue.
1147 * @param priv A pointer to struct lbs_private structure
1148 * @return cmd_ctrl_node A pointer to cmd_ctrl_node structure or NULL
1150 static struct cmd_ctrl_node *lbs_get_cmd_ctrl_node(struct lbs_private *priv)
1152 struct cmd_ctrl_node *tempnode;
1153 unsigned long flags;
1155 lbs_deb_enter(LBS_DEB_HOST);
1160 spin_lock_irqsave(&priv->driver_lock, flags);
1162 if (!list_empty(&priv->cmdfreeq)) {
1163 tempnode = list_first_entry(&priv->cmdfreeq,
1164 struct cmd_ctrl_node, list);
1165 list_del(&tempnode->list);
1167 lbs_deb_host("GET_CMD_NODE: cmd_ctrl_node is not available\n");
1171 spin_unlock_irqrestore(&priv->driver_lock, flags);
1173 lbs_deb_leave(LBS_DEB_HOST);
1178 * @brief This function executes next command in command
1179 * pending queue. It will put firmware back to PS mode
1182 * @param priv A pointer to struct lbs_private structure
1185 int lbs_execute_next_command(struct lbs_private *priv)
1187 struct cmd_ctrl_node *cmdnode = NULL;
1188 struct cmd_header *cmd;
1189 unsigned long flags;
1192 /* Debug group is LBS_DEB_THREAD and not LBS_DEB_HOST, because the
1193 * only caller to us is lbs_thread() and we get even when a
1194 * data packet is received */
1195 lbs_deb_enter(LBS_DEB_THREAD);
1197 spin_lock_irqsave(&priv->driver_lock, flags);
1199 if (priv->cur_cmd) {
1200 lbs_pr_alert( "EXEC_NEXT_CMD: already processing command!\n");
1201 spin_unlock_irqrestore(&priv->driver_lock, flags);
1206 if (!list_empty(&priv->cmdpendingq)) {
1207 cmdnode = list_first_entry(&priv->cmdpendingq,
1208 struct cmd_ctrl_node, list);
1211 spin_unlock_irqrestore(&priv->driver_lock, flags);
1214 cmd = cmdnode->cmdbuf;
1216 if (is_command_allowed_in_ps(le16_to_cpu(cmd->command))) {
1217 if ((priv->psstate == PS_STATE_SLEEP) ||
1218 (priv->psstate == PS_STATE_PRE_SLEEP)) {
1220 "EXEC_NEXT_CMD: cannot send cmd 0x%04x in psstate %d\n",
1221 le16_to_cpu(cmd->command),
1226 lbs_deb_host("EXEC_NEXT_CMD: OK to send command "
1227 "0x%04x in psstate %d\n",
1228 le16_to_cpu(cmd->command), priv->psstate);
1229 } else if (priv->psstate != PS_STATE_FULL_POWER) {
1231 * 1. Non-PS command:
1232 * Queue it. set needtowakeup to TRUE if current state
1233 * is SLEEP, otherwise call lbs_ps_wakeup to send Exit_PS.
1234 * 2. PS command but not Exit_PS:
1236 * 3. PS command Exit_PS:
1237 * Set needtowakeup to TRUE if current state is SLEEP,
1238 * otherwise send this command down to firmware
1241 if (cmd->command != cpu_to_le16(CMD_802_11_PS_MODE)) {
1242 /* Prepare to send Exit PS,
1243 * this non PS command will be sent later */
1244 if ((priv->psstate == PS_STATE_SLEEP)
1245 || (priv->psstate == PS_STATE_PRE_SLEEP)
1247 /* w/ new scheme, it will not reach here.
1248 since it is blocked in main_thread. */
1249 priv->needtowakeup = 1;
1251 lbs_ps_wakeup(priv, 0);
1257 * PS command. Ignore it if it is not Exit_PS.
1258 * otherwise send it down immediately.
1260 struct cmd_ds_802_11_ps_mode *psm = (void *)&cmd[1];
1263 "EXEC_NEXT_CMD: PS cmd, action 0x%02x\n",
1266 cpu_to_le16(CMD_SUBCMD_EXIT_PS)) {
1268 "EXEC_NEXT_CMD: ignore ENTER_PS cmd\n");
1269 list_del(&cmdnode->list);
1270 spin_lock_irqsave(&priv->driver_lock, flags);
1271 lbs_complete_command(priv, cmdnode, 0);
1272 spin_unlock_irqrestore(&priv->driver_lock, flags);
1278 if ((priv->psstate == PS_STATE_SLEEP) ||
1279 (priv->psstate == PS_STATE_PRE_SLEEP)) {
1281 "EXEC_NEXT_CMD: ignore EXIT_PS cmd in sleep\n");
1282 list_del(&cmdnode->list);
1283 spin_lock_irqsave(&priv->driver_lock, flags);
1284 lbs_complete_command(priv, cmdnode, 0);
1285 spin_unlock_irqrestore(&priv->driver_lock, flags);
1286 priv->needtowakeup = 1;
1293 "EXEC_NEXT_CMD: sending EXIT_PS\n");
1296 list_del(&cmdnode->list);
1297 lbs_deb_host("EXEC_NEXT_CMD: sending command 0x%04x\n",
1298 le16_to_cpu(cmd->command));
1299 lbs_submit_command(priv, cmdnode);
1302 * check if in power save mode, if yes, put the device back
1305 if ((priv->psmode != LBS802_11POWERMODECAM) &&
1306 (priv->psstate == PS_STATE_FULL_POWER) &&
1307 ((priv->connect_status == LBS_CONNECTED) ||
1308 lbs_mesh_connected(priv))) {
1309 if (priv->secinfo.WPAenabled ||
1310 priv->secinfo.WPA2enabled) {
1311 /* check for valid WPA group keys */
1312 if (priv->wpa_mcast_key.len ||
1313 priv->wpa_unicast_key.len) {
1315 "EXEC_NEXT_CMD: WPA enabled and GTK_SET"
1316 " go back to PS_SLEEP");
1317 lbs_ps_sleep(priv, 0);
1321 "EXEC_NEXT_CMD: cmdpendingq empty, "
1322 "go back to PS_SLEEP");
1323 lbs_ps_sleep(priv, 0);
1330 lbs_deb_leave(LBS_DEB_THREAD);
1334 static void lbs_send_confirmsleep(struct lbs_private *priv)
1336 unsigned long flags;
1339 lbs_deb_enter(LBS_DEB_HOST);
1340 lbs_deb_hex(LBS_DEB_HOST, "sleep confirm", (u8 *) &confirm_sleep,
1341 sizeof(confirm_sleep));
1343 ret = priv->hw_host_to_card(priv, MVMS_CMD, (u8 *) &confirm_sleep,
1344 sizeof(confirm_sleep));
1346 lbs_pr_alert("confirm_sleep failed\n");
1350 spin_lock_irqsave(&priv->driver_lock, flags);
1352 /* We don't get a response on the sleep-confirmation */
1353 priv->dnld_sent = DNLD_RES_RECEIVED;
1355 /* If nothing to do, go back to sleep (?) */
1356 if (!kfifo_len(&priv->event_fifo) && !priv->resp_len[priv->resp_idx])
1357 priv->psstate = PS_STATE_SLEEP;
1359 spin_unlock_irqrestore(&priv->driver_lock, flags);
1362 lbs_deb_leave(LBS_DEB_HOST);
1365 void lbs_ps_sleep(struct lbs_private *priv, int wait_option)
1367 lbs_deb_enter(LBS_DEB_HOST);
1370 * PS is currently supported only in Infrastructure mode
1371 * Remove this check if it is to be supported in IBSS mode also
1374 lbs_prepare_and_send_command(priv, CMD_802_11_PS_MODE,
1375 CMD_SUBCMD_ENTER_PS, wait_option, 0, NULL);
1377 lbs_deb_leave(LBS_DEB_HOST);
1381 * @brief This function sends Exit_PS command to firmware.
1383 * @param priv A pointer to struct lbs_private structure
1384 * @param wait_option wait response or not
1387 void lbs_ps_wakeup(struct lbs_private *priv, int wait_option)
1391 lbs_deb_enter(LBS_DEB_HOST);
1393 Localpsmode = cpu_to_le32(LBS802_11POWERMODECAM);
1395 lbs_prepare_and_send_command(priv, CMD_802_11_PS_MODE,
1397 wait_option, 0, &Localpsmode);
1399 lbs_deb_leave(LBS_DEB_HOST);
1403 * @brief This function checks condition and prepares to
1404 * send sleep confirm command to firmware if ok.
1406 * @param priv A pointer to struct lbs_private structure
1407 * @param psmode Power Saving mode
1410 void lbs_ps_confirm_sleep(struct lbs_private *priv)
1412 unsigned long flags =0;
1415 lbs_deb_enter(LBS_DEB_HOST);
1417 spin_lock_irqsave(&priv->driver_lock, flags);
1418 if (priv->dnld_sent) {
1420 lbs_deb_host("dnld_sent was set\n");
1423 /* In-progress command? */
1424 if (priv->cur_cmd) {
1426 lbs_deb_host("cur_cmd was set\n");
1429 /* Pending events or command responses? */
1430 if (kfifo_len(&priv->event_fifo) || priv->resp_len[priv->resp_idx]) {
1432 lbs_deb_host("pending events or command responses\n");
1434 spin_unlock_irqrestore(&priv->driver_lock, flags);
1437 lbs_deb_host("sending lbs_ps_confirm_sleep\n");
1438 lbs_send_confirmsleep(priv);
1440 lbs_deb_host("sleep confirm has been delayed\n");
1443 lbs_deb_leave(LBS_DEB_HOST);
1448 * @brief Configures the transmission power control functionality.
1450 * @param priv A pointer to struct lbs_private structure
1451 * @param enable Transmission power control enable
1452 * @param p0 Power level when link quality is good (dBm).
1453 * @param p1 Power level when link quality is fair (dBm).
1454 * @param p2 Power level when link quality is poor (dBm).
1455 * @param usesnr Use Signal to Noise Ratio in TPC
1457 * @return 0 on success
1459 int lbs_set_tpc_cfg(struct lbs_private *priv, int enable, int8_t p0, int8_t p1,
1460 int8_t p2, int usesnr)
1462 struct cmd_ds_802_11_tpc_cfg cmd;
1465 memset(&cmd, 0, sizeof(cmd));
1466 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
1467 cmd.action = cpu_to_le16(CMD_ACT_SET);
1468 cmd.enable = !!enable;
1469 cmd.usesnr = !!usesnr;
1474 ret = lbs_cmd_with_response(priv, CMD_802_11_TPC_CFG, &cmd);
1480 * @brief Configures the power adaptation settings.
1482 * @param priv A pointer to struct lbs_private structure
1483 * @param enable Power adaptation enable
1484 * @param p0 Power level for 1, 2, 5.5 and 11 Mbps (dBm).
1485 * @param p1 Power level for 6, 9, 12, 18, 22, 24 and 36 Mbps (dBm).
1486 * @param p2 Power level for 48 and 54 Mbps (dBm).
1488 * @return 0 on Success
1491 int lbs_set_power_adapt_cfg(struct lbs_private *priv, int enable, int8_t p0,
1492 int8_t p1, int8_t p2)
1494 struct cmd_ds_802_11_pa_cfg cmd;
1497 memset(&cmd, 0, sizeof(cmd));
1498 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
1499 cmd.action = cpu_to_le16(CMD_ACT_SET);
1500 cmd.enable = !!enable;
1505 ret = lbs_cmd_with_response(priv, CMD_802_11_PA_CFG , &cmd);
1511 struct cmd_ctrl_node *__lbs_cmd_async(struct lbs_private *priv,
1512 uint16_t command, struct cmd_header *in_cmd, int in_cmd_size,
1513 int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *),
1514 unsigned long callback_arg)
1516 struct cmd_ctrl_node *cmdnode;
1518 lbs_deb_enter(LBS_DEB_HOST);
1520 if (priv->surpriseremoved) {
1521 lbs_deb_host("PREP_CMD: card removed\n");
1522 cmdnode = ERR_PTR(-ENOENT);
1526 if (!lbs_is_cmd_allowed(priv)) {
1527 cmdnode = ERR_PTR(-EBUSY);
1531 cmdnode = lbs_get_cmd_ctrl_node(priv);
1532 if (cmdnode == NULL) {
1533 lbs_deb_host("PREP_CMD: cmdnode is NULL\n");
1535 /* Wake up main thread to execute next command */
1536 wake_up_interruptible(&priv->waitq);
1537 cmdnode = ERR_PTR(-ENOBUFS);
1541 cmdnode->callback = callback;
1542 cmdnode->callback_arg = callback_arg;
1544 /* Copy the incoming command to the buffer */
1545 memcpy(cmdnode->cmdbuf, in_cmd, in_cmd_size);
1547 /* Set sequence number, clean result, move to buffer */
1549 cmdnode->cmdbuf->command = cpu_to_le16(command);
1550 cmdnode->cmdbuf->size = cpu_to_le16(in_cmd_size);
1551 cmdnode->cmdbuf->seqnum = cpu_to_le16(priv->seqnum);
1552 cmdnode->cmdbuf->result = 0;
1554 lbs_deb_host("PREP_CMD: command 0x%04x\n", command);
1556 cmdnode->cmdwaitqwoken = 0;
1557 lbs_queue_cmd(priv, cmdnode);
1558 wake_up_interruptible(&priv->waitq);
1561 lbs_deb_leave_args(LBS_DEB_HOST, "ret %p", cmdnode);
1565 void lbs_cmd_async(struct lbs_private *priv, uint16_t command,
1566 struct cmd_header *in_cmd, int in_cmd_size)
1568 lbs_deb_enter(LBS_DEB_CMD);
1569 __lbs_cmd_async(priv, command, in_cmd, in_cmd_size,
1570 lbs_cmd_async_callback, 0);
1571 lbs_deb_leave(LBS_DEB_CMD);
1574 int __lbs_cmd(struct lbs_private *priv, uint16_t command,
1575 struct cmd_header *in_cmd, int in_cmd_size,
1576 int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *),
1577 unsigned long callback_arg)
1579 struct cmd_ctrl_node *cmdnode;
1580 unsigned long flags;
1583 lbs_deb_enter(LBS_DEB_HOST);
1585 cmdnode = __lbs_cmd_async(priv, command, in_cmd, in_cmd_size,
1586 callback, callback_arg);
1587 if (IS_ERR(cmdnode)) {
1588 ret = PTR_ERR(cmdnode);
1593 wait_event_interruptible(cmdnode->cmdwait_q, cmdnode->cmdwaitqwoken);
1595 spin_lock_irqsave(&priv->driver_lock, flags);
1596 ret = cmdnode->result;
1598 lbs_pr_info("PREP_CMD: command 0x%04x failed: %d\n",
1601 __lbs_cleanup_and_insert_cmd(priv, cmdnode);
1602 spin_unlock_irqrestore(&priv->driver_lock, flags);
1605 lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret);
1608 EXPORT_SYMBOL_GPL(__lbs_cmd);