Commit fda1bd0d authored by Mordechay Goodstein's avatar Mordechay Goodstein Committed by Luca Coelho

iwlwifi: iwl-trans: move all txcmd init to trans alloc

txcmd fields is not directly related to the PCIe transport,
so move to the common iwl_trans_alloc function.
Signed-off-by: default avatarMordechay Goodstein <mordechay.goodstein@intel.com>
Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20200924162105.862ef88d1ab2.Iba220a962b5d6d05c030b9275d97a89202d055dc@changeidSigned-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
parent ccca2cb4
...@@ -5,9 +5,8 @@ ...@@ -5,9 +5,8 @@
* *
* GPL LICENSE SUMMARY * GPL LICENSE SUMMARY
* *
* Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
* Copyright(c) 2016 - 2017 Intel Deutschland GmbH * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
* Copyright(c) 2018 - 2019 Intel Corporation * Copyright(c) 2012 - 2014, 2018 - 2020 Intel Corporation
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License as * it under the terms of version 2 of the GNU General Public License as
...@@ -27,9 +26,8 @@ ...@@ -27,9 +26,8 @@
* *
* BSD LICENSE * BSD LICENSE
* *
* Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
* Copyright(c) 2016 - 2017 Intel Deutschland GmbH * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
* Copyright(c) 2018 - 2019 Intel Corporation * Copyright(c) 2012 - 2014, 2018 - 2020 Intel Corporation
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
...@@ -61,6 +59,7 @@ ...@@ -61,6 +59,7 @@
#ifndef __iwl_fw_api_tx_h__ #ifndef __iwl_fw_api_tx_h__
#define __iwl_fw_api_tx_h__ #define __iwl_fw_api_tx_h__
#include <linux/ieee80211.h>
/** /**
* enum iwl_tx_flags - bitmasks for tx_flags in TX command * enum iwl_tx_flags - bitmasks for tx_flags in TX command
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
* *
* Copyright(c) 2015 Intel Mobile Communications GmbH * Copyright(c) 2015 Intel Mobile Communications GmbH
* Copyright(c) 2016 - 2017 Intel Deutschland GmbH * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
* Copyright(c) 2019 - 2020 Intel Corporation
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License as * it under the terms of version 2 of the GNU General Public License as
...@@ -28,6 +29,7 @@ ...@@ -28,6 +29,7 @@
* *
* Copyright(c) 2015 Intel Mobile Communications GmbH * Copyright(c) 2015 Intel Mobile Communications GmbH
* Copyright(c) 2016 - 2017 Intel Deutschland GmbH * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
* Copyright(c) 2019 - 2020 Intel Corporation
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
...@@ -60,6 +62,7 @@ ...@@ -60,6 +62,7 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/bsearch.h> #include <linux/bsearch.h>
#include "fw/api/tx.h"
#include "iwl-trans.h" #include "iwl-trans.h"
#include "iwl-drv.h" #include "iwl-drv.h"
#include "iwl-fh.h" #include "iwl-fh.h"
...@@ -67,10 +70,10 @@ ...@@ -67,10 +70,10 @@
struct iwl_trans *iwl_trans_alloc(unsigned int priv_size, struct iwl_trans *iwl_trans_alloc(unsigned int priv_size,
struct device *dev, struct device *dev,
const struct iwl_trans_ops *ops, const struct iwl_trans_ops *ops,
unsigned int cmd_pool_size, const struct iwl_cfg_trans_params *cfg_trans)
unsigned int cmd_pool_align)
{ {
struct iwl_trans *trans; struct iwl_trans *trans;
int txcmd_size, txcmd_align;
#ifdef CONFIG_LOCKDEP #ifdef CONFIG_LOCKDEP
static struct lock_class_key __key; static struct lock_class_key __key;
#endif #endif
...@@ -79,6 +82,25 @@ struct iwl_trans *iwl_trans_alloc(unsigned int priv_size, ...@@ -79,6 +82,25 @@ struct iwl_trans *iwl_trans_alloc(unsigned int priv_size,
if (!trans) if (!trans)
return NULL; return NULL;
trans->trans_cfg = cfg_trans;
if (!cfg_trans->gen2) {
txcmd_size = sizeof(struct iwl_tx_cmd);
txcmd_align = sizeof(void *);
} else if (cfg_trans->device_family < IWL_DEVICE_FAMILY_AX210) {
txcmd_size = sizeof(struct iwl_tx_cmd_gen2);
txcmd_align = 64;
} else {
txcmd_size = sizeof(struct iwl_tx_cmd_gen3);
txcmd_align = 128;
}
txcmd_size += sizeof(struct iwl_cmd_header);
txcmd_size += 36; /* biggest possible 802.11 header */
/* Ensure device TX cmd cannot reach/cross a page boundary in gen2 */
if (WARN_ON(cfg_trans->gen2 && txcmd_size >= txcmd_align))
return ERR_PTR(-EINVAL);
#ifdef CONFIG_LOCKDEP #ifdef CONFIG_LOCKDEP
lockdep_init_map(&trans->sync_cmd_lockdep_map, "sync_cmd_lockdep_map", lockdep_init_map(&trans->sync_cmd_lockdep_map, "sync_cmd_lockdep_map",
&__key, 0); &__key, 0);
...@@ -92,7 +114,7 @@ struct iwl_trans *iwl_trans_alloc(unsigned int priv_size, ...@@ -92,7 +114,7 @@ struct iwl_trans *iwl_trans_alloc(unsigned int priv_size,
"iwl_cmd_pool:%s", dev_name(trans->dev)); "iwl_cmd_pool:%s", dev_name(trans->dev));
trans->dev_cmd_pool = trans->dev_cmd_pool =
kmem_cache_create(trans->dev_cmd_pool_name, kmem_cache_create(trans->dev_cmd_pool_name,
cmd_pool_size, cmd_pool_align, txcmd_size, txcmd_align,
SLAB_HWCACHE_ALIGN, NULL); SLAB_HWCACHE_ALIGN, NULL);
if (!trans->dev_cmd_pool) if (!trans->dev_cmd_pool)
return NULL; return NULL;
......
...@@ -1436,10 +1436,9 @@ static inline bool iwl_trans_dbg_ini_valid(struct iwl_trans *trans) ...@@ -1436,10 +1436,9 @@ static inline bool iwl_trans_dbg_ini_valid(struct iwl_trans *trans)
* transport helper functions * transport helper functions
*****************************************************/ *****************************************************/
struct iwl_trans *iwl_trans_alloc(unsigned int priv_size, struct iwl_trans *iwl_trans_alloc(unsigned int priv_size,
struct device *dev, struct device *dev,
const struct iwl_trans_ops *ops, const struct iwl_trans_ops *ops,
unsigned int cmd_pool_size, const struct iwl_cfg_trans_params *cfg_trans);
unsigned int cmd_pool_align);
void iwl_trans_free(struct iwl_trans *trans); void iwl_trans_free(struct iwl_trans *trans);
/***************************************************** /*****************************************************
......
...@@ -1002,9 +1002,6 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1002,9 +1002,6 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
trans_pcie = IWL_TRANS_GET_PCIE_TRANS(iwl_trans); trans_pcie = IWL_TRANS_GET_PCIE_TRANS(iwl_trans);
/* the trans_cfg should never change, so set it now */
iwl_trans->trans_cfg = trans;
iwl_trans->hw_rf_id = iwl_read32(iwl_trans, CSR_HW_RF_ID); iwl_trans->hw_rf_id = iwl_read32(iwl_trans, CSR_HW_RF_ID);
for (i = 0; i < ARRAY_SIZE(iwl_dev_info_table); i++) { for (i = 0; i < ARRAY_SIZE(iwl_dev_info_table); i++) {
......
...@@ -3502,34 +3502,18 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev, ...@@ -3502,34 +3502,18 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
{ {
struct iwl_trans_pcie *trans_pcie; struct iwl_trans_pcie *trans_pcie;
struct iwl_trans *trans; struct iwl_trans *trans;
int ret, addr_size, txcmd_size, txcmd_align; int ret, addr_size;
const struct iwl_trans_ops *ops = &trans_ops_pcie_gen2; const struct iwl_trans_ops *ops = &trans_ops_pcie_gen2;
if (!cfg_trans->gen2) { if (!cfg_trans->gen2)
ops = &trans_ops_pcie; ops = &trans_ops_pcie;
txcmd_size = sizeof(struct iwl_tx_cmd);
txcmd_align = sizeof(void *);
} else if (cfg_trans->device_family < IWL_DEVICE_FAMILY_AX210) {
txcmd_size = sizeof(struct iwl_tx_cmd_gen2);
txcmd_align = 64;
} else {
txcmd_size = sizeof(struct iwl_tx_cmd_gen3);
txcmd_align = 128;
}
txcmd_size += sizeof(struct iwl_cmd_header);
txcmd_size += 36; /* biggest possible 802.11 header */
/* Ensure device TX cmd cannot reach/cross a page boundary in gen2 */
if (WARN_ON(cfg_trans->gen2 && txcmd_size >= txcmd_align))
return ERR_PTR(-EINVAL);
ret = pcim_enable_device(pdev); ret = pcim_enable_device(pdev);
if (ret) if (ret)
return ERR_PTR(ret); return ERR_PTR(ret);
trans = iwl_trans_alloc(sizeof(struct iwl_trans_pcie), &pdev->dev, ops, trans = iwl_trans_alloc(sizeof(struct iwl_trans_pcie), &pdev->dev, ops,
txcmd_size, txcmd_align); cfg_trans);
if (!trans) if (!trans)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment