Hannes Reinecke | 6a0cb1b | 2016-10-18 15:40:33 +0900 | [diff] [blame^] | 1 | /* |
| 2 | * Zoned block devices handling. |
| 3 | * |
| 4 | * Copyright (C) 2015 Seagate Technology PLC |
| 5 | * |
| 6 | * Written by: Shaun Tancheff <shaun.tancheff@seagate.com> |
| 7 | * |
| 8 | * Modified by: Damien Le Moal <damien.lemoal@hgst.com> |
| 9 | * Copyright (C) 2016 Western Digital |
| 10 | * |
| 11 | * This file is licensed under the terms of the GNU General Public |
| 12 | * License version 2. This program is licensed "as is" without any |
| 13 | * warranty of any kind, whether express or implied. |
| 14 | */ |
| 15 | #ifndef _UAPI_BLKZONED_H |
| 16 | #define _UAPI_BLKZONED_H |
| 17 | |
| 18 | #include <linux/types.h> |
| 19 | |
| 20 | /** |
| 21 | * enum blk_zone_type - Types of zones allowed in a zoned device. |
| 22 | * |
| 23 | * @BLK_ZONE_TYPE_CONVENTIONAL: The zone has no write pointer and can be writen |
| 24 | * randomly. Zone reset has no effect on the zone. |
| 25 | * @BLK_ZONE_TYPE_SEQWRITE_REQ: The zone must be written sequentially |
| 26 | * @BLK_ZONE_TYPE_SEQWRITE_PREF: The zone can be written non-sequentially |
| 27 | * |
| 28 | * Any other value not defined is reserved and must be considered as invalid. |
| 29 | */ |
| 30 | enum blk_zone_type { |
| 31 | BLK_ZONE_TYPE_CONVENTIONAL = 0x1, |
| 32 | BLK_ZONE_TYPE_SEQWRITE_REQ = 0x2, |
| 33 | BLK_ZONE_TYPE_SEQWRITE_PREF = 0x3, |
| 34 | }; |
| 35 | |
| 36 | /** |
| 37 | * enum blk_zone_cond - Condition [state] of a zone in a zoned device. |
| 38 | * |
| 39 | * @BLK_ZONE_COND_NOT_WP: The zone has no write pointer, it is conventional. |
| 40 | * @BLK_ZONE_COND_EMPTY: The zone is empty. |
| 41 | * @BLK_ZONE_COND_IMP_OPEN: The zone is open, but not explicitly opened. |
| 42 | * @BLK_ZONE_COND_EXP_OPEN: The zones was explicitly opened by an |
| 43 | * OPEN ZONE command. |
| 44 | * @BLK_ZONE_COND_CLOSED: The zone was [explicitly] closed after writing. |
| 45 | * @BLK_ZONE_COND_FULL: The zone is marked as full, possibly by a zone |
| 46 | * FINISH ZONE command. |
| 47 | * @BLK_ZONE_COND_READONLY: The zone is read-only. |
| 48 | * @BLK_ZONE_COND_OFFLINE: The zone is offline (sectors cannot be read/written). |
| 49 | * |
| 50 | * The Zone Condition state machine in the ZBC/ZAC standards maps the above |
| 51 | * deinitions as: |
| 52 | * - ZC1: Empty | BLK_ZONE_EMPTY |
| 53 | * - ZC2: Implicit Open | BLK_ZONE_COND_IMP_OPEN |
| 54 | * - ZC3: Explicit Open | BLK_ZONE_COND_EXP_OPEN |
| 55 | * - ZC4: Closed | BLK_ZONE_CLOSED |
| 56 | * - ZC5: Full | BLK_ZONE_FULL |
| 57 | * - ZC6: Read Only | BLK_ZONE_READONLY |
| 58 | * - ZC7: Offline | BLK_ZONE_OFFLINE |
| 59 | * |
| 60 | * Conditions 0x5 to 0xC are reserved by the current ZBC/ZAC spec and should |
| 61 | * be considered invalid. |
| 62 | */ |
| 63 | enum blk_zone_cond { |
| 64 | BLK_ZONE_COND_NOT_WP = 0x0, |
| 65 | BLK_ZONE_COND_EMPTY = 0x1, |
| 66 | BLK_ZONE_COND_IMP_OPEN = 0x2, |
| 67 | BLK_ZONE_COND_EXP_OPEN = 0x3, |
| 68 | BLK_ZONE_COND_CLOSED = 0x4, |
| 69 | BLK_ZONE_COND_READONLY = 0xD, |
| 70 | BLK_ZONE_COND_FULL = 0xE, |
| 71 | BLK_ZONE_COND_OFFLINE = 0xF, |
| 72 | }; |
| 73 | |
| 74 | /** |
| 75 | * struct blk_zone - Zone descriptor for BLKREPORTZONE ioctl. |
| 76 | * |
| 77 | * @start: Zone start in 512 B sector units |
| 78 | * @len: Zone length in 512 B sector units |
| 79 | * @wp: Zone write pointer location in 512 B sector units |
| 80 | * @type: see enum blk_zone_type for possible values |
| 81 | * @cond: see enum blk_zone_cond for possible values |
| 82 | * @non_seq: Flag indicating that the zone is using non-sequential resources |
| 83 | * (for host-aware zoned block devices only). |
| 84 | * @reset: Flag indicating that a zone reset is recommended. |
| 85 | * @reserved: Padding to 64 B to match the ZBC/ZAC defined zone descriptor size. |
| 86 | * |
| 87 | * start, len and wp use the regular 512 B sector unit, regardless of the |
| 88 | * device logical block size. The overall structure size is 64 B to match the |
| 89 | * ZBC/ZAC defined zone descriptor and allow support for future additional |
| 90 | * zone information. |
| 91 | */ |
| 92 | struct blk_zone { |
| 93 | __u64 start; /* Zone start sector */ |
| 94 | __u64 len; /* Zone length in number of sectors */ |
| 95 | __u64 wp; /* Zone write pointer position */ |
| 96 | __u8 type; /* Zone type */ |
| 97 | __u8 cond; /* Zone condition */ |
| 98 | __u8 non_seq; /* Non-sequential write resources active */ |
| 99 | __u8 reset; /* Reset write pointer recommended */ |
| 100 | __u8 reserved[36]; |
| 101 | }; |
| 102 | |
| 103 | #endif /* _UAPI_BLKZONED_H */ |