/* * This function adds a BSS priority table to the table list. * * The function allocates a new BSS priority table node and adds it to * the end of BSS priority table list, kept in driver memory.
*/ staticint mwifiex_add_bss_prio_tbl(struct mwifiex_private *priv)
{ struct mwifiex_adapter *adapter = priv->adapter; struct mwifiex_bss_prio_node *bss_prio; struct mwifiex_bss_prio_tbl *tbl = adapter->bss_prio_tbl;
bss_prio = kzalloc(sizeof(struct mwifiex_bss_prio_node), GFP_KERNEL); if (!bss_prio) return -ENOMEM;
/* * This function initializes the private structure and sets default * values to the members. * * Additionally, it also initializes all the locks and sets up all the * lists.
*/ int mwifiex_init_priv(struct mwifiex_private *priv)
{
u32 i;
/* * This function allocates buffers for members of the adapter * structure. * * The memory allocated includes scan table, command buffers, and * sleep confirm command buffer. In addition, the queues are * also initialized.
*/ staticint mwifiex_allocate_adapter(struct mwifiex_adapter *adapter)
{ int ret;
/* Allocate command buffer */
ret = mwifiex_alloc_cmd_buffer(adapter); if (ret) {
mwifiex_dbg(adapter, ERROR, "%s: failed to alloc cmd buffer\n",
__func__); return -1;
}
if (!adapter->sleep_cfm) {
mwifiex_dbg(adapter, ERROR, "%s: failed to alloc sleep cfm\t" " cmd buffer\n", __func__); return -1;
}
skb_reserve(adapter->sleep_cfm, INTF_HEADER_LEN);
return 0;
}
/* * This function initializes the adapter structure and sets default * values to the members of adapter. * * This also initializes the WMM related parameters in the driver private * structures.
*/ staticvoid mwifiex_init_adapter(struct mwifiex_adapter *adapter)
{ struct mwifiex_opt_sleep_confirm *sleep_cfm_buf = NULL;
/* * This function sets trans_start per tx_queue
*/ void mwifiex_set_trans_start(struct net_device *dev)
{ int i;
for (i = 0; i < dev->num_tx_queues; i++)
txq_trans_cond_update(netdev_get_tx_queue(dev, i));
netif_trans_update(dev);
}
/* * This function wakes up all queues in net_device
*/ void mwifiex_wake_up_net_dev_queue(struct net_device *netdev, struct mwifiex_adapter *adapter)
{
spin_lock_bh(&adapter->queue_lock);
netif_tx_wake_all_queues(netdev);
spin_unlock_bh(&adapter->queue_lock);
}
/* * This function stops all queues in net_device
*/ void mwifiex_stop_net_dev_queue(struct net_device *netdev, struct mwifiex_adapter *adapter)
{
spin_lock_bh(&adapter->queue_lock);
netif_tx_stop_all_queues(netdev);
spin_unlock_bh(&adapter->queue_lock);
}
/* * This function invalidates the list heads.
*/ staticvoid mwifiex_invalidate_lists(struct mwifiex_adapter *adapter)
{ struct mwifiex_private *priv;
s32 i, j;
for (i = 0; i < adapter->priv_num; i++)
list_del(&adapter->bss_prio_tbl[i].bss_prio_head);
for (i = 0; i < adapter->priv_num; i++) {
priv = adapter->priv[i]; for (j = 0; j < MAX_NUM_TID; ++j)
list_del(&priv->wmm.tid_tbl_ptr[j].ra_list);
list_del(&priv->tx_ba_stream_tbl_ptr);
list_del(&priv->rx_reorder_tbl_ptr);
list_del(&priv->sta_list);
list_del(&priv->auto_tdls_list);
}
}
/* * This function performs cleanup for adapter structure. * * The cleanup is done recursively, by canceling all pending * commands, freeing the member buffers previously allocated * (command buffers, scan table buffer, sleep confirm command * buffer), stopping the timers and calling the cleanup routines * for every interface.
*/ staticvoid
mwifiex_adapter_cleanup(struct mwifiex_adapter *adapter)
{
timer_delete(&adapter->wakeup_timer);
cancel_delayed_work_sync(&adapter->devdump_work);
mwifiex_cancel_all_pending_cmd(adapter);
wake_up_interruptible(&adapter->cmd_wait_q.wait);
wake_up_interruptible(&adapter->hs_activate_wait_q);
}
if (adapter->sleep_cfm)
dev_kfree_skb_any(adapter->sleep_cfm);
}
/* * This function intializes the lock variables and * the list heads.
*/ int mwifiex_init_lock_list(struct mwifiex_adapter *adapter)
{ struct mwifiex_private *priv;
s32 i, j;
spin_lock_init(&adapter->int_lock);
spin_lock_init(&adapter->main_proc_lock);
spin_lock_init(&adapter->mwifiex_cmd_lock);
spin_lock_init(&adapter->queue_lock); for (i = 0; i < adapter->priv_num; i++) {
priv = adapter->priv[i];
spin_lock_init(&priv->wmm.ra_list_spinlock);
spin_lock_init(&priv->curr_bcn_buf_lock);
spin_lock_init(&priv->sta_list_spinlock);
spin_lock_init(&priv->auto_tdls_lock);
}
for (i = 0; i < adapter->priv_num; ++i) {
INIT_LIST_HEAD(&adapter->bss_prio_tbl[i].bss_prio_head);
spin_lock_init(&adapter->bss_prio_tbl[i].bss_prio_lock);
}
for (i = 0; i < adapter->priv_num; i++) {
priv = adapter->priv[i]; for (j = 0; j < MAX_NUM_TID; ++j)
INIT_LIST_HEAD(&priv->wmm.tid_tbl_ptr[j].ra_list);
INIT_LIST_HEAD(&priv->tx_ba_stream_tbl_ptr);
INIT_LIST_HEAD(&priv->rx_reorder_tbl_ptr);
INIT_LIST_HEAD(&priv->sta_list);
INIT_LIST_HEAD(&priv->auto_tdls_list);
skb_queue_head_init(&priv->tdls_txq);
skb_queue_head_init(&priv->bypass_txq);
/* * 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
*/ int mwifiex_init_fw(struct mwifiex_adapter *adapter)
{ int ret; struct mwifiex_private *priv;
u8 i, first_sta = true;
if (adapter->if_ops.init_fw_port)
adapter->if_ops.init_fw_port(adapter);
return 0;
}
/* * This function deletes the BSS priority tables. * * The function traverses through all the allocated BSS priority nodes * in every BSS priority table and frees them.
*/ staticvoid mwifiex_delete_bss_prio_tbl(struct mwifiex_private *priv)
{ int i; struct mwifiex_adapter *adapter = priv->adapter; struct mwifiex_bss_prio_node *bssprio_node, *tmp_node; struct list_head *head;
spinlock_t *lock; /* bss priority lock */
for (i = 0; i < adapter->priv_num; ++i) {
head = &adapter->bss_prio_tbl[i].bss_prio_head;
lock = &adapter->bss_prio_tbl[i].bss_prio_lock;
mwifiex_dbg(adapter, INFO, "info: delete BSS priority table,\t" "bss_type = %d, bss_num = %d, i = %d,\t" "head = %p\n",
priv->bss_type, priv->bss_num, i, head);
/* * This function frees the private structure, including cleans * up the TX and RX queues and frees the BSS priority tables.
*/ void mwifiex_free_priv(struct mwifiex_private *priv)
{
mwifiex_clean_txrx(priv);
mwifiex_delete_bss_prio_tbl(priv);
mwifiex_free_curr_bcn(priv);
}
/* * This function is used to shutdown the driver. * * The following operations are performed sequentially - * - Check if already shut down * - Make sure the main process has stopped * - Clean up the Tx and Rx queues * - Delete BSS priority tables * - Free the adapter * - Notify completion
*/ void
mwifiex_shutdown_drv(struct mwifiex_adapter *adapter)
{ struct mwifiex_private *priv;
s32 i; struct sk_buff *skb;
/* mwifiex already shutdown */ if (adapter->hw_status == MWIFIEX_HW_STATUS_NOT_READY) return;
/* cancel current command */ if (adapter->curr_cmd) {
mwifiex_dbg(adapter, WARN, "curr_cmd is still in processing\n");
timer_delete_sync(&adapter->cmd_timer);
mwifiex_recycle_cmd_node(adapter, adapter->curr_cmd);
adapter->curr_cmd = NULL;
}
/* shut down mwifiex */
mwifiex_dbg(adapter, MSG, "info: shutdown mwifiex...\n");
/* Clean up Tx/Rx queues and delete BSS priority table */ for (i = 0; i < adapter->priv_num; i++) {
priv = adapter->priv[i];
/* * This function downloads the firmware to the card. * * The actual download is preceded by two sanity checks - * - Check if firmware is already running * - Check if the interface is the winner to download the firmware * * ...and followed by another - * - Check if the firmware is downloaded successfully * * After download is successfully completed, the host interrupts are enabled.
*/ int mwifiex_dnld_fw(struct mwifiex_adapter *adapter, struct mwifiex_fw_image *pmfw)
{ int ret;
u32 poll_num = 1;
/* check if firmware is already running */
ret = adapter->if_ops.check_fw_status(adapter, poll_num); if (!ret) {
mwifiex_dbg(adapter, MSG, "WLAN FW already running! Skip FW dnld\n"); return 0;
}
/* check if we are the winner for downloading FW */ if (adapter->if_ops.check_winner_status) {
adapter->winner = 0;
ret = adapter->if_ops.check_winner_status(adapter);
poll_num = MAX_FIRMWARE_POLL_TRIES; if (ret) {
mwifiex_dbg(adapter, MSG, "WLAN read winner status failed!\n"); return ret;
}
if (!adapter->winner) {
mwifiex_dbg(adapter, MSG, "WLAN is not the winner! Skip FW dnld\n"); goto poll_fw;
}
}
if (pmfw) { /* Download firmware with helper */
ret = adapter->if_ops.prog_fw(adapter, pmfw); if (ret) {
mwifiex_dbg(adapter, ERROR, "prog_fw failed ret=%#x\n", ret); return ret;
}
}
poll_fw: /* Check if the firmware is downloaded successfully or not */
ret = adapter->if_ops.check_fw_status(adapter, poll_num); if (ret)
mwifiex_dbg(adapter, ERROR, "FW failed to be active in time\n");
return ret;
}
EXPORT_SYMBOL_GPL(mwifiex_dnld_fw);
Messung V0.5
¤ Dauer der Verarbeitung: 0.1 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.