Revert "nvme/tcp: Change hdr in nvme_tcp_pdu to pointer"
This reverts commit ea5ad0b286
.
This code is moving from the nvmf target to the posix sock
layer in this series.
Change-Id: I333bdf325848e726ab82a9e6916e1bbdcd34009c
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/446
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
8b7e6ca407
commit
ea65bf612d
@ -82,24 +82,22 @@ struct _nvme_tcp_sgl {
|
||||
uint32_t total_size;
|
||||
};
|
||||
|
||||
union nvme_tcp_pdu_hdr {
|
||||
/* to hold error pdu data */
|
||||
uint8_t raw[SPDK_NVME_TCP_TERM_REQ_PDU_MAX_SIZE];
|
||||
struct spdk_nvme_tcp_common_pdu_hdr common;
|
||||
struct spdk_nvme_tcp_ic_req ic_req;
|
||||
struct spdk_nvme_tcp_term_req_hdr term_req;
|
||||
struct spdk_nvme_tcp_cmd capsule_cmd;
|
||||
struct spdk_nvme_tcp_h2c_data_hdr h2c_data;
|
||||
struct spdk_nvme_tcp_ic_resp ic_resp;
|
||||
struct spdk_nvme_tcp_rsp capsule_resp;
|
||||
struct spdk_nvme_tcp_c2h_data_hdr c2h_data;
|
||||
struct spdk_nvme_tcp_r2t_hdr r2t;
|
||||
|
||||
};
|
||||
|
||||
struct nvme_tcp_pdu {
|
||||
union nvme_tcp_pdu_hdr hdr_mem;
|
||||
union nvme_tcp_pdu_hdr *hdr;
|
||||
union {
|
||||
/* to hold error pdu data */
|
||||
uint8_t raw[SPDK_NVME_TCP_TERM_REQ_PDU_MAX_SIZE];
|
||||
struct spdk_nvme_tcp_common_pdu_hdr common;
|
||||
struct spdk_nvme_tcp_ic_req ic_req;
|
||||
struct spdk_nvme_tcp_term_req_hdr term_req;
|
||||
struct spdk_nvme_tcp_cmd capsule_cmd;
|
||||
struct spdk_nvme_tcp_h2c_data_hdr h2c_data;
|
||||
struct spdk_nvme_tcp_ic_resp ic_resp;
|
||||
struct spdk_nvme_tcp_rsp capsule_resp;
|
||||
struct spdk_nvme_tcp_c2h_data_hdr c2h_data;
|
||||
struct spdk_nvme_tcp_r2t_hdr r2t;
|
||||
|
||||
} hdr;
|
||||
|
||||
bool has_hdgst;
|
||||
bool ddgst_enable;
|
||||
uint8_t data_digest[SPDK_NVME_TCP_DIGEST_LEN];
|
||||
@ -198,9 +196,9 @@ static uint32_t
|
||||
nvme_tcp_pdu_calc_header_digest(struct nvme_tcp_pdu *pdu)
|
||||
{
|
||||
uint32_t crc32c;
|
||||
uint32_t hlen = pdu->hdr->common.hlen;
|
||||
uint32_t hlen = pdu->hdr.common.hlen;
|
||||
|
||||
crc32c = spdk_crc32c_update(&pdu->hdr->raw, hlen, ~0);
|
||||
crc32c = spdk_crc32c_update(&pdu->hdr.raw, hlen, ~0);
|
||||
crc32c = crc32c ^ SPDK_CRC32C_XOR;
|
||||
return crc32c;
|
||||
}
|
||||
@ -376,17 +374,17 @@ nvme_tcp_build_iovs(struct iovec *iov, int iovcnt, struct nvme_tcp_pdu *pdu,
|
||||
|
||||
sgl = &pdu->sgl;
|
||||
_nvme_tcp_sgl_init(sgl, iov, iovcnt, 0);
|
||||
hlen = pdu->hdr->common.hlen;
|
||||
hlen = pdu->hdr.common.hlen;
|
||||
|
||||
/* Header Digest */
|
||||
if (g_nvme_tcp_hdgst[pdu->hdr->common.pdu_type] && hdgst_enable) {
|
||||
if (g_nvme_tcp_hdgst[pdu->hdr.common.pdu_type] && hdgst_enable) {
|
||||
hlen += SPDK_NVME_TCP_DIGEST_LEN;
|
||||
}
|
||||
|
||||
plen = hlen;
|
||||
if (!pdu->data_len) {
|
||||
/* PDU header + possible header digest */
|
||||
_nvme_tcp_sgl_append(sgl, (uint8_t *)&pdu->hdr->raw, hlen);
|
||||
_nvme_tcp_sgl_append(sgl, (uint8_t *)&pdu->hdr.raw, hlen);
|
||||
goto end;
|
||||
}
|
||||
|
||||
@ -396,7 +394,7 @@ nvme_tcp_build_iovs(struct iovec *iov, int iovcnt, struct nvme_tcp_pdu *pdu,
|
||||
plen = hlen;
|
||||
}
|
||||
|
||||
if (!_nvme_tcp_sgl_append(sgl, (uint8_t *)&pdu->hdr->raw, hlen)) {
|
||||
if (!_nvme_tcp_sgl_append(sgl, (uint8_t *)&pdu->hdr.raw, hlen)) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
@ -414,12 +412,12 @@ nvme_tcp_build_iovs(struct iovec *iov, int iovcnt, struct nvme_tcp_pdu *pdu,
|
||||
}
|
||||
|
||||
/* Data Digest */
|
||||
if (g_nvme_tcp_ddgst[pdu->hdr->common.pdu_type] && ddgst_enable) {
|
||||
if (g_nvme_tcp_ddgst[pdu->hdr.common.pdu_type] && ddgst_enable) {
|
||||
plen += SPDK_NVME_TCP_DIGEST_LEN;
|
||||
_nvme_tcp_sgl_append(sgl, pdu->data_digest, SPDK_NVME_TCP_DIGEST_LEN);
|
||||
}
|
||||
|
||||
assert(plen == pdu->hdr->common.plen);
|
||||
assert(plen == pdu->hdr.common.plen);
|
||||
|
||||
end:
|
||||
if (_mapped_length != NULL) {
|
||||
@ -619,13 +617,13 @@ nvme_tcp_pdu_calc_psh_len(struct nvme_tcp_pdu *pdu, bool hdgst_enable)
|
||||
{
|
||||
uint8_t psh_len, pdo, padding_len;
|
||||
|
||||
psh_len = pdu->hdr->common.hlen;
|
||||
psh_len = pdu->hdr.common.hlen;
|
||||
|
||||
if (g_nvme_tcp_hdgst[pdu->hdr->common.pdu_type] && hdgst_enable) {
|
||||
if (g_nvme_tcp_hdgst[pdu->hdr.common.pdu_type] && hdgst_enable) {
|
||||
pdu->has_hdgst = true;
|
||||
psh_len += SPDK_NVME_TCP_DIGEST_LEN;
|
||||
if (pdu->hdr->common.plen > psh_len) {
|
||||
pdo = pdu->hdr->common.pdo;
|
||||
if (pdu->hdr.common.plen > psh_len) {
|
||||
pdo = pdu->hdr.common.pdo;
|
||||
padding_len = pdo - psh_len;
|
||||
if (padding_len > 0) {
|
||||
psh_len = pdo;
|
||||
|
@ -152,7 +152,6 @@ nvme_tcp_req_get(struct nvme_tcp_qpair *tqpair)
|
||||
tcp_req->active_r2ts = 0;
|
||||
tcp_req->iovcnt = 0;
|
||||
memset(&tcp_req->send_pdu, 0, sizeof(tcp_req->send_pdu));
|
||||
tcp_req->send_pdu.hdr = &tcp_req->send_pdu.hdr_mem;
|
||||
TAILQ_INSERT_TAIL(&tqpair->outstanding_reqs, tcp_req, link);
|
||||
|
||||
return tcp_req;
|
||||
@ -324,16 +323,16 @@ nvme_tcp_qpair_write_pdu(struct nvme_tcp_qpair *tqpair,
|
||||
uint32_t crc32c;
|
||||
uint32_t mapped_length = 0;
|
||||
|
||||
hlen = pdu->hdr->common.hlen;
|
||||
hlen = pdu->hdr.common.hlen;
|
||||
|
||||
/* Header Digest */
|
||||
if (g_nvme_tcp_hdgst[pdu->hdr->common.pdu_type] && tqpair->host_hdgst_enable) {
|
||||
if (g_nvme_tcp_hdgst[pdu->hdr.common.pdu_type] && tqpair->host_hdgst_enable) {
|
||||
crc32c = nvme_tcp_pdu_calc_header_digest(pdu);
|
||||
MAKE_DIGEST_WORD((uint8_t *)pdu->hdr->raw + hlen, crc32c);
|
||||
MAKE_DIGEST_WORD((uint8_t *)pdu->hdr.raw + hlen, crc32c);
|
||||
}
|
||||
|
||||
/* Data Digest */
|
||||
if (pdu->data_len > 0 && g_nvme_tcp_ddgst[pdu->hdr->common.pdu_type] && tqpair->host_ddgst_enable) {
|
||||
if (pdu->data_len > 0 && g_nvme_tcp_ddgst[pdu->hdr.common.pdu_type] && tqpair->host_ddgst_enable) {
|
||||
crc32c = nvme_tcp_pdu_calc_data_digest(pdu);
|
||||
MAKE_DIGEST_WORD(pdu->data_digest, crc32c);
|
||||
}
|
||||
@ -488,7 +487,7 @@ nvme_tcp_qpair_capsule_cmd_send(struct nvme_tcp_qpair *tqpair,
|
||||
SPDK_DEBUGLOG(SPDK_LOG_NVME, "enter\n");
|
||||
pdu = &tcp_req->send_pdu;
|
||||
|
||||
capsule_cmd = &pdu->hdr->capsule_cmd;
|
||||
capsule_cmd = &pdu->hdr.capsule_cmd;
|
||||
capsule_cmd->common.pdu_type = SPDK_NVME_TCP_PDU_TYPE_CAPSULE_CMD;
|
||||
plen = capsule_cmd->common.hlen = sizeof(*capsule_cmd);
|
||||
capsule_cmd->ccsqe = tcp_req->req->cmd;
|
||||
@ -609,7 +608,6 @@ nvme_tcp_qpair_set_recv_state(struct nvme_tcp_qpair *tqpair,
|
||||
case NVME_TCP_PDU_RECV_STATE_AWAIT_PDU_READY:
|
||||
case NVME_TCP_PDU_RECV_STATE_ERROR:
|
||||
memset(&tqpair->recv_pdu, 0, sizeof(struct nvme_tcp_pdu));
|
||||
tqpair->recv_pdu.hdr = &tqpair->recv_pdu.hdr_mem;
|
||||
break;
|
||||
case NVME_TCP_PDU_RECV_STATE_AWAIT_PDU_CH:
|
||||
case NVME_TCP_PDU_RECV_STATE_AWAIT_PDU_PSH:
|
||||
@ -638,8 +636,7 @@ nvme_tcp_qpair_send_h2c_term_req(struct nvme_tcp_qpair *tqpair, struct nvme_tcp_
|
||||
|
||||
rsp_pdu = &tqpair->send_pdu;
|
||||
memset(rsp_pdu, 0, sizeof(*rsp_pdu));
|
||||
rsp_pdu->hdr = &rsp_pdu->hdr_mem;
|
||||
h2c_term_req = &rsp_pdu->hdr->term_req;
|
||||
h2c_term_req = &rsp_pdu->hdr.term_req;
|
||||
h2c_term_req->common.pdu_type = SPDK_NVME_TCP_PDU_TYPE_H2C_TERM_REQ;
|
||||
h2c_term_req->common.hlen = h2c_term_req_hdr_len;
|
||||
|
||||
@ -648,14 +645,14 @@ nvme_tcp_qpair_send_h2c_term_req(struct nvme_tcp_qpair *tqpair, struct nvme_tcp_
|
||||
DSET32(&h2c_term_req->fei, error_offset);
|
||||
}
|
||||
|
||||
copy_len = pdu->hdr->common.hlen;
|
||||
copy_len = pdu->hdr.common.hlen;
|
||||
if (copy_len > SPDK_NVME_TCP_TERM_REQ_ERROR_DATA_MAX_SIZE) {
|
||||
copy_len = SPDK_NVME_TCP_TERM_REQ_ERROR_DATA_MAX_SIZE;
|
||||
}
|
||||
|
||||
/* Copy the error info into the buffer */
|
||||
memcpy((uint8_t *)rsp_pdu->hdr->raw + h2c_term_req_hdr_len, pdu->hdr->raw, copy_len);
|
||||
nvme_tcp_pdu_set_data(rsp_pdu, (uint8_t *)rsp_pdu->hdr->raw + h2c_term_req_hdr_len, copy_len);
|
||||
memcpy((uint8_t *)rsp_pdu->hdr.raw + h2c_term_req_hdr_len, pdu->hdr.raw, copy_len);
|
||||
nvme_tcp_pdu_set_data(rsp_pdu, (uint8_t *)rsp_pdu->hdr.raw + h2c_term_req_hdr_len, copy_len);
|
||||
|
||||
/* Contain the header len of the wrong received pdu */
|
||||
h2c_term_req->common.plen = h2c_term_req->common.hlen + copy_len;
|
||||
@ -675,15 +672,15 @@ nvme_tcp_pdu_ch_handle(struct nvme_tcp_qpair *tqpair)
|
||||
|
||||
pdu = &tqpair->recv_pdu;
|
||||
|
||||
SPDK_DEBUGLOG(SPDK_LOG_NVME, "pdu type = %d\n", pdu->hdr->common.pdu_type);
|
||||
if (pdu->hdr->common.pdu_type == SPDK_NVME_TCP_PDU_TYPE_IC_RESP) {
|
||||
SPDK_DEBUGLOG(SPDK_LOG_NVME, "pdu type = %d\n", pdu->hdr.common.pdu_type);
|
||||
if (pdu->hdr.common.pdu_type == SPDK_NVME_TCP_PDU_TYPE_IC_RESP) {
|
||||
if (tqpair->state != NVME_TCP_QPAIR_STATE_INVALID) {
|
||||
SPDK_ERRLOG("Already received IC_RESP PDU, and we should reject this pdu=%p\n", pdu);
|
||||
fes = SPDK_NVME_TCP_TERM_REQ_FES_PDU_SEQUENCE_ERROR;
|
||||
goto err;
|
||||
}
|
||||
expected_hlen = sizeof(struct spdk_nvme_tcp_ic_resp);
|
||||
if (pdu->hdr->common.plen != expected_hlen) {
|
||||
if (pdu->hdr.common.plen != expected_hlen) {
|
||||
plen_error = true;
|
||||
}
|
||||
} else {
|
||||
@ -693,52 +690,52 @@ nvme_tcp_pdu_ch_handle(struct nvme_tcp_qpair *tqpair)
|
||||
goto err;
|
||||
}
|
||||
|
||||
switch (pdu->hdr->common.pdu_type) {
|
||||
switch (pdu->hdr.common.pdu_type) {
|
||||
case SPDK_NVME_TCP_PDU_TYPE_CAPSULE_RESP:
|
||||
expected_hlen = sizeof(struct spdk_nvme_tcp_rsp);
|
||||
if (pdu->hdr->common.flags & SPDK_NVME_TCP_CH_FLAGS_HDGSTF) {
|
||||
if (pdu->hdr.common.flags & SPDK_NVME_TCP_CH_FLAGS_HDGSTF) {
|
||||
hd_len = SPDK_NVME_TCP_DIGEST_LEN;
|
||||
}
|
||||
|
||||
if (pdu->hdr->common.plen != (expected_hlen + hd_len)) {
|
||||
if (pdu->hdr.common.plen != (expected_hlen + hd_len)) {
|
||||
plen_error = true;
|
||||
}
|
||||
break;
|
||||
case SPDK_NVME_TCP_PDU_TYPE_C2H_DATA:
|
||||
expected_hlen = sizeof(struct spdk_nvme_tcp_c2h_data_hdr);
|
||||
if (pdu->hdr->common.plen < pdu->hdr->common.pdo) {
|
||||
if (pdu->hdr.common.plen < pdu->hdr.common.pdo) {
|
||||
plen_error = true;
|
||||
}
|
||||
break;
|
||||
case SPDK_NVME_TCP_PDU_TYPE_C2H_TERM_REQ:
|
||||
expected_hlen = sizeof(struct spdk_nvme_tcp_term_req_hdr);
|
||||
if ((pdu->hdr->common.plen <= expected_hlen) ||
|
||||
(pdu->hdr->common.plen > SPDK_NVME_TCP_TERM_REQ_PDU_MAX_SIZE)) {
|
||||
if ((pdu->hdr.common.plen <= expected_hlen) ||
|
||||
(pdu->hdr.common.plen > SPDK_NVME_TCP_TERM_REQ_PDU_MAX_SIZE)) {
|
||||
plen_error = true;
|
||||
}
|
||||
break;
|
||||
case SPDK_NVME_TCP_PDU_TYPE_R2T:
|
||||
expected_hlen = sizeof(struct spdk_nvme_tcp_r2t_hdr);
|
||||
if (pdu->hdr->common.flags & SPDK_NVME_TCP_CH_FLAGS_HDGSTF) {
|
||||
if (pdu->hdr.common.flags & SPDK_NVME_TCP_CH_FLAGS_HDGSTF) {
|
||||
hd_len = SPDK_NVME_TCP_DIGEST_LEN;
|
||||
}
|
||||
|
||||
if (pdu->hdr->common.plen != (expected_hlen + hd_len)) {
|
||||
if (pdu->hdr.common.plen != (expected_hlen + hd_len)) {
|
||||
plen_error = true;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
SPDK_ERRLOG("Unexpected PDU type 0x%02x\n", tqpair->recv_pdu.hdr->common.pdu_type);
|
||||
SPDK_ERRLOG("Unexpected PDU type 0x%02x\n", tqpair->recv_pdu.hdr.common.pdu_type);
|
||||
fes = SPDK_NVME_TCP_TERM_REQ_FES_INVALID_HEADER_FIELD;
|
||||
error_offset = offsetof(struct spdk_nvme_tcp_common_pdu_hdr, pdu_type);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
if (pdu->hdr->common.hlen != expected_hlen) {
|
||||
if (pdu->hdr.common.hlen != expected_hlen) {
|
||||
SPDK_ERRLOG("Expected PDU header length %u, got %u\n",
|
||||
expected_hlen, pdu->hdr->common.hlen);
|
||||
expected_hlen, pdu->hdr.common.hlen);
|
||||
fes = SPDK_NVME_TCP_TERM_REQ_FES_INVALID_HEADER_FIELD;
|
||||
error_offset = offsetof(struct spdk_nvme_tcp_common_pdu_hdr, hlen);
|
||||
goto err;
|
||||
@ -780,7 +777,7 @@ nvme_tcp_c2h_data_payload_handle(struct nvme_tcp_qpair *tqpair,
|
||||
assert(tcp_req != NULL);
|
||||
|
||||
SPDK_DEBUGLOG(SPDK_LOG_NVME, "enter\n");
|
||||
c2h_data = &pdu->hdr->c2h_data;
|
||||
c2h_data = &pdu->hdr.c2h_data;
|
||||
tcp_req->datao += pdu->data_len;
|
||||
flags = c2h_data->common.flags;
|
||||
|
||||
@ -826,7 +823,7 @@ static void
|
||||
nvme_tcp_c2h_term_req_payload_handle(struct nvme_tcp_qpair *tqpair,
|
||||
struct nvme_tcp_pdu *pdu)
|
||||
{
|
||||
nvme_tcp_c2h_term_req_dump(&pdu->hdr->term_req);
|
||||
nvme_tcp_c2h_term_req_dump(&pdu->hdr.term_req);
|
||||
nvme_tcp_qpair_set_recv_state(tqpair, NVME_TCP_PDU_RECV_STATE_ERROR);
|
||||
}
|
||||
|
||||
@ -856,7 +853,7 @@ nvme_tcp_pdu_payload_handle(struct nvme_tcp_qpair *tqpair,
|
||||
}
|
||||
}
|
||||
|
||||
switch (pdu->hdr->common.pdu_type) {
|
||||
switch (pdu->hdr.common.pdu_type) {
|
||||
case SPDK_NVME_TCP_PDU_TYPE_C2H_DATA:
|
||||
nvme_tcp_c2h_data_payload_handle(tqpair, pdu, reaped);
|
||||
break;
|
||||
@ -883,7 +880,7 @@ static void
|
||||
nvme_tcp_icresp_handle(struct nvme_tcp_qpair *tqpair,
|
||||
struct nvme_tcp_pdu *pdu)
|
||||
{
|
||||
struct spdk_nvme_tcp_ic_resp *ic_resp = &pdu->hdr->ic_resp;
|
||||
struct spdk_nvme_tcp_ic_resp *ic_resp = &pdu->hdr.ic_resp;
|
||||
uint32_t error_offset = 0;
|
||||
enum spdk_nvme_tcp_term_req_fes fes;
|
||||
|
||||
@ -930,7 +927,7 @@ nvme_tcp_capsule_resp_hdr_handle(struct nvme_tcp_qpair *tqpair, struct nvme_tcp_
|
||||
uint32_t *reaped)
|
||||
{
|
||||
struct nvme_tcp_req *tcp_req;
|
||||
struct spdk_nvme_tcp_rsp *capsule_resp = &pdu->hdr->capsule_resp;
|
||||
struct spdk_nvme_tcp_rsp *capsule_resp = &pdu->hdr.capsule_resp;
|
||||
uint32_t cid, error_offset = 0;
|
||||
enum spdk_nvme_tcp_term_req_fes fes;
|
||||
struct spdk_nvme_cpl cpl;
|
||||
@ -970,7 +967,7 @@ static void
|
||||
nvme_tcp_c2h_term_req_hdr_handle(struct nvme_tcp_qpair *tqpair,
|
||||
struct nvme_tcp_pdu *pdu)
|
||||
{
|
||||
struct spdk_nvme_tcp_term_req_hdr *c2h_term_req = &pdu->hdr->term_req;
|
||||
struct spdk_nvme_tcp_term_req_hdr *c2h_term_req = &pdu->hdr.term_req;
|
||||
uint32_t error_offset = 0;
|
||||
enum spdk_nvme_tcp_term_req_fes fes;
|
||||
|
||||
@ -982,7 +979,7 @@ nvme_tcp_c2h_term_req_hdr_handle(struct nvme_tcp_qpair *tqpair,
|
||||
}
|
||||
|
||||
/* set the data buffer */
|
||||
nvme_tcp_pdu_set_data(pdu, (uint8_t *)pdu->hdr->raw + c2h_term_req->common.hlen,
|
||||
nvme_tcp_pdu_set_data(pdu, (uint8_t *)pdu->hdr.raw + c2h_term_req->common.hlen,
|
||||
c2h_term_req->common.plen - c2h_term_req->common.hlen);
|
||||
nvme_tcp_qpair_set_recv_state(tqpair, NVME_TCP_PDU_RECV_STATE_AWAIT_PDU_PAYLOAD);
|
||||
return;
|
||||
@ -995,7 +992,7 @@ static void
|
||||
nvme_tcp_c2h_data_hdr_handle(struct nvme_tcp_qpair *tqpair, struct nvme_tcp_pdu *pdu)
|
||||
{
|
||||
struct nvme_tcp_req *tcp_req;
|
||||
struct spdk_nvme_tcp_c2h_data_hdr *c2h_data = &pdu->hdr->c2h_data;
|
||||
struct spdk_nvme_tcp_c2h_data_hdr *c2h_data = &pdu->hdr.c2h_data;
|
||||
uint32_t error_offset = 0;
|
||||
enum spdk_nvme_tcp_term_req_fes fes;
|
||||
|
||||
@ -1076,8 +1073,7 @@ spdk_nvme_tcp_send_h2c_data(struct nvme_tcp_req *tcp_req)
|
||||
|
||||
rsp_pdu = &tcp_req->send_pdu;
|
||||
memset(rsp_pdu, 0, sizeof(*rsp_pdu));
|
||||
rsp_pdu->hdr = &rsp_pdu->hdr_mem;
|
||||
h2c_data = &rsp_pdu->hdr->h2c_data;
|
||||
h2c_data = &rsp_pdu->hdr.h2c_data;
|
||||
|
||||
h2c_data->common.pdu_type = SPDK_NVME_TCP_PDU_TYPE_H2C_DATA;
|
||||
plen = h2c_data->common.hlen = sizeof(*h2c_data);
|
||||
@ -1128,7 +1124,7 @@ static void
|
||||
nvme_tcp_r2t_hdr_handle(struct nvme_tcp_qpair *tqpair, struct nvme_tcp_pdu *pdu)
|
||||
{
|
||||
struct nvme_tcp_req *tcp_req;
|
||||
struct spdk_nvme_tcp_r2t_hdr *r2t = &pdu->hdr->r2t;
|
||||
struct spdk_nvme_tcp_r2t_hdr *r2t = &pdu->hdr.r2t;
|
||||
uint32_t cid, error_offset = 0;
|
||||
enum spdk_nvme_tcp_term_req_fes fes;
|
||||
|
||||
@ -1197,11 +1193,11 @@ nvme_tcp_pdu_psh_handle(struct nvme_tcp_qpair *tqpair, uint32_t *reaped)
|
||||
assert(tqpair->recv_state == NVME_TCP_PDU_RECV_STATE_AWAIT_PDU_PSH);
|
||||
pdu = &tqpair->recv_pdu;
|
||||
|
||||
SPDK_DEBUGLOG(SPDK_LOG_NVME, "enter: pdu type =%u\n", pdu->hdr->common.pdu_type);
|
||||
SPDK_DEBUGLOG(SPDK_LOG_NVME, "enter: pdu type =%u\n", pdu->hdr.common.pdu_type);
|
||||
/* check header digest if needed */
|
||||
if (pdu->has_hdgst) {
|
||||
crc32c = nvme_tcp_pdu_calc_header_digest(pdu);
|
||||
rc = MATCH_DIGEST_WORD((uint8_t *)pdu->hdr->raw + pdu->hdr->common.hlen, crc32c);
|
||||
rc = MATCH_DIGEST_WORD((uint8_t *)pdu->hdr.raw + pdu->hdr.common.hlen, crc32c);
|
||||
if (rc == 0) {
|
||||
SPDK_ERRLOG("header digest error on tqpair=(%p) with pdu=%p\n", tqpair, pdu);
|
||||
fes = SPDK_NVME_TCP_TERM_REQ_FES_HDGST_ERROR;
|
||||
@ -1211,7 +1207,7 @@ nvme_tcp_pdu_psh_handle(struct nvme_tcp_qpair *tqpair, uint32_t *reaped)
|
||||
}
|
||||
}
|
||||
|
||||
switch (pdu->hdr->common.pdu_type) {
|
||||
switch (pdu->hdr.common.pdu_type) {
|
||||
case SPDK_NVME_TCP_PDU_TYPE_IC_RESP:
|
||||
nvme_tcp_icresp_handle(tqpair, pdu);
|
||||
break;
|
||||
@ -1230,7 +1226,7 @@ nvme_tcp_pdu_psh_handle(struct nvme_tcp_qpair *tqpair, uint32_t *reaped)
|
||||
break;
|
||||
|
||||
default:
|
||||
SPDK_ERRLOG("Unexpected PDU type 0x%02x\n", tqpair->recv_pdu.hdr->common.pdu_type);
|
||||
SPDK_ERRLOG("Unexpected PDU type 0x%02x\n", tqpair->recv_pdu.hdr.common.pdu_type);
|
||||
fes = SPDK_NVME_TCP_TERM_REQ_FES_INVALID_HEADER_FIELD;
|
||||
error_offset = 1;
|
||||
nvme_tcp_qpair_send_h2c_term_req(tqpair, pdu, fes, error_offset);
|
||||
@ -1261,7 +1257,7 @@ nvme_tcp_read_pdu(struct nvme_tcp_qpair *tqpair, uint32_t *reaped)
|
||||
if (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);
|
||||
(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;
|
||||
@ -1280,7 +1276,7 @@ nvme_tcp_read_pdu(struct nvme_tcp_qpair *tqpair, uint32_t *reaped)
|
||||
pdu = &tqpair->recv_pdu;
|
||||
rc = nvme_tcp_read_data(tqpair->sock,
|
||||
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);
|
||||
if (rc < 0) {
|
||||
nvme_tcp_qpair_set_recv_state(tqpair, NVME_TCP_PDU_RECV_STATE_ERROR);
|
||||
break;
|
||||
@ -1303,7 +1299,7 @@ nvme_tcp_read_pdu(struct nvme_tcp_qpair *tqpair, uint32_t *reaped)
|
||||
|
||||
data_len = pdu->data_len;
|
||||
/* data digest */
|
||||
if (spdk_unlikely((pdu->hdr->common.pdu_type == SPDK_NVME_TCP_PDU_TYPE_C2H_DATA) &&
|
||||
if (spdk_unlikely((pdu->hdr.common.pdu_type == SPDK_NVME_TCP_PDU_TYPE_C2H_DATA) &&
|
||||
tqpair->host_ddgst_enable)) {
|
||||
data_len += SPDK_NVME_TCP_DIGEST_LEN;
|
||||
pdu->ddgst_enable = true;
|
||||
@ -1439,8 +1435,7 @@ nvme_tcp_qpair_icreq_send(struct nvme_tcp_qpair *tqpair)
|
||||
|
||||
pdu = &tqpair->send_pdu;
|
||||
memset(&tqpair->send_pdu, 0, sizeof(tqpair->send_pdu));
|
||||
pdu->hdr = &pdu->hdr_mem;
|
||||
ic_req = &pdu->hdr->ic_req;
|
||||
ic_req = &pdu->hdr.ic_req;
|
||||
|
||||
ic_req->common.pdu_type = SPDK_NVME_TCP_PDU_TYPE_IC_REQ;
|
||||
ic_req->common.hlen = ic_req->common.plen = sizeof(*ic_req);
|
||||
@ -1565,7 +1560,6 @@ nvme_tcp_ctrlr_create_qpair(struct spdk_nvme_ctrlr *ctrlr,
|
||||
|
||||
tqpair->num_entries = qsize;
|
||||
qpair = &tqpair->qpair;
|
||||
tqpair->recv_pdu.hdr = &tqpair->recv_pdu.hdr_mem;
|
||||
rc = nvme_qpair_init(qpair, qid, ctrlr, qprio, num_requests);
|
||||
if (rc != 0) {
|
||||
free(tqpair);
|
||||
|
@ -303,7 +303,6 @@ nvmf_tcp_req_pdu_init(struct spdk_nvmf_tcp_req *tcp_req)
|
||||
|
||||
memset(tcp_req->pdu, 0, sizeof(*tcp_req->pdu));
|
||||
tcp_req->pdu->qpair = SPDK_CONTAINEROF(tcp_req->req.qpair, struct spdk_nvmf_tcp_qpair, qpair);
|
||||
tcp_req->pdu->hdr = &tcp_req->pdu->hdr_mem;
|
||||
|
||||
return tcp_req->pdu;
|
||||
}
|
||||
@ -718,16 +717,16 @@ spdk_nvmf_tcp_qpair_write_pdu(struct spdk_nvmf_tcp_qpair *tqpair,
|
||||
|
||||
assert(&tqpair->pdu_in_progress != pdu);
|
||||
|
||||
hlen = pdu->hdr->common.hlen;
|
||||
hlen = pdu->hdr.common.hlen;
|
||||
|
||||
/* Header Digest */
|
||||
if (g_nvme_tcp_hdgst[pdu->hdr->common.pdu_type] && tqpair->host_hdgst_enable) {
|
||||
if (g_nvme_tcp_hdgst[pdu->hdr.common.pdu_type] && tqpair->host_hdgst_enable) {
|
||||
crc32c = nvme_tcp_pdu_calc_header_digest(pdu);
|
||||
MAKE_DIGEST_WORD((uint8_t *)pdu->hdr->raw + hlen, crc32c);
|
||||
MAKE_DIGEST_WORD((uint8_t *)pdu->hdr.raw + hlen, crc32c);
|
||||
}
|
||||
|
||||
/* Data Digest */
|
||||
if (pdu->data_len > 0 && g_nvme_tcp_ddgst[pdu->hdr->common.pdu_type] && tqpair->host_ddgst_enable) {
|
||||
if (pdu->data_len > 0 && g_nvme_tcp_ddgst[pdu->hdr.common.pdu_type] && tqpair->host_ddgst_enable) {
|
||||
crc32c = nvme_tcp_pdu_calc_data_digest(pdu);
|
||||
MAKE_DIGEST_WORD(pdu->data_digest, crc32c);
|
||||
}
|
||||
@ -741,8 +740,8 @@ spdk_nvmf_tcp_qpair_write_pdu(struct spdk_nvmf_tcp_qpair *tqpair,
|
||||
pdu->sock_req.cb_fn = _pdu_write_done;
|
||||
pdu->sock_req.cb_arg = pdu;
|
||||
TAILQ_INSERT_TAIL(&tqpair->send_queue, pdu, tailq);
|
||||
if (pdu->hdr->common.pdu_type == SPDK_NVME_TCP_PDU_TYPE_IC_RESP ||
|
||||
pdu->hdr->common.pdu_type == SPDK_NVME_TCP_PDU_TYPE_C2H_TERM_REQ) {
|
||||
if (pdu->hdr.common.pdu_type == SPDK_NVME_TCP_PDU_TYPE_IC_RESP ||
|
||||
pdu->hdr.common.pdu_type == SPDK_NVME_TCP_PDU_TYPE_C2H_TERM_REQ) {
|
||||
rc = spdk_sock_writev(tqpair->sock, pdu->iov, pdu->sock_req.iovcnt);
|
||||
if (rc == mapped_length) {
|
||||
_pdu_write_done(pdu, 0);
|
||||
@ -772,7 +771,6 @@ spdk_nvmf_tcp_qpair_init_mem_resource(struct spdk_nvmf_tcp_qpair *tqpair)
|
||||
tqpair->resource_count = opts->max_queue_depth;
|
||||
|
||||
tqpair->mgmt_pdu.qpair = tqpair;
|
||||
tqpair->mgmt_pdu.hdr = &tqpair->mgmt_pdu.hdr_mem;
|
||||
|
||||
tqpair->reqs = calloc(tqpair->resource_count, sizeof(*tqpair->reqs));
|
||||
if (!tqpair->reqs) {
|
||||
@ -804,7 +802,6 @@ spdk_nvmf_tcp_qpair_init_mem_resource(struct spdk_nvmf_tcp_qpair *tqpair)
|
||||
|
||||
tcp_req->pdu = &tqpair->pdus[i];
|
||||
tcp_req->pdu->qpair = tqpair;
|
||||
tcp_req->pdu->hdr = &tcp_req->pdu->hdr_mem;
|
||||
|
||||
/* Set up memory to receive commands */
|
||||
if (tqpair->bufs) {
|
||||
@ -821,8 +818,6 @@ spdk_nvmf_tcp_qpair_init_mem_resource(struct spdk_nvmf_tcp_qpair *tqpair)
|
||||
tqpair->state_cntr[TCP_REQUEST_STATE_FREE]++;
|
||||
}
|
||||
|
||||
tqpair->pdu_in_progress.hdr = &tqpair->pdu_in_progress.hdr_mem;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -845,7 +840,6 @@ spdk_nvmf_tcp_qpair_init(struct spdk_nvmf_qpair *qpair)
|
||||
|
||||
tqpair->host_hdgst_enable = true;
|
||||
tqpair->host_ddgst_enable = true;
|
||||
tqpair->pdu_in_progress.hdr = &tqpair->pdu_in_progress.hdr_mem;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1038,7 +1032,6 @@ spdk_nvmf_tcp_qpair_set_recv_state(struct spdk_nvmf_tcp_qpair *tqpair,
|
||||
case NVME_TCP_PDU_RECV_STATE_ERROR:
|
||||
case NVME_TCP_PDU_RECV_STATE_AWAIT_PDU_READY:
|
||||
memset(&tqpair->pdu_in_progress, 0, sizeof(tqpair->pdu_in_progress));
|
||||
tqpair->pdu_in_progress.hdr = &tqpair->pdu_in_progress.hdr_mem;
|
||||
break;
|
||||
default:
|
||||
SPDK_ERRLOG("The state(%d) is invalid\n", state);
|
||||
@ -1083,7 +1076,7 @@ spdk_nvmf_tcp_send_c2h_term_req(struct spdk_nvmf_tcp_qpair *tqpair, struct nvme_
|
||||
|
||||
rsp_pdu = &tqpair->mgmt_pdu;
|
||||
|
||||
c2h_term_req = &rsp_pdu->hdr->term_req;
|
||||
c2h_term_req = &rsp_pdu->hdr.term_req;
|
||||
c2h_term_req->common.pdu_type = SPDK_NVME_TCP_PDU_TYPE_C2H_TERM_REQ;
|
||||
c2h_term_req->common.hlen = c2h_term_req_hdr_len;
|
||||
|
||||
@ -1092,11 +1085,11 @@ spdk_nvmf_tcp_send_c2h_term_req(struct spdk_nvmf_tcp_qpair *tqpair, struct nvme_
|
||||
DSET32(&c2h_term_req->fei, error_offset);
|
||||
}
|
||||
|
||||
copy_len = spdk_min(pdu->hdr->common.hlen, SPDK_NVME_TCP_TERM_REQ_ERROR_DATA_MAX_SIZE);
|
||||
copy_len = spdk_min(pdu->hdr.common.hlen, SPDK_NVME_TCP_TERM_REQ_ERROR_DATA_MAX_SIZE);
|
||||
|
||||
/* Copy the error info into the buffer */
|
||||
memcpy((uint8_t *)rsp_pdu->hdr->raw + c2h_term_req_hdr_len, pdu->hdr->raw, copy_len);
|
||||
nvme_tcp_pdu_set_data(rsp_pdu, (uint8_t *)rsp_pdu->hdr->raw + c2h_term_req_hdr_len, copy_len);
|
||||
memcpy((uint8_t *)rsp_pdu->hdr.raw + c2h_term_req_hdr_len, pdu->hdr.raw, copy_len);
|
||||
nvme_tcp_pdu_set_data(rsp_pdu, (uint8_t *)rsp_pdu->hdr.raw + c2h_term_req_hdr_len, copy_len);
|
||||
|
||||
/* Contain the header of the wrong received pdu */
|
||||
c2h_term_req->common.plen = c2h_term_req->common.hlen + copy_len;
|
||||
@ -1112,7 +1105,7 @@ spdk_nvmf_tcp_capsule_cmd_hdr_handle(struct spdk_nvmf_tcp_transport *ttransport,
|
||||
struct spdk_nvmf_tcp_req *tcp_req;
|
||||
|
||||
assert(pdu->psh_valid_bytes == pdu->psh_len);
|
||||
assert(pdu->hdr->common.pdu_type == SPDK_NVME_TCP_PDU_TYPE_CAPSULE_CMD);
|
||||
assert(pdu->hdr.common.pdu_type == SPDK_NVME_TCP_PDU_TYPE_CAPSULE_CMD);
|
||||
|
||||
tcp_req = spdk_nvmf_tcp_req_get(tqpair);
|
||||
if (!tcp_req) {
|
||||
@ -1142,7 +1135,7 @@ spdk_nvmf_tcp_capsule_cmd_payload_handle(struct spdk_nvmf_tcp_transport *ttransp
|
||||
uint32_t error_offset = 0;
|
||||
enum spdk_nvme_tcp_term_req_fes fes;
|
||||
|
||||
capsule_cmd = &pdu->hdr->capsule_cmd;
|
||||
capsule_cmd = &pdu->hdr.capsule_cmd;
|
||||
tcp_req = pdu->req;
|
||||
assert(tcp_req != NULL);
|
||||
if (capsule_cmd->common.pdo > SPDK_NVME_TCP_PDU_PDO_MAX_OFFSET) {
|
||||
@ -1200,7 +1193,7 @@ spdk_nvmf_tcp_h2c_data_hdr_handle(struct spdk_nvmf_tcp_transport *ttransport,
|
||||
struct spdk_nvme_tcp_h2c_data_hdr *h2c_data;
|
||||
int rc;
|
||||
|
||||
h2c_data = &pdu->hdr->h2c_data;
|
||||
h2c_data = &pdu->hdr.h2c_data;
|
||||
|
||||
SPDK_DEBUGLOG(SPDK_LOG_NVMF_TCP, "tqpair=%p, r2t_info: datao=%u, datal=%u, cccid=%u, ttag=%u\n",
|
||||
tqpair, h2c_data->datao, h2c_data->datal, h2c_data->cccid, h2c_data->ttag);
|
||||
@ -1273,7 +1266,7 @@ spdk_nvmf_tcp_send_capsule_resp_pdu(struct spdk_nvmf_tcp_req *tcp_req,
|
||||
rsp_pdu = nvmf_tcp_req_pdu_init(tcp_req);
|
||||
assert(rsp_pdu != NULL);
|
||||
|
||||
capsule_resp = &rsp_pdu->hdr->capsule_resp;
|
||||
capsule_resp = &rsp_pdu->hdr.capsule_resp;
|
||||
capsule_resp->common.pdu_type = SPDK_NVME_TCP_PDU_TYPE_CAPSULE_RESP;
|
||||
capsule_resp->common.plen = capsule_resp->common.hlen = sizeof(*capsule_resp);
|
||||
capsule_resp->rccqe = tcp_req->req.rsp->nvme_cpl;
|
||||
@ -1330,7 +1323,7 @@ spdk_nvmf_tcp_send_r2t_pdu(struct spdk_nvmf_tcp_qpair *tqpair,
|
||||
rsp_pdu = nvmf_tcp_req_pdu_init(tcp_req);
|
||||
assert(rsp_pdu != NULL);
|
||||
|
||||
r2t = &rsp_pdu->hdr->r2t;
|
||||
r2t = &rsp_pdu->hdr.r2t;
|
||||
r2t->common.pdu_type = SPDK_NVME_TCP_PDU_TYPE_R2T;
|
||||
r2t->common.plen = r2t->common.hlen = sizeof(*r2t);
|
||||
|
||||
@ -1393,7 +1386,7 @@ static void
|
||||
spdk_nvmf_tcp_h2c_term_req_hdr_handle(struct spdk_nvmf_tcp_qpair *tqpair,
|
||||
struct nvme_tcp_pdu *pdu)
|
||||
{
|
||||
struct spdk_nvme_tcp_term_req_hdr *h2c_term_req = &pdu->hdr->term_req;
|
||||
struct spdk_nvme_tcp_term_req_hdr *h2c_term_req = &pdu->hdr.term_req;
|
||||
uint32_t error_offset = 0;
|
||||
enum spdk_nvme_tcp_term_req_fes fes;
|
||||
|
||||
@ -1406,7 +1399,7 @@ spdk_nvmf_tcp_h2c_term_req_hdr_handle(struct spdk_nvmf_tcp_qpair *tqpair,
|
||||
}
|
||||
|
||||
/* set the data buffer */
|
||||
nvme_tcp_pdu_set_data(pdu, (uint8_t *)pdu->hdr->raw + h2c_term_req->common.hlen,
|
||||
nvme_tcp_pdu_set_data(pdu, (uint8_t *)pdu->hdr.raw + h2c_term_req->common.hlen,
|
||||
h2c_term_req->common.plen - h2c_term_req->common.hlen);
|
||||
spdk_nvmf_tcp_qpair_set_recv_state(tqpair, NVME_TCP_PDU_RECV_STATE_AWAIT_PDU_PAYLOAD);
|
||||
return;
|
||||
@ -1418,7 +1411,7 @@ static void
|
||||
spdk_nvmf_tcp_h2c_term_req_payload_handle(struct spdk_nvmf_tcp_qpair *tqpair,
|
||||
struct nvme_tcp_pdu *pdu)
|
||||
{
|
||||
struct spdk_nvme_tcp_term_req_hdr *h2c_term_req = &pdu->hdr->term_req;
|
||||
struct spdk_nvme_tcp_term_req_hdr *h2c_term_req = &pdu->hdr.term_req;
|
||||
|
||||
spdk_nvmf_tcp_h2c_term_req_dump(h2c_term_req);
|
||||
spdk_nvmf_tcp_qpair_set_recv_state(tqpair, NVME_TCP_PDU_RECV_STATE_ERROR);
|
||||
@ -1450,7 +1443,7 @@ spdk_nvmf_tcp_pdu_payload_handle(struct spdk_nvmf_tcp_qpair *tqpair,
|
||||
}
|
||||
}
|
||||
|
||||
switch (pdu->hdr->common.pdu_type) {
|
||||
switch (pdu->hdr.common.pdu_type) {
|
||||
case SPDK_NVME_TCP_PDU_TYPE_CAPSULE_CMD:
|
||||
spdk_nvmf_tcp_capsule_cmd_payload_handle(ttransport, tqpair, pdu);
|
||||
break;
|
||||
@ -1482,7 +1475,7 @@ spdk_nvmf_tcp_icreq_handle(struct spdk_nvmf_tcp_transport *ttransport,
|
||||
struct spdk_nvmf_tcp_qpair *tqpair,
|
||||
struct nvme_tcp_pdu *pdu)
|
||||
{
|
||||
struct spdk_nvme_tcp_ic_req *ic_req = &pdu->hdr->ic_req;
|
||||
struct spdk_nvme_tcp_ic_req *ic_req = &pdu->hdr.ic_req;
|
||||
struct nvme_tcp_pdu *rsp_pdu;
|
||||
struct spdk_nvme_tcp_ic_resp *ic_resp;
|
||||
uint32_t error_offset = 0;
|
||||
@ -1507,7 +1500,7 @@ spdk_nvmf_tcp_icreq_handle(struct spdk_nvmf_tcp_transport *ttransport,
|
||||
|
||||
rsp_pdu = &tqpair->mgmt_pdu;
|
||||
|
||||
ic_resp = &rsp_pdu->hdr->ic_resp;
|
||||
ic_resp = &rsp_pdu->hdr.ic_resp;
|
||||
ic_resp->common.pdu_type = SPDK_NVME_TCP_PDU_TYPE_IC_RESP;
|
||||
ic_resp->common.hlen = ic_resp->common.plen = sizeof(*ic_resp);
|
||||
ic_resp->pfv = 0;
|
||||
@ -1540,12 +1533,12 @@ spdk_nvmf_tcp_pdu_psh_handle(struct spdk_nvmf_tcp_qpair *tqpair,
|
||||
pdu = &tqpair->pdu_in_progress;
|
||||
|
||||
SPDK_DEBUGLOG(SPDK_LOG_NVMF_TCP, "pdu type of tqpair(%p) is %d\n", tqpair,
|
||||
pdu->hdr->common.pdu_type);
|
||||
pdu->hdr.common.pdu_type);
|
||||
/* check header digest if needed */
|
||||
if (pdu->has_hdgst) {
|
||||
SPDK_DEBUGLOG(SPDK_LOG_NVMF_TCP, "Compare the header of pdu=%p on tqpair=%p\n", pdu, tqpair);
|
||||
crc32c = nvme_tcp_pdu_calc_header_digest(pdu);
|
||||
rc = MATCH_DIGEST_WORD((uint8_t *)pdu->hdr->raw + pdu->hdr->common.hlen, crc32c);
|
||||
rc = MATCH_DIGEST_WORD((uint8_t *)pdu->hdr.raw + pdu->hdr.common.hlen, crc32c);
|
||||
if (rc == 0) {
|
||||
SPDK_ERRLOG("Header digest error on tqpair=(%p) with pdu=%p\n", tqpair, pdu);
|
||||
fes = SPDK_NVME_TCP_TERM_REQ_FES_HDGST_ERROR;
|
||||
@ -1555,7 +1548,7 @@ spdk_nvmf_tcp_pdu_psh_handle(struct spdk_nvmf_tcp_qpair *tqpair,
|
||||
}
|
||||
}
|
||||
|
||||
switch (pdu->hdr->common.pdu_type) {
|
||||
switch (pdu->hdr.common.pdu_type) {
|
||||
case SPDK_NVME_TCP_PDU_TYPE_IC_REQ:
|
||||
spdk_nvmf_tcp_icreq_handle(ttransport, tqpair, pdu);
|
||||
break;
|
||||
@ -1571,7 +1564,7 @@ spdk_nvmf_tcp_pdu_psh_handle(struct spdk_nvmf_tcp_qpair *tqpair,
|
||||
break;
|
||||
|
||||
default:
|
||||
SPDK_ERRLOG("Unexpected PDU type 0x%02x\n", tqpair->pdu_in_progress.hdr->common.pdu_type);
|
||||
SPDK_ERRLOG("Unexpected PDU type 0x%02x\n", tqpair->pdu_in_progress.hdr.common.pdu_type);
|
||||
fes = SPDK_NVME_TCP_TERM_REQ_FES_INVALID_HEADER_FIELD;
|
||||
error_offset = 1;
|
||||
spdk_nvmf_tcp_send_c2h_term_req(tqpair, pdu, fes, error_offset);
|
||||
@ -1591,14 +1584,14 @@ spdk_nvmf_tcp_pdu_ch_handle(struct spdk_nvmf_tcp_qpair *tqpair)
|
||||
assert(tqpair->recv_state == NVME_TCP_PDU_RECV_STATE_AWAIT_PDU_CH);
|
||||
pdu = &tqpair->pdu_in_progress;
|
||||
|
||||
if (pdu->hdr->common.pdu_type == SPDK_NVME_TCP_PDU_TYPE_IC_REQ) {
|
||||
if (pdu->hdr.common.pdu_type == SPDK_NVME_TCP_PDU_TYPE_IC_REQ) {
|
||||
if (tqpair->state != NVME_TCP_QPAIR_STATE_INVALID) {
|
||||
SPDK_ERRLOG("Already received ICreq PDU, and reject this pdu=%p\n", pdu);
|
||||
fes = SPDK_NVME_TCP_TERM_REQ_FES_PDU_SEQUENCE_ERROR;
|
||||
goto err;
|
||||
}
|
||||
expected_hlen = sizeof(struct spdk_nvme_tcp_ic_req);
|
||||
if (pdu->hdr->common.plen != expected_hlen) {
|
||||
if (pdu->hdr.common.plen != expected_hlen) {
|
||||
plen_error = true;
|
||||
}
|
||||
} else {
|
||||
@ -1608,51 +1601,51 @@ spdk_nvmf_tcp_pdu_ch_handle(struct spdk_nvmf_tcp_qpair *tqpair)
|
||||
goto err;
|
||||
}
|
||||
|
||||
switch (pdu->hdr->common.pdu_type) {
|
||||
switch (pdu->hdr.common.pdu_type) {
|
||||
case SPDK_NVME_TCP_PDU_TYPE_CAPSULE_CMD:
|
||||
expected_hlen = sizeof(struct spdk_nvme_tcp_cmd);
|
||||
pdo = pdu->hdr->common.pdo;
|
||||
pdo = pdu->hdr.common.pdo;
|
||||
if ((tqpair->cpda != 0) && (pdo != ((tqpair->cpda + 1) << 2))) {
|
||||
pdo_error = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (pdu->hdr->common.plen < expected_hlen) {
|
||||
if (pdu->hdr.common.plen < expected_hlen) {
|
||||
plen_error = true;
|
||||
}
|
||||
break;
|
||||
case SPDK_NVME_TCP_PDU_TYPE_H2C_DATA:
|
||||
expected_hlen = sizeof(struct spdk_nvme_tcp_h2c_data_hdr);
|
||||
pdo = pdu->hdr->common.pdo;
|
||||
pdo = pdu->hdr.common.pdo;
|
||||
if ((tqpair->cpda != 0) && (pdo != ((tqpair->cpda + 1) << 2))) {
|
||||
pdo_error = true;
|
||||
break;
|
||||
}
|
||||
if (pdu->hdr->common.plen < expected_hlen) {
|
||||
if (pdu->hdr.common.plen < expected_hlen) {
|
||||
plen_error = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case SPDK_NVME_TCP_PDU_TYPE_H2C_TERM_REQ:
|
||||
expected_hlen = sizeof(struct spdk_nvme_tcp_term_req_hdr);
|
||||
if ((pdu->hdr->common.plen <= expected_hlen) ||
|
||||
(pdu->hdr->common.plen > SPDK_NVME_TCP_TERM_REQ_PDU_MAX_SIZE)) {
|
||||
if ((pdu->hdr.common.plen <= expected_hlen) ||
|
||||
(pdu->hdr.common.plen > SPDK_NVME_TCP_TERM_REQ_PDU_MAX_SIZE)) {
|
||||
plen_error = true;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
SPDK_ERRLOG("Unexpected PDU type 0x%02x\n", pdu->hdr->common.pdu_type);
|
||||
SPDK_ERRLOG("Unexpected PDU type 0x%02x\n", pdu->hdr.common.pdu_type);
|
||||
fes = SPDK_NVME_TCP_TERM_REQ_FES_INVALID_HEADER_FIELD;
|
||||
error_offset = offsetof(struct spdk_nvme_tcp_common_pdu_hdr, pdu_type);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
if (pdu->hdr->common.hlen != expected_hlen) {
|
||||
if (pdu->hdr.common.hlen != expected_hlen) {
|
||||
SPDK_ERRLOG("PDU type=0x%02x, Expected ICReq header length %u, got %u on tqpair=%p\n",
|
||||
pdu->hdr->common.pdu_type,
|
||||
expected_hlen, pdu->hdr->common.hlen, tqpair);
|
||||
pdu->hdr.common.pdu_type,
|
||||
expected_hlen, pdu->hdr.common.hlen, tqpair);
|
||||
fes = SPDK_NVME_TCP_TERM_REQ_FES_INVALID_HEADER_FIELD;
|
||||
error_offset = offsetof(struct spdk_nvme_tcp_common_pdu_hdr, hlen);
|
||||
goto err;
|
||||
@ -1715,7 +1708,7 @@ spdk_nvmf_tcp_sock_process(struct spdk_nvmf_tcp_qpair *tqpair)
|
||||
|
||||
rc = nvme_tcp_read_data(tqpair->sock,
|
||||
sizeof(struct spdk_nvme_tcp_common_pdu_hdr) - pdu->ch_valid_bytes,
|
||||
(void *)&pdu->hdr->common + pdu->ch_valid_bytes);
|
||||
(void *)&pdu->hdr.common + pdu->ch_valid_bytes);
|
||||
if (rc < 0) {
|
||||
SPDK_DEBUGLOG(SPDK_LOG_NVMF_TCP, "will disconnect tqpair=%p\n", tqpair);
|
||||
return NVME_TCP_PDU_FATAL;
|
||||
@ -1738,7 +1731,7 @@ spdk_nvmf_tcp_sock_process(struct spdk_nvmf_tcp_qpair *tqpair)
|
||||
case NVME_TCP_PDU_RECV_STATE_AWAIT_PDU_PSH:
|
||||
rc = nvme_tcp_read_data(tqpair->sock,
|
||||
pdu->psh_len - pdu->psh_valid_bytes,
|
||||
(void *)&pdu->hdr->raw + sizeof(struct spdk_nvme_tcp_common_pdu_hdr) + pdu->psh_valid_bytes);
|
||||
(void *)&pdu->hdr.raw + sizeof(struct spdk_nvme_tcp_common_pdu_hdr) + pdu->psh_valid_bytes);
|
||||
if (rc < 0) {
|
||||
return NVME_TCP_PDU_FATAL;
|
||||
} else if (rc > 0) {
|
||||
@ -1768,7 +1761,7 @@ spdk_nvmf_tcp_sock_process(struct spdk_nvmf_tcp_qpair *tqpair)
|
||||
|
||||
data_len = pdu->data_len;
|
||||
/* data digest */
|
||||
if (spdk_unlikely((pdu->hdr->common.pdu_type != SPDK_NVME_TCP_PDU_TYPE_H2C_TERM_REQ) &&
|
||||
if (spdk_unlikely((pdu->hdr.common.pdu_type != SPDK_NVME_TCP_PDU_TYPE_H2C_TERM_REQ) &&
|
||||
tqpair->host_ddgst_enable)) {
|
||||
data_len += SPDK_NVME_TCP_DIGEST_LEN;
|
||||
pdu->ddgst_enable = true;
|
||||
@ -1943,7 +1936,7 @@ spdk_nvmf_tcp_send_c2h_data(struct spdk_nvmf_tcp_qpair *tqpair,
|
||||
rsp_pdu = nvmf_tcp_req_pdu_init(tcp_req);
|
||||
assert(rsp_pdu != NULL);
|
||||
|
||||
c2h_data = &rsp_pdu->hdr->c2h_data;
|
||||
c2h_data = &rsp_pdu->hdr.c2h_data;
|
||||
c2h_data->common.pdu_type = SPDK_NVME_TCP_PDU_TYPE_C2H_DATA;
|
||||
plen = c2h_data->common.hlen = sizeof(*c2h_data);
|
||||
|
||||
@ -2050,13 +2043,13 @@ spdk_nvmf_tcp_set_incapsule_data(struct spdk_nvmf_tcp_qpair *tqpair,
|
||||
uint32_t plen = 0;
|
||||
|
||||
pdu = &tqpair->pdu_in_progress;
|
||||
plen = pdu->hdr->common.hlen;
|
||||
plen = pdu->hdr.common.hlen;
|
||||
|
||||
if (tqpair->host_hdgst_enable) {
|
||||
plen += SPDK_NVME_TCP_DIGEST_LEN;
|
||||
}
|
||||
|
||||
if (pdu->hdr->common.plen != plen) {
|
||||
if (pdu->hdr.common.plen != plen) {
|
||||
tcp_req->has_incapsule_data = true;
|
||||
}
|
||||
}
|
||||
@ -2092,7 +2085,7 @@ spdk_nvmf_tcp_req_process(struct spdk_nvmf_tcp_transport *ttransport,
|
||||
spdk_trace_record(TRACE_TCP_REQUEST_STATE_NEW, 0, 0, (uintptr_t)tcp_req, 0);
|
||||
|
||||
/* copy the cmd from the receive pdu */
|
||||
tcp_req->cmd = tqpair->pdu_in_progress.hdr->capsule_cmd.ccsqe;
|
||||
tcp_req->cmd = tqpair->pdu_in_progress.hdr.capsule_cmd.ccsqe;
|
||||
|
||||
if (spdk_unlikely(spdk_nvmf_request_get_dif_ctx(&tcp_req->req, &tcp_req->req.dif.dif_ctx))) {
|
||||
tcp_req->req.dif.dif_insert_or_strip = true;
|
||||
|
@ -53,7 +53,6 @@ test_nvme_tcp_pdu_set_data_buf(void)
|
||||
uint32_t data_len;
|
||||
uint64_t i;
|
||||
|
||||
pdu.hdr = &pdu.hdr_mem;
|
||||
/* 1st case: input is a single SGL entry. */
|
||||
iov[0].iov_base = (void *)0xDEADBEEF;
|
||||
iov[0].iov_len = 4096;
|
||||
@ -122,11 +121,10 @@ test_nvme_tcp_build_iovs(void)
|
||||
uint32_t mapped_length = 0;
|
||||
int rc;
|
||||
|
||||
pdu.hdr = &pdu.hdr_mem;
|
||||
pdu.hdr->common.pdu_type = SPDK_NVME_TCP_PDU_TYPE_CAPSULE_CMD;
|
||||
pdu.hdr->common.hlen = sizeof(struct spdk_nvme_tcp_cmd);
|
||||
pdu.hdr->common.plen = pdu.hdr->common.hlen + SPDK_NVME_TCP_DIGEST_LEN + pdu_iov_len * 2 +
|
||||
SPDK_NVME_TCP_DIGEST_LEN;
|
||||
pdu.hdr.common.pdu_type = SPDK_NVME_TCP_PDU_TYPE_CAPSULE_CMD;
|
||||
pdu.hdr.common.hlen = sizeof(struct spdk_nvme_tcp_cmd);
|
||||
pdu.hdr.common.plen = pdu.hdr.common.hlen + SPDK_NVME_TCP_DIGEST_LEN + pdu_iov_len * 2 +
|
||||
SPDK_NVME_TCP_DIGEST_LEN;
|
||||
pdu.data_len = pdu_iov_len * 2;
|
||||
pdu.padding_len = 0;
|
||||
|
||||
@ -138,7 +136,7 @@ test_nvme_tcp_build_iovs(void)
|
||||
|
||||
rc = nvme_tcp_build_iovs(iovs, 5, &pdu, true, true, &mapped_length);
|
||||
CU_ASSERT(rc == 4);
|
||||
CU_ASSERT(iovs[0].iov_base == (void *)&pdu.hdr->raw);
|
||||
CU_ASSERT(iovs[0].iov_base == (void *)&pdu.hdr.raw);
|
||||
CU_ASSERT(iovs[0].iov_len == sizeof(struct spdk_nvme_tcp_cmd) + SPDK_NVME_TCP_DIGEST_LEN);
|
||||
CU_ASSERT(iovs[1].iov_base == (void *)0xDEADBEEF);
|
||||
CU_ASSERT(iovs[1].iov_len == pdu_iov_len);
|
||||
@ -154,11 +152,11 @@ test_nvme_tcp_build_iovs(void)
|
||||
pdu.data_iov[2].iov_len = 123;
|
||||
pdu.data_iovcnt = 3;
|
||||
pdu.data_len += 123;
|
||||
pdu.hdr->common.plen += 123;
|
||||
pdu.hdr.common.plen += 123;
|
||||
|
||||
rc = nvme_tcp_build_iovs(iovs, 5, &pdu, true, true, &mapped_length);
|
||||
CU_ASSERT(rc == 5);
|
||||
CU_ASSERT(iovs[0].iov_base == (void *)&pdu.hdr->raw);
|
||||
CU_ASSERT(iovs[0].iov_base == (void *)&pdu.hdr.raw);
|
||||
CU_ASSERT(iovs[0].iov_len == sizeof(struct spdk_nvme_tcp_cmd) + SPDK_NVME_TCP_DIGEST_LEN);
|
||||
CU_ASSERT(iovs[1].iov_base == (void *)0xDEADBEEF);
|
||||
CU_ASSERT(iovs[1].iov_len == pdu_iov_len);
|
||||
@ -293,7 +291,6 @@ test_nvme_tcp_pdu_set_data_buf_with_md(void)
|
||||
struct spdk_dif_ctx dif_ctx = {};
|
||||
int rc;
|
||||
|
||||
pdu.hdr = &pdu.hdr_mem;
|
||||
pdu.dif_ctx = &dif_ctx;
|
||||
|
||||
rc = spdk_dif_ctx_init(&dif_ctx, 520, 8, true, false, SPDK_DIF_DISABLE, 0,
|
||||
@ -390,17 +387,16 @@ test_nvme_tcp_build_iovs_with_md(void)
|
||||
uint32_t mapped_length = 0;
|
||||
int rc;
|
||||
|
||||
pdu.hdr = &pdu.hdr_mem;
|
||||
rc = spdk_dif_ctx_init(&dif_ctx, 520, 8, true, false, SPDK_DIF_DISABLE, 0,
|
||||
0, 0, 0, 0, 0);
|
||||
CU_ASSERT(rc == 0);
|
||||
|
||||
pdu.dif_ctx = &dif_ctx;
|
||||
|
||||
pdu.hdr->common.pdu_type = SPDK_NVME_TCP_PDU_TYPE_CAPSULE_CMD;
|
||||
pdu.hdr->common.hlen = sizeof(struct spdk_nvme_tcp_cmd);
|
||||
pdu.hdr->common.plen = pdu.hdr->common.hlen + SPDK_NVME_TCP_DIGEST_LEN + 512 * 8 +
|
||||
SPDK_NVME_TCP_DIGEST_LEN;
|
||||
pdu.hdr.common.pdu_type = SPDK_NVME_TCP_PDU_TYPE_CAPSULE_CMD;
|
||||
pdu.hdr.common.hlen = sizeof(struct spdk_nvme_tcp_cmd);
|
||||
pdu.hdr.common.plen = pdu.hdr.common.hlen + SPDK_NVME_TCP_DIGEST_LEN + 512 * 8 +
|
||||
SPDK_NVME_TCP_DIGEST_LEN;
|
||||
pdu.data_len = 512 * 8;
|
||||
pdu.padding_len = 0;
|
||||
|
||||
@ -410,7 +406,7 @@ test_nvme_tcp_build_iovs_with_md(void)
|
||||
|
||||
rc = nvme_tcp_build_iovs(iovs, 11, &pdu, true, true, &mapped_length);
|
||||
CU_ASSERT(rc == 10);
|
||||
CU_ASSERT(iovs[0].iov_base == (void *)&pdu.hdr->raw);
|
||||
CU_ASSERT(iovs[0].iov_base == (void *)&pdu.hdr.raw);
|
||||
CU_ASSERT(iovs[0].iov_len == sizeof(struct spdk_nvme_tcp_cmd) + SPDK_NVME_TCP_DIGEST_LEN);
|
||||
CU_ASSERT(iovs[1].iov_base == (void *)0xDEADBEEF);
|
||||
CU_ASSERT(iovs[1].iov_len == 512);
|
||||
|
@ -475,7 +475,6 @@ test_nvmf_tcp_send_c2h_data(void)
|
||||
struct nvme_tcp_pdu pdu = {};
|
||||
struct spdk_nvme_tcp_c2h_data_hdr *c2h_data;
|
||||
|
||||
pdu.hdr = &pdu.hdr_mem;
|
||||
thread = spdk_thread_create(NULL, NULL);
|
||||
SPDK_CU_ASSERT_FATAL(thread != NULL);
|
||||
spdk_set_thread(thread);
|
||||
@ -506,7 +505,7 @@ test_nvmf_tcp_send_c2h_data(void)
|
||||
CU_ASSERT(TAILQ_FIRST(&tqpair.send_queue) == &pdu);
|
||||
TAILQ_REMOVE(&tqpair.send_queue, &pdu, tailq);
|
||||
|
||||
c2h_data = &pdu.hdr->c2h_data;
|
||||
c2h_data = &pdu.hdr.c2h_data;
|
||||
CU_ASSERT(c2h_data->datao == 0);
|
||||
CU_ASSERT(c2h_data->datal = 300);
|
||||
CU_ASSERT(c2h_data->common.plen == sizeof(*c2h_data) + 300);
|
||||
@ -535,7 +534,6 @@ test_nvmf_tcp_h2c_data_hdr_handle(void)
|
||||
struct spdk_nvmf_tcp_req tcp_req = {};
|
||||
struct spdk_nvme_tcp_h2c_data_hdr *h2c_data;
|
||||
|
||||
pdu.hdr = &pdu.hdr_mem;
|
||||
TAILQ_INIT(&tqpair.state_queue[TCP_REQUEST_STATE_TRANSFERRING_HOST_TO_CONTROLLER]);
|
||||
|
||||
/* Set qpair state to make unrelated operations NOP */
|
||||
@ -556,7 +554,7 @@ test_nvmf_tcp_h2c_data_hdr_handle(void)
|
||||
TAILQ_INSERT_TAIL(&tqpair.state_queue[TCP_REQUEST_STATE_TRANSFERRING_HOST_TO_CONTROLLER],
|
||||
&tcp_req, state_link);
|
||||
|
||||
h2c_data = &pdu.hdr->h2c_data;
|
||||
h2c_data = &pdu.hdr.h2c_data;
|
||||
h2c_data->cccid = 1;
|
||||
h2c_data->ttag = 2;
|
||||
h2c_data->datao = 0;
|
||||
@ -582,14 +580,13 @@ test_nvmf_tcp_incapsule_data_handle(void)
|
||||
{
|
||||
struct spdk_nvmf_tcp_transport ttransport = {};
|
||||
struct spdk_nvmf_tcp_qpair tqpair = {};
|
||||
struct nvme_tcp_pdu pdu = {};
|
||||
struct nvme_tcp_pdu *pdu;
|
||||
union nvmf_c2h_msg rsp0 = {};
|
||||
union nvmf_c2h_msg rsp = {};
|
||||
|
||||
struct spdk_nvmf_request *req_temp = NULL;
|
||||
struct spdk_nvmf_tcp_req tcp_req2 = {};
|
||||
struct spdk_nvmf_tcp_req tcp_req1 = {};
|
||||
union nvme_tcp_pdu_hdr hdr = {};
|
||||
|
||||
struct spdk_nvme_tcp_cmd *capsule_data;
|
||||
struct spdk_nvmf_capsule_cmd *nvmf_capsule_data;
|
||||
@ -611,7 +608,6 @@ test_nvmf_tcp_incapsule_data_handle(void)
|
||||
tqpair.group = &tcp_group;
|
||||
|
||||
/* init tqpair, add pdu to pdu_in_progress and wait for the buff */
|
||||
pdu.hdr = &pdu.hdr_mem;
|
||||
for (i = TCP_REQUEST_STATE_FREE; i < TCP_REQUEST_NUM_STATES; i++) {
|
||||
TAILQ_INIT(&tqpair.state_queue[i]);
|
||||
}
|
||||
@ -621,7 +617,6 @@ test_nvmf_tcp_incapsule_data_handle(void)
|
||||
TAILQ_INSERT_TAIL(&tqpair.state_queue[TCP_REQUEST_STATE_FREE], &tcp_req2, state_link);
|
||||
tqpair.state_cntr[TCP_REQUEST_STATE_FREE]++;
|
||||
tqpair.qpair.transport = &ttransport.transport;
|
||||
tqpair.pdu_in_progress.hdr = &hdr;
|
||||
tqpair.state = NVME_TCP_QPAIR_STATE_RUNNING;
|
||||
tqpair.recv_state = NVME_TCP_PDU_RECV_STATE_AWAIT_PDU_PSH;
|
||||
|
||||
@ -640,8 +635,9 @@ test_nvmf_tcp_incapsule_data_handle(void)
|
||||
tqpair.state_cntr[TCP_REQUEST_STATE_NEW]++;
|
||||
|
||||
/* init pdu, make pdu need sgl buff */
|
||||
capsule_data = &pdu.hdr->capsule_cmd;
|
||||
nvmf_capsule_data = (struct spdk_nvmf_capsule_cmd *)&pdu.hdr->capsule_cmd.ccsqe;
|
||||
pdu = &tqpair.pdu_in_progress;
|
||||
capsule_data = &pdu->hdr.capsule_cmd;
|
||||
nvmf_capsule_data = (struct spdk_nvmf_capsule_cmd *)&pdu->hdr.capsule_cmd.ccsqe;
|
||||
sgl = &capsule_data->ccsqe.dptr.sgl1;
|
||||
|
||||
capsule_data->common.pdu_type = SPDK_NVME_TCP_PDU_TYPE_CAPSULE_CMD;
|
||||
@ -651,11 +647,9 @@ test_nvmf_tcp_incapsule_data_handle(void)
|
||||
|
||||
sgl->unkeyed.subtype = SPDK_NVME_SGL_SUBTYPE_TRANSPORT;
|
||||
sgl->generic.type = SPDK_NVME_SGL_TYPE_TRANSPORT_DATA_BLOCK;
|
||||
sgl = &pdu.hdr->capsule_cmd.ccsqe.dptr.sgl1;
|
||||
sgl->unkeyed.length = UT_IO_UNIT_SIZE;
|
||||
|
||||
nvmf_capsule_data->fctype = SPDK_NVMF_FABRIC_COMMAND_CONNECT;
|
||||
tqpair.pdu_in_progress = pdu;
|
||||
|
||||
/* insert tcp_req1 to pending_buf_queue, And this req takes precedence over the next req. */
|
||||
spdk_nvmf_tcp_req_process(&ttransport, &tcp_req1);
|
||||
|
Loading…
Reference in New Issue
Block a user