[openib-general] [PATCH v2] IB_mthca HCA profile module parameters

Moni Shoua monis at voltaire.com
Thu Nov 16 10:45:26 PST 2006


From: Leonid Arsh Mleonida at voltaire.com>

Adds module parameters that enable settting some of the HCA
profile values
Signed-off-by: Leonid Arsh <leonida at voltaire.com>
Signed-off-by: Moni Shoua <monis at voltaire.com>
---
  mthca_main.c |  139 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
  1 files changed, 128 insertions(+), 11 deletions(-)
--- mthca_main.c.orig	2006-11-14 22:07:58.000000000 -0500
+++ mthca_main.c	2006-11-16 11:27:17.683513163 -0500
@@ -80,21 +80,134 @@
  module_param(tune_pci, int, 0444);
  MODULE_PARM_DESC(tune_pci, "increase PCI burst from the default set by BIOS if nonzero");

+#define MTHCA_DEFAULT_NUM_QP            (1 << 16)
+#define MTHCA_DEFAULT_RDB_PER_QP        (1 << 2)
+#define MTHCA_DEFAULT_NUM_CQ            (1 << 16)
+#define MTHCA_DEFAULT_NUM_MCG           (1 << 13)
+#define MTHCA_DEFAULT_NUM_MPT           (1 << 17)
+#define MTHCA_DEFAULT_NUM_MTT           (1 << 20)
+#define MTHCA_DEFAULT_NUM_UDAV          (1 << 15)
+#define MTHCA_DEFAULT_NUM_RESERVED_MTTS (1 << 18)
+#define MTHCA_DEFAULT_NUM_UARC_SIZE     (1 << 18)
+
+static struct mthca_profile default_profile = {
+	.num_qp		   = MTHCA_DEFAULT_NUM_QP,
+	.rdb_per_qp	   = MTHCA_DEFAULT_RDB_PER_QP,
+	.num_cq		   = MTHCA_DEFAULT_NUM_CQ,
+	.num_mcg	   = MTHCA_DEFAULT_NUM_MCG,
+	.num_mpt	   = MTHCA_DEFAULT_NUM_MPT,
+	.num_mtt	   = MTHCA_DEFAULT_NUM_MTT,
+	.num_udav	   = MTHCA_DEFAULT_NUM_UDAV,                /* Tavor only */
+	.fmr_reserved_mtts = MTHCA_DEFAULT_NUM_RESERVED_MTTS,   /* Tavor only */
+	.uarc_size	   = MTHCA_DEFAULT_NUM_UARC_SIZE,           /* Arbel only */
+};
+
+module_param_named(num_qp, default_profile.num_qp, int, 0444);
+MODULE_PARM_DESC(num_qp, "maximum number of available QPs per HCA");
+
+module_param_named(rdb_per_qp, default_profile.rdb_per_qp, int, 0444);
+MODULE_PARM_DESC(rdb_per_qp, "number of RDB buffers per QP");
+
+module_param_named(num_cq, default_profile.num_cq, int, 0444);
+MODULE_PARM_DESC(num_cq, "maximum number of CQs per HCA");
+
+module_param_named(num_mcg, default_profile.num_mcg, int, 0444);
+MODULE_PARM_DESC(num_mcg, "maximum number of multicast groups per HCA");
+
+module_param_named(num_mpt, default_profile.num_mpt, int, 0444);
+MODULE_PARM_DESC(num_mpt, 
+		"maximum number of memory protection pable entries per HCA");
+
+module_param_named(num_mtt, default_profile.num_mtt, int, 0444);
+MODULE_PARM_DESC(num_mtt,
+		 "maximum number of memory translation table segments per HCA");
+/* Tavor only */
+module_param_named(num_udav, default_profile.num_udav, int, 0444);
+MODULE_PARM_DESC(num_udav, "maximum number of UD address vectors per HCA");
+
+/* Tavor only */
+module_param_named(fmr_reserved_mtts, default_profile.fmr_reserved_mtts, int, 0444);
+MODULE_PARM_DESC(fmr_reserved_mtts,
+		 "number of memory translation table segments reserved for FMR");
+
  static const char mthca_version[] __devinitdata =
  	DRV_NAME ": Mellanox InfiniBand HCA driver v"
  	DRV_VERSION " (" DRV_RELDATE ")\n";

