]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - drivers/target/target_core_sbc.c
target: provide generic sbc device type/revision helpers
[karo-tx-linux.git] / drivers / target / target_core_sbc.c
1 /*
2  * SCSI Block Commands (SBC) parsing and emulation.
3  *
4  * Copyright (c) 2002, 2003, 2004, 2005 PyX Technologies, Inc.
5  * Copyright (c) 2005, 2006, 2007 SBE, Inc.
6  * Copyright (c) 2007-2010 Rising Tide Systems
7  * Copyright (c) 2008-2010 Linux-iSCSI.org
8  *
9  * Nicholas A. Bellinger <nab@kernel.org>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24  */
25
26 #include <linux/kernel.h>
27 #include <linux/module.h>
28 #include <linux/ratelimit.h>
29 #include <asm/unaligned.h>
30 #include <scsi/scsi.h>
31
32 #include <target/target_core_base.h>
33 #include <target/target_core_backend.h>
34 #include <target/target_core_fabric.h>
35
36 #include "target_core_internal.h"
37 #include "target_core_ua.h"
38
39
40 static int sbc_emulate_readcapacity(struct se_cmd *cmd)
41 {
42         struct se_device *dev = cmd->se_dev;
43         unsigned long long blocks_long = dev->transport->get_blocks(dev);
44         unsigned char *rbuf;
45         unsigned char buf[8];
46         u32 blocks;
47
48         if (blocks_long >= 0x00000000ffffffff)
49                 blocks = 0xffffffff;
50         else
51                 blocks = (u32)blocks_long;
52
53         buf[0] = (blocks >> 24) & 0xff;
54         buf[1] = (blocks >> 16) & 0xff;
55         buf[2] = (blocks >> 8) & 0xff;
56         buf[3] = blocks & 0xff;
57         buf[4] = (dev->dev_attrib.block_size >> 24) & 0xff;
58         buf[5] = (dev->dev_attrib.block_size >> 16) & 0xff;
59         buf[6] = (dev->dev_attrib.block_size >> 8) & 0xff;
60         buf[7] = dev->dev_attrib.block_size & 0xff;
61
62         rbuf = transport_kmap_data_sg(cmd);
63         if (rbuf) {
64                 memcpy(rbuf, buf, min_t(u32, sizeof(buf), cmd->data_length));
65                 transport_kunmap_data_sg(cmd);
66         }
67
68         target_complete_cmd(cmd, GOOD);
69         return 0;
70 }
71
72 static int sbc_emulate_readcapacity_16(struct se_cmd *cmd)
73 {
74         struct se_device *dev = cmd->se_dev;
75         unsigned char *rbuf;
76         unsigned char buf[32];
77         unsigned long long blocks = dev->transport->get_blocks(dev);
78
79         memset(buf, 0, sizeof(buf));
80         buf[0] = (blocks >> 56) & 0xff;
81         buf[1] = (blocks >> 48) & 0xff;
82         buf[2] = (blocks >> 40) & 0xff;
83         buf[3] = (blocks >> 32) & 0xff;
84         buf[4] = (blocks >> 24) & 0xff;
85         buf[5] = (blocks >> 16) & 0xff;
86         buf[6] = (blocks >> 8) & 0xff;
87         buf[7] = blocks & 0xff;
88         buf[8] = (dev->dev_attrib.block_size >> 24) & 0xff;
89         buf[9] = (dev->dev_attrib.block_size >> 16) & 0xff;
90         buf[10] = (dev->dev_attrib.block_size >> 8) & 0xff;
91         buf[11] = dev->dev_attrib.block_size & 0xff;
92         /*
93          * Set Thin Provisioning Enable bit following sbc3r22 in section
94          * READ CAPACITY (16) byte 14 if emulate_tpu or emulate_tpws is enabled.
95          */
96         if (dev->dev_attrib.emulate_tpu || dev->dev_attrib.emulate_tpws)
97                 buf[14] = 0x80;
98
99         rbuf = transport_kmap_data_sg(cmd);
100         if (rbuf) {
101                 memcpy(rbuf, buf, min_t(u32, sizeof(buf), cmd->data_length));
102                 transport_kunmap_data_sg(cmd);
103         }
104
105         target_complete_cmd(cmd, GOOD);
106         return 0;
107 }
108
109 int spc_get_write_same_sectors(struct se_cmd *cmd)
110 {
111         u32 num_blocks;
112
113         if (cmd->t_task_cdb[0] == WRITE_SAME)
114                 num_blocks = get_unaligned_be16(&cmd->t_task_cdb[7]);
115         else if (cmd->t_task_cdb[0] == WRITE_SAME_16)
116                 num_blocks = get_unaligned_be32(&cmd->t_task_cdb[10]);
117         else /* WRITE_SAME_32 via VARIABLE_LENGTH_CMD */
118                 num_blocks = get_unaligned_be32(&cmd->t_task_cdb[28]);
119
120         /*
121          * Use the explicit range when non zero is supplied, otherwise calculate
122          * the remaining range based on ->get_blocks() - starting LBA.
123          */
124         if (num_blocks)
125                 return num_blocks;
126
127         return cmd->se_dev->transport->get_blocks(cmd->se_dev) -
128                 cmd->t_task_lba + 1;
129 }
130 EXPORT_SYMBOL(spc_get_write_same_sectors);
131
132 static int sbc_emulate_verify(struct se_cmd *cmd)
133 {
134         target_complete_cmd(cmd, GOOD);
135         return 0;
136 }
137
138 static int sbc_emulate_noop(struct se_cmd *cmd)
139 {
140         target_complete_cmd(cmd, GOOD);
141         return 0;
142 }
143
144 static inline u32 sbc_get_size(struct se_cmd *cmd, u32 sectors)
145 {
146         return cmd->se_dev->dev_attrib.block_size * sectors;
147 }
148
149 static int sbc_check_valid_sectors(struct se_cmd *cmd)
150 {
151         struct se_device *dev = cmd->se_dev;
152         unsigned long long end_lba;
153         u32 sectors;
154
155         sectors = cmd->data_length / dev->dev_attrib.block_size;
156         end_lba = dev->transport->get_blocks(dev) + 1;
157
158         if (cmd->t_task_lba + sectors > end_lba) {
159                 pr_err("target: lba %llu, sectors %u exceeds end lba %llu\n",
160                         cmd->t_task_lba, sectors, end_lba);
161                 return -EINVAL;
162         }
163
164         return 0;
165 }
166
167 static inline u32 transport_get_sectors_6(unsigned char *cdb)
168 {
169         /*
170          * Use 8-bit sector value.  SBC-3 says:
171          *
172          *   A TRANSFER LENGTH field set to zero specifies that 256
173          *   logical blocks shall be written.  Any other value
174          *   specifies the number of logical blocks that shall be
175          *   written.
176          */
177         return cdb[4] ? : 256;
178 }
179
180 static inline u32 transport_get_sectors_10(unsigned char *cdb)
181 {
182         return (u32)(cdb[7] << 8) + cdb[8];
183 }
184
185 static inline u32 transport_get_sectors_12(unsigned char *cdb)
186 {
187         return (u32)(cdb[6] << 24) + (cdb[7] << 16) + (cdb[8] << 8) + cdb[9];
188 }
189
190 static inline u32 transport_get_sectors_16(unsigned char *cdb)
191 {
192         return (u32)(cdb[10] << 24) + (cdb[11] << 16) +
193                     (cdb[12] << 8) + cdb[13];
194 }
195
196 /*
197  * Used for VARIABLE_LENGTH_CDB WRITE_32 and READ_32 variants
198  */
199 static inline u32 transport_get_sectors_32(unsigned char *cdb)
200 {
201         return (u32)(cdb[28] << 24) + (cdb[29] << 16) +
202                     (cdb[30] << 8) + cdb[31];
203
204 }
205
206 static inline u32 transport_lba_21(unsigned char *cdb)
207 {
208         return ((cdb[1] & 0x1f) << 16) | (cdb[2] << 8) | cdb[3];
209 }
210
211 static inline u32 transport_lba_32(unsigned char *cdb)
212 {
213         return (cdb[2] << 24) | (cdb[3] << 16) | (cdb[4] << 8) | cdb[5];
214 }
215
216 static inline unsigned long long transport_lba_64(unsigned char *cdb)
217 {
218         unsigned int __v1, __v2;
219
220         __v1 = (cdb[2] << 24) | (cdb[3] << 16) | (cdb[4] << 8) | cdb[5];
221         __v2 = (cdb[6] << 24) | (cdb[7] << 16) | (cdb[8] << 8) | cdb[9];
222
223         return ((unsigned long long)__v2) | (unsigned long long)__v1 << 32;
224 }
225
226 /*
227  * For VARIABLE_LENGTH_CDB w/ 32 byte extended CDBs
228  */
229 static inline unsigned long long transport_lba_64_ext(unsigned char *cdb)
230 {
231         unsigned int __v1, __v2;
232
233         __v1 = (cdb[12] << 24) | (cdb[13] << 16) | (cdb[14] << 8) | cdb[15];
234         __v2 = (cdb[16] << 24) | (cdb[17] << 16) | (cdb[18] << 8) | cdb[19];
235
236         return ((unsigned long long)__v2) | (unsigned long long)__v1 << 32;
237 }
238
239 static int sbc_write_same_supported(struct se_device *dev,
240                 unsigned char *flags)
241 {
242         if ((flags[0] & 0x04) || (flags[0] & 0x02)) {
243                 pr_err("WRITE_SAME PBDATA and LBDATA"
244                         " bits not supported for Block Discard"
245                         " Emulation\n");
246                 return -ENOSYS;
247         }
248
249         /*
250          * Currently for the emulated case we only accept
251          * tpws with the UNMAP=1 bit set.
252          */
253         if (!(flags[0] & 0x08)) {
254                 pr_err("WRITE_SAME w/o UNMAP bit not"
255                         " supported for Block Discard Emulation\n");
256                 return -ENOSYS;
257         }
258
259         return 0;
260 }
261
262 static void xdreadwrite_callback(struct se_cmd *cmd)
263 {
264         unsigned char *buf, *addr;
265         struct scatterlist *sg;
266         unsigned int offset;
267         int i;
268         int count;
269         /*
270          * From sbc3r22.pdf section 5.48 XDWRITEREAD (10) command
271          *
272          * 1) read the specified logical block(s);
273          * 2) transfer logical blocks from the data-out buffer;
274          * 3) XOR the logical blocks transferred from the data-out buffer with
275          *    the logical blocks read, storing the resulting XOR data in a buffer;
276          * 4) if the DISABLE WRITE bit is set to zero, then write the logical
277          *    blocks transferred from the data-out buffer; and
278          * 5) transfer the resulting XOR data to the data-in buffer.
279          */
280         buf = kmalloc(cmd->data_length, GFP_KERNEL);
281         if (!buf) {
282                 pr_err("Unable to allocate xor_callback buf\n");
283                 return;
284         }
285         /*
286          * Copy the scatterlist WRITE buffer located at cmd->t_data_sg
287          * into the locally allocated *buf
288          */
289         sg_copy_to_buffer(cmd->t_data_sg,
290                           cmd->t_data_nents,
291                           buf,
292                           cmd->data_length);
293
294         /*
295          * Now perform the XOR against the BIDI read memory located at
296          * cmd->t_mem_bidi_list
297          */
298
299         offset = 0;
300         for_each_sg(cmd->t_bidi_data_sg, sg, cmd->t_bidi_data_nents, count) {
301                 addr = kmap_atomic(sg_page(sg));
302                 if (!addr)
303                         goto out;
304
305                 for (i = 0; i < sg->length; i++)
306                         *(addr + sg->offset + i) ^= *(buf + offset + i);
307
308                 offset += sg->length;
309                 kunmap_atomic(addr);
310         }
311
312 out:
313         kfree(buf);
314 }
315
316 int sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
317 {
318         struct se_device *dev = cmd->se_dev;
319         unsigned char *cdb = cmd->t_task_cdb;
320         unsigned int size;
321         u32 sectors = 0;
322         int ret;
323
324         switch (cdb[0]) {
325         case READ_6:
326                 sectors = transport_get_sectors_6(cdb);
327                 cmd->t_task_lba = transport_lba_21(cdb);
328                 cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
329                 cmd->execute_cmd = ops->execute_rw;
330                 break;
331         case READ_10:
332                 sectors = transport_get_sectors_10(cdb);
333                 cmd->t_task_lba = transport_lba_32(cdb);
334                 cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
335                 cmd->execute_cmd = ops->execute_rw;
336                 break;
337         case READ_12:
338                 sectors = transport_get_sectors_12(cdb);
339                 cmd->t_task_lba = transport_lba_32(cdb);
340                 cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
341                 cmd->execute_cmd = ops->execute_rw;
342                 break;
343         case READ_16:
344                 sectors = transport_get_sectors_16(cdb);
345                 cmd->t_task_lba = transport_lba_64(cdb);
346                 cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
347                 cmd->execute_cmd = ops->execute_rw;
348                 break;
349         case WRITE_6:
350                 sectors = transport_get_sectors_6(cdb);
351                 cmd->t_task_lba = transport_lba_21(cdb);
352                 cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
353                 cmd->execute_cmd = ops->execute_rw;
354                 break;
355         case WRITE_10:
356         case WRITE_VERIFY:
357                 sectors = transport_get_sectors_10(cdb);
358                 cmd->t_task_lba = transport_lba_32(cdb);
359                 if (cdb[1] & 0x8)
360                         cmd->se_cmd_flags |= SCF_FUA;
361                 cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
362                 cmd->execute_cmd = ops->execute_rw;
363                 break;
364         case WRITE_12:
365                 sectors = transport_get_sectors_12(cdb);
366                 cmd->t_task_lba = transport_lba_32(cdb);
367                 if (cdb[1] & 0x8)
368                         cmd->se_cmd_flags |= SCF_FUA;
369                 cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
370                 cmd->execute_cmd = ops->execute_rw;
371                 break;
372         case WRITE_16:
373                 sectors = transport_get_sectors_16(cdb);
374                 cmd->t_task_lba = transport_lba_64(cdb);
375                 if (cdb[1] & 0x8)
376                         cmd->se_cmd_flags |= SCF_FUA;
377                 cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
378                 cmd->execute_cmd = ops->execute_rw;
379                 break;
380         case XDWRITEREAD_10:
381                 if ((cmd->data_direction != DMA_TO_DEVICE) ||
382                     !(cmd->se_cmd_flags & SCF_BIDI))
383                         goto out_invalid_cdb_field;
384                 sectors = transport_get_sectors_10(cdb);
385
386                 cmd->t_task_lba = transport_lba_32(cdb);
387                 cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
388
389                 /*
390                  * Setup BIDI XOR callback to be run after I/O completion.
391                  */
392                 cmd->execute_cmd = ops->execute_rw;
393                 cmd->transport_complete_callback = &xdreadwrite_callback;
394                 if (cdb[1] & 0x8)
395                         cmd->se_cmd_flags |= SCF_FUA;
396                 break;
397         case VARIABLE_LENGTH_CMD:
398         {
399                 u16 service_action = get_unaligned_be16(&cdb[8]);
400                 switch (service_action) {
401                 case XDWRITEREAD_32:
402                         sectors = transport_get_sectors_32(cdb);
403
404                         /*
405                          * Use WRITE_32 and READ_32 opcodes for the emulated
406                          * XDWRITE_READ_32 logic.
407                          */
408                         cmd->t_task_lba = transport_lba_64_ext(cdb);
409                         cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
410
411                         /*
412                          * Setup BIDI XOR callback to be run during after I/O
413                          * completion.
414                          */
415                         cmd->execute_cmd = ops->execute_rw;
416                         cmd->transport_complete_callback = &xdreadwrite_callback;
417                         if (cdb[1] & 0x8)
418                                 cmd->se_cmd_flags |= SCF_FUA;
419                         break;
420                 case WRITE_SAME_32:
421                         if (!ops->execute_write_same)
422                                 goto out_unsupported_cdb;
423
424                         sectors = transport_get_sectors_32(cdb);
425                         if (!sectors) {
426                                 pr_err("WSNZ=1, WRITE_SAME w/sectors=0 not"
427                                        " supported\n");
428                                 goto out_invalid_cdb_field;
429                         }
430
431                         size = sbc_get_size(cmd, 1);
432                         cmd->t_task_lba = get_unaligned_be64(&cdb[12]);
433
434                         if (sbc_write_same_supported(dev, &cdb[10]) < 0)
435                                 goto out_unsupported_cdb;
436                         cmd->execute_cmd = ops->execute_write_same;
437                         break;
438                 default:
439                         pr_err("VARIABLE_LENGTH_CMD service action"
440                                 " 0x%04x not supported\n", service_action);
441                         goto out_unsupported_cdb;
442                 }
443                 break;
444         }
445         case READ_CAPACITY:
446                 size = READ_CAP_LEN;
447                 cmd->execute_cmd = sbc_emulate_readcapacity;
448                 break;
449         case SERVICE_ACTION_IN:
450                 switch (cmd->t_task_cdb[1] & 0x1f) {
451                 case SAI_READ_CAPACITY_16:
452                         cmd->execute_cmd = sbc_emulate_readcapacity_16;
453                         break;
454                 default:
455                         pr_err("Unsupported SA: 0x%02x\n",
456                                 cmd->t_task_cdb[1] & 0x1f);
457                         goto out_invalid_cdb_field;
458                 }
459                 size = (cdb[10] << 24) | (cdb[11] << 16) |
460                        (cdb[12] << 8) | cdb[13];
461                 break;
462         case SYNCHRONIZE_CACHE:
463         case SYNCHRONIZE_CACHE_16:
464                 if (!ops->execute_sync_cache)
465                         goto out_unsupported_cdb;
466
467                 /*
468                  * Extract LBA and range to be flushed for emulated SYNCHRONIZE_CACHE
469                  */
470                 if (cdb[0] == SYNCHRONIZE_CACHE) {
471                         sectors = transport_get_sectors_10(cdb);
472                         cmd->t_task_lba = transport_lba_32(cdb);
473                 } else {
474                         sectors = transport_get_sectors_16(cdb);
475                         cmd->t_task_lba = transport_lba_64(cdb);
476                 }
477
478                 size = sbc_get_size(cmd, sectors);
479
480                 /*
481                  * Check to ensure that LBA + Range does not exceed past end of
482                  * device for IBLOCK and FILEIO ->do_sync_cache() backend calls
483                  */
484                 if (cmd->t_task_lba || sectors) {
485                         if (sbc_check_valid_sectors(cmd) < 0)
486                                 goto out_invalid_cdb_field;
487                 }
488                 cmd->execute_cmd = ops->execute_sync_cache;
489                 break;
490         case UNMAP:
491                 if (!ops->execute_unmap)
492                         goto out_unsupported_cdb;
493
494                 size = get_unaligned_be16(&cdb[7]);
495                 cmd->execute_cmd = ops->execute_unmap;
496                 break;
497         case WRITE_SAME_16:
498                 if (!ops->execute_write_same)
499                         goto out_unsupported_cdb;
500
501                 sectors = transport_get_sectors_16(cdb);
502                 if (!sectors) {
503                         pr_err("WSNZ=1, WRITE_SAME w/sectors=0 not supported\n");
504                         goto out_invalid_cdb_field;
505                 }
506
507                 size = sbc_get_size(cmd, 1);
508                 cmd->t_task_lba = get_unaligned_be64(&cdb[2]);
509
510                 if (sbc_write_same_supported(dev, &cdb[1]) < 0)
511                         goto out_unsupported_cdb;
512                 cmd->execute_cmd = ops->execute_write_same;
513                 break;
514         case WRITE_SAME:
515                 if (!ops->execute_write_same)
516                         goto out_unsupported_cdb;
517
518                 sectors = transport_get_sectors_10(cdb);
519                 if (!sectors) {
520                         pr_err("WSNZ=1, WRITE_SAME w/sectors=0 not supported\n");
521                         goto out_invalid_cdb_field;
522                 }
523
524                 size = sbc_get_size(cmd, 1);
525                 cmd->t_task_lba = get_unaligned_be32(&cdb[2]);
526
527                 /*
528                  * Follow sbcr26 with WRITE_SAME (10) and check for the existence
529                  * of byte 1 bit 3 UNMAP instead of original reserved field
530                  */
531                 if (sbc_write_same_supported(dev, &cdb[1]) < 0)
532                         goto out_unsupported_cdb;
533                 cmd->execute_cmd = ops->execute_write_same;
534                 break;
535         case VERIFY:
536                 size = 0;
537                 cmd->execute_cmd = sbc_emulate_verify;
538                 break;
539         case REZERO_UNIT:
540         case SEEK_6:
541         case SEEK_10:
542                 /*
543                  * There are still clients out there which use these old SCSI-2
544                  * commands. This mainly happens when running VMs with legacy
545                  * guest systems, connected via SCSI command pass-through to
546                  * iSCSI targets. Make them happy and return status GOOD.
547                  */
548                 size = 0;
549                 cmd->execute_cmd = sbc_emulate_noop;
550                 break;
551         default:
552                 ret = spc_parse_cdb(cmd, &size);
553                 if (ret)
554                         return ret;
555         }
556
557         /* reject any command that we don't have a handler for */
558         if (!(cmd->se_cmd_flags & SCF_SCSI_DATA_CDB) && !cmd->execute_cmd)
559                 goto out_unsupported_cdb;
560
561         if (cmd->se_cmd_flags & SCF_SCSI_DATA_CDB) {
562                 unsigned long long end_lba;
563
564                 if (sectors > dev->dev_attrib.fabric_max_sectors) {
565                         printk_ratelimited(KERN_ERR "SCSI OP %02xh with too"
566                                 " big sectors %u exceeds fabric_max_sectors:"
567                                 " %u\n", cdb[0], sectors,
568                                 dev->dev_attrib.fabric_max_sectors);
569                         goto out_invalid_cdb_field;
570                 }
571                 if (sectors > dev->dev_attrib.hw_max_sectors) {
572                         printk_ratelimited(KERN_ERR "SCSI OP %02xh with too"
573                                 " big sectors %u exceeds backend hw_max_sectors:"
574                                 " %u\n", cdb[0], sectors,
575                                 dev->dev_attrib.hw_max_sectors);
576                         goto out_invalid_cdb_field;
577                 }
578
579                 end_lba = dev->transport->get_blocks(dev) + 1;
580                 if (cmd->t_task_lba + sectors > end_lba) {
581                         pr_err("cmd exceeds last lba %llu "
582                                 "(lba %llu, sectors %u)\n",
583                                 end_lba, cmd->t_task_lba, sectors);
584                         goto out_invalid_cdb_field;
585                 }
586
587                 size = sbc_get_size(cmd, sectors);
588         }
589
590         ret = target_cmd_size_check(cmd, size);
591         if (ret < 0)
592                 return ret;
593
594         return 0;
595
596 out_unsupported_cdb:
597         cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
598         cmd->scsi_sense_reason = TCM_UNSUPPORTED_SCSI_OPCODE;
599         return -EINVAL;
600 out_invalid_cdb_field:
601         cmd->se_cmd_flags |= SCF_SCSI_CDB_EXCEPTION;
602         cmd->scsi_sense_reason = TCM_INVALID_CDB_FIELD;
603         return -EINVAL;
604 }
605 EXPORT_SYMBOL(sbc_parse_cdb);
606
607 u32 sbc_get_device_rev(struct se_device *dev)
608 {
609         return SCSI_SPC_2; /* Returns SPC-3 in Initiator Data */
610 }
611 EXPORT_SYMBOL(sbc_get_device_rev);
612
613 u32 sbc_get_device_type(struct se_device *dev)
614 {
615         return TYPE_DISK;
616 }
617 EXPORT_SYMBOL(sbc_get_device_type);