lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1238904128.4250.754.camel@haakon2.linux-iscsi.org>
Date:	Sat, 04 Apr 2009 21:02:08 -0700
From:	"Nicholas A. Bellinger" <nab@...ux-iscsi.org>
To:	LKML <linux-kernel@...r.kernel.org>,
	linux-scsi <linux-scsi@...r.kernel.org>
Cc:	James Bottomley <James.Bottomley@...senPartnership.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Hannes Reinecke <hare@...e.de>,
	FUJITA Tomonori <fujita.tomonori@....ntt.co.jp>,
	Mike Christie <michaelc@...wisc.edu>,
	"Martin K. Petersen" <martin.petersen@...cle.com>,
	Ming Zhang <blackmagic02881@...il.com>,
	Philipp Reisner <philipp.reisner@...bit.com>,
	Linus Torvalds <torvalds@...ux-foundation.org>
Subject: [RFC PATCH 13/19] Target_Core_Mod READ/WRITE command descriptor
	block generation code

This patch adds support for the generation of READ_6, READ_10, READ_12, READ_16,
WRITE_6, WRITE_10, WRITE_12 and WRITE_16 command descriptor blocks when handling
incoming fabric module requests that exceed the max_sectors presented for a storage
object through struct se_subsystem_api_t.

Signed-off-by: Nicholas A. Bellinger <nab@...ux-iscsi.org>

