19a6844d5SKenneth D. Merry /*- 2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 39b10f59aSPedro F. Giffuni * 49a6844d5SKenneth D. Merry * Copyright (c) 2015 Spectra Logic Corporation 59a6844d5SKenneth D. Merry * All rights reserved. 69a6844d5SKenneth D. Merry * 79a6844d5SKenneth D. Merry * Redistribution and use in source and binary forms, with or without 89a6844d5SKenneth D. Merry * modification, are permitted provided that the following conditions 99a6844d5SKenneth D. Merry * are met: 109a6844d5SKenneth D. Merry * 1. Redistributions of source code must retain the above copyright 119a6844d5SKenneth D. Merry * notice, this list of conditions, and the following disclaimer, 129a6844d5SKenneth D. Merry * without modification. 139a6844d5SKenneth D. Merry * 2. Redistributions in binary form must reproduce at minimum a disclaimer 149a6844d5SKenneth D. Merry * substantially similar to the "NO WARRANTY" disclaimer below 159a6844d5SKenneth D. Merry * ("Disclaimer") and any redistribution must be conditioned upon 169a6844d5SKenneth D. Merry * including a substantially similar Disclaimer requirement for further 179a6844d5SKenneth D. Merry * binary redistribution. 189a6844d5SKenneth D. Merry * 199a6844d5SKenneth D. Merry * NO WARRANTY 209a6844d5SKenneth D. Merry * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 219a6844d5SKenneth D. Merry * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 229a6844d5SKenneth D. Merry * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 239a6844d5SKenneth D. Merry * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 249a6844d5SKenneth D. Merry * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 259a6844d5SKenneth D. Merry * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 269a6844d5SKenneth D. Merry * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 279a6844d5SKenneth D. Merry * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 289a6844d5SKenneth D. Merry * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 299a6844d5SKenneth D. Merry * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 309a6844d5SKenneth D. Merry * POSSIBILITY OF SUCH DAMAGES. 319a6844d5SKenneth D. Merry * 329a6844d5SKenneth D. Merry * Authors: Ken Merry (Spectra Logic Corporation) 339a6844d5SKenneth D. Merry */ 349a6844d5SKenneth D. Merry 359a6844d5SKenneth D. Merry #ifndef _SYS_DISK_ZONE_H_ 369a6844d5SKenneth D. Merry #define _SYS_DISK_ZONE_H_ 379a6844d5SKenneth D. Merry 389a6844d5SKenneth D. Merry /* 399a6844d5SKenneth D. Merry * Interface for Zone-based disks. This allows managing devices that 409a6844d5SKenneth D. Merry * conform to the SCSI Zoned Block Commands (ZBC) and ATA Zoned ATA Command 419a6844d5SKenneth D. Merry * Set (ZAC) specifications. Devices using these command sets are 429a6844d5SKenneth D. Merry * currently (October 2015) hard drives using Shingled Magnetic Recording 439a6844d5SKenneth D. Merry * (SMR). 449a6844d5SKenneth D. Merry */ 459a6844d5SKenneth D. Merry 469a6844d5SKenneth D. Merry /* 479a6844d5SKenneth D. Merry * There are currently three types of zoned devices: 489a6844d5SKenneth D. Merry * 499a6844d5SKenneth D. Merry * Drive Managed: 509a6844d5SKenneth D. Merry * Drive Managed drives look and act just like a standard random access 519a6844d5SKenneth D. Merry * block device, but underneath, the drive reads and writes the bulk of 529a6844d5SKenneth D. Merry * its capacity using SMR zones. Sequential writes will yield better 539a6844d5SKenneth D. Merry * performance, but writing sequentially is not required. 549a6844d5SKenneth D. Merry * 559a6844d5SKenneth D. Merry * Host Aware: 569a6844d5SKenneth D. Merry * Host Aware drives expose the underlying zone layout via SCSI or ATA 579a6844d5SKenneth D. Merry * commands and allow the host to manage the zone conditions. The host 589a6844d5SKenneth D. Merry * is not required to manage the zones on the drive, though. Sequential 599a6844d5SKenneth D. Merry * writes will yield better performance in Sequential Write Preferred 609a6844d5SKenneth D. Merry * zones, but the host can write randomly in those zones. 619a6844d5SKenneth D. Merry * 629a6844d5SKenneth D. Merry * Host Managed: 639a6844d5SKenneth D. Merry * Host Managed drives expose the underlying zone layout via SCSI or ATA 649a6844d5SKenneth D. Merry * commands. The host is required to access the zones according to the 659a6844d5SKenneth D. Merry * rules described by the zone layout. Any commands that violate the 669a6844d5SKenneth D. Merry * rules will be returned with an error. 679a6844d5SKenneth D. Merry */ 689a6844d5SKenneth D. Merry struct disk_zone_disk_params { 699a6844d5SKenneth D. Merry uint32_t zone_mode; 709a6844d5SKenneth D. Merry #define DISK_ZONE_MODE_NONE 0x00 719a6844d5SKenneth D. Merry #define DISK_ZONE_MODE_HOST_AWARE 0x01 729a6844d5SKenneth D. Merry #define DISK_ZONE_MODE_DRIVE_MANAGED 0x02 739a6844d5SKenneth D. Merry #define DISK_ZONE_MODE_HOST_MANAGED 0x04 749a6844d5SKenneth D. Merry uint64_t flags; 759a6844d5SKenneth D. Merry #define DISK_ZONE_DISK_URSWRZ 0x001 769a6844d5SKenneth D. Merry #define DISK_ZONE_OPT_SEQ_SET 0x002 779a6844d5SKenneth D. Merry #define DISK_ZONE_OPT_NONSEQ_SET 0x004 789a6844d5SKenneth D. Merry #define DISK_ZONE_MAX_SEQ_SET 0x008 799a6844d5SKenneth D. Merry #define DISK_ZONE_RZ_SUP 0x010 809a6844d5SKenneth D. Merry #define DISK_ZONE_OPEN_SUP 0x020 819a6844d5SKenneth D. Merry #define DISK_ZONE_CLOSE_SUP 0x040 829a6844d5SKenneth D. Merry #define DISK_ZONE_FINISH_SUP 0x080 839a6844d5SKenneth D. Merry #define DISK_ZONE_RWP_SUP 0x100 849a6844d5SKenneth D. Merry #define DISK_ZONE_CMD_SUP_MASK 0x1f0 859a6844d5SKenneth D. Merry uint64_t optimal_seq_zones; 869a6844d5SKenneth D. Merry uint64_t optimal_nonseq_zones; 879a6844d5SKenneth D. Merry uint64_t max_seq_zones; 889a6844d5SKenneth D. Merry }; 899a6844d5SKenneth D. Merry 909a6844d5SKenneth D. Merry /* 919a6844d5SKenneth D. Merry * Used for reset write pointer, open, close and finish. 929a6844d5SKenneth D. Merry */ 939a6844d5SKenneth D. Merry struct disk_zone_rwp { 949a6844d5SKenneth D. Merry uint64_t id; 959a6844d5SKenneth D. Merry uint8_t flags; 969a6844d5SKenneth D. Merry #define DISK_ZONE_RWP_FLAG_NONE 0x00 979a6844d5SKenneth D. Merry #define DISK_ZONE_RWP_FLAG_ALL 0x01 989a6844d5SKenneth D. Merry }; 999a6844d5SKenneth D. Merry 1009a6844d5SKenneth D. Merry /* 1019a6844d5SKenneth D. Merry * Report Zones header. All of these values are passed out. 1029a6844d5SKenneth D. Merry */ 1039a6844d5SKenneth D. Merry struct disk_zone_rep_header { 1049a6844d5SKenneth D. Merry uint8_t same; 1059a6844d5SKenneth D. Merry #define DISK_ZONE_SAME_ALL_DIFFERENT 0x0 /* Lengths and types vary */ 1069a6844d5SKenneth D. Merry #define DISK_ZONE_SAME_ALL_SAME 0x1 /* Lengths and types the same */ 1079a6844d5SKenneth D. Merry #define DISK_ZONE_SAME_LAST_DIFFERENT 0x2 /* Types same, last len varies */ 1089a6844d5SKenneth D. Merry #define DISK_ZONE_SAME_TYPES_DIFFERENT 0x3 /* Types vary, length the same */ 1099a6844d5SKenneth D. Merry uint64_t maximum_lba; 1109a6844d5SKenneth D. Merry /* 1119a6844d5SKenneth D. Merry * XXX KDM padding space may not be a good idea inside the bio. 1129a6844d5SKenneth D. Merry */ 1139a6844d5SKenneth D. Merry uint8_t reserved[64]; 1149a6844d5SKenneth D. Merry }; 1159a6844d5SKenneth D. Merry 1169a6844d5SKenneth D. Merry /* 1179a6844d5SKenneth D. Merry * Report Zones entry. Note that the zone types, conditions, and flags 1189a6844d5SKenneth D. Merry * are mapped directly from the SCSI/ATA flag values. Any additional 1199a6844d5SKenneth D. Merry * SCSI/ATA zone types or conditions or flags that are defined in the 1209a6844d5SKenneth D. Merry * future could result in additional values that are not yet defined here. 1219a6844d5SKenneth D. Merry */ 1229a6844d5SKenneth D. Merry struct disk_zone_rep_entry { 1239a6844d5SKenneth D. Merry uint8_t zone_type; 1249a6844d5SKenneth D. Merry #define DISK_ZONE_TYPE_CONVENTIONAL 0x01 1259a6844d5SKenneth D. Merry #define DISK_ZONE_TYPE_SEQ_REQUIRED 0x02 /* Host Managed */ 1269a6844d5SKenneth D. Merry #define DISK_ZONE_TYPE_SEQ_PREFERRED 0x03 /* Host Aware */ 1279a6844d5SKenneth D. Merry uint8_t zone_condition; 1289a6844d5SKenneth D. Merry #define DISK_ZONE_COND_NOT_WP 0x00 1299a6844d5SKenneth D. Merry #define DISK_ZONE_COND_EMPTY 0x01 1309a6844d5SKenneth D. Merry #define DISK_ZONE_COND_IMPLICIT_OPEN 0x02 1319a6844d5SKenneth D. Merry #define DISK_ZONE_COND_EXPLICIT_OPEN 0x03 1329a6844d5SKenneth D. Merry #define DISK_ZONE_COND_CLOSED 0x04 1339a6844d5SKenneth D. Merry #define DISK_ZONE_COND_READONLY 0x0D 1349a6844d5SKenneth D. Merry #define DISK_ZONE_COND_FULL 0x0E 1359a6844d5SKenneth D. Merry #define DISK_ZONE_COND_OFFLINE 0x0F 1369a6844d5SKenneth D. Merry uint8_t zone_flags; 1379a6844d5SKenneth D. Merry #define DISK_ZONE_FLAG_RESET 0x01 /* Zone needs RWP */ 1389a6844d5SKenneth D. Merry #define DISK_ZONE_FLAG_NON_SEQ 0x02 /* Zone accssessed nonseq */ 1399a6844d5SKenneth D. Merry uint64_t zone_length; 1409a6844d5SKenneth D. Merry uint64_t zone_start_lba; 1419a6844d5SKenneth D. Merry uint64_t write_pointer_lba; 1429a6844d5SKenneth D. Merry /* XXX KDM padding space may not be a good idea inside the bio */ 1439a6844d5SKenneth D. Merry uint8_t reserved[32]; 1449a6844d5SKenneth D. Merry }; 1459a6844d5SKenneth D. Merry 1469a6844d5SKenneth D. Merry struct disk_zone_report { 1479a6844d5SKenneth D. Merry uint64_t starting_id; /* Passed In */ 1489a6844d5SKenneth D. Merry uint8_t rep_options; /* Passed In */ 1499a6844d5SKenneth D. Merry #define DISK_ZONE_REP_ALL 0x00 1509a6844d5SKenneth D. Merry #define DISK_ZONE_REP_EMPTY 0x01 1519a6844d5SKenneth D. Merry #define DISK_ZONE_REP_IMP_OPEN 0x02 1529a6844d5SKenneth D. Merry #define DISK_ZONE_REP_EXP_OPEN 0x03 1539a6844d5SKenneth D. Merry #define DISK_ZONE_REP_CLOSED 0x04 1549a6844d5SKenneth D. Merry #define DISK_ZONE_REP_FULL 0x05 1559a6844d5SKenneth D. Merry #define DISK_ZONE_REP_READONLY 0x06 1569a6844d5SKenneth D. Merry #define DISK_ZONE_REP_OFFLINE 0x07 1579a6844d5SKenneth D. Merry #define DISK_ZONE_REP_RWP 0x10 1589a6844d5SKenneth D. Merry #define DISK_ZONE_REP_NON_SEQ 0x11 1599a6844d5SKenneth D. Merry #define DISK_ZONE_REP_NON_WP 0x3F 1609a6844d5SKenneth D. Merry struct disk_zone_rep_header header; 1619a6844d5SKenneth D. Merry uint32_t entries_allocated; /* Passed In */ 1629a6844d5SKenneth D. Merry uint32_t entries_filled; /* Passed Out */ 1639a6844d5SKenneth D. Merry uint32_t entries_available; /* Passed Out */ 1649a6844d5SKenneth D. Merry struct disk_zone_rep_entry *entries; 1659a6844d5SKenneth D. Merry }; 1669a6844d5SKenneth D. Merry 1679a6844d5SKenneth D. Merry union disk_zone_params { 1689a6844d5SKenneth D. Merry struct disk_zone_disk_params disk_params; 1699a6844d5SKenneth D. Merry struct disk_zone_rwp rwp; 1709a6844d5SKenneth D. Merry struct disk_zone_report report; 1719a6844d5SKenneth D. Merry }; 1729a6844d5SKenneth D. Merry 1739a6844d5SKenneth D. Merry struct disk_zone_args { 1749a6844d5SKenneth D. Merry uint8_t zone_cmd; 1759a6844d5SKenneth D. Merry #define DISK_ZONE_OPEN 0x00 1769a6844d5SKenneth D. Merry #define DISK_ZONE_CLOSE 0x01 1779a6844d5SKenneth D. Merry #define DISK_ZONE_FINISH 0x02 1789a6844d5SKenneth D. Merry #define DISK_ZONE_REPORT_ZONES 0x03 1799a6844d5SKenneth D. Merry #define DISK_ZONE_RWP 0x04 1809a6844d5SKenneth D. Merry #define DISK_ZONE_GET_PARAMS 0x05 1819a6844d5SKenneth D. Merry union disk_zone_params zone_params; 1829a6844d5SKenneth D. Merry }; 1839a6844d5SKenneth D. Merry 1849a6844d5SKenneth D. Merry #endif /* _SYS_DISK_ZONE_H_ */ 185