iscsi: do not caculate the CRC in multiple times
Since a PDU can be sentout in many times, so this function is called multiple times, so move the caculation function in spdk_iscsi_conn_write_pdu Change-Id: Ib4da4a74c17709d98e4b01c2e76428021afea947 Signed-off-by: Ziye Yang <ziye.yang@intel.com> Reviewed-on: https://review.gerrithub.io/429931 (master) Reviewed-on: https://review.gerrithub.io/435681 Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
e2cdfd0ce6
commit
3cbfbbf62f
@ -51,6 +51,12 @@
|
||||
#include "iscsi/tgt_node.h"
|
||||
#include "iscsi/portal_grp.h"
|
||||
|
||||
#define MAKE_DIGEST_WORD(BUF, CRC32C) \
|
||||
( ((*((uint8_t *)(BUF)+0)) = (uint8_t)((uint32_t)(CRC32C) >> 0)), \
|
||||
((*((uint8_t *)(BUF)+1)) = (uint8_t)((uint32_t)(CRC32C) >> 8)), \
|
||||
((*((uint8_t *)(BUF)+2)) = (uint8_t)((uint32_t)(CRC32C) >> 16)), \
|
||||
((*((uint8_t *)(BUF)+3)) = (uint8_t)((uint32_t)(CRC32C) >> 24)))
|
||||
|
||||
#define SPDK_ISCSI_CONNECTION_MEMSET(conn) \
|
||||
memset(&(conn)->portal, 0, sizeof(*(conn)) - \
|
||||
offsetof(struct spdk_iscsi_conn, portal));
|
||||
@ -1261,6 +1267,22 @@ spdk_iscsi_conn_flush_pdus(void *_conn)
|
||||
void
|
||||
spdk_iscsi_conn_write_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
|
||||
{
|
||||
uint32_t crc32c;
|
||||
|
||||
if (pdu->bhs.opcode != ISCSI_OP_LOGIN_RSP) {
|
||||
/* Header Digest */
|
||||
if (conn->header_digest) {
|
||||
crc32c = spdk_iscsi_pdu_calc_header_digest(pdu);
|
||||
MAKE_DIGEST_WORD(pdu->header_digest, crc32c);
|
||||
}
|
||||
|
||||
/* Data Digest */
|
||||
if (conn->data_digest && DGET24(pdu->bhs.data_segment_len) != 0) {
|
||||
crc32c = spdk_iscsi_pdu_calc_data_digest(pdu);
|
||||
MAKE_DIGEST_WORD(pdu->data_digest, crc32c);
|
||||
}
|
||||
}
|
||||
|
||||
TAILQ_INSERT_TAIL(&conn->write_pdu_list, pdu, tailq);
|
||||
spdk_iscsi_conn_flush_pdus(conn);
|
||||
}
|
||||
|
@ -117,12 +117,6 @@ static int spdk_iscsi_reject(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu
|
||||
| (((uint32_t) *((uint8_t *)(BUF)+3)) << 24)) \
|
||||
== (CRC32C))
|
||||
|
||||
#define MAKE_DIGEST_WORD(BUF, CRC32C) \
|
||||
( ((*((uint8_t *)(BUF)+0)) = (uint8_t)((uint32_t)(CRC32C) >> 0)), \
|
||||
((*((uint8_t *)(BUF)+1)) = (uint8_t)((uint32_t)(CRC32C) >> 8)), \
|
||||
((*((uint8_t *)(BUF)+2)) = (uint8_t)((uint32_t)(CRC32C) >> 16)), \
|
||||
((*((uint8_t *)(BUF)+3)) = (uint8_t)((uint32_t)(CRC32C) >> 24)))
|
||||
|
||||
#if 0
|
||||
static int
|
||||
spdk_match_digest_word(const uint8_t *buf, uint32_t crc32c)
|
||||
@ -307,7 +301,7 @@ spdk_islun2lun(uint64_t islun)
|
||||
return lun_i;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
uint32_t
|
||||
spdk_iscsi_pdu_calc_header_digest(struct spdk_iscsi_pdu *pdu)
|
||||
{
|
||||
uint32_t crc32c;
|
||||
@ -325,7 +319,7 @@ spdk_iscsi_pdu_calc_header_digest(struct spdk_iscsi_pdu *pdu)
|
||||
return crc32c;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
uint32_t
|
||||
spdk_iscsi_pdu_calc_data_digest(struct spdk_iscsi_pdu *pdu)
|
||||
{
|
||||
uint32_t data_len = DGET24(pdu->bhs.data_segment_len);
|
||||
@ -573,7 +567,6 @@ spdk_iscsi_build_iovecs(struct spdk_iscsi_conn *conn, struct iovec *iovec,
|
||||
struct spdk_iscsi_pdu *pdu)
|
||||
{
|
||||
int iovec_cnt = 0;
|
||||
uint32_t crc32c;
|
||||
int enable_digest;
|
||||
int total_ahs_len;
|
||||
int data_len;
|
||||
@ -601,9 +594,6 @@ spdk_iscsi_build_iovecs(struct spdk_iscsi_conn *conn, struct iovec *iovec,
|
||||
|
||||
/* Header Digest */
|
||||
if (enable_digest && conn->header_digest) {
|
||||
crc32c = spdk_iscsi_pdu_calc_header_digest(pdu);
|
||||
MAKE_DIGEST_WORD(pdu->header_digest, crc32c);
|
||||
|
||||
iovec[iovec_cnt].iov_base = pdu->header_digest;
|
||||
iovec[iovec_cnt].iov_len = ISCSI_DIGEST_LEN;
|
||||
iovec_cnt++;
|
||||
@ -618,9 +608,6 @@ spdk_iscsi_build_iovecs(struct spdk_iscsi_conn *conn, struct iovec *iovec,
|
||||
|
||||
/* Data Digest */
|
||||
if (enable_digest && conn->data_digest && data_len != 0) {
|
||||
crc32c = spdk_iscsi_pdu_calc_data_digest(pdu);
|
||||
MAKE_DIGEST_WORD(pdu->data_digest, crc32c);
|
||||
|
||||
iovec[iovec_cnt].iov_base = pdu->data_digest;
|
||||
iovec[iovec_cnt].iov_len = ISCSI_DIGEST_LEN;
|
||||
iovec_cnt++;
|
||||
|
@ -435,6 +435,8 @@ int spdk_iscsi_copy_param2var(struct spdk_iscsi_conn *conn);
|
||||
|
||||
void spdk_iscsi_task_cpl(struct spdk_scsi_task *scsi_task);
|
||||
void spdk_iscsi_task_mgmt_cpl(struct spdk_scsi_task *scsi_task);
|
||||
uint32_t spdk_iscsi_pdu_calc_header_digest(struct spdk_iscsi_pdu *pdu);
|
||||
uint32_t spdk_iscsi_pdu_calc_data_digest(struct spdk_iscsi_pdu *pdu);
|
||||
|
||||
/* Memory management */
|
||||
void spdk_put_pdu(struct spdk_iscsi_pdu *pdu);
|
||||
|
@ -279,6 +279,18 @@ spdk_iscsi_tgt_node_cleanup_luns(struct spdk_iscsi_conn *conn,
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
spdk_iscsi_pdu_calc_header_digest(struct spdk_iscsi_pdu *pdu)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
spdk_iscsi_pdu_calc_data_digest(struct spdk_iscsi_pdu *pdu)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
spdk_shutdown_iscsi_conns_done(void)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user