OSDN Git Service

iwlwifi: iwl-trans: move all txcmd init to trans alloc
authorMordechay Goodstein <mordechay.goodstein@intel.com>
Thu, 24 Sep 2020 13:23:34 +0000 (16:23 +0300)
committerLuca Coelho <luciano.coelho@intel.com>
Thu, 1 Oct 2020 18:56:46 +0000 (21:56 +0300)
txcmd fields is not directly related to the PCIe transport,
so move to the common iwl_trans_alloc function.

Signed-off-by: Mordechay Goodstein <mordechay.goodstein@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20200924162105.862ef88d1ab2.Iba220a962b5d6d05c030b9275d97a89202d055dc@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
drivers/net/wireless/intel/iwlwifi/fw/api/tx.h
drivers/net/wireless/intel/iwlwifi/iwl-trans.c
drivers/net/wireless/intel/iwlwifi/iwl-trans.h
drivers/net/wireless/intel/iwlwifi/pcie/drv.c
drivers/net/wireless/intel/iwlwifi/pcie/trans.c

index 82d59b5..de2e2ca 100644 (file)
@@ -5,9 +5,8 @@
  *
  * GPL LICENSE SUMMARY
  *
- * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  * 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
  * it under the terms of version 2 of the GNU General Public License as
@@ -27,9 +26,8 @@
  *
  * BSD LICENSE
  *
- * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
  * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
- * Copyright(c) 2018 - 2019 Intel Corporation
+ * Copyright(c) 2012 - 2014, 2018 - 2020 Intel Corporation
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -61,6 +59,7 @@
 
 #ifndef __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
index f91197e..4a61ab5 100644 (file)
@@ -7,6 +7,7 @@
  *
  * Copyright(c) 2015 Intel Mobile Communications 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
  * it under the terms of version 2 of the GNU General Public License as
@@ -28,6 +29,7 @@
  *
  * Copyright(c) 2015 Intel Mobile Communications GmbH
  * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
+ * Copyright(c) 2019 - 2020 Intel Corporation
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -60,6 +62,7 @@
 #include <linux/kernel.h>
 #include <linux/bsearch.h>
 
+#include "fw/api/tx.h"
 #include "iwl-trans.h"
 #include "iwl-drv.h"
 #include "iwl-fh.h"
 struct iwl_trans *iwl_trans_alloc(unsigned int priv_size,
                                  struct device *dev,
                                  const struct iwl_trans_ops *ops,
-                                 unsigned int cmd_pool_size,
-                                 unsigned int cmd_pool_align)
+                                 const struct iwl_cfg_trans_params *cfg_trans)
 {
        struct iwl_trans *trans;
+       int txcmd_size, txcmd_align;
 #ifdef CONFIG_LOCKDEP
        static struct lock_class_key __key;
 #endif
@@ -79,6 +82,25 @@ struct iwl_trans *iwl_trans_alloc(unsigned int priv_size,
        if (!trans)
                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
        lockdep_init_map(&trans->sync_cmd_lockdep_map, "sync_cmd_lockdep_map",
                         &__key, 0);
@@ -92,7 +114,7 @@ struct iwl_trans *iwl_trans_alloc(unsigned int priv_size,
                 "iwl_cmd_pool:%s", dev_name(trans->dev));
        trans->dev_cmd_pool =
                kmem_cache_create(trans->dev_cmd_pool_name,
-                                 cmd_pool_size, cmd_pool_align,
+                                 txcmd_size, txcmd_align,
                                  SLAB_HWCACHE_ALIGN, NULL);
        if (!trans->dev_cmd_pool)
                return NULL;
index 32ea4c3..d17eafe 100644 (file)
@@ -1436,10 +1436,9 @@ static inline bool iwl_trans_dbg_ini_valid(struct iwl_trans *trans)
  * transport helper functions
  *****************************************************/
 struct iwl_trans *iwl_trans_alloc(unsigned int priv_size,
-                                 struct device *dev,
-                                 const struct iwl_trans_ops *ops,
-                                 unsigned int cmd_pool_size,
-                                 unsigned int cmd_pool_align);
+                         struct device *dev,
+                         const struct iwl_trans_ops *ops,
+                         const struct iwl_cfg_trans_params *cfg_trans);
 void iwl_trans_free(struct iwl_trans *trans);
 
 /*****************************************************
index 72bb2b3..d84afe0 100644 (file)
@@ -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);
 
-       /* 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);
 
        for (i = 0; i < ARRAY_SIZE(iwl_dev_info_table); i++) {
index a59684e..43adb66 100644 (file)
@@ -3502,34 +3502,18 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
 {
        struct iwl_trans_pcie *trans_pcie;
        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;
 
-       if (!cfg_trans->gen2) {
+       if (!cfg_trans->gen2)
                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);
        if (ret)
                return ERR_PTR(ret);
 
        trans = iwl_trans_alloc(sizeof(struct iwl_trans_pcie), &pdev->dev, ops,
-                               txcmd_size, txcmd_align);
+                               cfg_trans);
        if (!trans)
                return ERR_PTR(-ENOMEM);