Commit 55f5b205 authored by Hui, Chunyang's avatar Hui, Chunyang Committed by Jim Harris
Browse files

Opal: Add Opal library



First submission. Implemented part of the Opal library
and "scan" function. Can be invoked by nvme_manage.

Change-Id: Iba86d86dd3af06a06b6805120ee5005af8183459
Signed-off-by: default avatarChunyang Hui <chunyang.hui@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/439335


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avataryidong0635 <dongx.yi@intel.com>
Reviewed-by: default avatarGangCao <gang.cao@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent aeb3dc9d
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -77,6 +77,11 @@ New `get_spdk_version` RPC method is introduced to get version info of the runni
The `start_nbd_disk` RPC method now take nbd_device as an optional parameter. If nbd_device
is specified, use that specified nbd device. If it's not specified, pick available one.

### Opal

Add Opal scan support for NVMe to check whether it supports SED Opal and dump
device info. nvme_manage tool can be used to invoke this.

## v19.01:

### ocf bdev
+109 −1
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@
#include "spdk/env.h"
#include "spdk/string.h"
#include "spdk/util.h"
#include "spdk/opal.h"

#define MAX_DEVS 64

@@ -46,6 +47,7 @@ struct dev {
	const struct spdk_nvme_ctrlr_data	*cdata;
	struct spdk_nvme_ns_data		*common_ns_data;
	int					outstanding_admin_cmds;
	struct spdk_opal_dev			*opal_dev;
};

static struct dev devs[MAX_DEVS];
@@ -140,7 +142,8 @@ static void usage(void)
	printf("\t[5: detach namespace from controller]\n");
	printf("\t[6: format namespace or controller]\n");
	printf("\t[7: firmware update]\n");
	printf("\t[8: quit]\n");
	printf("\t[8: opal scan]\n");
	printf("\t[9: quit]\n");
}

static void
@@ -850,6 +853,108 @@ update_firmware_image(void)
	spdk_dma_free(fw_image);
}

static void spdk_dump_opal_info(struct spdk_opal_info *opal)
{
	if (!opal->opal_ssc_dev) {
		SPDK_ERRLOG("This device is not Opal enabled. Not Supported!\n");
		return;
	}

	if (opal->tper) {
		printf("\nOpal TPer feature:\n");
		printf("ACKNACK = %s", (opal->tper_acknack ? "Y, " : "N, "));
		printf("ASYNC = %s", (opal->tper_async ? "Y, " : "N, "));
		printf("BufferManagement = %s\n", (opal->tper_buffer_mgt ? "Y, " : "N, "));
		printf("ComIDManagement = %s", (opal->tper_comid_mgt ? "Y, " : "N, "));
		printf("Streaming = %s", (opal->tper_streaming ? "Y, " : "N, "));
		printf("Sync = %s\n", (opal->tper_sync ? "Y" : "N"));
		printf("\n");
	}

	if (opal->locking) {
		printf("Opal Locking feature:\n");
		printf("Locked = %s", (opal->locking_locked ? "Y, " : "N, "));
		printf("Locking Enabled = %s", (opal->locking_locking_enabled ? "Y, " : "N, "));
		printf("Locking supported = %s\n", (opal->locking_locking_supported ? "Y" : "N"));

		printf("MBR done = %s", (opal->locking_mbr_done ? "Y, " : "N, "));
		printf("MBR enabled = %s", (opal->locking_mbr_enabled ? "Y, " : "N, "));
		printf("Media encrypt = %s\n", (opal->locking_media_encrypt ? "Y" : "N"));
		printf("\n");
	}

	if (opal->geometry) {
		printf("Opal Geometry feature:\n");
		printf("Align = %s", (opal->geometry_align ? "Y, " : "N, "));
		printf("Logical block size = %d, ", opal->geometry_logical_block_size);
		printf("Lowest aligned LBA = %ld\n", opal->geometry_lowest_aligned_lba);
		printf("\n");
	}

	if (opal->single_user_mode) {
		printf("Opal Single User Mode feature:\n");
		printf("Any in SUM = %s", (opal->single_user_any ? "Y, " : "N, "));
		printf("All in SUM = %s", (opal->single_user_all ? "Y, " : "N, "));
		printf("Policy: %s Authority,\n", (opal->single_user_policy ? "Admin" : "Users"));
		printf("Number of locking objects = %d\n ", opal->single_user_locking_objects);
		printf("\n");
	}

	if (opal->datastore) {
		printf("Opal DataStore feature:\n");
		printf("Table alignment = %d, ", opal->datastore_alignment);
		printf("Max number of tables = %d, ", opal->datastore_max_tables);
		printf("Max size of tables = %d\n", opal->datastore_max_table_size);
		printf("\n");
	}

	if (opal->opal_v100) {
		printf("Opal V100 feature:\n");
		printf("Base comID = %d, ", opal->opal_v100_base_comid);
		printf("Number of comIDs = %d, ", opal->opal_v100_num_comid);
		printf("Range crossing = %s\n", (opal->opal_v100_range_crossing ? "N" : "Y"));
		printf("\n");
	}

	if (opal->opal_v200) {
		printf("Opal V200 feature:\n");
		printf("Base comID = %d, ", opal->opal_v200_base_comid);
		printf("Number of comIDs = %d, ", opal->opal_v200_num_comid);
		printf("Initial PIN = %d,\n", opal->opal_v200_initial_pin);
		printf("Reverted PIN = %d, ", opal->opal_v200_reverted_pin);
		printf("Number of admins = %d, ", opal->opal_v200_num_admin);
		printf("Number of users = %d\n", opal->opal_v200_num_user);
		printf("\n\n");
	}
}

