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

Moni Shoua monis at voltaire.com
Thu Dec 21 06:43:10 PST 2006


Roland Dreier wrote:
> OK, the patch below is what I ended up committing.  I am really not
> pleased with the patch you sent and expected me to include -- there
> are really obvious simple-to-fix things that it's just ridiculous for
> you to be sending, eg:
> 
>  > +MODULE_PARM_DESC(num_mpt, 
> 
> trailing whitespace -- please check that your patch applies with 'git
> apply --check --whitespace=error-all'
> 
>  > +		"maximum number of memory protection pable entries per HCA");
> 
> umm, 'pable'??
> 
> and plenty of other things...
> 
> For some reason I felt guilty about letting this patch hang for so
> long, and so I fixed it up, but after doing it this time, I'm not
> going to spend my time like that again.  I have plenty of work to do
> without cleaning up other people's messes...
> 
>     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 at voltaire.com>
>     Signed-off-by: Moni Shoua <monis at voltaire.com>
>     Signed-off-by: Roland Dreier <rolandd at cisco.com>
> 
> diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c
> index 0491ec7..711c1b8 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
>  
>  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 hca_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, hca_profile.num_qp, int, 0444);
> +MODULE_PARM_DESC(num_qp, "maximum number of QPs per HCA");
> +
> +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(num_cq, hca_profile.num_cq, int, 0444);
> +MODULE_PARM_DESC(num_cq, "maximum number of CQs per HCA");
> +
> +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_mpt, hca_profile.num_mpt, int, 0444);
> +MODULE_PARM_DESC(num_mpt,
> +		"maximum number of memory protection table entries per HCA");
> +
> +module_param_named(num_mtt, hca_profile.num_mtt, int, 0444);
> +MODULE_PARM_DESC(num_mtt,
> +		 "maximum number of memory translation table segments per HCA");
> +
> +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(fmr_reserved_mtts, hca_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 mthca_tune_pci(struct mthca_dev *mdev)
>  {
>  	int cap;
> @@ -303,7 +340,7 @@ static int mthca_init_tavor(struct mthca_dev *mdev)
>  		goto err_disable;
>  	}
>  
> -	profile = default_profile;
> +	profile = hca_profile;
>  	profile.num_uar   = dev_lim.uar_size / PAGE_SIZE;
>  	profile.uarc_size = 0;
>  	if (mdev->mthca_flags & MTHCA_FLAG_SRQ)
> @@ -621,7 +658,7 @@ static int mthca_init_arbel(struct mthca_dev *mdev)
>  		goto err_stop_fw;
>  	}
>  
> -	profile = default_profile;
> +	profile = hca_profile;
>  	profile.num_uar  = dev_lim.uar_size / PAGE_SIZE;
>  	profile.num_udav = 0;
>  	if (mdev->mthca_flags & MTHCA_FLAG_SRQ)
> @@ -1278,11 +1315,57 @@ static struct pci_driver mthca_driver = {
>  	.remove		= __devexit_p(mthca_remove_one)
>  };
>  
> +static void __init __mthca_check_profile_val(const char *name, 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);
> +
> +	if (old_pval != *pval) {
> +		printk(KERN_WARNING PFX "Invalid value %d for %s in module parameter.\n",
> +		       old_pval, name);
> +		printk(KERN_WARNING PFX "Corrected %s to %d.\n", name, *pval);
> +	}
> +}
> +
> +#define mthca_check_profile_val(name, default)				\
> +	__mthca_check_profile_val(#name, &hca_profile.name, default)
> +
> +static void __init mthca_validate_profile(void)
> +{
> +	mthca_check_profile_val(num_qp,            MTHCA_DEFAULT_NUM_QP);
> +	mthca_check_profile_val(rdb_per_qp,        MTHCA_DEFAULT_RDB_PER_QP);
> +	mthca_check_profile_val(num_cq,            MTHCA_DEFAULT_NUM_CQ);
> +	mthca_check_profile_val(num_mcg, 	   MTHCA_DEFAULT_NUM_MCG);
> +	mthca_check_profile_val(num_mpt, 	   MTHCA_DEFAULT_NUM_MPT);
> +	mthca_check_profile_val(num_mtt, 	   MTHCA_DEFAULT_NUM_MTT);
> +	mthca_check_profile_val(num_udav,          MTHCA_DEFAULT_NUM_UDAV);
> +	mthca_check_profile_val(fmr_reserved_mtts, MTHCA_DEFAULT_NUM_RESERVED_MTTS);
> +
> +	if (hca_profile.fmr_reserved_mtts >= hca_profile.num_mtt) {
> +		printk(KERN_WARNING PFX "Invalid fmr_reserved_mtts module parameter %d.\n",
> +		       hca_profile.fmr_reserved_mtts);
> +		printk(KERN_WARNING PFX "(Must be smaller than num_mtt %d)\n",
> +		       hca_profile.num_mtt);
> +		hca_profile.fmr_reserved_mtts = hca_profile.num_mtt / 2;
> +		printk(KERN_WARNING PFX "Corrected fmr_reserved_mtts to %d.\n",
> +		       hca_profile.fmr_reserved_mtts);
> +	}
> +}
> +
>  static int __init mthca_init(void)
>  {
>  	int ret;
>  
>  	mutex_init(&mthca_device_mutex);
> +
> +	mthca_validate_profile();
> +
>  	ret = mthca_catas_init();
>  	if (ret)
>  		return ret;
> 

OK.
Roland, 
Thanks for your help. 
I accepts the criticism and I hope to submit better patches next time.

 





More information about the general mailing list