/* bfa_ioim_api Allocate IOIM resource for initiator mode I/O request.  */
struct bfa_ioim_s* bfa_ioim_alloc(struct bfa_s *bfa, struct bfad_ioim_s *dio, struct bfa_itnim_s *itnim, u16 nsges)
/* bfa_ioim_api Allocate IOIM resource for initiator mode I/O request.  */
struct bfa_ioim_s* bfa_ioim_alloc(struct bfa_s *bfa, struct bfad_ioim_s *dio, struct bfa_itnim_s *itnim, u16 nsges)
{
	struct bfa_fcpim_mod_s *fcpim = BFA_FCPIM_MOD(bfa);
	struct bfa_ioim_s *ioim;
	bfa_q_deq(&fcpim->ioim_free_q, &ioim);
	if (!ioim) {
		bfa_fcpim_stats(fcpim, no_iotags);
		return NULL;
	}
	ioim->dio = dio;
	ioim->itnim = itnim;
	ioim->nsges = nsges;
	ioim->nsgpgs = 0;
	bfa_stats(fcpim, total_ios);
	bfa_stats(itnim, ios);
	fcpim->ios_active++;
	list_add_tail(&ioim->qe, &itnim->io_q);
	bfa_trc_fp(ioim->bfa, ioim->iotag);
	return ioim;
}