Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d0f76d68 authored by Emmanuel Grumbach's avatar Emmanuel Grumbach Committed by Wey-Yi Guy
Browse files

iwlwifi: virtualize the op_mode



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: default avatarEmmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: default avatarWey-Yi Guy <wey-yi.w.guy@intel.com>
parent 6459f987
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -959,7 +959,7 @@ static void iwlagn_wowlan_program_keys(struct ieee80211_hw *hw,
			       struct ieee80211_key_conf *key,
			       struct ieee80211_key_conf *key,
			       void *_data)
			       void *_data)
{
{
	struct iwl_priv *priv = hw->priv;
	struct iwl_priv *priv = IWL_MAC80211_GET_DVM(hw);
	struct wowlan_key_data *data = _data;
	struct wowlan_key_data *data = _data;
	struct iwl_rxon_context *ctx = data->ctx;
	struct iwl_rxon_context *ctx = data->ctx;
	struct aes_sc *aes_sc, *aes_tx_sc = NULL;
	struct aes_sc *aes_sc, *aes_tx_sc = NULL;
+11 −5
Original line number Original line Diff line number Diff line
@@ -38,6 +38,7 @@
#include "iwl-dev.h"
#include "iwl-dev.h"
#include "iwl-core.h"
#include "iwl-core.h"
#include "iwl-agn.h"
#include "iwl-agn.h"
#include "iwl-op-mode.h"


#define RS_NAME "iwl-agn-rs"
#define RS_NAME "iwl-agn-rs"


@@ -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_lq_sta *lq_sta = priv_sta;
	struct iwl_link_quality_cmd *table;
	struct iwl_link_quality_cmd *table;
	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
	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);
	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
	enum mac80211_rate_control_flags mac_flags;
	enum mac80211_rate_control_flags mac_flags;
	u32 tx_rate;
	u32 tx_rate;
@@ -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 sk_buff *skb = txrc->skb;
	struct ieee80211_supported_band *sband = txrc->sband;
	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 ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
	struct iwl_lq_sta *lq_sta = priv_sta;
	struct iwl_lq_sta *lq_sta = priv_sta;
	int rate_idx;
	int rate_idx;
@@ -2805,9 +2809,10 @@ static void *rs_alloc_sta(void *priv_rate, struct ieee80211_sta *sta,
			  gfp_t gfp)
			  gfp_t gfp)
{
{
	struct iwl_station_priv *sta_priv = (struct iwl_station_priv *) sta->drv_priv;
	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");
	IWL_DEBUG_RATE(priv, "create station rate scale window\n");


	return &sta_priv->lq_sta;
	return &sta_priv->lq_sta;
@@ -3074,7 +3079,8 @@ static void rs_free(void *priv_rate)
static void rs_free_sta(void *priv_r, struct ieee80211_sta *sta,
static void rs_free_sta(void *priv_r, struct ieee80211_sta *sta,
			void *priv_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, "enter\n");
	IWL_DEBUG_RATE(priv, "leave\n");
	IWL_DEBUG_RATE(priv, "leave\n");
+2 −2
Original line number Original line Diff line number Diff line
@@ -549,7 +549,7 @@ void iwlagn_config_ht40(struct ieee80211_conf *conf,


int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed)
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 iwl_rxon_context *ctx;
	struct ieee80211_conf *conf = &hw->conf;
	struct ieee80211_conf *conf = &hw->conf;
	struct ieee80211_channel *channel = conf->channel;
	struct ieee80211_channel *channel = conf->channel;
@@ -805,7 +805,7 @@ void iwlagn_bss_info_changed(struct ieee80211_hw *hw,
			     struct ieee80211_bss_conf *bss_conf,
			     struct ieee80211_bss_conf *bss_conf,
			     u32 changes)
			     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);
	struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif);
	int ret;
	int ret;
	bool force = false;
	bool force = false;
+21 −11
Original line number Original line Diff line number Diff line
@@ -52,6 +52,7 @@
#include "iwl-shared.h"
#include "iwl-shared.h"
#include "iwl-bus.h"
#include "iwl-bus.h"
#include "iwl-trans.h"
#include "iwl-trans.h"
#include "iwl-op-mode.h"


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


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


@@ -1158,18 +1158,21 @@ int iwl_op_mode_dvm_start(struct iwl_bus *bus,
	 ************************/
	 ************************/
	hw = iwl_alloc_all();
	hw = iwl_alloc_all();
	if (!hw) {
	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;
		err = -ENOMEM;
		goto out;
		goto out;
	}
	}


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


	/* At this point both hw and priv are allocated. */
	/* 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 */
	/* show what debugging capabilities we have */
	iwl_debug_config(priv);
	iwl_debug_config(priv);
@@ -1316,7 +1319,7 @@ int iwl_op_mode_dvm_start(struct iwl_bus *bus,
			"failed to create debugfs files. Ignoring error: %d\n",
			"failed to create debugfs files. Ignoring error: %d\n",
			err);
			err);


	return 0;
	return op_mode;


out_destroy_workqueue:
out_destroy_workqueue:
	destroy_workqueue(priv->workqueue);
	destroy_workqueue(priv->workqueue);
@@ -1328,11 +1331,14 @@ int iwl_op_mode_dvm_start(struct iwl_bus *bus,
	iwl_free_traffic_mem(priv);
	iwl_free_traffic_mem(priv);
	ieee80211_free_hw(priv->hw);
	ieee80211_free_hw(priv->hw);
out:
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);
	wait_for_completion(&nic(priv)->request_firmware_complete);


	IWL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n");
	IWL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n");
@@ -1374,6 +1380,10 @@ void iwl_op_mode_dvm_stop(struct iwl_priv *priv)
	ieee80211_free_hw(priv->hw);
	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,
};


/*****************************************************************************
/*****************************************************************************
 *
 *
+8 −0
Original line number Original line Diff line number Diff line
@@ -50,6 +50,7 @@
#include "iwl-bus.h"
#include "iwl-bus.h"
#include "iwl-trans.h"
#include "iwl-trans.h"
#include "iwl-shared.h"
#include "iwl-shared.h"
#include "iwl-op-mode.h"


struct iwl_tx_queue;
struct iwl_tx_queue;


@@ -710,6 +711,13 @@ struct iwl_wipan_noa_data {
	u8 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 {
struct iwl_priv {


	/*data shared among all the driver's layers */
	/*data shared among all the driver's layers */
Loading