nvme/tcp: remove unnecessary if check in nvme_tcp_read_pdu

This "if" is of no use here.

The state machine has the "NVME_TCP_PDU_RECV_STATE_AWAIT_PDU_CH"
state means the pdu does not receive enough length of header.

Signed-off-by: MengjinWu <mengjin.wu@intel.com>
Change-Id: Id50943f77b570fd337e2bb4e3b45281018d159e4
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14504
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
MengjinWu 2022-09-16 04:11:09 +00:00 committed by Jim Harris
parent bf41b46c4e
commit 0b7f5a57ac
2 changed files with 13 additions and 14 deletions

View File

@ -1615,9 +1615,9 @@ nvme_tcp_read_pdu(struct nvme_tcp_qpair *tqpair, uint32_t *reaped)
memset(pdu, 0, sizeof(struct nvme_tcp_pdu)); memset(pdu, 0, sizeof(struct nvme_tcp_pdu));
nvme_tcp_qpair_set_recv_state(tqpair, NVME_TCP_PDU_RECV_STATE_AWAIT_PDU_CH); nvme_tcp_qpair_set_recv_state(tqpair, NVME_TCP_PDU_RECV_STATE_AWAIT_PDU_CH);
break; break;
/* common header */ /* Wait for the pdu common header */
case NVME_TCP_PDU_RECV_STATE_AWAIT_PDU_CH: case NVME_TCP_PDU_RECV_STATE_AWAIT_PDU_CH:
if (pdu->ch_valid_bytes < sizeof(struct spdk_nvme_tcp_common_pdu_hdr)) { assert(pdu->ch_valid_bytes < sizeof(struct spdk_nvme_tcp_common_pdu_hdr));
rc = nvme_tcp_read_data(tqpair->sock, rc = nvme_tcp_read_data(tqpair->sock,
sizeof(struct spdk_nvme_tcp_common_pdu_hdr) - pdu->ch_valid_bytes, sizeof(struct spdk_nvme_tcp_common_pdu_hdr) - pdu->ch_valid_bytes,
(uint8_t *)&pdu->hdr.common + pdu->ch_valid_bytes); (uint8_t *)&pdu->hdr.common + pdu->ch_valid_bytes);
@ -1630,7 +1630,6 @@ nvme_tcp_read_pdu(struct nvme_tcp_qpair *tqpair, uint32_t *reaped)
rc = NVME_TCP_PDU_IN_PROGRESS; rc = NVME_TCP_PDU_IN_PROGRESS;
goto out; goto out;
} }
}
/* The command header of this PDU has now been read from the socket. */ /* The command header of this PDU has now been read from the socket. */
nvme_tcp_pdu_ch_handle(tqpair); nvme_tcp_pdu_ch_handle(tqpair);

View File

@ -1381,7 +1381,7 @@ test_nvme_tcp_ctrlr_connect_qpair(void)
tqpair->recv_pdu->hdr.common.pdu_type = SPDK_NVME_TCP_PDU_TYPE_IC_RESP; tqpair->recv_pdu->hdr.common.pdu_type = SPDK_NVME_TCP_PDU_TYPE_IC_RESP;
tqpair->recv_pdu->hdr.common.plen = sizeof(struct spdk_nvme_tcp_ic_resp); tqpair->recv_pdu->hdr.common.plen = sizeof(struct spdk_nvme_tcp_ic_resp);
tqpair->recv_pdu->hdr.common.hlen = sizeof(struct spdk_nvme_tcp_ic_resp); tqpair->recv_pdu->hdr.common.hlen = sizeof(struct spdk_nvme_tcp_ic_resp);
tqpair->recv_pdu->ch_valid_bytes = 8; tqpair->recv_pdu->ch_valid_bytes = 7;
tqpair->recv_pdu->psh_valid_bytes = tqpair->recv_pdu->hdr.common.hlen; tqpair->recv_pdu->psh_valid_bytes = tqpair->recv_pdu->hdr.common.hlen;
tqpair->recv_pdu->hdr.ic_resp.maxh2cdata = 4096; tqpair->recv_pdu->hdr.ic_resp.maxh2cdata = 4096;
tqpair->recv_pdu->hdr.ic_resp.cpda = 1; tqpair->recv_pdu->hdr.ic_resp.cpda = 1;