Commit f1788422 authored by Varun Prakash's avatar Varun Prakash Committed by Martin K. Petersen
Browse files

scsi: target: cxgbit: Check connection state before issuing hardware command



Current code does not check connection state before issuing
header/data digest offload and DDP page size setup hardware command.

Add a connection state check to issue hardware command only
if connection is in established state.

Signed-off-by: default avatarVarun Prakash <varun@chelsio.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent e33c2482
Loading
Loading
Loading
Loading
+24 −8
Original line number Diff line number Diff line
@@ -1485,6 +1485,26 @@ u32 cxgbit_send_tx_flowc_wr(struct cxgbit_sock *csk)
	return flowclen16;
}

static int
cxgbit_send_tcb_skb(struct cxgbit_sock *csk, struct sk_buff *skb)
{
	spin_lock_bh(&csk->lock);
	if (unlikely(csk->com.state != CSK_STATE_ESTABLISHED)) {
		spin_unlock_bh(&csk->lock);
		pr_err("%s: csk 0x%p, tid %u, state %u\n",
		       __func__, csk, csk->tid, csk->com.state);
		__kfree_skb(skb);
		return -1;
	}

	cxgbit_get_csk(csk);
	cxgbit_init_wr_wait(&csk->com.wr_wait);
	cxgbit_ofld_send(csk->com.cdev, skb);
	spin_unlock_bh(&csk->lock);

	return 0;
}

int cxgbit_setup_conn_digest(struct cxgbit_sock *csk)
{
	struct sk_buff *skb;
@@ -1510,10 +1530,8 @@ int cxgbit_setup_conn_digest(struct cxgbit_sock *csk)
				(dcrc ? ULP_CRC_DATA : 0)) << 4);
	set_wr_txq(skb, CPL_PRIORITY_CONTROL, csk->ctrlq_idx);

	cxgbit_get_csk(csk);
	cxgbit_init_wr_wait(&csk->com.wr_wait);

	cxgbit_ofld_send(csk->com.cdev, skb);
	if (cxgbit_send_tcb_skb(csk, skb))
		return -1;

	ret = cxgbit_wait_for_reply(csk->com.cdev,
				    &csk->com.wr_wait,
@@ -1545,10 +1563,8 @@ int cxgbit_setup_conn_pgidx(struct cxgbit_sock *csk, u32 pg_idx)
	req->val = cpu_to_be64(pg_idx << 8);
	set_wr_txq(skb, CPL_PRIORITY_CONTROL, csk->ctrlq_idx);

	cxgbit_get_csk(csk);
	cxgbit_init_wr_wait(&csk->com.wr_wait);

	cxgbit_ofld_send(csk->com.cdev, skb);
	if (cxgbit_send_tcb_skb(csk, skb))
		return -1;

	ret = cxgbit_wait_for_reply(csk->com.cdev,
				    &csk->com.wr_wait,