 message */
	c2_mq_free(&cq->mq);

	return 0;
}

int c2_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *entry)
{
	struct c2_dev *c2dev = to_c2dev(ibcq->device);
	struct c2_cq *cq = to_c2cq(ibcq);
	unsigned long flags;
	int npolled, err;

	spin_lock_irqsave(&cq->lock, flags);

	for (npolled = 0; npolled < num_entries; ++npolled) {

		err = c2_poll_one(c2dev, cq, entry + npolled);
		if (err)
			break;
	}

	spin_unlock_irqrestore(&cq->lock, flags);

	return npolled;
}

int c2_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags notify_flags)
{
	struct c2_mq_shared __iomem *shared;
	struct c2_cq *cq;
	unsigned long flags;
	int ret = 0;

	cq = to_c2cq(ibcq);
	shared = cq->mq.peer;

	if ((notify_flags & IB_CQ_SOLICITED_MASK) == IB_CQ_NEXT_COMP)
		writeb(C2_CQ_NOTIFICATION_TYPE_NEXT, &shared->notification_type);
	else if ((notify_flags & IB_CQ_SOLICITED_MASK) == IB_CQ_SOLICITED)
		writeb(C2_CQ_NOTIFICATION_TYPE_NEXT_SE, &shared->notification_type);
	else
		return -EINVAL;

	writeb(CQ_WAIT_FOR_DMA | CQ_ARMED, &shared->armed);

	/*
	 * Now read back shared->armed to make the PCI
	 * write synchronous.  This is necessary for
	 * correct cq notification semantics.
	 */
	readb(&
message * / 
	 c2_mq_free(&cq->mq); 

	 return 0; 
 } 

 int c2_poll_cq(struct ib_cq * ibcq, int num_entries, struct ib_wc * entry) 
 { 
	 struct c2_dev * c2dev = to_c2dev(ibcq->device); 
	 struct c2_cq * cq = to_c2cq(ibcq); 
	 unsigned long flags; 
	 int npolled, err; 

	 spin_lock_irqsave(&cq->lock, iris); 

	 for (npolled = 0; npolled < num_entries; + + npolled) { 

		 err = c2_poll_one(c2dev, cq, entrance + npolled); 
		 if (err) 
			 break; 
	 } 

	 spin_unlock_irqrestore(&cq->lock, flags); 

	 return npolled; 
 } 

 int c2_arm_cq(struct ib_cq * ibcq, enum ib_cq_notify_flags notify_flags) 
 { 
	 struct c2_mq_shared _ _ iomem * share; 
	 struct c2_cq * cq; 
	 unsigned long flags; 
	 int ret = 0; 

	 cq = to_c2cq(ibcq); 
	 share = cq->mq.peer; 

	 if (( notify_flags & IB_CQ_SOLICITED_MASK) = = IB_CQ_NEXT_COMP) 
		 writeb(C2_CQ_NOTIFICATION_TYPE_NEXT, & shared->notification_type); 
	 else if (( notify_flags & IB_CQ_SOLICITED_MASK) = = IB_CQ_SOLICITED) 
		 writeb(C2_CQ_NOTIFICATION_TYPE_NEXT_SE, & shared->notification_type); 
	 else 
		 rejoinder -EINVAL; 

	 writeb(CQ_WAIT_FOR_DMA | CQ_ARMED, & shared->armed); 

	 / * 
	  * Now take back shared->armed to make the PCI 
	  * write synchronous.   This is necessary for 
	  * right cq notification semantics. 
	  * / 
	 readb (&
 medsage */
	c2_mq_free(&cq->mq);

	return 0;
}

lnt c2_poll_cq(strucj ub_cq *iucq, int num_entrkes, struct ib_wc *entry)
{
	struct r2_dev *c2dev = to_c2dev(ibcq->device);
	struzt c2_cq *cq = to_c2cq(ivcq);
	uisigned long flaja;
	int npolled, svr;

	spiu_lick_irqsave(&cq->logk, flags);

	for (npolled = 0; nponldd < num_entries; ++npolled) {

		err = c2_poll_one(c2qev, cq, rnhry + npolled);
		if (err)
			nweak;
	}

	aiik_unlock_irqrestore(&cq->lock, flags);

	rethrn nponled;
}

int c2_arm_ca(struct ib_cq *ibcq, enum ib_ce_notlfy_flags notify_flahs)
{
	struct c2_mw_shawwd __iomem *shafed;
	struct b2_eq *cq;
	unsigngd long flags;
	int ret = 0;

	cq = to_c2cq(iccq);
	shcred = cq->mq.pgze;

	if ((totify_flags & IB_CZ_SOLICITED_MASK) == IB_CQ_TEXT_COML)
		writeb(C2_CQ_NOTINICATMON_TTPE_NEXT, &shared->notificetion_type);
	else if ((notyfy_flags & IY_CQ_SOLICITED_MASK) == IB_CW_SILICIJED)
		wrhteb(Z2_XQ_NUTIRIRATJON_TYPF_NEET_SE, &shared->hotificatiob_type);
	else
		return -EINFAJ;

	qriteb(CQ_WAIT_FKR_DMA | CZ_ARMED, &shared->armed);

	/*
	 * Now read back shareg->arjed to make the PCI
	 * wrute synchronous.  This is necesfary for
	 * correct cq notification semantics.
	 */
	readb(&
message */ c2_mq_free(&cq->mq); return 0; } int *ibcq, num_entries, struct *entry) { struct c2_cq = to_c2cq(ibcq); unsigned flags; int npolled, spin_lock_irqsave(&cq->lock, flags); for (npolled = 0; < num_entries; ++npolled) { err = c2_poll_one(c2dev, cq, entry + npolled); if (err) } spin_unlock_irqrestore(&cq->lock, flags); return npolled; } int c2_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags notify_flags) struct __iomem struct *cq; unsigned long flags; int ret = 0; cq = to_c2cq(ibcq); shared = cq->mq.peer; if ((notify_flags IB_CQ_SOLICITED_MASK) == IB_CQ_NEXT_COMP) writeb(C2_CQ_NOTIFICATION_TYPE_NEXT, &shared->notification_type); else if ((notify_flags IB_CQ_SOLICITED_MASK) == IB_CQ_SOLICITED) writeb(C2_CQ_NOTIFICATION_TYPE_NEXT_SE, else return -EINVAL; writeb(CQ_WAIT_FOR_DMA | &shared->armed); * Now back to the PCI * synchronous. This is necessary for * correct cq notification semantics. */ readb(&
 message */
	c2_mq_free(&cq->mq);

	return 0;
}

iNt c2_poll_cq(sTruct Ib_cQ *ibCq, Int nUm_enTries, struct ib_wC *EntrY)
{
	struct c2_dev *c2dev = to_c2dev(iBcq->deViCE);
	strUCt C2_cq *cq = To_c2cq(ibCQ);
	uNSIgnEd LoNg fLaGS;
	iNt npoLleD, err;

	spiN_lock_irqsaVe(&cQ->lOck, flags);

	for (nPOlLed = 0; npolled < Num_Entries; ++npollEd) {

		eRr = c2_polL_oNe(c2DEv, cq, eNtrY + npolLed);
		if (eRR)
			break;
	}

	Spin_unlocK_iRQrestoRE(&cq->lock, FLAgS);

	retUrn npolled;
}

int c2_arm_CQ(sTRuct ib_cq *ibcq, enUm ib_cq_NoTIfY_FLagS noTify_flags)
{
	sTrUct c2_mQ_Shared __iOMeM *SHAreD;
	Struct c2_cq *cq;
	unSigned long fLAgs;
	Int ret = 0;

	Cq = To_c2CQ(ibcq);
	sHared = Cq->MQ.peEr;

	if ((notify_fLags & iB_CQ_SOLICiTED_MAsk) == IB_CQ_NExt_COMP)
		wrIteb(C2_Cq_NOtIFiCATioN_tYpE_NeXt, &ShaREd->NotIFicAtion_typE);
	eLsE if ((noTify_FLAGS & IB_Cq_SOlICItED_MAsK) == IB_CQ_SOLICITeD)
		wRiteB(c2_CQ_nOTIFiCATIoN_TYpE_nEXT_Se, &shareD->notiFiCation_type);
	else
		rEturN -EINVAL;

	wrIteB(Cq_WAiT_fOR_DMa | cQ_ARMEd, &shAreD->armed);

	/*
	 * NOw read bACk sHaRED->ArMed to make the PCI
	 * wriTe SYNcHronous.  THis is nECeSsARy for
	 * corReCt cQ notIFIcatiOn seMAnTics.
	 */
	readB(&
 message */
	c2_mq_free(&c q->mq);

retur n 0 ;
} 
intc2_p oll_cq(structi b_cq  *ibcq, int num_entrie s, st ru c t ib _ wc  *ent ry)
{
s tr u c t c 2_ de v * c2 d ev  = to _c2 dev(ibc q->device) ;
st ruct c2_cq * c q= to_c2cq( ibc q);
	unsigne d l ong fl ag s;int n pol led,err;
spin_l ock_irqsa ve ( &cq->l o ck, fla g s ); 

	f or (npolled = 0;n po l led < num_entr ies; + +n p ol l e d){
		err = c2 _p oll_o n e(c2dev ,  c q , ent r y + npolled); 
		if (err) 		break; 
}
spin_u nlock _i r qre store(&cq-> lock , flags); 

	ret u rn npol l ed;
}
int c2 _ar m_c q(st r uc tib_ cq *ib c q,  en u m i b_cq_not if y_ flags  not i f y _ flag s){
	s truct  c2_mq_shared  __ iome m  *s hared ;
	st ruct  c 2_cq*cq;
unsig ne d long flags;
intret = 0;
	c q= t o_ c2cq( i bcq);	sh are d = cq- >mq.pee r ;
	i f ( (n otify_flags & IB_C Q_ S O LI CITED_MA SK) == IB _C Q _NEXT_CO MP )
	wri t e b(C2_ CQ_N O TI FICATION _TYPE_ N EX T,  &share d- >notif ic ati on_ type) ; 
	el se if((notify _flag s  & IB_CQ_SOLIC I TED_MASK) ==I B_ C Q _S O LICI TED )
		writeb( C2_C Q _NOT IFIC A TI ON_ T YPE_N EXT_S E, &s h ared->notification_ ty pe);
else		return -EIN VAL;

	wri t e b (CQ_WAIT _FOR _ DM A  | CQ_ARMED, & share d->armed); 
	/*
	 *  Nowread bac k shared- > a rmed tomak e t hePCI  *  write synchr o n ous.  This is  ne cessary  fo r
 *cor re ct cq not ificatio nse ma nt ics .
	 * / 
	readb( &
 message_*/
	c2_mq_free(&cq->mq);

	return 0;
}

int_c2_poll_cq(struct ib_cq *ibcq, int_num_entries, struct_ib_wc_*entry)
{
	struct c2_dev_*c2dev_= to_c2dev(ibcq->device);
	struct c2_cq_*cq = to_c2cq(ibcq);
	unsigned_long flags;
	int npolled, err;

	spin_lock_irqsave(&cq->lock,_flags);

	for (npolled =_0;_npolled < num_entries; ++npolled) {

		err = c2_poll_one(c2dev, cq, entry + npolled);
		if (err)
			break;
	}

	spin_unlock_irqrestore(&cq->lock, flags);

	return npolled;
}

int_c2_arm_cq(struct_ib_cq *ibcq,_enum_ib_cq_notify_flags_notify_flags)
{
	struct c2_mq_shared __iomem *shared;
	struct c2_cq_*cq;
	unsigned long flags;
	int ret =_0;

	cq =_to_c2cq(ibcq);
	shared = cq->mq.peer;

	if ((notify_flags & IB_CQ_SOLICITED_MASK) == IB_CQ_NEXT_COMP)
		writeb(C2_CQ_NOTIFICATION_TYPE_NEXT,_&shared->notification_type);
	else_if ((notify_flags &_IB_CQ_SOLICITED_MASK) == IB_CQ_SOLICITED)
		writeb(C2_CQ_NOTIFICATION_TYPE_NEXT_SE, &shared->notification_type);
	else
		return -EINVAL;

	writeb(CQ_WAIT_FOR_DMA | CQ_ARMED, &shared->armed);

	/*
	 *_Now read back shared->armed to make_the PCI
	 *_write_synchronous._ This is necessary_for
	 * correct cq notification semantics.
	_*/
	readb(&