int mwifiex_set_bss_role(struct mwifiex_private *priv, u8 bss_role) { if (GET_BSS_ROLE(priv) == bss_role) { dev_dbg(priv->adapter->dev, "info: already in the desired role.\n"); return 0; } mwifiex_free_priv(priv); mwifiex_init_priv(priv); priv->bss_role = bss_role; switch (bss_role) { case MWIFIEX_BSS_ROLE_UAP: priv->bss_mode = NL80211_IFTYPE_AP; break; case MWIFIEX_BSS_ROLE_STA: case MWIFIEX_BSS_ROLE_ANY: default: priv->bss_mode = NL80211_IFTYPE_STATION; break; } mwifiex_send_cmd(priv, HostCmd_CMD_SET_BSS_MODE, HostCmd_ACT_GEN_SET, 0, NULL, true); return mwifiex_sta_init_cmd(priv, false); }
/* * This function initializes the firmware. * * The following operations are performed sequentially - * - Allocate adapter structure * - Initialize the adapter structure * - Initialize the private structure * - Add BSS priority tables to the adapter structure * - For each interface, send the init commands to firmware * - Send the first command in command pending queue, if available */ int mwifiex_init_fw(struct mwifiex_adapter *adapter) { int ret; struct mwifiex_private *priv; u8 i, first_sta = true; int is_cmd_pend_q_empty; unsigned long flags; adapter->hw_status = MWIFIEX_HW_STATUS_INITIALIZING; /* Allocate memory for member of adapter structure */ ret = mwifiex_allocate_adapter(adapter); if (ret) return -1; /* Initialize adapter structure */ mwifiex_init_adapter(adapter); for (i = 0; i < adapter->priv_num; i++) { if (adapter->priv[i]) { priv = adapter->priv[i]; /* Initialize private structure */ ret = mwifiex_init_priv(priv); if (ret) return -1; } } if (adapter->if_ops.init_fw_port) { if (adapter->if_ops.init_fw_port(adapter)) return -1; } for (i = 0; i < adapter->priv_num; i++) { if (adapter->priv[i]) { ret = mwifiex_sta_init_cmd(adapter->priv[i], first_sta); if (ret == -1) return -1; first_sta = false; } } spin_lock_irqsave(&adapter->cmd_pending_q_lock, flags); is_cmd_pend_q_empty = list_empty(&adapter->cmd_pending_q); spin_unlock_irqrestore(&adapter->cmd_pending_q_lock, flags); if (!is_cmd_pend_q_empty) { /* Send the first command in queue and return */ if (mwifiex_main_process(adapter) != -1) ret = -EINPROGRESS; } else { adapter->hw_status = MWIFIEX_HW_STATUS_READY; } return ret; }