Skip to content

Commit

Permalink
iwlegacy: move ops out of config
Browse files Browse the repository at this point in the history
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Stanislaw Gruszka authored and John W. Linville committed Feb 6, 2012
1 parent 8300719 commit c39ae9f
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 167 deletions.
22 changes: 10 additions & 12 deletions drivers/net/wireless/iwlegacy/3945-mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -618,8 +618,7 @@ il3945_tx_skb(struct il_priv *il, struct sk_buff *skb)

/* Add buffer containing Tx command and MAC(!) header to TFD's
* first entry */
il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, txcmd_phys, len, 1,
0);
il->ops->lib->txq_attach_buf_to_tfd(il, txq, txcmd_phys, len, 1, 0);

/* Set up TFD's 2nd entry to point directly to remainder of skb,
* if any (802.11 null frames have no payload). */
Expand All @@ -628,8 +627,8 @@ il3945_tx_skb(struct il_priv *il, struct sk_buff *skb)
phys_addr =
pci_map_single(il->pci_dev, skb->data + hdr_len, len,
PCI_DMA_TODEVICE);
il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, phys_addr,
len, 0, U32_PAD(len));
il->ops->lib->txq_attach_buf_to_tfd(il, txq, phys_addr, len, 0,
U32_PAD(len));
}

/* Tell device the write idx *just past* this latest filled TFD */
Expand Down Expand Up @@ -2416,7 +2415,7 @@ __il3945_up(struct il_priv *il)
/* load bootstrap state machine,
* load bootstrap program into processor's memory,
* prepare to load the "initialize" uCode */
rc = il->cfg->ops->lib->load_ucode(il);
rc = il->ops->lib->load_ucode(il);

