/src/qemu/hw/scsi/emulation.c
Line | Count | Source |
1 | | #include "qemu/osdep.h" |
2 | | #include "qemu/units.h" |
3 | | #include "qemu/bswap.h" |
4 | | #include "hw/scsi/emulation.h" |
5 | | |
6 | | int scsi_emulate_block_limits(uint8_t *outbuf, const SCSIBlockLimits *bl) |
7 | 0 | { |
8 | | /* required VPD size with unmap support */ |
9 | 0 | memset(outbuf, 0, 0x3c); |
10 | |
|
11 | 0 | outbuf[0] = bl->wsnz; /* wsnz */ |
12 | |
|
13 | 0 | if (bl->max_io_sectors) { |
14 | | /* optimal transfer length granularity. This field and the optimal |
15 | | * transfer length can't be greater than maximum transfer length. |
16 | | */ |
17 | 0 | stw_be_p(outbuf + 2, MIN(bl->min_io_size, bl->max_io_sectors)); |
18 | | |
19 | | /* maximum transfer length */ |
20 | 0 | stl_be_p(outbuf + 4, bl->max_io_sectors); |
21 | | |
22 | | /* optimal transfer length */ |
23 | 0 | stl_be_p(outbuf + 8, MIN(bl->opt_io_size, bl->max_io_sectors)); |
24 | 0 | } else { |
25 | 0 | stw_be_p(outbuf + 2, bl->min_io_size); |
26 | 0 | stl_be_p(outbuf + 8, bl->opt_io_size); |
27 | 0 | } |
28 | | |
29 | | /* max unmap LBA count */ |
30 | 0 | stl_be_p(outbuf + 16, bl->max_unmap_sectors); |
31 | | |
32 | | /* max unmap descriptors */ |
33 | 0 | stl_be_p(outbuf + 20, bl->max_unmap_descr); |
34 | | |
35 | | /* optimal unmap granularity; alignment is zero */ |
36 | 0 | stl_be_p(outbuf + 24, bl->unmap_sectors); |
37 | | |
38 | | /* max write same size, make it the same as maximum transfer length */ |
39 | 0 | stl_be_p(outbuf + 36, bl->max_io_sectors); |
40 | |
|
41 | 0 | return 0x3c; |
42 | 0 | } |