From 94de66305e592ac8e44d8c5512b96697446c2d8a Mon Sep 17 00:00:00 2001 From: Boaz Harrosh Date: Thu, 16 Apr 2009 18:58:24 +0300 Subject: [PATCH] open-osd: osd-target: OSD2r05 draft support * OSD CDB Size and some elements have changed. Must of the changes did not really affected OSC's code since they where mostly in capabilities and data signatures, which are ignored by current implementation. So what changed is only the total size * OSD_CRYPTO_KEYID_SIZE grew from 20 bytes to 32 bytes This affected some attribute pages layout and functions API. The different arrays where hard coded 20, define an OSD_CRYPTO_KEYID_SIZE and use that everywhere. - Since now osd-util/osd-defs.h must be included by osd-target/osd-types.h because of OSD_CRYPTO_KEYID_SIZE above. All files that included both are fixed to only include the later. * Attributes-list-element header changed Attributes-list-element header is now 6 bytes bigger and all attributes-list values are 8 bytes aliened. This is actually what caused most of the changes. * Bump up the Product level and revision to reflect new target wire format (Fix handling off) After this patch the OSC's OSD2 target is wire compatible to latest OSD2 draft revision 5. There are no more expected wire changes to OSD2 standard. PLEASE NOTE: This target version will not longer work with OSC's osd-initiator. For Latest target the still supports osd-initiator, one needs to: []$ git checkout CDB_VER_OSD2r01 Signed-off-by: Boaz Harrosh --- osd-target/attr.c | 1 - osd-target/cdb.c | 9 ++++----- osd-target/coll.c | 1 - osd-target/db.c | 1 - osd-target/list-entry.c | 1 - osd-target/mtq.c | 1 - osd-target/obj.c | 2 -- osd-target/osd-types.h | 7 +++++-- osd-target/osd.c | 15 +++++++-------- osd-target/osd.h | 3 ++- osd-target/tests/cdb-test.c | 1 - osd-target/tests/db-test.c | 2 -- osd-target/tests/osd-test.c | 2 -- osd-target/tests/time-db.c | 1 - osd-util/osd-defs.h | 18 ++++++++++-------- 15 files changed, 28 insertions(+), 37 deletions(-) diff --git a/osd-target/attr.c b/osd-target/attr.c index 7da57dd..de107cf 100644 --- a/osd-target/attr.c +++ b/osd-target/attr.c @@ -24,7 +24,6 @@ #include #include "osd-types.h" -#include "osd-util/osd-defs.h" #include "db.h" #include "attr.h" #include "osd-util/osd-util.h" diff --git a/osd-target/cdb.c b/osd-target/cdb.c index 27a50f3..52022a9 100644 --- a/osd-target/cdb.c +++ b/osd-target/cdb.c @@ -25,7 +25,6 @@ #include "osd.h" #include "osd-util/osd-sense.h" -#include "osd-util/osd-defs.h" #include "target-sense.h" #include "cdb.h" #include "osd-util/osd-util.h" @@ -312,15 +311,15 @@ static int set_attr_list(struct command *cmd, uint64_t pid, uint64_t oid, list_hdr = &list_hdr[8]; /* XXX: osd errata */ while (list_len > 0) { - uint32_t page = get_ntohl(&list_hdr[0]); - uint32_t number = get_ntohl(&list_hdr[4]); - uint32_t len = get_ntohs(&list_hdr[8]); + uint32_t page = get_ntohl(&list_hdr[LE_PAGE_OFF]); + uint32_t number = get_ntohl(&list_hdr[LE_NUMBER_OFF]); + uint32_t len = get_ntohs(&list_hdr[LE_LEN_OFF]); uint32_t pad = 0; /* set attr on multiple objects if that is the case */ for (i = oid; i < oid+numoid; i++) { ret = osd_set_attributes(cmd->osd, pid, i, page, - number, &list_hdr[10], len, + number, &list_hdr[LE_VAL_OFF], len, isembedded, cdb_cont_len, cmd->sense); if (ret != 0) { cmd->senselen = ret; diff --git a/osd-target/coll.c b/osd-target/coll.c index a5770fe..aeb9762 100644 --- a/osd-target/coll.c +++ b/osd-target/coll.c @@ -24,7 +24,6 @@ #include #include "osd-types.h" -#include "osd-util/osd-defs.h" #include "db.h" #include "coll.h" #include "osd-util/osd-util.h" diff --git a/osd-target/db.c b/osd-target/db.c index 5d40fff..f19a272 100644 --- a/osd-target/db.c +++ b/osd-target/db.c @@ -23,7 +23,6 @@ #include #include -#include "osd-util/osd-defs.h" #include "osd-types.h" #include "osd.h" #include "db.h" diff --git a/osd-target/list-entry.c b/osd-target/list-entry.c index 44c57b6..db26611 100644 --- a/osd-target/list-entry.c +++ b/osd-target/list-entry.c @@ -20,7 +20,6 @@ #include #include -#include "osd-util/osd-defs.h" #include "osd.h" #include "list-entry.h" #include "osd-util/osd-util.h" diff --git a/osd-target/mtq.c b/osd-target/mtq.c index 240f8ef..0252b3d 100644 --- a/osd-target/mtq.c +++ b/osd-target/mtq.c @@ -24,7 +24,6 @@ #include #include "osd-types.h" -#include "osd-util/osd-defs.h" #include "db.h" #include "obj.h" #include "attr.h" diff --git a/osd-target/obj.c b/osd-target/obj.c index e6b078e..4086965 100644 --- a/osd-target/obj.c +++ b/osd-target/obj.c @@ -22,8 +22,6 @@ #include #include -#include "osd-types.h" -#include "osd-util/osd-defs.h" #include "osd.h" #include "osd-util/osd-util.h" #include "obj.h" diff --git a/osd-target/osd-types.h b/osd-target/osd-types.h index a016003..aaa1cfd 100644 --- a/osd-target/osd-types.h +++ b/osd-target/osd-types.h @@ -22,6 +22,8 @@ #include #include +#include "osd-util/osd-defs.h" + struct getattr_list_entry { uint32_t page; uint32_t number; @@ -36,6 +38,7 @@ struct getattr_list_entry { struct list_entry { uint32_t page; uint32_t number; + uint8_t reserved[6]; uint16_t len; union { void *val; @@ -48,7 +51,7 @@ enum { LE_NUMBER_OFF = offsetof(struct list_entry, number), LE_LEN_OFF = offsetof(struct list_entry, len), LE_VAL_OFF = offsetof(struct list_entry, val), - LE_MIN_ITEM_LEN = (LE_VAL_OFF + 0x7) & ~0x7 + LE_MIN_ITEM_LEN = LE_VAL_OFF, }; struct multiobj_list_entry { @@ -105,7 +108,7 @@ struct setattr_list { struct __attribute__((packed)) cur_cmd_attr_pg { uint16_t cdb_srvc_act; /* current cmd */ - uint8_t ricv[20]; /* response integrity check value */ + uint8_t ricv[OSD_CRYPTO_KEYID_SIZE]; /* response integrity check value */ uint8_t obj_type; uint8_t reserved[3]; uint64_t pid; diff --git a/osd-target/osd.c b/osd-target/osd.c index ea0debb..2044897 100644 --- a/osd-target/osd.c +++ b/osd-target/osd.c @@ -30,7 +30,6 @@ #include #include "osd.h" -#include "osd-util/osd-defs.h" #include "target-sense.h" #include "db.h" #include "attr.h" @@ -700,16 +699,16 @@ static int get_riap(struct osd_device *osd, uint64_t pid, uint64_t oid, val = "\xf1\x81\x00\x0eOSC OSDEMU\x00\x00"; break; case RIAP_VENDOR_IDENTIFICATION: - len = 4; + len = sizeof("OSC"); val = "OSC"; break; case RIAP_PRODUCT_IDENTIFICATION: - len = 8; - val = "OSDEMU "; + len = sizeof("OSDEMU"); + val = "OSDEMU"; break; case RIAP_PRODUCT_MODEL: - len = 5; - val = "9002"; + len = sizeof("OSD2r05"); + val = "OSD2r05"; break; case RIAP_PRODUCT_REVISION_LEVEL: len = RIAP_PRODUCT_REVISION_LEVEL_LEN; @@ -717,8 +716,8 @@ static int get_riap(struct osd_device *osd, uint64_t pid, uint64_t oid, val = ll; break; case RIAP_PRODUCT_SERIAL_NUMBER: - len = 2; - val = "1"; + len = sizeof("2"); + val = "2"; break; case RIAP_TOTAL_CAPACITY: /*FIXME: return capacity of osd->root device*/ diff --git a/osd-target/osd.h b/osd-target/osd.h index c6fb096..22bb8a4 100644 --- a/osd-target/osd.h +++ b/osd-target/osd.h @@ -108,7 +108,8 @@ int osd_set_attributes(struct osd_device *osd, uint64_t pid, uint64_t oid, uint32_t page, uint32_t number, const void *val, uint16_t len, uint8_t cmd_type, uint32_t cdb_cont_len, uint8_t *sense); int osd_set_key(struct osd_device *osd, int key_to_set, uint64_t pid, - uint64_t key, uint8_t seed[20], uint8_t *sense); + uint64_t key, uint8_t seed[OSD_CRYPTO_KEYID_SIZE], + uint8_t *sense); int osd_set_master_key(struct osd_device *osd, int dh_step, uint64_t key, uint32_t param_len, uint32_t alloc_len, uint8_t *outdata, uint64_t *outlen, uint32_t cdb_cont_len, uint8_t *sense); diff --git a/osd-target/tests/cdb-test.c b/osd-target/tests/cdb-test.c index 73157b8..9d657c5 100644 --- a/osd-target/tests/cdb-test.c +++ b/osd-target/tests/cdb-test.c @@ -28,7 +28,6 @@ #include "osd-types.h" #include "osd.h" #include "cdb.h" -#include "osd-util/osd-defs.h" #include "osd-util/osd-util.h" #include "osd-util/osd-sense.h" #include "osd-initiator/command.h" diff --git a/osd-target/tests/db-test.c b/osd-target/tests/db-test.c index 3019d34..617d24b 100644 --- a/osd-target/tests/db-test.c +++ b/osd-target/tests/db-test.c @@ -21,8 +21,6 @@ #include #include -#include "osd-util/osd-defs.h" -#include "osd-types.h" #include "osd.h" #include "db.h" #include "attr.h" diff --git a/osd-target/tests/osd-test.c b/osd-target/tests/osd-test.c index 1a8a0b0..9a0e426 100644 --- a/osd-target/tests/osd-test.c +++ b/osd-target/tests/osd-test.c @@ -24,8 +24,6 @@ #include #include -#include "osd-util/osd-defs.h" -#include "osd-types.h" #include "osd.h" #include "db.h" #include "attr.h" diff --git a/osd-target/tests/time-db.c b/osd-target/tests/time-db.c index ec7473e..01246fe 100644 --- a/osd-target/tests/time-db.c +++ b/osd-target/tests/time-db.c @@ -21,7 +21,6 @@ #include #include -#include "osd-util/osd-defs.h" #include "osd-types.h" #include "osd.h" #include "db.h" diff --git a/osd-util/osd-defs.h b/osd-util/osd-defs.h index 377781f..220b86d 100644 --- a/osd-util/osd-defs.h +++ b/osd-util/osd-defs.h @@ -21,8 +21,10 @@ * Shared defitions for OSD target and initiator. */ #define VARLEN_CDB 0x7f -#define OSD_CDB_SIZE 200 +#define OSD_CDB_SIZE 236 #define OSD_MAX_SENSE 252 +#define OSD_CRYPTO_KEYID_SIZE 32 +#define OSD_SYS_ID_SIZE 20 /* varlen cdb service actions for osd2r01 */ #define OSD_APPEND 0x8887 @@ -210,7 +212,7 @@ enum { CCAP_APPADDR = 0x5, /* lengths of the items */ - CCAP_RICV_LEN = 20, + CCAP_RICV_LEN = OSD_CRYPTO_KEYID_SIZE, CCAP_OBJT_LEN = 1, CCAP_PID_LEN = 8, CCAP_OID_LEN = 8, @@ -218,11 +220,11 @@ enum { /* offsets when retrieved in page format (page num and len at 0) */ CCAP_RICV_OFF = 8, - CCAP_OBJT_OFF = 28, - CCAP_PID_OFF = 32, - CCAP_OID_OFF = 40, - CCAP_APPADDR_OFF = 48, - CCAP_TOTAL_LEN = 56, + CCAP_OBJT_OFF = 28+12, + CCAP_PID_OFF = 32+12, + CCAP_OID_OFF = 40+12, + CCAP_APPADDR_OFF = 48+12, + CCAP_TOTAL_LEN = 56+12, }; /* userobject timestamp attribute page osd2r01 sec 7.1.2.18 */ @@ -282,7 +284,7 @@ enum { RIAP_CLOCK = 0x100, /* 6 */ /* lengths */ - RIAP_OSD_SYSTEM_ID_LEN = 20, + RIAP_OSD_SYSTEM_ID_LEN = OSD_SYS_ID_SIZE, RIAP_VENDOR_IDENTIFICATION_LEN = 8, RIAP_PRODUCT_IDENTIFICATION_LEN = 16, RIAP_PRODUCT_MODEL_LEN = 32,