18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci md_u.h : user <=> kernel API between Linux raidtools and RAID drivers 48c2ecf20Sopenharmony_ci Copyright (C) 1998 Ingo Molnar 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci This program is free software; you can redistribute it and/or modify 78c2ecf20Sopenharmony_ci it under the terms of the GNU General Public License as published by 88c2ecf20Sopenharmony_ci the Free Software Foundation; either version 2, or (at your option) 98c2ecf20Sopenharmony_ci any later version. 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci You should have received a copy of the GNU General Public License 128c2ecf20Sopenharmony_ci (for example /usr/src/linux/COPYING); if not, write to the Free 138c2ecf20Sopenharmony_ci Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 148c2ecf20Sopenharmony_ci*/ 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#ifndef _UAPI_MD_U_H 178c2ecf20Sopenharmony_ci#define _UAPI_MD_U_H 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci/* 208c2ecf20Sopenharmony_ci * Different major versions are not compatible. 218c2ecf20Sopenharmony_ci * Different minor versions are only downward compatible. 228c2ecf20Sopenharmony_ci * Different patchlevel versions are downward and upward compatible. 238c2ecf20Sopenharmony_ci */ 248c2ecf20Sopenharmony_ci#define MD_MAJOR_VERSION 0 258c2ecf20Sopenharmony_ci#define MD_MINOR_VERSION 90 268c2ecf20Sopenharmony_ci/* 278c2ecf20Sopenharmony_ci * MD_PATCHLEVEL_VERSION indicates kernel functionality. 288c2ecf20Sopenharmony_ci * >=1 means different superblock formats are selectable using SET_ARRAY_INFO 298c2ecf20Sopenharmony_ci * and major_version/minor_version accordingly 308c2ecf20Sopenharmony_ci * >=2 means that Internal bitmaps are supported by setting MD_SB_BITMAP_PRESENT 318c2ecf20Sopenharmony_ci * in the super status byte 328c2ecf20Sopenharmony_ci * >=3 means that bitmap superblock version 4 is supported, which uses 338c2ecf20Sopenharmony_ci * little-ending representation rather than host-endian 348c2ecf20Sopenharmony_ci */ 358c2ecf20Sopenharmony_ci#define MD_PATCHLEVEL_VERSION 3 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci/* ioctls */ 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci/* status */ 408c2ecf20Sopenharmony_ci#define RAID_VERSION _IOR (MD_MAJOR, 0x10, mdu_version_t) 418c2ecf20Sopenharmony_ci#define GET_ARRAY_INFO _IOR (MD_MAJOR, 0x11, mdu_array_info_t) 428c2ecf20Sopenharmony_ci#define GET_DISK_INFO _IOR (MD_MAJOR, 0x12, mdu_disk_info_t) 438c2ecf20Sopenharmony_ci#define RAID_AUTORUN _IO (MD_MAJOR, 0x14) 448c2ecf20Sopenharmony_ci#define GET_BITMAP_FILE _IOR (MD_MAJOR, 0x15, mdu_bitmap_file_t) 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci/* configuration */ 478c2ecf20Sopenharmony_ci#define CLEAR_ARRAY _IO (MD_MAJOR, 0x20) 488c2ecf20Sopenharmony_ci#define ADD_NEW_DISK _IOW (MD_MAJOR, 0x21, mdu_disk_info_t) 498c2ecf20Sopenharmony_ci#define HOT_REMOVE_DISK _IO (MD_MAJOR, 0x22) 508c2ecf20Sopenharmony_ci#define SET_ARRAY_INFO _IOW (MD_MAJOR, 0x23, mdu_array_info_t) 518c2ecf20Sopenharmony_ci#define SET_DISK_INFO _IO (MD_MAJOR, 0x24) 528c2ecf20Sopenharmony_ci#define WRITE_RAID_INFO _IO (MD_MAJOR, 0x25) 538c2ecf20Sopenharmony_ci#define UNPROTECT_ARRAY _IO (MD_MAJOR, 0x26) 548c2ecf20Sopenharmony_ci#define PROTECT_ARRAY _IO (MD_MAJOR, 0x27) 558c2ecf20Sopenharmony_ci#define HOT_ADD_DISK _IO (MD_MAJOR, 0x28) 568c2ecf20Sopenharmony_ci#define SET_DISK_FAULTY _IO (MD_MAJOR, 0x29) 578c2ecf20Sopenharmony_ci#define HOT_GENERATE_ERROR _IO (MD_MAJOR, 0x2a) 588c2ecf20Sopenharmony_ci#define SET_BITMAP_FILE _IOW (MD_MAJOR, 0x2b, int) 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci/* usage */ 618c2ecf20Sopenharmony_ci#define RUN_ARRAY _IOW (MD_MAJOR, 0x30, mdu_param_t) 628c2ecf20Sopenharmony_ci/* 0x31 was START_ARRAY */ 638c2ecf20Sopenharmony_ci#define STOP_ARRAY _IO (MD_MAJOR, 0x32) 648c2ecf20Sopenharmony_ci#define STOP_ARRAY_RO _IO (MD_MAJOR, 0x33) 658c2ecf20Sopenharmony_ci#define RESTART_ARRAY_RW _IO (MD_MAJOR, 0x34) 668c2ecf20Sopenharmony_ci#define CLUSTERED_DISK_NACK _IO (MD_MAJOR, 0x35) 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci/* 63 partitions with the alternate major number (mdp) */ 698c2ecf20Sopenharmony_ci#define MdpMinorShift 6 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_citypedef struct mdu_version_s { 728c2ecf20Sopenharmony_ci int major; 738c2ecf20Sopenharmony_ci int minor; 748c2ecf20Sopenharmony_ci int patchlevel; 758c2ecf20Sopenharmony_ci} mdu_version_t; 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_citypedef struct mdu_array_info_s { 788c2ecf20Sopenharmony_ci /* 798c2ecf20Sopenharmony_ci * Generic constant information 808c2ecf20Sopenharmony_ci */ 818c2ecf20Sopenharmony_ci int major_version; 828c2ecf20Sopenharmony_ci int minor_version; 838c2ecf20Sopenharmony_ci int patch_version; 848c2ecf20Sopenharmony_ci unsigned int ctime; 858c2ecf20Sopenharmony_ci int level; 868c2ecf20Sopenharmony_ci int size; 878c2ecf20Sopenharmony_ci int nr_disks; 888c2ecf20Sopenharmony_ci int raid_disks; 898c2ecf20Sopenharmony_ci int md_minor; 908c2ecf20Sopenharmony_ci int not_persistent; 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci /* 938c2ecf20Sopenharmony_ci * Generic state information 948c2ecf20Sopenharmony_ci */ 958c2ecf20Sopenharmony_ci unsigned int utime; /* 0 Superblock update time */ 968c2ecf20Sopenharmony_ci int state; /* 1 State bits (clean, ...) */ 978c2ecf20Sopenharmony_ci int active_disks; /* 2 Number of currently active disks */ 988c2ecf20Sopenharmony_ci int working_disks; /* 3 Number of working disks */ 998c2ecf20Sopenharmony_ci int failed_disks; /* 4 Number of failed disks */ 1008c2ecf20Sopenharmony_ci int spare_disks; /* 5 Number of spare disks */ 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci /* 1038c2ecf20Sopenharmony_ci * Personality information 1048c2ecf20Sopenharmony_ci */ 1058c2ecf20Sopenharmony_ci int layout; /* 0 the array's physical layout */ 1068c2ecf20Sopenharmony_ci int chunk_size; /* 1 chunk size in bytes */ 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_ci} mdu_array_info_t; 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ci/* non-obvious values for 'level' */ 1118c2ecf20Sopenharmony_ci#define LEVEL_MULTIPATH (-4) 1128c2ecf20Sopenharmony_ci#define LEVEL_LINEAR (-1) 1138c2ecf20Sopenharmony_ci#define LEVEL_FAULTY (-5) 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ci/* we need a value for 'no level specified' and 0 1168c2ecf20Sopenharmony_ci * means 'raid0', so we need something else. This is 1178c2ecf20Sopenharmony_ci * for internal use only 1188c2ecf20Sopenharmony_ci */ 1198c2ecf20Sopenharmony_ci#define LEVEL_NONE (-1000000) 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_citypedef struct mdu_disk_info_s { 1228c2ecf20Sopenharmony_ci /* 1238c2ecf20Sopenharmony_ci * configuration/status of one particular disk 1248c2ecf20Sopenharmony_ci */ 1258c2ecf20Sopenharmony_ci int number; 1268c2ecf20Sopenharmony_ci int major; 1278c2ecf20Sopenharmony_ci int minor; 1288c2ecf20Sopenharmony_ci int raid_disk; 1298c2ecf20Sopenharmony_ci int state; 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ci} mdu_disk_info_t; 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_citypedef struct mdu_start_info_s { 1348c2ecf20Sopenharmony_ci /* 1358c2ecf20Sopenharmony_ci * configuration/status of one particular disk 1368c2ecf20Sopenharmony_ci */ 1378c2ecf20Sopenharmony_ci int major; 1388c2ecf20Sopenharmony_ci int minor; 1398c2ecf20Sopenharmony_ci int raid_disk; 1408c2ecf20Sopenharmony_ci int state; 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_ci} mdu_start_info_t; 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_citypedef struct mdu_bitmap_file_s 1458c2ecf20Sopenharmony_ci{ 1468c2ecf20Sopenharmony_ci char pathname[4096]; 1478c2ecf20Sopenharmony_ci} mdu_bitmap_file_t; 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_citypedef struct mdu_param_s 1508c2ecf20Sopenharmony_ci{ 1518c2ecf20Sopenharmony_ci int personality; /* 1,2,3,4 */ 1528c2ecf20Sopenharmony_ci int chunk_size; /* in bytes */ 1538c2ecf20Sopenharmony_ci int max_fault; /* unused for now */ 1548c2ecf20Sopenharmony_ci} mdu_param_t; 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_ci#endif /* _UAPI_MD_U_H */ 157