}
static inline void
-iscsi_buf_init_hdr(struct iscsi_conn *conn, struct iscsi_buf *ibuf,
- char *vbuf, u8 *crc)
+iscsi_hdr_digest(struct iscsi_conn *conn, struct iscsi_buf *buf,
+ u8* crc)
{
- iscsi_buf_init_virt(ibuf, vbuf, sizeof(struct iscsi_hdr));
- if (conn->hdrdgst_en) {
- crypto_digest_digest(conn->tx_tfm, &ibuf->sg, 1, crc);
- ibuf->sg.length += sizeof(uint32_t);
- }
+ crypto_digest_digest(conn->tx_tfm, &buf->sg, 1, crc);
+ buf->sg.length += sizeof(uint32_t);
}
static void
r2t->sent = 0;
- iscsi_buf_init_hdr(conn, &r2t->headbuf, (char*)hdr,
- (u8 *)dtask->hdrext);
+ iscsi_buf_init_virt(&r2t->headbuf, (char*)hdr,
+ sizeof(struct iscsi_hdr));
r2t->dtask = dtask;
}
conn->dataout_pdus_cnt++;
- iscsi_buf_init_hdr(conn, &r2t->headbuf, (char*)hdr,
- (u8 *)dtask->hdrext);
+ iscsi_buf_init_virt(&r2t->headbuf, (char*)hdr,
+ sizeof(struct iscsi_hdr));
r2t->dtask = dtask;
hdr->flags = ISCSI_FLAG_CMD_FINAL;
}
- iscsi_buf_init_hdr(conn, &ctask->headbuf, (char*)hdr,
- (u8 *)dtask->hdrext);
+ iscsi_buf_init_virt(&ctask->headbuf, (char*)hdr,
+ sizeof(struct iscsi_hdr));
list_add(&dtask->item, &ctask->dataqueue);
zero_data(ctask->hdr.dlength);
}
- iscsi_buf_init_hdr(conn, &ctask->headbuf, (char*)&ctask->hdr,
- (u8 *)ctask->hdrext);
+ iscsi_buf_init_virt(&ctask->headbuf, (char*)&ctask->hdr,
+ sizeof(struct iscsi_hdr));
conn->scsicmd_pdus_cnt++;
}
mtask->xmstate &= ~XMSTATE_IMM_HDR;
if (mtask->data_count)
mtask->xmstate |= XMSTATE_IMM_DATA;
+ if (conn->c_stage != ISCSI_CONN_INITIAL_STAGE &&
+ conn->stop_stage != STOP_CONN_RECOVER &&
+ conn->hdrdgst_en)
+ iscsi_hdr_digest(conn, &mtask->headbuf,
+ (u8*)mtask->hdrext);
if (iscsi_sendhdr(conn, &mtask->headbuf, mtask->data_count)) {
mtask->xmstate |= XMSTATE_IMM_HDR;
if (mtask->data_count)
handle_xmstate_r_hdr(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
{
ctask->xmstate &= ~XMSTATE_R_HDR;
+ if (conn->hdrdgst_en)
+ iscsi_hdr_digest(conn, &ctask->headbuf, (u8*)ctask->hdrext);
if (!iscsi_sendhdr(conn, &ctask->headbuf, 0)) {
BUG_ON(ctask->xmstate != XMSTATE_IDLE);
return 0; /* wait for Data-In */
handle_xmstate_w_hdr(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)
{
ctask->xmstate &= ~XMSTATE_W_HDR;
+ if (conn->hdrdgst_en)
+ iscsi_hdr_digest(conn, &ctask->headbuf, (u8*)ctask->hdrext);
if (iscsi_sendhdr(conn, &ctask->headbuf, ctask->imm_count)) {
ctask->xmstate |= XMSTATE_W_HDR;
return -EAGAIN;
iscsi_unsolicit_data_init(conn, ctask);
BUG_ON(!ctask->dtask);
dtask = ctask->dtask;
-
+ if (conn->hdrdgst_en)
+ iscsi_hdr_digest(conn, &ctask->headbuf,
+ (u8*)dtask->hdrext);
ctask->xmstate &= ~XMSTATE_UNS_INIT;
}
if (iscsi_sendhdr(conn, &ctask->headbuf, ctask->data_count)) {
sizeof(void*));
solicit_head_again:
r2t = ctask->r2t;
-
+ if (conn->hdrdgst_en)
+ iscsi_hdr_digest(conn, &r2t->headbuf,
+ (u8*)r2t->dtask->hdrext);
if (iscsi_sendhdr(conn, &r2t->headbuf, r2t->data_count)) {
ctask->xmstate &= ~XMSTATE_SOL_DATA;
ctask->xmstate |= XMSTATE_SOL_HDR;
memcpy(&mtask->hdr, hdr, sizeof(struct iscsi_hdr));
- if (conn->c_stage == ISCSI_CONN_INITIAL_STAGE ||
- conn->stop_stage == STOP_CONN_RECOVER)
- iscsi_buf_init_virt(&mtask->headbuf, (char*)&mtask->hdr,
+ iscsi_buf_init_virt(&mtask->headbuf, (char*)&mtask->hdr,
sizeof(struct iscsi_hdr));
- else
- /* this will update header digest */
- iscsi_buf_init_hdr(conn, &mtask->headbuf, (char*)&mtask->hdr,
- (u8 *)mtask->hdrext);
spin_unlock_bh(&session->lock);