Lines Matching +full:x +full:- +full:min
1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
47 * rvt_compute_aeth - compute the AETH (syndrome + MSN)
54 u32 aeth = qp->r_msn & IB_MSN_MASK; in rvt_compute_aeth()
56 if (qp->ibqp.srq) { in rvt_compute_aeth()
63 u32 min, max, x; in rvt_compute_aeth() local
68 credits = READ_ONCE(qp->r_rq.kwq->count); in rvt_compute_aeth()
71 if (qp->ip) { in rvt_compute_aeth()
72 head = RDMA_READ_UAPI_ATOMIC(qp->r_rq.wq->head); in rvt_compute_aeth()
73 tail = RDMA_READ_UAPI_ATOMIC(qp->r_rq.wq->tail); in rvt_compute_aeth()
75 head = READ_ONCE(qp->r_rq.kwq->head); in rvt_compute_aeth()
76 tail = READ_ONCE(qp->r_rq.kwq->tail); in rvt_compute_aeth()
78 if (head >= qp->r_rq.size) in rvt_compute_aeth()
80 if (tail >= qp->r_rq.size) in rvt_compute_aeth()
88 credits = rvt_get_rq_count(&qp->r_rq, head, tail); in rvt_compute_aeth()
94 min = 0; in rvt_compute_aeth()
97 x = (min + max) / 2; in rvt_compute_aeth()
98 if (credit_table[x] == credits) in rvt_compute_aeth()
100 if (credit_table[x] > credits) { in rvt_compute_aeth()
101 max = x; in rvt_compute_aeth()
103 if (min == x) in rvt_compute_aeth()
105 min = x; in rvt_compute_aeth()
108 aeth |= x << IB_AETH_CREDIT_SHIFT; in rvt_compute_aeth()
115 * rvt_get_credit - flush the send work queue of a QP
123 struct rvt_dev_info *rdi = ib_to_rvt(qp->ibqp.device); in rvt_get_credit()
126 lockdep_assert_held(&qp->s_lock); in rvt_get_credit()
133 if (!(qp->s_flags & RVT_S_UNLIMITED_CREDIT)) { in rvt_get_credit()
134 qp->s_flags |= RVT_S_UNLIMITED_CREDIT; in rvt_get_credit()
135 if (qp->s_flags & RVT_S_WAIT_SSN_CREDIT) { in rvt_get_credit()
136 qp->s_flags &= ~RVT_S_WAIT_SSN_CREDIT; in rvt_get_credit()
137 rdi->driver_f.schedule_send(qp); in rvt_get_credit()
140 } else if (!(qp->s_flags & RVT_S_UNLIMITED_CREDIT)) { in rvt_get_credit()
143 if (rvt_cmp_msn(credit, qp->s_lsn) > 0) { in rvt_get_credit()
144 qp->s_lsn = credit; in rvt_get_credit()
145 if (qp->s_flags & RVT_S_WAIT_SSN_CREDIT) { in rvt_get_credit()
146 qp->s_flags &= ~RVT_S_WAIT_SSN_CREDIT; in rvt_get_credit()
147 rdi->driver_f.schedule_send(qp); in rvt_get_credit()
155 * rvt_restart_sge - rewind the sge state for a wqe
164 ss->sge = wqe->sg_list[0]; in rvt_restart_sge()
165 ss->sg_list = wqe->sg_list + 1; in rvt_restart_sge()
166 ss->num_sge = wqe->wr.num_sge; in rvt_restart_sge()
167 ss->total_len = wqe->length; in rvt_restart_sge()
169 return wqe->length - len; in rvt_restart_sge()