-static struct mthca_profile default_profile = {
-	.num_qp		   = 1 << 16,
-	.rdb_per_qp	   = 4,
-	.num_cq		   = 1 << 16,
-	.num_mcg	   = 1 << 13,
-	.num_mpt	   = 1 << 17,
-	.num_mtt	   = 1 << 20,
-	.num_udav	   = 1 << 15,	/* Tavor only */
-	.fmr_reserved_mtts = 1 << 18,	/* Tavor only */
-	.uarc_size	   = 1 << 18,	/* Arbel only */
-};
+#define is_power_of_2(x) (!(x & (x - 1)))
+
+static int __devinit mthca_check_profile_value(int* pval,int pval_default){
+    /* value must be positive and power of 2 */
+    int old_pval = *pval;
+    if (old_pval <= 0) {
+        *pval = pval_default;
+    } else if (!is_power_of_2(old_pval)) {
+        *pval = roundup_pow_of_two(old_pval);
+    }
+    return old_pval-*pval;
+}
+
+static int __devinit mthca_validate_profile(struct mthca_dev *mdev,
+					    struct mthca_profile *profile)
+{
+    if (mthca_check_profile_value(&default_profile.num_qp,
+                                  MTHCA_DEFAULT_NUM_QP)){
+		mthca_warn(mdev,"invalid num_qp passed. changed to %d.\n",
+                   default_profile.num_qp); 
+	}
+
+	if (mthca_check_profile_value(&default_profile.rdb_per_qp,
+                                  MTHCA_DEFAULT_RDB_PER_QP)){
+        mthca_warn(mdev,"invalid rdb_per_qp passed. changed to %d\n",
+                   default_profile.rdb_per_qp); 
+	}
+
+	if (mthca_check_profile_value(&default_profile.num_cq,
+                                  MTHCA_DEFAULT_NUM_CQ)){
+		mthca_warn(mdev,"invalid num_cq passed. changed to %d\n",
+                   default_profile.num_cq); 
+	}
+
+	if (mthca_check_profile_value(&default_profile.num_mcg,
+                                  MTHCA_DEFAULT_NUM_MCG)){
+		mthca_warn(mdev,"invalid num_mcg passed. changed to %d\n",
+                   default_profile.num_mcg); 
+	}
+	if (mthca_check_profile_value(&default_profile.num_mpt,
+                                  MTHCA_DEFAULT_NUM_MPT)){
+		mthca_warn(mdev,"invalid num_mpt passed. changed to %d\n",
+                   default_profile.num_mpt); 
+	}
+
+	if (mthca_check_profile_value(&default_profile.num_mtt,
+                                  MTHCA_DEFAULT_NUM_MTT)){
+		mthca_warn(mdev,"invalid num_mtt passed. changed to %d\n",
+                   default_profile.num_mtt); 
+	}
+
+	if (mthca_is_memfree(mdev)) {
+		if (mthca_check_profile_value(&default_profile.num_udav,
+                                      MTHCA_DEFAULT_NUM_UDAV)){
+			mthca_warn(mdev,"invalid num_udav passed. changed to %d\n",
+                       default_profile.num_udav); 
+		}
+
+		if (mthca_check_profile_value(&default_profile.fmr_reserved_mtts,
+                                      MTHCA_DEFAULT_NUM_RESERVED_MTTS)){
+			mthca_warn(mdev,"invalid fmr_reserved_mtts passed. changed to %d\n",
+                       default_profile.fmr_reserved_mtts); 
+		}
+		if (default_profile.fmr_reserved_mtts >= default_profile.num_mtt ) {
+			mthca_err(mdev,"Invalid fmr_reserved_mtts parameter" 
+                      "value (%d). Must be lower then num_mtt (%d)\n",
+				  default_profile.fmr_reserved_mtts,
+				  default_profile.num_mtt ); 
+			return -EINVAL;
+		}
+	}
+
+	return 0;
+}

  static int __devinit mthca_tune_pci(struct mthca_dev *mdev)
  {
@@ -1095,6 +1208,10 @@
  	if (err)
  		goto err_cmd;

+	err = mthca_validate_profile(mdev, &default_profile);
+	if (err)
+		goto err_cmd;
+
  	err = mthca_init_hca(mdev);
  	if (err)
  		goto err_cmd;




More information about the general mailing list