1 /*******************************************************************************
2 * Filename: target_core_scdb.c
4 * This file contains the generic target engine Split CDB related functions.
6 * Copyright (c) 2004-2005 PyX Technologies, Inc.
7 * Copyright (c) 2005, 2006, 2007 SBE, Inc.
8 * Copyright (c) 2007-2010 Rising Tide Systems
9 * Copyright (c) 2008-2010 Linux-iSCSI.org
11 * Nicholas A. Bellinger <nab@kernel.org>
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 ******************************************************************************/
29 #include <linux/net.h>
30 #include <linux/string.h>
31 #include <scsi/scsi.h>
32 #include <asm/unaligned.h>
34 #include <target/target_core_base.h>
35 #include <target/target_core_transport.h>
37 #include "target_core_scdb.h"
41 * 21-bit LBA w/ 8-bit SECTORS
44 unsigned long long lba
,
48 cdb
[1] = (lba
>> 16) & 0x1f;
49 cdb
[2] = (lba
>> 8) & 0xff;
51 cdb
[4] = sectors
& 0xff;
56 * 32-bit LBA w/ 16-bit SECTORS
59 unsigned long long lba
,
63 put_unaligned_be32(lba
, &cdb
[2]);
64 put_unaligned_be16(sectors
, &cdb
[7]);
69 * 32-bit LBA w/ 32-bit SECTORS
72 unsigned long long lba
,
76 put_unaligned_be32(lba
, &cdb
[2]);
77 put_unaligned_be32(sectors
, &cdb
[6]);
82 * 64-bit LBA w/ 32-bit SECTORS
85 unsigned long long lba
,
89 put_unaligned_be64(lba
, &cdb
[2]);
90 put_unaligned_be32(sectors
, &cdb
[10]);
96 * 64-bit LBA w/ 32-bit SECTORS such as READ_32, WRITE_32 and emulated XDWRITEREAD_32
99 unsigned long long lba
,
103 put_unaligned_be64(lba
, &cdb
[12]);
104 put_unaligned_be32(sectors
, &cdb
[28]);