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

Roland Dreier rdreier at cisco.com
Wed Nov 15 15:46:47 PST 2006


The patch is line-wrapped and bizarrely corrupted and won't apply, eg:

 > +		mthca_warn(mdev, "num_qp rounded to power of 2 (%d).\n",
 > +			  default_profile.num_qp); +	}

This is completely unnecessary:

 > +#define to_up_power_of_2(x) (x = roundup_pow_of_two(x))

...just open code this.

And this seems strange:

 > +#define is_power_of_2(x) (x>0 &&(x & (x - 1)))

so there's no warning if someone passes in a negative value??  and
it's backwards too, (x & (x - 1)) is 0 precisely for the powers of 2.
Was this patch tested at all?

Anyway, all this

 > +	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); +	}

seems very repetive.  Can't it be wrapped up in a function so we just
do something like

	mthca_check_profile_value(&default_profile.num_qp);
	mthca_check_profile_value(&default_profile.rdb_per_qp);
	mthca_check_profile_value(&default_profile.num_cq);

etc.

 - R.




More information about the general mailing list