[ofa-general] [PATCH] ib_mthca: use log values instead of numeric values when specifiying HCA resource maxes in module parameters

Jack Morgenstein jackm at dev.mellanox.co.il
Tue Apr 29 08:22:57 PDT 2008


ib_mthca: change all HCA resource module parameters to be log values.

Module parameters for overriding driver default maximum HCA resource
quantities should be log values, not numeric values -- since these
quantities should all be powers-of-2 anyway.

Signed-off-by: Jack Morgenstein <jackm at dev.mellanox.co.il>

---

Roland,
This is for kernel 2.6.26. (I generated it against your for-2.6.26 git tree).

I put a check in the patch for detecting if the user specified a log or not,
to make the transition from the old method (of numbers instead of logs)
easier.

Maybe add such a check to the mlx4 version, too?

Jack

index 9ebadd6..c9f9bbe 100644
--- a/drivers/infiniband/hw/mthca/mthca_main.c
+++ b/drivers/infiniband/hw/mthca/mthca_main.c
@@ -99,37 +99,88 @@ static struct mthca_profile hca_profile = {
 	.uarc_size          = MTHCA_DEFAULT_NUM_UARC_SIZE,     /* Arbel only */
 };
 
-module_param_named(num_qp, hca_profile.num_qp, int, 0444);
-MODULE_PARM_DESC(num_qp, "maximum number of QPs per HCA");
+static struct mthca_profile mod_param_profile = { 0 };
+module_param_named(num_qp, mod_param_profile.num_qp, int, 0444);
+MODULE_PARM_DESC(num_qp, "log maximum number of QPs per HCA (default 16)");
 
-module_param_named(rdb_per_qp, hca_profile.rdb_per_qp, int, 0444);
-MODULE_PARM_DESC(rdb_per_qp, "number of RDB buffers per QP");
+module_param_named(rdb_per_qp, mod_param_profile.rdb_per_qp, int, 0444);
+MODULE_PARM_DESC(rdb_per_qp, "log number of RDB buffers per QP (default 2)");
 
-module_param_named(num_cq, hca_profile.num_cq, int, 0444);
-MODULE_PARM_DESC(num_cq, "maximum number of CQs per HCA");
+module_param_named(num_cq, mod_param_profile.num_cq, int, 0444);
+MODULE_PARM_DESC(num_cq, "log maximum number of CQs per HCA (default 16)");
 
-module_param_named(num_mcg, hca_profile.num_mcg, int, 0444);
-MODULE_PARM_DESC(num_mcg, "maximum number of multicast groups per HCA");
+module_param_named(num_mcg, mod_param_profile.num_mcg, int, 0444);
+MODULE_PARM_DESC(num_mcg, "log maximum number of multicast groups per HCA"
+		 " (default 13)");
 
-module_param_named(num_mpt, hca_profile.num_mpt, int, 0444);
+module_param_named(num_mpt, mod_param_profile.num_mpt, int, 0444);
 MODULE_PARM_DESC(num_mpt,
-		"maximum number of memory protection table entries per HCA");
+		 "log maximum number of memory protection table entries per HCA"
+		 " (default 17)");
 
-module_param_named(num_mtt, hca_profile.num_mtt, int, 0444);
+module_param_named(num_mtt, mod_param_profile.num_mtt, int, 0444);
 MODULE_PARM_DESC(num_mtt,
-		 "maximum number of memory translation table segments per HCA");
+		 "log maximum number of memory translation table segments per"
+		 " HCA (default 20)");
 
-module_param_named(num_udav, hca_profile.num_udav, int, 0444);
-MODULE_PARM_DESC(num_udav, "maximum number of UD address vectors per HCA");
+module_param_named(num_udav, mod_param_profile.num_udav, int, 0444);
+MODULE_PARM_DESC(num_udav, "log maximum number of UD address vectors per HCA"
+		 " (default 15)");
 
-module_param_named(fmr_reserved_mtts, hca_profile.fmr_reserved_mtts, int, 0444);
+module_param_named(fmr_reserved_mtts, mod_param_profile.fmr_reserved_mtts,
+		   int, 0444);
 MODULE_PARM_DESC(fmr_reserved_mtts,
-		 "number of memory translation table segments reserved for FMR");
+		 "log number of memory translation table segments reserved for"
+		 " FMR (default 18)");
 
 static char mthca_version[] __devinitdata =
 	DRV_NAME ": Mellanox InfiniBand HCA driver v"
 	DRV_VERSION " (" DRV_RELDATE ")\n";
 
+static void process_mod_param_profile(void)
+{
+	if (mod_param_profile.num_qp > 31 	||
+	    mod_param_profile.rdb_per_qp > 31	||
+	    mod_param_profile.num_cq > 31 	||
+	    mod_param_profile.num_mcg > 31 	||
+	    mod_param_profile.num_mpt > 31 	||
+	    mod_param_profile.num_mtt > 31 	||
+	    mod_param_profile.num_udav > 31 	||
+	    mod_param_profile.fmr_reserved_mtts > 31) {
+		printk(KERN_WARNING PFX "Value of one or more HCA resource"
+		       " module parameters exceeds 31.\n");
+		printk(KERN_WARNING PFX "Are you specifying LOG values?\n");
+		printk(KERN_WARNING PFX "Reverting to using max default values"
+		       " for all HCA resources.\n");
+		return;
+	}
+
+	hca_profile.num_qp = (mod_param_profile.num_qp ?
+			      1 << mod_param_profile.num_qp :
+			      hca_profile.num_qp);		 
+	hca_profile.rdb_per_qp = (mod_param_profile.rdb_per_qp ?
+			      1 << mod_param_profile.rdb_per_qp :
+			      hca_profile.rdb_per_qp);
+	hca_profile.num_cq = (mod_param_profile.num_cq ?
+			      1 << mod_param_profile.num_cq :
+			      hca_profile.num_cq);
+	hca_profile.num_mcg = (mod_param_profile.num_mcg ?
+			      1 << mod_param_profile.num_mcg :
+			      hca_profile.num_mcg);
+	hca_profile.num_mpt = (mod_param_profile.num_mpt ?
+			      1 << mod_param_profile.num_mpt :
+			      hca_profile.num_mpt);
+	hca_profile.num_mtt = (mod_param_profile.num_mtt ?
+			      1 << mod_param_profile.num_mtt :
+			      hca_profile.num_mtt);
+	hca_profile.num_udav = (mod_param_profile.num_udav ?
+			      1 << mod_param_profile.num_udav :
+			      hca_profile.num_udav);
+	hca_profile.fmr_reserved_mtts = (mod_param_profile.fmr_reserved_mtts ?
+			      1 << mod_param_profile.fmr_reserved_mtts :
+			      hca_profile.fmr_reserved_mtts);
+}
+
 static int mthca_tune_pci(struct mthca_dev *mdev)
 {
 	if (!tune_pci)
@@ -1364,6 +1415,7 @@ static int __init mthca_init(void)
 {
 	int ret;
 
+	process_mod_param_profile();
 	mthca_validate_profile();
 
 	ret = mthca_catas_init();



More information about the general mailing list