16f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2607ca46eSDavid Howells /* 3607ca46eSDavid Howells * ioctl interface for the scsi media changer driver 4607ca46eSDavid Howells */ 5607ca46eSDavid Howells 6*c51c4841SMasahiro Yamada #ifndef _UAPI_LINUX_CHIO_H 7*c51c4841SMasahiro Yamada #define _UAPI_LINUX_CHIO_H 8*c51c4841SMasahiro Yamada 9607ca46eSDavid Howells /* changer element types */ 10607ca46eSDavid Howells #define CHET_MT 0 /* media transport element (robot) */ 11607ca46eSDavid Howells #define CHET_ST 1 /* storage element (media slots) */ 12607ca46eSDavid Howells #define CHET_IE 2 /* import/export element */ 13607ca46eSDavid Howells #define CHET_DT 3 /* data transfer element (tape/cdrom/whatever) */ 14607ca46eSDavid Howells #define CHET_V1 4 /* vendor specific #1 */ 15607ca46eSDavid Howells #define CHET_V2 5 /* vendor specific #2 */ 16607ca46eSDavid Howells #define CHET_V3 6 /* vendor specific #3 */ 17607ca46eSDavid Howells #define CHET_V4 7 /* vendor specific #4 */ 18607ca46eSDavid Howells 19607ca46eSDavid Howells 20607ca46eSDavid Howells /* 21607ca46eSDavid Howells * CHIOGPARAMS 22607ca46eSDavid Howells * query changer properties 23607ca46eSDavid Howells * 24607ca46eSDavid Howells * CHIOVGPARAMS 25607ca46eSDavid Howells * query vendor-specific element types 26607ca46eSDavid Howells * 27607ca46eSDavid Howells * accessing elements works by specifing type and unit of the element. 28607ca46eSDavid Howells * for example, storage elements are addressed with type = CHET_ST and 29607ca46eSDavid Howells * unit = 0 .. cp_nslots-1 30607ca46eSDavid Howells * 31607ca46eSDavid Howells */ 32607ca46eSDavid Howells struct changer_params { 33607ca46eSDavid Howells int cp_curpicker; /* current transport element */ 34607ca46eSDavid Howells int cp_npickers; /* number of transport elements (CHET_MT) */ 35607ca46eSDavid Howells int cp_nslots; /* number of storage elements (CHET_ST) */ 36607ca46eSDavid Howells int cp_nportals; /* number of import/export elements (CHET_IE) */ 37607ca46eSDavid Howells int cp_ndrives; /* number of data transfer elements (CHET_DT) */ 38607ca46eSDavid Howells }; 39607ca46eSDavid Howells struct changer_vendor_params { 40607ca46eSDavid Howells int cvp_n1; /* number of vendor specific elems (CHET_V1) */ 41607ca46eSDavid Howells char cvp_label1[16]; 42607ca46eSDavid Howells int cvp_n2; /* number of vendor specific elems (CHET_V2) */ 43607ca46eSDavid Howells char cvp_label2[16]; 44607ca46eSDavid Howells int cvp_n3; /* number of vendor specific elems (CHET_V3) */ 45607ca46eSDavid Howells char cvp_label3[16]; 46607ca46eSDavid Howells int cvp_n4; /* number of vendor specific elems (CHET_V4) */ 47607ca46eSDavid Howells char cvp_label4[16]; 48607ca46eSDavid Howells int reserved[8]; 49607ca46eSDavid Howells }; 50607ca46eSDavid Howells 51607ca46eSDavid Howells 52607ca46eSDavid Howells /* 53607ca46eSDavid Howells * CHIOMOVE 54607ca46eSDavid Howells * move a medium from one element to another 55607ca46eSDavid Howells */ 56607ca46eSDavid Howells struct changer_move { 57607ca46eSDavid Howells int cm_fromtype; /* type/unit of source element */ 58607ca46eSDavid Howells int cm_fromunit; 59607ca46eSDavid Howells int cm_totype; /* type/unit of destination element */ 60607ca46eSDavid Howells int cm_tounit; 61607ca46eSDavid Howells int cm_flags; 62607ca46eSDavid Howells }; 63607ca46eSDavid Howells #define CM_INVERT 1 /* flag: rotate media (for double-sided like MOD) */ 64607ca46eSDavid Howells 65607ca46eSDavid Howells 66607ca46eSDavid Howells /* 67607ca46eSDavid Howells * CHIOEXCHANGE 68607ca46eSDavid Howells * move one medium from element #1 to element #2, 69607ca46eSDavid Howells * and another one from element #2 to element #3. 70607ca46eSDavid Howells * element #1 and #3 are allowed to be identical. 71607ca46eSDavid Howells */ 72607ca46eSDavid Howells struct changer_exchange { 73607ca46eSDavid Howells int ce_srctype; /* type/unit of element #1 */ 74607ca46eSDavid Howells int ce_srcunit; 75607ca46eSDavid Howells int ce_fdsttype; /* type/unit of element #2 */ 76607ca46eSDavid Howells int ce_fdstunit; 77607ca46eSDavid Howells int ce_sdsttype; /* type/unit of element #3 */ 78607ca46eSDavid Howells int ce_sdstunit; 79607ca46eSDavid Howells int ce_flags; 80607ca46eSDavid Howells }; 81607ca46eSDavid Howells #define CE_INVERT1 1 82607ca46eSDavid Howells #define CE_INVERT2 2 83607ca46eSDavid Howells 84607ca46eSDavid Howells 85607ca46eSDavid Howells /* 86607ca46eSDavid Howells * CHIOPOSITION 87607ca46eSDavid Howells * move the transport element (robot arm) to a specific element. 88607ca46eSDavid Howells */ 89607ca46eSDavid Howells struct changer_position { 90607ca46eSDavid Howells int cp_type; 91607ca46eSDavid Howells int cp_unit; 92607ca46eSDavid Howells int cp_flags; 93607ca46eSDavid Howells }; 94607ca46eSDavid Howells #define CP_INVERT 1 95607ca46eSDavid Howells 96607ca46eSDavid Howells 97607ca46eSDavid Howells /* 98607ca46eSDavid Howells * CHIOGSTATUS 99607ca46eSDavid Howells * get element status for all elements of a specific type 100607ca46eSDavid Howells */ 101607ca46eSDavid Howells struct changer_element_status { 102607ca46eSDavid Howells int ces_type; 103607ca46eSDavid Howells unsigned char __user *ces_data; 104607ca46eSDavid Howells }; 105607ca46eSDavid Howells #define CESTATUS_FULL 0x01 /* full */ 106607ca46eSDavid Howells #define CESTATUS_IMPEXP 0x02 /* media was imported (inserted by sysop) */ 107607ca46eSDavid Howells #define CESTATUS_EXCEPT 0x04 /* error condition */ 108607ca46eSDavid Howells #define CESTATUS_ACCESS 0x08 /* access allowed */ 109607ca46eSDavid Howells #define CESTATUS_EXENAB 0x10 /* element can export media */ 110607ca46eSDavid Howells #define CESTATUS_INENAB 0x20 /* element can import media */ 111607ca46eSDavid Howells 112607ca46eSDavid Howells 113607ca46eSDavid Howells /* 114607ca46eSDavid Howells * CHIOGELEM 115607ca46eSDavid Howells * get more detailed status information for a single element 116607ca46eSDavid Howells */ 117607ca46eSDavid Howells struct changer_get_element { 118607ca46eSDavid Howells int cge_type; /* type/unit */ 119607ca46eSDavid Howells int cge_unit; 120607ca46eSDavid Howells int cge_status; /* status */ 121607ca46eSDavid Howells int cge_errno; /* errno */ 122607ca46eSDavid Howells int cge_srctype; /* source element of the last move/exchange */ 123607ca46eSDavid Howells int cge_srcunit; 124607ca46eSDavid Howells int cge_id; /* scsi id (for data transfer elements) */ 125607ca46eSDavid Howells int cge_lun; /* scsi lun (for data transfer elements) */ 126607ca46eSDavid Howells char cge_pvoltag[36]; /* primary volume tag */ 127607ca46eSDavid Howells char cge_avoltag[36]; /* alternate volume tag */ 128607ca46eSDavid Howells int cge_flags; 129607ca46eSDavid Howells }; 130607ca46eSDavid Howells /* flags */ 131607ca46eSDavid Howells #define CGE_ERRNO 0x01 /* errno available */ 132607ca46eSDavid Howells #define CGE_INVERT 0x02 /* media inverted */ 133607ca46eSDavid Howells #define CGE_SRC 0x04 /* media src available */ 134607ca46eSDavid Howells #define CGE_IDLUN 0x08 /* ID+LUN available */ 135607ca46eSDavid Howells #define CGE_PVOLTAG 0x10 /* primary volume tag available */ 136607ca46eSDavid Howells #define CGE_AVOLTAG 0x20 /* alternate volume tag available */ 137607ca46eSDavid Howells 138607ca46eSDavid Howells 139607ca46eSDavid Howells /* 140607ca46eSDavid Howells * CHIOSVOLTAG 141607ca46eSDavid Howells * set volume tag 142607ca46eSDavid Howells */ 143607ca46eSDavid Howells struct changer_set_voltag { 144607ca46eSDavid Howells int csv_type; /* type/unit */ 145607ca46eSDavid Howells int csv_unit; 146607ca46eSDavid Howells char csv_voltag[36]; /* volume tag */ 147607ca46eSDavid Howells int csv_flags; 148607ca46eSDavid Howells }; 149607ca46eSDavid Howells #define CSV_PVOLTAG 0x01 /* primary volume tag */ 150607ca46eSDavid Howells #define CSV_AVOLTAG 0x02 /* alternate volume tag */ 151607ca46eSDavid Howells #define CSV_CLEARTAG 0x04 /* clear volume tag */ 152607ca46eSDavid Howells 153607ca46eSDavid Howells /* ioctls */ 154607ca46eSDavid Howells #define CHIOMOVE _IOW('c', 1,struct changer_move) 155607ca46eSDavid Howells #define CHIOEXCHANGE _IOW('c', 2,struct changer_exchange) 156607ca46eSDavid Howells #define CHIOPOSITION _IOW('c', 3,struct changer_position) 157607ca46eSDavid Howells #define CHIOGPICKER _IOR('c', 4,int) /* not impl. */ 158607ca46eSDavid Howells #define CHIOSPICKER _IOW('c', 5,int) /* not impl. */ 159607ca46eSDavid Howells #define CHIOGPARAMS _IOR('c', 6,struct changer_params) 160607ca46eSDavid Howells #define CHIOGSTATUS _IOW('c', 8,struct changer_element_status) 161607ca46eSDavid Howells #define CHIOGELEM _IOW('c',16,struct changer_get_element) 162607ca46eSDavid Howells #define CHIOINITELEM _IO('c',17) 163607ca46eSDavid Howells #define CHIOSVOLTAG _IOW('c',18,struct changer_set_voltag) 164607ca46eSDavid Howells #define CHIOGVPARAMS _IOR('c',19,struct changer_vendor_params) 165607ca46eSDavid Howells 166*c51c4841SMasahiro Yamada #endif /* _UAPI_LINUX_CHIO_H */ 167