RDMA/rxe: Make the tasklet exits the same

Make changes to the three tasklets so that the exit logic from each is the
same. This makes the code easier to understand.

Link: https://lore.kernel.org/r/20220630190425.2251-8-rpearsonhpe@gmail.com
Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
This commit is contained in:
Bob Pearson 2022-06-30 14:04:24 -05:00 коммит произвёл Jason Gunthorpe
Родитель 445fd4f4fb
Коммит 8bb143c534
3 изменённых файлов: 60 добавлений и 46 удалений

Просмотреть файл

@ -562,7 +562,7 @@ int rxe_completer(void *arg)
struct sk_buff *skb = NULL; struct sk_buff *skb = NULL;
struct rxe_pkt_info *pkt = NULL; struct rxe_pkt_info *pkt = NULL;
enum comp_state state; enum comp_state state;
int ret = 0; int ret;
if (!rxe_get(qp)) if (!rxe_get(qp))
return -EAGAIN; return -EAGAIN;
@ -571,8 +571,7 @@ int rxe_completer(void *arg)
qp->req.state == QP_STATE_RESET) { qp->req.state == QP_STATE_RESET) {
rxe_drain_resp_pkts(qp, qp->valid && rxe_drain_resp_pkts(qp, qp->valid &&
qp->req.state == QP_STATE_ERROR); qp->req.state == QP_STATE_ERROR);
ret = -EAGAIN; goto exit;
goto done;
} }
if (qp->comp.timeout) { if (qp->comp.timeout) {
@ -582,10 +581,8 @@ int rxe_completer(void *arg)
qp->comp.timeout_retry = 0; qp->comp.timeout_retry = 0;
} }
if (qp->req.need_retry) { if (qp->req.need_retry)
ret = -EAGAIN; goto exit;
goto done;
}
state = COMPST_GET_ACK; state = COMPST_GET_ACK;
@ -678,8 +675,7 @@ int rxe_completer(void *arg)
qp->qp_timeout_jiffies) qp->qp_timeout_jiffies)
mod_timer(&qp->retrans_timer, mod_timer(&qp->retrans_timer,
jiffies + qp->qp_timeout_jiffies); jiffies + qp->qp_timeout_jiffies);
ret = -EAGAIN; goto exit;
goto done;
case COMPST_ERROR_RETRY: case COMPST_ERROR_RETRY:
/* we come here if the retry timer fired and we did /* we come here if the retry timer fired and we did
@ -691,10 +687,8 @@ int rxe_completer(void *arg)
*/ */
/* there is nothing to retry in this case */ /* there is nothing to retry in this case */
if (!wqe || (wqe->state == wqe_state_posted)) { if (!wqe || (wqe->state == wqe_state_posted))
ret = -EAGAIN; goto exit;
goto done;
}
/* if we've started a retry, don't start another /* if we've started a retry, don't start another
* retry sequence, unless this is a timeout. * retry sequence, unless this is a timeout.
@ -746,8 +740,7 @@ int rxe_completer(void *arg)
mod_timer(&qp->rnr_nak_timer, mod_timer(&qp->rnr_nak_timer,
jiffies + rnrnak_jiffies(aeth_syn(pkt) jiffies + rnrnak_jiffies(aeth_syn(pkt)
& ~AETH_TYPE_MASK)); & ~AETH_TYPE_MASK));
ret = -EAGAIN; goto exit;
goto done;
} else { } else {
rxe_counter_inc(rxe, rxe_counter_inc(rxe,
RXE_CNT_RNR_RETRY_EXCEEDED); RXE_CNT_RNR_RETRY_EXCEEDED);
@ -760,12 +753,20 @@ int rxe_completer(void *arg)
WARN_ON_ONCE(wqe->status == IB_WC_SUCCESS); WARN_ON_ONCE(wqe->status == IB_WC_SUCCESS);
do_complete(qp, wqe); do_complete(qp, wqe);
rxe_qp_error(qp); rxe_qp_error(qp);
ret = -EAGAIN; goto exit;
goto done;
} }
} }
/* A non-zero return value will cause rxe_do_task to
* exit its loop and end the tasklet. A zero return
* will continue looping and return to rxe_completer
*/
done: done:
ret = 0;
goto out;
exit:
ret = -EAGAIN;
out:
if (pkt) if (pkt)
free_pkt(pkt); free_pkt(pkt);
rxe_put(qp); rxe_put(qp);

Просмотреть файл

