Skip to content

Commit

Permalink
iwlwifi: implement a new device configuration table
Browse files Browse the repository at this point in the history
Add a new device table that contains information that can be checked
at runtime in order to decide which configuration to use.  This allows
us to map the full cfg independently from the tran-specific
configuration.

This is the first step in creating the new table.  Subsequent patches
will add the possibility of checking different values at runtime in
order to make the decision.

Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
  • Loading branch information
Luca Coelho committed Jan 4, 2020
1 parent b3bd641 commit 2a612a6
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 9 deletions.
6 changes: 6 additions & 0 deletions drivers/net/wireless/intel/iwlwifi/cfg/9000.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ static const struct iwl_tt_params iwl9000_tt_params = {
}, \
}

const struct iwl_cfg_trans_params iwl9000_trans_cfg = {
.device_family = IWL_DEVICE_FAMILY_9000,
.base_params = &iwl9000_base_params,
.mq_rx_supported = true,
.rf_id = true,
};

const struct iwl_cfg iwl9160_2ac_cfg = {
.name = "Intel(R) Dual Band Wireless AC 9160",
Expand Down
10 changes: 10 additions & 0 deletions drivers/net/wireless/intel/iwlwifi/iwl-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -452,9 +452,19 @@ struct iwl_cfg {
const struct iwl_fw_mon_regs mon_smem_regs;
};

#define IWL_CFG_ANY (~0)

struct iwl_dev_info {
u16 device;
u16 subdevice;
const struct iwl_cfg *cfg;
};

/*
* This list declares the config structures for all devices.
*/
extern const struct iwl_cfg_trans_params iwl9000_trans_cfg;

#if IS_ENABLED(CONFIG_IWLDVM)
extern const struct iwl_cfg iwl5300_agn_cfg;
extern const struct iwl_cfg iwl5100_agn_cfg;
Expand Down
42 changes: 33 additions & 9 deletions drivers/net/wireless/intel/iwlwifi/pcie/drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,14 +565,8 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
{IWL_PCI_DEVICE(0x06F0, 0x40A4, iwl9462_2ac_cfg_quz_a0_jf_b0_soc)},
{IWL_PCI_DEVICE(0x06F0, 0x4234, iwl9560_2ac_cfg_quz_a0_jf_b0_soc)},
{IWL_PCI_DEVICE(0x06F0, 0x42A4, iwl9462_2ac_cfg_quz_a0_jf_b0_soc)},
{IWL_PCI_DEVICE(0x2526, 0x0010, iwl9260_2ac_160_cfg)},
{IWL_PCI_DEVICE(0x2526, 0x0014, iwl9260_2ac_160_cfg)},
{IWL_PCI_DEVICE(0x2526, 0x0018, iwl9260_2ac_160_cfg)},
{IWL_PCI_DEVICE(0x2526, 0x001C, iwl9260_2ac_160_cfg)},
{IWL_PCI_DEVICE(0x2526, 0x0030, iwl9560_2ac_160_cfg)},

{IWL_PCI_DEVICE(0x2526, 0x0034, iwl9560_2ac_cfg)},
{IWL_PCI_DEVICE(0x2526, 0x0038, iwl9560_2ac_160_cfg)},
{IWL_PCI_DEVICE(0x2526, 0x003C, iwl9560_2ac_160_cfg)},
{IWL_PCI_DEVICE(0x2526, 0x0060, iwl9461_2ac_cfg_soc)},
{IWL_PCI_DEVICE(0x2526, 0x0064, iwl9461_2ac_cfg_soc)},
{IWL_PCI_DEVICE(0x2526, 0x00A0, iwl9462_2ac_cfg_soc)},
Expand Down Expand Up @@ -601,7 +595,6 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
{IWL_PCI_DEVICE(0x2526, 0x4010, iwl9260_2ac_160_cfg)},
{IWL_PCI_DEVICE(0x2526, 0x4018, iwl9260_2ac_160_cfg)},
{IWL_PCI_DEVICE(0x2526, 0x401C, iwl9260_2ac_160_cfg)},
{IWL_PCI_DEVICE(0x2526, 0x4030, iwl9560_2ac_160_cfg)},
{IWL_PCI_DEVICE(0x2526, 0x4034, iwl9560_2ac_160_cfg_soc)},
{IWL_PCI_DEVICE(0x2526, 0x40A4, iwl9462_2ac_cfg_soc)},
{IWL_PCI_DEVICE(0x2526, 0x4234, iwl9560_2ac_cfg_soc)},
Expand All @@ -613,6 +606,8 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
{IWL_PCI_DEVICE(0x2526, 0xA014, iwl9260_2ac_160_cfg)},
{IWL_PCI_DEVICE(0x2526, 0xE010, iwl9260_2ac_160_cfg)},
{IWL_PCI_DEVICE(0x2526, 0xE014, iwl9260_2ac_160_cfg)},
{IWL_PCI_DEVICE(0x2526, PCI_ANY_ID, iwl9000_trans_cfg)},

{IWL_PCI_DEVICE(0x271B, 0x0010, iwl9160_2ac_cfg)},
{IWL_PCI_DEVICE(0x271B, 0x0014, iwl9160_2ac_cfg)},
{IWL_PCI_DEVICE(0x271B, 0x0210, iwl9160_2ac_cfg)},
Expand Down Expand Up @@ -986,6 +981,22 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
};
MODULE_DEVICE_TABLE(pci, iwl_hw_card_ids);

