Skip to content

Commit

Permalink
iwlwifi: virtualize the op_mode
Browse files Browse the repository at this point in the history
Define the op_mode as an interface with its ops. All the functions
of the op_mode are "private", but its ops is made public in
iwl-op-mode.h.
The drv object starts the op_mode by using the start function in the
public ops.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
  • Loading branch information
Emmanuel Grumbach authored and Wey-Yi Guy committed Feb 27, 2012
1 parent 6459f98 commit d0f76d6
Show file tree
Hide file tree
Showing 12 changed files with 204 additions and 65 deletions.
2 changes: 1 addition & 1 deletion drivers/net/wireless/iwlwifi/iwl-agn-lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ static void iwlagn_wowlan_program_keys(struct ieee80211_hw *hw,
struct ieee80211_key_conf *key,
void *_data)
{
struct iwl_priv *priv = hw->priv;
struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
struct wowlan_key_data *data = _data;
struct iwl_rxon_context *ctx = data->ctx;
struct aes_sc *aes_sc, *aes_tx_sc = NULL;
Expand Down
16 changes: 11 additions & 5 deletions drivers/net/wireless/iwlwifi/iwl-agn-rs.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "iwl-dev.h"
#include "iwl-core.h"
#include "iwl-agn.h"
#include "iwl-op-mode.h"

#define RS_NAME "iwl-agn-rs"

Expand Down Expand Up @@ -909,7 +910,8 @@ static void rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband,
struct iwl_lq_sta *lq_sta = priv_sta;
struct iwl_link_quality_cmd *table;
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
struct iwl_priv *priv = (struct iwl_priv *)priv_r;
struct iwl_op_mode *op_mode = (struct iwl_op_mode *)priv_r;
struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode);
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
enum mac80211_rate_control_flags mac_flags;
u32 tx_rate;
Expand Down Expand Up @@ -2737,7 +2739,9 @@ static void rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta,