@ -624,6 +624,7 @@ int rxe_requester(void *arg)
u32 payload; u32 payload;
int mtu; int mtu;
int opcode; int opcode;
int err;
int ret; int ret;
struct rxe_send_wqe rollback_wqe; struct rxe_send_wqe rollback_wqe;
u32 rollback_psn; u32 rollback_psn;
@ -634,7 +635,6 @@ int rxe_requester(void *arg)
if (!rxe_get(qp)) if (!rxe_get(qp))
return -EAGAIN; return -EAGAIN;
next_wqe:
if (unlikely(!qp->valid || qp->req.state == QP_STATE_ERROR)) if (unlikely(!qp->valid || qp->req.state == QP_STATE_ERROR))
goto exit; goto exit;
@ -649,7 +649,7 @@ next_wqe:
goto exit; goto exit;
} }
/* we come here if the retransmot timer has fired /* we come here if the retransmit timer has fired
* or if the rnr timer has fired. If the retransmit * or if the rnr timer has fired. If the retransmit
* timer fires while we are processing an RNR NAK wait * timer fires while we are processing an RNR NAK wait
* until the rnr timer has fired before starting the * until the rnr timer has fired before starting the
@ -670,11 +670,11 @@ next_wqe:
} }
if (wqe->mask & WR_LOCAL_OP_MASK) { if (wqe->mask & WR_LOCAL_OP_MASK) {
ret = rxe_do_local_ops(qp, wqe); err = rxe_do_local_ops(qp, wqe);
if (unlikely(ret)) if (unlikely(err))
goto err; goto err;
else else
goto next_wqe; goto done;
} }
if (unlikely(qp_type(qp) == IB_QPT_RC && if (unlikely(qp_type(qp) == IB_QPT_RC &&
@ -723,8 +723,7 @@ next_wqe:
wqe->state = wqe_state_done; wqe->state = wqe_state_done;
wqe->status = IB_WC_SUCCESS; wqe->status = IB_WC_SUCCESS;
__rxe_do_task(&qp->comp.task); __rxe_do_task(&qp->comp.task);
rxe_put(qp); goto done;
return 0;
} }
payload = mtu; payload = mtu;
} }
@ -740,25 +739,29 @@ next_wqe:
if (unlikely(!av)) { if (unlikely(!av)) {
pr_err("qp#%d Failed no address vector\n", qp_num(qp)); pr_err("qp#%d Failed no address vector\n", qp_num(qp));
wqe->status = IB_WC_LOC_QP_OP_ERR; wqe->status = IB_WC_LOC_QP_OP_ERR;
goto err_drop_ah; goto err;
} }
skb = init_req_packet(qp, av, wqe, opcode, payload, &pkt); skb = init_req_packet(qp, av, wqe, opcode, payload, &pkt);
if (unlikely(!skb)) { if (unlikely(!skb)) {
pr_err("qp#%d Failed allocating skb\n", qp_num(qp)); pr_err("qp#%d Failed allocating skb\n", qp_num(qp));
wqe->status = IB_WC_LOC_QP_OP_ERR; wqe->status = IB_WC_LOC_QP_OP_ERR;
goto err_drop_ah; if (ah)
rxe_put(ah);
goto err;
} }
ret = finish_packet(qp, av, wqe, &pkt, skb, payload); err = finish_packet(qp, av, wqe, &pkt, skb, payload);
if (unlikely(ret)) { if (unlikely(err)) {
pr_debug("qp#%d Error during finish packet\n", qp_num(qp)); pr_debug("qp#%d Error during finish packet\n", qp_num(qp));
if (ret == -EFAULT) if (err == -EFAULT)
wqe->status = IB_WC_LOC_PROT_ERR; wqe->status = IB_WC_LOC_PROT_ERR;
else else
wqe->status = IB_WC_LOC_QP_OP_ERR; wqe->status = IB_WC_LOC_QP_OP_ERR;
kfree_skb(skb); kfree_skb(skb);
goto err_drop_ah; if (ah)
rxe_put(ah);
goto err;
} }
if (ah) if (ah)
@ -773,13 +776,14 @@ next_wqe:
save_state(wqe, qp, &rollback_wqe, &rollback_psn); save_state(wqe, qp, &rollback_wqe, &rollback_psn);
update_wqe_state(qp, wqe, &pkt); update_wqe_state(qp, wqe, &pkt);
update_wqe_psn(qp, wqe, &pkt, payload); update_wqe_psn(qp, wqe, &pkt, payload);
ret = rxe_xmit_packet(qp, &pkt, skb);
if (ret) { err = rxe_xmit_packet(qp, &pkt, skb);
if (err) {
qp->need_req_skb = 1; qp->need_req_skb = 1;
rollback_state(wqe, qp, &rollback_wqe, rollback_psn); rollback_state(wqe, qp, &rollback_wqe, rollback_psn);
if (ret == -EAGAIN) { if (err == -EAGAIN) {
rxe_run_task(&qp->req.task, 1); rxe_run_task(&qp->req.task, 1);
goto exit; goto exit;
} }
@ -790,16 +794,20 @@ next_wqe:
update_state(qp, &pkt); update_state(qp, &pkt);
goto next_wqe; /* A non-zero return value will cause rxe_do_task to
* exit its loop and end the tasklet. A zero return
err_drop_ah: * will continue looping and return to rxe_requester
if (ah) */
rxe_put(ah); done:
ret = 0;
goto out;
err: err:
wqe->state = wqe_state_error; wqe->state = wqe_state_error;
__rxe_do_task(&qp->comp.task); __rxe_do_task(&qp->comp.task);
exit: exit:
ret = -EAGAIN;
out:
rxe_put(qp); rxe_put(qp);
return -EAGAIN;
return ret;
} }

Просмотреть файл

@ -1276,17 +1276,15 @@ int rxe_responder(void *arg)
struct rxe_dev *rxe = to_rdev(qp->ibqp.device); struct rxe_dev *rxe = to_rdev(qp->ibqp.device);
enum resp_states state; enum resp_states state;
struct rxe_pkt_info *pkt = NULL; struct rxe_pkt_info *pkt = NULL;
int ret = 0; int ret;
if (!rxe_get(qp)) if (!rxe_get(qp))
return -EAGAIN; return -EAGAIN;
qp->resp.aeth_syndrome = AETH_ACK_UNLIMITED; qp->resp.aeth_syndrome = AETH_ACK_UNLIMITED;
if (!qp->valid) { if (!qp->valid)
ret = -EINVAL; goto exit;
goto done;
}
switch (qp->resp.state) { switch (qp->resp.state) {
case QP_STATE_RESET: case QP_STATE_RESET:
@ -1466,9 +1464,16 @@ int rxe_responder(void *arg)
} }
} }
/* A non-zero return value will cause rxe_do_task to
* exit its loop and end the tasklet. A zero return
* will continue looping and return to rxe_responder
*/
done:
ret = 0;
goto out;
exit: exit:
ret = -EAGAIN; ret = -EAGAIN;
done: out:
rxe_put(qp); rxe_put(qp);
return ret; return ret;
} }