#define IWL_DEV_INFO(_device, _subdevice, _cfg) \
{.device = (_device), .subdevice = (_subdevice), .cfg = &(_cfg)}

static const struct iwl_dev_info iwl_dev_info_table[] = {
#if IS_ENABLED(CONFIG_IWLMVM)
IWL_DEV_INFO(0x2526, 0x0010, iwl9260_2ac_160_cfg),
IWL_DEV_INFO(0x2526, 0x0014, iwl9260_2ac_160_cfg),
IWL_DEV_INFO(0x2526, 0x0018, iwl9260_2ac_160_cfg),
IWL_DEV_INFO(0x2526, 0x001C, iwl9260_2ac_160_cfg),
IWL_DEV_INFO(0x2526, 0x0030, iwl9560_2ac_160_cfg),
IWL_DEV_INFO(0x2526, 0x0038, iwl9560_2ac_160_cfg),
IWL_DEV_INFO(0x2526, 0x003C, iwl9560_2ac_160_cfg),
IWL_DEV_INFO(0x2526, 0x4030, iwl9560_2ac_160_cfg),
#endif /* CONFIG_IWLMVM */
};

/* PCI registers */
#define PCI_CFG_RETRY_TIMEOUT 0x041

Expand All @@ -997,7 +1008,7 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
struct iwl_trans *iwl_trans;
struct iwl_trans_pcie *trans_pcie;
unsigned long flags;
int ret;
int i, ret;
/*
* This is needed for backwards compatibility with the old
* tables, so we don't need to change all the config structs
Expand All @@ -1018,6 +1029,18 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
/* the trans_cfg should never change, so set it now */
iwl_trans->trans_cfg = trans;

for (i = 0; i < ARRAY_SIZE(iwl_dev_info_table); i++) {
const struct iwl_dev_info *dev_info = &iwl_dev_info_table[i];

if ((dev_info->device == IWL_CFG_ANY ||
dev_info->device == pdev->device) &&
(dev_info->subdevice == IWL_CFG_ANY ||
dev_info->subdevice == pdev->subsystem_device)) {
iwl_trans->cfg = dev_info->cfg;
goto found;
}
}

#if IS_ENABLED(CONFIG_IWLMVM)
/*
* special-case 7265D, it has the same PCI IDs.
Expand Down Expand Up @@ -1140,6 +1163,7 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (!iwl_trans->cfg)
iwl_trans->cfg = cfg;

found:
if (iwl_trans->trans_cfg->mq_rx_supported) {
if (WARN_ON(!iwl_trans->cfg->num_rbds)) {
ret = -EINVAL;
Expand Down

0 comments on commit 2a612a6

Please sign in to comment.