[ewg] [PATCH 1/2 - v2] IB/iser: move open-iscsi crypto functions to kernel_addons (SLES10, RHEL5)
Erez Zilber
erezz at voltaire.com
Sun Aug 5 23:50:33 PDT 2007
move open-iscsi crypto functions to kernel_addons (SLES10, RHEL5)
Signed-off-by: Erez Zilber <erezz at voltaire.com>
---
.../backport/2.6.16_sles10/include/linux/crypto.h | 54 ++++
.../2.6.16_sles10_sp1/include/linux/crypto.h | 54 ++++
.../backport/2.6.18_FC6/include/linux/crypto.h | 54 ++++
.../2.6.16_sles10/open-iscsi-tx-hash-fixes.patch | 277 --------------------
.../open-iscsi-tx-hash-fixes.patch | 277 --------------------
.../2.6.18_FC6/open-iscsi-tx-hash-fixes.patch | 277 --------------------
6 files changed, 162 insertions(+), 831 deletions(-)
create mode 100644 kernel_addons/backport/2.6.16_sles10/include/linux/crypto.h
create mode 100644 kernel_addons/backport/2.6.16_sles10_sp1/include/linux/crypto.h
create mode 100644 kernel_addons/backport/2.6.18_FC6/include/linux/crypto.h
delete mode 100644 kernel_patches/backport/2.6.16_sles10/open-iscsi-tx-hash-fixes.patch
delete mode 100644 kernel_patches/backport/2.6.16_sles10_sp1/open-iscsi-tx-hash-fixes.patch
delete mode 100644 kernel_patches/backport/2.6.18_FC6/open-iscsi-tx-hash-fixes.patch
diff --git a/kernel_addons/backport/2.6.16_sles10/include/linux/crypto.h b/kernel_addons/backport/2.6.16_sles10/include/linux/crypto.h
new file mode 100644
index 0000000..0f02f6f
--- /dev/null
+++ b/kernel_addons/backport/2.6.16_sles10/include/linux/crypto.h
@@ -0,0 +1,54 @@
+#ifndef BACKPORT_LINUX_CRYPTO_H
+#define BACKPORT_LINUX_CRYPTO_H
+
+#include_next <linux/crypto.h>
+
+#define CRYPTO_ALG_ASYNC 0x00000080
+
+struct hash_desc
+{
+ struct crypto_tfm *tfm;
+ u32 flags;
+};
+
+static inline int crypto_hash_init(struct hash_desc *desc)
+{
+ crypto_digest_init(desc->tfm);
+ return 0;
+}
+
+static inline int crypto_hash_digest(struct hash_desc *desc,
+ struct scatterlist *sg,
+ unsigned int nbytes, u8 *out)
+{
+ crypto_digest_digest(desc->tfm, sg, (nbytes+(PAGE_SIZE-1)) / PAGE_SIZE, out);
+ return nbytes;
+}
+
+static inline int crypto_hash_update(struct hash_desc *desc,
+ struct scatterlist *sg,
+ unsigned int nbytes)
+{
+ crypto_digest_update(desc->tfm, sg, (nbytes+(PAGE_SIZE-1)) / PAGE_SIZE);
+ return nbytes;
+}
+
+static inline int crypto_hash_final(struct hash_desc *desc, u8 *out)
+{
+ crypto_digest_final(desc->tfm, out);
+ return 0;
+}
+
+static inline struct crypto_tfm *crypto_alloc_hash(const char *alg_name,
+ u32 type, u32 mask)
+{
+ struct crypto_tfm *ret = crypto_alloc_tfm(alg_name ,type);
+ return ret ? ret : ERR_PTR(-ENOMEM);
+}
+
+static inline void crypto_free_hash(struct crypto_tfm *tfm)
+{
+ crypto_free_tfm(tfm);
+}
+
+#endif
diff --git a/kernel_addons/backport/2.6.16_sles10_sp1/include/linux/crypto.h b/kernel_addons/backport/2.6.16_sles10_sp1/include/linux/crypto.h
new file mode 100644
index 0000000..0f02f6f
--- /dev/null
+++ b/kernel_addons/backport/2.6.16_sles10_sp1/include/linux/crypto.h
@@ -0,0 +1,54 @@
+#ifndef BACKPORT_LINUX_CRYPTO_H
+#define BACKPORT_LINUX_CRYPTO_H
+
+#include_next <linux/crypto.h>
+
+#define CRYPTO_ALG_ASYNC 0x00000080
+
+struct hash_desc
+{
+ struct crypto_tfm *tfm;
+ u32 flags;
+};
+
+static inline int crypto_hash_init(struct hash_desc *desc)
+{
+ crypto_digest_init(desc->tfm);
+ return 0;
+}
+
+static inline int crypto_hash_digest(struct hash_desc *desc,
+ struct scatterlist *sg,
+ unsigned int nbytes, u8 *out)
+{
+ crypto_digest_digest(desc->tfm, sg, (nbytes+(PAGE_SIZE-1)) / PAGE_SIZE, out);
+ return nbytes;
+}
+
+static inline int crypto_hash_update(struct hash_desc *desc,
+ struct scatterlist *sg,
+ unsigned int nbytes)
+{
+ crypto_digest_update(desc->tfm, sg, (nbytes+(PAGE_SIZE-1)) / PAGE_SIZE);
+ return nbytes;
+}
+
+static inline int crypto_hash_final(struct hash_desc *desc, u8 *out)
+{
+ crypto_digest_final(desc->tfm, out);
+ return 0;
+}
+
+static inline struct crypto_tfm *crypto_alloc_hash(const char *alg_name,
+ u32 type, u32 mask)
+{
+ struct crypto_tfm *ret = crypto_alloc_tfm(alg_name ,type);
+ return ret ? ret : ERR_PTR(-ENOMEM);
+}
+
+static inline void crypto_free_hash(struct crypto_tfm *tfm)
+{
+ crypto_free_tfm(tfm);
+}
+
+#endif
diff --git a/kernel_addons/backport/2.6.18_FC6/include/linux/crypto.h b/kernel_addons/backport/2.6.18_FC6/include/linux/crypto.h
new file mode 100644
index 0000000..0f02f6f
--- /dev/null
+++ b/kernel_addons/backport/2.6.18_FC6/include/linux/crypto.h
@@ -0,0 +1,54 @@
+#ifndef BACKPORT_LINUX_CRYPTO_H
+#define BACKPORT_LINUX_CRYPTO_H
+
+#include_next <linux/crypto.h>
+
+#define CRYPTO_ALG_ASYNC 0x00000080
+
+struct hash_desc
+{
+ struct crypto_tfm *tfm;
+ u32 flags;
+};
+
+static inline int crypto_hash_init(struct hash_desc *desc)
+{
+ crypto_digest_init(desc->tfm);
+ return 0;
+}
+
+static inline int crypto_hash_digest(struct hash_desc *desc,
+ struct scatterlist *sg,
+ unsigned int nbytes, u8 *out)
+{
+ crypto_digest_digest(desc->tfm, sg, (nbytes+(PAGE_SIZE-1)) / PAGE_SIZE, out);
+ return nbytes;
+}
+
+static inline int crypto_hash_update(struct hash_desc *desc,
+ struct scatterlist *sg,
+ unsigned int nbytes)
+{
+ crypto_digest_update(desc->tfm, sg, (nbytes+(PAGE_SIZE-1)) / PAGE_SIZE);
+ return nbytes;
+}
+
+static inline int crypto_hash_final(struct hash_desc *desc, u8 *out)
+{
+ crypto_digest_final(desc->tfm, out);
+ return 0;
+}
+
+static inline struct crypto_tfm *crypto_alloc_hash(const char *alg_name,
+ u32 type, u32 mask)
+{
+ struct crypto_tfm *ret = crypto_alloc_tfm(alg_name ,type);
+ return ret ? ret : ERR_PTR(-ENOMEM);
+}
+
+static inline void crypto_free_hash(struct crypto_tfm *tfm)
+{
+ crypto_free_tfm(tfm);
+}
+
+#endif
diff --git a/kernel_patches/backport/2.6.16_sles10/open-iscsi-tx-hash-fixes.patch b/kernel_patches/backport/2.6.16_sles10/open-iscsi-tx-hash-fixes.patch
deleted file mode 100644
index 727fa88..0000000
--- a/kernel_patches/backport/2.6.16_sles10/open-iscsi-tx-hash-fixes.patch
+++ /dev/null
@@ -1,277 +0,0 @@
-Index: gen2_devel_kernel-20070129-1858_linux-2.6.18.6_check/drivers/scsi/iscsi_tcp.c
-===================================================================
---- gen2_devel_kernel-20070129-1858_linux-2.6.18.6_check.orig/drivers/scsi/iscsi_tcp.c
-+++ gen2_devel_kernel-20070129-1858_linux-2.6.18.6_check/drivers/scsi/iscsi_tcp.c
-@@ -108,8 +108,8 @@ iscsi_hdr_digest(struct iscsi_conn *conn
- {
- struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
-
-- crypto_hash_digest(&tcp_conn->tx_hash, &buf->sg, buf->sg.length, crc);
-- buf->sg.length = tcp_conn->hdr_size;
-+ crypto_digest_digest(tcp_conn->tx_tfm, &buf->sg, 1, crc);
-+ buf->sg.length += sizeof(uint32_t);
- }
-
- static inline int
-@@ -468,8 +468,7 @@ iscsi_tcp_hdr_recv(struct iscsi_conn *co
-
- sg_init_one(&sg, (u8 *)hdr,
- sizeof(struct iscsi_hdr) + ahslen);
-- crypto_hash_digest(&tcp_conn->rx_hash, &sg, sg.length,
-- (u8 *)&cdgst);
-+ crypto_digest_digest(tcp_conn->rx_tfm, &sg, 1, (u8 *)&cdgst);
- rdgst = *(uint32_t*)((char*)hdr + sizeof(struct iscsi_hdr) +
- ahslen);
- if (cdgst != rdgst) {
-@@ -649,9 +648,10 @@ iscsi_ctask_copy(struct iscsi_tcp_conn *
- * byte counters.
- **/
- static inline int
--iscsi_tcp_copy(struct iscsi_conn *conn, int buf_size)
-+iscsi_tcp_copy(struct iscsi_conn *conn)
- {
- struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
-+ int buf_size = tcp_conn->in.datalen;
- int buf_left = buf_size - tcp_conn->data_copied;
- int size = min(tcp_conn->in.copy, buf_left);
- int rc;
-@@ -676,7 +676,7 @@ iscsi_tcp_copy(struct iscsi_conn *conn,
- }
-
- static inline void
--partial_sg_digest_update(struct hash_desc *desc, struct scatterlist *sg,
-+partial_sg_digest_update(struct crypto_tfm *tfm, struct scatterlist *sg,
- int offset, int length)
- {
- struct scatterlist temp;
-@@ -684,7 +684,7 @@ partial_sg_digest_update(struct hash_des
- memcpy(&temp, sg, sizeof(struct scatterlist));
- temp.offset = offset;
- temp.length = length;
-- crypto_hash_update(desc, &temp, length);
-+ crypto_digest_update(tfm, &temp, 1);
- }
-
- static void
-@@ -693,7 +693,7 @@ iscsi_recv_digest_update(struct iscsi_tc
- struct scatterlist tmp;
-
- sg_init_one(&tmp, buf, len);
-- crypto_hash_update(&tcp_conn->rx_hash, &tmp, len);
-+ crypto_digest_update(tcp_conn->rx_tfm, &tmp, 1);
- }
-
- static int iscsi_scsi_data_in(struct iscsi_conn *conn)
-@@ -747,12 +747,12 @@ static int iscsi_scsi_data_in(struct isc
- if (!rc) {
- if (conn->datadgst_en) {
- if (!offset)
-- crypto_hash_update(
-- &tcp_conn->rx_hash,
-+ crypto_digest_update(
-+ &tcp_conn->rx_tfm,
- &sg[i], sg[i].length);
- else
- partial_sg_digest_update(
-- &tcp_conn->rx_hash,
-+ &tcp_conn->rx_tfm,
- &sg[i],
- sg[i].offset + offset,
- sg[i].length - offset);
-@@ -766,10 +766,9 @@ static int iscsi_scsi_data_in(struct isc
- /*
- * data-in is complete, but buffer not...
- */
-- partial_sg_digest_update(&tcp_conn->rx_hash,
-- &sg[i],
-- sg[i].offset,
-- sg[i].length-rc);
-+ partial_sg_digest_update(tcp_conn->rx_tfm,
-+ &sg[i],
-+ sg[i].offset, sg[i].length-rc);
- rc = 0;
- break;
- }
-@@ -813,7 +812,7 @@ iscsi_data_recv(struct iscsi_conn *conn)
- * Collect data segment to the connection's data
- * placeholder
- */
-- if (iscsi_tcp_copy(conn, tcp_conn->in.datalen)) {
-+ if (iscsi_tcp_copy(conn)) {
- rc = -EAGAIN;
- goto exit;
- }
-@@ -887,7 +886,7 @@ more:
- rc = iscsi_tcp_hdr_recv(conn);
- if (!rc && tcp_conn->in.datalen) {
- if (conn->datadgst_en)
-- crypto_hash_init(&tcp_conn->rx_hash);
-+ crypto_digest_init(tcp_conn->rx_tfm);
- tcp_conn->in_progress = IN_PROGRESS_DATA_RECV;
- } else if (rc) {
- iscsi_conn_failure(conn, rc);
-@@ -900,15 +899,10 @@ more:
-
- debug_tcp("extra data_recv offset %d copy %d\n",
- tcp_conn->in.offset, tcp_conn->in.copy);
-- rc = iscsi_tcp_copy(conn, sizeof(uint32_t));
-- if (rc) {
-- if (rc == -EAGAIN)
-- goto again;
-- iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
-- return 0;
-- }
--
-- memcpy(&recv_digest, conn->data, sizeof(uint32_t));
-+ skb_copy_bits(tcp_conn->in.skb, tcp_conn->in.offset,
-+ &recv_digest, 4);
-+ tcp_conn->in.offset += 4;
-+ tcp_conn->in.copy -= 4;
- if (recv_digest != tcp_conn->in.datadgst) {
- debug_tcp("iscsi_tcp: data digest error!"
- "0x%x != 0x%x\n", recv_digest,
-@@ -944,14 +938,13 @@ more:
- tcp_conn->in.padding);
- memset(pad, 0, tcp_conn->in.padding);
- sg_init_one(&sg, pad, tcp_conn->in.padding);
-- crypto_hash_update(&tcp_conn->rx_hash,
-- &sg, sg.length);
-+ crypto_digest_update(tcp_conn->rx_tfm,
-+ &sg, 1);
- }
-- crypto_hash_final(&tcp_conn->rx_hash,
-- (u8 *) &tcp_conn->in.datadgst);
-+ crypto_digest_final(tcp_conn->rx_tfm,
-+ (u8 *) & tcp_conn->in.datadgst);
- debug_tcp("rx digest 0x%x\n", tcp_conn->in.datadgst);
- tcp_conn->in_progress = IN_PROGRESS_DDIGEST_RECV;
-- tcp_conn->data_copied = 0;
- } else
- tcp_conn->in_progress = IN_PROGRESS_WAIT_HEADER;
- }
-@@ -1193,7 +1186,7 @@ static inline void
- iscsi_data_digest_init(struct iscsi_tcp_conn *tcp_conn,
- struct iscsi_tcp_cmd_task *tcp_ctask)
- {
-- crypto_hash_init(&tcp_conn->tx_hash);
-+ crypto_digest_init(tcp_conn->tx_tfm);
- tcp_ctask->digest_count = 4;
- }
-
-@@ -1449,9 +1442,8 @@ iscsi_send_padding(struct iscsi_conn *co
- iscsi_buf_init_iov(&tcp_ctask->sendbuf, (char*)&tcp_ctask->pad,
- tcp_ctask->pad_count);
- if (conn->datadgst_en)
-- crypto_hash_update(&tcp_conn->tx_hash,
-- &tcp_ctask->sendbuf.sg,
-- tcp_ctask->sendbuf.sg.length);
-+ crypto_digest_update(tcp_conn->tx_tfm,
-+ &tcp_ctask->sendbuf.sg, 1);
- } else if (!(tcp_ctask->xmstate & XMSTATE_W_RESEND_PAD))
- return 0;
-
-@@ -1483,7 +1475,7 @@ iscsi_send_digest(struct iscsi_conn *con
- tcp_conn = conn->dd_data;
-
- if (!(tcp_ctask->xmstate & XMSTATE_W_RESEND_DATA_DIGEST)) {
-- crypto_hash_final(&tcp_conn->tx_hash, (u8*)digest);
-+ crypto_digest_final(tcp_conn->tx_tfm, (u8*)digest);
- iscsi_buf_init_iov(buf, (char*)digest, 4);
- }
- tcp_ctask->xmstate &= ~XMSTATE_W_RESEND_DATA_DIGEST;
-@@ -1517,7 +1509,7 @@ iscsi_send_data(struct iscsi_cmd_task *c
- rc = iscsi_sendpage(conn, sendbuf, count, &buf_sent);
- *sent = *sent + buf_sent;
- if (buf_sent && conn->datadgst_en)
-- partial_sg_digest_update(&tcp_conn->tx_hash,
-+ partial_sg_digest_update(tcp_conn->tx_tfm,
- &sendbuf->sg, sendbuf->sg.offset + offset,
- buf_sent);
- if (!iscsi_buf_left(sendbuf) && *sg != tcp_ctask->bad_sg) {
-@@ -1774,22 +1766,18 @@ iscsi_tcp_conn_create(struct iscsi_cls_s
- /* initial operational parameters */
- tcp_conn->hdr_size = sizeof(struct iscsi_hdr);
-
-- tcp_conn->tx_hash.tfm = crypto_alloc_hash("crc32c", 0,
-- CRYPTO_ALG_ASYNC);
-- tcp_conn->tx_hash.flags = 0;
-- if (IS_ERR(tcp_conn->tx_hash.tfm))
-+ tcp_conn->tx_tfm = crypto_alloc_tfm("crc32c", 0);
-+ if (!tcp_conn->tx_tfm)
- goto free_tcp_conn;
-
-- tcp_conn->rx_hash.tfm = crypto_alloc_hash("crc32c", 0,
-- CRYPTO_ALG_ASYNC);
-- tcp_conn->rx_hash.flags = 0;
-- if (IS_ERR(tcp_conn->rx_hash.tfm))
-+ tcp_conn->rx_tfm = crypto_alloc_tfm("crc32c", 0);
-+ if (!tcp_conn->rx_tfm)
- goto free_tx_tfm;
-
- return cls_conn;
-
- free_tx_tfm:
-- crypto_free_hash(tcp_conn->tx_hash.tfm);
-+ crypto_free_tfm(tcp_conn->tx_tfm);
- free_tcp_conn:
- kfree(tcp_conn);
- tcp_conn_alloc_fail:
-@@ -1823,11 +1811,10 @@ iscsi_tcp_conn_destroy(struct iscsi_cls_
- iscsi_tcp_release_conn(conn);
- iscsi_conn_teardown(cls_conn);
-
-- if (tcp_conn->tx_hash.tfm)
-- crypto_free_hash(tcp_conn->tx_hash.tfm);
-- if (tcp_conn->rx_hash.tfm)
-- crypto_free_hash(tcp_conn->rx_hash.tfm);
--
-+ if (tcp_conn->tx_tfm)
-+ crypto_free_tfm(tcp_conn->tx_tfm);
-+ if (tcp_conn->rx_tfm)
-+ crypto_free_tfm(tcp_conn->rx_tfm);
- kfree(tcp_conn);
- }
-
-@@ -1835,11 +1822,9 @@ static void
- iscsi_tcp_conn_stop(struct iscsi_cls_conn *cls_conn, int flag)
- {
- struct iscsi_conn *conn = cls_conn->dd_data;
-- struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
-
- iscsi_conn_stop(cls_conn, flag);
- iscsi_tcp_release_conn(conn);
-- tcp_conn->hdr_size = sizeof(struct iscsi_hdr);
- }
-
- static int
-Index: gen2_devel_kernel-20070129-1858_linux-2.6.18.6_check/drivers/scsi/iscsi_tcp.h
-===================================================================
---- gen2_devel_kernel-20070129-1858_linux-2.6.18.6_check.orig/drivers/scsi/iscsi_tcp.h
-+++ gen2_devel_kernel-20070129-1858_linux-2.6.18.6_check/drivers/scsi/iscsi_tcp.h
-@@ -49,7 +49,6 @@
- #define ISCSI_SG_TABLESIZE SG_ALL
- #define ISCSI_TCP_MAX_CMD_LEN 16
-
--struct crypto_hash;
- struct socket;
-
- /* Socket connection recieve helper */
-@@ -82,7 +81,6 @@ struct iscsi_tcp_conn {
- * stop to terminate */
- /* iSCSI connection-wide sequencing */
- int hdr_size; /* PDU header size */
--
- /* control data */
- struct iscsi_tcp_recv in; /* TCP receive context */
- int in_progress; /* connection state machine */
-@@ -93,8 +91,8 @@ struct iscsi_tcp_conn {
- void (*old_write_space)(struct sock *);
-
- /* data and header digests */
-- struct hash_desc tx_hash; /* CRC32C (Tx) */
-- struct hash_desc rx_hash; /* CRC32C (Rx) */
-+ struct crypto_tfm *tx_tfm; /* CRC32C (Tx) */
-+ struct crypto_tfm *rx_tfm; /* CRC32C (Rx) */
-
- /* MIB custom statistics */
- uint32_t sendpage_failures_cnt;
diff --git a/kernel_patches/backport/2.6.16_sles10_sp1/open-iscsi-tx-hash-fixes.patch b/kernel_patches/backport/2.6.16_sles10_sp1/open-iscsi-tx-hash-fixes.patch
deleted file mode 100644
index 727fa88..0000000
--- a/kernel_patches/backport/2.6.16_sles10_sp1/open-iscsi-tx-hash-fixes.patch
+++ /dev/null
@@ -1,277 +0,0 @@
-Index: gen2_devel_kernel-20070129-1858_linux-2.6.18.6_check/drivers/scsi/iscsi_tcp.c
-===================================================================
---- gen2_devel_kernel-20070129-1858_linux-2.6.18.6_check.orig/drivers/scsi/iscsi_tcp.c
-+++ gen2_devel_kernel-20070129-1858_linux-2.6.18.6_check/drivers/scsi/iscsi_tcp.c
-@@ -108,8 +108,8 @@ iscsi_hdr_digest(struct iscsi_conn *conn
- {
- struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
-
-- crypto_hash_digest(&tcp_conn->tx_hash, &buf->sg, buf->sg.length, crc);
-- buf->sg.length = tcp_conn->hdr_size;
-+ crypto_digest_digest(tcp_conn->tx_tfm, &buf->sg, 1, crc);
-+ buf->sg.length += sizeof(uint32_t);
- }
-
- static inline int
-@@ -468,8 +468,7 @@ iscsi_tcp_hdr_recv(struct iscsi_conn *co
-
- sg_init_one(&sg, (u8 *)hdr,
- sizeof(struct iscsi_hdr) + ahslen);
-- crypto_hash_digest(&tcp_conn->rx_hash, &sg, sg.length,
-- (u8 *)&cdgst);
-+ crypto_digest_digest(tcp_conn->rx_tfm, &sg, 1, (u8 *)&cdgst);
- rdgst = *(uint32_t*)((char*)hdr + sizeof(struct iscsi_hdr) +
- ahslen);
- if (cdgst != rdgst) {
-@@ -649,9 +648,10 @@ iscsi_ctask_copy(struct iscsi_tcp_conn *
- * byte counters.
- **/
- static inline int
--iscsi_tcp_copy(struct iscsi_conn *conn, int buf_size)
-+iscsi_tcp_copy(struct iscsi_conn *conn)
- {
- struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
-+ int buf_size = tcp_conn->in.datalen;
- int buf_left = buf_size - tcp_conn->data_copied;
- int size = min(tcp_conn->in.copy, buf_left);
- int rc;
-@@ -676,7 +676,7 @@ iscsi_tcp_copy(struct iscsi_conn *conn,
- }
-
- static inline void
--partial_sg_digest_update(struct hash_desc *desc, struct scatterlist *sg,
-+partial_sg_digest_update(struct crypto_tfm *tfm, struct scatterlist *sg,
- int offset, int length)
- {
- struct scatterlist temp;
-@@ -684,7 +684,7 @@ partial_sg_digest_update(struct hash_des
- memcpy(&temp, sg, sizeof(struct scatterlist));
- temp.offset = offset;
- temp.length = length;
-- crypto_hash_update(desc, &temp, length);
-+ crypto_digest_update(tfm, &temp, 1);
- }
-
- static void
-@@ -693,7 +693,7 @@ iscsi_recv_digest_update(struct iscsi_tc
- struct scatterlist tmp;
-
- sg_init_one(&tmp, buf, len);
-- crypto_hash_update(&tcp_conn->rx_hash, &tmp, len);
-+ crypto_digest_update(tcp_conn->rx_tfm, &tmp, 1);
- }
-
- static int iscsi_scsi_data_in(struct iscsi_conn *conn)
-@@ -747,12 +747,12 @@ static int iscsi_scsi_data_in(struct isc
- if (!rc) {
- if (conn->datadgst_en) {
- if (!offset)
-- crypto_hash_update(
-- &tcp_conn->rx_hash,
-+ crypto_digest_update(
-+ &tcp_conn->rx_tfm,
- &sg[i], sg[i].length);
- else
- partial_sg_digest_update(
-- &tcp_conn->rx_hash,
-+ &tcp_conn->rx_tfm,
- &sg[i],
- sg[i].offset + offset,
- sg[i].length - offset);
-@@ -766,10 +766,9 @@ static int iscsi_scsi_data_in(struct isc
- /*
- * data-in is complete, but buffer not...
- */
-- partial_sg_digest_update(&tcp_conn->rx_hash,
-- &sg[i],
-- sg[i].offset,
-- sg[i].length-rc);
-+ partial_sg_digest_update(tcp_conn->rx_tfm,
-+ &sg[i],
-+ sg[i].offset, sg[i].length-rc);
- rc = 0;
- break;
- }
-@@ -813,7 +812,7 @@ iscsi_data_recv(struct iscsi_conn *conn)
- * Collect data segment to the connection's data
- * placeholder
- */
-- if (iscsi_tcp_copy(conn, tcp_conn->in.datalen)) {
-+ if (iscsi_tcp_copy(conn)) {
- rc = -EAGAIN;
- goto exit;
- }
-@@ -887,7 +886,7 @@ more:
- rc = iscsi_tcp_hdr_recv(conn);
- if (!rc && tcp_conn->in.datalen) {
- if (conn->datadgst_en)
-- crypto_hash_init(&tcp_conn->rx_hash);
-+ crypto_digest_init(tcp_conn->rx_tfm);
- tcp_conn->in_progress = IN_PROGRESS_DATA_RECV;
- } else if (rc) {
- iscsi_conn_failure(conn, rc);
-@@ -900,15 +899,10 @@ more:
-
- debug_tcp("extra data_recv offset %d copy %d\n",
- tcp_conn->in.offset, tcp_conn->in.copy);
-- rc = iscsi_tcp_copy(conn, sizeof(uint32_t));
-- if (rc) {
-- if (rc == -EAGAIN)
-- goto again;
-- iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
-- return 0;
-- }
--
-- memcpy(&recv_digest, conn->data, sizeof(uint32_t));
-+ skb_copy_bits(tcp_conn->in.skb, tcp_conn->in.offset,
-+ &recv_digest, 4);
-+ tcp_conn->in.offset += 4;
-+ tcp_conn->in.copy -= 4;
- if (recv_digest != tcp_conn->in.datadgst) {
- debug_tcp("iscsi_tcp: data digest error!"
- "0x%x != 0x%x\n", recv_digest,
-@@ -944,14 +938,13 @@ more:
- tcp_conn->in.padding);
- memset(pad, 0, tcp_conn->in.padding);
- sg_init_one(&sg, pad, tcp_conn->in.padding);
-- crypto_hash_update(&tcp_conn->rx_hash,
-- &sg, sg.length);
-+ crypto_digest_update(tcp_conn->rx_tfm,
-+ &sg, 1);
- }
-- crypto_hash_final(&tcp_conn->rx_hash,
-- (u8 *) &tcp_conn->in.datadgst);
-+ crypto_digest_final(tcp_conn->rx_tfm,
-+ (u8 *) & tcp_conn->in.datadgst);
- debug_tcp("rx digest 0x%x\n", tcp_conn->in.datadgst);
- tcp_conn->in_progress = IN_PROGRESS_DDIGEST_RECV;
-- tcp_conn->data_copied = 0;
- } else
- tcp_conn->in_progress = IN_PROGRESS_WAIT_HEADER;
- }
-@@ -1193,7 +1186,7 @@ static inline void
- iscsi_data_digest_init(struct iscsi_tcp_conn *tcp_conn,
- struct iscsi_tcp_cmd_task *tcp_ctask)
- {
-- crypto_hash_init(&tcp_conn->tx_hash);
-+ crypto_digest_init(tcp_conn->tx_tfm);
- tcp_ctask->digest_count = 4;
- }
-
-@@ -1449,9 +1442,8 @@ iscsi_send_padding(struct iscsi_conn *co
- iscsi_buf_init_iov(&tcp_ctask->sendbuf, (char*)&tcp_ctask->pad,
- tcp_ctask->pad_count);
- if (conn->datadgst_en)
-- crypto_hash_update(&tcp_conn->tx_hash,
-- &tcp_ctask->sendbuf.sg,
-- tcp_ctask->sendbuf.sg.length);
-+ crypto_digest_update(tcp_conn->tx_tfm,
-+ &tcp_ctask->sendbuf.sg, 1);
- } else if (!(tcp_ctask->xmstate & XMSTATE_W_RESEND_PAD))
- return 0;
-
-@@ -1483,7 +1475,7 @@ iscsi_send_digest(struct iscsi_conn *con
- tcp_conn = conn->dd_data;
-
- if (!(tcp_ctask->xmstate & XMSTATE_W_RESEND_DATA_DIGEST)) {
-- crypto_hash_final(&tcp_conn->tx_hash, (u8*)digest);
-+ crypto_digest_final(tcp_conn->tx_tfm, (u8*)digest);
- iscsi_buf_init_iov(buf, (char*)digest, 4);
- }
- tcp_ctask->xmstate &= ~XMSTATE_W_RESEND_DATA_DIGEST;
-@@ -1517,7 +1509,7 @@ iscsi_send_data(struct iscsi_cmd_task *c
- rc = iscsi_sendpage(conn, sendbuf, count, &buf_sent);
- *sent = *sent + buf_sent;
- if (buf_sent && conn->datadgst_en)
-- partial_sg_digest_update(&tcp_conn->tx_hash,
-+ partial_sg_digest_update(tcp_conn->tx_tfm,
- &sendbuf->sg, sendbuf->sg.offset + offset,
- buf_sent);
- if (!iscsi_buf_left(sendbuf) && *sg != tcp_ctask->bad_sg) {
-@@ -1774,22 +1766,18 @@ iscsi_tcp_conn_create(struct iscsi_cls_s
- /* initial operational parameters */
- tcp_conn->hdr_size = sizeof(struct iscsi_hdr);
-
-- tcp_conn->tx_hash.tfm = crypto_alloc_hash("crc32c", 0,
-- CRYPTO_ALG_ASYNC);
-- tcp_conn->tx_hash.flags = 0;
-- if (IS_ERR(tcp_conn->tx_hash.tfm))
-+ tcp_conn->tx_tfm = crypto_alloc_tfm("crc32c", 0);
-+ if (!tcp_conn->tx_tfm)
- goto free_tcp_conn;
-
-- tcp_conn->rx_hash.tfm = crypto_alloc_hash("crc32c", 0,
-- CRYPTO_ALG_ASYNC);
-- tcp_conn->rx_hash.flags = 0;
-- if (IS_ERR(tcp_conn->rx_hash.tfm))
-+ tcp_conn->rx_tfm = crypto_alloc_tfm("crc32c", 0);
-+ if (!tcp_conn->rx_tfm)
- goto free_tx_tfm;
-
- return cls_conn;
-
- free_tx_tfm:
-- crypto_free_hash(tcp_conn->tx_hash.tfm);
-+ crypto_free_tfm(tcp_conn->tx_tfm);
- free_tcp_conn:
- kfree(tcp_conn);
- tcp_conn_alloc_fail:
-@@ -1823,11 +1811,10 @@ iscsi_tcp_conn_destroy(struct iscsi_cls_
- iscsi_tcp_release_conn(conn);
- iscsi_conn_teardown(cls_conn);
-
-- if (tcp_conn->tx_hash.tfm)
-- crypto_free_hash(tcp_conn->tx_hash.tfm);
-- if (tcp_conn->rx_hash.tfm)
-- crypto_free_hash(tcp_conn->rx_hash.tfm);
--
-+ if (tcp_conn->tx_tfm)
-+ crypto_free_tfm(tcp_conn->tx_tfm);
-+ if (tcp_conn->rx_tfm)
-+ crypto_free_tfm(tcp_conn->rx_tfm);
- kfree(tcp_conn);
- }
-
-@@ -1835,11 +1822,9 @@ static void
- iscsi_tcp_conn_stop(struct iscsi_cls_conn *cls_conn, int flag)
- {
- struct iscsi_conn *conn = cls_conn->dd_data;
-- struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
-
- iscsi_conn_stop(cls_conn, flag);
- iscsi_tcp_release_conn(conn);
-- tcp_conn->hdr_size = sizeof(struct iscsi_hdr);
- }
-
- static int
-Index: gen2_devel_kernel-20070129-1858_linux-2.6.18.6_check/drivers/scsi/iscsi_tcp.h
-===================================================================
---- gen2_devel_kernel-20070129-1858_linux-2.6.18.6_check.orig/drivers/scsi/iscsi_tcp.h
-+++ gen2_devel_kernel-20070129-1858_linux-2.6.18.6_check/drivers/scsi/iscsi_tcp.h
-@@ -49,7 +49,6 @@
- #define ISCSI_SG_TABLESIZE SG_ALL
- #define ISCSI_TCP_MAX_CMD_LEN 16
-
--struct crypto_hash;
- struct socket;
-
- /* Socket connection recieve helper */
-@@ -82,7 +81,6 @@ struct iscsi_tcp_conn {
- * stop to terminate */
- /* iSCSI connection-wide sequencing */
- int hdr_size; /* PDU header size */
--
- /* control data */
- struct iscsi_tcp_recv in; /* TCP receive context */
- int in_progress; /* connection state machine */
-@@ -93,8 +91,8 @@ struct iscsi_tcp_conn {
- void (*old_write_space)(struct sock *);
-
- /* data and header digests */
-- struct hash_desc tx_hash; /* CRC32C (Tx) */
-- struct hash_desc rx_hash; /* CRC32C (Rx) */
-+ struct crypto_tfm *tx_tfm; /* CRC32C (Tx) */
-+ struct crypto_tfm *rx_tfm; /* CRC32C (Rx) */
-
- /* MIB custom statistics */
- uint32_t sendpage_failures_cnt;
diff --git a/kernel_patches/backport/2.6.18_FC6/open-iscsi-tx-hash-fixes.patch b/kernel_patches/backport/2.6.18_FC6/open-iscsi-tx-hash-fixes.patch
deleted file mode 100644
index 727fa88..0000000
--- a/kernel_patches/backport/2.6.18_FC6/open-iscsi-tx-hash-fixes.patch
+++ /dev/null
@@ -1,277 +0,0 @@
-Index: gen2_devel_kernel-20070129-1858_linux-2.6.18.6_check/drivers/scsi/iscsi_tcp.c
-===================================================================
---- gen2_devel_kernel-20070129-1858_linux-2.6.18.6_check.orig/drivers/scsi/iscsi_tcp.c
-+++ gen2_devel_kernel-20070129-1858_linux-2.6.18.6_check/drivers/scsi/iscsi_tcp.c
-@@ -108,8 +108,8 @@ iscsi_hdr_digest(struct iscsi_conn *conn
- {
- struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
-
-- crypto_hash_digest(&tcp_conn->tx_hash, &buf->sg, buf->sg.length, crc);
-- buf->sg.length = tcp_conn->hdr_size;
-+ crypto_digest_digest(tcp_conn->tx_tfm, &buf->sg, 1, crc);
-+ buf->sg.length += sizeof(uint32_t);
- }
-
- static inline int
-@@ -468,8 +468,7 @@ iscsi_tcp_hdr_recv(struct iscsi_conn *co
-
- sg_init_one(&sg, (u8 *)hdr,
- sizeof(struct iscsi_hdr) + ahslen);
-- crypto_hash_digest(&tcp_conn->rx_hash, &sg, sg.length,
-- (u8 *)&cdgst);
-+ crypto_digest_digest(tcp_conn->rx_tfm, &sg, 1, (u8 *)&cdgst);
- rdgst = *(uint32_t*)((char*)hdr + sizeof(struct iscsi_hdr) +
- ahslen);
- if (cdgst != rdgst) {
-@@ -649,9 +648,10 @@ iscsi_ctask_copy(struct iscsi_tcp_conn *
- * byte counters.
- **/
- static inline int
--iscsi_tcp_copy(struct iscsi_conn *conn, int buf_size)
-+iscsi_tcp_copy(struct iscsi_conn *conn)
- {
- struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
-+ int buf_size = tcp_conn->in.datalen;
- int buf_left = buf_size - tcp_conn->data_copied;
- int size = min(tcp_conn->in.copy, buf_left);
- int rc;
-@@ -676,7 +676,7 @@ iscsi_tcp_copy(struct iscsi_conn *conn,
- }
-
- static inline void
--partial_sg_digest_update(struct hash_desc *desc, struct scatterlist *sg,
-+partial_sg_digest_update(struct crypto_tfm *tfm, struct scatterlist *sg,
- int offset, int length)
- {
- struct scatterlist temp;
-@@ -684,7 +684,7 @@ partial_sg_digest_update(struct hash_des
- memcpy(&temp, sg, sizeof(struct scatterlist));
- temp.offset = offset;
- temp.length = length;
-- crypto_hash_update(desc, &temp, length);
-+ crypto_digest_update(tfm, &temp, 1);
- }
-
- static void
-@@ -693,7 +693,7 @@ iscsi_recv_digest_update(struct iscsi_tc
- struct scatterlist tmp;
-
- sg_init_one(&tmp, buf, len);
-- crypto_hash_update(&tcp_conn->rx_hash, &tmp, len);
-+ crypto_digest_update(tcp_conn->rx_tfm, &tmp, 1);
- }
-
- static int iscsi_scsi_data_in(struct iscsi_conn *conn)
-@@ -747,12 +747,12 @@ static int iscsi_scsi_data_in(struct isc
- if (!rc) {
- if (conn->datadgst_en) {
- if (!offset)
-- crypto_hash_update(
-- &tcp_conn->rx_hash,
-+ crypto_digest_update(
-+ &tcp_conn->rx_tfm,
- &sg[i], sg[i].length);
- else
- partial_sg_digest_update(
-- &tcp_conn->rx_hash,
-+ &tcp_conn->rx_tfm,
- &sg[i],
- sg[i].offset + offset,
- sg[i].length - offset);
-@@ -766,10 +766,9 @@ static int iscsi_scsi_data_in(struct isc
- /*
- * data-in is complete, but buffer not...
- */
-- partial_sg_digest_update(&tcp_conn->rx_hash,
-- &sg[i],
-- sg[i].offset,
-- sg[i].length-rc);
-+ partial_sg_digest_update(tcp_conn->rx_tfm,
-+ &sg[i],
-+ sg[i].offset, sg[i].length-rc);
- rc = 0;
- break;
- }
-@@ -813,7 +812,7 @@ iscsi_data_recv(struct iscsi_conn *conn)
- * Collect data segment to the connection's data
- * placeholder
- */
-- if (iscsi_tcp_copy(conn, tcp_conn->in.datalen)) {
-+ if (iscsi_tcp_copy(conn)) {
- rc = -EAGAIN;
- goto exit;
- }
-@@ -887,7 +886,7 @@ more:
- rc = iscsi_tcp_hdr_recv(conn);
- if (!rc && tcp_conn->in.datalen) {
- if (conn->datadgst_en)
-- crypto_hash_init(&tcp_conn->rx_hash);
-+ crypto_digest_init(tcp_conn->rx_tfm);
- tcp_conn->in_progress = IN_PROGRESS_DATA_RECV;
- } else if (rc) {
- iscsi_conn_failure(conn, rc);
-@@ -900,15 +899,10 @@ more:
-
- debug_tcp("extra data_recv offset %d copy %d\n",
- tcp_conn->in.offset, tcp_conn->in.copy);
-- rc = iscsi_tcp_copy(conn, sizeof(uint32_t));
-- if (rc) {
-- if (rc == -EAGAIN)
-- goto again;
-- iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
-- return 0;
-- }
--
-- memcpy(&recv_digest, conn->data, sizeof(uint32_t));
-+ skb_copy_bits(tcp_conn->in.skb, tcp_conn->in.offset,
-+ &recv_digest, 4);
-+ tcp_conn->in.offset += 4;
-+ tcp_conn->in.copy -= 4;
- if (recv_digest != tcp_conn->in.datadgst) {
- debug_tcp("iscsi_tcp: data digest error!"
- "0x%x != 0x%x\n", recv_digest,
-@@ -944,14 +938,13 @@ more:
- tcp_conn->in.padding);
- memset(pad, 0, tcp_conn->in.padding);
- sg_init_one(&sg, pad, tcp_conn->in.padding);
-- crypto_hash_update(&tcp_conn->rx_hash,
-- &sg, sg.length);
-+ crypto_digest_update(tcp_conn->rx_tfm,
-+ &sg, 1);
- }
-- crypto_hash_final(&tcp_conn->rx_hash,
-- (u8 *) &tcp_conn->in.datadgst);
-+ crypto_digest_final(tcp_conn->rx_tfm,
-+ (u8 *) & tcp_conn->in.datadgst);
- debug_tcp("rx digest 0x%x\n", tcp_conn->in.datadgst);
- tcp_conn->in_progress = IN_PROGRESS_DDIGEST_RECV;
-- tcp_conn->data_copied = 0;
- } else
- tcp_conn->in_progress = IN_PROGRESS_WAIT_HEADER;
- }
-@@ -1193,7 +1186,7 @@ static inline void
- iscsi_data_digest_init(struct iscsi_tcp_conn *tcp_conn,
- struct iscsi_tcp_cmd_task *tcp_ctask)
- {
-- crypto_hash_init(&tcp_conn->tx_hash);
-+ crypto_digest_init(tcp_conn->tx_tfm);
- tcp_ctask->digest_count = 4;
- }
-
-@@ -1449,9 +1442,8 @@ iscsi_send_padding(struct iscsi_conn *co
- iscsi_buf_init_iov(&tcp_ctask->sendbuf, (char*)&tcp_ctask->pad,
- tcp_ctask->pad_count);
- if (conn->datadgst_en)
-- crypto_hash_update(&tcp_conn->tx_hash,
-- &tcp_ctask->sendbuf.sg,
-- tcp_ctask->sendbuf.sg.length);
-+ crypto_digest_update(tcp_conn->tx_tfm,
-+ &tcp_ctask->sendbuf.sg, 1);
- } else if (!(tcp_ctask->xmstate & XMSTATE_W_RESEND_PAD))
- return 0;
-
-@@ -1483,7 +1475,7 @@ iscsi_send_digest(struct iscsi_conn *con
- tcp_conn = conn->dd_data;
-
- if (!(tcp_ctask->xmstate & XMSTATE_W_RESEND_DATA_DIGEST)) {
-- crypto_hash_final(&tcp_conn->tx_hash, (u8*)digest);
-+ crypto_digest_final(tcp_conn->tx_tfm, (u8*)digest);
- iscsi_buf_init_iov(buf, (char*)digest, 4);
- }
- tcp_ctask->xmstate &= ~XMSTATE_W_RESEND_DATA_DIGEST;
-@@ -1517,7 +1509,7 @@ iscsi_send_data(struct iscsi_cmd_task *c
- rc = iscsi_sendpage(conn, sendbuf, count, &buf_sent);
- *sent = *sent + buf_sent;
- if (buf_sent && conn->datadgst_en)
-- partial_sg_digest_update(&tcp_conn->tx_hash,
-+ partial_sg_digest_update(tcp_conn->tx_tfm,
- &sendbuf->sg, sendbuf->sg.offset + offset,
- buf_sent);
- if (!iscsi_buf_left(sendbuf) && *sg != tcp_ctask->bad_sg) {
-@@ -1774,22 +1766,18 @@ iscsi_tcp_conn_create(struct iscsi_cls_s
- /* initial operational parameters */
- tcp_conn->hdr_size = sizeof(struct iscsi_hdr);
-
-- tcp_conn->tx_hash.tfm = crypto_alloc_hash("crc32c", 0,
-- CRYPTO_ALG_ASYNC);
-- tcp_conn->tx_hash.flags = 0;
-- if (IS_ERR(tcp_conn->tx_hash.tfm))
-+ tcp_conn->tx_tfm = crypto_alloc_tfm("crc32c", 0);
-+ if (!tcp_conn->tx_tfm)
- goto free_tcp_conn;
-
-- tcp_conn->rx_hash.tfm = crypto_alloc_hash("crc32c", 0,
-- CRYPTO_ALG_ASYNC);
-- tcp_conn->rx_hash.flags = 0;
-- if (IS_ERR(tcp_conn->rx_hash.tfm))
-+ tcp_conn->rx_tfm = crypto_alloc_tfm("crc32c", 0);
-+ if (!tcp_conn->rx_tfm)
- goto free_tx_tfm;
-
- return cls_conn;
-
- free_tx_tfm:
-- crypto_free_hash(tcp_conn->tx_hash.tfm);
-+ crypto_free_tfm(tcp_conn->tx_tfm);
- free_tcp_conn:
- kfree(tcp_conn);
- tcp_conn_alloc_fail:
-@@ -1823,11 +1811,10 @@ iscsi_tcp_conn_destroy(struct iscsi_cls_
- iscsi_tcp_release_conn(conn);
- iscsi_conn_teardown(cls_conn);
-
-- if (tcp_conn->tx_hash.tfm)
-- crypto_free_hash(tcp_conn->tx_hash.tfm);
-- if (tcp_conn->rx_hash.tfm)
-- crypto_free_hash(tcp_conn->rx_hash.tfm);
--
-+ if (tcp_conn->tx_tfm)
-+ crypto_free_tfm(tcp_conn->tx_tfm);
-+ if (tcp_conn->rx_tfm)
-+ crypto_free_tfm(tcp_conn->rx_tfm);
- kfree(tcp_conn);
- }
-
-@@ -1835,11 +1822,9 @@ static void
- iscsi_tcp_conn_stop(struct iscsi_cls_conn *cls_conn, int flag)
- {
- struct iscsi_conn *conn = cls_conn->dd_data;
-- struct iscsi_tcp_conn *tcp_conn = conn->dd_data;
-
- iscsi_conn_stop(cls_conn, flag);
- iscsi_tcp_release_conn(conn);
-- tcp_conn->hdr_size = sizeof(struct iscsi_hdr);
- }
-
- static int
-Index: gen2_devel_kernel-20070129-1858_linux-2.6.18.6_check/drivers/scsi/iscsi_tcp.h
-===================================================================
---- gen2_devel_kernel-20070129-1858_linux-2.6.18.6_check.orig/drivers/scsi/iscsi_tcp.h
-+++ gen2_devel_kernel-20070129-1858_linux-2.6.18.6_check/drivers/scsi/iscsi_tcp.h
-@@ -49,7 +49,6 @@
- #define ISCSI_SG_TABLESIZE SG_ALL
- #define ISCSI_TCP_MAX_CMD_LEN 16
-
--struct crypto_hash;
- struct socket;
-
- /* Socket connection recieve helper */
-@@ -82,7 +81,6 @@ struct iscsi_tcp_conn {
- * stop to terminate */
- /* iSCSI connection-wide sequencing */
- int hdr_size; /* PDU header size */
--
- /* control data */
- struct iscsi_tcp_recv in; /* TCP receive context */
- int in_progress; /* connection state machine */
-@@ -93,8 +91,8 @@ struct iscsi_tcp_conn {
- void (*old_write_space)(struct sock *);
-
- /* data and header digests */
-- struct hash_desc tx_hash; /* CRC32C (Tx) */
-- struct hash_desc rx_hash; /* CRC32C (Rx) */
-+ struct crypto_tfm *tx_tfm; /* CRC32C (Tx) */
-+ struct crypto_tfm *rx_tfm; /* CRC32C (Rx) */
-
- /* MIB custom statistics */
- uint32_t sendpage_failures_cnt;
--
1.5.2
More information about the ewg
mailing list