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

Moni Shoua monis at voltaire.com
Sun Dec 10 03:40:17 PST 2006


Hi,
This patch was sent a while ago and I'd like to repost it now.

thanks
MoniS


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 |  115 +++++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 104 insertions(+), 11 deletions(-)
diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c
index 47ea021..deb0289 100644
--- a/drivers/infiniband/hw/mthca/mthca_main.c
+++ b/drivers/infiniband/hw/mthca/mthca_main.c
@@ -82,21 +82,110 @@ MODULE_PARM_DESC(tune_pci, "increase PCI
 
 struct mutex mthca_device_mutex;
 
+#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 */
-};
+
+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
+		*pval = roundup_pow_of_two(old_pval);
+
+	return old_pval-*pval;
+}
+
+#define mthca_check_profile_and_warn(name, var, defval) \
+	if (mthca_check_profile_value(&var, defval)) \
+		mthca_warn(mdev, "invalid %s passed. changed to %d.\n", #name, var); 
+
+static int __devinit mthca_validate_profile(struct mthca_dev *mdev,
+                                            struct mthca_profile *profile)
+{
+
+	mthca_check_profile_and_warn(num_qp, default_profile.num_qp,
+						 MTHCA_DEFAULT_NUM_QP);
+	mthca_check_profile_and_warn(rdb_per_qp, default_profile.rdb_per_qp,
+						 MTHCA_DEFAULT_RDB_PER_QP);
+	mthca_check_profile_and_warn(num_cq, default_profile.num_cq,
+						 MTHCA_DEFAULT_NUM_CQ);
+	mthca_check_profile_and_warn(num_mcg, default_profile.num_mcg,
+						 MTHCA_DEFAULT_NUM_MCG);
+	mthca_check_profile_and_warn(num_mpt, default_profile.num_mpt,
+						 MTHCA_DEFAULT_NUM_MPT);
+	mthca_check_profile_and_warn(num_mtt, default_profile.num_mtt,
+						 MTHCA_DEFAULT_NUM_MTT);
+
+	if (!mthca_is_memfree(mdev)) {
+		mthca_check_profile_and_warn(num_udav, default_profile.num_udav,
+							 MTHCA_DEFAULT_NUM_UDAV);
+		mthca_check_profile_and_warn(fmr_reserved_mtts, default_profile.fmr_reserved_mtts,
+							 MTHCA_DEFAULT_NUM_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)
 {
@@ -1084,6 +1173,10 @@ static int __mthca_init_one(struct pci_d
 	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