if (rc) {
IL_ERR("Unable to set up bootstrap uCode: %d\n", rc);
Expand Down Expand Up @@ -3458,7 +3457,7 @@ static struct attribute_group il3945_attribute_group = {
.attrs = il3945_sysfs_entries,
};

struct ieee80211_ops il3945_hw_ops = {
struct ieee80211_ops il3945_mac_ops = {
.tx = il3945_mac_tx,
.start = il3945_mac_start,
.stop = il3945_mac_stop,
Expand Down Expand Up @@ -3599,15 +3598,13 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
* 1. Allocating HW data
* ********************/

/* mac80211 allocates memory for this device instance, including
* space for this driver's ilate structure */
hw = il_alloc_all(cfg);
if (hw == NULL) {
pr_err("Can not allocate network device\n");
hw = ieee80211_alloc_hw(sizeof(struct il_priv), &il3945_mac_ops);
if (!hw) {
err = -ENOMEM;
goto out;
}
il = hw->priv;
il->hw = hw;
SET_IEEE80211_DEV(hw, &pdev->dev);

il->cmd_queue = IL39_CMD_QUEUE_NUM;
Expand All @@ -3618,11 +3615,12 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
*/
if (il3945_mod_params.disable_hw_scan) {
D_INFO("Disabling hw_scan\n");
il3945_hw_ops.hw_scan = NULL;
il3945_mac_ops.hw_scan = NULL;
}

D_INFO("*** LOAD DRIVER ***\n");
il->cfg = cfg;
il->ops = &il3945_ops;
il->pci_dev = pdev;
il->inta_mask = CSR_INI_SET_MASK;

Expand Down
13 changes: 5 additions & 8 deletions drivers/net/wireless/iwlegacy/3945.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ il3945_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx)
tx_info = &txq->txb[txq->q.read_ptr];
ieee80211_tx_status_irqsafe(il->hw, tx_info->skb);
tx_info->skb = NULL;
il->cfg->ops->lib->txq_free_tfd(il, txq);
il->ops->lib->txq_free_tfd(il, txq);
}

if (il_queue_space(q) > q->low_mark && txq_id >= 0 &&
Expand Down Expand Up @@ -960,12 +960,12 @@ il3945_hw_nic_init(struct il_priv *il)
struct il_rx_queue *rxq = &il->rxq;

spin_lock_irqsave(&il->lock, flags);
il->cfg->ops->lib->apm_ops.init(il);
il->ops->lib->apm_ops.init(il);
spin_unlock_irqrestore(&il->lock, flags);

il3945_set_pwr_vmain(il);

il->cfg->ops->lib->apm_ops.config(il);
il->ops->lib->apm_ops.config(il);

/* Allocate the RX queue, or reset if it is already allocated */
if (!rxq->bd) {
Expand Down Expand Up @@ -1615,7 +1615,7 @@ il3945_hw_reg_comp_txpower_temp(struct il_priv *il)
}

/* send Txpower command for current channel to ucode */
return il->cfg->ops->lib->send_tx_power(il);
return il->ops->lib->send_tx_power(il);
}

int
Expand Down Expand Up @@ -2685,13 +2685,12 @@ static struct il_hcmd_utils_ops il3945_hcmd_utils = {
.post_scan = il3945_post_scan,
};

static const struct il_ops il3945_ops = {
const struct il_ops il3945_ops = {
.lib = &il3945_lib,
.hcmd = &il3945_hcmd,
.utils = &il3945_hcmd_utils,
.led = &il3945_led_ops,
.legacy = &il3945_legacy_ops,
.ieee80211_ops = &il3945_hw_ops,
};

static struct il_base_params il3945_base_params = {
Expand All @@ -2711,7 +2710,6 @@ static struct il_cfg il3945_bg_cfg = {
.ucode_api_min = IL3945_UCODE_API_MIN,
.sku = IL_SKU_G,
.eeprom_ver = EEPROM_3945_EEPROM_VERSION,
.ops = &il3945_ops,
.mod_params = &il3945_mod_params,
.base_params = &il3945_base_params,
.led_mode = IL_LED_BLINK,
Expand All @@ -2724,7 +2722,6 @@ static struct il_cfg il3945_abg_cfg = {
.ucode_api_min = IL3945_UCODE_API_MIN,
.sku = IL_SKU_A | IL_SKU_G,
.eeprom_ver = EEPROM_3945_EEPROM_VERSION,
.ops = &il3945_ops,
.mod_params = &il3945_mod_params,
.base_params = &il3945_base_params,
.led_mode = IL_LED_BLINK,
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wireless/iwlegacy/3945.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ extern const struct pci_device_id il3945_hw_card_ids[];

#include "common.h"

extern const struct il_ops il3945_ops;

/* Highest firmware API version supported */
#define IL3945_UCODE_API_MAX 2

Expand Down Expand Up @@ -261,8 +263,6 @@ extern int il3945_commit_rxon(struct il_priv *il);
*/
extern u8 il3945_hw_find_station(struct il_priv *il, const u8 * bssid);

extern struct ieee80211_ops il3945_hw_ops;

extern __le32 il3945_get_antenna_flags(const struct il_priv *il);
extern int il3945_init_hw_rate_table(struct il_priv *il);
extern void il3945_reg_txpower_periodic(struct il_priv *il);
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wireless/iwlegacy/4965-calib.c
Original file line number Diff line number Diff line change
Expand Up @@ -923,8 +923,8 @@ il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp)
/* Some power changes may have been made during the calibration.
* Update and commit the RXON
*/
if (il->cfg->ops->lib->update_chain_flags)
il->cfg->ops->lib->update_chain_flags(il);
if (il->ops->lib->update_chain_flags)
il->ops->lib->update_chain_flags(il);

data->state = IL_CHAIN_NOISE_DONE;
il_power_update_mode(il, false);
Expand Down
78 changes: 49 additions & 29 deletions drivers/net/wireless/iwlegacy/4965-mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ il4965_hw_nic_init(struct il_priv *il)

/* nic_init */
spin_lock_irqsave(&il->lock, flags);
il->cfg->ops->lib->apm_ops.init(il);
il->ops->lib->apm_ops.init(il);

/* Set interrupt coalescing calibration timer to default (512 usecs) */
il_write8(il, CSR_INT_COALESCING, IL_HOST_INT_CALIB_TIMEOUT_DEF);
Expand All @@ -210,7 +210,7 @@ il4965_hw_nic_init(struct il_priv *il)

il4965_set_pwr_vmain(il);

il->cfg->ops->lib->apm_ops.config(il);
il->ops->lib->apm_ops.config(il);

/* Allocate the RX queue, or reset if it is already allocated */
if (!rxq->bd) {
Expand Down Expand Up @@ -1381,8 +1381,8 @@ il4965_hdl_stats(struct il_priv *il, struct il_rx_buf *rxb)
il4965_rx_calc_noise(il);
queue_work(il->workqueue, &il->run_time_calib_work);
}
if (il->cfg->ops->lib->temp_ops.temperature && change)
il->cfg->ops->lib->temp_ops.temperature(il);
if (il->ops->lib->temp_ops.temperature && change)
il->ops->lib->temp_ops.temperature(il);
}

void
Expand Down Expand Up @@ -1817,8 +1817,7 @@ il4965_tx_skb(struct il_priv *il, struct sk_buff *skb)
dma_unmap_len_set(out_meta, len, firstlen);
/* Add buffer containing Tx command and MAC(!) header to TFD's
* first entry */
il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, txcmd_phys, firstlen,
1, 0);
il->ops->lib->txq_attach_buf_to_tfd(il, txq, txcmd_phys, firstlen, 1, 0);

if (!ieee80211_has_morefrags(hdr->frame_control)) {
txq->need_update = 1;
Expand All @@ -1834,8 +1833,8 @@ il4965_tx_skb(struct il_priv *il, struct sk_buff *skb)
phys_addr =
pci_map_single(il->pci_dev, skb->data + hdr_len, secondlen,
PCI_DMA_TODEVICE);
il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, phys_addr,
secondlen, 0, 0);
il->ops->lib->txq_attach_buf_to_tfd(il, txq, phys_addr,
secondlen, 0, 0);
}

scratch_phys =
Expand All @@ -1855,9 +1854,8 @@ il4965_tx_skb(struct il_priv *il, struct sk_buff *skb)

/* Set up entry for this TFD in Tx byte-count array */
if (info->flags & IEEE80211_TX_CTL_AMPDU)
il->cfg->ops->lib->txq_update_byte_cnt_tbl(il, txq,
le16_to_cpu(tx_cmd->
len));
il->ops->lib->txq_update_byte_cnt_tbl(il, txq,
le16_to_cpu(tx_cmd->len));

pci_dma_sync_single_for_device(il->pci_dev, txcmd_phys, firstlen,
PCI_DMA_BIDIRECTIONAL);
Expand Down Expand Up @@ -2479,7 +2477,7 @@ il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx)
txq_id >= IL4965_FIRST_AMPDU_QUEUE);
tx_info->skb = NULL;

