[openib-general] [PATCH] IB/mthca: HCA profile module parameters

Moni Shoua monis at voltaire.com
Wed Nov 15 08:39:39 PST 2006


From: Leonid Arsh <leonida 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 |  104 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 101 insertions(+), 3 deletions(-)
--- mthca_main.c.orig	2006-11-14 22:07:58.000000000 -0500
+++ mthca_main.c	2006-11-15 09:42:30.151093815 -0500
@@ -80,9 +80,6 @@
 module_param(tune_pci, int, 0444);
 MODULE_PARM_DESC(tune_pci, "increase PCI burst from the default set by BIOS if nonzero");
 
-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,
@@ -96,6 +93,103 @@
 	.uarc_size	   = 1 << 18,	/* 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";
+
+#define is_power_of_2(x) (x>0 &&(x & (x - 1)))
+#define to_up_power_of_2(x) (x = roundup_pow_of_two(x))
+static int __devinit mthca_validate_profile(struct mthca_dev *mdev,
+					    struct mthca_profile *profile)
+{
+	if (!is_power_of_2(default_profile.num_qp)){
+		to_up_power_of_2(default_profile.num_qp);
+		mthca_warn(mdev, "num_qp rounded to power of 2 (%d).\n",
+			  default_profile.num_qp); 
+	}
+
+	if (!is_power_of_2(default_profile.rdb_per_qp)){
+		to_up_power_of_2(default_profile.rdb_per_qp);
+		mthca_warn(mdev, "rdb_per_qp rounded to power of 2 (%d)\n",
+			  default_profile.rdb_per_qp); 
+	}
+
+	if (!is_power_of_2(default_profile.num_cq)){
+		to_up_power_of_2(default_profile.num_cq);
+		mthca_warn(mdev, "num_cq rounded to power of 2 (%d)\n",
+			  default_profile.num_cq); 
+	}
+
+	if (!is_power_of_2(default_profile.num_mcg)){
+		to_up_power_of_2(default_profile.num_mcg);
+		mthca_warn(mdev, "num_mcg rounded to power of 2 (%d)\n",
+			  default_profile.num_mcg); 
+	}
+	if (!is_power_of_2(default_profile.num_mpt)){
+		to_up_power_of_2(default_profile.num_mpt);
+		mthca_warn(mdev, "num_mpt rounded to power of 2 (%d)\n",
+			  default_profile.num_mpt); 
+	}
+
+	if (!is_power_of_2(default_profile.num_mtt)){
+		to_up_power_of_2(default_profile.num_mtt);
+		mthca_warn(mdev, "num_mtt rounded to power of 2 (%d)\n",
+			  default_profile.num_mtt); 
+	}
+
+	if (mthca_is_memfree(mdev)) {
+		if (!is_power_of_2(default_profile.num_udav)){
+			to_up_power_of_2(default_profile.num_udav);
+			mthca_warn(mdev, "num_udav rounded to power of 2 (%d)\n",
+				  default_profile.num_udav); 
+		}
+
+		if (!is_power_of_2(default_profile.fmr_reserved_mtts)){
+			to_up_power_of_2(default_profile.fmr_reserved_mtts);
+			mthca_warn(mdev, "fmr_reserved_mtts rounded to power of 2 (%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)
 {
 	int cap;
@@ -1095,6 +1189,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