cio.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. /*
  2. * include/asm-s390/cio.h
  3. * include/asm-s390x/cio.h
  4. *
  5. * Common interface for I/O on S/390
  6. */
  7. #ifndef _ASM_S390_CIO_H_
  8. #define _ASM_S390_CIO_H_
  9. #include <linux/spinlock.h>
  10. #include <asm/types.h>
  11. #ifdef __KERNEL__
  12. #define LPM_ANYPATH 0xff
  13. #define __MAX_CSSID 0
  14. /**
  15. * struct cmd_scsw - command-mode subchannel status word
  16. * @key: subchannel key
  17. * @sctl: suspend control
  18. * @eswf: esw format
  19. * @cc: deferred condition code
  20. * @fmt: format
  21. * @pfch: prefetch
  22. * @isic: initial-status interruption control
  23. * @alcc: address-limit checking control
  24. * @ssi: suppress-suspended interruption
  25. * @zcc: zero condition code
  26. * @ectl: extended control
  27. * @pno: path not operational
  28. * @res: reserved
  29. * @fctl: function control
  30. * @actl: activity control
  31. * @stctl: status control
  32. * @cpa: channel program address
  33. * @dstat: device status
  34. * @cstat: subchannel status
  35. * @count: residual count
  36. */
  37. struct cmd_scsw {
  38. __u32 key : 4;
  39. __u32 sctl : 1;
  40. __u32 eswf : 1;
  41. __u32 cc : 2;
  42. __u32 fmt : 1;
  43. __u32 pfch : 1;
  44. __u32 isic : 1;
  45. __u32 alcc : 1;
  46. __u32 ssi : 1;
  47. __u32 zcc : 1;
  48. __u32 ectl : 1;
  49. __u32 pno : 1;
  50. __u32 res : 1;
  51. __u32 fctl : 3;
  52. __u32 actl : 7;
  53. __u32 stctl : 5;
  54. __u32 cpa;
  55. __u32 dstat : 8;
  56. __u32 cstat : 8;
  57. __u32 count : 16;
  58. } __attribute__ ((packed));
  59. /**
  60. * struct tm_scsw - transport-mode subchannel status word
  61. * @key: subchannel key
  62. * @eswf: esw format
  63. * @cc: deferred condition code
  64. * @fmt: format
  65. * @x: IRB-format control
  66. * @q: interrogate-complete
  67. * @ectl: extended control
  68. * @pno: path not operational
  69. * @fctl: function control
  70. * @actl: activity control
  71. * @stctl: status control
  72. * @tcw: TCW address
  73. * @dstat: device status
  74. * @cstat: subchannel status
  75. * @fcxs: FCX status
  76. * @schxs: subchannel-extended status
  77. */
  78. struct tm_scsw {
  79. u32 key:4;
  80. u32 :1;
  81. u32 eswf:1;
  82. u32 cc:2;
  83. u32 fmt:3;
  84. u32 x:1;
  85. u32 q:1;
  86. u32 :1;
  87. u32 ectl:1;
  88. u32 pno:1;
  89. u32 :1;
  90. u32 fctl:3;
  91. u32 actl:7;
  92. u32 stctl:5;
  93. u32 tcw;
  94. u32 dstat:8;
  95. u32 cstat:8;
  96. u32 fcxs:8;
  97. u32 schxs:8;
  98. } __attribute__ ((packed));
  99. /**
  100. * union scsw - subchannel status word
  101. * @cmd: command-mode SCSW
  102. * @tm: transport-mode SCSW
  103. */
  104. union scsw {
  105. struct cmd_scsw cmd;
  106. struct tm_scsw tm;
  107. } __attribute__ ((packed));
  108. int scsw_is_tm(union scsw *scsw);
  109. u32 scsw_key(union scsw *scsw);
  110. u32 scsw_eswf(union scsw *scsw);
  111. u32 scsw_cc(union scsw *scsw);
  112. u32 scsw_ectl(union scsw *scsw);
  113. u32 scsw_pno(union scsw *scsw);
  114. u32 scsw_fctl(union scsw *scsw);
  115. u32 scsw_actl(union scsw *scsw);
  116. u32 scsw_stctl(union scsw *scsw);
  117. u32 scsw_dstat(union scsw *scsw);
  118. u32 scsw_cstat(union scsw *scsw);
  119. int scsw_is_solicited(union scsw *scsw);
  120. int scsw_is_valid_key(union scsw *scsw);
  121. int scsw_is_valid_eswf(union scsw *scsw);
  122. int scsw_is_valid_cc(union scsw *scsw);
  123. int scsw_is_valid_ectl(union scsw *scsw);
  124. int scsw_is_valid_pno(union scsw *scsw);
  125. int scsw_is_valid_fctl(union scsw *scsw);
  126. int scsw_is_valid_actl(union scsw *scsw);
  127. int scsw_is_valid_stctl(union scsw *scsw);
  128. int scsw_is_valid_dstat(union scsw *scsw);
  129. int scsw_is_valid_cstat(union scsw *scsw);
  130. int scsw_cmd_is_valid_key(union scsw *scsw);
  131. int scsw_cmd_is_valid_sctl(union scsw *scsw);
  132. int scsw_cmd_is_valid_eswf(union scsw *scsw);
  133. int scsw_cmd_is_valid_cc(union scsw *scsw);
  134. int scsw_cmd_is_valid_fmt(union scsw *scsw);
  135. int scsw_cmd_is_valid_pfch(union scsw *scsw);
  136. int scsw_cmd_is_valid_isic(union scsw *scsw);
  137. int scsw_cmd_is_valid_alcc(union scsw *scsw);
  138. int scsw_cmd_is_valid_ssi(union scsw *scsw);
  139. int scsw_cmd_is_valid_zcc(union scsw *scsw);
  140. int scsw_cmd_is_valid_ectl(union scsw *scsw);
  141. int scsw_cmd_is_valid_pno(union scsw *scsw);
  142. int scsw_cmd_is_valid_fctl(union scsw *scsw);
  143. int scsw_cmd_is_valid_actl(union scsw *scsw);
  144. int scsw_cmd_is_valid_stctl(union scsw *scsw);
  145. int scsw_cmd_is_valid_dstat(union scsw *scsw);
  146. int scsw_cmd_is_valid_cstat(union scsw *scsw);
  147. int scsw_cmd_is_solicited(union scsw *scsw);
  148. int scsw_tm_is_valid_key(union scsw *scsw);
  149. int scsw_tm_is_valid_eswf(union scsw *scsw);
  150. int scsw_tm_is_valid_cc(union scsw *scsw);
  151. int scsw_tm_is_valid_fmt(union scsw *scsw);
  152. int scsw_tm_is_valid_x(union scsw *scsw);
  153. int scsw_tm_is_valid_q(union scsw *scsw);
  154. int scsw_tm_is_valid_ectl(union scsw *scsw);
  155. int scsw_tm_is_valid_pno(union scsw *scsw);
  156. int scsw_tm_is_valid_fctl(union scsw *scsw);
  157. int scsw_tm_is_valid_actl(union scsw *scsw);
  158. int scsw_tm_is_valid_stctl(union scsw *scsw);
  159. int scsw_tm_is_valid_dstat(union scsw *scsw);
  160. int scsw_tm_is_valid_cstat(union scsw *scsw);
  161. int scsw_tm_is_valid_fcxs(union scsw *scsw);
  162. int scsw_tm_is_valid_schxs(union scsw *scsw);
  163. int scsw_tm_is_solicited(union scsw *scsw);
  164. #define SCSW_FCTL_CLEAR_FUNC 0x1
  165. #define SCSW_FCTL_HALT_FUNC 0x2
  166. #define SCSW_FCTL_START_FUNC 0x4
  167. #define SCSW_ACTL_SUSPENDED 0x1
  168. #define SCSW_ACTL_DEVACT 0x2
  169. #define SCSW_ACTL_SCHACT 0x4
  170. #define SCSW_ACTL_CLEAR_PEND 0x8
  171. #define SCSW_ACTL_HALT_PEND 0x10
  172. #define SCSW_ACTL_START_PEND 0x20
  173. #define SCSW_ACTL_RESUME_PEND 0x40
  174. #define SCSW_STCTL_STATUS_PEND 0x1
  175. #define SCSW_STCTL_SEC_STATUS 0x2
  176. #define SCSW_STCTL_PRIM_STATUS 0x4
  177. #define SCSW_STCTL_INTER_STATUS 0x8
  178. #define SCSW_STCTL_ALERT_STATUS 0x10
  179. #define DEV_STAT_ATTENTION 0x80
  180. #define DEV_STAT_STAT_MOD 0x40
  181. #define DEV_STAT_CU_END 0x20
  182. #define DEV_STAT_BUSY 0x10
  183. #define DEV_STAT_CHN_END 0x08
  184. #define DEV_STAT_DEV_END 0x04
  185. #define DEV_STAT_UNIT_CHECK 0x02
  186. #define DEV_STAT_UNIT_EXCEP 0x01
  187. #define SCHN_STAT_PCI 0x80
  188. #define SCHN_STAT_INCORR_LEN 0x40
  189. #define SCHN_STAT_PROG_CHECK 0x20
  190. #define SCHN_STAT_PROT_CHECK 0x10
  191. #define SCHN_STAT_CHN_DATA_CHK 0x08
  192. #define SCHN_STAT_CHN_CTRL_CHK 0x04
  193. #define SCHN_STAT_INTF_CTRL_CHK 0x02
  194. #define SCHN_STAT_CHAIN_CHECK 0x01
  195. /*
  196. * architectured values for first sense byte
  197. */
  198. #define SNS0_CMD_REJECT 0x80
  199. #define SNS_CMD_REJECT SNS0_CMD_REJEC
  200. #define SNS0_INTERVENTION_REQ 0x40
  201. #define SNS0_BUS_OUT_CHECK 0x20
  202. #define SNS0_EQUIPMENT_CHECK 0x10
  203. #define SNS0_DATA_CHECK 0x08
  204. #define SNS0_OVERRUN 0x04
  205. #define SNS0_INCOMPL_DOMAIN 0x01
  206. /*
  207. * architectured values for second sense byte
  208. */
  209. #define SNS1_PERM_ERR 0x80
  210. #define SNS1_INV_TRACK_FORMAT 0x40
  211. #define SNS1_EOC 0x20
  212. #define SNS1_MESSAGE_TO_OPER 0x10
  213. #define SNS1_NO_REC_FOUND 0x08
  214. #define SNS1_FILE_PROTECTED 0x04
  215. #define SNS1_WRITE_INHIBITED 0x02
  216. #define SNS1_INPRECISE_END 0x01
  217. /*
  218. * architectured values for third sense byte
  219. */
  220. #define SNS2_REQ_INH_WRITE 0x80
  221. #define SNS2_CORRECTABLE 0x40
  222. #define SNS2_FIRST_LOG_ERR 0x20
  223. #define SNS2_ENV_DATA_PRESENT 0x10
  224. #define SNS2_INPRECISE_END 0x04
  225. /**
  226. * struct ccw1 - channel command word
  227. * @cmd_code: command code
  228. * @flags: flags, like IDA adressing, etc.
  229. * @count: byte count
  230. * @cda: data address
  231. *
  232. * The ccw is the basic structure to build channel programs that perform
  233. * operations with the device or the control unit. Only Format-1 channel
  234. * command words are supported.
  235. */
  236. struct ccw1 {
  237. __u8 cmd_code;
  238. __u8 flags;
  239. __u16 count;
  240. __u32 cda;
  241. } __attribute__ ((packed,aligned(8)));
  242. #define CCW_FLAG_DC 0x80
  243. #define CCW_FLAG_CC 0x40
  244. #define CCW_FLAG_SLI 0x20
  245. #define CCW_FLAG_SKIP 0x10
  246. #define CCW_FLAG_PCI 0x08
  247. #define CCW_FLAG_IDA 0x04
  248. #define CCW_FLAG_SUSPEND 0x02
  249. #define CCW_CMD_READ_IPL 0x02
  250. #define CCW_CMD_NOOP 0x03
  251. #define CCW_CMD_BASIC_SENSE 0x04
  252. #define CCW_CMD_TIC 0x08
  253. #define CCW_CMD_STLCK 0x14
  254. #define CCW_CMD_SENSE_PGID 0x34
  255. #define CCW_CMD_SUSPEND_RECONN 0x5B
  256. #define CCW_CMD_RDC 0x64
  257. #define CCW_CMD_RELEASE 0x94
  258. #define CCW_CMD_SET_PGID 0xAF
  259. #define CCW_CMD_SENSE_ID 0xE4
  260. #define CCW_CMD_DCTL 0xF3
  261. #define SENSE_MAX_COUNT 0x20
  262. /**
  263. * struct erw - extended report word
  264. * @res0: reserved
  265. * @auth: authorization check
  266. * @pvrf: path-verification-required flag
  267. * @cpt: channel-path timeout
  268. * @fsavf: failing storage address validity flag
  269. * @cons: concurrent sense
  270. * @scavf: secondary ccw address validity flag
  271. * @fsaf: failing storage address format
  272. * @scnt: sense count, if @cons == %1
  273. * @res16: reserved
  274. */
  275. struct erw {
  276. __u32 res0 : 3;
  277. __u32 auth : 1;
  278. __u32 pvrf : 1;
  279. __u32 cpt : 1;
  280. __u32 fsavf : 1;
  281. __u32 cons : 1;
  282. __u32 scavf : 1;
  283. __u32 fsaf : 1;
  284. __u32 scnt : 6;
  285. __u32 res16 : 16;
  286. } __attribute__ ((packed));
  287. /**
  288. * struct sublog - subchannel logout area
  289. * @res0: reserved
  290. * @esf: extended status flags
  291. * @lpum: last path used mask
  292. * @arep: ancillary report
  293. * @fvf: field-validity flags
  294. * @sacc: storage access code
  295. * @termc: termination code
  296. * @devsc: device-status check
  297. * @serr: secondary error
  298. * @ioerr: i/o-error alert
  299. * @seqc: sequence code
  300. */
  301. struct sublog {
  302. __u32 res0 : 1;
  303. __u32 esf : 7;
  304. __u32 lpum : 8;
  305. __u32 arep : 1;
  306. __u32 fvf : 5;
  307. __u32 sacc : 2;
  308. __u32 termc : 2;
  309. __u32 devsc : 1;
  310. __u32 serr : 1;
  311. __u32 ioerr : 1;
  312. __u32 seqc : 3;
  313. } __attribute__ ((packed));
  314. /**
  315. * struct esw0 - Format 0 Extended Status Word (ESW)
  316. * @sublog: subchannel logout
  317. * @erw: extended report word
  318. * @faddr: failing storage address
  319. * @saddr: secondary ccw address
  320. */
  321. struct esw0 {
  322. struct sublog sublog;
  323. struct erw erw;
  324. __u32 faddr[2];
  325. __u32 saddr;
  326. } __attribute__ ((packed));
  327. /**
  328. * struct esw1 - Format 1 Extended Status Word (ESW)
  329. * @zero0: reserved zeros
  330. * @lpum: last path used mask
  331. * @zero16: reserved zeros
  332. * @erw: extended report word
  333. * @zeros: three fullwords of zeros
  334. */
  335. struct esw1 {
  336. __u8 zero0;
  337. __u8 lpum;
  338. __u16 zero16;
  339. struct erw erw;
  340. __u32 zeros[3];
  341. } __attribute__ ((packed));
  342. /**
  343. * struct esw2 - Format 2 Extended Status Word (ESW)
  344. * @zero0: reserved zeros
  345. * @lpum: last path used mask
  346. * @dcti: device-connect-time interval
  347. * @erw: extended report word
  348. * @zeros: three fullwords of zeros
  349. */
  350. struct esw2 {
  351. __u8 zero0;
  352. __u8 lpum;
  353. __u16 dcti;
  354. struct erw erw;
  355. __u32 zeros[3];
  356. } __attribute__ ((packed));
  357. /**
  358. * struct esw3 - Format 3 Extended Status Word (ESW)
  359. * @zero0: reserved zeros
  360. * @lpum: last path used mask
  361. * @res: reserved
  362. * @erw: extended report word
  363. * @zeros: three fullwords of zeros
  364. */
  365. struct esw3 {
  366. __u8 zero0;
  367. __u8 lpum;
  368. __u16 res;
  369. struct erw erw;
  370. __u32 zeros[3];
  371. } __attribute__ ((packed));
  372. /**
  373. * struct irb - interruption response block
  374. * @scsw: subchannel status word
  375. * @esw: extened status word, 4 formats
  376. * @ecw: extended control word
  377. *
  378. * The irb that is handed to the device driver when an interrupt occurs. For
  379. * solicited interrupts, the common I/O layer already performs checks whether
  380. * a field is valid; a field not being valid is always passed as %0.
  381. * If a unit check occured, @ecw may contain sense data; this is retrieved
  382. * by the common I/O layer itself if the device doesn't support concurrent
  383. * sense (so that the device driver never needs to perform basic sene itself).
  384. * For unsolicited interrupts, the irb is passed as-is (expect for sense data,
  385. * if applicable).
  386. */
  387. struct irb {
  388. union scsw scsw;
  389. union {
  390. struct esw0 esw0;
  391. struct esw1 esw1;
  392. struct esw2 esw2;
  393. struct esw3 esw3;
  394. } esw;
  395. __u8 ecw[32];
  396. } __attribute__ ((packed,aligned(4)));
  397. /**
  398. * struct ciw - command information word (CIW) layout
  399. * @et: entry type
  400. * @reserved: reserved bits
  401. * @ct: command type
  402. * @cmd: command code
  403. * @count: command count
  404. */
  405. struct ciw {
  406. __u32 et : 2;
  407. __u32 reserved : 2;
  408. __u32 ct : 4;
  409. __u32 cmd : 8;
  410. __u32 count : 16;
  411. } __attribute__ ((packed));
  412. #define CIW_TYPE_RCD 0x0 /* read configuration data */
  413. #define CIW_TYPE_SII 0x1 /* set interface identifier */
  414. #define CIW_TYPE_RNI 0x2 /* read node identifier */
  415. /*
  416. * Flags used as input parameters for do_IO()
  417. */
  418. #define DOIO_ALLOW_SUSPEND 0x0001 /* allow for channel prog. suspend */
  419. #define DOIO_DENY_PREFETCH 0x0002 /* don't allow for CCW prefetch */
  420. #define DOIO_SUPPRESS_INTER 0x0004 /* suppress intermediate inter. */
  421. /* ... for suspended CCWs */
  422. /* Device or subchannel gone. */
  423. #define CIO_GONE 0x0001
  424. /* No path to device. */
  425. #define CIO_NO_PATH 0x0002
  426. /* Device has appeared. */
  427. #define CIO_OPER 0x0004
  428. /* Sick revalidation of device. */
  429. #define CIO_REVALIDATE 0x0008
  430. /* Device did not respond in time. */
  431. #define CIO_BOXED 0x0010
  432. /**
  433. * struct ccw_dev_id - unique identifier for ccw devices
  434. * @ssid: subchannel set id
  435. * @devno: device number
  436. *
  437. * This structure is not directly based on any hardware structure. The
  438. * hardware identifies a device by its device number and its subchannel,
  439. * which is in turn identified by its id. In order to get a unique identifier
  440. * for ccw devices across subchannel sets, @struct ccw_dev_id has been
  441. * introduced.
  442. */
  443. struct ccw_dev_id {
  444. u8 ssid;
  445. u16 devno;
  446. };
  447. /**
  448. * ccw_device_id_is_equal() - compare two ccw_dev_ids
  449. * @dev_id1: a ccw_dev_id
  450. * @dev_id2: another ccw_dev_id
  451. * Returns:
  452. * %1 if the two structures are equal field-by-field,
  453. * %0 if not.
  454. * Context:
  455. * any
  456. */
  457. static inline int ccw_dev_id_is_equal(struct ccw_dev_id *dev_id1,
  458. struct ccw_dev_id *dev_id2)
  459. {
  460. if ((dev_id1->ssid == dev_id2->ssid) &&
  461. (dev_id1->devno == dev_id2->devno))
  462. return 1;
  463. return 0;
  464. }
  465. extern void wait_cons_dev(void);
  466. extern void css_schedule_reprobe(void);
  467. extern void reipl_ccw_dev(struct ccw_dev_id *id);
  468. struct cio_iplinfo {
  469. u16 devno;
  470. int is_qdio;
  471. };
  472. extern int cio_get_iplinfo(struct cio_iplinfo *iplinfo);
  473. /* Function from drivers/s390/cio/chsc.c */
  474. int chsc_sstpc(void *page, unsigned int op, u16 ctrl);
  475. int chsc_sstpi(void *page, void *result, size_t size);
  476. #endif
  477. #endif