diff options
author | Leonid Arsh <leonida@voltaire.com> | 2006-12-10 06:40:17 -0500 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2006-12-15 23:46:31 -0500 |
commit | 82da703ee685b69b921b20eb76b50e519ca9956c (patch) | |
tree | 16f5619d4358a7bae27d6c3b6d1f69d51205b982 /drivers | |
parent | bf628dc22a09ed2022abb32c76011ae5f99ad6b0 (diff) |
IB/mthca: Add HCA profile module parameters
Add module parameters that enable settting some of the HCA
profile values, such as the number of QPs, CQs, etc.
Signed-off-by: Leonid Arsh <leonida@voltaire.com>
Signed-off-by: Moni Shoua <monis@voltaire.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_main.c | 111 |
1 files changed, 97 insertions, 14 deletions
diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c index 0491ec7a7c0a..711c1b845f3f 100644 --- a/drivers/infiniband/hw/mthca/mthca_main.c +++ b/drivers/infiniband/hw/mthca/mthca_main.c | |||
@@ -82,22 +82,59 @@ MODULE_PARM_DESC(tune_pci, "increase PCI burst from the default set by BIOS if n | |||
82 | 82 | ||
83 | struct mutex mthca_device_mutex; | 83 | struct mutex mthca_device_mutex; |
84 | 84 | ||
85 | #define MTHCA_DEFAULT_NUM_QP (1 << 16) | ||
86 | #define MTHCA_DEFAULT_RDB_PER_QP (1 << 2) | ||
87 | #define MTHCA_DEFAULT_NUM_CQ (1 << 16) | ||
88 | #define MTHCA_DEFAULT_NUM_MCG (1 << 13) | ||
89 | #define MTHCA_DEFAULT_NUM_MPT (1 << 17) | ||
90 | #define MTHCA_DEFAULT_NUM_MTT (1 << 20) | ||
91 | #define MTHCA_DEFAULT_NUM_UDAV (1 << 15) | ||
92 | #define MTHCA_DEFAULT_NUM_RESERVED_MTTS (1 << 18) | ||
93 | #define MTHCA_DEFAULT_NUM_UARC_SIZE (1 << 18) | ||
94 | |||
95 | static struct mthca_profile hca_profile = { | ||
96 | .num_qp = MTHCA_DEFAULT_NUM_QP, | ||
97 | .rdb_per_qp = MTHCA_DEFAULT_RDB_PER_QP, | ||
98 | .num_cq = MTHCA_DEFAULT_NUM_CQ, | ||
99 | .num_mcg = MTHCA_DEFAULT_NUM_MCG, | ||
100 | .num_mpt = MTHCA_DEFAULT_NUM_MPT, | ||
101 | .num_mtt = MTHCA_DEFAULT_NUM_MTT, | ||
102 | .num_udav = MTHCA_DEFAULT_NUM_UDAV, /* Tavor only */ | ||
103 | .fmr_reserved_mtts = MTHCA_DEFAULT_NUM_RESERVED_MTTS, /* Tavor only */ | ||
104 | .uarc_size = MTHCA_DEFAULT_NUM_UARC_SIZE, /* Arbel only */ | ||
105 | }; | ||
106 | |||
107 | module_param_named(num_qp, hca_profile.num_qp, int, 0444); | ||
108 | MODULE_PARM_DESC(num_qp, "maximum number of QPs per HCA"); | ||
109 | |||
110 | module_param_named(rdb_per_qp, hca_profile.rdb_per_qp, int, 0444); | ||
111 | MODULE_PARM_DESC(rdb_per_qp, "number of RDB buffers per QP"); | ||
112 | |||
113 | module_param_named(num_cq, hca_profile.num_cq, int, 0444); | ||
114 | MODULE_PARM_DESC(num_cq, "maximum number of CQs per HCA"); | ||
115 | |||
116 | module_param_named(num_mcg, hca_profile.num_mcg, int, 0444); | ||
117 | MODULE_PARM_DESC(num_mcg, "maximum number of multicast groups per HCA"); | ||
118 | |||
119 | module_param_named(num_mpt, hca_profile.num_mpt, int, 0444); | ||
120 | MODULE_PARM_DESC(num_mpt, | ||
121 | "maximum number of memory protection table entries per HCA"); | ||
122 | |||
123 | module_param_named(num_mtt, hca_profile.num_mtt, int, 0444); | ||
124 | MODULE_PARM_DESC(num_mtt, | ||
125 | "maximum number of memory translation table segments per HCA"); | ||
126 | |||
127 | module_param_named(num_udav, hca_profile.num_udav, int, 0444); | ||
128 | MODULE_PARM_DESC(num_udav, "maximum number of UD address vectors per HCA"); | ||
129 | |||
130 | module_param_named(fmr_reserved_mtts, hca_profile.fmr_reserved_mtts, int, 0444); | ||
131 | MODULE_PARM_DESC(fmr_reserved_mtts, | ||
132 | "number of memory translation table segments reserved for FMR"); | ||
133 | |||
85 | static const char mthca_version[] __devinitdata = | 134 | static const char mthca_version[] __devinitdata = |
86 | DRV_NAME ": Mellanox InfiniBand HCA driver v" | 135 | DRV_NAME ": Mellanox InfiniBand HCA driver v" |
87 | DRV_VERSION " (" DRV_RELDATE ")\n"; | 136 | DRV_VERSION " (" DRV_RELDATE ")\n"; |
88 | 137 | ||
89 | static struct mthca_profile default_profile = { | ||
90 | .num_qp = 1 << 16, | ||
91 | .rdb_per_qp = 4, | ||
92 | .num_cq = 1 << 16, | ||
93 | .num_mcg = 1 << 13, | ||
94 | .num_mpt = 1 << 17, | ||
95 | .num_mtt = 1 << 20, | ||
96 | .num_udav = 1 << 15, /* Tavor only */ | ||
97 | .fmr_reserved_mtts = 1 << 18, /* Tavor only */ | ||
98 | .uarc_size = 1 << 18, /* Arbel only */ | ||
99 | }; | ||
100 | |||
101 | static int mthca_tune_pci(struct mthca_dev *mdev) | 138 | static int mthca_tune_pci(struct mthca_dev *mdev) |
102 | { | 139 | { |
103 | int cap; | 140 | int cap; |
@@ -303,7 +340,7 @@ static int mthca_init_tavor(struct mthca_dev *mdev) | |||
303 | goto err_disable; | 340 | goto err_disable; |
304 | } | 341 | } |
305 | 342 | ||
306 | profile = default_profile; | 343 | profile = hca_profile; |
307 | profile.num_uar = dev_lim.uar_size / PAGE_SIZE; | 344 | profile.num_uar = dev_lim.uar_size / PAGE_SIZE; |
308 | profile.uarc_size = 0; | 345 | profile.uarc_size = 0; |
309 | if (mdev->mthca_flags & MTHCA_FLAG_SRQ) | 346 | if (mdev->mthca_flags & MTHCA_FLAG_SRQ) |
@@ -621,7 +658,7 @@ static int mthca_init_arbel(struct mthca_dev *mdev) | |||
621 | goto err_stop_fw; | 658 | goto err_stop_fw; |
622 | } | 659 | } |
623 | 660 | ||
624 | profile = default_profile; | 661 | profile = hca_profile; |
625 | profile.num_uar = dev_lim.uar_size / PAGE_SIZE; | 662 | profile.num_uar = dev_lim.uar_size / PAGE_SIZE; |
626 | profile.num_udav = 0; | 663 | profile.num_udav = 0; |
627 | if (mdev->mthca_flags & MTHCA_FLAG_SRQ) | 664 | if (mdev->mthca_flags & MTHCA_FLAG_SRQ) |
@@ -1278,11 +1315,57 @@ static struct pci_driver mthca_driver = { | |||
1278 | .remove = __devexit_p(mthca_remove_one) | 1315 | .remove = __devexit_p(mthca_remove_one) |
1279 | }; | 1316 | }; |
1280 | 1317 | ||
1318 | static void __init __mthca_check_profile_val(const char *name, int *pval, | ||
1319 | int pval_default) | ||
1320 | { | ||
1321 | /* value must be positive and power of 2 */ | ||
1322 | int old_pval = *pval; | ||
1323 | |||
1324 | if (old_pval <= 0) | ||
1325 | *pval = pval_default; | ||
1326 | else | ||
1327 | *pval = roundup_pow_of_two(old_pval); | ||
1328 | |||
1329 | if (old_pval != *pval) { | ||
1330 | printk(KERN_WARNING PFX "Invalid value %d for %s in module parameter.\n", | ||
1331 | old_pval, name); | ||
1332 | printk(KERN_WARNING PFX "Corrected %s to %d.\n", name, *pval); | ||
1333 | } | ||
1334 | } | ||
1335 | |||
1336 | #define mthca_check_profile_val(name, default) \ | ||
1337 | __mthca_check_profile_val(#name, &hca_profile.name, default) | ||
1338 | |||
1339 | static void __init mthca_validate_profile(void) | ||
1340 | { | ||
1341 | mthca_check_profile_val(num_qp, MTHCA_DEFAULT_NUM_QP); | ||
1342 | mthca_check_profile_val(rdb_per_qp, MTHCA_DEFAULT_RDB_PER_QP); | ||
1343 | mthca_check_profile_val(num_cq, MTHCA_DEFAULT_NUM_CQ); | ||
1344 | mthca_check_profile_val(num_mcg, MTHCA_DEFAULT_NUM_MCG); | ||
1345 | mthca_check_profile_val(num_mpt, MTHCA_DEFAULT_NUM_MPT); | ||
1346 | mthca_check_profile_val(num_mtt, MTHCA_DEFAULT_NUM_MTT); | ||
1347 | mthca_check_profile_val(num_udav, MTHCA_DEFAULT_NUM_UDAV); | ||
1348 | mthca_check_profile_val(fmr_reserved_mtts, MTHCA_DEFAULT_NUM_RESERVED_MTTS); | ||
1349 | |||
1350 | if (hca_profile.fmr_reserved_mtts >= hca_profile.num_mtt) { | ||
1351 | printk(KERN_WARNING PFX "Invalid fmr_reserved_mtts module parameter %d.\n", | ||
1352 | hca_profile.fmr_reserved_mtts); | ||
1353 | printk(KERN_WARNING PFX "(Must be smaller than num_mtt %d)\n", | ||
1354 | hca_profile.num_mtt); | ||
1355 | hca_profile.fmr_reserved_mtts = hca_profile.num_mtt / 2; | ||
1356 | printk(KERN_WARNING PFX "Corrected fmr_reserved_mtts to %d.\n", | ||
1357 | hca_profile.fmr_reserved_mtts); | ||
1358 | } | ||
1359 | } | ||
1360 | |||
1281 | static int __init mthca_init(void) | 1361 | static int __init mthca_init(void) |
1282 | { | 1362 | { |
1283 | int ret; | 1363 | int ret; |
1284 | 1364 | ||
1285 | mutex_init(&mthca_device_mutex); | 1365 | mutex_init(&mthca_device_mutex); |
1366 | |||
1367 | mthca_validate_profile(); | ||
1368 | |||
1286 | ret = mthca_catas_init(); | 1369 | ret = mthca_catas_init(); |
1287 | if (ret) | 1370 | if (ret) |
1288 | return ret; | 1371 | return ret; |