struct sk_buff *skb = txrc->skb;
struct ieee80211_supported_band *sband = txrc->sband;
struct iwl_priv *priv __maybe_unused = (struct iwl_priv *)priv_r;
struct iwl_op_mode *op_mode __maybe_unused =
(struct iwl_op_mode *)priv_r;
struct iwl_priv *priv __maybe_unused = IWL_OP_MODE_GET_DVM(op_mode);
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
struct iwl_lq_sta *lq_sta = priv_sta;
int rate_idx;
Expand Down Expand Up @@ -2805,9 +2809,10 @@ static void *rs_alloc_sta(void *priv_rate, struct ieee80211_sta *sta,
gfp_t gfp)
{
struct iwl_station_priv *sta_priv = (struct iwl_station_priv *) sta->drv_priv;
struct iwl_priv *priv;
struct iwl_op_mode *op_mode __maybe_unused =
(struct iwl_op_mode *)priv_rate;
struct iwl_priv *priv __maybe_unused = IWL_OP_MODE_GET_DVM(op_mode);

priv = (struct iwl_priv *)priv_rate;
IWL_DEBUG_RATE(priv, "create station rate scale window\n");

return &sta_priv->lq_sta;
Expand Down Expand Up @@ -3074,7 +3079,8 @@ static void rs_free(void *priv_rate)
static void rs_free_sta(void *priv_r, struct ieee80211_sta *sta,
void *priv_sta)
{
struct iwl_priv *priv __maybe_unused = priv_r;
struct iwl_op_mode *op_mode __maybe_unused = priv_r;
struct iwl_priv *priv __maybe_unused = IWL_OP_MODE_GET_DVM(op_mode);

IWL_DEBUG_RATE(priv, "enter\n");
IWL_DEBUG_RATE(priv, "leave\n");
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wireless/iwlwifi/iwl-agn-rxon.c
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ void iwlagn_config_ht40(struct ieee80211_conf *conf,

int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed)
{
struct iwl_priv *priv = hw->priv;
struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
struct iwl_rxon_context *ctx;
struct ieee80211_conf *conf = &hw->conf;
struct ieee80211_channel *channel = conf->channel;
Expand Down Expand Up @@ -805,7 +805,7 @@ void iwlagn_bss_info_changed(struct ieee80211_hw *hw,
struct ieee80211_bss_conf *bss_conf,
u32 changes)
{
struct iwl_priv *priv = hw->priv;
struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif);
int ret;
bool force = false;
Expand Down
32 changes: 21 additions & 11 deletions drivers/net/wireless/iwlwifi/iwl-agn.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#include "iwl-shared.h"
#include "iwl-bus.h"
#include "iwl-trans.h"
#include "iwl-op-mode.h"

/******************************************************************************
*
Expand Down Expand Up @@ -1142,14 +1143,13 @@ static void iwl_debug_config(struct iwl_priv *priv)
#endif
}

int iwl_op_mode_dvm_start(struct iwl_bus *bus,
const struct iwl_trans_ops *trans_ops,
struct iwl_cfg *cfg)
static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans)
{
struct iwl_fw *fw = &nic(bus)->fw;
struct iwl_fw *fw = &nic(trans)->fw;
int err = 0;
struct iwl_priv *priv;
struct ieee80211_hw *hw;
struct iwl_op_mode *op_mode;
u16 num_mac;
u32 ucode_flags;

Expand All @@ -1158,18 +1158,21 @@ int iwl_op_mode_dvm_start(struct iwl_bus *bus,
************************/
hw = iwl_alloc_all();
if (!hw) {
pr_err("%s: Cannot allocate network device\n", cfg->name);
pr_err("%s: Cannot allocate network device\n",
cfg(trans)->name);
err = -ENOMEM;
goto out;
}

priv = hw->priv;
priv->shrd = bus->shrd;
op_mode = hw->priv;
op_mode->ops = &iwl_dvm_ops;
priv = IWL_OP_MODE_GET_DVM(op_mode);
priv->shrd = trans->shrd;
priv->shrd->priv = priv;

/* At this point both hw and priv are allocated. */

SET_IEEE80211_DEV(hw, trans(priv)->dev);
SET_IEEE80211_DEV(priv->hw, trans(priv)->dev);

/* show what debugging capabilities we have */
iwl_debug_config(priv);
Expand Down Expand Up @@ -1316,7 +1319,7 @@ int iwl_op_mode_dvm_start(struct iwl_bus *bus,
"failed to create debugfs files. Ignoring error: %d\n",
err);

return 0;
return op_mode;

out_destroy_workqueue:
destroy_workqueue(priv->workqueue);
Expand All @@ -1328,11 +1331,14 @@ int iwl_op_mode_dvm_start(struct iwl_bus *bus,
iwl_free_traffic_mem(priv);
ieee80211_free_hw(priv->hw);
out:
return err;
op_mode = NULL;
return op_mode;
}

void iwl_op_mode_dvm_stop(struct iwl_priv *priv)
static void iwl_op_mode_dvm_stop(struct iwl_op_mode *op_mode)
{
struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode);

wait_for_completion(&nic(priv)->request_firmware_complete);

IWL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n");
Expand Down Expand Up @@ -1374,6 +1380,10 @@ void iwl_op_mode_dvm_stop(struct iwl_priv *priv)
ieee80211_free_hw(priv->hw);
}

const struct iwl_op_mode_ops iwl_dvm_ops = {
.start = iwl_op_mode_dvm_start,
.stop = iwl_op_mode_dvm_stop,
};

/*****************************************************************************
*
Expand Down
8 changes: 8 additions & 0 deletions drivers/net/wireless/iwlwifi/iwl-dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include "iwl-bus.h"
#include "iwl-trans.h"
#include "iwl-shared.h"
#include "iwl-op-mode.h"

struct iwl_tx_queue;

Expand Down Expand Up @@ -710,6 +711,13 @@ struct iwl_wipan_noa_data {
u8 data[];
};

#define IWL_OP_MODE_GET_DVM(_iwl_op_mode) \
((struct iwl_priv *) ((_iwl_op_mode)->op_mode_specific))

#define IWL_MAC80211_GET_DVM(_hw) \
((struct iwl_priv *) ((struct iwl_op_mode *) \
(_hw)->priv)->op_mode_specific)

struct iwl_priv {

/*data shared among all the driver's layers */
Expand Down
6 changes: 4 additions & 2 deletions drivers/net/wireless/iwlwifi/iwl-drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
#include "iwl-drv.h"
#include "iwl-trans.h"
#include "iwl-wifi.h"
#include "iwl-op-mode.h"

int iwl_drv_start(struct iwl_shared *shrd,
struct iwl_trans *trans, struct iwl_cfg *cfg)
Expand Down Expand Up @@ -94,8 +95,9 @@ int iwl_drv_start(struct iwl_shared *shrd,

void iwl_drv_stop(struct iwl_shared *shrd)
{
iwl_op_mode_dvm_stop(shrd->priv);
/* op_mode can be NULL if its start failed */
if (shrd->nic->op_mode)
iwl_op_mode_stop(shrd->nic->op_mode);

kfree(shrd->nic);
}

Loading

0 comments on commit d0f76d6

Please sign in to comment.