nvme/tcp: Remove duplicate code in nvme_tcp_read_pdu
Signed-off-by: MengjinWu <mengjin.wu@intel.com> Change-Id: I63f51ecba2b4d40579d2592d2c85a7aefdacf7e7 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14503 Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Xiaodong Liu <xiaodong.liu@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
31fc5f196f
commit
48312019c8
@ -1608,15 +1608,15 @@ nvme_tcp_read_pdu(struct nvme_tcp_qpair *tqpair, uint32_t *reaped)
|
|||||||
/* The loop here is to allow for several back-to-back state changes. */
|
/* The loop here is to allow for several back-to-back state changes. */
|
||||||
do {
|
do {
|
||||||
prev_state = tqpair->recv_state;
|
prev_state = tqpair->recv_state;
|
||||||
|
pdu = tqpair->recv_pdu;
|
||||||
switch (tqpair->recv_state) {
|
switch (tqpair->recv_state) {
|
||||||
/* If in a new state */
|
/* If in a new state */
|
||||||
case NVME_TCP_PDU_RECV_STATE_AWAIT_PDU_READY:
|
case NVME_TCP_PDU_RECV_STATE_AWAIT_PDU_READY:
|
||||||
memset(tqpair->recv_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 */
|
/* common header */
|
||||||
case NVME_TCP_PDU_RECV_STATE_AWAIT_PDU_CH:
|
case NVME_TCP_PDU_RECV_STATE_AWAIT_PDU_CH:
|
||||||
pdu = tqpair->recv_pdu;
|
|
||||||
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_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,
|
||||||
@ -1637,7 +1637,6 @@ nvme_tcp_read_pdu(struct nvme_tcp_qpair *tqpair, uint32_t *reaped)
|
|||||||
break;
|
break;
|
||||||
/* Wait for the pdu specific header */
|
/* Wait for the pdu specific header */
|
||||||
case NVME_TCP_PDU_RECV_STATE_AWAIT_PDU_PSH:
|
case NVME_TCP_PDU_RECV_STATE_AWAIT_PDU_PSH:
|
||||||
pdu = tqpair->recv_pdu;
|
|
||||||
rc = nvme_tcp_read_data(tqpair->sock,
|
rc = nvme_tcp_read_data(tqpair->sock,
|
||||||
pdu->psh_len - pdu->psh_valid_bytes,
|
pdu->psh_len - pdu->psh_valid_bytes,
|
||||||
(uint8_t *)&pdu->hdr.raw + sizeof(struct spdk_nvme_tcp_common_pdu_hdr) + pdu->psh_valid_bytes);
|
(uint8_t *)&pdu->hdr.raw + sizeof(struct spdk_nvme_tcp_common_pdu_hdr) + pdu->psh_valid_bytes);
|
||||||
@ -1656,7 +1655,6 @@ nvme_tcp_read_pdu(struct nvme_tcp_qpair *tqpair, uint32_t *reaped)
|
|||||||
nvme_tcp_pdu_psh_handle(tqpair, reaped);
|
nvme_tcp_pdu_psh_handle(tqpair, reaped);
|
||||||
break;
|
break;
|
||||||
case NVME_TCP_PDU_RECV_STATE_AWAIT_PDU_PAYLOAD:
|
case NVME_TCP_PDU_RECV_STATE_AWAIT_PDU_PAYLOAD:
|
||||||
pdu = tqpair->recv_pdu;
|
|
||||||
/* check whether the data is valid, if not we just return */
|
/* check whether the data is valid, if not we just return */
|
||||||
if (!pdu->data_len) {
|
if (!pdu->data_len) {
|
||||||
return NVME_TCP_PDU_IN_PROGRESS;
|
return NVME_TCP_PDU_IN_PROGRESS;
|
||||||
@ -1687,7 +1685,7 @@ nvme_tcp_read_pdu(struct nvme_tcp_qpair *tqpair, uint32_t *reaped)
|
|||||||
nvme_tcp_pdu_payload_handle(tqpair, reaped);
|
nvme_tcp_pdu_payload_handle(tqpair, reaped);
|
||||||
break;
|
break;
|
||||||
case NVME_TCP_PDU_RECV_STATE_ERROR:
|
case NVME_TCP_PDU_RECV_STATE_ERROR:
|
||||||
memset(tqpair->recv_pdu, 0, sizeof(struct nvme_tcp_pdu));
|
memset(pdu, 0, sizeof(struct nvme_tcp_pdu));
|
||||||
rc = NVME_TCP_PDU_FATAL;
|
rc = NVME_TCP_PDU_FATAL;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user