Skip to content

Commit

Permalink
cxgbe/iw_cxgbe: Fail early in some callbacks when the RNIC is stopped.
Browse files Browse the repository at this point in the history
Stop allocating new resources when the RNIC is stopped but continue to
allow previously allocated resources to be freed.  Note that t4_tom's
uld_stop tears down all TOE connections, including those being used for
iWARP, and that triggers the cleanup of iWARP resources.

Fail post_send/post_recv early too to avoid the SQ doorbell.

MFC after:	1 week
Sponsored by:	Chelsio Communications
  • Loading branch information
np-2020 committed Aug 30, 2024
1 parent 28294dc commit 9fdb683
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sys/dev/cxgbe/iw_cxgbe/cm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2602,6 +2602,8 @@ int c4iw_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)

CTR2(KTR_IW_CXGBE, "%s:ccB %p", __func__, cm_id);

if (__predict_false(c4iw_stopped(&dev->rdev)))
return -EIO;

if ((conn_param->ord > c4iw_max_read_depth) ||
(conn_param->ird > c4iw_max_read_depth)) {
Expand Down
4 changes: 4 additions & 0 deletions sys/dev/cxgbe/iw_cxgbe/cq.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ create_cq(struct c4iw_rdev *rdev, struct t4_cq *cq,
struct wrqe *wr;
u64 cq_bar2_qoffset = 0;

if (__predict_false(c4iw_stopped(rdev)))
return -EIO;
cq->cqid = c4iw_get_cqid(rdev, uctx);
if (!cq->cqid) {
ret = -ENOMEM;
Expand Down Expand Up @@ -1037,6 +1039,8 @@ int c4iw_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags flags)
unsigned long flag;

chp = to_c4iw_cq(ibcq);
if (__predict_false(c4iw_stopped(chp->cq.rdev)))
return -EIO;
spin_lock_irqsave(&chp->lock, flag);
t4_arm_cq(&chp->cq,
(flags & IB_CQ_SOLICITED_MASK) == IB_CQ_SOLICITED);
Expand Down
3 changes: 3 additions & 0 deletions sys/dev/cxgbe/iw_cxgbe/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,9 @@ struct ib_mr *c4iw_alloc_mr(struct ib_pd *pd,
php = to_c4iw_pd(pd);
rhp = php->rhp;

if (__predict_false(c4iw_stopped(&rhp->rdev)))
return ERR_PTR(-EIO);

if (mr_type != IB_MR_TYPE_MEM_REG ||
max_num_sg > t4_max_fr_depth(&rhp->rdev, use_dsgl))
return ERR_PTR(-EINVAL);
Expand Down
2 changes: 2 additions & 0 deletions sys/dev/cxgbe/iw_cxgbe/provider.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ c4iw_allocate_pd(struct ib_pd *pd, struct ib_udata *udata)
CTR4(KTR_IW_CXGBE, "%s: ibdev %p, pd %p, data %p", __func__, ibdev,
pd, udata);
rhp = (struct c4iw_dev *) ibdev;
if (__predict_false(c4iw_stopped(&rhp->rdev)))
return -EIO;
pdid = c4iw_get_resource(&rhp->rdev.resource.pdid_table);
if (!pdid)
return -EINVAL;
Expand Down
7 changes: 7 additions & 0 deletions sys/dev/cxgbe/iw_cxgbe/qp.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ static int create_qp(struct c4iw_rdev *rdev, struct t4_wq *wq,
struct wrqe *wr;
u64 sq_bar2_qoffset = 0, rq_bar2_qoffset = 0;

if (__predict_false(c4iw_stopped(rdev)))
return -EIO;

wq->sq.qid = c4iw_get_qpid(rdev, uctx);
if (!wq->sq.qid)
return -ENOMEM;
Expand Down Expand Up @@ -785,6 +788,8 @@ int c4iw_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,

qhp = to_c4iw_qp(ibqp);
rdev = &qhp->rhp->rdev;
if (__predict_false(c4iw_stopped(rdev)))
return -EIO;
spin_lock_irqsave(&qhp->lock, flag);
if (t4_wq_in_error(&qhp->wq)) {
spin_unlock_irqrestore(&qhp->lock, flag);
Expand Down Expand Up @@ -920,6 +925,8 @@ int c4iw_post_receive(struct ib_qp *ibqp, const struct ib_recv_wr *wr,
u16 idx = 0;

qhp = to_c4iw_qp(ibqp);
if (__predict_false(c4iw_stopped(&qhp->rhp->rdev)))
return -EIO;
spin_lock_irqsave(&qhp->lock, flag);
if (t4_wq_in_error(&qhp->wq)) {
spin_unlock_irqrestore(&qhp->lock, flag);
Expand Down

0 comments on commit 9fdb683

Please sign in to comment.