• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1  /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2  /*
3   * Zoned block devices handling.
4   *
5   * Copyright (C) 2015 Seagate Technology PLC
6   *
7   * Written by: Shaun Tancheff <shaun.tancheff@seagate.com>
8   *
9   * Modified by: Damien Le Moal <damien.lemoal@hgst.com>
10   * Copyright (C) 2016 Western Digital
11   *
12   * This file is licensed under  the terms of the GNU General Public
13   * License version 2. This program is licensed "as is" without any
14   * warranty of any kind, whether express or implied.
15   */
16  #ifndef _UAPI_BLKZONED_H
17  #define _UAPI_BLKZONED_H
18  
19  #include <linux/types.h>
20  #include <linux/ioctl.h>
21  
22  /**
23   * enum blk_zone_type - Types of zones allowed in a zoned device.
24   *
25   * @BLK_ZONE_TYPE_CONVENTIONAL: The zone has no write pointer and can be writen
26   *                              randomly. Zone reset has no effect on the zone.
27   * @BLK_ZONE_TYPE_SEQWRITE_REQ: The zone must be written sequentially
28   * @BLK_ZONE_TYPE_SEQWRITE_PREF: The zone can be written non-sequentially
29   *
30   * Any other value not defined is reserved and must be considered as invalid.
31   */
32  enum blk_zone_type {
33  	BLK_ZONE_TYPE_CONVENTIONAL	= 0x1,
34  	BLK_ZONE_TYPE_SEQWRITE_REQ	= 0x2,
35  	BLK_ZONE_TYPE_SEQWRITE_PREF	= 0x3,
36  };
37  
38  /**
39   * enum blk_zone_cond - Condition [state] of a zone in a zoned device.
40   *
41   * @BLK_ZONE_COND_NOT_WP: The zone has no write pointer, it is conventional.
42   * @BLK_ZONE_COND_EMPTY: The zone is empty.
43   * @BLK_ZONE_COND_IMP_OPEN: The zone is open, but not explicitly opened.
44   * @BLK_ZONE_COND_EXP_OPEN: The zones was explicitly opened by an
45   *                          OPEN ZONE command.
46   * @BLK_ZONE_COND_CLOSED: The zone was [explicitly] closed after writing.
47   * @BLK_ZONE_COND_FULL: The zone is marked as full, possibly by a zone
48   *                      FINISH ZONE command.
49   * @BLK_ZONE_COND_READONLY: The zone is read-only.
50   * @BLK_ZONE_COND_OFFLINE: The zone is offline (sectors cannot be read/written).
51   *
52   * The Zone Condition state machine in the ZBC/ZAC standards maps the above
53   * deinitions as:
54   *   - ZC1: Empty         | BLK_ZONE_EMPTY
55   *   - ZC2: Implicit Open | BLK_ZONE_COND_IMP_OPEN
56   *   - ZC3: Explicit Open | BLK_ZONE_COND_EXP_OPEN
57   *   - ZC4: Closed        | BLK_ZONE_CLOSED
58   *   - ZC5: Full          | BLK_ZONE_FULL
59   *   - ZC6: Read Only     | BLK_ZONE_READONLY
60   *   - ZC7: Offline       | BLK_ZONE_OFFLINE
61   *
62   * Conditions 0x5 to 0xC are reserved by the current ZBC/ZAC spec and should
63   * be considered invalid.
64   */
65  enum blk_zone_cond {
66  	BLK_ZONE_COND_NOT_WP	= 0x0,
67  	BLK_ZONE_COND_EMPTY	= 0x1,
68  	BLK_ZONE_COND_IMP_OPEN	= 0x2,
69  	BLK_ZONE_COND_EXP_OPEN	= 0x3,
70  	BLK_ZONE_COND_CLOSED	= 0x4,
71  	BLK_ZONE_COND_READONLY	= 0xD,
72  	BLK_ZONE_COND_FULL	= 0xE,
73  	BLK_ZONE_COND_OFFLINE	= 0xF,
74  };
75  
76  /**
77   * struct blk_zone - Zone descriptor for BLKREPORTZONE ioctl.
78   *
79   * @start: Zone start in 512 B sector units
80   * @len: Zone length in 512 B sector units
81   * @wp: Zone write pointer location in 512 B sector units
82   * @type: see enum blk_zone_type for possible values
83   * @cond: see enum blk_zone_cond for possible values
84   * @non_seq: Flag indicating that the zone is using non-sequential resources
85   *           (for host-aware zoned block devices only).
86   * @reset: Flag indicating that a zone reset is recommended.
87   * @reserved: Padding to 64 B to match the ZBC/ZAC defined zone descriptor size.
88   *
89   * start, len and wp use the regular 512 B sector unit, regardless of the
90   * device logical block size. The overall structure size is 64 B to match the
91   * ZBC/ZAC defined zone descriptor and allow support for future additional
92   * zone information.
93   */
94  struct blk_zone {
95  	__u64	start;		/* Zone start sector */
96  	__u64	len;		/* Zone length in number of sectors */
97  	__u64	wp;		/* Zone write pointer position */
98  	__u8	type;		/* Zone type */
99  	__u8	cond;		/* Zone condition */
100  	__u8	non_seq;	/* Non-sequential write resources active */
101  	__u8	reset;		/* Reset write pointer recommended */
102  	__u8	reserved[36];
103  };
104  
105  /**
106   * struct blk_zone_report - BLKREPORTZONE ioctl request/reply
107   *
108   * @sector: starting sector of report
109   * @nr_zones: IN maximum / OUT actual
110   * @reserved: padding to 16 byte alignment
111   * @zones: Space to hold @nr_zones @zones entries on reply.
112   *
113   * The array of at most @nr_zones must follow this structure in memory.
114   */
115  struct blk_zone_report {
116  	__u64		sector;
117  	__u32		nr_zones;
118  	__u8		reserved[4];
119  	struct blk_zone zones[0];
120  };
121  
122  /**
123   * struct blk_zone_range - BLKRESETZONE ioctl request
124   * @sector: starting sector of the first zone to issue reset write pointer
125   * @nr_sectors: Total number of sectors of 1 or more zones to reset
126   */
127  struct blk_zone_range {
128  	__u64		sector;
129  	__u64		nr_sectors;
130  };
131  
132  /**
133   * Zoned block device ioctl's:
134   *
135   * @BLKREPORTZONE: Get zone information. Takes a zone report as argument.
136   *                 The zone report will start from the zone containing the
137   *                 sector specified in the report request structure.
138   * @BLKRESETZONE: Reset the write pointer of the zones in the specified
139   *                sector range. The sector range must be zone aligned.
140   * @BLKGETZONESZ: Get the device zone size in number of 512 B sectors.
141   * @BLKGETNRZONES: Get the total number of zones of the device.
142   */
143  #define BLKREPORTZONE	_IOWR(0x12, 130, struct blk_zone_report)
144  #define BLKRESETZONE	_IOW(0x12, 131, struct blk_zone_range)
145  #define BLKGETZONESZ	_IOR(0x12, 132, __u32)
146  #define BLKGETNRZONES	_IOR(0x12, 133, __u32)
147  
148  #endif /* _UAPI_BLKZONED_H */
149