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:
parent
bf41b46c4e
commit
0b7f5a57ac
@ -1615,21 +1615,20 @@ 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:
|
||||||
|
assert(pdu->ch_valid_bytes < sizeof(struct spdk_nvme_tcp_common_pdu_hdr));
|
||||||
|
rc = nvme_tcp_read_data(tqpair->sock,
|
||||||
|
sizeof(struct spdk_nvme_tcp_common_pdu_hdr) - pdu->ch_valid_bytes,
|
||||||
|
(uint8_t *)&pdu->hdr.common + pdu->ch_valid_bytes);
|
||||||
|
if (rc < 0) {
|
||||||
|
nvme_tcp_qpair_set_recv_state(tqpair, NVME_TCP_PDU_RECV_STATE_ERROR);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pdu->ch_valid_bytes += rc;
|
||||||
if (pdu->ch_valid_bytes < sizeof(struct spdk_nvme_tcp_common_pdu_hdr)) {
|
if (pdu->ch_valid_bytes < sizeof(struct spdk_nvme_tcp_common_pdu_hdr)) {
|
||||||
rc = nvme_tcp_read_data(tqpair->sock,
|
rc = NVME_TCP_PDU_IN_PROGRESS;
|
||||||
sizeof(struct spdk_nvme_tcp_common_pdu_hdr) - pdu->ch_valid_bytes,
|
goto out;
|
||||||
(uint8_t *)&pdu->hdr.common + pdu->ch_valid_bytes);
|
|
||||||
if (rc < 0) {
|
|
||||||
nvme_tcp_qpair_set_recv_state(tqpair, NVME_TCP_PDU_RECV_STATE_ERROR);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
pdu->ch_valid_bytes += rc;
|
|
||||||
if (pdu->ch_valid_bytes < sizeof(struct spdk_nvme_tcp_common_pdu_hdr)) {
|
|
||||||
rc = NVME_TCP_PDU_IN_PROGRESS;
|
|
||||||
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. */
|
||||||
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user