Attached the patch in git format.

As it is my first real use of git (apart from pulling the commits from the original)
let me know if there's something missing.

Albert

FUJITA Tomonori wrote:
On Sat, 19 Jul 2008 19:34:54 +0200
Albert Pauw <[EMAIL PROTECTED]> wrote:

According to SSC-2 Rev 8 the Read Block Limits return data is made up of 6 bytes, index 0-5:

Byte 0 contains granularity (bits 0-4)
Byte 1-3 contain  Maximum Block Length Limit (MSB first)
Byte 4-5 contain Minimum Block Length Limit (MSB first)

Since all bytes are zeroed first, Byte 1 is zero.

I also added a defined value for the granularity, as defined by the
Read Block Limits command, and calculate the blk_len out of it.
Now you only need to change the GRANULARITY parameter.

So the patch is:

--- ssc.c    2008-07-19 19:29:58.000000000 +0200
+++ ssc.c.new    2008-07-19 19:30:54.000000000 +0200

Thanks, few comments.

@@ -35,6 +35,7 @@
 #include "tgtadm_error.h"
#define BLK_SHIFT 9
+#define GRANULARITY    9
static int ssc_rw(int host_no, struct scsi_cmd *cmd)
@@ -73,16 +74,16 @@
 {
     uint8_t *data;
     uint8_t buf[256];
-    uint16_t blk_len = 0x200;
+    uint16_t blk_len = 1 << GRANULARITY;
memset(buf, 0, sizeof(buf));
     data = buf;
- data[0] = 9;
+    data[0] = GRANULARITY;

For the future changes, can we add:

data[1] = (blk_len >> 16) & 0xff

     data[2] = blk_len >> 8;
     data[3] = blk_len & 0x0ff;

Let's do:

data[2] = (blk_len >> 8) & 0xff;
data[3] = blk_len & 0xff;

-    data[5] = blk_len >> 8;
-    data[6] = blk_len & 0x0ff;
+    data[4] = blk_len >> 8;
+    data[5] = blk_len & 0x0ff;

dito.

     memcpy(scsi_get_in_buffer(cmd), data, 6);
     eprintf("In ssc_read_block_limit \n");

We should check the buffer length but it would be better to do that
with a different patch.

>From 38ac36d4c2f88cdd961ec6828134fd3779a56ec5 Mon Sep 17 00:00:00 2001
From: Albert Pauw <[EMAIL PROTECTED]>
Date: Sun, 20 Jul 2008 08:00:06 +0200
Subject: [PATCH] ccording to SSC-2 Rev 8 the Read Block Limits return data is 
made up of
 6 bytes, index 0-5:

Byte 0 contains granularity (bits 0-4)
Byte 1-3 contain  Maximum Block Length Limit (MSB first)
Byte 4-5 contain Minimum Block Length Limit (MSB first)

Since all bytes are zeroed first, Byte 1 is zero.

I also added a defined value for the granularity, as defined by the
Read Block Limits command, and calculate the blk_len out of it.
Now you only need to change the GRANULARITY parameter.

Signed-off-by: Albert Pauw <[EMAIL PROTECTED]>
---
 usr/ssc.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/usr/ssc.c b/usr/ssc.c
index cd6623a..3c57b71 100644
--- a/usr/ssc.c
+++ b/usr/ssc.c
@@ -35,6 +35,7 @@
 #include "tgtadm_error.h"
 
 #define BLK_SHIFT      9
+#define GRANULARITY    9
 
 
 static int ssc_rw(int host_no, struct scsi_cmd *cmd)
@@ -73,16 +74,17 @@ static int ssc_read_block_limit(int host_no, struct 
scsi_cmd *cmd)
 {
        uint8_t *data;
        uint8_t buf[256];
-       uint16_t blk_len = 0x200;
+       uint16_t blk_len = 1 << GRANULARITY;
 
        memset(buf, 0, sizeof(buf));
        data = buf;
 
-       data[0] = 9;
-       data[2] = blk_len >> 8;
+       data[0] = GRANULARITY;
+       data[1] = (blk_len >> 16) &0x0ff;
+       data[2] = (blk_len >> 8) &0x0ff;
        data[3] = blk_len & 0x0ff;
-       data[5] = blk_len >> 8;
-       data[6] = blk_len & 0x0ff;
+       data[4] = (blk_len >> 8) &0x0ff;
+       data[5] = blk_len & 0x0ff;
 
        memcpy(scsi_get_in_buffer(cmd), data, 6);
        eprintf("In ssc_read_block_limit \n");
@@ -102,7 +104,6 @@ static int ssc_lu_init(struct scsi_lu *lu)
        lu->attrs.version_desc[0] = 0x0200; /* SSC no version claimed */
        lu->attrs.version_desc[1] = 0x0960; /* iSCSI */
        lu->attrs.version_desc[2] = 0x0300; /* SPC-3 */
-       lu->attrs.removable = 1;
 
        data = lu->mode_block_descriptor;
        size = lu->size >> BLK_SHIFT;
-- 
1.5.5.1

_______________________________________________
Stgt-devel mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/stgt-devel

Reply via email to