il->cfg->ops->lib->txq_free_tfd(il, txq);
il->ops->lib->txq_free_tfd(il, txq);
}
return nfreed;
}
Expand Down Expand Up @@ -3357,8 +3355,8 @@ il4965_sta_modify_sleep_tx_count(struct il_priv *il, int sta_id, int cnt)
void
il4965_update_chain_flags(struct il_priv *il)
{
if (il->cfg->ops->hcmd->set_rxon_chain) {
il->cfg->ops->hcmd->set_rxon_chain(il);
if (il->ops->hcmd->set_rxon_chain) {
il->ops->hcmd->set_rxon_chain(il);
if (il->active.rx_chain != il->staging.rx_chain)
il_commit_rxon(il);
}
Expand Down Expand Up @@ -3878,7 +3876,7 @@ il4965_setup_handlers(struct il_priv *il)
/* block ack */
il->handlers[N_COMPRESSED_BA] = il4965_hdl_compressed_ba;
/* Set up hardware specific Rx handlers */
il->cfg->ops->lib->handler_setup(il);
il->ops->lib->handler_setup(il);
}

/**
Expand Down Expand Up @@ -4780,7 +4778,7 @@ il4965_dump_nic_error_log(struct il_priv *il)
else
base = le32_to_cpu(il->card_alive.error_event_table_ptr);

if (!il->cfg->ops->lib->is_valid_rtc_data_addr(base)) {
if (!il->ops->lib->is_valid_rtc_data_addr(base)) {
IL_ERR("Not valid error log pointer 0x%08X for %s uCode\n",
base, (il->ucode_type == UCODE_INIT) ? "Init" : "RT");
return;
Expand Down Expand Up @@ -5009,8 +5007,8 @@ il4965_alive_start(struct il_priv *il)
/* Initialize our rx_config data */
il_connection_init_rx_config(il);

if (il->cfg->ops->hcmd->set_rxon_chain)
il->cfg->ops->hcmd->set_rxon_chain(il);
if (il->ops->hcmd->set_rxon_chain)
il->ops->hcmd->set_rxon_chain(il);
}

/* Configure bluetooth coexistence if enabled */
Expand Down Expand Up @@ -5282,7 +5280,7 @@ __il4965_up(struct il_priv *il)
/* load bootstrap state machine,
* load bootstrap program into processor's memory,
* prepare to load the "initialize" uCode */
ret = il->cfg->ops->lib->load_ucode(il);
ret = il->ops->lib->load_ucode(il);

