/* input: blade_id - blade on which resources should be reserved cbrs - number of CBRs dsr_bytes - number of DSR bytes needed output: handle to identify resource (0 = async resources already reserved)  */
unsigned long gru_reserve_async_resources(int blade_id, int cbrs, int dsr_bytes, struct completion *cmp)
/* input: blade_id - blade on which resources should be reserved cbrs - number of CBRs dsr_bytes - number of DSR bytes needed output: handle to identify resource (0 = async resources already reserved)  */
unsigned long gru_reserve_async_resources(int blade_id, int cbrs, int dsr_bytes, struct completion *cmp)
{
	struct gru_blade_state *bs;
	struct gru_thread_state *kgts;
	int ret = 0;
	bs = gru_base[blade_id];
	down_write(&bs->bs_kgts_sema);
	if (bs->bs_async_dsr_bytes + bs->bs_async_cbrs)
		goto done;
	bs->bs_async_dsr_bytes = dsr_bytes;
	bs->bs_async_cbrs = cbrs;
	bs->bs_async_wq = cmp;
	kgts = bs->bs_kgts;
	if (kgts && kgts->ts_gru)
		gru_unload_context(kgts, 0);
	ret = ASYNC_BID_TO_HAN(blade_id);
done:
	up_write(&bs->bs_kgts_sema);
	return ret;
}