diff --git a/drivers/target/target_core_scdb.c b/drivers/target/target_core_scdb.c
new file mode 100644
index 0000000..ec111d9
--- /dev/null
+++ b/drivers/target/target_core_scdb.c
@@ -0,0 +1,154 @@
+/*******************************************************************************
+ * Filename:  target_core_scdb.c
+ *
+ * This file contains the generic target engine Split CDB related functions.
+ *
+ * Copyright (c) 2004-2005 PyX Technologies, Inc.
+ * Copyright (c) 2005, 2006, 2007 SBE, Inc.
+ * Copyright (c) 2007-2009 Rising Tide Software, Inc.
+ * Copyright (c) 2008-2009 Linux-iSCSI.org
+ *
+ * Nicholas A. Bellinger <nab@...nel.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ ******************************************************************************/
+
+
+#define TARGET_CORE_SCDB_C
+
+#include <linux/net.h>
+#include <linux/string.h>
+
+#include <target/target_core_base.h>
+#include <target/target_core_hba.h>
+#include <target/target_core_transport.h>
+#include <target/target_core_scdb.h>
+
+#undef TARGET_CORE_SCDB_C
+
+/*	split_cdb_XX_6():
+ *
+ *      21-bit LBA w/ 8-bit SECTORS
+ */
+void split_cdb_XX_6(
+	unsigned long long lba,
+	u32 *sectors,
+	unsigned char *cdb)
+{
+	cdb[1] = (lba >> 16) & 0x1f;
+	cdb[2] = (lba >> 8) & 0xff;
+	cdb[3] = lba & 0xff;
+	cdb[4] = *sectors & 0xff;
+}
+
+void split_cdb_RW_6(
+	unsigned long long lba,
+	u32 *sectors,
+	unsigned char *cdb,
+	int rw)
+{
+	cdb[0] = (rw) ? 0x0a : 0x08;
+	split_cdb_XX_6(lba, sectors, &cdb[0]);
+}
+
+/*	split_cdb_XX_10():
+ *
+ *	32-bit LBA w/ 16-bit SECTORS
+ */
+void split_cdb_XX_10(
+	unsigned long long lba,
+	u32 *sectors,
+	unsigned char *cdb)
+{
+	cdb[2] = (lba >> 24) & 0xff;
+	cdb[3] = (lba >> 16) & 0xff;
+	cdb[4] = (lba >> 8) & 0xff;
+	cdb[5] = lba & 0xff;
+	cdb[7] = (*sectors >> 8) & 0xff;
+	cdb[8] = *sectors & 0xff;
+}
+
+void split_cdb_RW_10(
+	unsigned long long lba,
+	u32 *sectors,
+	unsigned char *cdb,
+	int rw)
+{
+	cdb[0] = (rw) ? 0x2a : 0x28;
+	split_cdb_XX_10(lba, sectors, &cdb[0]);
+}
+
+/*	split_cdb_XX_12():
+ *
+ *	32-bit LBA w/ 32-bit SECTORS
+ */
+void split_cdb_XX_12(
+	unsigned long long lba,
+	u32 *sectors,
+	unsigned char *cdb)
+{
+	cdb[2] = (lba >> 24) & 0xff;
+	cdb[3] = (lba >> 16) & 0xff;
+	cdb[4] = (lba >> 8) & 0xff;
+	cdb[5] = lba & 0xff;
+	cdb[6] = (*sectors >> 24) & 0xff;
+	cdb[7] = (*sectors >> 16) & 0xff;
+	cdb[8] = (*sectors >> 8) & 0xff;
+	cdb[9] = *sectors & 0xff;
+}
+
+void split_cdb_RW_12(
+	unsigned long long lba,
+	u32 *sectors,
+	unsigned char *cdb,
+	int rw)
+{
+	cdb[0] = (rw) ? 0xaa : 0xa8;
+	split_cdb_XX_12(lba, sectors, &cdb[0]);
+}
+
+/*	split_cdb_XX_16():
+ *
+ *	64-bit LBA w/ 32-bit SECTORS
+ */
+void split_cdb_XX_16(
+	unsigned long long lba,
+	u32 *sectors,
+	unsigned char *cdb)
+{
+	cdb[2] = (lba >> 56) & 0xff;
+	cdb[3] = (lba >> 48) & 0xff;
+	cdb[4] = (lba >> 40) & 0xff;
+	cdb[5] = (lba >> 32) & 0xff;
+	cdb[6] = (lba >> 24) & 0xff;
+	cdb[7] = (lba >> 16) & 0xff;
+	cdb[8] = (lba >> 8) & 0xff;
+	cdb[9] = lba & 0xff;
+	cdb[10] = (*sectors >> 24) & 0xff;
+	cdb[11] = (*sectors >> 16) & 0xff;
+	cdb[12] = (*sectors >> 8) & 0xff;
+	cdb[13] = *sectors & 0xff;
+}
+
+void split_cdb_RW_16(
+	unsigned long long lba,
+	u32 *sectors,
+	unsigned char *cdb,
+	int rw)
+{
+	cdb[0] = (rw) ? 0x8a : 0x88;
+	split_cdb_XX_16(lba, sectors, &cdb[0]);
+}
diff --git a/include/target/target_core_scdb.h b/include/target/target_core_scdb.h
new file mode 100644
index 0000000..1330bc3
--- /dev/null
+++ b/include/target/target_core_scdb.h
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Filename:  target_core_scdb.h
+ *
+ * This file contains the iSCSI Transport Split CDB related definitions.
+ *
+ * Copyright (c) 2004-2005 PyX Technologies, Inc.
+ * Copyright (c) 2005, 2006, 2007 SBE, Inc.
+ * Copyright (c) 2007-2009 Rising Tide Software, Inc.
+ * Copyright (c) 2008-2009 Linux-iSCSI.org
+ *
+ * Nicholas A. Bellinger <nab@...nel.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ ******************************************************************************/
+
+
+#ifndef TARGET_CORE_SCDB_H
+#define TARGET_CORE_SCDB_H
+
+extern void split_cdb_XX_6(unsigned long long, u32 *, unsigned char *);
+extern void split_cdb_RW_6(unsigned long long, u32 *, unsigned char *, int);
+extern void split_cdb_XX_10(unsigned long long, u32 *, unsigned char *);
+extern void split_cdb_RW_10(unsigned long long, u32 *, unsigned char *, int);
+extern void split_cdb_XX_12(unsigned long long, u32 *, unsigned char *);
+extern void split_cdb_RW_12(unsigned long long, u32 *, unsigned char *, int);
+extern void split_cdb_XX_16(unsigned long long, u32 *, unsigned char *);
+extern void split_cdb_RW_16(unsigned long long, u32 *, unsigned char *, int);
+
+#endif /* TARGET_CORE_SCDB_H */


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