if (ret) {
IL_ERR("Unable to set up bootstrap uCode: %d\n", ret);
Expand Down Expand Up @@ -5323,7 +5321,7 @@ il4965_bg_init_alive_start(struct work_struct *data)
if (test_bit(S_EXIT_PENDING, &il->status))
goto out;

il->cfg->ops->lib->init_alive_start(il);
il->ops->lib->init_alive_start(il);
out:
mutex_unlock(&il->mutex);
}
Expand Down Expand Up @@ -5755,7 +5753,7 @@ il4965_mac_channel_switch(struct ieee80211_hw *hw,
if (!il_is_associated(il))
goto out;

if (!il->cfg->ops->lib->set_channel_switch)
if (!il->ops->lib->set_channel_switch)
goto out;

ch = channel->hw_value;
Expand Down Expand Up @@ -5807,7 +5805,7 @@ il4965_mac_channel_switch(struct ieee80211_hw *hw,
*/
set_bit(S_CHANNEL_SWITCH_PENDING, &il->status);
il->switch_channel = cpu_to_le16(ch);
if (il->cfg->ops->lib->set_channel_switch(il, ch_switch)) {
if (il->ops->lib->set_channel_switch(il, ch_switch)) {
clear_bit(S_CHANNEL_SWITCH_PENDING, &il->status);
il->switch_channel = 0;
ieee80211_chswitch_done(il->vif, false);
Expand Down Expand Up @@ -5890,7 +5888,7 @@ il4965_bg_txpower_work(struct work_struct *work)
/* Regardless of if we are associated, we must reconfigure the
* TX power since frames can be sent on non-radar channels while
* not associated */
il->cfg->ops->lib->send_tx_power(il);
il->ops->lib->send_tx_power(il);

/* Update last_temperature to keep is_calib_needed from running
* when it isn't needed... */
Expand Down Expand Up @@ -5996,6 +5994,28 @@ il4965_tx_queue_set_status(struct il_priv *il, struct il_tx_queue *txq,
scd_retry ? "BA" : "AC", txq_id, tx_fifo_id);
}

const struct ieee80211_ops il4965_mac_ops = {
.tx = il4965_mac_tx,
.start = il4965_mac_start,
.stop = il4965_mac_stop,
.add_interface = il_mac_add_interface,
.remove_interface = il_mac_remove_interface,
.change_interface = il_mac_change_interface,
.config = il_mac_config,
.configure_filter = il4965_configure_filter,
.set_key = il4965_mac_set_key,
.update_tkip_key = il4965_mac_update_tkip_key,
.conf_tx = il_mac_conf_tx,
.reset_tsf = il_mac_reset_tsf,
.bss_info_changed = il_mac_bss_info_changed,
.ampdu_action = il4965_mac_ampdu_action,
.hw_scan = il_mac_hw_scan,
.sta_add = il4965_mac_sta_add,
.sta_remove = il_mac_sta_remove,
.channel_switch = il4965_mac_channel_switch,
.tx_last_beacon = il_mac_tx_last_beacon,
};

static int
il4965_init_drv(struct il_priv *il)
{
Expand All @@ -6020,8 +6040,8 @@ il4965_init_drv(struct il_priv *il)
il->force_reset.reset_duration = IL_DELAY_NEXT_FORCE_FW_RELOAD;

/* Choose which receivers/antennas to use */
if (il->cfg->ops->hcmd->set_rxon_chain)
il->cfg->ops->hcmd->set_rxon_chain(il);
if (il->ops->hcmd->set_rxon_chain)
il->ops->hcmd->set_rxon_chain(il);

il_init_scan_params(il);

Expand Down Expand Up @@ -6081,7 +6101,7 @@ il4965_set_hw_params(struct il_priv *il)
il->cfg->sku &= ~IL_SKU_N;

/* Device-specific setup */
return il->cfg->ops->lib->set_hw_params(il);
return il->ops->lib->set_hw_params(il);
}

static int
Expand All @@ -6098,18 +6118,18 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
* 1. Allocating HW data
************************/

hw = il_alloc_all(cfg);
hw = ieee80211_alloc_hw(sizeof(struct il_priv), &il4965_mac_ops);
if (!hw) {
err = -ENOMEM;
goto out;
}
il = hw->priv;
/* At this point both hw and il are allocated. */

il->hw = hw;
SET_IEEE80211_DEV(hw, &pdev->dev);

D_INFO("*** LOAD DRIVER ***\n");
il->cfg = cfg;
il->ops = &il4965_ops;
il->pci_dev = pdev;
il->inta_mask = CSR_INI_SET_MASK;

Expand Down
Loading

0 comments on commit c39ae9f

Please sign in to comment.