scsw.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Helper functions for scsw access.
  4. *
  5. * Copyright IBM Corp. 2008, 2012
  6. * Author(s): Peter Oberparleiter <[email protected]>
  7. */
  8. #ifndef _ASM_S390_SCSW_H_
  9. #define _ASM_S390_SCSW_H_
  10. #include <linux/types.h>
  11. #include <asm/css_chars.h>
  12. #include <asm/cio.h>
  13. /**
  14. * struct cmd_scsw - command-mode subchannel status word
  15. * @key: subchannel key
  16. * @sctl: suspend control
  17. * @eswf: esw format
  18. * @cc: deferred condition code
  19. * @fmt: format
  20. * @pfch: prefetch
  21. * @isic: initial-status interruption control
  22. * @alcc: address-limit checking control
  23. * @ssi: suppress-suspended interruption
  24. * @zcc: zero condition code
  25. * @ectl: extended control
  26. * @pno: path not operational
  27. * @res: reserved
  28. * @fctl: function control
  29. * @actl: activity control
  30. * @stctl: status control
  31. * @cpa: channel program address
  32. * @dstat: device status
  33. * @cstat: subchannel status
  34. * @count: residual count
  35. */
  36. struct cmd_scsw {
  37. __u32 key : 4;
  38. __u32 sctl : 1;
  39. __u32 eswf : 1;
  40. __u32 cc : 2;
  41. __u32 fmt : 1;
  42. __u32 pfch : 1;
  43. __u32 isic : 1;
  44. __u32 alcc : 1;
  45. __u32 ssi : 1;
  46. __u32 zcc : 1;
  47. __u32 ectl : 1;
  48. __u32 pno : 1;
  49. __u32 res : 1;
  50. __u32 fctl : 3;
  51. __u32 actl : 7;
  52. __u32 stctl : 5;
  53. __u32 cpa;
  54. __u32 dstat : 8;
  55. __u32 cstat : 8;
  56. __u32 count : 16;
  57. } __attribute__ ((packed));
  58. /**
  59. * struct tm_scsw - transport-mode subchannel status word
  60. * @key: subchannel key
  61. * @eswf: esw format
  62. * @cc: deferred condition code
  63. * @fmt: format
  64. * @x: IRB-format control
  65. * @q: interrogate-complete
  66. * @ectl: extended control
  67. * @pno: path not operational
  68. * @fctl: function control
  69. * @actl: activity control
  70. * @stctl: status control
  71. * @tcw: TCW address
  72. * @dstat: device status
  73. * @cstat: subchannel status
  74. * @fcxs: FCX status
  75. * @schxs: subchannel-extended status
  76. */
  77. struct tm_scsw {
  78. u32 key:4;
  79. u32 :1;
  80. u32 eswf:1;
  81. u32 cc:2;
  82. u32 fmt:3;
  83. u32 x:1;
  84. u32 q:1;
  85. u32 :1;
  86. u32 ectl:1;
  87. u32 pno:1;
  88. u32 :1;
  89. u32 fctl:3;
  90. u32 actl:7;
  91. u32 stctl:5;
  92. u32 tcw;
  93. u32 dstat:8;
  94. u32 cstat:8;
  95. u32 fcxs:8;
  96. u32 ifob:1;
  97. u32 sesq:7;
  98. } __attribute__ ((packed));
  99. /**
  100. * struct eadm_scsw - subchannel status word for eadm subchannels
  101. * @key: subchannel key
  102. * @eswf: esw format
  103. * @cc: deferred condition code
  104. * @ectl: extended control
  105. * @fctl: function control
  106. * @actl: activity control
  107. * @stctl: status control
  108. * @aob: AOB address
  109. * @dstat: device status
  110. * @cstat: subchannel status
  111. */
  112. struct eadm_scsw {
  113. u32 key:4;
  114. u32:1;
  115. u32 eswf:1;
  116. u32 cc:2;
  117. u32:6;
  118. u32 ectl:1;
  119. u32:2;
  120. u32 fctl:3;
  121. u32 actl:7;
  122. u32 stctl:5;
  123. u32 aob;
  124. u32 dstat:8;
  125. u32 cstat:8;
  126. u32:16;
  127. } __packed;
  128. /**
  129. * union scsw - subchannel status word
  130. * @cmd: command-mode SCSW
  131. * @tm: transport-mode SCSW
  132. * @eadm: eadm SCSW
  133. */
  134. union scsw {
  135. struct cmd_scsw cmd;
  136. struct tm_scsw tm;
  137. struct eadm_scsw eadm;
  138. } __packed;
  139. #define SCSW_FCTL_CLEAR_FUNC 0x1
  140. #define SCSW_FCTL_HALT_FUNC 0x2
  141. #define SCSW_FCTL_START_FUNC 0x4
  142. #define SCSW_ACTL_SUSPENDED 0x1
  143. #define SCSW_ACTL_DEVACT 0x2
  144. #define SCSW_ACTL_SCHACT 0x4
  145. #define SCSW_ACTL_CLEAR_PEND 0x8
  146. #define SCSW_ACTL_HALT_PEND 0x10
  147. #define SCSW_ACTL_START_PEND 0x20
  148. #define SCSW_ACTL_RESUME_PEND 0x40
  149. #define SCSW_STCTL_STATUS_PEND 0x1
  150. #define SCSW_STCTL_SEC_STATUS 0x2
  151. #define SCSW_STCTL_PRIM_STATUS 0x4
  152. #define SCSW_STCTL_INTER_STATUS 0x8
  153. #define SCSW_STCTL_ALERT_STATUS 0x10
  154. #define DEV_STAT_ATTENTION 0x80
  155. #define DEV_STAT_STAT_MOD 0x40
  156. #define DEV_STAT_CU_END 0x20
  157. #define DEV_STAT_BUSY 0x10
  158. #define DEV_STAT_CHN_END 0x08
  159. #define DEV_STAT_DEV_END 0x04
  160. #define DEV_STAT_UNIT_CHECK 0x02
  161. #define DEV_STAT_UNIT_EXCEP 0x01
  162. #define SCHN_STAT_PCI 0x80
  163. #define SCHN_STAT_INCORR_LEN 0x40
  164. #define SCHN_STAT_PROG_CHECK 0x20
  165. #define SCHN_STAT_PROT_CHECK 0x10
  166. #define SCHN_STAT_CHN_DATA_CHK 0x08
  167. #define SCHN_STAT_CHN_CTRL_CHK 0x04
  168. #define SCHN_STAT_INTF_CTRL_CHK 0x02
  169. #define SCHN_STAT_CHAIN_CHECK 0x01
  170. #define SCSW_SESQ_DEV_NOFCX 3
  171. #define SCSW_SESQ_PATH_NOFCX 4
  172. /*
  173. * architectured values for first sense byte
  174. */
  175. #define SNS0_CMD_REJECT 0x80
  176. #define SNS_CMD_REJECT SNS0_CMD_REJEC
  177. #define SNS0_INTERVENTION_REQ 0x40
  178. #define SNS0_BUS_OUT_CHECK 0x20
  179. #define SNS0_EQUIPMENT_CHECK 0x10
  180. #define SNS0_DATA_CHECK 0x08
  181. #define SNS0_OVERRUN 0x04
  182. #define SNS0_INCOMPL_DOMAIN 0x01
  183. /*
  184. * architectured values for second sense byte
  185. */
  186. #define SNS1_PERM_ERR 0x80
  187. #define SNS1_INV_TRACK_FORMAT 0x40
  188. #define SNS1_EOC 0x20
  189. #define SNS1_MESSAGE_TO_OPER 0x10
  190. #define SNS1_NO_REC_FOUND 0x08
  191. #define SNS1_FILE_PROTECTED 0x04
  192. #define SNS1_WRITE_INHIBITED 0x02
  193. #define SNS1_INPRECISE_END 0x01
  194. /*
  195. * architectured values for third sense byte
  196. */
  197. #define SNS2_REQ_INH_WRITE 0x80
  198. #define SNS2_CORRECTABLE 0x40
  199. #define SNS2_FIRST_LOG_ERR 0x20
  200. #define SNS2_ENV_DATA_PRESENT 0x10
  201. #define SNS2_INPRECISE_END 0x04
  202. /*
  203. * architectured values for PPRC errors
  204. */
  205. #define SNS7_INVALID_ON_SEC 0x0e
  206. /**
  207. * scsw_is_tm - check for transport mode scsw
  208. * @scsw: pointer to scsw
  209. *
  210. * Return non-zero if the specified scsw is a transport mode scsw, zero
  211. * otherwise.
  212. */
  213. static inline int scsw_is_tm(union scsw *scsw)
  214. {
  215. return css_general_characteristics.fcx && (scsw->tm.x == 1);
  216. }
  217. /**
  218. * scsw_key - return scsw key field
  219. * @scsw: pointer to scsw
  220. *
  221. * Return the value of the key field of the specified scsw, regardless of
  222. * whether it is a transport mode or command mode scsw.
  223. */
  224. static inline u32 scsw_key(union scsw *scsw)
  225. {
  226. if (scsw_is_tm(scsw))
  227. return scsw->tm.key;
  228. else
  229. return scsw->cmd.key;
  230. }
  231. /**
  232. * scsw_eswf - return scsw eswf field
  233. * @scsw: pointer to scsw
  234. *
  235. * Return the value of the eswf field of the specified scsw, regardless of
  236. * whether it is a transport mode or command mode scsw.
  237. */
  238. static inline u32 scsw_eswf(union scsw *scsw)
  239. {
  240. if (scsw_is_tm(scsw))
  241. return scsw->tm.eswf;
  242. else
  243. return scsw->cmd.eswf;
  244. }
  245. /**
  246. * scsw_cc - return scsw cc field
  247. * @scsw: pointer to scsw
  248. *
  249. * Return the value of the cc field of the specified scsw, regardless of
  250. * whether it is a transport mode or command mode scsw.
  251. */
  252. static inline u32 scsw_cc(union scsw *scsw)
  253. {
  254. if (scsw_is_tm(scsw))
  255. return scsw->tm.cc;
  256. else
  257. return scsw->cmd.cc;
  258. }
  259. /**
  260. * scsw_ectl - return scsw ectl field
  261. * @scsw: pointer to scsw
  262. *
  263. * Return the value of the ectl field of the specified scsw, regardless of
  264. * whether it is a transport mode or command mode scsw.
  265. */
  266. static inline u32 scsw_ectl(union scsw *scsw)
  267. {
  268. if (scsw_is_tm(scsw))
  269. return scsw->tm.ectl;
  270. else
  271. return scsw->cmd.ectl;
  272. }
  273. /**
  274. * scsw_pno - return scsw pno field
  275. * @scsw: pointer to scsw
  276. *
  277. * Return the value of the pno field of the specified scsw, regardless of
  278. * whether it is a transport mode or command mode scsw.
  279. */
  280. static inline u32 scsw_pno(union scsw *scsw)
  281. {
  282. if (scsw_is_tm(scsw))
  283. return scsw->tm.pno;
  284. else
  285. return scsw->cmd.pno;
  286. }
  287. /**
  288. * scsw_fctl - return scsw fctl field
  289. * @scsw: pointer to scsw
  290. *
  291. * Return the value of the fctl field of the specified scsw, regardless of
  292. * whether it is a transport mode or command mode scsw.
  293. */
  294. static inline u32 scsw_fctl(union scsw *scsw)
  295. {
  296. if (scsw_is_tm(scsw))
  297. return scsw->tm.fctl;
  298. else
  299. return scsw->cmd.fctl;
  300. }
  301. /**
  302. * scsw_actl - return scsw actl field
  303. * @scsw: pointer to scsw
  304. *
  305. * Return the value of the actl field of the specified scsw, regardless of
  306. * whether it is a transport mode or command mode scsw.
  307. */
  308. static inline u32 scsw_actl(union scsw *scsw)
  309. {
  310. if (scsw_is_tm(scsw))
  311. return scsw->tm.actl;
  312. else
  313. return scsw->cmd.actl;
  314. }
  315. /**
  316. * scsw_stctl - return scsw stctl field
  317. * @scsw: pointer to scsw
  318. *
  319. * Return the value of the stctl field of the specified scsw, regardless of
  320. * whether it is a transport mode or command mode scsw.
  321. */
  322. static inline u32 scsw_stctl(union scsw *scsw)
  323. {
  324. if (scsw_is_tm(scsw))
  325. return scsw->tm.stctl;
  326. else
  327. return scsw->cmd.stctl;
  328. }
  329. /**
  330. * scsw_dstat - return scsw dstat field
  331. * @scsw: pointer to scsw
  332. *
  333. * Return the value of the dstat field of the specified scsw, regardless of
  334. * whether it is a transport mode or command mode scsw.
  335. */
  336. static inline u32 scsw_dstat(union scsw *scsw)
  337. {
  338. if (scsw_is_tm(scsw))
  339. return scsw->tm.dstat;
  340. else
  341. return scsw->cmd.dstat;
  342. }
  343. /**
  344. * scsw_cstat - return scsw cstat field
  345. * @scsw: pointer to scsw
  346. *
  347. * Return the value of the cstat field of the specified scsw, regardless of
  348. * whether it is a transport mode or command mode scsw.
  349. */
  350. static inline u32 scsw_cstat(union scsw *scsw)
  351. {
  352. if (scsw_is_tm(scsw))
  353. return scsw->tm.cstat;
  354. else
  355. return scsw->cmd.cstat;
  356. }
  357. /**
  358. * scsw_cmd_is_valid_key - check key field validity
  359. * @scsw: pointer to scsw
  360. *
  361. * Return non-zero if the key field of the specified command mode scsw is
  362. * valid, zero otherwise.
  363. */
  364. static inline int scsw_cmd_is_valid_key(union scsw *scsw)
  365. {
  366. return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC);
  367. }
  368. /**
  369. * scsw_cmd_is_valid_sctl - check sctl field validity
  370. * @scsw: pointer to scsw
  371. *
  372. * Return non-zero if the sctl field of the specified command mode scsw is
  373. * valid, zero otherwise.
  374. */
  375. static inline int scsw_cmd_is_valid_sctl(union scsw *scsw)
  376. {
  377. return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC);
  378. }
  379. /**
  380. * scsw_cmd_is_valid_eswf - check eswf field validity
  381. * @scsw: pointer to scsw
  382. *
  383. * Return non-zero if the eswf field of the specified command mode scsw is
  384. * valid, zero otherwise.
  385. */
  386. static inline int scsw_cmd_is_valid_eswf(union scsw *scsw)
  387. {
  388. return (scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND);
  389. }
  390. /**
  391. * scsw_cmd_is_valid_cc - check cc field validity
  392. * @scsw: pointer to scsw
  393. *
  394. * Return non-zero if the cc field of the specified command mode scsw is
  395. * valid, zero otherwise.
  396. */
  397. static inline int scsw_cmd_is_valid_cc(union scsw *scsw)
  398. {
  399. return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC) &&
  400. (scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND);
  401. }
  402. /**
  403. * scsw_cmd_is_valid_fmt - check fmt field validity
  404. * @scsw: pointer to scsw
  405. *
  406. * Return non-zero if the fmt field of the specified command mode scsw is
  407. * valid, zero otherwise.
  408. */
  409. static inline int scsw_cmd_is_valid_fmt(union scsw *scsw)
  410. {
  411. return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC);
  412. }
  413. /**
  414. * scsw_cmd_is_valid_pfch - check pfch field validity
  415. * @scsw: pointer to scsw
  416. *
  417. * Return non-zero if the pfch field of the specified command mode scsw is
  418. * valid, zero otherwise.
  419. */
  420. static inline int scsw_cmd_is_valid_pfch(union scsw *scsw)
  421. {
  422. return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC);
  423. }
  424. /**
  425. * scsw_cmd_is_valid_isic - check isic field validity
  426. * @scsw: pointer to scsw
  427. *
  428. * Return non-zero if the isic field of the specified command mode scsw is
  429. * valid, zero otherwise.
  430. */
  431. static inline int scsw_cmd_is_valid_isic(union scsw *scsw)
  432. {
  433. return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC);
  434. }
  435. /**
  436. * scsw_cmd_is_valid_alcc - check alcc field validity
  437. * @scsw: pointer to scsw
  438. *
  439. * Return non-zero if the alcc field of the specified command mode scsw is
  440. * valid, zero otherwise.
  441. */
  442. static inline int scsw_cmd_is_valid_alcc(union scsw *scsw)
  443. {
  444. return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC);
  445. }
  446. /**
  447. * scsw_cmd_is_valid_ssi - check ssi field validity
  448. * @scsw: pointer to scsw
  449. *
  450. * Return non-zero if the ssi field of the specified command mode scsw is
  451. * valid, zero otherwise.
  452. */
  453. static inline int scsw_cmd_is_valid_ssi(union scsw *scsw)
  454. {
  455. return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC);
  456. }
  457. /**
  458. * scsw_cmd_is_valid_zcc - check zcc field validity
  459. * @scsw: pointer to scsw
  460. *
  461. * Return non-zero if the zcc field of the specified command mode scsw is
  462. * valid, zero otherwise.
  463. */
  464. static inline int scsw_cmd_is_valid_zcc(union scsw *scsw)
  465. {
  466. return (scsw->cmd.fctl & SCSW_FCTL_START_FUNC) &&
  467. (scsw->cmd.stctl & SCSW_STCTL_INTER_STATUS);
  468. }
  469. /**
  470. * scsw_cmd_is_valid_ectl - check ectl field validity
  471. * @scsw: pointer to scsw
  472. *
  473. * Return non-zero if the ectl field of the specified command mode scsw is
  474. * valid, zero otherwise.
  475. */
  476. static inline int scsw_cmd_is_valid_ectl(union scsw *scsw)
  477. {
  478. /* Must be status pending. */
  479. if (!(scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND))
  480. return 0;
  481. /* Must have alert status. */
  482. if (!(scsw->cmd.stctl & SCSW_STCTL_ALERT_STATUS))
  483. return 0;
  484. /* Must be alone or together with primary, secondary or both,
  485. * => no intermediate status.
  486. */
  487. if (scsw->cmd.stctl & SCSW_STCTL_INTER_STATUS)
  488. return 0;
  489. return 1;
  490. }
  491. /**
  492. * scsw_cmd_is_valid_pno - check pno field validity
  493. * @scsw: pointer to scsw
  494. *
  495. * Return non-zero if the pno field of the specified command mode scsw is
  496. * valid, zero otherwise.
  497. */
  498. static inline int scsw_cmd_is_valid_pno(union scsw *scsw)
  499. {
  500. /* Must indicate at least one I/O function. */
  501. if (!scsw->cmd.fctl)
  502. return 0;
  503. /* Must be status pending. */
  504. if (!(scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND))
  505. return 0;
  506. /* Can be status pending alone, or with any combination of primary,
  507. * secondary and alert => no intermediate status.
  508. */
  509. if (!(scsw->cmd.stctl & SCSW_STCTL_INTER_STATUS))
  510. return 1;
  511. /* If intermediate, must be suspended. */
  512. if (scsw->cmd.actl & SCSW_ACTL_SUSPENDED)
  513. return 1;
  514. return 0;
  515. }
  516. /**
  517. * scsw_cmd_is_valid_fctl - check fctl field validity
  518. * @scsw: pointer to scsw
  519. *
  520. * Return non-zero if the fctl field of the specified command mode scsw is
  521. * valid, zero otherwise.
  522. */
  523. static inline int scsw_cmd_is_valid_fctl(union scsw *scsw)
  524. {
  525. /* Only valid if pmcw.dnv == 1*/
  526. return 1;
  527. }
  528. /**
  529. * scsw_cmd_is_valid_actl - check actl field validity
  530. * @scsw: pointer to scsw
  531. *
  532. * Return non-zero if the actl field of the specified command mode scsw is
  533. * valid, zero otherwise.
  534. */
  535. static inline int scsw_cmd_is_valid_actl(union scsw *scsw)
  536. {
  537. /* Only valid if pmcw.dnv == 1*/
  538. return 1;
  539. }
  540. /**
  541. * scsw_cmd_is_valid_stctl - check stctl field validity
  542. * @scsw: pointer to scsw
  543. *
  544. * Return non-zero if the stctl field of the specified command mode scsw is
  545. * valid, zero otherwise.
  546. */
  547. static inline int scsw_cmd_is_valid_stctl(union scsw *scsw)
  548. {
  549. /* Only valid if pmcw.dnv == 1*/
  550. return 1;
  551. }
  552. /**
  553. * scsw_cmd_is_valid_dstat - check dstat field validity
  554. * @scsw: pointer to scsw
  555. *
  556. * Return non-zero if the dstat field of the specified command mode scsw is
  557. * valid, zero otherwise.
  558. */
  559. static inline int scsw_cmd_is_valid_dstat(union scsw *scsw)
  560. {
  561. return (scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND) &&
  562. (scsw->cmd.cc != 3);
  563. }
  564. /**
  565. * scsw_cmd_is_valid_cstat - check cstat field validity
  566. * @scsw: pointer to scsw
  567. *
  568. * Return non-zero if the cstat field of the specified command mode scsw is
  569. * valid, zero otherwise.
  570. */
  571. static inline int scsw_cmd_is_valid_cstat(union scsw *scsw)
  572. {
  573. return (scsw->cmd.stctl & SCSW_STCTL_STATUS_PEND) &&
  574. (scsw->cmd.cc != 3);
  575. }
  576. /**
  577. * scsw_tm_is_valid_key - check key field validity
  578. * @scsw: pointer to scsw
  579. *
  580. * Return non-zero if the key field of the specified transport mode scsw is
  581. * valid, zero otherwise.
  582. */
  583. static inline int scsw_tm_is_valid_key(union scsw *scsw)
  584. {
  585. return (scsw->tm.fctl & SCSW_FCTL_START_FUNC);
  586. }
  587. /**
  588. * scsw_tm_is_valid_eswf - check eswf field validity
  589. * @scsw: pointer to scsw
  590. *
  591. * Return non-zero if the eswf field of the specified transport mode scsw is
  592. * valid, zero otherwise.
  593. */
  594. static inline int scsw_tm_is_valid_eswf(union scsw *scsw)
  595. {
  596. return (scsw->tm.stctl & SCSW_STCTL_STATUS_PEND);
  597. }
  598. /**
  599. * scsw_tm_is_valid_cc - check cc field validity
  600. * @scsw: pointer to scsw
  601. *
  602. * Return non-zero if the cc field of the specified transport mode scsw is
  603. * valid, zero otherwise.
  604. */
  605. static inline int scsw_tm_is_valid_cc(union scsw *scsw)
  606. {
  607. return (scsw->tm.fctl & SCSW_FCTL_START_FUNC) &&
  608. (scsw->tm.stctl & SCSW_STCTL_STATUS_PEND);
  609. }
  610. /**
  611. * scsw_tm_is_valid_fmt - check fmt field validity
  612. * @scsw: pointer to scsw
  613. *
  614. * Return non-zero if the fmt field of the specified transport mode scsw is
  615. * valid, zero otherwise.
  616. */
  617. static inline int scsw_tm_is_valid_fmt(union scsw *scsw)
  618. {
  619. return 1;
  620. }
  621. /**
  622. * scsw_tm_is_valid_x - check x field validity
  623. * @scsw: pointer to scsw
  624. *
  625. * Return non-zero if the x field of the specified transport mode scsw is
  626. * valid, zero otherwise.
  627. */
  628. static inline int scsw_tm_is_valid_x(union scsw *scsw)
  629. {
  630. return 1;
  631. }
  632. /**
  633. * scsw_tm_is_valid_q - check q field validity
  634. * @scsw: pointer to scsw
  635. *
  636. * Return non-zero if the q field of the specified transport mode scsw is
  637. * valid, zero otherwise.
  638. */
  639. static inline int scsw_tm_is_valid_q(union scsw *scsw)
  640. {
  641. return 1;
  642. }
  643. /**
  644. * scsw_tm_is_valid_ectl - check ectl field validity
  645. * @scsw: pointer to scsw
  646. *
  647. * Return non-zero if the ectl field of the specified transport mode scsw is
  648. * valid, zero otherwise.
  649. */
  650. static inline int scsw_tm_is_valid_ectl(union scsw *scsw)
  651. {
  652. /* Must be status pending. */
  653. if (!(scsw->tm.stctl & SCSW_STCTL_STATUS_PEND))
  654. return 0;
  655. /* Must have alert status. */
  656. if (!(scsw->tm.stctl & SCSW_STCTL_ALERT_STATUS))
  657. return 0;
  658. /* Must be alone or together with primary, secondary or both,
  659. * => no intermediate status.
  660. */
  661. if (scsw->tm.stctl & SCSW_STCTL_INTER_STATUS)
  662. return 0;
  663. return 1;
  664. }
  665. /**
  666. * scsw_tm_is_valid_pno - check pno field validity
  667. * @scsw: pointer to scsw
  668. *
  669. * Return non-zero if the pno field of the specified transport mode scsw is
  670. * valid, zero otherwise.
  671. */
  672. static inline int scsw_tm_is_valid_pno(union scsw *scsw)
  673. {
  674. /* Must indicate at least one I/O function. */
  675. if (!scsw->tm.fctl)
  676. return 0;
  677. /* Must be status pending. */
  678. if (!(scsw->tm.stctl & SCSW_STCTL_STATUS_PEND))
  679. return 0;
  680. /* Can be status pending alone, or with any combination of primary,
  681. * secondary and alert => no intermediate status.
  682. */
  683. if (!(scsw->tm.stctl & SCSW_STCTL_INTER_STATUS))
  684. return 1;
  685. /* If intermediate, must be suspended. */
  686. if (scsw->tm.actl & SCSW_ACTL_SUSPENDED)
  687. return 1;
  688. return 0;
  689. }
  690. /**
  691. * scsw_tm_is_valid_fctl - check fctl field validity
  692. * @scsw: pointer to scsw
  693. *
  694. * Return non-zero if the fctl field of the specified transport mode scsw is
  695. * valid, zero otherwise.
  696. */
  697. static inline int scsw_tm_is_valid_fctl(union scsw *scsw)
  698. {
  699. /* Only valid if pmcw.dnv == 1*/
  700. return 1;
  701. }
  702. /**
  703. * scsw_tm_is_valid_actl - check actl field validity
  704. * @scsw: pointer to scsw
  705. *
  706. * Return non-zero if the actl field of the specified transport mode scsw is
  707. * valid, zero otherwise.
  708. */
  709. static inline int scsw_tm_is_valid_actl(union scsw *scsw)
  710. {
  711. /* Only valid if pmcw.dnv == 1*/
  712. return 1;
  713. }
  714. /**
  715. * scsw_tm_is_valid_stctl - check stctl field validity
  716. * @scsw: pointer to scsw
  717. *
  718. * Return non-zero if the stctl field of the specified transport mode scsw is
  719. * valid, zero otherwise.
  720. */
  721. static inline int scsw_tm_is_valid_stctl(union scsw *scsw)
  722. {
  723. /* Only valid if pmcw.dnv == 1*/
  724. return 1;
  725. }
  726. /**
  727. * scsw_tm_is_valid_dstat - check dstat field validity
  728. * @scsw: pointer to scsw
  729. *
  730. * Return non-zero if the dstat field of the specified transport mode scsw is
  731. * valid, zero otherwise.
  732. */
  733. static inline int scsw_tm_is_valid_dstat(union scsw *scsw)
  734. {
  735. return (scsw->tm.stctl & SCSW_STCTL_STATUS_PEND) &&
  736. (scsw->tm.cc != 3);
  737. }
  738. /**
  739. * scsw_tm_is_valid_cstat - check cstat field validity
  740. * @scsw: pointer to scsw
  741. *
  742. * Return non-zero if the cstat field of the specified transport mode scsw is
  743. * valid, zero otherwise.
  744. */
  745. static inline int scsw_tm_is_valid_cstat(union scsw *scsw)
  746. {
  747. return (scsw->tm.stctl & SCSW_STCTL_STATUS_PEND) &&
  748. (scsw->tm.cc != 3);
  749. }
  750. /**
  751. * scsw_tm_is_valid_fcxs - check fcxs field validity
  752. * @scsw: pointer to scsw
  753. *
  754. * Return non-zero if the fcxs field of the specified transport mode scsw is
  755. * valid, zero otherwise.
  756. */
  757. static inline int scsw_tm_is_valid_fcxs(union scsw *scsw)
  758. {
  759. return 1;
  760. }
  761. /**
  762. * scsw_tm_is_valid_schxs - check schxs field validity
  763. * @scsw: pointer to scsw
  764. *
  765. * Return non-zero if the schxs field of the specified transport mode scsw is
  766. * valid, zero otherwise.
  767. */
  768. static inline int scsw_tm_is_valid_schxs(union scsw *scsw)
  769. {
  770. return (scsw->tm.cstat & (SCHN_STAT_PROG_CHECK |
  771. SCHN_STAT_INTF_CTRL_CHK |
  772. SCHN_STAT_PROT_CHECK |
  773. SCHN_STAT_CHN_DATA_CHK));
  774. }
  775. /**
  776. * scsw_is_valid_actl - check actl field validity
  777. * @scsw: pointer to scsw
  778. *
  779. * Return non-zero if the actl field of the specified scsw is valid,
  780. * regardless of whether it is a transport mode or command mode scsw.
  781. * Return zero if the field does not contain a valid value.
  782. */
  783. static inline int scsw_is_valid_actl(union scsw *scsw)
  784. {
  785. if (scsw_is_tm(scsw))
  786. return scsw_tm_is_valid_actl(scsw);
  787. else
  788. return scsw_cmd_is_valid_actl(scsw);
  789. }
  790. /**
  791. * scsw_is_valid_cc - check cc field validity
  792. * @scsw: pointer to scsw
  793. *
  794. * Return non-zero if the cc field of the specified scsw is valid,
  795. * regardless of whether it is a transport mode or command mode scsw.
  796. * Return zero if the field does not contain a valid value.
  797. */
  798. static inline int scsw_is_valid_cc(union scsw *scsw)
  799. {
  800. if (scsw_is_tm(scsw))
  801. return scsw_tm_is_valid_cc(scsw);
  802. else
  803. return scsw_cmd_is_valid_cc(scsw);
  804. }
  805. /**
  806. * scsw_is_valid_cstat - check cstat field validity
  807. * @scsw: pointer to scsw
  808. *
  809. * Return non-zero if the cstat field of the specified scsw is valid,
  810. * regardless of whether it is a transport mode or command mode scsw.
  811. * Return zero if the field does not contain a valid value.
  812. */
  813. static inline int scsw_is_valid_cstat(union scsw *scsw)
  814. {
  815. if (scsw_is_tm(scsw))
  816. return scsw_tm_is_valid_cstat(scsw);
  817. else
  818. return scsw_cmd_is_valid_cstat(scsw);
  819. }
  820. /**
  821. * scsw_is_valid_dstat - check dstat field validity
  822. * @scsw: pointer to scsw
  823. *
  824. * Return non-zero if the dstat field of the specified scsw is valid,
  825. * regardless of whether it is a transport mode or command mode scsw.
  826. * Return zero if the field does not contain a valid value.
  827. */
  828. static inline int scsw_is_valid_dstat(union scsw *scsw)
  829. {
  830. if (scsw_is_tm(scsw))
  831. return scsw_tm_is_valid_dstat(scsw);
  832. else
  833. return scsw_cmd_is_valid_dstat(scsw);
  834. }
  835. /**
  836. * scsw_is_valid_ectl - check ectl field validity
  837. * @scsw: pointer to scsw
  838. *
  839. * Return non-zero if the ectl field of the specified scsw is valid,
  840. * regardless of whether it is a transport mode or command mode scsw.
  841. * Return zero if the field does not contain a valid value.
  842. */
  843. static inline int scsw_is_valid_ectl(union scsw *scsw)
  844. {
  845. if (scsw_is_tm(scsw))
  846. return scsw_tm_is_valid_ectl(scsw);
  847. else
  848. return scsw_cmd_is_valid_ectl(scsw);
  849. }
  850. /**
  851. * scsw_is_valid_eswf - check eswf field validity
  852. * @scsw: pointer to scsw
  853. *
  854. * Return non-zero if the eswf field of the specified scsw is valid,
  855. * regardless of whether it is a transport mode or command mode scsw.
  856. * Return zero if the field does not contain a valid value.
  857. */
  858. static inline int scsw_is_valid_eswf(union scsw *scsw)
  859. {
  860. if (scsw_is_tm(scsw))
  861. return scsw_tm_is_valid_eswf(scsw);
  862. else
  863. return scsw_cmd_is_valid_eswf(scsw);
  864. }
  865. /**
  866. * scsw_is_valid_fctl - check fctl field validity
  867. * @scsw: pointer to scsw
  868. *
  869. * Return non-zero if the fctl field of the specified scsw is valid,
  870. * regardless of whether it is a transport mode or command mode scsw.
  871. * Return zero if the field does not contain a valid value.
  872. */
  873. static inline int scsw_is_valid_fctl(union scsw *scsw)
  874. {
  875. if (scsw_is_tm(scsw))
  876. return scsw_tm_is_valid_fctl(scsw);
  877. else
  878. return scsw_cmd_is_valid_fctl(scsw);
  879. }
  880. /**
  881. * scsw_is_valid_key - check key field validity
  882. * @scsw: pointer to scsw
  883. *
  884. * Return non-zero if the key field of the specified scsw is valid,
  885. * regardless of whether it is a transport mode or command mode scsw.
  886. * Return zero if the field does not contain a valid value.
  887. */
  888. static inline int scsw_is_valid_key(union scsw *scsw)
  889. {
  890. if (scsw_is_tm(scsw))
  891. return scsw_tm_is_valid_key(scsw);
  892. else
  893. return scsw_cmd_is_valid_key(scsw);
  894. }
  895. /**
  896. * scsw_is_valid_pno - check pno field validity
  897. * @scsw: pointer to scsw
  898. *
  899. * Return non-zero if the pno field of the specified scsw is valid,
  900. * regardless of whether it is a transport mode or command mode scsw.
  901. * Return zero if the field does not contain a valid value.
  902. */
  903. static inline int scsw_is_valid_pno(union scsw *scsw)
  904. {
  905. if (scsw_is_tm(scsw))
  906. return scsw_tm_is_valid_pno(scsw);
  907. else
  908. return scsw_cmd_is_valid_pno(scsw);
  909. }
  910. /**
  911. * scsw_is_valid_stctl - check stctl field validity
  912. * @scsw: pointer to scsw
  913. *
  914. * Return non-zero if the stctl field of the specified scsw is valid,
  915. * regardless of whether it is a transport mode or command mode scsw.
  916. * Return zero if the field does not contain a valid value.
  917. */
  918. static inline int scsw_is_valid_stctl(union scsw *scsw)
  919. {
  920. if (scsw_is_tm(scsw))
  921. return scsw_tm_is_valid_stctl(scsw);
  922. else
  923. return scsw_cmd_is_valid_stctl(scsw);
  924. }
  925. /**
  926. * scsw_cmd_is_solicited - check for solicited scsw
  927. * @scsw: pointer to scsw
  928. *
  929. * Return non-zero if the command mode scsw indicates that the associated
  930. * status condition is solicited, zero if it is unsolicited.
  931. */
  932. static inline int scsw_cmd_is_solicited(union scsw *scsw)
  933. {
  934. return (scsw->cmd.cc != 0) || (scsw->cmd.stctl !=
  935. (SCSW_STCTL_STATUS_PEND | SCSW_STCTL_ALERT_STATUS));
  936. }
  937. /**
  938. * scsw_tm_is_solicited - check for solicited scsw
  939. * @scsw: pointer to scsw
  940. *
  941. * Return non-zero if the transport mode scsw indicates that the associated
  942. * status condition is solicited, zero if it is unsolicited.
  943. */
  944. static inline int scsw_tm_is_solicited(union scsw *scsw)
  945. {
  946. return (scsw->tm.cc != 0) || (scsw->tm.stctl !=
  947. (SCSW_STCTL_STATUS_PEND | SCSW_STCTL_ALERT_STATUS));
  948. }
  949. /**
  950. * scsw_is_solicited - check for solicited scsw
  951. * @scsw: pointer to scsw
  952. *
  953. * Return non-zero if the transport or command mode scsw indicates that the
  954. * associated status condition is solicited, zero if it is unsolicited.
  955. */
  956. static inline int scsw_is_solicited(union scsw *scsw)
  957. {
  958. if (scsw_is_tm(scsw))
  959. return scsw_tm_is_solicited(scsw);
  960. else
  961. return scsw_cmd_is_solicited(scsw);
  962. }
  963. #endif /* _ASM_S390_SCSW_H_ */