static void
test_opal(void)
{
	struct dev *iter;

	foreach_dev(iter) {
		if (spdk_nvme_ctrlr_get_flags(iter->ctrlr) & SPDK_NVME_CTRLR_SECURITY_SEND_RECV_SUPPORTED) {
			iter->opal_dev = spdk_opal_init_dev(iter->ctrlr);
			if (iter->opal_dev == NULL) {
				return;
			}
			if (spdk_opal_supported(iter->opal_dev)) {
				printf("\n\nOpal Supported:\n");
				display_controller(iter, CONTROLLER_DISPLAY_SIMPLISTIC);
				spdk_opal_scan(iter->opal_dev);
				spdk_dump_opal_info(spdk_opal_get_info(iter->opal_dev));
			}
			spdk_opal_close(iter->opal_dev);
		} else {
			printf("%04x:%02x:%02x.%02x: NVMe Security Support/Receive Not supported.\n",
			       iter->pci_addr.domain, iter->pci_addr.bus, iter->pci_addr.dev, iter->pci_addr.func);
			printf("%04x:%02x:%02x.%02x: Opal Not Supported\n\n\n",
			       iter->pci_addr.domain, iter->pci_addr.bus, iter->pci_addr.dev, iter->pci_addr.func);
		}
	}
}

static void
args_usage(const char *program_name)
{
@@ -943,6 +1048,9 @@ int main(int argc, char **argv)
			update_firmware_image();
			break;
		case 8:
			test_opal();
			break;
		case 9:
			exit_flag = true;
			break;
		default:

include/spdk/opal.h

0 → 100644
+145 −0
Original line number Diff line number Diff line
/*-
 *   BSD LICENSE
 *
 *   Copyright (c) Intel Corporation.
 *   All rights reserved.
 *
 *   Redistribution and use in source and binary forms, with or without
 *   modification, are permitted provided that the following conditions
 *   are met:
 *
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in
 *       the documentation and/or other materials provided with the
 *       distribution.
 *     * Neither the name of Intel Corporation nor the names of its
 *       contributors may be used to endorse or promote products derived
 *       from this software without specific prior written permission.
 *
 *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef SPDK_OPAL_H
#define SPDK_OPAL_H

#include "spdk/stdinc.h"
#include "spdk/nvme.h"
#include "spdk/log.h"
#include "spdk/endian.h"
#include "spdk/string.h"

#define SPDK_OPAL_NOT_SUPPORTED 0xFF

/*
 * TCG Storage Architecture Core Spec v2.01 r1.00
 * 5.1.5 Method Status Codes
 */
#define SPDK_OPAL_FAILED 0x3F

static const char *const spdk_opal_errors[] = {
	"SUCCESS",
	"NOT AUTHORIZED",
	"OBSOLETE/UNKNOWN ERROR",
	"SP BUSY",
	"SP FAILED",
	"SP DISABLED",
	"SP FROZEN",
	"NO SESSIONS AVAILABLE",
	"UNIQUENESS CONFLICT",
	"INSUFFICIENT SPACE",
	"INSUFFICIENT ROWS",
	"UNKNOWN ERROR",
	"INVALID PARAMETER",
	"OBSOLETE/UNKNOWN ERROR",
	"UNKNOWN ERROR",
	"TPER MALFUNCTION",
	"TRANSACTION FAILURE",
	"RESPONSE OVERFLOW",
	"AUTHORITY LOCKED OUT",
};

enum spdk_opal_cmd {
	OPAL_CMD_SAVE,
	OPAL_CMD_LOCK_UNLOCK,
	OPAL_CMD_TAKE_OWNERSHIP,
	OPAL_CMD_ACTIVATE_LSP,	/* locking sp */
	OPAL_CMD_SET_NEW_PASSWD,
	OPAL_CMD_ACTIVATE_USER,
	OPAL_CMD_REVERT_TPER,
	OPAL_CMD_SETUP_LOCKING_RANGE,
	OPAL_CMD_ADD_USER_TO_LOCKING_RANGE,
	OPAL_CMD_ENABLE_DISABLE_SHADOW_MBR,
	OPAL_CMD_ERASE_LOCKING_RANGE,
	OPAL_CMD_SECURE_ERASE_LOCKING_RANGE,
	OPAL_CMD_INITIAL_SETUP,
};

struct spdk_opal_info {
	uint8_t tper : 1;
	uint8_t locking : 1;
	uint8_t geometry : 1;
	uint8_t single_user_mode : 1;
	uint8_t datastore : 1;
	uint8_t opal_v200 : 1;
	uint8_t opal_v100 : 1;
	uint8_t vendor_specific : 1;
	uint8_t opal_ssc_dev : 1;
	uint8_t tper_acknack : 1;
	uint8_t tper_async : 1;
	uint8_t tper_buffer_mgt : 1;
	uint8_t tper_comid_mgt : 1;
	uint8_t tper_streaming : 1;
	uint8_t tper_sync : 1;
	uint8_t locking_locked : 1;
	uint8_t locking_locking_enabled : 1;
	uint8_t locking_locking_supported : 1;
	uint8_t locking_mbr_done : 1;
	uint8_t locking_mbr_enabled : 1;
	uint8_t locking_media_encrypt : 1;
	uint8_t geometry_align : 1;
	uint64_t geometry_alignment_granularity;
	uint32_t geometry_logical_block_size;
	uint64_t geometry_lowest_aligned_lba;
	uint8_t single_user_any : 1;
	uint8_t single_user_all : 1;
	uint8_t single_user_policy : 1;
	uint32_t single_user_locking_objects;
	uint16_t datastore_max_tables;
	uint32_t datastore_max_table_size;
	uint32_t datastore_alignment;
	uint16_t opal_v100_base_comid;
	uint16_t opal_v100_num_comid;
	uint8_t opal_v100_range_crossing : 1;
	uint16_t opal_v200_base_comid;
	uint16_t opal_v200_num_comid;
	uint8_t opal_v200_initial_pin;
	uint8_t opal_v200_reverted_pin;
	uint16_t opal_v200_num_admin;
	uint16_t opal_v200_num_user;
	uint8_t opal_v200_range_crossing : 1;
	uint16_t vu_feature_code; /* vendor specific feature */
};

struct spdk_opal_dev;

struct spdk_opal_dev *spdk_opal_init_dev(void *dev_handler);

void spdk_opal_scan(struct spdk_opal_dev *dev);
void spdk_opal_close(struct spdk_opal_dev *dev);
struct spdk_opal_info *spdk_opal_get_info(struct spdk_opal_dev *dev);

bool spdk_opal_supported(struct spdk_opal_dev *dev);

#endif
+376 −0
Original line number Diff line number Diff line
/*-
 *   BSD LICENSE
 *
 *   Copyright (c) Intel Corporation.
 *   All rights reserved.
 *
 *   Redistribution and use in source and binary forms, with or without
 *   modification, are permitted provided that the following conditions
 *   are met:
 *
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in
 *       the documentation and/or other materials provided with the
 *       distribution.
 *     * Neither the name of Intel Corporation nor the names of its
 *       contributors may be used to endorse or promote products derived
 *       from this software without specific prior written permission.
 *
 *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef SPDK_OPAL_SPEC_H
#define SPDK_OPAL_SPEC_H

#include "spdk/stdinc.h"

/*
 * TCG Storage Architecture Core Spec v2.01 r1.00
 * 3.2.2.3 Tokens
 */
#define SPDK_TINY_ATOM_TYPE_MAX			0x7F
#define SPDK_SHORT_ATOM_TYPE_MAX		0xBF
#define SPDK_MEDIUM_ATOM_TYPE_MAX		0xDF
#define SPDK_LONG_ATOM_TYPE_MAX			0xE3

#define SPDK_TINY_ATOM_SIGN_FLAG		0x40

#define SPDK_TINY_ATOM_DATA_MASK		0x3F

#define SPDK_SHORT_ATOM_ID			0x80
#define SPDK_SHORT_ATOM_BYTESTRING_FLAG		0x20
#define SPDK_SHORT_ATOM_SIGN_FLAG		0x10
#define SPDK_SHORT_ATOM_LEN_MASK		0x0F

#define SPDK_MEDIUM_ATOM_ID			0xC0
#define SPDK_MEDIUM_ATOM_BYTESTRING_FLAG	0x10

#define SPDK_MEDIUM_ATOM_SIGN_FLAG		0x08
#define SPDK_MEDIUM_ATOM_LEN_MASK		0x07

#define SPDK_LONG_ATOM_ID			0xE0
#define SPDK_LONG_ATOM_BYTESTRING_FLAG		0x02
#define SPDK_LONG_ATOM_SIGN_FLAG		0x01

/*
 * TCG Storage Architecture Core Spec v2.01 r1.00
 * Table-26 ComID management
 */
#define LV0_DISCOVERY_COMID			0x01

/*
 * TCG Storage Opal v2.01 r1.00
 * 5.2.3 Type Table Modification
 */
#define OPAL_MANUFACTURED_INACTIVE		0x08

#define LOCKING_RANGE_NON_GLOBAL		0x03

/*
 * Feature Code
 */
enum spdk_lv0_discovery_feature_code {
	/*
	 * TCG Storage Architecture Core Spec v2.01 r1.00
	 * 3.3.6 Level 0 Discovery
	 */
	FEATURECODE_TPER	= 0x0001,
	FEATURECODE_LOCKING	= 0x0002,

	/*
	 * Opal SSC 1.00 r3.00 Final
	 * 3.1.1.4 Opal SSC Feature
	 */
	FEATURECODE_OPALV100	= 0x0200,

	/*
	 * TCG Storage Opal v2.01 r1.00
	 * 3.1.1.4 Geometry Reporting Feature
	 * 3.1.1.5 Opal SSC V2.00 Feature
	 */
	FEATURECODE_OPALV200	= 0x0203,
	FEATURECODE_GEOMETRY	= 0x0003,

	/*
	 * TCG Storage Opal Feature Set Single User Mode v1.00 r2.00
	 * 4.2.1 Single User Mode Feature Descriptor
	 */
	FEATURECODE_SINGLEUSER	= 0x0201,

	/*
	 * TCG Storage Opal Feature Set Additional DataStore Tables v1.00 r1.00
	 * 4.1.1 DataStore Table Feature Descriptor
	 */
	FEATURECODE_DATASTORE	= 0x0202,
};

/*
 * TCG Storage Architecture Core Spec v2.01 r1.00
 * 5.1.4 Abstract Type
 */
enum spdk_opal_token {
	/* boolean */
	SPDK_OPAL_TRUE			= 0x01,
	SPDK_OPAL_FALSE			= 0x00,

	/* cell_block
	 * 5.1.4.2.3 */
	SPDK_OPAL_TABLE			= 0x00,
	SPDK_OPAL_STARTROW		= 0x01,
	SPDK_OPAL_ENDROW		= 0x02,
	SPDK_OPAL_STARTCOLUMN		= 0x03,
	SPDK_OPAL_ENDCOLUMN		= 0x04,
	SPDK_OPAL_VALUES		= 0x01,

	/* C_PIN table
	 * 5.3.2.12 */
	SPDK_OPAL_PIN			= 0x03,

	/* locking table
	 * 5.7.2.2 */
	SPDK_OPAL_RANGESTART		= 0x03,
	SPDK_OPAL_RANGELENGTH		= 0x04,
	SPDK_OPAL_READLOCKENABLED	= 0x05,
	SPDK_OPAL_WRITELOCKENABLED	= 0x06,
	SPDK_OPAL_READLOCKED		= 0x07,
	SPDK_OPAL_WRITELOCKED		= 0x08,
	SPDK_OPAL_ACTIVEKEY		= 0x0A,

	/* locking info table */
	SPDK_OPAL_MAXRANGES		= 0x04,

	/* mbr control */
	SPDK_OPAL_MBRENABLE		= 0x01,
	SPDK_OPAL_MBRDONE		= 0x02,

	/* properties */
	SPDK_OPAL_HOSTPROPERTIES	= 0x00,

	/* control tokens */
	SPDK_OPAL_STARTLIST		= 0xF0,
	SPDK_OPAL_ENDLIST		= 0xF1,
	SPDK_OPAL_STARTNAME		= 0xF2,
	SPDK_OPAL_ENDNAME		= 0xF3,
	SPDK_OPAL_CALL			= 0xF8,
	SPDK_OPAL_ENDOFDATA		= 0xF9,
	SPDK_OPAL_ENDOFSESSION		= 0xFA,
	SPDK_OPAL_STARTTRANSACTON	= 0xFB,
	SPDK_OPAL_ENDTRANSACTON		= 0xFC,
	SPDK_OPAL_EMPTYATOM		= 0xFF,
	SPDK_OPAL_WHERE			= 0x00,

	/* life cycle */
	SPDK_OPAL_LIFECYCLE		= 0x06,

	/* Autority table */
	SPDK_OPAL_AUTH_ENABLE		= 0x05,
};

/*
 * TCG Storage Architecture Core Spec v2.01 r1.00
 * Table-39 Level0 Discovery Header Format
 */
struct spdk_d0_header {
	uint32_t length;
	uint32_t revision;
	uint32_t reserved_0;
	uint32_t reserved_1;
	uint8_t vendor_specfic[32];
};

/*
 * TCG Storage Architecture Core Spec v2.01 r1.00
 * Table-42 TPer Feature Descriptor
 */
struct spdk_d0_tper_features {
	uint16_t feature_code;
	uint8_t reserved_0 : 4;
	uint8_t version : 4;
	uint8_t length;
	uint8_t sync : 1;
	uint8_t async : 1;
	uint8_t acknack : 1;
	uint8_t buffer_management : 1;
	uint8_t streaming : 1;
	uint8_t reserved_1 : 1;
	uint8_t comid_management : 1;
	uint8_t reserved_2 : 1;

	uint32_t reserved_3;
	uint32_t reserved_4;
	uint32_t reserved_5;
};

/*
 * TCG Storage Architecture Core Spec v2.01 r1.00
 * Table-43 Locking Feature Descriptor
 */
struct spdk_d0_locking_features {
	uint16_t feature_code;
	uint8_t reserved_0 : 4;
	uint8_t version : 4;
	uint8_t length;

	uint8_t locking_supported : 1;
	uint8_t locking_enabled : 1;
	uint8_t locked : 1;
	uint8_t media_encryption : 1;
	uint8_t mbr_enabled : 1;
	uint8_t mbr_done : 1;
	uint8_t reserved_1 : 1;
	uint8_t reserved_2 : 1;

	uint32_t reserved_3;
	uint32_t reserved_4;
	uint32_t reserved_5;
};

/*
 * TCG Storage Opal Feature Set Single User Mode v1.00 r2.00
 * 4.2.1 Single User Mode Feature Descriptor
 */
struct spdk_d0_sum {
	uint16_t feature_code;
	uint8_t reserved_0 : 4;
	uint8_t version : 4;
	uint8_t length;
	uint32_t num_locking_objects;

	uint8_t any : 1;
	uint8_t all : 1;
	uint8_t policy : 1;
	uint8_t reserved_1 : 5;

	uint8_t reserved_2;
	uint16_t reserved_3;
	uint32_t reserved_4;
};

/*
 * TCG Storage Opal v2.01 r1.00
 * 3.1.1.4 Geometry Reporting Feature
 */
struct spdk_d0_geo_features {
	uint16_t feature_code;
	uint8_t reserved_0 : 4;
	uint8_t version : 4;
	uint8_t length;

	uint8_t align : 1;
	uint8_t reserved_1 : 7;
	uint8_t reserved_2[7];
	uint32_t logical_block_size;
	uint64_t alignment_granularity;
	uint64_t lowest_aligned_lba;
};

/*
 * TCG Storage Opal Feature Set Additional DataStore Tables v1.00 r1.00
 * 4.1.1 DataStore Table Feature Descriptor
 */
struct spdk_d0_datastore_features {
	uint16_t feature_code;
	uint8_t reserved_0 : 4;
	uint8_t version : 4;
	uint8_t length;

	uint16_t reserved_1;
	uint16_t max_tables;
	uint32_t max_table_size;
	uint32_t alignment;
};

/*
 * Opal SSC 1.00 r3.00 Final
 * 3.1.1.4 Opal SSC Feature
 */
struct spdk_d0_opal_v100 {
	uint16_t feature_code;
	uint8_t reserved_0 : 4;
	uint8_t version : 4;
	uint8_t length;
	uint16_t base_comid;
	uint16_t number_comids;
	uint8_t range_crossing : 1;

	uint8_t reserved_1 : 7;
	uint8_t reserved_2;
	uint16_t reserved_3;
	uint32_t reserved_4;
	uint32_t reserved_5;
};

/*
 * TCG Storage Opal v2.01 r1.00
 * 3.1.1.4 Geometry Reporting Feature
 * 3.1.1.5 Opal SSC V2.00 Feature
 */
struct spdk_d0_opal_v200 {
	uint16_t featureCode;
	uint8_t reserved_0 : 4;
	uint8_t version : 4;
	uint8_t length;
	uint16_t base_comid;
	uint16_t num_comids;

	uint8_t range_crossing : 1;
	uint8_t reserved_1 : 7;

	uint16_t num_locking_admin_auth; /* Number of Locking SP Admin Authorities Supported */
	uint16_t num_locking_user_auth;
	uint8_t initial_pin;
	uint8_t reverted_pin;
	uint8_t reserved_2;
	uint32_t reserved_3;
};

/*
 * TCG Storage Architecture Core Spec v2.01 r1.00
 * 3.2.3 ComPackets, Packets & Subpackets
 */

/* CommPacket header format
 * (big-endian)
 */
struct spdk_opal_compacket {
	uint32_t reserved;
	uint8_t comid[2];
	uint8_t extended_comid[2];

	uint32_t outstanding_data;
	uint32_t min_transfer;
	uint32_t length;
};

/* packet header format */
struct spdk_opal_packet {
	uint32_t session_tsn;
	uint32_t session_hsn;
	uint32_t seq_number;

	uint16_t reserved;
	uint16_t ack_type;
	uint32_t acknowledgment;
	uint32_t length;
};

/* data subpacket header */
struct spdk_opal_data_subpacket {
	uint8_t reserved[6];
	uint16_t kind;
	uint32_t length;
};

#endif
+7 −0
Original line number Diff line number Diff line
@@ -724,6 +724,13 @@ struct spdk_scsi_pr_out_reg_and_move_param_list {
};
SPDK_STATIC_ASSERT(sizeof(struct spdk_scsi_pr_out_reg_and_move_param_list) == 24, "Incorrect size");

/*
 * SPC-4
 * Table-258 SECURITY PROTOCOL field in SECURITY PROTOCOL IN command
 */
#define SPDK_SCSI_SECP_INFO	0x00
#define SPDK_SCSI_SECP_TCG	0x01

#define SPDK_SCSI_UNMAP_LBPU			1 << 7
#define SPDK_SCSI_UNMAP_LBPWS			1 << 6
#define SPDK_SCSI_UNMAP_LBPWS10			1 << 5
Loading