FreeBSD/contrib/ofed/libcxgb4/src/cq.c
/*
 * Move all CQEs from the HWCQ into the SWCQ.
 * Deal with out-of-order and/or completions that complete
 * prior unsignalled WRs.
 */
Move all CQEs from the HWCQ into the SWCQ.
Deal with out-of-order and/or completions that complete
prior unsignalled WRs.
Move all CQEs from the HWCQ into the SWCQ . Deal with out - of - order and / or completions that complete prior unsignalled WRs .
void c4iw_flush_hw_cq(struct c4iw_cq *chp)
{
	struct t4_cqe *hw_cqe, *swcqe, read_cqe;
	struct c4iw_qp *qhp;
	struct t4_swsqe *swsqe;
	int ret;
	PDBG("%s  cqid 0x%x\n", __func__, chp->cq.cqid);
	ret = t4_next_hw_cqe(&chp->cq, &hw_cqe);
	while (!ret) {
		qhp = get_qhp(chp->rhp, CQE_QPID(hw_cqe));
		if (qhp == NULL)
			goto next_cqe;
		if (CQE_OPCODE(hw_cqe) == FW_RI_TERMINATE)
			goto next_cqe;
		if (CQE_OPCODE(hw_cqe) == FW_RI_READ_RESP) {
			if (CQE_TYPE(hw_cqe) == 1) {
				syslog(LOG_CRIT, "%s: got egress error in \
					read-response, dropping!\n", __func__);
				goto next_cqe;
			}
			if (CQE_WRID_STAG(hw_cqe) == 1)
				goto next_cqe;
			if (!qhp->wq.sq.oldest_read->signaled) {
				advance_oldest_read(&qhp->wq);
				goto next_cqe;
			}
			create_read_req_cqe(&qhp->wq, hw_cqe, &read_cqe);
			hw_cqe = &read_cqe;
			advance_oldest_read(&qhp->wq);
		}
		if (SQ_TYPE(hw_cqe)) {
			int idx = CQE_WRID_SQ_IDX(hw_cqe);
			BUG_ON(idx >= qhp->wq.sq.size);
			swsqe = &qhp->wq.sq.sw_sq[idx];
			swsqe->cqe = *hw_cqe;
			swsqe->complete = 1;
			flush_completed_wrs(&qhp->wq, &chp->cq);
		} else {
			swcqe = &chp->cq.sw_queue[chp->cq.sw_pidx];
			*swcqe = *hw_cqe;
			swcqe->header |= cpu_to_be32(V_CQE_SWCQE(1));
			t4_swcq_produce(&chp->cq);
		}
next_cqe:
		t4_hwcq_consume(&chp->cq);
		ret = t4_next_hw_cqe(&chp->cq, &hw_cqe);
	}
}
void c4iw_flush_hw_cq ( struct c4iw_cq * chp ) { struct t4_cqe * hw_cqe , * swcqe , read_cqe ; struct c4iw_qp * qhp ; struct t4_swsqe * swsqe ; int ret ; PDBG ( " \n " , __func__ , chp -> cq . cqid ) ; ret = t4_next_hw_cqe ( & chp -> cq , & hw_cqe ) ; while ( ! ret ) { qhp = get_qhp ( chp -> rhp , CQE_QPID ( hw_cqe ) ) ; if ( qhp == NULL ) goto next_cqe ; if ( CQE_OPCODE ( hw_cqe ) == FW_RI_TERMINATE ) goto next_cqe ; if ( CQE_OPCODE ( hw_cqe ) == FW_RI_READ_RESP ) { if ( CQE_TYPE ( hw_cqe ) == 1 ) { syslog ( LOG_CRIT , " \
 \n " , __func__ ) ; goto next_cqe ; } if ( CQE_WRID_STAG ( hw_cqe ) == 1 ) goto next_cqe ; if ( ! qhp -> wq . sq . oldest_read -> signaled ) { advance_oldest_read ( & qhp -> wq ) ; goto next_cqe ; } create_read_req_cqe ( & qhp -> wq , hw_cqe , & read_cqe ) ; hw_cqe = & read_cqe ; advance_oldest_read ( & qhp -> wq ) ; } if ( SQ_TYPE ( hw_cqe ) ) { int idx = CQE_WRID_SQ_IDX ( hw_cqe ) ; BUG_ON ( idx >= qhp -> wq . sq . size ) ; swsqe = & qhp -> wq . sq . sw_sq [ idx ] ; swsqe -> cqe = * hw_cqe ; swsqe -> complete = 1 ; flush_completed_wrs ( & qhp -> wq , & chp -> cq ) ; } else { swcqe = & chp -> cq . sw_queue [ chp -> cq . sw_pidx ] ; * swcqe = * hw_cqe ; swcqe -> header |= cpu_to_be32 ( V_CQE_SWCQE ( 1 ) ) ; t4_swcq_produce ( & chp -> cq ) ; } next_cqe : t4_hwcq_consume ( & chp -> cq ) ; ret = t4_next_hw_cqe ( & chp -> cq , & hw_cqe ) ; } }
Move all CQEs from the HWCQ into the SWCQ.
Move all CQEs from the HWCQ into the SWCQ .
/*
	 * This logic is similar to poll_cq(), but not quite the same
	 * unfortunately.  Need to move pertinent HW CQEs to the SW CQ but
	 * also do any translation magic that poll_cq() normally does.
	 */ /*
		 * drop CQEs with no associated QP
		 */ /*
			 * If we have reached here because of async
			 * event or other error, and have egress error
			 * then drop
			 */ /*
			 * drop peer2peer RTR reads.
			 */ /*
			 * Eat completions for unsignaled read WRs.
			 */ /*
			 * Don't write to the HWCQ, create a new read req CQE
			 * in local memory and move it into the swcq.
			 */ /* if its a SQ completion, then do the magic to move all the
		 * unsignaled and now in-order completions into the swcq.
		 */