/*
* Marvell Wireless LAN device driver: major functions
*
* Copyright (C) 2011, Marvell International Ltd.
*
* This software file (the "File") is distributed by Marvell International
* Ltd. under the terms of the GNU General Public License Version 2, June 1991
* (the "License"). You may use, redistribute and/or modify this File in
* accordance with the terms and conditions of the License, a copy of which
* is available by writing to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
* worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
* ARE EXPRESSLY DISCLAIMED. The License provides additional details about
* this warranty disclaimer.
*/
#include "main.h"
#include "wmm.h"
#include "cfg80211.h"
#include "11n.h"
#define VERSION "1.0"
const char driver_version[] = "mwifiex " VERSION " (%s) ";
static struct mwifiex_bss_attr mwifiex_bss_sta[] = {
{MWIFIEX_BSS_TYPE_STA, MWIFIEX_DATA_FRAME_TYPE_ETH_II, true, 0, 0},
};
static int drv_mode = DRV_MODE_STA;
/* Supported drv_mode table */
static struct mwifiex_drv_mode mwifiex_drv_mode_tbl[] = {
{
.drv_mode = DRV_MODE_STA,
.intf_num = ARRAY_SIZE(mwifiex_bss_sta),
.bss_attr = mwifiex_bss_sta,
},
};
/*
* This function registers the device and performs all the necessary
* initializations.
*
* The following initialization operations are performed -
* - Allocate adapter structure
* - Save interface specific operations table in adapter
* - Call interface specific initialization routine
* - Allocate private structures
* - Set default adapter structure parameters
* - Initialize locks
*
* In case of any errors during inittialization, this function also ensures
* proper cleanup before exiting.
*/
static int mwifiex_register(void *card, struct mwifiex_if_ops *if_ops,
struct mwifiex_drv_mode *drv_mode_ptr,
void **padapter)
{
struct mwifiex_adapter *adapter;
int i;
adapter = kzalloc(sizeof(struct mwifiex_adapter), GFP_KERNEL);
if (!adapter)
return -ENOMEM;
*padapter = adapter;
adapter->card = card;
/* Save interface specific operations in adapter */
memmove(&adapter->if_ops, if_ops, sizeof(struct mwifiex_if_ops));
/* card specific initialization has been deferred until now .. */
if (adapter->if_ops.init_if(adapter))
goto error;
adapter->priv_num = 0;
for (i = 0; i < drv_mode_ptr->intf_num; i++) {
adapter->priv[i] = NULL;
if (!drv_mode_ptr->bss_attr[i].active)
continue;
/* Allocate memory for private structure */
adapter->priv[i] = kzalloc(sizeof(struct mwifiex_private),
GFP_KERNEL);
if (!adapter->priv[i]) {
dev_err(adapter->dev, "%s: failed to alloc priv[%d]\n",
__func__, i);
goto error;
}
adapter->priv_num++;
adapter->priv[i]->adapter = adapter;
/* Save bss_type, frame_type & bss_priority */
adapter->priv[i]->bss_type = drv_mode_ptr->bss_attr[i].bss_type;
adapter->priv[i]->frame_type =
drv_mode_ptr->bss_attr[i].frame_type;
adapter->priv[i]->bss_priority =
drv_mode_ptr->bss_attr[i].bss_priority;
if (drv_mode_ptr->bss_attr[i].bss_type == MWIFIEX_BSS_TYPE_STA)
adapter->priv[i]->bss_role = MWIFIEX_BSS_ROLE_STA;
else if (drv_mode_ptr->bss_attr[i].bss_type ==
MWIFIEX_BSS_TYPE_UAP)
adapter->priv[i]->bss_role = MWIFIEX_BSS_ROLE_UAP;
/* Save bss_index & bss_num */
adapter->priv[i]->bss_index = i;
adapter->priv[i]->bss_num = drv_mode_ptr->bss_attr[i].bss_num;
}
adapter->drv_mode = drv_mode_ptr;
if (mwifiex_init_lock_list(adapter))
goto error;
init_timer(&adapter->cmd_timer);
adapter->cmd_timer.function = mwifiex_cmd_timeout_func;
adapter->cmd_timer.data = (unsigned long) adapter;
return 0;
error:
dev_dbg(adapter->dev, "info: leave mwifiex_register with error\n");
mwifiex_free_lock_list(adapter);
for (i = 0; i < drv_mode_ptr->intf_num; i++)
kfree(adapter->priv[i]);
kfree(adapter);
return -1;
}
/*
* This function unregisters the device and performs all the necessary
* cleanups.
*
* The following cleanup operations are performed -
* - Free the timers
* - Free beacon buffers
* - Free private structures
* - Free adapter structure
*/